Пример #1
0
        /// <summary>
        /// 保护定值选择
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DownloadProtectSetSelect_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var observale = (ObservableCollection <ProtectSetPoint>)protectSetPoint;
                if ((observale != null) && (observale.Count > 0))
                {
                    var qos            = new QualifyCommandSet(ActionDescrible.Select);
                    var protectsetAPDU = new APDU(appMessageManager.TransmitSequenceNumber, appMessageManager.RealReceiveSequenceNumber,
                                                  TypeIdentification.C_SE_NC_1, true, (byte)observale.Count,
                                                  CauseOfTransmissionList.Activation, appMessageManager.ASDUADdress, ProtectSetPoint.BasicAddress, qos);

                    foreach (var m in observale)
                    {
                        if (m.InternalID <= observale.Count)
                        {
                            var sf = new ShortFloating((float)m.ParameterValue);
                            protectsetAPDU.AddInformationObject(sf.GetDataArray(),
                                                                (byte)sf.GetDataArray().Length, (byte)(m.InternalID - 1));
                        }
                        else
                        {
                            throw new Exception("序号不在顺序范围之内,无法使用序列化方法,请检查InternalID是否连续");
                        }
                    }
                    //BeginInvokeUpdateHistory(fram.GetAPDUDataArray(), fram.FrameArray.Length, "测试");
                    SendTypeIMessage(TypeIdentification.P_ME_NC_1, protectsetAPDU);
                    MakeLogMessage(sender, "定值选择" + protectsetAPDU.ToString(), LogType.ProtectSetpoint);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "DownloadProtectSetSelect_Click");
            }
        }
Пример #2
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, QualifyCommandSet qos)
        {
            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);
            //设置命令限定词,最后一字节
            ASDU.InformationObject[ASDU.InformationObject.Length - 1] = qos.QOS;
            var apduLen = 4 + ASDU.Length; //控制域长度4 + ASDU长度

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

            TimeStamp = DateTime.Now;
        }