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."); } } } }
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); }