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 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 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.º 4
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);
        }
        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 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 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 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 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.º 10
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);
        }
        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 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 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));
        }
Ejemplo n.º 14
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));
        }
Ejemplo n.º 15
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));
        }
Ejemplo n.º 16
0
        private void addControllerTypeExecute()
        {
            TECControllerType toAdd = new TECControllerType(ControllerTypeManufacturer);

            toAdd.Name        = this.ControllerTypeName;
            toAdd.Description = this.ControllerTypeDescription;
            toAdd.Price       = this.ControllerTypeCost;
            toAdd.Labor       = this.ControllerTypeLabor;
            foreach (TECIO io in this.ControllerTypeIO)
            {
                toAdd.IO.Add(io);
            }
            foreach (QuantityItem <TECIOModule> quantItem in this.ControllerTypeModules)
            {
                for (int i = 0; i < quantItem.Quantity; i++)
                {
                    toAdd.IOModules.Add(quantItem.Item);
                }
            }

            Templates.Catalogs.Add(toAdd);

            this.ControllerTypeName         = "";
            this.ControllerTypeDescription  = "";
            this.ControllerTypeCost         = 0;
            this.ControllerTypeLabor        = 0;
            this.ControllerTypeManufacturer = null;
            this.ControllerTypeIO.ObservablyClear();
            this.ControllerTypeModules.ObservablyClear();
        }
        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.º 18
0
 public ControllerTypePropertiesItem(TECControllerType controllerType)
 {
     ControllerType              = controllerType;
     IOModules                   = new QuantityCollection <TECIOModule>(controllerType.IOModules);
     IOModules.QuantityChanged  += ioModules_QuantityChanged;
     AddIOCommand                = new RelayCommand(addIOExecute, canAddIO);
     this.ProtocolToIODropTarget = new ProtocolToIODropTarget();
 }
        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.º 20
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 CatalogCopyTest()
        {
            TECControllerType type = new TECControllerType(new TECManufacturer());
            var copy = type.CatalogCopy();

            Assert.AreEqual(type.Manufacturer, copy.Manufacturer);
            Assert.AreEqual(type.Cost, copy.Cost);
            Assert.AreEqual(type.Labor, copy.Labor);
            Assert.AreEqual(type.IOModules.Count, copy.IOModules.Count);
            Assert.AreEqual(type.IO.Count, copy.IO.Count);
        }
Ejemplo n.º 22
0
 private void setup(IEnumerable <TECControllerType> controllerTypes)
 {
     Quantity                = 1;
     noneControllerType      = new TECControllerType(new TECManufacturer());
     noneControllerType.Name = "Select Controller Type";
     toAdd           = new TECProvidedController(noneControllerType);
     ControllerTypes = new List <TECControllerType>(controllerTypes);
     ControllerTypes.Insert(0, noneControllerType);
     AddCommand   = new RelayCommand(addExecute, addCanExecute);
     SelectedType = noneControllerType;
     //PropertiesVM = new PropertiesVM()
 }
        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.º 24
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);
            }
        }
Ejemplo n.º 25
0
        private void testNetworkExecute()
        {
            TECControllerType type = new TECControllerType(bid.Catalogs.Manufacturers[0]);

            type.Name = "Controller Type";
            type.IO.Add(new TECIO(IOType.AI));

            bid.Catalogs.Add(type);

            TECProvidedController controller = new TECProvidedController(type);

            controller.Name        = "Test Server";
            controller.Description = "For testing.";
            controller.IsServer    = true;

            bid.AddController(controller);

            TECProvidedController child = new TECProvidedController(type);

            child.Name = "Child";

            bid.AddController(child);

            TECProvidedController emptyController = new TECProvidedController(type);

            emptyController.Name = "EmptyController";

            bid.AddController(emptyController);

            TECNetworkConnection connection = controller.AddNetworkConnection(bid.Catalogs.Protocols[0]);

            connection.AddChild(child);

            TECTypical   typical = new TECTypical();
            TECEquipment equip   = new TECEquipment();
            TECSubScope  ss      = new TECSubScope();

            ss.Name = "Test Subscope";
            ss.AddDevice(bid.Catalogs.Devices[0]);
            TECPoint point = new TECPoint();

            point.Type     = IOType.AI;
            point.Quantity = 1;
            ss.AddPoint(point);
            equip.SubScope.Add(ss);
            typical.Equipment.Add(equip);

            bid.Systems.Add(typical);
            typical.AddInstance();
        }
Ejemplo n.º 26
0
        public static TECControllerType TestControllerType(TECCatalogs catalogs, Random rand)
        {
            TECManufacturer   man  = catalogs.Manufacturers.RandomElement(rand);
            TECControllerType type = new TECControllerType(man);

            type.Description = string.Format("Test Controller Type");
            type.IO.Add(TestIO(rand, IOType.AI));
            type.IO.Add(TestIO(rand, IOType.AO));
            type.IO.Add(TestIO(rand, IOType.DI));
            type.IO.Add(TestIO(rand, IOType.DO));
            type.IO.Add(TestIO(rand, catalogs.Protocols.RandomElement(rand)));
            type.AssignRandomCostProperties(catalogs, rand);
            return(type);
        }
Ejemplo n.º 27
0
        public void CanAddModuleTest()
        {
            TECIOModule module = new TECIOModule(new TECManufacturer());

            TECControllerType cType = new TECControllerType(new TECManufacturer());

            cType.IOModules.Add(module);

            TECProvidedController controller = new TECProvidedController(cType);

            Assert.IsTrue(controller.CanAddModule(module));
            controller.AddModule(module);
            Assert.IsFalse(controller.CanAddModule(module));
        }
Ejemplo n.º 28
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);
        }
Ejemplo n.º 30
0
        public void AddConnection()
        {
            //Arrange
            TECControllerType controllerType = new TECControllerType(bid.Catalogs.Manufacturers[0]);

            bid.Catalogs.Add(controllerType);

            TECTypical typical = new TECTypical();

            bid.Systems.Add(typical);

            TECController controller = new TECProvidedController(controllerType);

            typical.AddController(controller);

            TECEquipment typEquip = new TECEquipment();

            typical.Equipment.Add(typEquip);

            TECSubScope typSS = new TECSubScope();

            typEquip.SubScope.Add(typSS);

            ObservableCollection <TECConnectionType> connectionTypes = new ObservableCollection <TECConnectionType>();

            connectionTypes.Add(bid.Catalogs.ConnectionTypes[0]);
            TECDevice dev = new TECDevice(connectionTypes, new List <TECProtocol>(), bid.Catalogs.Manufacturers[0]);

            bid.Catalogs.Add(dev);
            typSS.Devices.Add(dev);

            MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw);

            //Act
            IControllerConnection connection = controller.Connect(typSS, (typSS as IConnectable).AvailableProtocols.First());

            connection.Length        = 50;
            connection.ConduitLength = 50;
            connection.ConduitType   = bid.Catalogs.ConduitTypes[0];

            TECSystem   instance         = typical.AddInstance();
            TECSubScope instanceSubScope = instance.GetAllSubScope()[0];

            //Assert
            AssertMaterialVMMatchesCostBatch(matVM, connection.CostBatch);
        }