Esempio n. 1
0
 public static string GetDeviceState(HeadInfo.机头信息 head)
 {
     if (head.状态.在线状态)
     {
         if (head.状态.锁定机头)
         {
             return(DeviceStatusEnum.锁定.ToDescription());
         }
         if (head.状态.出币机或存币机正在数币)
         {
             return(DeviceStatusEnum.工作中.ToDescription());
         }
         if (head.状态.读币器故障)
         {
             return(DeviceStatusEnum.报警.ToDescription());
         }
         return(DeviceStatusEnum.在线.ToDescription());
     }
     return(DeviceStatusEnum.离线.ToDescription());
 }
Esempio n. 2
0
        static void server_OnChangeState(Recv机头网络状态报告 cmd)
        {
            string routeToken  = cmd.RecvData.routeAddress;
            string headAddress = cmd.机头地址;
            int?   deviceId    = null;

            //获取控制器实体
            Base_DeviceInfo  router      = DeviceBusiness.GetDeviceModel(routeToken);
            Data_MerchDevice merchDevice = MerchDeviceBusiness.GetMerchModel(router.ID, headAddress);

            if (merchDevice != null)
            {
                deviceId = merchDevice.DeviceID;
            }

            if (deviceId == null)
            {
                Data_MerchSegment merchSegment = MerchSegmentBusiness.GetMerchSegmentModel(router.ID, headAddress);
                if (merchSegment == null)
                {
                    deviceId = merchDevice.DeviceID;
                }
            }

            if (deviceId != null)
            {
                Base_DeviceInfo device = DeviceBusiness.GetDeviceModelById((int)deviceId);
                if (device != null)
                {
                    List <HeadInfo.机头信息> headList = HeadInfo.GetAllHead();
                    HeadInfo.机头信息        head     = headList.FirstOrDefault(t => t.令牌 == device.Token);
                    string strDeviceState         = GetDeviceState(head);

                    string state = DeviceStatusBusiness.GetDeviceState(device.Token);
                    if (state != strDeviceState)
                    {
                        DeviceStatusBusiness.SetDeviceState(device.Token, strDeviceState);
                    }
                }
            }
        }
Esempio n. 3
0
        private List <DeviceModel> GetDeviceList(List <DeviceModel> currList)
        {
            List <DeviceModel>   list     = new List <DeviceModel>();
            List <HeadInfo.机头信息> headList = HeadInfo.GetAllHead();

            foreach (var item in currList)
            {
                HeadInfo.机头信息 head = headList.FirstOrDefault(t => t.令牌 == item.DeviceToken);
                DeviceModel   info = new DeviceModel();
                info.RouterToken = item.RouterToken;
                info.DeviceId    = item.DeviceId;
                info.DeviceToken = item.DeviceToken;
                info.DeviceName  = item.DeviceName;
                info.DeviceType  = item.DeviceType;
                info.State       = UDPServer.GetDeviceState(head);
                info.SN          = item.SN;
                info.HeadAddress = item.HeadAddress;
                list.Add(info);
            }
            return(list);
        }