Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_Click(object sender, EventArgs e)
        {
            if (sender is Button)
            {
                Button btn = sender as Button;

                StationMember sta = btn.Tag as StationMember;

                if (sta != null)
                {
                    if (!_selectStation.Contains(sta))
                    {
                        _selectStation.Add(sta);

                        btn.BackColor = Color.Red;
                    }
                    else
                    {
                        _selectStation.Remove(sta);

                        btn.BackColor = Control.DefaultBackColor;
                    }

                    textBoxNextTars.Text = SelectStaStr();

                    SetOutputMsg(string.Format("当前已选择{0}", textBoxNextTars.Text));
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// 初始化成员
        /// </summary>
        private void InitStaMember()
        {
            string section = "StationConfigNum";

            string keyPre = string.Format("站点个数");

            string read = ConfigHelper.IniReadValue(section, keyPre, 100);

            if (string.IsNullOrEmpty(read))
            {
                read = "10";

                ConfigHelper.IniWriteValue(section, keyPre, read);
            }

            if (!Int32.TryParse(read, out _staCount))
            {
                _staCount = 10;
            }

            _staDic.Clear();

            for (int i = 1; i <= _staCount; i++)
            {
                StationMember member = GetConfigMember(i);

                if (member != null && !_staDic.ContainsKey(member.StaId))
                {
                    _staDic.Add(member.StaId, member);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// 返回待命点
        /// </summary>
        private void BackWaitPoint()
        {
            #region BackWaitPoint
            StationMember staMem = GetRelateMember(_locTar);

            if (staMem == null)
            {
                MessageBox.Show("没有配置相关的站点,请检查!", "提示");

                return;
            }

            ///构建任务
            TaskDispatch task = new TaskDispatch();

            task.Descip = _clientMark;

            TaskPathNode node = null;

            int lastTar = 0;

            ///添加任务节点
            foreach (var item in staMem.BackTarList)
            {
                node = new TaskPathNode("", item, false);

                task.TaskPathNode.Add(node);

                lastTar = item;
            }

            ///启动本地AGV
            task.StartSiteList.Add(LocSite.ToString());

            ///执行任务
            if (MessageBox.Show(string.Format("确定要返回待命点?"), "提示", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
            {
                WcfDispatchHelper.InitPara(_severIp, "", "");

                string result = WcfDispatchHelper.IStartTaskDispatch(task);

                if (result != "s")
                {
                    SetOutputMsg(result);

                    MessageBox.Show("当前没有空闲AGV," + "请稍后再试!", "提示");
                }
                else
                {
                    ResetBackCorlor();

                    SetOutputMsg(string.Format("开启新任务"));

                    MessageBox.Show("派发任务成功,点击启动开始运行!", "提示");
                }
            }
            #endregion
        }
Beispiel #4
0
        /// <summary>
        /// 呼叫AGV
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonCallAGv_Click(object sender, EventArgs e)
        {
            try
            {
                if (_isCalling)
                {
                    MessageBox.Show("AGV过来的途中,请等待!", "提示"); return;
                }

                TaskDispatch task = new TaskDispatch();

                task.Descip = _clientMark;

                StationMember sta = _staDic.Values.ToList().Find(c => { return(c.StaSite == LocSite); });

                if (sta == null)
                {
                    MessageBox.Show("未找到与本客户端绑定的站点", "提示"); return;
                }

                TaskPathNode node = new TaskPathNode(sta.StaSite.ToString(), sta.StaTarget, true);

                task.TaskPathNode.Add(node);

                if (sta != null && sta.WaitList != null)
                {
                    foreach (var item in sta.WaitList)
                    {
                        task.StartSiteList.Add(item.ToString());
                    }
                }

                if (task.StartSiteList == null || task.StartSiteList.Count < 1)
                {
                    MessageBox.Show("未正确配置其相应的待命点,请检查配置!", "提示");

                    return;
                }

                if (MessageBox.Show(string.Format("确定要呼叫AGV到【{0}】位置", sta.StaTarget), "提示", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                {
                    WcfDispatchHelper.InitPara(_severIp, "", "");

                    string result = WcfDispatchHelper.IStartTaskDispatch(task);

                    SetOutputMsg(string.Format("开启新任务"));

                    if (result != "s")
                    {
                        SetOutputMsg(result);

                        MessageBox.Show("当前没有空闲的AGV,请稍后再试!", "提示");
                    }
                    else
                    {
                        _isCalling = true;

                        _callingTask = task;

                        DispatchBackMember disback = WcfMainHelper.GetDispatch(task.DisGuid);

                        if (disback != null)
                        {
                            _callingAGV = disback.DisDevId;

                            DeviceBackImf devback = WcfMainHelper.GetDev(_callingAGV);

                            if (devback != null)
                            {
                                _callingSite = devback.SensorList.Find(c => { return(c.SenId == string.Format("{0}0002", devback.DevId)); }).RValue;
                            }
                            else
                            {
                                _callingSite = null;
                            }
                        }
                        else
                        {
                            _callingAGV = null;
                        }

                        MessageBox.Show("呼叫成功,请等待AGV过来!", "提示");
                    }
                }
            }
            catch { }
        }