Example #1
0
        /// <summary>
        /// 仅适用于分站的电源箱解码
        /// <param name="data">传入回发的Buffer</param>
        /// <param name="protocol">回发的对象</param>
        /// <param name="startIndex">分站号的索引位置</param>
        /// <param name="deviceCommunicationType">分站的类型</param>
        /// <param name="point">分站的测点号</param>
        /// </summary>
        public void HandleBatteryRealData(byte[] data, MasProtocol protocol, ushort startIndex, byte deviceCommunicationType, string point)
        {
            QueryBatteryRealDataResponse realData    = new QueryBatteryRealDataResponse();
            BatteryRealDataItem          BatteryItem = new BatteryRealDataItem();

            protocol.ProtocolType         = ProtocolType.QueryBatteryRealDataResponse;
            realData.BatteryDateTime      = DateTime.Now;
            realData.DeviceCode           = point;
            realData.BatteryRealDataItems = new List <BatteryRealDataItem>();

            BatteryItem.DeviceProperty = ItemDevProperty.Substation;

            Cache.HandleDeviceBattery(data, (byte)(startIndex + 5), BatteryItem);//解析电源箱的数据  111

            realData.BatteryRealDataItems.Add(BatteryItem);
            protocol.Protocol = realData;
        }
Example #2
0
        /// <summary>
        /// 表示交换机电源的确认
        /// </summary>
        /// <param name="net"></param>
        /// <param name="data"></param>
        private void SendBatteryAffirmToCenter(NetworkDeviceInfo net, byte[] data)
        {
            //7F-03-2A-00-00-01-8A-01-8A-01-8A-01-8A-01-8A-01-8A-00-00-00-00-09-41-00-40-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-E8-07

            ProtocolDataCreatedEventArgs upData = new ProtocolDataCreatedEventArgs();
            QueryBatteryRealDataResponse cData  = new QueryBatteryRealDataResponse();//获取交换机电源箱的应答数据;

            //需要反过来找一下,串口服务器对应的交换机IP地址。
            upData.DeviceCode          = net.IP;
            upData.DriverCode          = this.DriverCode;
            upData.MasProtocol         = new MasProtocol(SystemType.Security, DirectionType.Up, ProtocolType.QueryBatteryRealDataResponse);
            cData.DeviceCode           = net.IP;
            cData.DeviceProperty       = ItemDevProperty.Switches;
            cData.BatteryRealDataItems = new List <BatteryRealDataItem>();
            BatteryRealDataItem BatteryItem = new BatteryRealDataItem();

            cData.BatteryDateTime = DateTime.Now;
            Cache.HandleDeviceBattery(data, 5, BatteryItem, true);//解析电源箱的数据
            cData.BatteryRealDataItems.Add(BatteryItem);
            upData.MasProtocol.Protocol = cData;
            OnProtocolData(upData);
        }