Skip to content

Commit

Permalink
refactor: FireUpdate OnlineFeedback added to Handle Response method
Browse files Browse the repository at this point in the history
  • Loading branch information
mhengeli committed Dec 4, 2024
1 parent b587f82 commit c3d1fe2
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/ExtronQuantumDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class ExtronQuantumDevice : EssentialsBridgeableDevice, IRouting, ICommun
/// Provides a queue and dedicated worker thread for processing feedback messages from a device.
/// </summary>
private GenericQueue ReceiveQueue;
private GenericQueue CommandQueue;

//private readonly int _staticCanvas;

Expand Down Expand Up @@ -128,6 +129,7 @@ public ExtronQuantumDevice(string key, string name, ExtronQuantumConfig config,
_serialNumber = _config.DeviceSerialNumber;

ReceiveQueue = new GenericQueue(key + "-rxqueue");
CommandQueue = new GenericQueue(key + "-txqueue");

ConnectFeedback = new BoolFeedback(() => Connect);
OnlineFeedback = new BoolFeedback(() => _commsMonitor.IsOnline);
Expand All @@ -139,6 +141,7 @@ public ExtronQuantumDevice(string key, string name, ExtronQuantumConfig config,
_config.ErrorTimeoutMs > 5000 ? _config.ErrorTimeoutMs : 180000,
Poll);
Debug.Console(0, this, "Built Comms Monitor");
Debug.Console(3, this, "Comms Monitor {0}", _commsMonitor.Status);

if (_comms is ISocketStatus socket)
{
Expand Down Expand Up @@ -187,6 +190,7 @@ public ExtronQuantumDevice(string key, string name, ExtronQuantumConfig config,
}

_deviceInfo = new DeviceInfo();

}

private RoutingPortCollection<RoutingInputPort> CreateRoutingInputs(Dictionary<string, NameValue> inputs)
Expand Down Expand Up @@ -270,10 +274,25 @@ private void ProcessFeedbackMessage(string message)

if (message.StartsWith("bld", StringComparison.OrdinalIgnoreCase)) //firmware response
{
if(message == null)
{
Debug.Console(2, this, "Message null");
}
Debug.Console(2, this, $"Checking Starts with bld: {message}");
var firmware = message.Replace("Bld", "");

if (firmware == null)
Debug.Console(2, this, "firmware null");

if (_deviceInfo == null)
Debug.Console(2, this, "_deviceInfo null");

_deviceInfo.FirmwareVersion = firmware;

if (_deviceInfo.FirmwareVersion == null)
Debug.Console(2, this, "_deviceInfo.FirmwareVersion null");


FireDeviceInfoUpdate(_deviceInfo);
return;
}
Expand Down Expand Up @@ -366,7 +385,9 @@ private void ProcessFeedbackMessage(string message)
}
FirePresetFeedbacks();
return;
}
}

OnlineFeedback.FireUpdate();
}

private void FireInputFeedbacks()
Expand Down Expand Up @@ -621,7 +642,8 @@ public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingS
return;
}

SendText($"{canvas}*{window}*{inputSelector}!");
//SendText($"{canvas}*{window}*{inputSelector}!");
CommandQueue.Enqueue(new ProcessStringMessage($"{canvas}*{window}*{inputSelector}!", SendText));
}

public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type)
Expand Down

0 comments on commit c3d1fe2

Please sign in to comment.