Bug fixes in reading diverters: ReadDiverterTransitionOp, Elde.Diverter.Component, IControlCOm, IDiverter.

This commit is contained in:
Milan Hanajik
2018-06-12 17:07:15 +02:00
parent b5383a445e
commit 7c2135a8fe
7 changed files with 40 additions and 28 deletions
@@ -27,6 +27,7 @@ namespace TBF.BenchControl.Dummy.Diverter
log.Debug(this.ToString()); log.Debug(this.ToString());
} }
public int DiverterNr { get { return 0; } }
public bool State { get { return false; } } public bool State { get { return false; } }
public int ThresholdGate { get { return 50; } } public int ThresholdGate { get { return 50; } }
public int ThresholdLo { get { return 10; } } public int ThresholdLo { get { return 10; } }
+1 -1
View File
@@ -58,7 +58,7 @@ namespace TBF.BenchControl.Elde
public uint BeginState(int wmNr0) { return controlCom.BeginState(wmNr0); } public uint BeginState(int wmNr0) { return controlCom.BeginState(wmNr0); }
public double ReferenceFlow { get { return controlCom.ReferenceFlow; } } public double ReferenceFlow { get { return controlCom.ReferenceFlow; } }
public float RValvePosition(int rvNr1) { return controlCom.RValvePosition(rvNr1); } public float RValvePosition(int rvNr1) { return controlCom.RValvePosition(rvNr1); }
public float DivSamples(int ms) { return controlCom.DivSamples(ms); } public float DivSamples(int time, int divIx0) { return controlCom.DivSamples(time, divIx0); } /// Time unit is 2 ms
public int ScopeSamples(int i, int j, int k) { return controlCom.ScopeSamples(i, j, k); } public int ScopeSamples(int i, int j, int k) { return controlCom.ScopeSamples(i, j, k); }
public ulong DigitalInputs { get { return controlCom.DigitalInputs; } } public ulong DigitalInputs { get { return controlCom.DigitalInputs; } }
public float AnalogInput(int adcNr0) { return controlCom.AnalogInput(adcNr0); } public float AnalogInput(int adcNr0) { return controlCom.AnalogInput(adcNr0); }
+1 -1
View File
@@ -65,7 +65,7 @@ namespace TBF.BenchControl.Elde
public float ReferenceFlow { get { return referenceFlow; } } public float ReferenceFlow { get { return referenceFlow; } }
public float RValvePosition(int rvNr1) { return 0; } public float RValvePosition(int rvNr1) { return 0; }
public float DivSamples(int ms) { return 0; } public float DivSamples(int ms, int divIx0) { return 0; }
public int ScopeSamples(int i, int j, int k) { return 0; } public int ScopeSamples(int i, int j, int k) { return 0; }
public ulong DigitalInputs { get { return 0; } } public ulong DigitalInputs { get { return 0; } }
public float AnalogInput(int adcNr0) { return 0; } public float AnalogInput(int adcNr0) { return 0; }
+1 -1
View File
@@ -84,7 +84,7 @@ namespace TBF.BenchControl.Elde
//return ctrlBrdComponent.RValvePosition[rvNr1 - 1]; //return ctrlBrdComponent.RValvePosition[rvNr1 - 1];
return ctrlBrdComponent.Analogy[rvNr1 - 1]; /// Fixes bug: RValvePosition returns 0 all the time return ctrlBrdComponent.Analogy[rvNr1 - 1]; /// Fixes bug: RValvePosition returns 0 all the time
} }
public float DivSamples(int ms) { return ctrlBrdComponent.DIVSamples[ms, 0]; } public float DivSamples(int time, int divIx0) { return ctrlBrdComponent.DIVSamples[time, divIx0]; } /// Time unit is 2 ms
public int ScopeSamples(int i, int j, int k) { return ctrlBrdComponent.ScopeSamples[i, j, k]; } public int ScopeSamples(int i, int j, int k) { return ctrlBrdComponent.ScopeSamples[i, j, k]; }
public ulong DigitalInputs { get { return (ulong)ctrlBrdComponent.Vstupy; } } public ulong DigitalInputs { get { return (ulong)ctrlBrdComponent.Vstupy; } }
public float AnalogInput(int adcNr0) { return ctrlBrdComponent.Analogy[adcNr0]; } public float AnalogInput(int adcNr0) { return ctrlBrdComponent.Analogy[adcNr0]; }
+1 -1
View File
@@ -26,7 +26,7 @@ namespace TBF.BenchControl.Elde
uint BeginState(int wmNr0); uint BeginState(int wmNr0);
float ReferenceFlow { get; } float ReferenceFlow { get; }
float RValvePosition(int rvNr1); float RValvePosition(int rvNr1);
float DivSamples(int ms); float DivSamples(int time, int divIx0); /// time unit is 2 ms
int ScopeSamples(int i, int j, int k); int ScopeSamples(int i, int j, int k);
ulong DigitalInputs { get; } ulong DigitalInputs { get; }
float AnalogInput(int adcNr0); float AnalogInput(int adcNr0);
@@ -10,7 +10,10 @@ namespace TBF.BenchControl.Elde
public class ReadDiverterTransitionOp : IOperation public class ReadDiverterTransitionOp : IOperation
{ {
private static readonly ILog log = LogManager.GetLogger(typeof(ReadDiverterTransitionOp)); private static readonly ILog log = LogManager.GetLogger(typeof(ReadDiverterTransitionOp));
public override string ToString() { return string.Format("ReadDiverterTransitionOp()"); } public override string ToString()
{
return string.Format("ReadDiverterTransitionOp(.,{0},{1},{2},...)", div.Name, runsCountWhenSendingCmd, runsCountWhenReadingDiv);
}
const int SamplesCount = 240; /// Should be less then or equal to 256 const int SamplesCount = 240; /// Should be less then or equal to 256
float[] samples; float[] samples;
@@ -68,16 +71,16 @@ namespace TBF.BenchControl.Elde
{ {
counter = 0; counter = 0;
if (plotter == null) if (runsCountWhenSendingCmd == 0 && div.DiverterNr > 0)
{ {
if (div is TBF.BenchControl.Elde.Diverter.Diverter && runsCountWhenSendingCmd == 0) SendCommand();
{ log.DebugFormat("Start() ... Sending a command to read diverter {0}", div.Name);
SendCommand();
}
} }
else
if (plotter != null)
{ {
plotter.Start(batchNr, testName, repetition); plotter.Start(batchNr, testName, repetition);
log.DebugFormat("Start() ... plotter.Start({0}, {1}, {2})", batchNr, testName, repetition);
} }
} }
@@ -89,29 +92,31 @@ namespace TBF.BenchControl.Elde
{ {
counter++; counter++;
if (div is TBF.BenchControl.Elde.Diverter.Diverter) if (counter == runsCountWhenSendingCmd && div.DiverterNr > 0)
{ {
if (counter == runsCountWhenSendingCmd) SendCommand();
log.DebugFormat("Run() ... Sending a command to read diverter {0}", div.Name);
}
else if (counter == runsCountWhenReadingDiv && div.DiverterNr > 0)
{
if (plotter == null)
{ {
if (plotter == null) SendCommand(); ReadDiverterTransitionTimes();
log.DebugFormat("Run() ... Reading diverter {0} transition times: {1}s", div.Name, transitionTimeSec.Val);
} }
else if (counter == runsCountWhenReadingDiv) else
{ {
if (plotter == null) log.DebugFormat("Run() ... Reading diverter {0} samples", div.Name);
for (int i = 0; i < SamplesCount; i++)
{ {
ReadDiverterTransitionTimes(); float oneSample = controlBoard.DivSamples(i, div.DiverterNr - 1);
samples[i] = oneSample;
plotter.Update(oneSample);
} }
else plotter.Stop();
{
for (int i = 0; i < SamplesCount; i++)
{
float oneSample = controlBoard.DivSamples(i);
samples[i] = oneSample;
plotter.Update(oneSample);
}
CalculateDiverterTransitionTimes(); log.DebugFormat("Run() ... Calculating diverter {0} transition times: {1}s", div.Name, transitionTimeSec.Val);
} CalculateDiverterTransitionTimes();
} }
} }
@@ -121,7 +126,7 @@ namespace TBF.BenchControl.Elde
/// <summary>Stop this operation</summary> /// <summary>Stop this operation</summary>
public void Stop() public void Stop()
{ {
if (plotter != null) plotter.Stop(); log.DebugFormat("Stop()");
} }
void SendCommand() void SendCommand()
@@ -7,6 +7,12 @@ namespace TBF.BenchControl.GenericDevices
{ {
public interface IDiverter : IComponent public interface IDiverter : IComponent
{ {
/// <summary>
/// 1-based diverter number in case of Elde control board connected diverter (>= 1)
/// 0 = dummy diverter
/// </summary>
int DiverterNr { get; }
/// <summary> /// <summary>
/// Diverter state: true = to tank, false = bypass tank /// Diverter state: true = to tank, false = bypass tank
/// </summary> /// </summary>