Add calibration factor support to Genesis, implement TestRsltCalibFactor entity, related mappings, table creation logic, and data persistence methods. Extend GenesisSmartReader with Q3 calibration enhancements and introduce new debug logging.

This commit is contained in:
Michal Buzik 2026-05-22 09:18:41 +02:00
parent 6f919ede9b
commit db90a096e3
55 changed files with 2131 additions and 763 deletions

View File

@ -11,6 +11,7 @@ using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
using Common;
using Results.Entities;
using Results.Entities.helpers;
namespace Results
{
@ -267,9 +268,17 @@ namespace Results
{
log.Debug(tstRslt.ToString(1));
}
// Save batch, TestRslt, WaterMeter, MeterTestRslt, etc.
session.SaveOrUpdate(batch);
// Important: after this, TestRslt.Id should be generated
session.Flush();
// Optional table support
SolveSaveCalibFactors(batch, session);
//Commit - store results
transaction.Commit();
}
catch (Exception exc)
@ -290,6 +299,45 @@ namespace Results
return true;
}
private static void SolveSaveCalibFactors(Batch batch, ISession session)
{
bool hasCalibrationFactors = false;
foreach (var tstRslt in batch.TestRslts)
{
if (tstRslt.CalibFactorResultsToSave != null &&
tstRslt.CalibFactorResultsToSave.Count > 0)
{
hasCalibrationFactors = true;
break;
}
}
if (hasCalibrationFactors)
{
TestRsltCalibFactorHelper.CreateTableIfNotExists(session);
foreach (var tstRslt in batch.TestRslts)
{
if (tstRslt.CalibFactorResultsToSave == null ||
tstRslt.CalibFactorResultsToSave.Count == 0)
{
continue;
}
TestRsltCalibFactorHelper.DeleteByTestRsltIdNoTransaction(session, tstRslt.Id);
foreach (var calib in tstRslt.CalibFactorResultsToSave)
{
calib.TestRslt = tstRslt;
calib.ErrorStr = TestRsltCalibFactorHelper.Truncate(calib.ErrorStr, 240);
session.SaveOrUpdate(calib);
}
}
}
}
public static Batch LoadBatch(int batchNr)
{
@ -316,6 +364,15 @@ namespace Results
batch.WaterMeters = session.QueryOver<WaterMeter>()
.Where(x => (x.Batch.Id == batch.Id))
.List();
TestRsltCalibFactorHelper.CreateTableIfNotExists(session);
foreach (var tstRslt in batch.TestRslts)
{
tstRslt.CalibFactorResultsToSave = TestRsltCalibFactorHelper.GetByTestRsltId( session, tstRslt.Id);
}
}
return (batches.Count > 0) ? batches[0] : null;

View File

@ -0,0 +1,37 @@
namespace Results.Entities
{
public class MeterTestCalibFactorRslt
{
public virtual int Id { get; protected set; }
public virtual MeterTestRslt MeterTestRslt { get; set; }
/// 1, 2, 3 - calculated calib factor index
public virtual int CalibFactorIndex { get; set; }
/// Base calib factor originally set in meter
public virtual int BaseCalibFactor { get; set; }
/// Newly calculated calib factor
public virtual int CalculatedCalibFactor { get; set; }
/// true = calculated value was stored/written to meter
public virtual bool Stored { get; set; }
public virtual string ErrorStr { get; set; } // max 240 chars
public virtual double TimeStart { get; set; }
public virtual double TimeEnd { get; set; }
public virtual double CalibRawStart { get; set; }
public virtual double CalibRawEnd { get; set; }
public virtual double Error { get; set; }
public MeterTestCalibFactorRslt()
{
Stored = false;
ErrorStr = string.Empty;
}
}
}

View File

@ -151,6 +151,11 @@ namespace Results.Entities
public virtual int Counter3 { get; set; }
public virtual int Counter4 { get; set; }
public virtual int Counter5 { get; set; }
/// <summary>
/// Not maped table - exist only in Genesis DB !!
/// </summary>
public virtual IList<TestRsltCalibFactor> CalibFactorResultsToSave { get; set; }
/// Wrappers
public virtual string Name() { return Common.Utils.GetTestName(TestData.Name, TestData.Repeats, RepetitionNr); }
@ -266,15 +271,27 @@ namespace Results.Entities
MethodClass = string.Empty;
Remark = string.Empty;
CalibFactorResultsToSave = new List<TestRsltCalibFactor>();
}
public TestRslt(Batch batch, TestData testData, int part, int repetitionNr)
public TestRslt(
Batch batch,
TestData testData,
int part,
int repetitionNr)
: this(batch, testData, part, repetitionNr, null)
{
}
public TestRslt(Batch batch, TestData testData, int part, int repetitionNr, List<TestRsltCalibFactor> calibFactor)
: this()
{
Batch = batch;
TestData = testData;
Part = part;
RepetitionNr = repetitionNr;
CalibFactorResultsToSave = calibFactor != null ? new List<TestRsltCalibFactor>(calibFactor) : new List<TestRsltCalibFactor>();
}
public virtual void CopyContentFrom(TestRslt src)

View File

@ -0,0 +1,34 @@
namespace Results.Entities
{
public class TestRsltCalibFactor
{
public virtual int Id { get; protected set; }
public virtual TestRslt TestRslt { get; set; }
public virtual int CalibFactorIndex { get; set; } // 1, 2, 3
public virtual int BaseCalibFactor { get; set; }
public virtual int CalculatedCalibFactor { get; set; }
public virtual bool Stored { get; set; }
public virtual string ErrorStr { get; set; } // varchar(240)
public virtual double TimeStart { get; set; }
public virtual double TimeEnd { get; set; }
public virtual double CalibRawStart { get; set; }
public virtual double CalibRawEnd { get; set; }
public virtual double Error { get; set; }
public virtual double VolumeStart { get; set; }
public virtual double VolumeEnd { get; set; }
public TestRsltCalibFactor()
{
Stored = false;
ErrorStr = string.Empty;
}
}
}

View File

@ -0,0 +1,109 @@
using System.Collections.Generic;
using NHibernate;
namespace Results.Entities.helpers
{
public static class TestRsltCalibFactorHelper
{
public static bool TableExists(ISession session)
{
try
{
session.CreateSQLQuery( "SELECT 1 FROM TestRsltCalibFactor LIMIT 1")
.UniqueResult();
return true;
}
catch
{
return false;
}
}
public static void DeleteByTestRsltIdNoTransaction(
ISession session,
int testRsltId)
{
session.CreateSQLQuery(@" DELETE FROM TestRsltCalibFactor WHERE TestRsltId = :testRsltId")
.SetParameter("testRsltId", testRsltId)
.ExecuteUpdate();
}
public static IList<TestRsltCalibFactor> GetByTestRsltId(
ISession session,
int testRsltId)
{
return session.QueryOver<TestRsltCalibFactor>()
.Where(x => x.TestRslt.Id == testRsltId)
.OrderBy(x => x.CalibFactorIndex).Asc
.List();
}
public static string Truncate(string value, int maxLength)
{
if (string.IsNullOrEmpty(value))
return string.Empty;
return value.Length <= maxLength
? value
: value.Substring(0, maxLength);
}
public static void CreateTableIfNotExists(ISession session)
{
if (TableExists(session))
return;
string sql;
if (DB.DbType == Common.DBType.MySql)
{
sql = @"
CREATE TABLE IF NOT EXISTS TestRsltCalibFactor (
Id INT NOT NULL AUTO_INCREMENT,
TestRsltId INT NOT NULL,
CalibFactorIndex INT NOT NULL,
BaseCalibFactor INT NOT NULL,
CalculatedCalibFactor INT NOT NULL,
Stored BIT NOT NULL,
ErrorStr VARCHAR(240) NULL,
TimeStart DOUBLE NOT NULL,
TimeEnd DOUBLE NOT NULL,
CalibRawStart DOUBLE NOT NULL,
CalibRawEnd DOUBLE NOT NULL,
Error DOUBLE NOT NULL,
VolumeStart DOUBLE NOT NULL,
VolumeEnd DOUBLE NOT NULL,
PRIMARY KEY (Id),
INDEX IX_TestRsltCalibFactor_TestRsltId (TestRsltId),
CONSTRAINT FK_TestRsltCalibFactor_TestRslt
FOREIGN KEY (TestRsltId) REFERENCES TestRslt(Id)
ON DELETE CASCADE
);";
}
else
{
sql = @"
CREATE TABLE IF NOT EXISTS TestRsltCalibFactor (
Id INTEGER PRIMARY KEY AUTOINCREMENT,
TestRsltId INTEGER NOT NULL,
CalibFactorIndex INTEGER NOT NULL,
BaseCalibFactor INTEGER NOT NULL,
CalculatedCalibFactor INTEGER NOT NULL,
Stored INTEGER NOT NULL,
ErrorStr VARCHAR(240) NULL,
TimeStart DOUBLE NOT NULL,
TimeEnd DOUBLE NOT NULL,
CalibRawStart DOUBLE NOT NULL,
CalibRawEnd DOUBLE NOT NULL,
Error DOUBLE NOT NULL,
VolumeStart DOUBLE NOT NULL,
VolumeEnd DOUBLE NOT NULL,
FOREIGN KEY (TestRsltId) REFERENCES TestRslt(Id) ON DELETE CASCADE
);";
}
session.CreateSQLQuery(sql).ExecuteUpdate();
}
}
}

View File

@ -0,0 +1,36 @@
using FluentNHibernate.Mapping;
using Results.Entities;
namespace Results.Mappings
{
public class MeterTestCalibFactorRsltMap : ClassMap<MeterTestCalibFactorRslt>
{
public MeterTestCalibFactorRsltMap()
{
Id(x => x.Id);
References(x => x.MeterTestRslt)
.Not.Nullable()
.Cascade.None();
Map(x => x.CalibFactorIndex).Not.Nullable();
Map(x => x.BaseCalibFactor).Not.Nullable();
Map(x => x.CalculatedCalibFactor).Not.Nullable();
Map(x => x.Stored).Not.Nullable();
Map(x => x.ErrorStr)
.Length(240)
.Nullable();
Map(x => x.TimeStart).Not.Nullable();
Map(x => x.TimeEnd).Not.Nullable();
Map(x => x.CalibRawStart).Not.Nullable();
Map(x => x.CalibRawEnd).Not.Nullable();
Map(x => x.Error).Not.Nullable();
}
}
}

View File

@ -0,0 +1,41 @@
using FluentNHibernate.Mapping;
using Results.Entities;
namespace Results.Mappings
{
class TestRsltCalibFactorMap : ClassMap<TestRsltCalibFactor>
{
public TestRsltCalibFactorMap()
{
Id(x => x.Id);
References(x => x.TestRslt)
.Column("TestRsltId")
.Not.Nullable();
Map(x => x.CalibFactorIndex).Not.Nullable();
Map(x => x.BaseCalibFactor).Not.Nullable();
Map(x => x.CalculatedCalibFactor).Not.Nullable();
Map(x => x.Stored).Not.Nullable();
Map(x => x.ErrorStr)
.Length(240)
.Nullable();
Map(x => x.TimeStart).Not.Nullable();
Map(x => x.TimeEnd).Not.Nullable();
Map(x => x.CalibRawStart).Not.Nullable();
Map(x => x.CalibRawEnd).Not.Nullable();
Map(x => x.Error).Not.Nullable();
Map(x => x.VolumeStart).Not.Nullable();
Map(x => x.VolumeEnd).Not.Nullable();
}
}
}

View File

@ -69,12 +69,15 @@
<Compile Include="DBase.cs" />
<Compile Include="Entities\Batch.cs" />
<Compile Include="Entities\Components.cs" />
<Compile Include="Entities\helpers\TestRsltCalibFactorHelper.cs" />
<Compile Include="Entities\MeterTestCalibFactorRslt.cs" />
<Compile Include="Entities\MeterTestRslt.cs" />
<Compile Include="Entities\PurchaseBox.cs" />
<Compile Include="Entities\PurchaseOrder.cs" />
<Compile Include="Entities\PurchaseWaterMeterData.cs" />
<Compile Include="Entities\TestData.cs" />
<Compile Include="Entities\TestRslt.cs" />
<Compile Include="Entities\TestRsltCalibFactor.cs" />
<Compile Include="Entities\WaterMeterData.cs" />
<Compile Include="Entities\WaterMeter.cs" />
<Compile Include="DB.cs" />
@ -132,11 +135,13 @@
<Compile Include="ManualEntryItemSpec.cs" />
<Compile Include="Mappings\BatchMap.cs" />
<Compile Include="Mappings\ComponentsMap.cs" />
<Compile Include="Mappings\MeterTestCalibFactorRsltMap.cs" />
<Compile Include="Mappings\MeterTestRsltMap.cs" />
<Compile Include="Mappings\PurchaseBoxMap.cs" />
<Compile Include="Mappings\PurchaseOrderMap.cs" />
<Compile Include="Mappings\PurchaseWaterMeterDataMap.cs" />
<Compile Include="Mappings\TestDataMap.cs" />
<Compile Include="Mappings\TestRsltCalibFactorMap.cs" />
<Compile Include="Mappings\TestRsltMap.cs" />
<Compile Include="Mappings\WaterMeterDataMap.cs" />
<Compile Include="Mappings\WaterMeterMap.cs" />

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.9.3104.1")]
[assembly: AssemblyFileVersion("3.9.3104.1")]
[assembly: AssemblyVersion("3.9.3109.1")]
[assembly: AssemblyFileVersion("3.9.3109.1")]

View File

@ -16,18 +16,18 @@ namespace TBF.Rig.RegisterReaders.CommonRR.IPerl
public int DfltQ2c_15_rl { get; set; }
public int DfltQ2c_15_lr { get; set; }
public int DfltQ2c_20_rl { get; set; }
public int DfltQ2c_20_lr { get; set; }
public int DfltQ2c_25_63_rl { get; set; }
public int DfltQ2c_25_63_lr { get; set; }
public int DfltQ2c_25_10_rl { get; set; }
public int DfltQ2c_25_10_lr { get; set; }
public int DfltQ2c_32_rl { get; set; }
public int DfltQ2c_32_lr { get; set; }
public int DfltQ2c_40_rl { get; set; }
public int DfltQ2c_40_lr { get; set; }
public int CalibFactor1InchCh1 { get; set; }
public int CalibFactor1InchCh2 { get; set; }
public int CalibFactor2InchCh1 { get; set; }
public int CalibFactor2InchCh2 { get; set; }
public int CalibFactor3InchCh1 { get; set; }
public int CalibFactor3InchCh2 { get; set; }
public int CalibFactor4InchCh1 { get; set; }
public int CalibFactor4InchCh2 { get; set; }
public int CalibFactor6InchCh1 { get; set; }
public int CalibFactor6InchCh2 { get; set; }
public int CalibFactor6MoreInchCh1 { get; set; }
public int CalibFactor6MoreInchCh2 { get; set; }
public bool UseWebService { get; set; }
public string BaseUrl { get; set; }

View File

@ -0,0 +1,49 @@
using System.Threading;
using System.Threading.Tasks;
using GenesisCordonelInterface.API;
using GenesisCordonelInterface.Core.Threading;
using TBF.Rig.BridgeComponents.GciBridge;
namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
{
public class GciBridgeClient : IGciBridgeClient
{
private readonly GciBridge bridge;
public GciBridgeClient(GciBridge bridge)
{
this.bridge = bridge;
}
public Task<RetryResult<PublicModels.RegisterReadResult>>
ReadRegisterWithRetryAsync(
int slotId,
string registerName,
CancellationToken token = default)
{
return bridge.ReadRegisterWithRetryAsync(
slotId,
registerName,
token);
}
public Task<RetryResult<PublicModels.RegisterWriteResult>>
WriteRegisterWithRetryAsync(
int slotId,
string registerName,
ushort value,
bool verify,
bool throwOnError,
CancellationToken token = default)
{
return bridge.WriteRegisterWithRetryAsync(
slotId,
registerName,
value,
verify,
throwOnError,
token);
}
}
}

View File

@ -0,0 +1,25 @@
using System.Threading;
using System.Threading.Tasks;
using GenesisCordonelInterface.API;
using GenesisCordonelInterface.Core.Threading;
namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
{
public interface IGciBridgeClient
{
Task<RetryResult<PublicModels.RegisterReadResult>>
ReadRegisterWithRetryAsync(
int slotId,
string registerName,
CancellationToken token = default);
Task<RetryResult<PublicModels.RegisterWriteResult>>
WriteRegisterWithRetryAsync(
int slotId,
string registerName,
ushort value,
bool verify,
bool throwOnError,
CancellationToken token = default);
}
}

View File

@ -2,11 +2,16 @@ using System;
using System.Threading;
using System.Threading.Tasks;
using Common;
using Config.Entities;
using GenesisCordonelInterface.API;
using log4net;
using Results.Entities;
using Results.Entities.helpers;
using TBF.Rig.BridgeComponents.GciBridge;
using TBF.Rig.RegisterReaders.GenesisRegReader.communication.common;
using TBF.Rig.RegisterReaders.GenesisRegReader.implementations;
using TBF.Rig.Sequences;
using TBF.Rig.TestMethods.GenesisCommunication;
using TBF.Rig.TestMethods.iPerlCommunication.communication.C4.diagnosticLed;
@ -1468,7 +1473,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
if (gciBridge == null) return string.Empty;
CancellationToken token = default;
bool areInitialisedData = genesisSmartReader.CalculateQ3Calibration();
if (!areInitialisedData)
{
@ -1565,20 +1570,23 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
}
public string PrepareQ3Calibration()
public string PrepareQ3Calibration(TestMethodCfg cfg, Test test)
{
if (genesisHead != null && genesisHead.DebugLevel == DebugMode.Simulate)
{
log.Debug("Connect() - Simulated response");
return ResultOk;//"Simulated Connect";
}
return Task.Run(() => PrepareQ3Calibration_Async(genesisHead))
return Task.Run(() => PrepareQ3Calibration_Async(genesisHead, cfg, test))
.GetAwaiter()
.GetResult();
}
private async Task<string> PrepareQ3Calibration_Async(GenesisSmartReader genesisSmartReader)
private async Task<string> PrepareQ3Calibration_Async(
GenesisSmartReader genesisSmartReader,
TestMethodCfg cfg,
Test test)
{
try
{
@ -1588,32 +1596,51 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
if (string.IsNullOrEmpty(genesisHead.CommInterface)) return string.Empty;
GciBridge gciBridge = genesisHead.CommInterfaceBridge;
if (gciBridge == null) return string.Empty;
if (test == null) return "Valid Test Missing!";
Results.Entities.TestRslt tstRslt = ProcessData.BatchRslts.GetTestRslt(test.Name, test.Part);
log.Debug($"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - Test: {test.Name} - Part: {test.Part} - IsTestRslt: {(tstRslt==null?true:false)}");
if (tstRslt.CalibFactorResultsToSave.Count == 0)
{
for (int i = 0; i < genesisSmartReader.ChannelsCount; i++)
{
tstRslt.CalibFactorResultsToSave.Add(new TestRsltCalibFactor());
}
}
CancellationToken token = default;
//Get Activity Status
LedState ledMode = LedState.active; // swich on LED
byte valueLed = (ledMode == LedState.active) ? (byte)6 : (byte)0;
UInt16 valueCalibrate = 15625;
//TODO BUMI - implement variable values for Q3Calibration
UInt16 valueSampleRate = 10;
//TODO BUMI - implement variable values for Q3Calibration - be shure is implemented in Head
string prepareMeterSizeAndCalibration = await PrepareMeterSizeAndCalibration(genesisSmartReader, cfg, gciBridge, token);
if (prepareMeterSizeAndCalibration != ResultOk)
{
log.Error($"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - prepareMeterSizeAndCalibration failed. Result: {prepareMeterSizeAndCalibration}");
return prepareMeterSizeAndCalibration;
}
log.Debug( $"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - Start - Set Led Mode: {valueLed}");
var CalFactor1AsyncResult = await gciBridge.WriteRegisterWithRetryAsync(genesisSmartReader.GetSlotNr, RadioService.CalFactor1, valueCalibrate, false, false, token);
var CalFactor1AsyncResult = await gciBridge.WriteRegisterWithRetryAsync(genesisSmartReader.GetSlotNr, RadioService.CalFactor1, genesisSmartReader.Q3CalibValue[0], false, false, token);
if (CalFactor1AsyncResult == null || !CalFactor1AsyncResult.Success)
{
log.Error( $"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - CalFactor1AsyncResult failed. Result: {CalFactor1AsyncResult}");
return "Failed to disable Led Mode";
}
var CalFactor2AsyncResult = await gciBridge.WriteRegisterWithRetryAsync(genesisSmartReader.GetSlotNr, RadioService.CalFactor2, valueCalibrate, false, false, token);
var CalFactor2AsyncResult = await gciBridge.WriteRegisterWithRetryAsync(genesisSmartReader.GetSlotNr, RadioService.CalFactor2, genesisSmartReader.Q3CalibValue[1], false, false, token);
if (CalFactor2AsyncResult == null || !CalFactor2AsyncResult.Success)
{
log.Error( $"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - CalFactor2AsyncResult failed. Result: {CalFactor2AsyncResult}");
return "Failed to disable Led Mode";
}
var CalFactor3AsyncResult = await gciBridge.WriteRegisterWithRetryAsync(genesisSmartReader.GetSlotNr, RadioService.CalFactor3, valueCalibrate, false, false, token);
var CalFactor3AsyncResult = await gciBridge.WriteRegisterWithRetryAsync(genesisSmartReader.GetSlotNr, RadioService.CalFactor3, genesisSmartReader.Q3CalibValue[2], false, false, token);
if (CalFactor3AsyncResult == null || !CalFactor3AsyncResult.Success)
{
log.Error( $"PrepareQ3Calibration_Async( Slot: {genesisSmartReader.GetSlotNr}) - CalFactor3AsyncResult failed. Result: {CalFactor3AsyncResult}");
@ -1644,7 +1671,120 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
return ex.Message;
}
}
private static async Task<string> PrepareMeterSizeAndCalibration(GenesisSmartReader genesisSmartReader, TestMethodCfg cfg,
GciBridge gciBridge, CancellationToken token)
{
UInt16 valueCalibrate = 15625; //Predefined Calibration Value
try
{
if (cfg != null)
{
var MeterSizeAsyncResult = await gciBridge.ReadRegisterWithRetryAsync(genesisSmartReader.GetSlotNr,
RadioService.MeterSize, token);
if (MeterSizeAsyncResult == null || !MeterSizeAsyncResult.Success)
{
log.Error($"PrepareMeterSizeAndCalibration( Slot: {genesisSmartReader.GetSlotNr}) - Error reading MeterSize register. Result: {MeterSizeAsyncResult}");
return "Error reading MeterSize register";
}
string rawHex = MeterSizeAsyncResult.Result?.RawHex;
if (string.IsNullOrWhiteSpace(rawHex))
{
log.Error(
$"PrepareMeterSizeAndCalibration( Slot: {genesisSmartReader.GetSlotNr}) - MeterSize RawHex is empty");
return "MeterSize RawHex is empty";
}
uint meterSizeRaw = ParseRawHexToUInt32(rawHex);
// If register returns 4 bytes like "00 00 00 02", this gives 2.
// If it returns "02", this also gives 2.
if (meterSizeRaw > ushort.MaxValue)
{
log.Error(
$"PrepareMeterSizeAndCalibration( Slot: {genesisSmartReader.GetSlotNr}) - MeterSize too large. RawHex='{rawHex}', Value={meterSizeRaw}");
return "MeterSize value too large";
}
ushort int16MeterSize = (ushort)meterSizeRaw;
double[] dSize = cfg.GetQ3CalibrationBySizeDoubles(int16MeterSize);
if (dSize == null || dSize.Length != 3)
{
log.Info(
$"PrepareMeterSizeAndCalibration( Slot: {genesisSmartReader.GetSlotNr}) - Problem with Q3Calibration calculation. Size: {int16MeterSize}");
return ResultNok;
}
genesisSmartReader
.SetQ3Calibration(dSize); // new double[]{valueCalibrate,valueCalibrate,valueCalibrate}
log.Info(
$"PrepareMeterSizeAndCalibration( Slot: {genesisSmartReader.GetSlotNr}) - Based MeterSize: {int16MeterSize} Set Q3Calibration: CH1({dSize[0]}), CH2({dSize[1]}), CH3({dSize[2]})");
}
else
{
genesisSmartReader.SetQ3Calibration(new double[]
{ valueCalibrate, valueCalibrate, valueCalibrate });
}
}catch(Exception ex)
{
log.Error($"PrepareMeterSizeAndCalibration( Slot: {genesisSmartReader.GetSlotNr}) - Error during Q3Calibration calculation: {ex.Message}");
genesisSmartReader.SetQ3Calibration(new double[]
{ valueCalibrate, valueCalibrate, valueCalibrate });
return ResultNok;
}
return ResultOk;
}
/// <summary>
/// Used for test only.
/// </summary>
/// <param name="genesisSmartReader"></param>
/// <param name="cfg"></param>
/// <param name="rawHex"></param>
/// <returns></returns>
private static string PrepareCalibrationFromMeterSizeRawHex(
GenesisSmartReader genesisSmartReader,
TestMethodCfg cfg,
string rawHex)
{
ushort valueCalibrate = 15625;
if (cfg == null)
{
genesisSmartReader.SetQ3Calibration(new double[]
{
valueCalibrate,
valueCalibrate,
valueCalibrate
});
return ResultOk;
}
if (string.IsNullOrWhiteSpace(rawHex))
return "MeterSize RawHex is empty";
uint meterSizeRaw = ParseRawHexToUInt32(rawHex);
if (meterSizeRaw > ushort.MaxValue)
return "MeterSize value too large";
ushort meterSize = (ushort)meterSizeRaw;
double[] dSize = cfg.GetQ3CalibrationBySizeDoubles(meterSize);
if (dSize == null || dSize.Length != 3)
return ResultNok;
genesisSmartReader.SetQ3Calibration(dSize);
return ResultOk;
}
public string CheckMeterPrepare()
{
if (genesisHead != null && genesisHead.DebugLevel == DebugMode.Simulate)
@ -1681,13 +1821,20 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
return "Failed to disable Led Mode";
}
ushort int16 = Convert.ToUInt16(TriggerIdleAsyncResult.RawHex, 16);
if (int16 == 0)
try
{
log.Debug("Already set ");
return ResultOk;
UInt32 int32 = ParseRawHexToUInt32(TriggerIdleAsyncResult.RawHex);
if (int32 == 0)
{
log.Debug("Already set ");
return ResultOk;
}
}
catch (Exception ex)
{
log.Error( $"CheckMeterPrepare_Async( Slot: {genesisSmartReader.GetSlotNr}) - CheckMeterPrepare failed. Result: {TriggerIdleAsyncResult}");
}
var CalFactor2AsyncResult = await gciBridge.WriteRegisterWithRetryAsync(genesisSmartReader.GetSlotNr, RadioService.TriggerIdle, valueTrigerIdle, false, false, token);
if (CalFactor2AsyncResult == null || !CalFactor2AsyncResult.Success)
{
@ -1706,5 +1853,46 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
return ex.Message;
}
}
private static uint ParseRawHexToUInt32(string rawHex, bool littleEndian = false)
{
if (string.IsNullOrWhiteSpace(rawHex))
throw new FormatException("RawHex is empty.");
// Remove spaces/tabs/newlines
string cleaned = rawHex.Replace(" ", "")
.Replace("\t", "")
.Replace("\r", "")
.Replace("\n", "");
// Must be even number of hex chars
if (cleaned.Length % 2 != 0)
throw new FormatException($"Invalid hex length: {cleaned.Length}");
// Max 4 bytes = 8 hex chars
if (cleaned.Length > 8)
throw new FormatException($"Too many bytes for UInt32: '{rawHex}'");
byte[] bytes = new byte[cleaned.Length / 2];
for (int i = 0; i < bytes.Length; i++)
{
bytes[i] = Convert.ToByte(cleaned.Substring(i * 2, 2), 16);
}
if (littleEndian)
Array.Reverse(bytes);
uint value = 0;
foreach (byte b in bytes)
{
value = (value << 8) | b;
}
return value;
}
}
}

View File

@ -400,6 +400,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
public static readonly String ForwardArrow = "GENESISFLOW_ForwardArrow";
public static readonly String StoreCalibration = "GENESISFLOW_StoreCalibration";
public static readonly String TriggerIdle = "GENESISFLOW_TriggerIdle";
public static readonly String MeterSize = "GENESISFLOW_MeterSize";
public async Task<LedState> GetActivityLedStatusMode_Async(
GenesisSmartReader iHead,

View File

@ -215,6 +215,8 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations
}
public int ChannelsCount { get => iChanelsCount; }
private static int iChanelsCount = 3;
private int firstChanel;
@ -1340,8 +1342,8 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations
PrepareCalculatedChannelData();
try
{
log.DebugFormat("DataStreamPostProcessing() - harcoded call GetQ3Calibration(200.0, 120.0, 15625.0);");
SetQ3Calibration(new double[]{15625.0,15625.0,15625.0 });
log.DebugFormat("DataStreamPostProcessing() - harcoded call GetQ3Calibration(200.0, 120.0, 17969.0);");
SetQ3Calibration(new double[]{17969.0,17969.0,17969.0 });
CalculateQ3Calibration(200.0, 120.0);
}
catch (Exception ex)
@ -3958,7 +3960,8 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations
public int GetSlotNr { get => genesisHeadCfg?.SlotNr ?? -1; }
void SetQ3Calibration(double[] q3CalibInitial) { this.q3CalibInitial = q3CalibInitial; }
//TODO BUMI implement variable values for Q3Calibration!
public void SetQ3Calibration(double[] q3CalibInitial) { this.q3CalibInitial = q3CalibInitial; }
private double refVolume = double.NaN;
private double refTime = double.NaN;

View File

@ -990,16 +990,52 @@ namespace TBF.Rig.TestMethods.FlyingStart
{
CalculateMeterResults(chanelXMeterRslt, genesisSmart, tstRslt, genesisSmart.TimestampSecStartRawCh1,
genesisSmart.TimestampSecEndRawCh1, genesisSmart.VolumeLtrStartRawCh1, genesisSmart.VolumeLtrEndRawCh1);
//store in table
TestRsltCalibFactor testRsltCalibFactor = new TestRsltCalibFactor()
{
TestRslt = chanelXMeterRslt.TestRslt,
TimeStart = genesisSmart.TimestampSecStartRawCh1,
TimeEnd = genesisSmart.TimestampSecEndRawCh1,
VolumeStart = genesisSmart.VolumeLtrStartRawCh1,
VolumeEnd = genesisSmart.VolumeLtrEndRawCh1,
};
tstRslt.CalibFactorResultsToSave.Add(testRsltCalibFactor);
}
else if (iCH == 1)
{
CalculateMeterResults(chanelXMeterRslt, genesisSmart, tstRslt, genesisSmart.TimestampSecStartRawCh2,
genesisSmart.TimestampSecEndRawCh2, genesisSmart.VolumeLtrStartRawCh2, genesisSmart.VolumeLtrEndRawCh2);
//store in table
TestRsltCalibFactor testRsltCalibFactor = new TestRsltCalibFactor()
{
TestRslt = chanelXMeterRslt.TestRslt,
TimeStart = genesisSmart.TimestampSecStartRawCh2,
TimeEnd = genesisSmart.TimestampSecEndRawCh2,
VolumeStart = genesisSmart.VolumeLtrStartRawCh2,
VolumeEnd = genesisSmart.VolumeLtrEndRawCh2,
};
tstRslt.CalibFactorResultsToSave.Add(testRsltCalibFactor);
}
else if (iCH == 2)
{
CalculateMeterResults(chanelXMeterRslt, genesisSmart, tstRslt, genesisSmart.TimestampSecStartRawCh3,
genesisSmart.TimestampSecEndRawCh3, genesisSmart.VolumeLtrStartRawCh3, genesisSmart.VolumeLtrEndRawCh3);
//store in table
TestRsltCalibFactor testRsltCalibFactor = new TestRsltCalibFactor()
{
TestRslt = chanelXMeterRslt.TestRslt,
TimeStart = genesisSmart.TimestampSecStartRawCh3,
TimeEnd = genesisSmart.TimestampSecEndRawCh3,
VolumeStart = genesisSmart.VolumeLtrStartRawCh3,
VolumeEnd = genesisSmart.VolumeLtrEndRawCh3,
};
tstRslt.CalibFactorResultsToSave.Add(testRsltCalibFactor);
}
if (!genesisSmart.EnableShowChanels)

View File

@ -1398,6 +1398,18 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollection
{
CalculateMeterResults(chanelXMeterRslt, genesisSmart, tstRslt, genesisSmart.TimestampSecStartRawCh1,
genesisSmart.TimestampSecEndRawCh1, genesisSmart.VolumeLtrStartRawCh1, genesisSmart.VolumeLtrEndRawCh1);
//store in table
TestRsltCalibFactor testRsltCalibFactor = new TestRsltCalibFactor()
{
TestRslt = chanelXMeterRslt.TestRslt,
TimeStart = genesisSmart.TimestampSecStartRawCh1,
TimeEnd = genesisSmart.TimestampSecEndRawCh1,
VolumeStart = genesisSmart.VolumeLtrStartRawCh1,
VolumeEnd = genesisSmart.VolumeLtrEndRawCh1,
};
tstRslt.CalibFactorResultsToSave.Add(testRsltCalibFactor);
}
else if (iCH == 1)
{

View File

@ -2,8 +2,10 @@
/// Copyright (c) 2015-2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Xml.Serialization;
using Common;
using Config.Entities;
@ -74,18 +76,18 @@ namespace TBF.Rig.TestMethods.GenesisCommunication
public int DataBits { get; set; }
public Parity ParityBit { get; set; }
public StopBits StopBits { get; set; }
public int DfltQ2c_15_rl { get; set; }
public int DfltQ2c_15_lr { get; set; }
public int DfltQ2c_20_rl { get; set; }
public int DfltQ2c_20_lr { get; set; }
public int DfltQ2c_25_63_rl { get; set; }
public int DfltQ2c_25_63_lr { get; set; }
public int DfltQ2c_25_10_rl { get; set; }
public int DfltQ2c_25_10_lr { get; set; }
public int DfltQ2c_32_rl { get; set; }
public int DfltQ2c_32_lr { get; set; }
public int DfltQ2c_40_rl { get; set; }
public int DfltQ2c_40_lr { get; set; }
public int CalibFactor1InchCh1 { get; set; }
public int CalibFactor1InchCh2 { get; set; }
public int CalibFactor2InchCh1 { get; set; }
public int CalibFactor2InchCh2 { get; set; }
public int CalibFactor3InchCh1 { get; set; }
public int CalibFactor3InchCh2 { get; set; }
public int CalibFactor4InchCh1 { get; set; }
public int CalibFactor4InchCh2 { get; set; }
public int CalibFactor6InchCh1 { get; set; }
public int CalibFactor6InchCh2 { get; set; }
public int CalibFactor6MoreInchCh1 { get; set; }
public int CalibFactor6MoreInchCh2 { get; set; }
public bool UseWebService { get; set; }
public string BaseUrl { get; set; }
public string RelativeUrl { get; set; }
@ -93,5 +95,36 @@ namespace TBF.Rig.TestMethods.GenesisCommunication
///Remember to Ignore in XmlSerializer !!
[XmlIgnore]
public ITestParams TestParams { get; set; }
public int CalibFactor1InchCh3 { get; set; }
public int CalibFactor2InchCh3 { get; set; }
public int CalibFactor3InchCh3 { get; set; }
public int CalibFactor4InchCh3 { get; set; }
public int CalibFactor6InchCh3 { get; set; }
public int CalibFactor6MoreInchCh3 { get; set; }
public double[] GetQ3CalibrationBySizeDoubles(ushort int16MeterSize)
{
return GetQ3CalibrationBySizeInts(int16MeterSize).Select(i => (double)i).ToArray();
}
public int[] GetQ3CalibrationBySizeInts(ushort int16MeterSize)
{
switch (int16MeterSize)
{
case 0:
return new int[] { CalibFactor1InchCh1, CalibFactor1InchCh2, CalibFactor1InchCh3 };
case 1:
return new int[] { CalibFactor2InchCh1, CalibFactor2InchCh2, CalibFactor2InchCh3 };
case 2:
return new int[] { CalibFactor3InchCh1, CalibFactor3InchCh2, CalibFactor3InchCh3 };
case 3:
return new int[] { CalibFactor4InchCh1, CalibFactor4InchCh2, CalibFactor4InchCh3 };
case 4:
return new int[] { CalibFactor6InchCh1, CalibFactor6InchCh2, CalibFactor6InchCh3};
default:
return new int[] { CalibFactor6MoreInchCh1, CalibFactor6MoreInchCh2, CalibFactor6MoreInchCh3};
}
}
}
}

View File

@ -50,18 +50,24 @@ namespace TBF.Rig.TestMethods.GenesisCommunication
nrThreadsTextBox.Text = config.NrThreads.ToString();
iperlCheckErrorsToStopTextBox.Text = config.IperlCheckErrorsToStop.ToString();
textBox15rl.Text = config.DfltQ2c_15_rl.ToString();
textBox15lr.Text = config.DfltQ2c_15_lr.ToString();
textBox20rl.Text = config.DfltQ2c_20_rl.ToString();
textBox20lr.Text = config.DfltQ2c_20_lr.ToString();
textBox25_63rl.Text = config.DfltQ2c_25_63_rl.ToString();
textBox25_63lr.Text = config.DfltQ2c_25_63_lr.ToString();
textBox25_10rl.Text = config.DfltQ2c_25_10_rl.ToString();
textBox25_10lr.Text = config.DfltQ2c_25_10_lr.ToString();
textBox32rl.Text = config.DfltQ2c_32_rl.ToString();
textBox32lr.Text = config.DfltQ2c_32_lr.ToString();
textBox40rl.Text = config.DfltQ2c_40_rl.ToString();
textBox40lr.Text = config.DfltQ2c_40_lr.ToString();
textBoxCh1_15inch.Text = config.CalibFactor1InchCh1.ToString();
textBoxCh2_15inch.Text = config.CalibFactor1InchCh2.ToString();
textBoxCh3_15inch.Text = config.CalibFactor1InchCh3.ToString();
textBoxCh1_2inch.Text = config.CalibFactor2InchCh1.ToString();
textBoxCh2_2inch.Text = config.CalibFactor2InchCh2.ToString();
textBoxCh3_2inch.Text = config.CalibFactor2InchCh3.ToString();
textBoxCh1_3inch.Text = config.CalibFactor3InchCh1.ToString();
textBoxCh2_3inch.Text = config.CalibFactor3InchCh2.ToString();
textBoxCh3_3inch.Text = config.CalibFactor3InchCh3.ToString();
textBoxCh1_4inch.Text = config.CalibFactor4InchCh1.ToString();
textBoxCh2_4inch.Text = config.CalibFactor4InchCh2.ToString();
textBoxCh3_4inch.Text = config.CalibFactor4InchCh3.ToString();
textBoxCh1_6inch.Text = config.CalibFactor6InchCh1.ToString();
textBoxCh2_6inch.Text = config.CalibFactor6InchCh2.ToString();
textBoxCh3_6inch.Text = config.CalibFactor6InchCh3.ToString();
textBoxCh1_6MoreInch.Text = config.CalibFactor6MoreInchCh1.ToString();
textBoxCh2_6MoreInch.Text = config.CalibFactor6MoreInchCh2.ToString();
textBoxCh3_6MoreInch.Text = config.CalibFactor6MoreInchCh3.ToString();
useWebServiceCheckBox.Checked = config.UseWebService;
baseUrlTextBox.Text = config.BaseUrl;
@ -77,18 +83,24 @@ namespace TBF.Rig.TestMethods.GenesisCommunication
nrThreadsTextBox.Enabled = true;
iperlCheckErrorsToStopTextBox.Enabled = true;
textBox15rl.Enabled = true;
textBox15lr.Enabled = true;
textBox20rl.Enabled = true;
textBox20lr.Enabled = true;
textBox25_63rl.Enabled = true;
textBox25_63lr.Enabled = true;
textBox25_10rl.Enabled = true;
textBox25_10lr.Enabled = true;
textBox32rl.Enabled = true;
textBox32lr.Enabled = true;
textBox40rl.Enabled = true;
textBox40lr.Enabled = true;
textBoxCh1_15inch.Enabled = true;
textBoxCh2_15inch.Enabled = true;
textBoxCh3_15inch.Enabled = true;
textBoxCh1_2inch.Enabled = true;
textBoxCh2_2inch.Enabled = true;
textBoxCh3_2inch.Enabled = true;
textBoxCh1_3inch.Enabled = true;
textBoxCh2_3inch.Enabled = true;
textBoxCh3_3inch.Enabled = true;
textBoxCh1_4inch.Enabled = true;
textBoxCh2_4inch.Enabled = true;
textBoxCh3_4inch.Enabled = true;
textBoxCh1_6inch.Enabled = true;
textBoxCh2_6inch.Enabled = true;
textBoxCh3_6inch.Enabled = true;
textBoxCh1_6MoreInch.Enabled = true;
textBoxCh2_6MoreInch.Enabled = true;
textBoxCh3_6MoreInch.Enabled = true;
useWebServiceCheckBox.Enabled = true;
ManageCheckGroupBox(useWebServiceCheckBox, useWebServiceGroupBox);
@ -127,66 +139,42 @@ namespace TBF.Rig.TestMethods.GenesisCommunication
message += Environment.NewLine + string.Format(Strings.Invalid_0, iperlCheckErrorsToStopLabel.Text);
}
if (!int.TryParse(textBox15rl.Text, out dummy) || dummy < -50 || dummy > 50)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Default Q2 correction factor DN15 RL should be in range -50 .. 50";
}
if (!int.TryParse(textBox15lr.Text, out dummy) || dummy < -50 || dummy > 50)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Default Q2 correction factor DN15 LR should be in range -50 .. 50";
}
if (!int.TryParse(textBox20rl.Text, out dummy) || dummy < -50 || dummy > 50)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Default Q2 correction factor DN20 RL should be in range -50 .. 50";
}
if (!int.TryParse(textBox20lr.Text, out dummy) || dummy < -50 || dummy > 50)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Default Q2 correction factor DN20 LR should be in range -50 .. 50";
}
if (!int.TryParse(textBox25_63rl.Text, out dummy) || dummy < -50 || dummy > 50)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Default Q2 correction factor DN25 Q3 6.3 RL should be in range -50 .. 50";
}
if (!int.TryParse(textBox25_63lr.Text, out dummy) || dummy < -50 || dummy > 50)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Default Q2 correction factor DN25 Q3 6.3 LR should be in range -50 .. 50";
}
if (!int.TryParse(textBox25_10rl.Text, out dummy) || dummy < -50 || dummy > 50)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Default Q2 correction factor DN25 Q3 10 RL should be in range -50 .. 50";
}
if (!int.TryParse(textBox25_10lr.Text, out dummy) || dummy < -50 || dummy > 50)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Default Q2 correction factor DN25 Q3 10 LR should be in range -50 .. 50";
}
if (!int.TryParse(textBox32rl.Text, out dummy) || dummy < -50 || dummy > 50)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Default Q2 correction factor DN32 RL should be in range -50 .. 50";
}
if (!int.TryParse(textBox32lr.Text, out dummy) || dummy < -50 || dummy > 50)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Default Q2 correction factor DN32 LR should be in range -50 .. 50";
}
if (!int.TryParse(textBox40rl.Text, out dummy) || dummy < -50 || dummy > 50)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Default Q2 correction factor DN40 RL should be in range -50 .. 50";
}
if (!int.TryParse(textBox40lr.Text, out dummy) || dummy < -50 || dummy > 50)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Default Q2 correction factor DN40 LR should be in range -50 .. 50";
}
flags = CfgUpdateFlagsQ3(textBoxCh1_15inch.Text,"1.5 inch", ref message, flags, 1);
flags = CfgUpdateFlagsQ3(textBoxCh2_15inch.Text,"1.5 inch", ref message, flags, 2);
flags = CfgUpdateFlagsQ3(textBoxCh3_15inch.Text,"1.5 inch", ref message, flags, 3);
flags = CfgUpdateFlagsQ3(textBoxCh1_2inch.Text,"2 inch", ref message, flags, 1);
flags = CfgUpdateFlagsQ3(textBoxCh2_2inch.Text,"2 inch", ref message, flags, 2);
flags = CfgUpdateFlagsQ3(textBoxCh3_2inch.Text,"2 inch", ref message, flags, 3);
flags = CfgUpdateFlagsQ3(textBoxCh1_3inch.Text,"3 inch", ref message, flags, 1);
flags = CfgUpdateFlagsQ3(textBoxCh2_3inch.Text,"3 inch", ref message, flags, 2);
flags = CfgUpdateFlagsQ3(textBoxCh3_3inch.Text,"3 inch", ref message, flags, 3);
flags = CfgUpdateFlagsQ3(textBoxCh1_4inch.Text,"4 inch", ref message, flags, 1);
flags = CfgUpdateFlagsQ3(textBoxCh2_4inch.Text,"4 inch", ref message, flags, 2);
flags = CfgUpdateFlagsQ3(textBoxCh3_4inch.Text,"4 inch", ref message, flags, 3);
flags = CfgUpdateFlagsQ3(textBoxCh1_6inch.Text,"6 inch", ref message, flags, 1);
flags = CfgUpdateFlagsQ3(textBoxCh2_6inch.Text,"6 inch", ref message, flags, 2);
flags = CfgUpdateFlagsQ3(textBoxCh3_6inch.Text,"6 inch", ref message, flags, 3);
flags = CfgUpdateFlagsQ3(textBoxCh1_6MoreInch.Text,">6 inch", ref message, flags, 1);
flags = CfgUpdateFlagsQ3(textBoxCh1_6MoreInch.Text,">6 inch", ref message, flags, 2);
flags = CfgUpdateFlagsQ3(textBoxCh1_6MoreInch.Text,">6 inch", ref message, flags, 3);
return flags;
}
private CfgUpdateFlags CfgUpdateFlagsQ3(string ValueText, string DN, ref string message, CfgUpdateFlags flags, int ch, int minRange = 0, int maxRange = 25000)
{
int dummy;
if (!int.TryParse(ValueText, out dummy) || dummy < minRange || dummy > maxRange)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + $"Default Q3 correction factor DN({DN}) CH{ch} should be in range {minRange} .. {maxRange}";
}
return flags;
}
@ -208,18 +196,25 @@ namespace TBF.Rig.TestMethods.GenesisCommunication
var DelayBetweenRetries = config.DelayBetweenRetries;
var NrThreads = config.NrThreads;
var IperlCheckErrorsToStop = config.IperlCheckErrorsToStop;
var DfltQ2c_15_rl = config.DfltQ2c_15_rl;
var DfltQ2c_15_lr = config.DfltQ2c_15_lr;
var DfltQ2c_20_rl = config.DfltQ2c_20_rl;
var DfltQ2c_20_lr = config.DfltQ2c_20_lr;
var DfltQ2c_25_63_rl = config.DfltQ2c_25_63_rl;
var DfltQ2c_25_63_lr = config.DfltQ2c_25_63_lr;
var DfltQ2c_25_10_rl = config.DfltQ2c_25_10_rl;
var DfltQ2c_25_10_lr = config.DfltQ2c_25_10_lr;
var DfltQ2c_32_rl = config.DfltQ2c_32_rl;
var DfltQ2c_32_lr = config.DfltQ2c_32_lr;
var DfltQ2c_40_rl = config.DfltQ2c_40_rl;
var DfltQ2c_40_lr = config.DfltQ2c_40_lr;
var calFactor1Ch1 = config.CalibFactor1InchCh1;
var calFactor1Ch2 = config.CalibFactor1InchCh2;
var calFactor1Ch3 = config.CalibFactor1InchCh3;
var calFactor2Ch1 = config.CalibFactor2InchCh1;
var calFactor2Ch2 = config.CalibFactor2InchCh2;
var calFactor2Ch3 = config.CalibFactor2InchCh3;
var calFactor3Ch1 = config.CalibFactor3InchCh1;
var calFactor3Ch2 = config.CalibFactor3InchCh2;
var calFactor3Ch3 = config.CalibFactor3InchCh3;
var calFactor4Ch1 = config.CalibFactor4InchCh1;
var calFactor4Ch2 = config.CalibFactor4InchCh2;
var calFactor4Ch3 = config.CalibFactor4InchCh3;
var calFactor6Ch1 = config.CalibFactor6InchCh1;
var calFactor6Ch2 = config.CalibFactor6InchCh2;
var calFactor6Ch3 = config.CalibFactor6InchCh3;
var calFactor6MCh1 = config.CalibFactor6MoreInchCh1;
var calFactor6MCh2 = config.CalibFactor6MoreInchCh2;
var calFactor6MCh3 = config.CalibFactor6MoreInchCh3;
var UseWebService = config.UseWebService;
var BaseUrl = config.BaseUrl;
var RelativeUrl = config.RelativeUrl;
@ -230,18 +225,24 @@ namespace TBF.Rig.TestMethods.GenesisCommunication
flags |= UpdateDifferent(ref NrThreads, nrThreadsTextBox.Text, CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref IperlCheckErrorsToStop, iperlCheckErrorsToStopTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref DfltQ2c_15_rl, textBox15rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref DfltQ2c_15_lr, textBox15lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref DfltQ2c_20_rl, textBox20rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref DfltQ2c_20_lr, textBox20lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref DfltQ2c_25_63_rl, textBox25_63rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref DfltQ2c_25_63_lr, textBox25_63lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref DfltQ2c_25_10_rl, textBox25_10rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref DfltQ2c_25_10_lr, textBox25_10lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref DfltQ2c_32_rl, textBox32rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref DfltQ2c_32_lr, textBox32lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref DfltQ2c_40_rl, textBox40rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref DfltQ2c_40_lr, textBox40lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref calFactor1Ch1, textBoxCh1_15inch.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref calFactor1Ch2, textBoxCh2_15inch.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref calFactor1Ch3, textBoxCh3_15inch.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref calFactor2Ch1, textBoxCh1_2inch.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref calFactor2Ch2, textBoxCh2_2inch.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref calFactor2Ch3, textBoxCh3_2inch.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref calFactor3Ch1, textBoxCh1_3inch.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref calFactor3Ch2, textBoxCh2_3inch.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref calFactor3Ch3, textBoxCh3_3inch.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref calFactor4Ch1, textBoxCh1_4inch.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref calFactor4Ch2, textBoxCh2_4inch.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref calFactor4Ch3, textBoxCh3_4inch.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref calFactor6Ch1, textBoxCh1_6inch.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref calFactor6Ch2, textBoxCh2_6inch.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref calFactor6Ch3, textBoxCh3_6inch.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref calFactor6MCh1, textBoxCh1_6MoreInch.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref calFactor6MCh2, textBoxCh2_6MoreInch.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref calFactor6MCh3, textBoxCh3_6MoreInch.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref UseWebService, useWebServiceCheckBox.Checked, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref BaseUrl, baseUrlTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
@ -253,18 +254,24 @@ namespace TBF.Rig.TestMethods.GenesisCommunication
config.DelayBetweenRetries = DelayBetweenRetries;
config.NrThreads = NrThreads;
config.IperlCheckErrorsToStop = IperlCheckErrorsToStop;
config.DfltQ2c_15_rl = DfltQ2c_15_rl;
config.DfltQ2c_15_lr = DfltQ2c_15_lr;
config.DfltQ2c_20_rl = DfltQ2c_20_rl;
config.DfltQ2c_20_lr = DfltQ2c_20_lr;
config.DfltQ2c_25_63_rl = DfltQ2c_25_63_rl;
config.DfltQ2c_25_63_lr = DfltQ2c_25_63_lr;
config.DfltQ2c_25_10_rl = DfltQ2c_25_10_rl;
config.DfltQ2c_25_10_lr = DfltQ2c_25_10_lr;
config.DfltQ2c_32_rl = DfltQ2c_32_rl;
config.DfltQ2c_32_lr = DfltQ2c_32_lr;
config.DfltQ2c_40_rl = DfltQ2c_40_rl;
config.DfltQ2c_40_lr = DfltQ2c_40_lr;
config.CalibFactor1InchCh1 = calFactor1Ch1;
config.CalibFactor1InchCh2 = calFactor1Ch2;
config.CalibFactor1InchCh3 = calFactor1Ch3;
config.CalibFactor2InchCh1 = calFactor2Ch1;
config.CalibFactor2InchCh2 = calFactor2Ch2;
config.CalibFactor2InchCh3 = calFactor2Ch3;
config.CalibFactor3InchCh1 = calFactor3Ch1;
config.CalibFactor3InchCh2 = calFactor3Ch2;
config.CalibFactor3InchCh3 = calFactor3Ch3;
config.CalibFactor4InchCh1 = calFactor4Ch1;
config.CalibFactor4InchCh2 = calFactor4Ch2;
config.CalibFactor4InchCh3 = calFactor4Ch3;
config.CalibFactor6InchCh1 = calFactor6Ch1;
config.CalibFactor6InchCh2 = calFactor6Ch2;
config.CalibFactor6InchCh3 = calFactor6Ch3;
config.CalibFactor6MoreInchCh1 = calFactor6MCh1;
config.CalibFactor6MoreInchCh2 = calFactor6MCh2;
config.CalibFactor6MoreInchCh3 = calFactor6MCh3;
config.UseWebService = UseWebService;
config.BaseUrl = BaseUrl;
config.RelativeUrl = RelativeUrl;

File diff suppressed because it is too large Load Diff

View File

@ -63,6 +63,7 @@ namespace TBF.Rig.TestMethods.GenesisCommunication
retVal.Add(iPerlCommunicationForm.SlotDisconnectStr);
retVal.Add(iPerlCommunicationForm.PrepareSlotQ3CalibrationStr);
retVal.Add(iPerlCommunicationForm.WriteSlotQ3CalibrationStr);
retVal.Add(iPerlCommunicationForm.CheckMeterPrepareStr);
retVal.Add(iPerlCommunicationForm.HoldSlotStr);

View File

@ -73,18 +73,18 @@ namespace TBF.Rig.TestMethods.SmartMeterFlyingStartMassCollection
public int DataBits { get; set; }
public Parity ParityBit { get; set; }
public StopBits StopBits { get; set; }
public int DfltQ2c_15_rl { get; set; }
public int DfltQ2c_15_lr { get; set; }
public int DfltQ2c_20_rl { get; set; }
public int DfltQ2c_20_lr { get; set; }
public int DfltQ2c_25_63_rl { get; set; }
public int DfltQ2c_25_63_lr { get; set; }
public int DfltQ2c_25_10_rl { get; set; }
public int DfltQ2c_25_10_lr { get; set; }
public int DfltQ2c_32_rl { get; set; }
public int DfltQ2c_32_lr { get; set; }
public int DfltQ2c_40_rl { get; set; }
public int DfltQ2c_40_lr { get; set; }
public int CalibFactor1InchCh1 { get; set; }
public int CalibFactor1InchCh2 { get; set; }
public int CalibFactor2InchCh1 { get; set; }
public int CalibFactor2InchCh2 { get; set; }
public int CalibFactor3InchCh1 { get; set; }
public int CalibFactor3InchCh2 { get; set; }
public int CalibFactor4InchCh1 { get; set; }
public int CalibFactor4InchCh2 { get; set; }
public int CalibFactor6InchCh1 { get; set; }
public int CalibFactor6InchCh2 { get; set; }
public int CalibFactor6MoreInchCh1 { get; set; }
public int CalibFactor6MoreInchCh2 { get; set; }
public bool UseWebService { get; set; }
public string BaseUrl { get; set; }
public string RelativeUrl { get; set; }

View File

@ -51,18 +51,18 @@ namespace TBF.Rig.TestMethods.SmartMeterFlyingStartMassCollection
nrThreadsTextBox.Text = config.NrThreads.ToString();
iperlCheckErrorsToStopTextBox.Text = config.IperlCheckErrorsToStop.ToString();
textBox15rl.Text = config.DfltQ2c_15_rl.ToString();
textBox15lr.Text = config.DfltQ2c_15_lr.ToString();
textBox20rl.Text = config.DfltQ2c_20_rl.ToString();
textBox20lr.Text = config.DfltQ2c_20_lr.ToString();
textBox25_63rl.Text = config.DfltQ2c_25_63_rl.ToString();
textBox25_63lr.Text = config.DfltQ2c_25_63_lr.ToString();
textBox25_10rl.Text = config.DfltQ2c_25_10_rl.ToString();
textBox25_10lr.Text = config.DfltQ2c_25_10_lr.ToString();
textBox32rl.Text = config.DfltQ2c_32_rl.ToString();
textBox32lr.Text = config.DfltQ2c_32_lr.ToString();
textBox40rl.Text = config.DfltQ2c_40_rl.ToString();
textBox40lr.Text = config.DfltQ2c_40_lr.ToString();
textBox15rl.Text = config.CalibFactor1InchCh1.ToString();
textBox15lr.Text = config.CalibFactor1InchCh2.ToString();
textBox20rl.Text = config.CalibFactor2InchCh1.ToString();
textBox20lr.Text = config.CalibFactor2InchCh2.ToString();
textBox25_63rl.Text = config.CalibFactor3InchCh1.ToString();
textBox25_63lr.Text = config.CalibFactor3InchCh2.ToString();
textBox25_10rl.Text = config.CalibFactor4InchCh1.ToString();
textBox25_10lr.Text = config.CalibFactor4InchCh2.ToString();
textBox32rl.Text = config.CalibFactor6InchCh1.ToString();
textBox32lr.Text = config.CalibFactor6InchCh2.ToString();
textBox40rl.Text = config.CalibFactor6MoreInchCh1.ToString();
textBox40lr.Text = config.CalibFactor6MoreInchCh2.ToString();
useWebServiceCheckBox.Checked = config.UseWebService;
baseUrlTextBox.Text = config.BaseUrl;
@ -209,18 +209,18 @@ namespace TBF.Rig.TestMethods.SmartMeterFlyingStartMassCollection
var DelayBetweenRetries = config.DelayBetweenRetries;
var NrThreads = config.NrThreads;
var IperlCheckErrorsToStop = config.IperlCheckErrorsToStop;
var DfltQ2c_15_rl = config.DfltQ2c_15_rl;
var DfltQ2c_15_lr = config.DfltQ2c_15_lr;
var DfltQ2c_20_rl = config.DfltQ2c_20_rl;
var DfltQ2c_20_lr = config.DfltQ2c_20_lr;
var DfltQ2c_25_63_rl = config.DfltQ2c_25_63_rl;
var DfltQ2c_25_63_lr = config.DfltQ2c_25_63_lr;
var DfltQ2c_25_10_rl = config.DfltQ2c_25_10_rl;
var DfltQ2c_25_10_lr = config.DfltQ2c_25_10_lr;
var DfltQ2c_32_rl = config.DfltQ2c_32_rl;
var DfltQ2c_32_lr = config.DfltQ2c_32_lr;
var DfltQ2c_40_rl = config.DfltQ2c_40_rl;
var DfltQ2c_40_lr = config.DfltQ2c_40_lr;
var DfltQ2c_15_rl = config.CalibFactor1InchCh1;
var DfltQ2c_15_lr = config.CalibFactor1InchCh2;
var DfltQ2c_20_rl = config.CalibFactor2InchCh1;
var DfltQ2c_20_lr = config.CalibFactor2InchCh2;
var DfltQ2c_25_63_rl = config.CalibFactor3InchCh1;
var DfltQ2c_25_63_lr = config.CalibFactor3InchCh2;
var DfltQ2c_25_10_rl = config.CalibFactor4InchCh1;
var DfltQ2c_25_10_lr = config.CalibFactor4InchCh2;
var DfltQ2c_32_rl = config.CalibFactor6InchCh1;
var DfltQ2c_32_lr = config.CalibFactor6InchCh2;
var DfltQ2c_40_rl = config.CalibFactor6MoreInchCh1;
var DfltQ2c_40_lr = config.CalibFactor6MoreInchCh2;
var UseWebService = config.UseWebService;
var BaseUrl = config.BaseUrl;
var RelativeUrl = config.RelativeUrl;
@ -254,18 +254,18 @@ namespace TBF.Rig.TestMethods.SmartMeterFlyingStartMassCollection
config.DelayBetweenRetries = DelayBetweenRetries;
config.NrThreads = NrThreads;
config.IperlCheckErrorsToStop = IperlCheckErrorsToStop;
config.DfltQ2c_15_rl = DfltQ2c_15_rl;
config.DfltQ2c_15_lr = DfltQ2c_15_lr;
config.DfltQ2c_20_rl = DfltQ2c_20_rl;
config.DfltQ2c_20_lr = DfltQ2c_20_lr;
config.DfltQ2c_25_63_rl = DfltQ2c_25_63_rl;
config.DfltQ2c_25_63_lr = DfltQ2c_25_63_lr;
config.DfltQ2c_25_10_rl = DfltQ2c_25_10_rl;
config.DfltQ2c_25_10_lr = DfltQ2c_25_10_lr;
config.DfltQ2c_32_rl = DfltQ2c_32_rl;
config.DfltQ2c_32_lr = DfltQ2c_32_lr;
config.DfltQ2c_40_rl = DfltQ2c_40_rl;
config.DfltQ2c_40_lr = DfltQ2c_40_lr;
config.CalibFactor1InchCh1 = DfltQ2c_15_rl;
config.CalibFactor1InchCh2 = DfltQ2c_15_lr;
config.CalibFactor2InchCh1 = DfltQ2c_20_rl;
config.CalibFactor2InchCh2 = DfltQ2c_20_lr;
config.CalibFactor3InchCh1 = DfltQ2c_25_63_rl;
config.CalibFactor3InchCh2 = DfltQ2c_25_63_lr;
config.CalibFactor4InchCh1 = DfltQ2c_25_10_rl;
config.CalibFactor4InchCh2 = DfltQ2c_25_10_lr;
config.CalibFactor6InchCh1 = DfltQ2c_32_rl;
config.CalibFactor6InchCh2 = DfltQ2c_32_lr;
config.CalibFactor6MoreInchCh1 = DfltQ2c_40_rl;
config.CalibFactor6MoreInchCh2 = DfltQ2c_40_lr;
config.UseWebService = UseWebService;
config.BaseUrl = BaseUrl;
config.RelativeUrl = RelativeUrl;

View File

@ -55,18 +55,18 @@ namespace TBF.Rig.TestMethods.SmartTest
if (config is IiPerlTestMethodCfg cfg)
{
iperlCheckErrorsToStopTextBox.Text = cfg.IperlCheckErrorsToStop.ToString();
textBox15rl.Text = cfg.DfltQ2c_15_rl.ToString();
textBox15lr.Text = cfg.DfltQ2c_15_lr.ToString();
textBox20rl.Text = cfg.DfltQ2c_20_rl.ToString();
textBox20lr.Text = cfg.DfltQ2c_20_lr.ToString();
textBox25_63rl.Text = cfg.DfltQ2c_25_63_rl.ToString();
textBox25_63lr.Text = cfg.DfltQ2c_25_63_lr.ToString();
textBox25_10rl.Text = cfg.DfltQ2c_25_10_rl.ToString();
textBox25_10lr.Text = cfg.DfltQ2c_25_10_lr.ToString();
textBox32rl.Text = cfg.DfltQ2c_32_rl.ToString();
textBox32lr.Text = cfg.DfltQ2c_32_lr.ToString();
textBox40rl.Text = cfg.DfltQ2c_40_rl.ToString();
textBox40lr.Text = cfg.DfltQ2c_40_lr.ToString();
textBox15rl.Text = cfg.CalibFactor1InchCh1.ToString();
textBox15lr.Text = cfg.CalibFactor1InchCh2.ToString();
textBox20rl.Text = cfg.CalibFactor2InchCh1.ToString();
textBox20lr.Text = cfg.CalibFactor2InchCh2.ToString();
textBox25_63rl.Text = cfg.CalibFactor3InchCh1.ToString();
textBox25_63lr.Text = cfg.CalibFactor3InchCh2.ToString();
textBox25_10rl.Text = cfg.CalibFactor4InchCh1.ToString();
textBox25_10lr.Text = cfg.CalibFactor4InchCh2.ToString();
textBox32rl.Text = cfg.CalibFactor6InchCh1.ToString();
textBox32lr.Text = cfg.CalibFactor6InchCh2.ToString();
textBox40rl.Text = cfg.CalibFactor6MoreInchCh1.ToString();
textBox40lr.Text = cfg.CalibFactor6MoreInchCh2.ToString();
}
useWebServiceCheckBox.Checked = config.UseWebService;
@ -225,18 +225,18 @@ namespace TBF.Rig.TestMethods.SmartTest
{
var IperlCheckErrorsToStop = cfg.IperlCheckErrorsToStop;
var DfltQ2c_15_rl = cfg.DfltQ2c_15_rl;
var DfltQ2c_15_lr = cfg.DfltQ2c_15_lr;
var DfltQ2c_20_rl = cfg.DfltQ2c_20_rl;
var DfltQ2c_20_lr = cfg.DfltQ2c_20_lr;
var DfltQ2c_25_63_rl = cfg.DfltQ2c_25_63_rl;
var DfltQ2c_25_63_lr = cfg.DfltQ2c_25_63_lr;
var DfltQ2c_25_10_rl = cfg.DfltQ2c_25_10_rl;
var DfltQ2c_25_10_lr = cfg.DfltQ2c_25_10_lr;
var DfltQ2c_32_rl = cfg.DfltQ2c_32_rl;
var DfltQ2c_32_lr = cfg.DfltQ2c_32_lr;
var DfltQ2c_40_rl = cfg.DfltQ2c_40_rl;
var DfltQ2c_40_lr = cfg.DfltQ2c_40_lr;
var DfltQ2c_15_rl = cfg.CalibFactor1InchCh1;
var DfltQ2c_15_lr = cfg.CalibFactor1InchCh2;
var DfltQ2c_20_rl = cfg.CalibFactor2InchCh1;
var DfltQ2c_20_lr = cfg.CalibFactor2InchCh2;
var DfltQ2c_25_63_rl = cfg.CalibFactor3InchCh1;
var DfltQ2c_25_63_lr = cfg.CalibFactor3InchCh2;
var DfltQ2c_25_10_rl = cfg.CalibFactor4InchCh1;
var DfltQ2c_25_10_lr = cfg.CalibFactor4InchCh2;
var DfltQ2c_32_rl = cfg.CalibFactor6InchCh1;
var DfltQ2c_32_lr = cfg.CalibFactor6InchCh2;
var DfltQ2c_40_rl = cfg.CalibFactor6MoreInchCh1;
var DfltQ2c_40_lr = cfg.CalibFactor6MoreInchCh2;
flags |= UpdateDifferent(ref IperlCheckErrorsToStop, iperlCheckErrorsToStopTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref DfltQ2c_15_rl, textBox15rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
@ -253,18 +253,18 @@ namespace TBF.Rig.TestMethods.SmartTest
flags |= UpdateDifferent(ref DfltQ2c_40_lr, textBox40lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
cfg.IperlCheckErrorsToStop = IperlCheckErrorsToStop;
cfg.DfltQ2c_15_rl = DfltQ2c_15_rl;
cfg.DfltQ2c_15_lr = DfltQ2c_15_lr;
cfg.DfltQ2c_20_rl = DfltQ2c_20_rl;
cfg.DfltQ2c_20_lr = DfltQ2c_20_lr;
cfg.DfltQ2c_25_63_rl = DfltQ2c_25_63_rl;
cfg.DfltQ2c_25_63_lr = DfltQ2c_25_63_lr;
cfg.DfltQ2c_25_10_rl = DfltQ2c_25_10_rl;
cfg.DfltQ2c_25_10_lr = DfltQ2c_25_10_lr;
cfg.DfltQ2c_32_rl = DfltQ2c_32_rl;
cfg.DfltQ2c_32_lr = DfltQ2c_32_lr;
cfg.DfltQ2c_40_rl = DfltQ2c_40_rl;
cfg.DfltQ2c_40_lr = DfltQ2c_40_lr;
cfg.CalibFactor1InchCh1 = DfltQ2c_15_rl;
cfg.CalibFactor1InchCh2 = DfltQ2c_15_lr;
cfg.CalibFactor2InchCh1 = DfltQ2c_20_rl;
cfg.CalibFactor2InchCh2 = DfltQ2c_20_lr;
cfg.CalibFactor3InchCh1 = DfltQ2c_25_63_rl;
cfg.CalibFactor3InchCh2 = DfltQ2c_25_63_lr;
cfg.CalibFactor4InchCh1 = DfltQ2c_25_10_rl;
cfg.CalibFactor4InchCh2 = DfltQ2c_25_10_lr;
cfg.CalibFactor6InchCh1 = DfltQ2c_32_rl;
cfg.CalibFactor6InchCh2 = DfltQ2c_32_lr;
cfg.CalibFactor6MoreInchCh1 = DfltQ2c_40_rl;
cfg.CalibFactor6MoreInchCh2 = DfltQ2c_40_lr;
}
flags |= UpdateDifferent(ref UseWebService, useWebServiceCheckBox.Checked, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref BaseUrl, baseUrlTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);

View File

@ -812,14 +812,14 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
else if (currentActivity.ToLower().Equals(SlotConnectStr.ToLower())) error = SlotConnect(threadID, ihead, ref resultStr);
else if (currentActivity.ToLower().Equals(SlotPCBSlotStr.ToLower())) error = SlotPCBSlot(threadID, ihead, ref resultStr);
else if (currentActivity.ToLower().Equals(SlotSetPasswordStr.ToLower())) error = SlotSetPassword(threadID, ihead, ref resultStr);
else if (currentActivity.ToLower().Equals(SlotLoginStr.ToLower())) error = SlotLogin(threadID, ihead, ref resultStr);
else if (currentActivity.ToLower().Equals(SlotGroupedLoginStr.ToLower())) error = SlotGroupedLogin(threadID, ihead, ref resultStr);
else if (currentActivity.ToLower().Equals(SlotLoginStr.ToLower())) error = SlotLogin(threadID, ihead, ref resultStr);
else if (currentActivity.ToLower().Equals(SlotGroupedLoginStr.ToLower())) error = SlotGroupedLogin(threadID, ihead, ref resultStr);
else if (currentActivity.ToLower().Equals(SlotSetTestModeStr.ToLower())) error = SlotSetTestMode(threadID, ihead, ref resultStr);
else if (currentActivity.ToLower().Equals(SlotSetActiveModeStr.ToLower())) error = SlotSetActiveMode(threadID, ihead, ref resultStr);
else if (currentActivity.ToLower().Equals(SlotDisconnectStr.ToLower())) error = SlotDisconnect(threadID, ihead, ref resultStr);
else if (currentActivity.ToLower().Equals(PrepareSlotQ3CalibrationStr.ToLower())) error = PrepareSlotQ3Calibration(threadID, ihead, ref resultStr);
else if (currentActivity.ToLower().Equals(SlotSetActiveModeStr.ToLower()))error = SlotSetActiveMode(threadID, ihead, ref resultStr);
else if (currentActivity.ToLower().Equals(SlotDisconnectStr.ToLower())) error = SlotDisconnect(threadID, ihead, ref resultStr);
else if (currentActivity.ToLower().Equals(PrepareSlotQ3CalibrationStr.ToLower())) error = PrepareSlotQ3Calibration(threadID, ihead,wm, currentTest, tests , ref resultStr);
else if (currentActivity.ToLower().Equals(WriteSlotQ3CalibrationStr.ToLower())) error = WriteSlotQ3Calibration(threadID, ihead, ref resultStr);
else if (currentActivity.ToLower().Equals(CheckMeterPrepareStr.ToLower())) error = CheckMeterPrepare(threadID, ihead, ref resultStr);
else if (currentActivity.ToLower().Equals(CheckMeterPrepareStr.ToLower())) error = CheckMeterPrepare(threadID, ihead, ref resultStr);
else if (currentActivity.ToLower().Contains(ReadSerialNrStr.ToLower())) error = ReadSerialNr(threadID, ihead, ref resultStr);
else if (currentActivity.ToLower().Contains(SetTestModeStr.ToLower())) error = SetTestMode(threadID, ihead, ref resultStr);
@ -1021,10 +1021,30 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
return error;
}
private CommErr PrepareSlotQ3Calibration(int threadId, GenesisSmartReader iHead, ref string resultStr)
private CommErr PrepareSlotQ3Calibration(int threadId, GenesisSmartReader iHead, WaterMeter wm,
Test currentTest, IList<Test> tests, ref string resultStr)
{
CommErr error = CommErr.FailedLogin;
var gciFullLoginResult = iHead.OptoHeadTest.PrepareQ3Calibration();
//TODO BUMI get Next test method
Test NextTest = null;
bool bNextChatch = false;
foreach (Test test in tests)
{
if (test.Equals(currentTest))
{
bNextChatch = true;
continue;
}
if (bNextChatch)
{
NextTest = test;
break;
}
}
var gciFullLoginResult = iHead.OptoHeadTest.PrepareQ3Calibration(cfg,NextTest);
if (!string.IsNullOrEmpty(resultStr) && resultStr.Equals(TBF.Rig.RegisterReaders.GenesisRegReader.communication.OptoHeadTest.ResultOk))
{
log.Debug("SlotLogin successful");

View File

@ -1724,28 +1724,28 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.implementations
switch (ihead.MeterType)
{
case MeterType.DN15:
q2corrRL = cfgIPerl.DfltQ2c_15_rl;
q2corrLR = cfgIPerl.DfltQ2c_15_lr;
q2corrRL = cfgIPerl.CalibFactor1InchCh1;
q2corrLR = cfgIPerl.CalibFactor1InchCh2;
break;
case MeterType.DN20:
q2corrRL = cfgIPerl.DfltQ2c_20_rl;
q2corrLR = cfgIPerl.DfltQ2c_20_lr;
q2corrRL = cfgIPerl.CalibFactor2InchCh1;
q2corrLR = cfgIPerl.CalibFactor2InchCh2;
break;
case MeterType.DN25:
q2corrRL = cfgIPerl.DfltQ2c_25_63_rl;
q2corrLR = cfgIPerl.DfltQ2c_25_63_lr;
q2corrRL = cfgIPerl.CalibFactor3InchCh1;
q2corrLR = cfgIPerl.CalibFactor3InchCh2;
break;
case MeterType.DN25_Q3_10:
q2corrRL = cfgIPerl.DfltQ2c_25_10_rl;
q2corrLR = cfgIPerl.DfltQ2c_25_10_lr;
q2corrRL = cfgIPerl.CalibFactor4InchCh1;
q2corrLR = cfgIPerl.CalibFactor4InchCh2;
break;
case MeterType.DN32:
q2corrRL = cfgIPerl.DfltQ2c_32_rl;
q2corrLR = cfgIPerl.DfltQ2c_32_lr;
q2corrRL = cfgIPerl.CalibFactor6InchCh1;
q2corrLR = cfgIPerl.CalibFactor6InchCh2;
break;
case MeterType.DN40:
q2corrRL = cfgIPerl.DfltQ2c_40_rl;
q2corrLR = cfgIPerl.DfltQ2c_40_lr;
q2corrRL = cfgIPerl.CalibFactor6MoreInchCh1;
q2corrLR = cfgIPerl.CalibFactor6MoreInchCh2;
break;
default:
q2corrRL = 0;
@ -1832,28 +1832,28 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.implementations
switch (ihead.MeterType)
{
case MeterType.DN15:
q2corrRL = cfgIPerl.DfltQ2c_15_rl;
q2corrLR = cfgIPerl.DfltQ2c_15_lr;
q2corrRL = cfgIPerl.CalibFactor1InchCh1;
q2corrLR = cfgIPerl.CalibFactor1InchCh2;
break;
case MeterType.DN20:
q2corrRL = cfgIPerl.DfltQ2c_20_rl;
q2corrLR = cfgIPerl.DfltQ2c_20_lr;
q2corrRL = cfgIPerl.CalibFactor2InchCh1;
q2corrLR = cfgIPerl.CalibFactor2InchCh2;
break;
case MeterType.DN25:
q2corrRL = cfgIPerl.DfltQ2c_25_63_rl;
q2corrLR = cfgIPerl.DfltQ2c_25_63_lr;
q2corrRL = cfgIPerl.CalibFactor3InchCh1;
q2corrLR = cfgIPerl.CalibFactor3InchCh2;
break;
case MeterType.DN25_Q3_10:
q2corrRL = cfgIPerl.DfltQ2c_25_10_rl;
q2corrLR = cfgIPerl.DfltQ2c_25_10_lr;
q2corrRL = cfgIPerl.CalibFactor4InchCh1;
q2corrLR = cfgIPerl.CalibFactor4InchCh2;
break;
case MeterType.DN32:
q2corrRL = cfgIPerl.DfltQ2c_32_rl;
q2corrLR = cfgIPerl.DfltQ2c_32_lr;
q2corrRL = cfgIPerl.CalibFactor6InchCh1;
q2corrLR = cfgIPerl.CalibFactor6InchCh2;
break;
case MeterType.DN40:
q2corrRL = cfgIPerl.DfltQ2c_40_rl;
q2corrLR = cfgIPerl.DfltQ2c_40_lr;
q2corrRL = cfgIPerl.CalibFactor6MoreInchCh1;
q2corrLR = cfgIPerl.CalibFactor6MoreInchCh2;
break;
default:
q2corrRL = 0;

View File

@ -1724,28 +1724,28 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.implementations
switch (ihead.MeterType)
{
case MeterType.DN15:
q2corrRL = cfgIPerl.DfltQ2c_15_rl;
q2corrLR = cfgIPerl.DfltQ2c_15_lr;
q2corrRL = cfgIPerl.CalibFactor1InchCh1;
q2corrLR = cfgIPerl.CalibFactor1InchCh2;
break;
case MeterType.DN20:
q2corrRL = cfgIPerl.DfltQ2c_20_rl;
q2corrLR = cfgIPerl.DfltQ2c_20_lr;
q2corrRL = cfgIPerl.CalibFactor2InchCh1;
q2corrLR = cfgIPerl.CalibFactor2InchCh2;
break;
case MeterType.DN25:
q2corrRL = cfgIPerl.DfltQ2c_25_63_rl;
q2corrLR = cfgIPerl.DfltQ2c_25_63_lr;
q2corrRL = cfgIPerl.CalibFactor3InchCh1;
q2corrLR = cfgIPerl.CalibFactor3InchCh2;
break;
case MeterType.DN25_Q3_10:
q2corrRL = cfgIPerl.DfltQ2c_25_10_rl;
q2corrLR = cfgIPerl.DfltQ2c_25_10_lr;
q2corrRL = cfgIPerl.CalibFactor4InchCh1;
q2corrLR = cfgIPerl.CalibFactor4InchCh2;
break;
case MeterType.DN32:
q2corrRL = cfgIPerl.DfltQ2c_32_rl;
q2corrLR = cfgIPerl.DfltQ2c_32_lr;
q2corrRL = cfgIPerl.CalibFactor6InchCh1;
q2corrLR = cfgIPerl.CalibFactor6InchCh2;
break;
case MeterType.DN40:
q2corrRL = cfgIPerl.DfltQ2c_40_rl;
q2corrLR = cfgIPerl.DfltQ2c_40_lr;
q2corrRL = cfgIPerl.CalibFactor6MoreInchCh1;
q2corrLR = cfgIPerl.CalibFactor6MoreInchCh2;
break;
default:
q2corrRL = 0;
@ -1832,28 +1832,28 @@ namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.implementations
switch (ihead.MeterType)
{
case MeterType.DN15:
q2corrRL = cfgIPerl.DfltQ2c_15_rl;
q2corrLR = cfgIPerl.DfltQ2c_15_lr;
q2corrRL = cfgIPerl.CalibFactor1InchCh1;
q2corrLR = cfgIPerl.CalibFactor1InchCh2;
break;
case MeterType.DN20:
q2corrRL = cfgIPerl.DfltQ2c_20_rl;
q2corrLR = cfgIPerl.DfltQ2c_20_lr;
q2corrRL = cfgIPerl.CalibFactor2InchCh1;
q2corrLR = cfgIPerl.CalibFactor2InchCh2;
break;
case MeterType.DN25:
q2corrRL = cfgIPerl.DfltQ2c_25_63_rl;
q2corrLR = cfgIPerl.DfltQ2c_25_63_lr;
q2corrRL = cfgIPerl.CalibFactor3InchCh1;
q2corrLR = cfgIPerl.CalibFactor3InchCh2;
break;
case MeterType.DN25_Q3_10:
q2corrRL = cfgIPerl.DfltQ2c_25_10_rl;
q2corrLR = cfgIPerl.DfltQ2c_25_10_lr;
q2corrRL = cfgIPerl.CalibFactor4InchCh1;
q2corrLR = cfgIPerl.CalibFactor4InchCh2;
break;
case MeterType.DN32:
q2corrRL = cfgIPerl.DfltQ2c_32_rl;
q2corrLR = cfgIPerl.DfltQ2c_32_lr;
q2corrRL = cfgIPerl.CalibFactor6InchCh1;
q2corrLR = cfgIPerl.CalibFactor6InchCh2;
break;
case MeterType.DN40:
q2corrRL = cfgIPerl.DfltQ2c_40_rl;
q2corrLR = cfgIPerl.DfltQ2c_40_lr;
q2corrRL = cfgIPerl.CalibFactor6MoreInchCh1;
q2corrLR = cfgIPerl.CalibFactor6MoreInchCh2;
break;
default:
q2corrRL = 0;

View File

@ -1425,6 +1425,7 @@
<Compile Include="Rig\RegisterReaders\GenesisRegReader\common\OptoTelegramRaw.cs"/>
<Compile Include="Rig\RegisterReaders\GenesisRegReader\communication\ChannelAverages.cs"/>
<Compile Include="Rig\RegisterReaders\GenesisRegReader\communication\common\LedState.cs" />
<Compile Include="Rig\RegisterReaders\GenesisRegReader\communication\GciBridgeClient.cs" />
<Compile Include="Rig\RegisterReaders\GenesisRegReader\communication\Genesis\Crc16Ccitt.cs" />
<Compile Include="Rig\RegisterReaders\GenesisRegReader\communication\Genesis\DataPackages\EventArguments\BaseDataEventArgs.cs" />
<Compile Include="Rig\RegisterReaders\GenesisRegReader\communication\Genesis\DataPackages\EventArguments\BendDetectDataEventArgs.cs" />
@ -1511,6 +1512,7 @@
<Compile Include="Rig\RegisterReaders\GenesisRegReader\communication\Genesis\Registers\Registers.cs" />
<Compile Include="Rig\RegisterReaders\GenesisRegReader\communication\Genesis\StatusReturn.cs" />
<Compile Include="Rig\RegisterReaders\GenesisRegReader\communication\Genesis\ThreadWatcher.cs" />
<Compile Include="Rig\RegisterReaders\GenesisRegReader\communication\IGciBridgeClient.cs" />
<Compile Include="Rig\RegisterReaders\GenesisRegReader\communication\OptoHeadTest.cs" />
<Compile Include="Rig\RegisterReaders\GenesisRegReader\communication\RadioService.cs" />
<Compile Include="Rig\RegisterReaders\GenesisRegReader\communication\Utils\ISerialDriver.cs" />

View File

@ -89,8 +89,8 @@ namespace TBF.UI.Shared
{
Localize();
#if DEBUG
userNameTextBox.Text = "Sensus Developers";
passwordTextBox.Text = "5fbg12gf5hn8nhy1fr";
userNameTextBox.Text = "bumi";
passwordTextBox.Text = "70630";
#endif
Array.Sort(Program.LocalSettings.TestBenches);
for (int i = 0; i < Program.LocalSettings.BenchesCount; i++)

149
TBFTests/DBTest.cs Normal file
View File

@ -0,0 +1,149 @@
using System;
using System.Collections.Generic;
using System.IO;
using Common;
using JetBrains.Annotations;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Results;
using Results.Entities;
namespace TBFTests
{
[TestClass]
[TestSubject(typeof(DB))]
public class DBTests
{
private string _dbFile;
private string _dbName;
[TestInitialize]
public void Setup()
{
DB.DbType = DBType.MySql;
DB.ConnectionString =
"SERVER=localhost; DATABASE=tbf_test; UID=root; PASSWORD=; CHARSET=utf8;";
DB.SessionFactory = null;
Assert.IsTrue(DB.CreateEmptyDB());
}
[TestCleanup]
public void Cleanup()
{
DB.SessionFactory?.Dispose();
DB.SessionFactory = null;
if (File.Exists(_dbFile))
File.Delete(_dbFile);
}
[TestMethod]
public void LoadBatch_ExistingBatchNr_ReturnsBatch()
{
// ARRANGE
Batch batch = new Batch
{
BatchNr = 1234
};
bool saved = DB.SaveNewBatch(batch);
Assert.IsTrue(saved);
// ACT
Batch loaded = DB.LoadBatch(1234);
// ASSERT
Assert.IsNotNull(loaded);
Assert.AreEqual(1234, loaded.BatchNr);
}
[TestMethod]
public void LoadBatch_NotExistingBatchNr_ReturnsNull()
{
// ACT
Batch loaded = DB.LoadBatch(999999);
// ASSERT
Assert.IsNull(loaded);
}
[TestMethod]
public void LoadBatch_LoadsTestRsltCalibFactorResults()
{
Batch batch = new Batch
{
BatchNr = 2222,
TestRslts = new List<TestRslt>(),
WaterMeters = new List<WaterMeter>()
};
TestData testData = new TestData
{
Name = "Q3Calibration",
Repeats = 1,
Method = "SmartCommunication"
};
Components components = new Components();
TestRslt testRslt = new TestRslt
{
Batch = batch,
TestData = testData,
Components = components,
Part = 1,
RepetitionNr = 1,
StartTime = DateTime.Now,
EndTime = DateTime.Now,
TestDone = true,
CalibFactorResultsToSave = new List<TestRsltCalibFactor>
{
new TestRsltCalibFactor
{
CalibFactorIndex = 1,
BaseCalibFactor = 15625,
CalculatedCalibFactor = 17969,
Stored = true,
ErrorStr = "OK",
TimeStart = 1.1,
TimeEnd = 2.2,
CalibRawStart = 100,
CalibRawEnd = 200,
Error = 0.12,
VolumeStart = 10,
VolumeEnd = 20
}
}
};
batch.TestRslts.Add(testRslt);
bool saved = DB.SaveNewBatch(batch);
Assert.IsTrue(saved);
Batch loaded = DB.LoadBatch(2222);
Assert.IsNotNull(loaded);
Assert.IsNotNull(loaded.TestRslts);
Assert.AreEqual(1, loaded.TestRslts.Count);
TestRslt loadedTestRslt = loaded.TestRslts[0];
Assert.IsNotNull(loadedTestRslt.CalibFactorResultsToSave);
Assert.AreEqual(1, loadedTestRslt.CalibFactorResultsToSave.Count);
TestRsltCalibFactor loadedCalib =
loadedTestRslt.CalibFactorResultsToSave[0];
Assert.AreEqual(1, loadedCalib.CalibFactorIndex);
Assert.AreEqual(15625, loadedCalib.BaseCalibFactor);
Assert.AreEqual(17969, loadedCalib.CalculatedCalibFactor);
Assert.IsTrue(loadedCalib.Stored);
Assert.AreEqual("OK", loadedCalib.ErrorStr);
}
}
}

View File

@ -0,0 +1,54 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using GenesisCordonelInterface.API;
using GenesisCordonelInterface.Core.Threading;
using TBF.Rig.RegisterReaders.GenesisRegReader.communication;
namespace TBFTests.Rig.RegisterReaders.GenesisRegReader.communication
{
public class FakeGciBridgeClient : IGciBridgeClient
{
public List<(string Register, ushort Value)> Writes = new List<(string Register, ushort Value)>();
public Task<RetryResult<PublicModels.RegisterReadResult>>
ReadRegisterWithRetryAsync(
int slotId,
string registerName,
CancellationToken token = default)
{
return Task.FromResult(
new RetryResult<PublicModels.RegisterReadResult>
{
Success = true,
Result = new PublicModels.RegisterReadResult
{
Success = true,
RawHex = "0014"
}
});
}
public Task<RetryResult<PublicModels.RegisterWriteResult>>
WriteRegisterWithRetryAsync(
int slotId,
string registerName,
ushort value,
bool verify,
bool throwOnError,
CancellationToken token = default)
{
Writes.Add((registerName, value));
return Task.FromResult(
new RetryResult<PublicModels.RegisterWriteResult>
{
Success = true,
Result = new PublicModels.RegisterWriteResult
{
Success = true
}
});
}
}
}

View File

@ -0,0 +1,124 @@
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Config.Entities;
using GenesisCordonelInterface.API;
using JetBrains.Annotations;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TBF.Rig.BridgeComponents.GciBridge;
using TBF.Rig.RegisterReaders.GenesisRegReader.communication;
using TBF.Rig.RegisterReaders.GenesisRegReader.implementations;
using TBF.Rig.Sequences;
using TBF.Rig.TestMethods.GenesisCommunication;
namespace TBFTests.Rig.RegisterReaders.GenesisRegReader.communication
{
[TestClass]
[TestSubject(typeof(OptoHeadTest))]
public class OptoHeadTestImpelementations
{
[TestMethod]
public void PrepareMeterSizeAndCalibration_CfgNull_SetsDefaultCalibration()
{
GenesisSmartReader reader = new GenesisSmartReader();
MethodInfo method = typeof(OptoHeadTest).GetMethod(
"PrepareMeterSizeAndCalibration",
BindingFlags.NonPublic | BindingFlags.Static);
Assert.IsNotNull(method);
var task = (Task<string>)method.Invoke(
null,
new object[]
{
reader,
null,
null,
CancellationToken.None
});
string result = task.GetAwaiter().GetResult();
Assert.AreEqual(OptoHeadTest.ResultOk, result);
Assert.IsNotNull(reader.Q3CalibValue);
Assert.AreEqual(3, reader.Q3CalibValue.Length);
Assert.AreEqual(15625, reader.Q3CalibValue[0]);
Assert.AreEqual(15625, reader.Q3CalibValue[1]);
Assert.AreEqual(15625, reader.Q3CalibValue[2]);
}
[TestMethod]
public void PrepareMeterSizeAndCalibration_MeterSize4_TakesCalibrationFromConfiguration()
{
GenesisSmartReader reader = new GenesisSmartReader();
TestMethodCfg cfg = new TestMethodCfg(null)
{
CalibFactor6InchCh1 = 17969,
CalibFactor6InchCh2 = 17969,
CalibFactor6InchCh3 = 17969
};
MethodInfo method = typeof(OptoHeadTest).GetMethod(
"PrepareCalibrationFromMeterSizeRawHex",
BindingFlags.NonPublic | BindingFlags.Static);
Assert.IsNotNull(method);
string result = (string)method.Invoke(
null,
new object[]
{
reader,
cfg,
"04"
});
Assert.AreEqual(OptoHeadTest.ResultOk, result);
Assert.IsNotNull(reader.Q3CalibValue);
Assert.AreEqual(3, reader.Q3CalibValue.Length);
Assert.AreEqual(17969, reader.Q3CalibValue[0]);
Assert.AreEqual(17969, reader.Q3CalibValue[1]);
Assert.AreEqual(17969, reader.Q3CalibValue[2]);
}
[TestMethod]
public void PrepareQ3Calibration_SimulateMode_ReturnsOk()
{
// ARRANGE
GenesisSmartReader reader = new GenesisSmartReader
{
DebugLevel = Common.DebugMode.Simulate
};
OptoHeadTest optoHeadTest = new OptoHeadTest(reader);
TestMethodCfg cfg = new TestMethodCfg(null)
{
CalibFactor6InchCh1 = 17969,
CalibFactor6InchCh2 = 17969,
CalibFactor6InchCh3 = 17969
};
Test test = new Test
{
Name = "Q3Calibration",
Part = 1
};
// ACT
string result = optoHeadTest.PrepareQ3Calibration(cfg, test);
// ASSERT
Assert.AreEqual(OptoHeadTest.ResultOk, result);
}
}
}

View File

@ -0,0 +1,84 @@
using JetBrains.Annotations;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TBF.Rig.RegisterReaders.GenesisRegReader.communication;
using System;
namespace TBFTests.Rig.RegisterReaders.GenesisRegReader.communication
{
[TestClass]
[TestSubject(typeof(OptoHeadTest))]
public class OptoHeadTestTestParseIntAnswer
{
private static uint InvokeParseRawHexToUInt32(string rawHex, bool littleEndian = false)
{
var method = typeof(OptoHeadTest).GetMethod(
"ParseRawHexToUInt32",
System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Static);
Assert.IsNotNull(method, "Private method ParseRawHexToUInt32 was not found.");
return (uint)method.Invoke(null, new object[] { rawHex, littleEndian });
}
[TestMethod]
public void ParseRawHexToUInt32_OneByte_ReturnsValue()
{
uint result = InvokeParseRawHexToUInt32("33");
Assert.AreEqual(0x33u, result);
}
[TestMethod]
public void ParseRawHexToUInt32_TwoBytes_ReturnsValue()
{
uint result = InvokeParseRawHexToUInt32("33 33");
Assert.AreEqual(0x3333u, result);
}
[TestMethod]
public void ParseRawHexToUInt32_FourBytes_ReturnsValue()
{
uint result = InvokeParseRawHexToUInt32("33 33 00 00");
Assert.AreEqual(0x33330000u, result);
}
[TestMethod]
public void ParseRawHexToUInt32_FourBytesLittleEndian_ReturnsValue()
{
uint result = InvokeParseRawHexToUInt32("33 33 00 00", true);
Assert.AreEqual(0x00003333u, result);
}
[TestMethod]
public void ParseRawHexToUInt32_Empty_ThrowsFormatException()
{
var ex = Assert.ThrowsException<System.Reflection.TargetInvocationException>(() =>
InvokeParseRawHexToUInt32(""));
Assert.IsInstanceOfType(ex.InnerException, typeof(FormatException));
}
[TestMethod]
public void ParseRawHexToUInt32_InvalidHex_ThrowsFormatException()
{
var ex = Assert.ThrowsException<System.Reflection.TargetInvocationException>(() =>
InvokeParseRawHexToUInt32("GG"));
Assert.IsInstanceOfType(ex.InnerException, typeof(FormatException));
}
[TestMethod]
public void ParseRawHexToUInt32_TooManyBytes_ThrowsFormatException()
{
var ex = Assert.ThrowsException<System.Reflection.TargetInvocationException>(() =>
InvokeParseRawHexToUInt32("01 02 03 04 05"));
Assert.IsInstanceOfType(ex.InnerException, typeof(FormatException));
}
}
}

View File

@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TBFTests</RootNamespace>
<AssemblyName>TBFTests</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
@ -19,6 +19,7 @@
<TestProjectType>UnitTest</TestProjectType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<LangVersion>8</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -41,6 +42,9 @@
<Reference Include="Castle.Core, Version=5.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<HintPath>..\packages\Castle.Core.5.1.1\lib\net462\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="Iesi.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
<HintPath>..\packages\Iesi.Collections.4.0.0.4000\lib\net40\Iesi.Collections.dll</HintPath>
</Reference>
<Reference Include="JetBrains.Annotations, Version=4242.42.42.42, Culture=neutral, PublicKeyToken=1010a0d8d6380325, processorArchitecture=MSIL">
<HintPath>..\packages\JetBrains.Annotations.2023.3.0\lib\net20\JetBrains.Annotations.dll</HintPath>
</Reference>
@ -62,11 +66,18 @@
<Reference Include="Moq, Version=4.20.70.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.20.70\lib\net462\Moq.dll</HintPath>
</Reference>
<Reference Include="NHibernate, Version=4.0.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
<HintPath>..\packages\NHibernate.4.0.4.4000\lib\net40\NHibernate.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Data.SQLite, Version=2.0.3.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.SQLite.2.0.3\lib\net471\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
@ -81,6 +92,7 @@
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Transactions" />
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
@ -100,6 +112,7 @@
<Otherwise />
</Choose>
<ItemGroup>
<Compile Include="DBTest.cs" />
<Compile Include="Entities\MeasurementCorrectionTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Rig\Network\Camera\CJMS11\CameraTest.cs" />
@ -107,6 +120,9 @@
<Compile Include="Rig\Network\Camera\RoiForFixedStartKeyence\RoiTest.cs" />
<Compile Include="Rig\Output\FileWriters\Enhanced\WriterTest.cs" />
<Compile Include="Rig\RegisterReaders\GenesisRegReader\common\OptoTelegramRawTest.cs" />
<Compile Include="Rig\RegisterReaders\GenesisRegReader\communication\FakeGciBridgeClient.cs" />
<Compile Include="Rig\RegisterReaders\GenesisRegReader\communication\OptoHeadTestImpelementations.cs" />
<Compile Include="Rig\RegisterReaders\GenesisRegReader\communication\OptoHeadTestTestParseIntAnswer.cs" />
<Compile Include="Rig\RegisterReaders\GenesisRegReader\communication\OptoHeadTest_Test.cs" />
<Compile Include="Rig\RegisterReaders\GenesisRegReader\implementations\FakeSerialDriver.cs" />
<Compile Include="Rig\RegisterReaders\GenesisRegReader\implementations\GenesisReaderTests.cs" />
@ -151,6 +167,10 @@
<Project>{743df7db-c7b6-42eb-986d-0f485e5588e4}</Project>
<Name>Config</Name>
</ProjectReference>
<ProjectReference Include="..\GenesisCordonelInterface\GenesisCordonelInterface.csproj">
<Project>{c955d8ac-76b8-42d8-a83f-8aeb56cf2567}</Project>
<Name>GenesisCordonelInterface</Name>
</ProjectReference>
<ProjectReference Include="..\Results\Results.csproj">
<Project>{9d0dcc88-dc81-47eb-9fdd-4c3907871bfb}</Project>
<Name>Results</Name>
@ -160,7 +180,7 @@
<Name>SchematicDrawing</Name>
</ProjectReference>
<ProjectReference Include="..\TBF\TBF.csproj">
<Project>{8648FD92-CDA1-4C3A-B5F9-FE547CE1FA48}</Project>
<Project>{8648fd92-cda1-4c3a-b5f9-fe547ce1fa48}</Project>
<Name>TBF</Name>
</ProjectReference>
</ItemGroup>
@ -190,8 +210,10 @@
</PropertyGroup>
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.props'))" />
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.targets'))" />
<Error Condition="!Exists('..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets'))" />
</Target>
<Import Project="..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.targets')" />
<Import Project="..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets" Condition="Exists('..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

View File

@ -1,5 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite" />
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
</DbProviderFactories>
</system.data>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
@ -14,6 +23,86 @@
<assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Logic.ProductionToProductMapper" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.8.18.15404" newVersion="2.8.18.15404" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="mscorlib" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Xylem.Common.CommonCore" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.8.18.15402" newVersion="2.8.18.15402" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Xylem.Common.CommonCore.Configuration" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.8.18.15402" newVersion="2.8.18.15402" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Xylem.Common.Hardware.Interfaces.Ports.PortCore" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.8.18.15403" newVersion="2.8.18.15403" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Xylem.Common.Hardware.Interfaces.Ports.SerialPorts" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.8.18.25320" newVersion="2.8.18.25320" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Xylem.Common.Hardware.WaterMeter.Genesis.Applications" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.8.18.15402" newVersion="2.8.18.15402" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Xylem.Common.Hardware.WaterMeter.Genesis.GenesisConfig" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.8.18.15403" newVersion="2.8.18.15403" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Xylem.Common.Hardware.WaterMeter.Genesis.Registers" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.8.18.15403" newVersion="2.8.18.15403" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Xylem.Common.Hardware.WaterMeter.WaterMeterCore" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.8.18.34245" newVersion="2.8.18.34245" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Xylem.Common.Hardware.WaterMeter.WaterMeterRegisters" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.8.18.15402" newVersion="2.8.18.15402" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Xylem.Common.Logic.ProductionOrderCore" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.8.18.15403" newVersion="2.8.18.15403" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Xylem.Common.Logic.SoftwareAccessHelper" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.8.18.15403" newVersion="2.8.18.15403" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Xylem.Common.Metrology.Measurements" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.8.18.40662" newVersion="2.8.18.40662" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Xylem.Common.Utils.ByteArrayStyle" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.8.18.24507" newVersion="2.8.18.24507" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Xylem.Common.Utils.Crc16Ccitt" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.8.18.24507" newVersion="2.8.18.24507" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Xylem.Common.Utils.Logging" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.8.18.18277" newVersion="2.8.18.18277" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Data.SQLite" publicKeyToken="db937bc2d44ff139" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.3.0" newVersion="2.0.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -1,13 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Castle.Core" version="5.1.1" targetFramework="net472" />
<package id="Iesi.Collections" version="4.0.0.4000" targetFramework="net48" />
<package id="JetBrains.Annotations" version="2023.3.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Configuration.Abstractions" version="5.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Primitives" version="5.0.0" targetFramework="net472" />
<package id="Moq" version="4.20.70" targetFramework="net472" />
<package id="MSTest.TestAdapter" version="2.2.10" targetFramework="net472" />
<package id="MSTest.TestFramework" version="2.2.10" targetFramework="net472" />
<package id="NHibernate" version="4.0.4.4000" targetFramework="net48" />
<package id="Stub.System.Data.SQLite.Core.NetFramework" version="1.0.119.0" targetFramework="net48" />
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
<package id="System.Data.SQLite" version="2.0.3" targetFramework="net48" />
<package id="System.Data.SQLite.Core" version="1.0.119.0" targetFramework="net48" />
<package id="System.Memory" version="4.5.4" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="5.0.0" targetFramework="net472" />