send bookmarks to client
This commit is contained in:
		
							
								
								
									
										21
									
								
								bookmarks.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								bookmarks.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| [{ | ||||
|   "name": "DB0ZU", | ||||
|   "frequency": 145725000, | ||||
|   "modulation": "nfm" | ||||
| },{ | ||||
|   "name": "DB0ZM", | ||||
|   "frequency": 145750000, | ||||
|   "modulation": "nfm" | ||||
| },{ | ||||
|   "name": "DB0EL", | ||||
|   "frequency": 439275000, | ||||
|   "modulation": "nfm" | ||||
| },{ | ||||
|   "name": "DB0NJ", | ||||
|   "frequency": 438775000, | ||||
|   "modulation": "nfm" | ||||
| },{ | ||||
|   "name": "DB0NJ", | ||||
|   "frequency": 439437500, | ||||
|   "modulation": "dmr" | ||||
| }] | ||||
							
								
								
									
										43
									
								
								owrx/bookmarks.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								owrx/bookmarks.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,43 @@ | ||||
| import json | ||||
|  | ||||
|  | ||||
| class Bookmark(object): | ||||
|     def __init__(self, j): | ||||
|         self.name = j["name"] | ||||
|         self.frequency = j["frequency"] | ||||
|         self.modulation = j["modulation"] | ||||
|  | ||||
|     def getName(self): | ||||
|         return self.name | ||||
|  | ||||
|     def getFrequency(self): | ||||
|         return self.frequency | ||||
|  | ||||
|     def getModulation(self): | ||||
|         return self.modulation | ||||
|  | ||||
|     def __dict__(self): | ||||
|         return { | ||||
|             "name": self.getName(), | ||||
|             "frequency": self.getFrequency(), | ||||
|             "modulation": self.getModulation(), | ||||
|         } | ||||
|  | ||||
|  | ||||
| class Bookmarks(object): | ||||
|     sharedInstance = None | ||||
|     @staticmethod | ||||
|     def getSharedInstance(): | ||||
|         if Bookmarks.sharedInstance is None: | ||||
|             Bookmarks.sharedInstance = Bookmarks() | ||||
|         return Bookmarks.sharedInstance | ||||
|  | ||||
|     def __init__(self): | ||||
|         f = open("bookmarks.json", "r") | ||||
|         bookmarks_json = json.load(f) | ||||
|         f.close() | ||||
|         self.bookmarks = [Bookmark(d) for d in bookmarks_json] | ||||
|  | ||||
|     def getBookmarks(self, range): | ||||
|         (lo, hi) = range | ||||
|         return [b for b in self.bookmarks if lo <= b.getFrequency() <= hi] | ||||
| @@ -3,6 +3,7 @@ from owrx.source import DspManager, CpuUsageThread, SdrService, ClientRegistry | ||||
| from owrx.feature import FeatureDetector | ||||
| from owrx.version import openwebrx_version | ||||
| from owrx.bands import Bandplan | ||||
| from owrx.bookmarks import Bookmarks | ||||
| from owrx.map import Map | ||||
| from multiprocessing import Queue | ||||
| import json | ||||
| @@ -168,6 +169,8 @@ class OpenWebRxReceiverClient(Client): | ||||
|             srh = configProps["samp_rate"] / 2 | ||||
|             frequencyRange = (cf - srh, cf + srh) | ||||
|             self.write_dial_frequendies(Bandplan.getSharedInstance().collectDialFrequencies(frequencyRange)) | ||||
|             bookmarks = [b.__dict__() for b in Bookmarks.getSharedInstance().getBookmarks(frequencyRange)] | ||||
|             self.write_bookmarks(bookmarks) | ||||
|  | ||||
|         self.configSub = configProps.wire(sendConfig) | ||||
|         sendConfig(None, None) | ||||
| @@ -254,6 +257,9 @@ class OpenWebRxReceiverClient(Client): | ||||
|     def write_dial_frequendies(self, frequencies): | ||||
|         self.send({"type": "dial_frequencies", "value": frequencies}) | ||||
|  | ||||
|     def write_bookmarks(self, bookmarks): | ||||
|         self.send({"type": "bookmarks", "value": bookmarks}) | ||||
|  | ||||
|     def write_aprs_data(self, data): | ||||
|         self.send({"type": "aprs_data", "value": data}) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jakob Ketterl
					Jakob Ketterl