TankDraining sequence conditions added (MettlerToledo scales).
This commit is contained in:
@@ -22,7 +22,7 @@ namespace TBF.BenchControl.MettlerToledo
|
|||||||
TankClosed,
|
TankClosed,
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TankDraining : ComponentBase, ITankDraining
|
public class TankDraining : ComponentBase, ITankDraining, ISequenceCondition
|
||||||
{
|
{
|
||||||
private static readonly ILog log = LogManager.GetLogger(typeof(TankDraining));
|
private static readonly ILog log = LogManager.GetLogger(typeof(TankDraining));
|
||||||
|
|
||||||
@@ -32,8 +32,9 @@ namespace TBF.BenchControl.MettlerToledo
|
|||||||
private IValve drainValve;
|
private IValve drainValve;
|
||||||
public GenericDevices.IValve DrainValve { get { return drainValve; } }
|
public GenericDevices.IValve DrainValve { get { return drainValve; } }
|
||||||
|
|
||||||
private IOperation openDrainValveOp;
|
private IOperation openTheDrainValveOp;
|
||||||
private IOperation closeDrainValveOp;
|
private IOperation closeTheDrainValveOp;
|
||||||
|
private IOperation waitTankEmptyOp;
|
||||||
|
|
||||||
|
|
||||||
DrainState drainState;
|
DrainState drainState;
|
||||||
@@ -42,7 +43,9 @@ namespace TBF.BenchControl.MettlerToledo
|
|||||||
public TankDraining()
|
public TankDraining()
|
||||||
: base()
|
: base()
|
||||||
{
|
{
|
||||||
CreateConditions(false);
|
openTheDrainValveOp = null;
|
||||||
|
closeTheDrainValveOp = null;
|
||||||
|
waitTankEmptyOp = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TankDraining(Generic.IComponentCfg cfg)
|
public TankDraining(Generic.IComponentCfg cfg)
|
||||||
@@ -50,14 +53,19 @@ namespace TBF.BenchControl.MettlerToledo
|
|||||||
{
|
{
|
||||||
tankDrainingCfg = cfg as GenericDevices.ITankDrainingCfg;
|
tankDrainingCfg = cfg as GenericDevices.ITankDrainingCfg;
|
||||||
if (tankDrainingCfg == null) throw new Exception(string.Format("Cannot create component {0}", cfg.Name));
|
if (tankDrainingCfg == null) throw new Exception(string.Format("Cannot create component {0}", cfg.Name));
|
||||||
CreateConditions(true);
|
|
||||||
|
openTheDrainValveOp = null;
|
||||||
|
closeTheDrainValveOp = null;
|
||||||
|
waitTankEmptyOp = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void Initalize()
|
protected void Initalize()
|
||||||
{
|
{
|
||||||
drainValve = TbfComponents.FindComponent(tankDrainingCfg.DrainValve) as IValve;
|
drainValve = TbfComponents.FindComponent(tankDrainingCfg.DrainValve) as IValve;
|
||||||
openDrainValveOp = new Elde.SetValvesOp(StateMachine.ControlBoard, drainValve, null);
|
|
||||||
closeDrainValveOp = new Elde.SetValvesOp(StateMachine.ControlBoard, null, drainValve);
|
openTheDrainValveOp = new Elde.SetValvesOp(StateMachine.ControlBoard, drainValve, null);
|
||||||
|
closeTheDrainValveOp = new Elde.SetValvesOp(StateMachine.ControlBoard, null, drainValve);
|
||||||
|
waitTankEmptyOp = new WaitTankEmptyOp(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void RunBefore()
|
protected void RunBefore()
|
||||||
@@ -65,16 +73,16 @@ namespace TBF.BenchControl.MettlerToledo
|
|||||||
switch (drainState)
|
switch (drainState)
|
||||||
{
|
{
|
||||||
case DrainState.OpeningDV_Start:
|
case DrainState.OpeningDV_Start:
|
||||||
openDrainValveOp.Start();
|
openTheDrainValveOp.Start();
|
||||||
drainState = DrainState.OpeningDV_Run;
|
drainState = DrainState.OpeningDV_Run;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case DrainState.OpeningDV_Run:
|
case DrainState.OpeningDV_Run:
|
||||||
if (openDrainValveOp.Run() == Event.ValvesSet) drainState = DrainState.OpeningDV_Stop;
|
if (openTheDrainValveOp.Run() == Event.ValvesSet) drainState = DrainState.OpeningDV_Stop;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case DrainState.OpeningDV_Stop:
|
case DrainState.OpeningDV_Stop:
|
||||||
openDrainValveOp.Stop();
|
openTheDrainValveOp.Stop();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case DrainState.Draining:
|
case DrainState.Draining:
|
||||||
@@ -82,16 +90,16 @@ namespace TBF.BenchControl.MettlerToledo
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case DrainState.ClosingDV_Start:
|
case DrainState.ClosingDV_Start:
|
||||||
closeDrainValveOp.Start();
|
closeTheDrainValveOp.Start();
|
||||||
drainState = DrainState.ClosingDV_Run;
|
drainState = DrainState.ClosingDV_Run;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case DrainState.ClosingDV_Run:
|
case DrainState.ClosingDV_Run:
|
||||||
if (closeDrainValveOp.Run() == Event.ValvesSet) drainState = DrainState.ClosingDV_Stop;
|
if (closeTheDrainValveOp.Run() == Event.ValvesSet) drainState = DrainState.ClosingDV_Stop;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case DrainState.ClosingDV_Stop:
|
case DrainState.ClosingDV_Stop:
|
||||||
closeDrainValveOp.Stop();
|
closeTheDrainValveOp.Stop();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -105,52 +113,32 @@ namespace TBF.BenchControl.MettlerToledo
|
|||||||
public virtual string GetName() { return string.Empty; }
|
public virtual string GetName() { return string.Empty; }
|
||||||
public virtual bool IsEmpty() { return false; }
|
public virtual bool IsEmpty() { return false; }
|
||||||
|
|
||||||
///
|
|
||||||
/// ISequenceCondition interface implementation (conditions in transition sequences)
|
|
||||||
///
|
|
||||||
IList<string> sequenceConditionNames;
|
|
||||||
IList<IOperation> sequenceConditions;
|
|
||||||
|
|
||||||
public int ConditionsCount { get { return sequenceConditions != null ? sequenceConditions.Count : 0; } }
|
|
||||||
|
public int ConditionsCount { get { return 3; } }
|
||||||
|
|
||||||
/// Strings are added to the combo-box for transition sequence condition selection
|
/// Strings are added to the combo-box for transition sequence condition selection
|
||||||
public string ConditionName(int i)
|
public string ConditionName(int i)
|
||||||
{
|
{
|
||||||
if (sequenceConditionNames != null && i < sequenceConditionNames.Count && i >= 0)
|
switch (i)
|
||||||
return sequenceConditionNames[i];
|
{
|
||||||
else
|
case 0: return string.Format(Strings._0_open_the_drain_valve, Name);
|
||||||
return string.Empty;
|
case 1: return string.Format(Strings._0_close_the_drain_valve, Name);
|
||||||
|
case 2: return string.Format(Strings._0_wait_until_the_tank_is_empty, Name);
|
||||||
|
default: return string.Empty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Operations are executed as a part of a transition sequence
|
/// Operation to be executed as a part of a transition sequence
|
||||||
public IOperation ConditionOp(int i)
|
public IOperation ConditionOp(int i)
|
||||||
{
|
{
|
||||||
if (sequenceConditions != null && i < sequenceConditions.Count && i >= 0)
|
switch (i)
|
||||||
return sequenceConditions[i];
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClearConditions()
|
|
||||||
{
|
{
|
||||||
sequenceConditionNames = new List<string>();
|
case 0: return openTheDrainValveOp;
|
||||||
sequenceConditions = new List<IOperation>();
|
case 1: return closeTheDrainValveOp;
|
||||||
|
case 2: return waitTankEmptyOp;
|
||||||
|
default: return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddCondition(string conditionName, bool createOperation, IOperation conditionOperation)
|
|
||||||
{
|
|
||||||
sequenceConditionNames.Add(conditionName);
|
|
||||||
if (createOperation) sequenceConditions.Add(conditionOperation);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Create a list of conditions
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="createOps">true = create names and condition operations, false = create names only</param>
|
|
||||||
void CreateConditions(bool createOps)
|
|
||||||
{
|
|
||||||
ClearConditions();
|
|
||||||
AddCondition(string.Format(Strings.Wait_until_0_tank_is_empty, GetName()), createOps, new WaitTankEmptyOp(this));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+27
@@ -60,6 +60,33 @@ namespace TBF.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to {0} - close the drain valve.
|
||||||
|
/// </summary>
|
||||||
|
internal static string _0_close_the_drain_valve {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("_0_close_the_drain_valve", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to {0} - open the drain valve.
|
||||||
|
/// </summary>
|
||||||
|
internal static string _0_open_the_drain_valve {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("_0_open_the_drain_valve", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to {0} - wait until the tank is empty.
|
||||||
|
/// </summary>
|
||||||
|
internal static string _0_wait_until_the_tank_is_empty {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("_0_wait_until_the_tank_is_empty", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to <none>.
|
/// Looks up a localized string similar to <none>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1747,4 +1747,13 @@
|
|||||||
<data name="Close_the_cover" xml:space="preserve">
|
<data name="Close_the_cover" xml:space="preserve">
|
||||||
<value>Close the cover</value>
|
<value>Close the cover</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="_0_close_the_drain_valve" xml:space="preserve">
|
||||||
|
<value>{0} - close the drain valve</value>
|
||||||
|
</data>
|
||||||
|
<data name="_0_open_the_drain_valve" xml:space="preserve">
|
||||||
|
<value>{0} - open the drain valve</value>
|
||||||
|
</data>
|
||||||
|
<data name="_0_wait_until_the_tank_is_empty" xml:space="preserve">
|
||||||
|
<value>{0} - wait until the tank is empty</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
Reference in New Issue
Block a user