/// <summary> /// 获取ETV最大作业范围 /// </summary> /// <param name="smg"></param> /// <returns></returns> public CScope GetTvScope(CDeviceStatusDto smg) { foreach (KeyValuePair <CDeviceStatusDto, CScope> pair in DicMaxWork) { if (pair.Key.devicecode == smg.devicecode) { return(pair.Value); } } return(null); }
/// <summary> /// 读故障文件具体位(车厅、ETV等设备) /// </summary> /// <param name="itemNum"></param> /// <param name="byteNum"></param> /// <param name="bitNum"></param> /// <returns></returns> private bool ReadBit(struTelegram struSendTelegram) { try { // 先通过设备表中的可接受指令 CDeviceStatusDto deviceStatus = CCommonMethods.myMethods.GetDeviceStatus(struSendTelegram.nEMSSendFlag, struSendTelegram.nEquipID); if (null != deviceStatus && 1 == deviceStatus.isavailable) { return(true); } // 再通过故障表中的可接受指令 CDeviceFaultDto deviceFault = CCommonMethods.myMethods.GetDeviceFault(struSendTelegram.nEMSSendFlag, struSendTelegram.nEquipID, struSendTelegram.nDeviceByteBit); if (null != deviceFault && 1 == deviceFault.isable) { return(true); } // 最后读取PLC中的可接受指令位值 int itemNum = (int)((Hashtable)(CConfigManagement.myPara.HashDeviceIDItemAdressIndex[struSendTelegram.nEMSSendFlag]))[struSendTelegram.nEquipID];//.GetDeviceItemAdressIndex(struSendTelegram.nEMSSendFlag, struSendTelegram.nEquipID); ;// 订阅Item索引号 if (-1 == itemNum || null == m_PLCServer) { return(false); } byte[] data = new byte[m_nByteLen]; bool bFlag = m_PLCServer.Read(ref data, itemNum); int count = m_retryCount;// 重发次数 while (!bFlag && 0 < count--) { Thread.Sleep(50);//4000 bFlag = m_PLCServer.Read(ref data, itemNum); } if (bFlag) { int byteNum = struSendTelegram.nDeviceByteBit / 10; int bitNum = struSendTelegram.nDeviceByteBit % 10; int value = Convert.ToInt32(data[byteNum]); value = value >> bitNum; value = value % 2; if (value == 1) { return(true); } } return(false); } catch (Exception ex) { CLOGException.Trace("WorkFlowLib.CSendTelegramAction.ReadBit 异常", CBaseMethods.MyBase.GetExceptionInfo(ex)); return(false); } }
private Dictionary <int, CSound> m_dicSound;//语音播放对象 public CRequestAction() { m_nSendIDMax = CConfigManagement.myPara.MaxTelegramID;//读取配置文件 lstAction = new List <CAbstractAction>(); m_PLCServer = null; m_telegram = null; m_lstTelegram = new List <struTelegram>(); // 发送报文列表 m_soundName = string.Empty; m_lstTableDto = new List <struTableDto>(); // SQL操作表格数据 m_ledContent = string.Empty; // LED显示文本内容 m_struTelegram = new struTelegram(); m_carLocationTBL = new CCarLocationDto(); m_deviceStatusTBL = new CDeviceStatusDto(); m_struHallEquip = new struHallEquips(); m_soundUpdateContent = string.Empty; m_dicSound = new Dictionary <int, CSound>(); }
/// <summary> /// 填充车厅信息界面 /// </summary> /// <param name="carLocation"></param> public void FillFormHall(CDeviceStatusDto hallStatusTable) { m_equipDeviceStatus = hallStatusTable; if (null == hallStatusTable) { MessageBox.Show("没有指定设备!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); //this.Close(); return; } int side; int.TryParse(hallStatusTable.deviceaddr.Substring(0, 1), out side); int column; int.TryParse(hallStatusTable.deviceaddr.Substring(1, 2), out column); int layer; int.TryParse(hallStatusTable.deviceaddr.Substring(3, 2), out layer); string strAvailable = "可接受新指令"; if (0 == hallStatusTable.isavailable) { strAvailable = "不可接受新指令"; } this.TxtWareHouse.Text = CStaticClass.ConvertWareHouse(hallStatusTable.warehouse); this.TxtCurTask.Text = CStaticClass.ConvertTaskType(hallStatusTable.tasktype);// 当前作业 this.TxtHallAddr.Text = side + "边" + column + "列" + layer + "层" + " (当前层: " + hallStatusTable.devicelayer + "层)"; this.TxtEquipID.Text = CStaticClass.ConvertHallDescp(hallStatusTable.warehouse, hallStatusTable.devicecode); this.TxtHallMode.Text = CStaticClass.ConvertDeviceMode(hallStatusTable.devicemode); this.TxtHallType.Text = CStaticClass.ConvertHallType(hallStatusTable.halltype); this.TxtCurTaskStatus.Text = CStaticClass.ConvertFlowNodeDescpType(hallStatusTable.currentnode); // 当前作业状态(详细情况 如:有车入库) this.TxtIsAvailable.Text = strAvailable; this.TxtICCardID.Text = hallStatusTable.iccode; this.TxtEntryAutoStep.Text = hallStatusTable.instep.ToString(); this.TxtExitAutoStep.Text = hallStatusTable.outstep.ToString(); if (hallStatusTable.tasktype == (int)EnmTaskType.Init) { this.TxtCurTaskStatus.Text = ""; } }
public TvMaxScope(CDeviceStatusDto pTV, IList <CDeviceStatusDto> pTvList, CScope physScope) { cETV = pTV; etvList = pTvList; mPhysicWorkScope = physScope; }
/// <summary> /// 填充ETV或者TV信息界面 /// </summary> /// <param name="carLocation"></param> public void FillFormEquip(CDeviceStatusDto equipStatusTable) { m_equipDeviceStatus = equipStatusTable; if (null == equipStatusTable) { MessageBox.Show("没有指定设备!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.Close(); return; } int side = 0; int column = 0; int layer = 0; if (null != equipStatusTable.deviceaddr) { if (0 < equipStatusTable.deviceaddr.Length) { int.TryParse(equipStatusTable.deviceaddr.Substring(0, 1), out side); } if (2 < equipStatusTable.deviceaddr.Length) { int.TryParse(equipStatusTable.deviceaddr.Substring(1, 2), out column); } } if (null != equipStatusTable.devicelayer) { layer = (int)equipStatusTable.devicelayer; } string strAble = "可用"; string strAvailable = "可接受指令"; if (0 == equipStatusTable.isable) { strAble = "不可用"; } if (0 == equipStatusTable.isavailable) { strAvailable = "不可接受指令"; } this.TxtWareHouse.Text = CStaticClass.ConvertWareHouse(equipStatusTable.warehouse); this.TxtICCardID.Text = equipStatusTable.iccode; this.TxtCurTask.Text = CStaticClass.ConvertTaskType(equipStatusTable.tasktype); // 当前作业 this.TxtEquipAddr.Text = side + "边," + column + "列," + layer + "层"; // equipStatusTable.deviceaddr; if ((int)EnmSMGType.ETV != equipStatusTable.devicetype) { this.TxtEquipID.Text = CStaticClass.ConvertHallDescp(equipStatusTable.warehouse, equipStatusTable.devicecode); } else { this.TxtEquipID.Text = CStaticClass.ConvertETVDescp(equipStatusTable.devicecode); } this.TxtEquipMode.Text = CStaticClass.ConvertDeviceMode(equipStatusTable.devicemode); this.TxtCurTaskStatus.Text = CStaticClass.ConvertFlowNodeDescpType(equipStatusTable.currentnode);; // 当前作业状态(详细情况 如:正在装载) this.TxtIsable.Text = strAble; this.TxtIsavailable.Text = strAvailable; this.TxtRunStep.Text = equipStatusTable.runstep.ToString(); this.TxtLoadStep.Text = equipStatusTable.instep.ToString(); this.TxtUnloadStep.Text = equipStatusTable.outstep.ToString(); if (equipStatusTable.tasktype == (int)EnmTaskType.Init) { this.TxtCurTaskStatus.Text = ""; } }
/// <summary> /// 装载、卸载、移动下发时,避让处理 /// </summary> /// <param name="smg"></param> /// <param name="toAddrs"></param> /// <returns></returns> public bool DealAvoid(CDeviceStatusDto smg, string toAddrs, string iccode) { List <CDeviceStatusDto> Etvs = CCommonMethods.myMethods.GetEtvsByLayer((int)smg.warehouse, (int)smg.devicelayer); int nWarehouse = smg.warehouse; int curEtvCol = CBaseMethods.MyBase.GetColumnByAddrs(smg.deviceaddr); int curToCol = CBaseMethods.MyBase.GetColumnByAddrs(toAddrs); //终点列 int curMax; int curMin; #region if (curEtvCol > curToCol) { curMax = curEtvCol; curMin = curToCol - 3; if (curMin < 1) { curMin = 1; } } else { curMax = curToCol + 3; if (curMax > 40) { curMax = 40; } curMin = curEtvCol; } #endregion //对面ETV CDeviceStatusDto otherEtv = null; #region foreach (CDeviceStatusDto et in Etvs) { if (et.devicecode != smg.devicecode) { otherEtv = et; break; } } #endregion if (otherEtv == null) { return(false); } int otherCol = CBaseMethods.MyBase.GetColumnByAddrs(otherEtv.deviceaddr); #region 列数与实际不合的,先不让其去执行 bool isTrue = true; if (smg.devicecode < otherEtv.devicecode) { if (curEtvCol < otherCol) { isTrue = false; } } else { if (curEtvCol > otherCol) { isTrue = false; } } if (!isTrue) { string msg = String.Format("异常: ETV{0} 当前列{1},ETV{2} 当前列{3}", smg.devicecode, curEtvCol, otherEtv.devicecode, otherCol); CWException.WriteLog(msg, 4); return(false); } #endregion if (otherEtv.tasktype == (int)EnmTaskType.Init) { #region if (curMin < otherCol && otherCol < curMax) { if (otherEtv.isable == 0) { return(false); } #region 生成移动并下发 string oLayer = Convert.ToString(otherEtv.devicelayer).PadLeft(2, '0'); string oList = ""; if (curEtvCol > curToCol) //需向左避让 { oList = curMin.ToString().PadLeft(2, '0'); } else { oList = curMax.ToString().PadLeft(2, '0'); } string toAddress = string.Concat("1", oList, oLayer); //建立移动作业 struTelegram moveTask = new struTelegram(); moveTask.nEMSSendFlag = nWarehouse; moveTask.nPLCSendFlag = 0; moveTask.nTelegramType = 11; moveTask.nSubTypeEMS = 1; moveTask.nSubTypePLC = 0; moveTask.nEquipID = otherEtv.devicecode; if (!CBaseMethods.MyBase.IsEmpty(iccode)) { moveTask.strICCardID = iccode; } moveTask.strSrcLocAddr = otherEtv.deviceaddr; moveTask.strDestLocAddr = toAddress; moveTask.nTelegramID = new CRequestAction().MessageID; moveTask.nEndFlag = 9999; moveTask.nMasterType = (int)EnmTaskType.AvoidMove; //打包并发送报文 Int16[] movTelegram; m_telegramParser.PackTelegram(out movTelegram, moveTask); if (otherEtv.isavailable == 1) { otherEtv.tasktype = (int)EnmTaskType.AvoidMove; otherEtv.iccode = iccode; otherEtv.prevnode = null; otherEtv.currentnode = null; otherEtv.scrloc = otherEtv.deviceaddr; otherEtv.desccloc = toAddress; //更新数据 new CDBEditor().updateTableDto(otherEtv); DealSendTelegram(movTelegram, nWarehouse); } else { //加入队列 InsertWorkQueue(movTelegram, moveTask); } #endregion } return(true); #endregion } else //对面的TV在作业, { #region 对面的TV有作业,则如果有交叉的,当前先不下发,让其先执行完其作业 string oToAddrs = ""; #region if (otherEtv.currentnode == (int)EnmFlowNodeDescp.Load) { oToAddrs = otherEtv.scrloc; } else { oToAddrs = otherEtv.desccloc; } if (CBaseMethods.MyBase.IsEmpty(oToAddrs)) { CWException.WriteLog(string.Format("另一TV{0},作业类型:{1},卡号:{2},判断避让时其源/目的地址为空", otherEtv.devicecode, otherEtv.tasktype, otherEtv.iccode == null ? "" : otherEtv.iccode), 4); return(true); } #endregion int toColumn = CBaseMethods.MyBase.GetColumnByAddrs(oToAddrs); #region 处于等待卸载时,如果路径出现冲突,也可进行避让作业 if (smg.tasktype != (int)EnmTaskType.Init) //要下发(14,1)时处理 { if (smg.currentnode == (int)EnmFlowNodeDescp.WillUnLoad && otherEtv.currentnode == (int)EnmFlowNodeDescp.WillUnLoad) { //优先1#下发 if (smg.region == 2) { return(false); } } if (otherEtv.currentnode == (int)EnmFlowNodeDescp.WillUnLoad) { if (curMin < otherCol && otherCol < curMax) { if (otherEtv.isavailable == 0) { return(false); } #region 生成移动并下发,直接下发 string oLayer = Convert.ToString(otherEtv.devicelayer).PadLeft(2, '0'); string oList = ""; if (curEtvCol > curToCol) //需向左避让 { oList = curMin.ToString().PadLeft(2, '0'); } else { oList = curMax.ToString().PadLeft(2, '0'); } string toAddress = string.Concat("1", oList, oLayer); //建立移动作业 struTelegram moveTask = new struTelegram(); moveTask.nEMSSendFlag = nWarehouse; moveTask.nPLCSendFlag = 0; moveTask.nTelegramType = 11; moveTask.nSubTypeEMS = 1; moveTask.nSubTypePLC = 0; //给假值 moveTask.strCarSize = "123"; moveTask.nWheelbase = 2600; moveTask.overallLg = 4500; moveTask.overHang = 900; moveTask.nEquipID = otherEtv.devicecode; if (!CBaseMethods.MyBase.IsEmpty(iccode)) { moveTask.strICCardID = iccode; } moveTask.strSrcLocAddr = otherEtv.deviceaddr; moveTask.strDestLocAddr = toAddress; moveTask.nTelegramID = new CRequestAction().MessageID; moveTask.nEndFlag = 9999; moveTask.nMasterType = (int)EnmTaskType.ForceMove; //打包并发送报文 Int16[] movTelegram; m_telegramParser.PackTelegram(out movTelegram, moveTask); //下发移动避让作业 DealSendTelegram(movTelegram, nWarehouse); //更改其TV的可用性 otherEtv.isavailable = 0; new CDBEditor().updateTableDto(otherEtv); #endregion } return(true); } } #endregion #region 如果当前TV还没有进行动作,则这里就限制其下发 if (otherCol >= curMin && otherCol <= curMax) { return(false); } if (toColumn >= curMin && toColumn <= curMax) { return(false); } if (otherCol > curMax) { if (toColumn < curMax) { return(false); } } if (toColumn > curMax) { if (toColumn < curMax) { return(false); } } if (otherCol < curMin) { if (toColumn > curMin) { return(false); } } if (toColumn < curMin) { if (otherCol > curMin) { return(false); } } #endregion #endregion } return(true); }
/// <summary> /// 报文下发 /// </summary> /// <param name="objRequestParam"></param> public void TelegramSender(object objRequestParam) { try { CRequestAction RequestParam = (CRequestAction)objRequestParam; m_PLCServer = RequestParam.PLCServer; // 发送报文 foreach (struTelegram struSendTelegram in RequestParam.lstTelegram) { CWException.WriteLog(string.Format("Telegram ({0},{1}) will send ,devicecode:{2},iccode:{3}", struSendTelegram.nTelegramType, struSendTelegram.nSubTypeEMS, struSendTelegram.nEquipID, struSendTelegram.strICCardID), 4); Int16[] objTelegram; m_telegramParser.PackTelegram(out objTelegram, struSendTelegram); int warehouse = struSendTelegram.nEMSSendFlag; int equipID = struSendTelegram.nEquipID; //存在该位(nDeviceByteBit),表示在下发时要判断设备是否允许下发报文否,如果不存在该位,则可以直接下发当前报文 if (0 != struSendTelegram.nDeviceByteBit) { #region CDeviceStatusDto smg = CCommonMethods.myMethods.GetDeviceStatus(warehouse, equipID); #region if (smg == null) { //如果不存在设备号,则表示异常,先加入队列 CWException.WriteLog(string.Format("报文({0},{1})没有设备号,其卡号:{2}", struSendTelegram.nTelegramType, struSendTelegram.nSubTypeEMS, struSendTelegram.strICCardID), 4); //加入队列 InsertWorkQueue(objTelegram, struSendTelegram); continue; } #endregion if (smg.devicetype == (int)EnmSMGType.Hall) { #region 允许下发或加入队列 if (smg.devicemode == (int)EnmModel.Automatic && smg.isable == 1 && smg.isavailable == 1 && smg.tasktype == (int)EnmTaskType.Init) { smg.tasktype = struSendTelegram.nMasterType; smg.iccode = struSendTelegram.strICCardID; smg.prevnode = null; smg.currentnode = null; smg.scrloc = struSendTelegram.strSrcLocAddr; smg.desccloc = struSendTelegram.strDestLocAddr; new CDBEditor().updateTableDto(smg); //下发报文 DealSendTelegram(objTelegram, warehouse); } else { //加入队列 InsertWorkQueue(objTelegram, struSendTelegram); } #endregion } else if (smg.devicetype == (int)EnmSMGType.ETV) { #region 将(14,1)加入队列 if (struSendTelegram.nTelegramType == 14 && struSendTelegram.nSubTypeEMS == 1) { CWException.WriteLog(string.Format("warehouse:{0}, devicecode:{1} has telegram (14,1) add workqueue! ", smg.warehouse, smg.devicecode), 4); InsertWorkQueue(objTelegram, struSendTelegram); continue; } #endregion #region 判断避让, 执行(13,1)(11,1) if (smg.devicemode == (int)EnmModel.Automatic && smg.isable == 1 && smg.isavailable == 1 && smg.tasktype == (int)EnmTaskType.Init) { string toAddrss = ""; if (struSendTelegram.nTelegramType == 11 && struSendTelegram.nSubTypeEMS == 1) { toAddrss = struSendTelegram.strDestLocAddr; } else { toAddrss = struSendTelegram.strSrcLocAddr; } if (this.DealAvoid(smg, toAddrss, struSendTelegram.strICCardID)) { //允许下发,绑定设备,下发报文 smg.tasktype = struSendTelegram.nMasterType; smg.iccode = struSendTelegram.strICCardID; smg.prevnode = null; smg.currentnode = null; if (struSendTelegram.nMasterType != (int)EnmTaskType.MoveEquipTask) { smg.currentnode = (int)EnmFlowNodeDescp.Load; } smg.scrloc = struSendTelegram.strSrcLocAddr; smg.desccloc = struSendTelegram.strDestLocAddr; new CDBEditor().updateTableDto(smg); //下发报文 DealSendTelegram(objTelegram, warehouse); continue; } } //加入队列 InsertWorkQueue(objTelegram, struSendTelegram); #endregion } continue; #endregion } // 发送报文 DealSendTelegram(objTelegram, warehouse); } } catch (Exception ex) { CLOGException.Trace("AbstractActionLib.CTelegramSender.TelegramSender 异常", CBaseMethods.MyBase.GetExceptionInfo(ex)); } }