Exemplo n.º 1
0
        public void CanChangeTypeTest1()
        {
            TECControllerType cType    = new TECControllerType(new TECManufacturer());
            TECProtocol       protocol = new TECProtocol(new List <TECConnectionType>());

            cType.IO.Add(new TECIO(protocol));
            cType.IO.Add(new TECIO(IOType.AI));

            TECControllerType otherCType = new TECControllerType(new TECManufacturer());

            TECProvidedController controller = new TECProvidedController(cType);

            TECSubScope ss1 = new TECSubScope();
            TECSubScope ss2 = new TECSubScope();

            TECDevice proDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>()
            {
                protocol
            }, new TECManufacturer());
            TECDevice hardDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>(), new TECManufacturer());

            ss1.Devices.Add(proDevice);
            ss2.Devices.Add(hardDevice);
            TECPoint point = new TECPoint();

            point.Type = IOType.AI;
            ss2.AddPoint(point);

            controller.Connect(ss1, protocol);
            controller.Connect(ss2, ss2.HardwiredProtocol());

            Assert.IsFalse(controller.CanChangeType(otherCType));
        }
        public void Controller_RemoveAllConnections()
        {
            TECControllerType type = new TECControllerType(new TECManufacturer());

            type.IO.Add(new TECIO(IOType.AI));
            type.IO.Add(new TECIO(IOType.AI));

            TECController controller         = new TECProvidedController(type);
            TECController childController    = new TECProvidedController(type);
            TECController childestController = new TECProvidedController(type);

            TECProtocol protocol = new TECProtocol(new List <TECConnectionType> {
            });

            type.IO.Add(new TECIO(protocol));

            TECNetworkConnection connection = controller.AddNetworkConnection(protocol);

            connection.AddChild(childController);

            TECNetworkConnection childConnection = childController.AddNetworkConnection(protocol);

            childConnection.AddChild(childestController);

            childController.DisconnectAll();

            Assert.AreEqual(0, childController.ChildrenConnections.Count, "Connection not removed from controller");
            Assert.AreEqual(null, childController.ParentConnection, "Connection not removed from child");
            Assert.AreEqual(null, childestController.ParentConnection, "Connection not removed from childest");
        }
        public void ConnectTest1()
        {
            TECProtocol firstProtocol  = new TECProtocol(new List <TECConnectionType>());
            TECProtocol secondProtocol = new TECProtocol(new List <TECConnectionType>());
            TECProtocol thirdProtocol  = new TECProtocol(new List <TECConnectionType>());
            TECProtocol fourthProtocol = new TECProtocol(new List <TECConnectionType>());

            TECDevice compatibleDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>()
            {
                fourthProtocol
            }, new TECManufacturer());
            TECSubScope subScope = new TECSubScope();

            subScope.Devices.Add(compatibleDevice);

            TECControllerType type = new TECControllerType(new TECManufacturer());

            type.IO.Add(new TECIO(firstProtocol));
            type.IO.Add(new TECIO(secondProtocol));
            type.IO.Add(new TECIO(thirdProtocol));

            TECProvidedController controller = new TECProvidedController(type);
            var connection = controller.Connect(subScope, firstProtocol);

            Assert.IsNull(connection);
        }
        public void CompatibleProtocolsTest()
        {
            TECProtocol firstProtocol  = new TECProtocol(new List <TECConnectionType>());
            TECProtocol secondProtocol = new TECProtocol(new List <TECConnectionType>());
            TECProtocol thirdProtocol  = new TECProtocol(new List <TECConnectionType>());
            TECProtocol fourthProtocol = new TECProtocol(new List <TECConnectionType>());

            TECDevice compatibleDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>()
            {
                secondProtocol, firstProtocol
            }, new TECManufacturer());
            TECSubScope subScope = new TECSubScope();

            subScope.Devices.Add(compatibleDevice);


            TECControllerType type = new TECControllerType(new TECManufacturer());

            type.IO.Add(new TECIO(firstProtocol));
            type.IO.Add(new TECIO(secondProtocol));
            type.IO.Add(new TECIO(thirdProtocol));

            TECProvidedController controller = new TECProvidedController(type);

            var compatible = controller.CompatibleProtocols(subScope);

            Assert.AreEqual(2, compatible.Count);
            Assert.IsTrue(compatible.Contains(firstProtocol) && compatible.Contains(secondProtocol));
        }
Exemplo n.º 5
0
 public static TECIO TestIO(Random rand, TECProtocol protocol)
 {
     return(new TECIO(protocol)
     {
         Quantity = rand.Next(1, 5)
     });
 }
        public void RemoveNetworkConnectionTest()
        {
            TECProtocol firstProtocol  = new TECProtocol(new List <TECConnectionType>());
            TECProtocol secondProtocol = new TECProtocol(new List <TECConnectionType>());
            TECProtocol thirdProtocol  = new TECProtocol(new List <TECConnectionType>());
            TECProtocol fourthProtocol = new TECProtocol(new List <TECConnectionType>());

            TECDevice compatibleDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>()
            {
                secondProtocol, firstProtocol, fourthProtocol
            }, new TECManufacturer());
            TECSubScope subScope = new TECSubScope();

            subScope.Devices.Add(compatibleDevice);

            TECControllerType type = new TECControllerType(new TECManufacturer());

            type.IO.Add(new TECIO(firstProtocol));
            type.IO.Add(new TECIO(secondProtocol));
            type.IO.Add(new TECIO(thirdProtocol));

            TECProvidedController controller = new TECProvidedController(type);

            TECNetworkConnection connection = controller.Connect(subScope, firstProtocol) as TECNetworkConnection;

            controller.RemoveNetworkConnection(connection);

            Assert.IsFalse(connection.Children.Contains(subScope));
            Assert.IsFalse(controller.ChildrenConnections.Contains(connection));
            Assert.IsNull((subScope as IConnectable).GetParentConnection());
        }
        public void AddPointToConnectedNetwork()
        {
            TECControllerType type     = new TECControllerType(new TECManufacturer());
            TECProtocol       protocol = new TECProtocol(new List <TECConnectionType>());

            type.IO.Add(new TECIO(IOType.AI));
            type.IO.Add(new TECIO(protocol));
            TECProvidedController controller = new TECProvidedController(type);

            TECDevice device = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol> {
                protocol
            }, new TECManufacturer());

            TECSubScope subScope = new TECSubScope();

            subScope.Devices.Add(device);

            controller.Connect(subScope, protocol);

            TECPoint point = new TECPoint();

            point.Type = IOType.AI;
            subScope.AddPoint(point);

            Assert.IsTrue(subScope.Points.Contains(point));
            Assert.IsTrue(controller.AvailableIO.IONumber(IOType.AI) == 1);

            TECPoint otherPoint = new TECPoint();

            otherPoint.Type = IOType.AI;

            subScope.AddPoint(otherPoint);
            Assert.IsTrue(subScope.Points.Contains(otherPoint));
            Assert.IsTrue(controller.AvailableIO.IONumber(IOType.AI) == 1);
        }
        public void AddDeviceToConnectedNetwork()
        {
            TECControllerType type     = new TECControllerType(new TECManufacturer());
            TECProtocol       protocol = new TECProtocol(new List <TECConnectionType>());

            type.IO.Add(new TECIO(protocol));
            TECProvidedController controller = new TECProvidedController(type);

            TECDevice device = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol> {
                protocol
            }, new TECManufacturer());

            TECSubScope subScope = new TECSubScope();

            subScope.Devices.Add(device);

            controller.Connect(subScope, protocol);

            TECDevice otherDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol> {
                protocol
            }, new TECManufacturer());

            subScope.AddDevice(otherDevice);
            Assert.IsTrue(subScope.Devices.Contains(otherDevice));

            TECProtocol otherProtocol = new TECProtocol(new List <TECConnectionType>());
            TECDevice   nextDevice    = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol> {
                otherProtocol
            }, new TECManufacturer());

            subScope.AddDevice(nextDevice);
            Assert.IsFalse(subScope.Devices.Contains(nextDevice));
        }
        public void AvailableProtocols1()
        {
            TECConnectionType type1 = new TECConnectionType();
            TECConnectionType type2 = new TECConnectionType();

            TECProtocol prot1 = new TECProtocol(new List <TECConnectionType>());
            TECProtocol prot2 = new TECProtocol(new List <TECConnectionType>());
            TECProtocol prot3 = new TECProtocol(new List <TECConnectionType>());

            TECDevice dev1 = new TECDevice(new List <TECConnectionType>(),
                                           new List <TECProtocol> {
                prot1, prot2
            }, new TECManufacturer());
            TECDevice dev2 = new TECDevice(new List <TECConnectionType> {
                type2
            },
                                           new List <TECProtocol> {
                prot1, prot3
            }, new TECManufacturer());

            TECSubScope ss        = new TECSubScope();
            bool        dev1Added = ss.AddDevice(dev1);
            bool        dev2Added = ss.AddDevice(dev2);

            Assert.IsTrue(dev1Added);
            Assert.IsTrue(dev2Added);

            Assert.IsFalse(ss.AvailableProtocols.Any(prot => { return(prot is TECHardwiredProtocol); }));
            Assert.IsTrue(ss.AvailableProtocols.Contains(prot1));
            Assert.IsFalse(ss.AvailableProtocols.Contains(prot2));
            Assert.IsFalse(ss.AvailableProtocols.Contains(prot3));
            Assert.AreEqual(1, ss.AvailableProtocols.Count);
        }
Exemplo n.º 10
0
        public void CanConnectTest4()
        {
            TECProtocol firstProtocol  = new TECProtocol(new List <TECConnectionType>());
            TECProtocol secondProtocol = new TECProtocol(new List <TECConnectionType>());
            TECProtocol thirdProtocol  = new TECProtocol(new List <TECConnectionType>());
            TECProtocol fourthProtocol = new TECProtocol(new List <TECConnectionType>());

            TECDevice compatibleDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>()
            {
                secondProtocol, firstProtocol, fourthProtocol
            }, new TECManufacturer());
            TECSubScope subScope = new TECSubScope();

            subScope.Devices.Add(compatibleDevice);

            TECControllerType type   = new TECControllerType(new TECManufacturer());
            TECIOModule       module = new TECIOModule(new TECManufacturer());

            module.IO.Add(new TECIO(firstProtocol));
            module.IO.Add(new TECIO(secondProtocol));
            module.IO.Add(new TECIO(thirdProtocol));
            type.IOModules.Add(module);

            TECProvidedController controller = new TECProvidedController(type);

            Assert.IsTrue(controller.CanConnect(subScope, firstProtocol));
            Assert.IsTrue(controller.CanConnect(subScope, secondProtocol));
            Assert.IsFalse(controller.CanConnect(subScope, fourthProtocol));
        }
        public void CanConnectToNetworkTest1()
        {
            TECProtocol firstProtocol  = new TECProtocol(new List <TECConnectionType>());
            TECProtocol secondProtocol = new TECProtocol(new List <TECConnectionType>());
            TECProtocol thirdProtocol  = new TECProtocol(new List <TECConnectionType>());
            TECProtocol fourthProtocol = new TECProtocol(new List <TECConnectionType>());

            TECDevice compatibleDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>()
            {
                secondProtocol, firstProtocol, fourthProtocol
            }, new TECManufacturer());
            TECSubScope subScope = new TECSubScope();

            subScope.Devices.Add(compatibleDevice);

            TECControllerType type = new TECControllerType(new TECManufacturer());

            type.IO.Add(new TECIO(firstProtocol));
            type.IO.Add(new TECIO(secondProtocol));
            type.IO.Add(new TECIO(thirdProtocol));

            TECProvidedController controller = new TECProvidedController(type);
            TECNetworkConnection  connection = controller.AddNetworkConnection(thirdProtocol);

            Assert.IsFalse(subScope.CanConnectToNetwork(connection));
        }
Exemplo n.º 12
0
        public void TECIOTest1()
        {
            TECProtocol protocol = new TECProtocol(new List <TECConnectionType>());
            TECIO       io       = new TECIO(protocol);

            Assert.AreEqual(IOType.Protocol, io.Type);
            Assert.AreEqual(protocol, io.Protocol);
            Assert.AreEqual(1, io.Quantity);
        }
        public void RemoveAllChildHardwiredConnectionsTest()
        {
            TECProtocol firstProtocol  = new TECProtocol(new List <TECConnectionType>());
            TECProtocol secondProtocol = new TECProtocol(new List <TECConnectionType>());
            TECProtocol thirdProtocol  = new TECProtocol(new List <TECConnectionType>());
            TECProtocol fourthProtocol = new TECProtocol(new List <TECConnectionType>());

            TECDevice compatibleDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>()
            {
                secondProtocol, firstProtocol, fourthProtocol
            }, new TECManufacturer());
            TECSubScope subScope = new TECSubScope();

            subScope.Devices.Add(compatibleDevice);

            TECControllerType type = new TECControllerType(new TECManufacturer());

            type.IO.Add(new TECIO(firstProtocol));
            type.IO.Add(new TECIO(secondProtocol));
            type.IO.Add(new TECIO(thirdProtocol));

            TECProvidedController controller = new TECProvidedController(type);

            TECNetworkConnection connection = controller.Connect(subScope, firstProtocol) as TECNetworkConnection;

            TECDevice   compatibleHardDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>(), new TECManufacturer());
            TECSubScope hardSubScope         = new TECSubScope();

            hardSubScope.Devices.Add(compatibleDevice);
            TECPoint point = new TECPoint();

            point.Type = IOType.AI;
            hardSubScope.Points.Add(point);

            type.IO.Add(new TECIO(IOType.AI));

            TECHardwiredConnection hardConnection = controller.Connect(hardSubScope, hardSubScope.HardwiredProtocol()) as TECHardwiredConnection;


            TECController parentController = new TECProvidedController(type);

            parentController.Connect(controller, secondProtocol);

            Assert.IsNotNull(controller.ParentConnection);

            controller.RemoveAllChildHardwiredConnections();

            Assert.IsTrue(connection.Children.Contains(subScope));
            Assert.IsTrue(controller.ChildrenConnections.Contains(connection));
            Assert.AreEqual((subScope as IConnectable).GetParentConnection(), connection);

            Assert.IsFalse(controller.ChildrenConnections.Contains(hardConnection));
            Assert.IsNull((hardSubScope as IConnectable).GetParentConnection());

            Assert.IsNotNull(controller.ParentConnection);
        }
Exemplo n.º 14
0
        public static TECProtocol TestProtocol(TECCatalogs catalogs, Random rand)
        {
            List <TECConnectionType> connectionTypes = new List <TECConnectionType>();

            rand.RepeatAction(() => connectionTypes.Add(catalogs.ConnectionTypes.RandomElement(rand)), 5);
            TECProtocol prot = new TECProtocol(connectionTypes);

            prot.AssignTestLabel();
            return(prot);
        }
Exemplo n.º 15
0
        private void addProtocolExecute()
        {
            TECProtocol toAdd = new TECProtocol(this.ConnectionTypes);

            toAdd.Label = this.Name;

            this.Templates.Catalogs.Add(toAdd);

            this.Name = "";
            this.ConnectionTypes.ObservablyClear();
        }
Exemplo n.º 16
0
        public void TECIOSetType()
        {
            TECProtocol protocol = new TECProtocol(new List <TECConnectionType>());
            TECIO       io       = new TECIO(protocol);

            io.Type = IOType.AI;

            Assert.AreEqual(IOType.AI, io.Type);
            Assert.IsNull(io.Protocol);
            Assert.AreEqual(1, io.Quantity);
        }
Exemplo n.º 17
0
        public void ConnectToControllerTest1()
        {
            TECProtocol protocol      = new TECProtocol(new List <TECConnectionType>());
            TECProtocol otherProtocol = new TECProtocol(new List <TECConnectionType>());

            TECDevice protDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>()
            {
                protocol
            }, new TECManufacturer());
            TECDevice otherProtDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>()
            {
                otherProtocol
            }, new TECManufacturer());

            List <IConnectable> connectables = new List <IConnectable>();

            TECSubScope item1 = new TECSubScope();

            item1.Devices.Add(otherProtDevice);
            connectables.Add(item1);
            TECSubScope item2 = new TECSubScope();

            item2.Devices.Add(protDevice);
            connectables.Add(item2);
            TECSubScope item3 = new TECSubScope();

            item3.Devices.Add(protDevice);
            connectables.Add(item3);
            TECSubScope item4 = new TECSubScope();

            item4.Devices.Add(protDevice);
            connectables.Add(item4);
            TECSubScope item5 = new TECSubScope();

            item5.Devices.Add(protDevice);
            connectables.Add(item5);
            TECSubScope item6 = new TECSubScope();

            item6.Devices.Add(protDevice);
            connectables.Add(item6);


            TECControllerType type = new TECControllerType(new TECManufacturer());

            type.IO.Add(new TECIO(protocol));
            TECProvidedController controller = new TECProvidedController(type);

            List <IControllerConnection> connections = ConnectionHelper.ConnectToController(connectables, controller, new ConnectionProperties());

            foreach (var thing in connectables)
            {
                Assert.IsFalse(connections.Any(x => connectionContainsItem(x, thing)));
            }
        }
Exemplo n.º 18
0
        public void ConnectTest5()
        {
            TECProtocol firstProtocol  = new TECProtocol(new List <TECConnectionType>());
            TECProtocol secondProtocol = new TECProtocol(new List <TECConnectionType>());
            TECProtocol thirdProtocol  = new TECProtocol(new List <TECConnectionType>());
            TECProtocol fourthProtocol = new TECProtocol(new List <TECConnectionType>());

            TECDevice compatibleDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>()
            {
                secondProtocol, firstProtocol, fourthProtocol
            }, new TECManufacturer());
            TECSubScope subScope1 = new TECSubScope();

            subScope1.Devices.Add(compatibleDevice);
            TECSubScope subScope2 = new TECSubScope();

            subScope2.Devices.Add(compatibleDevice);
            TECSubScope subScope3 = new TECSubScope();

            subScope3.Devices.Add(compatibleDevice);
            TECSubScope subScope4 = new TECSubScope();

            subScope4.Devices.Add(compatibleDevice);

            List <IConnectable> connectables = new List <IConnectable>
            {
                subScope1,
                subScope2,
                subScope3,
                subScope4
            };


            TECControllerType type   = new TECControllerType(new TECManufacturer());
            TECIOModule       module = new TECIOModule(new TECManufacturer());

            module.IO.Add(new TECIO(firstProtocol));
            type.IOModules.Add(module);

            TECProvidedController controller = new TECProvidedController(type);

            foreach (var subScope in connectables)
            {
                TECNetworkConnection connection = controller.Connect(subScope, firstProtocol) as TECNetworkConnection;

                Assert.IsTrue(connection.Children.Contains(subScope));
                Assert.IsTrue(controller.ChildrenConnections.Contains(connection));
                Assert.IsTrue((subScope as IConnectable).GetParentConnection() == connection);
                Assert.IsTrue(connection.Protocol == firstProtocol);
            }
        }
Exemplo n.º 19
0
        public void CanConnectToControllerTest1()
        {
            TECProtocol protocol      = new TECProtocol(new List <TECConnectionType>());
            TECProtocol otherProtocol = new TECProtocol(new List <TECConnectionType>());

            TECDevice protDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>()
            {
                protocol
            }, new TECManufacturer());
            TECDevice otherProtDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>()
            {
                otherProtocol
            }, new TECManufacturer());

            List <IConnectable> connectables = new List <IConnectable>();

            TECSubScope item1 = new TECSubScope();

            item1.Devices.Add(otherProtDevice);
            connectables.Add(item1);
            TECSubScope item2 = new TECSubScope();

            item2.Devices.Add(protDevice);
            connectables.Add(item2);
            TECSubScope item3 = new TECSubScope();

            item3.Devices.Add(protDevice);
            connectables.Add(item3);
            TECSubScope item4 = new TECSubScope();

            item4.Devices.Add(protDevice);
            connectables.Add(item4);
            TECSubScope item5 = new TECSubScope();

            item5.Devices.Add(protDevice);
            connectables.Add(item5);
            TECSubScope item6 = new TECSubScope();

            item6.Devices.Add(protDevice);
            connectables.Add(item6);


            TECControllerType type = new TECControllerType(new TECManufacturer());

            type.IO.Add(new TECIO(protocol));
            TECProvidedController controller = new TECProvidedController(type);

            Assert.IsFalse(ConnectionHelper.CanConnectToController(connectables, controller));
        }
        public void UpdateTest()
        {
            TECProtocol       protocol = new TECProtocol(new List <TECConnectionType>());
            TECControllerType cType    = new TECControllerType(new TECManufacturer());

            cType.IO.Add(new TECIO(protocol));

            TECProvidedController controller = new TECProvidedController(cType);

            TECProtocol otherProtocol = new TECProtocol(new List <TECConnectionType>());

            TECDevice device = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>()
            {
                protocol
            }, new TECManufacturer());
            TECSubScope subScope = new TECSubScope();

            subScope.Devices.Add(device);

            ConnectOnAddVM vm = new ConnectOnAddVM(new List <TECSubScope>()
            {
                subScope
            },
                                                   new List <TECController> {
                controller
            },
                                                   new List <TECElectricalMaterial>());

            vm.SelectedController = vm.ParentControllers.First();

            Assert.IsTrue(vm.CanConnect());

            TECDevice otherDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>()
            {
                otherProtocol
            }, new TECManufacturer());

            subScope.Devices.Remove(device);
            subScope.Devices.Add(otherDevice);

            vm.Update(new List <IConnectable>()
            {
                subScope
            });

            Assert.IsNull(vm.SelectedController);
            Assert.AreEqual(0, vm.ParentControllers.Count);
        }
Exemplo n.º 21
0
        public void ChangeTypeTest()
        {
            TECControllerType cType    = new TECControllerType(new TECManufacturer());
            TECProtocol       protocol = new TECProtocol(new List <TECConnectionType>());

            cType.IO.Add(new TECIO(protocol));
            cType.IO.Add(new TECIO(IOType.AI));

            TECControllerType otherCType = new TECControllerType(new TECManufacturer());

            otherCType.IO.Add(new TECIO(protocol));
            otherCType.IO.Add(new TECIO(IOType.AI));

            TECProvidedController controller = new TECProvidedController(cType);

            TECSubScope ss1 = new TECSubScope();
            TECSubScope ss2 = new TECSubScope();

            TECConnectionType connectionType = new TECConnectionType();
            TECDevice         proDevice      = new TECDevice(new List <TECConnectionType> {
                connectionType
            }, new List <TECProtocol>()
            {
                protocol
            }, new TECManufacturer());
            TECDevice hardDevice = new TECDevice(new List <TECConnectionType> {
                connectionType
            }, new List <TECProtocol>(), new TECManufacturer());

            ss1.Devices.Add(proDevice);
            ss2.Devices.Add(hardDevice);
            TECPoint point = new TECPoint();

            point.Type = IOType.AI;
            ss2.AddPoint(point);

            controller.Connect(ss1, protocol);
            controller.Connect(ss2, ss2.HardwiredProtocol());

            controller.ChangeType(otherCType);

            Assert.AreEqual(2, controller.ChildrenConnections.Count);
            Assert.AreEqual(controller, (ss1 as IConnectable).GetParentConnection().ParentController);
            Assert.AreEqual(controller, (ss2 as IConnectable).GetParentConnection().ParentController);
        }
        public void CanAddNetworkConnectionTest()
        {
            TECProtocol firstProtocol  = new TECProtocol(new List <TECConnectionType>());
            TECProtocol secondProtocol = new TECProtocol(new List <TECConnectionType>());
            TECProtocol thirdProtocol  = new TECProtocol(new List <TECConnectionType>());
            TECProtocol fourthProtocol = new TECProtocol(new List <TECConnectionType>());

            TECControllerType type = new TECControllerType(new TECManufacturer());

            type.IO.Add(new TECIO(firstProtocol));
            type.IO.Add(new TECIO(secondProtocol));
            type.IO.Add(new TECIO(thirdProtocol));

            TECProvidedController controller = new TECProvidedController(type);

            Assert.IsTrue(controller.CanAddNetworkConnection(firstProtocol));
            Assert.IsFalse(controller.CanAddNetworkConnection(fourthProtocol));
        }
        public void CanConnectTest()
        {
            TECProtocol       protocol = new TECProtocol(new List <TECConnectionType>());
            TECControllerType cType    = new TECControllerType(new TECManufacturer());

            cType.IO.Add(new TECIO(protocol));

            TECProvidedController controller = new TECProvidedController(cType);

            TECProtocol       otherProtocol = new TECProtocol(new List <TECConnectionType>());
            TECControllerType otherCType    = new TECControllerType(new TECManufacturer());

            otherCType.IO.Add(new TECIO(otherProtocol));

            TECProvidedController otherController = new TECProvidedController(otherCType);

            TECDevice device = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>()
            {
                protocol
            }, new TECManufacturer());
            TECSubScope subScope = new TECSubScope();

            subScope.Devices.Add(device);

            ConnectOnAddVM vm = new ConnectOnAddVM(new List <TECSubScope>()
            {
                subScope
            },
                                                   new List <TECController> {
                controller, otherController
            },
                                                   new List <TECElectricalMaterial>());

            Assert.AreEqual(1, vm.ParentControllers.Count);

            vm.SelectedController = null;
            vm.Connect            = true;

            Assert.IsFalse(vm.CanConnect());

            vm.SelectedController = vm.ParentControllers.First();

            Assert.IsTrue(vm.CanConnect());
        }
Exemplo n.º 24
0
        public void ExistingNetworkIOTest()
        {
            TECProtocol protocol = new TECProtocol(new List <TECConnectionType>());

            TECControllerType type = new TECControllerType(new TECManufacturer());

            type.IO.Add(new TECIO(protocol));
            type.IO.Add(new TECIO(protocol));

            TECProvidedController controller = new TECProvidedController(type);

            controller.AddNetworkConnection(protocol);
            controller.AddNetworkConnection(protocol);

            var existing = ConnectionHelper.ExistingNetworkIO(controller);

            Assert.IsTrue(existing.ToList().Count == 1);
            Assert.IsTrue(existing.ToList().First().Quantity == 2);
        }
        public void AddNetworkConnectionTest1()
        {
            TECProtocol firstProtocol  = new TECProtocol(new List <TECConnectionType>());
            TECProtocol secondProtocol = new TECProtocol(new List <TECConnectionType>());
            TECProtocol thirdProtocol  = new TECProtocol(new List <TECConnectionType>());
            TECProtocol fourthProtocol = new TECProtocol(new List <TECConnectionType>());

            TECControllerType type = new TECControllerType(new TECManufacturer());

            type.IO.Add(new TECIO(firstProtocol));
            type.IO.Add(new TECIO(secondProtocol));
            type.IO.Add(new TECIO(thirdProtocol));

            TECProvidedController controller = new TECProvidedController(type);

            TECNetworkConnection connection = controller.AddNetworkConnection(fourthProtocol);

            Assert.IsFalse(controller.ChildrenConnections.Contains(connection));
            Assert.IsNull(connection);
        }
        public void Controller_AddNetworkConnection()
        {
            TECControllerType type = new TECControllerType(new TECManufacturer());

            type.IO.Add(new TECIO(IOType.AI));

            TECController controller      = new TECProvidedController(type);
            TECController childController = new TECProvidedController(type);

            TECProtocol protocol = new TECProtocol(new List <TECConnectionType> {
            });

            type.IO.Add(new TECIO(protocol));

            TECNetworkConnection connection = controller.AddNetworkConnection(protocol);

            connection.AddChild(childController);

            Assert.AreEqual(1, controller.ChildrenConnections.Count, "Connection not added to controller");
            Assert.AreEqual(connection, childController.ParentConnection, "Connection not added to child");
        }
        public void RemoveDeviceFromConnectedNetwork()
        {
            TECControllerType type     = new TECControllerType(new TECManufacturer());
            TECProtocol       protocol = new TECProtocol(new List <TECConnectionType>());

            type.IO.Add(new TECIO(protocol));
            TECProvidedController controller = new TECProvidedController(type);

            TECDevice device = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol> {
                protocol
            }, new TECManufacturer());

            TECSubScope subScope = new TECSubScope();

            subScope.Devices.Add(device);

            IControllerConnection connection = controller.Connect(subScope, protocol);

            subScope.RemoveDevice(device);

            Assert.IsNull((subScope as IConnectable).GetParentConnection());
            Assert.IsTrue(controller.ChildrenConnections.Contains(connection));
        }
Exemplo n.º 28
0
        public static TECCatalogs CreateTestCatalogs()
        {
            TECCatalogs outCatalogs = new TECCatalogs();

            //Associated Costs
            TECAssociatedCost elecCost = new TECAssociatedCost(CostType.Electrical);

            elecCost.Name  = "Elec Cost";
            elecCost.Cost  = 156.61;
            elecCost.Labor = 456.64;
            elecCost.Type  = CostType.Electrical;
            outCatalogs.AssociatedCosts.Add(elecCost);

            TECAssociatedCost tecCost = new TECAssociatedCost(CostType.TEC);

            tecCost.Name  = "TEC Cost";
            tecCost.Cost  = 46.43;
            tecCost.Labor = 61.45;
            tecCost.Type  = CostType.TEC;
            outCatalogs.AssociatedCosts.Add(tecCost);

            //Tags
            var tag1 = new TECTag();

            tag1.Label = "Tag 1";
            var tag2 = new TECTag();

            tag2.Label = "Test Tag";

            outCatalogs.Tags.Add(tag1);
            outCatalogs.Tags.Add(tag2);

            //Conduit Types
            var conduitType1 = new TECElectricalMaterial();

            conduitType1.Name  = "Test Conduit 1";
            conduitType1.Cost  = 64.49;
            conduitType1.Labor = 463.87;
            AssignSecondaryProperties(conduitType1, outCatalogs);
            conduitType1.RatedCosts.Add(tecCost);
            conduitType1.RatedCosts.Add(elecCost);

            outCatalogs.ConduitTypes.Add(conduitType1);

            var conduitType2 = new TECElectricalMaterial();

            conduitType2.Name  = "Test Conduit 2";
            conduitType2.Cost  = 13.45;
            conduitType2.Labor = 9873.40;
            AssignSecondaryProperties(conduitType2, outCatalogs);
            conduitType2.RatedCosts.Add(tecCost);
            conduitType2.RatedCosts.Add(elecCost);

            outCatalogs.ConduitTypes.Add(conduitType2);

            //ConnectionTypes
            var connectionType1 = new TECConnectionType();

            connectionType1.Name  = "FourC18";
            connectionType1.Cost  = 64.63;
            connectionType1.Labor = 98.16;
            AssignSecondaryProperties(connectionType1, outCatalogs);
            connectionType1.RatedCosts.Add(tecCost);
            connectionType1.RatedCosts.Add(elecCost);

            var connectionType2 = new TECConnectionType();

            connectionType2.Name  = "ThreeC18";
            connectionType2.Cost  = 73.16;
            connectionType2.Labor = 35.49;
            AssignSecondaryProperties(connectionType1, outCatalogs);
            connectionType1.RatedCosts.Add(tecCost);
            connectionType1.RatedCosts.Add(elecCost);

            outCatalogs.ConnectionTypes.Add(connectionType1);
            outCatalogs.ConnectionTypes.Add(connectionType2);

            //Manufacturers
            var manufacturer1 = new TECManufacturer();

            manufacturer1.Label      = "Test";
            manufacturer1.Multiplier = .51;

            outCatalogs.Manufacturers.Add(manufacturer1);

            //Devices
            ObservableCollection <TECConnectionType> contypes4 = new ObservableCollection <TECConnectionType>();

            contypes4.Add(connectionType1);
            TECDevice device1 = new TECDevice(Guid.NewGuid(), contypes4, new List <TECProtocol>(), manufacturer1);

            device1.Name        = "Device 1";
            device1.Description = "Description 1";
            device1.Price       = 64.96;
            device1.Tags.Add(tag1);
            AssignSecondaryProperties(device1, outCatalogs);

            outCatalogs.Devices.Add(device1);

            //IO Modules
            TECIOModule testIOModule = new TECIOModule(manufacturer1);

            testIOModule.Name         = "Test IO Module";
            testIOModule.Price        = 13.46;
            testIOModule.Manufacturer = manufacturer1;
            outCatalogs.IOModules.Add(testIOModule);

            //Controller Types
            TECControllerType controllerType = new TECControllerType(manufacturer1);

            controllerType.Name  = "Test Controller Type";
            controllerType.Price = 196.73;
            controllerType.Labor = 61.34;
            AssignSecondaryProperties(controllerType, outCatalogs);

            TECIO io = new TECIO(IOType.AI);

            io.Quantity = 100;
            controllerType.IO.Add(io);

            io          = new TECIO(IOType.UI);
            io.Quantity = 100;
            controllerType.IO.Add(io);

            io          = new TECIO(IOType.UO);
            io.Quantity = 100;
            controllerType.IO.Add(io);

            outCatalogs.ControllerTypes.Add(controllerType);

            //Panel Types
            TECPanelType panelType = new TECPanelType(manufacturer1);

            panelType.Price = 16.64;
            panelType.Labor = 91.46;
            panelType.Name  = "Test Panel Type";
            AssignSecondaryProperties(panelType, outCatalogs);

            outCatalogs.PanelTypes.Add(panelType);

            TECPanelType otherPanelType = new TECPanelType(manufacturer1);

            otherPanelType.Price = 46.61;
            otherPanelType.Labor = 64.19;
            otherPanelType.Name  = "Other Test Panel Type";
            AssignSecondaryProperties(otherPanelType, outCatalogs);

            outCatalogs.PanelTypes.Add(otherPanelType);

            //Valves
            TECDevice actuator = new TECDevice(new ObservableCollection <TECConnectionType>()
            {
                connectionType1
            },
                                               new List <TECProtocol>(),
                                               manufacturer1);

            actuator.Name = "actuator";
            outCatalogs.Devices.Add(actuator);
            TECValve valve = new TECValve(manufacturer1, actuator);

            outCatalogs.Valves.Add(valve);

            //Protocols
            TECProtocol protocol = new TECProtocol(new List <TECConnectionType> {
                connectionType1
            });

            protocol.Label = "BACnet IP";
            outCatalogs.Protocols.Add(protocol);

            controllerType.IO.Add(new TECIO(protocol));

            TECDevice netDevice = new TECDevice(Guid.NewGuid(), new List <TECConnectionType>(), new List <TECProtocol> {
                protocol
            }, manufacturer1);

            outCatalogs.Devices.Add(netDevice);

            return(outCatalogs);
        }
Exemplo n.º 29
0
        public void ConnectTest6()
        {
            TECProtocol firstProtocol  = new TECProtocol(new List <TECConnectionType>());
            TECProtocol secondProtocol = new TECProtocol(new List <TECConnectionType>());
            TECProtocol thirdProtocol  = new TECProtocol(new List <TECConnectionType>());
            TECProtocol fourthProtocol = new TECProtocol(new List <TECConnectionType>());

            TECConnectionType connectionType = new TECConnectionType();
            TECDevice         hardDevice     = new TECDevice(new List <TECConnectionType> {
                connectionType
            }, new List <TECProtocol>(), new TECManufacturer());

            TECSubScope hSubScope1 = new TECSubScope();

            hSubScope1.Devices.Add(hardDevice);
            hSubScope1.Points.Add(new TECPoint {
                Type = IOType.AI
            });

            TECSubScope hSubScope2 = new TECSubScope();

            hSubScope2.Devices.Add(hardDevice);
            hSubScope2.Points.Add(new TECPoint {
                Type = IOType.AI
            });

            TECSubScope hSubScope3 = new TECSubScope();

            hSubScope3.Devices.Add(hardDevice);
            hSubScope3.Points.Add(new TECPoint {
                Type = IOType.AI
            });

            TECSubScope hSubScope4 = new TECSubScope();

            hSubScope4.Devices.Add(hardDevice);
            hSubScope4.Points.Add(new TECPoint {
                Type = IOType.AI
            });

            TECSubScope hSubScope5 = new TECSubScope();

            hSubScope5.Devices.Add(hardDevice);
            hSubScope5.Points.Add(new TECPoint {
                Type = IOType.AI
            });


            TECDevice compatibleDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>()
            {
                secondProtocol, firstProtocol, fourthProtocol
            }, new TECManufacturer());
            TECSubScope subScope1 = new TECSubScope();

            subScope1.Devices.Add(compatibleDevice);
            TECSubScope subScope2 = new TECSubScope();

            subScope2.Devices.Add(compatibleDevice);
            TECSubScope subScope3 = new TECSubScope();

            subScope3.Devices.Add(compatibleDevice);
            TECSubScope subScope4 = new TECSubScope();

            subScope4.Devices.Add(compatibleDevice);

            List <IConnectable> connectables = new List <IConnectable>
            {
                subScope1,
                subScope2,
                subScope3,
                subScope4,
                hSubScope1,
                hSubScope2,
                hSubScope3,
                hSubScope4,
                hSubScope5
            };


            TECControllerType type   = new TECControllerType(new TECManufacturer());
            TECIOModule       module = new TECIOModule(new TECManufacturer());

            module.IO.Add(new TECIO(firstProtocol));

            TECIOModule hModule = new TECIOModule(new TECManufacturer());

            hModule.IO.Add(new TECIO(IOType.AI)
            {
                Quantity = 2
            });

            type.IOModules.Add(module);
            type.IOModules.Add(hModule);
            type.IOModules.Add(hModule);
            type.IOModules.Add(hModule);

            TECProvidedController controller = new TECProvidedController(type);

            foreach (var subScope in connectables)
            {
                IProtocol             protocol   = subScope.HardwiredProtocol() as IProtocol ?? firstProtocol;
                IControllerConnection connection = controller.Connect(subScope, protocol);

                bool containsChild = connection is TECNetworkConnection netConnect?
                                     netConnect.Children.Contains(subScope) : (connection as TECHardwiredConnection).Child == subScope;

                Assert.IsTrue(containsChild);
                Assert.IsTrue(controller.ChildrenConnections.Contains(connection));
                Assert.IsTrue((subScope as IConnectable).GetParentConnection() == connection);
                Assert.AreEqual(connection.Protocol, protocol);
            }
        }