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);
        }
        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 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));
        }
예제 #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);
        }
예제 #5
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 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);
        }
예제 #7
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 RemoveDeviceFromConnectedHardwired()
        {
            TECControllerType type = new TECControllerType(new TECManufacturer());

            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);

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

            subScope.RemoveDevice(device);

            Assert.IsNull((subScope as IConnectable).GetParentConnection());
            Assert.IsFalse(controller.ChildrenConnections.Contains(connection));
        }
        public void CanConnectTest6()
        {
            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);

            Assert.IsTrue(controller.CanConnect(subScope, subScope.HardwiredProtocol()));
        }