Exemple #1
0
        /// <summary>
        /// 定时获取AGV导航状态
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void timerStatus_Elapsed(object sender, ElapsedEventArgs e)
        {
            lock (lockerStatus)
            {
                if (msgStatusList.Count > 0)
                {
                    AGVComFrame response = comStatus.SendAndGet(msgStatusList.Dequeue(), 300);
                    if (null != response && null != response.data && null != this.OnStatusUpdate)
                    {
                        string   data     = response.Message;
                        AGVTypes _type    = (AGVTypes)(response.header.type - AGVProtocolHeader.TypeResponseOffset);
                        string   respData = _type.ToString() + ":" + data;
                        this.OnStatusUpdate.BeginInvoke(this, respData, null, null);
                    }
                }

                //AGVComFrame response = comStatus.SendAndGet(AGVComFrameBuilder.状态_查询机器人导航状态(), 300);
                //this.status = AGVComFrameBuilder.Response_状态_查询机器人导航状态(ref response);
                //if (null != this.status && null != this.OnStatusUpdate)
                //{
                //    string data = System.Text.ASCIIEncoding.UTF8.GetString(response.data);
                //    this.OnStatusUpdate.BeginInvoke(this, data, null, null);
                //}
            }
        }
Exemple #2
0
        public static AGVComFrame NoData_Request(AGVTypes type)
        {
            AGVComFrame frame = new AGVComFrame(new AGVProtocolHeader()
            {
                type = (UInt16)type, length = 0
            }, null);

            return(frame);
        }
Exemple #3
0
 public static bool CheckResponse(AGVTypes sendType, ref AGVComFrame response)
 {
     if (null != response && response.header.type == (UInt16)(sendType + AGVProtocolHeader.TypeResponseOffset))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
        private void button状态_Click(object sender, EventArgs e)
        {
            AGVTypes value = (AGVTypes)this.comboBox1.SelectedItem;

            if (agv1.IsConnected)
            {
                agv1.AddMessage(AGVComFrameBuilder.NoData_Request(value));
            }
            else
            {
                MessageBox.Show("设备未连接,请先连接设备!", "错误");
            }
        }
Exemple #5
0
 private void timerTask_Elapsed(object sender, ElapsedEventArgs e)
 {
     lock (lockerTask)
     {
         if (msgTaskList.Count > 0)
         {
             AGVComFrame response = comTask.SendAndGet(msgTaskList.Dequeue(), 300);
             if (null != response && null != response.data && null != this.OnTaskUpdate)
             {
                 string   data     = response.Message;
                 AGVTypes _type    = (AGVTypes)(response.header.type - AGVProtocolHeader.TypeResponseOffset);
                 string   respData = _type.ToString() + ":" + data;
                 this.OnTaskUpdate.BeginInvoke(this, respData, null, null);
             }
         }
     }
 }
        private void button状态_Click(object sender, EventArgs e)
        {
            AGVTypes value = (AGVTypes)this.comboBox1.SelectedItem;

            AGVComFrame frame = new AGVComFrame(new AGVProtocolHeader()
            {
                type = (UInt16)AGVTypes.导航_路径导航
            }, "{\"id\":\"LM1\"}");

            if (agv1.IsConnected)
            {
                //agv1.AddTaskMessage(frame);
                agv1.AddStatusMessage(AGVComFrameBuilder.NoData_Request(value));
            }
            else
            {
                MessageBox.Show("设备未连接,请先连接设备!", "错误");
            }
        }
 public AGVComFrame(AGVTypes type, object serialObj)
     : base()
 {
     this.header = new AGVProtocolHeader()
     {
         type   = (UInt16)type,
         number = (UInt16) new Random(new Guid().GetHashCode()).Next()
     };
     if (null != serialObj)
     {
         try
         {
             string d = JsonConvert.SerializeObject(serialObj, Formatting.None);
             this.data          = System.Text.ASCIIEncoding.UTF8.GetBytes(d);
             this.header.length = (uint)this.data.Length;
         }
         catch
         {
             this.data = null;
         }
     }
 }