mirror of
https://github.com/jwetzell/qController.git
synced 2026-08-19 22:24:18 +00:00
fix up SLIP decoding and data-less qlab replies
This commit is contained in:
@@ -81,21 +81,41 @@ namespace qController.Communication
|
|||||||
public void ParseCueUpdateInfo(OscMessage msg)
|
public void ParseCueUpdateInfo(OscMessage msg)
|
||||||
{
|
{
|
||||||
JToken cueUpdate = OSC2JSON(msg);
|
JToken cueUpdate = OSC2JSON(msg);
|
||||||
QCue cue = JsonConvert.DeserializeObject<QCue>(cueUpdate.ToString());
|
if(cueUpdate != null)
|
||||||
OnCueInfoUpdated(cue);
|
{
|
||||||
|
QCue cue = JsonConvert.DeserializeObject<QCue>(cueUpdate.ToString());
|
||||||
|
OnCueInfoUpdated(cue);
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
Log.Debug("QPARSER - cue update info does not have any data");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ParseSelectedCueInfo(OscMessage msg){
|
public void ParseSelectedCueInfo(OscMessage msg){
|
||||||
JToken selectedCue = OSC2JSON(msg);
|
JToken selectedCue = OSC2JSON(msg);
|
||||||
QCue cue = JsonConvert.DeserializeObject<QCue>(selectedCue.ToString());
|
if (selectedCue != null)
|
||||||
OnSelectedCueUpdated(cue);
|
{
|
||||||
|
QCue cue = JsonConvert.DeserializeObject<QCue>(selectedCue.ToString());
|
||||||
|
OnSelectedCueUpdated(cue);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log.Debug("QPARSER - selected does not have any data");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ParseQInfo(OscMessage msg)
|
public void ParseQInfo(OscMessage msg)
|
||||||
{
|
{
|
||||||
JToken qInfo = OSC2JSON(msg);
|
JToken qInfo = OSC2JSON(msg);
|
||||||
List<QWorkspaceInfo> qWorkspaceInfo = JsonConvert.DeserializeObject<List<QWorkspaceInfo>>(qInfo.ToString());
|
if (qInfo != null)
|
||||||
OnWorkspaceInfoReceived(qWorkspaceInfo);
|
{
|
||||||
|
List<QWorkspaceInfo> qWorkspaceInfo = JsonConvert.DeserializeObject<List<QWorkspaceInfo>>(qInfo.ToString());
|
||||||
|
OnWorkspaceInfoReceived(qWorkspaceInfo);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log.Debug("QPARSER - selected does not have any data");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ParseWorkspaceInfo(OscMessage msg)
|
public void ParseWorkspaceInfo(OscMessage msg)
|
||||||
@@ -131,8 +151,15 @@ namespace qController.Communication
|
|||||||
{
|
{
|
||||||
string cue_id = msg.Address.Split('/')[3];
|
string cue_id = msg.Address.Split('/')[3];
|
||||||
JToken children_obj = OSC2JSON(msg);
|
JToken children_obj = OSC2JSON(msg);
|
||||||
List<QCue> children = JsonConvert.DeserializeObject<List<QCue>>(children_obj.ToString());
|
if(children_obj != null)
|
||||||
OnChildrenUpdated(cue_id, children);
|
{
|
||||||
|
List<QCue> children = JsonConvert.DeserializeObject<List<QCue>>(children_obj.ToString());
|
||||||
|
OnChildrenUpdated(cue_id, children);
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
Log.Debug("QPARSER - children info message does not have any data");
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,6 +184,7 @@ namespace qController.Communication
|
|||||||
|
|
||||||
protected virtual void OnPlaybackPositionUpdated(string id)
|
protected virtual void OnPlaybackPositionUpdated(string id)
|
||||||
{
|
{
|
||||||
|
Log.Error(id);
|
||||||
PlaybackPositionUpdated?.Invoke(this, new PlaybackPositionArgs() { PlaybackPosition = id });
|
PlaybackPositionUpdated?.Invoke(this, new PlaybackPositionArgs() { PlaybackPosition = id });
|
||||||
}
|
}
|
||||||
protected virtual void OnConnectionStatusChanged(string status, string workspace_id)
|
protected virtual void OnConnectionStatusChanged(string status, string workspace_id)
|
||||||
|
|||||||
@@ -15,9 +15,14 @@ namespace SharpOSC
|
|||||||
this.Address = address;
|
this.Address = address;
|
||||||
Arguments = new List<object>();
|
Arguments = new List<object>();
|
||||||
Arguments.AddRange(args);
|
Arguments.AddRange(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override byte[] GetBytes()
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return "Address: " + Address + " Args: " + string.Join(",", Arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override byte[] GetBytes()
|
||||||
{
|
{
|
||||||
List<byte[]> parts = new List<byte[]>();
|
List<byte[]> parts = new List<byte[]>();
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,11 @@ namespace SharpOSC
|
|||||||
return parseMessage(OscData);
|
return parseMessage(OscData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static OscMessage GetMessage(byte[] OscData)
|
||||||
|
{
|
||||||
|
return parseMessage(OscData);
|
||||||
|
}
|
||||||
|
|
||||||
public abstract byte[] GetBytes();
|
public abstract byte[] GetBytes();
|
||||||
|
|
||||||
#region Parse OSC packages
|
#region Parse OSC packages
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ namespace SharpOSC
|
|||||||
public static readonly byte ESC = 0xdb;
|
public static readonly byte ESC = 0xdb;
|
||||||
public static readonly byte ESC_END = 0xDC;
|
public static readonly byte ESC_END = 0xDC;
|
||||||
public static readonly byte ESC_ESC = 0xDD;
|
public static readonly byte ESC_ESC = 0xDD;
|
||||||
|
private static List<byte> buffer = new List<byte>();
|
||||||
|
|
||||||
public static List<byte[]> Decode(byte[] data)
|
public static List<byte[]> Decode(byte[] data)
|
||||||
{
|
{
|
||||||
List<byte[]> messages = new List<byte[]>();
|
List<byte[]> messages = new List<byte[]>();
|
||||||
|
|
||||||
List<byte> buffer = new List<byte>();
|
|
||||||
bool escapeNext = false;
|
bool escapeNext = false;
|
||||||
for (int i = 0; i < data.Length; i++)
|
for (int i = 0; i < data.Length; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ namespace SharpOSC
|
|||||||
|
|
||||||
TcpSharpSocketClient? tcpClient;
|
TcpSharpSocketClient? tcpClient;
|
||||||
|
|
||||||
private List<byte> frameStream = new List<byte>();
|
|
||||||
|
|
||||||
public TCPClient(string address, int port)
|
public TCPClient(string address, int port)
|
||||||
{
|
{
|
||||||
_port = port;
|
_port = port;
|
||||||
@@ -78,38 +76,27 @@ namespace SharpOSC
|
|||||||
|
|
||||||
private void DataReceived(object sender, OnClientDataReceivedEventArgs e)
|
private void DataReceived(object sender, OnClientDataReceivedEventArgs e)
|
||||||
{
|
{
|
||||||
frameStream.AddRange(e.Data);
|
List<byte[]> messages = SlipFrame.Decode(e.Data);
|
||||||
|
_log.Debug("tcpclient: " + messages.Count + " messages pulled from slip");
|
||||||
int i = 0;
|
foreach (var message in messages)
|
||||||
int frameEnd = frameStream.FindIndex(1, frameByte => frameByte.Equals(SlipFrame.END));
|
|
||||||
while (frameEnd > 0)
|
|
||||||
{
|
{
|
||||||
List<byte> frame = frameStream.GetRange(0, frameEnd + 1);
|
try
|
||||||
frameStream.RemoveRange(0, frameEnd + 1);
|
|
||||||
List<byte[]> messages = SlipFrame.Decode(frame.ToArray());
|
|
||||||
foreach (var message in messages)
|
|
||||||
{
|
{
|
||||||
try
|
|
||||||
{
|
|
||||||
OscPacket packet = OscPacket.GetPacket(message);
|
|
||||||
OscMessage responseMessage = (OscMessage)packet;
|
|
||||||
if (packet == null)
|
|
||||||
{
|
|
||||||
_log.Error("packet is null");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (responseMessage == null)
|
OscMessage responseMessage = OscPacket.GetMessage(message);
|
||||||
{
|
if (responseMessage == null)
|
||||||
_log.Error("responeMessage is null");
|
{
|
||||||
}
|
_log.Error("responseMessage is null");
|
||||||
|
} else
|
||||||
|
{
|
||||||
OnMessageReceived(responseMessage);
|
OnMessageReceived(responseMessage);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
}
|
||||||
_log.Error($"Exception parsing OSC message: {ex.ToString()}");
|
catch (Exception ex)
|
||||||
}
|
{
|
||||||
|
_log.Error($"Exception parsing OSC message: {ex.ToString()}");
|
||||||
}
|
}
|
||||||
frameEnd = frameStream.FindIndex(0, frameByte => frameByte.Equals(SlipFrame.END));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -289,6 +289,9 @@ namespace qController
|
|||||||
}
|
}
|
||||||
qCell.UpdateSelectedCue(cue);
|
qCell.UpdateSelectedCue(cue);
|
||||||
});
|
});
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
Log.Error("Playback Position has been updated but cue is null?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user