diff --git a/Dirichlet.Numerics/UInt128.cs b/Dirichlet.Numerics/UInt128.cs index c38671769..376fd2340 100644 --- a/Dirichlet.Numerics/UInt128.cs +++ b/Dirichlet.Numerics/UInt128.cs @@ -183,7 +183,7 @@ namespace Dirichlet.Numerics public override string ToString() { - return ((BigInteger)this).ToString(); + return ((BigInteger)this).ToString("x"); } public string ToString(string format) diff --git a/TBF/Rig/BuiltIn/SetValvesOp.cs b/TBF/Rig/BuiltIn/SetValvesOp.cs index d746ef32a..cdb32fed0 100644 --- a/TBF/Rig/BuiltIn/SetValvesOp.cs +++ b/TBF/Rig/BuiltIn/SetValvesOp.cs @@ -15,7 +15,7 @@ namespace TBF.Rig.BuiltIn private static readonly ILog log = LogManager.GetLogger(typeof(SetValvesOp)); /// Set by the constructor - IControlBoard controlBoard; + IControlBoard cb; class SwitchPoint { @@ -183,8 +183,8 @@ namespace TBF.Rig.BuiltIn /// Only Elde.Valve valves are used, other valves on the lists are ignored public SetValvesOp(IControlBoard cb, IList valvesOpen, IList valvesClose) { - controlBoard = cb; - if (controlBoard == null) throw new ArgumentNullException("ctrlBoard"); + this.cb = cb; + if (this.cb == null) throw new ArgumentNullException("ctrlBoard"); if (valvesOpen == null) valvesOpen = new List(); if (valvesClose == null) valvesClose = new List(); @@ -219,8 +219,8 @@ namespace TBF.Rig.BuiltIn /// Only Elde.Valve valves are used, other valves on the lists are ignored public SetValvesOp(IControlBoard cb, bool open, OutputPath outPath) { - controlBoard = cb; - if (controlBoard == null) throw new ArgumentNullException("ctrlBoard"); + this.cb = cb; + if (this.cb == null) throw new ArgumentNullException("ctrlBoard"); IList none = new List(); /// An empty list of valves switchPointsRaw = new List(); @@ -280,7 +280,7 @@ namespace TBF.Rig.BuiltIn /// Start this operation public void Start() { - UInt128 changed = controlBoard.SetValves(switchPoints[0].MasksOpen, switchPoints[0].MasksClose, StateMachine.ExtendedValves); + UInt128 changed = cb.SetValves(switchPoints[0].MasksOpen, switchPoints[0].MasksClose, StateMachine.LogicalFnValves); swStartTime = StateMachine.Time; maxDelayTime = switchPoints[0].MaxDelay(changed); nextIx = 1; @@ -299,7 +299,7 @@ namespace TBF.Rig.BuiltIn if (StateMachine.Time >= swStartTime + switchPoints[nextIx].TimeSec) { - UInt128 changed = controlBoard.SetValves(switchPoints[nextIx].MasksOpen, switchPoints[nextIx].MasksClose, StateMachine.ExtendedValves); + UInt128 changed = cb.SetValves(switchPoints[nextIx].MasksOpen, switchPoints[nextIx].MasksClose, StateMachine.LogicalFnValves); int nextDelay = switchPoints[nextIx].MaxDelay(changed); if (switchPoints[nextIx].TimeSec + nextDelay > maxDelayTime) diff --git a/TBF/Rig/BuiltIn/ValveBase.cs b/TBF/Rig/BuiltIn/ValveBase.cs index 3818827b2..3ea618240 100644 --- a/TBF/Rig/BuiltIn/ValveBase.cs +++ b/TBF/Rig/BuiltIn/ValveBase.cs @@ -59,9 +59,10 @@ namespace TBF.Rig.BuiltIn } /// - /// Process the list of components and return extended valves + /// Process the list of components and return logical function valves + /// (their state is calculated from states of other valves). /// - public static IList ExtendedValves(IList cmpnts) + public static IList LogicalFnValves(IList cmpnts) { IList result = new List(); foreach (var cmpnt in cmpnts) diff --git a/TBF/Rig/ControlBoard/Uni/OutputMessage.cs b/TBF/Rig/ControlBoard/Uni/OutputMessage.cs index b91eb44f5..71ea71d3e 100644 --- a/TBF/Rig/ControlBoard/Uni/OutputMessage.cs +++ b/TBF/Rig/ControlBoard/Uni/OutputMessage.cs @@ -15,7 +15,7 @@ namespace TBF.Rig.ControlBoard.Uni public const int PayloadLen = 38; public const byte MessageCode = (byte)' '; - public static byte[] GetMessage(Action action, short config) + public static byte[] GetMessage(Action action, short config, ulong bitsToInvert) { byte[] message = new byte[PayloadLen + 5]; /// headed 3 bytes, checksum 2 bytes @@ -46,15 +46,16 @@ namespace TBF.Rig.ControlBoard.Uni message[15] = (byte)((config >> 8) & 0xff); /// Route + ulong routeOut = action.Route ^ bitsToInvert; message[16] = ((action.ActionId & ActionID.ChangeRoute) != 0) ? (byte)1 : (byte)0; /// Route change flag - message[17] = (byte)(action.Route & 0xFF); - message[18] = (byte)((action.Route >> 8) & 0xFF); - message[19] = (byte)((action.Route >> 16) & 0xFF); - message[20] = (byte)((action.Route >> 24) & 0xFF); - message[21] = (byte)((action.Route >> 32) & 0xFF); - message[22] = (byte)((action.Route >> 40) & 0xFF); - message[23] = (byte)((action.Route >> 48) & 0xFF); - message[24] = (byte)((action.Route >> 56) & 0xFF); + message[17] = (byte)(routeOut & 0xFF); + message[18] = (byte)((routeOut >> 8) & 0xFF); + message[19] = (byte)((routeOut >> 16) & 0xFF); + message[20] = (byte)((routeOut >> 24) & 0xFF); + message[21] = (byte)((routeOut >> 32) & 0xFF); + message[22] = (byte)((routeOut >> 40) & 0xFF); + message[23] = (byte)((routeOut >> 48) & 0xFF); + message[24] = (byte)((routeOut >> 56) & 0xFF); /// DA2 message[25] = 0; diff --git a/TBF/Rig/ControlBoard/Uni/UniCB.cs b/TBF/Rig/ControlBoard/Uni/UniCB.cs index 808a1472f..4876d6412 100644 --- a/TBF/Rig/ControlBoard/Uni/UniCB.cs +++ b/TBF/Rig/ControlBoard/Uni/UniCB.cs @@ -83,14 +83,32 @@ namespace TBF.Rig.ControlBoard.Uni int rcvdBytesCount; /// Count of valid bytes in rcvdData buffer /// - /// Digital outputs, states of electromagnetic valves + /// Route / digital outputs / states of electromagnetic valves /// + readonly UInt128 routeMask; /// Set in the constructor, bits of outputs that can be controlled by Action.ChangeRoute are set. + /// Regulation valve control outputs and diverters cannot be controlled by Action.ChangeRoute + /// Depends on the control board configuration + + ulong valvesToInvert; /// From configurations of valve and pump components. Inversion is applied when creating + /// Action.ChangeRoute an dafter obtaining RRoute from the control board + + /// State of digital outputs obtained from the control board + public UInt128 RRoute { get { return (UInt128)Data.Vystupy ^ valvesToInvert; } } + + UInt128 displayedRoute; /// A route displayed on the screen (inversions are not applied) + UInt128 bitsChangedByUI; /// Ones in this word indicate which valves/pumpes were changed in UI by mouse clicks + UInt128 displayedRoutePlusUI; /// A route displayed on the screen plus the modifications from UI (inversions are not applied) + UInt128 outputLatch; /// A copy of route sent to physical outputs UInt128 benchModelRoute; - UInt128 valvesToInvert; /// Propagated from configurations of other components - readonly UInt128 routeMask; /// This mask masks out virtual valves, routeMask is set in the constructor bool outputsInitialized; int lastStateMachineTime = 0; + /// + /// Route: 128-bit word representing the current state of all valves and pumps + /// + public UInt128 Route { get { return benchModelRoute; } } + + /// UI actions are blocked when true public bool IsUIBlocked { get; set; } @@ -119,12 +137,6 @@ namespace TBF.Rig.ControlBoard.Uni return 0; } - /// - /// Route: 128-bit word representing the current state of all valves and pumps - /// - public UInt128 Route { get { return benchModelRoute; } } - public UInt128 RRoute { get { return (UInt128)Data.Vystupy; } } - /// Values valid during a test public double RefFrequency { get { return Data.ReferenceFreq[0]; } } public double RefFrequency1 { get { return Data.ReferenceFreq[1]; } } @@ -179,14 +191,11 @@ namespace TBF.Rig.ControlBoard.Uni scopeAnalyzerData = null; switchCounterData = null; - routeMask = 0; - for (int i = 0; i < 128; i++) - { - if (i < cbCfg.VirtValvesRangeLo || i > cbCfg.VirtValvesRangeHi) - { - routeMask = routeMask | ((UInt128)1 << i); - } - } + routeMask = 0xFF00FFFFFF; + for (int i = 0; i < cbCfg.RegValvesCount; i++) routeMask &= ~((UInt128)3 << 2*i); + if (cbCfg.RelaysFInstalled) routeMask |= 0xFF0000000000; + if (cbCfg.RelaysGInstalled) routeMask |= 0xFF000000000000; + if (cbCfg.RelaysHInstalled) routeMask |= 0xFF00000000000000; log.Warn(this.ToString()); } @@ -197,8 +206,7 @@ namespace TBF.Rig.ControlBoard.Uni /// public void SpecifyInvertedValves(UInt128 valvesToInvert) { - this.valvesToInvert = valvesToInvert; - this.benchModelRoute = valvesToInvert; + this.valvesToInvert = (ulong)valvesToInvert; } #region IDevice interface @@ -225,17 +233,20 @@ namespace TBF.Rig.ControlBoard.Uni serialPort.ParityReplace = 0xFF; serialPort.Open(); + /// Handler handling mouse clicks on the schematc drawinng - valve or pump state changes TBF.UiBridge.Bridge.RouteChangeHandler += delegate(object sndr, TBF.UiBridge.RouteChangeArgs args) { - UInt128 mask = ((UInt128)1) << args.BitNr; - if ((benchModelRoute & mask) == 0) - { - benchModelRoute |= mask; - } - else - { - benchModelRoute &= (~mask); - } + UInt128 oneBitMask = ((UInt128)1) << args.BitNr; + bitsChangedByUI |= oneBitMask; + displayedRoutePlusUI = displayedRoutePlusUI ^ oneBitMask; + //if ((displayedRoutePlusUI & oneBitMask) == 0) + //{ + // displayedRoutePlusUI |= oneBitMask; + //} + //else + //{ + // displayedRoutePlusUI &= (~oneBitMask); + //} }; log.FatalFormat("{0} - Device successfully initialized", Name); @@ -329,20 +340,15 @@ namespace TBF.Rig.ControlBoard.Uni } rcvdBytesCount -= lastValidOffset; - /// Synchronize benchModelRoute with RRoute - SyncRoute(); - } + benchModelRoute = RRoute; + /// + if (!IsUIBlocked && bitsChangedByUI != 0) + { + benchModelRoute = (benchModelRoute & ~bitsChangedByUI) | (displayedRoutePlusUI & bitsChangedByUI); + bitsChangedByUI = 0; + } - /// - /// Set Route to value returned by RRoute. Take virtual valves into account. - /// - /// 'ulong' with bits of valves that have changed set to '1' - public UInt128 SyncRoute() - { - UInt128 oldRoute = benchModelRoute; - benchModelRoute = (RRoute & routeMask) | (benchModelRoute & (~routeMask)); - log.DebugFormat("SyncRoute(), new route = {0}", Utils.RouteToStr(benchModelRoute)); - return oldRoute ^ benchModelRoute; + log.DebugFormat("Route synced with RRoute and UI changes, new route = {0}", Utils.RouteToStr(benchModelRoute)); } /// @@ -352,6 +358,20 @@ namespace TBF.Rig.ControlBoard.Uni { if (cbCfg.DebugLevel != DebugMode.Normal) return; + + /// Synchronize benchModelRoute with RRoute + if (!IsUIBlocked && bitsChangedByUI != 0) + { + benchModelRoute = (benchModelRoute & ~bitsChangedByUI) | (displayedRoutePlusUI & bitsChangedByUI); + bitsChangedByUI = 0; + } + displayedRoute = Route; + displayedRoutePlusUI = Route; + bitsChangedByUI = 0; + ProcessData.UpdateMeasuredValuesAndSetpoints(); + Bridge.OnStateMachineTick(this, new StateMachineTickEventArgs(displayedRoute, ProcessData.MsrmntAvailableFlags, ProcessData.MeasuredValues, + ProcessData.AltStrings, ProcessData.Setpoints)); + /// Make sure the serial port is open if (serialPort == null || !serialPort.IsOpen) { @@ -374,7 +394,7 @@ namespace TBF.Rig.ControlBoard.Uni } } - if (!outputsInitialized || RRoute != benchModelRoute) /// || (StateMachine.Time - lastStateMachineTime) >= 15) + if (!outputsInitialized || (outputLatch & routeMask) != (benchModelRoute & routeMask)) /// || (StateMachine.Time - lastStateMachineTime) >= 15) { var actionsToModify = actionQueue.Where(x => (x.ActionId == ActionID.ChangeRoute)); bool oneModified = false; @@ -394,7 +414,7 @@ namespace TBF.Rig.ControlBoard.Uni if (!oneModified) { actionQueue.Enqueue(Action.ChangeRoute(false, (ulong)benchModelRoute)); - log.InfoFormat("ChangeRoute(route={0:X}) ... a new action enqueued", benchModelRoute); + log.InfoFormat("ChangeRoute(route={0:X}) ... a new action enqueued", (ulong)benchModelRoute); } foreach (var a in actionQueue) log.DebugFormat(" {0}", a); @@ -402,12 +422,13 @@ namespace TBF.Rig.ControlBoard.Uni var combinedAction = Action.FetchNonConflictingActions(actionQueue); /// Default action is RequestDataOnly - byte[] outData = OutputMessage.GetMessage(combinedAction, config); + byte[] outData = OutputMessage.GetMessage(combinedAction, config, valvesToInvert); if (outData != null && outData.Length > 0) { if ((combinedAction.ActionId & ActionID.ChangeRoute) != 0) { outputsInitialized = true; + outputLatch = combinedAction.Route; lastStateMachineTime = StateMachine.Time; } @@ -417,11 +438,6 @@ namespace TBF.Rig.ControlBoard.Uni Debug.WriteLine(s); log.Debug(s); } - - - ProcessData.UpdateMeasuredValuesAndSetpoints(); - Bridge.OnStateMachineTick(this, new StateMachineTickEventArgs(Route, ProcessData.MsrmntAvailableFlags, ProcessData.MeasuredValues, - ProcessData.AltStrings, ProcessData.Setpoints)); } public void StopDevice() @@ -470,11 +486,18 @@ namespace TBF.Rig.ControlBoard.Uni return 0; } - public UInt128 SetValves(UInt128 valvesToOpen, UInt128 valvesToClose, IList extendedValves) + /// + /// Called from Start() and Run() functions of SetValvesOp, i.e. from State.RunOperations(). + /// + /// Bits of valves to be open are set + /// Bits of valves to be closed are set + /// A list of logical function valves (to be calculated and applied afterwards) + /// Bits of changed valves are set in the return value + public UInt128 SetValves(UInt128 valvesToOpen, UInt128 valvesToClose, IList logicalFnValves) { UInt128 oldRoute = benchModelRoute; - benchModelRoute = (((benchModelRoute ^ valvesToInvert) | valvesToOpen) & (~valvesToClose)) ^ valvesToInvert; - foreach (var extV in extendedValves) extV.UpdateRoute(ref benchModelRoute); + benchModelRoute = (benchModelRoute | valvesToOpen) & (~valvesToClose); + foreach (var logFnV in logicalFnValves) logFnV.UpdateRoute(ref benchModelRoute); log.DebugFormat("SetValves(x,x), new route = {0}", Utils.RouteToStr(benchModelRoute)); UInt128 retVal = oldRoute ^ benchModelRoute; diff --git a/TBF/Rig/ControlBoard/Uni/UniCBCfg.cs b/TBF/Rig/ControlBoard/Uni/UniCBCfg.cs index 58bc1eb9e..beb42c14b 100644 --- a/TBF/Rig/ControlBoard/Uni/UniCBCfg.cs +++ b/TBF/Rig/ControlBoard/Uni/UniCBCfg.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Xml.Serialization; using Config.Entities; using SchematicDrawing; +using TBF.Resources; using TBF.Rig.Generic; namespace TBF.Rig.ControlBoard.Uni @@ -27,8 +28,9 @@ namespace TBF.Rig.ControlBoard.Uni public int DivertersCount; public int DrainValvesCount; public int RegValvesCount; - public int VirtValvesRangeLo; - public int VirtValvesRangeHi; + public bool RelaysFInstalled; + public bool RelaysGInstalled; + public bool RelaysHInstalled; /// Schematic drawing info public Shape Shape { get; set; } @@ -77,8 +79,12 @@ namespace TBF.Rig.ControlBoard.Uni public void InitializeAll() { ComPortNr = 1; - VirtValvesRangeLo = 90; - VirtValvesRangeHi = 99; + DivertersCount = 3; + DrainValvesCount = 4; + RegValvesCount = 5; + RelaysFInstalled = true; + RelaysGInstalled = true; + RelaysHInstalled = true; } string[] paramNames = new string[] @@ -87,23 +93,38 @@ namespace TBF.Rig.ControlBoard.Uni "Diverters count (1..5)", "Drain valves count (0..8)", "Regulation valves count (4..8)", - "Virtual valves range LO [bit#]", - "Virtual valves range HI [bit#]", + "Relays F are installed", + "Relays G are installed", + "Relays H are installed", }; public string ParamName(int i) { return paramNames[i]; } public int ParamsCount() { return paramNames.Length; } public ICollection ParamValues(int i) { - return null; + switch (i) + { + case 1: + return new string[] { "1", "2", "3", "4", "5" }; + case 2: + return new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8" }; + case 3: + return new string[] { "4", "5", "6", "7", "8" }; + case 4: + case 5: + case 6: + return new string[] { Strings.yes, Strings.no }; + default: + return null; + } } public string ToString(int i) { if (i == -1) { - return string.Format("{0}: COM{1} DIVs={2} VBs={3} RVs={4} VirtVRangeLo={5}, VirtVRangeHi={6}", - Name, ComPortNr, DivertersCount, DrainValvesCount, RegValvesCount, VirtValvesRangeLo, VirtValvesRangeHi); + return string.Format("{0}: COM{1} DIVs={2} VBs={3} RVs={4} RelaysF={5} RelaysG={6} RelaysH={7}", + Name, ComPortNr, DivertersCount, DrainValvesCount, RegValvesCount, RelaysFInstalled, RelaysGInstalled, RelaysHInstalled); } switch (i) @@ -112,27 +133,29 @@ namespace TBF.Rig.ControlBoard.Uni case 1: return DivertersCount.ToString(); case 2: return DrainValvesCount.ToString(); case 3: return RegValvesCount.ToString(); - case 4: return VirtValvesRangeLo.ToString(); - case 5: return VirtValvesRangeHi.ToString(); + case 4: return RelaysFInstalled ? Strings.yes : Strings.no; + case 5: return RelaysGInstalled ? Strings.yes : Strings.no; + case 6: return RelaysHInstalled ? Strings.yes : Strings.no; default: return string.Empty; } } - public CfgUpdateFlags UpdateParam(int i, string strValue) + public CfgUpdateFlags UpdateParam(int i, string str) { switch (i) { - case 0: ComPortNr = int.Parse(strValue); return CfgUpdateFlags.RestartRqrd; - case 1: DivertersCount = int.Parse(strValue); return CfgUpdateFlags.RestartRqrd; - case 2: DrainValvesCount = int.Parse(strValue); return CfgUpdateFlags.RestartRqrd; - case 3: RegValvesCount = int.Parse(strValue); return CfgUpdateFlags.RestartRqrd; - case 4: VirtValvesRangeLo = int.Parse(strValue); return CfgUpdateFlags.RestartRqrd; - case 5: VirtValvesRangeHi = int.Parse(strValue); return CfgUpdateFlags.RestartRqrd; + case 0: ComPortNr = int.Parse(str); return CfgUpdateFlags.RestartRqrd; + case 1: DivertersCount = int.Parse(str); return CfgUpdateFlags.RestartRqrd; + case 2: DrainValvesCount = int.Parse(str); return CfgUpdateFlags.RestartRqrd; + case 3: RegValvesCount = int.Parse(str); return CfgUpdateFlags.RestartRqrd; + case 4: RelaysFInstalled = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd; + case 5: RelaysGInstalled = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd; + case 6: RelaysHInstalled = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd; default: return CfgUpdateFlags.None; } } - public bool ValidateParam(int i, string strValue, out string message) + public bool ValidateParam(int i, string str, out string message) { message = string.Empty; int n; @@ -140,20 +163,21 @@ namespace TBF.Rig.ControlBoard.Uni switch (i) { case 0: - if (int.TryParse(strValue, out n) && (n >= 1)) return true; + if (int.TryParse(str, out n) && (n >= 1)) return true; break; case 1: - if (int.TryParse(strValue, out n) && (n >= 1) && n <= 5) return true; + if (int.TryParse(str, out n) && (n >= 1) && n <= 5) return true; break; case 2: - if (int.TryParse(strValue, out n) && (n >= 0) && n <= 8) return true; + if (int.TryParse(str, out n) && (n >= 0) && n <= 8) return true; break; case 3: - if (int.TryParse(strValue, out n) && (n >= 4) && n <= 8) return true; + if (int.TryParse(str, out n) && (n >= 4) && n <= 8) return true; break; case 4: case 5: - if (int.TryParse(strValue, out n) && (n >= 0) && n <= 127) return true; + case 6: + if (ParamValues(i).Contains(str)) return true; break; default: message = "Invalid index"; @@ -167,11 +191,12 @@ namespace TBF.Rig.ControlBoard.Uni void CopyContentTo(UniCBCfg prms) { prms.ComPortNr = ComPortNr; - prms.DivertersCount = DivertersCount; + prms.DivertersCount = DivertersCount; prms.DrainValvesCount = DrainValvesCount; - prms.RegValvesCount = RegValvesCount; - prms.VirtValvesRangeLo = VirtValvesRangeLo; - prms.VirtValvesRangeHi = VirtValvesRangeHi; + prms.RegValvesCount = RegValvesCount; + prms.RelaysFInstalled = RelaysFInstalled; + prms.RelaysGInstalled = RelaysGInstalled; + prms.RelaysHInstalled = RelaysHInstalled; } public Config.Entities.IParamsProvider Clone() diff --git a/TBF/Rig/StateMachine.cs b/TBF/Rig/StateMachine.cs index 9f8eb7369..cdaa61eb9 100644 --- a/TBF/Rig/StateMachine.cs +++ b/TBF/Rig/StateMachine.cs @@ -61,9 +61,9 @@ namespace TBF.Rig public static GenericDevices.IValve DrainValve1; public static GenericDevices.IValve DrainValve2; public static GenericDevices.IValve DrainValve3; - public static IList MasterValves; /// list of directly controlled valves - public static IList CoupledValves; /// list of coupled valves - public static IList ExtendedValves; /// list of extended valves + public static IList MasterValves; /// list of directly controlled valves + public static IList CoupledValves; /// list of coupled valves + public static IList LogicalFnValves; /// list of logical function valves public static IList LoopStartNames; public static IList LoopEndNames; @@ -225,7 +225,7 @@ namespace TBF.Rig components = Rig.TbfComponents.LoadComponentsFromDB(cmpntEntities); MasterValves = BuiltIn.ValveBase.GetMasterValves(components); CoupledValves = BuiltIn.ValveBase.CoupledValves(components); - ExtendedValves = BuiltIn.ValveBase.ExtendedValves(components); + LogicalFnValves = BuiltIn.ValveBase.LogicalFnValves(components); ProcessData.ComponentsWithMeasuredVal.Clear(); ProcessData.ComponentsWithSetpoint.Clear(); @@ -400,8 +400,12 @@ namespace TBF.Rig /// public static void StopDevices() { - foreach (var dev in devices) + /// StopDevices() functions of devices are called in + /// reversed order so that the parent compnent's StopDevices() + /// is called after calling StopDevices() of it's children. + for (int i = devices.Count - 1; i >= 0; i--) { + var dev = devices[i]; UiBridge.Bridge.OnActivity(null, string.Format("1. {0}", dev.Name)); /// Info dev.StopDevice(); } @@ -414,8 +418,12 @@ namespace TBF.Rig /// public static void StopDevices2() { - foreach (var dev in devices) + /// StopDevices2() functions of devices are called in + /// reversed order so that the parent compnent's StopDevices2() + /// is called after calling StopDevices2() of it's children. + for (int i = devices.Count - 1; i >= 0; i--) { + var dev = devices[i]; UiBridge.Bridge.OnActivity(null, string.Format("2. {0}", dev.Name)); /// Info dev.StopDevice2(); } @@ -812,9 +820,9 @@ namespace TBF.Rig { Thread.Sleep(100); /// Insert 1/10 sec.delay between RunOperations() and RunDeviceAfter() - /// Call RunDeviceAfter() functions in reversed order - /// so that the parent compnent's RunDeviceAfter() - /// is called after RunDeviceAfter() of it's children. + /// RunDeviceAfter() functions of devices are called in + /// reversed order so that the parent compnent's RunDeviceAfter() + /// is called after calling RunDeviceAfter() of it's children. for (int i = devices.Count - 1; i >= 0; i--) { devices[i].RunDeviceAfter(); diff --git a/TBF/UI/MainWnd.cs b/TBF/UI/MainWnd.cs index 45ce846f7..dfb38ace3 100644 --- a/TBF/UI/MainWnd.cs +++ b/TBF/UI/MainWnd.cs @@ -458,6 +458,12 @@ namespace TBF.UI activityStatusLabel.Text = args.StateChangedMsg; } + /// + /// This function copies route and process values to the schematic drawing control. + /// Schematic drawing is then redrawn accordingly in the next OnPaint(). + /// + /// + /// void OnStateMachineTick(object sender, StateMachineTickEventArgs args) { drawingCtrl.SupressRedraws = true;