示例#1
0
        /// <summary>
        /// 发送任务
        /// </summary>
        /// <param name="tr"></param>
        /// <param name="fl"></param>
        public int sendTask(TaskRecord tr, ForkLift fl)
        {
            string cmd = null;

            int result = 0;

            Console.WriteLine("ready to send task: " + tr.singleTask.taskName + "forklist stat:" + fl.taskStep + "forklift finished:" + fl.finishStatus);
            cmd = "cmd=set task by name;name=" + tr.taskRecordName; //发送命令格式,如果有多个对应值用;隔开,如果后面没有命令了,不需要再加;号
            Console.WriteLine("send msg :" + cmd + "to " + fl.forklift_number);

            lock (fl.tcpClient.clientLock)
            {
                try
                {
                    fl.tcpClient.SendMessage(cmd);  //确保发送成功

                    tr.taskRecordStat      = TASKSTAT_T.TASK_SEND;
                    tr.singleTask.taskStat = TASKSTAT_T.TASK_SEND;
                    AGVInitialize.getInitialize().getMainFrm().updateFrm(); //设置更新界面
                    tr.forkLift    = fl;
                    fl.taskStep    = ForkLift.TASK_STEP.TASK_SENDED;
                    fl.currentTask = tr.singleTask.taskText;
                    AGVInitialize.getInitialize().getDBConnect().UpdateTaskRecord(tr);
                    AGVInitialize.getInitialize().getDBConnect().updateForkLift(fl);  //更新车子状态
                }catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    AGVLog.WriteError("发送" + tr.singleTask.taskText + " 任务到" + fl.forklift_number + "号车 失败", new StackFrame(true));
                    result = -1;
                }
            }

            AGVLog.WriteError("发送" + tr.singleTask.taskText + " 任务到" + fl.forklift_number + "号车 成功", new StackFrame(true));
            return(result);
        }
示例#2
0
        public bool setForkCtrl(ForkLift fl, int ctrl)
        {
            string cmd   = "cmd=pause;pauseStat=" + ctrl;
            int    times = 0;

            while (times < 3)
            {
                try
                {
                    fl.tcpClient.SendMessage(cmd);
                    break;
                }
                catch
                {
                    Message message = new Message();
                    message.setMessageType(AGVMESSAGE_TYPE_T.AGVMESSAGE_SENDPAUSE_ERR);
                    message.setMessageStr("发送中断错误");

                    AGVInitialize.getInitialize().getAGVMessage().setMessage(message);
                }

                times++;
            }


            Console.WriteLine("setForkCtrl forklift " + fl.id + "cmd = " + cmd);
            AGVLog.WriteInfo("setForkCtrl forklift " + fl.id + "cmd = " + cmd, new StackFrame(true));
            return(true);
        }
示例#3
0
        public List <TaskRecord> SelectTaskRecordBySingleTaskID(int singleTaskID)
        {
            string sql = "select * from taskrecord where singleTask = " + singleTaskID + " order by taskRecordStat desc, taskLevel desc";
            //检测当前车子可用的车子数量,如果有两台可弹出用的车子,正常运行,如果只有一台可用的车子,弹出提示,请工作人员确认,如果无可用的车子,直接退出程序
            //确认的逻辑,连接车子ip,如果可以正常连接车子ip,则表示车子可用
            List <TaskRecord> taskRecordList = AGVInitialize.getInitialize().getDBConnect().SelectTaskRecordBySql(sql);

            return(taskRecordList);
        }
示例#4
0
        /// <summary>
        /// 车子查询后,不能重新查询,整个运行周期只维护一个Forklift列表
        /// </summary>
        /// <returns></returns>
        public List <ForkLift> getForkLiftList()
        {
            if (forkLiftList == null)
            {
                forkLiftList = AGVInitialize.getInitialize().getDBConnect().SelectForkList();
            }

            return(forkLiftList);
        }
示例#5
0
        public List <User> getUsers()
        {
            if (userList == null)
            {
                userList = AGVInitialize.getInitialize().getDBConnect().SelectUserList();
            }

            return(userList);
        }
示例#6
0
        private void handleLiftComException()
        {
            Message message = new Message();

            message.setMessageType(AGVMESSAGE_TYPE_T.AGVMESSAGE_LIFT_COM);
            message.setMessageStr("升降机PLC端口异常,请检查,当前处于系统暂停");
            AGVInitialize.getInitialize().getAGVMessage().setMessage(message);  //发送消息


            isStop = true; //结束串口读取线程
        }
示例#7
0
        public void addAllTaskRecord()
        {
            List <SingleTask> singleTaskList = AGVInitialize.getInitialize().getSingleTaskList();  //获取所有的任务

            foreach (SingleTask st in singleTaskList)
            {
                if (st.taskType == TASKTYPE_T.TASK_TYPE_UP_DILIVERY)
                {
                    TaskRecord tr = new TaskRecord();
                    tr.singleTask     = st;
                    tr.taskRecordName = st.taskName;
                    tr.taskRecordStat = TASKSTAT_T.TASK_READY_SEND;
                    AGVInitialize.getInitialize().getSchedule().addTaskRecord(tr);
                }
            }
        }
示例#8
0
        public void deleteCacheTaskRecord()
        {
            string sql = "truncate table taskrecord";

            AGVInitialize.getInitialize().getDBConnect().DeleteWithSql(sql);
        }