MettlerToledo : Zero instead of Taring, cleanup, ver. 3.1.1495

This commit is contained in:
Milan Hanajik 2020-06-17 09:12:02 +02:00
parent fea7d0dc85
commit ddca028eb2
10 changed files with 181 additions and 22 deletions

View File

@ -6,6 +6,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TBF", "TBF\TBF.csproj", "{8
{C8939821-BA5C-4988-A3D0-BF53B74865C7} = {C8939821-BA5C-4988-A3D0-BF53B74865C7}
{EFEC8A31-3022-4DA7-A8F6-16D30A94C3FF} = {EFEC8A31-3022-4DA7-A8F6-16D30A94C3FF}
{0C0A1F4D-1363-4544-A7C5-196C76D26CCA} = {0C0A1F4D-1363-4544-A7C5-196C76D26CCA}
{0F79CA69-9DBC-41F3-A6FC-5A2937365343} = {0F79CA69-9DBC-41F3-A6FC-5A2937365343}
{46E3B0E1-209F-4550-B0DD-D7E2C039B3CE} = {46E3B0E1-209F-4550-B0DD-D7E2C039B3CE}
{5D9B49E3-CDF9-4A27-80B4-58141D0EB0E0} = {5D9B49E3-CDF9-4A27-80B4-58141D0EB0E0}
EndProjectSection

View File

@ -40,9 +40,8 @@ namespace TBF.BenchControl.Dummy.Balance
public float BuoyancyPress { get { return 1.013f; } }
public float BuoyancyHumi { get { return 50.0f; } }
public IOperation TaringOp(ref Boxes.DoubleBox tara)
public IOperation ZeroOp()
{
tara.Val = 0;
return this;
}

View File

@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
using TBF.Boxes;
@ -17,9 +17,8 @@ namespace TBF.BenchControl.GenericDevices
/// <summary>
/// Events: BalanceDone, Error
/// </summary>
/// <param name="result">Reference to a variable for 'tara' in kg</param>
/// <returns>TaringOp instance reference casted to IOperaton</returns>
IOperation TaringOp(ref DoubleBox tara);
/// <returns>ZeroOp instance reference casted to IOperaton</returns>
IOperation ZeroOp();
/// <summary>
/// Events: BalanceDone, Error

View File

@ -297,16 +297,26 @@ namespace TBF.BenchControl.MettlerToledo.Multi
public void StopDevice2() { }
/// <summary>
/// Events: BalanceDone, Error
/// </summary>
/// <param name="result">Reference to a variable for 'tara' in kg</param>
/// <returns>TaringOp instance reference casted to IOperaton</returns>
public IOperation TaringOp(ref DoubleBox tara)
/// <returns>ZeroOp reference</returns>
public IOperation ZeroOp()
{
return new TaringOp(this, ref tara);
return new ZeroOp(this);
}
/// <summary>
/// Events: BalanceDone, Error
/// </summary>
/// <param name="result">Reference to a variable for 'tara' in kg</param>
/// <returns>TaringOp reference</returns>
public IOperation TaringOp(ref DoubleBox tara)
{
return new TaringOp(this, ref tara);
}
/// <summary>
/// Events: BalanceDone, Error
/// </summary>

View File

@ -0,0 +1,68 @@
///
/// Copyright (c) 2015-2020 Sensus Slovensko a.s.
///
using System;
using log4net;
namespace TBF.BenchControl.MettlerToledo.Multi
{
public class ZeroOp : IOperation
{
private static readonly ILog log = LogManager.GetLogger(typeof(ZeroOp));
public override string ToString() { return string.Format("ZeroOp(.,.)"); }
bool done;
/// Set by the constructor
BalanceDev balanceDev;
/// <summary>
/// Events: BalanceDone, Error
/// </summary>
/// <param name="balanceDev">Balance device instance</param>
public ZeroOp(BalanceDev balanceDev)
{
if (balanceDev == null) throw new ArgumentNullException("balanceDev");
this.balanceDev = balanceDev;
log.Debug(this.ToString());
}
/// <summary>Start this operation</summary>
public void Start()
{
done = true;
}
/// <summary>Run this operation</summary>
/// <returns>
/// Event.None
/// Event.BalanceDone
/// Event.Error . . . . . Current.Tick == null
/// </returns>
public Event Run()
{
if (done) return Event.BalanceDone; /// Zero has been done already
if (balanceDev.MsrmntState == MsrmntState.Busy) return Event.Busy;
if (balanceDev.MsrmntState == MsrmntState.Overload)
{
done = true;
return Event.BalanceOverload;
}
if (balanceDev.MsrmntState == MsrmntState.Valid)
{
done = true;
return Event.BalanceDone; /// Zero completed
}
return Event.Busy;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
}
}

View File

@ -519,13 +519,22 @@ namespace TBF.BenchControl.MettlerToledo.Standard
/// <summary>
/// Events: BalanceDone, Error
/// </summary>
/// <param name="result">Reference to a variable for 'tara' in kg</param>
/// <returns>TaringOp instance reference casted to IOperaton</returns>
public IOperation TaringOp(ref DoubleBox tara)
/// <returns>ZeroOp reference</returns>
public IOperation ZeroOp()
{
return new TaringOp(this, ref tara);
return new ZeroOp(this);
}
/// <summary>
/// Events: BalanceDone, Error
/// </summary>
/// <param name="result">Reference to a variable for 'tara' in kg</param>
/// <returns>TaringOp reference</returns>
public IOperation TaringOp(ref DoubleBox tara)
{
return new TaringOp(this, ref tara);
}
/// <summary>
/// Events: BalanceDone, Error
/// </summary>

View File

@ -0,0 +1,74 @@
///
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
using System;
using log4net;
namespace TBF.BenchControl.MettlerToledo.Standard
{
public class ZeroOp : IOperation
{
private static readonly ILog log = LogManager.GetLogger(typeof(ZeroOp));
public override string ToString() { return string.Format("ZeroOp(.,.)"); }
bool done;
/// Set by the constructor
BalanceDev balanceDev;
/// <summary>
/// Events: BalanceDone, Error
/// </summary>
/// <param name="balanceDev">Balance device instance</param>
/// <param name="result">Reference to variable for 'tara' in kg</param>
public ZeroOp(BalanceDev balanceDev)
{
if (balanceDev == null) throw new ArgumentNullException("balanceDev");
this.balanceDev = balanceDev;
log.Debug(this.ToString());
}
/// <summary>Start this operation</summary>
public void Start()
{
log.DebugFormat("{0} - Start()", balanceDev.Name);
done = false;
balanceDev.ZeroWhenStable();
}
/// <summary>Run this operation</summary>
/// <returns>
/// Event.None
/// Event.BalanceDone
/// Event.Error . . . . . Current.Tick == null
/// </returns>
public Event Run()
{
if (done) return Event.BalanceDone; /// Zeroing has been done already
if (balanceDev.MsrmntState == MsrmntState.Busy) return Event.Busy;
if (balanceDev.MsrmntState == MsrmntState.Overload)
{
done = true;
return Event.BalanceOverload;
}
if (balanceDev.MsrmntState == MsrmntState.Valid)
{
done = true;
return Event.BalanceDone; /// Zeroing completed
}
balanceDev.ZeroWhenStable(); /// Failed -> repeat zeroing
return Event.Busy;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
log.DebugFormat("{0} - Stop()", balanceDev.Name);
}
}
}

View File

@ -132,13 +132,10 @@ namespace TBF.BenchControl.Sequences
Bridge.OnActivity(this, Strings.Resetting_scales);
Bridge.Bench2UI(ButtonsEtc.StopBtnEn); /// Resetting scales -> Enable STOP button
DoubleBox tara1 = new DoubleBox(0);
DoubleBox tara2 = new DoubleBox(0);
DoubleBox tara3 = new DoubleBox(0);
State.Create("MainSeq : Reset scales").AddOperation(checkUiOp)
.AddOperation((StateMachine.Tank1 is IScale) ? (StateMachine.Tank1 as IScale).TaringOp(ref tara1) : null)
.AddOperation((StateMachine.Tank2 is IScale) ? (StateMachine.Tank2 as IScale).TaringOp(ref tara2) : null)
.AddOperation((StateMachine.Tank3 is IScale) ? (StateMachine.Tank3 as IScale).TaringOp(ref tara3) : null)
.AddOperation((StateMachine.Tank1 is IScale) ? (StateMachine.Tank1 as IScale).ZeroOp() : null)
.AddOperation((StateMachine.Tank2 is IScale) ? (StateMachine.Tank2 as IScale).ZeroOp() : null)
.AddOperation((StateMachine.Tank3 is IScale) ? (StateMachine.Tank3 as IScale).ZeroOp() : null)
.EnterState();
do
{

View File

@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.1.1492.0")]
[assembly: AssemblyFileVersion("3.1.1492.0")]
[assembly: AssemblyVersion("3.1.1495.0")]
[assembly: AssemblyFileVersion("3.1.1495.0")]

View File

@ -734,6 +734,7 @@
<Compile Include="BenchControl\MettlerToledo\Multi\ReadMassOp.cs" />
<Compile Include="BenchControl\MettlerToledo\Multi\ReadStableMassOp.cs" />
<Compile Include="BenchControl\MettlerToledo\Multi\TaringOp.cs" />
<Compile Include="BenchControl\MettlerToledo\Multi\ZeroOp.cs" />
<Compile Include="BenchControl\MettlerToledo\ReadMassesOp.cs" />
<Compile Include="BenchControl\MettlerToledo\Standard\BalanceCfg.cs" />
<Compile Include="BenchControl\MettlerToledo\Standard\BalanceCfgCtrl.cs">
@ -753,6 +754,7 @@
<Compile Include="BenchControl\MettlerToledo\Standard\ReadStableMassOp.cs" />
<Compile Include="BenchControl\MettlerToledo\Standard\SetUnitsOp.cs" />
<Compile Include="BenchControl\MettlerToledo\Standard\TaringOp.cs" />
<Compile Include="BenchControl\MettlerToledo\Standard\ZeroOp.cs" />
<Compile Include="BenchControl\MettlerToledo\TankDraining.cs" />
<Compile Include="BenchControl\MettlerToledo\WaitTankEmptyOp.cs" />
<Compile Include="BenchControl\MettlerToledo\WaitTankContainsMoreThenOp.cs" />