Esempio n. 1
0
        /// <summary>
        /// 线程处理 放置程序卡顿
        /// </summary>
        private void ThreadFunc()
        {
            while (true)
            {
                Thread.Sleep(2000);

                try
                {
                    if (!WcfDispatchHelper.IsConnected)
                    {
                        WcfDispatchHelper.Open();
                    }

                    if (!WcfMainHelper.IsConnected)
                    {
                        WcfMainHelper.Open();
                    }

                    if (!WcfTaskHelper.IsConnected)
                    {
                        WcfTaskHelper.Open();
                    }

                    CheckDispatch();

                    UpdateMap();
                }
                catch
                { }
            }
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        private void SendTask()
        {
            #region SendNow

            List <int> selectTar = GetSelectedTars();

            if (selectTar == null || selectTar.Count < 1)
            {
                MessageBox.Show("未选择有效任务", "提示");

                return;
            }

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

            task.Descip = _clientMark;

            TaskPathNode node = null;

            int lastTar = 0;

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

                task.TaskPathNode.Add(node);

                lastTar = item;
            }

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

            ///执行任务
            if (MessageBox.Show(string.Format("确定要执行任务【{0}】", textBoxNextTars.Text), "提示", 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
        }
Esempio n. 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
        }
Esempio n. 4
0
        /// <summary>
        /// 初始化参数
        /// </summary>
        private void InitPara()
        {
            string Section = "ShowConfig";

            int num = 0;

            #region  钮宽度
            string key = "BtnWidth";

            string read = ConfigHelper.IniReadValue(Section, key, 100);

            if (string.IsNullOrEmpty(read))
            {
                read = _btnWidth.ToString();

                ConfigHelper.IniWriteValue(Section, key, read);
            }

            if (Int32.TryParse(read, out num))
            {
                _btnWidth = num;
            }
            #endregion

            #region  钮高度
            key = "BtnHeight";

            read = ConfigHelper.IniReadValue(Section, key, 100);

            if (string.IsNullOrEmpty(read))
            {
                read = _btnHeight.ToString();

                ConfigHelper.IniWriteValue(Section, key, read);
            }

            if (Int32.TryParse(read, out num))
            {
                _btnHeight = num;
            }
            #endregion

            #region 横向距离
            key = "XDis";

            read = ConfigHelper.IniReadValue(Section, key, 100);

            if (string.IsNullOrEmpty(read))
            {
                read = _xDis.ToString();

                ConfigHelper.IniWriteValue(Section, key, read);
            }

            if (Int32.TryParse(read, out num))
            {
                _xDis = num;
            }
            #endregion

            #region 纵向距离
            key = "YDis";

            read = ConfigHelper.IniReadValue(Section, key, 100);

            if (string.IsNullOrEmpty(read))
            {
                read = _yDis.ToString();

                ConfigHelper.IniWriteValue(Section, key, read);
            }

            if (Int32.TryParse(read, out num))
            {
                _yDis = num;
            }
            #endregion

            #region 起始坐标

            int x = 0, y = 0;

            key = "StartPoint_X";

            read = ConfigHelper.IniReadValue(Section, key, 100);

            if (string.IsNullOrEmpty(read))
            {
                read = x.ToString();

                ConfigHelper.IniWriteValue(Section, key, read);
            }

            if (Int32.TryParse(read, out num))
            {
                x = num;
            }


            key = "StartPoint_Y";

            read = ConfigHelper.IniReadValue(Section, key, 100);

            if (string.IsNullOrEmpty(read))
            {
                read = y.ToString();

                ConfigHelper.IniWriteValue(Section, key, read);
            }

            if (Int32.TryParse(read, out num))
            {
                y = num;
            }

            _startLoc = new Point(x, y);
            #endregion

            #region 客户端配置
            Section = "CientConfig";

            key = "LoctionSite";

            read = ConfigHelper.IniReadValue(Section, key, 100);

            if (string.IsNullOrEmpty(read))
            {
                read = "-1";

                ConfigHelper.IniWriteValue(Section, key, read);
            }

            Int32.TryParse(read, out _locTar);

            key = "SeverIP";

            _severIp = ConfigHelper.IniReadValue(Section, key, 100);

            if (string.IsNullOrEmpty(_severIp))
            {
                _severIp = "127.0.0.1";

                ConfigHelper.IniWriteValue(Section, key, _severIp);
            }
            #endregion

            WcfDispatchHelper.InitPara(_severIp, "", "");

            WcfMainHelper.InitPara(_severIp, "", "");

            WcfTaskHelper.InitPara(_severIp, "", "");

            _clientMark = string.Format("微科创新_客户端【{0}】", _locTar);

            this.Text = string.Format("{0} IP:{1}", _clientMark, IPHelper.GetLocalIntranetIP());
        }
Esempio n. 5
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 { }
        }