MagFlux: - Decoding mask for streaming protocol introduced
This commit is contained in:
@@ -22,6 +22,7 @@ using Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts;
|
||||
using Xylem.Common.Metrology.Measurements;
|
||||
using Xylem.Common.Metrology.Measurements.Consts;
|
||||
using Xylem.Common.Utils.Logging;
|
||||
using XYLEM.Device;
|
||||
|
||||
|
||||
namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
@@ -34,7 +35,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
public class MagFluxMeter : IMeter, IMeterEvents
|
||||
{
|
||||
#region Variables and Properties
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Mark the streaming catcher as active
|
||||
/// </summary>
|
||||
@@ -43,7 +44,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
/// <summary>
|
||||
/// Streaming decoder
|
||||
/// </summary>
|
||||
private StreamingDecoder _streamingDecoder;
|
||||
//private StreamingDecoder _streamingDecoder;
|
||||
|
||||
/// <summary>
|
||||
/// Enable raw record logging, if set every incoming package will be logged
|
||||
@@ -112,6 +113,14 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
get; private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represent unique id
|
||||
/// </summary>
|
||||
public String UniqueId
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
|
||||
private String _currentActionText = "";
|
||||
/// <summary>
|
||||
/// Hold the current process name e.g. FlowTest, Preadjustemtn for logging
|
||||
@@ -229,7 +238,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
private set;
|
||||
get;
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorState ErrorStatus
|
||||
{
|
||||
@@ -398,14 +407,13 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
{
|
||||
return;
|
||||
}
|
||||
_streamingDecoder = new StreamingDecoder(false);
|
||||
if (!(StreamingPort is LedSerialPort))
|
||||
{
|
||||
throw new ApplicationException("No valid streaming port");
|
||||
}
|
||||
|
||||
SyncStreamingBuffer(SyncMarkRecord.DecodeEveryPackage);
|
||||
((LedSerialPort)StreamingPort).OnRawRecordReceived += StreamingCatcher_OnRawRecordReceived;
|
||||
StreamingProtocol.OnRecordIsDecoded += StreamingCatcher_OnRawRecordReceived;
|
||||
LogRawData(true);
|
||||
_streamingCatcherIsActive = true;
|
||||
}
|
||||
@@ -415,16 +423,9 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void StreamingCatcher_OnRawRecordReceived(Object sender, BasePortDataEventArgs e)
|
||||
private void StreamingCatcher_OnRawRecordReceived(Object sender, BaseDataEventArgs e)
|
||||
{
|
||||
var data = (String)e.GetData();
|
||||
|
||||
if (_streamingDecoder.DecodeMsg(data))
|
||||
{
|
||||
// Fire event for listener
|
||||
OnStreamingRecordDecoded?.Invoke(this,
|
||||
new MagFluxFlowDataEventArgs{ NewData = _streamingDecoder.DataMagFlux, RawData = data });
|
||||
}
|
||||
OnStreamingRecordDecoded?.Invoke(this, (MagFluxFlowDataEventArgs)e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -438,7 +439,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
throw new ApplicationException("No valid streaming port");
|
||||
}
|
||||
LogRawData(false);
|
||||
((LedSerialPort)StreamingPort).OnRawRecordReceived -= StreamingCatcher_OnRawRecordReceived;
|
||||
StreamingProtocol.OnRecordIsDecoded -= StreamingCatcher_OnRawRecordReceived;
|
||||
SyncStreamingBuffer(SyncMarkRecord.SkipDecoding);
|
||||
_streamingCatcherIsActive = false;
|
||||
}
|
||||
@@ -728,7 +729,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
{
|
||||
SetupMagFluxMeter(slot, slotConfig.Request, slotConfig.Streaming, ignoreCorruptedData);
|
||||
}
|
||||
SetLogger();
|
||||
SetLogger();
|
||||
_logger.Debug($"Slot:{slot} - Configuration loaded");
|
||||
}
|
||||
|
||||
@@ -741,9 +742,14 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <remarks date="2023-Mai-30" author="T.Wiedebusch">
|
||||
/// - Unique Id introduced,
|
||||
/// - Sensor Serial number mapped as PcbId.
|
||||
/// </remarks>
|
||||
public Boolean Login()
|
||||
{
|
||||
if (!RequestProtocol.Connect(RequestPort.GetPortName())) return IsLoggedOn;
|
||||
if (!RequestProtocol.Connect(RequestPort.GetPortName()))
|
||||
return IsLoggedOn;
|
||||
|
||||
IsLoggedOn = true;
|
||||
if (RequestProtocol.GetFirmwareVersion(out var fwVersion))
|
||||
@@ -762,15 +768,16 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
{
|
||||
FwGitHash = gitHash;
|
||||
}
|
||||
if (RequestProtocol.GetSensorSerialNo(out var serialNumber))
|
||||
if (RequestProtocol.GetUniqueId(out var uniqueId))
|
||||
{
|
||||
SerialNumber = serialNumber;
|
||||
UniqueId = uniqueId;
|
||||
}
|
||||
if (RequestProtocol.GetUniqueId(out var pcbId))
|
||||
if (RequestProtocol.GetSensorSerialNo(out var pcbId))
|
||||
{
|
||||
PcbId = pcbId;
|
||||
}
|
||||
|
||||
StreamingProtocol?.SetDecodingMask(pcbId, uniqueId);
|
||||
return IsLoggedOn;
|
||||
}
|
||||
|
||||
@@ -941,11 +948,36 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
return ret.HasValue ? ret.Value : false;
|
||||
}
|
||||
|
||||
private CalibrationPoints calibPoints;
|
||||
|
||||
/// <summary>
|
||||
/// Write calibration values to MagFlux
|
||||
/// </summary>
|
||||
public void WriteCalibration()
|
||||
{
|
||||
_logger.Info($"Slot:{Slot} - Write calibration values to MagFlux");
|
||||
RequestProtocol?.SetCalibrationPoints(calibPoints);
|
||||
}
|
||||
/// <summary>
|
||||
/// Write calibration values to MagFlux
|
||||
/// </summary>
|
||||
public void ReadCalibration()
|
||||
{
|
||||
_logger.Info($"Slot:{Slot} - Read calibration values from MagFlux");
|
||||
RequestProtocol?.GetCalibrationPoints(out calibPoints);
|
||||
}
|
||||
/// <inheritdoc />
|
||||
public void InitCalibration()
|
||||
{
|
||||
_logger.Info($"Slot:{Slot} - Init calibration and set calibration values of all channels to default");
|
||||
PreMeasurement();
|
||||
if (RequestProtocol == null)
|
||||
return;
|
||||
// first read out the current calibration points
|
||||
RequestProtocol.GetCalibrationPoints(out calibPoints);
|
||||
if (RequestProtocol.PrepareDeviceForCalibration())
|
||||
PreMeasurement();
|
||||
RequestProtocol.GetCalibrationPoints(out calibPoints);
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -958,6 +990,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
public void StopCalibration()
|
||||
{
|
||||
StopMeasurement();
|
||||
RequestProtocol?.AbortDeviceForCalibration();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -1129,7 +1162,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
void IMeter.SetupFromConfigFile(Int32 slot, Boolean ignoreCorruptedData, Boolean useRequest, Boolean useStreaming)
|
||||
{
|
||||
SetupFromConfigFile(slot, ignoreCorruptedData);
|
||||
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user