Пример #1
0
 public Monitor(HZKController hzkController)
 {
     // 设备控制类
     this.Controller = hzkController;
 }
Пример #2
0
 public CloseDoorCommand(HZKController hzkController, int devNo)
 {
     controller = hzkController;
     this.devNo = devNo;
 }
Пример #3
0
        /// <summary>
        /// 设备监控线程
        /// </summary>
        /// <param name="obj"></param>
        public void MonitorWorkingThread(object obj)
        {
            int idx = 0;
            int curlayer = 0, curstat = 0;

            HZKController controller = obj as HZKController;

            while (true)
            {
                // 轮询监控列表里的各个设备
                try
                {
                    // 查询当前状态
                    controller.Query(monitorDevList[idx].devNo, ref curlayer, ref curstat);

                    // 节点错误计数清0
                    monitorDevList[idx].errorCount = 0;

                    // 当前设备门电机和主电机都没有动作
                    if ((curstat & 0x03) == 0x00)
                    {
                        monitorDevList[idx].noRunCount++;
                        return;
                    }
                    else
                    {
                        // 系统非运行状态清0
                        monitorDevList[idx].noRunCount = 0;
                    }

                    // 显示设备柜门状态信息
                    if ((curstat & STATUS_DMOTOR_RUNNING) == STATUS_DMOTOR_RUNNING)     // 门电机运行
                    {
                        RaiseOnDeviceMonitorMessage(string.Format("提示:{0}号回转库开关门运行中!", monitorDevList[idx].devNo));
                    }

                    // 显示设备走层状态信息
                    if ((curstat & STATUS_MMOTOR_RUNNING) == STATUS_MMOTOR_RUNNING)     // 主电机运行
                    {
                        RaiseOnDeviceMonitorMessage(string.Format("提示:{0}号回转库走层运行中,当前层为第{1}层!", monitorDevList[idx].devNo, curlayer));
                        RaiseOnDeviceLayerInfo(curlayer);
                    }
                }
                catch (TimeoutException)
                {
                    // 与节点通信发生超时错误
                    RaiseOnDeviceMonitorMessage(string.Format("{0}号设备通信超时无响应!", monitorDevList[idx].devNo));
                    monitorDevList[idx].errorCount++;
                }
                catch (Exception)
                {
                    // 与节点通信发生无法收到正确回帧错误
                    RaiseOnDeviceMonitorMessage(string.Format("{0}号设备通信收到错误回帧!", monitorDevList[idx].devNo));
                    monitorDevList[idx].errorCount++;
                }
                finally
                {
                    // 本设备移除出监控队列时,检索号不能自加;
                    if (monitorDevList[idx].errorCount == 3)
                    {
                        // 与节点通信发生无法收到正确回帧错误
                        RaiseOnDeviceMonitorMessage(string.Format("{0}号设备通信错误,停止监控!", monitorDevList[idx].devNo));
                        // 从监控队列中移除设备
                        monitorDevList.Remove(monitorDevList[idx]);
                    }
                    else if (monitorDevList[idx].noRunCount == 3)
                    {
                        // 设备停止运行
                        RaiseOnDeviceMonitorMessage(string.Format("{0}号设备不在运行,停止监控!", monitorDevList[idx].devNo));
                        // 从监控队列中移除设备
                        monitorDevList.Remove(monitorDevList[idx]);
                    }
                    else
                    {
                        // 本设备没有移除操作时,检索号才能自加,查询下一个设备
                        idx++;
                    }

                    // 回到第一个设备进行监控
                    if (idx >= monitorDevList.Count)
                    {
                        idx = 0;
                    }
                }

                // 休眠400ms
                Thread.Sleep(400);
            }
        }
Пример #4
0
 public RunCommand(HZKController hzkController, int devNo)
 {
     controller = hzkController;
     this.devNo = devNo;
 }