MagFlux: - LogLocation implemented
This commit is contained in:
@@ -5,6 +5,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Newtonsoft.Json;
|
||||
using NLog.LayoutRenderers;
|
||||
using Xylem.Common.CommonCore.Consts;
|
||||
using Xylem.Common.Hardware.Interfaces.Ports.PortCore;
|
||||
using Xylem.Common.Hardware.Interfaces.Ports.PortCore.EventArguments;
|
||||
@@ -748,7 +749,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
if (!RequestProtocol.Connect(RequestPort.GetPortName())) return IsLoggedOn;
|
||||
|
||||
IsLoggedOn = true;
|
||||
if (RequestProtocol.GetFwVersion(out var fwVersion))
|
||||
if (RequestProtocol.GetFirmwareVersion(out var fwVersion))
|
||||
{
|
||||
FwVersion = fwVersion;
|
||||
}
|
||||
@@ -756,7 +757,7 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
{
|
||||
FwBuildDate = fwBuildDate;
|
||||
}
|
||||
if (RequestProtocol.GetMeterSize_mm(out var meterSize_mm))
|
||||
if (RequestProtocol.GetDn_mm(out var meterSize_mm))
|
||||
{
|
||||
MeterSize_mm = meterSize_mm;
|
||||
}
|
||||
@@ -1071,27 +1072,33 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxCore
|
||||
{
|
||||
LogManager.Flush();
|
||||
}
|
||||
// the id is a combination of UniqueId stored in PcbId and SensorSN (SensorId)
|
||||
var id = !string.IsNullOrEmpty(PcbId) ? $"PCBID{PcbId}" : "_";
|
||||
id += !string.IsNullOrEmpty(SerialNumber) ? $"_SN{SerialNumber}" : "_";
|
||||
var fileName = $"SLOT{Slot}_{id}";
|
||||
|
||||
if (string.IsNullOrEmpty(CurrentActionText))
|
||||
{
|
||||
_logger = NLogHelper.CreateOrGetMultiLogger($"Slot:{Slot}", $"", "Meter", "MeterBase", "MeterBase");
|
||||
if (RequestProtocol != null)
|
||||
{
|
||||
var path = NLogHelper.GetPath(_logger);
|
||||
RequestProtocol.SetLogLocation(path);
|
||||
var pathName = NLogHelper.GetPath(_logger);
|
||||
var path = Path.GetDirectoryName(pathName);
|
||||
RequestProtocol.SetLogLocation(path, fileName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var id = !string.IsNullOrEmpty(SerialNumber) ? $"SN{SerialNumber}" : $"PCB{PcbId}";
|
||||
|
||||
_logger = NLogHelper.CreateOrGetMultiLogger($"Slot:{Slot}_{id}_{CurrentActionText}", $"Slot", "Meter", "MeterBase", "MeterBase");
|
||||
_logger = NLogHelper.CreateOrGetMultiLogger($"Slot:{Slot}_{id}_{CurrentActionText}", "Slot", "Meter", "MeterBase", "MeterBase");
|
||||
if (RequestProtocol != null)
|
||||
{
|
||||
var path = NLogHelper.GetPath(_logger);
|
||||
RequestProtocol.SetLogLocation(path);
|
||||
var pathName = NLogHelper.GetPath(_logger);
|
||||
var path = Path.GetDirectoryName(pathName);
|
||||
RequestProtocol.SetLogLocation(path, fileName);
|
||||
}
|
||||
|
||||
if (StreamingPort != null && StreamingPort is LedSerialPort)
|
||||
//TODO check with roland
|
||||
if (StreamingPort is LedSerialPort)
|
||||
{
|
||||
var streamingIdent = $"LedRawData_Slot_{Slot}_{id}_{CurrentActionText}";
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
using System;
|
||||
using XYLEM.Device;
|
||||
using System.Collections.Generic;
|
||||
using NLog;
|
||||
using Xylem.Common.Hardware.Interfaces.Ports.PortCore.EventArguments;
|
||||
using Xylem.Common.Hardware.Interfaces.Protocols.ProtocolCore;
|
||||
using Xylem.Common.Hardware.Interfaces.Protocols.ProtocolCore.EventArguments;
|
||||
using Xylem.Common.Utils.Logging;
|
||||
using XYLEM.Device;
|
||||
|
||||
|
||||
namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
@@ -12,25 +13,28 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
/// <summary>
|
||||
/// Wrapper for MagFlux request protocol implemented in <see cref="IMagFluxRequestProtocol"/>
|
||||
/// </summary>
|
||||
public class RequestProtocol : BaseProtocol
|
||||
public class RequestProtocol : BaseProtocol, IMagFluxRequestProtocol
|
||||
{
|
||||
private readonly String _ident;
|
||||
private readonly ILogger _logger;
|
||||
private IMagFluxRequestProtocol _magFluxProtocol;
|
||||
private IMagFluxRequestProtocol _magFluxRequestProtocol;
|
||||
|
||||
/// <inheritdoc />
|
||||
public Int32 CalibrationPointsMax { get; } = 11;
|
||||
|
||||
/// <inheritdoc />
|
||||
public RequestProtocol(String ident) : base(ident)
|
||||
{
|
||||
_ident = ident;
|
||||
_magFluxProtocol = new MagFlux6200();
|
||||
_logger = NLogHelper.CreateOrGetMultiLogger(ident, "", "RequestProtocol", "MeterBase", "MeterBase");
|
||||
_magFluxRequestProtocol = new MagFlux6200();
|
||||
_logger = NLogHelper.CreateOrGetMultiLogger(_ident, "", "RequestProtocol", "MeterBase", "MeterBase");
|
||||
}
|
||||
|
||||
/// <inheritdoc/>>
|
||||
public override void Dispose()
|
||||
{
|
||||
_magFluxProtocol?.CloseConnection();
|
||||
_magFluxProtocol = null;
|
||||
_magFluxRequestProtocol?.CloseConnection();
|
||||
_magFluxRequestProtocol = null;
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
@@ -42,9 +46,26 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
|
||||
public override void DecodeRecord(IPortDataEventArgs data)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Wrapper to connect MagFlux
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2023-Mai-04" author="T.Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
public Boolean IsConnected()
|
||||
{
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
var retVal = _magFluxRequestProtocol.IsConnected();
|
||||
_logger.Debug(retVal ? $"{_ident} Connection established: true" : $"{_ident} Connection check request failed!");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Wrapper to connect MagFlux
|
||||
/// </summary>
|
||||
@@ -55,96 +76,45 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
/// </remarks>
|
||||
public Boolean Connect(String portName)
|
||||
{
|
||||
if (_magFluxProtocol == null) return false;
|
||||
var retVal = _magFluxProtocol.Connect(portName);
|
||||
return retVal;
|
||||
}
|
||||
/// <summary>
|
||||
/// Wrapper to set the log location for MagFlux direct raw output
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2023-Mai-04" author="T.Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
public Boolean SetLogLocation(String path)
|
||||
{
|
||||
if (_magFluxProtocol == null) return false;
|
||||
var retVal = _magFluxProtocol.SetLogLocation(path);
|
||||
return retVal;
|
||||
}
|
||||
/// <summary>
|
||||
/// Wrapper to close the connection to the MagFlux
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2023-Mai-04" author="T.Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
public Boolean CloseConnection()
|
||||
{
|
||||
if (_magFluxProtocol == null) return false;
|
||||
var retVal = _magFluxProtocol.CloseConnection();
|
||||
return retVal;
|
||||
}
|
||||
/// <summary>
|
||||
/// Wrapper to connect MagFlux
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2023-Mai-04" author="T.Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
public Boolean IsConnected()
|
||||
{
|
||||
if (_magFluxProtocol == null) return false;
|
||||
var retVal = _magFluxProtocol.IsConnected();
|
||||
return retVal;
|
||||
}
|
||||
/// <summary>
|
||||
/// Wrapper to get FW version of MagFlux
|
||||
/// </summary>
|
||||
/// <param name="fwVersion"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2023-Mai-04" author="T.Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
public Boolean GetFwVersion(out String fwVersion)
|
||||
{
|
||||
fwVersion = "?";
|
||||
if (_magFluxProtocol == null) return false;
|
||||
var retVal = _magFluxProtocol.GetFirmwareVersion(out fwVersion);
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
var retVal = _magFluxRequestProtocol.Connect(portName);
|
||||
_logger.Debug(retVal ? $"{_ident} Connection established to {portName}" :
|
||||
$"{_ident} Connection to {portName} failed!");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public String GetComCounters()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Wrapper to get FW GIT hash of MagFlux
|
||||
/// Wrapper to set the log location for MagFlux direct raw output
|
||||
/// </summary>
|
||||
/// <param name="fwGitHash"></param>
|
||||
/// <param name="path">location of raw logging</param>
|
||||
/// <param name="fileName">file name based on the UniqueId</param>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2023-Mai-04" author="T.Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
public Boolean GetFwGitHash(out String fwGitHash)
|
||||
public Boolean SetLogLocation(String path, String fileName)
|
||||
{
|
||||
fwGitHash = "?";
|
||||
if (_magFluxProtocol == null) return false;
|
||||
var retVal = _magFluxProtocol.GetFwGitHash(out fwGitHash);
|
||||
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}" : $"{_ident} Logging path setup failed!");
|
||||
return retVal;
|
||||
}
|
||||
/// <summary>
|
||||
/// Wrapper to get FW Build Date
|
||||
/// </summary>
|
||||
/// <param name="fwBuildDate"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2023-Mai-04" author="T.Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
public Boolean GetFwBuildDate(out String fwBuildDate)
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OpenLogFile()
|
||||
{
|
||||
fwBuildDate = "?";
|
||||
if (_magFluxProtocol == null) return false;
|
||||
var retVal = _magFluxProtocol.GetFwBuildDate(out fwBuildDate);
|
||||
return retVal;
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
///<inheritdoc/>
|
||||
/// <summary>
|
||||
/// Wrapper to get the sensor serial number
|
||||
/// </summary>
|
||||
@@ -156,10 +126,12 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
public Boolean GetSensorSerialNo(out String serialNumber)
|
||||
{
|
||||
serialNumber = "?";
|
||||
if (_magFluxProtocol == null) return false;
|
||||
var retVal = _magFluxProtocol.GetSensorSerialNo(out serialNumber);
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
var retVal = _magFluxRequestProtocol.GetSensorSerialNo(out serialNumber);
|
||||
_logger.Debug(retVal ? $"{_ident} SensorId: {serialNumber}" : $"{_ident} SensorId request failed!");
|
||||
return retVal;
|
||||
}
|
||||
///<inheritdoc/>
|
||||
/// <summary>
|
||||
/// Wrapper to get unique id referenced as PCBID
|
||||
/// </summary>
|
||||
@@ -171,10 +143,72 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
public Boolean GetUniqueId(out String pcbId)
|
||||
{
|
||||
pcbId = "?";
|
||||
if (_magFluxProtocol == null) return false;
|
||||
var retVal = _magFluxProtocol.GetUniqueId(out pcbId);
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
var retVal = _magFluxRequestProtocol.GetUniqueId(out pcbId);
|
||||
_logger.Debug(retVal ? $"{_ident} UniqueId: {pcbId}" : $"{_ident} UniqueId request failed!");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
///<inheritdoc/>
|
||||
/// <summary>
|
||||
/// Wrapper to get FW version of MagFlux
|
||||
/// </summary>
|
||||
/// <param name="fwVersion"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2023-Mai-04" author="T.Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
public Boolean GetFirmwareVersion(out String fwVersion)
|
||||
{
|
||||
fwVersion = "?";
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
var retVal = _magFluxRequestProtocol.GetFirmwareVersion(out fwVersion);
|
||||
_logger.Debug(retVal ? $"{_ident} FW Version: {fwVersion}" : $"{_ident} FW Version request failed!");
|
||||
return retVal;
|
||||
}
|
||||
///<inheritdoc/>
|
||||
/// <summary>
|
||||
/// Wrapper to get FW Build Date
|
||||
/// </summary>
|
||||
/// <param name="fwBuildDate"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2023-Mai-04" author="T.Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
public Boolean GetFwBuildDate(out String fwBuildDate)
|
||||
{
|
||||
fwBuildDate = "?";
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
var retVal = _magFluxRequestProtocol.GetFwBuildDate(out fwBuildDate);
|
||||
_logger.Debug(retVal ? $"{_ident} FW Build Date: {fwBuildDate}" : $"{_ident} FW Build Date request failed!");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
///<inheritdoc/>
|
||||
/// <summary>
|
||||
/// Wrapper to get FW GIT hash of MagFlux
|
||||
/// </summary>
|
||||
/// <param name="fwGitHash"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2023-Mai-04" author="T.Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
public Boolean GetFwGitHash(out String fwGitHash)
|
||||
{
|
||||
fwGitHash = "?";
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
var retVal = _magFluxRequestProtocol.GetFwGitHash(out fwGitHash);
|
||||
_logger.Debug(retVal ? $"{_ident} FW GIT Hash: {fwGitHash}" : $"{_ident} FW GIT Hash request failed!");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Boolean GetFlowRate_lps(out Single value_out)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
///<inheritdoc/>
|
||||
/// <summary>
|
||||
/// Wrapper to get meter size in mm
|
||||
/// </summary>
|
||||
@@ -183,11 +217,76 @@ namespace Xylem.Common.Hardware.WaterMeter.MagFlux.Protocols.RequestProtocol
|
||||
/// <remarks date="2023-Mai-04" author="T.Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
public Boolean GetMeterSize_mm(out Int32 meterSize)
|
||||
public Boolean GetDn_mm(out Int32 meterSize)
|
||||
{
|
||||
meterSize = 0;
|
||||
if (_magFluxProtocol == null) return false;
|
||||
var retVal = _magFluxProtocol.GetDn_mm(out meterSize);
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
var retVal = _magFluxRequestProtocol.GetDn_mm(out meterSize);
|
||||
_logger.Debug(retVal ? $"{_ident} MeterSize DN: {meterSize}" : $"{_ident} MeterSize request failed!");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Boolean GetDeviceHealthy()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Boolean GetDeviceErrorMessages(out List<String> status_list_out)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Boolean PrepareDeviceForCalibration()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Boolean AbortDeviceForCalibration()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Wrapper to get the calibration points from MagFlux
|
||||
/// </summary>
|
||||
/// <param name="calibPoints"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2023-Mai-17" author="T.Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
public Boolean GetCalibrationPoints(out CalibrationPoints calibPoints)
|
||||
{
|
||||
calibPoints = null;
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
var retVal = _magFluxRequestProtocol.GetCalibrationPoints(out calibPoints);
|
||||
_logger.Debug(retVal ? $"{_ident} Calibration successfully read from MagFlux" :
|
||||
$"{_ident} Calibration read failed!");
|
||||
return retVal;
|
||||
}
|
||||
/// <inheritdoc />
|
||||
public Boolean SetCalibrationPoints(CalibrationPoints new_calibration_points)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Wrapper to close the connection to the MagFlux
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2023-Mai-04" author="T.Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
public Boolean CloseConnection()
|
||||
{
|
||||
if (_magFluxRequestProtocol == null) return false;
|
||||
var retVal = _magFluxRequestProtocol.CloseConnection();
|
||||
_logger.Debug(retVal ? $"{_ident} Connection closed" : $"{_ident} Close connection request failed!");
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user