private void QueueDataDumps(AtemConnection conn) { try { foreach (byte[] cmd in _state) { var builder = new OutboundMessageBuilder(); if (!builder.TryAddData(cmd)) { throw new Exception("Failed to build message!"); } Log.InfoFormat("Length {0}", cmd.Length); conn.QueueMessage(builder.Create()); } Log.InfoFormat("Sent all data to {0}", conn.Endpoint); //conn.QueueMessage(new OutboundMessage(OutboundMessage.OutboundMessageType.Ping, new byte [0])); } catch (Exception e) { Console.WriteLine(e.Message); } }
public static List <OutboundMessage> CommandsToMessages(List <byte[]> commands) { var messages = new List <OutboundMessage>(); while (commands.Count > 0) { var builder = new OutboundMessageBuilder(); int removeCount = 0; foreach (byte[] data in commands) { if (!builder.TryAddData(data)) { break; } removeCount++; } if (removeCount == 0) { throw new Exception("Failed to build message!"); } commands.RemoveRange(0, removeCount); messages.Add(builder.Create()); // Log.InfoFormat("Length {0} {1}", builder.currentLength , removeCount); } return(messages); }
private static OutboundMessage CompileQueuedUpdateMessage(List <byte[]> queuedCommands) { var builder = new OutboundMessageBuilder(); int removeCount = 0; foreach (byte[] cmd in queuedCommands) { if (!builder.TryAddData(new List <byte[]> { cmd })) { break; } removeCount++; } if (removeCount == 0) { throw new Exception("Failed to dequeue command"); } queuedCommands.RemoveRange(0, removeCount); return(builder.Create()); }