Beispiel #1
0
        public SECSMessage Byte_TO_SecsMessage(byte[] aHeader)
        {
            SECSMessage message = new SECSMessage("", "");

            byte[] aBytes = new byte[]
            {
                aHeader[0],
                aHeader[1]
            };
            byte[] buffer2 = new byte[]
            {
                aHeader[6],
                aHeader[7],
                aHeader[8],
                aHeader[9]
            };
            message.SystemBytes = Byte2SecsValue.GetLong(buffer2);
            message.DeviceIdID  = Byte2SecsValue.AdjustDeviceID((short)Byte2SecsValue.GetInt(aBytes));
            message.Stream      = (int)(aHeader[2] & 255);
            int stream = message.Stream;

            if (stream > 128)
            {
                message.Stream = stream - 128;
                message.WBit   = true;
            }
            message.Function = (int)(aHeader[3] & 255);
            return(message);
        }
Beispiel #2
0
        private void OnReadHsms(SECSBlock aHSMSItem)
        {
            try
            {
                if (this.NowStatus == eHSMS_PORT_STATUS.TERMINATE)
                {
                    this.logger.Error("HSMSPort::OnReadHsms=> Port TERMINATE.");
                    return;
                }
            }
            catch (Exception exception)
            {
                this.logger.Error("HSMSPort::OnReadHsms", exception);
            }
            byte[] aBytes = new byte[4];
            Array.Copy(aHSMSItem.Header, 6, aBytes, 0, aBytes.Length);
            long mSystemBytes = Byte2SecsValue.GetLong(aBytes);
            byte num          = aHSMSItem.Header[5];

            if (num == 0)
            {
                this.logger.Debug("HSMSPort::OnReadHsms Not control message.");
                aHSMSItem.IsControlMsg = false;
                this.mHsmsParser.QueueEnque(aHSMSItem);
                return;
            }
            this.logger.Debug("HSMSPort::OnReadHsms control message.");
            lock (this.syncObject)
            {
                aHSMSItem.IsControlMsg = true;
                switch (num)
                {
                case 1:
                    this.mHsmsTimer.StopT7Timer();
                    if (this.NowStatus != eHSMS_PORT_STATUS.SELECT)
                    {
                        this.mHsmsWriter.WriteControlMessage(mSystemBytes, 0, eControlMessage.SELECT_RSP, 255, 255);
                        this.FireSelected();
                    }
                    else
                    {
                        this.mHsmsWriter.WriteControlMessage(mSystemBytes, 1, eControlMessage.SELECT_RSP, 255, 255);
                    }
                    break;

                case 2:
                    this.mHsmsTimer.StopT6Timer();
                    this.FireSelected(aHSMSItem.Header[3]);
                    break;

                case 3:
                    this.UpdateStatus(eHSMS_PORT_STATUS.CONNECT);
                    this.mHsmsWriter.WriteControlMessage(mSystemBytes, 0, eControlMessage.DESELECT_RSP, 255, 255);
                    break;

                case 5:
                    this.mHsmsWriter.WriteControlMessage(mSystemBytes, 0, eControlMessage.LINKTEST_RSP, 255, 255);
                    break;

                case 6:
                    this.mHsmsTimer.StopT6Timer();
                    break;

                case 7:
                    this.TraceRejectReqCode(aHSMSItem.Header[3]);
                    break;

                case 9:
                    this.OnDisconnect("Separate.");
                    break;
                }
            }
        }