PumpTandem bug fix : Error handling when one of two pumps was renamed.
This commit is contained in:
@@ -5,6 +5,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Dirichlet.Numerics;
|
using Dirichlet.Numerics;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
using Common;
|
||||||
|
|
||||||
namespace TBF.Rig.BuiltIn.PumpTandem
|
namespace TBF.Rig.BuiltIn.PumpTandem
|
||||||
{
|
{
|
||||||
@@ -15,8 +16,8 @@ namespace TBF.Rig.BuiltIn.PumpTandem
|
|||||||
|
|
||||||
readonly PumpCfg pumpCfg;
|
readonly PumpCfg pumpCfg;
|
||||||
|
|
||||||
readonly GenericDevices.IPump pump1;
|
GenericDevices.IPump pump1;
|
||||||
readonly GenericDevices.IPump pump2;
|
GenericDevices.IPump pump2;
|
||||||
|
|
||||||
GenericDevices.IPumpFM pumpFm1;
|
GenericDevices.IPumpFM pumpFm1;
|
||||||
GenericDevices.IPumpFM pumpFm2;
|
GenericDevices.IPumpFM pumpFm2;
|
||||||
@@ -48,18 +49,18 @@ namespace TBF.Rig.BuiltIn.PumpTandem
|
|||||||
: base(cfg)
|
: base(cfg)
|
||||||
{
|
{
|
||||||
pumpCfg = cfg as PumpCfg;
|
pumpCfg = cfg as PumpCfg;
|
||||||
|
|
||||||
pump1 = TbfComponents.FindComponent(pumpCfg.Pump1, components) as GenericDevices.IPump;
|
|
||||||
if (pump1 == null) throw new Exception("Cannot find component Pump 1");
|
|
||||||
|
|
||||||
pump2 = TbfComponents.FindComponent(pumpCfg.Pump2, components) as GenericDevices.IPump;
|
|
||||||
if (pump2 == null) throw new Exception("Cannot find component Pump 2");
|
|
||||||
|
|
||||||
log.Warn(this.ToString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
|
if (pumpCfg.DebugLevel == DebugMode.Normal)
|
||||||
|
{
|
||||||
|
pump1 = TbfComponents.FindComponent(pumpCfg.Pump1, StateMachine.Components) as GenericDevices.IPump;
|
||||||
|
if (pump1 == null) throw new Exception(string.Format("Cannot find component {0}", pumpCfg.Pump1 != null ? pumpCfg.Pump1 : "<null>"));
|
||||||
|
|
||||||
|
pump2 = TbfComponents.FindComponent(pumpCfg.Pump2, StateMachine.Components) as GenericDevices.IPump;
|
||||||
|
if (pump2 == null) throw new Exception(string.Format("Cannot find component {0}", pumpCfg.Pump2 != null ? pumpCfg.Pump2 : "<null>"));
|
||||||
|
|
||||||
pumpFm1 = pump1 as GenericDevices.IPumpFM;
|
pumpFm1 = pump1 as GenericDevices.IPumpFM;
|
||||||
pumpFm2 = pump2 as GenericDevices.IPumpFM;
|
pumpFm2 = pump2 as GenericDevices.IPumpFM;
|
||||||
|
|
||||||
@@ -72,6 +73,13 @@ namespace TBF.Rig.BuiltIn.PumpTandem
|
|||||||
else if (pump2 is Danfoss.VLT2800.Pump) { mask2 = (pump2 as Danfoss.VLT2800.Pump).Mask; }
|
else if (pump2 is Danfoss.VLT2800.Pump) { mask2 = (pump2 as Danfoss.VLT2800.Pump).Mask; }
|
||||||
else if (pump2 is Modbus.PumpFM.DanfossVLT.Pump) { mask2 = (pump2 as Modbus.PumpFM.DanfossVLT.Pump).Mask; }
|
else if (pump2 is Modbus.PumpFM.DanfossVLT.Pump) { mask2 = (pump2 as Modbus.PumpFM.DanfossVLT.Pump).Mask; }
|
||||||
else { mask2 = 0; }
|
else { mask2 = 0; }
|
||||||
|
|
||||||
|
log.FatalFormat("{0} initialized: {1}", Name, this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log.FatalFormat("{0} simulated: {1}", Name, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user