public List<WaggonType> GetAll()
        {
            List<WaggonType> waggonTypes = new List<WaggonType>();

            XmlDocument document = new XmlDocument();
            document.Load(this.FilePath);
            XmlNodeList waggonTypeNodes = document.SelectNodes("/ConfigBuilderConfiguration/WaggonTypes/WaggonType");
            foreach (XmlNode waggonTypeNode in waggonTypeNodes)
            {
                string name = waggonTypeNode.Attributes["Name"].Value;
                string usageName = waggonTypeNode.Attributes["Usage"].Value;
                WaggonType newWaggonType = new WaggonType(name, usageName);

                XmlNodeList cameraNodes = waggonTypeNode.SelectNodes("Cameras/Camera");
                foreach (XmlNode cameraNode in cameraNodes)
                {
                    string id = cameraNode.Attributes["Id"].Value;
                    string referenceId = cameraNode.Attributes["ReferenceId"].Value;
                    string cameraName = cameraNode.Attributes["Name"].Value;
                    Camera cam = new Camera(id);
                    cam.CameraType = "M3113";
                    cam.Group = "Innenkamera";
                    cam.Name = cameraName;
                    cam.ReferenceId = referenceId;
                    newWaggonType.AddCamera(cam);
                }

                waggonTypes.Add(newWaggonType);
            }

            return waggonTypes;
        }
Exemplo n.º 2
0
        public void WaggonType_Equals_AreEqual()
        {
            string waggonTypeName = "R1234";
            string usage = "Video";
            WaggonType wt1 = new WaggonType(waggonTypeName, usage);
            WaggonType wt2 = new WaggonType(waggonTypeName, usage);

            Assert.AreEqual(wt1, wt2);
        }
Exemplo n.º 3
0
        public void WaggonType_Ctor_WaggonTypeNameIsLikeExpected()
        {
            string expected = "R1234";
            string usage = "Video";
            WaggonType waggonType = new WaggonType(expected, usage);
            string actual = waggonType.Name;

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 4
0
        public void WaggonType_EqualsWithDifferentWaggonTypes_AreNotEqual()
        {
            string waggonTypeName1 = "R1234";
            string waggonTypeName2 = "R4321";
            string usage = "Video";
            WaggonType wt1 = new WaggonType(waggonTypeName1, usage);
            WaggonType wt2 = new WaggonType(waggonTypeName2, usage);

            Assert.AreNotEqual(wt1, wt2);
        }
Exemplo n.º 5
0
        public void WaggonType_EqualsWithDifferentUsages_AreNotEqual()
        {
            string waggonTypeName = "R1234";
            string usage1 = "Video";
            string usage2 = "Diagnose";
            WaggonType wt1 = new WaggonType(waggonTypeName, usage1);
            WaggonType wt2 = new WaggonType(waggonTypeName, usage2);

            Assert.AreNotEqual(wt1, wt2);
        }
        private WaggonType CreateWaggonTypeFromXmlNode(XmlNode waggonTypeNode)
        {
            string typeName = waggonTypeNode.Attributes["Name"].Value;
            string usageName = waggonTypeNode.Attributes["Usage"].Value;
            WaggonType waggonType = new WaggonType(typeName, usageName);

            // Kameras
            XmlNode camerasRootNode = waggonTypeNode.SelectSingleNode("Cameras");
            string cameraType = camerasRootNode["CameraType"].Value;
            XmlNodeList cameraNodes = waggonTypeNode.SelectNodes("Cameras/Camera");
            foreach (XmlNode cameraNode in cameraNodes)
            {
                Camera camera = CreateCameraFromXmlNode(cameraNode, cameraType);
                waggonType.AddCamera(camera);
            }

            // Devices
            XmlNodeList deviceNodes = waggonTypeNode.SelectNodes("Devices/Device");
            foreach (XmlNode deviceNode in deviceNodes)
            {
                Device device = CreateDeviceFromXmlNode(deviceNode);
                waggonType.AddDevice(device);
            }

            // Switches
            XmlNodeList switchNodes = waggonTypeNode.SelectNodes("Switches/Switch");
            foreach (XmlNode switchNode in switchNodes)
            {
                Switch mySwitch = CreateSwitchFromXmlNode(switchNode);
                waggonType.AddSwitch(mySwitch);
            }

            // Subsystems
            XmlNodeList subsystemNodes = waggonTypeNode.SelectNodes("Subsystems/Subsystem");
            foreach (XmlNode subsystemNode in subsystemNodes)
            {
                Subsystem subsystem = CreateSubsystemFromXmlNode(subsystemNode);
                waggonType.AddSubsystem(subsystem);
            }

            return waggonType;
        }