MagFlux: - state definitions and base functions
This commit is contained in:
@@ -155,7 +155,7 @@
|
|||||||
</site>
|
</site>
|
||||||
<site name="MeterProcessState" id="2">
|
<site name="MeterProcessState" id="2">
|
||||||
<application path="/" applicationPool="Clr4IntegratedAppPool">
|
<application path="/" applicationPool="Clr4IntegratedAppPool">
|
||||||
<virtualDirectory path="/" physicalPath="C:\Users\SZLATEV\source\repos\laa_production\Common\Service\MeterProcessState" />
|
<virtualDirectory path="/" physicalPath="D:\Projekte\SENSUS_GitLab\laa_production\Common\Service\MeterProcessState" />
|
||||||
</application>
|
</application>
|
||||||
<bindings>
|
<bindings>
|
||||||
<binding protocol="http" bindingInformation="*:56011:localhost" />
|
<binding protocol="http" bindingInformation="*:56011:localhost" />
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
namespace Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// State of MagFlux device 32 bits, bit encoded,
|
||||||
|
/// those bits can be used as mask to find a combination of states
|
||||||
|
/// </summary>
|
||||||
|
internal enum State
|
||||||
|
{
|
||||||
|
Okay = 0x00000000,
|
||||||
|
ReverseFlow = 0x00000001,
|
||||||
|
LowFlow = 0x00000002,
|
||||||
|
SampleTimeError = 0x00000004,
|
||||||
|
FlowSuspended = 0x00000008,
|
||||||
|
FlowApproximated = 0x00000010,
|
||||||
|
FlowOutOfRange = 0x00000020,
|
||||||
|
FlowNewStart = 0x00000040,
|
||||||
|
TemperatureOutOfRange = 0x00000080,
|
||||||
|
EmptyPipe = 0x00000100,
|
||||||
|
DisconnectedOrHwFault = 0x00000200
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Concatenation for al states:
|
||||||
|
/// - state,
|
||||||
|
/// - state information to display a text message.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks date="2023-Jun-02" author="Thomas Wiedebusch">
|
||||||
|
/// - Initial
|
||||||
|
/// </remarks>
|
||||||
|
class StateDef
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Collection of state information
|
||||||
|
/// </summary>
|
||||||
|
private static readonly List<StateStruct> _stateContainer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ctor
|
||||||
|
/// - Setup state and state informal text,
|
||||||
|
/// - Setup ProductionProcessFunctions, if these are null, it is just a state without any predefined function
|
||||||
|
/// </summary>
|
||||||
|
static StateDef()
|
||||||
|
{
|
||||||
|
_stateContainer = new List<StateStruct>
|
||||||
|
{
|
||||||
|
new StateStruct(State.Okay, "Good"),
|
||||||
|
new StateStruct(State.ReverseFlow, "Reverse flow detected"),
|
||||||
|
new StateStruct(State.LowFlow, "Low flow rate"),
|
||||||
|
new StateStruct(State.SampleTimeError, "Sample time error"),
|
||||||
|
new StateStruct(State.FlowSuspended, "Flow suspended"),
|
||||||
|
new StateStruct(State.FlowApproximated, "Flow approximated"),
|
||||||
|
new StateStruct(State.FlowOutOfRange, "Flow out of range"),
|
||||||
|
new StateStruct(State.FlowNewStart, "Flow new start"),
|
||||||
|
new StateStruct(State.TemperatureOutOfRange, "Temperature out of range"),
|
||||||
|
new StateStruct(State.EmptyPipe, "Empty pipe detected"),
|
||||||
|
new StateStruct(State.DisconnectedOrHwFault, "HW fault or disconnected")
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Get the information of all states set in mask
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="stateMask">state mask to search for information texts</param>
|
||||||
|
/// <returns>information attached to state mask</returns>
|
||||||
|
/// <remarks date="2023-Jun-02" author="Thomas Wiedebusch">
|
||||||
|
/// - Initial
|
||||||
|
/// </remarks>
|
||||||
|
public String GetStateInfosOfStateMask(UInt32 stateMask)
|
||||||
|
{
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
sb.Append("Device State:\n");
|
||||||
|
|
||||||
|
// if state is okay return immediately
|
||||||
|
if (stateMask == (UInt32)State.Okay)
|
||||||
|
{
|
||||||
|
sb.Append(GetStateInfoOfState(State.Okay)).Append("\n");
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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");
|
||||||
|
}
|
||||||
|
return sb.ToString();
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Get the current information
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="state">state to search for information text</param>
|
||||||
|
/// <returns>information attached to state depending on region</returns>
|
||||||
|
/// <remarks date="2023-Jun-02" author="Thomas Wiedebusch">
|
||||||
|
/// - Initial
|
||||||
|
/// </remarks>
|
||||||
|
public String GetStateInfoOfState(State state)
|
||||||
|
{
|
||||||
|
return (from stateContainer in _stateContainer
|
||||||
|
where stateContainer.State == state
|
||||||
|
select stateContainer.Info).FirstOrDefault();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Get the state of the text
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text">information text to search if state is assigned</param>
|
||||||
|
/// <returns>state attached to information text</returns>
|
||||||
|
/// <remarks date="2023-Jun-02" author="Thomas Wiedebusch">
|
||||||
|
/// - Initial
|
||||||
|
/// </remarks>
|
||||||
|
public State GetStateOfInfoText(String text)
|
||||||
|
{
|
||||||
|
return (from stateContainer in _stateContainer
|
||||||
|
where stateContainer.Info == text
|
||||||
|
select stateContainer.State).FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Concatenation between final test state and text
|
||||||
|
/// </summary>
|
||||||
|
struct StateStruct
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Assign state information tas text for state
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="state">assigned state for call of this process</param>
|
||||||
|
/// <param name="info">name for process to display a message</param>
|
||||||
|
/// <remarks date="2023-Jun-02" author="Thomas Wiedebusch">
|
||||||
|
/// - Initial
|
||||||
|
/// </remarks>
|
||||||
|
public StateStruct(State state, String info)
|
||||||
|
{
|
||||||
|
State = state;
|
||||||
|
Info = info;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// The state
|
||||||
|
/// </summary>
|
||||||
|
public readonly State State;
|
||||||
|
/// <summary>
|
||||||
|
/// The info message of the state
|
||||||
|
/// </summary>
|
||||||
|
public readonly String Info;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -256,6 +256,9 @@
|
|||||||
<Compile Include="BatchActions\BatchCallStopCalibration.cs" />
|
<Compile Include="BatchActions\BatchCallStopCalibration.cs" />
|
||||||
<Compile Include="BatchActions\BatchCallStopMeasurement.cs" />
|
<Compile Include="BatchActions\BatchCallStopMeasurement.cs" />
|
||||||
<Compile Include="Consts\DisplayCodes.cs" />
|
<Compile Include="Consts\DisplayCodes.cs" />
|
||||||
|
<Compile Include="Consts\State.cs" />
|
||||||
|
<Compile Include="Consts\StateDef.cs" />
|
||||||
|
<Compile Include="Consts\StateStruct.cs" />
|
||||||
<Compile Include="DataPackages\FlowDeviations.cs" />
|
<Compile Include="DataPackages\FlowDeviations.cs" />
|
||||||
<Compile Include="IMeterBatch.cs" />
|
<Compile Include="IMeterBatch.cs" />
|
||||||
<Compile Include="MeterBatch.cs" />
|
<Compile Include="MeterBatch.cs" />
|
||||||
|
|||||||
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.4.0.0")]
|
[assembly: AssemblyVersion("1.5.0.0")]
|
||||||
[assembly: AssemblyFileVersion("1.4.0.0")]
|
[assembly: AssemblyFileVersion("1.5.0.0")]
|
||||||
|
|||||||
Reference in New Issue
Block a user