diff --git a/GetPackages.BAT b/GetPackages.BAT new file mode 100644 index 0000000..9b6def3 --- /dev/null +++ b/GetPackages.BAT @@ -0,0 +1,2 @@ +@Echo ON +nuget install .\packages.config -OutputDirectory .\packages -excludeVersion diff --git a/QscQsysDspPlugin/QscDsp.cs b/QscQsysDspPlugin/QscDsp.cs index c9a3c48..e00a1f8 100644 --- a/QscQsysDspPlugin/QscDsp.cs +++ b/QscQsysDspPlugin/QscDsp.cs @@ -71,13 +71,39 @@ public static QscDsp BuildDevice(DeviceConfig dc) public Dictionary Cameras { get; set; } public List PresetList = new List(); + public BoolFeedback IsPrimaryFeedback; + public BoolFeedback IsActiveFeedback; + DeviceConfig _Dc; CrestronQueue CommandQueue; bool CommandQueueInProgress = false; + bool _IsPrimary; + public bool IsPrimary + { + get { return _IsPrimary; } + private set + { + _IsPrimary = value; + IsPrimaryFeedback.FireUpdate(); + } + } + + bool _IsActive; + public bool IsActive + { + get { return _IsActive; } + private set + { + _IsActive = value; + IsActiveFeedback.FireUpdate(); + } + } uint HeartbeatTracker = 0; public bool ShowHexResponse { get; set; } + + public string DspName { get; private set; } /// @@ -96,6 +122,9 @@ public QscDsp(string key, string name, IBasicCommunication comm, DeviceConfig dc CommandQueue = new CrestronQueue(100); Communication = comm; + + DspName = name; + var socket = comm as ISocketStatus; if (socket != null) { @@ -113,6 +142,11 @@ public QscDsp(string key, string name, IBasicCommunication comm, DeviceConfig dc // Custom monitoring, will check the heartbeat tracker count every 20s and reset. Heartbeat sbould be coming in every 20s if subscriptions are valid CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 20000, 120000, 300000, CheckSubscriptions); + // Failover feedback, IsPrimary - will indicate dsp is either standalone or primary Core of a redundant pair + // IsActive - indicates this core is the active unit of a redundant pair. + IsPrimaryFeedback = new BoolFeedback(() => IsPrimary); + IsActiveFeedback = new BoolFeedback(() => IsActive); + LevelControlPoints = new Dictionary(); Dialers = new Dictionary(); Cameras = new Dictionary(); @@ -311,6 +345,15 @@ public void SetPrefix(string prefix) } } + /// + /// Issue a Status Get ("sg") to Core. + /// + /// string + public void StatusGet(bool enable) + { + if (enable) SendLine("sg"); + } + /// /// Writes the config /// @@ -402,6 +445,19 @@ void Port_LineReceived(object dev, GenericCommMethodReceiveTextArgs args) } if (args.Text.IndexOf("sr ") > -1) { + Debug.Console(1, this, "Status Response received"); + + var statusMessage = Regex.Split(args.Text, " (?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)"); //Splits by space unless enclosed in double quotes using look ahead method: https://stackoverflow.com/questions/18893390/splitting-on-comma-outside-quotes + + if (statusMessage.Length != 5) return; + + + + IsPrimary = statusMessage[3].Contains("1") ? true : false; + IsActive = statusMessage[4].Contains("1") ? true : false; + + Debug.Console(1, this, "IsPrimary = {0}{1}:: IsActive = {2}{3}", statusMessage[3], IsPrimary, statusMessage[4], IsActive); + } else if (args.Text.IndexOf("cv") > -1) { @@ -483,6 +539,13 @@ void Port_LineReceived(object dev, GenericCommMethodReceiveTextArgs args) } + public void ProcessSimulatedRx(string s) + { + GenericCommMethodReceiveTextArgs args = new GenericCommMethodReceiveTextArgs(s); + + Port_LineReceived(this, args); + } + /// /// Sends a command to the DSP (with delimiter appended) /// diff --git a/QscQsysDspPlugin/QscDspBridge.cs b/QscQsysDspPlugin/QscDspBridge.cs index 98ae23d..11bfd49 100644 --- a/QscQsysDspPlugin/QscDspBridge.cs +++ b/QscQsysDspPlugin/QscDspBridge.cs @@ -28,11 +28,21 @@ public static void LinkToApiExt(this QscDsp DspDevice, BasicTriList trilist, uin // from Plugin > to SiMPL DspDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); + trilist.StringInput[joinMap.DspName].StringValue = DspDevice.DspName; + + DspDevice.IsPrimaryFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsPrimary]); + DspDevice.IsPrimaryFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.IsSecondary]); + DspDevice.IsActiveFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsActive]); + DspDevice.IsActiveFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.IsInactive]); // from SiMPL > to Plugin trilist.SetStringSigAction(joinMap.Prefix, (s) => { DspDevice.SetPrefix(s); }); trilist.SetStringSigAction(joinMap.Address, (s) => { DspDevice.SetIpAddress(s); }); + trilist.SetBoolSigAction(joinMap.GetStatus, (b) => { DspDevice.StatusGet(b); }); + + trilist.SetStringSigAction(joinMap.SimTxRx, (s) => { DspDevice.ProcessSimulatedRx(s); }); + foreach (var channel in DspDevice.LevelControlPoints) { //var QscChannel = channel.Value as QSC.DSP.EPI.QscDspLevelControl; @@ -145,6 +155,13 @@ public static void LinkToApiExt(this QscDsp DspDevice, BasicTriList trilist, uin public class QscDspDeviceJoinMap : JoinMapBase { public uint IsOnline { get; set; } + public uint IsPrimary { get; set; } + public uint IsSecondary { get; set; } + public uint IsActive { get; set; } + public uint SimTxRx { get; set; } + public uint IsInactive { get; set; } + public uint GetStatus { get; set; } + public uint DspName { get; set; } public uint Address { get; set; } public uint Prefix { get; set; } public uint ChannelMuteToggle { get; set; } @@ -203,8 +220,15 @@ public QscDspDeviceJoinMap() // SIngleJoins IsOnline = 1; + IsPrimary = 2; + IsSecondary = 3; + IsActive = 4; + IsInactive = 5; + SimTxRx = 6; + GetStatus = 2; Prefix = 2; Address = 1; + DspName = 3; Presets = 100; DialStringCmd = 3100; IncomingCall = 3100; diff --git a/QscQsysDspPlugin/QscQsysDspPlugin.csproj b/QscQsysDspPlugin/QscQsysDspPlugin.csproj index 2f803d7..8fc39d7 100644 --- a/QscQsysDspPlugin/QscQsysDspPlugin.csproj +++ b/QscQsysDspPlugin/QscQsysDspPlugin.csproj @@ -55,7 +55,7 @@ False ..\packages\PepperDashEssentials\lib\net35\PepperDashEssentials.dll - + False ..\packages\PepperDashEssentials\lib\net35\PepperDash_Core.dll diff --git a/packages.config b/packages.config index 6c509dd..27ef4e0 100644 --- a/packages.config +++ b/packages.config @@ -1,3 +1,3 @@ - + \ No newline at end of file