Example #1
0
        private void LoadTopologyElement(XmlElement topology)
        {
            //Load base attribute
            mAbstractedLevel = topology.GetAttribute(XmlTag.TAG_ABSTRACTEDLEVEL, "");

            //Load sensors list
            XmlNodeList sensorNodes = topology.GetElementsByTagName(XmlTag.TAG_SENSOR);
            foreach (XmlElement element in sensorNodes)
            {
                WSNSensorIndie sensor = new WSNSensorIndie();
                sensor.LoadFromXML(element);
                mSensors.Add(sensor);
            }

            //Load channels list
            XmlNodeList channelNodes = topology.GetElementsByTagName(XmlTag.TAG_CHANNEL);
            foreach (XmlElement element in channelNodes)
            {
                WSNChannelIndie channel = new WSNChannelIndie();
                channel.LoadFromXML(element);
                mChannels.Add(channel);
            }
        }
Example #2
0
        public override XmlDocument GenerateXML(params bool[] values)
        {
            XmlDocument docOut = null;
            do
            {
                if (mLoaded == false)
                    break;
                docOut = new XmlDocument();

                // WSN
                #region generate kwsn xml file
                mXRoot = docOut.CreateElement(XmlTag.TAG_WSN);
                docOut.AppendChild(mXRoot);

                // Network
                XmlElement network = docOut.CreateElement(XmlTag.TAG_NETWORK);
                mXRoot.AppendChild(network);

                //Declaration
                mDeclaration = docOut.CreateElement(XmlTag.TAG_DECLARATION);
                mDeclaration.InnerText = "";
                mXRoot.AppendChild(mDeclaration);

                #region get kwsn components from the extended pn file

                XmlElement models = (mPNDoc.ChildNodes[0] as XmlElement).GetElementsByTagName(XmlTag.TAG_MODELS)[0] as XmlElement;

                foreach (XmlElement model in models.ChildNodes)
                {
                    String modelName = model.GetAttribute(XmlTag.ATTR_NAME);

                    List<WSNSensorIndie> _sensors = new List<WSNSensorIndie>();
                    List<WSNChannelIndie> _channels = new List<WSNChannelIndie>();

                    XmlElement topology = model.GetElementsByTagName(XmlTag.TAG_TOPOLOGY)[0] as XmlElement;

                    //Load base attribute
                    String _abstractedLevel = topology.GetAttribute(XmlTag.TAG_ABSTRACTEDLEVEL, "");

                    //Load sensors list
                    XmlNodeList sensorNodes = topology.GetElementsByTagName(XmlTag.TAG_SENSOR);
                    foreach (XmlElement element in sensorNodes)
                    {
                        WSNSensorIndie sensor = new WSNSensorIndie();
                        sensor.LoadFromXML(element);
                        _sensors.Add(sensor);
                    }

                    //Load channels list
                    XmlNodeList channelNodes = topology.GetElementsByTagName(XmlTag.TAG_CHANNEL);
                    foreach (XmlElement element in channelNodes)
                    {
                        WSNChannelIndie channel = new WSNChannelIndie();
                        channel.LoadFromXML(element);
                        _channels.Add(channel);
                    }

                    network.AppendChild(GenerateCanvasXml(docOut, modelName, _sensors, _channels));
                #endregion

                }
                #endregion
            } while (false);

            return docOut;
        }