示例#1
0
        public Messenger(ITransiver transiver)
        {
            _transiver = transiver;
            _transiver.DataReceived += _transiver_DataReceived;



            _rs = new FrameReceiverState();
            _rs.Init();
            _rs.FrameReceived += _rs_FrameReceived;
            _rs.FrameError    += _rs_FrameError;
        }
示例#2
0
        void _rs_FrameReceived(FrameReceiverState obj)
        {
            switch (_messageType)
            {
            case MessageType.GetMarker:
                if (ReadMarkerCompleted != null)
                {
                    _colorMarkerResponseMessage             = new ColorMarkerResponseMessage();
                    _colorMarkerResponseMessage.TimePoint   = obj.PayloadBuff[0];
                    _colorMarkerResponseMessage.R           = obj.PayloadBuff[1];
                    _colorMarkerResponseMessage.G           = obj.PayloadBuff[2];
                    _colorMarkerResponseMessage.B           = obj.PayloadBuff[3];
                    _colorMarkerResponseMessage.MarkerIndex = _markerIndex;
                    ReadMarkerCompleted(this, _colorMarkerResponseMessage);
                }
                break;

            case MessageType.GetMarkerCount:
                if (ReadMarkerCountCompleted != null)
                {
                    _colorMarkerCountResponseMessage = new ColorMarkerCountResponseMessage()
                    {
                        MarkerCount = obj.PayloadBuff[0]
                    };
                    ReadMarkerCountCompleted(this, _colorMarkerCountResponseMessage);
                }
                break;

            case MessageType.GetTimeSpan:
                if (ReadTimeSpanCompleted != null)
                {
                    _timeSpanResponseMessage           = new TimeSpanResponseMessage();
                    _timeSpanResponseMessage.TimeSpan  = obj.PayloadBuff[0];
                    _timeSpanResponseMessage.TimeSpan |= (UInt16)((UInt16)obj.PayloadBuff[1] << 8);
                    ReadTimeSpanCompleted(this, _timeSpanResponseMessage);
                }
                break;

            case MessageType.GetTimeProgress:
                if (ReadTimeProgressCompleted != null)
                {
                    _timeProgressResponseMessage = new TimeProgressResponseMessage();
                    _timeProgressResponseMessage.TimeProgress  = obj.PayloadBuff[0];
                    _timeProgressResponseMessage.TimeProgress |= (UInt16)((UInt16)obj.PayloadBuff[1] << 8);
                    ReadTimeProgressCompleted(this, _timeProgressResponseMessage);
                }
                break;

            case MessageType.GetSystemStateFlags:
                if (ReadSystemStateFlagsCompleted != null)
                {
                    _systemStateFlagsResponseMessage      = new SystemStateFlagsResponseMessage();
                    _systemStateFlagsResponseMessage.Data = obj.PayloadBuff;
                    ReadSystemStateFlagsCompleted(this, _systemStateFlagsResponseMessage);
                }
                break;
            }

            _messageType     = MessageType.Undefined;
            _pendingResponse = false;
        }
示例#3
0
 void _rs_FrameError(FrameReceiverState obj)
 {
     _messageType     = MessageType.Undefined;
     _pendingResponse = false;
 }