Uni.RegValveAnalog and Uni.RegValveTandem added, several Elde components removed.

This commit is contained in:
Milan Hanajik
2021-03-12 22:59:11 +01:00
parent b1862e2f02
commit baae5655d4
68 changed files with 391 additions and 7060 deletions
-269
View File
@@ -1,269 +0,0 @@
///
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using Dirichlet.Numerics;
using TBF.Rig.ControlBoard.Legacy;
using TBF.Rig.Generic;
using TBF.Boxes;
using TBF.Resources;
namespace TBF.Rig.Elde.Diverter
{
public class Diverter : ComponentBase, IDevice, GenericDevices.IDiverter, GenericDevices.ISequenceCondition, GenericDevices.IHasCalendarEvents, SchematicDrawing.IDrawingItCmpnt
{
private static readonly ILog log = LogManager.GetLogger(typeof(Diverter));
public override string ToString() { return string.Format("Diverter({0})", Cfg.ToString(1)); }
/// <summary>
/// Enumeration of balances via static fields and methods
/// </summary>
static int nextIdx = 0;
public static new void ResetStaticProperties()
{
nextIdx = 0;
}
public static int DivertersCount { get { return nextIdx; } }
public static GenericDevices.IDiverter[] Diverters;
readonly int diverterNr0; /// 0-based diverter number
public int DiverterNr { get { return diverterNr0 + 1; } } /// 1-based public diverter number
readonly DiverterCfg diverterCfg;
public SchematicDrawing.IDrawingItem DrawingItem { get { return diverterCfg as SchematicDrawing.IDrawingItem; } }
readonly CBoard controlBoard;
readonly UInt128 mask; /// derived from bitPosition in the constructor
public int AdcNr { get { return diverterCfg.AdcNr; } }
readonly int flowMtrNr4Cmd;
readonly IOperation diverterToTankOp;
readonly IOperation diverterToSinkOp;
public bool State { get { return (controlBoard.RRoute & mask) != 0; } }
public int ThresholdGate { get { return diverterCfg.StartingLevel; } }
public int ThresholdLo { get { return diverterCfg.ThresholdLo; } }
public int ThresholdHi { get { return diverterCfg.ThresholdHi; } }
FloatBox switchTimeStart;
FloatBox switchTimeEnd;
public FloatBox SwitchTimeStart { get { return switchTimeStart; } }
public FloatBox SwitchTimeEnd { get { return switchTimeEnd; } }
/// <summary>
/// For a given flow in [m3/h] returns a test time correction in [s]
/// </summary>
public double TestTimeCorrection(double flow)
{
return Config.Formulas.GetCorrection(flow, Corrections);
}
public Diverter()
{
}
public Diverter(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
diverterCfg = cfg as DiverterCfg;
controlBoard = TbfComponents.FindComponent(cfg.ParentName, components) as CBoard;
if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
if (cfg.DebugLevel != Config.Entities.DebugMode.Off)
{
if (diverterCfg.BitNr < 0 || diverterCfg.BitNr >= 64) throw new ArgumentOutOfRangeException("position");
this.mask = (((UInt128)1) << diverterCfg.BitNr);
switchTimeStart = new FloatBox(diverterCfg.DfltSwithTimeStartMs / 1000.0f);
switchTimeEnd = new FloatBox(diverterCfg.DfltSwithTimeEndMs / 1000.0f);
diverterNr0 = nextIdx++;
///
if (Diverters == null || Diverters.Length < nextIdx)
{
GenericDevices.IDiverter[] divertersSoFar = Diverters;
Diverters = new GenericDevices.IDiverter[nextIdx];
if (divertersSoFar != null)
{
for (int i = 0; i < divertersSoFar.Length; i++) Diverters[i] = divertersSoFar[i];
}
Diverters[nextIdx - 1] = this;
}
/// Prepare arguments of SendCalibData()
if (diverterCfg.AdcNr >= 0 && diverterCfg.AdcNr < controlBoard.RegValveCalib.GetLength(0))
{
controlBoard.RegValveCalib[diverterCfg.AdcNr, 0] = (uint)diverterCfg.AdcValueToSink;
controlBoard.RegValveCalib[diverterCfg.AdcNr, 1] = (uint)diverterCfg.AdcValueToTank;
}
else
{
log.ErrorFormat("Unable to set {0} ADC levels: RegValveCalib array size={1}, diverter AdcNr={2}",
Name, controlBoard.RegValveCalib.GetLength(0), diverterCfg.AdcNr);
}
int divNrFromName;
if (!int.TryParse(Name.Substring(3), out divNrFromName))
{
divNrFromName = nextIdx;
}
#if GENESIS || PETERSBURG_50 || PETERSBURG_200 || FUZHOU_50 || FUZHOU_150 || FUZHOU_300 || ROMA_200 || SLM_150
flowMtrNr4Cmd = divNrFromName + 1;
#elif BADGER_STREDNA_TRAT
flowMtrNr4Cmd = (divNrFromName == 1) ? 1 : ((divNrFromName == 2) ? 9 : 20);
#elif BADGER_VELKA_TRAT
flowMtrNr4Cmd = ((divNrFromName % 10) == 1) ? 0x11 : (((divNrFromName % 10) == 2) ? 0x22 : 0x33);
#elif FUZHOU_100
flowMtrNr4Cmd = divNrFromName;
#elif CEVAK_200
flowMtrNr4Cmd = (divNrFromName == 4) ? 5 : divNrFromName;
#elif DEWA_300 || PUCHONG_200
flowMtrNr4Cmd = divNrFromName + 2; /// Div1: 1,2,3, Div2: 4, Div3: 5, Div4: 6, Div5: 7
#elif TURA_IPERL || TURA_IPERL_NEW
flowMtrNr4Cmd = divNrFromName + 16 * divNrFromName;
#elif FILIPINY_50
flowMtrNr4Cmd = (divNrFromName == 1) ? 1 : 7;
#elif GELSENWASSER
switch (divNrFromName)
{
default:
case 1: flowMtrNr4Cmd = 1; break;
case 2: flowMtrNr4Cmd = 0x12; break;
case 3: flowMtrNr4Cmd = 3; break;
case 4: flowMtrNr4Cmd = 5; break;
}
#else
flowMtrNr4Cmd = (divNrFromName == 1) ? 1 : 3;
#endif
diverterToTankOp = new SwitchDiverterOp(controlBoard, true, flowMtrNr4Cmd);
diverterToSinkOp = new SwitchDiverterOp(controlBoard, false, flowMtrNr4Cmd);
log.Warn(this.ToString());
}
}
///
/// Calendar support
///
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
DateTime calibrationDue = diverterCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
if (calibrationDue > TBF.UI.Constants.MinDate)
{
/// Calibration due date calendar event
calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
{
/// Weekly reminders (last 5 weeks)
calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
false));
}
if (DateTime.Now.Date <= calibrationDue.Date)
{
/// Daily reminders (last 5 days)
calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
true));
}
}
return calendarEvents;
}
///
/// IDevice interface implementation
///
public void Initialize() { }
public void RunDeviceBefore()
{
short adcValue = (short)controlBoard.AnalogInputRaw(diverterCfg.AdcNr, 0);
Handlers.OnAdcChanged(this, new CmdResponseArgs(CfgChangeCmd.GetAdc, diverterCfg.BitNr, adcValue));
}
public void RunDeviceAfter() { }
public void StopDevice() { }
public void StopDevice2() { }
///
/// ISequenceCondition interface implementation
///
public int ConditionsCount { get { return 2; } }
/// Returned strings are added to the combo-box
public string ConditionName(int i)
{
if (i == 0) return string.Format("{0} {1}", Name, Strings.Start);
else return string.Format("{0} {1}", Name, Strings.End);
}
public IOperation ConditionOp(int i)
{
if (i == 0) return diverterToTankOp;
else return diverterToSinkOp;
}
#region Configuration Change Handling
public static void OnCfgChange(object sender, CfgChangeArgs args)
{
if (CfgChangeHandler == null) return;
try { CfgChangeHandler(sender, args); }
catch (Exception e) { log.Error("CfgChangeHandler(...) failed", e); }
}
public static event EventHandler<CfgChangeArgs> CfgChangeHandler;
public override void StartChangeHandler()
{
CfgChangeHandler += delegate(object sender, CfgChangeArgs args)
{
DiverterCfg tmpcfg = args.Cfg as DiverterCfg;
if (tmpcfg != null && tmpcfg.Name.Equals(Name))
{
if (args.Command == CfgChangeCmd.CfgChange)
{
}
else if (args.Command == CfgChangeCmd.GetAdc1 || args.Command == CfgChangeCmd.GetAdc2)
{
short adcValue = (short)controlBoard.AnalogInputRaw(diverterCfg.AdcNr, 0);
DiverterCfgCtrl.OnCmdResponse(this, new CmdResponseArgs(args.Command, diverterCfg.BitNr, adcValue));
}
else if (args.Command == CfgChangeCmd.DivToTank)
{
controlBoard.DiverterToTank(flowMtrNr4Cmd);
}
else if (args.Command == CfgChangeCmd.DivToSink)
{
controlBoard.DiverterToSink(flowMtrNr4Cmd);
}
else if (args.Command == CfgChangeCmd.ReadDivTransition)
{
controlBoard.ReadDiverterTransition(flowMtrNr4Cmd);
}
}
};
}
#endregion Configuration Change Handling
}
}
-98
View File
@@ -1,98 +0,0 @@
///
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
using System;
using System.IO;
using System.Collections.Generic;
using System.Xml.Serialization;
using Config.Entities;
using SchematicDrawing;
using TBF.Rig.Generic;
namespace TBF.Rig.Elde.Diverter
{
public class DiverterCfg : ComponentCfgBase, IChildComponentCfg, GenericDevices.ICalibInfoCfg, IRouteBasedDrawingItem
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(DiverterCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new DiverterCfgCtrl(); }
///
/// Serialized parameters
///
public int BitNr { get; set; } /// 0..127
public bool Inverted { get; set; } /// When true the diverter function is inverted: 0 = to the tank, 1 = off
public int AdcNr; /// 0..15(?), number of the analog input
public int AdcValueToSink; /// 0..1023
public int AdcValueToTank; /// 0..1023
public int StartingLevel; /// 0..100 in %, threshold for the ADC value to start the test
public int ThresholdLo; /// 0..100 in %, threshold for low level when diverter transition time is measured
public int ThresholdHi; /// 0..100 in %, threshold for high level when diverter transition time is measured
public int DfltSwithTimeStartMs; /// Default diverter transition time 'start' or 'to tank' in ms
public int DfltSwithTimeEndMs; /// Default diverter transition time 'end' or 'to sink' in ms
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
/// Schematic drawing info
public Shape Shape { get; set; }
public int X { get; set; }
public int Y { get; set; }
public Sz Sz { get; set; }
public Orient Orient { get; set; }
public bool Flip { get; set; }
public int LblX { get; set; }
public int LblY { get; set; }
public Orient LblOrient { get; set; }
[XmlIgnore]
public IList<GNode> GNodes { get; set; }
[XmlIgnore]
public IList<GEdge> EdgesToSet { get; set; }
/// Private parameterless constructor invoked by all other (public) constructors
DiverterCfg()
{
GNodes = new List<GNode>();
EdgesToSet = new List<GEdge>();
}
public DiverterCfg(IComponentFactory factory)
: this()
{
Shape = Shape.Div;
Sz = Sz.M;
Factory = factory;
Name = "Div";
ParentName = "CB";
BitNr = 0;
AdcNr = 5; /// Div1: AdcNr=5 , Div2: AdcNr=6
AdcValueToSink = 100;
AdcValueToTank = 500;
StartingLevel = 50;
ThresholdLo = 10;
ThresholdHi = 90;
CalibCertificateNr = string.Empty;
}
public string ToString(int i)
{
return string.Format("Name={0}, Parent={1}, Bit={2}, ADC#={3}, ADC2Sink={4}, ADC2Tank={5}, Gate={6}%, Lo={7}%, Lo={8}%",
Name,
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName),
BitNr,
AdcNr,
AdcValueToSink,
AdcValueToTank,
StartingLevel,
ThresholdLo,
ThresholdHi);
}
}
}
-623
View File
@@ -1,623 +0,0 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
namespace TBF.Rig.Elde.Diverter
{
partial class DiverterCfgCtrl
{
/// <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.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.parentNameLabel = new System.Windows.Forms.Label();
this.bitPositionLabel = new System.Windows.Forms.Label();
this.bitPositionTextBox = new System.Windows.Forms.TextBox();
this.parentNameComboBox = new System.Windows.Forms.ComboBox();
this.startingEdgeTextBox = new System.Windows.Forms.TextBox();
this.startingEdgeLabel = new System.Windows.Forms.Label();
this.thresholdLoTextBox = new System.Windows.Forms.TextBox();
this.thresholdLoLabel = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.startButton = new System.Windows.Forms.Button();
this.stopButton = new System.Windows.Forms.Button();
this.updateButton = new System.Windows.Forms.Button();
this.adcToTankTextBox = new System.Windows.Forms.TextBox();
this.adcTankLabel = new System.Windows.Forms.Label();
this.adcToSinkTextBox = new System.Windows.Forms.TextBox();
this.adcSinkLabel = new System.Windows.Forms.Label();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.label4 = new System.Windows.Forms.Label();
this.adcTextBox = new System.Windows.Forms.TextBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.setButton2 = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.getButton2 = new System.Windows.Forms.Button();
this.pctTextBox2 = new System.Windows.Forms.TextBox();
this.adcTextBox2 = new System.Windows.Forms.TextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.setButton1 = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.ADC = new System.Windows.Forms.Label();
this.getButton1 = new System.Windows.Forms.Button();
this.pctTextBox1 = new System.Windows.Forms.TextBox();
this.adcTextBox1 = new System.Windows.Forms.TextBox();
this.adcNrTextBox = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.thresholdHiTextBox = new System.Windows.Forms.TextBox();
this.thresholdHiLabel = new System.Windows.Forms.Label();
this.dfltSwitchTimeEndTextBox = new System.Windows.Forms.TextBox();
this.dfltSwitchTimeEndLabel = new System.Windows.Forms.Label();
this.dfltSwitchTimeStartTextBox = new System.Windows.Forms.TextBox();
this.dfltSwitchTimeStartLabel = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.groupBox4.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(144, 41);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(130, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(21, 44);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(141, 17);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// parentNameLabel
//
this.parentNameLabel.AutoSize = true;
this.parentNameLabel.Location = new System.Drawing.Point(21, 67);
this.parentNameLabel.Name = "parentNameLabel";
this.parentNameLabel.Size = new System.Drawing.Size(69, 13);
this.parentNameLabel.TabIndex = 3;
this.parentNameLabel.Text = "Parent Name";
//
// bitPositionLabel
//
this.bitPositionLabel.AutoSize = true;
this.bitPositionLabel.Location = new System.Drawing.Point(21, 91);
this.bitPositionLabel.Name = "bitPositionLabel";
this.bitPositionLabel.Size = new System.Drawing.Size(59, 13);
this.bitPositionLabel.TabIndex = 5;
this.bitPositionLabel.Text = "Bit Position";
//
// bitPositionTextBox
//
this.bitPositionTextBox.Enabled = false;
this.bitPositionTextBox.Location = new System.Drawing.Point(144, 88);
this.bitPositionTextBox.Name = "bitPositionTextBox";
this.bitPositionTextBox.Size = new System.Drawing.Size(46, 20);
this.bitPositionTextBox.TabIndex = 6;
//
// parentNameComboBox
//
this.parentNameComboBox.Enabled = false;
this.parentNameComboBox.FormattingEnabled = true;
this.parentNameComboBox.Location = new System.Drawing.Point(144, 64);
this.parentNameComboBox.Name = "parentNameComboBox";
this.parentNameComboBox.Size = new System.Drawing.Size(130, 21);
this.parentNameComboBox.TabIndex = 4;
//
// startingEdgeTextBox
//
this.startingEdgeTextBox.Enabled = false;
this.startingEdgeTextBox.Location = new System.Drawing.Point(144, 180);
this.startingEdgeTextBox.Name = "startingEdgeTextBox";
this.startingEdgeTextBox.Size = new System.Drawing.Size(46, 20);
this.startingEdgeTextBox.TabIndex = 14;
//
// startingEdgeLabel
//
this.startingEdgeLabel.AutoSize = true;
this.startingEdgeLabel.Location = new System.Drawing.Point(21, 183);
this.startingEdgeLabel.Name = "startingEdgeLabel";
this.startingEdgeLabel.Size = new System.Drawing.Size(68, 13);
this.startingEdgeLabel.TabIndex = 13;
this.startingEdgeLabel.Text = "Starting level";
//
// thresholdLoTextBox
//
this.thresholdLoTextBox.Enabled = false;
this.thresholdLoTextBox.Location = new System.Drawing.Point(144, 203);
this.thresholdLoTextBox.Name = "thresholdLoTextBox";
this.thresholdLoTextBox.Size = new System.Drawing.Size(46, 20);
this.thresholdLoTextBox.TabIndex = 17;
//
// thresholdLoLabel
//
this.thresholdLoLabel.AutoSize = true;
this.thresholdLoLabel.Location = new System.Drawing.Point(21, 206);
this.thresholdLoLabel.Name = "thresholdLoLabel";
this.thresholdLoLabel.Size = new System.Drawing.Size(69, 13);
this.thresholdLoLabel.TabIndex = 16;
this.thresholdLoLabel.Text = "Threshold Lo";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(197, 205);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(15, 13);
this.label2.TabIndex = 18;
this.label2.Text = "%";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(197, 183);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(15, 13);
this.label1.TabIndex = 15;
this.label1.Text = "%";
//
// startButton
//
this.startButton.Location = new System.Drawing.Point(10, 557);
this.startButton.Name = "startButton";
this.startButton.Size = new System.Drawing.Size(55, 31);
this.startButton.TabIndex = 22;
this.startButton.Text = "Start";
this.startButton.UseVisualStyleBackColor = true;
this.startButton.Click += new System.EventHandler(this.startButton_Click);
//
// stopButton
//
this.stopButton.Location = new System.Drawing.Point(71, 557);
this.stopButton.Name = "stopButton";
this.stopButton.Size = new System.Drawing.Size(55, 31);
this.stopButton.TabIndex = 23;
this.stopButton.Text = "Stop";
this.stopButton.UseVisualStyleBackColor = true;
this.stopButton.Click += new System.EventHandler(this.stopButton_Click);
//
// updateButton
//
this.updateButton.Enabled = false;
this.updateButton.Location = new System.Drawing.Point(206, 557);
this.updateButton.Name = "updateButton";
this.updateButton.Size = new System.Drawing.Size(85, 31);
this.updateButton.TabIndex = 26;
this.updateButton.Text = "Update Edge";
this.updateButton.UseVisualStyleBackColor = true;
this.updateButton.Click += new System.EventHandler(this.updateButton_Click);
//
// adcToTankTextBox
//
this.adcToTankTextBox.Enabled = false;
this.adcToTankTextBox.Location = new System.Drawing.Point(144, 157);
this.adcToTankTextBox.Name = "adcToTankTextBox";
this.adcToTankTextBox.Size = new System.Drawing.Size(46, 20);
this.adcToTankTextBox.TabIndex = 12;
//
// adcTankLabel
//
this.adcTankLabel.AutoSize = true;
this.adcTankLabel.Location = new System.Drawing.Point(21, 160);
this.adcTankLabel.Name = "adcTankLabel";
this.adcTankLabel.Size = new System.Drawing.Size(94, 13);
this.adcTankLabel.TabIndex = 11;
this.adcTankLabel.Text = "ADC when to tank";
//
// adcToSinkTextBox
//
this.adcToSinkTextBox.Enabled = false;
this.adcToSinkTextBox.Location = new System.Drawing.Point(144, 134);
this.adcToSinkTextBox.Name = "adcToSinkTextBox";
this.adcToSinkTextBox.Size = new System.Drawing.Size(46, 20);
this.adcToSinkTextBox.TabIndex = 10;
//
// adcSinkLabel
//
this.adcSinkLabel.AutoSize = true;
this.adcSinkLabel.Location = new System.Drawing.Point(21, 137);
this.adcSinkLabel.Name = "adcSinkLabel";
this.adcSinkLabel.Size = new System.Drawing.Size(92, 13);
this.adcSinkLabel.TabIndex = 9;
this.adcSinkLabel.Text = "ADC when to sink";
//
// groupBox4
//
this.groupBox4.Controls.Add(this.label4);
this.groupBox4.Controls.Add(this.adcTextBox);
this.groupBox4.Location = new System.Drawing.Point(10, 352);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(279, 40);
this.groupBox4.TabIndex = 19;
this.groupBox4.TabStop = false;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(11, 17);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(32, 13);
this.label4.TabIndex = 22;
this.label4.Text = "ADC:";
//
// adcTextBox
//
this.adcTextBox.Location = new System.Drawing.Point(47, 14);
this.adcTextBox.Name = "adcTextBox";
this.adcTextBox.Size = new System.Drawing.Size(44, 20);
this.adcTextBox.TabIndex = 21;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.setButton2);
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Controls.Add(this.label5);
this.groupBox2.Controls.Add(this.getButton2);
this.groupBox2.Controls.Add(this.pctTextBox2);
this.groupBox2.Controls.Add(this.adcTextBox2);
this.groupBox2.Location = new System.Drawing.Point(10, 462);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(280, 59);
this.groupBox2.TabIndex = 21;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Measured value 2";
//
// setButton2
//
this.setButton2.Location = new System.Drawing.Point(229, 17);
this.setButton2.Name = "setButton2";
this.setButton2.Size = new System.Drawing.Size(38, 33);
this.setButton2.TabIndex = 5;
this.setButton2.Text = "Set";
this.setButton2.UseVisualStyleBackColor = true;
this.setButton2.Click += new System.EventHandler(this.setButton_Click);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(209, 28);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(15, 13);
this.label3.TabIndex = 4;
this.label3.Text = "%";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(11, 27);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(32, 13);
this.label5.TabIndex = 3;
this.label5.Text = "ADC:";
//
// getButton2
//
this.getButton2.Location = new System.Drawing.Point(101, 18);
this.getButton2.Name = "getButton2";
this.getButton2.Size = new System.Drawing.Size(38, 33);
this.getButton2.TabIndex = 2;
this.getButton2.Text = "Get";
this.getButton2.UseVisualStyleBackColor = true;
this.getButton2.Click += new System.EventHandler(this.getButton2_Click);
//
// pctTextBox2
//
this.pctTextBox2.Location = new System.Drawing.Point(160, 24);
this.pctTextBox2.Name = "pctTextBox2";
this.pctTextBox2.Size = new System.Drawing.Size(46, 20);
this.pctTextBox2.TabIndex = 1;
//
// adcTextBox2
//
this.adcTextBox2.Location = new System.Drawing.Point(47, 24);
this.adcTextBox2.Name = "adcTextBox2";
this.adcTextBox2.Size = new System.Drawing.Size(44, 20);
this.adcTextBox2.TabIndex = 0;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.setButton1);
this.groupBox1.Controls.Add(this.label6);
this.groupBox1.Controls.Add(this.ADC);
this.groupBox1.Controls.Add(this.getButton1);
this.groupBox1.Controls.Add(this.pctTextBox1);
this.groupBox1.Controls.Add(this.adcTextBox1);
this.groupBox1.Location = new System.Drawing.Point(10, 398);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(280, 59);
this.groupBox1.TabIndex = 20;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Measured value 1";
//
// setButton1
//
this.setButton1.Location = new System.Drawing.Point(229, 17);
this.setButton1.Name = "setButton1";
this.setButton1.Size = new System.Drawing.Size(38, 33);
this.setButton1.TabIndex = 5;
this.setButton1.Text = "Set";
this.setButton1.UseVisualStyleBackColor = true;
this.setButton1.Click += new System.EventHandler(this.setButton_Click);
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(209, 28);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(15, 13);
this.label6.TabIndex = 4;
this.label6.Text = "%";
//
// ADC
//
this.ADC.AutoSize = true;
this.ADC.Location = new System.Drawing.Point(11, 28);
this.ADC.Name = "ADC";
this.ADC.Size = new System.Drawing.Size(32, 13);
this.ADC.TabIndex = 3;
this.ADC.Text = "ADC:";
//
// getButton1
//
this.getButton1.Location = new System.Drawing.Point(101, 18);
this.getButton1.Name = "getButton1";
this.getButton1.Size = new System.Drawing.Size(38, 33);
this.getButton1.TabIndex = 2;
this.getButton1.Text = "Get";
this.getButton1.UseVisualStyleBackColor = true;
this.getButton1.Click += new System.EventHandler(this.getButton1_Click);
//
// pctTextBox1
//
this.pctTextBox1.Location = new System.Drawing.Point(160, 24);
this.pctTextBox1.Name = "pctTextBox1";
this.pctTextBox1.Size = new System.Drawing.Size(46, 20);
this.pctTextBox1.TabIndex = 1;
//
// adcTextBox1
//
this.adcTextBox1.Location = new System.Drawing.Point(47, 24);
this.adcTextBox1.Name = "adcTextBox1";
this.adcTextBox1.Size = new System.Drawing.Size(44, 20);
this.adcTextBox1.TabIndex = 0;
//
// adcNrTextBox
//
this.adcNrTextBox.Enabled = false;
this.adcNrTextBox.Location = new System.Drawing.Point(144, 111);
this.adcNrTextBox.Name = "adcNrTextBox";
this.adcNrTextBox.Size = new System.Drawing.Size(46, 20);
this.adcNrTextBox.TabIndex = 8;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(21, 114);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(76, 13);
this.label7.TabIndex = 7;
this.label7.Text = "Analog input #";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(197, 228);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(15, 13);
this.label8.TabIndex = 29;
this.label8.Text = "%";
//
// thresholdHiTextBox
//
this.thresholdHiTextBox.Enabled = false;
this.thresholdHiTextBox.Location = new System.Drawing.Point(144, 226);
this.thresholdHiTextBox.Name = "thresholdHiTextBox";
this.thresholdHiTextBox.Size = new System.Drawing.Size(46, 20);
this.thresholdHiTextBox.TabIndex = 28;
//
// thresholdHiLabel
//
this.thresholdHiLabel.AutoSize = true;
this.thresholdHiLabel.Location = new System.Drawing.Point(21, 229);
this.thresholdHiLabel.Name = "thresholdHiLabel";
this.thresholdHiLabel.Size = new System.Drawing.Size(67, 13);
this.thresholdHiLabel.TabIndex = 27;
this.thresholdHiLabel.Text = "Threshold Hi";
//
// dfltSwitchTimeEndTextBox
//
this.dfltSwitchTimeEndTextBox.Enabled = false;
this.dfltSwitchTimeEndTextBox.Location = new System.Drawing.Point(144, 272);
this.dfltSwitchTimeEndTextBox.Name = "dfltSwitchTimeEndTextBox";
this.dfltSwitchTimeEndTextBox.Size = new System.Drawing.Size(46, 20);
this.dfltSwitchTimeEndTextBox.TabIndex = 33;
//
// dfltSwitchTimeEndLabel
//
this.dfltSwitchTimeEndLabel.AutoSize = true;
this.dfltSwitchTimeEndLabel.Location = new System.Drawing.Point(21, 275);
this.dfltSwitchTimeEndLabel.Name = "dfltSwitchTimeEndLabel";
this.dfltSwitchTimeEndLabel.Size = new System.Drawing.Size(117, 13);
this.dfltSwitchTimeEndLabel.TabIndex = 32;
this.dfltSwitchTimeEndLabel.Text = "Default switch time end";
//
// dfltSwitchTimeStartTextBox
//
this.dfltSwitchTimeStartTextBox.Enabled = false;
this.dfltSwitchTimeStartTextBox.Location = new System.Drawing.Point(144, 249);
this.dfltSwitchTimeStartTextBox.Name = "dfltSwitchTimeStartTextBox";
this.dfltSwitchTimeStartTextBox.Size = new System.Drawing.Size(46, 20);
this.dfltSwitchTimeStartTextBox.TabIndex = 31;
//
// dfltSwitchTimeStartLabel
//
this.dfltSwitchTimeStartLabel.AutoSize = true;
this.dfltSwitchTimeStartLabel.Location = new System.Drawing.Point(21, 252);
this.dfltSwitchTimeStartLabel.Name = "dfltSwitchTimeStartLabel";
this.dfltSwitchTimeStartLabel.Size = new System.Drawing.Size(119, 13);
this.dfltSwitchTimeStartLabel.TabIndex = 30;
this.dfltSwitchTimeStartLabel.Text = "Default switch time start";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(197, 252);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(20, 13);
this.label9.TabIndex = 34;
this.label9.Text = "ms";
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(197, 275);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(20, 13);
this.label10.TabIndex = 35;
this.label10.Text = "ms";
//
// DiverterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.label10);
this.Controls.Add(this.label9);
this.Controls.Add(this.dfltSwitchTimeEndTextBox);
this.Controls.Add(this.dfltSwitchTimeEndLabel);
this.Controls.Add(this.dfltSwitchTimeStartTextBox);
this.Controls.Add(this.dfltSwitchTimeStartLabel);
this.Controls.Add(this.label8);
this.Controls.Add(this.thresholdHiTextBox);
this.Controls.Add(this.thresholdHiLabel);
this.Controls.Add(this.adcNrTextBox);
this.Controls.Add(this.label7);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.adcToTankTextBox);
this.Controls.Add(this.adcTankLabel);
this.Controls.Add(this.adcToSinkTextBox);
this.Controls.Add(this.adcSinkLabel);
this.Controls.Add(this.updateButton);
this.Controls.Add(this.stopButton);
this.Controls.Add(this.startButton);
this.Controls.Add(this.label1);
this.Controls.Add(this.label2);
this.Controls.Add(this.thresholdLoTextBox);
this.Controls.Add(this.thresholdLoLabel);
this.Controls.Add(this.startingEdgeTextBox);
this.Controls.Add(this.startingEdgeLabel);
this.Controls.Add(this.parentNameComboBox);
this.Controls.Add(this.bitPositionTextBox);
this.Controls.Add(this.bitPositionLabel);
this.Controls.Add(this.parentNameLabel);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "DiverterCfgCtrl";
this.Size = new System.Drawing.Size(300, 700);
this.Load += new System.EventHandler(this.DiverterCfgCtrl_Load);
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.Label parentNameLabel;
private System.Windows.Forms.Label bitPositionLabel;
private System.Windows.Forms.TextBox bitPositionTextBox;
private System.Windows.Forms.ComboBox parentNameComboBox;
private System.Windows.Forms.TextBox startingEdgeTextBox;
private System.Windows.Forms.Label startingEdgeLabel;
private System.Windows.Forms.TextBox thresholdLoTextBox;
private System.Windows.Forms.Label thresholdLoLabel;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button startButton;
private System.Windows.Forms.Button stopButton;
private System.Windows.Forms.Button updateButton;
private System.Windows.Forms.TextBox adcToTankTextBox;
private System.Windows.Forms.Label adcTankLabel;
private System.Windows.Forms.TextBox adcToSinkTextBox;
private System.Windows.Forms.Label adcSinkLabel;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox adcTextBox;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Button setButton2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Button getButton2;
private System.Windows.Forms.TextBox pctTextBox2;
private System.Windows.Forms.TextBox adcTextBox2;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button setButton1;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label ADC;
private System.Windows.Forms.Button getButton1;
private System.Windows.Forms.TextBox pctTextBox1;
private System.Windows.Forms.TextBox adcTextBox1;
private System.Windows.Forms.TextBox adcNrTextBox;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.TextBox thresholdHiTextBox;
private System.Windows.Forms.Label thresholdHiLabel;
private System.Windows.Forms.TextBox dfltSwitchTimeEndTextBox;
private System.Windows.Forms.Label dfltSwitchTimeEndLabel;
private System.Windows.Forms.TextBox dfltSwitchTimeStartTextBox;
private System.Windows.Forms.Label dfltSwitchTimeStartLabel;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label10;
}
}
-379
View File
@@ -1,379 +0,0 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using System;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.UI.Bench.Components;
namespace TBF.Rig.Elde.Diverter
{
public partial class DiverterCfgCtrl : UserControl, IComponentCfgCtrl
{
static readonly ILog log = LogManager.GetLogger(typeof(DiverterCfgCtrl));
ComponentParametersDlg parent;
public bool ShowMore { get { return true; } }
DiverterCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as DiverterCfg;
Redraw();
}
}
public DiverterCfgCtrl()
{
InitializeComponent();
}
private void DiverterCfgCtrl_Load(object sender, EventArgs e)
{
parent = ParentForm as ComponentParametersDlg;
if (parent == null) return;
if (parent.CmpntEntities != null)
{
foreach (var cmpnt in parent.CmpntEntities)
{
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is ControlBoard.Legacy.Factory)
{
parentNameComboBox.Items.Add(cmpnt.Name);
}
}
}
if (config != null)
{
adc1 = config.AdcValueToSink;
pct1 = 0;
adc2 = config.AdcValueToTank;
pct2 = 100;
}
Redraw();
StartResponseHandler();
}
public void Closing()
{
StopResponseHandler();
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName;
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
nameTextBox.Text = config.Name;
bitPositionTextBox.Text = config.BitNr.ToString();
adcNrTextBox.Text = config.AdcNr.ToString();
adcToSinkTextBox.Text = config.AdcValueToSink.ToString();
adcToTankTextBox.Text = config.AdcValueToTank.ToString();
startingEdgeTextBox.Text = config.StartingLevel.ToString();
thresholdLoTextBox.Text = config.ThresholdLo.ToString();
thresholdHiTextBox.Text = config.ThresholdHi.ToString();
dfltSwitchTimeStartTextBox.Text = config.DfltSwithTimeStartMs.ToString();
dfltSwitchTimeEndTextBox.Text = config.DfltSwithTimeEndMs.ToString();
adcTextBox1.Text = adc1.ToString();
adcTextBox2.Text = adc2.ToString();
pctTextBox1.Text = pct1.ToString();
pctTextBox2.Text = pct2.ToString();
}
public void Unlock()
{
nameTextBox.Enabled = true;
parentNameComboBox.Enabled = true;
bitPositionTextBox.Enabled = true;
adcNrTextBox.Enabled = true;
adcToSinkTextBox.Enabled = true;
adcToTankTextBox.Enabled = true;
startingEdgeTextBox.Enabled = true;
thresholdLoTextBox.Enabled = true;
thresholdHiTextBox.Enabled = true;
dfltSwitchTimeStartTextBox.Enabled = true;
dfltSwitchTimeEndTextBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
int dummy;
int divLo;
int divHi;
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Parent Name'";
}
if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy > 127)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Bit Position' should be between 0 and 127";
}
if (!int.TryParse(adcNrTextBox.Text, out dummy) || dummy < 0 || dummy > 15)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Analog input #' should be between 0 and 15";
}
if (!int.TryParse(adcToSinkTextBox.Text, out dummy) || dummy < 0 || dummy > 1023)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'ADC when to sink' should be between 0 and 1023";
}
if (!int.TryParse(adcToTankTextBox.Text, out dummy) || dummy < 0 || dummy > 1023)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'ADC when to tank' should be between 0 and 1023";
}
if (!int.TryParse(startingEdgeTextBox.Text, out dummy) || dummy < 0 || dummy > 100)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Starting Edge' should be between 0 and 100%";
}
if (!int.TryParse(thresholdLoTextBox.Text, out divLo) || divLo < 0 || divLo > 100)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Threshold LO' should be between 0 and 100%";
}
if (!int.TryParse(thresholdHiTextBox.Text, out divHi) || dummy > 100 || divHi <= divLo)
{
flags |= CfgUpdateFlags.Error;
if (divHi <= divLo)
{
message += Environment.NewLine + "'Threshold HI' should greater then 'Threshold LO'";
}
else
{
message += Environment.NewLine + "'Threshold HI' should be between 0 and 100%";
}
}
if (!int.TryParse(dfltSwitchTimeStartTextBox.Text, out dummy) || dummy <= 0)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Default switch time start' should be positive integer";
}
if (!int.TryParse(dfltSwitchTimeEndTextBox.Text, out dummy) || dummy <= 0)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Default switch time end' should be positive integer";
}
return flags;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
// CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
if (!config.Name.Equals(nameTextBox.Text))
{
config.Name = nameTextBox.Text;
flags |= CfgUpdateFlags.RestartRqrd;
}
string parentname = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
if (!config.ParentName.Equals(parentname))
{
config.ParentName = parentname;
flags |= CfgUpdateFlags.RestartRqrd;
}
int tmp = int.Parse(bitPositionTextBox.Text);
if (config.BitNr != tmp)
{
config.BitNr = tmp;
flags |= CfgUpdateFlags.RestartRqrd;
}
tmp = int.Parse(adcNrTextBox.Text);
if (config.AdcNr != tmp)
{
config.AdcNr = tmp;
flags |= CfgUpdateFlags.RestartRqrd;
}
tmp = int.Parse(adcToSinkTextBox.Text);
if (config.AdcValueToSink != tmp)
{
config.AdcValueToSink = tmp;
flags |= CfgUpdateFlags.RestartRqrd;
}
tmp = int.Parse(adcToTankTextBox.Text);
if (config.AdcValueToTank != tmp)
{
config.AdcValueToTank = tmp;
flags |= CfgUpdateFlags.RestartRqrd;
}
tmp = int.Parse(startingEdgeTextBox.Text);
if (config.StartingLevel != tmp)
{
config.StartingLevel = tmp;
flags |= CfgUpdateFlags.RestartRqrd;
}
tmp = int.Parse(thresholdLoTextBox.Text);
if (config.ThresholdLo != tmp)
{
config.ThresholdLo = tmp;
flags |= CfgUpdateFlags.RestartRqrd;
}
tmp = int.Parse(thresholdHiTextBox.Text);
if (config.ThresholdHi != tmp)
{
config.ThresholdHi = tmp;
flags |= CfgUpdateFlags.RestartRqrd;
}
tmp = int.Parse(dfltSwitchTimeStartTextBox.Text);
if (config.DfltSwithTimeStartMs != tmp)
{
config.DfltSwithTimeStartMs = tmp;
flags |= CfgUpdateFlags.RestartRqrd;
}
tmp = int.Parse(dfltSwitchTimeEndTextBox.Text);
if (config.DfltSwithTimeEndMs != tmp)
{
config.DfltSwithTimeEndMs = tmp;
flags |= CfgUpdateFlags.RestartRqrd;
}
return flags;
}
int adc1;
int pct1;
int adc2;
int pct2;
private void getButton1_Click(object sender, EventArgs e)
{
Diverter.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.GetAdc1, config));
}
private void getButton2_Click(object sender, EventArgs e)
{
Diverter.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.GetAdc2, config));
}
private void setButton_Click(object sender, EventArgs e)
{
int tmpPct1;
int tmpPct2;
if ((int.TryParse(pctTextBox1.Text, out tmpPct1) && (tmpPct1 >= 0) && (tmpPct1 <= 100)) &&
(int.TryParse(pctTextBox2.Text, out tmpPct2) && (tmpPct2 >= 0) && (tmpPct2 <= 100)))
{
pct1 = tmpPct1;
pct2 = tmpPct2;
UpdateDivAdc();
}
}
void UpdateDivAdc()
{
if ((adc1 == adc2) || (pct1 == pct2)) return;
double factor = (float)(adc2 - adc1) / (float)(pct2 - pct1);
int adcToSink = (int)((float)(0 - pct1) * factor + (float)adc1 + 0.5f);
int adcToTank = (int)((float)(100 - pct1) * factor + (float)adc1 + 0.5f);
if ((adcToSink >= 0) && (adcToTank >= 0))
{
adcToSinkTextBox.Text = adcToSink.ToString();
adcToTankTextBox.Text = adcToTank.ToString();
}
}
private void startButton_Click(object sender, EventArgs e)
{
Diverter.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.DivToTank, config));
}
private void stopButton_Click(object sender, EventArgs e)
{
Diverter.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.DivToSink, config));
}
private void updateButton_Click(object sender, EventArgs e)
{
Diverter.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.ReadDivTransition, config));
}
#region Configuration Change Handling
public static void OnCmdResponse(object sender, CmdResponseArgs args)
{
if (CmdResponseHandler == null) return;
try { CmdResponseHandler(sender, args); }
catch (Exception e) { log.Error("CmdResponseHandler(...) failed", e); }
}
public static event EventHandler<CmdResponseArgs> CmdResponseHandler;
public void StartResponseHandler()
{
Handlers.AdcChangedHandler += delegate(object sndr, CmdResponseArgs args)
{
if (InvokeRequired) { Invoke(new EventHandler<CmdResponseArgs>(OnAdcChanged), sndr, args); }
else OnAdcChanged(sndr, args);
};
CmdResponseHandler += delegate(object sender, CmdResponseArgs args)
{
if (args.Command == CfgChangeCmd.GetAdc1)
{
adc1 = args.Response;
adcTextBox1.Text = adc1.ToString();
}
else if (args.Command == CfgChangeCmd.GetAdc2)
{
adc2 = args.Response;
adcTextBox2.Text = adc2.ToString();
}
};
}
public void StopResponseHandler()
{
CmdResponseHandler = null;
}
void OnAdcChanged(object sender, CmdResponseArgs data)
{
if (data.Command == CfgChangeCmd.GetAdc && data.Id == config.BitNr)
{
adcTextBox.Text = data.Response.ToString();
}
}
#endregion Configuration Change Handling
}
}
-27
View File
@@ -1,27 +0,0 @@
///
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Elde.Diverter
{
public class DiverterFactory : IComponentFactory
{
public string ClassName { get { return "Diverter"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Diverter.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Diverter(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Diverter(cfg, components); }
public IComponentCfg DefaultConfig() { return new DiverterCfg(this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(DiverterCfg.Serializer, component, this);
}
}
}
-36
View File
@@ -1,36 +0,0 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using System;
using log4net;
namespace TBF.Rig.Elde.Diverter
{
static class Handlers
{
static readonly ILog log = LogManager.GetLogger(typeof(Handlers));
static Handlers()
{
}
/// <summary>
/// Called from the state machine when a procedure is selected and UI needs to be updated.
/// </summary>
public static void OnAdcChanged(object sender, CmdResponseArgs data)
{
if (AdcChangedHandler == null)
return;
try
{
AdcChangedHandler(sender, data);
}
catch (Exception e)
{
log.Error("AdcChangedHandler(...) failed", e);
}
}
public static event EventHandler<CmdResponseArgs> AdcChangedHandler;
}
}
@@ -1,61 +0,0 @@
///
/// Copyright (c) 2020 Sensus Slovensko a.s.
///
using System;
using log4net;
using TBF.Boxes;
namespace TBF.Rig.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() { }
}
}
-43
View File
@@ -1,43 +0,0 @@
///
/// Copyright (c) 2017-2020 Sensus Slovensko a.s.
///
using System;
using TBF.Rig.ControlBoard.Legacy;
namespace TBF.Rig.Elde.Diverter
{
public class SwitchDiverterOp : IOperation
{
CBoard controlBoard;
bool toTank;
int flowMtrNr;
public SwitchDiverterOp(CBoard controlBoard, bool toTank, int flowMtrNr)
{
this.controlBoard = controlBoard;
this.toTank = toTank;
this.flowMtrNr = flowMtrNr;
}
public void Start()
{
if (toTank)
{
controlBoard.DiverterToTank(flowMtrNr);
}
else
{
controlBoard.DiverterToSink(flowMtrNr);
}
}
public Event Run()
{
return Event.ConditionMet;
}
public void Stop()
{
}
}
}
-122
View File
@@ -1,122 +0,0 @@
///
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.Rig.ControlBoard.Legacy;
using TBF.Rig.Generic;
using TBF.Boxes;
using TBF.Resources;
namespace TBF.Rig.Elde.PressureMeter
{
public class PressureMeter : ComponentBase, GenericDevices.IPressureMeter, GenericDevices.IHasCalendarEvents, SchematicDrawing.IDrawingItCmpnt
{
private static readonly ILog log = LogManager.GetLogger(typeof(PressureMeter));
public override string ToString() { return string.Format("PressureMeter({0})", Cfg.ToString(1)); }
readonly PressureMeterCfg pressureMeterCfg;
public SchematicDrawing.IDrawingItem DrawingItem { get { return pressureMeterCfg as SchematicDrawing.IDrawingItem; } }
public readonly CBoard ControlBoard;
public readonly int Idx0; /// 0..3
public readonly byte RS485Address; /// 0..255
public PressureMeter()
{
}
public PressureMeter(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
pressureMeterCfg = cfg as PressureMeterCfg;
ControlBoard = (CBoard)TbfComponents.FindComponent(cfg.ParentName, components);
if (ControlBoard == null) throw new Exception("Cannot find " + Name + " parent");
Idx0 = pressureMeterCfg.Idx0;
RS485Address = pressureMeterCfg.RS485Address;
/// Prepare data for SendCalibData() control board component method
ControlBoard.MeretRS485Address[Idx0] = RS485Address;
if (pressureMeterCfg.Protocol == Config.Entities.MeretProtocol.Undefined)
{
throw new Exception("Metret protocol not defined");
}
else if (pressureMeterCfg.Protocol == Config.Entities.MeretProtocol.Modbus)
{
ControlBoard.MeretProtocol |= (byte)(1 << Idx0);
}
log.Warn(this.ToString());
}
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
DateTime calibrationDue = pressureMeterCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
if (calibrationDue > TBF.UI.Constants.MinDate)
{
/// Calibration due date calendar event
calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
{
/// Weekly reminders (last 5 weeks)
calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
false));
}
if (DateTime.Now.Date <= calibrationDue.Date)
{
/// Daily reminders (last 5 days)
calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
true));
}
}
return calendarEvents;
}
/// <summary>
/// Returns the water pressure and convert from kPa to default units
/// </summary>
/// <returns>Pressure</returns>
public double ReadPressure()
{
double rawPressure = Config.Units.ConvertFrom(Config.Unit.kPa, ControlBoard.Pressure(Idx0));
return Config.Formulas.CorrectedValue(rawPressure, Corrections);
}
/// <summary>
/// Events: PressureDone, Error
/// </summary>
/// <param name="pressure">Reference to a variable for the pressure in Bar</param>
/// <returns>ReadPressureOp instance reference casted to IOperaton</returns>
public IOperation ReadPressureOp(ref DoubleBox pressure)
{
return new ReadPressureOp(this, ref pressure);
}
/// <summary>
/// Events: pressureDone, Error
/// </summary>
/// <param name="pressure">Reference to a variable for the pressure in Bar</param>
/// <param name="pressureDone">Event returned when measurement done</param>
/// <returns>ReadPressureOp instance reference casted to IOperaton</returns>
public IOperation ReadPressureOp(ref DoubleBox pressure, Event pressureDone)
{
return new ReadPressureOp(this, ref pressure, pressureDone);
}
}
}
@@ -1,79 +0,0 @@
///
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
using Config.Entities;
using SchematicDrawing;
using TBF.Rig.Generic;
namespace TBF.Rig.Elde.PressureMeter
{
public class PressureMeterCfg : ComponentCfgBase, IChildComponentCfg, TBF.Rig.GenericDevices.ICalibInfoCfg, IDrawingItem
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(PressureMeterCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new PressureMeterCfgCtrl(); }
///
/// Serialized parameters
///
public int Idx0; /// 0..3
public MeretProtocol Protocol; /// Meret or Modbus
public byte RS485Address; /// 0..255
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
/// Schematic drawing info
public Shape Shape { get; set; }
public int X { get; set; }
public int Y { get; set; }
public Sz Sz { get; set; }
public Orient Orient { get; set; }
public bool Flip { get; set; }
public int LblX { get; set; }
public int LblY { get; set; }
public Orient LblOrient { get; set; }
[XmlIgnore]
public IList<GNode> GNodes { get; set; }
/// Private parameterless constructor invoked by all other (public) constructors
PressureMeterCfg()
{
GNodes = new List<GNode>();
}
public PressureMeterCfg(IComponentFactory factory)
: this()
{
Shape = Shape.PressM;
Sz = Sz.M;
Factory = factory;
Name = "Pr";
ParentName = "CB";
Idx0 = 0;
Protocol = MeretProtocol.Modbus;
RS485Address = 99;
}
public string ToString(int i)
{
return string.Format("Name={0}, Parent={1}, Idx0={2}, Protocol={3}, Address={4}",
Name,
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName),
Idx0,
Protocol.ToDescription(),
RS485Address);
}
}
}
@@ -1,180 +0,0 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
namespace TBF.Rig.Elde.PressureMeter
{
partial class PressureMeterCfgCtrl
{
/// <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.positionTextBox = new System.Windows.Forms.TextBox();
this.positionLabel = new System.Windows.Forms.Label();
this.parentNameLabel = new System.Windows.Forms.Label();
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.componentNameLabel = new System.Windows.Forms.Label();
this.rs485AddressLabel = new System.Windows.Forms.Label();
this.rs485AddressTextBox = new System.Windows.Forms.TextBox();
this.parentNameComboBox = new System.Windows.Forms.ComboBox();
this.protocolComboBox = new System.Windows.Forms.ComboBox();
this.protocolLabel = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// positionTextBox
//
this.positionTextBox.Enabled = false;
this.positionTextBox.Location = new System.Drawing.Point(138, 104);
this.positionTextBox.Name = "positionTextBox";
this.positionTextBox.Size = new System.Drawing.Size(46, 20);
this.positionTextBox.TabIndex = 6;
//
// positionLabel
//
this.positionLabel.AutoSize = true;
this.positionLabel.Location = new System.Drawing.Point(28, 107);
this.positionLabel.Name = "positionLabel";
this.positionLabel.Size = new System.Drawing.Size(44, 13);
this.positionLabel.TabIndex = 5;
this.positionLabel.Text = "Position";
//
// parentNameLabel
//
this.parentNameLabel.AutoSize = true;
this.parentNameLabel.Location = new System.Drawing.Point(28, 81);
this.parentNameLabel.Name = "parentNameLabel";
this.parentNameLabel.Size = new System.Drawing.Size(69, 13);
this.parentNameLabel.TabIndex = 3;
this.parentNameLabel.Text = "Parent Name";
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(138, 52);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(130, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(28, 55);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// componentNameLabel
//
this.componentNameLabel.AutoSize = true;
this.componentNameLabel.Location = new System.Drawing.Point(135, 28);
this.componentNameLabel.Name = "componentNameLabel";
this.componentNameLabel.Size = new System.Drawing.Size(83, 13);
this.componentNameLabel.TabIndex = 0;
this.componentNameLabel.Text = "ComonentName";
//
// rs485AddressLabel
//
this.rs485AddressLabel.AutoSize = true;
this.rs485AddressLabel.Location = new System.Drawing.Point(28, 159);
this.rs485AddressLabel.Name = "rs485AddressLabel";
this.rs485AddressLabel.Size = new System.Drawing.Size(81, 13);
this.rs485AddressLabel.TabIndex = 9;
this.rs485AddressLabel.Text = "RS485 Address";
//
// rs485AddressTextBox
//
this.rs485AddressTextBox.Enabled = false;
this.rs485AddressTextBox.Location = new System.Drawing.Point(138, 156);
this.rs485AddressTextBox.Name = "rs485AddressTextBox";
this.rs485AddressTextBox.Size = new System.Drawing.Size(46, 20);
this.rs485AddressTextBox.TabIndex = 10;
//
// parentNameComboBox
//
this.parentNameComboBox.Enabled = false;
this.parentNameComboBox.FormattingEnabled = true;
this.parentNameComboBox.Location = new System.Drawing.Point(138, 78);
this.parentNameComboBox.Name = "parentNameComboBox";
this.parentNameComboBox.Size = new System.Drawing.Size(130, 21);
this.parentNameComboBox.TabIndex = 4;
//
// protocolComboBox
//
this.protocolComboBox.Enabled = false;
this.protocolComboBox.FormattingEnabled = true;
this.protocolComboBox.Location = new System.Drawing.Point(138, 130);
this.protocolComboBox.Name = "protocolComboBox";
this.protocolComboBox.Size = new System.Drawing.Size(130, 21);
this.protocolComboBox.TabIndex = 8;
//
// protocolLabel
//
this.protocolLabel.AutoSize = true;
this.protocolLabel.Location = new System.Drawing.Point(28, 133);
this.protocolLabel.Name = "protocolLabel";
this.protocolLabel.Size = new System.Drawing.Size(46, 13);
this.protocolLabel.TabIndex = 7;
this.protocolLabel.Text = "Protocol";
//
// PressureMeterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.protocolComboBox);
this.Controls.Add(this.protocolLabel);
this.Controls.Add(this.parentNameComboBox);
this.Controls.Add(this.rs485AddressTextBox);
this.Controls.Add(this.rs485AddressLabel);
this.Controls.Add(this.positionTextBox);
this.Controls.Add(this.positionLabel);
this.Controls.Add(this.parentNameLabel);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.componentNameLabel);
this.Name = "PressureMeterCfgCtrl";
this.Size = new System.Drawing.Size(300, 200);
this.Load += new System.EventHandler(this.PressureMeterCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox positionTextBox;
private System.Windows.Forms.Label positionLabel;
private System.Windows.Forms.Label parentNameLabel;
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label componentNameLabel;
private System.Windows.Forms.Label rs485AddressLabel;
private System.Windows.Forms.TextBox rs485AddressTextBox;
private System.Windows.Forms.ComboBox parentNameComboBox;
private System.Windows.Forms.ComboBox protocolComboBox;
private System.Windows.Forms.Label protocolLabel;
}
}
@@ -1,133 +0,0 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using System;
using System.Windows.Forms;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.UI.Bench.Components;
namespace TBF.Rig.Elde.PressureMeter
{
public partial class PressureMeterCfgCtrl : UserControl, IComponentCfgCtrl
{
ComponentParametersDlg parent;
public bool ShowMore { get { return false; } }
PressureMeterCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as PressureMeterCfg;
Redraw();
}
}
public PressureMeterCfgCtrl()
{
InitializeComponent();
}
private void PressureMeterCfgCtrl_Load(object sender, EventArgs e)
{
parent = ParentForm as ComponentParametersDlg;
if (parent == null) return;
if (parent.CmpntEntities != null)
{
foreach (var cmpnt in parent.CmpntEntities)
{
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is ControlBoard.Legacy.Factory)
{
parentNameComboBox.Items.Add(cmpnt.Name);
}
}
}
for (MeretProtocol prot = MeretProtocol.Meret; prot < MeretProtocol.Count; prot++)
{
protocolComboBox.Items.Add(prot.ToDescription());
}
Redraw();
}
public void Closing()
{
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
componentNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
positionTextBox.Text = config.Idx0.ToString();
protocolComboBox.Text = config.Protocol.ToDescription();
rs485AddressTextBox.Text = config.RS485Address.ToString();
}
public void Unlock()
{
nameTextBox.Enabled = true;
parentNameComboBox.Enabled = true;
positionTextBox.Enabled = true;
protocolComboBox.Enabled = true;
rs485AddressTextBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
int dummy;
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Parent Name'";
}
if (!int.TryParse(positionTextBox.Text, out dummy) || dummy < 0 || dummy > 15)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Position' should be between 0 and 15";
}
if (!protocolComboBox.Items.Contains(protocolComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Protocol'";
}
if (!int.TryParse(rs485AddressTextBox.Text, out dummy) || dummy < 0 || dummy > 255)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'RS485 Address' should be between 0 and 255";
}
return flags;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
config.Name = nameTextBox.Text;
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
config.Idx0 = int.Parse(positionTextBox.Text);
config.Protocol = MeretProtocol.Undefined;
for (MeretProtocol prot = MeretProtocol.Meret; prot < MeretProtocol.Count; prot++)
{
if (protocolComboBox.Text == prot.ToDescription()) { config.Protocol = prot; break; }
}
config.RS485Address = (byte)int.Parse(rs485AddressTextBox.Text);
return flags;
}
}
}
@@ -1,27 +0,0 @@
///
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Elde.PressureMeter
{
public class PressureMeterFactory : IComponentFactory
{
public string ClassName { get { return "PressureMeter"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { PressureMeter.ResetStaticProperties(); }
public IComponent DummyComponent() { return new PressureMeter(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new PressureMeter(cfg, components); }
public IComponentCfg DefaultConfig() { return new PressureMeterCfg(this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(PressureMeterCfg.Serializer, component, this);
}
}
}
@@ -1,62 +0,0 @@
///
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
///
using System;
using log4net;
using TBF.Boxes;
namespace TBF.Rig.Elde.PressureMeter
{
public class ReadPressureOp : IOperation
{
private static readonly ILog log = LogManager.GetLogger(typeof(ReadPressureOp));
public override string ToString() { return string.Format("ReadPressureOp(.,{0},{1},.)", eventDone, pressureMeter.Idx0); }
/// Set by the constructor
readonly PressureMeter pressureMeter;
readonly Event eventDone;
/// Measured value
DoubleBox pressure;
/// <summary>
/// Events: PressureInDone, PressureOutDone or Error
/// </summary>
/// <param name="pressureMeter">Pressure meter reference</param>
/// <param name="pressure">Reference to the measured pressure variable, value is in bar</param>
/// <param name="eventDone">Event to be returned by Run() when completed OK</param>
public ReadPressureOp(PressureMeter pressureMeter, ref DoubleBox pressure, Event eventDone)
{
if (pressureMeter == null) throw new ArgumentNullException("pressureMeter");
this.pressureMeter = pressureMeter;
this.pressure = pressure;
this.eventDone = eventDone;
log.Debug(this.ToString());
}
public ReadPressureOp(PressureMeter pressureMeter, ref DoubleBox pressure)
: this(pressureMeter, ref pressure, Event.PressureDone)
{
}
/// <summary>Start this operation</summary>
public void Start()
{
pressure.Val = pressureMeter.ReadPressure();
}
/// <summary>Run this operation</summary>
/// <returns>
/// Event.PressureInDone or Event.PressureOutDone
/// </returns>
public Event Run()
{
pressure.Val = pressureMeter.ReadPressure();
return eventDone;
}
/// <summary>Stop this operation</summary>
public void Stop() { }
}
}
@@ -1,111 +0,0 @@
///
/// Copyright (c) 2015-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.Rig.ControlBoard.Legacy;
using TBF.Boxes;
using TBF.Resources;
namespace TBF.Rig.Elde.PressureMeterInternal
{
public class PressureMeter : ComponentBase, GenericDevices.IPressureMeter, GenericDevices.IHasCalendarEvents, SchematicDrawing.IDrawingItCmpnt
{
private static readonly ILog log = LogManager.GetLogger(typeof(PressureMeter));
public override string ToString() { return string.Format("PressureMeter({0})", Cfg.ToString(1)); }
readonly PressureMeterCfg pressureMeterCfg;
public SchematicDrawing.IDrawingItem DrawingItem { get { return pressureMeterCfg as SchematicDrawing.IDrawingItem; } }
public readonly CBoard ControlBoard;
public int Idx0 { get { return pressureMeterCfg.Idx0; } } /// 0..7
public PressureMeter() { }
public PressureMeter(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
pressureMeterCfg = cfg as PressureMeterCfg;
ControlBoard = (CBoard)TbfComponents.FindComponent(cfg.ParentName, components);
if (ControlBoard == null) throw new Exception("Cannot find " + Name + " parent");
/// Prepare data for SendCalibData() control board component method
ControlBoard.TempCalibData[pressureMeterCfg.CoefsIdx0, 0] = pressureMeterCfg.A1;
ControlBoard.TempCalibData[pressureMeterCfg.CoefsIdx0, 1] = pressureMeterCfg.A2;
ControlBoard.TempCalibData[pressureMeterCfg.CoefsIdx0, 2] = pressureMeterCfg.A3;
ControlBoard.TempCalibData[pressureMeterCfg.CoefsIdx0, 3] = pressureMeterCfg.A4;
ControlBoard.TempCalibData[pressureMeterCfg.CoefsIdx0, 4] = pressureMeterCfg.A5;
ControlBoard.MeretRS485Address[0] = 0; /// This disables Merets, Groch temperatures, enables on-board A/D pressure and temperature
log.Warn(this.ToString());
}
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
DateTime calibrationDue = pressureMeterCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
if (calibrationDue > TBF.UI.Constants.MinDate)
{
/// Calibration due date calendar event
calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
{
/// Weekly reminders (last 5 weeks)
calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
false));
}
if (DateTime.Now.Date <= calibrationDue.Date)
{
/// Daily reminders (last 5 days)
calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
true));
}
}
return calendarEvents;
}
/// <summary>
/// Returns the water pressure and convert from kPa to default units
/// </summary>
/// <returns>Pressure</returns>
public double ReadPressure()
{
double rawPressure = Config.Units.ConvertFrom(Config.Unit.kPa, ControlBoard.Pressure(Idx0));
return Config.Formulas.CorrectedValue(rawPressure, Corrections);
}
/// <summary>
/// Events: PressureDone, Error
/// </summary>
/// <param name="pressure">Reference to a variable for the pressure in Bar</param>
/// <returns>ReadPressureOp instance reference casted to IOperaton</returns>
public IOperation ReadPressureOp(ref DoubleBox pressure)
{
return new ReadPressureOp(this, ref pressure);
}
/// <summary>
/// Events: pressureDone, Error
/// </summary>
/// <param name="pressure">Reference to a variable for the pressure in Bar</param>
/// <param name="pressureDone">Event returned when measurement done</param>
/// <returns>ReadPressureOp instance reference casted to IOperaton</returns>
public IOperation ReadPressureOp(ref DoubleBox pressure, Event pressureDone)
{
return new ReadPressureOp(this, ref pressure, pressureDone);
}
}
}
@@ -1,86 +0,0 @@
///
/// Copyright (c) 2015-2016 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
using Config.Entities;
using SchematicDrawing;
using TBF.Rig.Generic;
namespace TBF.Rig.Elde.PressureMeterInternal
{
public class PressureMeterCfg : ComponentCfgBase, IChildComponentCfg, TBF.Rig.GenericDevices.ICalibInfoCfg, IDrawingItem
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(PressureMeterCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new PressureMeterCfgCtrl(); }
///
/// Serialized parameters
///
public int Idx0; /// 0..7
public int CoefsIdx0; /// 0..7
public float A1;
public float A2;
public float A3;
public float A4;
public float A5;
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
/// Schematic drawing info
public Shape Shape { get; set; }
public int X { get; set; }
public int Y { get; set; }
public Sz Sz { get; set; }
public Orient Orient { get; set; }
public bool Flip { get; set; }
public int LblX { get; set; }
public int LblY { get; set; }
public Orient LblOrient { get; set; }
[XmlIgnore]
public IList<GNode> GNodes { get; set; }
/// Private parameterless constructor invoked by all other (public) constructors
PressureMeterCfg()
{
GNodes = new List<GNode>();
}
public PressureMeterCfg(IComponentFactory factory)
: this()
{
Shape = Shape.PressM;
Sz = Sz.M;
Factory = factory;
Name = "Pr";
ParentName = "CB";
Idx0 = 0;
CoefsIdx0 = 0;
A1 = 0;
A2 = 0;
A3 = 0;
A4 = 0;
A5 = 0;
}
public string ToString(int i)
{
return string.Format("Name={0}, Parent={1}, Idx0={2}, CoefsIdx0={3}, A1={4}, A2={5}, A3={6}, A4={7}, A5={8}",
Name,
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName),
Idx0, CoefsIdx0,
A1, A2, A3, A4, A5);
}
}
}
@@ -1,272 +0,0 @@
///
/// Copyright (c) 2015 Sensus Metering Systems
/// Author: Milan Hanajik
///
namespace TBF.Rig.Elde.PressureMeterInternal
{
partial class PressureMeterCfgCtrl
{
/// <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.positionTextBox = new System.Windows.Forms.TextBox();
this.positionLabel = new System.Windows.Forms.Label();
this.parentNameLabel = new System.Windows.Forms.Label();
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.a1TextBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.a2TextBox = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.a3TextBox = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.a5TextBox = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.a4TextBox = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.parentNameComboBox = new System.Windows.Forms.ComboBox();
this.coefsIdxTextBox = new System.Windows.Forms.TextBox();
this.coefsIdxLabel = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// positionTextBox
//
this.positionTextBox.Enabled = false;
this.positionTextBox.Location = new System.Drawing.Point(130, 81);
this.positionTextBox.Name = "positionTextBox";
this.positionTextBox.Size = new System.Drawing.Size(46, 20);
this.positionTextBox.TabIndex = 6;
//
// positionLabel
//
this.positionLabel.AutoSize = true;
this.positionLabel.Location = new System.Drawing.Point(20, 84);
this.positionLabel.Name = "positionLabel";
this.positionLabel.Size = new System.Drawing.Size(44, 13);
this.positionLabel.TabIndex = 5;
this.positionLabel.Text = "Position";
//
// parentNameLabel
//
this.parentNameLabel.AutoSize = true;
this.parentNameLabel.Location = new System.Drawing.Point(20, 60);
this.parentNameLabel.Name = "parentNameLabel";
this.parentNameLabel.Size = new System.Drawing.Size(69, 13);
this.parentNameLabel.TabIndex = 3;
this.parentNameLabel.Text = "Parent Name";
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(130, 34);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(130, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(20, 37);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(127, 10);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// a1TextBox
//
this.a1TextBox.Enabled = false;
this.a1TextBox.Location = new System.Drawing.Point(130, 127);
this.a1TextBox.Name = "a1TextBox";
this.a1TextBox.Size = new System.Drawing.Size(130, 20);
this.a1TextBox.TabIndex = 10;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(20, 130);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(20, 13);
this.label1.TabIndex = 9;
this.label1.Text = "A1";
//
// a2TextBox
//
this.a2TextBox.Enabled = false;
this.a2TextBox.Location = new System.Drawing.Point(130, 148);
this.a2TextBox.Name = "a2TextBox";
this.a2TextBox.Size = new System.Drawing.Size(130, 20);
this.a2TextBox.TabIndex = 12;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(20, 151);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(20, 13);
this.label2.TabIndex = 11;
this.label2.Text = "A2";
//
// a3TextBox
//
this.a3TextBox.Enabled = false;
this.a3TextBox.Location = new System.Drawing.Point(130, 169);
this.a3TextBox.Name = "a3TextBox";
this.a3TextBox.Size = new System.Drawing.Size(130, 20);
this.a3TextBox.TabIndex = 14;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(20, 172);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(20, 13);
this.label3.TabIndex = 13;
this.label3.Text = "A3";
//
// a5TextBox
//
this.a5TextBox.Enabled = false;
this.a5TextBox.Location = new System.Drawing.Point(130, 211);
this.a5TextBox.Name = "a5TextBox";
this.a5TextBox.Size = new System.Drawing.Size(130, 20);
this.a5TextBox.TabIndex = 18;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(20, 214);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(20, 13);
this.label5.TabIndex = 17;
this.label5.Text = "A5";
//
// a4TextBox
//
this.a4TextBox.Enabled = false;
this.a4TextBox.Location = new System.Drawing.Point(130, 190);
this.a4TextBox.Name = "a4TextBox";
this.a4TextBox.Size = new System.Drawing.Size(130, 20);
this.a4TextBox.TabIndex = 16;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(20, 193);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(20, 13);
this.label4.TabIndex = 15;
this.label4.Text = "A4";
//
// parentNameComboBox
//
this.parentNameComboBox.Enabled = false;
this.parentNameComboBox.FormattingEnabled = true;
this.parentNameComboBox.Location = new System.Drawing.Point(130, 57);
this.parentNameComboBox.Name = "parentNameComboBox";
this.parentNameComboBox.Size = new System.Drawing.Size(130, 21);
this.parentNameComboBox.TabIndex = 4;
//
// coefsIdxTextBox
//
this.coefsIdxTextBox.Enabled = false;
this.coefsIdxTextBox.Location = new System.Drawing.Point(130, 104);
this.coefsIdxTextBox.Name = "coefsIdxTextBox";
this.coefsIdxTextBox.Size = new System.Drawing.Size(46, 20);
this.coefsIdxTextBox.TabIndex = 8;
//
// coefsIdxLabel
//
this.coefsIdxLabel.AutoSize = true;
this.coefsIdxLabel.Location = new System.Drawing.Point(20, 107);
this.coefsIdxLabel.Name = "coefsIdxLabel";
this.coefsIdxLabel.Size = new System.Drawing.Size(78, 13);
this.coefsIdxLabel.TabIndex = 7;
this.coefsIdxLabel.Text = "Coeficients idx.";
//
// TempMeterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.coefsIdxTextBox);
this.Controls.Add(this.coefsIdxLabel);
this.Controls.Add(this.parentNameComboBox);
this.Controls.Add(this.a5TextBox);
this.Controls.Add(this.label5);
this.Controls.Add(this.a4TextBox);
this.Controls.Add(this.label4);
this.Controls.Add(this.a3TextBox);
this.Controls.Add(this.label3);
this.Controls.Add(this.a2TextBox);
this.Controls.Add(this.label2);
this.Controls.Add(this.a1TextBox);
this.Controls.Add(this.label1);
this.Controls.Add(this.positionTextBox);
this.Controls.Add(this.positionLabel);
this.Controls.Add(this.parentNameLabel);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "TempMeterCfgCtrl";
this.Size = new System.Drawing.Size(300, 240);
this.Load += new System.EventHandler(this.TempMeterCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox positionTextBox;
private System.Windows.Forms.Label positionLabel;
private System.Windows.Forms.Label parentNameLabel;
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.TextBox a1TextBox;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox a2TextBox;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox a3TextBox;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox a5TextBox;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox a4TextBox;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.ComboBox parentNameComboBox;
private System.Windows.Forms.TextBox coefsIdxTextBox;
private System.Windows.Forms.Label coefsIdxLabel;
}
}
@@ -1,160 +0,0 @@
///
/// Copyright (c) 2015-2018 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.UI.Bench.Components;
namespace TBF.Rig.Elde.PressureMeterInternal
{
public partial class PressureMeterCfgCtrl : UserControl, IComponentCfgCtrl
{
ComponentParametersDlg parent;
public bool ShowMore { get { return false; } }
PressureMeterCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as PressureMeterCfg;
Redraw();
}
}
public PressureMeterCfgCtrl()
{
InitializeComponent();
}
private void TempMeterCfgCtrl_Load(object sender, EventArgs e)
{
parent = ParentForm as ComponentParametersDlg;
if (parent == null) return;
if (parent.CmpntEntities != null)
{
foreach (var cmpnt in parent.CmpntEntities)
{
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is ControlBoard.Legacy.Factory)
{
parentNameComboBox.Items.Add(cmpnt.Name);
}
}
}
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;
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
positionTextBox.Text = config.Idx0.ToString();
coefsIdxTextBox.Text = config.CoefsIdx0.ToString();
a1TextBox.Text = config.A1.ToString();
a2TextBox.Text = config.A2.ToString();
a3TextBox.Text = config.A3.ToString();
a4TextBox.Text = config.A4.ToString();
a5TextBox.Text = config.A5.ToString();
}
public void Unlock()
{
nameTextBox.Enabled = true;
parentNameComboBox.Enabled = true;
positionTextBox.Enabled = true;
coefsIdxTextBox.Enabled = true;
a1TextBox.Enabled = true;
a2TextBox.Enabled = true;
a3TextBox.Enabled = true;
a4TextBox.Enabled = true;
a5TextBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
int dummy;
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Parent Name'";
}
if (!int.TryParse(positionTextBox.Text, out dummy) || dummy < 0 || dummy > 7)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Position' should be between 0 and 7";
}
if (!int.TryParse(coefsIdxTextBox.Text, out dummy) || dummy < 0 || dummy > 7)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Coeficients idx.' should be between 0 and 7";
}
float fdummy;
if (!Utils.TryParseEFloat(a1TextBox.Text, out fdummy))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'A1' is not valid";
}
if (!Utils.TryParseEFloat(a2TextBox.Text, out fdummy))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'A2' is not valid";
}
if (!Utils.TryParseEFloat(a3TextBox.Text, out fdummy))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'A3' is not valid";
}
if (!Utils.TryParseEFloat(a4TextBox.Text, out fdummy))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'A4' is not valid";
}
if (!Utils.TryParseEFloat(a5TextBox.Text, out fdummy))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'A5' is not valid";
}
return flags;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
config.Name = nameTextBox.Text;
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
config.Idx0 = int.Parse(positionTextBox.Text);
config.CoefsIdx0 = int.Parse(coefsIdxTextBox.Text);
bool updateOk = Utils.TryParseEFloat(a1TextBox.Text, out config.A1) &&
Utils.TryParseEFloat(a2TextBox.Text, out config.A2) &&
Utils.TryParseEFloat(a3TextBox.Text, out config.A3) &&
Utils.TryParseEFloat(a4TextBox.Text, out config.A4) &&
Utils.TryParseEFloat(a5TextBox.Text, out config.A5);
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,27 +0,0 @@
///
/// Copyright (c) 2015-2016 Sensus Metering Systems
//
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Elde.PressureMeterInternal
{
public class PressureMeterFactory : IComponentFactory
{
public string ClassName { get { return "PressureMeterInternal"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { PressureMeter.ResetStaticProperties(); }
public IComponent DummyComponent() { return new PressureMeter(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new PressureMeter(cfg, components); }
public IComponentCfg DefaultConfig() { return new PressureMeterCfg(this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(PressureMeterCfg.Serializer, component, this);
}
}
}
@@ -1,59 +0,0 @@
///
/// Copyright (c) 2015-2021 Sensus Slovensko a.s.
///
using System;
using log4net;
using TBF.Boxes;
namespace TBF.Rig.Elde.PressureMeterInternal
{
public class ReadPressureOp : IOperation
{
private static readonly ILog log = LogManager.GetLogger(typeof(ReadPressureOp));
public override string ToString() { return string.Format("ReadPressureOp()"); }
/// Set by the constructor
readonly PressureMeter pressureMeter;
readonly Event eventDone;
DoubleBox pressureBox;
/// <summary>
/// Events: PressureInDone, PressureOutDone or Error
/// </summary>
/// <param name="pressureMeter">Pressure meter reference</param>
/// <param name="pressureBox">Reference to the measured pressure variable, value is in bar</param>
/// <param name="eventDone">Event to be returned by Run() when completed OK</param>
public ReadPressureOp(PressureMeter pressureMeter, ref DoubleBox pressureBox, Event eventDone)
{
if (pressureMeter == null) throw new ArgumentNullException("pressureMeter");
this.pressureMeter = pressureMeter;
this.pressureBox = pressureBox;
this.eventDone = eventDone;
log.Debug(this.ToString());
}
public ReadPressureOp(PressureMeter pressureMeter, ref DoubleBox pressure)
: this(pressureMeter, ref pressure, Event.PressureDone)
{
}
/// <summary>Start this operation</summary>
public void Start()
{
pressureBox.Val = pressureMeter.ReadPressure();
}
/// <summary>Run this operation</summary>
/// <returns>
/// Event.PressureInDone or Event.PressureOutDone
/// </returns>
public Event Run()
{
pressureBox.Val = pressureMeter.ReadPressure();
return eventDone;
}
/// <summary>Stop this operation</summary>
public void Stop() { }
}
}
-179
View File
@@ -1,179 +0,0 @@
///
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using log4net;
using Dirichlet.Numerics;
using SchematicDrawing;
using TBF.Rig.ControlBoard.Legacy;
namespace TBF.Rig.Elde.PumpWithFM
{
public class Pump : ComponentBase, GenericDevices.IPumpFM, GenericDevices.IValve, IOperation, IDrawingItCmpntWithSetpoint
{
private static readonly ILog log = LogManager.GetLogger(typeof(Pump));
public override string ToString() { return string.Format("PumpWithFM({0})", Cfg.ToString(1)); }
readonly PumpCfg pumpCfg;
public IDrawingItem DrawingItem { get { return pumpCfg as IDrawingItem; } }
public int Delay { get { return pumpCfg.Delay; } }
public ValveCategory Category { get { return ValveCategory.Feeding; } } /// Pump category is Feeding
public GenericDevices.IValve CoupledTo { get { return null; } }
public bool InvertCouple { get { return false; } }
public int LagOpening { get { return 0; } }
public int LagClosing { get { return 0; } }
readonly CBoard controlBoard;
readonly int bitPosition; /// 0 .. 63
int FMIndex; /// 0 .. FMPumpsCount-1
public readonly UInt128 Mask; /// derived from bitPosition in the constructor
public bool State
{
get { return (controlBoard.Route & Mask) != 0; }
}
/// <summary>
/// Pump power in [%] in range 0 .. 100.0f
/// </summary>
private double power;
public double Power { get { return power; } }
///
public double SetpointVal
{
get { return power; }
set
{
power = (float)value;
if (power != 0) TurnOn(power);
}
}
///
public void IncreaseSetpoint()
{
power += 0.05;
if (power > 100.0) power = 100.0;
TurnOn(power);
}
///
public void DecreaseSetpoint()
{
power -= 0.05;
if (power <= 0)
{
power = 0;
TurnOff();
}
else
{
TurnOn(power);
}
}
public Pump()
{
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="cfg">Pump configuration object</param>
/// <param name="components">List of all components (used to find the control board)</param>
public Pump(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
pumpCfg = cfg as PumpCfg;
controlBoard = (CBoard)TbfComponents.FindComponent(cfg.ParentName, components);
if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
bitPosition = pumpCfg.BitNr;
Mask = (((UInt128)1) << pumpCfg.BitNr);
FMIndex = pumpCfg.FMIndex;
log.Warn(this.ToString());
}
public void TurnOn(double powerArg)
{
log.InfoFormat("{0}.TurnOn({1})", Name, powerArg);
this.power = powerArg;
controlBoard.SetFMFreq(FMIndex, powerArg);
}
public void TurnOff()
{
log.InfoFormat("{0}.TurnOff()", Name);
this.power = 0.0f;
controlBoard.SetFMFreq(FMIndex, 0.0f);
}
/// <summary>
/// The currently running operation.
/// </summary>
public enum CurrentOp
{
None,
TurnOn,
TurnOff,
}
///
CurrentOp currentOp;
double powerForOp;
/// <summary>
/// Turn the pump frequency inverter on.
/// </summary>
public IOperation TurnOnOp(double powerArg)
{
if (currentOp != CurrentOp.None) throw new Exception("Sequence error");
currentOp = CurrentOp.TurnOn;
powerForOp = powerArg;
return this;
}
/// <summary>
/// Turn the pump frequency inverter on.
/// </summary>
public IOperation TurnOffOp()
{
if (currentOp != CurrentOp.None) throw new Exception("Sequence error");
currentOp = CurrentOp.TurnOff;
return this;
}
/// <summary>Start the operation</summary>
public void Start()
{
switch (currentOp)
{
case CurrentOp.TurnOn:
TurnOn(powerForOp);
return;
case CurrentOp.TurnOff:
default:
TurnOff();
return;
}
}
/// <summary>Run the operation</summary>
public Event Run()
{
return Event.TurnPumpOnOffDone;
}
/// <summary>Stop the operation</summary>
public void Stop()
{
currentOp = CurrentOp.None;
}
}
}
-84
View File
@@ -1,84 +0,0 @@
///
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
using System.IO;
using System.Collections.Generic;
using System.Xml.Serialization;
using Config.Entities;
using SchematicDrawing;
using TBF.Rig.Generic;
namespace TBF.Rig.Elde.PumpWithFM
{
public class PumpCfg : ComponentCfgBase, IChildComponentCfg, IRouteBasedDrawingItem, IDrawingItemWithSetpoint
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(PumpCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new PumpCfgCtrl(); }
///
/// Serialized parameters
///
public int BitNr { get; set; }
public bool Inverted { get; set; } /// When true the pump function is inverted: 0 = on, 1 = off
public int FMIndex;
public int Delay;
/// Schematic drawing info
public Shape Shape { get; set; }
public int X { get; set; }
public int Y { get; set; }
public Sz Sz { get; set; }
public Orient Orient { get; set; }
public bool Flip { get; set; }
public int LblX { get; set; }
public int LblY { get; set; }
public Orient LblOrient { get; set; }
public int SetpX { get; set; }
public int SetpY { get; set; }
public Orient SetpOrient { get; set; }
public string SetpFormat { get; set; }
public Config.Unit SetpUnit { get; set; }
[XmlIgnore]
public IList<GNode> GNodes { get; set; }
[XmlIgnore]
public IList<GEdge> EdgesToSet { get; set; }
/// Private parameterless constructor invoked by all other (public) constructors
PumpCfg()
{
GNodes = new List<GNode>();
EdgesToSet = new List<GEdge>();
}
public PumpCfg(IComponentFactory factory)
: this()
{
Shape = Shape.PumpFM;
Sz = Sz.M;
SetpFormat = "{0:F0} %";
SetpUnit = Config.Unit.Pct;
Name = "P";
Factory = factory;
ParentName = "CB";
BitNr = 0;
FMIndex = 0;
Delay = 1;
}
public string ToString(int i)
{
return string.Format("Name={0}, Parent={1}, Bit={2}, FMIndex={3}, Delay={4}",
Name,
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName),
BitNr,
FMIndex,
Delay);
}
}
}
-226
View File
@@ -1,226 +0,0 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
namespace TBF.Rig.Elde.PumpWithFM
{
partial class PumpCfgCtrl
{
/// <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.bitPositionTextBox = new System.Windows.Forms.TextBox();
this.bitPositionLabel = new System.Windows.Forms.Label();
this.parentNameLabel = new System.Windows.Forms.Label();
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.parentNameComboBox = new System.Windows.Forms.ComboBox();
this.fmIndexTextBox = new System.Windows.Forms.TextBox();
this.fmIndexLabel = new System.Windows.Forms.Label();
this.delayTextBox = new System.Windows.Forms.TextBox();
this.delayLabel = new System.Windows.Forms.Label();
this.unitsComboBox = new System.Windows.Forms.ComboBox();
this.unitsLabel = new System.Windows.Forms.Label();
this.formatTextBox = new System.Windows.Forms.TextBox();
this.formatLabel = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// bitPositionTextBox
//
this.bitPositionTextBox.Enabled = false;
this.bitPositionTextBox.Location = new System.Drawing.Point(146, 99);
this.bitPositionTextBox.Name = "bitPositionTextBox";
this.bitPositionTextBox.Size = new System.Drawing.Size(46, 20);
this.bitPositionTextBox.TabIndex = 6;
//
// bitPositionLabel
//
this.bitPositionLabel.AutoSize = true;
this.bitPositionLabel.Location = new System.Drawing.Point(36, 102);
this.bitPositionLabel.Name = "bitPositionLabel";
this.bitPositionLabel.Size = new System.Drawing.Size(59, 13);
this.bitPositionLabel.TabIndex = 5;
this.bitPositionLabel.Text = "Bit Position";
//
// parentNameLabel
//
this.parentNameLabel.AutoSize = true;
this.parentNameLabel.Location = new System.Drawing.Point(36, 76);
this.parentNameLabel.Name = "parentNameLabel";
this.parentNameLabel.Size = new System.Drawing.Size(69, 13);
this.parentNameLabel.TabIndex = 3;
this.parentNameLabel.Text = "Parent Name";
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(146, 47);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(130, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(36, 50);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(143, 21);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// parentNameComboBox
//
this.parentNameComboBox.Enabled = false;
this.parentNameComboBox.FormattingEnabled = true;
this.parentNameComboBox.Location = new System.Drawing.Point(146, 73);
this.parentNameComboBox.Name = "parentNameComboBox";
this.parentNameComboBox.Size = new System.Drawing.Size(130, 21);
this.parentNameComboBox.TabIndex = 4;
//
// fmIndexTextBox
//
this.fmIndexTextBox.Enabled = false;
this.fmIndexTextBox.Location = new System.Drawing.Point(146, 124);
this.fmIndexTextBox.Name = "fmIndexTextBox";
this.fmIndexTextBox.Size = new System.Drawing.Size(46, 20);
this.fmIndexTextBox.TabIndex = 8;
//
// fmIndexLabel
//
this.fmIndexLabel.AutoSize = true;
this.fmIndexLabel.Location = new System.Drawing.Point(36, 127);
this.fmIndexLabel.Name = "fmIndexLabel";
this.fmIndexLabel.Size = new System.Drawing.Size(51, 13);
this.fmIndexLabel.TabIndex = 7;
this.fmIndexLabel.Text = "FM Index";
//
// delayTextBox
//
this.delayTextBox.Enabled = false;
this.delayTextBox.Location = new System.Drawing.Point(146, 149);
this.delayTextBox.Name = "delayTextBox";
this.delayTextBox.Size = new System.Drawing.Size(46, 20);
this.delayTextBox.TabIndex = 10;
//
// delayLabel
//
this.delayLabel.AutoSize = true;
this.delayLabel.Location = new System.Drawing.Point(36, 152);
this.delayLabel.Name = "delayLabel";
this.delayLabel.Size = new System.Drawing.Size(48, 13);
this.delayLabel.TabIndex = 9;
this.delayLabel.Text = "Delay [s]";
//
// unitsComboBox
//
this.unitsComboBox.Enabled = false;
this.unitsComboBox.FormattingEnabled = true;
this.unitsComboBox.Location = new System.Drawing.Point(146, 201);
this.unitsComboBox.Name = "unitsComboBox";
this.unitsComboBox.Size = new System.Drawing.Size(80, 21);
this.unitsComboBox.TabIndex = 32;
//
// unitsLabel
//
this.unitsLabel.AutoSize = true;
this.unitsLabel.Location = new System.Drawing.Point(36, 204);
this.unitsLabel.Name = "unitsLabel";
this.unitsLabel.Size = new System.Drawing.Size(71, 13);
this.unitsLabel.TabIndex = 31;
this.unitsLabel.Text = "Setpoint units";
//
// formatTextBox
//
this.formatTextBox.Enabled = false;
this.formatTextBox.Location = new System.Drawing.Point(146, 175);
this.formatTextBox.Name = "formatTextBox";
this.formatTextBox.Size = new System.Drawing.Size(130, 20);
this.formatTextBox.TabIndex = 30;
//
// formatLabel
//
this.formatLabel.AutoSize = true;
this.formatLabel.Location = new System.Drawing.Point(36, 178);
this.formatLabel.Name = "formatLabel";
this.formatLabel.Size = new System.Drawing.Size(78, 13);
this.formatLabel.TabIndex = 29;
this.formatLabel.Text = "Setpoint format";
//
// PumpCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.unitsComboBox);
this.Controls.Add(this.unitsLabel);
this.Controls.Add(this.formatTextBox);
this.Controls.Add(this.formatLabel);
this.Controls.Add(this.delayTextBox);
this.Controls.Add(this.delayLabel);
this.Controls.Add(this.fmIndexTextBox);
this.Controls.Add(this.fmIndexLabel);
this.Controls.Add(this.parentNameComboBox);
this.Controls.Add(this.bitPositionTextBox);
this.Controls.Add(this.bitPositionLabel);
this.Controls.Add(this.parentNameLabel);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "PumpCfgCtrl";
this.Size = new System.Drawing.Size(400, 250);
this.Load += new System.EventHandler(this.PumpCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox bitPositionTextBox;
private System.Windows.Forms.Label bitPositionLabel;
private System.Windows.Forms.Label parentNameLabel;
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.ComboBox parentNameComboBox;
private System.Windows.Forms.TextBox fmIndexTextBox;
private System.Windows.Forms.Label fmIndexLabel;
private System.Windows.Forms.TextBox delayTextBox;
private System.Windows.Forms.Label delayLabel;
private System.Windows.Forms.ComboBox unitsComboBox;
private System.Windows.Forms.Label unitsLabel;
private System.Windows.Forms.TextBox formatTextBox;
private System.Windows.Forms.Label formatLabel;
}
}
-148
View File
@@ -1,148 +0,0 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using System;
using System.Windows.Forms;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.UI.Bench.Components;
namespace TBF.Rig.Elde.PumpWithFM
{
public partial class PumpCfgCtrl : UserControl, IComponentCfgCtrl
{
ComponentParametersDlg parent;
public bool ShowMore { get { return false; } }
PumpCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as PumpCfg;
Redraw();
}
}
public PumpCfgCtrl()
{
InitializeComponent();
}
private void PumpCfgCtrl_Load(object sender, EventArgs e)
{
parent = ParentForm as ComponentParametersDlg;
if (parent == null) return;
if (parent.CmpntEntities != null)
{
foreach (var cmpnt in parent.CmpntEntities)
{
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is ControlBoard.Legacy.Factory)
{
parentNameComboBox.Items.Add(cmpnt.Name);
}
}
}
for (Config.Unit units = 0; units < global::Config.Unit.Count; units++)
{
if (global::Config.Units.IsQuantity(units, global::Config.Quantity.Error))
{
unitsComboBox.Items.Add(units.ToString());
}
}
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;
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
bitPositionTextBox.Text = config.BitNr.ToString();
fmIndexTextBox.Text = config.FMIndex.ToString();
delayTextBox.Text = config.Delay.ToString();
formatTextBox.Text = config.SetpFormat;
unitsComboBox.Text = config.SetpUnit.ToString();
}
public void Unlock()
{
nameTextBox.Enabled = true;
parentNameComboBox.Enabled = true;
bitPositionTextBox.Enabled = true;
fmIndexTextBox.Enabled = true;
delayTextBox.Enabled = true;
formatTextBox.Enabled = true;
unitsComboBox.Enabled = true;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
config.Name = nameTextBox.Text;
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
config.BitNr = int.Parse(bitPositionTextBox.Text);
config.FMIndex = int.Parse(fmIndexTextBox.Text);
config.Delay = int.Parse(delayTextBox.Text);
config.SetpFormat = formatTextBox.Text;
config.SetpUnit = global::Config.Unit.None;
for (Config.Unit units = 0; units < global::Config.Unit.Count; units++)
{
if (unitsComboBox.Text == units.ToString())
{
config.SetpUnit = units;
break;
}
}
return flags;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
int dummy;
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Parent Name'";
}
if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy >= 128)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Bit Position' should be between 0 and 127";
}
if (!int.TryParse(fmIndexTextBox.Text, out dummy) || dummy < 0)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'FM Index' should be between 0 and FMPumpsCount - 1";
}
if (!int.TryParse(delayTextBox.Text, out dummy) || dummy < 0 || dummy >= 300 || (dummy % StateMachine.Period) != 0)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Delay' should be between 0 and 300s (5min)";
}
if (!unitsComboBox.Items.Contains(unitsComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Units'";
}
return flags;
}
}
}
-120
View File
@@ -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>
-27
View File
@@ -1,27 +0,0 @@
///
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Elde.PumpWithFM
{
public class PumpFactory : IComponentFactory
{
public string ClassName { get { return "PumpWithFM"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Pump.ResetStaticProperties(); }
public IComponent DummyComponent() { return new Pump(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Pump(cfg, components); }
public IComponentCfg DefaultConfig() { return new PumpCfg(this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(PumpCfg.Serializer, component, this);
}
}
}
@@ -1,78 +0,0 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.Rig.GenericDevices;
namespace TBF.Rig.Elde.RegulValve
{
public class ChangeRegulValvePositionOp : IOperation
{
private static readonly ILog log = LogManager.GetLogger(typeof(ChangeRegulValvePositionOp));
public override string ToString()
{
return string.Format("ChangeRegulValvePositionOp({0},{1}s)", regulValve.Name, timePulseSec.ToString("F2"));
}
/// Set by the constructor
readonly TBF.Rig.ControlBoard.Legacy.CBoard controlBoard;
readonly RegulValve regulValve;
readonly int regulValveNr;
readonly double timePulseSec;
/// <summary>
/// Set required water flow.
/// Events: FlowSet, FlowTimeOut
/// </summary>
/// <param name="cb">Control board device</param>
/// <param name="rv">Regulation valve component</param>
/// <param name="posLoPct">Lower limit of the position to be achieved</param>
/// <param name="posHiPct">Upper limit of the position to be achieved</param>
/// <param name="timeout">Timeout in sec. for setting the flow</param>
/// <remarks>Only Elde.Valve flow are used, other flow on the lists are ignored</remarks>
public ChangeRegulValvePositionOp(TBF.Rig.ControlBoard.IControlBoard cb, RegulValve rv, double timePulseSec)
{
controlBoard = cb as TBF.Rig.ControlBoard.Legacy.CBoard;
if (controlBoard == null) throw new ArgumentNullException("ctrlBoard");
regulValve = rv as RegulValve;
if (regulValve == null) throw new ArgumentNullException("regValve is null or not Elde");
regulValveNr = this.regulValve.Idx1;
this.timePulseSec = timePulseSec;
log.Debug(this.ToString());
}
/// <summary>Start this operation</summary>
public void Start()
{
float positionPct = controlBoard.RValvePosition(regulValveNr);
log.WarnFormat("RV#={0}, actPos={1}%", regulValveNr, positionPct.ToString("F1"));
controlBoard.ValveMove(regulValveNr,
TBF.Rig.ControlBoard.Legacy.RegulValveMode.PulseWidth,
new double[2] { timePulseSec, timePulseSec },
regulValve.StableTime);
}
/// <summary>Run this operation</summary>
/// <returns>
/// Event.SetFlowDone
/// </returns>
public Event Run()
{
float positionPct = controlBoard.RValvePosition(regulValveNr);
log.WarnFormat("RV#={0}, actPos={1}%", regulValveNr, positionPct.ToString("F1"));
return Event.PositionReached;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
}
}
-36
View File
@@ -1,36 +0,0 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using System;
using log4net;
namespace TBF.Rig.Elde.RegulValve
{
static class Handlers
{
static readonly ILog log = LogManager.GetLogger(typeof(Handlers));
static Handlers()
{
}
/// <summary>
/// Called from the state machine when a procedure is selected and UI needs to be updated.
/// </summary>
public static void OnAdcChanged(object sender, CmdResponseArgs data)
{
if (AdcChangedHandler == null)
return;
try
{
AdcChangedHandler(sender, data);
}
catch (Exception e)
{
log.Error("AdcChangedHandler(...) failed", e);
}
}
public static event EventHandler<CmdResponseArgs> AdcChangedHandler;
}
}
-210
View File
@@ -1,210 +0,0 @@
///
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using SchematicDrawing;
using TBF.Rig.ControlBoard.Legacy;
using TBF.Rig.Generic;
using TBF.Boxes;
namespace TBF.Rig.Elde.RegulValve
{
public class RegulValve : ComponentBase, IDevice, GenericDevices.IRegValve, IDrawingItCmpntWithSetpoint
{
private static readonly ILog log = LogManager.GetLogger(typeof(RegulValve));
public override string ToString() { return string.Format("RegulValve({0})", Cfg.ToString(1)); }
public readonly RegulValveCfg RegulValveCfg;
public IDrawingItem DrawingItem { get { return RegulValveCfg as IDrawingItem; } }
IDictionary<double, double> dict;
public IDictionary<double, double> Dict { get { return dict; } }
public readonly CBoard ControlBoard;
public ValveCategory Category { get { return RegulValveCfg.Category; } }
public int Idx1 { get { return RegulValveCfg.Idx1; } } /// 1..7
public int DacValueClosed { get { return RegulValveCfg.AdcValueClosed; } } /// 0..1023
public int DacValueOpen { get { return RegulValveCfg.AdcValueOpen; } } /// 0..1023
public int StableTime { get { return RegulValveCfg.StableTime; } } /// 0=200ms, step=50ms, max. 1500ms (max.26)
public int FlowStableSec { get { return RegulValveCfg.FlowStableSec; } } /// 0..60 sec
///
public bool IsCoax { get { return false; } }
///
public double Position { get { return ControlBoard.RValvePosition(Idx1); } }
///
public double SetpointVal
{
get { return (double)ControlBoard.RValvePosition(Idx1); }
set { } // TODO
}
///
public void IncreaseSetpoint()
{
/// TODO
}
///
public void DecreaseSetpoint()
{
/// TODO
}
int adcChannel;
#region Configuration Change Handling
public static void OnCfgChange(object sender, CfgChangeArgs args)
{
if (CfgChangeHandler == null) return;
try { CfgChangeHandler(sender, args); }
catch (Exception e) { log.Error("CfgChangeHandler(...) failed", e); }
}
public static event EventHandler<CfgChangeArgs> CfgChangeHandler;
public override void StartChangeHandler()
{
CfgChangeHandler += delegate(object sender, CfgChangeArgs args)
{
RegulValveCfg tmpcfg = args.Cfg as RegulValveCfg;
if (tmpcfg != null && tmpcfg.Name.Equals(Name))
{
if (args.Command == CfgChangeCmd.CfgChange)
{
RegulValveCfg.StableTimeMs = tmpcfg.StableTimeMs;
RegulValveCfg.FlowStableSec = tmpcfg.FlowStableSec;
}
else if (args.Command == CfgChangeCmd.RVOpenStep)
{
ControlBoard.ValveMove(Idx1, RegulValveMode.PulseWidth, new double[2] { 2.0, 2.0 }, StableTime);
// TODO: avoid conflicts
// TOTEST
}
else if (args.Command == CfgChangeCmd.RVCloseStep)
{
ControlBoard.ValveMove(Idx1, RegulValveMode.PulseWidth, new double[2] { -2.0, -2.0 }, StableTime);
// TODO: avoid conflicts
// TOTEST
}
else if (args.Command == CfgChangeCmd.GetAdc1 || args.Command == CfgChangeCmd.GetAdc2)
{
short adcValue = (short)ControlBoard.AnalogInputRaw(adcChannel, 0);
RegulValveCfgCtrl.OnCmdResponse(this, new CmdResponseArgs(args.Command, Idx1, adcValue));
}
}
};
}
#endregion Configuration Change Handling
public RegulValve()
{
}
public RegulValve(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
RegulValveCfg = cfg as RegulValveCfg;
ControlBoard = (CBoard)TbfComponents.FindComponent(cfg.ParentName, components);
if (ControlBoard == null) throw new Exception("Cannot find " + Name + " parent");
this.dict = new Dictionary<double, double>();
#if GENESIS
adcChannel = (Idx1 < 6) ? (Idx1 - 1) : (Idx1 - 2);
#elif SENTEC || IZRAEL_25
adcChannel = (Idx1 < 3) ? (Idx1 - 1) : (Idx1 - 2);
#elif CEVAK_200
adcChannel = Math.Max(Idx1 - 3, 0);
#elif GELSENWASSER
adcChannel = Idx1 - 2;
#else
adcChannel = Idx1 - 1;
#endif
if (Idx1 < ControlBoard.RegValveCalib.GetLength(0))
{
this.ControlBoard.RegValveCalib[adcChannel, 0] = (uint)DacValueClosed;
this.ControlBoard.RegValveCalib[adcChannel, 1] = (uint)DacValueOpen;
}
else
{
log.ErrorFormat("Unable to set {0} ADC levels: RegValveCalib array size={1}, RV Idx1={2}, RV AdcNr={3}",
Name, ControlBoard.RegValveCalib.GetLength(0), Idx1, Idx1 - 1);
}
log.Warn(this.ToString());
}
///
/// IDevice interface implementation
///
public void Initialize() { }
public void RunDeviceBefore()
{
short adcValue = (short)ControlBoard.AnalogInputRaw(adcChannel, 0);
Handlers.OnAdcChanged(this, new CmdResponseArgs(CfgChangeCmd.GetAdc, Idx1, adcValue));
}
public void RunDeviceAfter() { }
public void StopDevice() { }
public void StopDevice2() { }
/// <summary>
/// Operation to set the water flow within tolerances
/// Events: Event.None, Event.FlowReached, Event.FlowTimeOut
/// </summary>
/// <param name="flowMeter">Flowmeter component</param>
/// <param name="requiredFlowLo">Lower limit of the required flow [m3/h]</param>
/// <param name="requiredFlowHi">Higher limit of the required flow [m3/h]</param>
/// <param name="pidCoef">PID coefficient (float)</param>
/// <param name="measuredFlow">Measured flow [m3/h]</param>
/// <param name="timeout">Timeout in [s]</param>
/// <returns>SetFlowOp instance</returns>
public IOperation SetFlowOp(GenericDevices.IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi, DoubleBox measuredFlow, int timeout)
{
return new SetFlowOp(ControlBoard, this, flowMeter, requiredFlowLo, requiredFlowHi, measuredFlow, RegulValveCfg.ReTryCommands, timeout);
}
/// <summary>
/// Operation to set the water flow within tolerances. Leave the measurement running.
/// Events: Event.None, Event.FlowReached, Event.FlowTimeOut
/// </summary>
/// <param name="flowMeter">Flowmeter component</param>
/// <param name="requiredFlowLo">Lower limit of the required flow [m3/h]</param>
/// <param name="requiredFlowHi">Higher limit of the required flow [m3/h]</param>
/// <param name="measuredFlow">Measured flow [m3/h]</param>
/// <param name="timeout">Timeout in [s]</param>
/// <returns>SetFlowOp instance</returns>
public IOperation SetFlowAndMeasureOp(GenericDevices.IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi,
DoubleBox measuredFlow, int timeout, float filterConstant)
{
return new SetFlowOp(ControlBoard, this, flowMeter, requiredFlowLo, requiredFlowHi, measuredFlow, RegulValveCfg.ReTryCommands, timeout, true);
}
/// <summary>
/// Operation to set the regulation valve to a required position
/// Events: Event.None
/// </summary>
/// <param name="flowLo">Lower limit of the required valve position in [%]</param>
/// <param name="flowLo">Higher limit of the required valve position in [%]</param>
/// <returns>SetPositionOp instance</returns>
public IOperation SetRegulValvePositionOp(double pctLo, double pctHi, int timeoutMs)
{
return new SetRegulValvePositionOp(ControlBoard, this, pctLo, pctHi, timeoutMs);
}
public IOperation ChangeRegulValvePositionOp(double timePulseSec)
{
return new ChangeRegulValvePositionOp(ControlBoard, this, timePulseSec);
}
}
}
-101
View File
@@ -1,101 +0,0 @@
///
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
using Config.Entities;
using SchematicDrawing;
using TBF.Rig.Generic;
namespace TBF.Rig.Elde.RegulValve
{
public class RegulValveCfg : ComponentCfgBase, IChildComponentCfg, IDrawingItemWithSetpoint
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(RegulValveCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new RegulValveCfgCtrl(); }
///
/// Serialized parameters
///
public int Idx1; /// 1..8
public ValveCategory Category; /// Feeding, Output or All
public int AdcValueClosed; /// 0..1023
public int AdcValueOpen; /// 0..1023
public int StableTimeMs; /// 200..1500 ms, step is 50 ms
public int FlowStableSec; /// 0..60 sec
public bool StoredPositionReuse; /// true = store and re-use previous regulation valve positions
public bool ReTryCommands;
/// Schematic drawing info
public Shape Shape { get; set; }
public int X { get; set; }
public int Y { get; set; }
public Sz Sz { get; set; }
public Orient Orient { get; set; }
public bool Flip { get; set; }
public int LblX { get; set; }
public int LblY { get; set; }
public Orient LblOrient { get; set; }
public int SetpX { get; set; }
public int SetpY { get; set; }
public Orient SetpOrient { get; set; }
public string SetpFormat { get; set; }
public Config.Unit SetpUnit { get; set; }
[XmlIgnore]
public IList<GNode> GNodes { get; set; }
/// <summary>
/// Stabilization time when setting the flow: 0=200ms, step 50ms, max. 1.5 sec.
/// </summary>
public int StableTime { get { return (StableTimeMs - 200) / 50; } }
/// Private parameterless constructor invoked by all other (public) constructors
RegulValveCfg()
{
GNodes = new List<GNode>();
}
public RegulValveCfg(string name, IComponentFactory factory)
: this()
{
Shape = Shape.RegV;
Sz = Sz.M;
SetpFormat = "{0:F0} %";
SetpUnit = Config.Unit.Pct;
Name = name;
Factory = factory;
ParentName = "CB";
Category = ValveCategory.Output;
Idx1 = 1;
AdcValueClosed = 100;
AdcValueOpen = 500;
StableTimeMs = 500;
FlowStableSec = 5;
StoredPositionReuse = false;
ReTryCommands = false;
}
public string ToString(int i)
{
return string.Format("Name={0} ({1}), Idx1={2}, Cat.={3}, ADC-Closed={4}, ADC-Open={5}, StabTm={6}ms, FlowStable={7}s, PosReuse={8}, ReTryCmds={9}",
Name,
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName),
Idx1,
Category,
AdcValueClosed,
AdcValueOpen,
StableTimeMs,
FlowStableSec,
StoredPositionReuse,
ReTryCommands);
}
}
}
@@ -1,19 +0,0 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using System;
namespace TBF.BenchControl.Elde.RegulValve
{
public class RegulValveCfgChangeArgs : EventArgs
{
public CfgChangeCmd Command;
public Generic.IComponentCfg Cfg;
public RegulValveCfgChangeArgs(CfgChangeCmd command, Generic.IComponentCfg cfg)
{
Command = command;
Cfg = cfg;
}
}
}
-570
View File
@@ -1,570 +0,0 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
namespace TBF.Rig.Elde.RegulValve
{
partial class RegulValveCfgCtrl
{
/// <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.positionTextBox = new System.Windows.Forms.TextBox();
this.positionLabel = new System.Windows.Forms.Label();
this.parentNameLabel = new System.Windows.Forms.Label();
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.adcClosedLabel = new System.Windows.Forms.Label();
this.adcClosedTextBox = new System.Windows.Forms.TextBox();
this.adcOpenTextBox = new System.Windows.Forms.TextBox();
this.adcOpenLabel = new System.Windows.Forms.Label();
this.parentNameComboBox = new System.Windows.Forms.ComboBox();
this.storedPosReuseCheckBox = new System.Windows.Forms.CheckBox();
this.stableTimeTextBox = new System.Windows.Forms.TextBox();
this.stableTimeLabel = new System.Windows.Forms.Label();
this.flowStableSecTextBox = new System.Windows.Forms.TextBox();
this.flowStableSecLabel = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.setButton1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.ADC = new System.Windows.Forms.Label();
this.getButton1 = new System.Windows.Forms.Button();
this.pctTextBox1 = new System.Windows.Forms.TextBox();
this.adcTextBox1 = new System.Windows.Forms.TextBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.setButton2 = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.getButton2 = new System.Windows.Forms.Button();
this.pctTextBox2 = new System.Windows.Forms.TextBox();
this.adcTextBox2 = new System.Windows.Forms.TextBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.closeButton = new System.Windows.Forms.Button();
this.openButton = new System.Windows.Forms.Button();
this.adcTextBox = new System.Windows.Forms.TextBox();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.label4 = new System.Windows.Forms.Label();
this.categoryComboBox = new System.Windows.Forms.ComboBox();
this.categoryLabel = new System.Windows.Forms.Label();
this.reTryCommandsCheckBox = new System.Windows.Forms.CheckBox();
this.unitsComboBox = new System.Windows.Forms.ComboBox();
this.unitsLabel = new System.Windows.Forms.Label();
this.formatTextBox = new System.Windows.Forms.TextBox();
this.formatLabel = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox4.SuspendLayout();
this.SuspendLayout();
//
// positionTextBox
//
this.positionTextBox.Enabled = false;
this.positionTextBox.Location = new System.Drawing.Point(138, 114);
this.positionTextBox.Name = "positionTextBox";
this.positionTextBox.Size = new System.Drawing.Size(46, 20);
this.positionTextBox.TabIndex = 8;
//
// positionLabel
//
this.positionLabel.AutoSize = true;
this.positionLabel.Location = new System.Drawing.Point(28, 117);
this.positionLabel.Name = "positionLabel";
this.positionLabel.Size = new System.Drawing.Size(18, 13);
this.positionLabel.TabIndex = 7;
this.positionLabel.Text = "ID";
//
// parentNameLabel
//
this.parentNameLabel.AutoSize = true;
this.parentNameLabel.Location = new System.Drawing.Point(28, 68);
this.parentNameLabel.Name = "parentNameLabel";
this.parentNameLabel.Size = new System.Drawing.Size(69, 13);
this.parentNameLabel.TabIndex = 3;
this.parentNameLabel.Text = "Parent Name";
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(138, 41);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(130, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(28, 44);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(135, 14);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(89, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComponentName";
//
// adcClosedLabel
//
this.adcClosedLabel.AutoSize = true;
this.adcClosedLabel.Location = new System.Drawing.Point(28, 141);
this.adcClosedLabel.Name = "adcClosedLabel";
this.adcClosedLabel.Size = new System.Drawing.Size(93, 13);
this.adcClosedLabel.TabIndex = 9;
this.adcClosedLabel.Text = "ADC when Closed";
//
// adcClosedTextBox
//
this.adcClosedTextBox.Enabled = false;
this.adcClosedTextBox.Location = new System.Drawing.Point(138, 138);
this.adcClosedTextBox.Name = "adcClosedTextBox";
this.adcClosedTextBox.Size = new System.Drawing.Size(46, 20);
this.adcClosedTextBox.TabIndex = 10;
//
// adcOpenTextBox
//
this.adcOpenTextBox.Enabled = false;
this.adcOpenTextBox.Location = new System.Drawing.Point(138, 162);
this.adcOpenTextBox.Name = "adcOpenTextBox";
this.adcOpenTextBox.Size = new System.Drawing.Size(46, 20);
this.adcOpenTextBox.TabIndex = 12;
//
// adcOpenLabel
//
this.adcOpenLabel.AutoSize = true;
this.adcOpenLabel.Location = new System.Drawing.Point(28, 165);
this.adcOpenLabel.Name = "adcOpenLabel";
this.adcOpenLabel.Size = new System.Drawing.Size(87, 13);
this.adcOpenLabel.TabIndex = 11;
this.adcOpenLabel.Text = "ADC when Open";
//
// parentNameComboBox
//
this.parentNameComboBox.Enabled = false;
this.parentNameComboBox.FormattingEnabled = true;
this.parentNameComboBox.Location = new System.Drawing.Point(138, 65);
this.parentNameComboBox.Name = "parentNameComboBox";
this.parentNameComboBox.Size = new System.Drawing.Size(130, 21);
this.parentNameComboBox.TabIndex = 4;
//
// storedPosReuseCheckBox
//
this.storedPosReuseCheckBox.AutoSize = true;
this.storedPosReuseCheckBox.Enabled = false;
this.storedPosReuseCheckBox.Location = new System.Drawing.Point(31, 239);
this.storedPosReuseCheckBox.Name = "storedPosReuseCheckBox";
this.storedPosReuseCheckBox.Size = new System.Drawing.Size(162, 17);
this.storedPosReuseCheckBox.TabIndex = 17;
this.storedPosReuseCheckBox.Text = "Enable stored position re-use";
this.storedPosReuseCheckBox.UseVisualStyleBackColor = true;
//
// stableTimeTextBox
//
this.stableTimeTextBox.Enabled = false;
this.stableTimeTextBox.Location = new System.Drawing.Point(138, 186);
this.stableTimeTextBox.Name = "stableTimeTextBox";
this.stableTimeTextBox.Size = new System.Drawing.Size(46, 20);
this.stableTimeTextBox.TabIndex = 14;
//
// stableTimeLabel
//
this.stableTimeLabel.AutoSize = true;
this.stableTimeLabel.Location = new System.Drawing.Point(28, 189);
this.stableTimeLabel.Name = "stableTimeLabel";
this.stableTimeLabel.Size = new System.Drawing.Size(81, 13);
this.stableTimeLabel.TabIndex = 13;
this.stableTimeLabel.Text = "Stable time [ms]";
//
// flowStableSecTextBox
//
this.flowStableSecTextBox.Enabled = false;
this.flowStableSecTextBox.Location = new System.Drawing.Point(138, 210);
this.flowStableSecTextBox.Name = "flowStableSecTextBox";
this.flowStableSecTextBox.Size = new System.Drawing.Size(46, 20);
this.flowStableSecTextBox.TabIndex = 16;
//
// flowStableSecLabel
//
this.flowStableSecLabel.AutoSize = true;
this.flowStableSecLabel.Location = new System.Drawing.Point(28, 213);
this.flowStableSecLabel.Name = "flowStableSecLabel";
this.flowStableSecLabel.Size = new System.Drawing.Size(74, 13);
this.flowStableSecLabel.TabIndex = 15;
this.flowStableSecLabel.Text = "Flow stable [s]";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.setButton1);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.ADC);
this.groupBox1.Controls.Add(this.getButton1);
this.groupBox1.Controls.Add(this.pctTextBox1);
this.groupBox1.Controls.Add(this.adcTextBox1);
this.groupBox1.Location = new System.Drawing.Point(10, 398);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(280, 59);
this.groupBox1.TabIndex = 19;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Measured value 1";
//
// setButton1
//
this.setButton1.Location = new System.Drawing.Point(229, 17);
this.setButton1.Name = "setButton1";
this.setButton1.Size = new System.Drawing.Size(38, 33);
this.setButton1.TabIndex = 5;
this.setButton1.Text = "Set";
this.setButton1.UseVisualStyleBackColor = true;
this.setButton1.Click += new System.EventHandler(this.setButton_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(209, 28);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(15, 13);
this.label1.TabIndex = 4;
this.label1.Text = "%";
//
// ADC
//
this.ADC.AutoSize = true;
this.ADC.Location = new System.Drawing.Point(11, 28);
this.ADC.Name = "ADC";
this.ADC.Size = new System.Drawing.Size(32, 13);
this.ADC.TabIndex = 3;
this.ADC.Text = "ADC:";
//
// getButton1
//
this.getButton1.Location = new System.Drawing.Point(101, 18);
this.getButton1.Name = "getButton1";
this.getButton1.Size = new System.Drawing.Size(38, 33);
this.getButton1.TabIndex = 2;
this.getButton1.Text = "Get";
this.getButton1.UseVisualStyleBackColor = true;
this.getButton1.Click += new System.EventHandler(this.getButton1_Click);
//
// pctTextBox1
//
this.pctTextBox1.Location = new System.Drawing.Point(160, 24);
this.pctTextBox1.Name = "pctTextBox1";
this.pctTextBox1.Size = new System.Drawing.Size(46, 20);
this.pctTextBox1.TabIndex = 1;
//
// adcTextBox1
//
this.adcTextBox1.Location = new System.Drawing.Point(47, 24);
this.adcTextBox1.Name = "adcTextBox1";
this.adcTextBox1.Size = new System.Drawing.Size(44, 20);
this.adcTextBox1.TabIndex = 0;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.setButton2);
this.groupBox2.Controls.Add(this.label2);
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Controls.Add(this.getButton2);
this.groupBox2.Controls.Add(this.pctTextBox2);
this.groupBox2.Controls.Add(this.adcTextBox2);
this.groupBox2.Location = new System.Drawing.Point(10, 462);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(280, 59);
this.groupBox2.TabIndex = 20;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Measured value 2";
//
// setButton2
//
this.setButton2.Location = new System.Drawing.Point(229, 17);
this.setButton2.Name = "setButton2";
this.setButton2.Size = new System.Drawing.Size(38, 33);
this.setButton2.TabIndex = 5;
this.setButton2.Text = "Set";
this.setButton2.UseVisualStyleBackColor = true;
this.setButton2.Click += new System.EventHandler(this.setButton_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(209, 28);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(15, 13);
this.label2.TabIndex = 4;
this.label2.Text = "%";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(11, 27);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(32, 13);
this.label3.TabIndex = 3;
this.label3.Text = "ADC:";
//
// getButton2
//
this.getButton2.Location = new System.Drawing.Point(101, 18);
this.getButton2.Name = "getButton2";
this.getButton2.Size = new System.Drawing.Size(38, 33);
this.getButton2.TabIndex = 2;
this.getButton2.Text = "Get";
this.getButton2.UseVisualStyleBackColor = true;
this.getButton2.Click += new System.EventHandler(this.getButton2_Click);
//
// pctTextBox2
//
this.pctTextBox2.Location = new System.Drawing.Point(160, 24);
this.pctTextBox2.Name = "pctTextBox2";
this.pctTextBox2.Size = new System.Drawing.Size(46, 20);
this.pctTextBox2.TabIndex = 1;
//
// adcTextBox2
//
this.adcTextBox2.Location = new System.Drawing.Point(47, 24);
this.adcTextBox2.Name = "adcTextBox2";
this.adcTextBox2.Size = new System.Drawing.Size(44, 20);
this.adcTextBox2.TabIndex = 0;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.closeButton);
this.groupBox3.Controls.Add(this.openButton);
this.groupBox3.Location = new System.Drawing.Point(10, 527);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(280, 60);
this.groupBox3.TabIndex = 21;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Regulation valve";
//
// closeButton
//
this.closeButton.Location = new System.Drawing.Point(14, 19);
this.closeButton.Name = "closeButton";
this.closeButton.Size = new System.Drawing.Size(107, 28);
this.closeButton.TabIndex = 1;
this.closeButton.Text = "Close";
this.closeButton.UseVisualStyleBackColor = true;
this.closeButton.Click += new System.EventHandler(this.closeButton_Click);
//
// openButton
//
this.openButton.Location = new System.Drawing.Point(160, 19);
this.openButton.Name = "openButton";
this.openButton.Size = new System.Drawing.Size(107, 28);
this.openButton.TabIndex = 0;
this.openButton.Text = "Open";
this.openButton.UseVisualStyleBackColor = true;
this.openButton.Click += new System.EventHandler(this.openButton_Click);
//
// adcTextBox
//
this.adcTextBox.Location = new System.Drawing.Point(47, 14);
this.adcTextBox.Name = "adcTextBox";
this.adcTextBox.Size = new System.Drawing.Size(44, 20);
this.adcTextBox.TabIndex = 21;
//
// groupBox4
//
this.groupBox4.Controls.Add(this.label4);
this.groupBox4.Controls.Add(this.adcTextBox);
this.groupBox4.Location = new System.Drawing.Point(10, 352);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(279, 40);
this.groupBox4.TabIndex = 22;
this.groupBox4.TabStop = false;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(11, 17);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(32, 13);
this.label4.TabIndex = 22;
this.label4.Text = "ADC:";
//
// categoryComboBox
//
this.categoryComboBox.Enabled = false;
this.categoryComboBox.FormattingEnabled = true;
this.categoryComboBox.Location = new System.Drawing.Point(138, 90);
this.categoryComboBox.Name = "categoryComboBox";
this.categoryComboBox.Size = new System.Drawing.Size(130, 21);
this.categoryComboBox.TabIndex = 6;
//
// categoryLabel
//
this.categoryLabel.AutoSize = true;
this.categoryLabel.Location = new System.Drawing.Point(28, 93);
this.categoryLabel.Name = "categoryLabel";
this.categoryLabel.Size = new System.Drawing.Size(49, 13);
this.categoryLabel.TabIndex = 5;
this.categoryLabel.Text = "Category";
//
// reTryCommandsCheckBox
//
this.reTryCommandsCheckBox.AutoSize = true;
this.reTryCommandsCheckBox.Enabled = false;
this.reTryCommandsCheckBox.Location = new System.Drawing.Point(31, 262);
this.reTryCommandsCheckBox.Name = "reTryCommandsCheckBox";
this.reTryCommandsCheckBox.Size = new System.Drawing.Size(108, 17);
this.reTryCommandsCheckBox.TabIndex = 18;
this.reTryCommandsCheckBox.Text = "Re-try commands";
this.reTryCommandsCheckBox.UseVisualStyleBackColor = true;
//
// unitsComboBox
//
this.unitsComboBox.Enabled = false;
this.unitsComboBox.FormattingEnabled = true;
this.unitsComboBox.Location = new System.Drawing.Point(138, 309);
this.unitsComboBox.Name = "unitsComboBox";
this.unitsComboBox.Size = new System.Drawing.Size(80, 21);
this.unitsComboBox.TabIndex = 32;
//
// unitsLabel
//
this.unitsLabel.AutoSize = true;
this.unitsLabel.Location = new System.Drawing.Point(28, 312);
this.unitsLabel.Name = "unitsLabel";
this.unitsLabel.Size = new System.Drawing.Size(71, 13);
this.unitsLabel.TabIndex = 31;
this.unitsLabel.Text = "Setpoint units";
//
// formatTextBox
//
this.formatTextBox.Enabled = false;
this.formatTextBox.Location = new System.Drawing.Point(138, 285);
this.formatTextBox.Name = "formatTextBox";
this.formatTextBox.Size = new System.Drawing.Size(130, 20);
this.formatTextBox.TabIndex = 30;
//
// formatLabel
//
this.formatLabel.AutoSize = true;
this.formatLabel.Location = new System.Drawing.Point(28, 288);
this.formatLabel.Name = "formatLabel";
this.formatLabel.Size = new System.Drawing.Size(78, 13);
this.formatLabel.TabIndex = 29;
this.formatLabel.Text = "Setpoint format";
//
// RegulValveCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.unitsComboBox);
this.Controls.Add(this.unitsLabel);
this.Controls.Add(this.formatTextBox);
this.Controls.Add(this.formatLabel);
this.Controls.Add(this.reTryCommandsCheckBox);
this.Controls.Add(this.categoryComboBox);
this.Controls.Add(this.categoryLabel);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.flowStableSecTextBox);
this.Controls.Add(this.flowStableSecLabel);
this.Controls.Add(this.stableTimeTextBox);
this.Controls.Add(this.stableTimeLabel);
this.Controls.Add(this.storedPosReuseCheckBox);
this.Controls.Add(this.parentNameComboBox);
this.Controls.Add(this.adcOpenTextBox);
this.Controls.Add(this.adcOpenLabel);
this.Controls.Add(this.adcClosedTextBox);
this.Controls.Add(this.adcClosedLabel);
this.Controls.Add(this.positionTextBox);
this.Controls.Add(this.positionLabel);
this.Controls.Add(this.parentNameLabel);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "RegulValveCfgCtrl";
this.Size = new System.Drawing.Size(300, 700);
this.Load += new System.EventHandler(this.RegulationValveCfgCtrl_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox positionTextBox;
private System.Windows.Forms.Label positionLabel;
private System.Windows.Forms.Label parentNameLabel;
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.Label adcClosedLabel;
private System.Windows.Forms.TextBox adcClosedTextBox;
private System.Windows.Forms.TextBox adcOpenTextBox;
private System.Windows.Forms.Label adcOpenLabel;
private System.Windows.Forms.ComboBox parentNameComboBox;
private System.Windows.Forms.CheckBox storedPosReuseCheckBox;
private System.Windows.Forms.TextBox stableTimeTextBox;
private System.Windows.Forms.Label stableTimeLabel;
private System.Windows.Forms.TextBox flowStableSecTextBox;
private System.Windows.Forms.Label flowStableSecLabel;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button setButton1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label ADC;
private System.Windows.Forms.Button getButton1;
private System.Windows.Forms.TextBox pctTextBox1;
private System.Windows.Forms.TextBox adcTextBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Button setButton2;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button getButton2;
private System.Windows.Forms.TextBox pctTextBox2;
private System.Windows.Forms.TextBox adcTextBox2;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Button closeButton;
private System.Windows.Forms.Button openButton;
private System.Windows.Forms.TextBox adcTextBox;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.ComboBox categoryComboBox;
private System.Windows.Forms.Label categoryLabel;
private System.Windows.Forms.CheckBox reTryCommandsCheckBox;
private System.Windows.Forms.ComboBox unitsComboBox;
private System.Windows.Forms.Label unitsLabel;
private System.Windows.Forms.TextBox formatTextBox;
private System.Windows.Forms.Label formatLabel;
}
}
@@ -1,379 +0,0 @@
///
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.UI.Bench.Components;
namespace TBF.Rig.Elde.RegulValve
{
public partial class RegulValveCfgCtrl : UserControl, IComponentCfgCtrl
{
static readonly ILog log = LogManager.GetLogger(typeof(RegulValveCfgCtrl));
ComponentParametersDlg parent;
public bool ShowMore { get { return true; } }
RegulValveCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as RegulValveCfg;
Redraw();
}
}
public RegulValveCfgCtrl()
{
InitializeComponent();
}
private void RegulationValveCfgCtrl_Load(object sender, EventArgs e)
{
parent = ParentForm as ComponentParametersDlg;
if (parent == null) return;
if (parent.CmpntEntities != null)
{
foreach (var cmpnt in parent.CmpntEntities)
{
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is ControlBoard.Legacy.Factory)
{
parentNameComboBox.Items.Add(cmpnt.Name);
}
}
}
categoryComboBox.Items.Add(ValveCategory.Feeding.ToString());
categoryComboBox.Items.Add(ValveCategory.Output.ToString());
if (config != null)
{
adc1 = config.AdcValueClosed;
pct1 = 0;
adc2 = config.AdcValueOpen;
pct2 = 100;
}
for (Config.Unit units = 0; units < global::Config.Unit.Count; units++)
{
if (global::Config.Units.IsQuantity(units, global::Config.Quantity.Error))
{
unitsComboBox.Items.Add(units.ToString());
}
}
Redraw();
StartResponseHandler();
}
public void Closing()
{
StopResponseHandler();
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
categoryComboBox.Text = config.Category.ToString();
positionTextBox.Text = config.Idx1.ToString();
adcClosedTextBox.Text = config.AdcValueClosed.ToString();
adcOpenTextBox.Text = config.AdcValueOpen.ToString();
stableTimeTextBox.Text = config.StableTimeMs.ToString();
flowStableSecTextBox.Text = config.FlowStableSec.ToString();
storedPosReuseCheckBox.Checked = config.StoredPositionReuse;
reTryCommandsCheckBox.Checked = config.ReTryCommands;
formatTextBox.Text = config.SetpFormat;
unitsComboBox.Text = config.SetpUnit.ToString();
adcTextBox1.Text = adc1.ToString();
adcTextBox2.Text = adc2.ToString();
pctTextBox1.Text = pct1.ToString();
pctTextBox2.Text = pct2.ToString();
}
public void Unlock()
{
nameTextBox.Enabled = true;
parentNameComboBox.Enabled = true;
categoryComboBox.Enabled = true;
positionTextBox.Enabled = true;
adcClosedTextBox.Enabled = true;
adcOpenTextBox.Enabled = true;
stableTimeTextBox.Enabled = true;
flowStableSecTextBox.Enabled = true;
storedPosReuseCheckBox.Enabled = true;
reTryCommandsCheckBox.Enabled = true;
formatTextBox.Enabled = true;
unitsComboBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
int dummy;
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Parent Name'";
}
if (!categoryComboBox.Text.Equals(ValveCategory.Feeding.ToString()) &&
!categoryComboBox.Text.Equals(ValveCategory.Output.ToString()))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Category'";
}
if (!int.TryParse(positionTextBox.Text, out dummy) || dummy < 1 || dummy > 8)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Position' should be between 1 and 8";
}
if (!int.TryParse(adcClosedTextBox.Text, out dummy) || dummy < 0 || dummy > 1023)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'ADC when Closed' should be between 0 and 1023";
}
if (!int.TryParse(adcOpenTextBox.Text, out dummy) || dummy < 0 || dummy > 1023)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'ADC when Open' should be between 0 and 1023";
}
if (!int.TryParse(stableTimeTextBox.Text, out dummy) || dummy < 200 || dummy > 1500 || (dummy % 50) != 0)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Stable time' should be between 200 and 1500 ms in 50 ms steps";
}
if (!int.TryParse(flowStableSecTextBox.Text, out dummy) || dummy < 0 || dummy > 60)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Flow stable' should be between 0 and 60 sec";
}
if (!unitsComboBox.Items.Contains(unitsComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Units'";
}
return flags;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
///
if (!config.Name.Equals(nameTextBox.Text))
{
config.Name = nameTextBox.Text;
flags |= CfgUpdateFlags.RestartRqrd;
}
string parentname = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
if (!config.ParentName.Equals(parentname))
{
config.ParentName = parentname;
flags |= CfgUpdateFlags.RestartRqrd;
}
ValveCategory newCategory;
if (categoryComboBox.Text.Equals(ValveCategory.Feeding.ToString())) newCategory = ValveCategory.Feeding;
else if (categoryComboBox.Text.Equals(ValveCategory.Output.ToString())) newCategory = ValveCategory.Output;
else newCategory = ValveCategory.None;
if (newCategory != config.Category)
{
config.Category = newCategory;
flags |= CfgUpdateFlags.RestartRqrd;
}
int tmp = int.Parse(positionTextBox.Text);
if (config.Idx1 != tmp)
{
config.Idx1 = tmp;
flags |= CfgUpdateFlags.RestartRqrd;
}
tmp = int.Parse(adcClosedTextBox.Text);
if (config.AdcValueClosed != tmp)
{
config.AdcValueClosed = tmp;
flags |= CfgUpdateFlags.RestartRqrd;
}
tmp = int.Parse(adcOpenTextBox.Text);
if (config.AdcValueOpen != tmp)
{
config.AdcValueOpen = tmp;
flags |= CfgUpdateFlags.RestartRqrd;
}
tmp = int.Parse(stableTimeTextBox.Text);
if (config.StableTimeMs != tmp)
{
config.StableTimeMs = tmp;
flags |= CfgUpdateFlags.AnyChange;
}
tmp = int.Parse(flowStableSecTextBox.Text);
if (config.FlowStableSec != tmp)
{
config.FlowStableSec = tmp;
flags |= CfgUpdateFlags.AnyChange;
}
bool btmp = storedPosReuseCheckBox.Checked;
if (config.StoredPositionReuse != btmp)
{
config.StoredPositionReuse = btmp;
flags |= CfgUpdateFlags.RestartRqrd;
}
btmp = reTryCommandsCheckBox.Checked;
if (config.ReTryCommands != btmp)
{
config.ReTryCommands = btmp;
flags |= CfgUpdateFlags.RestartRqrd;
}
if ((flags & CfgUpdateFlags.AnyChange) != 0)
{
RegulValve.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
}
config.SetpFormat = formatTextBox.Text;
config.SetpUnit = global::Config.Unit.None;
for (Config.Unit units = 0; units < global::Config.Unit.Count; units++)
{
if (unitsComboBox.Text == units.ToString())
{
config.SetpUnit = units;
break;
}
}
return flags;
}
int adc1;
int pct1;
int adc2;
int pct2;
private void openButton_Click(object sender, EventArgs e)
{
RegulValve.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.RVOpenStep, config));
}
private void closeButton_Click(object sender, EventArgs e)
{
RegulValve.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.RVCloseStep, config));
}
//
private void getButton1_Click(object sender, EventArgs e)
{
RegulValve.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.GetAdc1, config));
}
private void getButton2_Click(object sender, EventArgs e)
{
RegulValve.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.GetAdc2, config));
}
private void setButton_Click(object sender, EventArgs e)
{
int tmpPct1;
int tmpPct2;
if ((int.TryParse(pctTextBox1.Text, out tmpPct1) && (tmpPct1 >= 0) && (tmpPct1 <= 100)) &&
(int.TryParse(pctTextBox2.Text, out tmpPct2) && (tmpPct2 >= 0) && (tmpPct2 <= 100)))
{
pct1 = tmpPct1;
pct2 = tmpPct2;
UpdateValveOpenClose();
}
}
void UpdateValveOpenClose()
{
if ((adc1 == adc2) || (pct1 == pct2)) return;
double factor = (float)(adc2 - adc1) / (float)(pct2 - pct1);
int adcClosed = (int)((float)(0 - pct1) * factor + (float)adc1 + 0.5f);
int adcOpen = (int)((float)(100 - pct1) * factor + (float)adc1 + 0.5f);
if ((adcClosed >= 0) && (adcOpen >= 0))
{
adcClosedTextBox.Text = adcClosed.ToString();
adcOpenTextBox.Text = adcOpen.ToString();
}
}
#region Configuration Change Handling
public static void OnCmdResponse(object sender, CmdResponseArgs args)
{
if (CmdResponseHandler == null) return;
try { CmdResponseHandler(sender, args); }
catch (Exception e) { log.Error("CmdResponseHandler(...) failed", e); }
}
public static event EventHandler<CmdResponseArgs> CmdResponseHandler;
public void StartResponseHandler()
{
Handlers.AdcChangedHandler += delegate(object sndr, CmdResponseArgs args)
{
if (InvokeRequired) { Invoke(new EventHandler<CmdResponseArgs>(OnAdcChanged), sndr, args); }
else OnAdcChanged(sndr, args);
};
CmdResponseHandler += delegate(object sender, CmdResponseArgs args)
{
if (args.Command == CfgChangeCmd.GetAdc1)
{
adc1 = args.Response;
adcTextBox1.Text = adc1.ToString();
}
else if (args.Command == CfgChangeCmd.GetAdc2)
{
adc2 = args.Response;
adcTextBox2.Text = adc2.ToString();
}
};
}
public void StopResponseHandler()
{
CmdResponseHandler = null;
}
void OnAdcChanged(object sender, CmdResponseArgs data)
{
if (data.Command == CfgChangeCmd.GetAdc && data.Id == config.Idx1)
{
adcTextBox.Text = data.Response.ToString();
}
}
#endregion Configuration Change Handling
}
}
@@ -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,27 +0,0 @@
///
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Elde.RegulValve
{
public class RegulValveFactory : IComponentFactory
{
public string ClassName { get { return "RegulationValve"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { RegulValve.ResetStaticProperties(); }
public IComponent DummyComponent() { return new RegulValve(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new RegulValve(cfg, components); }
public IComponentCfg DefaultConfig() { return new RegulValveCfg("RV", this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(RegulValveCfg.Serializer, component, this);
}
}
}
-458
View File
@@ -1,458 +0,0 @@
///
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.Rig.ControlBoard.Legacy;
using TBF.Rig.GenericDevices;
using TBF.Boxes;
namespace TBF.Rig.Elde.RegulValve
{
public class SetFlowOp : IOperation
{
private static readonly ILog log = LogManager.GetLogger(typeof(SetFlowOp));
public override string ToString()
{
return string.Format("SetFlowOp({0}, Qfrom={1}, Qto={2})", regulValve.Name, requiredFlowLo, requiredFlowHi);
}
/// Set by the constructor
readonly CBoard controlBoard;
readonly Elde.RegulValve.RegulValve regulValve;
readonly int regulValveNr;
readonly IFlowMeter flowMeter;
readonly double requiredFlowLo;
readonly double requiredFlowHi;
readonly double reqFlowAve;
readonly int timeout;
readonly bool leaveMeasurementRunning;
readonly bool reTryCommands;
readonly double nominalFlow;
readonly double maximalFlow;
///
/// Internal states of this operation
///
enum OpState
{
Idle = 0,
ValveMoveToPosition1, /// Wait 1 takt
ValveMoveToPosition2, /// This is actual move to position
ValveMoveToPosition3, /// Wait 1 takt
CheckStatePosition, /// Verify
SettingPosition,
ValveMoveToFlow1, /// Wait 1 takt
ValveMoveToFlow2, /// This is actual move to flow
ValveMoveToFlow3, /// Wait 1 takt
CheckStateFlow, /// Verify
SettingFlow,
FlowReached,
SendCommandAgain,
}
OpState opState;
double currentReqFlowLo;
double currentReqFlowHi;
double targetPositionLo;
double targetPositionHi;
int startTime;
int expireTime;
DoubleBox flowBox;
int flowWithinBoundsTime;
/// <summary>
/// Set required water flow. Conditionally leave the measurement running.
/// Events: FlowSet, FlowTimeOut
/// </summary>
/// <param name="controlBoard">Control board device</param>
/// <param name="regulValve">Regulation valve component</param>
/// <param name="flowMeter">Flowmeter component</param>
/// <param name="requiredFlowLo">Lower limit of the flow to be achieved in [m3/h]</param>
/// <param name="requiredFlowHi">Upper limit of the flow to be achieved in [m3/h]</param>
/// <param name="pidCoef">PID coefficient (float)</param>
/// <param name="timeout">Timeout for the flow setting in [s]</param>
/// <param name="leaveMeasurementRunning">true = Leave the measurement running after op. stop</param>
/// <remarks>Only Elde.Valve flow are used, other flow on the lists are ignored</remarks>
public SetFlowOp(CBoard controlBoard, IRegValve regulValve, IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi,
DoubleBox flowBox, bool reTryCmds, int timeout, bool leaveMeasurementRunning)
{
if (controlBoard == null) throw new ArgumentNullException("ctrlBoard");
this.controlBoard = controlBoard;
this.regulValve = regulValve as Elde.RegulValve.RegulValve;
if (this.regulValve == null) throw new ArgumentNullException("regValve is null or not Elde");
regulValveNr = this.regulValve.Idx1;
if (flowMeter == null) throw new ArgumentNullException("flowMeter");
this.flowMeter = flowMeter;
nominalFlow = flowMeter.NominalFlow;
maximalFlow = nominalFlow * 1.25;
this.reqFlowAve = (requiredFlowLo + requiredFlowHi) / 2;
this.requiredFlowLo = (0.7 * requiredFlowLo) + (0.3 * this.reqFlowAve); /// Move the lower limit 15% of the range up
this.requiredFlowHi = (0.7 * requiredFlowHi) + (0.3 * this.reqFlowAve); /// Move the upper limit 15% of the range down
if (flowBox == null) throw new ArgumentNullException("flowBox");
this.flowBox = flowBox;
this.reTryCommands = reTryCmds;
this.timeout = timeout;
this.leaveMeasurementRunning = leaveMeasurementRunning;
log.Debug(this.ToString());
}
/// <summary>
/// Set required water flow - Do not leave the measurement running.
/// Events: FlowSet
/// </summary>
public SetFlowOp(CBoard controlBoard, IRegValve regValve, IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi,
DoubleBox flowbox, bool reTryCmds, int timeout)
: this(controlBoard, regValve, flowMeter, requiredFlowLo, requiredFlowHi, flowbox, reTryCmds, timeout, false)
{
}
/// <summary>
/// Set required water flow - No timeout.
/// Events: FlowSet
/// </summary>
public SetFlowOp(CBoard controlBoard, IRegValve regValve, IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi,
DoubleBox flowbox, bool reTryCmds)
: this(controlBoard, regValve, flowMeter, requiredFlowLo, requiredFlowHi, flowbox, reTryCmds, int.MaxValue, false)
{
}
/// <summary>
/// Fetch target position limits from the dictionary or return false
/// </summary>
/// <param name="avgReqFlow">Average of the flow targer range (input)</param>
/// <param name="positionLo">Target valve position low limit (output)</param>
/// <param name="positionHi">Target valve position high limit (output)</param>
/// <returns>true when positions for the target flow are stored in the memory, otherwise return false</returns>
bool FetchTargetPosition(double avgReqFlow, out double positionLo, out double positionHi)
{
double targetPosition;
if (regulValve.Dict.TryGetValue(avgReqFlow, out targetPosition))
{
positionLo = Math.Max(targetPosition * 0.95f, 0.0f);
positionHi = Math.Min(targetPosition * 1.05f, 100.0f);
return true;
}
else
{
positionLo = 0.0f;
positionHi = 0.0f;
return false;
}
}
void StoreTargetPosition(double avgReqFlow, double actPosition)
{
if (!regulValve.Dict.ContainsKey(reqFlowAve))
{
regulValve.Dict.Add(new KeyValuePair<double, double>(avgReqFlow, actPosition));
}
return;
}
/// <summary>Start this operation</summary>
public void Start()
{
startTime = StateMachine.Time;
expireTime = StateMachine.Time + timeout;
if (expireTime < 0) expireTime = int.MaxValue;
double flowMtrFreq = flowMeter.ReadFrequency();
double flow = flowMeter.ReadFlow();
currentReqFlowLo = requiredFlowLo; /// Default lower limit
currentReqFlowHi = requiredFlowHi; /// Default upper limit
if (flow != 0)
{
flowBox.Val = flow;
if (flow >= reqFlowAve) currentReqFlowHi = reqFlowAve; /// Decrease upper limit
if (flow <= reqFlowAve) currentReqFlowLo = reqFlowAve; /// Increase lower limit
}
flowWithinBoundsTime = 0;
if (regulValve.RegulValveCfg.StoredPositionReuse && FetchTargetPosition(reqFlowAve, out targetPositionLo, out targetPositionHi))
{
log.InfoFormat("SetFlowOp:Start() rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3} FETCHED: posLo={4} posHi={5}",
regulValveNr, flowMeter.Idx1, currentReqFlowLo, currentReqFlowHi, targetPositionLo, targetPositionHi);
opState = OpState.ValveMoveToPosition1;
}
else
{
log.InfoFormat("SetFlowOp:Start() rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3}",
regulValveNr, flowMeter.Idx1, currentReqFlowLo, currentReqFlowHi);
opState = OpState.ValveMoveToFlow1;
}
/// Start flow measurement
controlBoard.SendCommand(Command.Start, flowMeter.Idx1, int.MaxValue, int.MaxValue, 0, 0); /// TestMethods=0, StopDevs=0
}
/// <summary>Run this operation</summary>
/// <returns>
/// Event.OpArgumentError
/// Event.Starting
/// Event.Busy
/// Event.FlowReached
/// Event.RegulValveTimeOut
/// </returns>
public Event Run()
{
float rvPosition = controlBoard.RValvePosition(regulValveNr);
double flowMtrFreq = flowMeter.ReadFrequency();
double flow = flowMeter.ReadFlow();
if (flow != 0)
{
flowBox.Val = flow;
}
log.InfoFormat("SetFlowOp:Run(T={0}) rv#={1} pos={2}% freq={3} flow={4} opState={5}",
StateMachine.Time - startTime, regulValveNr, rvPosition.ToString("F1"), flowMtrFreq, flow, opState);
if (StateMachine.Time > expireTime)
{
return Event.RegulValveTimeOut;
}
else if (opState == OpState.SendCommandAgain)
{
flowWithinBoundsTime = 0;
if (regulValve.RegulValveCfg.StoredPositionReuse && FetchTargetPosition(reqFlowAve, out targetPositionLo, out targetPositionHi))
{
log.InfoFormat("Run(): rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3} FETCHED: posLo={4} posHi={5}",
regulValveNr, flowMeter.Idx1, currentReqFlowLo, currentReqFlowHi, targetPositionLo, targetPositionHi);
opState = OpState.ValveMoveToPosition1;
}
else
{
log.InfoFormat("Run(): rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3}",
regulValveNr, flowMeter.Idx1, currentReqFlowLo, currentReqFlowHi);
opState = OpState.ValveMoveToFlow1;
}
/// Start flow measurement
controlBoard.SendCommand(Command.Start, flowMeter.Idx1, int.MaxValue, int.MaxValue, 0, 0); /// TestMethods=0, StopDevs=0
return Event.Starting;
}
else if (opState == OpState.ValveMoveToPosition1)
{
opState = OpState.ValveMoveToPosition2;
return Event.Starting;
}
else if (opState == OpState.ValveMoveToPosition2) /// Move to position
{
/// Issues the appropriate ValveMove(...) command
controlBoard.ValveMove(regulValveNr, RegulValveMode.TargetPosition,
new double[2] { targetPositionLo, targetPositionHi },
regulValve.StableTime);
opState = OpState.SettingPosition;
return Event.Starting;
}
else if (opState == OpState.ValveMoveToPosition3)
{
if (reTryCommands)
{
opState = OpState.CheckStatePosition;
}
else
{
opState = OpState.SettingPosition;
}
return Event.Starting;
}
else if (opState == OpState.CheckStatePosition) /// Verify
{
if (((ulong)controlBoard.StatusP & (ulong)StatusP.RefPulsesMsrmnt) == 0)
{
opState = OpState.SendCommandAgain;
return Event.Starting;
}
else if (controlBoard.RegulValveState(regulValveNr) != RegulValveState.DacValueRegul)
{
/// Repeat appropriate ValveMove(...) command
controlBoard.ValveMove(regulValveNr, RegulValveMode.TargetPosition,
new double[2] { targetPositionLo, targetPositionHi },
regulValve.StableTime);
log.InfoFormat("SetFlowOp: ValveMove({0}, Position, {1}, {2}, {3})",
regulValveNr, targetPositionLo, targetPositionHi, regulValve.StableTime);
opState = OpState.ValveMoveToPosition3;
return Event.Starting;
}
else
{
opState = OpState.SettingPosition;
return Event.Starting;
}
}
else if (opState == OpState.SettingPosition)
{
/// Repeated untill position is reached
if ((targetPositionLo <= rvPosition) && (rvPosition <= targetPositionHi))
{
opState = OpState.ValveMoveToFlow1;
}
return Event.Starting;
}
else if (opState == OpState.ValveMoveToFlow1)
{
opState = OpState.ValveMoveToFlow2;
return Event.Starting;
}
else if (opState == OpState.ValveMoveToFlow2) /// Move to flow
{
///
/// Done once, issues an appropriate ValveMove(...) command
///
if ((currentReqFlowLo >= currentReqFlowHi) || (currentReqFlowLo > maximalFlow) || (currentReqFlowHi <= 0))
{
return Event.OpArgumentError;
}
log.InfoFormat("Run(): rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3}",
regulValveNr, flowMeter.Idx1, currentReqFlowLo, currentReqFlowHi);
double freqLo = 2000.0 * currentReqFlowLo / nominalFlow;
double freqHi = 2000.0 * currentReqFlowHi / nominalFlow;
controlBoard.ValveMove(regulValveNr, RegulValveMode.TargetFrequency,
new double[2] { freqLo, freqHi },
regulValve.StableTime);
opState = OpState.ValveMoveToFlow3;
return Event.Starting;
}
else if (opState == OpState.ValveMoveToFlow3)
{
if (reTryCommands)
{
opState = OpState.CheckStateFlow;
}
else
{
opState = OpState.SettingFlow;
}
return Event.Starting;
}
else if (opState == OpState.CheckStateFlow) /// Verify the flow setting
{
if ( ((ulong)controlBoard.StatusP & (ulong)StatusP.RefPulsesMsrmnt) == 0 ||
(controlBoard.RegulValveState(regulValveNr) & RegulValveState.PwOrFreqRegul) != RegulValveState.PwOrFreqRegul)
{
opState = OpState.SendCommandAgain;
return Event.Starting;
}
else if (controlBoard.RegulValveState(regulValveNr) != RegulValveState.PwOrFreqRegul)
{
/// Done once, issues an appropriate ValveMove(...) command
double freqLo = 2000.0 * currentReqFlowLo / nominalFlow;
double freqHi = 2000.0 * currentReqFlowHi / nominalFlow;
controlBoard.ValveMove(regulValveNr, RegulValveMode.TargetFrequency,
new double[2] { (float)freqLo, (float)freqHi },
regulValve.StableTime);
log.InfoFormat("SetFlowOp: ValveMove({0}, Frequency, {1}, {2}, {3})",
regulValveNr, freqLo, freqHi, regulValve.StableTime);
opState = OpState.ValveMoveToFlow3;
return Event.Starting;
}
else
{
opState = OpState.SettingFlow;
return Event.Busy;
}
}
else if (opState == OpState.SettingFlow)
{
/// Regulation valve is setting flow to the required value
if ((currentReqFlowLo <= flow) && (flow <= currentReqFlowHi))
{
/// Flow is within range
if (flowWithinBoundsTime++ >= regulValve.FlowStableSec)
{
/// Flow is within range for sufficiently long time
if (regulValve.RegulValveCfg.StoredPositionReuse)
{
double storedPosition;
if (regulValve.Dict.TryGetValue(reqFlowAve, out storedPosition))
{
/// update the stored valve position
StoreTargetPosition(reqFlowAve, (rvPosition + storedPosition) / 2.0f);
log.InfoFormat("Run(): rv#={0} reqFlow={1} pos={2}% stored={3} <--- Updating a stored position",
regulValveNr, reqFlowAve, rvPosition.ToString("F1"), storedPosition);
}
else
{
/// store the valve position
StoreTargetPosition(reqFlowAve, rvPosition);
log.InfoFormat("Run(): rv#={0} reqFlow={1} pos={2}% <--- Storing a new position",
regulValveNr, reqFlowAve, rvPosition.ToString("F1"));
}
}
log.InfoFormat("flow = {0} m3/h (lo={1}, hi={2}, REACHED)", flow, currentReqFlowLo, currentReqFlowHi);
opState = OpState.FlowReached;
return Event.FlowReached;
}
else
{
log.InfoFormat("flow = {0} m3/h (lo={1}, hi={2}, FLOW_OK_TIMER={3}s)", flow, currentReqFlowLo, currentReqFlowHi, flowWithinBoundsTime);
return Event.Busy;
}
}
else if (StateMachine.Time > expireTime)
{
return Event.RegulValveTimeOut;
}
else
{
log.InfoFormat("flow = {0} m3/h (lo={1}, hi={2})", flow, currentReqFlowLo, currentReqFlowHi);
flowWithinBoundsTime = 0;
return Event.Busy;
}
}
else /// opState == OpState.FlowReached
{
log.InfoFormat("flow = {0} m3/h (lo={1}, hi={2}, REACHED)", flow, currentReqFlowLo, currentReqFlowHi);
return Event.FlowReached;
}
}
/// <summary>Start this operation</summary>
public void Stop()
{
if (!leaveMeasurementRunning)
{
/// Stop measurement
controlBoard.SendCommand(Command.Stop, flowMeter.Idx1, 50000, 50000, 0, StopDevs.RegValveRegulation); /// TestMethods=0
}
opState = OpState.Idle;
}
}
}
@@ -1,167 +0,0 @@
///
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.Rig.ControlBoard.Legacy;
using TBF.Rig.GenericDevices;
namespace TBF.Rig.Elde.RegulValve
{
public class SetRegulValvePositionOp : IOperation
{
private static readonly ILog log = LogManager.GetLogger(typeof(SetRegulValvePositionOp));
public override string ToString()
{
return string.Format("SetRegulValvePositionOp({0},{1},{2})", regulValve.Name, posLoPct, posHiPct);
}
const int CoaxValveNr = 7; /// Coax. valve has number 7
///
/// Internal states of this operation
///
enum OpState
{
Idle = 0,
MoveToPosition, /// Send commend to move to position
CheckState, /// Check RV state by reading statos word
MovingToPosition, /// Command passed OK, RV is moving to a position
}
OpState opState;
/// Set by the constructor
readonly CBoard controlBoard;
readonly RegulValve regulValve;
readonly int regulValveNr;
readonly double posLoPct;
readonly double posHiPct;
readonly int timeout;
/// Process values
bool firstRun;
int expireTime;
bool positionReached;
/// <summary>
/// Set required water flow.
/// Events: FlowSet, FlowTimeOut
/// </summary>
/// <param name="controlBoard">Control board device</param>
/// <param name="_regulValve">Regulation valve component</param>
/// <param name="posLoPct">Lower limit of the position to be achieved</param>
/// <param name="posHiPct">Upper limit of the position to be achieved</param>
/// <param name="timeout">Timeout in sec. for setting the flow</param>
/// <remarks>Only Elde.Valve flow are used, other flow on the lists are ignored</remarks>
public SetRegulValvePositionOp(CBoard controlBoard, RegulValve regulValve, double posLoPct, double posHiPct, int timeout)
{
if (controlBoard == null) throw new ArgumentNullException("ctrlBoard");
this.controlBoard = controlBoard;
this.regulValve = regulValve as RegulValve;
if (regulValve == null) throw new ArgumentNullException("regValve is null or not Elde");
this.regulValveNr = this.regulValve.Idx1;
this.posLoPct = posLoPct;
this.posHiPct = posHiPct;
this.timeout = timeout;
log.Debug(this.ToString());
}
/// <summary>
/// Set required water flow - no timeout.
/// Events: FlowSet
/// </summary>
public SetRegulValvePositionOp(CBoard controlBoard, RegulValve regValve, double posLoPct, double posHiPct)
: this(controlBoard, regValve, posLoPct, posHiPct, int.MaxValue)
{
}
/// <summary>Start this operation</summary>
public void Start()
{
firstRun = true;
positionReached = false;
expireTime = StateMachine.Time + timeout;
log.InfoFormat("Start(): RV#={0}, reqPosLo={1}%, reqPosHi={2}%", regulValveNr, posLoPct.ToString("F1"), posHiPct.ToString("F1"));
opState = OpState.MoveToPosition;
}
/// <summary>Run this operation</summary>
/// <returns>
/// Event.None . . . . . . . busy adjusting position
/// Event.PositionReached . . position reached
/// Event.OpArgumentError . . invalid required position
/// </returns>
public Event Run()
{
if (opState == OpState.MoveToPosition)
{
if (posLoPct >= posHiPct || posLoPct > 100.0f || posHiPct < 0)
{
return Event.OpArgumentError;
}
firstRun = false;
controlBoard.ValveMove(regulValveNr,
RegulValveMode.TargetPosition,
new double[2] { posLoPct, posHiPct },
regulValve.StableTime);
opState = OpState.CheckState;
return Event.None;
}
if (positionReached) return Event.PositionReached;
float positionPct = controlBoard.RValvePosition(regulValveNr);
log.WarnFormat("Run(): RV#={0}, actPos={1}%", regulValveNr, positionPct.ToString("F1"));
if (opState == OpState.CheckState)
{
if (regulValveNr == CoaxValveNr && ((ulong)controlBoard.StatusP & (ulong)StatusP.CoaxRegValveBusy) == 0)
{
opState = OpState.MoveToPosition;
return Event.None;
}
else if (posLoPct <= positionPct && positionPct <= posHiPct)
{
positionReached = true;
return Event.PositionReached;
}
else if ((regulValveNr < 6) && (controlBoard.RegulValveState(regulValveNr) != RegulValveState.DacValueRegul))
{
opState = OpState.MoveToPosition; /// Resend move command again in the next run
return Event.None;
}
else
{
opState = OpState.MovingToPosition;
return Event.None;
}
}
else if (StateMachine.Time > expireTime)
{
return Event.RegulValveTimeOut;
}
else if (opState == OpState.MovingToPosition)
{
if (posLoPct <= positionPct && positionPct <= posHiPct)
{
positionReached = true;
return Event.PositionReached;
}
return Event.None;
}
return Event.None;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
}
}
@@ -1,79 +0,0 @@
///
/// Copyright (c) 2017-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.Rig.ControlBoard.Legacy;
using TBF.Rig.GenericDevices;
namespace TBF.Rig.Elde.RegulValveCoax
{
public class ChangeRegulValvePositionOp : IOperation
{
private static readonly ILog log = LogManager.GetLogger(typeof(ChangeRegulValvePositionOp));
public override string ToString()
{
return string.Format("ChangeRegulValvePositionOp({0},{1}s)", regulValve.Name, timePulseSec.ToString("F2"));
}
/// Set by the constructor
readonly CBoard controlBoard;
readonly RegulValve regulValve;
readonly int regulValveNr;
readonly double timePulseSec;
/// <summary>
/// Set required water flow.
/// Events: FlowSet, FlowTimeOut
/// </summary>
/// <param name="controlBoard">Control board device</param>
/// <param name="_regulValve">Regulation valve component</param>
/// <param name="posLoPct">Lower limit of the position to be achieved</param>
/// <param name="posHiPct">Upper limit of the position to be achieved</param>
/// <param name="timeout">Timeout in sec. for setting the flow</param>
/// <remarks>Only Elde.Valve flow are used, other flow on the lists are ignored</remarks>
public ChangeRegulValvePositionOp(CBoard controlBoard, RegulValve _regulValve, double timePulseSec)
{
if (controlBoard == null) throw new ArgumentNullException("ctrlBoard");
this.controlBoard = controlBoard;
regulValve = _regulValve as RegulValve;
if (regulValve == null) throw new ArgumentNullException("regValve is null or not Elde");
regulValveNr = this.regulValve.Idx1;
this.timePulseSec = timePulseSec;
log.Debug(this.ToString());
}
/// <summary>Start this operation</summary>
public void Start()
{
float positionPct = controlBoard.RValvePosition(regulValveNr);
log.WarnFormat("RV#={0}, actPos={1}%", regulValveNr, positionPct.ToString("F1"));
controlBoard.ValveMove(regulValveNr,
RegulValveMode.PulseWidth,
new double[2] { timePulseSec, timePulseSec },
regulValve.StableTime);
}
/// <summary>Run this operation</summary>
/// <returns>
/// Event.SetFlowDone
/// </returns>
public Event Run()
{
float positionPct = controlBoard.RValvePosition(regulValveNr);
log.WarnFormat("RV#={0}, actPos={1}%", regulValveNr, positionPct.ToString("F1"));
return Event.PositionReached;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
}
}
-27
View File
@@ -1,27 +0,0 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Elde.RegulValveCoax
{
public class Factory : IComponentFactory
{
public string ClassName { get { return "RegulationValve-Coax"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { RegulValve.ResetStaticProperties(); }
public IComponent DummyComponent() { return new RegulValve(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new RegulValve(cfg, components); }
public IComponentCfg DefaultConfig() { return new RegulValveCfg("RV", this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(RegulValveCfg.Serializer, component, this);
}
}
}
@@ -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,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,27 +0,0 @@
///
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Elde.RegulValveTandem
{
public class RegulValveTandemFactory : IComponentFactory
{
public string ClassName { get { return "RegulationValveTandem"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { RegulValveTandem.ResetStaticProperties(); }
public IComponent DummyComponent() { return new RegulValveTandem(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new RegulValveTandem(cfg, components); }
public IComponentCfg DefaultConfig() { return new RegulValveTandemCfg("RV", this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(RegulValveTandemCfg.Serializer, component, this);
}
}
}
-27
View File
@@ -1,27 +0,0 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Elde.TempMeterMeret
{
public class Factory : IComponentFactory
{
public string ClassName { get { return "TempMeterMeret"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { TempMeter.ResetStaticProperties(); }
public IComponent DummyComponent() { return new TempMeter(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new TempMeter(cfg, components); }
public IComponentCfg DefaultConfig() { return new TempMeterCfg(this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(TempMeterCfg.Serializer, component, this);
}
}
}
-61
View File
@@ -1,61 +0,0 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
using log4net;
using TBF.Boxes;
namespace TBF.Rig.Elde.TempMeterMeret
{
public class ReadTempOp : IOperation
{
private static readonly ILog log = LogManager.GetLogger(typeof(ReadTempOp));
public override string ToString() { return string.Format("ReadTempOp({0},.,{1})", tempMeter.Name, eventDone); }
/// Set by the constructor
TempMeter tempMeter;
Event eventDone;
DoubleBox temp;
/// <summary>
/// Events: TempInDone, TempOutDone, TempDivDone or Error
/// </summary>
/// <param name="tempMeter">TempMeter reference</param>
/// <param name="temp">Reference to the variable, value is in degree Celsius</param>
/// <param name="eventDone">Event to be returned by Run() when completed OK</param>
public ReadTempOp(TempMeter tempMeter, ref DoubleBox temp, Event eventDone)
{
if (tempMeter == null) throw new ArgumentNullException("tempMeter");
this.tempMeter = tempMeter;
this.temp = temp;
this.eventDone = eventDone;
log.Debug(this.ToString());
}
public ReadTempOp(TempMeter tempMeter, ref DoubleBox temp)
: this(tempMeter, ref temp, Event.TempDone)
{
}
/// <summary>Start this operation</summary>
public void Start()
{
temp.Val = tempMeter.ReadTemperature();
}
/// <summary>Run this operation</summary>
/// <returns>
/// Event.TempInDone, Event.TempOutDone or Event.TempDivDone
/// </returns>
public Event Run()
{
temp.Val = tempMeter.ReadTemperature();
return eventDone;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
}
}
-99
View File
@@ -1,99 +0,0 @@
///
/// Copyright (c) 2018-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.Rig.ControlBoard.Legacy;
using TBF.Boxes;
using TBF.Resources;
namespace TBF.Rig.Elde.TempMeterMeret
{
public class TempMeter : ComponentBase, GenericDevices.ITempMeter, GenericDevices.IHasCalendarEvents, SchematicDrawing.IDrawingItCmpnt
{
private static readonly ILog log = LogManager.GetLogger(typeof(TempMeter));
public override string ToString() { return string.Format("TempMeter({0})", Cfg.ToString(1)); }
readonly TempMeterCfg tempMtrCfg;
public SchematicDrawing.IDrawingItem DrawingItem { get { return tempMtrCfg as SchematicDrawing.IDrawingItem; } }
public readonly CBoard ControlBoard;
public TempMeter() {}
public TempMeter(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
tempMtrCfg = cfg as TempMeterCfg;
ControlBoard = TbfComponents.FindComponent(cfg.ParentName, components) as CBoard;
if (ControlBoard == null) throw new Exception("Cannot find " + Name + " parent");
/// Prepare data for SendCalibData() control board component method
ControlBoard.MeretRS485Address[tempMtrCfg.MeretIdx0] = tempMtrCfg.ModbusAddress;
log.Warn(this.ToString());
}
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
{
DateTime calibrationDue = tempMtrCfg.CalibValidDate;
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
if (calibrationDue > TBF.UI.Constants.MinDate)
{
/// Calibration due date calendar event
calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
{
/// Weekly reminders (last 5 weeks)
calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
false));
}
if (DateTime.Now.Date <= calibrationDue.Date)
{
/// Daily reminders (last 5 days)
calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
string.Format(Strings.Calibration_due_date_is_0,
calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
true));
}
}
return calendarEvents;
}
public double ReadTemperature()
{
return Config.Formulas.CorrectedValue((double)ControlBoard.Temperature(tempMtrCfg.TempIdx0), Corrections);
}
/// <summary>
/// Events: TempDone, Error
/// </summary>
/// <param name="temp">Reference to a variable for the temperature in Celsius</param>
/// <returns>ReadTempOp instance reference casted to IOperaton</returns>
public IOperation ReadTempOp(ref DoubleBox temp)
{
return new ReadTempOp(this, ref temp);
}
/// <summary>
/// Events: tempDone, Error
/// </summary>
/// <param name="temp">Reference to a variable for the temperature in Celsius</param>
/// <param name="tempDone">Event returned when measurement done</param>
/// <returns>ReadTempOp instance reference casted to IOperaton</returns>
public IOperation ReadTempOp(ref DoubleBox temp, Event tempDone)
{
return new ReadTempOp(this, ref temp, tempDone);
}
}
}
-204
View File
@@ -1,204 +0,0 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Serialization;
using Config.Entities;
using SchematicDrawing;
using TBF.Rig.Generic;
namespace TBF.Rig.Elde.TempMeterMeret
{
public class TempMeterCfg : ComponentCfgBase, IChildComponentCfg, Config.Entities.IParamsProvider, TBF.Rig.GenericDevices.ICalibInfoCfg, IDrawingItemWithMeasuredVal
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TempMeterCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities)
{
var parents = cmpntEntities.Where(x => x.ClassName == "ControlBoard.Legacy");
return new Configs.ParamsProvider.ComponentCfgCtrl(this, parents);
}
///
/// Serialized parameters
///
public int TempIdx0; /// 0..19
public byte ModbusAddress; /// 1..247
public int MeretIdx0; /// Meter pressure meters count .. (Meter pressure meters count + Meter temperature meters count - 1)
/// Calibration info serialized parameters displayed in Metrology tab page
public string CalibCertificateNr { get; set; }
public DateTime CalibDate { get; set; }
public DateTime CalibValidDate { get; set; }
/// Schematic drawing info
public Shape Shape { get; set; }
public int X { get; set; }
public int Y { get; set; }
public Sz Sz { get; set; }
public Orient Orient { get; set; }
public bool Flip { get; set; }
public int LblX { get; set; }
public int LblY { get; set; }
public Orient LblOrient { get; set; }
public int MsrdX { get; set; }
public int MsrdY { get; set; }
public Orient MsrdOrient { get; set; }
public Config.Unit MsrdUnit { get; set; }
public string MsrdFormat { get; set; }
public double MsrdValLimLo { get; set; }
public double MsrdValLimHi { get; set; }
[XmlIgnore]
public IList<GNode> GNodes { get; set; }
/// Private parameterless constructor invoked by all other (public) constructors
TempMeterCfg()
{
GNodes = new List<GNode>();
}
public TempMeterCfg(IComponentFactory factory)
: this()
{
Shape = Shape.TempM;
Sz = Sz.M;
MsrdUnit = Config.Unit.C;
MsrdFormat = "{0:F1} °C";
Factory = factory;
Name = "T";
ParentName = "CB";
Name = "T";
ParentName = "CB";
InitializeAll();
}
public string ComponentName { get { return Name; } }
public void InitializeAll()
{
TempIdx0 = 8;
ModbusAddress = 1;
MeretIdx0 = 4;
}
string[] paramNames = new string[]
{
"Temp. index (0)",
"Modbus address",
"Meret index (0)",
};
public string ParamName(int i) { return paramNames[i]; }
public int ParamsCount() { return paramNames.Length; }
public ICollection<string> ParamValues(int i) { return null; }
public string ToString(int i)
{
if (i == -1)
{
return string.Format("Name={0}, Parent={1}, TempIx0={2}, Modbus address={3}, MeretIx0={4}",
Name,
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName),
TempIdx0, ModbusAddress, MeretIdx0);
}
switch (i)
{
case 0: return TempIdx0.ToString();
case 1: return ModbusAddress.ToString();
case 2: return MeretIdx0.ToString();
default: return string.Empty;
}
}
public CfgUpdateFlags UpdateParam(int i, string strValue)
{
switch (i)
{
case 0:
int ival = int.Parse(strValue);
if (TempIdx0 != ival)
{
TempIdx0 = ival;
return CfgUpdateFlags.RestartRqrd;
}
else return CfgUpdateFlags.None;
case 1:
byte addr = byte.Parse(strValue);
if (ModbusAddress != addr)
{
ModbusAddress = addr;
return CfgUpdateFlags.RestartRqrd;
}
else return CfgUpdateFlags.None;
case 2:
int ival2 = int.Parse(strValue);
if (MeretIdx0 != ival2)
{
MeretIdx0 = ival2;
return CfgUpdateFlags.RestartRqrd;
}
else return CfgUpdateFlags.None;
default:
return CfgUpdateFlags.None;
}
}
public bool ValidateParam(int i, string strValue, out string message)
{
message = string.Empty;
int dummy;
switch (i)
{
case 0:
if (int.TryParse(strValue, out dummy) && dummy >= 0 && dummy <= 19) return true;
break;
case 1:
if (int.TryParse(strValue, out dummy) && dummy >= 1 && dummy <= 247) return true;
message = ParamName(i) + " is invalid. Address range is 1 .. 247";
return false;
case 2:
if (int.TryParse(strValue, out dummy) && dummy >= 0 && dummy <= 19) return true;
break;
default:
message = "Invalid index";
return false;
}
message = ParamName(i) + " is invalid";
return false;
}
void CopyContentTo(TempMeterCfg prms)
{
prms.ParentName = this.ParentName;
prms.TempIdx0 = this.TempIdx0;
prms.ModbusAddress = this.ModbusAddress;
prms.MeretIdx0 = this.MeretIdx0;
}
public Config.Entities.IParamsProvider Clone()
{
TempMeterCfg pars = new TempMeterCfg();
CopyContentTo(pars);
return pars;
}
public bool UpdateEmbeddedDbEntity()
{
return true; /// =OK, do nothing
}
}
}
+1
View File
@@ -32,6 +32,7 @@ namespace TBF.Rig.Uni.RegValve
public int DacValueOpen { get { return regValveCfg.AdcValueOpen; } } /// 0 .. 1023
public int StableTime { get { return regValveCfg.StableTime; } } /// 0=200ms, step=50ms, max. 1500ms (max.26)
public int FlowStableSec { get { return regValveCfg.FlowStableSec; } } /// 0 .. 60 sec
public bool StoredPositionReuse { get { return regValveCfg.StoredPositionReuse; } }
///
public bool IsCoax { get { return false; } }
@@ -1,19 +0,0 @@
///
/// Copyright (c) 2021 Sensus Metering Systems
///
using System;
namespace TBF.Rig.Uni.RegValve
{
public class RegulValveCfgChangeArgs : EventArgs
{
public CfgChangeCmd Command;
public Generic.IComponentCfg Cfg;
public RegulValveCfgChangeArgs(CfgChangeCmd command, Generic.IComponentCfg cfg)
{
Command = command;
Cfg = cfg;
}
}
}
@@ -0,0 +1,74 @@
///
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.Rig.ControlBoard.Uni;
using TBF.Rig.GenericDevices;
namespace TBF.Rig.Uni.RegValveAnalog
{
public class ChangeRegulValvePositionOp : IOperation
{
private static readonly ILog log = LogManager.GetLogger(typeof(ChangeRegulValvePositionOp));
public override string ToString()
{
return string.Format("ChangeRegulValvePositionOp({0},{1}s)", regValve.Name, timePulseSec.ToString("F2"));
}
/// Set by the constructor
readonly UniCB uniCB;
readonly RegValve regValve;
readonly double timePulseSec;
/// <summary>
/// Set required water flow.
/// Events: FlowSet, FlowTimeOut
/// </summary>
/// <param name="uniCB">Control board device</param>
/// <param name="regValve">Regulation valve component</param>
/// <param name="posLoPct">Lower limit of the position to be achieved</param>
/// <param name="posHiPct">Upper limit of the position to be achieved</param>
/// <param name="timeout">Timeout in sec. for setting the flow</param>
/// <remarks>Only Elde.Valve flow are used, other flow on the lists are ignored</remarks>
public ChangeRegulValvePositionOp(UniCB uniCB, RegValve regValve, double timePulseSec)
{
if (uniCB == null) throw new ArgumentNullException("ctrlBoard");
this.uniCB = uniCB;
this.regValve = regValve as RegValve;
if (this.regValve == null) throw new ArgumentNullException("regValve is null or not Elde");
this.timePulseSec = timePulseSec;
log.Debug(this.ToString());
}
/// <summary>Start this operation</summary>
public void Start()
{
double positionPct = regValve.Position;
log.WarnFormat("RV#={0}, actPos={1}%", regValve.Idx1, positionPct.ToString("F1"));
uniCB.RegVlvIncrMove(false, regValve.Idx1, timePulseSec);
}
/// <summary>Run this operation</summary>
/// <returns>
/// Event.SetFlowDone
/// </returns>
public Event Run()
{
double positionPct = regValve.Position;
log.WarnFormat("RV#={0}, actPos={1}%", regValve.Idx1, positionPct.ToString("F1"));
return Event.PositionReached;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
}
}
+27
View File
@@ -0,0 +1,27 @@
///
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Uni.RegValveAnalog
{
public class Factory : IComponentFactory
{
public string ClassName { get { return "RegValveAnalog"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { RegValve.ResetStaticProperties(); }
public IComponent DummyComponent() { return new RegValve(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new RegValve(cfg, components); }
public IComponentCfg DefaultConfig() { return new RegValveCfg("RV", this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(RegValveCfg.Serializer, component, this);
}
}
}
@@ -1,41 +1,48 @@
///
/// Copyright (c) 2017-2020 Sensus Slovensko a.s.
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using SchematicDrawing;
using TBF.Rig.ControlBoard.Legacy;
using TBF.Rig.ControlBoard.Uni;
using TBF.Boxes;
namespace TBF.Rig.Elde.RegulValveCoax
namespace TBF.Rig.Uni.RegValveAnalog
{
public class RegulValve : ComponentBase, GenericDevices.IRegValve, IDrawingItCmpntWithSetpoint
public class RegValve : ComponentBase, GenericDevices.IRegValve, IDrawingItCmpntWithSetpoint
{
private static readonly ILog log = LogManager.GetLogger(typeof(RegulValve));
private static readonly ILog log = LogManager.GetLogger(typeof(RegValve));
public override string ToString() { return string.Format("RegulValve({0})", Cfg.ToString(1)); }
public readonly RegulValveCfg RegulValveCfg;
public IDrawingItem DrawingItem { get { return RegulValveCfg as IDrawingItem; } }
readonly RegValveCfg regValveCfg;
public ValveCategory Category { get { return regValveCfg.Category; } }
public int Idx1 { get { return regValveCfg.Idx1; } } /// 1..7
public int StableTime { get { return regValveCfg.StableTime; } } /// 0=200ms, step=50ms, max. 1500ms (max.26)
public int FlowStableSec { get { return regValveCfg.FlowStableSec; } } /// 0..60 sec
public bool StoredPositionReuse { get { return regValveCfg.StoredPositionReuse; } }
public IDrawingItem DrawingItem { get { return regValveCfg as IDrawingItem; } }
IDictionary<double, double> dict;
public IDictionary<double, double> Dict { get { return dict; } }
public readonly CBoard ControlBoard;
readonly UniCB uniCB;
public ValveCategory Category { get { return RegulValveCfg.Category; } }
public int Idx1 { get { return RegulValveCfg.Idx1; } } /// 1..7
public int StableTime { get { return RegulValveCfg.StableTime; } } /// 0=200ms, step=50ms, max. 1500ms (max.26)
public int FlowStableSec { get { return RegulValveCfg.FlowStableSec; } } /// 0..60 sec
///
///
public bool IsCoax { get { return true; } }
///
public double Position { get { return ControlBoard.RValvePosition(Idx1); } }
public double Position
{
get {
return 50.0; // TODO: was return uniCB.RValvePosition(Idx1);
}
}
///
public double SetpointVal
{
get { return (double)ControlBoard.RValvePosition(Idx1); }
get { return Position; }
set { } // TODO
}
///
@@ -50,17 +57,17 @@ namespace TBF.Rig.Elde.RegulValveCoax
}
public RegulValve()
public RegValve()
{
}
public RegulValve(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
public RegValve(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
RegulValveCfg = cfg as RegulValveCfg;
regValveCfg = cfg as RegValveCfg;
ControlBoard = (CBoard)TbfComponents.FindComponent(cfg.ParentName, components);
if (ControlBoard == null) throw new Exception("Cannot find " + Name + " parent");
uniCB = TbfComponents.FindComponent(cfg.ParentName, components) as UniCB;
if (uniCB == null) throw new Exception("Cannot find " + Name + " parent");
this.dict = new Dictionary<double, double>();
@@ -73,15 +80,15 @@ namespace TBF.Rig.Elde.RegulValveCoax
/// Events: Event.None, Event.FlowReached, Event.FlowTimeOut
/// </summary>
/// <param name="flowMeter">Flowmeter component</param>
/// <param name="requiredFlowLo">Lower limit of the required flow [m3/h]</param>
/// <param name="requiredFlowHi">Higher limit of the required flow [m3/h]</param>
/// <param name="qFrom">Lower limit of the required flow [m3/h]</param>
/// <param name="qTo">Higher limit of the required flow [m3/h]</param>
/// <param name="pidCoef">PID coefficient (float)</param>
/// <param name="measuredFlow">Measured flow [m3/h]</param>
/// <param name="timeout">Timeout in [s]</param>
/// <returns>SetFlowOp instance</returns>
public IOperation SetFlowOp(GenericDevices.IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi, DoubleBox measuredFlow, int timeout)
public IOperation SetFlowOp(GenericDevices.IFlowMeter flowMeter, double qFrom, double qTo, DoubleBox measuredFlow, int timeout)
{
return new SetFlowOp(ControlBoard, this, flowMeter, requiredFlowLo, requiredFlowHi, measuredFlow, RegulValveCfg.ReTryCommands, timeout);
return new SetFlowOp(uniCB, this, flowMeter, qFrom, qTo, measuredFlow, regValveCfg.ReTryCommands, timeout);
}
/// <summary>
@@ -89,15 +96,15 @@ namespace TBF.Rig.Elde.RegulValveCoax
/// Events: Event.None, Event.FlowReached, Event.FlowTimeOut
/// </summary>
/// <param name="flowMeter">Flowmeter component</param>
/// <param name="requiredFlowLo">Lower limit of the required flow [m3/h]</param>
/// <param name="requiredFlowHi">Higher limit of the required flow [m3/h]</param>
/// <param name="qFrom">Lower limit of the required flow [m3/h]</param>
/// <param name="qTo">Higher limit of the required flow [m3/h]</param>
/// <param name="measuredFlow">Measured flow [m3/h]</param>
/// <param name="timeout">Timeout in [s]</param>
/// <returns>SetFlowOp instance</returns>
public IOperation SetFlowAndMeasureOp(GenericDevices.IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi,
public IOperation SetFlowAndMeasureOp(GenericDevices.IFlowMeter flowMeter, double qFrom, double qTo,
DoubleBox measuredFlow, int timeout, float filterConstant)
{
return new SetFlowOp(ControlBoard, this, flowMeter, requiredFlowLo, requiredFlowHi, measuredFlow, RegulValveCfg.ReTryCommands, timeout, true);
return new SetFlowOp(uniCB, this, flowMeter, qFrom, qTo, measuredFlow, regValveCfg.ReTryCommands, timeout, true);
}
/// <summary>
@@ -109,12 +116,12 @@ namespace TBF.Rig.Elde.RegulValveCoax
/// <returns>SetPositionOp instance</returns>
public IOperation SetRegulValvePositionOp(double pctLo, double pctHi, int timeoutMs)
{
return new SetRegulValvePositionOp(ControlBoard, this, pctLo, pctHi, timeoutMs);
return new SetRegulValvePositionOp(uniCB, this, pctLo, pctHi, timeoutMs);
}
public IOperation ChangeRegulValvePositionOp(double timePulseSec)
{
return new ChangeRegulValvePositionOp(ControlBoard, this, timePulseSec);
return new ChangeRegulValvePositionOp(uniCB, this, timePulseSec);
}
}
}
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2017-2020 Sensus Slovensko a.s.
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -9,14 +9,14 @@ using Config.Entities;
using SchematicDrawing;
using TBF.Rig.Generic;
namespace TBF.Rig.Elde.RegulValveCoax
namespace TBF.Rig.Uni.RegValveAnalog
{
public class RegulValveCfg : ComponentCfgBase, IChildComponentCfg, IDrawingItemWithSetpoint
public class RegValveCfg : ComponentCfgBase, IChildComponentCfg, IDrawingItemWithSetpoint
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(RegulValveCfg) })[0];
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(RegValveCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new RegulValveCfgCtrl(); }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new RegValveCfgCtrl(); }
///
/// Serialized parameters
@@ -53,12 +53,12 @@ namespace TBF.Rig.Elde.RegulValveCoax
public int StableTime { get { return (StableTimeMs - 200) / 50; } }
/// Private parameterless constructor invoked by all other (public) constructors
RegulValveCfg()
RegValveCfg()
{
GNodes = new List<GNode>();
}
public RegulValveCfg(string name, IComponentFactory factory)
public RegValveCfg(string name, IComponentFactory factory)
: this()
{
Shape = Shape.RegV;
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2017-2020 Sensus Slovensko a.s.
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
@@ -7,26 +7,26 @@ using Config.Entities;
using TBF.Rig.Generic;
using TBF.UI.Bench.Components;
namespace TBF.Rig.Elde.RegulValveCoax
namespace TBF.Rig.Uni.RegValveAnalog
{
public partial class RegulValveCfgCtrl : UserControl, IComponentCfgCtrl
public partial class RegValveCfgCtrl : UserControl, IComponentCfgCtrl
{
ComponentParametersDlg parent;
public bool ShowMore { get { return true; } }
RegulValveCfg config;
RegValveCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as RegulValveCfg;
config = value as RegValveCfg;
Redraw();
}
}
public RegulValveCfgCtrl()
public RegValveCfgCtrl()
{
InitializeComponent();
}
@@ -1,9 +1,9 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
namespace TBF.Rig.Elde.RegulValveCoax
namespace TBF.Rig.Uni.RegValveAnalog
{
partial class RegulValveCfgCtrl
partial class RegValveCfgCtrl
{
/// <summary>
/// Required designer variable.
@@ -1,28 +1,27 @@
///
/// Copyright (c) 2017-2020 Sensus Slovensko a.s.
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.Rig.ControlBoard.Legacy;
using TBF.Rig.ControlBoard.Uni;
using TBF.Rig.GenericDevices;
using TBF.Boxes;
namespace TBF.Rig.Elde.RegulValveCoax
namespace TBF.Rig.Uni.RegValveAnalog
{
public class SetFlowOp : IOperation
{
private static readonly ILog log = LogManager.GetLogger(typeof(SetFlowOp));
public override string ToString()
{
return string.Format("SetFlowOp({0}, Qfrom={1}, Qto={2})", regulValve.Name, finalReqFlowLo, finalReqFlowHi);
return string.Format("SetFlowOp({0}, Qfrom={1}, Qto={2})", regValve.Name, finalReqFlowLo, finalReqFlowHi);
}
/// Set by the constructor
readonly CBoard controlBoard;
readonly Elde.RegulValveCoax.RegulValve regulValve;
readonly int regulValveNr;
readonly int flowMeterNr;
readonly UniCB uniCB;
readonly RegValve regValve;
readonly int flowMeterId;
readonly double finalReqFlowLo;
readonly double finalReqFlowHi;
readonly double reqFlowAve;
@@ -77,24 +76,23 @@ namespace TBF.Rig.Elde.RegulValveCoax
/// <param name="timeout">Timeout for the flow setting in [s]</param>
/// <param name="leaveMeasurementRunning">true = Leave the measurement running after op. stop</param>
/// <remarks>Only Elde.Valve flow are used, other flow on the lists are ignored</remarks>
public SetFlowOp(CBoard controlBoard, IRegValve _regulValve, IFlowMeter flowMeter,
public SetFlowOp(TBF.Rig.ControlBoard.IControlBoard cb, IRegValve _regulValve, IFlowMeter flowMeter,
double requiredFlowLo, double requiredFlowHi, DoubleBox measuredFlow,
bool reTryCmds, int timeout, bool leaveMeasurementRunning)
{
if (controlBoard == null) throw new ArgumentNullException("ctrlBoard");
this.controlBoard = controlBoard;
uniCB = cb as UniCB;
if (uniCB == null) throw new ArgumentNullException("ctrlBoard");
regulValve = _regulValve as Elde.RegulValveCoax.RegulValve;
if (regulValve == null) throw new ArgumentNullException(string.Format("{0} is not Elde.RegulValveCoax.", _regulValve.Name));
regulValveNr = this.regulValve.Idx1;
regValve = _regulValve as TBF.Rig.Uni.RegValveAnalog.RegValve;
if (regValve == null) throw new ArgumentNullException(string.Format("{0} is not Elde.RegulValveCoax.", _regulValve.Name));
if (flowMeter is Uni.FlowMeter.FlowMeter)
{
this.flowMeterNr = (flowMeter as Uni.FlowMeter.FlowMeter).Idx1;
this.flowMeterId = (flowMeter as Uni.FlowMeter.FlowMeter).Idx1;
}
else if (flowMeter is Elde.FlowMeterTwins.FlowMeter)
{
this.flowMeterNr = 0;
this.flowMeterId = 0;
}
else
{
@@ -121,9 +119,9 @@ namespace TBF.Rig.Elde.RegulValveCoax
/// Set required water flow - Do not leave the measurement running.
/// Events: FlowSet
/// </summary>
public SetFlowOp(CBoard controlBoard, IRegValve regValve, IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi,
public SetFlowOp(UniCB uniCB, IRegValve regValve, IFlowMeter flowMeter, double qFrom, double qTo,
DoubleBox measuredFlow, bool reTryCmds, int timeout)
: this(controlBoard, regValve, flowMeter, requiredFlowLo, requiredFlowHi, measuredFlow, reTryCmds, timeout, false)
: this(uniCB, regValve, flowMeter, qFrom, qTo, measuredFlow, reTryCmds, timeout, false)
{
}
@@ -131,9 +129,9 @@ namespace TBF.Rig.Elde.RegulValveCoax
/// Set required water flow - No timeout.
/// Events: FlowSet
/// </summary>
public SetFlowOp(CBoard controlBoard, IRegValve regValve, IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi,
public SetFlowOp(UniCB uniCB, IRegValve regValve, IFlowMeter flowMeter, double qFrom, double qTo,
DoubleBox measuredFlow, bool reTryCmds)
: this(controlBoard, regValve, flowMeter, requiredFlowLo, requiredFlowHi, measuredFlow, reTryCmds, int.MaxValue, false)
: this(uniCB, regValve, flowMeter, qFrom, qTo, measuredFlow, reTryCmds, int.MaxValue, false)
{
}
@@ -147,7 +145,7 @@ namespace TBF.Rig.Elde.RegulValveCoax
bool FetchTargetPosition(double avgReqFlow, out double positionLo, out double positionHi)
{
double targetPosition;
if (regulValve.Dict.TryGetValue(avgReqFlow, out targetPosition))
if (regValve.Dict.TryGetValue(avgReqFlow, out targetPosition))
{
positionLo = Math.Max(targetPosition * 0.95f, 0.0f);
positionHi = Math.Min(targetPosition * 1.05f, 100.0f);
@@ -163,9 +161,9 @@ namespace TBF.Rig.Elde.RegulValveCoax
void StoreTargetPosition(double avgReqFlow, double actPosition)
{
if (!regulValve.Dict.ContainsKey(reqFlowAve))
if (!regValve.Dict.ContainsKey(reqFlowAve))
{
regulValve.Dict.Add(new KeyValuePair<double, double>(avgReqFlow, actPosition));
regValve.Dict.Add(new KeyValuePair<double, double>(avgReqFlow, actPosition));
}
return;
}
@@ -173,7 +171,7 @@ namespace TBF.Rig.Elde.RegulValveCoax
/// <summary>Start this operation</summary>
public void Start()
{
double flowMtrFreq = controlBoard.RefFrequency;
double flowMtrFreq = uniCB.RefFrequency;
currentReqFlowLo = reqFlowAve;
currentReqFlowHi = reqFlowAve;
///
@@ -192,17 +190,17 @@ namespace TBF.Rig.Elde.RegulValveCoax
flowWithinBoundsTime = 0;
if (regulValve.RegulValveCfg.StoredPositionReuse && FetchTargetPosition(reqFlowAve, out targetPositionLo, out targetPositionHi))
if (regValve.StoredPositionReuse && FetchTargetPosition(reqFlowAve, out targetPositionLo, out targetPositionHi))
{
log.WarnFormat("Start() rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3} FETCHED: posLo={4} posHi={5}",
regulValveNr, flowMeterNr, currentReqFlowLo, currentReqFlowHi, targetPositionLo, targetPositionHi);
regValve.Idx1, flowMeterId, currentReqFlowLo, currentReqFlowHi, targetPositionLo, targetPositionHi);
opState = OpState.ValveMoveToPosition1;
}
else
{
log.WarnFormat("Start() rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3}",
regulValveNr, flowMeterNr, currentReqFlowLo, currentReqFlowHi);
regValve.Idx1, flowMeterId, currentReqFlowLo, currentReqFlowHi);
opState = OpState.ValveMoveToFlow1;
}
@@ -210,11 +208,9 @@ namespace TBF.Rig.Elde.RegulValveCoax
expireTime = StateMachine.Time + timeout;
if (expireTime < 0) expireTime = int.MaxValue;
ControlBoard.Legacy.TestMethods tm = 0;
StopDevs sd = 0;
// '_regulValve.RegulValveCfg.PidCoef' replaced by a casted operation parameter 'pidCoef'
controlBoard.SendCommand(Command.Start, flowMeterNr, int.MaxValue, int.MaxValue, tm, sd);
}
/// Start the flow measurement
uniCB.MeasureFlow(false, flowMeterId);
}
/// <summary>Run this operation</summary>
/// <returns>
@@ -222,8 +218,8 @@ namespace TBF.Rig.Elde.RegulValveCoax
/// </returns>
public Event Run()
{
float rvPosition = controlBoard.RValvePosition(regulValveNr);
double flowMtrFreq = controlBoard.RefFrequency;
double rvPosition = regValve.Position;
double flowMtrFreq = uniCB.RefFrequency;
double flow = flowMtrFreq * nominalFlow / 2000.0;
if (flowMtrFreq != 0)
@@ -234,24 +230,24 @@ namespace TBF.Rig.Elde.RegulValveCoax
}
log.InfoFormat("Run() rv#={0} pos={1}% freq={2} flow={3} curFlLo={4} curFlHi={5} state={6}",
regulValveNr, rvPosition.ToString("F1"), flowMtrFreq.ToString("F1"), flow.ToString("F3"), currentReqFlowLo.ToString("F3"), currentReqFlowHi.ToString("F3"), opState);
regValve.Idx1, rvPosition.ToString("F1"), flowMtrFreq.ToString("F1"), flow.ToString("F3"), currentReqFlowLo.ToString("F3"), currentReqFlowHi.ToString("F3"), opState);
if (opState == OpState.SendCommandAgain)
{
flowWithinBoundsTime = 0;
if (regulValve.RegulValveCfg.StoredPositionReuse && FetchTargetPosition(reqFlowAve, out targetPositionLo, out targetPositionHi))
if (regValve.StoredPositionReuse && FetchTargetPosition(reqFlowAve, out targetPositionLo, out targetPositionHi))
{
log.InfoFormat(" Run() rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3} FETCHED: posLo={4} posHi={5}",
regulValveNr, flowMeterNr, currentReqFlowLo.ToString("F3"), currentReqFlowHi.ToString("F3"), targetPositionLo, targetPositionHi);
regValve.Idx1, flowMeterId, currentReqFlowLo.ToString("F3"), currentReqFlowHi.ToString("F3"), targetPositionLo, targetPositionHi);
opState = OpState.ValveMoveToPosition1;
}
else
{
log.InfoFormat(" Run() rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3}",
regulValveNr, flowMeterNr, currentReqFlowLo.ToString("F3"), currentReqFlowHi.ToString("F3"));
regValve.Idx1, flowMeterId, currentReqFlowLo.ToString("F3"), currentReqFlowHi.ToString("F3"));
opState = OpState.ValveMoveToFlow1;
}
@@ -259,11 +255,10 @@ namespace TBF.Rig.Elde.RegulValveCoax
expireTime = StateMachine.Time + timeout;
if (expireTime < 0) expireTime = int.MaxValue;
ControlBoard.Legacy.TestMethods tm = 0;
StopDevs sd = 0;
// '_regulValve.RegulValveCfg.PidCoef' replaced by a casted operation parameter 'pidCoef'
controlBoard.SendCommand(Command.Start, flowMeterNr, int.MaxValue, int.MaxValue, tm, sd);
log.DebugFormat(" return Event.None");
/// Start the flow measurement
uniCB.MeasureFlow(false, flowMeterId);
return Event.None;
}
else if (opState == OpState.ValveMoveToPosition1)
@@ -275,9 +270,10 @@ namespace TBF.Rig.Elde.RegulValveCoax
else if (opState == OpState.ValveMoveToPosition2) /// Move to position
{
/// Issues the appropriate ValveMove(...) command
controlBoard.ValveMove(regulValveNr, RegulValveMode.TargetPosition,
new double[2] { (targetPositionLo + targetPositionHi) / 2, (targetPositionLo + targetPositionHi) / 2 },
regulValve.StableTime);
// TODO: Reimplement
//uniCB.ValveMove(regValve.Idx1, RegulValveMode.TargetPosition,
// new double[2] { (targetPositionLo + targetPositionHi) / 2, (targetPositionLo + targetPositionHi) / 2 },
// regValve.StableTime);
opState = OpState.SettingPosition;
log.DebugFormat(" return Event.None");
@@ -298,21 +294,22 @@ namespace TBF.Rig.Elde.RegulValveCoax
}
else if (opState == OpState.CheckStatePosition) /// Verify
{
if (((ulong)controlBoard.StatusP & (ulong)StatusP.RefPulsesMsrmnt) == 0)
if (((ulong)uniCB.State & (ulong)StatusP.TestWithRefFlowmtr) == 0)
{
opState = OpState.SendCommandAgain;
log.DebugFormat(" return Event.None");
return Event.None;
}
else if (((ulong)controlBoard.StatusP & (ulong)StatusP.CoaxRegValveBusy) == 0)
else if (((ulong)uniCB.State & (ulong)StatusP.CoaxRegValveBusy) == 0)
{
/// Repeat appropriate ValveMove(...) command
controlBoard.ValveMove(regulValveNr, RegulValveMode.TargetPosition,
new double[2] { (targetPositionLo + targetPositionHi) / 2, (targetPositionLo + targetPositionHi) / 2 },
regulValve.StableTime);
// TODO: Reimplement
///// Repeat appropriate ValveMove(...) command
//uniCB.ValveMove(regValve.Idx1, RegulValveMode.TargetPosition,
// new double[2] { (targetPositionLo + targetPositionHi) / 2, (targetPositionLo + targetPositionHi) / 2 },
// regValve.StableTime);
log.InfoFormat(" Run() ValveMove({0}, Position, {1}, {2}, {3})",
regulValveNr, (targetPositionLo + targetPositionHi) / 2, (targetPositionLo + targetPositionHi) / 2, regulValve.StableTime);
regValve.Idx1, (targetPositionLo + targetPositionHi) / 2, (targetPositionLo + targetPositionHi) / 2, regValve.StableTime);
opState = OpState.ValveMoveToPosition3;
log.DebugFormat(" return Event.None");
@@ -354,13 +351,14 @@ namespace TBF.Rig.Elde.RegulValveCoax
double freqLo = 2000.0 * currentReqFlowLo / nominalFlow;
double freqHi = 2000.0 * currentReqFlowHi / nominalFlow;
controlBoard.ValveMove(regulValveNr, RegulValveMode.TargetFrequency,
new double[2] { (freqLo + freqHi) / 2, (freqLo + freqHi) / 2 },
regulValve.StableTime);
// TODO: Reimplement
//uniCB.ValveMove(regValve.Idx1, RegulValveMode.TargetFrequency,
// new double[2] { (freqLo + freqHi) / 2, (freqLo + freqHi) / 2 },
// regValve.StableTime);
log.WarnFormat(" Run() ValveMove({0}, Freq., {1}, {2}, {3}) flowMtr#={4} TARGET: flowLo={5} flowHi={6}",
regulValveNr, (freqLo + freqHi) / 2, (freqLo + freqHi) / 2,
regulValve.StableTime,
flowMeterNr, currentReqFlowLo.ToString("F3"), currentReqFlowHi.ToString("F3"));
regValve.Idx1, (freqLo + freqHi) / 2, (freqLo + freqHi) / 2,
regValve.StableTime,
flowMeterId, currentReqFlowLo.ToString("F3"), currentReqFlowHi.ToString("F3"));
opState = OpState.ValveMoveToFlow3;
log.DebugFormat(" return Event.None");
@@ -381,19 +379,20 @@ namespace TBF.Rig.Elde.RegulValveCoax
}
else if (opState == OpState.CheckStateFlow) /// Verify the flow setting
{
if (((ulong)controlBoard.StatusP & (ulong)StatusP.CoaxRegValveBusy) == 0)
if (((ulong)uniCB.State & (ulong)StatusP.CoaxRegValveBusy) == 0)
{
/// Done once, issues an appropriate ValveMove(...) command
double freqLo = 2000.0 * currentReqFlowLo / nominalFlow;
double freqHi = 2000.0 * currentReqFlowHi / nominalFlow;
controlBoard.ValveMove(regulValveNr, RegulValveMode.TargetFrequency,
new double[2] { (freqLo + freqHi) / 2, (freqLo + freqHi) / 2 },
regulValve.StableTime);
// TODO: Reimplement
//uniCB.ValveMove(regValve.Idx1, RegulValveMode.TargetFrequency,
// new double[2] { (freqLo + freqHi) / 2, (freqLo + freqHi) / 2 },
// regValve.StableTime);
log.WarnFormat(" Run() ValveMove({0}, Frequency, {1}, {2}, {3}) flowMtr#={4} TARGET: flowLo={5} flowHi={6}",
regulValveNr, (freqLo + freqHi) / 2, (freqLo + freqHi) / 2,
regulValve.StableTime,
flowMeterNr, currentReqFlowLo.ToString("F3"), currentReqFlowHi.ToString("F3"));
regValve.Idx1, (freqLo + freqHi) / 2, (freqLo + freqHi) / 2,
regValve.StableTime,
flowMeterId, currentReqFlowLo.ToString("F3"), currentReqFlowHi.ToString("F3"));
opState = OpState.ValveMoveToFlow3;
log.DebugFormat(" return Event.None");
@@ -413,24 +412,24 @@ namespace TBF.Rig.Elde.RegulValveCoax
///
if ((currentReqFlowLo <= flow) && (flow <= currentReqFlowHi))
{
if (flowWithinBoundsTime++ >= regulValve.FlowStableSec)
if (flowWithinBoundsTime++ >= regValve.FlowStableSec)
{
if (regulValve.RegulValveCfg.StoredPositionReuse)
if (regValve.StoredPositionReuse)
{
double storedPosition;
if (regulValve.Dict.TryGetValue(reqFlowAve, out storedPosition))
if (regValve.Dict.TryGetValue(reqFlowAve, out storedPosition))
{
/// update the stored valve position
StoreTargetPosition(reqFlowAve, (rvPosition + storedPosition) / 2.0f);
log.InfoFormat(" Run() rv#={0} reqFlow={1} pos={2}% stored={3} <--- Updating a stored position",
regulValveNr, reqFlowAve, rvPosition.ToString("F1"), storedPosition);
regValve.Idx1, reqFlowAve, rvPosition.ToString("F1"), storedPosition);
}
else
{
/// store the valve position
StoreTargetPosition(reqFlowAve, rvPosition);
log.InfoFormat(" Run() rv#={0} reqFlow={1} pos={2}% <--- Storing a new position",
regulValveNr, reqFlowAve, rvPosition.ToString("F1"));
regValve.Idx1, reqFlowAve, rvPosition.ToString("F1"));
}
}
@@ -472,15 +471,9 @@ namespace TBF.Rig.Elde.RegulValveCoax
public void Stop()
{
opState = OpState.Idle;
if (leaveMeasurementRunning) return;
/// Stop measurement
ControlBoard.Legacy.TestMethods tm = 0;
StopDevs sd = StopDevs.RegValveRegulation;
controlBoard.SendCommand(Command.Stop, flowMeterNr, 50000, 50000, tm, sd);
log.WarnFormat("Stop() SendCommand(Stop, {0}, ...)", flowMeterNr);
uniCB.Stop(false); /// Stop measurement
log.WarnFormat("Stop() SendCommand(Stop, {0}, ...)", flowMeterId);
}
}
}
@@ -1,24 +1,22 @@
///
/// Copyright (c) 2017-2020 Sensus Slovensko a.s.
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.Rig.ControlBoard.Legacy;
using TBF.Rig.ControlBoard.Uni;
using TBF.Rig.GenericDevices;
namespace TBF.Rig.Elde.RegulValveCoax
namespace TBF.Rig.Uni.RegValveAnalog
{
public class SetRegulValvePositionOp : IOperation
{
private static readonly ILog log = LogManager.GetLogger(typeof(SetRegulValvePositionOp));
public override string ToString()
{
return string.Format("SetRegulValvePositionOp({0},{1},{2})", regulValve.Name, posLoPct, posHiPct);
return string.Format("SetRegulValvePositionOp({0},{1},{2})", regValve.Name, posLoPct, posHiPct);
}
const int CoaxValveNr = 7; /// Coax. valve has number 7
///
/// Internal states of this operation
///
@@ -32,9 +30,8 @@ namespace TBF.Rig.Elde.RegulValveCoax
OpState opState;
/// Set by the constructor
readonly CBoard controlBoard;
readonly RegulValve regulValve;
readonly int regulValveNr;
readonly UniCB uniCB;
readonly RegValve regValve;
readonly double posLoPct;
readonly double posHiPct;
readonly int timeout;
@@ -48,24 +45,22 @@ namespace TBF.Rig.Elde.RegulValveCoax
/// Set required water flow.
/// Events: FlowSet, FlowTimeOut
/// </summary>
/// <param name="controlBoard">Control board device</param>
/// <param name="uniCB">Control board device</param>
/// <param name="_regulValve">Regulation valve component</param>
/// <param name="posLoPct">Lower limit of the position to be achieved</param>
/// <param name="posHiPct">Upper limit of the position to be achieved</param>
/// <param name="timeout">Timeout in sec. for setting the flow</param>
/// <remarks>Only Elde.Valve flow are used, other flow on the lists are ignored</remarks>
public SetRegulValvePositionOp(CBoard controlBoard, RegulValve regulValve, double posLoPct, double posHiPct, int timeout)
public SetRegulValvePositionOp(UniCB uniCB, RegValve regV, double posLoPct, double posHiPct, int timeout)
{
if (controlBoard == null) throw new ArgumentNullException("ctrlBoard");
this.controlBoard = controlBoard;
if (uniCB == null) throw new ArgumentNullException("ctrlBoard");
this.uniCB = uniCB;
this.regulValve = regulValve as RegulValve;
if (regulValve == null) throw new ArgumentNullException("regValve is null or not Elde");
this.regulValveNr = this.regulValve.Idx1;
this.regValve = regV as RegValve;
if (regV == null) throw new ArgumentNullException("regValve is null or not Elde");
this.posLoPct = posLoPct;
this.posHiPct = posHiPct;
this.timeout = timeout;
log.Debug(this.ToString());
@@ -75,8 +70,8 @@ namespace TBF.Rig.Elde.RegulValveCoax
/// Set required water flow - no timeout.
/// Events: FlowSet
/// </summary>
public SetRegulValvePositionOp(CBoard controlBoard, RegulValve regValve, double posLoPct, double posHiPct)
: this(controlBoard, regValve, posLoPct, posHiPct, int.MaxValue)
public SetRegulValvePositionOp(UniCB uniCB, RegValve regValve, double posLoPct, double posHiPct)
: this(uniCB, regValve, posLoPct, posHiPct, int.MaxValue)
{
}
@@ -86,7 +81,7 @@ namespace TBF.Rig.Elde.RegulValveCoax
firstRun = true;
positionReached = false;
expireTime = StateMachine.Time + timeout;
log.InfoFormat("Start(): RV#={0}, reqPosLo={1}%, reqPosHi={2}%", regulValveNr, posLoPct.ToString("F1"), posHiPct.ToString("F1"));
log.InfoFormat("Start(): RV#={0}, reqPosLo={1}%, reqPosHi={2}%", regValve.Idx1, posLoPct.ToString("F1"), posHiPct.ToString("F1"));
opState = OpState.MoveToPosition;
}
@@ -107,22 +102,19 @@ namespace TBF.Rig.Elde.RegulValveCoax
firstRun = false;
controlBoard.ValveMove(regulValveNr,
RegulValveMode.TargetPosition,
new double[2] { posLoPct, posHiPct },
regulValve.StableTime);
uniCB.RegVlvMoveToPos(false, regValve.Idx1, posLoPct, posHiPct);
opState = OpState.CheckState;
return Event.None;
}
if (positionReached) return Event.PositionReached;
float positionPct = controlBoard.RValvePosition(regulValveNr);
log.WarnFormat("Run(): RV#={0}, actPos={1}%", regulValveNr, positionPct.ToString("F1"));
double positionPct = regValve.Position;
log.WarnFormat("Run(): RV#={0}, actPos={1}%", regValve.Idx1, positionPct.ToString("F1"));
if (opState == OpState.CheckState)
{
if (regulValveNr == CoaxValveNr && ((ulong)controlBoard.StatusP & (ulong)StatusP.CoaxRegValveBusy) == 0)
if ((uniCB.State & (ulong)StatusP.CoaxRegValveBusy) == 0)
{
opState = OpState.MoveToPosition;
return Event.None;
@@ -132,7 +124,9 @@ namespace TBF.Rig.Elde.RegulValveCoax
positionReached = true;
return Event.PositionReached;
}
else if ((regulValveNr < 6) && (controlBoard.RegulValveState(regulValveNr) != RegulValveState.DacValueRegul))
else if (regValve.Idx1 < 6
/// && uniCB.RegulValveState(regValve.Idx1) != RegulValveState.DacValueRegul // TODO: Reimplement
)
{
opState = OpState.MoveToPosition; /// Resend move command again in the next run
return Event.None;
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -7,7 +7,7 @@ using log4net;
using TBF.Rig.ControlBoard.Legacy;
using TBF.Rig.GenericDevices;
namespace TBF.Rig.Elde.RegulValveTandem
namespace TBF.Rig.Uni.RegValveTandem
{
public class ChangeRegulValvePositionOp : IOperation
{
@@ -19,7 +19,7 @@ namespace TBF.Rig.Elde.RegulValveTandem
/// Set by the constructor
readonly CBoard controlBoard;
readonly Elde.RegulValve.RegulValve regulValve;
readonly TBF.Rig.Uni.RegValve.RegValve regulValve;
readonly int regulValveNr;
readonly double timePulseSec;
@@ -38,7 +38,7 @@ namespace TBF.Rig.Elde.RegulValveTandem
if (controlBoard == null) throw new ArgumentNullException("ctrlBoard");
this.controlBoard = controlBoard;
regulValve = _regulValve as Elde.RegulValve.RegulValve;
regulValve = _regulValve as TBF.Rig.Uni.RegValve.RegValve;
if (regulValve == null) throw new ArgumentNullException("regValve is null or not Elde");
regulValveNr = this.regulValve.Idx1;
+27
View File
@@ -0,0 +1,27 @@
///
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.Rig.Generic;
namespace TBF.Rig.Uni.RegValveTandem
{
public class Factory : IComponentFactory
{
public string ClassName { get { return "RegValveTandem"; } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { RegValveTandem.ResetStaticProperties(); }
public IComponent DummyComponent() { return new RegValveTandem(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new RegValveTandem(cfg, components); }
public IComponentCfg DefaultConfig() { return new RegValveTandemCfg("RV", this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(RegValveTandemCfg.Serializer, component, this);
}
}
}
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -8,23 +8,23 @@ using TBF.Rig.ControlBoard.Legacy;
using TBF.Rig.Generic;
using TBF.Boxes;
namespace TBF.Rig.Elde.RegulValveTandem
namespace TBF.Rig.Uni.RegValveTandem
{
public class RegulValveTandem : ComponentBase, GenericDevices.IRegValve
public class RegValveTandem : ComponentBase, GenericDevices.IRegValve
{
private static readonly ILog log = LogManager.GetLogger(typeof(RegulValveTandem));
private static readonly ILog log = LogManager.GetLogger(typeof(RegValveTandem));
public override string ToString() { return string.Format("RegulValve({0})", Cfg.ToString(1)); }
public readonly RegulValveTandemCfg RegulValveTandemCfg;
public readonly RegValveTandemCfg RegulValveTandemCfg;
IDictionary<double, double> dict;
public IDictionary<double, double> Dict { get { return dict; } }
CBoard controlBoard { get { return regulValve.ControlBoard; } }
CBoard controlBoard { get { return regValve.ControlBoard; } }
public ValveCategory Category { get { return RegulValveTandemCfg.Category; } }
readonly RegulValve.RegulValve regulValve;
readonly RegulValve.RegulValve fixedRV;
readonly TBF.Rig.Uni.RegValve.RegValve regValve;
readonly TBF.Rig.Uni.RegValve.RegValve fixedRV;
readonly float fixedPctLo; /// [%]
readonly float fixedPctHi; /// [%]
@@ -35,23 +35,23 @@ namespace TBF.Rig.Elde.RegulValveTandem
public double Position
{
get { return regulValve.Position; }
get { return regValve.Position; }
}
public RegulValveTandem()
public RegValveTandem()
{
}
public RegulValveTandem(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
public RegValveTandem(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
RegulValveTandemCfg = cfg as RegulValveTandemCfg;
RegulValveTandemCfg = cfg as RegValveTandemCfg;
regulValve = (RegulValve.RegulValve)TbfComponents.FindComponent(RegulValveTandemCfg.RegulValveName, components);
if (regulValve == null) throw new Exception("Cannot find regulation valve");
regValve = TbfComponents.FindComponent(RegulValveTandemCfg.RegulValveName, components) as TBF.Rig.Uni.RegValve.RegValve;
if (regValve == null) throw new Exception("Cannot find regulation valve");
fixedRV = (RegulValve.RegulValve)TbfComponents.FindComponent(RegulValveTandemCfg.FixedRVName, components);
fixedRV = TbfComponents.FindComponent(RegulValveTandemCfg.FixedRVName, components) as TBF.Rig.Uni.RegValve.RegValve;
if (fixedRV == null) throw new Exception("Cannot find fixed RV");
fixedPctLo = Math.Max(0.0f, RegulValveTandemCfg.FixedRVPosition - 3.0f);
@@ -75,7 +75,7 @@ namespace TBF.Rig.Elde.RegulValveTandem
/// <returns>SetFlowOp instance</returns>
public IOperation SetFlowOp(GenericDevices.IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi, DoubleBox measuredFlow, int timeout)
{
return new SetFlowOp(controlBoard, regulValve, fixedRV, fixedPctLo, fixedPctHi,
return new SetFlowOp(controlBoard, regValve, fixedRV, fixedPctLo, fixedPctHi,
flowMeter, requiredFlowLo, requiredFlowHi, measuredFlow, timeout);
}
@@ -92,7 +92,7 @@ namespace TBF.Rig.Elde.RegulValveTandem
public IOperation SetFlowAndMeasureOp(GenericDevices.IFlowMeter flowMeter, double requiredFlowLo, double requiredFlowHi,
DoubleBox measuredFlow, int timeout, float filterConstant)
{
return new SetFlowOp(controlBoard, regulValve, fixedRV, fixedPctLo, fixedPctHi,
return new SetFlowOp(controlBoard, regValve, fixedRV, fixedPctLo, fixedPctHi,
flowMeter, requiredFlowLo, requiredFlowHi, measuredFlow, timeout, true);
}
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2016 Sensus Metering Systems
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -8,14 +8,14 @@ using System.Xml.Serialization;
using Config.Entities;
using TBF.Rig.Generic;
namespace TBF.Rig.Elde.RegulValveTandem
namespace TBF.Rig.Uni.RegValveTandem
{
public class RegulValveTandemCfg : ComponentCfgBase, IChildComponentCfg
public class RegValveTandemCfg : ComponentCfgBase, IChildComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(RegulValveTandemCfg) })[0];
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(RegValveTandemCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new RegulValveTandemCfgCtrl(); }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new RegValveTandemCfgCtrl(); }
///
/// Serialized parameters
@@ -28,11 +28,11 @@ namespace TBF.Rig.Elde.RegulValveTandem
public int FlowStableSec; /// 0..60 sec
/// Private parameterless constructor invoked by all other (public) constructors
RegulValveTandemCfg()
RegValveTandemCfg()
{
}
public RegulValveTandemCfg(string name, IComponentFactory factory)
public RegValveTandemCfg(string name, IComponentFactory factory)
: this()
{
Name = name;
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
@@ -7,26 +7,26 @@ using Config.Entities;
using TBF.Rig.Generic;
using TBF.UI.Bench.Components;
namespace TBF.Rig.Elde.RegulValveTandem
namespace TBF.Rig.Uni.RegValveTandem
{
public partial class RegulValveTandemCfgCtrl : UserControl, IComponentCfgCtrl
public partial class RegValveTandemCfgCtrl : UserControl, IComponentCfgCtrl
{
ComponentParametersDlg parent;
public bool ShowMore { get { return true; } }
RegulValveTandemCfg config;
RegValveTandemCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as RegulValveTandemCfg;
config = value as RegValveTandemCfg;
Redraw();
}
}
public RegulValveTandemCfgCtrl()
public RegValveTandemCfgCtrl()
{
InitializeComponent();
}
@@ -1,9 +1,9 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
namespace TBF.Rig.Elde.RegulValveTandem
namespace TBF.Rig.Uni.RegValveTandem
{
partial class RegulValveTandemCfgCtrl
partial class RegValveTandemCfgCtrl
{
/// <summary>
/// Required designer variable.
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -8,22 +8,20 @@ using TBF.Rig.ControlBoard.Legacy;
using TBF.Rig.GenericDevices;
using TBF.Boxes;
namespace TBF.Rig.Elde.RegulValveTandem
namespace TBF.Rig.Uni.RegValveTandem
{
public class SetFlowOp : IOperation
{
private static readonly ILog log = LogManager.GetLogger(typeof(SetFlowOp));
public override string ToString()
{
return string.Format("SetFlowOp({0}, Qfrom={1}, Qto={2})", regulValve.Name, finalReqFlowLo, finalReqFlowHi);
return string.Format("SetFlowOp({0}, Qfrom={1}, Qto={2})", regValve.Name, finalReqFlowLo, finalReqFlowHi);
}
/// Set by the constructor
readonly CBoard controlBoard;
readonly Elde.RegulValve.RegulValve regulValve;
readonly int regulValveNr;
readonly Elde.RegulValve.RegulValve fixedRV;
readonly int fixedRVNr;
readonly TBF.Rig.Uni.RegValve.RegValve regValve;
readonly TBF.Rig.Uni.RegValve.RegValve fixedRV;
readonly double fixedPctLo;
readonly double fixedPctHi;
readonly int flowMeterNr;
@@ -83,13 +81,11 @@ namespace TBF.Rig.Elde.RegulValveTandem
if (controlBoard == null) throw new ArgumentNullException("ctrlBoard");
this.controlBoard = controlBoard;
regulValve = regV as Elde.RegulValve.RegulValve;
if (regulValve == null) throw new ArgumentNullException("regValve is null or not Elde");
regulValveNr = regulValve.Idx1;
regValve = regV as TBF.Rig.Uni.RegValve.RegValve;
if (regValve == null) throw new ArgumentNullException("regValve is null or not Elde");
fixedRV = fxdRV as Elde.RegulValve.RegulValve;
fixedRV = fxdRV as TBF.Rig.Uni.RegValve.RegValve;
if (fixedRV == null) throw new ArgumentNullException("regValve is null or not Elde");
fixedRVNr = fixedRV.Idx1;
this.fixedPctLo = fxdPctLo;
this.fixedPctHi = fxdPctHi;
@@ -152,7 +148,7 @@ namespace TBF.Rig.Elde.RegulValveTandem
bool FetchTargetPosition(double avgReqFlow, out double positionLo, out double positionHi)
{
double targetPosition;
if (regulValve.Dict.TryGetValue(avgReqFlow, out targetPosition))
if (regValve.Dict.TryGetValue(avgReqFlow, out targetPosition))
{
positionLo = Math.Max(targetPosition * 0.95, 0.0);
positionHi = Math.Min(targetPosition * 1.05, 100.0);
@@ -168,9 +164,9 @@ namespace TBF.Rig.Elde.RegulValveTandem
void StoreTargetPosition(double avgReqFlow, double actPosition)
{
if (!regulValve.Dict.ContainsKey(reqFlowAve))
if (!regValve.Dict.ContainsKey(reqFlowAve))
{
regulValve.Dict.Add(new KeyValuePair<double, double>(avgReqFlow, actPosition));
regValve.Dict.Add(new KeyValuePair<double, double>(avgReqFlow, actPosition));
}
return;
}
@@ -197,17 +193,17 @@ namespace TBF.Rig.Elde.RegulValveTandem
flowWithinBoundsTime = 0;
if (regulValve.RegulValveCfg.StoredPositionReuse && FetchTargetPosition(reqFlowAve, out targetPositionLo, out targetPositionHi))
if (regValve.StoredPositionReuse && FetchTargetPosition(reqFlowAve, out targetPositionLo, out targetPositionHi))
{
log.InfoFormat("Start(): rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3} FETCHED: posLo={4} posHi={5}",
regulValveNr, flowMeterNr, currentReqFlowLo, currentReqFlowHi, targetPositionLo, targetPositionHi);
regValve.Idx1, flowMeterNr, currentReqFlowLo, currentReqFlowHi, targetPositionLo, targetPositionHi);
opState = OpState.IssueSetPositionCommand;
}
else
{
log.InfoFormat("Start(): rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3}",
regulValveNr, flowMeterNr, currentReqFlowLo, currentReqFlowHi);
regValve.Idx1, flowMeterNr, currentReqFlowLo, currentReqFlowHi);
opState = OpState.IssueSetPositionCommand_FixedRV;
}
@@ -227,8 +223,8 @@ namespace TBF.Rig.Elde.RegulValveTandem
/// </returns>
public Event Run()
{
float rvPosition = controlBoard.RValvePosition(regulValveNr);
float fixedRVPosition = controlBoard.RValvePosition(fixedRVNr);
float rvPosition = controlBoard.RValvePosition(regValve.Idx1);
float fixedRVPosition = controlBoard.RValvePosition(fixedRV.Idx1);
double flowMtrFreq = controlBoard.RefFrequency;
double flow = flowMtrFreq * nominalFlow / 2000.0;
@@ -240,16 +236,16 @@ namespace TBF.Rig.Elde.RegulValveTandem
}
log.InfoFormat("Run(): rv#={0} pos={1}% freq={2} flow={3} opState={4}",
regulValveNr, rvPosition.ToString("F1"), flowMtrFreq, flow, opState);
regValve.Idx1, rvPosition.ToString("F1"), flowMtrFreq, flow, opState);
if (opState == OpState.IssueSetPositionCommand)
{
///
/// Done once, issues an appropriate ValveMove(...) command
///
controlBoard.ValveMove(regulValveNr, RegulValveMode.TargetPosition,
controlBoard.ValveMove(regValve.Idx1, RegulValveMode.TargetPosition,
new double[2] { targetPositionLo, targetPositionHi },
regulValve.StableTime);
regValve.StableTime);
opState = OpState.SettingPosition;
return Event.None;
@@ -270,9 +266,9 @@ namespace TBF.Rig.Elde.RegulValveTandem
///
/// Done once, issues an appropriate ValveMove(...) command
///
controlBoard.ValveMove(fixedRVNr, RegulValveMode.TargetPosition,
controlBoard.ValveMove(fixedRV.Idx1, RegulValveMode.TargetPosition,
new double[2] { fixedPctLo, fixedPctHi },
regulValve.StableTime);
regValve.StableTime);
opState = OpState.SettingPosition_FixedRV;
return Event.None;
@@ -299,13 +295,13 @@ namespace TBF.Rig.Elde.RegulValveTandem
}
log.InfoFormat("Run(): rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3}",
regulValveNr, flowMeterNr, currentReqFlowLo, currentReqFlowHi);
regValve.Idx1, flowMeterNr, currentReqFlowLo, currentReqFlowHi);
double freqLo = 2000.0 * currentReqFlowLo / nominalFlow;
double freqHi = 2000.0 * currentReqFlowHi / nominalFlow;
controlBoard.ValveMove(regulValveNr, RegulValveMode.TargetFrequency,
controlBoard.ValveMove(regValve.Idx1, RegulValveMode.TargetFrequency,
new double[2] { freqLo, freqHi },
regulValve.StableTime);
regValve.StableTime);
opState = OpState.SettingFlow;
return Event.None;
@@ -317,24 +313,24 @@ namespace TBF.Rig.Elde.RegulValveTandem
///
if ((currentReqFlowLo <= flow) && (flow <= currentReqFlowHi))
{
if (flowWithinBoundsTime++ >= regulValve.FlowStableSec)
if (flowWithinBoundsTime++ >= regValve.FlowStableSec)
{
if (regulValve.RegulValveCfg.StoredPositionReuse)
if (regValve.StoredPositionReuse)
{
double storedPosition;
if (regulValve.Dict.TryGetValue(reqFlowAve, out storedPosition))
if (regValve.Dict.TryGetValue(reqFlowAve, out storedPosition))
{
/// update the stored valve position
StoreTargetPosition(reqFlowAve, (rvPosition + storedPosition) / 2.0f);
log.InfoFormat("Run(): rv#={0} reqFlow={1} pos={2}% stored={3} <--- Updating a stored position",
regulValveNr, reqFlowAve, rvPosition.ToString("F1"), storedPosition);
regValve.Idx1, reqFlowAve, rvPosition.ToString("F1"), storedPosition);
}
else
{
/// store the valve position
StoreTargetPosition(reqFlowAve, rvPosition);
log.InfoFormat("Run(): rv#={0} reqFlow={1} pos={2}% <--- Storing a new position",
regulValveNr, reqFlowAve, rvPosition.ToString("F1"));
regValve.Idx1, reqFlowAve, rvPosition.ToString("F1"));
}
}
opState = OpState.FlowReached;
@@ -1,26 +1,25 @@
///
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.Rig.ControlBoard.Legacy;
using TBF.Rig.GenericDevices;
using TBF.Rig.Uni;
namespace TBF.Rig.Elde.RegulValveTandem
namespace TBF.Rig.Uni.RegValveTandem
{
public class SetRegulValvePositionOp : IOperation
{
private static readonly ILog log = LogManager.GetLogger(typeof(SetRegulValvePositionOp));
public override string ToString()
{
return string.Format("SetRegulValvePositionOp({0},{1},{2})", regulValve.Name, posLoPct, posHiPct);
return string.Format("SetRegulValvePositionOp({0},{1},{2})", regValve.Name, posLoPct, posHiPct);
}
/// Set by the constructor
readonly CBoard controlBoard;
readonly Elde.RegulValve.RegulValve regulValve;
readonly int regulValveNr;
readonly TBF.Rig.ControlBoard.Uni.UniCB uniCB;
readonly RegValve.RegValve regValve;
readonly double posLoPct;
readonly double posHiPct;
readonly int timeout;
@@ -40,18 +39,16 @@ namespace TBF.Rig.Elde.RegulValveTandem
/// <param name="posHiPct">Upper limit of the position to be achieved</param>
/// <param name="timeout">Timeout in sec. for setting the flow</param>
/// <remarks>Only Elde.Valve flow are used, other flow on the lists are ignored</remarks>
public SetRegulValvePositionOp(CBoard controlBoard, IRegValve regV, float posLoPct, float posHiPct, int timeout)
public SetRegulValvePositionOp(TBF.Rig.ControlBoard.IControlBoard cb, IRegValve regV, double posLoPct, double posHiPct, int timeout)
{
if (controlBoard == null) throw new ArgumentNullException("ctrlBoard");
this.controlBoard = controlBoard;
uniCB = cb as TBF.Rig.ControlBoard.Uni.UniCB;
if (uniCB == null) throw new ArgumentNullException("ctrlBoard");
regulValve = regV as Elde.RegulValve.RegulValve;
if (regulValve == null) throw new ArgumentNullException("regValve is null or not Elde");
regulValveNr = this.regulValve.Idx1;
regValve = regV as RegValve.RegValve;
if (regValve == null) throw new ArgumentNullException("regValve is null or not Uni");
this.posLoPct = posLoPct;
this.posHiPct = posHiPct;
this.timeout = timeout;
log.Debug(this.ToString());
@@ -61,7 +58,7 @@ namespace TBF.Rig.Elde.RegulValveTandem
/// Set required water flow - no timeout.
/// Events: FlowSet
/// </summary>
public SetRegulValvePositionOp(CBoard controlBoard, RegulValveTandem regValve, float posLoPct, float posHiPct)
public SetRegulValvePositionOp(TBF.Rig.ControlBoard.IControlBoard controlBoard, RegValveTandem regValve, float posLoPct, float posHiPct)
: this(controlBoard, regValve, posLoPct, posHiPct, int.MaxValue)
{
}
@@ -72,7 +69,7 @@ namespace TBF.Rig.Elde.RegulValveTandem
firstRun = true;
positionReached = false;
expireTime = StateMachine.Time + timeout;
log.InfoFormat("Start(): RV#={0}, reqPosLo={1}%, reqPosHi={2}%", regulValveNr, posLoPct.ToString("F1"), posHiPct.ToString("F1"));
log.InfoFormat("Start(): RV#={0}, reqPosLo={1}%, reqPosHi={2}%", regValve.Idx1, posLoPct.ToString("F1"), posHiPct.ToString("F1"));
}
/// <summary>Run this operation</summary>
@@ -92,17 +89,14 @@ namespace TBF.Rig.Elde.RegulValveTandem
firstRun = false;
controlBoard.ValveMove(regulValveNr,
RegulValveMode.TargetPosition,
new double[2] { posLoPct, posHiPct },
regulValve.StableTime);
uniCB.RegVlvMoveToPos(false, regValve.Idx1, posLoPct, posHiPct);
return Event.None;
}
if (positionReached) return Event.PositionReached;
float positionPct = controlBoard.RValvePosition(regulValveNr);
log.WarnFormat("Run(): RV#={0}, actPos={1}%", regulValveNr, positionPct.ToString("F1"));
double positionPct = regValve.Position;
log.WarnFormat("Run(): RV#={0}, actPos={1}%", regValve.Idx1, positionPct.ToString("F1"));
if (posLoPct >= posHiPct || posLoPct >= 100.0f || posHiPct <= 0)
{
@@ -126,10 +120,7 @@ namespace TBF.Rig.Elde.RegulValveTandem
/// <summary>Stop this operation</summary>
public void Stop()
{
controlBoard.ValveMove(regulValveNr,
RegulValveMode.Stop,
new double[2] { posLoPct, posHiPct },
regulValve.StableTime);
uniCB.Stop(false);
}
}
}