Пример #1
0
        public void Receive(DataPackage pkgData)
        {
            //收到上报参数
            ReportedParameterItem reportParameterItem = new ReportedParameterItem();

            byte[] dataBuffer = pkgData.PureData;

            using (MemoryStream ms = new MemoryStream(dataBuffer))
            {
                using (BinaryReader br = new BinaryReader(ms))
                {
                    reportParameterItem.StateInterval = br.ReadInt16();
                    reportParameterItem.ThuEnable = br.ReadByte();
                    reportParameterItem.TempInterval = br.ReadByte();
                    reportParameterItem.HumiInterval = br.ReadByte();
                    reportParameterItem.GPIOEnable = br.ReadByte();
                    //br.ReadBytes(6);
                }
            }

            if (OnDataChanged != null)
            {
                DataHandlerEventArgs eventArgs = new DataHandlerEventArgs();
                eventArgs.CMD_ID = pkgData.CtrlHead.CMD_ID;
                eventArgs.Value = reportParameterItem;
                OnDataChanged(this, eventArgs);
            }
        }
Пример #2
0
        public void Receive(DataPackage pkgData)
        {
            //收到系统信息【采集器→主机】

            DeviceStatusItem deviceStatus = new DeviceStatusItem();

            byte[] dataBuffer = pkgData.PureData;

            using (MemoryStream ms = new MemoryStream(dataBuffer))
            {
                using (BinaryReader br = new BinaryReader(ms))
                {
                    deviceStatus.Time.Buffer = br.ReadBytes(7);
                    deviceStatus.TH.Buffer = br.ReadBytes(4);
                    deviceStatus.Status_D0 = br.ReadByte();
                    deviceStatus.Status_D1 = br.ReadByte();
                    deviceStatus.Status_D2 = br.ReadByte();
                    deviceStatus.Status_D3 = br.ReadByte();
                    deviceStatus.Status_D4 = br.ReadByte();

                }
            }

            if (OnDataChanged != null)
            {
                DataHandlerEventArgs eventArgs = new DataHandlerEventArgs();
                eventArgs.CMD_ID = pkgData.CtrlHead.CMD_ID;
                eventArgs.Value = deviceStatus;
                OnDataChanged(this, eventArgs);
            }
        }
Пример #3
0
        public void Receive(DataPackage pkgData)
        {
            //CE_ID=newID(当 newID=0 时,返回现有 ID),D_LEN=0【采集器→主机】

            ceInfo.CE_ID = pkgData.CtrlHead.CE_ID;  //更新当前CE_ID

            if (OnDataChanged != null)
            {
                DataHandlerEventArgs eventArgs = new DataHandlerEventArgs();
                eventArgs.CMD_ID = pkgData.CtrlHead.CMD_ID;
                eventArgs.Value = pkgData.CtrlHead.CE_ID;
                OnDataChanged(this, eventArgs);
            }
        }
Пример #4
0
        public void OnDataChanged(object sender, DataHandlerEventArgs e)
        {
            try
            {
                Client c = sender as Client;

                if (client == null || !client.Equals(c)) client = c;

                if (e.CMD_ID == HCCommand.EXTEND_COMMAND)
                {
                    //扩展命令
                    ProExtend(e);
                }

            }
            catch (System.Exception ex)
            {

            }
        }
Пример #5
0
        public void OnDataChanged(object sender, DataHandlerEventArgs e)
        {
            if (e.CurrentMode == RunMode.Monitor)
            {
                //更新客户端设备的状态信息
                if (e.CMD_ID == HCCommand.QUERY_DEVICE_STATUS)
                {
                    this.DeviceStatus = e.Value as DeviceStatusItem;
                    Console.WriteLine(DateTime.Now);
                }
                else if (e.CMD_ID == HCCommand.QUERY_VERSION)
                {
                    this.Version = e.Value as VersionItem;
                }
            }

            //数据存储
            dataSaveMan.OnDataChanged(sender, e);

            //if (e.CurrentMode == RunMode.Monitor)
            //{
            //    Client client = sender as Client;
            //    if (client != null && clientDict.ContainsKey(client.Name))
            //    {
            //        clientDict[client.Name].Client_OnDataChanged(sender, e);

            //        //更新客户端设备的状态信息
            //        if (e.CMD_ID == HCBase.HCCommand.QUERY_DEVICE_STATUS)
            //        {
            //            clientDict[client.Name].DeviceStatus = e.Value as DeviceStatusItem;
            //            Console.WriteLine(DateTime.Now);
            //        }
            //        else if (e.CMD_ID == HCBase.HCCommand.QUERY_VERSION)
            //        {
            //            clientDict[client.Name].Version = e.Value as VersionItem;
            //        }
            //    }
            //}
        }
Пример #6
0
        void ProExtend(DataHandlerEventArgs e)
        {
            //收到扩展命令
            if (e.EX_CMD_ID == HCCommand.EX_TURNOUT_FLIP)
            {
                var item = e.Value as TurnoutFlipItem;
                ProTurnoutAction(item);

            }
            else if (e.EX_CMD_ID == HCCommand.EX_UP_OIL_PRESSURE)
            {
                var item = e.Value as OilPressureItem;
                if (item != null)
                {

                }
            }
            else if (e.EX_CMD_ID == HCCommand.EX_UP_OIL_DATA)
            {
                var item = e.Value as OilDataItem;
                if (item != null)
                {

                }
            }
            else if (e.EX_CMD_ID == HCCommand.EX_UP_VEHICLE_SIGNAL)
            {
                var item = e.Value as VehicleSignalItem;
                if (item != null)
                {

                }
            }
            else if (e.EX_CMD_ID == HCCommand.EX_GAP_TRIGGER)
            {

            }
        }
Пример #7
0
 void clientMan_OnDataChanged(object sender, DataHandlerEventArgs e)
 {
 }
Пример #8
0
        void ProExtend(DataHandlerEventArgs e)
        {
            if (e.EX_CMD_ID == HCBase.HCCommand.EX_COLLECTOR_QUERY_STATUS)
            {
                //查询采集状态
                var item = e.Value as CollectorWorkStatusItem;
                if (item != null)
                {

                }

            }
            else if (e.EX_CMD_ID == HCBase.HCCommand.EX_COLLECTOR_QUERY_VALUE)
            {
                var item = e.Value as CollectorValueItem;
                if (item != null)
                {

                }

            }
        }
Пример #9
0
        void devClient_OnDataChanged(object sender, DataHandlerEventArgs e)
        {
            //收到事件
            if (e.CurrentMode == RunMode.Monitor)
            {
                Client client = sender as Client;
                if (client != null)
                {
                    if (e.CMD_ID == HCBase.HCCommand.EXTEND_COMMAND)
                    {
                        //扩展命令
                        ProExtend(e);
                    }
                    else if (e.CMD_ID == HCBase.HCCommand.QUERY_DEVICE_STATUS)
                    {
                        //设备状态信息
                        UpdateDeviceStatus(e.Value as DeviceStatusItem);
                    }
                    else if (e.CMD_ID == HCBase.HCCommand.QUERY_VERSION)
                    {
                        //版本
                        var version = e.Value as VersionItem;
                    }
                    else if (e.CMD_ID == HCBase.HCCommand.REPORTED_PARAMETER)
                    {
                        //上报参数
                        var reportParamItem = e.Value as ReportedParameterItem;
                        ShowReportParam(reportParamItem);
                    }

                }
            }
            else
            {
                if (e.CurrentMode == RunMode.Image)
                {
                    //图像
                    var eArgs = e as FileHandlerEventArgs;
                    ProImage(eArgs);
                }
                else if (e.CurrentMode == RunMode.Video)
                {
                    //录像
                    var eArgs = e as FileHandlerEventArgs;
                    ProVideo(eArgs);
                }
                else if (e.CurrentMode == RunMode.Stream)
                {
                    //实时码流
                    var eArgs = e as StreamHandlerEventArgs;
                    ProStream(eArgs);
                }
                else if (e.CurrentMode == RunMode.FileOP)
                {
                    //读取待上送扳动过程油压数据记录
                    var eArgs = e as FileHandlerEventArgs;
                    ProFlipOilPressure(eArgs);
                }
                else if (e.CurrentMode == RunMode.FileFA)
                {
                    //读取待上送扳动过程加速度数据记录
                    var eArgs = e as FileHandlerEventArgs;
                    ProFlipAcceleration(eArgs);
                }
                else if (e.CurrentMode == RunMode.FileVA)
                {
                    //读取待上送过车过程加速度数据记录
                    var eArgs = e as FileHandlerEventArgs;
                    ProVehicleAcceleration(eArgs);
                }

            }
        }
Пример #10
0
        public void Receive(DataPackage pkgData)
        {
            //收到版本信息【采集器→主机】

            VersionItem verItem = new VersionItem();

            byte[] dataBuffer = pkgData.PureData;
            using (MemoryStream ms = new MemoryStream(dataBuffer))
            {
                using (BinaryReader br = new BinaryReader(ms))
                {
                    byte[] readBytes = br.ReadBytes(64);
                    verItem.SN = Encoding.Default.GetString(readBytes).Trim(new char[]{'\0'});     //序列号

                    readBytes = br.ReadBytes(32);
                    verItem.Ver = Encoding.Default.GetString(readBytes).Trim(new char[] { '\0' });    //firmware 版本

                }
            }

            if (OnDataChanged != null)
            {
                DataHandlerEventArgs eventArgs = new DataHandlerEventArgs();
                eventArgs.CMD_ID = pkgData.CtrlHead.CMD_ID;
                eventArgs.Value = verItem;
                OnDataChanged(this, eventArgs);
            }
        }
Пример #11
0
        public void Receive(DataPackage pkgData)
        {
            //收到系统信息【采集器→主机】
            SysInfoItem sysInfo = new SysInfoItem();

            byte[] dataBuffer = pkgData.PureData;
            using (MemoryStream ms = new MemoryStream(dataBuffer))
            {
                using (BinaryReader br = new BinaryReader(ms))
                {
                    byte[] readBytes = br.ReadBytes(32);
                    sysInfo.VenderCode = Encoding.Default.GetString(readBytes);     //厂商代码

                    readBytes = br.ReadBytes(32);
                    sysInfo.VenderName = Encoding.Default.GetString(readBytes);     //厂商名称

                    readBytes = br.ReadBytes(32);
                    sysInfo.ProductType = Encoding.Default.GetString(readBytes);    //产品型号

                    readBytes = br.ReadBytes(32);
                    sysInfo.HwVersion = Encoding.Default.GetString(readBytes);      //硬件版本

                    readBytes = br.ReadBytes(32);
                    sysInfo.LoaderVersion = Encoding.Default.GetString(readBytes);  //Loader 版本

                    readBytes = br.ReadBytes(32);
                    sysInfo.LoaderCompileTime = Encoding.Default.GetString(readBytes);  //Loader 编译时间

                    readBytes = br.ReadBytes(64);
                    sysInfo.ProductSN = Encoding.Default.GetString(readBytes);    //产品序列号

                    readBytes = br.ReadBytes(6);
                    sysInfo.MacAddr = Utils.ConvertTools.ToHexString(readBytes, "-");      //MAC 地址

                    short value = br.ReadInt16();
                    sysInfo.CPUTFrequency = string.Format("{0} MHz", value);      //CPU 主频 MHz

                    value = br.ReadInt16();
                    sysInfo.DDRFrequency = string.Format("{0} MHz", value);       //DDR 主频 MHz
                }
            }

            if (OnDataChanged != null)
            {
                DataHandlerEventArgs eventArgs = new DataHandlerEventArgs();
                eventArgs.CMD_ID = pkgData.CtrlHead.CMD_ID;
                eventArgs.Value = sysInfo;
                OnDataChanged(this, eventArgs);
            }
        }
Пример #12
0
        void OnDataChangeAction(DataPackage pkgData, object value)
        {
            byte[] dataBuffer = pkgData.PureData;
            uint cmd = dataBuffer[0];

            if (OnDataChanged != null)
            {
                DataHandlerEventArgs eventArgs = new DataHandlerEventArgs();
                eventArgs.CMD_ID = pkgData.CtrlHead.CMD_ID;
                eventArgs.EX_CMD_ID = cmd;
                eventArgs.Value = value;
                OnDataChanged(this, eventArgs);
            }
        }