All scales support GetSerNumOp (however some return null). Reading S/N of all scales on program startup, ver. 2.14.588
This commit is contained in:
parent
71e1cf47df
commit
2fb1c44ff2
@ -55,6 +55,11 @@ namespace TBF.BenchControl.Dummy.Balance
|
||||
return this;
|
||||
}
|
||||
|
||||
public IOperation GetSerNumOp(ref string serialNumber)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
|
||||
@ -79,5 +79,12 @@ namespace TBF.BenchControl.GenericDevices
|
||||
/// <param name="method">Method: false = slow (precise), true = fast (immediate)</param>
|
||||
/// <returns>ReadMassAverageOp instance reference casted to IOperaton</returns>
|
||||
IOperation ReadStableMassOp(ref DoubleBox mass, int readingsCount, double maxSpread, Config.Entities.MassMethod method);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Events: Done, Error
|
||||
/// </summary>
|
||||
/// <param name="serialNumber">Reference to the serialNumber</param>
|
||||
/// <returns>GetBalanceSerNumOp instance reference casted to IOperaton</returns>
|
||||
IOperation GetSerNumOp(ref string serialNumber);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.GenericDevices
|
||||
{
|
||||
public interface IScale2 : IScale, IComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Events: Done, Error
|
||||
/// </summary>
|
||||
/// <param name="serialNumber">Reference to the serialNumber</param>
|
||||
/// <returns>GetBalanceSNOp instance reference casted to IOperaton</returns>
|
||||
IOperation GetBalanceSNOp(ref string serialNumber);
|
||||
}
|
||||
}
|
||||
@ -315,5 +315,15 @@ namespace TBF.BenchControl.MettlerToledo.Multi
|
||||
{
|
||||
return new ReadStableMassOp(this, ref mass, readingsCount, maxSpread, method);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Events: BalanceDone, Error
|
||||
/// </summary>
|
||||
/// <param name="serialNumber">Reference to the serialNumber</param>
|
||||
/// <returns>GetBalanceSNOp instance reference casted to IOperaton</returns>
|
||||
public IOperation GetSerNumOp(ref string serialNumber)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -491,5 +491,15 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
{
|
||||
return new ReadStableMassOp(this, ref mass, readingsCount, maxSpread, method);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Events: BalanceDone, Error
|
||||
/// </summary>
|
||||
/// <param name="serialNumber">Reference to the serialNumber</param>
|
||||
/// <returns>GetBalanceSNOp instance reference casted to IOperaton</returns>
|
||||
public virtual IOperation GetSerNumOp(ref string serialNumber)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,12 +1,8 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2017 Sensus Metering Systems
|
||||
/// Author: Milan Hanajik
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.IO.Ports;
|
||||
using log4net;
|
||||
using Config.Entities;
|
||||
using TBF.BenchControl.Generic;
|
||||
@ -19,7 +15,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
/// <note>
|
||||
/// Implemented and tested on 15.10.2013 by Milan Hanajik
|
||||
/// </note>
|
||||
public class BalanceNewDev : BalanceDev, IDevice, GenericDevices.IScale2
|
||||
public class BalanceNewDev : BalanceDev, IDevice, GenericDevices.IScale
|
||||
{
|
||||
/// <summary>
|
||||
/// Info: StartMassMeasurement() and "Balnce response = .., Mass = ..."
|
||||
@ -55,7 +51,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
return;
|
||||
}
|
||||
|
||||
log.InfoFormat("{0} - GetSerialNumber()", Name);
|
||||
log.WarnFormat("{0} - GetSerialNumber()", Name);
|
||||
|
||||
msrmntState = MsrmntState.Busy;
|
||||
stringBuilder.Clear();
|
||||
@ -123,7 +119,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
{
|
||||
serialNumber = fields[2].Substring(1, fields[2].Length - 2);
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("{0} - Balance response = {1}, s/n = {1}", Name,
|
||||
log.WarnFormat("{0} - Balance response = {1}, s/n = {1}", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"), serialNumber);
|
||||
}
|
||||
else
|
||||
@ -140,7 +136,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
mass = 0;
|
||||
Masses[balanceNr] = mass;
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("{0} - Balance response = {1}", Name,
|
||||
log.WarnFormat("{0} - Balance response = {1}", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"));
|
||||
}
|
||||
else
|
||||
@ -203,14 +199,14 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
if (fields[3].Equals("g")) mass /= 1000.0f;
|
||||
if (fields[3].Equals("t")) mass *= 1000.0f;
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("{0} - Balance response = {1}, Mass = {2}", Name,
|
||||
log.WarnFormat("{0} - Balance response = {1}, Mass = {2}", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"), mass);
|
||||
}
|
||||
else if (fields.Length >= 2 && fields[1].Equals("I"))
|
||||
{
|
||||
mass = mass = balanceCfg.Capacity;
|
||||
msrmntState = MsrmntState.Overload;
|
||||
log.InfoFormat("{0} - Balance response = {1}, Overload", Name,
|
||||
log.WarnFormat("{0} - Balance response = {1}, Overload", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"), mass);
|
||||
}
|
||||
else
|
||||
@ -256,9 +252,9 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
/// </summary>
|
||||
/// <param name="serialNumber">Reference to the serialNumber</param>
|
||||
/// <returns>GetBalanceSNOp instance reference casted to IOperaton</returns>
|
||||
public IOperation GetBalanceSNOp(ref string serialNumber)
|
||||
public override IOperation GetSerNumOp(ref string serialNumber)
|
||||
{
|
||||
return new GetBalanceSNOp(this, ref serialNumber);
|
||||
return new GetSerNumOp(this, ref serialNumber);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -1,63 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
/// Author: Milan Hanajik
|
||||
///
|
||||
using System;
|
||||
using log4net;
|
||||
|
||||
namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
{
|
||||
public class GetBalanceSNOp : IOperation
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(GetBalanceSNOp));
|
||||
public override string ToString() { return string.Format("GetBalanceSNOp(.,.)"); }
|
||||
|
||||
/// Set by the constructor
|
||||
BalanceNewDev balanceDev;
|
||||
string serialNumber;
|
||||
|
||||
/// <summary>
|
||||
/// Events: BalanceDone, Error
|
||||
/// </summary>
|
||||
/// <param name="balanceDev">Balance device instance</param>
|
||||
/// <param name="serialNumber">Reference to the serialNumber</param>
|
||||
public GetBalanceSNOp(BalanceNewDev balanceDev, ref string serialNumber)
|
||||
{
|
||||
if (balanceDev == null) throw new ArgumentNullException("balanceDev");
|
||||
this.balanceDev = balanceDev;
|
||||
|
||||
this.serialNumber = serialNumber;
|
||||
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
log.DebugFormat("{0} - Start()", balanceDev.Name);
|
||||
balanceDev.GetSerialNumber();
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
/// <returns>
|
||||
/// Event.None
|
||||
/// Event.BalanceDone
|
||||
/// </returns>
|
||||
public Event Run()
|
||||
{
|
||||
if (balanceDev.MsrmntState == MsrmntState.Valid)
|
||||
{
|
||||
serialNumber = balanceDev.SerialNumber;
|
||||
return Event.BalanceDone; /// S/N read successful
|
||||
}
|
||||
if (balanceDev.MsrmntState == MsrmntState.Failed) return Event.Error; /// S/N read failed
|
||||
return Event.None; /// No result yet
|
||||
}
|
||||
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
log.DebugFormat("{0} - Stop()", balanceDev.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,62 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using log4net;
|
||||
|
||||
namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
{
|
||||
public class GetSerNumOp : IOperation
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(GetSerNumOp));
|
||||
public override string ToString() { return string.Format("GetSerNumOp(.,.)"); }
|
||||
|
||||
/// Set by the constructor
|
||||
BalanceNewDev scale;
|
||||
string serialNumber;
|
||||
|
||||
/// <summary>
|
||||
/// Events: BalanceDone, Error
|
||||
/// </summary>
|
||||
/// <param name="scale">Balance device instance</param>
|
||||
/// <param name="serialNumber">Reference to the serialNumber</param>
|
||||
public GetSerNumOp(BalanceNewDev scale, ref string serialNumber)
|
||||
{
|
||||
if (scale == null) throw new ArgumentNullException("balanceDev");
|
||||
this.scale = scale;
|
||||
|
||||
this.serialNumber = serialNumber;
|
||||
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
log.DebugFormat("{0} - Start()", scale.Name);
|
||||
scale.GetSerialNumber();
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
/// <returns>
|
||||
/// Event.None
|
||||
/// Event.BalanceDone
|
||||
/// </returns>
|
||||
public Event Run()
|
||||
{
|
||||
if (scale.MsrmntState == MsrmntState.Valid)
|
||||
{
|
||||
serialNumber = scale.SerialNumber;
|
||||
return Event.BalanceDone; /// S/N read successful
|
||||
}
|
||||
if (scale.MsrmntState == MsrmntState.Failed) return Event.Error; /// S/N read failed
|
||||
return Event.None; /// No result yet
|
||||
}
|
||||
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
log.DebugFormat("{0} - Stop()", scale.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -124,6 +124,27 @@ namespace TBF.BenchControl.Sequences
|
||||
}
|
||||
while (e.Contains(Event.ValvesBusy));
|
||||
|
||||
//--------------------------------------------------------------------------------------------
|
||||
State getSNs = State.Create("MainSeq : Reading serial numbers of all scales").AddOperation(checkUiOp);
|
||||
string serNum1 = string.Empty;
|
||||
string serNum2 = string.Empty;
|
||||
string serNum3 = string.Empty;
|
||||
if (StateMachine.Scale1 != null) getSNs.AddOperation(StateMachine.Scale1.GetSerNumOp(ref serNum1));
|
||||
if (StateMachine.Scale2 != null) getSNs.AddOperation(StateMachine.Scale2.GetSerNumOp(ref serNum2));
|
||||
if (StateMachine.Scale3 != null) getSNs.AddOperation(StateMachine.Scale3.GetSerNumOp(ref serNum3));
|
||||
getSNs.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) goto error;
|
||||
if (e.Contains(Event.UiCmdStop)) goto stop;
|
||||
}
|
||||
while (e.Contains(Event.Busy));
|
||||
|
||||
if (!string.IsNullOrEmpty(serNum1)) log.WarnFormat("Scale {0} : s/n = {1}", StateMachine.Scale1.Name, serNum1);
|
||||
if (!string.IsNullOrEmpty(serNum2)) log.WarnFormat("Scale {0} : s/n = {1}", StateMachine.Scale2.Name, serNum2);
|
||||
if (!string.IsNullOrEmpty(serNum3)) log.WarnFormat("Scale {0} : s/n = {1}", StateMachine.Scale3.Name, serNum3);
|
||||
|
||||
//--------------------------------------------------------------------------------------------
|
||||
IntBox remainingTime = new IntBox();
|
||||
State startNew = State.Create("MainSeq : Draining tanks")
|
||||
@ -190,11 +211,15 @@ namespace TBF.BenchControl.Sequences
|
||||
while (e.Contains(Event.ValvesBusy));
|
||||
|
||||
//--------------------------------------------------------------------------------------------
|
||||
State taraAll = State.Create("MainSeq : Reset all balances").AddOperation(checkUiOp);
|
||||
DoubleBox tara = new DoubleBox(0);
|
||||
if (StateMachine.Scale1 != null) taraAll.AddOperation(StateMachine.Scale1.TaringOp(ref tara));
|
||||
if (StateMachine.Scale2 != null) taraAll.AddOperation(StateMachine.Scale2.TaringOp(ref tara));
|
||||
if (StateMachine.Scale3 != null) taraAll.AddOperation(StateMachine.Scale3.TaringOp(ref tara));
|
||||
Bridge.OnActivity(this, Strings.Resetting_scales);
|
||||
//--------------------------------------------------------------------------------------------
|
||||
State taraAll = State.Create("MainSeq : Resetting scales").AddOperation(checkUiOp);
|
||||
DoubleBox tara1 = new DoubleBox(0);
|
||||
DoubleBox tara2 = new DoubleBox(0);
|
||||
DoubleBox tara3 = new DoubleBox(0);
|
||||
if (StateMachine.Scale1 != null) taraAll.AddOperation(StateMachine.Scale1.TaringOp(ref tara1));
|
||||
if (StateMachine.Scale2 != null) taraAll.AddOperation(StateMachine.Scale2.TaringOp(ref tara2));
|
||||
if (StateMachine.Scale3 != null) taraAll.AddOperation(StateMachine.Scale3.TaringOp(ref tara3));
|
||||
taraAll.EnterState();
|
||||
do
|
||||
{
|
||||
|
||||
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("2.14.587.1")]
|
||||
[assembly: AssemblyFileVersion("2.14.587.1")]
|
||||
[assembly: AssemblyVersion("2.14.588.1")]
|
||||
[assembly: AssemblyFileVersion("2.14.588.1")]
|
||||
|
||||
9
TestBenchFramework/Resources/Strings.Designer.cs
generated
9
TestBenchFramework/Resources/Strings.Designer.cs
generated
@ -3471,6 +3471,15 @@ namespace TBF.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Resetting scales.
|
||||
/// </summary>
|
||||
internal static string Resetting_scales {
|
||||
get {
|
||||
return ResourceManager.GetString("Resetting_scales", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Resistance.
|
||||
/// </summary>
|
||||
|
||||
@ -1783,4 +1783,7 @@
|
||||
<data name="Temp_lim_lo_chdr" xml:space="preserve">
|
||||
<value>Temp. lim. lo [°C]</value>
|
||||
</data>
|
||||
<data name="Resetting_scales" xml:space="preserve">
|
||||
<value>Resetting scales</value>
|
||||
</data>
|
||||
</root>
|
||||
@ -518,7 +518,7 @@
|
||||
<Compile Include="BenchControl\MettlerToledo\Standard\BalanceNewFactory.cs" />
|
||||
<Compile Include="BenchControl\MettlerToledo\Standard\BalanceOld.cs" />
|
||||
<Compile Include="BenchControl\MettlerToledo\Standard\BalanceOldFactory.cs" />
|
||||
<Compile Include="BenchControl\MettlerToledo\Standard\GetBalanceSNOp.cs" />
|
||||
<Compile Include="BenchControl\MettlerToledo\Standard\GetSerNumOp.cs" />
|
||||
<Compile Include="BenchControl\MettlerToledo\Standard\ReadMassOp.cs" />
|
||||
<Compile Include="BenchControl\MettlerToledo\Standard\ReadStableMassOp.cs" />
|
||||
<Compile Include="BenchControl\MettlerToledo\Standard\SetUnitsOp.cs" />
|
||||
@ -1363,7 +1363,6 @@
|
||||
<Compile Include="BenchControl\Elde\Valve\ValveCfg.cs" />
|
||||
<Compile Include="BenchControl\Elde\Valve\ValveFactory.cs" />
|
||||
<Compile Include="BenchControl\GenericDevices\IScale.cs" />
|
||||
<Compile Include="BenchControl\GenericDevices\IScale2.cs" />
|
||||
<Compile Include="BenchControl\Generic\IComponentCfgCtrl.cs" />
|
||||
<Compile Include="BenchControl\GenericDevices\IDiverter.cs" />
|
||||
<Compile Include="BenchControl\GenericDevices\IFlowMeter.cs" />
|
||||
|
||||
Loading…
Reference in New Issue
Block a user