diff --git a/TestBenchFramework/BenchControl/Elde/Valve/SetValvesOp.cs b/TestBenchFramework/BenchControl/Elde/Valve/SetValvesOp.cs index 80286b512..5507d6b8c 100644 --- a/TestBenchFramework/BenchControl/Elde/Valve/SetValvesOp.cs +++ b/TestBenchFramework/BenchControl/Elde/Valve/SetValvesOp.cs @@ -23,7 +23,7 @@ namespace TBF.BenchControl.Elde.Valve public SwitchPoint(int time, IList vOpen, IList vClose) { this.TimeSec = time; - this.VOpen = (vOpen == null) ? new List() : vOpen; + this.VOpen = (vOpen == null) ? new List() : vOpen; this.VClose = (vClose == null) ? new List() : vClose; } @@ -78,7 +78,7 @@ namespace TBF.BenchControl.Elde.Valve foreach (var valve in StateMachine.CoupledValves) { if ((!valve.InvertCouple && valvesOpen.Contains(valve.CoupledTo)) || - (valve.InvertCouple && valvesClose.Contains(valve.CoupledTo))) + (valve.InvertCouple && valvesClose.Contains(valve.CoupledTo))) { /// The coupled valve 'valve' is opening int time = valve.LagOpening; @@ -92,7 +92,7 @@ namespace TBF.BenchControl.Elde.Valve } } else if ((!valve.InvertCouple && valvesClose.Contains(valve.CoupledTo)) || - (valve.InvertCouple && valvesOpen.Contains(valve.CoupledTo))) + (valve.InvertCouple && valvesOpen.Contains(valve.CoupledTo))) { /// The coupled valve 'valve' is closing int time = valve.LagClosing; @@ -175,8 +175,8 @@ namespace TBF.BenchControl.Elde.Valve if (controlBoard == null) throw new ArgumentNullException("ctrlBoard"); this.controlBoard = controlBoard; - if (valvesOpen == null) valvesOpen = new List(); - if (valvesClose == null) valvesOpen = new List(); + if (valvesOpen == null) valvesOpen = new List(); + if (valvesClose == null) valvesClose = new List(); switchPointsRaw = CollectSwitchPoints(valvesOpen, valvesClose); switchPoints = SortAndMergeSwitchPoints(switchPointsRaw); @@ -215,7 +215,7 @@ namespace TBF.BenchControl.Elde.Valve if (nextIx >= switchPoints.Count) { if (StateMachine.Time >= swStartTime + maxDelayTime) return Event.ValvesSet; - else return Event.None; + else return Event.ValvesBusy; } if (StateMachine.Time >= swStartTime + switchPoints[nextIx].TimeSec) @@ -231,7 +231,7 @@ namespace TBF.BenchControl.Elde.Valve nextIx++; } - return Event.None; + return Event.ValvesBusy; } /// Start this operation diff --git a/TestBenchFramework/BenchControl/Events.cs b/TestBenchFramework/BenchControl/Events.cs index 98a66d28d..bf15addff 100644 --- a/TestBenchFramework/BenchControl/Events.cs +++ b/TestBenchFramework/BenchControl/Events.cs @@ -36,9 +36,14 @@ public enum Event { None = 0, - Done, + Busy, /// Useful when waiting in state until at least one is busy (all are done) + Done, /// Useful when waiting in state until the first is done, the rest miht still be busy + /// ModelessFormClosed, + + ValvesBusy, ValvesSet, + AmbientDone, BalanceDone, BalanceOverload, @@ -107,5 +112,6 @@ No, Next, /// To move to the next state when debugging OK, + TimerBusy, } } diff --git a/TestBenchFramework/BenchControl/GenericDevices/IBalance.cs b/TestBenchFramework/BenchControl/GenericDevices/IBalance.cs index ff8bf2ad8..472c4be2b 100644 --- a/TestBenchFramework/BenchControl/GenericDevices/IBalance.cs +++ b/TestBenchFramework/BenchControl/GenericDevices/IBalance.cs @@ -10,7 +10,7 @@ namespace TBF.BenchControl.GenericDevices public interface IBalance : IDevice, IComponent { /// - /// Camera number: 0-based index required for communication with the Elde component + /// Balance number: 0-based index required for communication with the Elde component /// int BalanceNr { get; } @@ -24,6 +24,12 @@ namespace TBF.BenchControl.GenericDevices /// bool IsEmpty(float mass); + /// + /// Time in seconds to empty the tank completely when it is full + /// + int EmptyTimeSec { get; } + + /// /// Measurement correction table /// diff --git a/TestBenchFramework/BenchControl/MettlerToledo/BalanceCfg.cs b/TestBenchFramework/BenchControl/MettlerToledo/BalanceCfg.cs index ec6cab463..9e0161ab3 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/BalanceCfg.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/BalanceCfg.cs @@ -15,15 +15,17 @@ namespace TBF.BenchControl.MettlerToledo public Handshake Handshake; public float Capacity; /// Max. water mass in 'kg' or volume in 'l' public float Empty; /// 'Empty' water mass in 'kg' or volume in 'l' + public int EmptyTimeSec; /// Parameterless constructor public BalanceCfg() { Empty = 20.0f; + EmptyTimeSec = 180; } /// Constructor - public BalanceCfg(IComponentFactory factory, string name, int comPortNr, int baudRate, Parity parity, int dataBits, StopBits stopBits, Handshake handshake, float capacity, float empty) + public BalanceCfg(IComponentFactory factory, string name, int comPortNr, int baudRate, Parity parity, int dataBits, StopBits stopBits, Handshake handshake, float capacity, float empty, int emptyTimeSec) : base(factory, name) { this.ComPortNr = comPortNr; @@ -34,16 +36,18 @@ namespace TBF.BenchControl.MettlerToledo this.Handshake = handshake; this.Capacity = capacity; this.Empty = empty; + this.EmptyTimeSec = emptyTimeSec; } public IComponentCfg Clone() { - return new BalanceCfg(Factory, Name, ComPortNr, BaudRate, Parity, DataBits, StopBits, Handshake, Capacity, Empty); + return new BalanceCfg(Factory, Name, ComPortNr, BaudRate, Parity, DataBits, StopBits, Handshake, Capacity, Empty, EmptyTimeSec); } public string ToString(int i) { - return string.Format("COM{0}, {1}Bd, {2}bits, parity={3}, stopBits={4}, {5}, capacity={6}kg", ComPortNr, BaudRate, DataBits, Parity, StopBits, Handshake, Capacity); + return string.Format("COM{0}, {1}Bd, {2}bits, parity={3}, stopBits={4}, {5}, capacity={6}kg, empty={7}kg, emptyTime={8}s", + ComPortNr, BaudRate, DataBits, Parity, StopBits, Handshake, Capacity, Empty, EmptyTimeSec); } public TBF.Entities.Component CreateDbEntity() diff --git a/TestBenchFramework/BenchControl/MettlerToledo/BalanceCfgCtrl.Designer.cs b/TestBenchFramework/BenchControl/MettlerToledo/BalanceCfgCtrl.Designer.cs index afac54529..e2f5db78e 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/BalanceCfgCtrl.Designer.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/BalanceCfgCtrl.Designer.cs @@ -49,13 +49,16 @@ this.label3 = new System.Windows.Forms.Label(); this.emptyTextBox = new System.Windows.Forms.TextBox(); this.emptyLabel = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.emptyTimeTextBox = new System.Windows.Forms.TextBox(); + this.label5 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // handshakeComboBox // this.handshakeComboBox.Enabled = false; this.handshakeComboBox.FormattingEnabled = true; - this.handshakeComboBox.Location = new System.Drawing.Point(136, 173); + this.handshakeComboBox.Location = new System.Drawing.Point(136, 159); this.handshakeComboBox.Name = "handshakeComboBox"; this.handshakeComboBox.Size = new System.Drawing.Size(130, 21); this.handshakeComboBox.TabIndex = 14; @@ -64,7 +67,7 @@ // this.stopBitsComboBox.Enabled = false; this.stopBitsComboBox.FormattingEnabled = true; - this.stopBitsComboBox.Location = new System.Drawing.Point(136, 149); + this.stopBitsComboBox.Location = new System.Drawing.Point(136, 137); this.stopBitsComboBox.Name = "stopBitsComboBox"; this.stopBitsComboBox.Size = new System.Drawing.Size(130, 21); this.stopBitsComboBox.TabIndex = 12; @@ -73,7 +76,7 @@ // this.parityComboBox.Enabled = false; this.parityComboBox.FormattingEnabled = true; - this.parityComboBox.Location = new System.Drawing.Point(136, 101); + this.parityComboBox.Location = new System.Drawing.Point(136, 93); this.parityComboBox.Name = "parityComboBox"; this.parityComboBox.Size = new System.Drawing.Size(130, 21); this.parityComboBox.TabIndex = 8; @@ -81,7 +84,7 @@ // nameTextBox // this.nameTextBox.Enabled = false; - this.nameTextBox.Location = new System.Drawing.Point(136, 29); + this.nameTextBox.Location = new System.Drawing.Point(136, 27); this.nameTextBox.Name = "nameTextBox"; this.nameTextBox.Size = new System.Drawing.Size(130, 20); this.nameTextBox.TabIndex = 2; @@ -89,7 +92,7 @@ // nameLabel // this.nameLabel.AutoSize = true; - this.nameLabel.Location = new System.Drawing.Point(26, 32); + this.nameLabel.Location = new System.Drawing.Point(26, 30); this.nameLabel.Name = "nameLabel"; this.nameLabel.Size = new System.Drawing.Size(35, 13); this.nameLabel.TabIndex = 1; @@ -98,7 +101,7 @@ // classNameLabel // this.classNameLabel.AutoSize = true; - this.classNameLabel.Location = new System.Drawing.Point(133, 8); + this.classNameLabel.Location = new System.Drawing.Point(133, 7); this.classNameLabel.Name = "classNameLabel"; this.classNameLabel.Size = new System.Drawing.Size(83, 13); this.classNameLabel.TabIndex = 0; @@ -107,7 +110,7 @@ // handshakeLabel // this.handshakeLabel.AutoSize = true; - this.handshakeLabel.Location = new System.Drawing.Point(25, 176); + this.handshakeLabel.Location = new System.Drawing.Point(25, 162); this.handshakeLabel.Name = "handshakeLabel"; this.handshakeLabel.Size = new System.Drawing.Size(62, 13); this.handshakeLabel.TabIndex = 13; @@ -116,7 +119,7 @@ // stopBitsLabel // this.stopBitsLabel.AutoSize = true; - this.stopBitsLabel.Location = new System.Drawing.Point(25, 152); + this.stopBitsLabel.Location = new System.Drawing.Point(25, 140); this.stopBitsLabel.Name = "stopBitsLabel"; this.stopBitsLabel.Size = new System.Drawing.Size(49, 13); this.stopBitsLabel.TabIndex = 11; @@ -125,7 +128,7 @@ // dataBitsTextBox // this.dataBitsTextBox.Enabled = false; - this.dataBitsTextBox.Location = new System.Drawing.Point(136, 125); + this.dataBitsTextBox.Location = new System.Drawing.Point(136, 115); this.dataBitsTextBox.Name = "dataBitsTextBox"; this.dataBitsTextBox.Size = new System.Drawing.Size(43, 20); this.dataBitsTextBox.TabIndex = 10; @@ -133,7 +136,7 @@ // dataBitsLabel // this.dataBitsLabel.AutoSize = true; - this.dataBitsLabel.Location = new System.Drawing.Point(25, 128); + this.dataBitsLabel.Location = new System.Drawing.Point(25, 118); this.dataBitsLabel.Name = "dataBitsLabel"; this.dataBitsLabel.Size = new System.Drawing.Size(50, 13); this.dataBitsLabel.TabIndex = 9; @@ -142,7 +145,7 @@ // partityLabel // this.partityLabel.AutoSize = true; - this.partityLabel.Location = new System.Drawing.Point(25, 104); + this.partityLabel.Location = new System.Drawing.Point(25, 98); this.partityLabel.Name = "partityLabel"; this.partityLabel.Size = new System.Drawing.Size(33, 13); this.partityLabel.TabIndex = 7; @@ -151,7 +154,7 @@ // baudRateTextBox // this.baudRateTextBox.Enabled = false; - this.baudRateTextBox.Location = new System.Drawing.Point(136, 77); + this.baudRateTextBox.Location = new System.Drawing.Point(136, 71); this.baudRateTextBox.Name = "baudRateTextBox"; this.baudRateTextBox.Size = new System.Drawing.Size(130, 20); this.baudRateTextBox.TabIndex = 6; @@ -159,7 +162,7 @@ // baudRateLabel // this.baudRateLabel.AutoSize = true; - this.baudRateLabel.Location = new System.Drawing.Point(25, 80); + this.baudRateLabel.Location = new System.Drawing.Point(25, 74); this.baudRateLabel.Name = "baudRateLabel"; this.baudRateLabel.Size = new System.Drawing.Size(58, 13); this.baudRateLabel.TabIndex = 5; @@ -168,7 +171,7 @@ // comPortNrTextBox // this.comPortNrTextBox.Enabled = false; - this.comPortNrTextBox.Location = new System.Drawing.Point(136, 53); + this.comPortNrTextBox.Location = new System.Drawing.Point(136, 49); this.comPortNrTextBox.Name = "comPortNrTextBox"; this.comPortNrTextBox.Size = new System.Drawing.Size(43, 20); this.comPortNrTextBox.TabIndex = 4; @@ -176,7 +179,7 @@ // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(25, 56); + this.label1.Location = new System.Drawing.Point(25, 52); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(98, 13); this.label1.TabIndex = 3; @@ -185,7 +188,7 @@ // capacityLabel // this.capacityLabel.AutoSize = true; - this.capacityLabel.Location = new System.Drawing.Point(25, 201); + this.capacityLabel.Location = new System.Drawing.Point(25, 185); this.capacityLabel.Name = "capacityLabel"; this.capacityLabel.Size = new System.Drawing.Size(76, 13); this.capacityLabel.TabIndex = 15; @@ -194,7 +197,7 @@ // capacityTextBox // this.capacityTextBox.Enabled = false; - this.capacityTextBox.Location = new System.Drawing.Point(136, 198); + this.capacityTextBox.Location = new System.Drawing.Point(136, 182); this.capacityTextBox.Name = "capacityTextBox"; this.capacityTextBox.Size = new System.Drawing.Size(43, 20); this.capacityTextBox.TabIndex = 16; @@ -202,7 +205,7 @@ // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(185, 201); + this.label2.Location = new System.Drawing.Point(185, 185); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(19, 13); this.label2.TabIndex = 17; @@ -211,7 +214,7 @@ // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(185, 225); + this.label3.Location = new System.Drawing.Point(185, 207); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(19, 13); this.label3.TabIndex = 20; @@ -220,7 +223,7 @@ // emptyTextBox // this.emptyTextBox.Enabled = false; - this.emptyTextBox.Location = new System.Drawing.Point(136, 222); + this.emptyTextBox.Location = new System.Drawing.Point(136, 204); this.emptyTextBox.Name = "emptyTextBox"; this.emptyTextBox.Size = new System.Drawing.Size(43, 20); this.emptyTextBox.TabIndex = 19; @@ -228,16 +231,45 @@ // emptyLabel // this.emptyLabel.AutoSize = true; - this.emptyLabel.Location = new System.Drawing.Point(25, 225); + this.emptyLabel.Location = new System.Drawing.Point(25, 207); this.emptyLabel.Name = "emptyLabel"; this.emptyLabel.Size = new System.Drawing.Size(64, 13); this.emptyLabel.TabIndex = 18; this.emptyLabel.Text = "Tank Empty"; // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(185, 229); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(24, 13); + this.label4.TabIndex = 23; + this.label4.Text = "sec"; + // + // emptyTimeTextBox + // + this.emptyTimeTextBox.Enabled = false; + this.emptyTimeTextBox.Location = new System.Drawing.Point(136, 226); + this.emptyTimeTextBox.Name = "emptyTimeTextBox"; + this.emptyTimeTextBox.Size = new System.Drawing.Size(43, 20); + this.emptyTimeTextBox.TabIndex = 22; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(25, 229); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(90, 13); + this.label5.TabIndex = 21; + this.label5.Text = "Tank Empty Time"; + // // BalanceCfgCtrl // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.label4); + this.Controls.Add(this.emptyTimeTextBox); + this.Controls.Add(this.label5); this.Controls.Add(this.label3); this.Controls.Add(this.emptyTextBox); this.Controls.Add(this.emptyLabel); @@ -290,5 +322,8 @@ private System.Windows.Forms.Label label3; private System.Windows.Forms.TextBox emptyTextBox; private System.Windows.Forms.Label emptyLabel; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.TextBox emptyTimeTextBox; + private System.Windows.Forms.Label label5; } } diff --git a/TestBenchFramework/BenchControl/MettlerToledo/BalanceCfgCtrl.cs b/TestBenchFramework/BenchControl/MettlerToledo/BalanceCfgCtrl.cs index b3817b00a..6269f2097 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/BalanceCfgCtrl.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/BalanceCfgCtrl.cs @@ -104,6 +104,7 @@ namespace TBF.BenchControl.MettlerToledo handshakeComboBox.Text = config.Handshake.ToString(); capacityTextBox.Text = config.Capacity.ToString(); emptyTextBox.Text = config.Empty.ToString(); + emptyTimeTextBox.Text = config.EmptyTimeSec.ToString(); } public void Unlock() @@ -117,6 +118,7 @@ namespace TBF.BenchControl.MettlerToledo handshakeComboBox.Enabled = true; capacityTextBox.Enabled = true; emptyTextBox.Enabled = true; + emptyTimeTextBox.Enabled = true; } public CfgVerifyFlags VerifyCfg(ref string message) @@ -150,6 +152,11 @@ namespace TBF.BenchControl.MettlerToledo flags |= CfgVerifyFlags.Error; message += Environment.NewLine + "'Tank Empty' is not valid"; } + if (!int.TryParse(emptyTimeTextBox.Text, out dummy) || dummy < 1 || dummy > 999) + { + flags |= CfgVerifyFlags.Error; + message += Environment.NewLine + "'Tank Empty Time' should be between 1 and 999 sec"; + } return flags; } @@ -167,6 +174,7 @@ namespace TBF.BenchControl.MettlerToledo config.Handshake = GetHandshake(handshakeComboBox.SelectedItem.ToString()); config.Capacity = Utils.ParseUFloat(capacityTextBox.Text); config.Empty = Utils.ParseUFloat(emptyTextBox.Text); + config.EmptyTimeSec = int.Parse(emptyTimeTextBox.Text); } } } diff --git a/TestBenchFramework/BenchControl/MettlerToledo/BalanceDev.cs b/TestBenchFramework/BenchControl/MettlerToledo/BalanceDev.cs index 6bb6abe8d..301fa5478 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/BalanceDev.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/BalanceDev.cs @@ -44,7 +44,8 @@ namespace TBF.BenchControl.MettlerToledo public string Name { get { return balanceCfg.Name; } } public int BalanceNr { get { return balanceNr; } } public float Capacity { get { return balanceCfg.Capacity; } } - public IList Corrections { get { return balanceCfg.Corrections; } } + public int EmptyTimeSec { get { return balanceCfg.EmptyTimeSec; } } + public IList Corrections { get { return balanceCfg.Corrections; } } /// The state of the mass measurement public MsrmntState MsrmntState diff --git a/TestBenchFramework/BenchControl/MettlerToledo/BalanceFactory.cs b/TestBenchFramework/BenchControl/MettlerToledo/BalanceFactory.cs index c14c6e8e1..195729593 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/BalanceFactory.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/BalanceFactory.cs @@ -18,7 +18,7 @@ namespace TBF.BenchControl.MettlerToledo { return new BalanceCfg(this, "Balance1", 3, 2400, System.IO.Ports.Parity.Even, 7, System.IO.Ports.StopBits.One, System.IO.Ports.Handshake.XOnXOff, - 200.0f, 20.0f); // kg + 200.0f, 20.0f, 180); // kg, kg, s } public IComponentCfgCtrl CreateCfgCtrl() diff --git a/TestBenchFramework/BenchControl/MettlerToledo/BalanceNewFactory.cs b/TestBenchFramework/BenchControl/MettlerToledo/BalanceNewFactory.cs index 98fb7cbbd..00ec093d0 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/BalanceNewFactory.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/BalanceNewFactory.cs @@ -18,7 +18,7 @@ namespace TBF.BenchControl.MettlerToledo { return new BalanceCfg(this, "Balance1", 3, 2400, System.IO.Ports.Parity.Even, 7, System.IO.Ports.StopBits.One, System.IO.Ports.Handshake.XOnXOff, - 200.0f, 20.0f); // kg + 200.0f, 20.0f, 180); // kg, kg, s } public IComponentCfgCtrl CreateCfgCtrl() diff --git a/TestBenchFramework/BenchControl/MettlerToledo/TaringOp.cs b/TestBenchFramework/BenchControl/MettlerToledo/TaringOp.cs index ce5117347..6b6b9547f 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/TaringOp.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/TaringOp.cs @@ -47,7 +47,7 @@ namespace TBF.BenchControl.MettlerToledo { if (done) return Event.BalanceDone; /// Taring has been done already - if (balanceDev.MsrmntState == MsrmntState.Busy) return Event.None; + if (balanceDev.MsrmntState == MsrmntState.Busy) return Event.Busy; if (balanceDev.MsrmntState == MsrmntState.Overload) { @@ -64,7 +64,7 @@ namespace TBF.BenchControl.MettlerToledo } balanceDev.Taring(); /// Failed -> repeat taring - return Event.None; + return Event.Busy; } /// Stop this operation diff --git a/TestBenchFramework/BenchControl/Operations/TimerOp.cs b/TestBenchFramework/BenchControl/Operations/TimerOp.cs index adadb5eef..b234bf3d9 100644 --- a/TestBenchFramework/BenchControl/Operations/TimerOp.cs +++ b/TestBenchFramework/BenchControl/Operations/TimerOp.cs @@ -59,7 +59,7 @@ namespace TBF.BenchControl.Operations } else { - return Event.None; + return Event.TimerBusy; } } diff --git a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs index af44bc5d6..0d9088d4c 100644 --- a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs +++ b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs @@ -42,26 +42,20 @@ namespace TBF.BenchControl.Sequences Bridge.Bench2UI(ButtonsEtc.StopBtnEn); - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Measuring_the_weight); - //------------------------------------------------ - State.Create("MainSeq : Setting valves to the default state") - .AddOperation(new MettlerToledo.ReadMassesOp()) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen, - StateMachine.DefaultValvesClose)) - .EnterState(); + //-------------------------------------------------------------------------------------------- + Bridge.OnActivity(this, Strings.Starting_system); + State.Create("MainSeq : Setting valves to default positions") + .AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose)) + .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.Error)) goto error; - if (e.Contains(Event.UiCmdStop)) goto stop; } - while (!(e.Contains(Event.ValvesSet) && e.Contains(Event.BalanceDone))); + while (e.Contains(Event.ValvesBusy)); - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Starting_the_cameras); - //------------------------------------------------ - State startNew = State.Create("MainSeq : Starting the cameras") + //-------------------------------------------------------------------------------------------- + Bridge.OnActivity(this, Strings.Emptying_tank); + State startNew = State.Create("MainSeq : Emptying tanks, Starting cameras") .AddOperation(checkUiOp); foreach (var cmpnt in StateMachine.Components) { @@ -71,18 +65,94 @@ namespace TBF.BenchControl.Sequences startNew.AddOperation(camera.StartNewOp()); } } - startNew.EnterState(); + + IList allEmptyingValves = new List(); + if (StateMachine.EmptyTankValve1 != null) allEmptyingValves.Add(StateMachine.EmptyTankValve1); + if (StateMachine.EmptyTankValve2 != null) allEmptyingValves.Add(StateMachine.EmptyTankValve2); + if (StateMachine.EmptyTankValve3 != null) allEmptyingValves.Add(StateMachine.EmptyTankValve3); + + // Determine the tank emptying time (the maximum for all balances) + int balanceEmptyTime = 0; + if (StateMachine.Balance1 != null && StateMachine.Balance1.EmptyTimeSec > balanceEmptyTime) + { + balanceEmptyTime = StateMachine.Balance1.EmptyTimeSec; + } + if (StateMachine.Balance2 != null && StateMachine.Balance2.EmptyTimeSec > balanceEmptyTime) + { + balanceEmptyTime = StateMachine.Balance2.EmptyTimeSec; + } + if (StateMachine.Balance3 != null && StateMachine.Balance3.EmptyTimeSec > balanceEmptyTime) + { + balanceEmptyTime = StateMachine.Balance3.EmptyTimeSec; + } + if (balanceEmptyTime > 0) + { + startNew.AddOperation(new TimerOp(balanceEmptyTime)) + .AddOperation(StateMachine.ControlBoard.SetValvesOp(allEmptyingValves, null)); + } + + startNew.EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); if (e.Contains(Event.Error)) goto error; - if (e.Contains(Event.UiCmdStop)) goto stop; + if (e.Contains(Event.UiCmdStop) && + !e.Contains(Event.ValvesBusy) && + !e.Contains(Event.CameraBusy)) + { + goto stop_emptying; + } } - while (e.Contains(Event.CameraBusy)); + while (e.Contains(Event.TimerBusy) || + e.Contains(Event.CameraBusy) || + e.Contains(Event.ValvesBusy)); if (e.Contains(Event.CameraOpFailed)) goto error; /// TODO: resolve in some other way - //-------------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------------------------- + stop_emptying: + State stopEmptying = State.Create("MainSeq : Stop emptying of water tanks") + .AddOperation(checkUiOp) + .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, allEmptyingValves)) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.Error)) goto error; + if (e.Contains(Event.UiCmdStop)) goto stop; + } + while (e.Contains(Event.ValvesBusy)); + + //-------------------------------------------------------------------------------------------- + State taraAll = State.Create("MainSeq : Reset all balances").AddOperation(checkUiOp); + FloatBox tara = new FloatBox(0); + if (StateMachine.Balance1 != null) taraAll.AddOperation(StateMachine.Balance1.TaringOp(ref tara)); + if (StateMachine.Balance2 != null) taraAll.AddOperation(StateMachine.Balance2.TaringOp(ref tara)); + if (StateMachine.Balance3 != null) taraAll.AddOperation(StateMachine.Balance3.TaringOp(ref tara)); + taraAll.EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.Error)) goto error; + if (e.Contains(Event.UiCmdStop)) goto stop; + } + while (e.Contains(Event.Busy)); + + //-------------------------------------------------------------------------------------------- + Bridge.OnActivity(this, Strings.Measuring_the_weight); + State.Create("MainSeq : Mesuring the weight for the 1st time") + .AddOperation(checkUiOp) + .AddOperation(new MettlerToledo.ReadMassesOp()) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.Error)) goto error; + if (e.Contains(Event.UiCmdStop)) goto stop; + } + while (!e.Contains(Event.BalanceDone)); + + //-------------------------------------------------------------------------------------------- select_procedure: selection = MakeSelection(MKSelContext.ProcedureNotSelected); diff --git a/TestBenchFramework/Resources/Strings.Designer.cs b/TestBenchFramework/Resources/Strings.Designer.cs index 936654334..e1b9d0331 100644 --- a/TestBenchFramework/Resources/Strings.Designer.cs +++ b/TestBenchFramework/Resources/Strings.Designer.cs @@ -1635,6 +1635,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Starting the system. + /// + internal static string Starting_system { + get { + return ResourceManager.GetString("Starting_system", resourceCulture); + } + } + /// /// Looks up a localized string similar to Starting the cameras. /// diff --git a/TestBenchFramework/Resources/Strings.de.resx b/TestBenchFramework/Resources/Strings.de.resx index 0fd7e47ab..3d8c7c091 100644 --- a/TestBenchFramework/Resources/Strings.de.resx +++ b/TestBenchFramework/Resources/Strings.de.resx @@ -762,4 +762,7 @@ Startventil + + Prüfstand starten + \ No newline at end of file diff --git a/TestBenchFramework/Resources/Strings.resx b/TestBenchFramework/Resources/Strings.resx index 433c6db49..642b93aee 100644 --- a/TestBenchFramework/Resources/Strings.resx +++ b/TestBenchFramework/Resources/Strings.resx @@ -850,4 +850,7 @@ Camera error + + Starting the system + \ No newline at end of file diff --git a/TestBenchFramework/Screens/ProcessTabPageCtrl.Designer.cs b/TestBenchFramework/Screens/ProcessTabPageCtrl.Designer.cs index ce20099c9..d6bbf1bd6 100644 --- a/TestBenchFramework/Screens/ProcessTabPageCtrl.Designer.cs +++ b/TestBenchFramework/Screens/ProcessTabPageCtrl.Designer.cs @@ -1506,6 +1506,7 @@ this.Name = "ProcessTabPageCtrl"; this.Size = new System.Drawing.Size(1097, 498); this.Load += new System.EventHandler(this.ProcessTabPageCtrl_Load); + this.Paint += new System.Windows.Forms.PaintEventHandler(this.ProcessTabPageCtrl_Paint); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); this.groupBox2.ResumeLayout(false); diff --git a/TestBenchFramework/Screens/ProcessTabPageCtrl.cs b/TestBenchFramework/Screens/ProcessTabPageCtrl.cs index 629e2aa7a..8c6124922 100644 --- a/TestBenchFramework/Screens/ProcessTabPageCtrl.cs +++ b/TestBenchFramework/Screens/ProcessTabPageCtrl.cs @@ -1,4 +1,5 @@ using System; +using System.Drawing; using System.Windows.Forms; using log4net; using TBF.UiBridge; @@ -425,5 +426,26 @@ namespace TBF.Screens void OnProcedureCompleted(object sender, ProcedureCompletedEventArgs args) { } + + private void ProcessTabPageCtrl_Paint(object sender, PaintEventArgs e) + { + System.Drawing.SolidBrush filledBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Blue); + System.Drawing.SolidBrush benchBrush = new System.Drawing.SolidBrush(System.Drawing.Color.LightBlue); + + System.Drawing.Graphics formGraphics = this.CreateGraphics(); + + formGraphics.FillRectangle(filledBrush, new Rectangle(861, 470, 63, 14)); // tank -> pump + formGraphics.FillRectangle(benchBrush, new Rectangle(34, 470, 789, 14)); // pump ->bench horizontal + formGraphics.FillRectangle(benchBrush, new Rectangle(20, 378, 14, 106)); // pump ->bench vertical + formGraphics.FillRectangle(benchBrush, new Rectangle(34, 378, 825, 14)); // pump ->bench horizontal + //formGraphics.FillRectangle(myBrush, new Rectangle(104, 378, 106, 14)); // WM1-WM2 + //formGraphics.FillRectangle(myBrush, new Rectangle(174, 378, 106, 14)); // WM2-WM3 + //formGraphics.FillRectangle(myBrush, new Rectangle(244, 378, 106, 14)); // WM3-WM4 + //formGraphics.FillRectangle(myBrush, new Rectangle(314, 378, 106, 14)); // WM4-WM5 + //formGraphics.FillRectangle(myBrush, new Rectangle(384, 378, 106, 14)); // WM5-WM6 + + filledBrush.Dispose(); + formGraphics.Dispose(); + } } }