/// <summary> /// AGV后退 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AgvBackwardBtn_Click(object sender, EventArgs e) { if (agvList.FocusedItem == null) { MessageBox.Show("请选中需要操作的车辆", "提示"); return; } else { if (!AgvForwardBtn.Enabled) { StopAGV(); } if (WcfMainHelper.SendOrder(agvList.FocusedItem.Text, new FControlOrder("后退", 1, 2))) { //记录agv状态 agvStatus[agvList.FocusedItem.Text] = "backmove"; AgvBackwardBtn.Enabled = false; } else { MessageBox.Show("请尝试再操作一次", "提示"); } } }
/// <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 { } } }
/// <summary> /// ListView初始化 标题 /// </summary> private void ListView_Init() { //Agv列表 agvList.Columns.Add("AGV", 80, HorizontalAlignment.Center); agvList.Columns.Add("状态", 109, HorizontalAlignment.Center); agvList.View = System.Windows.Forms.View.Details; //调度任务列表 currentTaskList.Columns.Add("ID", 0, HorizontalAlignment.Left); currentTaskList.Columns.Add("任务", 220, HorizontalAlignment.Left); currentTaskList.Columns.Add("路径", 100, HorizontalAlignment.Left); currentTaskList.View = System.Windows.Forms.View.Details; List <DeviceBackImf> devDatas = WcfMainHelper.GetDevList(); if (devDatas == null) { MessageBox.Show("请先启动服务"); Close(); return; } foreach (var data in devDatas) { agvStatus.Add(data.DevId, "stop"); } }
/// <summary> /// 检测调度状态 /// </summary> private void CheckDispatch() { WcfMainHelper.InitPara(_severIp, "", ""); List <DispatchBackMember> result = WcfMainHelper.GetDispatchList(); if (result != null) { foreach (var item in result) { if (item.TaskImf == _clientMark && item.OrderStatue == ResultTypeEnum.Suc) { WcfMainHelper.CtrDispatch(item.DisGuid, DisOrderCtrTypeEnum.Stop); } } if (_callingTask != null) { if (result.Find(c => { return(c.DisGuid == _callingTask.DisGuid); }) == null) { _callingTask = null; } } } if (_callingTask == null) { _isCalling = false; } }
/// <summary> /// 发生故障、离线的车,清除其相应的任务 /// </summary> public void ClearTask() { while (true) { Thread.Sleep(5000); List <F_AGV> agvs = F_DataCenter.MDev.ErrorOrFalse(); List <FDispatchBackImf> dispatchList = WcfMainHelper.GetDispatchList(); if (dispatchList != null && agvs != null && dispatchList.Count > 0) { foreach (var agv in agvs) { foreach (var dispatch in dispatchList) { // 有故障的车是否对应任务的设备ID if (agv.Id == dispatch.Dev) { if (dic.ContainsKey(agv.Id)) { int count = 0; dic.TryGetValue(agv.Id, out count); if (count >= 10) { // 终止该任务 WcfMainHelper.CtrDispatch(dispatch.Id, EnumCtrType.Stop); sendServerLog("终止异常的 " + agv.Id + "正在执行的任务"); //LogFactory.LogRunning("终止异常的 " + agv.Id + "正在执行的任务"); FLog.Log("终止异常的 " + agv.Id + "正在执行的任务"); count = 0; //异常终止的任务释放AGV F_AGV.AgvRelease(agv.Id); } else { count++; sendServerLog("异常的 " + agv.Id + "已等待处理 " + count + " 次"); //LogFactory.LogRunning("异常的 " + agv.Id + "已等待处理 " + count + " 次"); FLog.Log("异常的 " + agv.Id + "已等待处理 " + count + " 次"); } dic.Remove(agv.Id); dic.Add(agv.Id, count); } else { dic.Add(agv.Id, 0); } } } } } else { dic.Clear(); } } }
/// <summary> /// 任务完成 /// </summary> public void ISetTaskSuc() { if (_taskDispatch != null) { if (WcfMainHelper.CtrDispatch(_taskDispatch.Id, EnumCtrType.Stop)) { _isSuc = true; } } FLog.Log(_taskDispatch.Id + "任务完成"); }
/// <summary> /// 清除站点 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AgvClearSiteBtn_Click(object sender, EventArgs e) { if (agvList.FocusedItem == null) { MessageBox.Show("请选中需要操作的车辆", "提示"); return; } else { WcfMainHelper.SendOrder(agvList.FocusedItem.Text, new FControlOrder("清除站点", 3, 0)); } }
/// <summary> /// 停止函数 /// </summary> public void StopAGV() { //WcfMainHelper.InitPara(_severIp, "", ""); // 1是快速停止、0是慢速 if (WcfMainHelper.SendOrder(agvList.FocusedItem.Text, new FControlOrder("停止", 2, 0))) { AgvForwardBtn.Enabled = true; AgvBackwardBtn.Enabled = true; } else { MessageBox.Show("请尝试再操作一次", "提示"); } }
/// <summary> /// 返回区域二附近的待命点 /// </summary> private void BackToPointAround() { if (_devArea2 == null) { return; } if (_devTarWait == null) { WcfMainHelper.InitPara(_severIp, "", ""); List <DispatchBackMember> diss = WcfMainHelper.GetDispatchList(); List <DeviceBackImf> devs = WcfMainHelper.GetDevList(); foreach (var item in _waitAreaTwoList) { if ((!IsDispatchContainPath(diss, item.StaTarget)) && (!IsDevOnSite(devs, item.StaSite))) { _devTarWait = item; break; } } } if (_devTarWait != null) { WcfMainHelper.InitPara(_severIp, "", ""); DeviceBackImf result = WcfMainHelper.GetDev(_devArea2.DevId); if (result != null) { if (result.SensorList.Find(c => { return(c.SenId == string.Format("{0}0003", _devArea2.DevId)); }).RValue == _devTarWait.StaTarget.ToString()) { _devTarWait = null; _devArea2 = null; } else { WcfMainHelper.SendOrder(_devArea2.DevId, new CommonDeviceOrderObj(DeviceOrderTypeEnum.OrderIndexThree, _devTarWait.StaTarget)); } } } }
/// <summary> /// 任务完成 /// </summary> public void ISetTaskSuc() { //if (_plc != null) //{ // _plc.IsLock = false; //} //if (_agv != null) { F_AGV.AgvRelease(_agv.Id); } if (_taskDispatch != null) { if (WcfMainHelper.CtrDispatch(_taskDispatch.Id, EnumCtrType.Stop)) { _isSuc = true; } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonSendRun_Click(object sender, EventArgs e) { WcfMainHelper.InitPara(_severIp, "", ""); List <DeviceBackImf> devs = WcfMainHelper.GetDevList(); SensorBackImf sens = null; if (devs != null && devs.Count > 0) { foreach (var item in devs) { if (item.DevType == "AGV") { sens = item.SensorList.Find(c => { return(c.SenId == string.Format("{0}0002", item.DevId)); }); if (sens != null && sens.RValue == LocSite.ToString()) { if (MessageBox.Show(string.Format("确定要启动【{0}】地标上AGV【{1}】", LocSite, item.DevId), "提示", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { if (WcfMainHelper.SendOrder(item.DevId, new CommonDeviceOrderObj("定点启动" + LocSite, 1))) { SetOutputMsg(string.Format("启动【{0}】地标上AGV【{1}】", LocSite, item.DevId)); MessageBox.Show("启动成功!", "提示"); } else { MessageBox.Show("请尝试再操作一次", "提示"); } } return; } } } } else { SetOutputMsg(string.Format("未获取到服务端的AGV")); } SetOutputMsg(string.Format("地标【{0}】上未找到AGV", LocSite)); MessageBox.Show(string.Format("地标【{0}】上未找到AGV", LocSite), "提示"); }
/// <summary> /// 事务线程 /// </summary> private void ThreadFunc() { List <DeviceBackImf> getList = null; List <FDispatchBackImf> dispatchList = null; while (true) { Thread.Sleep(1000); try { getList = WcfMainHelper.GetDevList(); dispatchList = WcfMainHelper.GetDispatchList(); if (getList != null) { lock (_ans) { _devList.Clear(); _devList.AddRange(getList); //AGVDataMaster.UpdateAgvs(_devList); } MapItemMaster.UpdateItems(_devList); MapDevMsgMaster.UpdateDevInfo(_devList); } if (dispatchList != null) { lock (_ansDis) { _dispatchList.Clear(); _dispatchList.AddRange(dispatchList); } } } catch { } } }
/// <summary> /// 检查线边辊台PLC连接状态 /// </summary> public void CheckPlcStatus() { while (true) { Thread.Sleep(5000); List <DeviceBackImf> devsList = WcfMainHelper.GetDevList(); foreach (var dev in devsList) { if (dev.DevType == "WK_PLC" && !dev.IsAlive) { F_PLCLine plc = new F_PLCLine(dev.DevId); plc.SendOrdr(0, 0); } } } }
/// <summary> /// 事务线程 /// </summary> private void ThreadFunc() { List <DeviceBackImf> getList = null; //List<FDispatchBackImf> dispatchList = null; while (true) { Thread.Sleep(500); try { getList = WcfMainHelper.GetDevList(); //dispatchList = WcfMainHelper.GetDispatchList(); if (getList != null) { lock (_ans) { _devList.Clear(); _devList.AddRange(getList); AGVDataMaster.UpdateAgvs(_devList); } } //if (dispatchList != null) //{ // lock (_ansDis) // { // _dispatchList.Clear(); // _dispatchList.AddRange(dispatchList); // } //} } catch { } } }
/// <summary> /// /// </summary> private void UpdateMap() { List <IAgvData> agvs = new List <IAgvData>(); List <DeviceBackImf> devs = WcfMainHelper.GetDevList(); List <IAgvData> updateList = new List <IAgvData>(); if (devs != null) { devs.ForEach(c => { if (c.DevType == "AGV") { updateList.Add(new AgvData(c)); } }); _mapCtr.UpdateAgvMessage(updateList); } }
/// <summary> /// 事务线程 /// </summary> private void ThreadFunc() { List <DeviceBackImf> getList = null; List <FDispatchBackImf> dispatchList = null; while (true) { Thread.Sleep(500); try { getList = WcfMainHelper.GetDevList(); dispatchList = WcfMainHelper.GetDispatchList(); if (getList != null) { lock (_ans) { _devList.Clear(); _devList.AddRange(getList); } } if (dispatchList != null) { lock (_ansDis) { _dispatchList.Clear(); _dispatchList.AddRange(dispatchList); } } } catch { } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ClientForm_FormClosing(object sender, FormClosingEventArgs e) { WcfMainHelper.InitPara(_severIp, "", ""); List <DispatchBackMember> result = WcfMainHelper.GetDispatchList(); if (result != null) { _isCalling = false; foreach (var item in result) { if (item.TaskImf == _clientMark) { MessageBox.Show("当前还有任务未完成,不允许关闭客户端!", "提示"); e.Cancel = true; return; } } } if (_devArea2 != null || _isCalling) { MessageBox.Show("当前还有任务未完成,不允许关闭客户端!", "提示"); e.Cancel = true; return; } if (MessageBox.Show("确定关闭客户端?", "提示", MessageBoxButtons.YesNo) != System.Windows.Forms.DialogResult.Yes) { e.Cancel = true; } }
/// <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 { } }
/// <summary> /// 给棍台发送相应动作 /// </summary> /// <param name="oper"></param> /// <param name="para"></param> /// <returns></returns> public bool SendOrdr(EnumType oper, EnumPara para) { return(WcfMainHelper.SendOrder(_id, new FControlOrder("远程", 1, (int)oper, (int)para))); }
/// <summary> /// 事务处理 /// </summary> public String DoWork() { if (_isSuc) { return(""); } if (!_isStart) { if (++_triggerCounter > F_DataCenter.ClearTime) { _isOverTime = true; } } if (_agv != null) { if (_agv.IsAlive) { _disAliveCounter = 0; } else { if (++_disAliveCounter > F_DataCenter.ClearTime) { _isDisaliveOverTime = true; } } } else { if (++_triggerCounter > F_DataCenter.ClearTime) { _isOverTime = true; } } _taskDispatch = WcfMainHelper.GetDispatch(Id); if (_taskDispatch == null) { FDispatchOrder dis = new FDispatchOrder(); dis.NavigationType = EnumNavigationType.Magnet; dis.Id = Id; dis.EndSite = _endSite; if (!string.IsNullOrEmpty(_startSite)) { dis.StartSiteList.Add(_startSite); } ///修改By fujun dis.DevList.Add(Id); string back = ""; WcfMainHelper.StartDispatch(dis, out back); return(back); } else { ///修改By fujun _isStart = true; #region 滚筒逻辑 ///确定此时任务的AGV if (_agv == null) { _agv = new F_AGV(_taskDispatch.Dev); } ///此次调度任务已经完成 if (_taskDispatch.Statue == EnumResultType.Suc) { if (_operType == EnumOper.取货) //窑尾 { ///当前AGV的到达的地标 与 棍台绑定地标一致 if (_agv.Site == _plc.Site) { FLog.Log(_agv.Id + "到达窑尾,开始取货"); if (_agv != null && _plc.EnterChargeAgv == _agv.Id) { if (_plc.IsEnterBatteryLock //&& !ParamControl.Do_EnterEndChargeLock ) { _plc.IsEnterBatteryLock = false; ParamControl.Do_EnterEndChargeLock = true; ParamControl.EndChargeLock = _plc.IsEnterBatteryLock; _plc.EnterChargeAgv = null; } } //如果界面打开忽略《窑尾》AGV货物状态和Plc货物状态则 直接发送棍台转动命令 if (ParamControl.Is_IgnoreTailUnloadStatus || (_plc.Sta_Material == EnumSta_Material.货 && (_agv.Sta_Material == EnumagvSta_Material.无货 || _agv.Sta_Material == EnumagvSta_Material.送中))) { if (_agv.Sta_Monitor != EnumSta_Monitor.电机反转) { _agv.SendOrdr(EnumType.料操作, EnumPara.agv上料启动); FLog.Log(_agv.Id + "启动车载辊台"); } else { if (BeginTime == null) { BeginTime = System.DateTime.Now; } _agv.SendOrdr(EnumType.料操作, EnumPara.agv上料启动); _plc.SendOrdr(EnumType.料操作, EnumPara.窑尾辊台允许下料); FLog.Log(_agv.Id + "启动车载辊台,启动窑尾辊台"); } } //如果界面打开忽略《窑尾》AGV货物状态,并且上面已经发送了指定时间的棍台转动时间 if ((ParamControl.Is_IgnoreTailUnloadStatus && IsTailRunTimeFinish()) || (//_plc.Sta_Material == EnumSta_Material.无货 && _agv.Sta_Material == EnumagvSta_Material.货)) { _agv.SendOrdr(EnumType.料操作, EnumPara.agv辊台停止); _plc.SendOrdr(EnumType.料操作, EnumPara.窑头辊台上料完成); FLog.Log(_agv.Id + "停止车载辊台,停止窑尾辊台"); //如果界面打开忽略《窑尾》AGV棍台状态,则进去结束任务 if (ParamControl.Is_IgnoreTailStaStatus || _agv.Sta_Monitor == EnumSta_Monitor.电机停止 ) { //取货完成,解锁窑尾 if (_plc != null // && !ParamControl.Do_EndPlcLock ) { _plc.IsLock = false; ParamControl.Do_EndPlcLock = true; } ISetTaskSuc(); } } } else { ISetTaskSuc(); } return(""); } else if (_operType == EnumOper.放货) //窑头 { ///当前AGV的到达的地标 与 棍台绑定地标一致 if (_agv.Site == _plc.Site) { FLog.Log(_agv.Id + "到达窑头,开始放货"); if (_agv != null && _plc.EnterChargeAgv == _agv.Id) { if (_plc.IsEnterBatteryLock ) { _plc.IsEnterBatteryLock = false; _plc.EnterChargeAgv = null; } } //如果界面打开忽略《窑头》AGV货物状态和Plc货物状态则 直接发送棍台转动命令 if (ParamControl.Is_IgnoreHeadUnloadStatus || ((_plc.Sta_Material == EnumSta_Material.允许下料 || _plc.Sta_Material == EnumSta_Material.无货 || _plc.Sta_Material == EnumSta_Material.未知) && (_agv.Sta_Material == EnumagvSta_Material.送中 || _agv.Sta_Material == EnumagvSta_Material.货))) { if (_agv.Sta_Monitor != EnumSta_Monitor.电机反转) { _agv.SendOrdr(EnumType.料操作, EnumPara.agv下料启动); FLog.Log(_agv.Id + "启动车载辊台"); } else { if (BeginTime == null) { BeginTime = System.DateTime.Now; } _plc.SendOrdr(EnumType.料操作, EnumPara.窑头辊台上料中); _agv.SendOrdr(EnumType.料操作, EnumPara.agv下料启动); FLog.Log(_agv.Id + "启动车载辊台,启动窑头辊台"); } } //如果界面打开忽略《窑头》AGV货物状态,并且上面已经发送了指定时间的棍台转动时间 if ((ParamControl.Is_IgnoreHeadUnloadStatus && IsHeadRunTimeFinish()) || (//(_plc.Sta_Material == EnumSta_Material.允许下料 || _plc.Sta_Material == EnumSta_Material.未知) && _agv.Sta_Material == EnumagvSta_Material.无货)) { _plc.SendOrdr(EnumType.料操作, EnumPara.窑头辊台上料完成); _agv.SendOrdr(EnumType.料操作, EnumPara.agv辊台停止); FLog.Log(_agv.Id + "停止车载辊台,停止窑头辊台"); //如果界面打开忽略《窑头》AGV棍台状态,则进去结束任务 if (ParamControl.Is_IgnoreHeadStaStatus || _agv.Sta_Monitor == EnumSta_Monitor.电机停止 ) { //放货完成,解锁窑头 if (_plc != null //&& !ParamControl.Do_HeadPlcLock ) { _plc.IsLock = false; ParamControl.Do_HeadPlcLock = true; } ISetTaskSuc(); } } } else { ISetTaskSuc(); } return(""); } else if (_operType == EnumOper.充电) { if (!_plc.ExitFlag) { _plc.ExitFlag = true; } ISetTaskSuc(); return(""); } else if (_operType == EnumOper.无动作) { ISetTaskSuc(); return(""); } else if (_operType == EnumOper.对接完成) { if (_plc.IsExitBatteryLock && _plc.ExitChargeAgv == _agv.Id) { if (_plc.Site == "14") { ParamControl.Do_ExitHeadChargeLock = true; } //else if (_plc.Site == "11") //{ // ParamControl.Do_ExitEndChargeLock = true ; //} _plc.IsExitBatteryLock = false; _plc.ExitChargeAgv = null; ParamControl.HeadChargeAGV = _plc.ExitChargeAgv; ParamControl.HeadChargeLock = _plc.IsExitBatteryLock; } if (!_plc.ExitFlag) { _plc.ExitFlag = true; } ISetTaskSuc(); return(""); } } return(""); #endregion } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonAlter_Click(object sender, EventArgs e) { if (_isLogin) { #region if (buttonAlter.Text != "保 存") { WcfMainHelper.InitPara(_severIp, "", ""); List <DispatchBackMember> result = WcfMainHelper.GetDispatchList(); if (_devArea2 != null) { MessageBox.Show("当前客户端目前有派发任务未完成,不允许修改!", "提示"); return; } if (result != null) { foreach (var item in result) { if (item.TaskImf == _clientMark) { MessageBox.Show("当前客户端目前有派发任务未完成,不允许修改!", "提示"); return; } } } buttonAlter.Text = "保 存"; textBoxCurTar.ReadOnly = false; } else { if (Int32.TryParse(textBoxCurTar.Text, out _locTar)) { buttonAlter.Text = "修 改"; textBoxCurTar.ReadOnly = true; string Section = "CientConfig"; string key = "LoctionSite"; ConfigHelper.IniWriteValue(Section, key, _locTar.ToString()); InitPara(); MessageBox.Show("修改成功!", "提示"); } else { MessageBox.Show("输入站点格式有误!", "提示"); } } #endregion } else { MessageBox.Show("请先登录后再操作!", "提示"); } }
/// <summary> /// 初始化参数 /// </summary> public void InitPara() { _severIp = "192.168.6.79"; // 吕超电脑的IP //_severIp = "127.0.0.1"; WcfMainHelper.InitPara(_severIp, "", ""); }
/// <summary> /// 初始化参数 /// </summary> public void InitPara() { _severIp = "127.0.0.1"; WcfMainHelper.InitPara(_severIp, "", ""); }
/// <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()); }
/// <summary> /// 初始化参数 /// </summary> public void InitPara() { _severIp = "192.168.6.79"; WcfMainHelper.InitPara(_severIp, "", ""); }
/// <summary> /// 事务处理 /// </summary> public String DoWork() { if (_isSuc) { return(""); } _taskDispatch = WcfMainHelper.GetDispatch(Id); if (_taskDispatch == null) { FDispatchOrder dis = new FDispatchOrder(); dis.NavigationType = EnumNavigationType.Magnet; dis.Id = Id; dis.EndSite = _endSite; if (!string.IsNullOrEmpty(_startSite)) { dis.StartSiteList.Add(_startSite); } string back = ""; WcfMainHelper.StartDispatch(dis, out back); return(back); } else { ///确定此时任务的AGV if (_agv == null) { _agv = new F_AGV(_taskDispatch.Dev); } ///此次调度任务已经完成 if (_taskDispatch.Statue == EnumResultType.Suc) { if (_operType == EnumOper.取货) //窑尾 { ///当前AGV的到达的地标 与 棍台绑定地标一致 if (_agv.Site == _plc.Site) { if (_agv != null && _plc.EnterChargeAgv == _agv.Id) { if (_plc.IsEnterBatteryLock) { _plc.IsEnterBatteryLock = false; } } //如果界面打开忽略《窑尾》AGV货物状态和Plc货物状态则 直接发送棍台转动命令 if (ParamControl.Is_IgnoreTailUnloadStatus || (_plc.Sta_Material == EnumSta_Material.货 && (_agv.Sta_Material == EnumSta_Material.无货 || _agv.Sta_Material == EnumSta_Material.送中))) { if (BeginTime == null) { BeginTime = System.DateTime.Now; } _agv.SendOrdr(EnumType.料操作, EnumPara.agv上料启动); _plc.SendOrdr(EnumType.料操作, EnumPara.窑尾辊台允许下料); } //如果界面打开忽略《窑尾》AGV货物状态,并且上面已经发送了指定时间的棍台转动时间 if ((ParamControl.Is_IgnoreTailUnloadStatus && IsTailRunTimeFinish()) || (_plc.Sta_Material == EnumSta_Material.无货 && _agv.Sta_Material == EnumSta_Material.货)) { _agv.SendOrdr(EnumType.料操作, EnumPara.agv辊台停止); _plc.SendOrdr(EnumType.料操作, EnumPara.窑头辊台上料完成); //如果界面打开忽略《窑尾》AGV棍台状态,则进去结束任务 if (ParamControl.Is_IgnoreTailStaStatus || _agv.Sta_Monitor == EnumSta_Monitor.电机停止 ) { ISetTaskSuc(); } } } return(""); } else if (_operType == EnumOper.放货) //窑头 { ///当前AGV的到达的地标 与 棍台绑定地标一致 if (_agv.Site == _plc.Site) { if (_agv != null && _plc.EnterChargeAgv == _agv.Id) { if (_plc.IsEnterBatteryLock) { _plc.IsEnterBatteryLock = false; } } //如果界面打开忽略《窑头》AGV货物状态和Plc货物状态则 直接发送棍台转动命令 if (ParamControl.Is_IgnoreHeadUnloadStatus || ((_plc.Sta_Material == EnumSta_Material.货 || _plc.Sta_Material == EnumSta_Material.无货) && (_agv.Sta_Material == EnumSta_Material.送中 || _agv.Sta_Material == EnumSta_Material.货))) { if (BeginTime == null) { BeginTime = System.DateTime.Now; } _plc.SendOrdr(EnumType.料操作, EnumPara.窑头辊台上料中); _agv.SendOrdr(EnumType.料操作, EnumPara.agv下料启动); } //如果界面打开忽略《窑头》AGV货物状态,并且上面已经发送了指定时间的棍台转动时间 if ((ParamControl.Is_IgnoreHeadUnloadStatus && IsHeadRunTimeFinish()) || (_plc.Sta_Material == EnumSta_Material.货 && _agv.Sta_Material == EnumSta_Material.无货)) { _plc.SendOrdr(EnumType.料操作, EnumPara.窑头辊台上料完成); _agv.SendOrdr(EnumType.料操作, EnumPara.agv辊台停止); //如果界面打开忽略《窑头》AGV棍台状态,则进去结束任务 if (ParamControl.Is_IgnoreHeadStaStatus || _agv.Sta_Monitor == EnumSta_Monitor.电机停止 ) { ISetTaskSuc(); } } } return(""); } else if (_operType == EnumOper.充电) { ISetTaskSuc(); return(""); } else if (_operType == EnumOper.无动作) { ISetTaskSuc(); return(""); } else if (_operType == EnumOper.对接完成) { if (_plc.IsExitBatteryLock && _plc.ExitChargeAgv == _agv.Id) { _plc.IsExitBatteryLock = false; } if (_plc.ExitFlag) { _plc.ExitFlag = true; } ISetTaskSuc(); return(""); } } return(""); } }