- Tank emptying remaining time indication

- Bug fixed: When copying a procwdure ItemId was not correctly set, remained 0
- Always create a message log when device initialization is completed successfully
This commit is contained in:
Milan Hanajik
2014-12-10 22:39:53 +01:00
parent 42c255e40e
commit ea6c9818cf
11 changed files with 86 additions and 22 deletions
@@ -96,7 +96,7 @@ namespace TBF.BenchControl.Cameras.IdcCamera
if (idcCameraCfg.DebugLevel != Entities.DebugMode.DetectedOff)
{
log.WarnFormat("Detected: {0} on COM{1} ver. {2}", Name, idcCameraCfg.ComPortNr, Idc100.Version);
log.FatalFormat("Successfully initialized device {0}", ToString());
}
}
@@ -212,6 +212,8 @@ namespace TBF.BenchControl.Elde
EtCalib,
DiverterEdge,
BalanceRange);
log.FatalFormat("Successfully initialized device {0}", ToString());
}
/// <summary>Run this device</summary>
@@ -75,6 +75,8 @@ namespace TBF.BenchControl.Greco
serialPort.Open();
measurementBuilder = new StringBuilder(40);
msrmntState = MsrmntState.Busy;
log.FatalFormat("Successfully initialized device {0}", ToString());
}
/// <summary>Run this device</summary>
@@ -22,7 +22,7 @@ namespace TBF.BenchControl.MettlerToledo
/// Warn: Start measurement when busy is true
/// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(BalanceDev));
public override string ToString() { return string.Format("{0}, Mettler-Toledo Balance", balanceCfg.Name); }
public override string ToString() { return string.Format("{0} - Mettler-Toledo Balance", balanceCfg.Name); }
/// <summary>
/// Enumeration of balances via static fields and methods
@@ -100,6 +100,8 @@ namespace TBF.BenchControl.MettlerToledo
serialPort = new SerialPort(comPortName, balanceCfg.BaudRate, balanceCfg.Parity, balanceCfg.DataBits, balanceCfg.StopBits);
serialPort.Handshake = balanceCfg.Handshake;
serialPort.Open();
log.FatalFormat("Successfully initialized device {0}", ToString());
}
public bool IsEmpty(float mass)
@@ -21,7 +21,7 @@ namespace TBF.BenchControl.MettlerToledo
/// Warn: Start measurement when busy is true
/// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(BalanceNewDev));
public override string ToString() { return string.Format("Mettler-Toledo Balance with SN"); }
public override string ToString() { return string.Format("{0} - Mettler-Toledo Balance with SN", balanceCfg.Name); }
public static void ResetStaticProperties() { }
@@ -28,30 +28,52 @@ namespace TBF.BenchControl.Operations
/// Set by constructors
int timerTime;
Event eventExpired;
TBF.Boxes.IntBox remainingTimeSec;
/// <summary>
/// Constructors, optional argument is a timer name (you can create more then one timer)
/// </summary>
public TimerOp(int timerTime, Event eventExpired)
public TimerOp(int timerTimeSec, Event eventExpired, TBF.Boxes.IntBox remainingTimeSec)
{
this.timerTime = timerTime;
this.timerTime = timerTimeSec;
this.eventExpired = eventExpired;
this.remainingTimeSec = remainingTimeSec;
}
public TimerOp(int timerTimeSec, Event eventExpired)
: this(timerTimeSec, eventExpired, null)
{
}
public TimerOp(int timerTime, TBF.Boxes.IntBox remainingTimeSec)
: this(timerTime, Event.TimerExpired, remainingTimeSec)
{
}
public TimerOp(int timerTime)
: this(timerTime, Event.TimerExpired)
: this(timerTime, Event.TimerExpired, null)
{
}
void UpdateRemainingTime()
{
if (remainingTimeSec != null)
{
remainingTimeSec.Val = System.Math.Max(expireTime - StateMachine.Time, 0);
}
}
/// <param name="obj">Time period (TimeSpan)</param>
public void Start()
{
timeExpired = false;
timerStarted = true;
expireTime = StateMachine.Time + timerTime;
UpdateRemainingTime();
}
public Event Run()
{
UpdateRemainingTime();
if (timerStarted && !timeExpired && StateMachine.Time >= expireTime)
{
timeExpired = true;
@@ -54,7 +54,7 @@ namespace TBF.BenchControl.Sequences
while (e.Contains(Event.ValvesBusy));
//--------------------------------------------------------------------------------------------
Bridge.OnActivity(this, Strings.Emptying_tank);
IntBox remainingTime = new IntBox();
State startNew = State.Create("MainSeq : Emptying tanks, Starting cameras")
.AddOperation(checkUiOp);
foreach (var cmpnt in StateMachine.Components)
@@ -87,13 +87,16 @@ namespace TBF.BenchControl.Sequences
}
if (balanceEmptyTime > 0)
{
startNew.AddOperation(new TimerOp(balanceEmptyTime))
startNew.AddOperation(new TimerOp(balanceEmptyTime, remainingTime))
.AddOperation(StateMachine.ControlBoard.SetValvesOp(allEmptyingValves, null));
}
startNew.EnterState();
do
{
Bridge.OnActivity(this, string.Format("{0}, {1} {2} {3}", Strings.Emptying_tank,
Strings.remaining_time, remainingTime.Val.ToString(), Strings.sec));
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) goto error;
if (e.Contains(Event.UiCmdStop) &&
@@ -109,6 +112,8 @@ namespace TBF.BenchControl.Sequences
if (e.Contains(Event.CameraOpFailed)) goto error; /// TODO: resolve in some other way
Bridge.OnActivity(this, Strings.Emptying_tank);
stop_emptying:
//--------------------------------------------------------------------------------------------
State stopEmptying = State.Create("MainSeq : Stop emptying of water tanks")
+18
View File
@@ -1473,6 +1473,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to remaining time.
/// </summary>
internal static string remaining_time {
get {
return ResourceManager.GetString("remaining_time", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt; &amp;Remove.
/// </summary>
@@ -1554,6 +1563,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to s.
/// </summary>
internal static string sec {
get {
return ResourceManager.GetString("sec", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Selected results:.
/// </summary>
@@ -765,4 +765,10 @@
<data name="Starting_system" xml:space="preserve">
<value>Prüfstand starten</value>
</data>
<data name="remaining_time" xml:space="preserve">
<value>remaining time</value>
</data>
<data name="sec" xml:space="preserve">
<value>s</value>
</data>
</root>
@@ -853,4 +853,10 @@
<data name="Starting_system" xml:space="preserve">
<value>Starting the system</value>
</data>
<data name="remaining_time" xml:space="preserve">
<value>remaining time</value>
</data>
<data name="sec" xml:space="preserve">
<value>s</value>
</data>
</root>
@@ -116,7 +116,7 @@ namespace TBF.UiControls
public void AddOne()
{
/// Find an unused test name
/// Find an unused procedure name
string newName;
for (int nameId = 1; true; nameId++)
{
@@ -126,7 +126,7 @@ namespace TBF.UiControls
if (notUsed) break;
}
base.AddOne(new Entities.Procedure(newName, MyItems.Count));
base.AddOne(new Entities.Procedure(newName, MyItems.Count + 1));
}
public new void RemoveSelected()
@@ -187,6 +187,7 @@ namespace TBF.UiControls
/// Make a copy of the selected procedure
Entities.Procedure newProcedure = selectedProcedure.Clone();
newProcedure.Name = selectedProcedure.Name + Strings.New_name_copy;
newProcedure.ItemNr = MyItems.Count;
newProcedure.CreationUser = Entities.User.CurrentUser.Name;
newProcedure.CreationTime = DateTime.Now;