public void updateAlarm(int alarm)
        {
            Console.WriteLine(forkLift.forklift_number + "号车 alarm = " + alarm +
                              "gAlarm =" + forkLift.gAlarm);
            if (alarm == 0)
            {
                forkLift.gAlarm++;
            }
            else if (alarm == 1)
            {
                forkLift.gAlarm = 0;
            }
            Console.WriteLine(forkLift.forklift_number + "号车 alarm = " + alarm + "gAlarm =" + forkLift.gAlarm);

            if (forkLift.gAlarm > AGVConstant.AGVALARM_TIME)              //防撞信号 检测超过12次,弹出报警提示
            {
                string msg = forkLift.forklift_number + "触发防撞,暂停所有AGV";
                AGVLog.WriteError(msg, new StackFrame(true));
                AGVMessage message = new AGVMessage();
                message.setMessageType(AGVMessageHandler_TYPE_T.AGVMessageHandler_AGV_ALARM);
                message.setMessageStr(msg);
                TaskexeDao.getDao().InsertTaskexePause("");
                TaskexeDao.getDao().InsertTaskexeSysInfo(msg);
                forkLift.gAlarm = 0;
                AGVMessageHandler.getMessageHandler().setMessage(message);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 记录日志,优先级低
        /// </summary>
        /// <param name="s">日志能容</param>
        public static void WriteConnectInfo(string content, StackFrame sf)
        {
            string ct = sf.GetMethod().Name + ": ";

            TaskexeDao.getDao().InsertTaskexeSysInfo(content);
            WriteConnectLogs("<INFO>", ct + content);
        }
        public TaskexeBean getAndRemoveNextTaskexeBean()
        {
            TaskexeBean taskexeBean = getTaskexeTaskList().Dequeue();

            if (!"Send".Equals(taskexeBean.getOpflag()))
            {
                TaskexeDao.getDao().sendTaskexeBean(taskexeBean);
            }
            return(taskexeBean);
        }
        public bool isSystemRunning()
        {
            List <TaskexeBean> taskexeBeanList = TaskexeDao.getDao().getTaskexeStartOrPauseList();

            if (taskexeBeanList == null || taskexeBeanList.Count <= 0)
            {
                return(true);
            }
            return("sysContinue".Equals(taskexeBeanList[0].getTaskid()));
        }
        public Queue <TaskexeBean> getTaskexeTaskList()
        {
            if (!(taskexeBeanQueue == null || taskexeBeanQueue.Count <= 0))
            {
                return(taskexeBeanQueue);
            }

            List <TaskexeBean> taskexeBeanList = TaskexeDao.getDao().getTaskexeTaskList();

            foreach (TaskexeBean taskexeBean in taskexeBeanList)
            {
                taskexeBeanQueue.Enqueue(taskexeBean);
            }

            return(taskexeBeanQueue);
        }
        public TaskexeBean getNextTaskexeBean()
        {
            List <TaskexeBean> taskexeBeanList = TaskexeDao.getDao().getTaskexeTaskList();

            if (taskexeBeanList == null || taskexeBeanList.Count <= 0)
            {
                return(null);
            }
            TaskexeBean taskexeBean = taskexeBeanList[0];

            AGVLog.WriteSendInfo("下一个执行的任务ID:" + taskexeBean.getTaskid(), new StackFrame(true));
            if (!"Send".Equals(taskexeBean.getOpflag()))
            {
                TaskexeDao.getDao().sendTaskexeBean(taskexeBean);
            }
            return(taskexeBean);
        }
Ejemplo n.º 7
0
 private static void WriteLogsTo(string type, string content, string filepath)
 {
     try {
         lock (obj) {
             if (File.Exists(filepath))
             {
                 StreamWriter sw = new StreamWriter(filepath, true, System.Text.Encoding.Default);
                 sw.WriteLine();
                 sw.WriteLine(DateTime.Now + " " + type);
                 sw.WriteLine("      " + content);
                 sw.Close();
             }
         }
     } catch (Exception ex) {
         MessageBox.Show(filepath + "文件被占用,无法更新日志,请检查后重启AGV服务程序!");
         TaskexeDao.getDao().InsertTaskexeSysInfo(filepath + "文件被占用,无法更新日志,请检查后重启AGV服务程序!");
     }
 }
        public void sendCommand()
        {
            AGVLog.WriteSendInfo("开始处理!", new StackFrame(true));
            TaskexeBean taskexeBean = TaskexeService.getInstance().getNextTaskexeBean();

            if (taskexeBean == null)
            {
                return;
            }
            string     cmd        = "cmd=set task by name;name=" + taskexeBean.getTaskid() + ".xml";
            SingleTask singleTask = AGVCacheData.getSingleTaskByID(taskexeBean.getTaskid());

            sendContinueCommand();

            Thread.Sleep(1000);

            int i = -2;

            if ("1".Equals(singleTask.getAllocOpType()))
            {
                while (string.IsNullOrEmpty(latestMsgFromClient) || latestMsgFromClient.IndexOf("task_isfinished=") < 0 || !"0".Equals(latestMsgFromClient.Substring(latestMsgFromClient.IndexOf("task_isfinished=") + "task_isfinished=".Length, 1)))
                {
                    send(cmd);
                    AGVLog.WriteSendInfo("发送命令:" + cmd, new StackFrame(true));
                    Thread.Sleep(3000);
                    if (!AGVEngine.getInstance().isAgvReady())
                    {
                        latestMsgFromClient = "task_isfinished=" + (i++) + ";";
                    }
                }
            }

            while (true)
            {
                AGVLog.WriteSendInfo("判断任务" + taskexeBean.getTaskid() + "是否Over!", new StackFrame(true));
                if ("Over".Equals(TaskexeDao.getDao().selectTaskexeByUuid(taskexeBean.getUuid()).getOpflag()))
                {
                    break;
                }
                Thread.Sleep(5000);
            }
            Thread.Sleep(1000);
        }
Ejemplo n.º 9
0
        public void agvInit()
        {
            if (FormController.isNeedLogin())
            {
                FormController.getFormController().getLoginFrm().ShowDialog();
            }

            TaskexeDao.getDao().InsertTaskexeSysInfo("AGV通讯服务程序启动!");
            setForkliftStateFirst();

            handleCheckRunning(checkRunning());

            if (isNeedElevator)
            {
                ElevatorFactory.getElevator().startReadSerialPortThread();
            }

            if (isNeedAGVSocketServer)
            {
                AGVSocketServer.getSocketServer().StartAccept();
            }

            if (isNeedSchedule)
            {
                ScheduleFactory.getSchedule().startShedule();
            }

            if (isNeedTaskexe)
            {
                TaskexeService.getInstance().start();
            }

            AGVMessageHandler.getMessageHandler().StartHandleMessage();

            if (isNeedMain)
            {
                FormController.getFormController().getMainFrm().ShowDialog();
            }
            else
            {
                FormController.getFormController().getInfoFrm().ShowDialog();
            }
        }
Ejemplo n.º 10
0
 public void exitAGVServer()
 {
     TaskexeDao.getDao().InsertTaskexeSysInfo("AGV通讯服务程序已关闭,开启前无法与AGV通讯!");
     System.Environment.Exit(0);
 }