예제 #1
0
        /// <summary>
        /// APDU初始化
        /// </summary>
        /// <param name="transmitSeqNum">发送序列号</param>
        /// <param name="ReceiveSeqNum">接收序列号</param>
        /// <param name="typeID">类型ID</param>
        /// <param name="isquense">是否序列号 true-序列化 false-非序列化</param>
        /// <param name="objectCount">信息对象数目数目</param>
        /// <param name="cot">传输原因</param>
        /// <param name="ASDUPublicAddress">公共地址</param>
        public APDU(UInt16 transmitSeqNum, UInt16 ReceiveSeqNum, TypeIdentification typeID, bool isquense, byte objectCount,
                    CauseOfTransmissionList cot, UInt16 ASDUPublicAddress, UInt32 objectAddress)
        {
            ASDU = new ApplicationServiceDataUnit((byte)typeID, objectCount, isquense, (byte)cot, ASDUPublicAddress);
            //信息对象地址为0
            ASDU.InformationObject[0] = ElementTool.GetBit7_0(objectAddress);
            ASDU.InformationObject[1] = ElementTool.GetBit15_8(objectAddress);
            ASDU.InformationObject[2] = ElementTool.GetBit23_16(objectAddress);
            var apduLen = 4 + ASDU.Length; //控制域长度4 + ASDU长度

            APCI = new APCITypeI((byte)apduLen, transmitSeqNum, ReceiveSeqNum);

            TimeStamp = DateTime.Now;
        }
예제 #2
0
        /// <summary>
        /// 使用字节数组初始化,属于强制性转换初始化
        /// </summary>
        /// <param name="dataArray">字节数组</param>
        public APDU(byte[] dataArray)
        {
            if (dataArray.Length < 15)
            {
                throw new Exception("APDU(byte[] dataArray) 长度不应该小于15");
            }
            TimeStamp = DateTime.Now;
            APCI      = new APCITypeI(dataArray);
            var data = new byte[dataArray.Length - 6];

            Array.Copy(dataArray, 6, data, 0, dataArray.Length - 6);
            FrameArray = dataArray;
            ASDU       = new ApplicationServiceDataUnit(data);

            TimeStamp = DateTime.Now;
        }