public void RemovePointFromConnectedHardwired()
        {
            TECControllerType type = new TECControllerType(new TECManufacturer());

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

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

            TECSubScope subScope = new TECSubScope();

            subScope.Devices.Add(device);

            TECPoint point = new TECPoint();

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

            controller.Connect(subScope, subScope.HardwiredProtocol());

            subScope.RemovePoint(point);

            Assert.IsFalse(subScope.Points.Contains(point));
            Assert.IsTrue(controller.AvailableIO.IONumber(IOType.AI) == 1);
        }
Ejemplo n.º 2
0
        public void GetConnectablesTest()
        {
            TECSystem    system    = new TECSystem();
            TECEquipment equipment = new TECEquipment();

            system.Equipment.Add(equipment);
            TECSubScope first  = new TECSubScope();
            TECSubScope second = new TECSubScope();

            equipment.SubScope.Add(first);
            equipment.SubScope.Add(second);
            TECProvidedController controller = new TECProvidedController(new TECControllerType(new TECManufacturer()));

            system.AddController(controller);

            var connectables = ConnectionHelper.GetConnectables(system, obj => true);

            Assert.IsTrue(connectables.Count == 3);
            Assert.IsTrue(connectables.Contains(first));
            Assert.IsTrue(connectables.Contains(second));
            Assert.IsTrue(connectables.Contains(controller));

            connectables = ConnectionHelper.GetConnectables(system, obj => obj is TECSubScope);

            Assert.IsTrue(connectables.Count == 2);
            Assert.IsTrue(connectables.Contains(first));
            Assert.IsTrue(connectables.Contains(second));
        }
        public void DiconnectTest1()
        {
            TECConnectionType connectionType   = new TECConnectionType();
            TECDevice         compatibleDevice = new TECDevice(new List <TECConnectionType> {
                connectionType
            }, new List <TECProtocol>(), new TECManufacturer());
            TECSubScope subScope = new TECSubScope();

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

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

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

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

            TECProvidedController controller = new TECProvidedController(type);

            TECHardwiredConnection connection = controller.Connect(subScope, subScope.AvailableProtocols.First(x => x is TECHardwiredProtocol)) as TECHardwiredConnection;

            controller.Disconnect(subScope);

            Assert.IsFalse(controller.ChildrenConnections.Contains(connection));
            Assert.IsNull((subScope as IConnectable).GetParentConnection());
        }
        public void AddDeviceToConnectedHardwired()
        {
            TECControllerType type = new TECControllerType(new TECManufacturer());

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

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

            TECSubScope subScope = new TECSubScope();

            subScope.AddDevice(device);

            controller.Connect(subScope, subScope.HardwiredProtocol());

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

            subScope.AddDevice(otherDevice);

            Assert.IsFalse(subScope.Devices.Contains(otherDevice));

            TECConnectionType otherConnectionType = new TECConnectionType();
            TECDevice         nextDevice          = new TECDevice(new List <TECConnectionType> {
                otherConnectionType
            }, new List <TECProtocol>(), new TECManufacturer());
            bool deviceAdded = subScope.AddDevice(nextDevice);

            Assert.IsFalse(deviceAdded);
            Assert.IsFalse(subScope.Devices.Contains(nextDevice));
        }
        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));
        }
Ejemplo n.º 6
0
        public void AddRemoveSystemInstanceWithBidConnection()
        {
            var bid = new TECBid();

            bid.Catalogs = ModelCreation.TestCatalogs(rand);
            var bidController = new TECProvidedController(bid.Catalogs.ControllerTypes.RandomElement(rand));

            bid.AddController(bidController);

            var system    = new TECTypical();
            var equipment = new TECEquipment();
            var subScope  = new TECSubScope();

            TECDevice dev = bid.Catalogs.Devices.First(x => x.HardwiredConnectionTypes.Count > 0);

            subScope.Devices.Add(dev);

            TECHardwiredProtocol hardProt = subScope.AvailableProtocols.First(x => x is TECHardwiredProtocol) as TECHardwiredProtocol;

            system.Equipment.Add(equipment);
            equipment.SubScope.Add(subScope);
            var instance         = system.AddInstance();
            var instanceSubScope = instance.GetAllSubScope().First();

            bidController.Connect(instanceSubScope, hardProt);

            Assert.AreEqual(1, bidController.ChildrenConnections.Count, "Connection not added");

            system.Instances.Remove(instance);

            Assert.AreEqual(0, bidController.ChildrenConnections.Count, "Connection not removed");
        }
Ejemplo n.º 7
0
        public void RemoveInstanceWithGlobalConnectionToController()
        {
            TECBid bid = new TECBid();

            bid.Catalogs = ModelCreation.TestCatalogs(rand);

            TECControllerType type = bid.Catalogs.ControllerTypes.RandomElement(rand);

            TECController controller = new TECProvidedController(type);

            bid.AddController(controller);

            TECTypical    typical           = new TECTypical();
            TECController typicalController = new TECProvidedController(type);

            typical.AddController(typicalController);

            bid.Systems.Add(typical);
            TECSystem     system             = typical.AddInstance();
            TECController instanceController = typical.GetInstancesFromTypical(typicalController).First();

            Assert.IsTrue(controller.CanConnect(instanceController));

            IControllerConnection connection = controller.Connect(instanceController, instanceController.AvailableProtocols.First());

            Assert.IsTrue(connection is TECNetworkConnection);

            typical.Instances.Remove(system);

            Assert.IsTrue((connection as TECNetworkConnection).Children.Count == 0);
        }
Ejemplo n.º 8
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));
        }
        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 ConnectTest2()
        {
            TECConnectionType connectionType   = new TECConnectionType();
            TECDevice         compatibleDevice = new TECDevice(new List <TECConnectionType> {
                connectionType
            }, new List <TECProtocol>(), new TECManufacturer());
            TECSubScope subScope = new TECSubScope();

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

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

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

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

            TECProvidedController controller = new TECProvidedController(type);

            TECHardwiredConnection connection = controller.Connect(subScope, subScope.HardwiredProtocol()) as TECHardwiredConnection;

            Assert.IsTrue(connection.Child == subScope);
            Assert.IsTrue(controller.ChildrenConnections.Contains(connection));
            Assert.IsTrue((subScope as IConnectable).GetParentConnection() == connection);
            Assert.IsTrue(connection.Protocol is TECHardwiredProtocol);
        }
        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));
        }
        public void CompatibleProtocolsTest2()
        {
            TECConnectionType connectionType   = new TECConnectionType();
            TECDevice         compatibleDevice = new TECDevice(new List <TECConnectionType> {
                connectionType
            }, new List <TECProtocol>(), new TECManufacturer());
            TECSubScope subScope = new TECSubScope();

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

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

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

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

            TECProvidedController controller = new TECProvidedController(type);

            var compatible = controller.CompatibleProtocols(subScope);

            Assert.AreEqual(1, compatible.Count);
            Assert.IsTrue(compatible.Any(x => x is TECHardwiredProtocol));
        }
        public void CopyProvidedControllerTest()
        {
            //Arrange
            TECCatalogs           catalogs   = ModelCreation.TestCatalogs(rand);
            TECProvidedController controller = ModelCreation.TestProvidedController(catalogs, rand);
            TECProvidedController copy       = controller.CopyController(new Dictionary <Guid, Guid>()) as TECProvidedController;

            //TECTagged
            Assert.AreEqual(controller.Name, copy.Name);
            Assert.AreEqual(controller.Description, copy.Description);
            Assert.IsTrue(controller.Tags.SequenceEqual(copy.Tags));

            //TECScope
            Assert.IsTrue(controller.AssociatedCosts.SequenceEqual(copy.AssociatedCosts));

            //TECLocated
            Assert.AreEqual(controller.Location, copy.Location);

            //TECController
            Assert.AreEqual(controller.IsServer, copy.IsServer);

            //TECFBOController
            Assert.AreEqual(controller.Type, copy.Type);
            Assert.IsTrue(controller.IOModules.SequenceEqual(copy.IOModules));
        }
        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");
        }
Ejemplo n.º 16
0
        public void ConnectTest3()
        {
            TECConnectionType connectionType   = new TECConnectionType();
            TECDevice         compatibleDevice = new TECDevice(new List <TECConnectionType> {
                connectionType
            }, new List <TECProtocol>(), new TECManufacturer());
            TECSubScope subScope = new TECSubScope();

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

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

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

            module.IO.Add(new TECIO(IOType.AO));
            type.IOModules.Add(module);

            TECProvidedController  controller = new TECProvidedController(type);
            TECHardwiredConnection connection = controller.Connect(subScope, subScope.HardwiredProtocol()) as TECHardwiredConnection;

            Assert.IsNull(connection);
        }
Ejemplo n.º 17
0
        public ChangeControllerTypeVM(TECProvidedController controller, IEnumerable <TECControllerType> types)
        {
            this.Controller = controller;
            this.Types      = getCompatibleTypes(types);

            ChangeCommand = new RelayCommand <TECControllerType>(changeTypeExecute, canChangeType);
        }
Ejemplo n.º 18
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 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);
        }
Ejemplo n.º 21
0
        public static TECProvidedController TestProvidedController(TECCatalogs catalogs, Random rand)
        {
            TECProvidedController controller = new TECProvidedController(catalogs.ControllerTypes.RandomElement(rand));

            controller.Description = "Test Provided Controller";
            controller.AssignRandomScopeProperties(catalogs, rand);
            return(controller);
        }
Ejemplo n.º 22
0
        internal static bool addRequiredIOModules(TECProvidedController controller)
        {
            //The IO needed by the points connected to the controller
            IOCollection necessaryIO = new IOCollection();
            bool         needsSave   = false;

            foreach (TECHardwiredConnection ssConnect in
                     controller.ChildrenConnections.Where(con => con is TECHardwiredConnection))
            {
                foreach (TECIO io in ssConnect.Child.HardwiredIO.ToList())
                {
                    for (int i = 0; i < io.Quantity; i++)
                    {
                        //The point IO that exists on our controller at the moment.
                        IOCollection totalPointIO = getPointIO(controller);
                        necessaryIO.Add(io.Type);
                        //Check if our io that exists satisfies the IO that we need.
                        if (!totalPointIO.Contains(necessaryIO))
                        {
                            needsSave = true;
                            bool moduleFound = false;
                            //If it doesn't, we need to add an IO module that will satisfy it.
                            foreach (TECIOModule module in controller.Type.IOModules)
                            {
                                //We only need to check for the type of the last IO that we added.
                                if (module.IOCollection.Contains(io.Type) && controller.CanAddModule(module))
                                {
                                    controller.AddModule(module);
                                    moduleFound = true;
                                    break;
                                }
                            }
                            if (!moduleFound)
                            {
                                controller.DisconnectAll();
                                MessageBox.Show(string.Format("The controller type of the controller '{0}' is incompatible with the connected points. Please review the controller's connections.",
                                                              controller.Name));

                                return(true);
                            }
                        }
                    }
                }
            }
            return(needsSave);

            IOCollection getPointIO(TECController con)
            {
                IOCollection pointIOCollection = new IOCollection();

                foreach (TECIO pointIO in controller.IO.ToList().Where(io => (TECIO.PointIO.Contains(io.Type) || TECIO.UniversalIO.Contains(io.Type))))
                {
                    pointIOCollection.Add(pointIO);
                }
                return(pointIOCollection);
            }
        }
 public ProvidedControllerPropertiesItem(TECProvidedController controller)
 {
     Controller             = controller;
     AddModuleCommand       = new RelayCommand <TECIOModule>(addModuleExecute, canAddModule);
     RemoveModuleCommand    = new RelayCommand <TECIOModule>(removeModuleExecute, canRemoveModule);
     OptimizeModulesCommand = new RelayCommand(optimizeModulesExecute);
     populateIO();
     populateModules();
 }
Ejemplo n.º 24
0
        public static TECController CreateTestController(bool isTypical, TECCatalogs catalogs)
        {
            var type = catalogs.ControllerTypes[0];

            var controller = new TECProvidedController(type, isTypical);

            controller.Tags.Add(catalogs.Tags[0]);
            return(controller);
        }
        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);
        }
Ejemplo n.º 26
0
        public void ControllerInPanel_AddPanel()
        {
            TECPanel      panel      = new TECPanel(new TECPanelType(new TECManufacturer()));
            TECController controller = new TECProvidedController(new TECControllerType(new TECManufacturer()));

            ControllerInPanel controllerInPanel = new ControllerInPanel(controller, null);

            controllerInPanel.Panel = panel;

            Assert.AreEqual(panel.Controllers.Count, 1, "Controller not added to panel");
        }
Ejemplo n.º 27
0
        public void ControllerInPanel_RemovePanel()
        {
            TECPanel      panel      = new TECPanel(new TECPanelType(new TECManufacturer()));
            TECController controller = new TECProvidedController(new TECControllerType(new TECManufacturer()));

            ControllerInPanel controllerInPanel = new ControllerInPanel(controller, panel);

            controllerInPanel.Panel = null;

            Assert.AreEqual(panel.Controllers.Count, 0, "Controller not removed to panel");
        }
Ejemplo n.º 28
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)));
            }
        }
        public void Bid_AddController()
        {
            TECControllerType controllerType = new TECControllerType(manufacturer);

            controllerType.Price = 100;
            TECController controller = new TECProvidedController(controllerType);

            bid.AddController(controller);

            Assert.AreEqual(100, costs.GetCost(CostType.TEC));
            Assert.AreEqual(0, costs.GetCost(CostType.Electrical));
        }
Ejemplo n.º 30
0
 private static void linkProvidedControllerToControllerType(TECProvidedController controller, IEnumerable <TECControllerType> controllerTypes)
 {
     foreach (TECControllerType type in controllerTypes)
     {
         if (controller.Type.Guid == type.Guid)
         {
             if (!controller.ChangeType(type))
             {
                 logger.Error("Controller type isn't compatible with controller, can't change type.");
             }
         }
     }
 }