FM2014: - extended
This commit is contained in:
parent
c9973301f2
commit
567c04d98f
@ -35,11 +35,10 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO.Ports;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core.Consts;
|
||||
using Xylem.Common.CommonCore.Consts;
|
||||
using Xylem.Common.Hardware.Interfaces.Ports.PortCore.EventArguments;
|
||||
using Xylem.Common.Utils.ProcessExec.EventArguments;
|
||||
|
||||
|
||||
namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
@ -50,12 +49,12 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
{
|
||||
#region events
|
||||
/// <inheritdoc />
|
||||
public virtual event EventHandler<StringPortDataEventArgs> OnRawRecordReceived;
|
||||
public virtual event EventHandler<ProcessExecEventArgs> OnRawRecordReceived;
|
||||
#endregion
|
||||
|
||||
#region properties
|
||||
|
||||
const Char _eos = FM2014CmdDef.END_OF_STRING;
|
||||
private const Char _eos = FM2014CmdDef.END_OF_STRING;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Boolean ReceiveTaskIsActive
|
||||
@ -94,7 +93,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Int32? Address
|
||||
public Int32 Address
|
||||
{
|
||||
get;
|
||||
set;
|
||||
@ -156,6 +155,30 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Number of processing steps for this actual process progress
|
||||
/// </summary>
|
||||
private Int32 MaxActualProcessProgress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Progress of actual process
|
||||
/// </summary>
|
||||
private Int32 _actualProcessProgress;
|
||||
/// <summary>
|
||||
/// Actual process progress of subroutine
|
||||
/// </summary>
|
||||
private Int32 ActualProcessProgress
|
||||
{
|
||||
get => _actualProcessProgress;
|
||||
set
|
||||
{
|
||||
_actualProcessProgress = value;
|
||||
if (_actualProcessProgress > MaxActualProcessProgress)
|
||||
_actualProcessProgress = MaxActualProcessProgress;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region methods
|
||||
@ -189,6 +212,9 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
/// - Manual input of volume.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2026-Jan-10" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
public Boolean ManualRefCalibration()
|
||||
{
|
||||
if (SerialPort == null || !SerialPort.IsOpen)
|
||||
@ -218,6 +244,8 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
// Measurement Loop
|
||||
Task.Run(() =>
|
||||
{
|
||||
// Get the process information
|
||||
var info = FM2014CmdDef.GetCmdInfo(FM2014CmdDef.CmdDef.CMD_REF_GET_PLS_CTR);
|
||||
var cmdCode = FM2014CmdDef.GetCmdChar(FM2014CmdDef.CmdDef.CMD_REF_GET_PLS_CTR);
|
||||
do
|
||||
{
|
||||
@ -227,7 +255,11 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
var refPulseStr = SerialPort.ReadTo($"{_eos}");
|
||||
|
||||
if (int.TryParse(refPulseStr, NumberStyles.HexNumber, new CultureInfo("en"), out var refPulses))
|
||||
OnRawRecordReceived?.Invoke(this, new StringPortDataEventArgs($"{refPulses:D}"));
|
||||
{
|
||||
var response = new FM2014CmdDef.CmdResponse(FM2014CmdDef.CmdDef.CMD_REF_GET_PLS_CTR, "",
|
||||
refPulses);
|
||||
OnRawRecordReceived?.Invoke(this, new ProcessExecEventArgs(info, specificInfoObj: response));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -241,7 +273,14 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Login to individual address.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <inheritdoc/>
|
||||
/// <remarks date="2026-Jan-08" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
public Boolean Login()
|
||||
{
|
||||
if (SerialPort == null)
|
||||
|
||||
@ -314,6 +314,10 @@
|
||||
<Project>{1B02C79E-0B19-43E2-8F6B-71EF0C786C97}</Project>
|
||||
<Name>CommonCore</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\..\..\Utils\ProcessExec\ProcessExec.csproj">
|
||||
<Project>{2FD60CF1-45CD-4060-B8E5-4F39FBA7F1CB}</Project>
|
||||
<Name>ProcessExec</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\..\Interfaces\Ports\PortCore\PortCore.csproj">
|
||||
<Project>{2e139f63-b6fe-4ea9-a098-85364fe9b26c}</Project>
|
||||
<Name>PortCore</Name>
|
||||
|
||||
@ -35,7 +35,7 @@ using System;
|
||||
using System.IO.Ports;
|
||||
//using NLog;
|
||||
using Xylem.Common.CommonCore.Consts;
|
||||
using Xylem.Common.Hardware.Interfaces.Ports.PortCore.EventArguments;
|
||||
using Xylem.Common.Utils.ProcessExec.EventArguments;
|
||||
|
||||
namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
{
|
||||
@ -51,7 +51,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
/// <summary>
|
||||
/// String data feedback
|
||||
/// </summary>
|
||||
event EventHandler<StringPortDataEventArgs> OnRawRecordReceived;
|
||||
event EventHandler<ProcessExecEventArgs> OnRawRecordReceived;
|
||||
#endregion
|
||||
|
||||
#region properties
|
||||
@ -89,7 +89,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
/// <summary>
|
||||
/// FM2014 address string
|
||||
/// </summary>
|
||||
Int32? Address
|
||||
Int32 Address
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
@ -44,7 +44,8 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Xylem.Common.Hardware.Interfaces.Ports.PortCore.EventArguments;
|
||||
using Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core.Consts;
|
||||
using Xylem.Common.Utils.ProcessExec.EventArguments;
|
||||
|
||||
namespace Sensus.MiniPrf.Ui
|
||||
{
|
||||
@ -430,10 +431,6 @@ namespace Sensus.MiniPrf.Ui
|
||||
}
|
||||
}
|
||||
|
||||
private void _fm2014_OnRawRecordReceived(Object sender, StringPortDataEventArgs e)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion BoardControls
|
||||
|
||||
#region ProcessControls
|
||||
@ -652,9 +649,12 @@ namespace Sensus.MiniPrf.Ui
|
||||
|
||||
#region Event handler
|
||||
|
||||
private void DataReceived_Handler(Object sender, BasePortDataEventArgs e)
|
||||
private void DataReceived_Handler(Object sender, ProcessExecEventArgs e)
|
||||
{
|
||||
LogText(e.GetData().ToString());
|
||||
|
||||
var resp = (FM2014CmdDef.CmdResponse)e.SpecificInfoObj;
|
||||
if (resp.IntValue != null)
|
||||
LogText(resp.IntValue.ToString());
|
||||
|
||||
// Return to standby
|
||||
if (!_fm2014.ReceiveTaskIsActive)
|
||||
|
||||
@ -125,6 +125,10 @@
|
||||
<Project>{4B88B0D3-E791-4774-9521-EABEACDC420E}</Project>
|
||||
<Name>Logging</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Common\Utils\ProcessExec\ProcessExec.csproj">
|
||||
<Project>{2FD60CF1-45CD-4060-B8E5-4F39FBA7F1CB}</Project>
|
||||
<Name>ProcessExec</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user