RegValvePosition class with RV/position pair, FeedingPath RV positions used in sequences, ver. 2.30.1976
This commit is contained in:
parent
da7ac83c75
commit
0539844d85
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("2.30.1971.0")]
|
||||
[assembly: AssemblyFileVersion("2.30.1971.0")]
|
||||
[assembly: AssemblyVersion("2.30.1976.0")]
|
||||
[assembly: AssemblyFileVersion("2.30.1976.0")]
|
||||
|
||||
@ -14,8 +14,7 @@ namespace TBF.Rig
|
||||
public float Qto;
|
||||
public string Selector;
|
||||
public IValve Pump; /// pump to use with this path or null
|
||||
public IList<IRegValve> RegulValves;
|
||||
public IList<float> RegulValvesPct;
|
||||
public IList<RegValvePosition> RegVPositions;
|
||||
public IList<IValve> ValvesOpen; /// a list of valves to open or null
|
||||
public IList<IValve> ValvesClose; /// a list of valves to close or null
|
||||
|
||||
@ -24,10 +23,9 @@ namespace TBF.Rig
|
||||
{
|
||||
ItemNr = itemNr;
|
||||
Name = name;
|
||||
RegVPositions = new List<RegValvePosition>();
|
||||
ValvesOpen = new List<IValve>();
|
||||
ValvesClose = new List<IValve>();
|
||||
RegulValves = new List<IRegValve>();
|
||||
RegulValvesPct = new List<float>();
|
||||
}
|
||||
|
||||
/// Constructor from data entity
|
||||
@ -40,29 +38,22 @@ namespace TBF.Rig
|
||||
Pump = TbfComponents.FindComponent(entity.Pump, components) as IValve;
|
||||
|
||||
///
|
||||
/// Feeding regulation valve components
|
||||
/// Feeding regulation valves and their positions
|
||||
///
|
||||
RegVPositions.Clear();
|
||||
foreach (var cmpnt in components)
|
||||
{
|
||||
IRegValve regValve = cmpnt as IRegValve;
|
||||
if (regValve != null && regValve.Category == TBF.Rig.ValveCategory.Feeding)
|
||||
IRegValve rv = cmpnt as IRegValve;
|
||||
if (rv != null && rv.Category == TBF.Rig.ValveCategory.Feeding && !(rv is TBF.Rig.Elde.RegulValveTandem.RegulValveTandem))
|
||||
{
|
||||
RegulValves.Add(regValve);
|
||||
RegVPositions.Add(new RegValvePosition(rv));
|
||||
}
|
||||
}
|
||||
TBF.Utils.UpdateRegVPositionsFromStr(ref RegVPositions, entity.RegulValvesPct);
|
||||
|
||||
///
|
||||
/// Feeding regulation valve precentages
|
||||
/// Regular valves to open
|
||||
///
|
||||
string[] rvPosStr = (entity.RegulValvesPct != null) ? entity.RegulValvesPct.Split(new char[] { ';' }) : new string[0];
|
||||
for (int i = 0; i < RegulValves.Count; i++)
|
||||
{
|
||||
string str = (i < rvPosStr.Length) ? rvPosStr[i] : "---";
|
||||
float pct;
|
||||
if (!Utils.TryParseUFloat(str, out pct) || pct > 100.0f || str == "---") pct = 0;
|
||||
RegulValvesPct.Add(pct);
|
||||
}
|
||||
|
||||
string[] vOpen = entity.ValvesOpen.Split(new char[] { ';' });
|
||||
ValvesOpen = new List<IValve>();
|
||||
foreach (var vName in vOpen)
|
||||
@ -71,6 +62,9 @@ namespace TBF.Rig
|
||||
if (cmpnt is IValve) ValvesOpen.Add(cmpnt as IValve);
|
||||
}
|
||||
|
||||
///
|
||||
/// Regular valves to close
|
||||
///
|
||||
string[] vClose = entity.ValvesClose.Split(new char[] { ';' });
|
||||
ValvesClose = new List<IValve>();
|
||||
foreach (var vName in vClose)
|
||||
|
||||
@ -1,10 +1,7 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
/// Copyright (c) 2013-2015 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace TBF.Rig
|
||||
{
|
||||
|
||||
@ -27,7 +27,7 @@ namespace TBF.Rig
|
||||
public IValve StartValve3;
|
||||
public bool InvertSV3;
|
||||
public int LagSV3;
|
||||
public float[] RegulValvesPct;
|
||||
public IList<RegValvePosition> RegVPositions;
|
||||
public IList<IValve> ValvesOpen;
|
||||
public IList<IValve> ValvesClose;
|
||||
|
||||
@ -36,6 +36,7 @@ namespace TBF.Rig
|
||||
{
|
||||
ItemNr = itemNr;
|
||||
Name = name;
|
||||
RegVPositions = new List<RegValvePosition>();
|
||||
ValvesOpen = new List<IValve>();
|
||||
ValvesClose = new List<IValve>();
|
||||
}
|
||||
@ -54,13 +55,6 @@ namespace TBF.Rig
|
||||
TempDiv = TbfComponents.FindComponent(entity.TempDiv, components) as ITempMeter;
|
||||
Scale = TbfComponents.FindComponent(entity.Scale, components) as IScaleOrTank;
|
||||
|
||||
int regvCount = 0;
|
||||
foreach (var cmpnt in components)
|
||||
{
|
||||
if ((cmpnt is IRegValve) && !(cmpnt is Rig.Elde.RegulValveTandem.RegulValveTandem)) regvCount++;
|
||||
}
|
||||
RegulValvesPct = string.IsNullOrEmpty(entity.RegulValvesPct) ? new float[0] : Utils.GetRegulValvesPositions(entity.RegulValvesPct, regvCount);
|
||||
|
||||
string[] svs = entity.StartValve != null ? entity.StartValve.Split(new char[] { '~' }) : new string[0];
|
||||
int iTmp;
|
||||
///
|
||||
@ -73,6 +67,23 @@ namespace TBF.Rig
|
||||
InvertSV3 = (svs.Length > 6) ? svs[6].Equals("i") : false;
|
||||
LagSV3 = (svs.Length > 7 && int.TryParse(svs[7], out iTmp)) ? iTmp : 0;
|
||||
|
||||
///
|
||||
/// Output regulation valves and their positions
|
||||
///
|
||||
RegVPositions.Clear();
|
||||
foreach (var cmpnt in components)
|
||||
{
|
||||
IRegValve rv = cmpnt as IRegValve;
|
||||
if (rv != null && rv.Category == TBF.Rig.ValveCategory.Output && !(rv is TBF.Rig.Elde.RegulValveTandem.RegulValveTandem))
|
||||
{
|
||||
RegVPositions.Add(new RegValvePosition(rv));
|
||||
}
|
||||
}
|
||||
TBF.Utils.UpdateRegVPositionsFromStr(ref RegVPositions, entity.RegulValvesPct);
|
||||
|
||||
///
|
||||
/// Regular valves to open
|
||||
///
|
||||
string[] vOpen = entity.ValvesOpen.Split(new char[] { ';' });
|
||||
ValvesOpen = new List<IValve>();
|
||||
foreach (var vName in vOpen)
|
||||
@ -81,7 +92,10 @@ namespace TBF.Rig
|
||||
if (cmpnt is IValve) ValvesOpen.Add(cmpnt as IValve);
|
||||
}
|
||||
|
||||
string[] vClose = entity.ValvesClose.Split(new char[] { ';' });
|
||||
///
|
||||
/// Regular valves to close
|
||||
///
|
||||
string[] vClose = entity.ValvesClose.Split(new char[] { ';' });
|
||||
ValvesClose = new List<IValve>();
|
||||
foreach (var vName in vClose)
|
||||
{
|
||||
|
||||
27
TBF/Rig/RegValvePosition.cs
Normal file
27
TBF/Rig/RegValvePosition.cs
Normal file
@ -0,0 +1,27 @@
|
||||
///
|
||||
/// Copyright (c) 2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using TBF.Rig.GenericDevices;
|
||||
|
||||
namespace TBF.Rig
|
||||
{
|
||||
public class RegValvePosition
|
||||
{
|
||||
public IRegValve RegValve;
|
||||
public float Position; /// 0 .. 100.0f is position in %, <0 (default -1.0f) means no change
|
||||
|
||||
public RegValvePosition(IRegValve regValve, float position)
|
||||
{
|
||||
RegValve = regValve;
|
||||
Position = position;
|
||||
}
|
||||
|
||||
/// Constructor with reg. valve and no position change
|
||||
public RegValvePosition(IRegValve regValve)
|
||||
{
|
||||
RegValve = regValve;
|
||||
Position = -1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -38,13 +38,11 @@ namespace TBF.Rig.Sequences
|
||||
///------------------------------------------------------------
|
||||
/// Global static variables set only once.
|
||||
///------------------------------------------------------------
|
||||
public static IList<IFlowMeter> FlowMeters; /// list of reference flowmeters
|
||||
public static IList<IRegValve> RegulValves; /// list of regulation valves
|
||||
public static IList<IRegValve> FeedingRegulValves; /// list of feeding regulation valves
|
||||
public static IList<IRegValve> OutputRegulValves; /// list of output regulation valves
|
||||
public static IList<IPumpFM> PumpsWithFM; /// list of FM controlled pumps
|
||||
public static IList<IWaterMeter> WaterMeters; /// list of water meters
|
||||
public static IList<ICamera> Cameras; /// list of cameras
|
||||
public static IList<IFlowMeter> FlowMeters; /// list of reference flowmeters
|
||||
public static IList<RegValvePosition> RegVPositions; /// list of regulation valves
|
||||
public static IList<IPumpFM> PumpsWithFM; /// list of FM controlled pumps
|
||||
public static IList<IWaterMeter> WaterMeters; /// list of water meters
|
||||
public static IList<ICamera> Cameras; /// list of cameras
|
||||
|
||||
///------------------------------------------------------------
|
||||
/// Procedure related (static) variables.
|
||||
@ -494,27 +492,28 @@ namespace TBF.Rig.Sequences
|
||||
}
|
||||
|
||||
|
||||
/// return SetRegValvePositionOp operations for RV-s with changed positions
|
||||
IList<IOperation> GetRegValvePositioningOps(IList<IRegValve> regValves, float[] regValvePositions)
|
||||
/// <summary>
|
||||
/// Returns a list of reg.valve positioning operations
|
||||
/// </summary>
|
||||
/// <param name="regVPositions">List of reg.valve/position pairs, position is in %, position LT 0 ... no operation</param>
|
||||
/// <returns>List of reg.valve positioning operations</returns>
|
||||
List<IOperation> GetRegVPositioningOps(IList<RegValvePosition> regVPositions)
|
||||
{
|
||||
IList<IOperation> rvPosOps = new List<IOperation>();
|
||||
List<IOperation> rvPosOps = new List<IOperation>();
|
||||
|
||||
if (regValves != null && regValvePositions != null)
|
||||
if (regVPositions == null) return rvPosOps;
|
||||
|
||||
foreach (var rvp in regVPositions)
|
||||
{
|
||||
for (int i = 0; i < Math.Min(regValves.Count, regValvePositions.Length); i++)
|
||||
if (rvp.Position >= 0) /// Negative value means no position change
|
||||
{
|
||||
if (regValvePositions[i] >= 0) /// Negative value means no position change
|
||||
if (rvp.RegValve.IsCoax)
|
||||
{
|
||||
if (RegulValves[i].IsCoax)
|
||||
{
|
||||
rvPosOps.Add(regValves[i].SetRegulValvePositionOp(regValvePositions[i], regValvePositions[i], 60));
|
||||
}
|
||||
else
|
||||
{
|
||||
float lo = Math.Max(0, regValvePositions[i] - 3.0f);
|
||||
float hi = Math.Min(100.0f, regValvePositions[i] + 3.0f);
|
||||
rvPosOps.Add(regValves[i].SetRegulValvePositionOp(lo, hi, 60));
|
||||
}
|
||||
rvPosOps.Add(rvp.RegValve.SetRegulValvePositionOp(rvp.Position, -1, 60));
|
||||
}
|
||||
else
|
||||
{
|
||||
rvPosOps.Add(rvp.RegValve.SetRegulValvePositionOp(rvp.Position - 3.0f, rvp.Position + 3.0f, 60));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -608,7 +607,7 @@ namespace TBF.Rig.Sequences
|
||||
string activity = string.Format(message, transitionSequence.Name, step.ItemNr + 1, stepsCount);
|
||||
Bridge.OnActivity(this, activity);
|
||||
Bridge.OnMessage(this, step.Message);
|
||||
log.Info(activity + " " +step.Message);
|
||||
log.InfoFormat("{0} {1}", activity, step.Message);
|
||||
//------------------------------------------------
|
||||
|
||||
/// Prepare operation to switch valves
|
||||
@ -646,8 +645,9 @@ namespace TBF.Rig.Sequences
|
||||
}
|
||||
}
|
||||
|
||||
/// Get regulation valve positioning operations
|
||||
IList<IOperation> rvPosOps = GetRegValvePositioningOps(RegulValves, Utils.GetRegulValvesPositions(step.RegulValvesPct, RegulValves.Count));
|
||||
|
||||
Utils.UpdateRegVPositionsFromStr(ref RegVPositions, step.RegulValvesPct);
|
||||
IList<IOperation> rvPosOps = GetRegVPositioningOps(RegVPositions);
|
||||
|
||||
/// Max. one SetRegulValvePositionOp can be started or stopped in one sub-step.
|
||||
/// Therefore SetRegulValvePositionOp operations are added and removed to subsequent states one by one.
|
||||
@ -780,9 +780,11 @@ namespace TBF.Rig.Sequences
|
||||
///
|
||||
/// Always set route at the beginning of this test
|
||||
///
|
||||
List<IOperation> regVPosOps = GetRegVPositioningOps(inPath.RegVPositions);
|
||||
regVPosOps.AddRange(GetRegVPositioningOps(outPath.RegVPositions));
|
||||
Event evnt = PerformSteps(GenericDevices.ValveBase.Merge(inPath.ValvesOpen, benchPath.ValvesOpen, outPath.ValvesOpen),
|
||||
GenericDevices.ValveBase.Merge(inPath.ValvesClose, benchPath.ValvesClose, outPath.ValvesClose),
|
||||
GetRegValvePositioningOps(OutputRegulValves, outPath.RegulValvesPct),
|
||||
regVPosOps,
|
||||
"SequenceBase : Transition : TestStart - Default action");
|
||||
|
||||
if (evnt == Event.Error || evnt == Event.UiCmdStop) return evnt;
|
||||
@ -794,11 +796,15 @@ namespace TBF.Rig.Sequences
|
||||
///
|
||||
/// Set route for the next test
|
||||
///
|
||||
List<IOperation> regVPosOps = GetRegVPositioningOps(nextInPath.RegVPositions);
|
||||
regVPosOps.AddRange(GetRegVPositioningOps(nextOutPath.RegVPositions));
|
||||
Event evnt = PerformSteps(GenericDevices.ValveBase.Merge(nextInPath.ValvesOpen, nextBenchPath.ValvesOpen, nextOutPath.ValvesOpen),
|
||||
GenericDevices.ValveBase.Merge(nextInPath.ValvesClose, nextBenchPath.ValvesClose, nextOutPath.ValvesClose),
|
||||
GetRegValvePositioningOps(OutputRegulValves, outPath.RegulValvesPct),
|
||||
regVPosOps,
|
||||
"SequenceBase : AfterTestWithOverlap : Default action");
|
||||
|
||||
if (evnt == Event.Error || evnt == Event.UiCmdStop) return evnt;
|
||||
|
||||
/// Set PID coefficient, etc.
|
||||
int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
StateMachine.ControlBoard.SetFiltersPidShortPulses(filters, nextPidCoef, (nextTolerRed == 0) ? 0 : 1);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Text;
|
||||
@ -225,9 +225,7 @@ namespace TBF.Rig
|
||||
IList<IScaleOrTank> tanks = new List<IScaleOrTank>();
|
||||
ProcessData.IperlHeads = new List<TestMethods.iPerlCommunication.iPerlHead.IperlHead>();
|
||||
SequenceBase.FlowMeters = new List<IFlowMeter>();
|
||||
SequenceBase.RegulValves = new List<IRegValve>();
|
||||
SequenceBase.FeedingRegulValves = new List<IRegValve>();
|
||||
SequenceBase.OutputRegulValves = new List<IRegValve>();
|
||||
SequenceBase.RegVPositions = new List<RegValvePosition>();
|
||||
SequenceBase.PumpsWithFM = new List<IPumpFM>();
|
||||
SequenceBase.WaterMeters = new List<IWaterMeter>();
|
||||
SequenceBase.Cameras = new List<ICamera>();
|
||||
@ -259,10 +257,7 @@ namespace TBF.Rig
|
||||
if (cmpnt is IFlowMeter) SequenceBase.FlowMeters.Add(cmpnt as IFlowMeter);
|
||||
if ((cmpnt is IRegValve) && !(cmpnt is Rig.Elde.RegulValveTandem.RegulValveTandem))
|
||||
{
|
||||
IRegValve rv = cmpnt as IRegValve;
|
||||
SequenceBase.RegulValves.Add(rv);
|
||||
if (rv.Category == ValveCategory.Feeding) SequenceBase.FeedingRegulValves.Add(rv);
|
||||
if (rv.Category == ValveCategory.Output) SequenceBase.OutputRegulValves.Add(rv);
|
||||
SequenceBase.RegVPositions.Add(new RegValvePosition(cmpnt as IRegValve));
|
||||
}
|
||||
if (cmpnt is IPumpFM && !(cmpnt is Elde.PumpTandem.Pump))
|
||||
{
|
||||
|
||||
@ -1258,6 +1258,7 @@
|
||||
<Compile Include="Rig\RegisterReaders\SerialStream\FrameReceivedEventArgs.cs" />
|
||||
<Compile Include="Rig\RegisterReaders\SerialStream\DatastreamFrame.cs" />
|
||||
<Compile Include="Rig\RegisterReaders\SerialStream\ProcParams.cs" />
|
||||
<Compile Include="Rig\RegValvePosition.cs" />
|
||||
<Compile Include="Rig\Sequences\DeferredTestEvaluationData.cs" />
|
||||
<Compile Include="Rig\Sequences\MainSeqUtils.cs" />
|
||||
<Compile Include="Rig\Sequences\Plotter.cs" />
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2017 Sensus Metering Systems
|
||||
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Windows.Forms;
|
||||
using NHibernate;
|
||||
using log4net;
|
||||
using Config.Entities;
|
||||
using Common;
|
||||
using Common.Forms;
|
||||
using Config.Entities;
|
||||
using TBF.Rig;
|
||||
using TBF.Rig.GenericDevices;
|
||||
using TBF.Resources;
|
||||
@ -34,8 +34,8 @@ namespace TBF.UI.Bench.Paths
|
||||
|
||||
public IList<Rig.Generic.IComponent> TbfComponents;
|
||||
public IList<IValve> Valves;
|
||||
public IList<IRegValve> FeedingRegulValves;
|
||||
public IList<IRegValve> OutputRegulValves;
|
||||
public IList<IRegValve> FeedingRegValves;
|
||||
public IList<IRegValve> OutputRegValves;
|
||||
public ISession Session; /// One common DB session passed also to the controls inside tab pages
|
||||
public IList<Procedure> Procedures;
|
||||
public IList<Test> Tests;
|
||||
@ -54,7 +54,7 @@ namespace TBF.UI.Bench.Paths
|
||||
|
||||
/// SharedDlgButtons configuration
|
||||
sharedButtons.ParentForm = this;
|
||||
sharedButtons.RequiredGroupMembership = new Common.GID[] { Common.GID.Metrologists };
|
||||
sharedButtons.RequiredGroupMembership = new GID[] { GID.Metrologists };
|
||||
sharedButtons.OptionalButtons = SharedButtons.Buttons.Add | SharedButtons.Buttons.Remove |
|
||||
SharedButtons.Buttons.Up | SharedButtons.Buttons.Down;
|
||||
sharedButtons.Unlocked += Unlocked;
|
||||
@ -80,27 +80,26 @@ namespace TBF.UI.Bench.Paths
|
||||
Valves = Rig.GenericDevices.ValveBase.MasterValves(TbfComponents);
|
||||
|
||||
/// Find all feeding regulation valves
|
||||
FeedingRegulValves = new List<IRegValve>();
|
||||
OutputRegulValves = new List<IRegValve>();
|
||||
FeedingRegValves = new List<IRegValve>();
|
||||
OutputRegValves = new List<IRegValve>();
|
||||
foreach (var cmpnt in TbfComponents)
|
||||
{
|
||||
IRegValve regValve = cmpnt as IRegValve;
|
||||
if (regValve != null && !(cmpnt is TBF.Rig.Elde.RegulValveTandem.RegulValveTandem))
|
||||
if (cmpnt is IRegValve && !(cmpnt is TBF.Rig.Elde.RegulValveTandem.RegulValveTandem))
|
||||
{
|
||||
switch (regValve.Category)
|
||||
switch ((cmpnt as IRegValve).Category)
|
||||
{
|
||||
case ValveCategory.Feeding:
|
||||
FeedingRegulValves.Add(regValve);
|
||||
FeedingRegValves.Add(cmpnt as IRegValve);
|
||||
break;
|
||||
case ValveCategory.Output:
|
||||
OutputRegulValves.Add(regValve);
|
||||
OutputRegValves.Add(cmpnt as IRegValve);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Create the database session for paths
|
||||
Session = TBF.DB.CreateSession(Common.DBKind.Config);
|
||||
Session = TBF.DB.CreateSession(DBKind.Config);
|
||||
|
||||
Procedures = Session.QueryOver<Procedure>().List();
|
||||
Tests = Session.QueryOver<Test>().List();
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
using Common;
|
||||
@ -77,18 +76,18 @@ namespace TBF.UI.Bench.Paths
|
||||
Columns.Add(Strings.Pump, (ls.FeedingColumnCount > 5) ? ls.FeedingColumnWidths[5] : 60 * parent.Dpi / Constants.Dpi100pct);
|
||||
int clmn = (int)Column.FixedColumnsCount;
|
||||
|
||||
foreach (var rv in parent.FeedingRegulValves)
|
||||
foreach (var rv in parent.FeedingRegValves)
|
||||
{
|
||||
Columns.Add(rv.Cfg.Name, (ls.FeedingColumnCount > clmn) ? ls.FeedingColumnWidths[clmn] : 50 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(string.Format("{0} [%]", rv.Name), (ls.FeedingColumnCount > clmn) ? ls.FeedingColumnWidths[clmn] : 50 * parent.Dpi / Constants.Dpi100pct);
|
||||
clmn++;
|
||||
}
|
||||
regvCount = clmn - (int)Column.FixedColumnsCount;
|
||||
regvCount = parent.FeedingRegValves.Count;
|
||||
|
||||
foreach (var vlv in parent.Valves)
|
||||
{
|
||||
if (vlv.Category == TBF.Rig.ValveCategory.Feeding)
|
||||
{
|
||||
Columns.Add(vlv.Cfg.Name, (ls.FeedingColumnCount > clmn) ? ls.FeedingColumnWidths[clmn] : 50 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(vlv.Name, (ls.FeedingColumnCount > clmn) ? ls.FeedingColumnWidths[clmn] : 50 * parent.Dpi / Constants.Dpi100pct);
|
||||
clmn++;
|
||||
}
|
||||
}
|
||||
@ -106,7 +105,7 @@ namespace TBF.UI.Bench.Paths
|
||||
if (cmpnt is IPump) pumpCBox.Items.Add(cmpnt.Cfg.Name);
|
||||
}
|
||||
|
||||
editors = new Control[fixedColumnsCount + regvCount + 64];
|
||||
editors = new Control[fixedColumnsCount + regvCount + valvesCount];
|
||||
///
|
||||
editors[(int)Column.Name] = new TextBox(); /// Name
|
||||
editors[(int)Column.Qfrom] = new TextBox(); /// Q_from
|
||||
@ -126,8 +125,8 @@ namespace TBF.UI.Bench.Paths
|
||||
editors[fixedColumnsCount + i] = cb;
|
||||
}
|
||||
|
||||
/// Prepare valve combo-boxes (max. 64 valves)
|
||||
for (int i = 0; i < 64; i++)
|
||||
/// Prepare valve combo-boxes
|
||||
for (int i = 0; i < valvesCount; i++)
|
||||
{
|
||||
ComboBox cb = new ComboBox();
|
||||
cb.Items.Add("---");
|
||||
@ -323,18 +322,18 @@ namespace TBF.UI.Bench.Paths
|
||||
///
|
||||
/// Regulation valves
|
||||
///
|
||||
string regulValvesPct = string.Empty;
|
||||
string regulVPositions = string.Empty;
|
||||
for (int i = fixedColumnsCount; i < fixedColumnsCount + regvCount; i++)
|
||||
{
|
||||
if (regulValvesPct.Length > 0) regulValvesPct += ";";
|
||||
if (regulVPositions.Length > 0) regulVPositions += ";";
|
||||
float fdummy;
|
||||
if (lvi.SubItems[i].Text.Equals("---") ||
|
||||
(Utils.TryParseUFloat(lvi.SubItems[i].Text, out fdummy) && (fdummy >= 0) && (fdummy <= 100.0f)))
|
||||
{
|
||||
regulValvesPct += lvi.SubItems[i].Text;
|
||||
regulVPositions += lvi.SubItems[i].Text;
|
||||
}
|
||||
}
|
||||
entity.RegulValvesPct = regulValvesPct;
|
||||
entity.RegulValvesPct = regulVPositions;
|
||||
|
||||
///
|
||||
/// Valves
|
||||
|
||||
@ -112,14 +112,14 @@ namespace TBF.UI.Bench.Paths
|
||||
{
|
||||
if (vlv.Category == ValveCategory.Output)
|
||||
{
|
||||
Columns.Add(vlv.Cfg.Name, (ls.OutputColumnCount > clmn) ? ls.OutputColumnWidths[clmn] : 50 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(vlv.Name, (ls.OutputColumnCount > clmn) ? ls.OutputColumnWidths[clmn] : 50 * parent.Dpi / Constants.Dpi100pct);
|
||||
clmn++;
|
||||
valvescount++;
|
||||
}
|
||||
}
|
||||
foreach (var rvlv in parent.OutputRegulValves)
|
||||
foreach (var rv in parent.OutputRegValves)
|
||||
{
|
||||
Columns.Add(rvlv.Cfg.Name + " [%]", (ls.OutputColumnCount > clmn) ? ls.OutputColumnWidths[clmn] : 55 * parent.Dpi / Constants.Dpi100pct);
|
||||
Columns.Add(string.Format("{0} [%]", rv.Name), (ls.OutputColumnCount > clmn) ? ls.OutputColumnWidths[clmn] : 55 * parent.Dpi / Constants.Dpi100pct);
|
||||
clmn++;
|
||||
regulValvesCount++;
|
||||
}
|
||||
@ -384,12 +384,12 @@ namespace TBF.UI.Bench.Paths
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < parent.OutputRegulValves.Count; i++ )
|
||||
foreach (var rvp in path.RegVPositions)
|
||||
{
|
||||
int subItemNr = lvi.SubItems.Count;
|
||||
if (i < path.RegulValvesPct.Length && 0 <= path.RegulValvesPct[i] && path.RegulValvesPct[i] <= 100)
|
||||
if (0 <= rvp.Position && rvp.Position <= 100)
|
||||
{
|
||||
float rvPos = path.RegulValvesPct[i];
|
||||
float rvPos = rvp.Position;
|
||||
lvi.SubItems.Add(rvPos.ToString());
|
||||
lvi.SubItems[subItemNr].BackColor = (rvPos == 0) ? Color.White : Color.LightGray;
|
||||
}
|
||||
|
||||
29
TBF/Utils.cs
29
TBF/Utils.cs
@ -1,12 +1,11 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO.Ports;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Config.Entities;
|
||||
using Dirichlet.Numerics;
|
||||
|
||||
@ -190,37 +189,33 @@ namespace TBF
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get an array of RegulValve positions from a string
|
||||
/// Update a list of regulation valve position pairs from a string
|
||||
/// </summary>
|
||||
/// <param name="entity">String from TransitionStep entity defining all RegulValve positions</param>
|
||||
/// <returns>float[] of regulation valve positions from 0 to 100.0f</returns>
|
||||
public static float[] GetRegulValvesPositions(string regulValvesPct, int regvCount)
|
||||
/// <param name="regVPositionsStr">String with reg.valve positions in % separated by ';'</param>
|
||||
/// <param name="regVPositions">List with reg. valve / position pairs</param>
|
||||
public static void UpdateRegVPositionsFromStr(ref IList<Rig.RegValvePosition> regVPositions, string regVPositionsStr)
|
||||
{
|
||||
float[] result = new float[regvCount];
|
||||
string[] rvPosStr = string.IsNullOrEmpty(regVPositionsStr) ? new string[0] : regVPositionsStr.Split(new char[] { ';' });
|
||||
|
||||
string[] rvPosStr = string.IsNullOrEmpty(regulValvesPct) ? new string[0] : regulValvesPct.Split(new char[] { ';' });
|
||||
for (int i = 0; i < regvCount; i++)
|
||||
for (int i = 0; i < Math.Min(rvPosStr.Length, regVPositions.Count); i++)
|
||||
{
|
||||
float fdummy;
|
||||
if ((i < rvPosStr.Length) && Utils.TryParseUFloat(rvPosStr[i], out fdummy) &&
|
||||
(fdummy >= 0) && (fdummy <= 100.0f))
|
||||
if (Utils.TryParseUFloat(rvPosStr[i], out fdummy) && fdummy >= 0 && fdummy <= 100.0f)
|
||||
{
|
||||
result[i] = fdummy;
|
||||
regVPositions[i].Position = fdummy;
|
||||
}
|
||||
else // if ((i < rvPosStr.Length) && rvPosStr[i].Equals("---"))
|
||||
else //if (rvPosStr[i].Equals("---"))
|
||||
{
|
||||
result[i] = -1.0f; /// Negative value means no regulation valve position change
|
||||
regVPositions[i].Position = -1.0f; /// Negative value means no regulation valve position change
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get an array of Pump-With-FM power percentages from a string
|
||||
/// </summary>
|
||||
/// <param name="entity">String from TransitionStep entity defining all FM pump powers</param>
|
||||
/// <param name="pumpWithFMPcts">String from TransitionStep entity defining all FM pump powers</param>
|
||||
/// <returns>float[] of FM-pump power percentages from 0 to 100.0f</returns>
|
||||
public static float[] GetPumpWithFMPcts(string pumpWithFMPcts)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user