예제 #1
0
        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;
        }
예제 #2
0
        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;
            }
        }
예제 #3
0
 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;
 }