public MessageTransceiver(SlaveContext contextManager, int session) { this._slaveContext = contextManager; // 创建上行队列 FormatterType formatterType = contextManager.GetProperty <FormatterType>("EngineQueueFormat"); MessengerOption receiveOption = new MessengerOption(CoreConstants.UpLinkMQName, GetMessageType) { Type = contextManager.GetProperty <MessengerType>("MessengerType"), Formatter = formatterType, ReceiveType = ReceiveType.Synchronous }; _uplinkMessenger = Messenger.GetMessenger(receiveOption); // 创建下行队列 MessengerOption sendOption = new MessengerOption(CoreConstants.DownLinkMQName, GetMessageType) { Type = contextManager.GetProperty <MessengerType>("MessengerType"), Formatter = formatterType, ReceiveType = ReceiveType.Synchronous }; _downLinkMessenger = Messenger.GetMessenger(sendOption); _messageQueue = new LocalMessageQueue <MessageBase>(CoreConstants.DefaultEventsQueueSize); this.SessionId = session; }
private void ProcessControlMessage(ControlMessage message) { switch (message.Name) { case MessageNames.CtrlStart: _context.CtrlStartMessage = message; break; case MessageNames.CtrlAbort: _context.Cancellation.Cancel(); _context.DebugManager.Dispose(); // 如果线程还未结束,则等待 if (_context.FlowControlThread.IsAlive) { if (_context.FlowControlThread.Join(_context.GetProperty <int>("AbortTimeout"))) { SlaveFlowTaskBase.CurrentFlowTask?.TaskAbortAction(); } else { _context.FlowControlThread.Abort(); } _context.CoroutineManager.Dispose(); } break; } }
public UplinkMessageProcessor(SlaveContext context) { this._context = context; this._transceiver = _context.MessageTransceiver; this._waitTimer = new Timer(SendHeartBeatMessage, null, Timeout.Infinite, Timeout.Infinite); this._heartBeatInterval = _context.GetProperty <int>("StatusUploadInterval"); this._eventProcessFlag = -1; }