public static bool SendAGVCmdEnable = true; //允许发送AGV指令的允许位,收到消息后置为flase,将指令表中的通信状态改过来后置为true。 public static void ExecuteAGVCmd(object obj) //执行AGV指令表(不断查询数据库AGV指令表中有没有未发送给AGV的指令,然后将其发送出去) { DataBaseHandle db = obj as DataBaseHandle; SqlConnection con = new SqlConnection(); while (RunExecuteAGVCmdThread) { if ((ExecuteFlag == true || HandAndDownFlag == true) && SendAGVCmdEnable == true) //开始执行订单 { db.SelectAGVCmd(con); //查询AGV需要发送的指令 } Thread.Sleep(TimeSpan.FromSeconds(3)); //3s查询一次 } RunExecuteAGVCmdThread = true; }