MettlerToledo.Standard always reads immediate mass when idle.
This commit is contained in:
@@ -1,61 +0,0 @@
|
|||||||
///
|
|
||||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
|
||||||
///
|
|
||||||
using System;
|
|
||||||
using log4net;
|
|
||||||
|
|
||||||
namespace TBF.BenchControl.MettlerToledo
|
|
||||||
{
|
|
||||||
public class KeepReadingMassesOp : IOperation
|
|
||||||
{
|
|
||||||
private static readonly ILog log = LogManager.GetLogger(typeof(KeepReadingMassesOp));
|
|
||||||
public override string ToString() { return string.Format("KeepReadingMassesOp()"); }
|
|
||||||
|
|
||||||
bool done;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Events: BalanceDone, Error
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="balanceDev">Balance device instance</param>
|
|
||||||
/// <param name="requiredReadingsCount">Required mass readings count (>= 3)</param>
|
|
||||||
/// <param name="result">Reference to the measured mass in kg</param>
|
|
||||||
public KeepReadingMassesOp()
|
|
||||||
{
|
|
||||||
log.Debug(this.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Start this operation</summary>
|
|
||||||
public void Start()
|
|
||||||
{
|
|
||||||
done = false;
|
|
||||||
|
|
||||||
for (int i = 0; i < Standard.BalanceDev.BalancesCount; i++)
|
|
||||||
{
|
|
||||||
Standard.BalanceDev.Balances[i].GetImmediateMassMeasurement();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Run this operation</summary>
|
|
||||||
/// <returns>
|
|
||||||
/// Event.None
|
|
||||||
/// </returns>
|
|
||||||
public Event Run()
|
|
||||||
{
|
|
||||||
if (done) return Event.BalanceDone; /// Mass has already been read
|
|
||||||
|
|
||||||
for (int i = 0; i < Standard.BalanceDev.BalancesCount; i++)
|
|
||||||
{
|
|
||||||
if (Standard.BalanceDev.Balances[i].MsrmntState != MsrmntState.Busy)
|
|
||||||
{
|
|
||||||
Standard.BalanceDev.Balances[i].GetImmediateMassMeasurement();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Event.None;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Stop this operation</summary>
|
|
||||||
public void Stop()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
///
|
///
|
||||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
|
||||||
///
|
///
|
||||||
using System;
|
using System;
|
||||||
using log4net;
|
using log4net;
|
||||||
@@ -31,7 +31,7 @@ namespace TBF.BenchControl.MettlerToledo
|
|||||||
|
|
||||||
for (int i = 0; i < Standard.BalanceDev.BalancesCount; i++)
|
for (int i = 0; i < Standard.BalanceDev.BalancesCount; i++)
|
||||||
{
|
{
|
||||||
Standard.BalanceDev.Balances[i].GetImmediateMassMeasurement();
|
Standard.BalanceDev.Balances[i].SendImmediateMeasurementCmd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,13 @@ using TBF.Resources;
|
|||||||
|
|
||||||
namespace TBF.BenchControl.MettlerToledo.Standard
|
namespace TBF.BenchControl.MettlerToledo.Standard
|
||||||
{
|
{
|
||||||
|
public enum Activity
|
||||||
|
{
|
||||||
|
Idle,
|
||||||
|
ImmediateMeasurement,
|
||||||
|
RunningOperation,
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Mettler Toledo ICS4_5 Weighting terminal connected via serial interface (RS232)
|
/// Mettler Toledo ICS4_5 Weighting terminal connected via serial interface (RS232)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -64,7 +71,8 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>The state of the mass measurement</summary>
|
/// <summary>The state of the mass measurement</summary>
|
||||||
public MsrmntState MsrmntState { get { return msrmntState; } }
|
public Activity Activity;
|
||||||
|
public MsrmntState MsrmntState { get { return msrmntState; } set { msrmntState = value; } }
|
||||||
protected MsrmntState msrmntState;
|
protected MsrmntState msrmntState;
|
||||||
|
|
||||||
/// <summary>Time since the last serial command in seconds</summary>
|
/// <summary>Time since the last serial command in seconds</summary>
|
||||||
@@ -121,6 +129,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
throw new Exception(string.Format("{0}: {1}", Name, Strings.Calibration_certificate_validity_expired));
|
throw new Exception(string.Format("{0}: {1}", Name, Strings.Calibration_certificate_validity_expired));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Activity = Activity.Idle;
|
||||||
msrmntState = MsrmntState.Failed; /// Data not valid yet
|
msrmntState = MsrmntState.Failed; /// Data not valid yet
|
||||||
MsrmntTime = 0;
|
MsrmntTime = 0;
|
||||||
|
|
||||||
@@ -178,7 +187,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
return (mass >= thld);
|
return (mass >= thld);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ZeroWhenStable()
|
public virtual void SendZeroWhenStableCmd()
|
||||||
{
|
{
|
||||||
if (balanceCfg.DebugLevel == DebugMode.Simulate) return;
|
if (balanceCfg.DebugLevel == DebugMode.Simulate) return;
|
||||||
|
|
||||||
@@ -188,7 +197,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.InfoFormat("{0} - ZeroWhenStable()", Name);
|
log.InfoFormat("{0} - SendZeroWhenStableCmd() - \"Z\\r\\n\"", Name);
|
||||||
|
|
||||||
msrmntState = MsrmntState.Busy;
|
msrmntState = MsrmntState.Busy;
|
||||||
MsrmntTime = 0;
|
MsrmntTime = 0;
|
||||||
@@ -196,7 +205,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
serialPort.Write("Z\r\n");
|
serialPort.Write("Z\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Taring()
|
public virtual void SendTaraCmd()
|
||||||
{
|
{
|
||||||
if (balanceCfg.DebugLevel == DebugMode.Simulate) return;
|
if (balanceCfg.DebugLevel == DebugMode.Simulate) return;
|
||||||
|
|
||||||
@@ -206,7 +215,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.InfoFormat("{0} - Taring()", Name);
|
log.InfoFormat("{0} - SendTaraCmd() - - \"T\\r\\n\"", Name);
|
||||||
|
|
||||||
msrmntState = MsrmntState.Busy;
|
msrmntState = MsrmntState.Busy;
|
||||||
MsrmntTime = 0;
|
MsrmntTime = 0;
|
||||||
@@ -217,7 +226,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get a stable mass measurement
|
/// Get a stable mass measurement
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void GetStableMassMeasurement()
|
public void SendStableMeasurementCmd()
|
||||||
{
|
{
|
||||||
if (balanceCfg.DebugLevel == DebugMode.Simulate) return;
|
if (balanceCfg.DebugLevel == DebugMode.Simulate) return;
|
||||||
|
|
||||||
@@ -227,7 +236,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.InfoFormat("{0} - GetStableMassMeasurement()", Name);
|
log.InfoFormat("{0} - SendStableMeasurementCmd() - \"S\\r\\n\"", Name);
|
||||||
|
|
||||||
msrmntState = MsrmntState.Busy;
|
msrmntState = MsrmntState.Busy;
|
||||||
MsrmntTime = 0;
|
MsrmntTime = 0;
|
||||||
@@ -238,7 +247,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get an immediate mass measurement
|
/// Get an immediate mass measurement
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void GetImmediateMassMeasurement()
|
public void SendImmediateMeasurementCmd()
|
||||||
{
|
{
|
||||||
if (balanceCfg.DebugLevel == DebugMode.Simulate || serialPort == null) return;
|
if (balanceCfg.DebugLevel == DebugMode.Simulate || serialPort == null) return;
|
||||||
|
|
||||||
@@ -248,7 +257,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.InfoFormat("{0} - GetImmediateMassMeasurement()", Name);
|
log.InfoFormat("{0} - SendImmediateMeasurementCmd() - \"SI\\r\\n\"", Name);
|
||||||
|
|
||||||
msrmntState = MsrmntState.Busy;
|
msrmntState = MsrmntState.Busy;
|
||||||
MsrmntTime = 0;
|
MsrmntTime = 0;
|
||||||
@@ -270,7 +279,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
/// Get the serial number
|
/// Get the serial number
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>After a successful SetUnits(kg) mass is still sent in g. MH 15.10.2013</remarks>
|
/// <remarks>After a successful SetUnits(kg) mass is still sent in g. MH 15.10.2013</remarks>
|
||||||
public void SetUnits(Units unit)
|
public void SendSetUnitsCmd(Units unit)
|
||||||
{
|
{
|
||||||
if (balanceCfg.DebugLevel == DebugMode.Simulate) return;
|
if (balanceCfg.DebugLevel == DebugMode.Simulate) return;
|
||||||
|
|
||||||
@@ -280,17 +289,30 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.InfoFormat("{0} - SetUnits({1})", Name, unit);
|
|
||||||
|
|
||||||
msrmntState = MsrmntState.Busy;
|
msrmntState = MsrmntState.Busy;
|
||||||
stringBuilder.Clear();
|
stringBuilder.Clear();
|
||||||
switch (unit)
|
switch (unit)
|
||||||
{
|
{
|
||||||
case Units.g: serialPort.Write("U g\r\n"); break;
|
case Units.g:
|
||||||
case Units.kg: serialPort.Write("U kg\r\n"); break;
|
log.InfoFormat("{0} - SetUnits({1}) - \"U g\\r\\n\"", Name, unit);
|
||||||
case Units.t: serialPort.Write("U t\r\n"); break;
|
serialPort.Write("U g\r\n");
|
||||||
case Units.lb: serialPort.Write("U lb\r\n"); break;
|
break;
|
||||||
case Units.oz: serialPort.Write("U oz\r\n"); break;
|
case Units.kg:
|
||||||
|
log.InfoFormat("{0} - SetUnits({1}) - \"U kg\\r\\n\"", Name, unit);
|
||||||
|
serialPort.Write("U kg\r\n");
|
||||||
|
break;
|
||||||
|
case Units.t:
|
||||||
|
log.InfoFormat("{0} - SetUnits({1}) - \"U t\\r\\n\"", Name, unit);
|
||||||
|
serialPort.Write("U t\r\n");
|
||||||
|
break;
|
||||||
|
case Units.lb:
|
||||||
|
log.InfoFormat("{0} - SetUnits({1}) - \"U lb\\r\\n\"", Name, unit);
|
||||||
|
serialPort.Write("U lb\r\n");
|
||||||
|
break;
|
||||||
|
case Units.oz:
|
||||||
|
log.InfoFormat("{0} - SetUnits({1}) - \"U oz\\r\\n\"", Name, unit);
|
||||||
|
serialPort.Write("U oz\r\n");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,6 +340,11 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
log.DebugFormat("{0} - RunDeviceBefore()", Name);
|
log.DebugFormat("{0} - RunDeviceBefore()", Name);
|
||||||
|
|
||||||
if (msrmntState != MsrmntState.Busy) return; /// No measurement in progress
|
if (msrmntState != MsrmntState.Busy) return; /// No measurement in progress
|
||||||
|
///
|
||||||
|
if (Activity == Activity.ImmediateMeasurement)
|
||||||
|
{
|
||||||
|
Activity = Activity.Idle;
|
||||||
|
}
|
||||||
|
|
||||||
string justReceived = serialPort.ReadExisting();
|
string justReceived = serialPort.ReadExisting();
|
||||||
if (justReceived != null && justReceived.Length > 0)
|
if (justReceived != null && justReceived.Length > 0)
|
||||||
@@ -501,6 +528,11 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
/// <summary>Run this device</summary>
|
/// <summary>Run this device</summary>
|
||||||
public void RunDeviceAfter()
|
public void RunDeviceAfter()
|
||||||
{
|
{
|
||||||
|
if (Activity == Activity.Idle)
|
||||||
|
{
|
||||||
|
SendImmediateMeasurementCmd();
|
||||||
|
Activity = Activity.ImmediateMeasurement;
|
||||||
|
}
|
||||||
base.RunAfter();
|
base.RunAfter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
///
|
///
|
||||||
/// Copyright (c) 2013-2017 Sensus Metering Systems
|
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
|
||||||
///
|
///
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
@@ -41,21 +41,21 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the serial number
|
/// Get the serial number
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void GetSerialNumber()
|
public void SendGetSerialNumberCmd()
|
||||||
{
|
{
|
||||||
if (balanceCfg.DebugLevel == DebugMode.Simulate) return;
|
if (balanceCfg.DebugLevel == DebugMode.Simulate) return;
|
||||||
|
|
||||||
if (msrmntState == MsrmntState.Busy)
|
if (msrmntState == MsrmntState.Busy)
|
||||||
{
|
{
|
||||||
log.WarnFormat("{0} - GetSerialNumber() returns without getting the s/n because measurementState == MeasurementState.Busy", Name);
|
log.WarnFormat("{0} - SendGetSerialNumberCmd() returns without getting the s/n because measurementState == MeasurementState.Busy", Name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.WarnFormat("{0} - GetSerialNumber()", Name);
|
log.WarnFormat("{0} - SendGetSerialNumberCmd() - \"I4\\r\\n\"", Name);
|
||||||
|
|
||||||
msrmntState = MsrmntState.Busy;
|
msrmntState = MsrmntState.Busy;
|
||||||
stringBuilder.Clear();
|
stringBuilder.Clear();
|
||||||
serialPort.Write(new byte[] { (byte)'I', (byte)'4', (byte)0x0D, (byte)0x0A }, 0, 4);
|
serialPort.Write("I4\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -84,6 +84,11 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
log.DebugFormat("{0} - RunDevice()", Name);
|
log.DebugFormat("{0} - RunDevice()", Name);
|
||||||
|
|
||||||
if (base.msrmntState != MsrmntState.Busy) return; /// No measurement in progress
|
if (base.msrmntState != MsrmntState.Busy) return; /// No measurement in progress
|
||||||
|
///
|
||||||
|
if (Activity == Activity.ImmediateMeasurement)
|
||||||
|
{
|
||||||
|
Activity = Activity.Idle;
|
||||||
|
}
|
||||||
|
|
||||||
string justReceived = serialPort.ReadExisting();
|
string justReceived = serialPort.ReadExisting();
|
||||||
if (justReceived != null && justReceived.Length > 0)
|
if (justReceived != null && justReceived.Length > 0)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
///
|
///
|
||||||
/// Copyright (c) 2016-2017 Sensus Metering Systems
|
/// Copyright (c) 2016-2020 Sensus Slovensko a.s.
|
||||||
///
|
///
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -27,9 +27,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
private static readonly ILog log = LogManager.GetLogger(typeof(BalanceOld));
|
private static readonly ILog log = LogManager.GetLogger(typeof(BalanceOld));
|
||||||
public override string ToString() { return string.Format("MettlerToledo.Standard.BalanceOld({0})", Cfg.ToString(1)); }
|
public override string ToString() { return string.Format("MettlerToledo.Standard.BalanceOld({0})", Cfg.ToString(1)); }
|
||||||
|
|
||||||
public BalanceOld()
|
public BalanceOld() { }
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public BalanceOld(Generic.IComponentCfg cfg)
|
public BalanceOld(Generic.IComponentCfg cfg)
|
||||||
: base(cfg)
|
: base(cfg)
|
||||||
@@ -37,25 +35,13 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
log.Debug(this.ToString());
|
log.Debug(this.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Taring()
|
|
||||||
|
public override void SendZeroWhenStableCmd()
|
||||||
{
|
{
|
||||||
if (balanceCfg.DebugLevel == DebugMode.Simulate) return;
|
base.SendTaraCmd();
|
||||||
|
|
||||||
if (msrmntState == MsrmntState.Busy)
|
|
||||||
{
|
|
||||||
log.WarnFormat("{0} - Taring() returns without starting taring the scale because measurementState == MeasurementState.Busy", Name);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
log.InfoFormat("{0} - Taring()", Name);
|
|
||||||
|
|
||||||
stringBuilder.Clear();
|
|
||||||
serialPort.Write("T\r\n");
|
|
||||||
|
|
||||||
mass = 0;
|
|
||||||
msrmntState = MsrmntState.Valid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parse characters received from the serial port
|
/// Parse characters received from the serial port
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -78,9 +64,14 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.DebugFormat("{0} - RunDevice()", Name);
|
log.DebugFormat("{0} - RunDeviceBefore()", Name);
|
||||||
|
|
||||||
if (base.msrmntState != MsrmntState.Busy) return; /// No measurement in progress
|
if (base.msrmntState != MsrmntState.Busy) return; /// No measurement in progress
|
||||||
|
///
|
||||||
|
if (Activity == Activity.ImmediateMeasurement)
|
||||||
|
{
|
||||||
|
Activity = Activity.Idle;
|
||||||
|
}
|
||||||
|
|
||||||
string justReceived = serialPort.ReadExisting();
|
string justReceived = serialPort.ReadExisting();
|
||||||
if (justReceived != null && justReceived.Length > 0)
|
if (justReceived != null && justReceived.Length > 0)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
/// Set by the constructor
|
/// Set by the constructor
|
||||||
BalanceNewDev scale;
|
BalanceNewDev scale;
|
||||||
string serialNumber;
|
string serialNumber;
|
||||||
|
bool activityStarted;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Events: BalanceDone, Error
|
/// Events: BalanceDone, Error
|
||||||
@@ -24,7 +25,6 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
{
|
{
|
||||||
if (scale == null) throw new ArgumentNullException("balanceDev");
|
if (scale == null) throw new ArgumentNullException("balanceDev");
|
||||||
this.scale = scale;
|
this.scale = scale;
|
||||||
|
|
||||||
this.serialNumber = serialNumber;
|
this.serialNumber = serialNumber;
|
||||||
|
|
||||||
log.Debug(this.ToString());
|
log.Debug(this.ToString());
|
||||||
@@ -33,9 +33,17 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
/// <summary>Start this operation</summary>
|
/// <summary>Start this operation</summary>
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
log.DebugFormat("{0} - Start()", scale.Name);
|
if (scale.Activity == Activity.Idle)
|
||||||
scale.GetSerialNumber();
|
{
|
||||||
}
|
scale.SendGetSerialNumberCmd();
|
||||||
|
activityStarted = true;
|
||||||
|
scale.Activity = Activity.RunningOperation;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
activityStarted = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Run this operation</summary>
|
/// <summary>Run this operation</summary>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
@@ -44,27 +52,33 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public Event Run()
|
public Event Run()
|
||||||
{
|
{
|
||||||
log.DebugFormat("{0} - GetSerNumOp.Run() ... MsrmntState = {1}", scale.Name, scale.MsrmntState);
|
if (!activityStarted && scale.Activity == Activity.Idle)
|
||||||
|
{
|
||||||
|
scale.SendGetSerialNumberCmd();
|
||||||
|
activityStarted = true;
|
||||||
|
scale.Activity = Activity.RunningOperation;
|
||||||
|
return Event.Busy;
|
||||||
|
}
|
||||||
|
|
||||||
if (scale.MsrmntState == MsrmntState.Valid)
|
if (scale.MsrmntState == MsrmntState.Valid)
|
||||||
{
|
{
|
||||||
serialNumber = scale.SerialNumber;
|
serialNumber = scale.SerialNumber;
|
||||||
return Event.BalanceDone; /// S/N read successful
|
return Event.BalanceDone; /// S/N read successful
|
||||||
}
|
}
|
||||||
else if (scale.MsrmntState == MsrmntState.Failed)
|
|
||||||
|
if (scale.MsrmntState == MsrmntState.Failed)
|
||||||
{
|
{
|
||||||
return Event.Error; /// S/N read failed
|
return Event.Error; /// S/N read failed
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
return Event.Busy; /// No result yet
|
||||||
return Event.Busy; /// No result yet
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Stop this operation</summary>
|
/// <summary>Stop this operation</summary>
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
log.DebugFormat("{0} - Stop()", scale.Name);
|
if (scale.MsrmntState == MsrmntState.Busy) scale.MsrmntState = MsrmntState.Failed;
|
||||||
|
scale.Activity = Activity.Idle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
///
|
///
|
||||||
/// Copyright (c) 2013-2017 Sensus Metering Systems
|
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
|
||||||
///
|
///
|
||||||
using System;
|
using System;
|
||||||
using log4net;
|
using log4net;
|
||||||
@@ -12,84 +12,42 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
private static readonly ILog log = LogManager.GetLogger(typeof(ReadMassOp));
|
private static readonly ILog log = LogManager.GetLogger(typeof(ReadMassOp));
|
||||||
public override string ToString() { return string.Format("ReadMassOp(.,.)"); }
|
public override string ToString() { return string.Format("ReadMassOp(.,.)"); }
|
||||||
|
|
||||||
bool started;
|
|
||||||
bool done;
|
|
||||||
|
|
||||||
/// Set by the constructor
|
/// Set by the constructor
|
||||||
BalanceDev scale;
|
BalanceDev scale;
|
||||||
DoubleBox result;
|
DoubleBox result;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Events: BalanceDone, Error
|
/// Events: BalanceDone (always)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="scale">Balance device instance</param>
|
/// <param name="scale">Balance device instance</param>
|
||||||
/// <param name="requiredReadingsCount">Required mass readings count (>= 3)</param>
|
|
||||||
/// <param name="result">Reference to the measured mass in kg</param>
|
/// <param name="result">Reference to the measured mass in kg</param>
|
||||||
public ReadMassOp(BalanceDev scale, ref DoubleBox result)
|
public ReadMassOp(BalanceDev scale, ref DoubleBox result)
|
||||||
{
|
{
|
||||||
if (scale == null) throw new ArgumentNullException("balanceDev");
|
if (scale == null) throw new ArgumentNullException("balanceDev");
|
||||||
this.scale = scale;
|
this.scale = scale;
|
||||||
|
|
||||||
this.result = result;
|
this.result = result;
|
||||||
|
|
||||||
log.Debug(this.ToString());
|
log.Debug(this.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Start this operation</summary>
|
/// <summary>Start this operation</summary>
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
scale.GetImmediateMassMeasurement();
|
result.Val = scale.Mass;
|
||||||
started = true;
|
|
||||||
done = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Run this operation</summary>
|
/// <summary>Run this operation</summary>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// Event.None
|
|
||||||
/// Event.BalanceDone
|
/// Event.BalanceDone
|
||||||
/// Event.Error . . . . . Current.Tick == null
|
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public Event Run()
|
public Event Run()
|
||||||
{
|
{
|
||||||
scale.MsrmntTime++;
|
result.Val = scale.Mass;
|
||||||
|
return Event.BalanceDone;
|
||||||
if (!started)
|
|
||||||
{
|
|
||||||
scale.GetImmediateMassMeasurement();
|
|
||||||
started = true;
|
|
||||||
done = false;
|
|
||||||
return Event.Busy;
|
|
||||||
}
|
|
||||||
else if (started && scale.MsrmntState == MsrmntState.Busy)
|
|
||||||
{
|
|
||||||
/// Measurement is in progress
|
|
||||||
|
|
||||||
if (scale.MsrmntTime >= 2)
|
|
||||||
{
|
|
||||||
/// Timeout - no response from the scale within 2 seconds - send command again
|
|
||||||
scale.GetImmediateMassMeasurement();
|
|
||||||
started = true;
|
|
||||||
done = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Event.Busy;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/// Measurement completed or failed: (started == true) && (scale.MsrmntState != MsrmntState.Busy)
|
|
||||||
|
|
||||||
if (scale.MsrmntState == MsrmntState.Valid) result.Val = scale.Mass;
|
|
||||||
log.InfoFormat("ReadMassOp.Run() ... state={0}, mass={1} ... returning Event.BalanceDone",
|
|
||||||
scale.MsrmntState, scale.Mass);
|
|
||||||
done = true;
|
|
||||||
started = false;
|
|
||||||
return Event.BalanceDone; /// Mass read OK
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Stop this operation</summary>
|
/// <summary>Stop this operation</summary>
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,9 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
double[] sortedMassReadings;
|
double[] sortedMassReadings;
|
||||||
int currentReadingsCount;
|
int currentReadingsCount;
|
||||||
|
|
||||||
|
bool activityStarted;
|
||||||
bool measurementCompleted;
|
bool measurementCompleted;
|
||||||
|
int timeout;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Events: BalanceDone, Error
|
/// Events: BalanceDone, Error
|
||||||
@@ -45,28 +47,46 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
this.totalReadingsCount = (readingsCount < 4) ? 5 : readingsCount; /// readingsCount is at least 4
|
this.totalReadingsCount = (readingsCount < 4) ? 5 : readingsCount; /// readingsCount is at least 4
|
||||||
this.maxSpread = (maxSpread == 0) ? (scale.Capacity / 20000.0) : maxSpread;
|
this.maxSpread = (maxSpread == 0) ? (scale.Capacity / 20000.0) : maxSpread;
|
||||||
this.method = method;
|
this.method = method;
|
||||||
|
|
||||||
this.result = result;
|
this.result = result;
|
||||||
|
|
||||||
massReadings = new double[totalReadingsCount];
|
massReadings = new double[totalReadingsCount];
|
||||||
sortedMassReadings = new double[totalReadingsCount];
|
sortedMassReadings = new double[totalReadingsCount];
|
||||||
currentReadingsCount = 0;
|
currentReadingsCount = 0;
|
||||||
measurementCompleted = false;
|
activityStarted = false;
|
||||||
|
measurementCompleted = false;
|
||||||
|
timeout = (method == Config.Entities.MassMethod.Scale) ? 60 : 2;
|
||||||
|
|
||||||
log.Debug(this.ToString());
|
log.Debug(this.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Call scale.XYStartMeasurement() function and set measurementStarted flag.
|
||||||
|
/// </summary>
|
||||||
|
void StartMeasurement()
|
||||||
|
{
|
||||||
|
if (method == Config.Entities.MassMethod.Scale)
|
||||||
|
scale.SendStableMeasurementCmd();
|
||||||
|
else
|
||||||
|
scale.SendImmediateMeasurementCmd();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Start this operation</summary>
|
/// <summary>Start this operation</summary>
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
currentReadingsCount = 0;
|
currentReadingsCount = 0;
|
||||||
measurementCompleted = false;
|
measurementCompleted = false;
|
||||||
|
|
||||||
if (method == Config.Entities.MassMethod.Scale)
|
if (scale.Activity == Activity.Idle)
|
||||||
scale.GetStableMassMeasurement();
|
{
|
||||||
|
StartMeasurement();
|
||||||
|
activityStarted = true;
|
||||||
|
scale.Activity = Activity.RunningOperation;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
scale.GetImmediateMassMeasurement();
|
{
|
||||||
}
|
activityStarted = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Run this operation</summary>
|
/// <summary>Run this operation</summary>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
@@ -78,21 +98,23 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
{
|
{
|
||||||
scale.MsrmntTime++;
|
scale.MsrmntTime++;
|
||||||
|
|
||||||
if (measurementCompleted) return Event.BalanceDone;
|
if (!activityStarted && scale.Activity == Activity.Idle)
|
||||||
|
{
|
||||||
|
StartMeasurement();
|
||||||
|
activityStarted = true;
|
||||||
|
scale.Activity = Activity.RunningOperation;
|
||||||
|
return Event.None;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (measurementCompleted)
|
||||||
|
{
|
||||||
|
return Event.BalanceDone;
|
||||||
|
}
|
||||||
|
|
||||||
if (scale.MsrmntState == MsrmntState.Busy)
|
if (scale.MsrmntState == MsrmntState.Busy)
|
||||||
{
|
{
|
||||||
/// Measurement is in progress - resend command if timeout occurs
|
/// Measurement is in progress - resend command if timeout occurs
|
||||||
|
if (scale.MsrmntTime >= timeout) StartMeasurement();
|
||||||
if (method == Config.Entities.MassMethod.Scale)
|
|
||||||
{
|
|
||||||
if (scale.MsrmntTime >= 60) scale.GetStableMassMeasurement();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (scale.MsrmntTime >= 2) scale.GetImmediateMassMeasurement();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Event.None; /// Wait for a mass measurement
|
return Event.None; /// Wait for a mass measurement
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,14 +199,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
///
|
StartMeasurement(); /// Start a new measurement
|
||||||
/// Start a new measurement
|
|
||||||
///
|
|
||||||
if (method == Config.Entities.MassMethod.Scale)
|
|
||||||
scale.GetStableMassMeasurement();
|
|
||||||
else
|
|
||||||
scale.GetImmediateMassMeasurement();
|
|
||||||
|
|
||||||
return Event.None;
|
return Event.None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -192,6 +207,8 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
/// <summary>Stop this operation</summary>
|
/// <summary>Stop this operation</summary>
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
}
|
if (scale.MsrmntState == MsrmntState.Busy) scale.MsrmntState = MsrmntState.Failed;
|
||||||
|
scale.Activity = Activity.Idle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
///
|
///
|
||||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
|
||||||
/// Author: Milan Hanajik
|
|
||||||
///
|
///
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -16,19 +15,19 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
public override string ToString() { return string.Format("SetUnitsOp({0})", units); }
|
public override string ToString() { return string.Format("SetUnitsOp({0})", units); }
|
||||||
|
|
||||||
/// Set by the constructor
|
/// Set by the constructor
|
||||||
BalanceDev balanceDev;
|
BalanceDev scale;
|
||||||
BalanceDev.Units units;
|
BalanceDev.Units units;
|
||||||
|
bool activityStarted;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Events: BalanceDone, Error
|
/// Events: BalanceDone, Error
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="balanceDev">Balance device instance</param>
|
/// <param name="scale">Balance device instance</param>
|
||||||
/// <param name="result">Reference to the serialNumber</param>
|
/// <param name="result">Reference to the serialNumber</param>
|
||||||
public SetUnitsOp(BalanceDev balanceDev, BalanceDev.Units units)
|
public SetUnitsOp(BalanceDev scale, BalanceDev.Units units)
|
||||||
{
|
{
|
||||||
if (balanceDev == null) throw new ArgumentNullException("balanceDev");
|
if (scale == null) throw new ArgumentNullException("balanceDev");
|
||||||
this.balanceDev = balanceDev;
|
this.scale = scale;
|
||||||
|
|
||||||
this.units = units;
|
this.units = units;
|
||||||
|
|
||||||
log.Debug(this.ToString());
|
log.Debug(this.ToString());
|
||||||
@@ -37,9 +36,19 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
/// <summary>Start this operation</summary>
|
/// <summary>Start this operation</summary>
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
log.DebugFormat("{0} - Start()", balanceDev.Name);
|
log.DebugFormat("{0} - SetUnitsOp - Start()", scale.Name);
|
||||||
balanceDev.SetUnits(units);
|
|
||||||
}
|
if (scale.Activity == Activity.Idle)
|
||||||
|
{
|
||||||
|
scale.SendSetUnitsCmd(units);
|
||||||
|
activityStarted = true;
|
||||||
|
scale.Activity = Activity.RunningOperation;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
activityStarted = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Run this operation</summary>
|
/// <summary>Run this operation</summary>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
@@ -48,15 +57,25 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public Event Run()
|
public Event Run()
|
||||||
{
|
{
|
||||||
if (balanceDev.MsrmntState == MsrmntState.Valid) return Event.BalanceDone; /// Units set
|
if (!activityStarted && scale.Activity == Activity.Idle)
|
||||||
if (balanceDev.MsrmntState == MsrmntState.Failed) return Event.Error; /// Failed
|
{
|
||||||
|
scale.SendSetUnitsCmd(units);
|
||||||
|
activityStarted = true;
|
||||||
|
scale.Activity = Activity.RunningOperation;
|
||||||
|
return Event.None;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scale.MsrmntState == MsrmntState.Valid) return Event.BalanceDone; /// Units set
|
||||||
|
if (scale.MsrmntState == MsrmntState.Failed) return Event.Error; /// Failed
|
||||||
return Event.None; /// No result yet
|
return Event.None; /// No result yet
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Stop this operation</summary>
|
/// <summary>Stop this operation</summary>
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
log.DebugFormat("{0} - Stop()", balanceDev.Name);
|
if (scale.MsrmntState == MsrmntState.Busy) scale.MsrmntState = MsrmntState.Failed;
|
||||||
|
scale.Activity = Activity.Idle;
|
||||||
|
log.DebugFormat("{0} - SetUnitsOp - Stop()", scale.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
///
|
///
|
||||||
/// Copyright (c) 2013-2016 Sensus Metering Systems
|
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
|
||||||
///
|
///
|
||||||
using System;
|
using System;
|
||||||
using log4net;
|
using log4net;
|
||||||
@@ -15,19 +15,19 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
bool done;
|
bool done;
|
||||||
|
|
||||||
/// Set by the constructor
|
/// Set by the constructor
|
||||||
BalanceDev balanceDev;
|
BalanceDev scale;
|
||||||
DoubleBox tara;
|
DoubleBox tara;
|
||||||
|
bool activityStarted;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Events: BalanceDone, Error
|
/// Events: BalanceDone, Error
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="balanceDev">Balance device instance</param>
|
/// <param name="scale">Balance device instance</param>
|
||||||
/// <param name="result">Reference to variable for 'tara' in kg</param>
|
/// <param name="result">Reference to variable for 'tara' in kg</param>
|
||||||
public TaringOp(BalanceDev balanceDev, ref DoubleBox tara)
|
public TaringOp(BalanceDev scale, ref DoubleBox tara)
|
||||||
{
|
{
|
||||||
if (balanceDev == null) throw new ArgumentNullException("balanceDev");
|
if (scale == null) throw new ArgumentNullException("balanceDev");
|
||||||
this.balanceDev = balanceDev;
|
this.scale = scale;
|
||||||
|
|
||||||
this.tara = tara;
|
this.tara = tara;
|
||||||
|
|
||||||
log.Debug(this.ToString());
|
log.Debug(this.ToString());
|
||||||
@@ -36,10 +36,20 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
/// <summary>Start this operation</summary>
|
/// <summary>Start this operation</summary>
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
log.DebugFormat("{0} - Start()", balanceDev.Name);
|
log.DebugFormat("{0} - TaringOp - tart()", scale.Name);
|
||||||
|
|
||||||
done = false;
|
done = false;
|
||||||
balanceDev.Taring();
|
if (scale.Activity == Activity.Idle)
|
||||||
}
|
{
|
||||||
|
scale.SendTaraCmd();
|
||||||
|
activityStarted = true;
|
||||||
|
scale.Activity = Activity.RunningOperation;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
activityStarted = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Run this operation</summary>
|
/// <summary>Run this operation</summary>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
@@ -49,32 +59,42 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public Event Run()
|
public Event Run()
|
||||||
{
|
{
|
||||||
if (done) return Event.BalanceDone; /// Taring has been done already
|
if (!activityStarted && scale.Activity == Activity.Idle)
|
||||||
|
|
||||||
if (balanceDev.MsrmntState == MsrmntState.Busy) return Event.Busy;
|
|
||||||
|
|
||||||
if (balanceDev.MsrmntState == MsrmntState.Overload)
|
|
||||||
{
|
{
|
||||||
tara.Val = balanceDev.Capacity;
|
scale.SendTaraCmd();
|
||||||
|
activityStarted = true;
|
||||||
|
scale.Activity = Activity.RunningOperation;
|
||||||
|
return Event.Busy;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (done) return Event.BalanceDone; /// Taring has been done already
|
||||||
|
|
||||||
|
if (scale.MsrmntState == MsrmntState.Busy) return Event.Busy;
|
||||||
|
|
||||||
|
if (scale.MsrmntState == MsrmntState.Overload)
|
||||||
|
{
|
||||||
|
tara.Val = scale.Capacity;
|
||||||
done = true;
|
done = true;
|
||||||
return Event.BalanceOverload;
|
return Event.BalanceOverload;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (balanceDev.MsrmntState == MsrmntState.Valid)
|
if (scale.MsrmntState == MsrmntState.Valid)
|
||||||
{
|
{
|
||||||
tara.Val = balanceDev.Mass;
|
tara.Val = scale.Mass;
|
||||||
done = true;
|
done = true;
|
||||||
return Event.BalanceDone; /// Taring completed
|
return Event.BalanceDone; /// Taring completed
|
||||||
}
|
}
|
||||||
|
|
||||||
balanceDev.Taring(); /// Failed -> repeat taring
|
scale.SendTaraCmd(); /// Failed -> repeat taring
|
||||||
return Event.Busy;
|
return Event.Busy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Stop this operation</summary>
|
/// <summary>Stop this operation</summary>
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
log.DebugFormat("{0} - Stop()", balanceDev.Name);
|
if (scale.MsrmntState == MsrmntState.Busy) scale.MsrmntState = MsrmntState.Failed;
|
||||||
|
scale.Activity = Activity.Idle;
|
||||||
|
log.DebugFormat("{0} - TaringOp - Stop()", scale.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,17 +14,18 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
bool done;
|
bool done;
|
||||||
|
|
||||||
/// Set by the constructor
|
/// Set by the constructor
|
||||||
BalanceDev balanceDev;
|
BalanceDev scale;
|
||||||
|
bool activityStarted;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Events: BalanceDone, Error
|
/// Events: BalanceDone, Error
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="balanceDev">Balance device instance</param>
|
/// <param name="scale">Balance device instance</param>
|
||||||
/// <param name="result">Reference to variable for 'tara' in kg</param>
|
/// <param name="result">Reference to variable for 'tara' in kg</param>
|
||||||
public ZeroOp(BalanceDev balanceDev)
|
public ZeroOp(BalanceDev scale)
|
||||||
{
|
{
|
||||||
if (balanceDev == null) throw new ArgumentNullException("balanceDev");
|
if (scale == null) throw new ArgumentNullException("balanceDev");
|
||||||
this.balanceDev = balanceDev;
|
this.scale = scale;
|
||||||
|
|
||||||
log.Debug(this.ToString());
|
log.Debug(this.ToString());
|
||||||
}
|
}
|
||||||
@@ -32,10 +33,20 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
/// <summary>Start this operation</summary>
|
/// <summary>Start this operation</summary>
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
log.DebugFormat("{0} - Start()", balanceDev.Name);
|
log.DebugFormat("{0} - ZeroOp - Start()", scale.Name);
|
||||||
|
|
||||||
done = false;
|
done = false;
|
||||||
balanceDev.ZeroWhenStable();
|
if (scale.Activity == Activity.Idle)
|
||||||
}
|
{
|
||||||
|
scale.SendZeroWhenStableCmd();
|
||||||
|
activityStarted = true;
|
||||||
|
scale.Activity = Activity.RunningOperation;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
activityStarted = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Run this operation</summary>
|
/// <summary>Run this operation</summary>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
@@ -45,30 +56,40 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public Event Run()
|
public Event Run()
|
||||||
{
|
{
|
||||||
if (done) return Event.BalanceDone; /// Zeroing has been done already
|
if (!activityStarted && scale.Activity == Activity.Idle)
|
||||||
|
{
|
||||||
|
scale.SendZeroWhenStableCmd();
|
||||||
|
activityStarted = true;
|
||||||
|
scale.Activity = Activity.RunningOperation;
|
||||||
|
return Event.Busy;
|
||||||
|
}
|
||||||
|
|
||||||
if (balanceDev.MsrmntState == MsrmntState.Busy) return Event.Busy;
|
if (done) return Event.BalanceDone; /// Zeroing has been done already
|
||||||
|
|
||||||
if (balanceDev.MsrmntState == MsrmntState.Overload)
|
if (scale.MsrmntState == MsrmntState.Busy) return Event.Busy;
|
||||||
|
|
||||||
|
if (scale.MsrmntState == MsrmntState.Overload)
|
||||||
{
|
{
|
||||||
done = true;
|
done = true;
|
||||||
return Event.BalanceOverload;
|
return Event.BalanceOverload;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (balanceDev.MsrmntState == MsrmntState.Valid)
|
if (scale.MsrmntState == MsrmntState.Valid)
|
||||||
{
|
{
|
||||||
done = true;
|
done = true;
|
||||||
return Event.BalanceDone; /// Zeroing completed
|
return Event.BalanceDone; /// Zeroing completed
|
||||||
}
|
}
|
||||||
|
|
||||||
balanceDev.ZeroWhenStable(); /// Failed -> repeat zeroing
|
scale.SendZeroWhenStableCmd(); /// Failed -> repeat zeroing
|
||||||
return Event.Busy;
|
return Event.Busy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Stop this operation</summary>
|
/// <summary>Stop this operation</summary>
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
log.DebugFormat("{0} - Stop()", balanceDev.Name);
|
if (scale.MsrmntState == MsrmntState.Busy) scale.MsrmntState = MsrmntState.Failed;
|
||||||
|
scale.Activity = Activity.Idle;
|
||||||
|
log.DebugFormat("{0} - ZeroOp - Stop()", scale.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -534,7 +534,6 @@ namespace TBF.BenchControl.Sequences
|
|||||||
|
|
||||||
State.Create("SequenceBase : Transition : TestEnd - Default action")
|
State.Create("SequenceBase : Transition : TestEnd - Default action")
|
||||||
.AddOperation(checkUiOp)
|
.AddOperation(checkUiOp)
|
||||||
.AddOperation(new MettlerToledo.KeepReadingMassesOp())
|
|
||||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen,
|
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen,
|
||||||
StateMachine.DefaultValvesClose))
|
StateMachine.DefaultValvesClose))
|
||||||
.EnterState();
|
.EnterState();
|
||||||
@@ -648,7 +647,6 @@ namespace TBF.BenchControl.Sequences
|
|||||||
.Create(string.Format("SequenceBase.Transition() : Step {0} start, opening={1}, closing={2}", step.ItemNr + 1, step.ValvesOpen, step.ValvesClose))
|
.Create(string.Format("SequenceBase.Transition() : Step {0} start, opening={1}, closing={2}", step.ItemNr + 1, step.ValvesOpen, step.ValvesClose))
|
||||||
.AddOperation(checkUiOp)
|
.AddOperation(checkUiOp)
|
||||||
.AddOperation(conditionOperation)
|
.AddOperation(conditionOperation)
|
||||||
.AddOperation(new MettlerToledo.KeepReadingMassesOp())
|
|
||||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(Utils.ValvesOpen(step), Utils.ValvesClose(step)));
|
.AddOperation(StateMachine.ControlBoard.SetValvesOp(Utils.ValvesOpen(step), Utils.ValvesClose(step)));
|
||||||
for (int j = 0; j <= i; j++)
|
for (int j = 0; j <= i; j++)
|
||||||
{
|
{
|
||||||
@@ -670,8 +668,7 @@ namespace TBF.BenchControl.Sequences
|
|||||||
.Create(string.Format("SequenceBase.Transition() : Step {0} delay {1}s, opening={2}, closing={3}", step.ItemNr + 1, delay, step.ValvesOpen, step.ValvesClose))
|
.Create(string.Format("SequenceBase.Transition() : Step {0} delay {1}s, opening={2}, closing={3}", step.ItemNr + 1, delay, step.ValvesOpen, step.ValvesClose))
|
||||||
.AddOperation(checkUiOp)
|
.AddOperation(checkUiOp)
|
||||||
.AddOperation(conditionOperation)
|
.AddOperation(conditionOperation)
|
||||||
.AddOperation(new MettlerToledo.KeepReadingMassesOp())
|
.AddOperation(StateMachine.ControlBoard.SetValvesOp(Utils.ValvesOpen(step), Utils.ValvesClose(step)))
|
||||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(Utils.ValvesOpen(step), Utils.ValvesClose(step)))
|
|
||||||
.AddOperation(new TimerOp(delay));
|
.AddOperation(new TimerOp(delay));
|
||||||
for (int j = 0; j <= lastStartedRV; j++)
|
for (int j = 0; j <= lastStartedRV; j++)
|
||||||
{
|
{
|
||||||
@@ -717,7 +714,6 @@ namespace TBF.BenchControl.Sequences
|
|||||||
.Create(string.Format("SequenceBase.Transition() : Step {0} stop, opening={1}, closing={2}", step.ItemNr + 1, step.ValvesOpen, step.ValvesClose))
|
.Create(string.Format("SequenceBase.Transition() : Step {0} stop, opening={1}, closing={2}", step.ItemNr + 1, step.ValvesOpen, step.ValvesClose))
|
||||||
.AddOperation(checkUiOp)
|
.AddOperation(checkUiOp)
|
||||||
.AddOperation(conditionOperation)
|
.AddOperation(conditionOperation)
|
||||||
.AddOperation(new MettlerToledo.KeepReadingMassesOp())
|
|
||||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(Utils.ValvesOpen(step), Utils.ValvesClose(step)));
|
.AddOperation(StateMachine.ControlBoard.SetValvesOp(Utils.ValvesOpen(step), Utils.ValvesClose(step)));
|
||||||
for (int j = first; j <= lastStartedRV; j++)
|
for (int j = first; j <= lastStartedRV; j++)
|
||||||
{
|
{
|
||||||
@@ -776,7 +772,6 @@ namespace TBF.BenchControl.Sequences
|
|||||||
{
|
{
|
||||||
State.Create("SequenceBase : Transition : TestStart - Default action")
|
State.Create("SequenceBase : Transition : TestStart - Default action")
|
||||||
.AddOperation(checkUiOp)
|
.AddOperation(checkUiOp)
|
||||||
.AddOperation(new MettlerToledo.KeepReadingMassesOp())
|
|
||||||
.AddOperation(StateMachine.ControlBoard
|
.AddOperation(StateMachine.ControlBoard
|
||||||
.SetValvesOp(BuiltIn.ValveBase.Merge(inPath.ValvesOpen, benchPath.ValvesOpen, outPath.ValvesOpen),
|
.SetValvesOp(BuiltIn.ValveBase.Merge(inPath.ValvesOpen, benchPath.ValvesOpen, outPath.ValvesOpen),
|
||||||
BuiltIn.ValveBase.Merge(inPath.ValvesClose, benchPath.ValvesClose, outPath.ValvesClose)))
|
BuiltIn.ValveBase.Merge(inPath.ValvesClose, benchPath.ValvesClose, outPath.ValvesClose)))
|
||||||
@@ -796,7 +791,6 @@ namespace TBF.BenchControl.Sequences
|
|||||||
/// Set route for the next test
|
/// Set route for the next test
|
||||||
State.Create("SequenceBase : AfterTestWithOverlap : Default action")
|
State.Create("SequenceBase : AfterTestWithOverlap : Default action")
|
||||||
.AddOperation(checkUiOp)
|
.AddOperation(checkUiOp)
|
||||||
.AddOperation(new MettlerToledo.KeepReadingMassesOp())
|
|
||||||
.AddOperation(StateMachine.ControlBoard
|
.AddOperation(StateMachine.ControlBoard
|
||||||
.SetValvesOp(BuiltIn.ValveBase.Merge(nextInPath.ValvesOpen, nextBenchPath.ValvesOpen, nextOutPath.ValvesOpen),
|
.SetValvesOp(BuiltIn.ValveBase.Merge(nextInPath.ValvesOpen, nextBenchPath.ValvesOpen, nextOutPath.ValvesOpen),
|
||||||
BuiltIn.ValveBase.Merge(nextInPath.ValvesClose, nextBenchPath.ValvesClose, nextOutPath.ValvesClose)))
|
BuiltIn.ValveBase.Merge(nextInPath.ValvesClose, nextBenchPath.ValvesClose, nextOutPath.ValvesClose)))
|
||||||
@@ -825,7 +819,6 @@ namespace TBF.BenchControl.Sequences
|
|||||||
/// Set flow for the next test
|
/// Set flow for the next test
|
||||||
State.Create(string.Format("SequenceBase : AfterTestWithOverlap - Setting the flow to {0} - {1} m3/h", nextQfrom, nextQto))
|
State.Create(string.Format("SequenceBase : AfterTestWithOverlap - Setting the flow to {0} - {1} m3/h", nextQfrom, nextQto))
|
||||||
.AddOperation(checkUiOp)
|
.AddOperation(checkUiOp)
|
||||||
.AddOperation(new MettlerToledo.KeepReadingMassesOp())
|
|
||||||
.AddOperation(nextOutPath.RegulValve.SetFlowAndMeasureOp(nextOutPath.FlowMeter, nextQfrom, nextQto, RefFlow, FlowSettingTimeoutSec, 0))
|
.AddOperation(nextOutPath.RegulValve.SetFlowAndMeasureOp(nextOutPath.FlowMeter, nextQfrom, nextQto, RefFlow, FlowSettingTimeoutSec, 0))
|
||||||
.EnterState();
|
.EnterState();
|
||||||
do {
|
do {
|
||||||
|
|||||||
@@ -635,7 +635,6 @@ namespace TBF.BenchControl.TestMethods.DiverterTest
|
|||||||
State.Create("SequenceBase : Transition : TestEnd - Default action")
|
State.Create("SequenceBase : Transition : TestEnd - Default action")
|
||||||
.AddOperation(checkUiOp)
|
.AddOperation(checkUiOp)
|
||||||
.AddOperations(readTempPressOps)
|
.AddOperations(readTempPressOps)
|
||||||
.AddOperation(new MettlerToledo.KeepReadingMassesOp())
|
|
||||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose))
|
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose))
|
||||||
.EnterState();
|
.EnterState();
|
||||||
do {
|
do {
|
||||||
|
|||||||
+1
-2
@@ -695,8 +695,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl
|
|||||||
State.Create("SequenceBase : Transition : TestEnd - Default action")
|
State.Create("SequenceBase : Transition : TestEnd - Default action")
|
||||||
.AddOperation(checkUiOp)
|
.AddOperation(checkUiOp)
|
||||||
.AddOperations(readTempPressOps)
|
.AddOperations(readTempPressOps)
|
||||||
.AddOperation(new MettlerToledo.KeepReadingMassesOp())
|
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose))
|
||||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose))
|
|
||||||
.EnterState();
|
.EnterState();
|
||||||
do {
|
do {
|
||||||
e = StateMachine.WaitRunDevsRunOps();
|
e = StateMachine.WaitRunDevsRunOps();
|
||||||
|
|||||||
-1
@@ -800,7 +800,6 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative
|
|||||||
State.Create("SequenceBase : Transition : TestEnd - Default action")
|
State.Create("SequenceBase : Transition : TestEnd - Default action")
|
||||||
.AddOperation(checkUiOp)
|
.AddOperation(checkUiOp)
|
||||||
.AddOperations(readTempPressOps)
|
.AddOperations(readTempPressOps)
|
||||||
.AddOperation(new MettlerToledo.KeepReadingMassesOp())
|
|
||||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose))
|
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose))
|
||||||
.EnterState();
|
.EnterState();
|
||||||
do {
|
do {
|
||||||
|
|||||||
-1
@@ -809,7 +809,6 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged
|
|||||||
State.Create("SequenceBase : Transition : TestEnd - Default action")
|
State.Create("SequenceBase : Transition : TestEnd - Default action")
|
||||||
.AddOperation(checkUiOp)
|
.AddOperation(checkUiOp)
|
||||||
.AddOperations(readTempPressOps)
|
.AddOperations(readTempPressOps)
|
||||||
.AddOperation(new MettlerToledo.KeepReadingMassesOp())
|
|
||||||
.AddOperation(cBrd.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose))
|
.AddOperation(cBrd.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose))
|
||||||
.EnterState();
|
.EnterState();
|
||||||
do {
|
do {
|
||||||
|
|||||||
@@ -681,7 +681,6 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
|
|||||||
State.Create("SequenceBase : Transition : TestEnd - Default action")
|
State.Create("SequenceBase : Transition : TestEnd - Default action")
|
||||||
.AddOperation(checkUiOp)
|
.AddOperation(checkUiOp)
|
||||||
.AddOperations(readTempPressOps)
|
.AddOperations(readTempPressOps)
|
||||||
.AddOperation(new MettlerToledo.KeepReadingMassesOp())
|
|
||||||
.AddOperation(cBrd.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose))
|
.AddOperation(cBrd.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose))
|
||||||
.EnterState();
|
.EnterState();
|
||||||
do {
|
do {
|
||||||
|
|||||||
@@ -715,7 +715,6 @@
|
|||||||
<DependentUpon>TempMeterCfgCtrl.cs</DependentUpon>
|
<DependentUpon>TempMeterCfgCtrl.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="BenchControl\Keithley\TempMeter\Factory.cs" />
|
<Compile Include="BenchControl\Keithley\TempMeter\Factory.cs" />
|
||||||
<Compile Include="BenchControl\MettlerToledo\KeepReadingMassesOp.cs" />
|
|
||||||
<Compile Include="BenchControl\MettlerToledo\Multi\BalanceCfg.cs" />
|
<Compile Include="BenchControl\MettlerToledo\Multi\BalanceCfg.cs" />
|
||||||
<Compile Include="BenchControl\MettlerToledo\Multi\BalanceCfgCtrl.cs">
|
<Compile Include="BenchControl\MettlerToledo\Multi\BalanceCfgCtrl.cs">
|
||||||
<SubType>UserControl</SubType>
|
<SubType>UserControl</SubType>
|
||||||
|
|||||||
Reference in New Issue
Block a user