| 
									
										
										
										
											2017-01-02 21:07:43 -05:00
										 |  |  | // Copyright (c) Charles J. Cliffe
 | 
					
						
							|  |  |  | // SPDX-License-Identifier: GPL-2.0+
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-17 22:58:56 -05:00
										 |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <vector>
 | 
					
						
							|  |  |  | #include <map>
 | 
					
						
							| 
									
										
										
										
											2014-11-30 17:11:29 -05:00
										 |  |  | #include <thread>
 | 
					
						
							| 
									
										
										
										
											2014-11-17 22:58:56 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-11 23:35:06 -05:00
										 |  |  | #include "DemodulatorInstance.h"
 | 
					
						
							| 
									
										
										
										
											2014-11-17 22:58:56 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-13 22:59:21 -04:00
										 |  |  | class DataNode; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-17 22:58:56 -05:00
										 |  |  | class DemodulatorMgr { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2014-11-22 22:33:32 -05:00
										 |  |  |     DemodulatorMgr(); | 
					
						
							|  |  |  |     ~DemodulatorMgr(); | 
					
						
							| 
									
										
										
										
											2014-11-17 22:58:56 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-27 11:11:30 +02:00
										 |  |  |     DemodulatorInstancePtr newThread(); | 
					
						
							|  |  |  |     | 
					
						
							|  |  |  |     //return snapshot-copy of the list purposefully
 | 
					
						
							|  |  |  |     std::vector<DemodulatorInstancePtr> getDemodulators(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::vector<DemodulatorInstancePtr> getOrderedDemodulators(bool actives = true); | 
					
						
							|  |  |  |     std::vector<DemodulatorInstancePtr> getDemodulatorsAt(long long freq, int bandwidth); | 
					
						
							|  |  |  |      | 
					
						
							| 
									
										
										
										
											2021-04-04 22:14:31 -04:00
										 |  |  |     DemodulatorInstancePtr getPreviousDemodulator(const DemodulatorInstancePtr& demod, bool actives = true); | 
					
						
							|  |  |  |     DemodulatorInstancePtr getNextDemodulator(const DemodulatorInstancePtr& demod, bool actives = true); | 
					
						
							| 
									
										
										
										
											2017-08-27 11:11:30 +02:00
										 |  |  |     DemodulatorInstancePtr getLastDemodulator(); | 
					
						
							|  |  |  |     DemodulatorInstancePtr getFirstDemodulator(); | 
					
						
							| 
									
										
										
										
											2016-01-13 21:29:26 -05:00
										 |  |  |     bool anyDemodulatorsAt(long long freq, int bandwidth); | 
					
						
							| 
									
										
										
										
											2021-04-04 22:14:31 -04:00
										 |  |  |     void deleteThread(const DemodulatorInstancePtr&); | 
					
						
							| 
									
										
										
										
											2014-11-17 22:58:56 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-23 19:39:27 -05:00
										 |  |  |     void terminateAll(); | 
					
						
							| 
									
										
										
										
											2014-12-10 00:34:27 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-04 22:14:31 -04:00
										 |  |  |     void setActiveDemodulator(const DemodulatorInstancePtr& demod, bool temporary = true); | 
					
						
							| 
									
										
										
										
											2017-08-27 11:11:30 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     //Dangerous: this is only intended by some internal classes,
 | 
					
						
							|  |  |  |     // and only set a pre-existing demod
 | 
					
						
							|  |  |  |     void setActiveDemodulatorByRawPointer(DemodulatorInstance* demod, bool temporary = true); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-11 22:59:43 -05:00
										 |  |  |     DemodulatorInstancePtr getActiveContextModem(); | 
					
						
							|  |  |  |     DemodulatorInstancePtr getCurrentModem(); | 
					
						
							| 
									
										
										
										
											2017-08-27 11:11:30 +02:00
										 |  |  |     DemodulatorInstancePtr getLastDemodulatorWith(const std::string& type, | 
					
						
							| 
									
										
										
										
											2017-04-01 19:38:08 +02:00
										 |  |  | 												const std::wstring& userLabel, | 
					
						
							|  |  |  | 												long long frequency, | 
					
						
							|  |  |  | 												int bandwidth); | 
					
						
							| 
									
										
										
										
											2014-12-10 00:34:27 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-02 20:10:55 -05:00
										 |  |  |     int getLastBandwidth() const; | 
					
						
							| 
									
										
										
										
											2021-04-04 22:14:31 -04:00
										 |  |  |     void setLastBandwidth(int lastBandwidth_in); | 
					
						
							| 
									
										
										
										
											2015-02-02 20:10:55 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-17 18:57:42 -05:00
										 |  |  |     std::string getLastDemodulatorType() const; | 
					
						
							| 
									
										
										
										
											2021-04-04 22:14:31 -04:00
										 |  |  |     void setLastDemodulatorType(std::string lastDemodType_in); | 
					
						
							| 
									
										
										
										
											2015-02-02 20:10:55 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     float getLastGain() const; | 
					
						
							| 
									
										
										
										
											2021-04-04 22:14:31 -04:00
										 |  |  |     void setLastGain(float lastGain_in); | 
					
						
							| 
									
										
										
										
											2015-02-02 20:10:55 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-15 17:43:10 -05:00
										 |  |  |     bool getLastDeltaLock() const; | 
					
						
							|  |  |  |     void setLastDeltaLock(bool lock); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-02 20:10:55 -05:00
										 |  |  |     float getLastSquelchLevel() const; | 
					
						
							| 
									
										
										
										
											2021-04-04 22:14:31 -04:00
										 |  |  |     void setLastSquelchLevel(float lastSquelch_in); | 
					
						
							| 
									
										
										
										
											2015-02-02 20:10:55 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     bool isLastSquelchEnabled() const; | 
					
						
							| 
									
										
										
										
											2021-04-04 22:14:31 -04:00
										 |  |  |     void setLastSquelchEnabled(bool lastSquelchEnabled_in); | 
					
						
							| 
									
										
										
										
											2015-11-20 21:55:37 -05:00
										 |  |  |      | 
					
						
							| 
									
										
										
										
											2015-08-19 17:06:06 -04:00
										 |  |  |     bool isLastMuted() const; | 
					
						
							| 
									
										
										
										
											2021-04-04 22:14:31 -04:00
										 |  |  |     void setLastMuted(bool lastMuted_in); | 
					
						
							| 
									
										
										
										
											2015-08-19 17:06:06 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-04 22:14:31 -04:00
										 |  |  |     ModemSettings getLastModemSettings(const std::string&); | 
					
						
							|  |  |  |     void setLastModemSettings(const std::string&, ModemSettings); | 
					
						
							| 
									
										
										
										
											2015-11-26 01:54:54 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     void updateLastState(); | 
					
						
							| 
									
										
										
										
											2016-07-06 21:23:59 +02:00
										 |  |  |      | 
					
						
							| 
									
										
										
										
											2016-09-13 22:59:21 -04:00
										 |  |  |     void setOutputDevices(std::map<int,RtAudio::DeviceInfo> devs); | 
					
						
							| 
									
										
										
										
											2019-01-22 00:01:31 -05:00
										 |  |  |     std::map<int, RtAudio::DeviceInfo> getOutputDevices(); | 
					
						
							| 
									
										
										
										
											2021-04-04 22:14:31 -04:00
										 |  |  |     void saveInstance(DataNode *node, const DemodulatorInstancePtr& inst); | 
					
						
							| 
									
										
										
										
											2017-04-01 19:38:08 +02:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2017-08-27 11:11:30 +02:00
										 |  |  |     DemodulatorInstancePtr loadInstance(DataNode *node); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-06 20:49:37 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-22 22:33:32 -05:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2014-12-11 19:07:21 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-29 19:54:03 +01:00
										 |  |  |     //utility method that attempts to decode node value as std::wstring, else as std::string, else 
 | 
					
						
							| 
									
										
										
										
											2018-06-06 20:49:37 +02:00
										 |  |  |     //return an empty string.
 | 
					
						
							|  |  |  |     static std::wstring getSafeWstringValue(DataNode* node); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-27 11:11:30 +02:00
										 |  |  |     std::vector<DemodulatorInstancePtr> demods; | 
					
						
							| 
									
										
										
										
											2016-07-06 21:23:59 +02:00
										 |  |  |      | 
					
						
							| 
									
										
										
										
											2019-02-11 22:59:43 -05:00
										 |  |  |     DemodulatorInstancePtr activeContextModem; | 
					
						
							|  |  |  |     DemodulatorInstancePtr currentModem; | 
					
						
							| 
									
										
										
										
											2017-08-27 11:11:30 +02:00
										 |  |  |     DemodulatorInstancePtr activeVisualDemodulator; | 
					
						
							| 
									
										
										
										
											2014-12-11 19:07:21 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-02 20:10:55 -05:00
										 |  |  |     int lastBandwidth; | 
					
						
							| 
									
										
										
										
											2015-11-17 18:57:42 -05:00
										 |  |  |     std::string lastDemodType; | 
					
						
							| 
									
										
										
										
											2015-06-10 10:50:14 +02:00
										 |  |  |     bool lastDemodLock; | 
					
						
							| 
									
										
										
										
											2015-02-02 20:10:55 -05:00
										 |  |  |     bool lastSquelchEnabled; | 
					
						
							|  |  |  |     float lastSquelch; | 
					
						
							|  |  |  |     float lastGain; | 
					
						
							| 
									
										
										
										
											2015-11-20 21:55:37 -05:00
										 |  |  |     bool lastMuted; | 
					
						
							| 
									
										
										
										
											2016-02-15 17:43:10 -05:00
										 |  |  |     bool lastDeltaLock; | 
					
						
							| 
									
										
										
										
											2015-11-26 01:54:54 -05:00
										 |  |  |      | 
					
						
							| 
									
										
										
										
											2016-06-02 23:56:31 +02:00
										 |  |  |     //protects access to demods lists and such, need to be recursive
 | 
					
						
							|  |  |  |     //because of the usage of public re-entrant methods 
 | 
					
						
							|  |  |  |     std::recursive_mutex demods_busy; | 
					
						
							| 
									
										
										
										
											2017-08-27 11:11:30 +02:00
										 |  |  |     | 
					
						
							| 
									
										
										
										
											2015-11-26 01:54:54 -05:00
										 |  |  |     std::map<std::string, ModemSettings> lastModemSettings; | 
					
						
							| 
									
										
										
										
											2016-09-13 22:59:21 -04:00
										 |  |  |     std::map<int,RtAudio::DeviceInfo> outputDevices; | 
					
						
							| 
									
										
										
										
											2014-11-17 22:58:56 -05:00
										 |  |  | }; |