/// <summary> /// 针对序列化的SQ = 1,设置首地址地址 /// </summary> /// <returns></returns> public bool SetSequenceFirstObjectAddress(UInt32 addrss) { if (IsSequence) { informationObject[0] = ElementTool.GetBit7_0(addrss); informationObject[1] = ElementTool.GetBit15_8(addrss); informationObject[2] = ElementTool.GetBit23_16(addrss); return(true); } else { return(false); } }
/// <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; }
/// <summary> /// 针对遥信信息,以此添加信息对象,单点,双点信息,非序列化 /// </summary> /// <param name="telesignalisationAddress">遥信地址</param> /// <param name="qds">带品质描述单点或双点信息</param> public bool AddInformationObject(UInt32 telesignalisationAddress, byte qds) { bool state = false; if (ASDU.IsSequence == true) { return(state); } var data = new byte[3 + 1]; data[0] = ElementTool.GetBit7_0(telesignalisationAddress); data[1] = ElementTool.GetBit15_8(telesignalisationAddress); data[2] = ElementTool.GetBit23_16(telesignalisationAddress); data[3] = qds; ASDU.AddInformationObject(data, 4); return(true); }
/// <summary> /// 添加信息对象,非序列化,浮点数+地址+品质描述词 /// </summary> /// <param name="Address">遥测地址</param> /// <param name="sf">浮点数</param> public bool AddInformationObject(UInt32 address, ShortFloating sf) { bool state = false; if (ASDU.IsSequence == true) { return(state); } var data = new byte[3 + sf.GetDataArray().Length]; data[0] = ElementTool.GetBit7_0(address); data[1] = ElementTool.GetBit15_8(address); data[2] = ElementTool.GetBit23_16(address); Array.Copy(sf.GetDataArray(), 0, data, 3, sf.GetDataArray().Length); ASDU.AddInformationObject(data, (byte)data.Length); return(true); }
/// <summary> /// 针对遥测信息,,非序列化 /// </summary> /// <param name="Address">遥测地址</param> /// <param name="nve">归一化值</param> /// <param name="time">时间信标</param> public bool AddInformationObject(UInt32 address, NormalizationValue nve, CP56Time2a time) { bool state = false; if (ASDU.IsSequence == true) { return(state); } var data = new byte[3 + nve.GetDataArray().Length + time.GetDataArray().Length]; data[0] = ElementTool.GetBit7_0(address); data[1] = ElementTool.GetBit15_8(address); data[2] = ElementTool.GetBit23_16(address); Array.Copy(nve.GetDataArray(), 0, data, 3, nve.GetDataArray().Length); Array.Copy(time.GetDataArray(), 0, data, 3 + nve.GetDataArray().Length, time.GetDataArray().Length); ASDU.AddInformationObject(data, (byte)data.Length); return(true); }
/// <summary> /// 针对遥信信息,以此添加信息对象,单点,双点信息,非序列化 /// </summary> /// <param name="telesignalisationAddress">遥信地址</param> /// <param name="qds">带品质描述单点或双点信息</param> public bool AddInformationObject(UInt32 telesignalisationAddress, byte qds, CP56Time2a time) { bool state = false; if (ASDU.IsSequence == true) { return(state); } var data = new byte[3 + 1 + time.GetDataArray().Length];//地址3 + 品质描述1 + 时间戳7 data[0] = ElementTool.GetBit7_0(telesignalisationAddress); data[1] = ElementTool.GetBit15_8(telesignalisationAddress); data[2] = ElementTool.GetBit23_16(telesignalisationAddress); data[3] = qds; Array.Copy(time.GetDataArray(), 0, data, 4, time.GetDataArray().Length); ASDU.AddInformationObject(data, (byte)(4 + time.GetDataArray().Length)); return(true); }