/// <summary> /// 针对遥测信息,序列化 /// <summary> /// <param name="sf">浮点数</param> /// <param name="time">时间信标</param> public bool AddInformationObject(ShortFloating sf, CP56Time2a time) { bool state = false; if (ASDU.IsSequence == true) { return(state); } var data = new byte[sf.GetDataArray().Length + time.GetDataArray().Length]; Array.Copy(sf.GetDataArray(), 0, data, 0, sf.GetDataArray().Length); Array.Copy(time.GetDataArray(), 0 + sf.GetDataArray().Length, data, sf.GetDataArray().Length, time.GetDataArray().Length); ASDU.AddInformationObject(data, (byte)data.Length); return(true); }
/// <summary> /// 获取报数据 /// </summary> /// <returns>字节数组</returns> public byte[] GetPacketData() { if (DirectoryName.Length > 200) { throw new ArgumentException("字符过长"); } //21+x int len = 21 + DirectoryNameLen; int index = 0; packetData = new byte[len]; packetData[index++] = (byte)OperationSign; packetData[index++] = ElementTool.GetBit7_0(DirectoryID); packetData[index++] = ElementTool.GetBit15_8(DirectoryID); packetData[index++] = ElementTool.GetBit23_16(DirectoryID); packetData[index++] = ElementTool.GetBit31_24(DirectoryID); packetData[index++] = DirectoryNameLen; var name = UnicodeEncoding.ASCII.GetBytes(DirectoryName); Array.Copy(name, 0, packetData, index, name.Length); int offset = index + name.Length; var start = QueryStartingTime.GetDataArray(); var end = QueryEndTime.GetDataArray(); Array.Copy(start, 0, packetData, offset, 7); offset += 7; Array.Copy(end, 0, packetData, offset, 7); return(packetData); }
/// <summary> /// 针对遥信信息,以此添加信息对象,单点,双点信息,序列化 /// </summary> /// <param name="telesignalisationAddress">遥信地址</param> /// <param name="qds">品质描述</param> public bool AddInformationObject(byte qds, CP56Time2a time) { bool state = false; if (ASDU.IsSequence == false) { return(state); } var data = new byte[1 + time.GetDataArray().Length];// 品质描述1 + 时间戳7 data[0] = qds; Array.Copy(time.GetDataArray(), 0, data, 1, time.GetDataArray().Length); ASDU.AddInformationObject(data, 4); return(true); }
/// <summary> /// 针对遥测信息,,序列化 /// </summary> /// <param name="nve">归一化值</param> /// <param name="time">时间信标</param> public bool AddInformationObject(NormalizationValue nve, CP56Time2a time) { bool state = false; if (ASDU.IsSequence == true) { return(state); } var data = new byte[nve.GetDataArray().Length + time.GetDataArray().Length]; Array.Copy(nve.GetDataArray(), 0, data, 0, nve.GetDataArray().Length); Array.Copy(time.GetDataArray(), 0 + nve.GetDataArray().Length, data, nve.GetDataArray().Length, time.GetDataArray().Length); ASDU.AddInformationObject(data, (byte)data.Length); return(true); }
/// <summary> /// 针对遥测信息,,非序列化 /// </summary> /// <param name="Address">遥测地址</param> /// <param name="sf">浮点数</param> /// <param name="time">时间信标</param> public bool AddInformationObject(UInt32 address, ShortFloating sf, CP56Time2a time) { 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); Array.Copy(time.GetDataArray(), 0, data, 3 + sf.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); }
/// <summary> /// 获取数据数组 /// </summary> /// <returns>数组</returns> public byte[] GetArrayData() { var data = new byte[NameLen + 13]; data[0] = NameLen; var nameByte = UnicodeEncoding.ASCII.GetBytes(Name); Array.Copy(nameByte, 0, data, 1, NameLen); data[NameLen + 1] = ElementTool.GetBit7_0(Size); data[NameLen + 2] = ElementTool.GetBit15_8(Size); data[NameLen + 3] = ElementTool.GetBit23_16(Size); data[NameLen + 4] = ElementTool.GetBit31_24(Size); data[NameLen + 5] = Property; Array.Copy(Time.GetDataArray(), 0, data, NameLen + 6, 7); attributeData = data; return(data); }
/// <summary> /// MasterCommand APDU初始化,用于时钟同步 /// </summary> /// <param name="typeID">类型ID</param> /// <param name="transmitSeqNum">发送序列号</param> /// <param name="ReceiveSeqNum">接收序列号</param> /// <param name="cot">传输原因</param> /// <param name="asduPublicAddress">ASDU公共地址</param> /// <param name="time">时间标识</param> public MasterCommand(UInt16 transmitSeqNum, UInt16 ReceiveSeqNum, TypeIdentification typeID, CauseOfTransmissionList cot, UInt16 asduPublicAddress, CP56Time2a time) { ASDU = new ApplicationServiceDataUnit((byte)typeID, (byte)1, false, (byte)cot, asduPublicAddress); //信息对象地址为0 ASDU.InformationObject[0] = 0; ASDU.InformationObject[1] = 0; ASDU.InformationObject[2] = 0; Array.Copy(time.GetDataArray(), 0, ASDU.InformationObject, 3, 7); var apduLen = 4 + ASDU.Length; //控制域长度4 + ASDU长度 APCI = new APCITypeI((byte)apduLen, transmitSeqNum, ReceiveSeqNum); TimeStamp = DateTime.Now; }
/// <summary> /// 查询日志文件 /// </summary> /// <param name="transmitSeqNum">发送序列号</param> /// <param name="ReceiveSeqNum">接收序列号</param> /// <param name="cot">传输原因</param> /// <param name="ASDUPublicAddress">ASDU公共地址</param> /// <param name="objectAddress">对象地址</param> /// <param name="fileName">文件名称</param> /// <param name="startTime">开始时间</param> /// <param name="endTime">结束时间</param> public FileTransmit(UInt16 transmitSeqNum, UInt16 ReceiveSeqNum, CauseOfTransmissionList cot, UInt16 ASDUPublicAddress, UInt32 objectAddress, UInt16 fileName, CP56Time2a startTime, CP56Time2a endTime) { ASDU = new ApplicationServiceDataUnit((byte)TypeIdentification.F_SC_NB_1, 1, false, (byte)cot, ASDUPublicAddress); ASDU.InformationObject[0] = ElementTool.GetBit7_0(objectAddress); ASDU.InformationObject[1] = ElementTool.GetBit15_8(objectAddress); ASDU.InformationObject[2] = ElementTool.GetBit23_16(objectAddress); ASDU.InformationObject[3] = ElementTool.GetBit7_0(fileName); ASDU.InformationObject[4] = ElementTool.GetBit15_8(fileName); Array.Copy(startTime.GetDataArray(), 0, ASDU.InformationObject, 5, 7); Array.Copy(endTime.GetDataArray(), 0, ASDU.InformationObject, 12, 7); var apduLen = 4 + ASDU.Length; //控制域长度4 + ASDU长度 APCI = new APCITypeI((byte)apduLen, transmitSeqNum, ReceiveSeqNum); TimeStamp = DateTime.Now; }
/// <summary> /// 添加信息对象--针对目录 /// </summary> /// <param name="fileName">文件名</param> /// <param name="fileLen">文件长度</param> /// <param name="sof">文件状态</param> /// <param name="time">时间</param> public bool AddInformationObject(UInt16 fileName, UInt32 fileLen, StatusOfFile sof, CP56Time2a time) { bool state = false; if (ASDU.IsSequence == true) { return(state); } var data = new byte[2 + 3 + 1 + 7]; data[0] = ElementTool.GetBit7_0(fileName); data[1] = ElementTool.GetBit15_8(fileName); data[2] = ElementTool.GetBit7_0(fileLen); data[3] = ElementTool.GetBit15_8(fileLen); data[4] = ElementTool.GetBit23_16(fileLen); data[5] = sof.SOF; Array.Copy(time.GetDataArray(), 0, data, 6, 7); ASDU.AddInformationObject(data, (byte)data.Length); return(true); }