public void SpecificDoesntContainUniversalIO() { //Ex. 6 AI doesn't contain 5 UI, uses Contains(TECIO) TECIO ai = new TECIO(IOType.AI); ai.Quantity = 5; TECIO ao = new TECIO(IOType.AO); ao.Quantity = 5; TECIO di = new TECIO(IOType.DI); di.Quantity = 5; TECIO ioDO = new TECIO(IOType.DO); ioDO.Quantity = 5; List <TECIO> io = new List <TECIO> { ai, ao, di, ioDO }; IOCollection collection = new IOCollection(io); TECIO ui = new TECIO(IOType.UI); ui.Quantity = 3; TECIO uo = new TECIO(IOType.UO); uo.Quantity = 3; Assert.IsFalse(collection.Contains(ui)); Assert.IsFalse(collection.Contains(uo)); }
public void RemoveSpecificListFromUnivsersal() { List <TECIO> io = new List <TECIO> { new TECIO(IOType.AI), new TECIO(IOType.AO), new TECIO(IOType.DI), new TECIO(IOType.DO) }; List <TECIO> otherIO = new List <TECIO> { new TECIO(IOType.UI), new TECIO(IOType.UI), new TECIO(IOType.UI), new TECIO(IOType.UI), new TECIO(IOType.UO), new TECIO(IOType.UO), new TECIO(IOType.UO), new TECIO(IOType.UO) }; IOCollection firstColletion = new IOCollection(io); IOCollection secondCollection = new IOCollection(otherIO); IOCollection resultCollection = new IOCollection(secondCollection); resultCollection.Remove(firstColletion.ToList()); Assert.IsTrue(resultCollection.Contains(IOType.UI)); Assert.AreEqual(2, resultCollection.IONumber(IOType.UI)); Assert.IsTrue(resultCollection.Contains(IOType.UO)); Assert.AreEqual(2, resultCollection.IONumber(IOType.UO)); }
public void AddList() { List <TECIO> io = new List <TECIO> { new TECIO(IOType.AI), new TECIO(IOType.AO), new TECIO(IOType.DI), new TECIO(IOType.DO) }; IOCollection firstColletion = new IOCollection(io); IOCollection secondCollection = new IOCollection(io); IOCollection resultCollection = new IOCollection(); resultCollection.Add(firstColletion.ToList()); resultCollection.Add(secondCollection.ToList()); Assert.IsTrue(resultCollection.Contains(IOType.AI)); Assert.AreEqual(2, resultCollection.IONumber(IOType.AI)); Assert.IsTrue(resultCollection.Contains(IOType.AO)); Assert.AreEqual(2, resultCollection.IONumber(IOType.AO)); Assert.IsTrue(resultCollection.Contains(IOType.DI)); Assert.AreEqual(2, resultCollection.IONumber(IOType.DI)); Assert.IsTrue(resultCollection.Contains(IOType.DO)); Assert.AreEqual(2, resultCollection.IONumber(IOType.DO)); }
public void UniversalContainsSpecificIO() { //Ex. 5 UI contains 3 AI and 3 DI separately, uses Contains(TECIO) TECIO ui = new TECIO(IOType.UI); ui.Quantity = 5; TECIO uo = new TECIO(IOType.UO); uo.Quantity = 5; List <TECIO> io = new List <TECIO> { ui, uo }; IOCollection collection = new IOCollection(io); TECIO aiX = new TECIO(IOType.AI); aiX.Quantity = 3; TECIO aoX = new TECIO(IOType.AO); aoX.Quantity = 3; TECIO diX = new TECIO(IOType.DI); diX.Quantity = 3; TECIO ioDOX = new TECIO(IOType.DO); ioDOX.Quantity = 3; Assert.IsTrue(collection.Contains(aiX)); Assert.IsTrue(collection.Contains(aoX)); Assert.IsTrue(collection.Contains(diX)); Assert.IsTrue(collection.Contains(ioDOX)); }
public void SpecificDoesntContainUniversalType() { //Ex. AI and DI don't contain UI, uses Contains(IOType) List <TECIO> io = new List <TECIO> { new TECIO(IOType.AI), new TECIO(IOType.AO), new TECIO(IOType.DI), new TECIO(IOType.DO) }; IOCollection collection = new IOCollection(io); Assert.IsFalse(collection.Contains(IOType.UI)); Assert.IsFalse(collection.Contains(IOType.UO)); }
public void UnivseralContainsSpecificType() { //Ex. UI contains AI and DI, uses Contains(IOType) List <TECIO> io = new List <TECIO> { new TECIO(IOType.UI), new TECIO(IOType.UO) }; IOCollection collection = new IOCollection(io); Assert.IsTrue(collection.Contains(IOType.AI)); Assert.IsTrue(collection.Contains(IOType.AO)); Assert.IsTrue(collection.Contains(IOType.DI)); Assert.IsTrue(collection.Contains(IOType.DO)); }
public void ContainsSameType() { //Ex. AI contains AI, uses Contains(IOType) List <TECIO> io = new List <TECIO> { new TECIO(IOType.AI), new TECIO(IOType.AO), new TECIO(IOType.DI), new TECIO(IOType.DO) }; IOCollection collection = new IOCollection(io); Assert.IsTrue(collection.Contains(IOType.AI)); Assert.IsTrue(collection.Contains(IOType.AO)); Assert.IsTrue(collection.Contains(IOType.DI)); Assert.IsTrue(collection.Contains(IOType.DO)); }
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 void ContainsSameIO() { //Ex. 5 AI contains 3 AI, uses Contains(TECIO) TECIO ai = new TECIO(IOType.AI); ai.Quantity = 5; TECIO ao = new TECIO(IOType.AO); ao.Quantity = 5; TECIO di = new TECIO(IOType.DI); di.Quantity = 5; TECIO ioDO = new TECIO(IOType.DO); ioDO.Quantity = 5; List <TECIO> io = new List <TECIO> { ai, ao, di, ioDO }; IOCollection collection = new IOCollection(io); TECIO aiX = new TECIO(IOType.AI); aiX.Quantity = 3; TECIO aoX = new TECIO(IOType.AO); aoX.Quantity = 3; TECIO diX = new TECIO(IOType.DI); diX.Quantity = 3; TECIO ioDOX = new TECIO(IOType.DO); ioDOX.Quantity = 3; Assert.IsTrue(collection.Contains(aiX)); Assert.IsTrue(collection.Contains(aoX)); Assert.IsTrue(collection.Contains(diX)); Assert.IsTrue(collection.Contains(ioDOX)); }
public void ContainsSameCollection() { //Ex. 5 AI, 3 DI contains 4 AI, 2 DI. Uses Contains(IOCollection) TECIO ai = new TECIO(IOType.AI); ai.Quantity = 5; TECIO ao = new TECIO(IOType.AO); ao.Quantity = 5; TECIO di = new TECIO(IOType.DI); di.Quantity = 5; TECIO ioDO = new TECIO(IOType.DO); ioDO.Quantity = 5; List <TECIO> io = new List <TECIO> { ai, ao, di, ioDO }; IOCollection collection = new IOCollection(io); TECIO aix = new TECIO(IOType.AI); aix.Quantity = 3; TECIO aox = new TECIO(IOType.AO); aox.Quantity = 2; TECIO dix = new TECIO(IOType.DI); dix.Quantity = 4; TECIO ioDOx = new TECIO(IOType.DO); ioDOx.Quantity = 5; List <TECIO> subjectIo = new List <TECIO> { aix, aox, dix, ioDOx }; IOCollection subjectCollection = new IOCollection(subjectIo); Assert.IsTrue(collection.Contains(subjectCollection)); }
public void SpecificDoesntContainUniversalCollection() { //Ex. 3 AI, 2 DI, 3 AO, 2 DO doesn't contain 2 UI, 2 UO. Uses Contains(IOCollection) TECIO ai = new TECIO(IOType.AI); ai.Quantity = 5; TECIO ao = new TECIO(IOType.AO); ao.Quantity = 5; TECIO di = new TECIO(IOType.DI); di.Quantity = 5; TECIO ioDO = new TECIO(IOType.DO); ioDO.Quantity = 5; List <TECIO> io = new List <TECIO> { ai, ao, di, ioDO }; IOCollection collection = new IOCollection(io); TECIO ui = new TECIO(IOType.UI); ui.Quantity = 2; TECIO uo = new TECIO(IOType.UO); uo.Quantity = 2; List <TECIO> subjectIO = new List <TECIO> { ui, uo }; IOCollection subjectCollection = new IOCollection(subjectIO); Assert.IsFalse(collection.Contains(subjectCollection)); }
public void UniversalContainsSpecificCollection() { //Ex. 5 UI, 5 UO contains 3 AI, 2 DI, 3 AO, 2 DO. Uses Contains(IOCollection) TECIO ui = new TECIO(IOType.UI); ui.Quantity = 5; TECIO uo = new TECIO(IOType.UO); uo.Quantity = 5; List <TECIO> io = new List <TECIO> { ui, uo }; IOCollection collection = new IOCollection(io); TECIO ai = new TECIO(IOType.AI); ai.Quantity = 3; TECIO ao = new TECIO(IOType.AO); ao.Quantity = 2; TECIO di = new TECIO(IOType.DI); di.Quantity = 2; TECIO ioDO = new TECIO(IOType.DO); ioDO.Quantity = 3; List <TECIO> subjectIo = new List <TECIO> { ai, ao, di, ioDO }; IOCollection subjectCollection = new IOCollection(subjectIo); Assert.IsTrue(collection.Contains(subjectCollection)); }