/// <summary> /// 控制流程的命令数据提交 /// </summary> /// <param name="reStr"></param> /// <returns></returns> public virtual bool NodeCmdCommit(bool diffSnd, ref string reStr) { if (!SysCfg.SysCfgModel.SimMode) { int blockNum = this.dicCommuDataDB1.Count(); if (SysCfg.SysCfgModel.PlcCommSynMode) { if (!plcRW.IsConnect) { if (!plcRW.ConnectPLC(ref reStr)) { ThrowErrorStat(this.nodeName + "PLC连接失败", EnumNodeStatus.设备故障); return(false); } } if (!plcRW.WriteMultiDB(this.db1StartAddr, blockNum, this.db1ValsToSnd)) { ThrowErrorStat("发送设备命令失败!", EnumNodeStatus.设备故障); return(false); } for (int i = 0; i < blockNum; i++) { int commID = i + 1; this.dicCommuDataDB1[commID].Val = this.db1ValsToSnd[i]; // this.db1ValsReal[i] = vals[i]; } } else { int addrSt = int.Parse(this.db1StartAddr.Substring(1)) - 2000; for (int i = 0; i < blockNum; i++) { int commID = i + 1; this.dicCommuDataDB1[commID].Val = this.db1ValsToSnd[i]; plcRW.Db1Vals[addrSt + i] = this.db1ValsToSnd[i]; // this.db1ValsReal[i] = vals[i]; } } } else { for (int i = 0; i < dicCommuDataDB1.Count(); i++) { int commID = i + 1; PLCDataDef commObj = dicCommuDataDB1[commID]; commObj.Val = db1ValsToSnd[i]; } } return(true); }
public DataTable GetDB2DataDetail() { DataTable dt = new DataTable(); dt.Columns.Add("索引"); dt.Columns.Add("地址"); dt.Columns.Add("内容"); dt.Columns.Add("描述"); int index = 1; for (int i = 0; i < dicCommuDataDB2.Count(); i++) { PLCDataDef commObj = dicCommuDataDB2[i + 1]; dt.Rows.Add(index++, commObj.DataAddr, commObj.Val, commObj.DataDescription); } return(dt); }
/// <summary> /// /// </summary> /// <param name="xe"></param> /// <returns></returns> public virtual bool BuildCfg(XElement xe, ref string reStr) { this.nodeID = xe.Attribute("id").Value; this.nodeEnabled = bool.Parse(xe.Attribute("enabled").Value); XElement baseDataXE = xe.Element("BaseDatainfo"); if (baseDataXE == null) { reStr = this.nodeID + ",没有BaseDatainfo节点配置信息"; return(false); } XAttribute attr = baseDataXE.Attribute("barcodeScanner"); if (attr != null) { this.barcodeID = int.Parse(attr.Value); } attr = baseDataXE.Attribute("rfid"); if (attr != null) { this.rfidID = byte.Parse(attr.Value); } attr = baseDataXE.Attribute("plcID"); if (attr != null) { this.plcID = int.Parse(attr.Value); } attr = baseDataXE.Attribute("mesStep"); if (attr != null) { this.mesProcessStepID.Clear(); this.mesProcessStepID.AddRange(attr.Value.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)); } this.nodeName = baseDataXE.Element("NodeName").Value; //mes nodeid,nodename XElement db1XE = baseDataXE.Element("DB1Addr"); string db1StartStr = db1XE.Attribute("addrStart").Value; this.db1StartAddr = db1StartStr; int db1Start = int.Parse(db1StartStr.Substring(1)); int db1BlockNum = int.Parse(db1XE.Attribute("blockNum").Value); int db1ID = 1; this.dicCommuDataDB1 = new Dictionary <int, PLCDataDef>(); db1ValsReal = new Int16[db1BlockNum]; db1ValsToSnd = new Int16[db1BlockNum]; for (int i = 0; i < db1BlockNum; i++) { PLCDataDef commData = new PLCDataDef(); commData.CommuID = db1ID++; commData.CommuMethod = EnumCommMethod.PLC_MIT_COMMU; commData.DataByteLen = 2; commData.DataDescription = ""; commData.DataTypeDef = EnumCommuDataType.DEVCOM_short; commData.Val = 0; commData.DataAddr = "D" + (db1Start + i).ToString(); dicCommuDataDB1[commData.CommuID] = commData; //db1Vals[i] = 0; } XElement db2XE = baseDataXE.Element("DB2Addr"); string db2StartStr = db2XE.Attribute("addrStart").Value; this.db2StartAddr = db2StartStr; int db2Start = int.Parse(db2StartStr.Substring(1)); int db2BlockNum = int.Parse(db2XE.Attribute("blockNum").Value); int db2ID = 1; this.dicCommuDataDB2 = new Dictionary <int, PLCDataDef>(); db2Vals = new Int16[db2BlockNum]; for (int i = 0; i < db2BlockNum; i++) { PLCDataDef commData = new PLCDataDef(); commData.CommuID = db2ID++; commData.CommuMethod = EnumCommMethod.PLC_MIT_COMMU; commData.DataByteLen = 2; commData.DataDescription = ""; commData.DataTypeDef = EnumCommuDataType.DEVCOM_short; commData.Val = 0; db2Vals[i] = 0; commData.DataAddr = "D" + (db2Start + i).ToString(); dicCommuDataDB2[commData.CommuID] = commData; } XElement selfDataXE = xe.Element("SelfDatainfo"); if (selfDataXE != null) { if (selfDataXE.Element("Db1Desc") != null) { string dbDesc = selfDataXE.Element("Db1Desc").Value.ToString(); string[] dbDescArray = dbDesc.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); if (dbDescArray != null && dbDescArray.Count() > 0) { for (int i = 0; i < Math.Min(dbDescArray.Count(), this.dicCommuDataDB1.Count()); i++) { this.dicCommuDataDB1[1 + i].DataDescription = dbDescArray[i]; } } } if (selfDataXE.Element("Db2Desc") != null) { string dbDesc = selfDataXE.Element("Db2Desc").Value.ToString(); string[] dbDescArray = dbDesc.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); if (dbDescArray != null && dbDescArray.Count() > 0) { for (int i = 0; i < Math.Min(dbDescArray.Count(), this.dicCommuDataDB2.Count()); i++) { this.dicCommuDataDB2[1 + i].DataDescription = dbDescArray[i]; } } } } this.currentStat = new CtlNodeStatus(nodeName); this.currentStat.Status = EnumNodeStatus.设备空闲; this.currentStat.StatDescribe = "空闲状态"; return(true); }
public virtual bool BuildCfg(XElement xe, ref string reStr) { this.nodeID = xe.Attribute("id").Value; XElement baseDataXE = xe.Element("BaseDatainfo"); if (baseDataXE == null) { reStr = this.nodeID + ",没有BaseDatainfo节点配置信息"; return(false); } this.nodeName = baseDataXE.Element("NodeName").Value; //mes nodeid,nodename XElement db1XE = baseDataXE.Element("DB1Addr"); string db1StartStr = db1XE.Attribute("addrStart").Value; this.db1StartAddr = db1StartStr; int db1Start = int.Parse(db1StartStr.Substring(1)); int db1BlockNum = int.Parse(db1XE.Attribute("blockNum").Value); int db1ID = 1; this.dicCommuDataDB1 = new Dictionary <int, PLCDataDef>(); db1ValsReal = new Int16[db1BlockNum]; db1ValsToSnd = new Int16[db1BlockNum]; for (int i = 0; i < db1BlockNum; i++) { PLCDataDef commData = new PLCDataDef(); commData.CommuID = db1ID++; commData.CommuMethod = EnumCommMethod.PLC_MIT_COMMU; commData.DataByteLen = 2; commData.DataDescription = ""; commData.DataTypeDef = EnumCommuDataType.DEVCOM_short; commData.Val = 0; commData.DataAddr = "D" + (db1Start + i).ToString(); dicCommuDataDB1[commData.CommuID] = commData; //db1Vals[i] = 0; } XElement db2XE = baseDataXE.Element("DB2Addr"); string db2StartStr = db2XE.Attribute("addrStart").Value; this.db2StartAddr = db2StartStr; int db2Start = int.Parse(db2StartStr.Substring(1)); int db2BlockNum = int.Parse(db2XE.Attribute("blockNum").Value); int db2ID = 1; this.dicCommuDataDB2 = new Dictionary <int, PLCDataDef>(); db2Vals = new Int16[db2BlockNum]; for (int i = 0; i < db2BlockNum; i++) { PLCDataDef commData = new PLCDataDef(); commData.CommuID = db2ID++; commData.CommuMethod = EnumCommMethod.PLC_MIT_COMMU; commData.DataByteLen = 2; commData.DataDescription = ""; commData.DataTypeDef = EnumCommuDataType.DEVCOM_short; commData.Val = 0; db2Vals[i] = 0; commData.DataAddr = "D" + (db2Start + i).ToString(); dicCommuDataDB2[commData.CommuID] = commData; } XElement selfDataXE = xe.Element("SelfDatainfo"); if (selfDataXE != null) { if (selfDataXE.Element("Db1Desc") != null) { string dbDesc = selfDataXE.Element("Db1Desc").Value.ToString(); string[] dbDescArray = dbDesc.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); if (dbDescArray != null && dbDescArray.Count() > 0) { for (int i = 0; i < Math.Min(dbDescArray.Count(), this.dicCommuDataDB1.Count()); i++) { this.dicCommuDataDB1[1 + i].DataDescription = dbDescArray[i]; } } } if (selfDataXE.Element("Db2Desc") != null) { string dbDesc = selfDataXE.Element("Db2Desc").Value.ToString(); string[] dbDescArray = dbDesc.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); if (dbDescArray != null && dbDescArray.Count() > 0) { for (int i = 0; i < Math.Min(dbDescArray.Count(), this.dicCommuDataDB2.Count()); i++) { this.dicCommuDataDB2[1 + i].DataDescription = dbDescArray[i]; } } } } this.dicCommuDataDB1[1].DataDescription = "参数写入标志,1:复位,2:写入完成"; this.dicCommuDataDB1[2].DataDescription = "任务处理完成标志,1:复位,2:处理完成,3:撤销处理完成"; this.dicCommuDataDB1[3].DataDescription = "任务类型标志,1:产品入库,2:空筐入库,3:产品出库,4:空筐出库,5:移库"; this.dicCommuDataDB1[4].DataDescription = "入口编号(从1开始)"; this.dicCommuDataDB1[5].DataDescription = "出口编号(从1开始)"; this.dicCommuDataDB1[6].DataDescription = "货位编号 :排(从1开始)"; this.dicCommuDataDB1[7].DataDescription = "货位编号 :列(从1开始)"; this.dicCommuDataDB1[8].DataDescription = "货位编号 :层(从1开始)"; this.dicCommuDataDB1[9].DataDescription = "货位编号2(移库时用) :排(从1开始)"; this.dicCommuDataDB1[10].DataDescription = "货位编号2 (移库时用):列(从1开始)"; this.dicCommuDataDB1[11].DataDescription = "位编号2(移库时用) :层(从1开始)"; this.dicCommuDataDB1[12].DataDescription = "1:故障处理未完成,2:故障处理完成"; this.dicCommuDataDB1[13].DataDescription = "预留参数1"; this.dicCommuDataDB1[14].DataDescription = "预留参数2"; this.dicCommuDataDB1[15].DataDescription = "预留参数3"; return(true); }
/// <summary> /// /// </summary> /// <param name="xe"></param> /// <returns></returns> public virtual bool BuildCfg(XElement xe, ref string reStr) { this.nodeID = xe.Attribute("id").Value; XElement baseDataXE = xe.Element("BaseDatainfo"); if (baseDataXE == null) { reStr = this.nodeID + ",没有BaseDatainfo节点配置信息"; return(false); } this.nodeName = baseDataXE.Element("NodeName").Value; //mes nodeid,nodename XElement mesXE = baseDataXE.Element("MESDef"); if (mesXE != null) { this.mesNodeID = mesXE.Attribute("id").Value; this.mesNodeName = mesXE.Attribute("name").Value; } XElement db1XE = baseDataXE.Element("DB1Addr"); string db1StartStr = db1XE.Attribute("addrStart").Value; this.db1StartAddr = db1StartStr; int db1Start = int.Parse(db1StartStr.Substring(1)); int db1BlockNum = int.Parse(db1XE.Attribute("blockNum").Value); int db1ID = 1; this.dicCommuDataDB1 = new Dictionary <int, PLCDataDef>(); db1ValsReal = new Int16[db1BlockNum]; db1ValsToSnd = new Int16[db1BlockNum]; for (int i = 0; i < db1BlockNum; i++) { PLCDataDef commData = new PLCDataDef(); commData.CommuID = db1ID++; commData.CommuMethod = EnumCommMethod.PLC_MIT_COMMU; commData.DataByteLen = 2; commData.DataDescription = ""; commData.DataTypeDef = EnumCommuDataType.DEVCOM_short; commData.Val = 0; commData.DataAddr = "D" + (db1Start + i).ToString(); dicCommuDataDB1[commData.CommuID] = commData; //db1Vals[i] = 0; } XElement db2XE = baseDataXE.Element("DB2Addr"); string db2StartStr = db2XE.Attribute("addrStart").Value; this.db2StartAddr = db2StartStr; int db2Start = int.Parse(db2StartStr.Substring(1)); int db2BlockNum = int.Parse(db2XE.Attribute("blockNum").Value); int db2ID = 1; this.dicCommuDataDB2 = new Dictionary <int, PLCDataDef>(); db2Vals = new Int16[db2BlockNum]; for (int i = 0; i < db2BlockNum; i++) { PLCDataDef commData = new PLCDataDef(); commData.CommuID = db2ID++; commData.CommuMethod = EnumCommMethod.PLC_MIT_COMMU; commData.DataByteLen = 2; commData.DataDescription = ""; commData.DataTypeDef = EnumCommuDataType.DEVCOM_short; commData.Val = 0; db2Vals[i] = 0; commData.DataAddr = "D" + (db2Start + i).ToString(); dicCommuDataDB2[commData.CommuID] = commData; } this.currentStat = new CtlNodeStatus(nodeName); this.currentStat.Status = EnumNodeStatus.设备空闲; this.currentStat.StatDescribe = "空闲状态"; return(true); }