Esempio n. 1
0
        /// <summary>
        /// 客户端返回消息解码
        /// </summary>
        /// <param name="buff"></param>
        /// <returns></returns>
        private NetStructure.HeartBreak DecodeData(byte[] buff)
        {
            NetStructure.HeartBreak info = new NetStructure.HeartBreak();
            byte[] tempData = buff;
            info.MachineId   = ConvertHelper.BytesToInt16(tempData, true);
            info.ChannelInfo = tempData[2];

            return(info);
        }
Esempio n. 2
0
        /// <summary>
        /// 内外部数据转换
        /// </summary>
        /// <param name="info"></param>
        /// <param name="machine"></param>
        /// <returns></returns>
        private HeartBreak exchangeData(NetStructure.HeartBreak info, Machines machine)
        {
            int    channel     = info.ChannelInfo;
            int    machineId   = machine.ID;
            string machineName = machine.Name;

            return(new HeartBreak()
            {
                DateCreate = DateTime.Now,
                ChannelInfo = channel,
                MachineId = machineId,
                MachineName = machineName
            });
        }
Esempio n. 3
0
        public void HandlerTest()
        {
            DbHandler db = new DbHandler();

            NetStructure.HeartBreak outInfo = new NetStructure.HeartBreak()
            {
                MachineId   = 19,
                ChannelInfo = 6
            };
            Machines   machine   = db.SelectMachine(outInfo.MachineId);
            HeartBreak innerInfo = this.exchangeData(outInfo, machine);

            //记录原始数据
            db.InsertHeartBreak(innerInfo);
            ////记录设备状态
            //RefreshOnlineInfo(machine);
        }
Esempio n. 4
0
        public byte[] HandlerClientData(byte[] buff)
        {
            DbHandler db = new DbHandler();

            NetStructure.HeartBreak outInfo = this.DecodeData(buff);
            Machines machine = db.SelectMachine(outInfo.MachineId);

            if (machine == null)
            {
                throw new Exception(outInfo.MachineId.ToString());
            }
            //记录设备状态
            RefreshOnlineInfo(machine);
            ////记录原始数据
            //HeartBreak innerInfo = this.exchangeData(outInfo, machine);
            //db.InsertHeartBreak(innerInfo);

            byte[] resp = { };
            return(resp);
        }