Merge branch 'main' of https://slm.sms-esaap.com/la_operations/laa_production
This commit is contained in:
@@ -56,12 +56,6 @@ namespace XYLEM
|
||||
/// <param name="baudRate">Like 9600 (default on RS485)</param>
|
||||
/// <param name="parity">Like Parity.Even (default on RS485)</param>
|
||||
/// <returns></returns>
|
||||
Boolean Connect(string comport, UInt16 id, UInt32 baudRate, Parity parity);
|
||||
|
||||
/// <summary>
|
||||
/// Close communication connection to Meter
|
||||
/// </summary>
|
||||
/// <returns>true on okay or false on error</returns>
|
||||
Boolean CloseConnection();
|
||||
Boolean Connect(string comport, UInt16 id, UInt32 baudRate, Parity parity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
using System.IO.Ports;
|
||||
using System;
|
||||
using System.IO.Ports;
|
||||
using XYLEM.Device;
|
||||
|
||||
namespace XYLEM
|
||||
{
|
||||
public interface IMagFluxAPI
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Make communication connection to Meter
|
||||
///
|
||||
@@ -36,5 +36,12 @@ namespace XYLEM
|
||||
/// <returns>Return a MagFlux device or "null" if failing connect</returns>
|
||||
/// <exception cref="InvalidDataException"> if the configuration is not valid</exception>
|
||||
IMagFluxRequestProtocol Connect(string comport, ushort id, uint baudRate, Parity parity, string log_path = null, RUN_TYPE runAs = RUN_TYPE.Normal);
|
||||
|
||||
/// <summary>
|
||||
/// Close communication connection to all Meters and clean up for a fresh connection of all devices.
|
||||
/// Note to continue, all devices needs initialized to be reconnected with Connect(...)
|
||||
/// </summary>
|
||||
/// <returns>true on okay or false on error</returns>
|
||||
Boolean CloseConnections();
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,20 @@ namespace XYLEM
|
||||
/// <returns>true if yes</returns>
|
||||
Boolean IsConnected();
|
||||
|
||||
/// <summary>
|
||||
/// Close communication connection to Meter
|
||||
/// </summary>
|
||||
/// <returns>true on okay or false on error</returns>
|
||||
Boolean CloseConnection();
|
||||
|
||||
/// <summary>
|
||||
/// Try reconnect communication to a Meter that already had a communication connection
|
||||
/// Note: will reuse already used communication settings and CloseConnection() is not already closed before call.
|
||||
/// Used for reestablished communication to Meter when fail to respond during normal operation
|
||||
/// </summary>
|
||||
/// <returns>true on okay or false on error</returns>
|
||||
Boolean Reconnect();
|
||||
|
||||
/// <summary>
|
||||
/// Get current device Modbus ID / Device Address
|
||||
/// </summary>
|
||||
@@ -147,6 +161,22 @@ namespace XYLEM
|
||||
/// <returns>true on okay or false on error</returns>
|
||||
Boolean GetFlowRate_lps(out Single value_out);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Average Electrode measurement used for Device calibration verification
|
||||
/// </summary>
|
||||
/// <param name="value_out"> Average Electrode [mV] </param>
|
||||
/// <returns>true on okay or false on error</returns>
|
||||
Boolean GetAverage_Electrode_mV(out Single value_out);
|
||||
|
||||
/// <summary>
|
||||
/// Standard deviation electrode measurement used for Device calibration verification
|
||||
/// Note: update will only happen after x seconds, depending on filter config in device
|
||||
/// </summary>
|
||||
/// <param name="value_out"> Average Electrode [mV] </param>
|
||||
/// <returns>true on okay or false on error</returns>
|
||||
Boolean GetStdDev_Electrode_mV(out Single value_out);
|
||||
|
||||
/// <summary>
|
||||
/// !!! Warning make sure to turn off simulation, when calibration off sensor is done !!!
|
||||
/// ----
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -89,20 +89,21 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore.Consts
|
||||
public static String GetStateInfosOfStateMask(UInt32 stateMask)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("Device State:\n");
|
||||
sb.Append($"Device State: 0x{stateMask:X4}");
|
||||
|
||||
// if state is okay return immediately
|
||||
if (stateMask == (UInt32)State.Okay)
|
||||
{
|
||||
sb.Append(GetStateInfoOfState(State.Okay)).Append("\n");
|
||||
sb.Append(GetStateInfoOfState(State.Okay));
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
sb.Append(" => ");
|
||||
// loop all states set in state mask
|
||||
foreach (var state in _stateContainer.Where(state => state.State != State.Okay).Where(state =>
|
||||
((UInt32)state.State & stateMask) == (UInt32)state.State))
|
||||
{
|
||||
sb.Append(state.Info).Append("\n");
|
||||
sb.Append(state.Info).Append(" | ");
|
||||
}
|
||||
return sb.ToString();
|
||||
|
||||
|
||||
@@ -37,6 +37,14 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
{
|
||||
#region Variables and Properties
|
||||
|
||||
/// <summary>
|
||||
/// Ident of request protocol
|
||||
/// </summary>
|
||||
private String RequestIdent
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// Reminder for status bits
|
||||
/// </summary>
|
||||
@@ -51,6 +59,22 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
/// </summary>
|
||||
private Boolean _enableRawDataLogging;
|
||||
|
||||
/// <summary>
|
||||
/// Simulated flow activity
|
||||
/// </summary>
|
||||
public Boolean SimulatedFlowIsActive
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
/// <summary>
|
||||
/// Empty pipe ignore
|
||||
/// </summary>
|
||||
public Boolean IgnoreEmptyPipeDetection
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
/// <summary>
|
||||
/// to reduce the IrdA communication in test bench, preparation will be done once (when SkipPreparationForTestBench is true)
|
||||
/// </summary>
|
||||
@@ -67,7 +91,11 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
/// Quality watch mode can be used to decode intermediate records and check
|
||||
/// for actual quality of the measurements.
|
||||
/// </summary>
|
||||
public Boolean QualityWatchMode;
|
||||
public Boolean QualityWatchMode
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represent FW version
|
||||
@@ -123,6 +151,22 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
get; private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Average of the electrode in milli Volts
|
||||
/// </summary>
|
||||
public Single AverageElectrode_mV
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Standard deviation of the electrode in milli Volts
|
||||
/// </summary>
|
||||
public Single StandardDeviationElectrode_mV
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents Empty Pipe Detection control bits
|
||||
/// Bit0="EPD disabled", 1="Enabled w. Flags only", 2="EPD enabled full"
|
||||
@@ -300,6 +344,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
private readonly CancellationTokenSource _keepSessionToken = new CancellationTokenSource();
|
||||
|
||||
private ILogger _logger;
|
||||
//private ILogger _loggerRawData;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -407,7 +452,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
if (record.StatusBits != _lastStatusBits)
|
||||
{
|
||||
_lastStatusBits = record.StatusBits;
|
||||
_logger.Info($"Slot:{Slot} - {StateDef.GetStateInfosOfStateMask(record.StatusBits)}");
|
||||
_logger.Debug($"{RequestIdent} {StateDef.GetStateInfosOfStateMask(record.StatusBits)}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -491,7 +536,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
_logger.Trace($"Slot:{Slot} - Start to dispose");
|
||||
WriteLog("Start to dispose");
|
||||
|
||||
StreamingProtocol.OnRecordIsDecoded -= StreamingProtocol_ApplyDecodedRecord;
|
||||
RequestProtocol.OnRecordIsDecoded -= RequestProtocol_ApplyDecodedRecord;
|
||||
@@ -542,30 +587,30 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
|
||||
RequestProtocol?.Dispose();
|
||||
StreamingProtocol?.Dispose();
|
||||
_logger.Trace($"Slot:{Slot} - Dispose is finished");
|
||||
WriteLog("Dispose is finished");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Ctor
|
||||
/// </summary>
|
||||
/// <param name="slot">Slot number for test-bench </param>
|
||||
/// <param name="requestPort"><see cref="PortConfig" /> for request Port</param>
|
||||
/// <param name="streamingPort"><see cref="PortConfig" /> for streaming Port</param>
|
||||
/// <param name="ignoreCorruptedData">don´t send CRC error or telegrams with error flag to caller</param>
|
||||
/// <param name="password">
|
||||
/// If you have a password for highest access level you need, if you don't want to access the meter
|
||||
/// (just read led record) than you can leave it null
|
||||
/// </param>
|
||||
/// <remarks date="2023-Apr-20" author="Thomas Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
public MagFluxMeter(Int32 slot, PortConfig? requestPort, PortConfig? streamingPort,
|
||||
Boolean ignoreCorruptedData = true, String password = null)
|
||||
{
|
||||
_logger = NLogHelper.CreateOrGetMultiLogger($"Slot:{slot}", "Slot", "Meter", "MeterBase", "MeterBase");
|
||||
SetupMagFluxMeter(slot, requestPort, streamingPort, ignoreCorruptedData, password);
|
||||
}
|
||||
///// <summary>
|
||||
///// Ctor
|
||||
///// </summary>
|
||||
///// <param name="slot">Slot number for test-bench </param>
|
||||
///// <param name="requestPort"><see cref="PortConfig" /> for request Port</param>
|
||||
///// <param name="streamingPort"><see cref="PortConfig" /> for streaming Port</param>
|
||||
///// <param name="ignoreCorruptedData">don´t send CRC error or telegrams with error flag to caller</param>
|
||||
///// <param name="password">
|
||||
///// If you have a password for highest access level you need, if you don't want to access the meter
|
||||
///// (just read led record) than you can leave it null
|
||||
///// </param>
|
||||
///// <remarks date="2023-Apr-20" author="Thomas Wiedebusch">
|
||||
///// - Initial
|
||||
///// </remarks>
|
||||
//public MagFluxMeter(Int32 slot, PortConfig? requestPort, PortConfig? streamingPort,
|
||||
// Boolean ignoreCorruptedData = true, String password = null)
|
||||
//{
|
||||
// _logger = NLogHelper.CreateOrGetMultiLogger($"Slot:{slot}", "Slot", "Meter", "MeterBase", "MeterBase");
|
||||
// SetupMagFluxMeter(slot, requestPort, streamingPort, ignoreCorruptedData, password);
|
||||
//}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -591,15 +636,15 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
{
|
||||
if (requestPort.Value.Type == "Xylem.Common.Hardware.Interfaces.Ports.SerialPorts.UartSerialPort")
|
||||
{
|
||||
var requestIdent = $"Slot:{Slot}, Port:{requestPort.Value.PortName}, Protocol:Request, Type:UART -";
|
||||
RequestIdent = $"Slot:{Slot}, Port:{requestPort.Value.PortName}, Protocol:Request, Type:UART -";
|
||||
|
||||
RequestProtocol = new RequestProtocol(requestIdent);
|
||||
RequestProtocol = new RequestProtocol(RequestIdent);
|
||||
TransmitProtocol = new UartTransmitProtocol(requestPort.Value.PortName);
|
||||
//RequestProtocol.SetTransmitProtocol(TransmitProtocol);
|
||||
|
||||
// request port is needed to assign the port name from file, else it is not used
|
||||
// as the IMagFluxRequestProtocol implements the port handling and communication
|
||||
RequestPort = new UartSerialPort(requestIdent, requestPort.Value.GetSerialPort(),
|
||||
RequestPort = new UartSerialPort(RequestIdent, requestPort.Value.GetSerialPort(),
|
||||
TransmitProtocol.GetTransmitPortSettings());
|
||||
}
|
||||
}
|
||||
@@ -608,7 +653,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
{
|
||||
var ledTransmit = new LedTransmitProtocol(streamingPort.Value.PortName);
|
||||
|
||||
var streamingIdent = $"Slot:{Slot}, Port:{streamingPort.Value.PortName}, Protocol:LED";
|
||||
var streamingIdent = $"Slot:{Slot}, Port:{streamingPort.Value.PortName}, Protocol:Streaming, Type:LED -";
|
||||
|
||||
StreamingPort = new LedSerialPort(streamingIdent, streamingPort.Value.GetSerialPort(),
|
||||
ledTransmit.GetTransmitPortSettings());
|
||||
@@ -617,7 +662,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
Configuration = new ProcessConfig(ProgramConfig.ConfigFileName);
|
||||
|
||||
SetLogger();
|
||||
_logger.Debug($"Slot:{Slot} - Setup done");
|
||||
WriteLog("Setup done");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -630,23 +675,23 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
{
|
||||
if (RequestProtocol.Connect(RequestPort.GetPortName()))
|
||||
{
|
||||
_logger.Trace($"Slot:{Slot} - RequestPort and RequestProtocol linked");
|
||||
WriteLog("RequestPort and RequestProtocol linked");
|
||||
RequestProtocol.OnRecordIsDecoded += RequestProtocol_ApplyDecodedRecord;
|
||||
RequestProtocol.CloseConnection();
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Trace($"Slot:{Slot} - RequestPort Connection failed");
|
||||
WriteLog("RequestPort Connection failed");
|
||||
}
|
||||
}
|
||||
if (StreamingPort != null && StreamingPort.GetPortName() != BaseSerialPort.PortNotAssigned)
|
||||
{
|
||||
LinkPortToProtocol(StreamingPort, StreamingProtocol);
|
||||
_logger.Trace($"Slot:{Slot} - StreamingPort and StreamingProtocol linked");
|
||||
WriteLog("StreamingPort and StreamingProtocol linked");
|
||||
StreamingProtocol.OnRecordIsDecoded += StreamingProtocol_ApplyDecodedRecord;
|
||||
}
|
||||
|
||||
_logger.Debug($"Slot:{Slot} - Connected and communication started");
|
||||
WriteLog("Connected and communication started");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -702,7 +747,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
|
||||
private void RequestProtocol_AuthorizationGrant(Object sender, EventArgs e)
|
||||
{
|
||||
_logger.Debug($"Slot:{Slot} - Authorization succeeded");
|
||||
WriteLog("Authorization succeeded");
|
||||
}
|
||||
|
||||
public void SetupFromConfigFile(Int32 slot, Boolean ignoreCorruptedData = true)
|
||||
@@ -727,7 +772,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
calibrationCmPerH.dutFlowRate = (Single)result.MeasuredDutFlowQmPerH;
|
||||
calibrationsCmPerH.Add(calibrationCmPerH);
|
||||
}
|
||||
_logger.Debug($"Slot:{Slot} - Test bench calibration values received");
|
||||
WriteLog("Test bench calibration values received");
|
||||
|
||||
WriteCalibration(calibrationsCmPerH);
|
||||
ReadCalibration(out _);
|
||||
@@ -791,7 +836,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
}
|
||||
}
|
||||
|
||||
_logger.Debug($"Slot:{slot} - Configuration loaded");
|
||||
WriteLog("Configuration loaded");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -859,9 +904,21 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
{
|
||||
EpdControlBits = epd_cntl_bits;
|
||||
}
|
||||
|
||||
RequestProtocol?.GetCalibrationPoints(out _);
|
||||
StreamingProtocol?.SetDecodingMask(SensorSerialNo, uniqueId);
|
||||
if (RequestProtocol.GetStdDev_Electrode_mV(out var u_mV))
|
||||
{
|
||||
StandardDeviationElectrode_mV = u_mV;
|
||||
}
|
||||
if (RequestProtocol.GetAverage_Electrode_mV(out u_mV))
|
||||
{
|
||||
AverageElectrode_mV = u_mV;
|
||||
}
|
||||
|
||||
SimulatedFlowIsActive = RequestProtocol.IsSimulatedFlowActive();
|
||||
IgnoreEmptyPipeDetection = RequestProtocol.GetIgnoreFailOnEmptyPipeOnHealthy();
|
||||
|
||||
RequestProtocol.GetCalibrationPoints(out _);
|
||||
StreamingProtocol.SetDecodingMask(SensorSerialNo, uniqueId);
|
||||
|
||||
return IsLoggedOn;
|
||||
}
|
||||
|
||||
@@ -874,7 +931,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
/// <inheritdoc />
|
||||
public void InitMeasurement()
|
||||
{
|
||||
_logger.Info($"Slot:{Slot} - Init measurement");
|
||||
WriteLog("Init measurement");
|
||||
PreMeasurement();
|
||||
}
|
||||
|
||||
@@ -904,7 +961,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
measurement.OnActionStateHasChanged += Measurement_ActionStateHasChanged;
|
||||
}
|
||||
|
||||
_logger.Info($"Slot:{Slot} - Start measurement");
|
||||
WriteLog("Start measurement");
|
||||
|
||||
ProcessStatus = ProcessState.MeasurementIsActive;
|
||||
_listOfIMeasurement.ForEach(m => m.MeasurementState = MeasurementStates.IsWaitingForStartData);
|
||||
@@ -914,7 +971,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
/// <inheritdoc />
|
||||
public void StopMeasurement()
|
||||
{
|
||||
_logger.Info($"Slot:{Slot} - Stop measurement");
|
||||
WriteLog("Stop measurement");
|
||||
ProcessStatus = ProcessState.MeasurementIsDone;
|
||||
_listOfIMeasurement.ForEach(m => m.MeasurementState = MeasurementStates.IsWaitingForEndData);
|
||||
SyncStreamingBuffer(SyncMarkRecord.SyncEnd);
|
||||
@@ -937,7 +994,6 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
///
|
||||
public List<MeasurementResults> GetAllMeasurementResults(Double? refVolume, Double? refTimeS, Boolean intermediateMeasurement = false,
|
||||
Int32? channel = null, MeasurementDirection dir = MeasurementDirection.TakeBoth)
|
||||
{
|
||||
@@ -958,7 +1014,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
? mainMeasurement.GetIntermediateMeasurementResult(refVolume, refTimeS)
|
||||
: mainMeasurement.GetFinalMeasurementResult(refVolume, refTimeS);
|
||||
results.Add(mainResult);
|
||||
_logger.Info($"Slot:{Slot}, Channel:{mainMeasurement.GetChannel()} - MeasuredTime({mainResult.DutTimeS}s), " +
|
||||
_logger.Debug($"Slot:{Slot}, Channel:{mainMeasurement.GetChannel()} - MeasuredTime({mainResult.DutTimeS}s), " +
|
||||
$"MeasuredVolume({mainResult.DutVolumeCm}Qm)");
|
||||
|
||||
foreach (var otherMeasurement in _listOfIMeasurement.Where(m => m.GetType() != typeof(MagFluxRecord)))
|
||||
@@ -968,7 +1024,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
var otherResults = intermediateMeasurement
|
||||
? otherMeasurement.GetIntermediateMeasurementResult(refVolume, refTimeS)
|
||||
: otherMeasurement.GetFinalMeasurementResult(refVolume, refTimeS);
|
||||
_logger.Info($"Slot:{Slot}, Channel:{otherMeasurement.GetChannel()} - ChannelTime({otherResults.DutTimeS}s), " +
|
||||
_logger.Debug($"Slot:{Slot}, Channel:{otherMeasurement.GetChannel()} - ChannelTime({otherResults.DutTimeS}s), " +
|
||||
$"ChannelVolume({otherResults.DutVolumeCm}Qm)");
|
||||
results.Add(otherResults);
|
||||
}
|
||||
@@ -988,7 +1044,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
/// <inheritdoc />
|
||||
public MeasurementStates GetMeasurementState(Int32? onlyChannelNr = null)
|
||||
{
|
||||
_logger.Trace($"Slot:{Slot} - Get measurement state");
|
||||
WriteLog("Get measurement state");
|
||||
if (!_listOfIMeasurement.Any())
|
||||
{
|
||||
return MeasurementStates.NotStarted;
|
||||
@@ -1005,7 +1061,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
/// <inheritdoc />
|
||||
public Boolean RequestIntermediateMeasurementState(Int32? onlyChannelNr = null)
|
||||
{
|
||||
_logger.Trace($"Slot:{Slot} - Get measurement state");
|
||||
WriteLog("Get measurement state");
|
||||
if (!_listOfIMeasurement.Any())
|
||||
{
|
||||
return false;
|
||||
@@ -1048,13 +1104,25 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
return pcbId;
|
||||
}
|
||||
/// <summary>
|
||||
/// Get empty pipe control bits MagFlux
|
||||
/// </summary>
|
||||
public Boolean GetEmptyPipeControl()
|
||||
{
|
||||
var retVal = RequestProtocol.GetEmptyPipeControl(out var epd_cntl_bits);
|
||||
if (retVal)
|
||||
{
|
||||
EpdControlBits = epd_cntl_bits;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
/// <summary>
|
||||
/// Write calibration values to MagFlux
|
||||
/// </summary>
|
||||
public void WriteCalibration(List<Calibration> calibrationsCmPerH)
|
||||
{
|
||||
_logger.Info($"Slot:{Slot} - Write calibration values to MagFlux");
|
||||
RequestProtocol?.SetCalibrationPoints(calibrationsCmPerH);
|
||||
RequestProtocol?.CloseConnection();
|
||||
//RequestProtocol?.CloseConnection();
|
||||
}
|
||||
/// <summary>
|
||||
/// Read calibration values to MagFlux
|
||||
@@ -1062,44 +1130,60 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
public void ReadCalibration(out List<Calibration> calibrationsCmPerH)
|
||||
{
|
||||
calibrationsCmPerH = null;
|
||||
_logger.Info($"Slot:{Slot} - Read calibration values from MagFlux");
|
||||
RequestProtocol?.GetCalibrationPoints(out calibrationsCmPerH);
|
||||
RequestProtocol?.CloseConnection();
|
||||
//RequestProtocol?.CloseConnection();
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Turn on/off fixed test flow output from MagFlux
|
||||
///// Used for getting a fixed simulated flow from MagFlux
|
||||
///// </summary>
|
||||
///// <param name="testFlowOn"></param>
|
||||
///// <returns>true on okay or false on error</returns>
|
||||
//public Boolean SetSimulatedFlowActive(Boolean testFlowOn)
|
||||
//{
|
||||
// _logger.Info($"Slot:{Slot} - Set test flow");
|
||||
// return RequestProtocol.SetSimulatedFlowActive(on);
|
||||
//}
|
||||
/// <summary>
|
||||
/// Average Electrode measurement used for Device calibration verification
|
||||
/// </summary>
|
||||
/// <param name="u_mV"> Average Electrode [mV] </param>
|
||||
/// <returns>true on okay or false on error</returns>
|
||||
public Boolean GetAverage_Electrode_mV(out Single u_mV)
|
||||
{
|
||||
u_mV = 0;
|
||||
var retVal = RequestProtocol.GetAverage_Electrode_mV(out u_mV);
|
||||
AverageElectrode_mV = u_mV;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Is the fixed test flow active
|
||||
///// Used for getting a fixed simulated flow from MagFlux
|
||||
///// </summary>
|
||||
///// <returns>true if ON</returns>
|
||||
//public Boolean IsSimulatedFlowActive()
|
||||
//{
|
||||
// _logger.Info($"Slot:{Slot} - Get test flow setting");
|
||||
// return RequestProtocol.IsSimulatedFlowActive();
|
||||
//};
|
||||
/// <summary>
|
||||
/// Standard deviation electrode measurement used for Device calibration verification
|
||||
/// Note: update will only happen after x seconds, depending on filter config in device
|
||||
/// </summary>
|
||||
/// <param name="u_mV"> Average Electrode [mV] </param>
|
||||
/// <returns>true on okay or false on error</returns>
|
||||
public Boolean GetStdDev_Electrode_mV(out Single u_mV)
|
||||
{
|
||||
u_mV = 0;
|
||||
var retVal = RequestProtocol.GetStdDev_Electrode_mV(out u_mV);
|
||||
StandardDeviationElectrode_mV = u_mV;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ignore Empty pipe flag on Healthy, because it is not yet working correct
|
||||
/// Note: Not 100% secure all test is working during empty pipe, metrology board firmware may not allow running during detection of empty pipe
|
||||
/// </summary>
|
||||
/// <param name="ignoreEmptyPipeStatus"></param>
|
||||
/// <returns>true on okay or false on error</returns>
|
||||
public Boolean SetIgnoreFailOnEmptyPipeOnHealthy(Boolean ignoreEmptyPipeStatus)
|
||||
{
|
||||
var retVal = RequestProtocol.SetIgnoreFailOnEmptyPipeOnHealthy(ignoreEmptyPipeStatus);
|
||||
if (retVal)
|
||||
IgnoreEmptyPipeDetection = ignoreEmptyPipeStatus;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set PCB settings and PCB calibrations to default.
|
||||
/// </summary>
|
||||
public Boolean SetPCBToDemoDefaults()
|
||||
{
|
||||
_logger.Info($"Slot:{Slot} - Set PCB settings and PCB calibrations to default");
|
||||
if (RequestProtocol == null)
|
||||
return false;
|
||||
var retVal = RequestProtocol.SetPCBToDemoDefaults();
|
||||
RequestProtocol?.CloseConnection();
|
||||
//RequestProtocol?.CloseConnection();
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -1108,11 +1192,10 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
/// </summary>
|
||||
public Boolean SetMeterSizeMm(UInt16 meterSize_mm)
|
||||
{
|
||||
_logger.Info($"Slot:{Slot} - Set meter size in mm");
|
||||
if (RequestProtocol == null)
|
||||
return false;
|
||||
var retVal = RequestProtocol.SetMeterSizeMm(meterSize_mm);
|
||||
RequestProtocol?.CloseConnection();
|
||||
//RequestProtocol?.CloseConnection();
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -1121,23 +1204,21 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
/// </summary>
|
||||
public Boolean SetSensorSerialNo(UInt32 sensorSerialNo)
|
||||
{
|
||||
_logger.Info($"Slot:{Slot} - Set sensor serial no.");
|
||||
if (RequestProtocol == null)
|
||||
return false;
|
||||
var retVal = RequestProtocol.SetSensorSerialNo(sensorSerialNo);
|
||||
RequestProtocol?.CloseConnection();
|
||||
//RequestProtocol?.CloseConnection();
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void InitCalibration()
|
||||
{
|
||||
_logger.Info($"Slot:{Slot} - Init calibration and set calibration values of all channels to default");
|
||||
if (RequestProtocol == null)
|
||||
return;
|
||||
if (RequestProtocol.PrepareDeviceForCalibration())
|
||||
PreMeasurement();
|
||||
RequestProtocol?.CloseConnection();
|
||||
//RequestProtocol?.CloseConnection();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -1150,7 +1231,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
public void StopCalibration()
|
||||
{
|
||||
StopMeasurement();
|
||||
RequestProtocol?.CloseConnection();
|
||||
//RequestProtocol?.CloseConnection();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -1193,7 +1274,13 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
/// <inheritdoc />
|
||||
public void WriteLog(String text)
|
||||
{
|
||||
_logger.Info($"Slot:{Slot} - {text}");
|
||||
_logger.Trace($"Slot:{Slot} - {text}");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void LogRawData(Boolean on)
|
||||
{
|
||||
_enableRawDataLogging = on;
|
||||
//if (_enableRawDataLogging)
|
||||
//{
|
||||
// if (_loggerRawData == null)
|
||||
@@ -1202,14 +1289,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
// StreamingPort.GetPortName(), "", "LedRawData", "TargetLedRawDataBase", "LedRawDataBase");
|
||||
|
||||
// }
|
||||
// _loggerRawData.Info($"{text}");
|
||||
//}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void LogRawData(Boolean on)
|
||||
{
|
||||
_enableRawDataLogging = on;
|
||||
if (StreamingPort is LedSerialPort port)
|
||||
{
|
||||
port.RecordStreamingRawData = _enableRawDataLogging;
|
||||
@@ -1297,24 +1377,24 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
((LedSerialPort)StreamingPort).RefreshLogger();
|
||||
|
||||
|
||||
if (!string.IsNullOrEmpty(SerialNumber) && CurrentActionText.Contains("PG"))
|
||||
{
|
||||
//if (!string.IsNullOrEmpty(SerialNumber) && CurrentActionText.Contains("PG"))
|
||||
//{
|
||||
|
||||
//var pathMain = NLogHelper.GetPath(_logger);
|
||||
//var pathRaw = NLogHelper.GetPath(((LedSerialPort)StreamingPort).GetRawLogger());
|
||||
// //var pathMain = NLogHelper.GetPath(_logger);
|
||||
// //var pathRaw = NLogHelper.GetPath(((LedSerialPort)StreamingPort).GetRawLogger());
|
||||
|
||||
//var basePath = Path.GetDirectoryName(pathMain);
|
||||
// //var basePath = Path.GetDirectoryName(pathMain);
|
||||
|
||||
//var testRunString = CurrentActionText.Replace("PG", "");
|
||||
//var lastChat = pathMain.LastIndexOf('\\');
|
||||
//pathMain = pathMain.Substring(lastChat + 1);
|
||||
//pathRaw = Path.GetFileName(pathRaw);
|
||||
// //var testRunString = CurrentActionText.Replace("PG", "");
|
||||
// //var lastChat = pathMain.LastIndexOf('\\');
|
||||
// //pathMain = pathMain.Substring(lastChat + 1);
|
||||
// //pathRaw = Path.GetFileName(pathRaw);
|
||||
|
||||
//var tmpUrl = $"http://10.49.40.25/MeterProcessState/api/TestBench/SetMeterLogPathInfo?SerialNumber={SerialNumber}&TestRunId={testRunString}&BasePath={basePath}&MainLogName={pathMain}&LEDName={pathRaw}";
|
||||
//_logger.Debug($"Request Url: { tmpUrl}");
|
||||
////ToDO: Update to service URl
|
||||
//LocalWebRequest.GetRequest(tmpUrl);
|
||||
}
|
||||
// //var tmpUrl = $"http://10.49.40.25/MeterProcessState/api/TestBench/SetMeterLogPathInfo?SerialNumber={SerialNumber}&TestRunId={testRunString}&BasePath={basePath}&MainLogName={pathMain}&LEDName={pathRaw}";
|
||||
// //_logger.Debug($"Request Url: { tmpUrl}");
|
||||
// ////ToDO: Update to service URl
|
||||
// //LocalWebRequest.GetRequest(tmpUrl);
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
public class RequestProtocol : BaseProtocol
|
||||
{
|
||||
private readonly String _ident;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger _logger;
|
||||
private IMagFluxRequestProtocol _magFluxRequestProtocol;
|
||||
private IMagFluxAPI _magFluxApi;
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
_ident = ident;
|
||||
_magFluxApi = new MagFluxAPI();
|
||||
_calibPointsCmPerH = new List<Calibration>();
|
||||
_logger = NLogHelper.CreateOrGetMultiLogger(_ident, "", "RequestProtocol", "MeterBase",
|
||||
_logger = NLogHelper.CreateOrGetMultiLogger(_ident, "", "RequestProtocol", "MeterBase",
|
||||
"MeterBase");
|
||||
}
|
||||
|
||||
@@ -74,24 +74,41 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
/// <remarks date="2024-Aug-12" author="T.Wiedebusch">
|
||||
/// - MagFluxApi
|
||||
/// </remarks>
|
||||
/// <remarks date="2024-Sep-20" author="T.Wiedebusch">
|
||||
/// - Avoid re-opening if connection is already done
|
||||
/// </remarks>
|
||||
public Boolean Connect(String portName)
|
||||
{
|
||||
if (_magFluxApi == null) return false;
|
||||
if (_magFluxApi == null)
|
||||
return false;
|
||||
if (_magFluxRequestProtocol != null && _magFluxRequestProtocol.IsConnected())
|
||||
{
|
||||
_logger.Info($"{_ident} Connection already established to {portName}");
|
||||
return true;
|
||||
}
|
||||
|
||||
_magFluxRequestProtocol = _magFluxApi.Connect(portName);
|
||||
if (_magFluxRequestProtocol == null)
|
||||
{
|
||||
_logger.Debug($"{_ident} Connection to {portName} failed! Object reference returned null");
|
||||
_logger.Error($"{_ident} Connection to {portName} failed! Object reference returned null");
|
||||
return false;
|
||||
}
|
||||
|
||||
Thread.Sleep(100);
|
||||
var retVal = _magFluxRequestProtocol.IsConnected();
|
||||
_logger.Debug(retVal ? $"{_ident} Connection established to {portName}" :
|
||||
$"{_ident} Connection to {portName} failed!");
|
||||
if (retVal)
|
||||
{
|
||||
_logger.Info($"{_ident} New connection established to {portName}");
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Error($"{_ident} Connection to {portName} failed!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public String GetComCounters()
|
||||
public String GetComCounters()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@@ -107,10 +124,13 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
/// </remarks>
|
||||
public Boolean SetLogLocation(String path, String fileName)
|
||||
{
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
if (_magFluxRequestProtocol == null)
|
||||
return false;
|
||||
var retVal = _magFluxRequestProtocol.SetLogLocation(path, fileName);
|
||||
if (string.IsNullOrEmpty(fileName)) fileName = "?";
|
||||
_logger.Debug(retVal ? $"{_ident} Logging set to: {path}\\{fileName}" :
|
||||
if (string.IsNullOrEmpty(fileName))
|
||||
fileName = "?";
|
||||
_logger.Debug(retVal ?
|
||||
$"{_ident} Logging set to: {path}\\{fileName}" :
|
||||
$"{_ident} Logging path setup failed!");
|
||||
return retVal;
|
||||
}
|
||||
@@ -119,7 +139,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Wrapper to set experimental boards to defaults regarding board serial number
|
||||
/// and board calibration values
|
||||
@@ -130,78 +150,85 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
/// </remarks>
|
||||
public Boolean SetPCBToDemoDefaults()
|
||||
{
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
if (_magFluxRequestProtocol == null)
|
||||
return false;
|
||||
var retVal = _magFluxRequestProtocol.SetPCBToDemoDefaults();
|
||||
_logger.Debug(retVal ? $"{_ident} Successfully set PCB settings and PCB calibrations to default" :
|
||||
_logger.Debug(retVal ?
|
||||
$"{_ident} Successfully set PCB settings and PCB calibrations to default" :
|
||||
$"{_ident} PCB settings and PCB calibrations setup to default failed!");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Wrapper to get the simulated flow setting
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
///// <remarks date="2024-Aug-23" author="T.Wiedebusch">
|
||||
///// - Initial
|
||||
///// </remarks>
|
||||
//public Boolean GetSimulatedFlowOn()
|
||||
//{
|
||||
// if (_magFluxRequestProtocol == null) return false;
|
||||
// var retVal = _magFluxRequestProtocol.IsSimulatedFlowActive();
|
||||
// _logger.Debug(retVal ? $"{_ident} Simulated flow active read back returns: true" :
|
||||
// $"{_ident} Read back simulated flow status failed!");
|
||||
// return retVal;
|
||||
//}
|
||||
/// <summary>
|
||||
/// Wrapper to get the simulated flow setting
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2024-Aug-23" author="T.Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
public Boolean IsSimulatedFlowActive()
|
||||
{
|
||||
if (_magFluxRequestProtocol == null)
|
||||
return false;
|
||||
var retVal = _magFluxRequestProtocol.IsSimulatedFlowActive();
|
||||
_logger.Debug($"{_ident} Simulated flow active read back returns: {retVal}");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Wrapper to set the simulated flow setting
|
||||
///// </summary>
|
||||
///// <param name="on">true to ignore state</param>
|
||||
///// <returns></returns>
|
||||
///// <remarks date="2024-Aug-23" author="T.Wiedebusch">
|
||||
///// - Initial
|
||||
///// </remarks>
|
||||
//public Boolean SetSimulatedFlowActive(Boolean on)
|
||||
//{
|
||||
// if (_magFluxRequestProtocol == null) return false;
|
||||
// var retVal = _magFluxRequestProtocol.SetSimulatedFlowActive(on);
|
||||
// _logger.Debug(retVal ? $"{_ident} Simulated flow active set to: {on}" :
|
||||
// $"{_ident} Simulated flow active setup failed!");
|
||||
// return retVal;
|
||||
//}
|
||||
/// <summary>
|
||||
/// Wrapper to set the simulated flow setting
|
||||
/// </summary>
|
||||
/// <param name="on">true to ignore state</param>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2024-Aug-23" author="T.Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
public Boolean SetSimulatedFlowActive(Boolean on)
|
||||
{
|
||||
if (_magFluxRequestProtocol == null)
|
||||
return false;
|
||||
var retVal = _magFluxRequestProtocol.SetSimulatedFlowActive(on);
|
||||
_logger.Debug(retVal ?
|
||||
$"{_ident} Simulated flow active set to: {on}" :
|
||||
$"{_ident} Simulated flow active setup failed!");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Wrapper to get the ignore empty pipe mode status
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
///// <remarks date="2024-Aug-23" author="T.Wiedebusch">
|
||||
///// - Initial
|
||||
///// </remarks>
|
||||
//public Boolean GetIgnoreEmptyPipeStatus()
|
||||
//{
|
||||
// if (_magFluxRequestProtocol == null) return false;
|
||||
// var retVal = _magFluxRequestProtocol.IgnoreFailOnEmptyPipeOnHealthy();
|
||||
// _logger.Debug(retVal ? $"{_ident} Ignore empty pipe status read back returns: {retVal}" :
|
||||
// $"{_ident} Read back empty pipe status failed!");
|
||||
// return retVal;
|
||||
//}
|
||||
/// <summary>
|
||||
/// Wrapper to get the ignore empty pipe mode status
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2024-Aug-23" author="T.Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
public Boolean GetIgnoreFailOnEmptyPipeOnHealthy()
|
||||
{
|
||||
if (_magFluxRequestProtocol == null)
|
||||
return false;
|
||||
var retVal = _magFluxRequestProtocol.GetIgnoreFailOnEmptyPipeOnHealthy();
|
||||
_logger.Debug($"{_ident} Ignore empty pipe status read back returns: {retVal}");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Wrapper to set the ignore empty pipe mode
|
||||
///// </summary>
|
||||
///// <param name="on">true to ignore state</param>
|
||||
///// <returns></returns>
|
||||
///// <remarks date="2024-Aug-23" author="T.Wiedebusch">
|
||||
///// - Initial
|
||||
///// </remarks>
|
||||
//public Boolean SetIgnoreEmptyPipeStatus(Boolean on)
|
||||
//{
|
||||
// if (_magFluxRequestProtocol == null) return false;
|
||||
// var retVal = _magFluxRequestProtocol.IgnoreFailOnEmptyPipeOnHealthy(on);
|
||||
// _logger.Debug(retVal ? $"{_ident} Ignore empty pipe status adjusted to: {on}" :
|
||||
// $"{_ident} Setup empty pipe status request failed!");
|
||||
// return retVal;
|
||||
//}
|
||||
/// <summary>
|
||||
/// Wrapper to set the ignore empty pipe mode
|
||||
/// </summary>
|
||||
/// <param name="on">true to ignore state</param>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2024-Aug-23" author="T.Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
public Boolean SetIgnoreFailOnEmptyPipeOnHealthy(Boolean on)
|
||||
{
|
||||
if (_magFluxRequestProtocol == null)
|
||||
return false;
|
||||
_magFluxRequestProtocol.SetIgnoreFailOnEmptyPipeOnHealthy(on);
|
||||
var retVal = _magFluxRequestProtocol.GetIgnoreFailOnEmptyPipeOnHealthy();
|
||||
_logger.Debug(retVal == on ?
|
||||
$"{_ident} Ignore empty pipe status adjusted to: {on}" :
|
||||
$"{_ident} Ignore empty pipe status setup failed!");
|
||||
return retVal == on;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wrapper to get the empty pipe bits
|
||||
@@ -214,13 +241,54 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
public Boolean GetEmptyPipeControl(out Int32 epd_cntl_bits)
|
||||
{
|
||||
epd_cntl_bits = 0;
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
if (_magFluxRequestProtocol == null)
|
||||
return false;
|
||||
var retVal = _magFluxRequestProtocol.GetEmptyPipeControl(out epd_cntl_bits);
|
||||
_logger.Debug(retVal ? $"{_ident} Empty pipe control bits: 0x{epd_cntl_bits:X1}" :
|
||||
_logger.Debug(retVal ?
|
||||
$"{_ident} Empty pipe control bits: 0x{epd_cntl_bits:X4}" :
|
||||
$"{_ident} Empty pipe control bits request failed!");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wrapper to get the standard deviation value of the electrode in milli Volts
|
||||
/// </summary>
|
||||
/// <param name="u_mV"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2024-Sep-19" author="T.Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
public Boolean GetStdDev_Electrode_mV(out Single u_mV)
|
||||
{
|
||||
u_mV = 0;
|
||||
if (_magFluxRequestProtocol == null)
|
||||
return false;
|
||||
var retVal = _magFluxRequestProtocol.GetStdDev_Electrode_mV(out u_mV);
|
||||
_logger.Debug(retVal ?
|
||||
$"{_ident} Standard deviation of electrode: {u_mV:F6} mV" :
|
||||
$"{_ident} Standard deviation of electrode request failed!");
|
||||
return retVal;
|
||||
}
|
||||
/// <summary>
|
||||
/// Wrapper to get the standard deviation value of the electrode in milli Volts
|
||||
/// </summary>
|
||||
/// <param name="u_mV"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2024-Sep-19" author="T.Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
public Boolean GetAverage_Electrode_mV(out Single u_mV)
|
||||
{
|
||||
u_mV = 0;
|
||||
if (_magFluxRequestProtocol == null)
|
||||
return false;
|
||||
var retVal = _magFluxRequestProtocol.GetAverage_Electrode_mV(out u_mV);
|
||||
_logger.Debug(retVal ?
|
||||
$"{_ident} Average of electrode: {u_mV:F6} mV" :
|
||||
$"{_ident} Average of electrode request failed!");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wrapper to get the board calibration value
|
||||
/// </summary>
|
||||
@@ -232,9 +300,11 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
public Boolean GetElectrodeBoardCorrectionFactor(out Single value_out)
|
||||
{
|
||||
value_out = 0f;
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
if (_magFluxRequestProtocol == null)
|
||||
return false;
|
||||
var retVal = _magFluxRequestProtocol.GetElectrodeBoardCorrectionFactor(out value_out);
|
||||
_logger.Debug(retVal ? $"{_ident} Board calibration: {value_out:F4}" :
|
||||
_logger.Debug(retVal ?
|
||||
$"{_ident} Board calibration: {value_out:F4}" :
|
||||
$"{_ident} SensorSerialNo request failed!");
|
||||
return retVal;
|
||||
}
|
||||
@@ -250,9 +320,11 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
public Boolean GetSensorSerialNo(out String sensorSerialNo)
|
||||
{
|
||||
sensorSerialNo = "?";
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
if (_magFluxRequestProtocol == null)
|
||||
return false;
|
||||
var retVal = _magFluxRequestProtocol.GetSensorSerialNo(out sensorSerialNo);
|
||||
_logger.Debug(retVal ? $"{_ident} SensorSerialNo: {sensorSerialNo}" :
|
||||
_logger.Debug(retVal ?
|
||||
$"{_ident} SensorSerialNo: {sensorSerialNo}" :
|
||||
$"{_ident} SensorSerialNo request failed!");
|
||||
return retVal;
|
||||
}
|
||||
@@ -268,9 +340,11 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
public Boolean GetPcbId(out String pcbId)
|
||||
{
|
||||
pcbId = "?";
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
if (_magFluxRequestProtocol == null)
|
||||
return false;
|
||||
var retVal = _magFluxRequestProtocol.GetBoardSerialNo(out pcbId);
|
||||
_logger.Debug(retVal ? $"{_ident} PcbId: {pcbId}" :
|
||||
_logger.Debug(retVal ?
|
||||
$"{_ident} PcbId: {pcbId}" :
|
||||
$"{_ident} PcbId request failed!");
|
||||
return retVal;
|
||||
}
|
||||
@@ -285,9 +359,11 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
/// </remarks>
|
||||
public Boolean SetSensorSerialNo(UInt32 sensorSerialNo)
|
||||
{
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
if (_magFluxRequestProtocol == null)
|
||||
return false;
|
||||
var retVal = _magFluxRequestProtocol.SetSensorSerialNo(sensorSerialNo);
|
||||
_logger.Debug(retVal ? $"{_ident} Set SensorSerialNo: {sensorSerialNo}" :
|
||||
_logger.Debug(retVal ?
|
||||
$"{_ident} Set SensorSerialNo: {sensorSerialNo}" :
|
||||
$"{_ident} Set SensorSerialNo request failed!");
|
||||
return retVal;
|
||||
}
|
||||
@@ -303,9 +379,11 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
public Boolean GetUniqueId(out String pcbId)
|
||||
{
|
||||
pcbId = "?";
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
if (_magFluxRequestProtocol == null)
|
||||
return false;
|
||||
var retVal = _magFluxRequestProtocol.GetUniqueId(out pcbId);
|
||||
_logger.Debug(retVal ? $"{_ident} UniqueId: {pcbId}" :
|
||||
_logger.Debug(retVal ?
|
||||
$"{_ident} UniqueId: {pcbId}" :
|
||||
$"{_ident} UniqueId request failed!");
|
||||
return retVal;
|
||||
}
|
||||
@@ -321,9 +399,11 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
public Boolean GetFirmwareVersion(out String fwVersion)
|
||||
{
|
||||
fwVersion = "?";
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
if (_magFluxRequestProtocol == null)
|
||||
return false;
|
||||
var retVal = _magFluxRequestProtocol.GetFirmwareVersion(out fwVersion);
|
||||
_logger.Debug(retVal ? $"{_ident} FW Version: {fwVersion}" :
|
||||
_logger.Debug(retVal ?
|
||||
$"{_ident} FW Version: {fwVersion}" :
|
||||
$"{_ident} FW Version request failed!");
|
||||
return retVal;
|
||||
}
|
||||
@@ -339,13 +419,15 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
public Boolean GetFwBuildDate(out String fwBuildDate)
|
||||
{
|
||||
fwBuildDate = "?";
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
if (_magFluxRequestProtocol == null)
|
||||
return false;
|
||||
var retVal = _magFluxRequestProtocol.GetFwBuildDate(out fwBuildDate);
|
||||
_logger.Debug(retVal ? $"{_ident} FW Build Date: {fwBuildDate}" :
|
||||
_logger.Debug(retVal ?
|
||||
$"{_ident} FW Build Date: {fwBuildDate}" :
|
||||
$"{_ident} FW Build Date request failed!");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Wrapper to get FW GIT hash of MagFlux
|
||||
/// </summary>
|
||||
@@ -357,9 +439,11 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
public Boolean GetFwGitHash(out String fwGitHash)
|
||||
{
|
||||
fwGitHash = "?";
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
if (_magFluxRequestProtocol == null)
|
||||
return false;
|
||||
var retVal = _magFluxRequestProtocol.GetFwGitHash(out fwGitHash);
|
||||
_logger.Debug(retVal ? $"{_ident} FW GIT Hash: {fwGitHash}" :
|
||||
_logger.Debug(retVal ?
|
||||
$"{_ident} FW GIT Hash: {fwGitHash}" :
|
||||
$"{_ident} FW GIT Hash request failed!");
|
||||
return retVal;
|
||||
}
|
||||
@@ -375,9 +459,11 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
public Boolean GetApiRegisterVersion(out String apiRegisterVersion)
|
||||
{
|
||||
apiRegisterVersion = "?";
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
if (_magFluxRequestProtocol == null)
|
||||
return false;
|
||||
var retVal = _magFluxRequestProtocol.GetAPIRegisterVersion(out apiRegisterVersion);
|
||||
_logger.Debug(retVal ? $"{_ident} MagFlux API Register Version: {apiRegisterVersion}" :
|
||||
_logger.Debug(retVal ?
|
||||
$"{_ident} MagFlux API Register Version: {apiRegisterVersion}" :
|
||||
$"{_ident} MagFlux API Register Version request failed!");
|
||||
return retVal;
|
||||
}
|
||||
@@ -398,9 +484,11 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
public Boolean GetMeterSizeMm(out Int32 meterSize)
|
||||
{
|
||||
meterSize = 0;
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
if (_magFluxRequestProtocol == null)
|
||||
return false;
|
||||
var retVal = _magFluxRequestProtocol.GetDn_mm(out meterSize);
|
||||
_logger.Debug(retVal ? $"{_ident} MeterSize DN: {meterSize}" :
|
||||
_logger.Debug(retVal ?
|
||||
$"{_ident} MeterSize DN: {meterSize}" :
|
||||
$"{_ident} MeterSize request failed!");
|
||||
return retVal;
|
||||
}
|
||||
@@ -415,9 +503,11 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
/// </remarks>
|
||||
public Boolean SetMeterSizeMm(UInt16 meterSize)
|
||||
{
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
if (_magFluxRequestProtocol == null)
|
||||
return false;
|
||||
var retVal = _magFluxRequestProtocol.SetDn_mm(meterSize);
|
||||
_logger.Debug(retVal ? $"{_ident} Set MeterSize DN: {meterSize}" :
|
||||
_logger.Debug(retVal ?
|
||||
$"{_ident} Set MeterSize DN: {meterSize}" :
|
||||
$"{_ident} Set MeterSize failed!");
|
||||
return retVal;
|
||||
}
|
||||
@@ -434,18 +524,22 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
|
||||
public Boolean PrepareDeviceForCalibration()
|
||||
{
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
if (_magFluxRequestProtocol == null)
|
||||
return false;
|
||||
var retVal = _magFluxRequestProtocol.PrepareDeviceForCalibration();
|
||||
_logger.Debug(retVal ? $"{_ident} MagFlux successfully prepared for calibration" :
|
||||
_logger.Debug(retVal ?
|
||||
$"{_ident} MagFlux successfully prepared for calibration" :
|
||||
$"{_ident} MagFlux preparation for calibration failed!");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public Boolean AbortDeviceForCalibration()
|
||||
{
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
if (_magFluxRequestProtocol == null)
|
||||
return false;
|
||||
var retVal = _magFluxRequestProtocol.AbortDeviceForCalibration();
|
||||
_logger.Debug(retVal ? $"{_ident} MagFlux calibration successfully aborted" :
|
||||
_logger.Debug(retVal ?
|
||||
$"{_ident} MagFlux calibration successfully aborted" :
|
||||
$"{_ident} MagFlux abortion of calibration failed!");
|
||||
return retVal;
|
||||
}
|
||||
@@ -466,15 +560,17 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
public Boolean GetCalibrationPoints(out List<Calibration> calibPointsCmPerH)
|
||||
{
|
||||
calibPointsCmPerH = new List<Calibration>();
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
if (_magFluxRequestProtocol == null)
|
||||
return false;
|
||||
|
||||
var retVal = _magFluxRequestProtocol.GetCalibrationPoints(out var calibrations);
|
||||
_logger.Debug(retVal ? $"{_ident} MagFlux calibration successfully read:\n{calibrations}" :
|
||||
_logger.Debug(retVal ?
|
||||
$"{_ident} MagFlux calibration successfully read:\n{calibrations}" :
|
||||
$"{_ident} MagFlux calibration read failed!");
|
||||
|
||||
if (!retVal)
|
||||
return false;
|
||||
|
||||
|
||||
// extract the single calibration points from container as ref and DUT in liters per second
|
||||
var calibPoints = calibrations?.calibrations?.ToList();
|
||||
if (calibPoints == null)
|
||||
@@ -512,7 +608,8 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
/// </remarks>
|
||||
public Boolean SetCalibrationPoints(List<Calibration> calibPointsCmPerH)
|
||||
{
|
||||
if (_magFluxRequestProtocol == null || calibPointsCmPerH == null) return false;
|
||||
if (_magFluxRequestProtocol == null || calibPointsCmPerH == null)
|
||||
return false;
|
||||
|
||||
// remove zeros as this are possibly empty (unused) fields
|
||||
var removedZeros = calibPointsCmPerH.Where(x => x.dutFlowRate != 0 || x.refFlowRate != 0);
|
||||
@@ -542,7 +639,8 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
}
|
||||
var cbs = new CalibrationPoints(calibPoints, calibPoints.Count);
|
||||
var retVal = _magFluxRequestProtocol.SetCalibrationPoints(cbs);
|
||||
_logger.Debug(retVal ? $"{_ident} MagFlux calibration successfully set:\n{cbs}" :
|
||||
_logger.Debug(retVal ?
|
||||
$"{_ident} MagFlux calibration successfully set:\n{cbs}" :
|
||||
$"{_ident} MagFlux calibration setup failed!");
|
||||
return retVal;
|
||||
}
|
||||
@@ -560,12 +658,14 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
/// </remarks>
|
||||
public Boolean CloseConnection()
|
||||
{
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
if (_magFluxRequestProtocol == null)
|
||||
return false;
|
||||
MagFluxAPI.CloseAllConnections();
|
||||
|
||||
Thread.Sleep(100);
|
||||
var retVal = _magFluxRequestProtocol.IsConnected();
|
||||
_logger.Debug(!retVal ? $"{_ident} Connection is closed" :
|
||||
_logger.Info(!retVal ?
|
||||
$"{_ident} Connection is closed" :
|
||||
$"{_ident} Close connection request failed!");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
89102b0142e574de38a9f47d370f3334e5e6c268
|
||||
8fbe991b217e7692af4817ad205b768685aa5a72
|
||||
|
||||
Reference in New Issue
Block a user