void CheckValidity() { int inputs = 0; int outputs = 0; bool isSignal = false; bool isData = false; for (int i = 0; i < connectedIOs.Count; i++) { switch (connectedIOs[i].IOtype) { case RTIO.ProcessingIOType.SignalInput: inputs++; isSignal = true; break; case RTIO.ProcessingIOType.SignalOutput: outputs++; isSignal = true; break; case RTIO.ProcessingIOType.DataInput: inputs++; isData = true; break; case RTIO.ProcessingIOType.DataOutput: outputs++; isData = true; break; } } valid = true; if (isSignal && isData) { valid = false; } if (outputs != 1) { valid = false; } if (valid) { if (isSignal) { netType = ProcessingNetType.Signal; } else { netType = ProcessingNetType.Data; } } else { netType = ProcessingNetType.Unknown; } }
public ProcessingNet(SystemPanel _owner) { owner = _owner; connectedIOs = new List <RTIO>(); connections = new List <ProcessingConnection>(); _isNamed = false; _name = owner.createUniqueNetName(); netType = ProcessingNetType.Unknown; init(); }
public ProcessingNet(SystemPanel _owner, BinaryReader src) { owner = _owner; connectedIOs = new List <RTIO>(); connections = new List <ProcessingConnection>(); _isNamed = src.ReadBoolean(); if (_isNamed) { _name = src.ReadString(); } else { _name = owner.createUniqueNetName(); } netType = ProcessingNetType.Unknown; init(); int cios = src.ReadInt32(); if (cios < 0) { throw new Exception("Bad Input File: File corrupt in Net Read"); } for (int i = 0; i < cios; i++) { String elementID = src.ReadString(); int elementIO = src.ReadInt32(); RTForm pe = owner.findElement(elementID); if (pe == null) { throw new Exception("Bad Input File: Linked Element not found"); } List <RTIO> rio = pe.GetIOs(); if ((elementIO < 0) || (elementIO >= rio.Count)) { throw new Exception("Bad Input File: Linked Element has not enough IOs"); } rio[elementIO].connectedTo = this; connectedIOs.Add(rio[elementIO]); } int cns = src.ReadInt32(); if (cns < 0) { throw new Exception("Bad Input File: File corrupt in Net Read"); } for (int i = 0; i < cns; i++) { int a = src.ReadInt32(); int b = src.ReadInt32(); if ((a < 0) || (b < 0) || (a >= connectedIOs.Count) || (a >= connectedIOs.Count)) { throw new Exception("Bad Input File: File corrupt in Net Read"); } connections.Add(new ProcessingConnection(a, b)); } CheckValidity(); }