BenchControl.Uni.Diverter/FlowMeter/RegReader added, etc. (many changes and refactorization).
This commit is contained in:
@@ -13,9 +13,9 @@ using TBF.BenchControl.GenericDevices;
|
||||
|
||||
namespace TBF.BenchControl.ControlBoard.Legacy
|
||||
{
|
||||
public class ControlBoardDev : ComponentBase, IControlBoard
|
||||
public class CBoard : ComponentBase, IControlBoard
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(ControlBoardDev));
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(CBoard));
|
||||
public override string ToString() { return string.Format("ControlBoard({0})", Cfg.ToString(1)); }
|
||||
|
||||
const int FiltersCount = 8;
|
||||
@@ -333,14 +333,14 @@ namespace TBF.BenchControl.ControlBoard.Legacy
|
||||
}
|
||||
}
|
||||
|
||||
public ControlBoardDev()
|
||||
public CBoard()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public ControlBoardDev(Generic.IComponentCfg cfg)
|
||||
public CBoard(Generic.IComponentCfg cfg)
|
||||
: base(cfg)
|
||||
{
|
||||
controlBoardCfg = cfg as ControlBoardCfg;
|
||||
|
||||
@@ -14,9 +14,9 @@ namespace TBF.BenchControl.ControlBoard.Legacy
|
||||
/// <summary>Max. number of components of this class in the system</summary>
|
||||
public int MaxCount { get { return 1; } }
|
||||
|
||||
public IComponent DummyComponent() { return new ControlBoardDev(); }
|
||||
public IComponent DummyComponent() { return new CBoard(); }
|
||||
|
||||
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new ControlBoardDev(cfg); }
|
||||
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new CBoard(cfg); }
|
||||
|
||||
public IComponentCfg DefaultConfig() { return new ControlBoardCfg(this); }
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace TBF.BenchControl.ControlBoard.Legacy
|
||||
|
||||
public IComponent ComponentFromCmpntCfg(IComponentCfg config, IList<Generic.IComponent> components)
|
||||
{
|
||||
return new ControlBoardDev((ControlBoardCfg)config);
|
||||
return new CBoard((ControlBoardCfg)config);
|
||||
}
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
|
||||
@@ -32,6 +32,6 @@ namespace TBF.BenchControl.ControlBoard.Legacy
|
||||
return ComponentCfgBase.CreateFromDbEntity(ControlBoardCfg.Serializer, component, this);
|
||||
}
|
||||
|
||||
public void ResetStaticProperties() { ControlBoardDev.ResetStaticProperties(); }
|
||||
public void ResetStaticProperties() { CBoard.ResetStaticProperties(); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace TBF.BenchControl.ControlBoard.Legacy
|
||||
public override string ToString() { return string.Format("ExecuteCommandOp( command={0}, testMethod={1} )", commandOnStartOp, testMethod); }
|
||||
|
||||
/// Set by the constructor
|
||||
readonly ControlBoardDev controlBoard;
|
||||
readonly CBoard controlBoard;
|
||||
readonly Command commandOnStartOp;
|
||||
readonly Command commandOnStopOp;
|
||||
readonly TestMethods testMethod;
|
||||
@@ -40,7 +40,7 @@ namespace TBF.BenchControl.ControlBoard.Legacy
|
||||
/// <param name="testMethod">Test method</param>
|
||||
/// <param name="refPulses">Test duration in number of reference flowmeter pulses</param>
|
||||
/// <param name="filterConstant">Specifies filter for watermeter pulses</param>
|
||||
public ExecuteCommandOp(ControlBoardDev controlBoard, Command commandOnStartOp, Command commandOnStopOp, TestMethods testMethod)
|
||||
public ExecuteCommandOp(CBoard controlBoard, Command commandOnStartOp, Command commandOnStopOp, TestMethods testMethod)
|
||||
{
|
||||
if (controlBoard == null) throw new ArgumentNullException("controlBoardDev");
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace TBF.BenchControl.ControlBoard.Legacy
|
||||
public override string ToString() { return string.Format("QueryMeasurementEndOp()"); }
|
||||
|
||||
/// Set by the constructor
|
||||
readonly ControlBoardDev controlBoard;
|
||||
readonly CBoard controlBoard;
|
||||
|
||||
bool done;
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace TBF.BenchControl.ControlBoard.Legacy
|
||||
/// Events: MeasurementCompleted
|
||||
/// </summary>
|
||||
/// <param name="eventDone">Event to be returned by Run() when completed OK</param>
|
||||
public QueryMeasurementEndOp(ControlBoardDev controlBoardDev)
|
||||
public QueryMeasurementEndOp(CBoard controlBoardDev)
|
||||
{
|
||||
if (controlBoardDev == null) throw new ArgumentNullException("controlBoardDev");
|
||||
this.controlBoard = controlBoardDev;
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace TBF.BenchControl.ControlBoard.Legacy
|
||||
float[] samples;
|
||||
|
||||
/// Set by the constructor
|
||||
readonly ControlBoardDev controlBoard;
|
||||
readonly CBoard controlBoard;
|
||||
readonly GenericDevices.IDiverter div;
|
||||
readonly bool toTank;
|
||||
readonly int runsCountWhenSendingCmd;
|
||||
@@ -43,7 +43,7 @@ namespace TBF.BenchControl.ControlBoard.Legacy
|
||||
/// <param name="method">Test method</param>
|
||||
/// <param name="refPulses">Test duration in number of reference flowmeter pulses</param>
|
||||
/// <param name="filterConstant">Specifies filter for watermeter pulses</param>
|
||||
public ReadDiverterTransitionOp(ControlBoardDev controlBoard, GenericDevices.IDiverter div, int runsCountWhenSendingCmd, int runsCountWhenReadingDiv, bool toTank,
|
||||
public ReadDiverterTransitionOp(CBoard controlBoard, GenericDevices.IDiverter div, int runsCountWhenSendingCmd, int runsCountWhenReadingDiv, bool toTank,
|
||||
Sequences.Statistics plotter, int batchNr, string testName, int repetition)
|
||||
{
|
||||
if (controlBoard == null) throw new ArgumentNullException("controlBoardDev");
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace TBF.BenchControl.ControlBoard.Legacy
|
||||
|
||||
/// Set by the constructor
|
||||
readonly GenericDevices.IFlowMeter flowMeter;
|
||||
readonly ControlBoardDev controlBoard;
|
||||
readonly CBoard controlBoard;
|
||||
readonly DoubleBox flowBox;
|
||||
readonly Event eventDone;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace TBF.BenchControl.ControlBoard.Legacy
|
||||
/// <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 ReadFlowOp(GenericDevices.IFlowMeter flowMeter, ControlBoardDev controlBoard, ref DoubleBox flowBox, Event eventDone)
|
||||
public ReadFlowOp(GenericDevices.IFlowMeter flowMeter, CBoard controlBoard, ref DoubleBox flowBox, Event eventDone)
|
||||
{
|
||||
if (flowMeter == null || controlBoard == null) throw new ArgumentNullException();
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace TBF.BenchControl.ControlBoard.Legacy
|
||||
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
public ReadFlowOp(GenericDevices.IFlowMeter flowMeter, ControlBoardDev controlBoard, ref DoubleBox flowBox)
|
||||
public ReadFlowOp(GenericDevices.IFlowMeter flowMeter, CBoard controlBoard, ref DoubleBox flowBox)
|
||||
: this(flowMeter, controlBoard, ref flowBox, Event.FlowMeasurementDone)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace TBF.BenchControl.ControlBoard.Legacy
|
||||
public override string ToString() { return string.Format("StartMeasurementOp(ref={0},pulses={1})", flowMeterNr, totalRefPulses); }
|
||||
|
||||
/// Set by the constructor
|
||||
readonly ControlBoardDev controlBoard;
|
||||
readonly CBoard controlBoard;
|
||||
readonly IRegulValve regulValve;
|
||||
readonly int regulValveNr;
|
||||
readonly int regulValveStableTime;
|
||||
@@ -54,7 +54,7 @@ namespace TBF.BenchControl.ControlBoard.Legacy
|
||||
/// <param name="method">Test method</param>
|
||||
/// <param name="totalRefPulses">Test duration in number of reference flowmeter pulses</param>
|
||||
/// <param name="filterConstant">Specifies filter for watermeter pulses</param>
|
||||
public StartMeasurementOp(ControlBoardDev controlBoard, OutputPath outputPath, TestMethods method,
|
||||
public StartMeasurementOp(CBoard controlBoard, OutputPath outputPath, TestMethods method,
|
||||
double requiredFlowLo, double requiredFlowHi, int refPulses, int delayBeforeFlowRegulation = 0)
|
||||
: this(controlBoard, outputPath, method, requiredFlowLo, requiredFlowHi, refPulses, refPulses, delayBeforeFlowRegulation)
|
||||
{
|
||||
@@ -69,7 +69,7 @@ namespace TBF.BenchControl.ControlBoard.Legacy
|
||||
/// <param name="method">Test method</param>
|
||||
/// <param name="refPulses">Test duration in number of reference flowmeter pulses</param>
|
||||
/// <param name="filterConstant">Specifies filter for watermeter pulses</param>
|
||||
public StartMeasurementOp(ControlBoardDev controlBoard, OutputPath outputPath, TestMethods method,
|
||||
public StartMeasurementOp(CBoard controlBoard, OutputPath outputPath, TestMethods method,
|
||||
double requiredFlowLo, double requiredFlowHi, int totalRefPulses, int massRefPulses, int delayBeforeFlowRegulation = 0)
|
||||
{
|
||||
if (controlBoard == null) throw new ArgumentNullException("controlBoardDev");
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace TBF.BenchControl.ControlBoard.Legacy
|
||||
public override string ToString() { return string.Format("StopFlowRegulationOp(.)"); }
|
||||
|
||||
/// Set by the constructor
|
||||
readonly ControlBoardDev controlBoard;
|
||||
readonly CBoard controlBoard;
|
||||
readonly int flowMeterNr;
|
||||
|
||||
/// <summary>
|
||||
@@ -20,7 +20,7 @@ namespace TBF.BenchControl.ControlBoard.Legacy
|
||||
/// Events: None or PreviousStopped
|
||||
/// </summary>
|
||||
/// <param name="controlBoardDev">Control board component reference</param>
|
||||
public StopFlowRegulationOp(ControlBoardDev controlBoardDev)
|
||||
public StopFlowRegulationOp(CBoard controlBoardDev)
|
||||
{
|
||||
if (controlBoardDev == null) throw new ArgumentNullException("controlBoardDev");
|
||||
this.controlBoard = controlBoardDev;
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace TBF.BenchControl.ControlBoard.Legacy
|
||||
public override string ToString() { return string.Format("StopPreviousOp(.)"); }
|
||||
|
||||
/// Set by the constructor
|
||||
readonly ControlBoardDev controlBoard;
|
||||
readonly CBoard controlBoard;
|
||||
|
||||
///
|
||||
/// Internal states of this operation
|
||||
@@ -31,7 +31,7 @@ namespace TBF.BenchControl.ControlBoard.Legacy
|
||||
/// Events: None or PreviousStopped
|
||||
/// </summary>
|
||||
/// <param name="controlBoardDev">Control board component reference</param>
|
||||
public StopPreviousOp(ControlBoardDev controlBoardDev)
|
||||
public StopPreviousOp(CBoard controlBoardDev)
|
||||
{
|
||||
if (controlBoardDev == null) throw new ArgumentNullException("controlBoardDev");
|
||||
this.controlBoard = controlBoardDev;
|
||||
|
||||
@@ -1,182 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2020 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using log4net;
|
||||
using Config.Entities;
|
||||
using Dirichlet.Numerics;
|
||||
using TBF.BenchControl.Generic;
|
||||
using TBF.BenchControl.GenericDevices;
|
||||
|
||||
namespace TBF.BenchControl.ControlBoard.New
|
||||
{
|
||||
public class CBoard : ComponentBase, IControlBoard
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(CBoard));
|
||||
public override string ToString() { return string.Format("CBoard({0})", Cfg.ToString(1)); }
|
||||
|
||||
readonly CBoardCfg cBoardCfg;
|
||||
|
||||
public OutputPath Devices
|
||||
{
|
||||
set { devices = value; }
|
||||
get { return devices; }
|
||||
}
|
||||
OutputPath devices;
|
||||
|
||||
public CBoard()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public CBoard(Generic.IComponentCfg cfg)
|
||||
: base(cfg)
|
||||
{
|
||||
cBoardCfg = cfg as CBoardCfg;
|
||||
|
||||
}
|
||||
|
||||
public void SpecifyInvertedValves(UInt128 valvesToInvert)
|
||||
{
|
||||
this.valvesToInvert = valvesToInvert;
|
||||
this.benchModelRoute = valvesToInvert;
|
||||
}
|
||||
|
||||
|
||||
public void Initialize() { }
|
||||
public void RunDeviceBefore() { }
|
||||
public void RunDeviceAfter() { }
|
||||
public void StopDevice() { }
|
||||
public void StopDevice2() { }
|
||||
|
||||
|
||||
///
|
||||
/// IControlBoard interface
|
||||
///
|
||||
|
||||
/// <summary>
|
||||
/// Route: 128-bit word representing the current state of all valves and pumps
|
||||
/// </summary>
|
||||
public UInt128 Route { get { return benchModelRoute; } }
|
||||
UInt128 benchModelRoute;
|
||||
UInt128 valvesToInvert; /// Route = valesToInvert ^ RequiredRouteWithoutInvertedVlaves
|
||||
readonly UInt128 routeMask; /// This mask masks out virtual valves, routeMask is set in the constructor
|
||||
|
||||
public UInt64 DigitalInputs { get { return 0; } }
|
||||
|
||||
public double RefFrequency { get { return 0; } }
|
||||
public double RefFlow { get { return 0; } }
|
||||
|
||||
///
|
||||
/// Last test result
|
||||
///
|
||||
public int RefPulses { get { return 0; } }
|
||||
public double TestTime { get { return 1.0; } }
|
||||
public int RefPulsesWM(int wmNr1) { return (wmNr1 > 0 && wmNr1 <= Config.Data.WMsCount) ? 0 : 0; }
|
||||
public int PulsesWM(int wmNr1) { return (wmNr1 > 0 && wmNr1 <= Config.Data.WMsCount) ? 0 : 0; }
|
||||
public double TestTimeWM(int wmNr1) { return (wmNr1 > 0 && wmNr1 <= Config.Data.WMsCount) ? 1.0 : 1.0; }
|
||||
|
||||
|
||||
public void UpdateUI(string sParam, int iParam, double value) { }
|
||||
public void ClearProcessValues() { }
|
||||
|
||||
public UInt128 SetValves(UInt128 valvesToOpen, UInt128 valvesToClose, IList<BuiltIn.ValveEx.Valve> extendedValves)
|
||||
{
|
||||
return routeMask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Open one valve and/or close one valve.
|
||||
/// Events: ValvesSet
|
||||
/// </summary>
|
||||
/// <param name="valveOpen">Valve to be opened</param>
|
||||
/// <param name="valveClose">Valve to be closed</param>
|
||||
/// <returns>Created operation</returns>
|
||||
public IOperation SetValvesOp(IValve valveOpen, IValve valveClose)
|
||||
{
|
||||
return new BuiltIn.SetValvesOp(this, valveOpen, valveClose);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Open and/or close multiple valves.
|
||||
/// Events: ValvesSet
|
||||
/// </summary>
|
||||
/// <param name="valvesOpen">A list of valves to be opened</param>
|
||||
/// <param name="valvesClose">A list of valves to be closed</param>
|
||||
/// <returns>Created operation</returns>
|
||||
public IOperation SetValvesOp(IList<IValve> valvesOpen, IList<IValve> valvesClose)
|
||||
{
|
||||
return new BuiltIn.SetValvesOp(this, valvesOpen, valvesClose);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Open start/stop valve.
|
||||
/// Events: ValvesSet, ValvesBusy, Error
|
||||
/// </summary>
|
||||
/// <returns>Created operation</returns>
|
||||
public IOperation OpenStartValveOp()
|
||||
{
|
||||
return new BuiltIn.SetValvesOp(this, true, devices);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Close start/stop valve.
|
||||
/// Events: ValvesSet, ValvesBusy, Error
|
||||
/// </summary>
|
||||
/// <returns>Created operation</returns>
|
||||
public IOperation CloseStartValveOp()
|
||||
{
|
||||
return new BuiltIn.SetValvesOp(this, false, devices);
|
||||
}
|
||||
|
||||
public float ValveOpenCloseTime { get { return 0.1f; } }
|
||||
|
||||
|
||||
public IOperation SetFlowOp(double reqrdFlowLo, double reqrdFlowHi, TBF.Boxes.DoubleBox measuredFlow, int timeout)
|
||||
{
|
||||
return null; /// TODO
|
||||
}
|
||||
|
||||
public IOperation StopFlowRegulationOp()
|
||||
{
|
||||
return null; /// TODO
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start a test, Events: MeasurementStarted
|
||||
/// </summary>
|
||||
/// <param name="iParam">Int32 parameter 1</param>
|
||||
/// <param name="dParam1">Double parameter 1 (alternative lower flow limit)</param>
|
||||
/// <param name="dParam2">Double parameter 2 (alternative upper flow limit)</param>
|
||||
/// <returns>Operation</returns>
|
||||
public IOperation StartTestOp(Test test, int iParam = 0, double dParam1 = 0, double dParam2 = 0)
|
||||
{
|
||||
return null; /// TODO
|
||||
}
|
||||
|
||||
public IOperation QueryMeasurementEndOp()
|
||||
{
|
||||
return null; /// TODO
|
||||
}
|
||||
|
||||
public IOperation StopMeasurementOp()
|
||||
{
|
||||
return null; /// TODO
|
||||
}
|
||||
|
||||
public IOperation ReadDiverterTransitionOp(bool isStart, Sequences.Statistics plotter, int batchNr, string testName, int repetition)
|
||||
{
|
||||
return null; /// TODO
|
||||
}
|
||||
|
||||
public IOperation StopPreviousOp()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2020 Sensus Slovensko a.s.
|
||||
///
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Serialization;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.ControlBoard.New
|
||||
{
|
||||
public class CBoardCfg : ComponentCfgBase, IComponentCfg
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(CBoardCfg) })[0];
|
||||
public override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
public IComponentCfgCtrl GetControl() { return new CBoardCfgCtrl(); }
|
||||
|
||||
///
|
||||
/// Serialized parameters
|
||||
///
|
||||
public int ComPortNr;
|
||||
public int VirtualValvesRangeLo;
|
||||
public int VirtualValvesRangeHi;
|
||||
|
||||
/// Private parameterless constructor invoked by all other (public) constructors
|
||||
CBoardCfg()
|
||||
{
|
||||
Name = "CB";
|
||||
ParentName = string.Empty;
|
||||
ComPortNr = 1;
|
||||
VirtualValvesRangeLo = 50;
|
||||
VirtualValvesRangeHi = 59;
|
||||
}
|
||||
|
||||
public CBoardCfg(IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
this.Factory = factory;
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("Name={0}, Com{1}, VVRangeLo={2}, VVRangeHi={3}", Name, ComPortNr, VirtualValvesRangeLo, VirtualValvesRangeHi);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,155 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2020 Sensus Slovensko a.s.
|
||||
///
|
||||
namespace TBF.BenchControl.ControlBoard.New
|
||||
{
|
||||
partial class CBoardCfgCtrl
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.comPortNrLabel = new System.Windows.Forms.Label();
|
||||
this.comPortNrTextBox = new System.Windows.Forms.TextBox();
|
||||
this.classNameLabel = new System.Windows.Forms.Label();
|
||||
this.nameLabel = new System.Windows.Forms.Label();
|
||||
this.nameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.vValveRangeLoTextBox = new System.Windows.Forms.TextBox();
|
||||
this.vValveRangeLoLabel = new System.Windows.Forms.Label();
|
||||
this.vValveRangeHiTextBox = new System.Windows.Forms.TextBox();
|
||||
this.vValveRangeHiLabel = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// comPortNrLabel
|
||||
//
|
||||
this.comPortNrLabel.AutoSize = true;
|
||||
this.comPortNrLabel.Location = new System.Drawing.Point(42, 85);
|
||||
this.comPortNrLabel.Name = "comPortNrLabel";
|
||||
this.comPortNrLabel.Size = new System.Drawing.Size(95, 13);
|
||||
this.comPortNrLabel.TabIndex = 0;
|
||||
this.comPortNrLabel.Text = "Serial port number:";
|
||||
//
|
||||
// comPortNrTextBox
|
||||
//
|
||||
this.comPortNrTextBox.Enabled = false;
|
||||
this.comPortNrTextBox.Location = new System.Drawing.Point(166, 82);
|
||||
this.comPortNrTextBox.Name = "comPortNrTextBox";
|
||||
this.comPortNrTextBox.Size = new System.Drawing.Size(80, 20);
|
||||
this.comPortNrTextBox.TabIndex = 1;
|
||||
//
|
||||
// classNameLabel
|
||||
//
|
||||
this.classNameLabel.AutoSize = true;
|
||||
this.classNameLabel.Location = new System.Drawing.Point(163, 26);
|
||||
this.classNameLabel.Name = "classNameLabel";
|
||||
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
|
||||
this.classNameLabel.TabIndex = 2;
|
||||
this.classNameLabel.Text = "ComonentName";
|
||||
//
|
||||
// nameLabel
|
||||
//
|
||||
this.nameLabel.AutoSize = true;
|
||||
this.nameLabel.Location = new System.Drawing.Point(42, 60);
|
||||
this.nameLabel.Name = "nameLabel";
|
||||
this.nameLabel.Size = new System.Drawing.Size(35, 13);
|
||||
this.nameLabel.TabIndex = 3;
|
||||
this.nameLabel.Text = "Name";
|
||||
//
|
||||
// nameTextBox
|
||||
//
|
||||
this.nameTextBox.Enabled = false;
|
||||
this.nameTextBox.Location = new System.Drawing.Point(166, 57);
|
||||
this.nameTextBox.Name = "nameTextBox";
|
||||
this.nameTextBox.Size = new System.Drawing.Size(80, 20);
|
||||
this.nameTextBox.TabIndex = 4;
|
||||
//
|
||||
// vValveRangeLoTextBox
|
||||
//
|
||||
this.vValveRangeLoTextBox.Enabled = false;
|
||||
this.vValveRangeLoTextBox.Location = new System.Drawing.Point(166, 107);
|
||||
this.vValveRangeLoTextBox.Name = "vValveRangeLoTextBox";
|
||||
this.vValveRangeLoTextBox.Size = new System.Drawing.Size(80, 20);
|
||||
this.vValveRangeLoTextBox.TabIndex = 6;
|
||||
//
|
||||
// vValveRangeLoLabel
|
||||
//
|
||||
this.vValveRangeLoLabel.AutoSize = true;
|
||||
this.vValveRangeLoLabel.Location = new System.Drawing.Point(42, 110);
|
||||
this.vValveRangeLoLabel.Name = "vValveRangeLoLabel";
|
||||
this.vValveRangeLoLabel.Size = new System.Drawing.Size(118, 13);
|
||||
this.vValveRangeLoLabel.TabIndex = 5;
|
||||
this.vValveRangeLoLabel.Text = "Virtual valves range Lo:";
|
||||
//
|
||||
// vValveRangeHiTextBox
|
||||
//
|
||||
this.vValveRangeHiTextBox.Enabled = false;
|
||||
this.vValveRangeHiTextBox.Location = new System.Drawing.Point(166, 132);
|
||||
this.vValveRangeHiTextBox.Name = "vValveRangeHiTextBox";
|
||||
this.vValveRangeHiTextBox.Size = new System.Drawing.Size(80, 20);
|
||||
this.vValveRangeHiTextBox.TabIndex = 8;
|
||||
//
|
||||
// vValveRangeHiLabel
|
||||
//
|
||||
this.vValveRangeHiLabel.AutoSize = true;
|
||||
this.vValveRangeHiLabel.Location = new System.Drawing.Point(42, 135);
|
||||
this.vValveRangeHiLabel.Name = "vValveRangeHiLabel";
|
||||
this.vValveRangeHiLabel.Size = new System.Drawing.Size(116, 13);
|
||||
this.vValveRangeHiLabel.TabIndex = 7;
|
||||
this.vValveRangeHiLabel.Text = "Virtual valves range Hi:";
|
||||
//
|
||||
// ControlBoardCfgCtrl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.vValveRangeHiTextBox);
|
||||
this.Controls.Add(this.vValveRangeHiLabel);
|
||||
this.Controls.Add(this.vValveRangeLoTextBox);
|
||||
this.Controls.Add(this.vValveRangeLoLabel);
|
||||
this.Controls.Add(this.nameTextBox);
|
||||
this.Controls.Add(this.nameLabel);
|
||||
this.Controls.Add(this.classNameLabel);
|
||||
this.Controls.Add(this.comPortNrTextBox);
|
||||
this.Controls.Add(this.comPortNrLabel);
|
||||
this.Name = "ControlBoardCfgCtrl";
|
||||
this.Size = new System.Drawing.Size(300, 200);
|
||||
this.Load += new System.EventHandler(this.ControlBoardCfgCtrl_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label comPortNrLabel;
|
||||
private System.Windows.Forms.TextBox comPortNrTextBox;
|
||||
private System.Windows.Forms.Label classNameLabel;
|
||||
private System.Windows.Forms.Label nameLabel;
|
||||
private System.Windows.Forms.TextBox nameTextBox;
|
||||
private System.Windows.Forms.TextBox vValveRangeLoTextBox;
|
||||
private System.Windows.Forms.Label vValveRangeLoLabel;
|
||||
private System.Windows.Forms.TextBox vValveRangeHiTextBox;
|
||||
private System.Windows.Forms.Label vValveRangeHiLabel;
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2020 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using Config.Entities;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.ControlBoard.New
|
||||
{
|
||||
public partial class CBoardCfgCtrl : UserControl, IComponentCfgCtrl
|
||||
{
|
||||
public bool ShowMore { get { return false; } }
|
||||
|
||||
CBoardCfg config;
|
||||
public IComponentCfg Config
|
||||
{
|
||||
get { return config as IComponentCfg; }
|
||||
set
|
||||
{
|
||||
config = value as CBoardCfg;
|
||||
Redraw();
|
||||
}
|
||||
}
|
||||
|
||||
public CBoardCfgCtrl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void ControlBoardCfgCtrl_Load(object sender, EventArgs e)
|
||||
{
|
||||
Redraw();
|
||||
}
|
||||
|
||||
public void Closing()
|
||||
{
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
|
||||
classNameLabel.Text = config.Factory.ClassName;
|
||||
nameTextBox.Text = config.Name;
|
||||
comPortNrTextBox.Text = config.ComPortNr.ToString();
|
||||
vValveRangeLoTextBox.Text = config.VirtualValvesRangeLo.ToString();
|
||||
vValveRangeHiTextBox.Text = config.VirtualValvesRangeHi.ToString();
|
||||
}
|
||||
|
||||
public void Unlock()
|
||||
{
|
||||
nameTextBox.Enabled = true;
|
||||
comPortNrTextBox.Enabled = true;
|
||||
vValveRangeLoTextBox.Enabled = true;
|
||||
vValveRangeHiTextBox.Enabled = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify current user controls for validity.
|
||||
/// Called when user wants to close/save the configuration.
|
||||
/// </summary>
|
||||
/// <returns>See VerifyFlags</returns>
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
||||
|
||||
int dummy;
|
||||
if (!int.TryParse(comPortNrTextBox.Text, out dummy) || dummy <= 0 || dummy > 999)
|
||||
{
|
||||
message += "Control board serial port number is invalid";
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
}
|
||||
if (!int.TryParse(vValveRangeLoTextBox.Text, out dummy) || dummy < 0 || dummy > 63)
|
||||
{
|
||||
message += "Virtual valves range Lo is invalid";
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
}
|
||||
if (!int.TryParse(vValveRangeHiTextBox.Text, out dummy) || dummy < 0 || dummy > 63)
|
||||
{
|
||||
message += "Virtual valves range Hi is invalid";
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save settings to the configuration class.
|
||||
/// </summary>
|
||||
public CfgUpdateFlags UpdateCfg()
|
||||
{
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd;
|
||||
|
||||
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
|
||||
|
||||
this.Name = nameTextBox.Text;
|
||||
this.config.ComPortNr = int.Parse(comPortNrTextBox.Text);
|
||||
this.config.VirtualValvesRangeLo = int.Parse(vValveRangeLoTextBox.Text);
|
||||
this.config.VirtualValvesRangeHi = int.Parse(vValveRangeHiTextBox.Text);
|
||||
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -1,37 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2020 Sensus Slovensko a.s.
|
||||
///
|
||||
using System.Collections.Generic;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.ControlBoard.New
|
||||
{
|
||||
public class CBoardFactory : IComponentFactory
|
||||
{
|
||||
public string ClassName { get { return this.GetType().Namespace.Substring(17); } }
|
||||
public override string ToString() { return ClassName; }
|
||||
|
||||
/// <summary>Max. number of components of this class in the system</summary>
|
||||
public int MaxCount { get { return 1; } }
|
||||
|
||||
public IComponent DummyComponent() { return new CBoard(); }
|
||||
|
||||
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new CBoard(cfg); }
|
||||
|
||||
public IComponentCfg DefaultConfig() { return new CBoardCfg(this); }
|
||||
|
||||
public IComponentCfgCtrl CreateCfgCtrl() { return new CBoardCfgCtrl(); }
|
||||
|
||||
public IComponent ComponentFromCmpntCfg(IComponentCfg config, IList<Generic.IComponent> components)
|
||||
{
|
||||
return new CBoard((CBoardCfg)config);
|
||||
}
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
|
||||
{
|
||||
return ComponentCfgBase.CreateFromDbEntity(CBoardCfg.Serializer, component, this);
|
||||
}
|
||||
|
||||
public void ResetStaticProperties() { }
|
||||
}
|
||||
}
|
||||
@@ -39,20 +39,32 @@ namespace TBF.BenchControl.ControlBoard.Uni
|
||||
Queue<IOutputMessage> msgQueue;
|
||||
|
||||
/// Received data
|
||||
GeneralData generalData;
|
||||
public GeneralData Data;
|
||||
DivTransitionData divTransitionData;
|
||||
ScopeAnalyzerData scopeAnalyzerData;
|
||||
SwitchCountersData switchCounterData;
|
||||
|
||||
|
||||
UInt128 benchModelRoute;
|
||||
public UInt128 Route { set; get; } /// State of valves, test bench route
|
||||
///
|
||||
public UInt64 DigitalInputs { set; get; } /// Inputs
|
||||
|
||||
public UInt64 State { get { return Data.State; } } /// Control board state
|
||||
public UInt64 DigitalInputs { get { return Data.Vstupy; } } /// Digital inputs
|
||||
public UInt128 Route { get { return Data.Vystupy; } } /// Test bench route: states of valves
|
||||
|
||||
public Int16 AnalogInput(int channel)
|
||||
{
|
||||
if (Data.AnalogInput != null && channel >= 0 && channel < Data.AnalogInput.Length)
|
||||
{
|
||||
return Data.AnalogInput[channel];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// Values valid during a test
|
||||
public double RefFrequency { set; get; }
|
||||
public double RefFlow { set; get; }
|
||||
public double RefFrequency { get { return Data.ReferenceFreq[0]; } }
|
||||
|
||||
public double RefFlow
|
||||
{
|
||||
get { return (Devices != null && Devices.FlowMeter != null) ? Devices.FlowMeter.ReadFlow() : 0.0; }
|
||||
}
|
||||
|
||||
/// Last test results
|
||||
public double TestTime { set; get; }
|
||||
@@ -91,7 +103,7 @@ namespace TBF.BenchControl.ControlBoard.Uni
|
||||
#endif
|
||||
cBoardCfg = cfg as CBoardCfg;
|
||||
|
||||
generalData = new GeneralData();
|
||||
Data = new GeneralData();
|
||||
divTransitionData = null;
|
||||
scopeAnalyzerData = null;
|
||||
switchCounterData = null;
|
||||
@@ -114,7 +126,6 @@ namespace TBF.BenchControl.ControlBoard.Uni
|
||||
public void SpecifyInvertedValves(UInt128 valvesToInvert)
|
||||
{
|
||||
this.valvesToInvert = valvesToInvert;
|
||||
this.benchModelRoute = valvesToInvert;
|
||||
}
|
||||
|
||||
#region IDevice interface
|
||||
@@ -185,7 +196,7 @@ namespace TBF.BenchControl.ControlBoard.Uni
|
||||
else if (GeneralData.FrameFitsData(rcvdData, cumulativeSums, rcvdBytesCount, offset))
|
||||
{
|
||||
/// Regular data received
|
||||
generalData.UpdateData(rcvdData, offset);
|
||||
Data.UpdateData(rcvdData, offset);
|
||||
string s = Telegram.LogTelegram("General data ", rcvdData, offset, GeneralData.MessageLen);
|
||||
Debug.WriteLine(s);
|
||||
log.Debug(s);
|
||||
@@ -399,5 +410,17 @@ namespace TBF.BenchControl.ControlBoard.Uni
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void DiverterToTank(int divNr1)
|
||||
{
|
||||
}
|
||||
|
||||
public void DiverterToSink(int divNr1)
|
||||
{
|
||||
}
|
||||
|
||||
public void ReadDiverterTransition(int divNr1)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ namespace TBF.BenchControl.ControlBoard.Uni
|
||||
public void InitializeAll()
|
||||
{
|
||||
ComPortNr = 1;
|
||||
VirtValvesRangeLo = 50;
|
||||
VirtValvesRangeHi = 59;
|
||||
VirtValvesRangeLo = 90;
|
||||
VirtValvesRangeHi = 99;
|
||||
}
|
||||
|
||||
string[] paramNames = new string[]
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace TBF.BenchControl.ControlBoard.Uni
|
||||
public enum StatusP : ulong
|
||||
{
|
||||
/// byte 0
|
||||
FlowmtrIdMask = 0x7, /// bits 0,1,2
|
||||
FlowmtrNrMask = 0x7, /// bits 0,1,2
|
||||
TestInProgress = 0x8, /// bit 3
|
||||
TestCompleted = 0x10, /// bit 4
|
||||
ReadingCounters = 0x20, /// bit 5
|
||||
@@ -44,6 +44,11 @@ namespace TBF.BenchControl.ControlBoard.Uni
|
||||
TimeoutOccured = 0x100000000, /// bit 32 (after 40s without communication)
|
||||
MeretAddresses = 0x200000000, /// bit 33
|
||||
ScopeBufferFull = 0x400000000, /// bit 34
|
||||
/// byte 5
|
||||
/// byte 6
|
||||
Flowmtr1Active = 0x1000000000000, /// bit 48
|
||||
Flowmtr2Active = 0x2000000000000, /// bit 49
|
||||
Flowmtr3Active = 0x4000000000000, /// bit 50
|
||||
}
|
||||
|
||||
public enum Command : byte
|
||||
@@ -67,15 +72,26 @@ namespace TBF.BenchControl.ControlBoard.Uni
|
||||
CalibrationMode = 128,
|
||||
}
|
||||
|
||||
public enum StopParam : byte
|
||||
public enum StopDevs : byte
|
||||
{
|
||||
StopEtalon = 1,
|
||||
StopDiverter = 2,
|
||||
StopDirectGate = 8,
|
||||
StopTimer = 16,
|
||||
StartStopMethod = 32,
|
||||
None = 0,
|
||||
Reference = 0x01, /// bit 0
|
||||
Diverter = 0x02, /// bit 1
|
||||
GatePulse = 0x08, /// bit 3
|
||||
TimeMeasurement = 0x10, /// bit 4
|
||||
BypassDevCoupled2Div = 0x20, /// bit 5
|
||||
RegValveRegulation = 0x80, /// bit 7
|
||||
All = 0xFF,
|
||||
}
|
||||
|
||||
public enum TestMethods
|
||||
{
|
||||
Diverter = 0x01, /// bit 0: 1=Mass method (diverters are used), 0=Volume method
|
||||
FixedStart = 0x02, /// bit 1: 1=fixed start method, 0=flying start method
|
||||
Synchro = 0x04, /// bit 2: 1=Synchro method, 0=Pulse counting
|
||||
MassAndContinue = 0x10, /// bit 4: 1=Method with mass measurement followed by a volume method
|
||||
}
|
||||
|
||||
public enum ValveChgFlag : byte
|
||||
{
|
||||
DoNotChange = 0,
|
||||
@@ -85,8 +101,17 @@ namespace TBF.BenchControl.ControlBoard.Uni
|
||||
|
||||
public enum RegValveMode : byte
|
||||
{
|
||||
Mode0 = 0,
|
||||
Mode1 = 1,
|
||||
Mode2 = 2,
|
||||
None = 0,
|
||||
PulseWidth = 1, /// Pulse width 0.05 .. 2 sec.
|
||||
TargetPosition = 2, /// Low and high position (=DAC value) limits (0..100%) are specified
|
||||
TargetFrequency = 3, /// Low and high frequency limits (0..2000Hz,0..2200Hz) are specified
|
||||
Stop = 4, /// Stop regulation
|
||||
}
|
||||
|
||||
public enum RegValveState : byte
|
||||
{
|
||||
Idle = 0,
|
||||
PwOrFreqRegul = 2,
|
||||
DacValueRegul = 3,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace TBF.BenchControl.ControlBoard.Uni
|
||||
|
||||
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new CBoard(cfg); }
|
||||
|
||||
public IComponentCfg DefaultConfig() { return new CBoardCfg(this.GetType().Namespace.Substring(32), this); }
|
||||
public IComponentCfg DefaultConfig() { return new CBoardCfg("UniCB", this); }
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
|
||||
{
|
||||
|
||||
@@ -10,26 +10,24 @@ namespace TBF.BenchControl.ControlBoard.Uni
|
||||
public const byte MessageCode = (byte)' ';
|
||||
|
||||
/// General data
|
||||
public ulong Status; /// byte 5..9, 5 bytes = 40 bits
|
||||
public uint Status5;
|
||||
public uint Status6; /// Parallel flow meters mask: bit0=0x01=Et1, bit1=0x02=Et2, bit2=0x04=Et3
|
||||
public ulong State; /// bytes 5,6,7,8,9,80,81 = 7 bytes = 56 bits
|
||||
public uint Chyby485;
|
||||
public ulong Vystupy;
|
||||
public uint[] StavDA = new uint[2];
|
||||
public float[] ReferenceFreq = new float[4];
|
||||
public uint[] EtPulses = new uint[Const.WMsCount + 1]; /// EtPulses[0]=total pulses, EtPulses[1..WMsCount] gated et.pulses for respective WM
|
||||
public double[] ReferenceFreq = new double[4];
|
||||
public uint[] EtPulses = new uint[Const.WMsCount + 1]; /// EtPulses[0]=total pulses, EtPulses[1..WMsCount] gated et.pulses for respective WM
|
||||
public uint EtPulsesK;
|
||||
public uint EtPulses2;
|
||||
public uint EtPulses3;
|
||||
public uint[] WMeterPuls = new uint[Const.WMsCount + 1]; /// WMsCount = 20
|
||||
public double[] ImpulseTime = new double[Const.WMsCount + 1]; /// WMsCount = 20
|
||||
public uint[] RegVStatus = new uint[Const.RVsCount + 1 + 1]; /// RVsCount = 8, posledny rValveStatus[9] je prudovy
|
||||
public uint[] WMeterPuls = new uint[Const.WMsCount + 1]; /// WMsCount = 20
|
||||
public double[] ImpulseTime = new double[Const.WMsCount + 1]; /// WMsCount = 20
|
||||
public uint[] RegVStatus = new uint[Const.RVsCount + 1 + 1]; /// RVsCount = 8, posledny rValveStatus[9] je prudovy
|
||||
public float[] RegVMoveTime = new float[Const.RVsCount];
|
||||
public int DivTime;
|
||||
public double Ttime; /// s
|
||||
public double TimeRef; /// s
|
||||
public double Ttime; /// s
|
||||
public double TimeRef; /// s
|
||||
public ulong Vstupy;
|
||||
public int[] AnalogyRaw = new int[Const.ADCsCount];
|
||||
public Int16[] AnalogInput = new Int16[Const.ADCsCount];
|
||||
public int[] TemperatureRaw = new int[8];
|
||||
|
||||
|
||||
@@ -66,12 +64,12 @@ namespace TBF.BenchControl.ControlBoard.Uni
|
||||
/// <param name="data">Received data</param>
|
||||
/// <param name="offs">Offset to the files</param>
|
||||
/// <returns></returns>
|
||||
short GetInt16(byte[] data, int offs) { return BitConverter.ToInt16(data, offs); }
|
||||
ushort GetUInt16(byte[] data, int offs) { return BitConverter.ToUInt16(data, offs); }
|
||||
uint GetUInt24(byte[] data, int offs) { return BitConverter.ToUInt32(data, offs) & 0x00FFFFFF; }
|
||||
uint GetUInt32(byte[] data, int offs) { return BitConverter.ToUInt32(data, offs); }
|
||||
ulong GetUInt40(byte[] data, int offs) { return BitConverter.ToUInt64(data, offs) & 0x000000FFFFFFFFFF; }
|
||||
ulong GetUInt64(byte[] data, int offs) { return BitConverter.ToUInt64(data, offs); }
|
||||
Int16 GetInt16(byte[] data, int offs) { return BitConverter.ToInt16(data, offs); }
|
||||
UInt16 GetUInt16(byte[] data, int offs) { return BitConverter.ToUInt16(data, offs); }
|
||||
UInt32 GetUInt24(byte[] data, int offs) { return BitConverter.ToUInt32(data, offs) & 0x00FFFFFF; }
|
||||
UInt32 GetUInt32(byte[] data, int offs) { return BitConverter.ToUInt32(data, offs); }
|
||||
UInt64 GetUInt40(byte[] data, int offs) { return BitConverter.ToUInt64(data, offs) & 0x000000FFFFFFFFFF; }
|
||||
UInt64 GetUInt64(byte[] data, int offs) { return BitConverter.ToUInt64(data, offs); }
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -81,7 +79,10 @@ namespace TBF.BenchControl.ControlBoard.Uni
|
||||
/// <param name="offs">Offset of the message</param>
|
||||
public void UpdateData(byte[] data, int offs)
|
||||
{
|
||||
Status = GetUInt40(data, offs + (int)Poz.Status); /// Byte 5,6,7,8,9
|
||||
State = GetUInt40(data, offs + (int)Poz.State) | /// Byte 5,6,7,8,9,80,81
|
||||
((ulong)data[offs + (int)Poz.Stat5] << 40) |
|
||||
((ulong)data[offs + (int)Poz.Stat6] << 48);
|
||||
|
||||
Vystupy = GetUInt64(data, offs + (int)Poz.Vyst); /// Byte 10 .. 17
|
||||
StavDA[1] = GetUInt16(data, offs + (int)Poz.SDA2); /// Byte 18,19
|
||||
Vstupy = GetUInt40(data, offs + (int)Poz.Vst); /// Byte 20,21,22,23,24
|
||||
@@ -89,7 +90,7 @@ namespace TBF.BenchControl.ControlBoard.Uni
|
||||
/// A/D converters: Feedback from RV-s and diverters
|
||||
for (int i = 0; i < Const.ADCsCount; i++) /// Byte 25 .. 56
|
||||
{
|
||||
AnalogyRaw[i] = GetInt16(data, offs + (int)Poz.Analogy + 2 * i);
|
||||
AnalogInput[i] = GetInt16(data, offs + (int)Poz.Analogy + 2 * i);
|
||||
}
|
||||
|
||||
/// Groch temperature meters
|
||||
@@ -101,8 +102,6 @@ namespace TBF.BenchControl.ControlBoard.Uni
|
||||
EtPulses[0] = GetUInt24(data, offs + (int)Poz.Et1); /// Byte 73,74,75
|
||||
EtPulsesK = GetUInt24(data, offs + (int)Poz.EtK); /// Byte 76,77,78
|
||||
byte spare1 = data[offs + (int)Poz.spare1]; /// byte 79
|
||||
Status5 = data[offs + (int)Poz.Stat5]; /// Byte 80
|
||||
Status6 = data[offs + (int)Poz.Stat6]; /// Byte 81
|
||||
byte spare2 = data[offs + (int)Poz.spare2]; /// byte 82
|
||||
|
||||
for (int i = 0; i < Const.RVsCount; i++) /// Byte 83 .. 90
|
||||
@@ -110,7 +109,7 @@ namespace TBF.BenchControl.ControlBoard.Uni
|
||||
RegVStatus[i + 1] = ((uint)data[offs + (int)Poz.RVs + i] >> 3) & 7;
|
||||
}
|
||||
/// 4-20 mA reg. valve
|
||||
uint stavRegQ = (uint)((Status >> 16) & 0xFF);
|
||||
uint stavRegQ = (uint)((State >> 16) & 0xFF);
|
||||
RegVStatus[Const.RVsCount + 1] = (stavRegQ >> 4) & 2;
|
||||
|
||||
/// This must preceed processing bytes 91 .. 250 as Ttime is used there
|
||||
@@ -123,7 +122,7 @@ namespace TBF.BenchControl.ControlBoard.Uni
|
||||
int ix2 = offs + (int)Poz.CTR1;
|
||||
for (int wmNr = 1; wmNr <= Const.WMsCount; wmNr++, ix1 += 6, ix2 += 2)
|
||||
{
|
||||
if ((Status & (ulong)StatusP.SynchroMethod) != 0)
|
||||
if ((State & (ulong)StatusP.SynchroMethod) != 0)
|
||||
{
|
||||
ushort pulses = GetUInt16(data, ix2);
|
||||
WMeterPuls[wmNr] = pulses;
|
||||
@@ -154,15 +153,23 @@ namespace TBF.BenchControl.ControlBoard.Uni
|
||||
ReferenceFreq[0] = (par2[0] != 0) ? (5.0f * par1[0] / par2[0]) : 0.0f;
|
||||
ReferenceFreq[1] = ReferenceFreq[2] = ReferenceFreq[3] = 0;
|
||||
///
|
||||
if ((Status & (ulong)StatusP.TestWithRefFlowmtr) != 0 && (Status & (ulong)StatusP.FlowmtrIdMask) == 0)
|
||||
if ((State & (ulong)StatusP.TestWithRefFlowmtr) != 0 && (State & (ulong)StatusP.FlowmtrNrMask) == 0)
|
||||
{
|
||||
/// Measurement with parallel flowmeters
|
||||
if ((Status6 & 0x01) != 0)
|
||||
if ((State & (ulong)StatusP.Flowmtr1Active) != 0)
|
||||
{
|
||||
ReferenceFreq[1] = ReferenceFreq[0];
|
||||
if ((Status6 & 0x02) != 0)
|
||||
}
|
||||
|
||||
if ((State & (ulong)StatusP.Flowmtr2Active) != 0)
|
||||
{
|
||||
ReferenceFreq[2] = (par2[1] != 0) ? (5.0f * par1[1] / par2[1]) : 0.0f;
|
||||
if ((Status6 & 0x04) != 0)
|
||||
}
|
||||
|
||||
if ((State & (ulong)StatusP.Flowmtr3Active) != 0)
|
||||
{
|
||||
ReferenceFreq[3] = (par2[2] != 0) ? (5.0f * par1[2] / par2[2]) : 0.0f;
|
||||
}
|
||||
|
||||
ReferenceFreq[0] = ReferenceFreq[1] + ReferenceFreq[2] + ReferenceFreq[3];
|
||||
}
|
||||
@@ -188,8 +195,8 @@ namespace TBF.BenchControl.ControlBoard.Uni
|
||||
/// </summary>
|
||||
public enum Poz : int
|
||||
{
|
||||
Status = 5, /// 5 .. 9
|
||||
Vyst = Status + 5, /// 10 .. 17
|
||||
State = 5, /// 5 .. 9
|
||||
Vyst = State + 5, /// 10 .. 17
|
||||
SDA2 = Vyst + 8, /// 18,19
|
||||
Vst = SDA2 + 2, /// 20 .. 24
|
||||
Analogy = Vst + 5, /// 25 .. 56
|
||||
|
||||
Reference in New Issue
Block a user