A – Registration and execution - Register GenesisCommunication Factory in the component list. - Separate the Genesis form and sequence from iPerl communication. B – Communication activities - Restore initialization, connection, PCB reading, password and login. - Include grouped login, mode switching and disconnection. - Support processing up to 10 slots. C1 – Input calibration factors - Read three factors from Water meters / Text1–Text3. - Validate integer values in the range 1–65535. - Preserve the default of 15625 when all three fields are empty. D – Q3 calibration - Connect the Prepare Q3 → measurement → Write Q3 workflow. - Add channel processing to FlyingStart and FlyingStartMassCollection. - Reset previous measurement data and validate calculated factors. - Mark factors as stored only after StoreCalibration succeeds. E – Results and database - Store calibration factors separately for each meter and channel. - Add result entities, mappings and Q3 data. - Extend DB.cs / EnsureSchema to create and update the schema. - Preserve compatibility with the existing binary format. Validation: - Debug build and 18 tests passed. - Simulated communication runs follow the same activity sequence. - The complete Q3 workflow has not yet been verified on hardware. Known limitation: - An inherited mismatch in simulated responses and error propagation can produce an incorrect OK result; this change does not fix it.
230 lines
8.9 KiB
C#
230 lines
8.9 KiB
C#
///
|
|
/// Copyright (c) 2015-2022 Sensus Slovensko a.s.
|
|
///
|
|
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Xml.Serialization;
|
|
using Common;
|
|
using Config.Entities;
|
|
using TBF.Resources;
|
|
using TBF.Rig.Generic;
|
|
using TBF.Rig.TestMethods.iPerlCommunication;
|
|
|
|
namespace TBF.Rig.TestMethods.GenesisCommunication
|
|
{
|
|
public class iPerlCommunicationParams : TestParamsBase, IParamsProvider, ITestParams
|
|
{
|
|
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(iPerlCommunicationParams) })[0];
|
|
public override XmlSerializer GetSerializer() { return Serializer; }
|
|
|
|
public string Activity
|
|
{
|
|
get { return base.Activity; }
|
|
set { base.Activity = value; }
|
|
}
|
|
|
|
/// Communication activity
|
|
public bool SimultWithPrevious;
|
|
public bool SimultWithNext;
|
|
|
|
public override void InitializeAll()
|
|
{
|
|
Activity = GenesisCommunicationForm.SlotInitializeStr;
|
|
SimultWithPrevious = false;
|
|
SimultWithNext = false;
|
|
}
|
|
|
|
|
|
string[] paramNames = new string[]
|
|
{
|
|
Strings.Activity,
|
|
Strings.Simultaneous_with_previous_step,
|
|
Strings.Simultaneous_with_next_step,
|
|
};
|
|
public override string ParamName(int i) { return paramNames[i]; }
|
|
public override int ParamsCount() { return paramNames.Length; }
|
|
|
|
public override ICollection<string> ParamValues(int i)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
var retVal = new List<string>();
|
|
|
|
retVal.Add(GenesisCommunicationForm.SlotInitializeStr);
|
|
retVal.Add(GenesisCommunicationForm.SlotUpdateStr);
|
|
retVal.Add(GenesisCommunicationForm.SlotConnectStr);
|
|
retVal.Add(GenesisCommunicationForm.SlotPCBSlotStr);
|
|
retVal.Add(GenesisCommunicationForm.SlotSetPasswordStr);
|
|
retVal.Add(GenesisCommunicationForm.SlotLoginStr);
|
|
retVal.Add(GenesisCommunicationForm.SlotGroupedLoginStr);
|
|
retVal.Add(GenesisCommunicationForm.SlotSetTestModeStr);
|
|
retVal.Add(GenesisCommunicationForm.SlotSetActiveModeStr);
|
|
retVal.Add(GenesisCommunicationForm.SlotDisconnectStr);
|
|
retVal.Add(GenesisCommunicationForm.PrepareSlotQ3CalibrationStr);
|
|
retVal.Add(GenesisCommunicationForm.WriteSlotQ3CalibrationStr);
|
|
retVal.Add(GenesisCommunicationForm.CheckMeterPrepareStr);
|
|
retVal.Add(GenesisCommunicationForm.HoldSlotStr);
|
|
|
|
|
|
|
|
// retVal.Add(GenesisCommunicationForm.ReadConfigurationStr);
|
|
// retVal.Add(GenesisCommunicationForm.ReadSerialNrStr);
|
|
// retVal.Add(string.Format("{0} A0", GenesisCommunicationForm.SetTestModeStr));
|
|
// retVal.Add(string.Format("{0} A4", GenesisCommunicationForm.SetTestModeStr));
|
|
// retVal.Add(GenesisCommunicationForm.ReadCalibrationStr);
|
|
// retVal.Add(GenesisCommunicationForm.ReadCalibrationV4Str);
|
|
// retVal.Add(GenesisCommunicationForm.NormalizeCalibrationFactorStr);
|
|
// retVal.Add(GenesisCommunicationForm.NormalizeCalibrationV4FactorsStr);
|
|
// retVal.Add(GenesisCommunicationForm.GetDefaultQ2CorrectionsStr);
|
|
// retVal.Add(GenesisCommunicationForm.ReadQ2CorrectionStr);
|
|
// retVal.Add(GenesisCommunicationForm.ResetQ2CorrectionStr);
|
|
// retVal.Add(GenesisCommunicationForm.WriteDefaultQ2CorrectionsStr);
|
|
// retVal.Add(GenesisCommunicationForm.InitOrReadQ2CorrectionsStr);
|
|
// retVal.Add(GenesisCommunicationForm.WriteCalibrationFactorStr);
|
|
// retVal.Add(GenesisCommunicationForm.WriteCalibrationV4FactorsStr);
|
|
// retVal.Add(GenesisCommunicationForm.WriteQ2CorrectionStr);
|
|
// retVal.Add(GenesisCommunicationForm.WriteQ2CorrectionAltStr);
|
|
// retVal.Add(GenesisCommunicationForm.WriteQ2CorrectionGreeceStr);
|
|
// retVal.Add(GenesisCommunicationForm.WriteQ2CorrectionRLStr);
|
|
// retVal.Add(GenesisCommunicationForm.WriteQ2CorrectionLRStr);
|
|
// retVal.Add(GenesisCommunicationForm.WriteQ2CorrectionIncl05Str);
|
|
// retVal.Add(GenesisCommunicationForm.WriteQ2CorrectionAltIncl05Str);
|
|
// retVal.Add(GenesisCommunicationForm.WriteQ2CorrectionPlusIncl05Str);
|
|
// retVal.Add(GenesisCommunicationForm.WriteQ2CorrectionPlusAltIncl05Str);
|
|
// retVal.Add(GenesisCommunicationForm.WriteQ2CorrectionGreeceIncl05Str);
|
|
// retVal.Add(GenesisCommunicationForm.WriteQ2CorrectionRLIncl05Str);
|
|
// retVal.Add(GenesisCommunicationForm.WriteQ2CorrectionLRIncl05Str);
|
|
// retVal.Add(iPerlCommunicationSeq.Q2correctedFromCmd + "Qx");
|
|
// retVal.Add(iPerlCommunicationSeq.StrictQ2ErrorCheckStr + "Qx");
|
|
// retVal.Add(iPerlCommunicationSeq.Q2correctionCheckCmd);
|
|
// retVal.Add(iPerlCommunicationSeq.IperlCheckCmd);
|
|
// retVal.Add(GenesisCommunicationForm.UpdateBothQ2FactorsTestRLOnlyStr);
|
|
// retVal.Add(GenesisCommunicationForm.UpdateBothQ2FactorsTestLROnlyStr);
|
|
// retVal.Add(GenesisCommunicationForm.UpdateQ2CorrectionsStr);
|
|
// retVal.Add(GenesisCommunicationForm.ConditnlUpdateQ2CorrectionsStr);
|
|
// retVal.Add(GenesisCommunicationForm.ConditnlUpdateQ2CorrRLStr);
|
|
// retVal.Add(GenesisCommunicationForm.ConditnlUpdateQ2CorrLRStr);
|
|
// retVal.Add("Q2 corrected from Q2adj");
|
|
// retVal.Add("Q2 correction check Q2bc Q2ac");
|
|
// retVal.Add(GenesisCommunicationForm.SetActiveModeStr);
|
|
// retVal.Add(GenesisCommunicationForm.SetIdleModeStr);
|
|
// retVal.Add("---");
|
|
// retVal.Add(GenesisCommunicationForm.Reset2HzCorrectionStr);
|
|
// retVal.Add(GenesisCommunicationForm.Write2HzCorrectionStr);
|
|
// retVal.Add(GenesisCommunicationForm.DewaReworkRLStr);
|
|
// retVal.Add(GenesisCommunicationForm.DewaReworkLRStr);
|
|
// retVal.Add(GenesisCommunicationForm.StartTestingSealedMetersStr);
|
|
// retVal.Add(GenesisCommunicationForm.EndTestingSealedMetersStr);
|
|
// retVal.Add(string.Format("{0} if enabled", GenesisCommunicationForm.ReadConfigurationStr));
|
|
// retVal.Add(string.Format("{0} 80", GenesisCommunicationForm.SetTestModeStr));
|
|
// retVal.Add("iPerl_check prevWorkStep direction q2factors");
|
|
// for (ConditionID id = ConditionID.A; id < ConditionID.Count; id++)
|
|
// {
|
|
// retVal.Add(string.Format(SequenceConditionOp.ConditionNameFmt, id));
|
|
// }
|
|
|
|
return retVal;
|
|
}
|
|
else
|
|
{
|
|
return new string[] { Strings.yes, Strings.no };
|
|
}
|
|
}
|
|
|
|
public override string ToString(int i)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0: return Activity;
|
|
case 1: return (SimultWithPrevious ? Strings.yes : Strings.no);
|
|
case 2: return (SimultWithNext ? Strings.yes : Strings.no);
|
|
default: return string.Empty;
|
|
}
|
|
}
|
|
|
|
public CfgUpdateFlags UpdateParam(int i, string strValue)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0: Activity = strValue; return CfgUpdateFlags.None;
|
|
case 1: SimultWithPrevious = strValue.ToLower().Equals(Strings.yes.ToLower()); return CfgUpdateFlags.None;
|
|
case 2: SimultWithNext = strValue.ToLower().Equals(Strings.yes.ToLower()); return CfgUpdateFlags.None;
|
|
default: return CfgUpdateFlags.None;
|
|
}
|
|
}
|
|
|
|
public bool ValidateParam(int i, string strValue, out string message)
|
|
{
|
|
message = string.Empty;
|
|
|
|
switch (i)
|
|
{
|
|
case 0:
|
|
return true;
|
|
case 1:
|
|
case 2:
|
|
if (strValue.Equals(Strings.yes) || strValue.Equals(Strings.no)) return true;
|
|
break;
|
|
default:
|
|
message = "Invalid index";
|
|
return false;
|
|
}
|
|
|
|
message = ParamName(i) + " is invalid";
|
|
return false;
|
|
}
|
|
|
|
void CopyContentTo(iPerlCommunicationParams prms)
|
|
{
|
|
prms.Activity = this.Activity;
|
|
prms.SimultWithPrevious = this.SimultWithPrevious;
|
|
prms.SimultWithNext = this.SimultWithNext;
|
|
}
|
|
|
|
public IParamsProvider Clone()
|
|
{
|
|
iPerlCommunicationParams pars = new iPerlCommunicationParams();
|
|
CopyContentTo(pars);
|
|
return pars;
|
|
}
|
|
|
|
public override void UpdateFromDbEntity(ComponentTest dbEntity)
|
|
{
|
|
if (dbEntity == null) return;
|
|
try
|
|
{
|
|
iPerlCommunicationParams tmp = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as iPerlCommunicationParams;
|
|
|
|
testParamsEntity = dbEntity;
|
|
componentName = dbEntity.CmpntName;
|
|
test = dbEntity.Test;
|
|
|
|
if (tmp != null) tmp.CopyContentTo(this);
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Parameterless constructor initializes the parameters
|
|
/// </summary>
|
|
public iPerlCommunicationParams()
|
|
{
|
|
}
|
|
|
|
public iPerlCommunicationParams(bool initialize)
|
|
{
|
|
if (initialize) InitializeAll();
|
|
}
|
|
|
|
public iPerlCommunicationParams(ComponentTest testParamsEntity, string componentName, Test test)
|
|
{
|
|
this.testParamsEntity = testParamsEntity;
|
|
this.componentName = componentName;
|
|
this.test = test;
|
|
}
|
|
}
|
|
}
|