Skip to content

Commit

Permalink
Added parsing of status response to report Active and Primary status.
Browse files Browse the repository at this point in the history
  • Loading branch information
mhengeli committed Aug 4, 2021
1 parent c69ec2c commit 4854fb5
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 2 deletions.
2 changes: 2 additions & 0 deletions GetPackages.BAT
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@Echo ON
nuget install .\packages.config -OutputDirectory .\packages -excludeVersion
63 changes: 63 additions & 0 deletions QscQsysDspPlugin/QscDsp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,39 @@ public static QscDsp BuildDevice(DeviceConfig dc)
public Dictionary<string, QscDspCamera> Cameras { get; set; }
public List<QscDspPresets> PresetList = new List<QscDspPresets>();

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; }


/// <summary>
Expand All @@ -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)
{
Expand All @@ -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<string, QscDspLevelControl>();
Dialers = new Dictionary<string, QscDspDialer>();
Cameras = new Dictionary<string, QscDspCamera>();
Expand Down Expand Up @@ -311,6 +345,15 @@ public void SetPrefix(string prefix)
}
}

/// <summary>
/// Issue a Status Get ("sg") to Core.
/// </summary>
/// <param name="prefix">string</param>
public void StatusGet(bool enable)
{
if (enable) SendLine("sg");
}

/// <summary>
/// Writes the config
/// </summary>
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
}

/// <summary>
/// Sends a command to the DSP (with delimiter appended)
/// </summary>
Expand Down
24 changes: 24 additions & 0 deletions QscQsysDspPlugin/QscDspBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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; }
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion QscQsysDspPlugin/QscQsysDspPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\PepperDashEssentials\lib\net35\PepperDashEssentials.dll</HintPath>
</Reference>
<Reference Include="PepperDash_Core, Version=1.0.15.26179, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="PepperDash_Core, Version=1.0.41.31808, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\PepperDashEssentials\lib\net35\PepperDash_Core.dll</HintPath>
</Reference>
Expand Down
2 changes: 1 addition & 1 deletion packages.config
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<packages>
<package id="PepperDashEssentials" version="1.6.4" targetFramework="net35" allowedVersions="[1.0,2.0)"/>
<package id="PepperDashEssentials" version="1.9.0" targetFramework="net35" allowedVersions="[1.0,2.0)"/>
</packages>

0 comments on commit 4854fb5

Please sign in to comment.