Ejemplo n.º 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;
 }
Ejemplo n.º 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;
            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);
        }