Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="filename"></param>
        public void LoadFromFile(string filename)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(filename);

            // 2010-09-10
            //
            // device defines node is null, file is not devicedefine file
            //
            XmlNode deviceDefinesNode = doc.SelectSingleNode(DeviceDefineNodeNames.DeviceDefineCollection);

            if (deviceDefinesNode == null)
            {
                logger.Error("load " + filename + " fail");
                return;
            }

            foreach (XmlNode deviceDefineNode in deviceDefinesNode.ChildNodes)
            {
                if (deviceDefineNode.Name == DeviceDefineNodeNames.DeviceDefine)
                {
                    string deviceType = XmlHelper.GetAttribute((XmlElement)deviceDefineNode,
                                                               DeviceDefineNodeNames.DeviceType);
                    string deviceText = XmlHelper.GetAttribute((XmlElement)deviceDefineNode,
                                                               DeviceDefineNodeNames.DeviceText);

                    // TODO: remove xmlOperaFactory DeviceDefineCollection
                    //
                    // TODO: 2010-07-28 add device parameter define
                    //
                    DeviceDefine dd = new DeviceDefine(deviceType, deviceText);

                    dd.DevcieDefineNode = deviceDefineNode;

                    XmlNode paramDefinesNode = deviceDefineNode.SelectSingleNode(ParameterNodeNames.ParameterDefineCollection);
                    if (paramDefinesNode != null)
                    {
                        ParameterDefineCollection paramDefines = XmlModbusParameterDefineBuilder.BuildParameterDefineCollection(paramDefinesNode);
                        dd.ParameterDefineCollection = paramDefines;
                    }

                    this.DeviceDefineCollection.Add(dd);

                    //this.CommuniSoft.DeviceDefineCollection.Add(dd);
                }
            }
        }
Beispiel #2
0
        // TODO:  update datasource 2009-12-26
        //        datasource is db record or xml file ...
        //
        // TODO: add dbdevice?
        // a device create from dbdevice(datasoure)
        //
        #region Members
        #endregion //Members

        #region Device
        /// <summary>
        ///
        /// </summary>
        public Device(DeviceDefine deviceDefine, string name, int address)
        {
            this._deviceDefine = deviceDefine;
            this._name         = name;
            this.m_address     = address;
        }