public DeviceCommand(ulong messageId, int gatewayMessageId, INode device, IDataTransportLayer responseDispatcher, int SecondsTimeout, String TrackingExtraData) { State = CommandStates.JustWaitingForBegin; this.TrackingExtraData = TrackingExtraData; Node = device; this.MessageId = messageId; this.GatewayMessageId = gatewayMessageId; this.SecondsTimeout = SecondsTimeout; this.ResponseDispatcher = responseDispatcher; Timer = new Timer(OnTimeout, this, Timeout.Infinite, Timeout.Infinite); }
public static void CreateCommand(INode node, IDataTransportLayer disp, ulong messageId, int gatewayMessageId, int timeout, Action action, String trackingExtraData, CommanderReader commanderReader) { var command = new DeviceCommand(messageId, gatewayMessageId, node, disp, timeout, trackingExtraData); GetDeviceList(node.GetDeviceId()).Add(command); try { if (node == null) { throw new ArgumentNullException("node"); } node.ExecuteOnGuard(action.Invoke, "CreateCommand", ""); command.Begin(); } catch { command.Rollback(); GetDeviceList(node.Id).Remove(command); throw; } }