Example #1
0
        public void initPanel(ForkLift fl)
        {
            this.forklift = fl;

            forkNumberLabel.Text = fl.forklift_number.ToString() + "号车";


            if (fl.getPauseStr().Equals("暂停"))
            {
                pauseCtrlButton.Text = "启动";
            }
            else
            {
                pauseCtrlButton.Text = fl.getPauseStr();
            }

            forkNumberLabel.Location = new Point(10, 20);
            forkNumberLabel.Size     = new Size(60, 30);

            pauseCtrlButton.Location = new Point(80, 10);
            pauseCtrlButton.Size     = new Size(60, 30);

            if (fl.getPauseStr().Equals("运行")) //不支持运行的时候设置暂停
            {
                pauseCtrlButton.Enabled = false;
            }

            pauseCtrlButton.Click += pauseCtroButton_Click;
            this.Controls.Add(forkNumberLabel);
            this.Controls.Add(pauseCtrlButton);
        }
Example #2
0
        public DateTime updateTime;            //发送成功时候的时间

        public TaskRecord(TASKSTAT_T taskRecordStat, SingleTask singleTask, ForkLift forkLift = null)
        {
            this.forkLift       = forkLift;
            this.taskRecordStat = taskRecordStat;
            this.singleTask     = singleTask;
            this.taskRecordName = singleTask.taskName;
        }
Example #3
0
 public void startRecvMsg(ForkLift fl)
 {
     recvThread = new Thread(new ParameterizedThreadStart(receive));
     recvThread.IsBackground = true;
     this.isRecvMsgFlag      = true; //设置接收标志
     recvThread.Start(fl);
 }
Example #4
0
        public ForkLift getForkLiftByID(int forkLiftID)
        {
            ForkLift forkLift = null;

            foreach (ForkLift fl in forkLiftList)
            {
                if (fl.id == forkLiftID)
                {
                    forkLift = fl;
                }
            }

            return(forkLift);
        }
Example #5
0
        public void initPanel(ForkLift fl)
        {
            numberLabel.Text    = fl.forklift_number.ToString();
            stateLabel.Text     = "任务状态";
            batteryLabel.Text   = "电池电量";
            pauseLabel.Text     = "暂停状态";
            batteryLabel_c.Text = "";

            numberLabel.Location = new Point(70, 0);
            numberLabel.Size     = new Size(20, 20);
            stateLabel_c.Text    = "";
            stateLabel.Location  = new System.Drawing.Point(10, 25);
            stateLabel.Size      = new System.Drawing.Size(60, 29);


            stateLabel_c.Location = new System.Drawing.Point(85, 25);
            stateLabel_c.Size     = new System.Drawing.Size(40, 29);

            batteryLabel.Location = new System.Drawing.Point(10, 65);
            batteryLabel.Size     = new System.Drawing.Size(60, 29);


            batteryLabel_c.Location = new System.Drawing.Point(85, 65);
            batteryLabel_c.Size     = new System.Drawing.Size(40, 29);

            pauseLabel.Location = new System.Drawing.Point(10, 105);
            pauseLabel.Size     = new System.Drawing.Size(60, 29);

            pauseLabel_c.Location = new System.Drawing.Point(85, 105);
            pauseLabel_c.Size     = new System.Drawing.Size(40, 29);

            this.fl = fl;
            this.infoPanel.Location    = new Point(0, 30);
            this.infoPanel.Size        = new Size(150, 140);
            this.infoPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.Name = "panel_a" + fl.forklift_number;
            this.infoPanel.Controls.Add(stateLabel);
            this.infoPanel.Controls.Add(stateLabel_c);
            this.infoPanel.Controls.Add(batteryLabel);
            this.infoPanel.Controls.Add(batteryLabel_c);

            this.infoPanel.Controls.Add(pauseLabel);
            this.infoPanel.Controls.Add(pauseLabel_c);

            this.Controls.Add(numberLabel);

            this.Controls.Add(infoPanel);
        }
Example #6
0
        public List <ForkLift> SelectForkList()
        {
            string query = "select * from forklift order by number";


            //Create a list to store the result
            List <ForkLift> list = new List <ForkLift>();

            AGVLog.WriteInfo("SelectForkList sql = " + query, new StackFrame(true));
            try
            {
                //Open connection
                lock (lockDB)
                {
                    if (this.OpenConnection() == true)
                    {
                        //Create Command
                        MySqlCommand cmd = new MySqlCommand(query, connection);
                        //Create a data reader and Execute the command
                        MySqlDataReader dataReader = cmd.ExecuteReader();

                        //Read the data and store them in the list
                        while (dataReader.Read())
                        {
                            ForkLift fl = new ForkLift();
                            fl.id = int.Parse(dataReader["id"] + "");
                            fl.forklift_number = int.Parse(dataReader["number"] + "");
                            fl.ip   = dataReader["ip"] + "";
                            fl.port = int.Parse(dataReader["port"] + "");
                            list.Add(fl);
                        }

                        //close Data Reader
                        dataReader.Close();

                        //close Connection
                        this.CloseConnection();
                    }
                }
            }catch (Exception ex)
            {
                Console.WriteLine(" sql err " + ex.ToString());
                this.CloseConnection();
            }

            return(list);
        }
Example #7
0
        public void receive(object fl)
        {
            ForkLift forklift = (ForkLift)fl;

            byte[]    buffer = new byte[512];
            Socket    msock;
            TcpClient vClient = null;

            Console.WriteLine("receive ConnectStatus: " + ConnectStatus);
            if (ConnectStatus == false) //检查连接状态
            {
                return;
            }

            while (isRecvMsgFlag)
            {
                try
                {
                    vClient = getTcpClient();
                    msock   = client.Client;
                    Array.Clear(buffer, 0, buffer.Length);
                    int bytes = msock.Receive(buffer);
                    readTimeOutTimes = 0;    //读取超时次数清零
                    if (hrmCallback != null) //处理消息
                    {
                        hrmCallback(forklift.id, buffer, bytes);
                        Thread.Sleep(10);
                    }
                }
                catch (SocketException ex)
                {
                    if (ex.ErrorCode == 10060 && readTimeOutTimes < 10) //超时次数超过10次,关闭socket进行重连
                    {
                        AGVLog.WriteWarn("read msg timeout", new StackFrame(true));
                        Console.WriteLine("read msg timeout");
                        readTimeOutTimes++;
                        continue;
                    }
                    AGVLog.WriteError("读取消息错误" + ex.ErrorCode, new StackFrame(true));
                    Console.WriteLine("recv msg client close" + ex.ErrorCode);
                    Closeclient();
                }
            }
        }
Example #8
0
        /// <summary>
        /// 更新车子状态
        /// </summary>
        /// <param name="fl"></param>
        public void updateForkLift(ForkLift fl)
        {
            string sql = "update forklift set currentTask = \"" + fl.currentTask + "\", taskStep = " + (int)fl.taskStep + " where id = " + fl.id;

            AGVLog.WriteInfo("updateForkLift sql = " + sql, new StackFrame(true));
            try
            {
                lock (lockDB)
                {
                    if (this.OpenConnection() == true)
                    {
                        Console.WriteLine("sql = " + sql);
                        MySqlCommand cmd = new MySqlCommand(sql, connection);
                        cmd.ExecuteNonQuery();

                        this.CloseConnection();
                    }
                }
            }catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                this.CloseConnection();
            }
        }
Example #9
0
 public AGVTcpClient(ForkLift fl)
 {
     this.ip    = fl.ip;
     this.port  = fl.port;
     t_forklift = fl;
 }
Example #10
0
 public void setForkLift(ForkLift fl)
 {
     this.fl = fl;
 }