Пример #1
0
 public void Copy(ref CtlNodeStatus targetNode)
 {
     // targetNode =new CtlNodeStatus(this.NodeName);
     targetNode.NodeName       = nodeName;
     targetNode.ProductBarcode = this.productBarcode;
     targetNode.Status         = this.status;
     targetNode.ProductExist   = this.productExist;
     targetNode.StatDescribe   = this.statDescribe;
 }
Пример #2
0
        /// <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);
        }