(1) DIverter threshold used, (2) UniCB state display can be enabled / disabled, ver. 3.1.1598
This commit is contained in:
@@ -411,7 +411,7 @@ namespace TBF.Rig.ControlBoard.Legacy
|
||||
DiverterEdge = new uint[divertersCount];
|
||||
for (int i = 0; i < divertersCount; i++)
|
||||
{
|
||||
DiverterEdge[i] = (uint)Rig.Uni.Diverter.Diverter.Diverters[i].ThresholdGate;
|
||||
DiverterEdge[i] = (uint)Rig.Uni.Diverter.Diverter.Diverters[i].StartThreshold;
|
||||
controlCom.SetDivLimit(i, (uint)Rig.Uni.Diverter.Diverter.Diverters[i].ThresholdLo,
|
||||
(uint)Rig.Uni.Diverter.Diverter.Diverters[i].ThresholdHi);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
log.InfoFormat("Op.Start() RV#={0} Et#={1} Qfrom={2} Qto={3}", regV.Idx1, flowMeter.Idx1, qFrom, qTo);
|
||||
|
||||
/// Start the test (and the flow measurement)
|
||||
uniCB.StartTest(false, flowMeter.Idx1, 0, 40, true, false, false, false, pulsesCount, 0);
|
||||
uniCB.StartTest(false, flowMeter.Idx1, 0, 0, true, false, false, false, pulsesCount, 0);
|
||||
|
||||
opState = OpState.StartingTest;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
log.InfoFormat("Op.Start() RV#={0} Et#={1} Div#={2} Qfrom={3} Qto={4}", regV.Idx1, flowMeter.Idx1, div.DiverterNr, qFrom, qTo);
|
||||
|
||||
/// Start the test (and the flow measurement)
|
||||
uniCB.StartTest(false, flowMeter.Idx1, div.DiverterNr, 40, true, true, false, isProlongedTest, pulsesCount, massPulsesCount);
|
||||
uniCB.StartTest(false, flowMeter.Idx1, div.DiverterNr, div.StartThreshold, true, true, false, isProlongedTest, pulsesCount, massPulsesCount);
|
||||
|
||||
opState = OpState.StartingTest;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
message[35] = (byte)Math.Max(1, Math.Min(255, action.PID)); /// PIDRV
|
||||
message[36] = 0; // (byte)Math.Max(4, Math.Min(255, action.TolerRV)); /// TolerRV (4..20 mA reg.valve only)
|
||||
message[37] = (byte)Math.Max(0, Math.Min(255, action.StabTime)); /// StabRV
|
||||
message[38] = 0x1A; // (byte)((action.DivThreshold >> 2) & 0xFF); /// HranAK
|
||||
message[38] = (byte)((action.DivThreshold >> 2) & 0xFF);
|
||||
|
||||
message[39] = 0;
|
||||
message[40] = 0;
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
log.InfoFormat("Op.Start() RV#={0} Et#={1} Qfrom={2} Qto={3}", regV.Idx1, flowMeter.Idx1, qFrom, qTo);
|
||||
|
||||
/// Start the test (and the flow measurement)
|
||||
uniCB.StartTest(false, flowMeter.Idx1, 0, 40, false, false, true, false, pulsesCount, 0);
|
||||
uniCB.StartTest(false, flowMeter.Idx1, 0, 0, false, false, true, false, pulsesCount, 0);
|
||||
|
||||
opState = OpState.StartingTest;
|
||||
}
|
||||
|
||||
@@ -37,16 +37,20 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
public string AltString
|
||||
{
|
||||
get {
|
||||
altString.Clear();
|
||||
altString.AppendFormat("State: {0}.{1}.{2}.{3}\n", (State >> 48) & 0xFF, (State >> 40) & 0xFF, (State >> 32) & 0xFF, Convert.ToUInt32(State & 0xFFFFFFFF).ToString("X6"));
|
||||
altString.AppendFormat("DI: {0}\n", ToBin40(DigitalInputs));
|
||||
altString.AppendFormat("DO: {0}\n", ToBin40(((UInt64)Route) >> 8));
|
||||
altString.AppendFormat("AI0: {0:D3} AI1: {1:D3} AI2: {2:D3} AI3: {3:D3} AI4: {4:D3} AI5: {5:D3}\n",
|
||||
AnalogInput(0), AnalogInput(1), AnalogInput(2), AnalogInput(3), AnalogInput(4), AnalogInput(5));
|
||||
altString.AppendFormat("AI8: {0:D3} AI9: {1:D3} AI10: {2:D3} AI11: {3:D3}\n",
|
||||
AnalogInput(8), AnalogInput(9), AnalogInput(10), AnalogInput(11));
|
||||
altString.AppendFormat("Frequency: {0:F1} Hz Pulses: {1}", RefFrequency, RefPulses);
|
||||
return altString.ToString();
|
||||
if (cbCfg != null && cbCfg.ShowState)
|
||||
{
|
||||
altString.Clear();
|
||||
altString.AppendFormat("State: {0}.{1}.{2}.{3}\n", (State >> 48) & 0xFF, (State >> 40) & 0xFF, (State >> 32) & 0xFF, Convert.ToUInt32(State & 0xFFFFFFFF).ToString("X6"));
|
||||
altString.AppendFormat("DI: {0}\n", ToBin40(DigitalInputs));
|
||||
altString.AppendFormat("DO: {0}\n", ToBin40(((UInt64)Route) >> 8));
|
||||
altString.AppendFormat("AI0: {0:D3} AI1: {1:D3} AI2: {2:D3} AI3: {3:D3} AI4: {4:D3} AI5: {5:D3}\n",
|
||||
AnalogInput(0), AnalogInput(1), AnalogInput(2), AnalogInput(3), AnalogInput(4), AnalogInput(5));
|
||||
altString.AppendFormat("AI8: {0:D3} AI9: {1:D3} AI10: {2:D3} AI11: {3:D3}\n",
|
||||
AnalogInput(8), AnalogInput(9), AnalogInput(10), AnalogInput(11));
|
||||
altString.AppendFormat("Frequency: {0:F1} Hz Pulses: {1}", RefFrequency, RefPulses);
|
||||
return altString.ToString();
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
public bool RelaysFInstalled;
|
||||
public bool RelaysGInstalled;
|
||||
public bool RelaysHInstalled;
|
||||
public bool ShowState;
|
||||
|
||||
/// Schematic drawing info
|
||||
public Shape Shape { get; set; }
|
||||
@@ -88,6 +89,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
RelaysFInstalled = true;
|
||||
RelaysGInstalled = true;
|
||||
RelaysHInstalled = true;
|
||||
ShowState = false;
|
||||
}
|
||||
|
||||
string[] paramNames = new string[]
|
||||
@@ -99,6 +101,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
"Relays F are installed",
|
||||
"Relays G are installed",
|
||||
"Relays H are installed",
|
||||
"Show state",
|
||||
};
|
||||
public string ParamName(int i) { return paramNames[i]; }
|
||||
public int ParamsCount() { return paramNames.Length; }
|
||||
@@ -116,6 +119,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
return new string[] { Strings.yes, Strings.no };
|
||||
default:
|
||||
return null;
|
||||
@@ -139,6 +143,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
case 4: return RelaysFInstalled ? Strings.yes : Strings.no;
|
||||
case 5: return RelaysGInstalled ? Strings.yes : Strings.no;
|
||||
case 6: return RelaysHInstalled ? Strings.yes : Strings.no;
|
||||
case 7: return ShowState ? Strings.yes : Strings.no;
|
||||
default: return string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -154,6 +159,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
case 4: RelaysFInstalled = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd;
|
||||
case 5: RelaysGInstalled = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd;
|
||||
case 6: RelaysHInstalled = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd;
|
||||
case 7: ShowState = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd;
|
||||
default: return CfgUpdateFlags.None;
|
||||
}
|
||||
}
|
||||
@@ -180,6 +186,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
if (ParamValues(i).Contains(str)) return true;
|
||||
break;
|
||||
default:
|
||||
@@ -200,6 +207,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
prms.RelaysFInstalled = RelaysFInstalled;
|
||||
prms.RelaysGInstalled = RelaysGInstalled;
|
||||
prms.RelaysHInstalled = RelaysHInstalled;
|
||||
prms.ShowState = ShowState;
|
||||
}
|
||||
|
||||
public Config.Entities.IParamsProvider Clone()
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace TBF.Rig.Dummy.Diverter
|
||||
|
||||
public int DiverterNr { get { return 0; } }
|
||||
public bool State { get { return false; } }
|
||||
public int ThresholdGate { get { return 50; } }
|
||||
public int StartThreshold { get { return 50; } }
|
||||
public int ThresholdLo { get { return 10; } }
|
||||
public int ThresholdHi { get { return 90; } }
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace TBF.Rig.GenericDevices
|
||||
/// <summary>
|
||||
/// Threshold for the ADC value to start the test in %, 0..100
|
||||
/// </summary>
|
||||
int ThresholdGate { get; }
|
||||
int StartThreshold { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Threshold for low level when diverter transition time is measured in %, 0..100
|
||||
|
||||
@@ -29,23 +29,33 @@ namespace TBF.Rig.Uni.Diverter
|
||||
public static int DivertersCount { get { return nextIdx; } }
|
||||
public static GenericDevices.IDiverter[] Diverters;
|
||||
|
||||
readonly DiverterCfg diverterCfg;
|
||||
public SchematicDrawing.IDrawingItem DrawingItem { get { return diverterCfg as SchematicDrawing.IDrawingItem; } }
|
||||
readonly DiverterCfg divCfg;
|
||||
public SchematicDrawing.IDrawingItem DrawingItem { get { return divCfg as SchematicDrawing.IDrawingItem; } }
|
||||
|
||||
readonly UniCB cBoard;
|
||||
readonly UInt128 mask; /// derived from bitPosition in the constructor
|
||||
|
||||
public int DiverterNr { get { return diverterCfg.DivNr1; } } /// 1-based public diverter number
|
||||
public int AdcNr { get { return diverterCfg.AdcNr; } }
|
||||
public int DiverterNr { get { return divCfg.DivNr1; } } /// 1-based public diverter number
|
||||
public int AdcNr { get { return divCfg.AdcNr; } }
|
||||
|
||||
readonly IOperation diverterToTankOp;
|
||||
readonly IOperation diverterToSinkOp;
|
||||
|
||||
|
||||
public bool State { get { return (cBoard.Route & mask) != 0; } }
|
||||
public int ThresholdGate { get { return diverterCfg.StartThresholdPct; } }
|
||||
public int ThresholdLo { get { return diverterCfg.ThresholdLoPct; } }
|
||||
public int ThresholdHi { get { return diverterCfg.ThresholdHiPct; } }
|
||||
|
||||
public int StartThreshold
|
||||
{
|
||||
get { return Math.Max(0, Math.Min(1023, Convert.ToInt32(divCfg.AdcValueToSink + (divCfg.AdcValueToTank - divCfg.AdcValueToSink) * (divCfg.StartThresholdPct / 100.0)))); }
|
||||
}
|
||||
public int ThresholdLo
|
||||
{
|
||||
get { return Math.Max(0, Math.Min(1023, Convert.ToInt32(divCfg.AdcValueToSink + (divCfg.AdcValueToTank - divCfg.AdcValueToSink) * (divCfg.ThresholdLoPct / 100.0)))); }
|
||||
}
|
||||
public int ThresholdHi
|
||||
{
|
||||
get { return Math.Max(0, Math.Min(1023, Convert.ToInt32(divCfg.AdcValueToSink + (divCfg.AdcValueToTank - divCfg.AdcValueToSink) * (divCfg.ThresholdHiPct / 100.0)))); }
|
||||
}
|
||||
|
||||
FloatBox switchTimeStart;
|
||||
FloatBox switchTimeEnd;
|
||||
@@ -68,18 +78,18 @@ namespace TBF.Rig.Uni.Diverter
|
||||
public Diverter(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
|
||||
: base(cfg)
|
||||
{
|
||||
diverterCfg = cfg as DiverterCfg;
|
||||
divCfg = cfg as DiverterCfg;
|
||||
|
||||
cBoard = TbfComponents.FindComponent(cfg.ParentName, components) as UniCB;
|
||||
if (cBoard == 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);
|
||||
if (divCfg.BitNr < 0 || divCfg.BitNr >= 64) throw new ArgumentOutOfRangeException("position");
|
||||
this.mask = (((UInt128)1) << divCfg.BitNr);
|
||||
|
||||
switchTimeStart = new FloatBox(diverterCfg.DfltSwithTimeStartMs / 1000.0f);
|
||||
switchTimeEnd = new FloatBox(diverterCfg.DfltSwithTimeEndMs / 1000.0f);
|
||||
switchTimeStart = new FloatBox(divCfg.DfltSwithTimeStartMs / 1000.0f);
|
||||
switchTimeEnd = new FloatBox(divCfg.DfltSwithTimeEndMs / 1000.0f);
|
||||
|
||||
///// Prepare arguments of SendCalibData()
|
||||
//if (diverterCfg.AdcNr >= 0 && diverterCfg.AdcNr < cBoard.RegValveCalib.GetLength(0))
|
||||
@@ -105,7 +115,7 @@ namespace TBF.Rig.Uni.Diverter
|
||||
///
|
||||
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
|
||||
{
|
||||
DateTime calibrationDue = diverterCfg.CalibValidDate;
|
||||
DateTime calibrationDue = divCfg.CalibValidDate;
|
||||
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
|
||||
|
||||
if (calibrationDue > TBF.UI.Constants.MinDate)
|
||||
@@ -141,8 +151,8 @@ namespace TBF.Rig.Uni.Diverter
|
||||
public void Initialize() { }
|
||||
public void RunDeviceBefore()
|
||||
{
|
||||
Int16 adcValue = cBoard.Data.AnalogInput[diverterCfg.AdcNr];
|
||||
Handlers.OnAdcChanged(this, new CmdResponseArgs(CfgChangeCmd.GetAdc, diverterCfg.BitNr, adcValue));
|
||||
Int16 adcValue = cBoard.Data.AnalogInput[divCfg.AdcNr];
|
||||
Handlers.OnAdcChanged(this, new CmdResponseArgs(CfgChangeCmd.GetAdc, divCfg.BitNr, adcValue));
|
||||
}
|
||||
public void RunDeviceAfter() { }
|
||||
public void StopDevice() { }
|
||||
@@ -191,20 +201,20 @@ namespace TBF.Rig.Uni.Diverter
|
||||
}
|
||||
else if (args.Command == CfgChangeCmd.GetAdc1 || args.Command == CfgChangeCmd.GetAdc2)
|
||||
{
|
||||
Int16 adcValue = cBoard.Data.AnalogInput[diverterCfg.AdcNr];
|
||||
DiverterCfgCtrl.OnCmdResponse(this, new CmdResponseArgs(args.Command, diverterCfg.BitNr, adcValue));
|
||||
Int16 adcValue = cBoard.Data.AnalogInput[divCfg.AdcNr];
|
||||
DiverterCfgCtrl.OnCmdResponse(this, new CmdResponseArgs(args.Command, divCfg.BitNr, adcValue));
|
||||
}
|
||||
else if (args.Command == CfgChangeCmd.DivToTank)
|
||||
{
|
||||
cBoard.SwitchDiverter(true, diverterCfg.DivNr1, true);
|
||||
cBoard.SwitchDiverter(true, divCfg.DivNr1, true);
|
||||
}
|
||||
else if (args.Command == CfgChangeCmd.DivToSink)
|
||||
{
|
||||
cBoard.SwitchDiverter(true, diverterCfg.DivNr1, false);
|
||||
cBoard.SwitchDiverter(true, divCfg.DivNr1, false);
|
||||
}
|
||||
else if (args.Command == CfgChangeCmd.ReadDivTransition)
|
||||
{
|
||||
cBoard.ReadDiverterTransition(true, diverterCfg.DivNr1);
|
||||
cBoard.ReadDiverterTransition(true, divCfg.DivNr1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user