IGenesisMeter, new GenesisStatus
This commit is contained in:
@@ -55,6 +55,7 @@
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=PCBID/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=perc/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=PERIODICLOG/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=POWERMON/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Preadjustment/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=prot/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=restorable/@EntryIndexedValue">True</s:Boolean>
|
||||
|
||||
@@ -9,7 +9,10 @@ namespace Xylem.Common.CommonCore.Configuration
|
||||
/// </summary>
|
||||
public static class ServiceUrls
|
||||
{
|
||||
|
||||
|
||||
private const String DefaultInspectCordonelRequirementInfoUrl =
|
||||
"http://sla12iis01.emea.sensus.net/LaaProductionWeb/";
|
||||
|
||||
// return code: 404 not found, 400 Error with text, 200 okay
|
||||
private const String DefaultEolDataForSentinelServiceUrl =
|
||||
"http://sla12iis01.emea.sensus.net/LaaProductionWeb/api/cordonel/eolprogress/";
|
||||
@@ -143,6 +146,9 @@ namespace Xylem.Common.CommonCore.Configuration
|
||||
private const String DefaultGenesisCalibrationResult =
|
||||
"http://sla12iis01.emea.sensus.net/MeterProcessState/api/GenesisMeter/PostCalibrationResult";
|
||||
|
||||
private const String DefaultGetGenesisCalibrationResults =
|
||||
"http://sla12iis01.emea.sensus.net/MeterProcessState/api/FinalCheck/CalibrationResults/";
|
||||
|
||||
private const String DefaultGenesisMeter =
|
||||
"http://sla12iis01.emea.sensus.net/MeterProcessState/api/GenesisMeter/";
|
||||
|
||||
@@ -390,6 +396,16 @@ namespace Xylem.Common.CommonCore.Configuration
|
||||
DefaultSetCordonelAppVersionServiceUrl;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inspect a specific requirement (read only).
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static String InspectCordonelRequirementInfoServiceUrl()
|
||||
{
|
||||
return ConfigurationManager.AppSettings["InspectCordonelRequirementInfoServiceUrl"] ??
|
||||
DefaultInspectCordonelRequirementInfoUrl;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all production infos for skip process checks or limits for production like:
|
||||
/// - Battery drained percentage upper limit,
|
||||
@@ -716,6 +732,16 @@ namespace Xylem.Common.CommonCore.Configuration
|
||||
DefaultGetSoftwareStartUpAccessUrl;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Genesis calibration results for final check if those have been correctly set
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static String GetGenesisCalibrationResultsUrl()
|
||||
{
|
||||
return ConfigurationManager.AppSettings["GetGenesisCalibrationResults"] ??
|
||||
DefaultGetGenesisCalibrationResults;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Post Genesis calibration results
|
||||
/// </summary>
|
||||
|
||||
@@ -198,6 +198,10 @@
|
||||
<Project>{9EB1F659-6F73-4F65-BCAB-4114FD94F5FC}</Project>
|
||||
<Name>CommonCore.Configuration</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\CommonCore\CommonCore.csproj">
|
||||
<Project>{1B02C79E-0B19-43E2-8F6B-71EF0C786C97}</Project>
|
||||
<Name>CommonCore</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Hardware\WaterMeter\Genesis\Applications\Applications.csproj">
|
||||
<Project>{315E94B8-B82F-4B25-B5BD-297DF3BC1D54}</Project>
|
||||
<Name>Applications</Name>
|
||||
|
||||
@@ -588,7 +588,7 @@ namespace CordonelAssemblyLine.Model
|
||||
var genesisStatus = new GenesisStatus();
|
||||
|
||||
// this calculates all life time values
|
||||
if (!GenesisStatusHandler.BuildLifeTimeInformation(meter, genesisStatus))
|
||||
if (!GenesisStatusHandler.BuildLifeTimeInformation(meter, genesisStatus, out _))
|
||||
{
|
||||
meter.WriteLog("Batterie nicht lesbar");
|
||||
lblS08Text = "Batterie nicht lesbar";
|
||||
|
||||
@@ -228,8 +228,10 @@
|
||||
<Compile Include="..\..\..\..\.shared\SharedAssemblyInfo.cs">
|
||||
<Link>Properties\SharedAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Consts\Alarm.cs" />
|
||||
<Compile Include="Consts\PowCorrConst.cs" />
|
||||
<Compile Include="Consts\MetrologyDefinition.cs" />
|
||||
<Compile Include="IGenesisMeter.cs" />
|
||||
<Compile Include="PowerCorrectionCalc.cs" />
|
||||
<Compile Include="PowerCorrection.cs" />
|
||||
<Compile Include="Consts\ErrorState.cs" />
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,231 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Xylem.Common.CommonCore.Consts;
|
||||
using Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.Applications;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisConfig;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.Consts;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
|
||||
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore;
|
||||
|
||||
namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface of special GenesisMeter derived from IMeter
|
||||
/// </summary>
|
||||
public interface IGenesisMeter : IMeter
|
||||
{
|
||||
#region properties
|
||||
/// <summary>
|
||||
/// Represent <see cref="Register.Configexchange.PcbSerialNumber" />
|
||||
/// proposed for login
|
||||
/// </summary>
|
||||
String PcbId
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transmit protocol access for underlie objects to change response timeout
|
||||
/// </summary>
|
||||
ITransmitProtocol TransmitProtocol{ get; }
|
||||
|
||||
/// <summary>
|
||||
/// List of all present meter applications installed in meter
|
||||
/// </summary>
|
||||
List<MeterApplications> MeterAppListVersion
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Successfully logged on to meter
|
||||
/// </summary>
|
||||
Boolean IsLoggedOn
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Core revision of boot code.
|
||||
/// </summary>
|
||||
Int32? CoreRevision
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Core revision of boot code as string.
|
||||
/// </summary>
|
||||
String StrCoreRevision
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is the FLEXNETVERSION version which describes the entire packet.
|
||||
/// </summary>
|
||||
String FwVersion
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is the FLEXNETVERSION version which describes the entire packet.
|
||||
/// </summary>
|
||||
UInt32? InstalledFwVersion
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is the Metrology Lookup Table CRC.
|
||||
/// </summary>
|
||||
String LutCrc
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is the meter size.
|
||||
/// </summary>
|
||||
String MeterSize
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Region (EMEA, NA or China).
|
||||
/// </summary>
|
||||
String Region
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Radio frequency in MHz (433 or 868 or null).
|
||||
/// </summary>
|
||||
Int32? RadioFrequencyMhz
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Metrology upgrade permission.
|
||||
/// </summary>
|
||||
Byte MetrologyUpgradePermission
|
||||
{
|
||||
set; get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Order number under which this meter has to be produced
|
||||
/// </summary>
|
||||
Int32 OrderNumber
|
||||
{
|
||||
set; get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Radio address
|
||||
/// </summary>
|
||||
Int64 RadioAddress
|
||||
{
|
||||
set; get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process configuration
|
||||
/// </summary>
|
||||
ProcessConfig Configuration
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Customer serial number for informal issues
|
||||
/// </summary>
|
||||
String CustomerSerialNumber
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region methods
|
||||
|
||||
/// <summary>
|
||||
/// Check region and size.
|
||||
/// After reading the version, all valid registers are going to be selected.
|
||||
/// </summary>
|
||||
void CheckRegionSizeLutCrc();
|
||||
|
||||
/// <summary>
|
||||
/// Reset the empty pipe alarm
|
||||
/// </summary>
|
||||
void ResetAlarm(Alarm clear);
|
||||
|
||||
/// <summary>
|
||||
/// Upload app list to database
|
||||
/// </summary>
|
||||
/// <param name="progressName"></param>
|
||||
/// <param name="version"></param>
|
||||
/// <returns></returns>
|
||||
StatusReturn PushProgress(String progressName, String version);
|
||||
|
||||
/// <summary>
|
||||
/// Clear password to force new password reading
|
||||
/// </summary>
|
||||
void ClearPassword();
|
||||
|
||||
/// <summary>
|
||||
/// Executes all StoreConfiguration and StoreCalibration for each application.
|
||||
/// </summary>
|
||||
/// <returns>true if all configurations are stored</returns>
|
||||
Boolean StoreAllConfigurations();
|
||||
|
||||
/// <summary>
|
||||
/// Login with identical password as last time to avoid get password from database
|
||||
/// </summary>
|
||||
Boolean ReLogin();
|
||||
|
||||
/// <summary>
|
||||
/// Returns meter registers
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
MeterRegisters GetConfigRegistersDefinitions();
|
||||
|
||||
/// <summary>
|
||||
/// Common routine for reboot being able to override this routine which will be called in
|
||||
/// MeteResetPsu to simulate a reboot.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
StatusReturn RebootGenesis();
|
||||
|
||||
/// <summary>
|
||||
/// Write Register, optional: wait for result and validate,
|
||||
/// write register will ALWAYS log the data DON'T use for password write
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Data type of Register</typeparam>
|
||||
/// <param name="regName">Register name</param>
|
||||
/// <param name="value">Value to save as byte array in raw format</param>
|
||||
/// <param name="waitForResult">wait until result is ready</param>
|
||||
/// <param name="checkRegister">check the content of the register by read back</param>
|
||||
/// <param name="skipRetryErrorCode">skip retries on this error code return</param>
|
||||
/// <returns>true on successful operation</returns>
|
||||
Boolean WriteRegister<T>(String regName, T value, Boolean waitForResult = true,
|
||||
Boolean checkRegister = false, UInt16 skipRetryErrorCode = CommunicationConfig.SkipRetryErrorCode);
|
||||
|
||||
/// <summary>
|
||||
/// Read Register and return byte array
|
||||
/// </summary>
|
||||
/// <param name="regName">Register name</param>
|
||||
/// <param name="expectedLength">expected length for response</param>
|
||||
/// <param name="skipRetryErrorCode">skip retries on this error code return</param>
|
||||
/// <returns>value as byte array in raw format or null</returns>
|
||||
Byte[] ReadRegister(String regName, Int32? expectedLength = null,
|
||||
UInt16 skipRetryErrorCode = CommunicationConfig.SkipRetryErrorCode);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using Xylem.Common.Hardware.WaterMeter.Genesis.DataPackages.MeasurementRecords;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisConfig.Const;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
|
||||
using Xylem.Common.Logic.ProductionOrderCore.TestResults;
|
||||
using Xylem.Common.Logic.SoftwareAccessHelper;
|
||||
using Xylem.Common.Metrology.Measurements;
|
||||
using Xylem.Common.Metrology.Measurements.Consts;
|
||||
|
||||
@@ -31,7 +32,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
/// <inheritdoc />
|
||||
public void InitCalibration()
|
||||
{
|
||||
_logger.Info($"Slot:{Slot} - Init calibration and set calibration values of all channels to default");
|
||||
Logger.Info($"Slot:{Slot} - Init calibration and set calibration values of all channels to default");
|
||||
for (var channel = 0; channel < MeterConfig.CalibChannels; channel++)
|
||||
{
|
||||
_calibFactor[channel] = new CalibFactor(channel, _registersToStoreCalibFactor[channel]);
|
||||
@@ -84,11 +85,11 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
if (channel == 0 || channel > MeterConfig.CalibChannels)
|
||||
{
|
||||
var message = $"Slot:{Slot}, Channel:{channel} - Calibration channel out of range";
|
||||
_logger.Warn(message);
|
||||
Logger.Warn(message);
|
||||
throw new ApplicationException(message);
|
||||
}
|
||||
|
||||
_logger.Info($"Slot:{Slot}, Channel:{channel} - Calculate Calibrationfactor Relative(RefVolumeCm:{refVolumeCm}, refTimeS:{refTimeS},reqDeviationPercent:{reqDeviationPercent})");
|
||||
Logger.Info($"Slot:{Slot}, Channel:{channel} - Calculate Calibrationfactor Relative(RefVolumeCm:{refVolumeCm}, refTimeS:{refTimeS},reqDeviationPercent:{reqDeviationPercent})");
|
||||
|
||||
var calibFactorRel = calib.CalculateCalibFactorRel(refVolumeCm, refTimeS, reqDeviationPercent);
|
||||
|
||||
@@ -96,7 +97,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
if (null == calibFactorRel)
|
||||
{
|
||||
var message = $"Slot:{Slot}, Channel:{channel} - Calibration factor not calculated";
|
||||
_logger.Warn(message);
|
||||
Logger.Warn(message);
|
||||
throw new ApplicationException(message);
|
||||
}
|
||||
|
||||
@@ -104,9 +105,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
_calibFactor[channel - 1].BuildMeterCalibFactor(calibFactorRel.Value);
|
||||
_calibFactor[channel - 1].IsCalculated = true;
|
||||
|
||||
_logger.Info($"Slot:{Slot}, Channel:{channel} - New calibration factor({_calibFactor[channel - 1].GetRelativeCalibFactor()}rel/{calibFactorRel})");
|
||||
Logger.Info($"Slot:{Slot}, Channel:{channel} - New calibration factor({_calibFactor[channel - 1].GetRelativeCalibFactor()}rel/{calibFactorRel})");
|
||||
|
||||
_logger.Info($"Slot:{Slot}, Channel:{channel} - Calc /{ _calibFactor[channel - 1].GetMeterRawCalibFactor()} * {calibFactorRel.Value}) -> UInt16");
|
||||
Logger.Info($"Slot:{Slot}, Channel:{channel} - Calc /{ _calibFactor[channel - 1].GetMeterRawCalibFactor()} * {calibFactorRel.Value}) -> UInt16");
|
||||
|
||||
|
||||
//Setup the required tolerance value to check against
|
||||
@@ -123,12 +124,12 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
|
||||
var warnMessage = $"Slot:{Slot}, Channel:{channel} - " +
|
||||
$"Calibration factor is out of range({calibFactorRel.Value}rel)";
|
||||
_logger.Warn(warnMessage);
|
||||
Logger.Warn(warnMessage);
|
||||
throw new ApplicationException(warnMessage);
|
||||
}
|
||||
|
||||
|
||||
var t = new JustageResults()
|
||||
var t = new JustageResults
|
||||
{
|
||||
pcbId = PcbId,
|
||||
p1Target = reqDeviationPercent,
|
||||
@@ -144,15 +145,15 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
|
||||
try
|
||||
{
|
||||
var tmpUrl = $"http://10.49.40.25/MeterProcessState/api/TestBench/SetCalibrationValues";
|
||||
_logger.Info($"Request Url: { tmpUrl}");
|
||||
var tmpUrl = "http://10.49.40.25/MeterProcessState/api/TestBench/SetCalibrationValues";
|
||||
Logger.Info($"Request Url: { tmpUrl}");
|
||||
//ToDO: Update to service URl
|
||||
|
||||
Logic.SoftwareAccessHelper.LocalWebRequest.PostAsJson<JustageResults>(t, tmpUrl);
|
||||
LocalWebRequest.PostAsJson<JustageResults>(t, tmpUrl);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error($"Request Url: { ex.Message}");
|
||||
Logger.Error($"Request Url: { ex.Message}");
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +164,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
public void SetCalibFactorsAllChannels(Boolean justLog = false)
|
||||
{
|
||||
WriteRegister<Byte>(Register.Genesisflow.SampleRate, 2, checkRegister: true);
|
||||
WriteRegister<UInt16>(Register.Genesisflow.TriggerIdle, 0x1234, true);
|
||||
WriteRegister<UInt16>(Register.Genesisflow.TriggerIdle, 0x1234);
|
||||
|
||||
for (var channel = 0; channel < MeterConfig.CalibChannels; channel++)
|
||||
{
|
||||
@@ -174,14 +175,14 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
|
||||
if (justLog)
|
||||
{
|
||||
_logger.Warn($"Slot:{Slot} - Calculated calibration factors but not stored to registers");
|
||||
Logger.Warn($"Slot:{Slot} - Calculated calibration factors but not stored to registers");
|
||||
}
|
||||
else
|
||||
{
|
||||
var registerRawCalibFactor = _calibFactor[channel].GetMeterRawCalibFactor();
|
||||
var resultWrite = WriteRegister(_calibFactor[channel].RegisterToStoreCalibFactor,
|
||||
registerRawCalibFactor, checkRegister: true);
|
||||
_logger.Info($"Slot:{Slot}, Channel:{channel} - Stored calibration factor({_registersToStoreCalibFactor[channel]})");
|
||||
Logger.Info($"Slot:{Slot}, Channel:{channel} - Stored calibration factor({_registersToStoreCalibFactor[channel]})");
|
||||
|
||||
//if (!string.IsNullOrEmpty(SerialNumber) && CurrentActionText.Contains("PG"))
|
||||
//{
|
||||
@@ -198,7 +199,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
//
|
||||
if (resultWrite)
|
||||
{
|
||||
_logger.Warn($"Set calibration went wrong {_calibFactor[channel].RegisterToStoreCalibFactor}, with {registerRawCalibFactor}");
|
||||
Logger.Warn($"Set calibration went wrong {_calibFactor[channel].RegisterToStoreCalibFactor}, with {registerRawCalibFactor}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,11 +207,11 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
|
||||
WriteRegister(Register.Genesisflow.ResetAccumulators, true);
|
||||
//WriteRegister<UInt16>(Register.Genesisflow.ForwardArrow, 0, checkRegister: true);
|
||||
WriteRegister<UInt16>(Register.Genesisflow.StoreCalibration, 1, true);
|
||||
WriteRegister<UInt16>(Register.Genesisflow.StoreCalibration, 1);
|
||||
|
||||
_logger.Info($"Slot:{Slot} - StoreCalibration { RegisterConverter.ByteArrayToValue<UInt16>(ReadRegister(Register.Genesisflow.StoreCalibration))}");
|
||||
WriteRegister<UInt16>(Register.Genesisflow.TriggerActive, 1, true);
|
||||
_logger.Info($"Slot:{Slot} - Set forward arrow of LCD, reset accumulators, set sample rate to 2Hz");
|
||||
Logger.Info($"Slot:{Slot} - StoreCalibration { RegisterConverter.ByteArrayToValue<UInt16>(ReadRegister(Register.Genesisflow.StoreCalibration))}");
|
||||
WriteRegister<UInt16>(Register.Genesisflow.TriggerActive, 1);
|
||||
Logger.Info($"Slot:{Slot} - Set forward arrow of LCD, reset accumulators, set sample rate to 2Hz");
|
||||
WriteRegister<Byte>(Register.Genesisflow.SampleRate, 10, checkRegister: true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
/// </summary>
|
||||
public void InitMeasurement()
|
||||
{
|
||||
_logger.Info($"Slot:{Slot} - Init measurement");
|
||||
Logger.Info($"Slot:{Slot} - Init measurement");
|
||||
PreMeasurement();
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
displayState = ReadRegister(Register.Genesisflow.TriggerIdle);
|
||||
if (displayState == null)
|
||||
{
|
||||
_logger.Info($"Slot:{Slot} - Not able to read display state");
|
||||
Logger.Info($"Slot:{Slot} - Not able to read display state");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
measurement.OnActionStateHasChanged += Measurement_ActionStateHasChanged;
|
||||
}
|
||||
|
||||
_logger.Info($"Slot:{Slot} - Start measurement");
|
||||
Logger.Info($"Slot:{Slot} - Start measurement");
|
||||
|
||||
ProcessStatus = ProcessState.MeasurementIsActive;
|
||||
_listOfIMeasurement.ForEach(m => m.MeasurementState = MeasurementStates.IsWaitingForStartData);
|
||||
@@ -134,7 +134,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
/// <inheritdoc />
|
||||
public void StopMeasurement()
|
||||
{
|
||||
_logger.Info($"Slot:{Slot} - Stop measurement");
|
||||
Logger.Info($"Slot:{Slot} - Stop measurement");
|
||||
ProcessStatus = ProcessState.MeasurementIsDone;
|
||||
_listOfIMeasurement.ForEach(m => m.MeasurementState = MeasurementStates.IsWaitingForEndData);
|
||||
SyncStreamingBuffer(SyncMarkRecord.SyncEnd);
|
||||
@@ -199,7 +199,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
? mainMeasurement.GetIntermediateMeasurementResult(refVolume, refTimeS)
|
||||
: mainMeasurement.GetFinalMeasurementResult(refVolume, refTimeS);
|
||||
results.Add(mainResult);
|
||||
_logger.Info($"Slot:{Slot}, Channel:{mainMeasurement.GetChannel()} - MeasuredTime({mainResult.DutTimeS}s), " +
|
||||
Logger.Info($"Slot:{Slot}, Channel:{mainMeasurement.GetChannel()} - MeasuredTime({mainResult.DutTimeS}s), " +
|
||||
$"MeasuredVolume({mainResult.DutVolumeCm}Qm)");
|
||||
|
||||
foreach (var otherMeasurement in _listOfIMeasurement.Where(m => m.GetType() != typeof(FlowTestRecord)))
|
||||
@@ -209,13 +209,13 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
var otherResults = intermediateMeasurement
|
||||
? otherMeasurement.GetIntermediateMeasurementResult(refVolume, refTimeS)
|
||||
: otherMeasurement.GetFinalMeasurementResult(refVolume, refTimeS);
|
||||
_logger.Info($"Slot:{Slot}, Channel:{otherMeasurement.GetChannel()} - ChannelTime({otherResults.DutTimeS}s), " +
|
||||
Logger.Info($"Slot:{Slot}, Channel:{otherMeasurement.GetChannel()} - ChannelTime({otherResults.DutTimeS}s), " +
|
||||
$"ChannelVolume({otherResults.DutVolumeCm}Qm)");
|
||||
results.Add(otherResults);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Warn($"Slot:{Slot}, No Results for channel:{otherMeasurement.GetChannel()} Ex: {ex.Message}");
|
||||
Logger.Warn($"Slot:{Slot}, No Results for channel:{otherMeasurement.GetChannel()} Ex: {ex.Message}");
|
||||
if (channel == null)
|
||||
{
|
||||
throw new ApplicationException($"Can not read result from channel:{otherMeasurement.GetChannel() } Ex: {ex.Message}");
|
||||
@@ -261,7 +261,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
/// <inheritdoc />
|
||||
public MeasurementStates GetMeasurementState(Int32? onlyChannelNr = null)
|
||||
{
|
||||
_logger.Trace($"Slot:{Slot} - Get measurement state");
|
||||
Logger.Trace($"Slot:{Slot} - Get measurement state");
|
||||
if (!_listOfIMeasurement.Any())
|
||||
{
|
||||
return MeasurementStates.NotStarted;
|
||||
@@ -278,7 +278,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
/// <inheritdoc />
|
||||
public Boolean RequestIntermediateMeasurementState(Int32? onlyChannelNr = null)
|
||||
{
|
||||
_logger.Trace($"Slot:{Slot} - Get measurement state");
|
||||
Logger.Trace($"Slot:{Slot} - Get measurement state");
|
||||
if (!_listOfIMeasurement.Any())
|
||||
{
|
||||
return false;
|
||||
|
||||
@@ -3,96 +3,50 @@
|
||||
namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// Status of Cordonel like:
|
||||
/// - Battery drainage,
|
||||
/// - Production date of electronics,
|
||||
/// - Due date for production,
|
||||
/// - Remaining life time,
|
||||
/// - Special permissions for production capability check for
|
||||
/// - Battery Drainage in %,
|
||||
/// - Remaining Life Time in years,
|
||||
/// - Production Due Date as DateTime.
|
||||
/// Status of Cordonel calculated out of the Cordonel readouts
|
||||
/// </summary>
|
||||
public class GenesisStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// Data base primary key
|
||||
/// Average days per month based on 365.25 [Days/Year] / 12 [Months/Year] = 30.4375
|
||||
/// </summary>
|
||||
public Int32 Id { get; set; }
|
||||
public const Double DAYS_PER_MONTH = 30.4375d;
|
||||
|
||||
/// <summary>
|
||||
/// Order number
|
||||
/// Average seconds per month
|
||||
/// </summary>
|
||||
public Int32? OrderNumber { get; set; }
|
||||
public const Double SECONDS_PER_MONTH = 3600 * 24 * DAYS_PER_MONTH;
|
||||
|
||||
/// <summary>
|
||||
/// PcbId.
|
||||
/// Months from seconds
|
||||
/// </summary>
|
||||
public String PcbId { get; set; }
|
||||
public const Double MONTHS_FROM_SECONDS = 1.0d / SECONDS_PER_MONTH;
|
||||
|
||||
/// <summary>
|
||||
/// Skip radio parameter check
|
||||
/// Calculate years from seconds taking the leap year into account
|
||||
/// </summary>
|
||||
public Boolean SkipRadioParametersCheck { get; set; }
|
||||
public const Double YEARS_FROM_SECONDS = 1.0d / (3600.0 * 24.0 * 365.25);
|
||||
|
||||
/// <summary>
|
||||
/// Override FW version. Normally the FW will be assigned to the latest released version
|
||||
/// and taken from the data base. Here special versions can be used for FW tests.
|
||||
/// null means take the current released version
|
||||
/// Convert milli-ampere-hours to micro-ampere-seconds
|
||||
/// </summary>
|
||||
public Int32? OverrideFwCheck { get; set; }
|
||||
public const Double MILLI_AMPERE_HOURS_TO_MICRO_AMPERE_SECONDS = 1000.0d * 3600.0;
|
||||
|
||||
/// <summary>
|
||||
/// override the Lut version to check the look-up-table installation as this device may be used for development.
|
||||
/// null means take the current released version
|
||||
/// </summary>
|
||||
public Int32? OverrideLutCheck { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Internally used to signal that production and shipping is proved and validated.
|
||||
/// </summary>
|
||||
public Boolean ProductionAccepted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Date and time of production of electronics.
|
||||
/// </summary>
|
||||
public DateTime KitronProductionDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Last date until production has to be finished, can be extended by special permission
|
||||
/// </summary>
|
||||
public DateTime ProductionDueDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Remaining life time for Cordonel in years based on battery drainage.
|
||||
/// Remaining lifetime for Cordonel in years based on battery drainage.
|
||||
/// </summary>
|
||||
public Double RemainingLifeTimeYears { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Exceeded life time of all batteries in seconds.
|
||||
/// Exceeded lifetime of all batteries in seconds.
|
||||
/// </summary>
|
||||
public UInt64 ExceededLifeTime_s { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Required life time in years for assembly, is dependent on region and special permission.
|
||||
/// </summary>
|
||||
public Double RequiredLifeTimeYearsAssembly { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Required life time in years for shipping, is dependent on region and special permission.
|
||||
/// </summary>
|
||||
public Double RequiredLifeTimeYearsShipping { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Battery drainage in percent.
|
||||
/// </summary>
|
||||
public Double DrainedBatteryLoadPercent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Maximum drained Battery load in percent.
|
||||
/// </summary>
|
||||
public Double MaxDrainedBatteryLoadPercent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of batteries attached to Cordonel.
|
||||
/// </summary>
|
||||
@@ -103,41 +57,42 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisStatus
|
||||
/// </summary>
|
||||
public UInt64 InitialBatteryLoad_mAh { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Quiescent current used for alternative calculation of threshold for
|
||||
/// maximum remaining battery load given by Cordonel requirements.
|
||||
/// If this values and the <see cref="EstimatedProductionBatteryLoadPercent"/>
|
||||
/// is set, this has a higher priority as the normal threshold.
|
||||
/// </summary>
|
||||
public Double? QuiescentCurrent_uA { get; set; }
|
||||
|
||||
///<summary>
|
||||
///Additional allowed load for production used for alternative calculation of
|
||||
/// threshold for maximum remaining battery load given by Cordonel requirements.
|
||||
/// If this values and the <see cref="QuiescentCurrent_uA"/>
|
||||
/// is set, this has a higher priority as the normal threshold.
|
||||
/// </summary>
|
||||
public Double? EstimatedProductionBatteryLoadPercent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Drained capacity of all batteries in uAs.
|
||||
/// </summary>
|
||||
public UInt64 DrainedBatteryLoad_uAs { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Alternative calculation of required battery load in percent based on quiescent
|
||||
/// current multiplied by operational time and supplement for production.
|
||||
/// </summary>
|
||||
public Double? AlternativeRequiredBatteryLoadPercent { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Battery assembly time based on the POWERMON_TotalUsedSeconds and the current time in UTC.
|
||||
/// </summary>
|
||||
public DateTime? BatteryAssemblyDateTimeUtc { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Comment for approval and permissions reasons:
|
||||
/// e.g. "On customer requirement for test purposes the life time isn't of importance".
|
||||
/// Calculation of storage months based on assembly time and UtcNow.
|
||||
/// </summary>
|
||||
public String ApprovalComment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Name of approver for special permissions.
|
||||
/// </summary>
|
||||
public String ApproverName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Date of approval.
|
||||
/// </summary>
|
||||
public DateTime ApprovalDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Uniontown limits
|
||||
/// </summary>
|
||||
public Double UNTLimit { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Uniontown status
|
||||
/// </summary>
|
||||
public Boolean UNTStatus { get; internal set; }
|
||||
public Double EMEALimit { get; internal set; }
|
||||
public Boolean EMEAStatus { get; internal set; }
|
||||
public Double PreProductionUNTLimit { get; internal set; }
|
||||
public Boolean PreProductionUNTStatus { get; internal set; }
|
||||
public Double PreProductionEMEALimit { get; internal set; }
|
||||
public Boolean PreProductionEMEAStatus { get; internal set; }
|
||||
public Double? StorageMonths { get; internal set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,10 +61,18 @@
|
||||
<Project>{9EB1F659-6F73-4F65-BCAB-4114FD94F5FC}</Project>
|
||||
<Name>CommonCore.Configuration</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\..\Logic\ProductionOrderCore\ProductionOrderCore.csproj">
|
||||
<Project>{6D2777BB-7A88-466D-A49B-3266F9BF0160}</Project>
|
||||
<Name>ProductionOrderCore</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\..\SoftwareAccessHelper\SoftwareAccessHelper.csproj">
|
||||
<Project>{A33E3C6D-EAAE-4A20-A0EE-F9E6922FD029}</Project>
|
||||
<Name>SoftwareAccessHelper</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\WaterMeterCore\WaterMeterCore.csproj">
|
||||
<Project>{8203abb8-38e5-472e-a742-33f38b7a74a6}</Project>
|
||||
<Name>WaterMeterCore</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\GenesisCore\GenesisCore.csproj">
|
||||
<Project>{04201E95-90A0-4B73-A72F-379739B2A3AE}</Project>
|
||||
<Name>GenesisCore</Name>
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using LaaPackages.Features.Cordonel.Models;
|
||||
using Newtonsoft.Json;
|
||||
using Xylem.Common.CommonCore.Configuration;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
|
||||
using Xylem.Common.Logic.SoftwareAccessHelper;
|
||||
using Xylem.Common.Logic.ProductionOrderCore.TestResults;
|
||||
|
||||
namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// Handler for the production status check. This will be feed by the DB.
|
||||
/// The base is the standard requirement or the special requirement.
|
||||
/// - Calculation of drained battery,
|
||||
/// - Assembly capability check,
|
||||
/// - Shipping capability check.
|
||||
@@ -16,86 +21,181 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisStatus
|
||||
public static class GenesisStatusHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Get all production infos for skip process checks or limits for production like:
|
||||
/// Get all production infos out of the "CordonelRequirements" which can be "StandardRequirements" or
|
||||
/// "SpecialRequirements". The call of "CordonelRequirements" will automatically select the active
|
||||
/// requirement with priority to the "SpecialRequirement".
|
||||
/// - Battery drained percentage upper limit,
|
||||
/// - Production due date for a special register,
|
||||
/// - Required life time for assembly line,
|
||||
/// - Required life time for shipping line.
|
||||
/// - Required lifetime for assembly line,
|
||||
/// - Required lifetime for shipping line.
|
||||
/// </summary>
|
||||
/// <param name="pcbId"></param>
|
||||
/// <param name="orderNumber"></param>
|
||||
/// <param name="productionStatus"></param>
|
||||
/// <param name="prodRequirements"></param>
|
||||
/// <param name="errorMsg"></param>
|
||||
/// <returns>true if successfully executed</returns>
|
||||
/// <remarks date="2023-Mar-02" author="Roland Drabesch/Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
/// <remarks date="2024-Jan-23" author="Roland Drabesch/Thomas Wiedebusch">
|
||||
/// - Clone all properties coming from data base to reference (deep clone).
|
||||
/// - Clone all properties coming from database to reference (deep clone).
|
||||
/// </remarks>
|
||||
public static Boolean GetProductionSkipAndLifeTimeInfoFromDb(String pcbId, Int32 orderNumber,
|
||||
GenesisStatus productionStatus)
|
||||
/// <remarks date="2024-Jul-19" author="Thomas Wiedebusch">
|
||||
/// - Changed from "ProductionSkipAndLifeTimeInfo" to "CordonelRequirements".
|
||||
/// </remarks>
|
||||
/// <remarks date="2024-Dec-17" author="Thomas Wiedebusch">
|
||||
/// - Overwrite production "ProductionOrderNr" if null with "OuterProductionOrderNr" which is standard for
|
||||
/// standard requirements as those are neither PcbId based nor order number based.
|
||||
/// </remarks>
|
||||
public static Boolean GetCordonelRequirementInfoFromDb(String pcbId, CordonelRequirements prodRequirements,
|
||||
out String errorMsg)
|
||||
{
|
||||
if (string.IsNullOrEmpty(pcbId) || productionStatus == null)
|
||||
errorMsg = "";
|
||||
if (null == prodRequirements || string.IsNullOrEmpty(pcbId))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
GenesisStatus status;
|
||||
|
||||
try
|
||||
{
|
||||
var url = ""; // ServiceUrls.GetProductionSkipAndLifeTimeInfoServiceUrl();
|
||||
url += $"{pcbId}&orderNumber={orderNumber}";
|
||||
var response = LocalWebRequest.GetRequest(url, 2000);
|
||||
status = JsonConvert.DeserializeObject<GenesisStatus>(response);
|
||||
if (status == null)
|
||||
var url = ServiceUrls.GetCordonelRequirementInfoServiceUrl();
|
||||
url += pcbId;
|
||||
var response = LocalWebRequest.GetRequest(url, 30000, out var httpStatus);
|
||||
if (httpStatus == HttpStatusCode.OK && !string.IsNullOrEmpty(response))
|
||||
{
|
||||
return false;
|
||||
var requirements = JsonConvert.DeserializeObject<CordonelRequirements>(response);
|
||||
var type = typeof(CordonelRequirements);
|
||||
foreach (var prop in type.GetProperties())
|
||||
{
|
||||
if (prop.CanWrite)
|
||||
prop.SetValue(prodRequirements, prop.GetValue(requirements, null), null);
|
||||
}
|
||||
|
||||
// For standard requirements the order number has to be set as those are neither PcbId based
|
||||
// nor order number based
|
||||
if (prodRequirements.ProductionOrderNr == null)
|
||||
prodRequirements.ProductionOrderNr = prodRequirements.OuterProductionOrderNr;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception )
|
||||
catch (Exception e)
|
||||
{
|
||||
errorMsg = e.Message;
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the calibration results for a meter from a test-bench calibration.
|
||||
/// </summary>
|
||||
/// <param name="pcbId"></param>
|
||||
/// <param name="calibResults"></param>
|
||||
/// <param name="errorMsg"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2024-11-09" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
public static Boolean GetCalibrationResultsFromDb(String pcbId, CalibrationResults calibResults,
|
||||
out String errorMsg)
|
||||
{
|
||||
errorMsg = "";
|
||||
if (null == calibResults || string.IsNullOrEmpty(pcbId))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var type = typeof(GenesisStatus);
|
||||
|
||||
foreach (var prop in type.GetProperties())
|
||||
try
|
||||
{
|
||||
try
|
||||
var url = ServiceUrls.GetGenesisCalibrationResultsUrl();
|
||||
url += pcbId;
|
||||
var requestResponse = LocalWebRequest.GetRequest(url, 30000, out var httpStatus);
|
||||
if (httpStatus == HttpStatusCode.OK && !string.IsNullOrEmpty(requestResponse))
|
||||
{
|
||||
if( prop.CanWrite)
|
||||
prop.SetValue(productionStatus, prop.GetValue(status, null), null);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// nothing to do, go ahead
|
||||
var calibRes = JsonConvert.DeserializeObject<CalibrationResults>(requestResponse);
|
||||
// ClassAccess.CopyProperties(calibResults, calibRes);
|
||||
var type = typeof(CalibrationResults);
|
||||
foreach (var prop in type.GetProperties())
|
||||
{
|
||||
if (prop.CanWrite)
|
||||
prop.SetValue(calibResults, prop.GetValue(calibRes, null), null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
errorMsg = e.Message;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read and calculate life time information.
|
||||
/// Get the state of executed flow tests for a meter from a test-bench run.
|
||||
/// </summary>
|
||||
/// <param name="pcbId"></param>
|
||||
/// <param name="testBenchState"></param>
|
||||
/// <param name="errorMsg"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2024-11-09" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
public static Boolean GetFlowTestStateFromDb(String pcbId, List<String> testBenchState, out String errorMsg)
|
||||
{
|
||||
errorMsg = "";
|
||||
if (testBenchState == null || string.IsNullOrEmpty(pcbId))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var url = ServiceUrls.MeterInfoForTestBench() + pcbId;
|
||||
var requestResponse = LocalWebRequest.GetRequest(url, 30000, out var httpStatus);
|
||||
if (httpStatus == HttpStatusCode.OK && !string.IsNullOrEmpty(requestResponse))
|
||||
{
|
||||
var state = JsonConvert.DeserializeObject<String[]>(requestResponse);
|
||||
testBenchState.AddRange(state);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
errorMsg = e.Message;
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read and calculate lifetime information.
|
||||
/// </summary>
|
||||
/// <param name="currentGenesis"></param>
|
||||
/// <param name="status"></param>
|
||||
/// <param name="errorMsg"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2023-Mar-02" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
public static Boolean BuildLifeTimeInformation(GenesisMeter currentGenesis, GenesisStatus status)
|
||||
/// <remarks date="2024-Nov-15" author="Thomas Wiedebusch">
|
||||
/// - errorMsg.
|
||||
/// </remarks>
|
||||
public static Boolean BuildLifeTimeInformation(IGenesisMeter currentGenesis, GenesisStatus status, out String errorMsg)
|
||||
{
|
||||
Boolean retVal;
|
||||
|
||||
if (currentGenesis == null || status == null) return false;
|
||||
errorMsg = "";
|
||||
if (currentGenesis == null || status == null)
|
||||
return false;
|
||||
|
||||
// read information from genesis
|
||||
try
|
||||
{
|
||||
if (!currentGenesis.IsLoggedOn) currentGenesis.Login();
|
||||
|
||||
if (!currentGenesis.IsLoggedOn)
|
||||
currentGenesis.Login();
|
||||
|
||||
status.ExceededLifeTime_s = RegisterConverter.ByteArrayToValue<UInt32>(
|
||||
currentGenesis.ReadRegister(Register.Powermon.BatteryExceededSeconds));
|
||||
status.DrainedBatteryLoad_uAs = RegisterConverter.ByteArrayToValue<UInt64>(
|
||||
@@ -109,15 +209,16 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisStatus
|
||||
|
||||
retVal = CalculateLifeTime(status);
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception e)
|
||||
{
|
||||
retVal = false;
|
||||
errorMsg = e.Message;
|
||||
return false;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
/// <summary>
|
||||
/// Calculation of life time values.
|
||||
/// Calculation of lifetime values.
|
||||
/// </summary>
|
||||
/// <param name="status"></param>
|
||||
/// <returns>true if all calculations could be executed</returns>
|
||||
@@ -127,54 +228,62 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisStatus
|
||||
/// <remarks date="2023-Dec-??" author="Roland Drahbesch">
|
||||
/// - Uniontown limits UNT.
|
||||
/// </remarks>
|
||||
/// <remarks date="2024-Sep-25" author="Thomas Wiedebusch">
|
||||
/// - Alternative calculation based on quiescent current and production supplement instead of UNT limits.
|
||||
/// </remarks>
|
||||
/// <remarks date="2024-Oct-22" author="Thomas Wiedebusch">
|
||||
/// - Battery assembly time calculation added.
|
||||
/// </remarks>
|
||||
/// <remarks date="2024-Nov-25" author="Thomas Wiedebusch">
|
||||
/// - Exit if essential inputs missing.
|
||||
/// </remarks>
|
||||
/// <remarks date="2025-Mar-25" author="Thomas Wiedebusch">
|
||||
/// - Calculate storage months.
|
||||
/// </remarks>
|
||||
public static Boolean CalculateLifeTime(GenesisStatus status)
|
||||
{
|
||||
var retVal = true;
|
||||
// Mark as false if the basic inputs are missed
|
||||
if (status == null ||
|
||||
status.InitialBatteryLoad_mAh == 0 ||
|
||||
status.BatteryQuantity == 0 ||
|
||||
status.DrainedBatteryLoad_uAs == 0 ||
|
||||
status.ExceededLifeTime_s == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Calculate the initial overall battery load of all batteries in uAs as the drained load uses this unit.
|
||||
var initialBatteryLoad_uAs = 1000 * 3600 * status.InitialBatteryLoad_mAh * (UInt64)status.BatteryQuantity;
|
||||
var initialBatteryLoad_uAs = GenesisStatus.MILLI_AMPERE_HOURS_TO_MICRO_AMPERE_SECONDS * status.InitialBatteryLoad_mAh * status.BatteryQuantity;
|
||||
|
||||
// Relation of drained to initial load, set the battery to fully unloaded for failed check to force a recalculation
|
||||
var drainedBatteryLoad_rel = 1.0;
|
||||
if (initialBatteryLoad_uAs != 0)
|
||||
{
|
||||
drainedBatteryLoad_rel = (Double)status.DrainedBatteryLoad_uAs / initialBatteryLoad_uAs;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal = false;
|
||||
}
|
||||
status.DrainedBatteryLoadPercent = drainedBatteryLoad_rel * 100;
|
||||
|
||||
// The estimated life time uses the drained load over the actual exceeded life time and assumes, that further on
|
||||
// an identical load will be consumed over the remaining life cycle. The initial load will be multiplied with the
|
||||
// drained load relation. Set the estimated time to the exceeded time to force a recalculation on failed input.
|
||||
var estimatedLifeTime_s = (Double)status.ExceededLifeTime_s;
|
||||
if (drainedBatteryLoad_rel != 0.0)
|
||||
{
|
||||
estimatedLifeTime_s = status.ExceededLifeTime_s / drainedBatteryLoad_rel;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal = false;
|
||||
}
|
||||
var drainedBatteryLoad_rel = status.DrainedBatteryLoad_uAs / initialBatteryLoad_uAs;
|
||||
status.DrainedBatteryLoadPercent = drainedBatteryLoad_rel * 100.0;
|
||||
|
||||
// The estimated lifetime uses the drained load over the actual exceeded lifetime and assumes, that further on
|
||||
// an identical load will be consumed over the remaining life cycle.
|
||||
var estimatedLifeTime_s = status.ExceededLifeTime_s / drainedBatteryLoad_rel;
|
||||
var remainingLifetime_s = estimatedLifeTime_s - status.ExceededLifeTime_s;
|
||||
// convert the seconds to years
|
||||
status.RemainingLifeTimeYears = remainingLifetime_s / 3600 / 24 / 365.25;
|
||||
status.RemainingLifeTimeYears = remainingLifetime_s * GenesisStatus.YEARS_FROM_SECONDS;
|
||||
|
||||
status.UNTLimit = 1368000000 + (status.ExceededLifeTime_s * 77.7);
|
||||
status.UNTStatus = status.UNTLimit >= status.DrainedBatteryLoad_uAs;
|
||||
// Calculate an alternative threshold for remaining battery load based on the quiescent current and a supplement
|
||||
// for production purpose. Those values can be assigned in the Cordonel requirements.
|
||||
if (status.QuiescentCurrent_uA != null &&
|
||||
status.QuiescentCurrent_uA > 0 &&
|
||||
status.EstimatedProductionBatteryLoadPercent != null)
|
||||
{
|
||||
status.AlternativeRequiredBatteryLoadPercent =
|
||||
// The additional free power for production purposes
|
||||
(Double)status.EstimatedProductionBatteryLoadPercent +
|
||||
// The power consumption based on the actual lifetime and consumed current in relation to absolute load
|
||||
status.ExceededLifeTime_s * (Double)status.QuiescentCurrent_uA / initialBatteryLoad_uAs * 100.0;
|
||||
}
|
||||
|
||||
|
||||
status.EMEALimit = 1368000000 + (status.ExceededLifeTime_s * 119.8);
|
||||
status.EMEAStatus = status.UNTLimit >= status.DrainedBatteryLoad_uAs;
|
||||
|
||||
status.PreProductionUNTLimit = (1368000000/2) + (status.ExceededLifeTime_s * 77.7);
|
||||
status.PreProductionUNTStatus = status.UNTLimit >= status.DrainedBatteryLoad_uAs;
|
||||
|
||||
status.PreProductionEMEALimit = (1368000000 / 2) + (status.ExceededLifeTime_s * 119.8);
|
||||
status.PreProductionEMEAStatus = status.UNTLimit >= status.DrainedBatteryLoad_uAs;
|
||||
return retVal;
|
||||
// Calculate battery assembly time
|
||||
var actualDate = DateTime.UtcNow;
|
||||
status.BatteryAssemblyDateTimeUtc = actualDate.AddSeconds(-(Double)status.ExceededLifeTime_s);
|
||||
var timeDifference = actualDate - status.BatteryAssemblyDateTimeUtc;
|
||||
status.StorageMonths = timeDifference.GetValueOrDefault().TotalSeconds * GenesisStatus.MONTHS_FROM_SECONDS;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+16726
File diff suppressed because it is too large
Load Diff
+39
@@ -0,0 +1,39 @@
|
||||
Release summary for product 1.69
|
||||
|
||||
Block ./Zero/objects/zero
|
||||
Id 0x00, CRC 0x3F95, size 36868 bytes, version 4.98
|
||||
|
||||
Block ../../Applications/PowerMon/powermon
|
||||
Id 0x01, CRC 0x9ACE, size 3068 bytes, version 0.67
|
||||
|
||||
Block ../../Applications/ConfigExchange/configex
|
||||
Id 0x04, CRC 0xF967, size 8036 bytes, version 2.19
|
||||
|
||||
Block ../../Applications/Logger/logger
|
||||
Id 0x08, CRC 0xDC48, size 3972 bytes, version 0.17
|
||||
|
||||
Block ../../Applications/PeriodicLogging/periodiclog
|
||||
Id 0x11, CRC 0x92E5, size 12540 bytes, version 0.70
|
||||
|
||||
Block ../../Applications/Communications/SensusRFRadio/SensusRF_433
|
||||
Id 0x10, CRC 0x731F, size 79504 bytes, version 4.76
|
||||
|
||||
Block ../../Applications/Metrology/Water/GenesisFlow/genesisflow
|
||||
Id 0x0F, CRC 0x8228, size 23300 bytes, version 2.87
|
||||
|
||||
Block ../../Applications/Customer/GenesisDefault/customer
|
||||
Id 0x09, CRC 0xE3CF, size 6104 bytes, version 1.52
|
||||
|
||||
Block ../../Applications/MetrologyAssistant/assistant
|
||||
Id 0x12, CRC 0xF798, size 7728 bytes, version 1.07
|
||||
|
||||
Block ../../Applications/Communications/IrDA/irda
|
||||
Id 0x14, CRC 0x8376, size 23144 bytes, version 1.98
|
||||
|
||||
Block ../../Applications/Communications/NFC/nfc
|
||||
Id 0x15, CRC 0xB3D8, size 6424 bytes, version 0.53
|
||||
|
||||
Block ../../Applications/FlexNetVersion/flexnetversion
|
||||
Id 0x18, CRC 0xB848, size 116 bytes, version 11.07
|
||||
Minimum supported core revision: "Cordonel 1.62"
|
||||
Maximum supported core revision: "Cordonel 1.69"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+16920
File diff suppressed because it is too large
Load Diff
+40
@@ -0,0 +1,40 @@
|
||||
Release summary for product 1.71
|
||||
|
||||
Block ./Zero/objects/zero
|
||||
Id 0x00, CRC 0x2325, size 37728 bytes, version 5.17
|
||||
|
||||
Block ../../Applications/PowerMon/objects/powermon
|
||||
Id 0x01, CRC 0x2527, size 3068 bytes, version 0.68
|
||||
|
||||
Block ../../Applications/ConfigExchange/objects/configex
|
||||
Id 0x04, CRC 0x0822, size 7904 bytes, version 2.26
|
||||
|
||||
Block ../../Applications/Logger/objects/logger
|
||||
Id 0x08, CRC 0x12D4, size 3972 bytes, version 0.18
|
||||
|
||||
Block ../../Applications/PeriodicLogging/objects/periodiclog
|
||||
Id 0x11, CRC 0x5E72, size 12528 bytes, version 0.73
|
||||
|
||||
Block ../../Applications/Communications/SensusRFRadio/objects/SensusRF
|
||||
Id 0x10, CRC 0xFFCE, size 81820 bytes, version 4.93
|
||||
|
||||
Block ../../Applications/Metrology/Water/GenesisFlow/objects/genesisflow
|
||||
Id 0x0F, CRC 0xA3A6, size 25164 bytes, version 3.02
|
||||
|
||||
Block ../../Applications/Customer/GenesisDefault/objects/customer
|
||||
Id 0x09, CRC 0xAEC5, size 6148 bytes, version 1.55
|
||||
|
||||
Block ../../Applications/MetrologyAssistant/objects/assistant
|
||||
Id 0x12, CRC 0xB4D5, size 7948 bytes, version 1.11
|
||||
|
||||
Block ../../Applications/Communications/IrDA/objects/irda
|
||||
Id 0x14, CRC 0x2EB1, size 23324 bytes, version 2.06
|
||||
|
||||
Block ../../Applications/Communications/NFC/objects/nfc
|
||||
Id 0x15, CRC 0xCE04, size 6452 bytes, version 0.57
|
||||
|
||||
Block ../../Applications/FlexNetVersion/objects/flexnetversion
|
||||
Id 0x18, CRC 0xBA83, size 116 bytes, version 12.47
|
||||
|
||||
Minimum supported core revision: "Cordonel 1.62"
|
||||
Maximum supported core revision: "Cordonel 1.71"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+16819
File diff suppressed because it is too large
Load Diff
+40
@@ -0,0 +1,40 @@
|
||||
Release summary for product 1.78
|
||||
|
||||
Block ./Zero/objects/zero
|
||||
Id 0x00, CRC16 0x39A8, size 37972 bytes, version 5.37
|
||||
|
||||
Block ../../Applications/PowerMon/objects/powermon
|
||||
Id 0x01, CRC16 0xB16C, size 3112 bytes, version 0.70
|
||||
|
||||
Block ../../Applications/ConfigExchange/objects/configex
|
||||
Id 0x04, CRC16 0x8290, size 7944 bytes, version 2.38
|
||||
|
||||
Block ../../Applications/Logger/objects/logger
|
||||
Id 0x08, CRC16 0x12D4, size 3972 bytes, version 0.18
|
||||
|
||||
Block ../../Applications/PeriodicLogging/objects/periodiclog
|
||||
Id 0x11, CRC16 0x5796, size 12412 bytes, version 0.75
|
||||
|
||||
Block ../../Applications/Communications/SensusRFRadio/objects/SensusRF
|
||||
Id 0x10, CRC16 0x0704, size 93488 bytes, version 5.30
|
||||
|
||||
Block ../../Applications/Metrology/Water/GenesisFlow/objects/genesisflow
|
||||
Id 0x0F, CRC16 0xA3A6, size 25164 bytes, version 3.02
|
||||
|
||||
Block ../../Applications/Customer/GenesisDefault/objects/customer
|
||||
Id 0x09, CRC16 0xD56D, size 6196 bytes, version 1.59
|
||||
|
||||
Block ../../Applications/MetrologyAssistant/objects/assistant
|
||||
Id 0x12, CRC16 0x9BA6, size 7948 bytes, version 1.13
|
||||
|
||||
Block ../../Applications/Communications/IrDA/objects/irda
|
||||
Id 0x14, CRC16 0x2EB1, size 23324 bytes, version 2.06
|
||||
|
||||
Block ../../Applications/Communications/NFC/objects/nfc
|
||||
Id 0x15, CRC16 0x43F4, size 6808 bytes, version 0.59
|
||||
|
||||
Block ../../Applications/FlexNetVersion/objects/flexnetversion
|
||||
Id 0x18, CRC16 0xB2D5, size 116 bytes, version 13.0B
|
||||
|
||||
Minimum supported core revision: "Cordonel 1.62"
|
||||
Maximum supported core revision: "Cordonel 1.78"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+16819
File diff suppressed because it is too large
Load Diff
+40
@@ -0,0 +1,40 @@
|
||||
Release summary for product 1.78
|
||||
|
||||
Block ./Zero/objects/zero
|
||||
Id 0x00, CRC16 0x3828, size 37972 bytes, version 5.37
|
||||
|
||||
Block ../../Applications/PowerMon/objects/powermon
|
||||
Id 0x01, CRC16 0xB16C, size 3112 bytes, version 0.70
|
||||
|
||||
Block ../../Applications/ConfigExchange/objects/configex
|
||||
Id 0x04, CRC16 0x8290, size 7944 bytes, version 2.38
|
||||
|
||||
Block ../../Applications/Logger/objects/logger
|
||||
Id 0x08, CRC16 0x12D4, size 3972 bytes, version 0.18
|
||||
|
||||
Block ../../Applications/Metrology/Water/GenesisFlow/objects/genesisflow
|
||||
Id 0x0F, CRC16 0x8228, size 23300 bytes, version 2.87
|
||||
|
||||
Block ../../Applications/MetrologyAssistant/objects/assistant
|
||||
Id 0x12, CRC16 0x9BA6, size 7948 bytes, version 1.13
|
||||
|
||||
Block ../../Applications/Customer/GenesisDefault/objects/customer
|
||||
Id 0x09, CRC16 0xD56D, size 6196 bytes, version 1.59
|
||||
|
||||
Block ../../Applications/Communications/IrDA/objects/irda
|
||||
Id 0x14, CRC16 0x2EB1, size 23324 bytes, version 2.06
|
||||
|
||||
Block ../../Applications/Communications/NFC/objects/nfc
|
||||
Id 0x15, CRC16 0x25B6, size 6824 bytes, version 0.61
|
||||
|
||||
Block ../../Applications/FlexNetVersion/objects/flexnetversion
|
||||
Id 0x18, CRC16 0xE953, size 116 bytes, version 13.F3
|
||||
|
||||
Block ../../Applications/Communications/SensusRFRadio/objects/SensusRF
|
||||
Id 0x10, CRC16 0x8261, size 93424 bytes, version 5.25
|
||||
|
||||
Block ../../Applications/PeriodicLogging/objects/periodiclog
|
||||
Id 0x11, CRC16 0x5796, size 12412 bytes, version 0.75
|
||||
|
||||
Minimum supported core revision: "Cordonel 1.62"
|
||||
Maximum supported core revision: "Cordonel 1.78"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+16769
File diff suppressed because it is too large
Load Diff
+43
@@ -0,0 +1,43 @@
|
||||
Release summary for product 1.75
|
||||
|
||||
Block ./Zero/objects/zero
|
||||
Id 0x00, CRC16 0x43E2, size 37948 bytes, version 5.33
|
||||
|
||||
Block ../../Applications/PowerMon/objects/powermon
|
||||
Id 0x01, CRC16 0x2527, size 3068 bytes, version 0.68
|
||||
|
||||
Block ../../Applications/ConfigExchange/objects/configex
|
||||
Id 0x04, CRC16 0x73BF, size 7940 bytes, version 2.35
|
||||
|
||||
Block ../../Applications/Logger/objects/logger
|
||||
Id 0x08, CRC16 0x12D4, size 3972 bytes, version 0.18
|
||||
|
||||
Block ../../Applications/Metrology/Water/GenesisFlow/objects/genesisflow
|
||||
Id 0x0F, CRC16 0x3A55, CRC32 0xFBEE5A5E, size 25424 bytes, version 3.15
|
||||
|
||||
Block ../../Applications/MetrologyAssistant/objects/assistant
|
||||
Id 0x12, CRC16 0xD466, size 7948 bytes, version 1.14
|
||||
|
||||
Block ../../Applications/Customer/GenesisDefault/objects/customer
|
||||
Id 0x09, CRC16 0xDCD7, size 6468 bytes, version 1.57
|
||||
|
||||
Block ../../Applications/Communications/IrDA/objects/irda
|
||||
Id 0x14, CRC16 0x2ACD, size 24108 bytes, version 2.10
|
||||
|
||||
Block ../../Applications/Communications/NFC/objects/nfc
|
||||
Id 0x15, CRC16 0x43F4, size 6808 bytes, version 0.59
|
||||
|
||||
Block ../../Applications/FlexNetVersion/objects/flexnetversion
|
||||
Id 0x18, CRC16 0x68A4, size 116 bytes, version 20.06
|
||||
|
||||
Block ../../Applications/Communications/FlexNetSerial/objects/flexnetserial
|
||||
Id 0x1A, CRC16 0x7326, size 6180 bytes, version 0.20
|
||||
|
||||
Block ../../Applications/NA2WAlarms/objects/na2walarms
|
||||
Id 0x17, CRC16 0x49D9, size 10264 bytes, version 1.02
|
||||
|
||||
Block ../../Applications/NA2WLogger/objects/NA2WLogger
|
||||
Id 0x16, CRC16 0xC9EF, size 9712 bytes, version 1.99
|
||||
|
||||
Minimum supported core revision: "Cordonel 1.62"
|
||||
Maximum supported core revision: "Cordonel 1.75"
|
||||
@@ -0,0 +1,978 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using NCrunch.Framework;
|
||||
using Xylem.Common.CommonCore.Consts;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.Applications;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.Applications.Const;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisConfig;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers.DataTypes;
|
||||
using Xylem.Common.Logic.ProductionOrderCore.TestResults;
|
||||
|
||||
namespace Xylem.Common.Hardware.WaterMeter.Genesis.MockGenesis
|
||||
{
|
||||
/// <summary>
|
||||
/// Mock Genesis for usage to simulate an original Genesis without any hardware:
|
||||
/// - The communication will use buffers program internally instead a physical port,
|
||||
/// - Login, Logout and all other operations will NOT use a database call.
|
||||
/// </summary>
|
||||
public class MockGenesis : GenesisMeter
|
||||
{
|
||||
#region -------------------------------- Properties -----------------------------------------------------------
|
||||
|
||||
/// <summary>
|
||||
/// The application description file (ADF) will be used to install a simulated new firmware to
|
||||
/// the mock Genesis
|
||||
/// </summary>
|
||||
private String _packageDescriptionFile = DefaultPackageDescriptionFile;
|
||||
|
||||
/// <summary>
|
||||
/// The required mock firmware installation is based on the file application simulation an installation
|
||||
/// based on the package description file.
|
||||
/// </summary>
|
||||
private List<FileApplications> _mockFw = new List<FileApplications>();
|
||||
|
||||
/// <summary>
|
||||
/// A list of all config registers for debug.
|
||||
/// </summary>
|
||||
// ReSharper disable once CollectionNeverQueried.Local for DEBUG only
|
||||
private readonly List<String> _configRegisterNames = new List<String>();
|
||||
|
||||
/// <summary>
|
||||
/// A list of all FLASH registers for debug.
|
||||
/// </summary>
|
||||
// ReSharper disable once CollectionNeverQueried.Local for DEBUG only
|
||||
private readonly List<String> _flashRegisterNames = new List<String>();
|
||||
|
||||
/// <summary>
|
||||
/// Simulated permanent storage (FLASH memory) to keep the values set with store configuration.
|
||||
/// </summary>
|
||||
private readonly MeterRegisters _flashRegister = new MeterRegisters();
|
||||
|
||||
/// <summary>
|
||||
/// A list of all known registers which do not return the written value.
|
||||
/// EXAMPLES:
|
||||
/// - SENSUSRADIO_SystemState writing 0xFF returns 0x02
|
||||
/// - XXX_StoreConfiguration writing 0x01 returns 0x00
|
||||
///
|
||||
/// The registers can be fully qualified or contain a substring like _StoreConfiguration if it always
|
||||
/// returns an identical reply!
|
||||
///
|
||||
/// The first value is the expected value which will be searched for and the second value is the reply!
|
||||
/// Only it the first value is exact as described here the reply is going to be changed.
|
||||
///
|
||||
/// </summary>
|
||||
private static readonly List<RecoveryRegisterItem> SpecialRegisterReplies = new List<RecoveryRegisterItem>
|
||||
{
|
||||
// (partial) name expected value reply value
|
||||
new RecoveryRegisterItem("SENSUSRADIO_SystemState", new Byte[]{0xFF}, new Byte[]{0x02}),
|
||||
new RecoveryRegisterItem("_StoreCalibration", new Byte[]{0x01}, new Byte[]{0x00}),
|
||||
new RecoveryRegisterItem("_StoreConfiguration", new Byte[]{0x01}, new Byte[]{0x00})
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// The root path for all mock FwPackaged.
|
||||
/// </summary>
|
||||
private const String RootMockFwPath = "MockFwExamples";
|
||||
|
||||
/// <summary>
|
||||
/// Mock object can overwrite PcbId for test purposes and set password to null to avoid
|
||||
/// usage of wrong password and lock of the device trying to log in with the wrong password
|
||||
/// </summary>
|
||||
public new String PcbId
|
||||
{
|
||||
set
|
||||
{
|
||||
base.PcbId = value;
|
||||
ClearPassword();
|
||||
}
|
||||
get => base.PcbId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mock object can overwrite LutCrc for test purposes
|
||||
/// </summary>
|
||||
public new String LutCrc
|
||||
{
|
||||
set => base.LutCrc = value;
|
||||
get => base.LutCrc;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mock object can overwrite StrCoreRevision for test purposes
|
||||
/// </summary>
|
||||
public new String StrCoreRevision
|
||||
{
|
||||
set => base.StrCoreRevision = value;
|
||||
get => base.StrCoreRevision;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mock object can overwrite CoreRevision for test purposes
|
||||
/// </summary>
|
||||
public new Int32? CoreRevision
|
||||
{
|
||||
set => base.CoreRevision = value;
|
||||
get => base.CoreRevision;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mock object can overwrite RadioFrequencyMhz for test purposes
|
||||
/// </summary>
|
||||
public new Int32? RadioFrequencyMhz
|
||||
{
|
||||
set => base.RadioFrequencyMhz = value;
|
||||
get => base.RadioFrequencyMhz;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mock object can overwrite InstalledFwVersion for test purposes
|
||||
/// </summary>
|
||||
public new UInt32? InstalledFwVersion
|
||||
{
|
||||
set => base.InstalledFwVersion = value;
|
||||
get => base.InstalledFwVersion;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mock object can overwrite Region for test purposes
|
||||
/// </summary>
|
||||
public new String Region
|
||||
{
|
||||
set => base.Region = value;
|
||||
get => base.Region;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mock object can overwrite MeterSize for test purposes
|
||||
/// </summary>
|
||||
public new String MeterSize
|
||||
{
|
||||
set => base.MeterSize = value;
|
||||
get => base.MeterSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mock object can overwrite FwVersion for test purposes
|
||||
/// </summary>
|
||||
public new String FwVersion
|
||||
{
|
||||
private set => base.FwVersion = value;
|
||||
get => base.FwVersion;
|
||||
}
|
||||
/// <summary>
|
||||
/// Mock object can overwrite login status for test purposes
|
||||
/// </summary>
|
||||
public new Boolean IsLoggedOn
|
||||
{
|
||||
set => base.IsLoggedOn = value;
|
||||
get => base.IsLoggedOn;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The exec path of the assembly for debug in environment.
|
||||
/// </summary>
|
||||
private readonly String _assemblyExecRootPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
|
||||
/// <summary>
|
||||
/// Fw package path relative to solution main folder.
|
||||
/// </summary>
|
||||
private readonly String _mockFwPackageRootPath;
|
||||
|
||||
#endregion ----------------------------- Properties -----------------------------------------------------------
|
||||
|
||||
#region --------------------------------- Default package description file ------------------------------------
|
||||
|
||||
/// <summary>
|
||||
/// This file will be used to assign the default MeterApplications as simulated installation to the Genesis
|
||||
/// meter. It contains only the important information:
|
||||
/// - Each line starting with "Id" is an App,
|
||||
/// - the "Maximum supported core revision" will be used as CoreRevision.
|
||||
/// </summary>
|
||||
private const String DefaultPackageDescriptionFile =
|
||||
"Id 0x00, CRC16 0x39A8, size 37972 bytes, version 5.37\r\n" +
|
||||
"Id 0x01, CRC16 0xB16C, size 3112 bytes, version 0.70\r\n" +
|
||||
"Id 0x04, CRC16 0x8290, size 7944 bytes, version 2.38\r\n" +
|
||||
"Id 0x08, CRC16 0x12D4, size 3972 bytes, version 0.18\r\n" +
|
||||
"Id 0x11, CRC16 0x5796, size 12412 bytes, version 0.75\r\n" +
|
||||
"Id 0x10, CRC16 0x0704, size 93488 bytes, version 5.30\r\n" +
|
||||
"Id 0x0F, CRC16 0xA3A6, size 25164 bytes, version 3.02\r\n" +
|
||||
"Id 0x09, CRC16 0xD56D, size 6196 bytes, version 1.59\r\n" +
|
||||
"Id 0x12, CRC16 0x9BA6, size 7948 bytes, version 1.13\r\n" +
|
||||
"Id 0x14, CRC16 0x2EB1, size 23324 bytes, version 2.06\r\n" +
|
||||
"Id 0x15, CRC16 0x43F4, size 6808 bytes, version 0.59\r\n" +
|
||||
"Id 0x18, CRC16 0xB2D5, size 116 bytes, version 13.0B\r\n" +
|
||||
"Maximum supported core revision: \"Cordonel 1.78\"";
|
||||
|
||||
#endregion ------------------------------ Default package description file ------------------------------------
|
||||
|
||||
#region -------------------------------- Class handling -------------------------------------------------------
|
||||
|
||||
/// <summary>
|
||||
/// Standard Ctor
|
||||
/// </summary>
|
||||
public MockGenesis()
|
||||
{
|
||||
var subFolder = Path.Combine("Hardware", "WaterMeter", "Genesis", "MockGenesis");
|
||||
var solutionPath = "";
|
||||
if (NCrunchEnvironment.NCrunchIsResident())
|
||||
{
|
||||
solutionPath = NCrunchEnvironment.GetOriginalSolutionPath().Replace("Common.sln", "");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_assemblyExecRootPath != null)
|
||||
{
|
||||
// We are in the Unit test folder "..\Common\Production\ProductionUiCordonel.UnitTests\bin\Debug"
|
||||
// and need to go back to "..\Common"
|
||||
var directoryInfo = Directory.GetParent(_assemblyExecRootPath)?.Parent?.Parent?.Parent?.Parent;
|
||||
if (directoryInfo != null)
|
||||
{
|
||||
solutionPath = directoryInfo.FullName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_mockFwPackageRootPath = Path.Combine(solutionPath, subFolder, "MockFwExamples");
|
||||
Console.WriteLine($@"MOCK GENESIS: Search path for MockFwExamples: {_mockFwPackageRootPath}");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region -------------------------------- Firmware update and modification -------------------------------------
|
||||
|
||||
/// <summary>
|
||||
/// Install a new firmware to the mock with the package description file as serialized string
|
||||
/// <see cref="DefaultPackageDescriptionFile"/> which is reduced to the important lines or alternative
|
||||
/// a named FW Version string like "R1.3.0B" or "R130B" which has to be part of the MockFwExamples.
|
||||
///
|
||||
/// The filters to find the path in the root path is the region and FW release version
|
||||
/// "EMEA" or "NA"
|
||||
/// "R130B" or "R1.3.0B"
|
||||
/// additional naming is allowed (e.g. "EMEA_R13F3_replaces_R1107_R1108")
|
||||
///
|
||||
/// The filters to accept the file is:
|
||||
/// "product" and
|
||||
/// ".txt"
|
||||
/// additional naming is allowed (e.g. "rowproduct_R130B.txt")
|
||||
///
|
||||
/// The FW root path is the path where the FW update packages are stored.
|
||||
/// All files needed to be stored directly in the main folder of the FW version:
|
||||
///
|
||||
/// EXAMPLE:
|
||||
/// [Root path]\EMEA_R130B\rowproduct_xyz.txt (package description file, mandatory is "product" and ".txt")
|
||||
/// \configuration.json
|
||||
/// \binfile00_0537_xyz.bin (package description file, mandatory is "binfile" and ".bin")
|
||||
/// \binfile01_0070_xyz.bin
|
||||
/// \...
|
||||
/// \binfile18_130B_xyz.bin
|
||||
/// [Root path]\NA_R2006 \naproduct_xyz.txt (package description file, mandatory is "product" and ".txt")
|
||||
/// \configuration.json
|
||||
/// \binfile00_0533_xyz.bin (package description file, mandatory is "binfile" and ".bin")
|
||||
/// \binfile01_0068_xyz.bin
|
||||
/// \...
|
||||
/// \binfile18_2006_xyz.bin
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="packageDescriptionFile"></param>
|
||||
/// <param name="fwName">if this is null, the description file will be installed</param>
|
||||
/// <remarks date="2024-Dec-02" author="Thomas Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
/// <remarks date="2024-Dec-12" author="Thomas Wiedebusch">
|
||||
/// - Logout, clear FLASH, login.
|
||||
/// </remarks>
|
||||
/// <remarks date="2024-Dec-18" author="Thomas Wiedebusch">
|
||||
/// - Take FW version from MockFwExamples if explicit named with the release string.
|
||||
/// </remarks>
|
||||
/// <remarks date="2024-Dec-19" author="Thomas Wiedebusch">
|
||||
/// - Returns bool.
|
||||
/// </remarks>
|
||||
public Boolean InstallNewMockFw(String packageDescriptionFile = null, String fwName = null)
|
||||
{
|
||||
if (fwName != null)
|
||||
{
|
||||
var releaseName = FwVersion.Replace(".", "");
|
||||
|
||||
if (!FwVersion.Equals(fwName) && !releaseName.Contains(fwName))
|
||||
{
|
||||
//Load new rawproduct.txt or naproduct.txt and install it to MockGenesis
|
||||
if (!MeterFwUpdate.LoadPackageFile(_mockFwPackageRootPath, fwName, out _packageDescriptionFile))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (packageDescriptionFile != null)
|
||||
{
|
||||
// Set the new package file which will be parsed and used as simulation for all installed
|
||||
// applications
|
||||
_packageDescriptionFile = packageDescriptionFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Logout();
|
||||
_flashRegister.MeterRegisterDic.Clear();
|
||||
_flashRegisterNames.Clear();
|
||||
|
||||
// Force re-generation of the meter app and config register lists
|
||||
MeterAppListVersion.Clear();
|
||||
ConfigRegister.MeterRegisterDic.Clear();
|
||||
ConfigApplications.Clear();
|
||||
|
||||
// Login to build initial registers being able to use the FLASH register dictionary immediately.
|
||||
Login();
|
||||
|
||||
return RebootGenesis() == StatusReturn.Okay;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prepare the mock installed firmware by parsing the package description file.
|
||||
/// </summary>
|
||||
/// <remarks date="2024-Dec-01" author="Thomas Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
private void ParsePackageDescriptionFile()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_packageDescriptionFile))
|
||||
return;
|
||||
|
||||
if (_mockFw == null)
|
||||
_mockFw = new List<FileApplications>();
|
||||
_mockFw.Clear();
|
||||
|
||||
MeterFwUpdate.GetPackageFileApplications(_packageDescriptionFile, _mockFw);
|
||||
CoreRevision = MeterFwUpdate.GetCoreRevisionMax(_packageDescriptionFile);
|
||||
if (CoreRevision != null)
|
||||
StrCoreRevision = BuildFwVersionStringFromDec(CoreRevision);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modify or erase one mock app to simulate an application error of the firmware package.
|
||||
/// This will be used for test purposes to manually change installed app-properties.
|
||||
///
|
||||
/// REMIND: All Apps are required to stay in MeterAppListVersion as this is a list of all Apps found in the
|
||||
/// configuration.json. Does mean, for erasure just change the status to
|
||||
/// <see cref="MeterAppState.MeterAppNotInstalled"/> !
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="appId"></param>
|
||||
/// <param name="version">null doesn't change actual version</param>
|
||||
/// <param name="crc">null doesn't change actual CRC</param>
|
||||
/// <param name="eraseApp"></param>
|
||||
/// <returns>true if modification could be done</returns>
|
||||
/// <remarks date="2024-Dec-04..05" author="Thomas Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
public Boolean ModifyMockApp(Byte appId, UInt32? version = null, UInt16? crc = null, Boolean eraseApp = false)
|
||||
{
|
||||
if (MeterAppListVersion == null ||
|
||||
MeterAppListVersion.Count == 0 ||
|
||||
MeterAppListVersion.All(app => app.AppId != appId))
|
||||
return false;
|
||||
|
||||
Logout();
|
||||
|
||||
foreach (var app in MeterAppListVersion.Where(app => app.AppId == appId))
|
||||
{
|
||||
if (eraseApp)
|
||||
{
|
||||
app.IsInstalled = false;
|
||||
app.Status = MeterAppState.MeterAppNotInstalled;
|
||||
app.StrVersion = "0.0";
|
||||
app.Version = 0;
|
||||
}
|
||||
if (version != null)
|
||||
{
|
||||
app.Version = (UInt32)version;
|
||||
app.StrVersion = BuildFwVersionStringFromDec((Int32?)version);
|
||||
}
|
||||
|
||||
if (crc != null)
|
||||
{
|
||||
app.Crc = (UInt16)crc;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endregion ----------------------------- Firmware update and modification -------------------------------------
|
||||
|
||||
#region -------------------------------- Mock Genesis Initialization ------------------------------------------
|
||||
/// <summary>
|
||||
/// Mock reading all applications from a predefined package description file instead from the Meter.
|
||||
/// </summary>
|
||||
/// <remarks date="2024-Dec-01" author="Thomas Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
protected override void ReadMeterFirmwareAndAssignRegisters()
|
||||
{
|
||||
// Avoid overwriting of list if this already exits
|
||||
if (MeterAppListVersion.Any() && MeterAppListVersion.All(f => f.Status != MeterAppState.Unknown))
|
||||
{
|
||||
Logger.Warn($"Slot:{Slot} - Trying to overwride installed FW. Skipping generation of new " +
|
||||
"App list and meter register dictionary");
|
||||
return;
|
||||
}
|
||||
|
||||
// This loads the configuration.json from the exec directory
|
||||
LoadConfiguration(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)));
|
||||
|
||||
// Simulate a firmware installation using the package description file to assign applications
|
||||
ParsePackageDescriptionFile();
|
||||
|
||||
// Use the _mockFw created out of the package description file and which is a file application list
|
||||
if (_mockFw == null || _mockFw.Count < MeterFwUpdate.MinAppsRequiredForOperation)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//Get all existing applications from meter register dictionary
|
||||
foreach (var meterApp in ConfigApplications.OrderBy(o => o.AppId))
|
||||
{
|
||||
// Take all listed config apps even if not installed
|
||||
var app = new MeterApplications
|
||||
{
|
||||
AppId = meterApp.AppId,
|
||||
Version = 0,
|
||||
StrVersion = "0.00",
|
||||
AppName = meterApp.AppName,
|
||||
Crc = 0x0000,
|
||||
Status = MeterAppState.MeterAppNotInstalled,
|
||||
IsInstalled = false
|
||||
};
|
||||
|
||||
foreach (var fileApp in _mockFw)
|
||||
{
|
||||
if (fileApp.AppId == meterApp.AppId)
|
||||
{
|
||||
app.Version = fileApp.Version;
|
||||
app.StrVersion = fileApp.StrVersion;
|
||||
app.Crc = fileApp.Crc;
|
||||
app.Status = MeterAppState.MeterAppUpToDate;
|
||||
app.IsInstalled = true;
|
||||
}
|
||||
|
||||
// The FLEXNETVERSION is the overall firmware version
|
||||
if (fileApp.AppId == MeterFwUpdate.FlexnetVersionAppId)
|
||||
{
|
||||
InstalledFwVersion = fileApp.Version;
|
||||
FwVersion = fileApp.StrVersion;
|
||||
}
|
||||
}
|
||||
|
||||
MeterAppListVersion.Add(app);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Initial list of ALL registers defined in configuration.json read from local bin directory
|
||||
var tempConfigRegisters = ConfigRegister.MeterRegisterDic.ToList();
|
||||
|
||||
// Reduce registers to valid registers for a specific application with a specific version
|
||||
// The old register dictionary is going to be cleared automatically calling this method.
|
||||
BuildValidMeterRegisters(tempConfigRegisters);
|
||||
|
||||
// Fill the meter register dictionary with defaults are stored values in simulated FLASH memory
|
||||
InitConfigAndFlashRegisters();
|
||||
|
||||
// Check for SENSUSRADIO as indication for region "EMEA", else it is regin "NA"
|
||||
Region = "NA";
|
||||
if (ConfigRegister.MeterRegisterDic.Any(app => app.Key.AppName.Equals("SENSUSRADIO")))
|
||||
{
|
||||
var value = ConfigRegister.Get("SENSUSRADIO_FrequencyIndicator");
|
||||
if (value != null)
|
||||
{
|
||||
RadioFrequencyMhz = RegisterConverter.ByteArrayToValue<Int32>(value);
|
||||
Region = "EMEA";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error($"Slot:{Slot} - {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use the app name to flash all contents:
|
||||
/// - Take all values from RAM memory (config register dictionary) and copy it to FLASH memory (flash
|
||||
/// register dictionary) which simulates the non-volatile memory of the Genesis.
|
||||
/// </summary>
|
||||
/// <param name="appName"></param>
|
||||
/// <remarks date="2024-Dec-03" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
private void FlashMemory(String appName)
|
||||
{
|
||||
if (_flashRegister == null || ConfigRegister == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Safe all data from config to FLASH register dictionary for App.
|
||||
foreach (var reg in ConfigRegister.MeterRegisterDic)
|
||||
{
|
||||
try
|
||||
{
|
||||
var regName = reg.Key.GetIdent();
|
||||
|
||||
// Filter for all registers of a specific App
|
||||
if (regName.Contains(appName))
|
||||
{
|
||||
// Avoid writing of NOT writable registers, only read write makes sense as others cannot be
|
||||
// read back!
|
||||
if (reg.Key.RegisterDetail.Privilege.Lvl8 == Access.RW &&
|
||||
reg.Key.DataType != typeof(Rpc))
|
||||
{
|
||||
var flashData = ConfigRegister.Get(regName);
|
||||
// Throws an exception if register doesn't exist, but we want to go ahead with the others
|
||||
var regDef = _flashRegister.GetRegisterDefinitionByName(regName);
|
||||
_flashRegister.Set(regDef, flashData);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error($"Slot:{Slot} - {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store one single parameter to flash memory to simulate FW internal change of register or the
|
||||
/// "GENESISFLOW_StoreCalibration":
|
||||
/// - Avoid to check of RO or WO to force an update as it would be done by the FW.
|
||||
/// </summary>
|
||||
/// <param name="regName"></param>
|
||||
/// <remarks date="2024-Dec-07" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
private void SingleParameterFlashMemory(String regName)
|
||||
{
|
||||
if (_flashRegister == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var flashData = ConfigRegister.Get(regName);
|
||||
// Throws an exception if register doesn't exist, but we want to go ahead with the others
|
||||
var regDef = _flashRegister.GetRegisterDefinitionByName(regName);
|
||||
_flashRegister.Set(regDef, flashData);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error($"Slot:{Slot} - {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fill the meter register dictionary with the stored values of the simulated FLASH memory:
|
||||
/// - If FLASH memory register dictionary doesn't exist (initial start) generate a copy of
|
||||
/// the config register dictionary and fill it with default values from configuration.json,
|
||||
/// - Copy ALWAYS the content of the FLASH to the config register dictionary.
|
||||
///
|
||||
/// REMIND:
|
||||
/// If an application has received a store configuration, the FLASH content will be overwritten
|
||||
/// from default value to the actual value of the config register dictionary as this is the
|
||||
/// temporary value (RAM simulation) of the Genesis.
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks date="2024-Dec-03..10" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
private void InitConfigAndFlashRegisters()
|
||||
{
|
||||
if (_flashRegister == null || ConfigRegister == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_configRegisterNames.Clear();
|
||||
// If the FLASH registers do not exist, create those and fill it with default values
|
||||
if (_flashRegister.MeterRegisterDic.Count == 0)
|
||||
{
|
||||
foreach (var reg in ConfigRegister.MeterRegisterDic)
|
||||
{
|
||||
var regName = reg.Key.GetIdent();
|
||||
_flashRegisterNames.Add(regName);
|
||||
var regDef = ConfigRegister.GetRegisterDefinitionByName(regName);
|
||||
|
||||
// First clone entire register set to avoid exception if register is not available
|
||||
_flashRegister.MeterRegisterDic.TryAdd(reg.Key, null);
|
||||
|
||||
// Avoid writing of NOT writable registers
|
||||
if (reg.Key.RegisterDetail.Privilege.Lvl8 == Access.RW) // && reg.Key.DataType != typeof(Rpc))
|
||||
{
|
||||
// Add default value to FLASH register dictionary
|
||||
RegisterConverter.SetToDefault(regDef, out var value);
|
||||
_flashRegister.Set(regDef, value);
|
||||
}
|
||||
}
|
||||
|
||||
_flashRegisterNames.Sort();
|
||||
}
|
||||
|
||||
// Preset at initial login after start or reboot all config registers with the FLASH register values.
|
||||
// Those are set to default on initial start and after store configuration on a predefined value.
|
||||
foreach (var reg in ConfigRegister.MeterRegisterDic)
|
||||
{
|
||||
try
|
||||
{
|
||||
var regName = reg.Key.GetIdent();
|
||||
_configRegisterNames.Add(regName);
|
||||
var regDef = ConfigRegister.GetRegisterDefinitionByName(regName);
|
||||
|
||||
// Avoid writing of NOT writable registers, only read write makes sense as others cannot be read
|
||||
// back!
|
||||
if (reg.Key.RegisterDetail.Privilege.Lvl8 == Access.RW) //&& reg.Key.DataType != typeof(Rpc))
|
||||
{
|
||||
var flashData = _flashRegister.Get(regName);
|
||||
|
||||
// Throws an exception if register doesn't exist, but we want to go ahead with the others
|
||||
ConfigRegister.Set(regDef, flashData);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error($"Slot:{Slot} - {ex.Message}");
|
||||
}
|
||||
_configRegisterNames.Sort();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion ----------------------------- Mock Genesis Initialization ------------------------------------------
|
||||
|
||||
#region -------------------------------- Mock Genesis Simulation ----------------------------------------------
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Simulate login to mock Genesis for test purposes
|
||||
/// </summary>
|
||||
/// <remarks date="2024-Nov-28" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
public override Boolean Login()
|
||||
{
|
||||
ReadMeterFirmwareAndAssignRegisters();
|
||||
IsLoggedOn = true;
|
||||
return IsLoggedOn;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Simulate logout to mock Genesis for test purposes
|
||||
/// </summary>
|
||||
/// <remarks date="2024-Nov-28" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
public override Boolean Logout()
|
||||
{
|
||||
IsLoggedOn = false;
|
||||
return IsLoggedOn;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Simulate login with password to mock Genesis for test purposes
|
||||
/// </summary>
|
||||
/// <remarks date="2024-Nov-28" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
public override Boolean Login(String password, Boolean runImmediately = true,
|
||||
Boolean skipReadMeterFwAndAssignRegisters = false)
|
||||
{
|
||||
Password = password;
|
||||
return Login();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mock Write Register:
|
||||
/// - Optional: wait for result and validate.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Data type of Register</typeparam>
|
||||
/// <param name="regName">Register to change</param>
|
||||
/// <param name="value">Value to save</param>
|
||||
/// <param name="waitForResult">wait until result is ready</param>
|
||||
/// <param name="checkRegister">check the content of the register by read back</param>
|
||||
/// <param name="skipRetryErrorCode">skip retries on this error code return</param>
|
||||
/// <returns>true on successful operation</returns>
|
||||
/// <remarks date="2024-Dec-02..03" author="Thomas Wiedebusch">
|
||||
/// - Initial mock implementation.
|
||||
/// </remarks>
|
||||
/// <remarks date="2024-Dec-10" author="Thomas Wiedebusch">
|
||||
/// - Capture "SYSTEM_TriggerUpgrade" to force a reboot and install the FW defined in the actual FW package
|
||||
/// description file.
|
||||
/// - Store calibration executed on calibration registers.
|
||||
/// </remarks>
|
||||
public override Boolean WriteRegister<T>(String regName, T value, Boolean waitForResult = true,
|
||||
Boolean checkRegister = false, UInt16 skipRetryErrorCode = CommunicationConfig.SkipRetryErrorCode)
|
||||
{
|
||||
try
|
||||
{
|
||||
var regDef = ConfigRegister.GetRegisterDefinitionByName(regName);
|
||||
var data = RegisterConverter.ValueToByteArray(value);
|
||||
var hideDataInLog = regDef.RegisterName.Contains("EncryptionKey") ||
|
||||
regDef.RegisterName.Contains("Password");
|
||||
|
||||
var rawMsg = RegisterConverter.GetRegisterRawText(regDef, data, hideDataInLog);
|
||||
Logger.Info($"Slot:{Slot} - Write register({regDef.GetIdent()}), record({rawMsg})");
|
||||
|
||||
// Check for special response for predefined registers which reply with a changed
|
||||
// parameter like SENSUSRADIO_SystemState set to 0xFF creates a reply of 0x02.
|
||||
// This has to be done BEFORE ConfigRegister.Set!
|
||||
CheckAndModifySpecialReplies(regName, data);
|
||||
|
||||
// Avoid writing of NOT writable registers and out of range of register value
|
||||
if (!PreRegisterWrite(regDef, data))
|
||||
return false;
|
||||
|
||||
// Throws an exception if register doesn't exist
|
||||
ConfigRegister.Set(regDef, data);
|
||||
|
||||
// For mock simulation the write register is going to kick-off special activities
|
||||
CheckSpecialActivities(regName, value);
|
||||
|
||||
// If no further action like check register or read-back is required, exit here with success
|
||||
if (!waitForResult && !checkRegister)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// If register check by read back is not required we return the acknowledgment state
|
||||
if (!checkRegister || regDef.RegisterDetail.Privilege.Lvl8 == Access.WO)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var readBackData = ReadRegister(regName, data.Length, skipRetryErrorCode);
|
||||
if (readBackData == null)
|
||||
return false;
|
||||
|
||||
// Check if register read was okay and read and written data are EQUAL
|
||||
for (var i = 0; i < data.Length; i++)
|
||||
{
|
||||
if (readBackData[i] != data[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error($"Slot:{Slot} - {e.Message}");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check for special activities needed to execute on register write access:
|
||||
/// - Store configuration to safe all values of a single App to the simulated FLASH memory,
|
||||
/// - Store calibration stores all defined register <see cref="CalibrationResults.CalibrationRegisterNames"/>,
|
||||
/// to the simulated FLASH memory,
|
||||
/// - Trigger upgrade forces a reboot of the meter including a reload of all applications and regeneration of
|
||||
/// all registers.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="regName"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <remarks date="2024-Dec-10" author="Thomas Wiedebusch">
|
||||
/// - Initial MockGenesis simulation.
|
||||
/// </remarks>
|
||||
private void CheckSpecialActivities<T>(String regName, T value)
|
||||
{
|
||||
// Capture "StoreConfiguration" to copy config register contents of App to FLASH
|
||||
var searchString = "_StoreConfiguration";
|
||||
if (regName.Contains(searchString))
|
||||
{
|
||||
var appName = regName.Replace(searchString, "");
|
||||
FlashMemory(appName);
|
||||
}
|
||||
|
||||
// Capture "StoreCalibration" to copy config register contents of App to FLASH
|
||||
searchString = "GENESISFLOW_StoreCalibration";
|
||||
if (regName.Contains(searchString))
|
||||
{
|
||||
// Store single parameter to FLASH
|
||||
foreach (var registerName in CalibrationResults.CalibrationRegisterNames)
|
||||
SingleParameterFlashMemory(registerName);
|
||||
}
|
||||
|
||||
// Capture "UpgradePermissions" to copy config register contents of App to FLASH as
|
||||
// SYSTEM doesn't have a "StoreConfiguration" command
|
||||
searchString = "SYSTEM_UpgradePermissions";
|
||||
if (regName.Contains(searchString))
|
||||
{
|
||||
SingleParameterFlashMemory(searchString);
|
||||
}
|
||||
|
||||
// Capture "SYSTEM_TriggerUpgrade" to force a reboot and install the actual given firmware
|
||||
// package description file as FW.
|
||||
searchString = "SYSTEM_TriggerUpgrade";
|
||||
if (regName.Equals(searchString) && typeof(T) == typeof(Boolean))
|
||||
{
|
||||
var forceTriggerUpgrade = (Boolean)Convert.ChangeType(value, typeof(Boolean));
|
||||
if (forceTriggerUpgrade)
|
||||
RebootGenesis();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check for special response for predefined registers which reply with a changed parameter like
|
||||
/// SENSUSRADIO_SystemState set to 0xFF creates a reply of 0x02. This should simulate the real
|
||||
/// GenesisMeter reply.
|
||||
/// </summary>
|
||||
/// <param name="regName"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <remarks date="2024-Dec-10" author="Thomas Wiedebusch">
|
||||
/// - Initial MockGenesis simulation.
|
||||
/// </remarks>
|
||||
private static void CheckAndModifySpecialReplies(String regName, Byte[] data)
|
||||
{
|
||||
|
||||
if (SpecialRegisterReplies.Any(n => regName.Contains(n.RegisterIdent)))
|
||||
{
|
||||
foreach (var special in SpecialRegisterReplies.Where(special =>
|
||||
regName.Contains(special.RegisterIdent)))
|
||||
{
|
||||
var retVal = true;
|
||||
|
||||
// Avoid buffer overflow
|
||||
if (data.Length < special.ReadBackValue.Length)
|
||||
break;
|
||||
|
||||
for (var i = 0; i < special.WriteValue.Length; i++)
|
||||
{
|
||||
// Check the required input which forces a change of the response
|
||||
if (data[i] != special.WriteValue[i])
|
||||
retVal = false;
|
||||
}
|
||||
|
||||
if (!retVal)
|
||||
break;
|
||||
|
||||
// Exchange the received value with the special reply
|
||||
for (var i = 0; i < special.ReadBackValue.Length; i++)
|
||||
{
|
||||
data[i] = special.ReadBackValue[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mock Read Register and return byte array for test purposes stored in the config register dictionary.
|
||||
/// </summary>
|
||||
/// <param name="regName"></param>
|
||||
/// <param name="expectedLength">expected length for response</param>
|
||||
/// <param name="skipRetryErrorCode">skip retries on this error code return</param>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2024-Dec-02..03" author="Thomas Wiedebusch">
|
||||
/// - Initial mock implementation.
|
||||
/// </remarks>
|
||||
public override Byte[] ReadRegister(String regName, Int32? expectedLength = null,
|
||||
UInt16 skipRetryErrorCode = CommunicationConfig.SkipRetryErrorCode)
|
||||
{
|
||||
try
|
||||
{
|
||||
var regDef = ConfigRegister.GetRegisterDefinitionByName(regName);
|
||||
var hideDataInLog = regDef.RegisterName.Contains("EncryptionKey");
|
||||
|
||||
// Avoid reading of NOT readable registers
|
||||
if (regDef.RegisterDetail.Privilege.Lvl8 != Access.RW &&
|
||||
regDef.RegisterDetail.Privilege.Lvl8 != Access.RO)
|
||||
return null;
|
||||
|
||||
var result = ConfigRegister.Get(regName);
|
||||
// Avoid access of not present register
|
||||
if (result == null)
|
||||
{
|
||||
Logger.Error($"Slot:{Slot} - Read register({regDef.GetIdent()}) returns value (null)");
|
||||
return null;
|
||||
}
|
||||
|
||||
var rawMsg = RegisterConverter.GetRegisterRawText(regDef, result, hideDataInLog);
|
||||
Logger.Info($"Slot:{Slot} - Read register({regDef.GetIdent()}), record({rawMsg})");
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error($"Slot:{Slot} - {e.Message}");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The simulation of the Genesis reboot:
|
||||
/// - Login to create the actual installed
|
||||
/// Kill all old applications,
|
||||
/// this will force a regeneration of a valid application list and config register dictionary!
|
||||
/// This will include the copy of FLASH register values or defaults to the config meter dictionary.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2024-Dec-03" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
/// <remarks date="2024-Dec-07" author="Thomas Wiedebusch">
|
||||
/// - Reboot count used to check for success of reboot.
|
||||
/// </remarks>
|
||||
/// <remarks date="2024-Dec-11..12" author="Thomas Wiedebusch">
|
||||
/// - Prepared to override the Genesis reboot used in <see cref="MeterResetPsu"/>.
|
||||
/// </remarks>
|
||||
public override StatusReturn RebootGenesis()
|
||||
{
|
||||
// ReLogin to build initial registers if it has not been performed in advance
|
||||
ReLogin();
|
||||
|
||||
const String registerName = "CUSTOMER_RebootCount";
|
||||
var rebootCountBeforeReboot = RegisterConverter.ByteArrayToValue<UInt32>(ReadRegister(registerName));
|
||||
|
||||
// Simulate reboot execution by increasing the reboot count by one
|
||||
rebootCountBeforeReboot++;
|
||||
if (WriteRegister(registerName, rebootCountBeforeReboot))
|
||||
{
|
||||
SingleParameterFlashMemory(registerName);
|
||||
}
|
||||
|
||||
// Kill all old applications to force a regeneration of a valid application list
|
||||
// and config register dictionary!
|
||||
Logout();
|
||||
FwVersion = "";
|
||||
InstalledFwVersion = 0;
|
||||
Region = "";
|
||||
RadioFrequencyMhz = null;
|
||||
MeterAppListVersion.Clear();
|
||||
ConfigRegister.MeterRegisterDic.Clear();
|
||||
ConfigApplications.Clear();
|
||||
|
||||
// Login to build initial registers if it has not been performed in advance
|
||||
Login();
|
||||
var rebootCountAfterReboot = RegisterConverter.ByteArrayToValue<UInt32>(ReadRegister(registerName));
|
||||
|
||||
return rebootCountAfterReboot == rebootCountBeforeReboot ? StatusReturn.Okay : StatusReturn.Failed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear the config registers to simulate an invalid load or invalid configuration.json
|
||||
/// </summary>
|
||||
/// <remarks date="2025-Feb-17" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
public void KillConfigRegisters()
|
||||
{
|
||||
ConfigRegister.MeterRegisterDic.Clear();
|
||||
}
|
||||
|
||||
#endregion ----------------------------- Mock Genesis simulation ----------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{D7A7E1FF-D024-407F-B30D-4C519CFA7BF1}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Xylem.Common.Hardware.WaterMeter.Genesis.MockGenesis</RootNamespace>
|
||||
<AssemblyName>Xylem.Common.Hardware.WaterMeter.Genesis.MockGenesis</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="NCrunch.Framework, Version=5.11.0.0, Culture=neutral, PublicKeyToken=01d101bf6f3e0aea, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\..\packages\NCrunch.Framework.5.11.0\lib\net35\NCrunch.Framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\..\packages\NLog.5.2.2\lib\net46\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="MockGenesis.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\CommonCore\CommonCore.csproj">
|
||||
<Project>{1B02C79E-0B19-43E2-8F6B-71EF0C786C97}</Project>
|
||||
<Name>CommonCore</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\..\Logic\ProductionOrderCore\ProductionOrderCore.csproj">
|
||||
<Project>{6D2777BB-7A88-466D-A49B-3266F9BF0160}</Project>
|
||||
<Name>ProductionOrderCore</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\WaterMeterCore\WaterMeterRegisters\WaterMeterRegisters.csproj">
|
||||
<Project>{26AFCF1E-1287-48B8-A506-32B1E8A0DD0E}</Project>
|
||||
<Name>WaterMeterRegisters</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Applications\Applications.csproj">
|
||||
<Project>{315e94b8-b82f-4b25-b5bd-297df3bc1d54}</Project>
|
||||
<Name>Applications</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\GenesisConfig\GenesisConfig.csproj">
|
||||
<Project>{F013A56B-7BE6-4852-9CD8-B971CD1ADD0C}</Project>
|
||||
<Name>GenesisConfig</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\GenesisCore\GenesisCore.csproj">
|
||||
<Project>{04201E95-90A0-4B73-A72F-379739B2A3AE}</Project>
|
||||
<Name>GenesisCore</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\GenesisFile\GenesisFile.csproj">
|
||||
<Project>{2C6378C6-6BA1-4CEE-8992-8404D8369A90}</Project>
|
||||
<Name>GenesisFile</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Registers\Registers.csproj">
|
||||
<Project>{F4AAF7E6-7333-4284-B735-E32DEB076C64}</Project>
|
||||
<Name>Registers</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,5 @@
|
||||
<ProjectConfiguration>
|
||||
<Settings>
|
||||
<HiddenComponentWarnings />
|
||||
</Settings>
|
||||
</ProjectConfiguration>
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
[
|
||||
//Content missing CSD parameters to force a failure for register-restorer
|
||||
{
|
||||
"RegisterName": "SENSUSRADIO_RadioAddress",
|
||||
"RegisterValue": "GI6fMA==",
|
||||
"Source": 0
|
||||
},
|
||||
{
|
||||
"RegisterName": "SENSUSRADIO_EncryptionKey",
|
||||
"RegisterValue": "Dp+sxqDh7xw7J6SbrCFlNQ==",
|
||||
"Source": 0
|
||||
},
|
||||
{
|
||||
"RegisterName": "GENESISFLOW_MeterSize",
|
||||
"RegisterValue": "AAAAAQ==",
|
||||
"Source": 0
|
||||
},
|
||||
{
|
||||
"RegisterName": "GENESISFLOW_DisplayUnits",
|
||||
"RegisterValue": "AAAAAA==",
|
||||
"Source": 0
|
||||
},
|
||||
{
|
||||
"RegisterName": "METROLOGYASST_FlowUnits",
|
||||
"RegisterValue": "AAAABA==",
|
||||
"Source": 0
|
||||
},
|
||||
{
|
||||
"RegisterName": "SENSUSRADIO_FrequencyIndicator",
|
||||
"RegisterValue": "AAABsQ==",
|
||||
"Source": 0
|
||||
},
|
||||
{
|
||||
"RegisterName": "METROLOGYASST_PulseMode",
|
||||
"RegisterValue": "AAAABQ==",
|
||||
"Source": 0
|
||||
},
|
||||
{
|
||||
"RegisterName": "METROLOGYASST_PulseLength",
|
||||
"RegisterValue": "AAAACA==",
|
||||
"Source": 0
|
||||
},
|
||||
{
|
||||
"RegisterName": "METROLOGYASST_PressurePresent",
|
||||
"RegisterValue": "AAAAAA==",
|
||||
"Source": 0
|
||||
},
|
||||
{
|
||||
"RegisterName": "METROLOGYASST_TemperatureUnits",
|
||||
"RegisterValue": "AAAAAA==",
|
||||
"Source": 0
|
||||
},
|
||||
{
|
||||
"RegisterName": "METROLOGYASST_PressureRate",
|
||||
"RegisterValue": "AAAAAA==",
|
||||
"Source": 0
|
||||
},
|
||||
{
|
||||
"RegisterName": "METROLOGYASST_PressureUnits",
|
||||
"RegisterValue": "AAAAAA==",
|
||||
"Source": 0
|
||||
},
|
||||
{
|
||||
"RegisterName": "METROLOGYASST_PulseWeight",
|
||||
"RegisterValue": "ADDUAA==",
|
||||
"Source": 0
|
||||
},
|
||||
{
|
||||
"RegisterName": "SENSUSRADIO_MbusState",
|
||||
"RegisterValue": "AAAABw==",
|
||||
"Source": 0
|
||||
},
|
||||
{
|
||||
"RegisterName": "SENSUSRADIO_OmTxInterval",
|
||||
"RegisterValue": "AAAOEA==",
|
||||
"Source": 0
|
||||
},
|
||||
{
|
||||
"RegisterName": "SENSUSRADIO_TxInterval",
|
||||
"RegisterValue": "AAAADw==",
|
||||
"Source": 0
|
||||
},
|
||||
{
|
||||
"RegisterName": "SENSUSRADIO_WakeupInterval",
|
||||
"RegisterValue": "AAAAAw==",
|
||||
"Source": 0
|
||||
},
|
||||
{
|
||||
"RegisterName": "SENSUSRADIO_LatInterval",
|
||||
"RegisterValue": "AAAAAw==",
|
||||
"Source": 0
|
||||
},
|
||||
{
|
||||
"RegisterName": "GENESISFLOW_DisplayPow10",
|
||||
"RegisterValue": "/f///w==",
|
||||
"Source": 0
|
||||
},
|
||||
{
|
||||
"RegisterName": "METROLOGYASST_FlowPoint",
|
||||
"RegisterValue": "AgAAAA==",
|
||||
"Source": 0
|
||||
}
|
||||
]
|
||||
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
[{"RegisterName":"GENESISFLOW_MeterSize","RegisterValue":"AAAACw==","Source":0},{"RegisterName":"GENESISFLOW_DisplayUnits","RegisterValue":"AAAAAg==","Source":0},{"RegisterName":"METROLOGYASST_FlowUnits","RegisterValue":"AAAABg==","Source":0},{"RegisterName":"METROLOGYASST_PulseMode","RegisterValue":"AAAABQ==","Source":0},{"RegisterName":"METROLOGYASST_PulseLength","RegisterValue":"AAAACA==","Source":0},{"RegisterName":"METROLOGYASST_PressurePresent","RegisterValue":"AAAAAQ==","Source":0},{"RegisterName":"METROLOGYASST_TemperatureUnits","RegisterValue":"AAAAAQ==","Source":0},{"RegisterName":"METROLOGYASST_PressureRate","RegisterValue":"AADqYA==","Source":0},{"RegisterName":"METROLOGYASST_PressureUnits","RegisterValue":"AAAAAA==","Source":0},{"RegisterName":"GENESISFLOW_ForwardArrow","RegisterValue":"AAAAAA==","Source":0},{"RegisterName":"METROLOGYASST_PulseWeight","RegisterValue":"ABJ7ww==","Source":0},{"RegisterName":"GENESISFLOW_DisplayPow10","RegisterValue":"/////w==","Source":0},{"RegisterName":"METROLOGYASST_FlowPoint","RegisterValue":"AwAAAA==","Source":0},{"RegisterName":"CUSTOMER_AlarmEnableMask","RegisterValue":"AAAAAA==","Source":1},{"RegisterName":"GENESISFLOW_LowFlowThreshold","RegisterValue":"AAAAyA==","Source":1},{"RegisterName":"GENESISFLOW_LowFlowMaxPeriod","RegisterValue":"ADwAAA==","Source":1},{"RegisterName":"GENESISFLOW_Timeout","RegisterValue":"AAE=","Source":1},{"RegisterName":"GENESISFLOW_MinValidToF","RegisterValue":"ANG3Fw==","Source":1},{"RegisterName":"GENESISFLOW_MinValidAmplitude","RegisterValue":"JYAAAA==","Source":1},{"RegisterName":"GENESISFLOW_MaxValidToF","RegisterValue":"AXl8ww==","Source":1},{"RegisterName":"GENESISFLOW_MaxValidDeltaToF","RegisterValue":"ABxPvg==","Source":1},{"RegisterName":"GENESISFLOW_MaxValidAmplitude","RegisterValue":"rwAAAA==","Source":1},{"RegisterName":"CUSTOMER_PressureLowDelay","RegisterValue":"AAAAPA==","Source":1},{"RegisterName":"CUSTOMER_PressureLowThreshold","RegisterValue":"AAOpgA==","Source":1},{"RegisterName":"CUSTOMER_PressureHighDelay","RegisterValue":"AAAAPA==","Source":1},{"RegisterName":"CUSTOMER_PressureHighThreshold","RegisterValue":"ABUOoA==","Source":1},{"RegisterName":"CUSTOMER_TemperatureLowDelay","RegisterValue":"AAAAPA==","Source":1},{"RegisterName":"CUSTOMER_TemperatureLowThreshold","RegisterValue":"AAAAFA==","Source":1},{"RegisterName":"CUSTOMER_TemperatureHighDelay","RegisterValue":"AAAAPA==","Source":1},{"RegisterName":"CUSTOMER_TemperatureHighThreshold","RegisterValue":"AAABDg==","Source":1},{"RegisterName":"CUSTOMER_ExcessFlowVolumeThreshold","RegisterValue":"APQkAA==","Source":1},{"RegisterName":"CUSTOMER_ExcessFlowTimeThreshold","RegisterValue":"AAAABQ==","Source":1},{"RegisterName":"CUSTOMER_LeakTimeThreshold","RegisterValue":"AAAQ4A==","Source":1},{"RegisterName":"CUSTOMER_LeakFlowThreshold","RegisterValue":"AAF3AA==","Source":1},{"RegisterName":"GENESISFLOW_LedMode","RegisterValue":"AAAAAA==","Source":1},{"RegisterName":"GENESISFLOW_ForwardArrow","RegisterValue":"AAAAAQ==","Source":1},{"RegisterName":"GENESISFLOW_SampleRate","RegisterValue":"AAI=","Source":1},{"RegisterName":"POWERMON_BatteryQuantity","RegisterValue":"AAAAAg==","Source":1},{"RegisterName":"SYSTEM_UpgradePermissions","RegisterValue":"AAAA/w==","Source":1},{"RegisterName":"POWERMON_WarnFromClamp","RegisterValue":"JZgGAA==","Source":1},{"RegisterName":"METROLOGYASST_TemperatureUnits","RegisterValue":"AAAAAQ==","Source":1},{"RegisterName":"CUSTOMER_ReverseFlowTimeThreshold","RegisterValue":"AAAAPA==","Source":1},{"RegisterName":"CUSTOMER_AlarmVisualMask","RegisterValue":"AAAAAA==","Source":1},{"RegisterName":"CUSTOMER_AlarmBroadcastMask","RegisterValue":"AAAAAA==","Source":1},{"RegisterName":"IRDA_AdapterPresenceLimit","RegisterValue":"AAM=","Source":1},{"RegisterName":"CUSTOMER_RebootCount","RegisterValue":"AAAAAA==","Source":1},{"RegisterName":"METROLOGYASST_PressureUnits","RegisterValue":"AAE=","Source":1},{"RegisterName":"GENESISFLOW_ArrowThreshold","RegisterValue":"AAAAAA==","Source":1},{"RegisterName":"METROLOGYASST_PressureRate","RegisterValue":"AADqYA==","Source":1},{"RegisterName":"CUSTOMER_InstallationTime","RegisterValue":"AAAAAA==","Source":1},{"RegisterName":"GENESISFLOW_MaxDeltaToFRange","RegisterValue":"AAIY3g==","Source":1},{"RegisterName":"GENESISFLOW_MaxDeltaToFDeviation","RegisterValue":"AAGtfw==","Source":1},{"RegisterName":"GENESISFLOW_StartHit","RegisterValue":"AAAABg==","Source":1},{"RegisterName":"METROLOGYASST_PulseEvenDistribution","RegisterValue":"AA==","Source":1}]
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Xylem.Common.Hardware.WaterMeter.Genesis.MockGenesis")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Xylem")]
|
||||
[assembly: AssemblyProduct("MockGenesis")]
|
||||
[assembly: AssemblyCopyright("Copyright © Xylem 2024")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("d7a7e1ff-d024-407f-b30d-4c519cfa7bf1")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NCrunch.Framework" version="5.11.0" targetFramework="net481" />
|
||||
<package id="NLog" version="5.2.2" targetFramework="net48" />
|
||||
</packages>
|
||||
@@ -130,7 +130,7 @@ namespace Xylem.Common.Hardware.WaterMeter.WaterMeterCore
|
||||
Boolean Login();
|
||||
|
||||
/// <summary>
|
||||
/// Start Login with out password service and a fixed password
|
||||
/// Start Login without password service and a fixed password
|
||||
/// </summary>
|
||||
/// <param name="password">password for login</param>
|
||||
/// <param name="runImmediately">execute immediately</param>
|
||||
@@ -209,9 +209,7 @@ namespace Xylem.Common.Hardware.WaterMeter.WaterMeterCore
|
||||
void StartCalibration();
|
||||
|
||||
/// <summary>
|
||||
/// Meter must have a active for calibration <see />
|
||||
/// Stop receive record from meter, decode and store record
|
||||
/// record will not calculate or store
|
||||
/// Meter must have an active Stop Record for calibration
|
||||
/// </summary>
|
||||
void StopCalibration();
|
||||
|
||||
@@ -282,6 +280,10 @@ namespace Xylem.Common.Hardware.WaterMeter.WaterMeterCore
|
||||
/// Clear all object set up on runtime
|
||||
/// </summary>
|
||||
void DisposeMeter();
|
||||
|
||||
/// <summary>
|
||||
/// Dispose the entire test bench
|
||||
/// </summary>
|
||||
void TestBenchDispose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,287 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts;
|
||||
using Xylem.Common.Metrology.Measurements;
|
||||
using Xylem.Common.Metrology.Measurements.Consts;
|
||||
|
||||
namespace Xylem.Common.Hardware.WaterMeter.WaterMeterCore
|
||||
{
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// IMeter is the highest level interface between a meter with direct communication to a test bench.
|
||||
/// has general things like calibration, measurement and set up routines.
|
||||
/// no specific meter stuff in here!
|
||||
/// it is always disposable
|
||||
/// </summary>
|
||||
[Guid("7BD20046-DF8C-44A6-8F6B-687FAA26FA71")
|
||||
, ComVisible(true)
|
||||
, InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
|
||||
|
||||
public interface IMeter : IDisposable
|
||||
{
|
||||
#region events
|
||||
|
||||
/// <summary>
|
||||
/// occurs when ProcessState has changed
|
||||
/// </summary>
|
||||
event EventHandler OnProcessStatusChanged;
|
||||
|
||||
/// <summary>
|
||||
/// occurs when ErrorState has changed
|
||||
/// </summary>
|
||||
event EventHandler OnErrorStatusChanged;
|
||||
|
||||
/// <summary>
|
||||
/// occurs when Init is completed
|
||||
/// </summary>
|
||||
event EventHandler OnInitCompleted;
|
||||
|
||||
/// <summary>
|
||||
/// occurs when the initialization for Measurement is completed
|
||||
/// </summary>
|
||||
event EventHandler OnMeasurementInitCompleted;
|
||||
|
||||
/// <summary>
|
||||
/// occurs when the Measurement is completed
|
||||
/// </summary>
|
||||
event EventHandler OnMeasurementCompleted;
|
||||
|
||||
/// <summary>
|
||||
/// occurs when the initialization for calibration is completed
|
||||
/// </summary>
|
||||
event EventHandler OnCalibInitCompleted;
|
||||
|
||||
/// <summary>
|
||||
/// occurs when the calibration is completed
|
||||
/// </summary>
|
||||
event EventHandler OnCalibCompleted;
|
||||
|
||||
/// <summary>
|
||||
/// occurs when meter gets disposed
|
||||
/// </summary>
|
||||
event EventHandler OnDisposeCompleted;
|
||||
#endregion
|
||||
|
||||
#region properties
|
||||
/// <summary>
|
||||
/// unique meter identification
|
||||
/// </summary>
|
||||
String SerialNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// read-only to see current Process state <see cref="ProcessState" />
|
||||
/// </summary>
|
||||
ProcessState ProcessStatus { get; }
|
||||
|
||||
/// <summary>
|
||||
/// the current slot in test-bench
|
||||
/// </summary>
|
||||
Int32 Slot { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Setup of intermediate update time for measurement updates and overflow detections,
|
||||
/// has to be calculated depending on flow-rate and nominal diameter (DN)
|
||||
/// </summary>
|
||||
Int32 IntermediateUpdateTimeS { get; set; }
|
||||
/// <summary>
|
||||
/// Skip the test bench preparation process
|
||||
/// </summary>
|
||||
Boolean SkipPreparationForTestBench { get; set; }
|
||||
/// <summary>
|
||||
/// Set the current action test
|
||||
/// </summary>
|
||||
String CurrentActionText { get; set; }
|
||||
#endregion
|
||||
|
||||
#region method
|
||||
|
||||
/// <summary>
|
||||
/// Read the PcbId from IMeter, if device has no readable PcbId simulate one
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
String GetPcbId();
|
||||
|
||||
/// <summary>
|
||||
/// Open Com ports, try some communication, login
|
||||
/// </summary>
|
||||
void ConnectMeter();
|
||||
|
||||
/// <summary>
|
||||
/// Setup up meter from config file. just a workaround for vb6 calls. please do not use if your working with .net
|
||||
/// </summary>
|
||||
/// <param name="slot">Slot Number for Test bench</param>
|
||||
/// <param name="ignoreCorruptedData">don´t send CRC error or telegrams with error flag to caller</param>
|
||||
/// <param name="useRequest"></param>
|
||||
/// <param name="useStreaming"></param>
|
||||
void SetupFromConfigFile(Int32 slot, Boolean ignoreCorruptedData = true, Boolean useRequest = true, Boolean useStreaming = true);
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Logout from device
|
||||
/// </summary>
|
||||
Boolean Logout();
|
||||
|
||||
/// <summary>
|
||||
/// Start Login with password service
|
||||
/// </summary>
|
||||
Boolean Login();
|
||||
|
||||
/// <summary>
|
||||
/// Start Login with out password service and a fixed password
|
||||
/// </summary>
|
||||
/// <param name="password">password for login</param>
|
||||
/// <param name="runImmediately">execute immediately</param>
|
||||
/// <param name="skipReadMeterFwAndAssignRegisters">skip app readout and register generation to speed up
|
||||
/// the initial connection process</param>
|
||||
Boolean Login(String password, Boolean runImmediately = true, Boolean skipReadMeterFwAndAssignRegisters = false);
|
||||
|
||||
/// <summary>
|
||||
/// set up measurement parameter and set meter into test-mode
|
||||
/// </summary>
|
||||
void InitMeasurement();
|
||||
|
||||
/// <summary>
|
||||
/// Starting a Measurement
|
||||
/// Meter must be initialized <see cref="InitMeasurement" />
|
||||
/// Start to receive record from meter and decode this record into <code>MeasurementRecord</code>
|
||||
/// <see cref="IMeasurementRecord" />
|
||||
/// </summary>
|
||||
[ComVisible(false)]
|
||||
void StartMeasurement();
|
||||
|
||||
/// <summary>
|
||||
/// Meter must have a active measurement <see cref="StartMeasurement" />
|
||||
/// Stop receive record from meter and decode record
|
||||
/// </summary>
|
||||
void StopMeasurement();
|
||||
|
||||
/// <remarks date="2018JAN09" author="drabesch">
|
||||
/// - simplify the measurement results handling
|
||||
/// - getting the main measurement of the entire device (combination of all paths)
|
||||
/// - add MeasurementResult
|
||||
/// - remove all other methods
|
||||
/// </remarks>
|
||||
/// <summary>
|
||||
/// After a completed measurement , you can grab <see cref="MeasurementResults"/>
|
||||
/// </summary>
|
||||
/// <returns>Calculated results</returns>
|
||||
MeasurementResults GetMainMeasurementResult(Double? refVolume, Double? refTimeS, Boolean intermediateMeasurement = false, MeasurementDirection dir = MeasurementDirection.TakeBoth);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The first measurement is ALWAYS a FlowTestRecord.
|
||||
/// </summary>
|
||||
List<MeasurementResults> GetAllMeasurementResults(Double? refVolume, Double? refTimeS,
|
||||
Boolean intermediateMeasurement = false, Int32? channel = null, MeasurementDirection dir = MeasurementDirection.TakeBoth);
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// get current state of the running measurement
|
||||
/// </summary>
|
||||
/// <param name="onlyChannelNr">leave empty for an aggregate state for all measurements or pass the channel number to check</param>
|
||||
/// <returns></returns>
|
||||
MeasurementStates GetMeasurementState(Int32? onlyChannelNr = null );
|
||||
|
||||
/// <summary>
|
||||
/// Request for intermediate measurement state.
|
||||
/// </summary>
|
||||
/// <param name="onlyChannelNr"></param>
|
||||
/// <returns></returns>
|
||||
Boolean RequestIntermediateMeasurementState(Int32? onlyChannelNr = null);
|
||||
|
||||
/// <summary>
|
||||
/// set up calibration parameter (calibration factor to default) and set meter into calibration mode
|
||||
/// </summary>
|
||||
void InitCalibration();
|
||||
|
||||
/// <summary>
|
||||
/// Starting a Calibration
|
||||
/// Meter must be initialized <see cref="InitCalibration" />
|
||||
/// Start to receive record from meter, decode and store this record
|
||||
/// no <see cref="IMeasurementRecord" /> available
|
||||
/// To finish calibration process run <see cref="StopCalibration" />
|
||||
/// </summary>
|
||||
[ComVisible(false)]
|
||||
void StartCalibration();
|
||||
|
||||
/// <summary>
|
||||
/// Meter must have a active for calibration <see />
|
||||
/// Stop receive record from meter, decode and store record
|
||||
/// record will not calculate or store
|
||||
/// </summary>
|
||||
void StopCalibration();
|
||||
|
||||
/// <summary>
|
||||
/// Get current state of the running calibration
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
MeasurementStates GetCalibrationState();
|
||||
|
||||
/// <summary>
|
||||
/// Calculate calibration factor for static and flying start / stop
|
||||
/// Results kept internal and not being saved to meter.
|
||||
/// if you want to store them on meter use <see cref="SetCalibFactorsAllChannels" />
|
||||
/// </summary>
|
||||
/// <param name="refVolumeCm">the reference volume is essential for calculation of calibration factor</param>
|
||||
/// <param name="refTimeS">the reference time is needed for flying start/stop</param>
|
||||
/// <param name="reqDeviationPercent">the required deviation to set the scale apart from 0</param>
|
||||
/// <param name="maxCalibFactorTolerancePercent"> override the default max calibration factor tolerance</param>
|
||||
void BuildAndCheckCalibFactorsAllChannels(Double refVolumeCm, Double? refTimeS = null, Double reqDeviationPercent = 0.0, Double maxCalibFactorTolerancePercent = 0.0);
|
||||
|
||||
/// <summary>
|
||||
/// Save calculated calibration on meter if no calibration results available an exception occurred
|
||||
/// </summary>
|
||||
void SetCalibFactorsAllChannels(Boolean justLog = false);
|
||||
|
||||
/// <summary>
|
||||
/// To control the LCD from meter for status information etc.
|
||||
/// </summary>
|
||||
/// <param name="release">if set to true the meter will show his normal screen, if set to false the next parameter will shown in display</param>
|
||||
/// <param name="textInHex">test shown in LCD in byte array as hex value (0x33,0xFF shows 33FF on screen)</param>
|
||||
void SetLcdText(Boolean release, Byte[] textInHex);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sets Display text and update production database
|
||||
/// </summary>
|
||||
/// <param name="newState">New ProductionState</param>
|
||||
/// <param name="webRequest">web logging required per default true, for offline usage set to false</param>
|
||||
void SetProcessState(DisplayCodes newState, Boolean webRequest = true);
|
||||
|
||||
/// <summary>
|
||||
/// Get last Process State
|
||||
/// </summary>
|
||||
DisplayCodes GetLastProcessState();
|
||||
|
||||
/// <summary>
|
||||
/// Add external text to internal log file handling
|
||||
/// </summary>
|
||||
/// <param name="text">text to log</param>
|
||||
void WriteLog(String text);
|
||||
|
||||
/// <summary>
|
||||
/// Enable/Disable Raw record Logging
|
||||
/// </summary>
|
||||
/// <param name="on">True = Write Raw record into log/ false = Stop write raw record into log </param>
|
||||
void LogRawData(Boolean on);
|
||||
|
||||
/// <summary>
|
||||
/// Check if the meter has any errors that can occur on a measurement
|
||||
/// the error reason has find out in the log files
|
||||
/// </summary>
|
||||
/// <returns>false = everything is good, detect at least one error</returns>
|
||||
Boolean CheckStateAfterMeasurement();
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Clear all object set up on runtime
|
||||
/// </summary>
|
||||
void DisposeMeter();
|
||||
void TestBenchDispose();
|
||||
}
|
||||
}
|
||||
+39
-16
@@ -123,9 +123,20 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
|
||||
Progress = 50;
|
||||
|
||||
var genesisStatus = new GenesisStatus();
|
||||
//TODO Roland: Check this implementation --- START
|
||||
if (Meter.Region.Equals("EMEA"))
|
||||
{
|
||||
genesisStatus.QuiescentCurrent_uA = 119.8;
|
||||
genesisStatus.EstimatedProductionBatteryLoadPercent = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
genesisStatus.QuiescentCurrent_uA = 77.7;
|
||||
genesisStatus.EstimatedProductionBatteryLoadPercent = 1.0;
|
||||
}
|
||||
|
||||
// this calculates all life time values
|
||||
if (!GenesisStatusHandler.BuildLifeTimeInformation(Meter, genesisStatus))
|
||||
// this calculates all lifetime values
|
||||
if (!GenesisStatusHandler.BuildLifeTimeInformation(Meter, genesisStatus, out _))
|
||||
{
|
||||
|
||||
setTxt("Batterie nicht lesbar", true, true);
|
||||
@@ -142,27 +153,39 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
|
||||
return;
|
||||
}
|
||||
|
||||
if (!genesisStatus.UNTStatus)
|
||||
if (genesisStatus.AlternativeRequiredBatteryLoadPercent != null &&
|
||||
genesisStatus.DrainedBatteryLoadPercent > genesisStatus.AlternativeRequiredBatteryLoadPercent)
|
||||
{
|
||||
if (Meter.Region == "NA")
|
||||
{
|
||||
|
||||
|
||||
currentProcessState = ProductionProcessState.Error;
|
||||
}
|
||||
|
||||
//
|
||||
setTxt($"UNT Limit überschritten Limit{genesisStatus.UNTLimit} vs {genesisStatus.DrainedBatteryLoad_uAs}", true, true);
|
||||
|
||||
|
||||
setTxt($"{Meter.Region} limit OK ", true, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
setTxt($"{Meter.Region} limit überschritten ", true, true);
|
||||
}
|
||||
setTxt($"Maximum drained battery load: {genesisStatus.AlternativeRequiredBatteryLoadPercent} % - " +
|
||||
$" Meter reports drained battery load: {genesisStatus.DrainedBatteryLoad_uAs} %", true, true);
|
||||
//if (!genesisStatus.UNTStatus)
|
||||
//{
|
||||
// if (Meter.Region == "NA")
|
||||
// {
|
||||
|
||||
|
||||
// currentProcessState = ProductionProcessState.Error;
|
||||
// }
|
||||
|
||||
// //
|
||||
// setTxt($"UNT Limit überschritten Limit{genesisStatus.UNTLimit} vs {genesisStatus.DrainedBatteryLoad_uAs}", true, true);
|
||||
|
||||
|
||||
//}
|
||||
//TODO Roland: Check this implementation --- STOP
|
||||
|
||||
if (genesisStatus.RemainingLifeTimeYears < 20)
|
||||
{
|
||||
if (genesisStatus.DrainedBatteryLoadPercent > 9)
|
||||
{
|
||||
currentProcessState = ProductionProcessState.Error;
|
||||
setTxt("EMEA Limit überschritten Limit 8% vs {genesisStatus.DrainedBatteryLoadPercent}", true, true);
|
||||
setTxt($"EMEA Limit überschritten Limit 8% vs {genesisStatus.DrainedBatteryLoadPercent}", true, true);
|
||||
|
||||
|
||||
Meter.WriteLog("Batterie über 10% entladen");
|
||||
@@ -212,7 +235,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
|
||||
|
||||
|
||||
|
||||
if (currentProcessState != ProductionProcessState.Error)
|
||||
if (currentProcessState != ProductionProcessState.Error)
|
||||
{
|
||||
currentProcessState = ProductionProcessState.Done;
|
||||
return;
|
||||
|
||||
+2
-1
@@ -14,6 +14,7 @@ using System.Windows.Forms;
|
||||
using System.Windows.Threading;
|
||||
using Xylem.Common.CommonCore.Configuration;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.Consts;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
|
||||
using Xylem.Common.Logic.SoftwareAccessHelper;
|
||||
using Button = System.Windows.Controls.Button;
|
||||
@@ -322,7 +323,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
|
||||
stm.Start(); // Start polling
|
||||
|
||||
DebugMessage(" OK\r\n", true);
|
||||
Meter.ResetAlarm(GenesisMeter.Alarm.EMPTY_PIPE);
|
||||
Meter.ResetAlarm(Alarm.EMPTY_PIPE);
|
||||
Thread.Sleep(5000);
|
||||
//Meter.WriteRegister("SENSUSRADIO_SYSTEMSTATE", 0x01, true, false);
|
||||
forcePush();
|
||||
|
||||
+5
-4
@@ -6,6 +6,7 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Windows.Controls;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.Consts;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
|
||||
|
||||
@@ -165,11 +166,11 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
|
||||
}
|
||||
else
|
||||
{
|
||||
Meter.ResetAlarm(GenesisMeter.Alarm.ALL);//(true, new byte[] { 0x00, 0x00, 0x00, 0x01 });
|
||||
Meter.ResetAlarm(Alarm.ALL);//(true, new byte[] { 0x00, 0x00, 0x00, 0x01 });
|
||||
|
||||
Meter.SetLcdText(true, new Byte[] { 0x00, 0x00, 0x00, 0x01 });
|
||||
|
||||
Meter.ResetAlarm(GenesisMeter.Alarm.EMPTY_PIPE);//(true, new byte[] { 0x00, 0x00, 0x00, 0x01 });
|
||||
Meter.ResetAlarm(Alarm.EMPTY_PIPE);//(true, new byte[] { 0x00, 0x00, 0x00, 0x01 });
|
||||
|
||||
Meter.WriteRegister("SENSUSRADIO_SystemState", 0xFF);
|
||||
Meter.Logout();
|
||||
@@ -253,11 +254,11 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
|
||||
}
|
||||
}
|
||||
|
||||
Meter.ResetAlarm(GenesisMeter.Alarm.ALL);//(true, new byte[] { 0x00, 0x00, 0x00, 0x01 });
|
||||
Meter.ResetAlarm(Alarm.ALL);//(true, new byte[] { 0x00, 0x00, 0x00, 0x01 });
|
||||
|
||||
Meter.SetLcdText(true, new Byte[] { 0x00, 0x00, 0x00, 0x01 });
|
||||
|
||||
Meter.ResetAlarm(GenesisMeter.Alarm.EMPTY_PIPE);//(true, new byte[] { 0x00, 0x00, 0x00, 0x01 });
|
||||
Meter.ResetAlarm(Alarm.EMPTY_PIPE);//(true, new byte[] { 0x00, 0x00, 0x00, 0x01 });
|
||||
|
||||
if (rebootSucceeded && hasDiffrences.HasValue && !hasDiffrences.Value)
|
||||
{
|
||||
|
||||
@@ -779,154 +779,154 @@ namespace Service.MeterProcessState.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[Route("GetProductionSkipAndLifeTimeInfo")]
|
||||
public async Task<HttpResponseMessage> GetProductionSkipAndLifeTimeInfo(Int32? pcbId = null, Int32? orderNumber = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!pcbId.HasValue && !orderNumber.HasValue)
|
||||
{
|
||||
return Request.CreateResponse(HttpStatusCode.InternalServerError, new ApplicationException("No Argument"));
|
||||
}
|
||||
return Request.CreateResponse(HttpStatusCode.OK, await Task.Run(() =>
|
||||
{
|
||||
//[Route("GetProductionSkipAndLifeTimeInfo")]
|
||||
//public async Task<HttpResponseMessage> GetProductionSkipAndLifeTimeInfo(Int32? pcbId = null, Int32? orderNumber = null)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// if (!pcbId.HasValue && !orderNumber.HasValue)
|
||||
// {
|
||||
// return Request.CreateResponse(HttpStatusCode.InternalServerError, new ApplicationException("No Argument"));
|
||||
// }
|
||||
// return Request.CreateResponse(HttpStatusCode.OK, await Task.Run(() =>
|
||||
// {
|
||||
|
||||
using (var dataAccess = new SqlDataAccess(GlobalConfig.connectionString.Value))
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
// using (var dataAccess = new SqlDataAccess(GlobalConfig.connectionString.Value))
|
||||
// {
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
|
||||
int DefaultMaxMonthsNaRegion = 6;
|
||||
int DefaultMaxMonthsEmeaRegion = 3;
|
||||
Double DefaultRequiredLifeTimeYearsAssembly = 21.0;
|
||||
Double DefaultRequiredLifeTimeYearsShipping = 20.0;
|
||||
Double DefaultMaxDrainedBatteryLoadPercent = 10.0;
|
||||
sb.AppendLine("Select IdendKey, [Value] from ProductionDefaultKeys where IdendKey in (");
|
||||
sb.AppendLine(" 'DefaultMaxMonthsNaRegion'");
|
||||
sb.AppendLine(" ,'DefaultMaxMonthsEmeaRegion'");
|
||||
sb.AppendLine(" ,'DefaultRequiredLifeTimeYearsAssembly'");
|
||||
sb.AppendLine(" ,'DefaultRequiredLifeTimeYearsShipping'");
|
||||
sb.AppendLine(" ,'DefaultMaxDrainedBatteryLoadPercent'");
|
||||
sb.AppendLine(" )");
|
||||
// int DefaultMaxMonthsNaRegion = 6;
|
||||
// int DefaultMaxMonthsEmeaRegion = 3;
|
||||
// Double DefaultRequiredLifeTimeYearsAssembly = 21.0;
|
||||
// Double DefaultRequiredLifeTimeYearsShipping = 20.0;
|
||||
// Double DefaultMaxDrainedBatteryLoadPercent = 10.0;
|
||||
// sb.AppendLine("Select IdendKey, [Value] from ProductionDefaultKeys where IdendKey in (");
|
||||
// sb.AppendLine(" 'DefaultMaxMonthsNaRegion'");
|
||||
// sb.AppendLine(" ,'DefaultMaxMonthsEmeaRegion'");
|
||||
// sb.AppendLine(" ,'DefaultRequiredLifeTimeYearsAssembly'");
|
||||
// sb.AppendLine(" ,'DefaultRequiredLifeTimeYearsShipping'");
|
||||
// sb.AppendLine(" ,'DefaultMaxDrainedBatteryLoadPercent'");
|
||||
// sb.AppendLine(" )");
|
||||
|
||||
|
||||
var dt = dataAccess.ExecuteQuery(sb.ToString());
|
||||
// var dt = dataAccess.ExecuteQuery(sb.ToString());
|
||||
|
||||
foreach (var item in dt.Select())
|
||||
{
|
||||
switch (item["IdendKey"].ToString())
|
||||
{
|
||||
case "DefaultMaxMonthsNaRegion":
|
||||
int.TryParse(item["Value"].ToString(), out DefaultMaxMonthsNaRegion);
|
||||
// foreach (var item in dt.Select())
|
||||
// {
|
||||
// switch (item["IdendKey"].ToString())
|
||||
// {
|
||||
// case "DefaultMaxMonthsNaRegion":
|
||||
// int.TryParse(item["Value"].ToString(), out DefaultMaxMonthsNaRegion);
|
||||
|
||||
break;
|
||||
case "DefaultMaxMonthsEmeaRegion":
|
||||
int.TryParse(item["Value"].ToString(), out DefaultMaxMonthsEmeaRegion);
|
||||
break;
|
||||
case "DefaultRequiredLifeTimeYearsAssembly":
|
||||
double.TryParse(item["Value"].ToString(), out DefaultRequiredLifeTimeYearsAssembly);
|
||||
break;
|
||||
case "DefaultRequiredLifeTimeYearsShipping":
|
||||
double.TryParse(item["Value"].ToString(), out DefaultRequiredLifeTimeYearsShipping);
|
||||
break;
|
||||
case "DefaultMaxDrainedBatteryLoadPercent":
|
||||
double.TryParse(item["Value"].ToString(), out DefaultMaxDrainedBatteryLoadPercent);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// break;
|
||||
// case "DefaultMaxMonthsEmeaRegion":
|
||||
// int.TryParse(item["Value"].ToString(), out DefaultMaxMonthsEmeaRegion);
|
||||
// break;
|
||||
// case "DefaultRequiredLifeTimeYearsAssembly":
|
||||
// double.TryParse(item["Value"].ToString(), out DefaultRequiredLifeTimeYearsAssembly);
|
||||
// break;
|
||||
// case "DefaultRequiredLifeTimeYearsShipping":
|
||||
// double.TryParse(item["Value"].ToString(), out DefaultRequiredLifeTimeYearsShipping);
|
||||
// break;
|
||||
// case "DefaultMaxDrainedBatteryLoadPercent":
|
||||
// double.TryParse(item["Value"].ToString(), out DefaultMaxDrainedBatteryLoadPercent);
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
|
||||
}
|
||||
sb = new StringBuilder();
|
||||
// }
|
||||
// sb = new StringBuilder();
|
||||
|
||||
sb.AppendLine($" select [id] ");
|
||||
sb.AppendLine($" ,[OrderNumber] ");
|
||||
sb.AppendLine($" ,[PcbId] ");
|
||||
sb.AppendLine($" ,[SkipRadioParametersCheck] ");
|
||||
sb.AppendLine($" ,[OverrideFwCheck] ");
|
||||
sb.AppendLine($" ,[OverrideLutCheck] ");
|
||||
sb.AppendLine($" ,[RequiredLifeTimeYearsAssembly] ");
|
||||
sb.AppendLine($" ,[RequiredLifeTimeYearsShipping] ");
|
||||
sb.AppendLine($" ,[KitronProductionDate] ");
|
||||
sb.AppendLine($" ,[MaxDrainedBatteryLoadPercent] ");
|
||||
sb.AppendLine($" ,[MaxStorageMonths] ");
|
||||
sb.AppendLine($" ,[ApprovalDate] ");
|
||||
sb.AppendLine($" ,[ApproverName] ");
|
||||
sb.AppendLine($" ,[ApprovalComment] ");
|
||||
// sb.AppendLine($" select [id] ");
|
||||
// sb.AppendLine($" ,[OrderNumber] ");
|
||||
// sb.AppendLine($" ,[PcbId] ");
|
||||
// sb.AppendLine($" ,[SkipRadioParametersCheck] ");
|
||||
// sb.AppendLine($" ,[OverrideFwCheck] ");
|
||||
// sb.AppendLine($" ,[OverrideLutCheck] ");
|
||||
// sb.AppendLine($" ,[RequiredLifeTimeYearsAssembly] ");
|
||||
// sb.AppendLine($" ,[RequiredLifeTimeYearsShipping] ");
|
||||
// sb.AppendLine($" ,[KitronProductionDate] ");
|
||||
// sb.AppendLine($" ,[MaxDrainedBatteryLoadPercent] ");
|
||||
// sb.AppendLine($" ,[MaxStorageMonths] ");
|
||||
// sb.AppendLine($" ,[ApprovalDate] ");
|
||||
// sb.AppendLine($" ,[ApproverName] ");
|
||||
// sb.AppendLine($" ,[ApprovalComment] ");
|
||||
|
||||
sb.AppendLine($" FROM [Auftrag].[dbo].[ProductionSkipAndLifeTimeInfo] ");
|
||||
sb.AppendLine($" where 1 = 1 ");
|
||||
if (orderNumber.HasValue)
|
||||
{
|
||||
sb.AppendLine($" and (OrderNumber = {orderNumber.Value} or OrderNumber is null) ");
|
||||
}
|
||||
if (pcbId.HasValue)
|
||||
{
|
||||
sb.AppendLine($" and (PcbId = {pcbId.Value} or PcbId is null) ");
|
||||
}
|
||||
// sb.AppendLine($" FROM [Auftrag].[dbo].[ProductionSkipAndLifeTimeInfo] ");
|
||||
// sb.AppendLine($" where 1 = 1 ");
|
||||
// if (orderNumber.HasValue)
|
||||
// {
|
||||
// sb.AppendLine($" and (OrderNumber = {orderNumber.Value} or OrderNumber is null) ");
|
||||
// }
|
||||
// if (pcbId.HasValue)
|
||||
// {
|
||||
// sb.AppendLine($" and (PcbId = {pcbId.Value} or PcbId is null) ");
|
||||
// }
|
||||
|
||||
// PcbId != null sticht ordernumber , Ordernumbner
|
||||
//TODO Roland: The defaults should come from a DefaultProductionSkipAndLifeTimeInfo table
|
||||
// // PcbId != null sticht ordernumber , Ordernumbner
|
||||
// //TODO Roland: The defaults should come from a DefaultProductionSkipAndLifeTimeInfo table
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
dt = dataAccess.ExecuteQuery(sb.ToString());
|
||||
// dt = dataAccess.ExecuteQuery(sb.ToString());
|
||||
|
||||
if (dt.Rows.Count == 0)
|
||||
{
|
||||
var stat = new GenesisStatus
|
||||
{
|
||||
OverrideLutCheck = null,
|
||||
OverrideFwCheck = null,
|
||||
SkipRadioParametersCheck = false,
|
||||
RequiredLifeTimeYearsAssembly = DefaultRequiredLifeTimeYearsAssembly,
|
||||
RequiredLifeTimeYearsShipping = DefaultRequiredLifeTimeYearsShipping,
|
||||
MaxDrainedBatteryLoadPercent = DefaultMaxDrainedBatteryLoadPercent,
|
||||
};
|
||||
//TODO Roland implement defaults
|
||||
// get region from order if (Region == "NA")
|
||||
stat.ProductionDueDate = stat.KitronProductionDate.AddMonths(DefaultMaxMonthsNaRegion);
|
||||
// else
|
||||
stat.ProductionDueDate = stat.KitronProductionDate.AddMonths(DefaultMaxMonthsEmeaRegion);
|
||||
return stat;
|
||||
}
|
||||
var ret = new GenesisStatus();
|
||||
//TODO Roland check for multiple rows take the last?
|
||||
foreach (var item in dt.Select())
|
||||
{
|
||||
try
|
||||
{
|
||||
ret.OrderNumber = orderNumber;
|
||||
ret.PcbId = pcbId.ToString();
|
||||
ret.SkipRadioParametersCheck = (Boolean)item["SkipRadioParametersCheck"];
|
||||
ret.OverrideFwCheck = (int)item["OverrideFwCheck"];
|
||||
ret.OverrideLutCheck = (int)item["OverrideLutCheck"];
|
||||
//ret.RequiredLifeTimeYearsAssembly = (Double)item["RequiredLifeTimeYearsAssembly"];
|
||||
//ret.RequiredLifeTimeYearsShipping = (Double)item["RequiredLifeTimeYearsShipping"];
|
||||
//ret.MaxDrainedBatteryLoadPercent = (Double)item["MaxDrainedBatteryLoadPercent"];
|
||||
//ret.KitronProductionDate = (DateTime)item["KitronProductionDate"];
|
||||
var maxStorageMonths = (Int32)item["MaxStorageMonths"];
|
||||
ret.ProductionDueDate = ret.KitronProductionDate + TimeSpan.FromDays(30.0 * maxStorageMonths);
|
||||
ret.ApprovalDate = (DateTime)item["ApprovalDate"];
|
||||
ret.ApproverName = item["ApproverName"].ToString();
|
||||
ret.ApprovalComment = item["ApprovalComment"].ToString();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
// if (dt.Rows.Count == 0)
|
||||
// {
|
||||
// var stat = new GenesisStatus
|
||||
// {
|
||||
// OverrideLutCheck = null,
|
||||
// OverrideFwCheck = null,
|
||||
// SkipRadioParametersCheck = false,
|
||||
// RequiredLifeTimeYearsAssembly = DefaultRequiredLifeTimeYearsAssembly,
|
||||
// RequiredLifeTimeYearsShipping = DefaultRequiredLifeTimeYearsShipping,
|
||||
// MaxDrainedBatteryLoadPercent = DefaultMaxDrainedBatteryLoadPercent,
|
||||
// };
|
||||
// //TODO Roland implement defaults
|
||||
// // get region from order if (Region == "NA")
|
||||
// stat.ProductionDueDate = stat.KitronProductionDate.AddMonths(DefaultMaxMonthsNaRegion);
|
||||
// // else
|
||||
// stat.ProductionDueDate = stat.KitronProductionDate.AddMonths(DefaultMaxMonthsEmeaRegion);
|
||||
// return stat;
|
||||
// }
|
||||
// var ret = new GenesisStatus();
|
||||
// //TODO Roland check for multiple rows take the last?
|
||||
// foreach (var item in dt.Select())
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// ret.OrderNumber = orderNumber;
|
||||
// ret.PcbId = pcbId.ToString();
|
||||
// ret.SkipRadioParametersCheck = (Boolean)item["SkipRadioParametersCheck"];
|
||||
// ret.OverrideFwCheck = (int)item["OverrideFwCheck"];
|
||||
// ret.OverrideLutCheck = (int)item["OverrideLutCheck"];
|
||||
// //ret.RequiredLifeTimeYearsAssembly = (Double)item["RequiredLifeTimeYearsAssembly"];
|
||||
// //ret.RequiredLifeTimeYearsShipping = (Double)item["RequiredLifeTimeYearsShipping"];
|
||||
// //ret.MaxDrainedBatteryLoadPercent = (Double)item["MaxDrainedBatteryLoadPercent"];
|
||||
// //ret.KitronProductionDate = (DateTime)item["KitronProductionDate"];
|
||||
// var maxStorageMonths = (Int32)item["MaxStorageMonths"];
|
||||
// ret.ProductionDueDate = ret.KitronProductionDate + TimeSpan.FromDays(30.0 * maxStorageMonths);
|
||||
// ret.ApprovalDate = (DateTime)item["ApprovalDate"];
|
||||
// ret.ApproverName = item["ApproverName"].ToString();
|
||||
// ret.ApprovalComment = item["ApprovalComment"].ToString();
|
||||
// }
|
||||
// catch (Exception)
|
||||
// {
|
||||
// }
|
||||
// }
|
||||
|
||||
return ret;
|
||||
}
|
||||
// return ret;
|
||||
// }
|
||||
|
||||
}));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Request.CreateResponse(HttpStatusCode.ExpectationFailed, ex.ToString() + "<br >" + ex.InnerException.ToString());
|
||||
}
|
||||
}
|
||||
// }));
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// return Request.CreateResponse(HttpStatusCode.ExpectationFailed, ex.ToString() + "<br >" + ex.InnerException.ToString());
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json;
|
||||
using RestSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -308,6 +307,36 @@ namespace Xylem.Common.Logic.SoftwareAccessHelper
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Web request
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="httpStatus"></param>
|
||||
/// <param name="timeoutMs"></param>
|
||||
/// <returns></returns>
|
||||
public static String GetRequest(String url, Double timeoutMs, out HttpStatusCode httpStatus)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
var httpClient = new HttpClient();
|
||||
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
|
||||
httpClient.Timeout = TimeSpan.FromMilliseconds(timeoutMs);
|
||||
var response = httpClient
|
||||
.GetAsync(url)
|
||||
.Result;
|
||||
|
||||
httpStatus = response.StatusCode;
|
||||
return response.Content.ReadAsStringAsync().Result;
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
httpStatus = HttpStatusCode.ServiceUnavailable;
|
||||
return error.Message;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Web request with asynchronous operation
|
||||
/// </summary>
|
||||
@@ -347,7 +376,7 @@ namespace Xylem.Common.Logic.SoftwareAccessHelper
|
||||
{
|
||||
request.AddJsonBody(json);
|
||||
}
|
||||
|
||||
|
||||
var r = client.ExecuteAsPost(request, Method.POST.ToString());
|
||||
return r;
|
||||
}
|
||||
@@ -415,8 +444,7 @@ namespace Xylem.Common.Logic.SoftwareAccessHelper
|
||||
/// <returns></returns>
|
||||
public static String DeleteRequest(String url, Int32? timeoutMs = null, Dictionary<String, String> header = null, Boolean isRetry = false)
|
||||
{
|
||||
Int32 temp;
|
||||
var ret = DeleteRequestWithError(url, out temp, timeoutMs, header, isRetry);
|
||||
var ret = DeleteRequestWithError(url, out var temp, timeoutMs, header, isRetry);
|
||||
if (temp != 200)
|
||||
{
|
||||
throw new ApplicationException($"WebRequest Status {temp}");
|
||||
@@ -479,8 +507,7 @@ namespace Xylem.Common.Logic.SoftwareAccessHelper
|
||||
/// <returns></returns>
|
||||
public static String GetRequest(String url, Int32? timeoutMs = null, Dictionary<String, String> header = null, Boolean isRetry = false)
|
||||
{
|
||||
Int32 temp;
|
||||
var ret = GetRequestWithError(url, out temp, timeoutMs, header, isRetry);
|
||||
var ret = GetRequestWithError(url, out var temp, timeoutMs, header, isRetry);
|
||||
if (temp != 200)
|
||||
{
|
||||
throw new ApplicationException($"WebRequest Status {temp}");
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.Consts;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
|
||||
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore;
|
||||
|
||||
@@ -139,10 +140,10 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
{
|
||||
clbAlarms.ItemCheck -= clbAlarms_ItemCheck;
|
||||
var cAlarm = _currentGenesis.GetAlarms();
|
||||
//MessageBox.Show($"Checkalarm EMPTY_PIPE = { _currentGenesis.HasAlarms(GenesisMeter.Alarm.EMPTY_PIPE)}");
|
||||
//MessageBox.Show($"Checkalarm EMPTY_PIPE = { _currentGenesis.HasAlarms(Alarm.EMPTY_PIPE)}");
|
||||
|
||||
clbAlarms.Items.Clear();
|
||||
foreach (GenesisMeter.Alarm suit in (GenesisMeter.Alarm[])Enum.GetValues(typeof(GenesisMeter.Alarm)))
|
||||
foreach (Alarm suit in (Alarm[])Enum.GetValues(typeof(Alarm)))
|
||||
{
|
||||
|
||||
clbAlarms.Items.Add(suit, cAlarm.HasFlag(suit));
|
||||
@@ -169,8 +170,8 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
{
|
||||
if (_currentGenesis != null)
|
||||
{
|
||||
//_currentGenesis.ResetAlarm(GenesisMeter.Alarm.EMPTY_PIPE | GenesisMeter.Alarm.REBOOT);
|
||||
var allEnums = ((GenesisMeter.Alarm[])Enum.GetValues(typeof(GenesisMeter.Alarm)));
|
||||
//_currentGenesis.ResetAlarm(Alarm.EMPTY_PIPE | Alarm.REBOOT);
|
||||
var allEnums = ((Alarm[])Enum.GetValues(typeof(Alarm)));
|
||||
if (allEnums.Length > e.Index)
|
||||
{
|
||||
_currentGenesis.ResetAlarm(allEnums[e.Index]);
|
||||
@@ -392,16 +393,16 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
{
|
||||
if (_currentGenesis != null && _currentGenesis.IsLoggedOn)
|
||||
{
|
||||
_currentGenesis.ResetAlarm(GenesisMeter.Alarm.ALL);
|
||||
_currentGenesis.ResetAlarm(Alarm.ALL);
|
||||
}
|
||||
}
|
||||
private void finishMeter(GenesisMeter Meter)
|
||||
{
|
||||
Meter.ResetAlarm(GenesisMeter.Alarm.ALL);//(true, new byte[] { 0x00, 0x00, 0x00, 0x01 });
|
||||
Meter.ResetAlarm(Alarm.ALL);//(true, new byte[] { 0x00, 0x00, 0x00, 0x01 });
|
||||
|
||||
Meter.SetLcdText(true, new Byte[] { 0x00, 0x00, 0x00, 0x01 });
|
||||
|
||||
Meter.ResetAlarm(GenesisMeter.Alarm.EMPTY_PIPE);//(true, new byte[] { 0x00, 0x00, 0x00, 0x01 });
|
||||
Meter.ResetAlarm(Alarm.EMPTY_PIPE);//(true, new byte[] { 0x00, 0x00, 0x00, 0x01 });
|
||||
_currentGenesis.WriteRegister(Register.Metrologyasst.PulseMode, 5, true, true);
|
||||
var useRadio = true;
|
||||
if (useRadio)
|
||||
@@ -487,7 +488,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
ReadAlarm("CUSTOMER_AlarmVisualMask", lblAVM, clbAVM);
|
||||
|
||||
var cAlarm = _currentGenesis.GetAlarms();
|
||||
//MessageBox.Show($"Checkalarm EMPTY_PIPE = { _currentGenesis.HasAlarms(GenesisMeter.Alarm.EMPTY_PIPE)}");
|
||||
//MessageBox.Show($"Checkalarm EMPTY_PIPE = { _currentGenesis.HasAlarms(Alarm.EMPTY_PIPE)}");
|
||||
|
||||
Boolean retry = false;
|
||||
Boolean roland = false;
|
||||
@@ -495,7 +496,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
|
||||
if (lblAEM.Text == "00-00-80-53" && lblABM.Text == "00-00-1F-DC" && lblAVM.Text == "00-00-1F-DC")
|
||||
{
|
||||
if (cAlarm == GenesisMeter.Alarm.EMPTY_PIPE)
|
||||
if (cAlarm == Alarm.EMPTY_PIPE)
|
||||
{
|
||||
MessageBox.Show("weiter");
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user