Esempio n. 1
0
        public void scenelayout(ref List <NewRoom> rooms)
        {
            XmlDocument xmldoc = new XmlDocument();

            xmldoc.Load(xmlname);
            XmlNodeList roomnodes = xmldoc.GetElementsByTagName("RoomNo");

            if (roomnodes != null)
            {
                foreach (XmlNode roomnode in roomnodes)
                {
                    NewRoom room = new NewRoom();
                    room.roomname = roomnode.Attributes["Name"].Value;
                    XmlNodeList typenodes = roomnode.ChildNodes;
                    foreach (XmlNode typenode in typenodes)
                    {
                        if (typenode.Name == "Ground")
                        {
                            XmlNodeList nodes = typenode.ChildNodes;
                            foreach (XmlNode node in nodes)
                            {
                                string name = node.Attributes["Name"].Value;
                                string positon;
                                string size;
                                if (name == "Floor")
                                {
                                    size    = node.SelectSingleNode("SizeParam").InnerXml;
                                    positon = node.SelectSingleNode("Position").InnerXml;
                                    room.setfloor(size, positon);
                                }
                                else if (name == "Outwall")
                                {
                                    size    = node.SelectSingleNode("SizeParam").InnerXml;
                                    positon = node.SelectSingleNode("Position").InnerXml;
                                    room.setoutwall(size, positon);
                                }
                                else if (name == "Inwall")
                                {
                                    size    = node.SelectSingleNode("SizeParam").InnerXml;
                                    positon = node.SelectSingleNode("Position").InnerXml;
                                    room.setinwall(size, positon);
                                }
                            }
                        }
                        else if (typenode.Name == "Device")
                        {
                            XmlNodeList nodes = typenode.ChildNodes;

                            foreach (XmlNode node in nodes)
                            {
                                string RFID    = node.Attributes["RFID"].Value;
                                string positon = node.Attributes["Position"].Value;

                                if (node.Name == "Cabinet")
                                {
                                    XmlNodeList unodes  = node.ChildNodes;
                                    string[]    statues = new string[42];
                                    for (int j = 0; j < 42; j++)
                                    {
                                        statues[j] = "0";
                                    }
                                    foreach (XmlNode unode in unodes)
                                    {
                                        if (unode.Name == "Server")
                                        {
                                            string URFID     = unode.Attributes["RFID"].Value;
                                            string UPosition = unode.Attributes["Position"].Value;
                                            string UType     = unode.Attributes["Type"].Value;
                                            int    tt        = Convert.ToInt32(UPosition) - 1;
                                            int    yy        = Convert.ToInt32(UType);
                                            for (int i = 0; i < yy; i++)
                                            {
                                                statues[tt + i] = "1";
                                            }
                                            room.setserver(yy, positon, URFID, RFID, tt);
                                        }
                                    }
                                    room.setcabinet(statues, positon, RFID);
                                }
                                else if (node.Name == "Ups")
                                {
                                    room.setups(positon, RFID);
                                }
                                else if (node.Name == "Air")
                                {
                                    room.setaircondition(positon, RFID);
                                }
                            }
                        }
                    }
                    rooms.Add(room);
                }
            }
        }
Esempio n. 2
0
 public void scenelayout(ref List<NewRoom> rooms)
 {
     XmlDocument xmldoc = new XmlDocument();
     xmldoc.Load(xmlname);
     XmlNodeList roomnodes = xmldoc.GetElementsByTagName("RoomNo");
     if (roomnodes != null)
     {
         foreach (XmlNode roomnode in roomnodes)
         {
             NewRoom room = new NewRoom();
             room.roomname = roomnode.Attributes["Name"].Value;
             XmlNodeList typenodes = roomnode.ChildNodes;
             foreach (XmlNode typenode in typenodes)
             {
                 if (typenode.Name == "Ground")
                 {
                     XmlNodeList nodes = typenode.ChildNodes;
                     foreach (XmlNode node in nodes)
                     {
                         string name = node.Attributes["Name"].Value;
                         string positon;
                         string size;
                         if (name == "Floor")
                         {
                             size = node.SelectSingleNode("SizeParam").InnerXml;
                             positon = node.SelectSingleNode("Position").InnerXml;
                             room.setfloor(size, positon);
                         }
                         else if (name == "Outwall")
                         {
                             size = node.SelectSingleNode("SizeParam").InnerXml;
                             positon = node.SelectSingleNode("Position").InnerXml;
                             room.setoutwall(size, positon);
                         }
                         else if (name == "Inwall")
                         {
                             size = node.SelectSingleNode("SizeParam").InnerXml;
                             positon = node.SelectSingleNode("Position").InnerXml;
                             room.setinwall(size, positon);
                         }
                     }
                 }
                 else if (typenode.Name == "Device")
                 {
                     XmlNodeList nodes = typenode.ChildNodes;
                     
                     foreach (XmlNode node in nodes)
                     {
                         string RFID = node.Attributes["RFID"].Value;
                         string positon = node.Attributes["Position"].Value;
                         
                         if (node.Name == "Cabinet")
                         {                                   
                             XmlNodeList unodes = node.ChildNodes;                               
                             string[] statues = new string[42];
                             for (int j = 0; j < 42;j++ )
                             {
                                 statues[j] = "0";
                             }
                             foreach (XmlNode unode in unodes)
                             {
                                 if (unode.Name=="Server")
                                 {
                                     string URFID = unode.Attributes["RFID"].Value;
                                     string UPosition = unode.Attributes["Position"].Value;
                                     string UType = unode.Attributes["Type"].Value;
                                     int tt = Convert.ToInt32(UPosition)-1;
                                     int yy = Convert.ToInt32(UType);
                                     for (int i = 0; i < yy;i++ )
                                     {
                                         statues[tt + i] = "1";
                                     }
                                     room.setserver(yy, positon, URFID,RFID,tt);
                                 }
                             }
                             room.setcabinet(statues, positon,RFID);
                         }
                         else if (node.Name == "Ups")
                         {
                             room.setups(positon, RFID);
                         }
                         else if (node.Name == "Air")
                         {
                             room.setaircondition(positon, RFID);
                         }
                     }
                 }
             }
             rooms.Add(room);
         }
     }
 }