public bool StackBind(ILayer bottom, ILayer top) { if (top is IDispatcherLayer) { DispatcherLayer = top as IDispatcherLayer; return(true); } STrace.Error(GetType().FullName, "Falta IDispatcherLayer!"); return(false); }
public DeviceCommand(int trackingId, int gatewayMessageId, int NodeCode, IDispatcherLayer ResponseDispatcher, int SecondsTimeout, String TrackingExtraData, CommanderReader CommanderReader) { State = CommandStates.JustWaitingForBegin; this.TrackingExtraData = TrackingExtraData; this.NodeCode = NodeCode; this.CommanderReader = CommanderReader; this.trackingId = trackingId; this.gatewayMessageId = gatewayMessageId; this.SecondsTimeout = SecondsTimeout; this.ResponseDispatcher = ResponseDispatcher; Timer = new Timer(OnTimeout, this, Timeout.Infinite, Timeout.Infinite); }
public static void CreateCommand(INode node, IDispatcherLayer disp, int trackingId, int gatewayMessageId, int timeout, Action action, String trackingExtraData, CommanderReader commanderReader) { var command = new DeviceCommand(trackingId, gatewayMessageId, node.DeviceId, disp, timeout, trackingExtraData, commanderReader); GetDeviceList(node.DeviceId).Add(command); try { action.Invoke(); command.Begin(); } catch (Exception e) { STrace.Exception(typeof(DevicesCommandStatus).FullName, e); command.Rollback(); GetDeviceList(node.DeviceId).Remove(command); } }
public static void DispatchResetStateMachine(int NodeCode, int TrackingId, String TrackingExtraData, IDispatcherLayer Dispatcher) { var userMessage = new UserMessage(NodeCode, (ulong)TrackingId); userMessage.UserSettings.Add("user_message_code", "FSM_RESET"); userMessage.UserSettings.Add("trackingId", TrackingId.ToString()); userMessage.UserSettings.Add("trackingExtraData", TrackingExtraData); Dispatcher.Dispatch(userMessage); }
public static int RejectCommand(int NodeCode, int TrackingId, String TrackingExtraData, IDispatcherLayer Dispatcher, Uri request) { STrace.Debug(typeof(CommanderReader).FullName, NodeCode, "Comando Rechazado: " + request); var userMessage = new UserMessage(NodeCode, (ulong)TrackingId); userMessage.UserSettings.Add("user_message_code", "NACK"); userMessage.UserSettings.Add("nack_reason", "REJECTED"); userMessage.UserSettings.Add("original_request", request.GetComponents(UriComponents.PathAndQuery, UriFormat.Unescaped)); userMessage.UserSettings.Add("trackingId", TrackingId.ToString()); userMessage.UserSettings.Add("trackingExtraData", TrackingExtraData); Dispatcher.Dispatch(userMessage); return(1); }