Ejemplo n.º 1
0
 public void Parse(SECSBlock mHSMSItem)
 {
     try
     {
         SECSDecoding decoding = new SECSDecoding();
         string       str      = ByteStringBuilder.ToLogString(mHSMSItem.Header);
         string       str2     = ByteStringBuilder.ToLogString(mHSMSItem.DataItem);
         SECSMessage  msg      = decoding.Byte_TO_SecsMessage(mHSMSItem.Header);
         msg.Root   = decoding.Byte_TO_SecsItem(mHSMSItem.DataItem);
         msg.Header = mHSMSItem.Header;
         //this.logger.Info(string.Format("[RECV] S{0}F{1} {2} System Bytes={3} {4} {5}", new object[]
         //{
         //	msg.Stream,
         //	msg.Function,
         //	msg.WBit ? "W" : "",
         //	msg.SystemBytes,
         //	str,
         //	str2
         //}));
         //this.logger.Warn("[RECV] " + SecsItem2Str.GetSecsMessageStr(msg));
         if (this.OnReceived != null)
         {
             this.OnReceived(msg);
         }
     }
     catch (Exception exception)
     {
         this.logger.Error("Parser#Parse", exception);
         if (this.OnParseError != null)
         {
             this.OnParseError(string.Format("{0}: {1}", SECSErrorsMessage.GetSECSErrorMessage(SECSErrors.ParseError), exception.Message));
         }
     }
 }
Ejemplo n.º 2
0
        public static string ToString(byte[] bs)
        {
            StringBuilder builder = new StringBuilder(bs.Length * 2);

            for (int i = 0; i < bs.Length; i++)
            {
                byte b = bs[i];
                builder.Append(ByteStringBuilder.ToString(b));
            }
            return(builder.ToString());
        }
Ejemplo n.º 3
0
        private byte[] ReadBody(int aLength)
        {
            int num = 0;

            byte[] bs = new byte[aLength];
            while (num < bs.Length)
            {
                this.mHsmsTimer.StartT8Timer();
                int num2 = this.reader.Read(bs, num, bs.Length - num);
                this.mHsmsTimer.StopT8Timer();
                num += num2;
            }
            string str = ByteStringBuilder.ToLogString(bs);

            this.logger.Debug(string.Format("Read Data: {0} -- {1}", aLength, str));
            return(bs);
        }
Ejemplo n.º 4
0
        public SECSBlock ByteToBlock(byte[] aBytes)
        {
            SECSBlock block = new SECSBlock
            {
                Length   = aBytes.Length,
                Header   = new byte[10],
                DataItem = new byte[aBytes.Length - 10]
            };

            Array.Copy(aBytes, 0, block.Header, 0, block.Header.Length);
            Array.Copy(aBytes, 10, block.DataItem, 0, block.DataItem.Length);
            string str = ByteStringBuilder.ToLogString(block.Header);

            this.logger.Debug(string.Format("Reader#ByteToBlock Header: {0}", str));
            string str2 = ByteStringBuilder.ToLogString(block.DataItem);

            this.logger.Debug(string.Format("Reader#ByteToBlock Data: {0}", str2));
            return(block);
        }
Ejemplo n.º 5
0
 public void WriteControlMessage(long mSystemBytes, byte rspcode, eControlMessage stype, byte high, byte low)
 {
     try
     {
         byte[] bs = new byte[14];
         bs[0] = 0;
         bs[1] = 0;
         bs[2] = 0;
         bs[3] = 10;
         byte[] intBytes = SecsValue2Byte.GetIntBytes((int)mSystemBytes, 4);
         bs[10] = intBytes[0];
         bs[11] = intBytes[1];
         bs[12] = intBytes[2];
         bs[13] = intBytes[3];
         bs[4]  = high;
         bs[5]  = low;
         bs[7]  = rspcode;
         bs[9]  = (byte)stype;
         if (stype == eControlMessage.SELECT_REQ)
         {
             this.mHsmsTimer.StartT6Timer();
         }
         else if (stype == eControlMessage.LINKTEST_REQ)
         {
             this.mHsmsTimer.StartT6Timer();
         }
         this.logger.Debug(string.Format("[WriteControlMessage] [{0}-{2}] -- {1}", mSystemBytes, ByteStringBuilder.ToLogString(bs), stype));
         this.writer.Write(bs);
         this.writer.Flush();
     }
     catch (Exception exception)
     {
         this.logger.Error("WriteControlMessage", exception);
         if (this.OnWriteError != null)
         {
             this.OnWriteError(SECSEventType.Error, null, string.Format("{0}: Socket Error.", SECSErrorsMessage.GetSECSErrorMessage(SECSErrors.WriteError)));
         }
     }
 }
Ejemplo n.º 6
0
 internal static string GetBinaryStr(byte[] data)
 {
     return(ByteStringBuilder.ToLogString(data));
 }