示例#1
0
        public StartHeaderOrder(InputByteArray InputArray)
            : base(InputArray, WtdOrder.StartHeader)
        {
            // at least 3 bytes remaining. ( command code, length byte and length must be from
            // 1 to 7.
            if (InputArray.RemainingLength < 3)
            {
                this.Errmsg = "SOH not long enough";
            }

            if (this.Errmsg == null)
            {
                var buf2 = InputArray.PeekBytes(2);
                this.LengthByte = buf2[1];

                // invalid start of header order length.
                if ((this.LengthByte < 1) || (this.LengthByte > 7))
                {
                    this.Errmsg = "SOH length not valid";
                }
            }

            if (this.Errmsg == null)
            {
                int actualOrderLength = CalcActualOrderLength(this.LengthByte);
                var buf = InputArray.PeekBytesPad(this.BytesLength, 9, 0x00);

                this.FlagByte                 = buf[2];
                this.ReservedByte             = buf[3];
                this.FirstResponseFieldNumber = buf[4];
                this.ErrRow         = buf[5];
                this.CmdKeySwitches = buf.SubArray(6, 3);

                // advance current pos in input array by the actual length of the order.
                InputArray.AdvanceIndex(this.BytesLength);
            }
        }