ControlBoards, IControlBoard iface, Devices, test methods.
This commit is contained in:
@@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using log4net;
|
||||
using Dirichlet.Numerics;
|
||||
using TBF.BenchControl.ControlBoard.Legacy;
|
||||
using TBF.BenchControl.Generic;
|
||||
using TBF.Boxes;
|
||||
using TBF.Resources;
|
||||
@@ -69,7 +70,7 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
{
|
||||
diverterCfg = cfg as DiverterCfg;
|
||||
|
||||
controlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
|
||||
controlBoard = TbfComponents.FindComponent(cfg.ParentName, components) as ControlBoardDev;
|
||||
if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
|
||||
|
||||
if (diverterCfg.BitPosition < 0 || diverterCfg.BitPosition >= 64) throw new ArgumentOutOfRangeException("position");
|
||||
@@ -189,7 +190,7 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
public void Initialize() { }
|
||||
public void RunDeviceBefore()
|
||||
{
|
||||
int adcValue = (int)StateMachine.ControlBoard.AnalogInputRaw(diverterCfg.AdcNr, 0);
|
||||
int adcValue = (int)controlBoard.AnalogInputRaw(diverterCfg.AdcNr, 0);
|
||||
Handlers.OnAdcChanged(this, new CmdResponseArgs(CfgChangeCmd.GetAdc, diverterCfg.BitPosition, adcValue));
|
||||
}
|
||||
public void RunDeviceAfter() { }
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
{
|
||||
foreach (var cmpnt in parent.TbfComponents)
|
||||
{
|
||||
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.ControlBoardFactory)
|
||||
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is ControlBoard.Legacy.ControlBoardFactory)
|
||||
{
|
||||
parentNameComboBox.Items.Add(cmpnt.Name);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
///
|
||||
/// Copyright (c) 2020 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using log4net;
|
||||
using TBF.Boxes;
|
||||
|
||||
namespace TBF.BenchControl.Elde.Diverter
|
||||
{
|
||||
public class ReadDiverterStateOp : IOperation
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(ReadDiverterStateOp));
|
||||
public override string ToString() { return string.Format("ReadDiverterStateOp(div={0}, delay={1})", div.Name, delay); }
|
||||
|
||||
/// Set by the constructor
|
||||
readonly GenericDevices.IDiverter div;
|
||||
readonly int delay;
|
||||
|
||||
int startTime;
|
||||
|
||||
/// <summary>
|
||||
/// Events: FlowInDone, FlowOutDone or Error
|
||||
/// </summary>
|
||||
/// <param name="flowMeter">Flow meter reference</param>
|
||||
/// <param name="flowBox">Reference to the measured flow variable, value is in bar</param>
|
||||
/// <param name="eventDone">Event to be returned by Run() when completed OK</param>
|
||||
public ReadDiverterStateOp(GenericDevices.IDiverter div, int delay)
|
||||
{
|
||||
this.div = div;
|
||||
if (div == null) throw new ArgumentNullException();
|
||||
|
||||
this.delay = delay;
|
||||
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
public ReadDiverterStateOp(GenericDevices.IDiverter div)
|
||||
: this(div, 0)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
startTime = StateMachine.Time;
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
/// <returns> Event.ToTank or Event.ToSink </returns>
|
||||
public Event Run()
|
||||
{
|
||||
if (StateMachine.Time - startTime <= delay)
|
||||
{
|
||||
return Event.None;
|
||||
}
|
||||
return div.State ? Event.ToTank : Event.ToSink;
|
||||
}
|
||||
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop() { }
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
///
|
||||
/// Copyright (c) 2017 Sensus Metering Systems
|
||||
/// Copyright (c) 2017-2020 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using TBF.BenchControl.ControlBoard.Legacy;
|
||||
|
||||
namespace TBF.BenchControl.Elde.Diverter
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user