private void ForkliftManualCtrlToolStripMenuItem_Click(object sender, EventArgs e) { AGVManualCtrlForm amcForm = AGVInitialize.getInitialize().getAGVManualCtrlForm(); amcForm.updateAGVMCForm(); amcForm.ShowDialog(); }
private void cancelItemClick(object sender, EventArgs e) { MenuItem item = (MenuItem)sender; TaskRecord tr = (TaskRecord)selectedButton.getBindValue(); if (tr != null && tr.taskRecordStat == TASKSTAT_T.TASK_READY_SEND) { selectedButton.BackColor = Color.White; AGVInitialize.getInitialize().getSchedule().removeTaskRecord(tr.singleTask, TASKSTAT_T.TASK_READY_SEND); selectedButton.bindValue(null); } /* * if (item.Name.Equals("cancelTaskItem")) * { * * st = (SingleTask)this.SingleTaskDTG.CurrentCell.Value; * } * if (st != null) * { * st.taskStat = TASKSTAT_T.TASK_NOT_ASSIGN; * this.SingleTaskDTG.CurrentCell.Style.BackColor = Color.White; * AGVInitialize.getInitialize().getSchedule().removeTaskRecord(st, TASKSTAT_T.TASK_READY_SEND); * }*/ }
private void mainForm_Closing(Object sender, FormClosingEventArgs e) { List <TaskRecord> trList = AGVInitialize.getInitialize().getAGVUtil().updateTaskRecordList(); DialogResult dr = System.Windows.Forms.DialogResult.No; if (trList.Count > 0) { dr = MessageBox.Show("当前有任务没完成,确认退出?", "退出提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); } else if (AGVInitialize.getInitialize().getAGVCom().getOutCommand() != util.LIFT_OUT_COMMAND_T.LIFT_OUT_COMMAND_MIN) { dr = MessageBox.Show("升降机上有任务,确认退出?", "退出提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); } else { dr = MessageBox.Show("确认退出?", "退出提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button2); } if (dr == System.Windows.Forms.DialogResult.OK) { this.Dispose(); System.Environment.Exit(0); } else if (dr == System.Windows.Forms.DialogResult.Cancel) { e.Cancel = true; } }
private void loginFrm_Closing(object sender, FormClosingEventArgs e) { this.Hide(); if (AGVInitialize.getInitialize().getCurrentUser() == null) { System.Environment.Exit(0); } }
public static AGVInitialize getInitialize() //初始化单例 { if (initialize == null) { initialize = new AGVInitialize(); } return(initialize); }
private void cancelItemClick(object sender, EventArgs e) { MenuItem item = (MenuItem)sender; TaskRecord tr = (TaskRecord)selectedButton.getBindValue(); if (tr != null && tr.taskRecordStat == TASKSTAT_T.TASK_READY_SEND) { int number = 0; try { if (selectedButton.st.taskText.Length == 2) { number = int.Parse(selectedButton.st.taskText.Substring(0, 1)); } else if (selectedButton.st.taskText.Length == 3) { number = int.Parse(selectedButton.st.taskText.Substring(0, 2)); } } catch (Exception ex) { Console.WriteLine("parse task nunber err"); } if (number % 2 == 1) //当前添加的是奇数任务,1,3,5,7,9,11号任务 { bool exist = checkDoubleTaskRecord(selectedButton.st.taskID + 1); if (exist) { DialogResult dr; dr = MessageBox.Show(number + 1 + "号任务已经缓存,确定要取消该任务?", "任务添加提示", MessageBoxButtons.YesNo); //有偶数号任务被添加时,取消前面的任务,如果前面的货没有被移走,AGV会撞到前面的货 if (dr == DialogResult.No) { Console.WriteLine(" cancelItemClick cancel "); return; } } } selectedButton.BackColor = Color.White; AGVInitialize.getInitialize().getSchedule().removeTaskRecord(tr.singleTask, TASKSTAT_T.TASK_READY_SEND); selectedButton.bindValue(null); } /* * if (item.Name.Equals("cancelTaskItem")) * { * * st = (SingleTask)this.SingleTaskDTG.CurrentCell.Value; * } * if (st != null) * { * st.taskStat = TASKSTAT_T.TASK_NOT_ASSIGN; * this.SingleTaskDTG.CurrentCell.Style.BackColor = Color.White; * AGVInitialize.getInitialize().getSchedule().removeTaskRecord(st, TASKSTAT_T.TASK_READY_SEND); * }*/ }
public List <SingleTask> getSingleTaskList() //获取供选择任务列表 { lock (lockData) { if (singleTaskList == null) { singleTaskList = AGVInitialize.getInitialize().getDBConnect().SelectSingleTaskList(); } } return(singleTaskList); }
private bool checkDoubleTaskRecord(int taskID) //检查是是否缓存了相对应的偶数任务,偶数不是指ID,是指任务号 { bool exist = false; List <TaskRecord> tsList = AGVInitialize.getInitialize().getAGVUtil().SelectReadySendTaskdBySingleTaskID(taskID); if (tsList.Count > 0) { exist = true; } return(exist); }
private void confirm_Click(object sender, EventArgs e) { DialogResult dr; string message = "确认禁用" + disableForkLiftNumber + "号车吗"; dr = MessageBox.Show(message, "禁用单车确认", MessageBoxButtons.YesNo); if (dr == System.Windows.Forms.DialogResult.Yes) { AGVInitialize.getInitialize().getAGVUtil().disableForklift(disableForkLiftNumber); this.Hide(); } }
private void initUserPanel() { User user = AGVInitialize.getInitialize().getCurrentUser(); if (user == null) { this.userLabel.Text = "无"; } else { this.userLabel.Text = user.userName; } }
private bool checkUser(string userName, string passwd) { foreach (User user in userList) { if (user.userPasswd.Equals(passwd) && user.userName.Equals(userName)) { AGVInitialize.getInitialize().setCurrentUser(user); return(true); } } return(false); }
/// <summary> /// 点击后,注意查看主界面车子是否启动,如果没有启动,可以进来再次点击启动 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void pauseCtroButton_Click(object sender, EventArgs e) { Button button = (Button)sender; if (forklift.getPauseStr().Equals("暂停")) { AGVInitialize.getInitialize().getAGVUtil().setForkCtrl(forklift, 0); forklift.shedulePause = 0; forklift.calcPositionArea(); button.Text = "运行"; button.Enabled = false; } }
private void _updateSystemPause() { bool systemPause = AGVInitialize.getInitialize().getSchedule().getSystemPause(); if (systemPause && this.systemPauseButton.Name.Equals("pause")) { setFrmEnableExcludeControPanel(false); } else if (!systemPause && this.systemPauseButton.Name.Equals("start")) { setFrmEnableExcludeControPanel(true); } }
public void setSingleTaskByTaskName(string taskName) { SingleTask st = AGVInitialize.getInitialize().getDBConnect().SelectSingleTaskByName(taskName); Console.WriteLine("TaskRecord taskName = " + taskName); if (st != null) { this.singleTask = st; } else { Console.WriteLine("TaskRecord Set Name error"); } }
private TaskRecord lookTaskRecordByTaskId(int taskID) //获取taskID对应的任务,如果任务列表中没有,则返回空 { List <TaskRecord> trList = AGVInitialize.getInitialize().getAGVUtil().updateTaskRecordList(); foreach (TaskRecord tr in trList) { if (tr.singleTask != null && tr.singleTask.taskID == taskID) { return(tr); } } return(null); }
private void handleRecordTask(string taskName, string cmd) { SingleTask st = AGVInitialize.getInitialize().getSingleTaskByTaskName(taskName); if (cmd.Equals("add")) { st.taskStat = TASKSTAT_T.TASK_SEND; AGVInitialize.getInitialize().getSchedule().addTaskRecord(TASKSTAT_T.TASK_READY_SEND, st); } else if (cmd.Equals("remove")) { AGVInitialize.getInitialize().getSchedule().removeTaskRecord(st, TASKSTAT_T.TASK_READY_SEND); } }
private void palletItemClick(object sender, EventArgs e) { MenuItem item = (MenuItem)sender; Console.WriteLine("select button name = " + selectedButton.Name); TaskRecord tr = (TaskRecord)selectedButton.getBindValue(); if (tr == null) { int number = 0; try { if (selectedButton.st.taskText.Length == 2) { number = int.Parse(selectedButton.st.taskText.Substring(0, 1)); } else if (selectedButton.st.taskText.Length == 3) { number = int.Parse(selectedButton.st.taskText.Substring(0, 2)); } }catch (Exception ex) { Console.WriteLine("parse task nunber err"); } if (number % 2 == 1) //当前添加的是奇数任务,1,3,5,7,9,11号任务 { bool exist = checkDoubleTaskRecord(selectedButton.st.taskID + 1); if (exist) { DialogResult dr; dr = MessageBox.Show(number + 1 + "号任务已经缓存,该任务不能被添加", "任务添加提示", MessageBoxButtons.OK); //有偶数号任务被添加时,前面的奇数号任务不能被添加,否则AGV会撞到前面的货 if (dr == DialogResult.OK) { Console.WriteLine(" palletItemClick invalid "); return; } } } selectedButton.BackColor = Color.LightGray; tr = new TaskRecord(); tr.singleTask = selectedButton.st; tr.taskRecordName = selectedButton.st.taskName; tr.taskRecordStat = TASKSTAT_T.TASK_READY_SEND; AGVInitialize.getInitialize().getSchedule().addTaskRecord(tr); selectedButton.bindValue(tr); } }
/* * /// <summary> * /// 插入任务记录 * /// </summary> * /// <param name="taskRecordStat"></param> * /// <param name="st"></param> * public List<TaskRecord> SelectTaskRecordBySingleTaskAndStat(int taskRecordStat, SingleTask st) * { * string sql = "select * from taskrecord where taskRecordStat = " + taskRecordStat + " and singleTask = " + st.taskID; * List<TaskRecord> taskRecordList = new List<TaskRecord>(); * * if (this.OpenConnection() == true) * { * Console.WriteLine("sql = " + sql); * MySqlCommand cmd = new MySqlCommand(sql, connection); * MySqlDataReader dataReader = cmd.ExecuteReader(); * while (dataReader.Read()) * { * TaskRecord taskRecord = new TaskRecord(); * taskRecord.taskRecordID = int.Parse(dataReader["taskRecordID"] + ""); * taskRecord.taskRecordStat = (TASKSTAT_T) int.Parse(dataReader["taskRecordStat"] + ""); * try * { * taskRecord.forkLift = AGVInitialize.getInitialize().getForkLiftByID(int.Parse(dataReader["forklift"] + "")); * } * catch (FormatException fx) * { * Console.WriteLine("message = " + fx.Message); * } * Console.WriteLine("----------------------------"); * //taskRecord.singleTask = AGVInitialize.getInitialize().getSingleTaskByID(int.Parse(dataReader["singleTask"] + "")); * taskRecordList.Add(taskRecord); * } * * dataReader.Close(); * } * * this.CloseConnection(); * return taskRecordList; * } * */ /// <summary> /// 插入任务记录 /// </summary> /// <param name="taskRecordStat"></param> /// <param name="st"></param> public List <TaskRecord> SelectTaskRecordBySql(string sql) { List <TaskRecord> taskRecordList = new List <TaskRecord>(); try { lock (lockDB) { if (this.OpenConnection() == true) { //Console.WriteLine("sql = " + sql); MySqlCommand cmd = new MySqlCommand(sql, connection); MySqlDataReader dataReader = cmd.ExecuteReader(); while (dataReader.Read()) { TaskRecord taskRecord = new TaskRecord(); taskRecord.taskRecordID = int.Parse(dataReader["taskRecordID"] + ""); taskRecord.taskRecordStat = (TASKSTAT_T)int.Parse(dataReader["taskRecordStat"] + ""); taskRecord.taskLevel = int.Parse(dataReader["taskLevel"] + ""); try { if (!String.IsNullOrEmpty(dataReader["forklift"].ToString())) { taskRecord.forkLift = AGVInitialize.getInitialize().getForkLiftByID(int.Parse(dataReader["forklift"] + "")); } } catch (FormatException fx) { Console.WriteLine("message = " + fx.Message); } taskRecord.singleTask = AGVInitialize.getInitialize().getSingleTaskByID(int.Parse(dataReader["singleTask"] + "")); taskRecord.taskRecordName = taskRecord.singleTask.taskName; taskRecord.updateTime = (DateTime)(dataReader["taskRecordUpdateTime"]); taskRecordList.Add(taskRecord); } dataReader.Close(); this.CloseConnection(); } } }catch (Exception ex) { Console.WriteLine(ex.ToString()); this.CloseConnection(); } return(taskRecordList); }
private void palletItemClick(object sender, EventArgs e) { MenuItem item = (MenuItem)sender; Console.WriteLine("Name = " + item.Name + "value = " + this.SingleTaskDTG.CurrentCell.Value); SingleTask st = null; st = (SingleTask)this.SingleTaskDTG.CurrentCell.Value; if (st != null) { st.taskStat = TASKSTAT_T.TASK_READY_SEND; AGVInitialize.getInitialize().getSchedule().addTaskRecord(TASKSTAT_T.TASK_READY_SEND, st); this.SingleTaskDTG.CurrentCell.Style.BackColor = Color.LightGray; } }
private void systemPauseButton_Click(object sender, EventArgs e) { Button button = (Button)sender; if (button.Name.Equals("pause")) { AGVInitialize.getInitialize().getSchedule().setPause(SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_SYSTEM_WITH_START); setFrmEnableExcludeControPanel(false); } else if (button.Name.Equals("start")) { AGVInitialize.getInitialize().getSchedule().setPause(SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_TYPE_MIN); setFrmEnableExcludeControPanel(true); } }
public static void Send(Socket handler) { StringBuilder sb = new StringBuilder(); sb.Append("battery_soc="); sb.Append(forklift.getBatterySoc() + ";"); sb.Append("agvMessage="); sb.Append((int)AGVInitialize.getInitialize().getAGVMessage().getMessage().getMessageType()); Console.WriteLine(" send data = " + sb.ToString()); AGVLog.WriteError(" send data = " + sb.ToString(), new StackFrame(true)); byte[] byteData = Encoding.ASCII.GetBytes(sb.ToString()); handler.Send(byteData); }
private void addAllTaskRecordButton_Click(object sender, EventArgs e) { List <TaskRecord> listTaskRecords = AGVInitialize.getInitialize().getAGVUtil().SelectReadySendTask(); if (listTaskRecords.Count > 0) { DialogResult dr; dr = MessageBox.Show("有缓存任务,禁止一键添加", "提示", MessageBoxButtons.OK); } else { AGVInitialize.getInitialize().getAGVUtil().addAllTaskRecord(); updateFrm(); } }
public List <SingleTask> getDownPickSingleTask() { List <SingleTask> sList = AGVInitialize.getInitialize().getDBConnect().SelectSingleTaskList(); List <SingleTask> downList = new List <SingleTask>(); foreach (SingleTask st in sList) { if (st.taskType == TASKTYPE_T.TASK_TYPE_DOWN_PICK) { downList.Add(st); } } return(downList); }
void openNewForm() { int i = 0; DataGridViewRow dgvw = new DataGridViewRow(); this.SingleTaskDTG.Rows.Clear(); //移除所有的行 重新绘制 singleTaskList = AGVInitialize.getInitialize().getSingleTaskList(); foreach (SingleTask sl in singleTaskList) { if (i % TASK_COLUMN_NUM == 0) { dgvw = new DataGridViewRow(); } DataGridViewTextBoxCell tb = new DataGridViewTextBoxCell(); tb.Value = sl; if (sl.taskStat == TASKSTAT_T.TASK_READY_SEND || sl.taskStat == TASKSTAT_T.TASK_END) //待可以发送状态,可以取消该任务 { tb.Style.BackColor = Color.LightGray; } else if (sl.taskStat == TASKSTAT_T.TASK_SEND || sl.taskStat == TASKSTAT_T.TASK_SEND_SUCCESS) { Console.WriteLine("sl name = " + sl.taskName); tb.Style.BackColor = Color.Green; } dgvw.Cells.Add(tb); if ((i + 1) % TASK_COLUMN_NUM == 0) { this.SingleTaskDTG.Rows.Add(dgvw); } i++; } if ((i + 1) % TASK_COLUMN_NUM != 0) { this.SingleTaskDTG.Rows.Add(dgvw); } if (isFirstShow) { isFirstShow = false; this.ShowDialog(); } else { this.Update(); } }
static void Main() { AGVLog agvLog = new AGVLog(); //List<SingleTask> sList = new List<SingleTask>(); agvLog.initAGVLog(); //初始化log Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); AGVInitialize.getInitialize().getLoginFrm().ShowDialog(); //agvTask.startConnectForkLift(); //开始与车子建立连接 //agvTask.startPLCRecv(); //开始采集PLC数据 //agvTask.startToHandleTaskList(); //开始处理任务发送 AGVInitialize.getInitialize().agvInit(); AGVInitialize.getInitialize().getAGVTcpServer().StartAccept(); AGVInitialize.getInitialize().getSchedule().startShedule(); AGVInitialize.getInitialize().getAGVMessage().setUsbGreenLed(); //default green led AGVInitialize.getInitialize().getAGVMessage().StartHandleMessage(); int i = 0; //while(i < 1) { i++; //AGVInitialize.getInitialize().getAGVCom().setDataCommand(LIFT_IN_COMMAND_T.LIFT_IN_COMMAND_UP); } AGVInitialize.getInitialize().getMainFrm().ShowDialog(); //Application.Run(AGVInitialize.getInitialize().getMainFrm()); //AGVTcpClient tcpClient = new AGVTcpClient(); //Thread.Sleep(1000); //tcpClient.SendMessage("cmd=set task by name;name=abing;"); //connectDB(); //AGVInitialize init = AGVInitialize.getInitialize(); //init.getAllForkLifts(false); // //while (!isExit) { Thread.Sleep(5); }; }
/// <summary> /// 可能有缓存任务,刚启动时,车子的状态需要设置 /// </summary> private void setForkliftStateFirst() { foreach (ForkLift fl in forkLiftList) { List <TaskRecord> taskRecordList = AGVInitialize.getInitialize().getAGVUtil().updateTaskRecordList(); foreach (TaskRecord tr in taskRecordList) { if (tr.taskRecordStat == TASKSTAT_T.TASK_SEND || tr.taskRecordStat == TASKSTAT_T.TASK_SEND_SUCCESS) { if (tr.forkLift != null && tr.forkLift.forklift_number == fl.forklift_number) { fl.taskStep = ForkLift.TASK_STEP.TASK_EXCUTE; } } } } }
private void handleMessage(String content) { Console.WriteLine("Content : " + content); int pos_c = -1; string cmd = null; pos_c = content.IndexOf("cmd="); if (pos_c != -1) { cmd = content.Substring(pos_c + 4); Console.WriteLine("cmd = " + cmd); if (cmd.StartsWith("add_recordTask")) //添加任务 { pos_c = cmd.IndexOf("param="); if (pos_c != -1) { string taskName = cmd.Substring(pos_c + 6); handleRecordTask(taskName, "add"); Console.WriteLine("taskName = " + taskName); } } else if (cmd.StartsWith("setSystemPause")) //移除任务 { pos_c = cmd.IndexOf("param="); if (pos_c != -1) { string tmp = cmd.Substring(pos_c + 6); Console.WriteLine(" pauseStat = " + tmp); if (tmp.Equals("0")) { AGVInitialize.getInitialize().getSchedule().setPause(SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_TYPE_MIN); } else if (tmp.Equals("1")) { AGVInitialize.getInitialize().getSchedule().setPause(SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_SYSTEM_WITH_START); } } } else if (cmd.StartsWith("updateDownTask")) { //AGVInitialize.getInitialize().getSchedule().updateDownPickSingleTask(); } } }
private void palletItemClick(object sender, EventArgs e) { MenuItem item = (MenuItem)sender; Console.WriteLine("select button name = " + selectedButton.Name); TaskRecord tr = (TaskRecord)selectedButton.getBindValue(); if (tr == null) { selectedButton.BackColor = Color.LightGray; tr = new TaskRecord(); tr.singleTask = selectedButton.st; tr.taskRecordName = selectedButton.st.taskName; tr.taskRecordStat = TASKSTAT_T.TASK_READY_SEND; AGVInitialize.getInitialize().getSchedule().addTaskRecord(tr); selectedButton.bindValue(tr); } }
private void cancelItemClick(object sender, EventArgs e) { MenuItem item = (MenuItem)sender; Console.WriteLine("Name = " + item.Name + "value = " + this.SingleTaskDTG.CurrentCell.Value); SingleTask st = null; if (item.Name.Equals("cancelTaskItem")) { st = (SingleTask)this.SingleTaskDTG.CurrentCell.Value; } if (st != null) { st.taskStat = TASKSTAT_T.TASK_NOT_ASSIGN; this.SingleTaskDTG.CurrentCell.Style.BackColor = Color.White; AGVInitialize.getInitialize().getSchedule().removeTaskRecord(st, TASKSTAT_T.TASK_READY_SEND); } }
/// <summary> /// 将该任务的优先级提到最高 设置该任务的优先级,默认查询任务的时候将会参考该任务的有先级来查询 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void topItemClick(object sender, EventArgs e) { MenuItem item = (MenuItem)sender; TaskRecord tr = (TaskRecord)selectedButton.getBindValue(); Console.WriteLine(" tr is nulll " + tr == null); try { if (checkTopFunc(tr)) { selectedButton.BackColor = Color.Gray; AGVInitialize.getInitialize().getSchedule().topTaskRecord(tr); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }