From eea80d39c0be03d61d1bea175b0f957430aee114 Mon Sep 17 00:00:00 2001 From: Michal Buzik Date: Mon, 27 Apr 2026 10:48:27 +0200 Subject: [PATCH] Remove `GenesisCommunication` test methods and components: - Deleted `CalibrationStruct`, `ConfigStruct`, `Enums`, `Factory`, `GenesisHead`, and related files. --- TBF/Rig/BridgeComponents/GciBridge/Factory.cs | 2 +- .../BridgeComponents/GciBridge/GciBridge.cs | 2 + .../GenesisRegReader/GenesisCfg.cs | 7 +- .../GenesisRegReader/GenesisCfgCtrl.cs | 43 +- .../GenesisCfgCtrl.designer.cs | 7 +- .../common/OptoTelegramRaw.cs | 1 - .../communication/OptoHeadTest.cs | 87 ++- .../implementations/GenesisSmartReader.cs | 37 +- TBF/Rig/TbfComponents.cs | 2 +- .../TestMethods/FlyingStart/FlyingStartSeq.cs | 25 +- .../FlyingStartMassCollectionSeq.cs | 11 +- .../GenesisHead/CalibrationStruct.cs | 197 ------ .../GenesisHead/ConfigStruct.cs | 225 ------ .../GenesisCommunication/GenesisHead/Enums.cs | 110 --- .../GenesisHead/Factory.cs | 26 - .../GenesisHead/GenesisHead.cs | 657 ------------------ .../GenesisHead/GenesisHeadCfg.cs | 69 -- .../GenesisHead/GenesisHeadCfgCtrl.cs | 111 --- .../GenesisHeadCfgCtrl.designer.cs | 197 ------ .../GenesisHead/GenesisHeadCfgCtrl.resx | 120 ---- .../GenesisHead/OptoReceivedEventArgs.cs | 20 - .../GenesisHead/OptoTelegramRaw.cs | 295 -------- .../GenesisHead/ProcParams.cs | 186 ----- .../GenesisHead/StatusStruct.cs | 160 ----- TBF/TBF.csproj | 39 +- TBF/app.config | 44 ++ TBF/packages.config | 1 + .../GenesisHeadBatchIntegrationTest.cs | 1 - 28 files changed, 237 insertions(+), 2445 deletions(-) delete mode 100644 TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/CalibrationStruct.cs delete mode 100644 TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/ConfigStruct.cs delete mode 100644 TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/Enums.cs delete mode 100644 TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/Factory.cs delete mode 100644 TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/GenesisHead.cs delete mode 100644 TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/GenesisHeadCfg.cs delete mode 100644 TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/GenesisHeadCfgCtrl.cs delete mode 100644 TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/GenesisHeadCfgCtrl.designer.cs delete mode 100644 TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/GenesisHeadCfgCtrl.resx delete mode 100644 TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/OptoReceivedEventArgs.cs delete mode 100644 TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/OptoTelegramRaw.cs delete mode 100644 TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/ProcParams.cs delete mode 100644 TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/StatusStruct.cs diff --git a/TBF/Rig/BridgeComponents/GciBridge/Factory.cs b/TBF/Rig/BridgeComponents/GciBridge/Factory.cs index b53284e28..830b22dfe 100644 --- a/TBF/Rig/BridgeComponents/GciBridge/Factory.cs +++ b/TBF/Rig/BridgeComponents/GciBridge/Factory.cs @@ -5,7 +5,7 @@ namespace TBF.Rig.BridgeComponents.GciBridge { public class Factory : IComponentFactory { - public string ClassName { get { return GetType().Namespace.Substring(12); } } + public string ClassName { get { return this.GetType().Namespace.Substring(12); } } public override string ToString() { diff --git a/TBF/Rig/BridgeComponents/GciBridge/GciBridge.cs b/TBF/Rig/BridgeComponents/GciBridge/GciBridge.cs index 60f5dfddc..b8ee20082 100644 --- a/TBF/Rig/BridgeComponents/GciBridge/GciBridge.cs +++ b/TBF/Rig/BridgeComponents/GciBridge/GciBridge.cs @@ -49,6 +49,8 @@ namespace TBF.Rig.BridgeComponents.GciBridge public bool HasWriter { get { return writer != null; } } public bool IsGuiInitialized { get { return gciGUI != null; } } public bool IsExternalInitialized { get { return gciExternalInterface != null; } } + public ExternalInterfaceType GciExternalInterface { get { return gciExternalInterface; } } + public GciBridgeCfg GciBridgeCfg { get { return gciBridgeCfg; } } public GciBridge() { } diff --git a/TBF/Rig/RegisterReaders/GenesisRegReader/GenesisCfg.cs b/TBF/Rig/RegisterReaders/GenesisRegReader/GenesisCfg.cs index df125b09a..c952cb81e 100644 --- a/TBF/Rig/RegisterReaders/GenesisRegReader/GenesisCfg.cs +++ b/TBF/Rig/RegisterReaders/GenesisRegReader/GenesisCfg.cs @@ -28,7 +28,8 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader public int RfidComPortNr; /// 0 = use MuxBoardNr public int MuxBoardNr; /// 0 = use RfidComPort(Nr), otherwise mux. board nr. 1 .. 4 public int Group; /// Number written to QuidoRS to connct the watermeter to RfidComPort, 1 .. 10 - public CommunicationInterface CommunicationInterface; /// Communication Interface: RFID or NFC + //public CommunicationInterface CommunicationInterface; /// Communication Interface: RFID or NFC + public string CommunicationInterfaceBridge; /// Communication Interface: RFID or NFC public bool EnableShowChanels; public int IBeginDataFlush; @@ -54,7 +55,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader RfidComPortNr = 0; /// = use mux. board MuxBoardNr = 1; ProcParams = CreateProcParamsProvider() as ProcParams; - CommunicationInterface = CommunicationInterface.RFID; + CommunicationInterfaceBridge = string.Empty; HeadCommunicationComPortNr = 0; EnableShowChanels = false; IBeginDataFlush = 2000; @@ -69,7 +70,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader public string ToString(int i) { - return $"{Name} Group1 (mux#)={MuxBoardNr}, Group2={Group}, Opto=Com{OptoComPortNr}, {CommunicationInterface}=Com{RfidComPortNr}, EnableShowChanels={EnableShowChanels}, IBeginDataFlush={IBeginDataFlush}"; + return $"{Name} Group1 (mux#)={MuxBoardNr}, Group2={Group}, Opto=Com{OptoComPortNr}, {CommunicationInterfaceBridge}=Com{RfidComPortNr}, EnableShowChanels={EnableShowChanels}, IBeginDataFlush={IBeginDataFlush}"; } } } \ No newline at end of file diff --git a/TBF/Rig/RegisterReaders/GenesisRegReader/GenesisCfgCtrl.cs b/TBF/Rig/RegisterReaders/GenesisRegReader/GenesisCfgCtrl.cs index 34e071473..ca131b255 100644 --- a/TBF/Rig/RegisterReaders/GenesisRegReader/GenesisCfgCtrl.cs +++ b/TBF/Rig/RegisterReaders/GenesisRegReader/GenesisCfgCtrl.cs @@ -9,6 +9,7 @@ using Common; using TBF.Resources; using TBF.Rig.Generic; using TBF.Rig.RegisterReaders.GenesisRegReader.implementations; +using TBF.UI.Bench.Components; namespace TBF.Rig.RegisterReaders.GenesisRegReader @@ -31,18 +32,50 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader public GenesisCfgCtrl() { InitializeComponent(); + } private void WaterMeterCfgCtrl_Load(object sender, EventArgs e) { nameLabel.Text = Strings.Name; classNameLabel.Text = config.Factory.ClassName; + Init(); + Redraw(); } public void Closing() { } + + + + public void Init() + { + if (!string.IsNullOrEmpty((config.CommunicationInterfaceBridge))) + { + string className = TbfComponents.FindComponent(config.CommunicationInterfaceBridge).ClassName; + } + + + //string[] communicationInterfaces = config.CommunicationInterfaceBridge; + //comboBoxCommunicationInterface.Items.Add(); + + ComponentParametersDlg parent = ParentForm as ComponentParametersDlg; + if (parent == null) return; + + if (parent.CmpntEntities != null) + { + foreach (var cmpnt in parent.CmpntEntities) + { + if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is TBF.Rig.BridgeComponents.GciBridge.Factory) + { + comboBoxCommunicationInterface.Items.Add(cmpnt.Name); + } + } + } + } + void Redraw() { @@ -57,7 +90,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader rfidPortNrTextBox.Text = config.RfidComPortNr.ToString(); muxBoardNrTextBox.Text = config.MuxBoardNr.ToString(); groupTextBox.Text = config.Group.ToString(); - comboBoxCommunicationInterface.SelectedItem = config.CommunicationInterface.ToString(); + comboBoxCommunicationInterface.SelectedItem = config.CommunicationInterfaceBridge; tBBeginDataFlush.Text = config.IBeginDataFlush.ToString(); checkBox_EnableShowChanels.Checked = config.EnableShowChanels; @@ -141,6 +174,12 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader message += Environment.NewLine + string.Format(Strings.Invalid_0, tBBeginDataFlush.Text); } + if (string.IsNullOrEmpty(comboBoxCommunicationInterface.Text) || comboBoxCommunicationInterface.SelectedIndex < 0) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + "Communication Interface is not selected"; + } + return flags; } @@ -167,7 +206,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader config.RfidComPortNr = int.Parse(rfidPortNrTextBox.Text); config.MuxBoardNr = int.Parse(muxBoardNrTextBox.Text); config.Group = int.Parse(groupTextBox.Text); - config.CommunicationInterface = (CommunicationInterface)comboBoxCommunicationInterface.SelectedIndex; + config.CommunicationInterfaceBridge = comboBoxCommunicationInterface.SelectedIndex >= 0 ? comboBoxCommunicationInterface.SelectedItem.ToString() : null; config.HeadCommunicationComPortNr = int.Parse(headPortNrTextBox.Text); config.IBeginDataFlush = int.Parse(tBBeginDataFlush.Text); config.EnableShowChanels = checkBox_EnableShowChanels.Checked; diff --git a/TBF/Rig/RegisterReaders/GenesisRegReader/GenesisCfgCtrl.designer.cs b/TBF/Rig/RegisterReaders/GenesisRegReader/GenesisCfgCtrl.designer.cs index f7892893b..b2ad2805a 100644 --- a/TBF/Rig/RegisterReaders/GenesisRegReader/GenesisCfgCtrl.designer.cs +++ b/TBF/Rig/RegisterReaders/GenesisRegReader/GenesisCfgCtrl.designer.cs @@ -175,17 +175,16 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader // this.comboBoxCommunicationInterface.Enabled = false; this.comboBoxCommunicationInterface.FormattingEnabled = true; - this.comboBoxCommunicationInterface.Items.AddRange(new object[] { "RFID", "NFC" }); - this.comboBoxCommunicationInterface.Location = new System.Drawing.Point(226, 34); + this.comboBoxCommunicationInterface.Location = new System.Drawing.Point(202, 34); this.comboBoxCommunicationInterface.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.comboBoxCommunicationInterface.Name = "comboBoxCommunicationInterface"; - this.comboBoxCommunicationInterface.Size = new System.Drawing.Size(79, 28); + this.comboBoxCommunicationInterface.Size = new System.Drawing.Size(152, 28); this.comboBoxCommunicationInterface.TabIndex = 9; // // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(46, 38); + this.label1.Location = new System.Drawing.Point(8, 38); this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(187, 20); diff --git a/TBF/Rig/RegisterReaders/GenesisRegReader/common/OptoTelegramRaw.cs b/TBF/Rig/RegisterReaders/GenesisRegReader/common/OptoTelegramRaw.cs index f8dc924ff..e2cfab77b 100644 --- a/TBF/Rig/RegisterReaders/GenesisRegReader/common/OptoTelegramRaw.cs +++ b/TBF/Rig/RegisterReaders/GenesisRegReader/common/OptoTelegramRaw.cs @@ -5,7 +5,6 @@ using System; using System.Globalization; using TBF.Rig.RegisterReaders.GenesisRegReader.communication.Genesis.DataPackages.MeasurementRecords; -using TBF.Rig.RegisterReaders.GenesisRegReader.communication.Genesis.Protocols.StreamingProtocol; using Xylem.Common.Metrology.Measurements; diff --git a/TBF/Rig/RegisterReaders/GenesisRegReader/communication/OptoHeadTest.cs b/TBF/Rig/RegisterReaders/GenesisRegReader/communication/OptoHeadTest.cs index aad213dfd..bbf52cbfc 100644 --- a/TBF/Rig/RegisterReaders/GenesisRegReader/communication/OptoHeadTest.cs +++ b/TBF/Rig/RegisterReaders/GenesisRegReader/communication/OptoHeadTest.cs @@ -2,9 +2,11 @@ using System; using System.IO.Ports; using Common; using log4net; +using TBF.Rig.BridgeComponents.GciBridge; using TBF.Rig.RegisterReaders.GenesisRegReader.implementations; using TBF.Rig.TestMethods.iPerlCommunication.communication.C4.diagnosticLed; using TBF.Rig.TestMethods.iPerlCommunication.communication.Utils; +using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore; namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication @@ -19,14 +21,17 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication public static SerialDriver BuildConnection(GenesisSmartReader genesidHead) { - return new SerialDriverBuilder() - .WithPort($"COM{genesidHead.RfidComPortNr}") - .WithBaudRate(9600) - .WithDataBits(8) - .WithParity(Parity.None) - .WithStopBits(StopBits.One) - .WithTimeouts(4000, 2000) - .BuildAndConnect(); + InitSlot(1, genesidHead.RfidComPortNr, genesidHead.RfidComPortNr); + genesidHead?.CommInterfaceBridgeComponent.ConnectExternal(); + + // return new SerialDriverBuilder() + // .WithPort($"COM{genesidHead.RfidComPortNr}") + // .WithBaudRate(9600) + // .WithDataBits(8) + // .WithParity(Parity.None) + // .WithStopBits(StopBits.One) + // .WithTimeouts(4000, 2000) + // .BuildAndConnect(); } @@ -37,17 +42,75 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication public void CloseConnection() { - if (serialDriver != null) - serialDriver.CloseConnection(); - serialDriver = null; + genesisHead?.CommInterfaceBridgeComponent?.DisconnectExternal(); + + // if (serialDriver != null) + // serialDriver.CloseConnection(); + // serialDriver = null; } + private bool slotDefined = false; + + public bool SlotDefined { get => slotDefined; } + + /// + /// + /// + /// must be unique to one connection + /// + /// + public void InitSlot(int slotNr, int ComportNr, int OptoComPortNr ) + { + // init slot + + //create slot object - set pots, etc. + //bridge - call init slot + + //switch + slotDefined = true; + } + + public void DisposeSlot() + { + slotDefined = false; + } + public bool ReadSerialNr() { + if (slotDefined) + { + InitSlot(1,1,1); + } + try { if (genesisHead != null) { + if (string.IsNullOrEmpty(genesisHead.CommInterface)) + { + return false; + } + + if (genesisHead.CommInterfaceBridge != null) + { + //we have bridge interface + + GciBridge gciBridge = genesisHead.CommInterfaceBridgeComponent; + gciBridge.GciBridgeCfg.EnableExternalAccess = true; + gciBridge.GciBridgeCfg.EnableGuiAccess = false; + gciBridge.Initialize(); + if (!gciBridge.GciExternalInterface.IsConnected) + { + gciBridge.ConnectExternal(); + //gciBridge.GciExternalInterface.InitOneMeterFromExtern(1, GenesisMeter.ConfigSource.ExternStorage, GenesisMeter.PasswordSource.ExternUniStorage, GenesisMeter.PasswordSource.ExternUniStorage); + + gciBridge.DisconnectExternal(); + } + + } + + + if (serialDriver == null) serialDriver = BuildConnection(genesisHead); @@ -80,6 +143,8 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication { if (genesisHead != null) { + if(genesisHead.RfidComPortNr != 0 && genesisHead. ) + if (serialDriver == null) serialDriver = BuildConnection(genesisHead); diff --git a/TBF/Rig/RegisterReaders/GenesisRegReader/implementations/GenesisSmartReader.cs b/TBF/Rig/RegisterReaders/GenesisRegReader/implementations/GenesisSmartReader.cs index 648ab375b..494cc718e 100644 --- a/TBF/Rig/RegisterReaders/GenesisRegReader/implementations/GenesisSmartReader.cs +++ b/TBF/Rig/RegisterReaders/GenesisRegReader/implementations/GenesisSmartReader.cs @@ -114,7 +114,30 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations public MeterType MeterType => genesisHeadCfg?.MeterType ?? MeterType.AutoDetect; - public CommunicationInterface CommInterface => genesisHeadCfg?.CommunicationInterface ?? default; + public string CommInterface => genesisHeadCfg?.CommunicationInterfaceBridge ?? default; + + public TBF.Rig.BridgeComponents.GciBridge.Factory CommInterfaceBridge + { + get + { + if (!string.IsNullOrEmpty((genesisHeadCfg?.CommunicationInterfaceBridge))) + { + IComponent findComponent = TbfComponents.FindComponent(genesisHeadCfg?.CommunicationInterfaceBridge); + BridgeComponents.GciBridge.Factory component = findComponent as TBF.Rig.BridgeComponents.GciBridge.Factory; + return component; + } + + return null; + } + } + + public TBF.Rig.BridgeComponents.GciBridge.GciBridge CommInterfaceBridgeComponent + { + get + { + return CommInterfaceBridge.GetComponent(null) as TBF.Rig.BridgeComponents.GciBridge.GciBridge; + } + } public bool EnableShowChanels => genesisHeadCfg?.EnableShowChanels ?? false; @@ -4063,5 +4086,17 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations log.Debug("=== Q3 CALIBRATION END ==="); } + + void newPokus() + { + //TODO BUMI implement genesis communication + //volat z GCI Bridge + + //vybere sa component - GCI bridge + // - rozhranie + // - database + + } + } } \ No newline at end of file diff --git a/TBF/Rig/TbfComponents.cs b/TBF/Rig/TbfComponents.cs index 34fd7be79..fafa75950 100644 --- a/TBF/Rig/TbfComponents.cs +++ b/TBF/Rig/TbfComponents.cs @@ -195,7 +195,7 @@ namespace TBF.Rig new TestMethods.FlyingStartFirstRepetWithMassColl.HeatMeters.Factory(), new TestMethods.FlyingStartTankCollection.Single.Factory(), new TestMethods.FlyingStartTankCollection.Compound.Factory(), - new TestMethods.GenesisCommunication.GenesisHead.Factory(), + //new TestMethods.GenesisCommunication.GenesisHead.Factory(), new TestMethods.GrabImage.Factory(), new TestMethods.iPerlCommunication.TestMethodFactory(), /// iPerlCommunication new TestMethods.LeakTest.Factory(), diff --git a/TBF/Rig/TestMethods/FlyingStart/FlyingStartSeq.cs b/TBF/Rig/TestMethods/FlyingStart/FlyingStartSeq.cs index edda07691..8b81c2ce5 100644 --- a/TBF/Rig/TestMethods/FlyingStart/FlyingStartSeq.cs +++ b/TBF/Rig/TestMethods/FlyingStart/FlyingStartSeq.cs @@ -12,7 +12,6 @@ using TBF.Rig; using TBF.Rig.GenericDevices; using TBF.Boxes; using TBF.Resources; -using TBF.Rig.TestMethods.GenesisCommunication.GenesisHead; using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.common; using TBF.UiBridge; @@ -140,8 +139,8 @@ namespace TBF.Rig.TestMethods.FlyingStart string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); TestStartTime = DateTime.Now; // Genesis switch - bool atleastOneGenesis = GenesisHeadBatch.Start(sensPath.RegisterReaders, Program.LocalSettings.LastSNTexts); - log.Info($"Genesis - atleastOneGenesis = {atleastOneGenesis}"); + //bool atleastOneGenesis = GenesisHeadBatch.Start(sensPath.RegisterReaders, Program.LocalSettings.LastSNTexts); + //log.Info($"Genesis - atleastOneGenesis = {atleastOneGenesis}"); /// /// Optionally display prompt to emerge temperature meters to appropriate baths for heat meters test @@ -334,7 +333,7 @@ namespace TBF.Rig.TestMethods.FlyingStart //TODO genesis - check with genesis switch - if (atleastOneGenesis) + /*if (atleastOneGenesis) { log.Info($"Genesis - Starting... Test Name:{test.Name.ToLower()}."); if (test.Name.ToLower().Contains("calib")) @@ -349,7 +348,7 @@ namespace TBF.Rig.TestMethods.FlyingStart GenesisHeadBatch.BatchHolder.Value.MetersLogin(); GenesisHeadBatch.BatchHolder.Value.MetersInitMeasurement(); } - } + }*/ /// /// Prepare cameras, ROI-s and measurementOperations /// @@ -395,8 +394,8 @@ namespace TBF.Rig.TestMethods.FlyingStart readDatastreamOps.Add(datastreamRR.ReadDatastreamOp()); } - if (rr is GenesisHead) // Genesis - CORDONEL head - (rr as GenesisHead).StartRead(test.Name, BatchRslts.Batch.BatchNr, repetitionNr); + /*if (rr is GenesisHead) // Genesis - CORDONEL head + (rr as GenesisHead).StartRead(test.Name, BatchRslts.Batch.BatchNr, repetitionNr);*/ } } @@ -484,7 +483,7 @@ namespace TBF.Rig.TestMethods.FlyingStart //TODO genesis - check with genesis switch - if (atleastOneGenesis) + /* if (atleastOneGenesis) { if (test.Name.ToLower().Contains("calib")) { @@ -496,7 +495,7 @@ namespace TBF.Rig.TestMethods.FlyingStart log.Info("Genesis - Init measurement stopped."); GenesisHeadBatch.BatchHolder.Value.MetersStopMeasurement(); } - } + }*/ //------------------------------------------------ Bridge.OnActivity(this, Strings.Test_completed); @@ -660,7 +659,7 @@ namespace TBF.Rig.TestMethods.FlyingStart GenericDevices.IRegReaderDatastream dstrReader = regReader as GenericDevices.IRegReaderDatastream; TestMethods.iPerlCommunication.iPerlHead.IperlHead iPerl = regReader as TestMethods.iPerlCommunication.iPerlHead.IperlHead; GenericDevices.IRegReaderLiveCamera cameraRoi = regReader as GenericDevices.IRegReaderLiveCamera; - GenesisHead Genesis = regReader as GenesisHead; + //GenesisHead Genesis = regReader as GenesisHead; if (meterRslt != null && regReader != null) { @@ -669,7 +668,7 @@ namespace TBF.Rig.TestMethods.FlyingStart meterRslt.PulsesMeter = Convert.ToDouble(regReader.WMPulses); - if (Genesis != null) + /*if (Genesis != null) { Genesis.Stop(tstRslt.TestTime, tstRslt.VolumeCTV); @@ -711,7 +710,7 @@ namespace TBF.Rig.TestMethods.FlyingStart var calError = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); Genesis.Log(" MeterError = " + calError.ToString() + " %"); } - else + else*/ { if (dstrReader != null) { @@ -867,7 +866,7 @@ namespace TBF.Rig.TestMethods.FlyingStart stopTest: - GenesisHeadBatch.BatchHolder.Value.RemoveAllMeters(); + /*GenesisHeadBatch.BatchHolder.Value.RemoveAllMeters();*/ StopRecordingStatistics(); cBrd.StopAll(false); diff --git a/TBF/Rig/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs b/TBF/Rig/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs index 6dffef161..7c1e347d7 100644 --- a/TBF/Rig/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs +++ b/TBF/Rig/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs @@ -20,8 +20,7 @@ using TBF.Rig.RegisterReaders.PoseidonReader; using TBF.Rig.RegisterReaders.PoseidonReader.implementations; using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.common; using TBF.UiBridge; -using TBF.Rig.RegisterReaders.PulsesFromUniCB; -using TBF.Rig.TestMethods.GenesisCommunication.GenesisHead; + namespace TBF.Rig.TestMethods.FlyingStartMassCollection { @@ -990,7 +989,7 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollection GenericDevices.IRegReaderDatastream dstrReader = regReader as GenericDevices.IRegReaderDatastream; TestMethods.iPerlCommunication.iPerlHead.IperlHead iPerl = regReader as TestMethods.iPerlCommunication.iPerlHead.IperlHead; GenericDevices.IRegReaderLiveCamera cameraRoi = regReader as GenericDevices.IRegReaderLiveCamera; - TestMethods.GenesisCommunication.GenesisHead.GenesisHead Genesis = regReader as TestMethods.GenesisCommunication.GenesisHead.GenesisHead; + //TestMethods.GenesisCommunication.GenesisHead.GenesisHead Genesis = regReader as TestMethods.GenesisCommunication.GenesisHead.GenesisHead; TBF.Rig.RegisterReaders.GenesisRegReader.implementations.GenesisSmartReader GenesisSmart = regReader as TBF.Rig.RegisterReaders.GenesisRegReader.implementations.GenesisSmartReader; if (meterRslt != null && regReader != null) @@ -1032,7 +1031,7 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollection meterRslt.PulsesMeter = Convert.ToDouble(regReader.WMPulses); //Genesis grab data to results - if (Genesis != null) + /*if (Genesis != null) { log.Debug("Genesis - store data on end!"); meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses); // missing in geenral genesis @@ -1081,7 +1080,7 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollection Genesis.Log(" MeterError = " + calError.ToString() + " %"); } - else if (GenesisSmart != null) + else*/ if (GenesisSmart != null) { log.Debug("GenesisSmart - store data on end!"); bUpgradeCountOfMeters = true; @@ -1329,7 +1328,7 @@ namespace TBF.Rig.TestMethods.FlyingStartMassCollection if (stopCycle) retVal = Event.ErrorFlagsStop; stopTest: - GenesisHeadBatch.BatchHolder.Value.RemoveAllMeters(); + /*GenesisHeadBatch.BatchHolder.Value.RemoveAllMeters();*/ StopRecordingStatistics(); /// Make sure graph files are closed /// diff --git a/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/CalibrationStruct.cs b/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/CalibrationStruct.cs deleted file mode 100644 index 2784c4171..000000000 --- a/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/CalibrationStruct.cs +++ /dev/null @@ -1,197 +0,0 @@ -/// -/// Copyright (c) 2015-2017 Sensus Metering Systems -/// -using System; - -namespace TBF.Rig.TestMethods.GenesisCommunication.GenesisHead -{ - public class CalibrationStruct - { - public static readonly int Length = 35; - - public Byte Version; - public MeterType MeterType; - public UInt16 Calibration; - public VolumeUnits VolumeUnits; - public FlowArrow FlowArrow; - public UInt16 FWVersion; - public UInt16[] TargetField; - public UInt16 RecipMeanCurrent; - public UInt16 ThresholdVolume; - public UInt16 ThresholdTime; - public UInt16 FlowActivationThr; - public UInt16 VolumeArrowThr; - public UInt32 CalibrationTime; - public ulong SerialNumber; - public MeterSealed MeterSealed; - public byte CheckSum; - - - public CalibrationStruct() - { - TargetField = new UInt16[3]; - } - - public byte[] ToByteArray() - { - byte[] result = new byte[Length]; - - result[0] = Version; - result[1] = (byte)MeterType; - - result[2] = (byte)(Calibration & 0x00FF); - result[3] = (byte)((Calibration >> 8) & 0x00FF); - - result[4] = (byte)VolumeUnits; - - result[5] = (byte)FlowArrow; - - result[6] = (byte)(FWVersion & 0x00FF); - result[7] = (byte)((FWVersion >> 8) & 0x00FF); - - result[8] = (byte)( TargetField[0] & 0x00FF); - result[9] = (byte)((TargetField[0] >> 8) & 0x00FF); - result[10] = (byte)( TargetField[1] & 0x00FF); - result[11] = (byte)((TargetField[1] >> 8) & 0x00FF); - result[12] = (byte)( TargetField[2] & 0x00FF); - result[13] = (byte)((TargetField[2] >> 8) & 0x00FF); - - result[14] = (byte)(RecipMeanCurrent & 0x00FF); - result[15] = (byte)((RecipMeanCurrent >> 8) & 0x00FF); - - result[16] = (byte)(ThresholdVolume & 0x00FF); - result[17] = (byte)((ThresholdVolume >> 8) & 0x00FF); - - result[18] = (byte)(ThresholdTime & 0x00FF); - result[19] = (byte)((ThresholdTime >> 8) & 0x00FF); - - result[20] = (byte)(FlowActivationThr & 0x00FF); - result[21] = (byte)((FlowActivationThr >> 8) & 0x00FF); - - result[22] = (byte)(VolumeArrowThr & 0x00FF); - result[23] = (byte)((VolumeArrowThr >> 8) & 0x00FF); - - result[24] = (byte)(CalibrationTime & 0x000000FF); - result[25] = (byte)((CalibrationTime >> 8) & 0x000000FF); - result[26] = (byte)((CalibrationTime >> 16) & 0x000000FF); - result[27] = (byte)((CalibrationTime >> 24) & 0x000000FF); - - result[28] = (byte)(SerialNumber & 0x00000000000000FF); - result[29] = (byte)((SerialNumber >> 8) & 0x00000000000000FF); - result[30] = (byte)((SerialNumber >> 16) & 0x00000000000000FF); - result[31] = (byte)((SerialNumber >> 24) & 0x00000000000000FF); - result[32] = (byte)((SerialNumber >> 32) & 0x00000000000000FF); - - result[33] = (byte)MeterSealed; - result[34] = CheckSum; - - return result; - } - - /// - /// Create a calibration structure from a complete byte array - /// - /// A complete byte array data - /// CalibrationStruct or null when byte array was not complete - public static CalibrationStruct FromByteArray(byte[] data) - { - if (data.Length != Length) return null; - - CalibrationStruct result = new CalibrationStruct(); - - result.Version = data[0]; - result.MeterType = (MeterType)data[1]; - result.Calibration = (UInt16)(data[2] + 256 * data[3]); - result.VolumeUnits = (VolumeUnits)data[4]; - result.FlowArrow = (FlowArrow)data[5]; - result.FWVersion = (UInt16)(data[6] + 256 * data[7]); - result.TargetField[0] = (UInt16)(data[8] + 256 * data[9]); - result.TargetField[1] = (UInt16)(data[10] + 256 * data[11]); - result.TargetField[2] = (UInt16)(data[12] + 256 * data[13]); - result.RecipMeanCurrent = (UInt16)(data[14] + 256 * data[15]); - result.ThresholdVolume = (UInt16)(data[16] + 256 * data[17]); - result.ThresholdTime = (UInt16)(data[18] + 256 * data[19]); - result.FlowActivationThr = (UInt16)(data[20] + 256 * data[21]); - result.VolumeArrowThr = (UInt16)(data[22] + 256 * data[23]); - result.CalibrationTime = (((UInt32)data[27] * 256 + data[26]) * 256 + data[25]) * 256 + data[24]; - result.SerialNumber = ((((UInt64)data[32] * 256 + data[31]) * 256 + data[30]) * 256 + data[29]) * 256 + data[28]; - result.MeterSealed = (MeterSealed)data[33]; - result.CheckSum = data[34]; - - return result; - } - - /// - /// Update the calibration structure from an incomplete byte array - /// - /// Byte array data - /// Offset of byte array data in CalibrationStruct - /// true when successful, false when data are not appropriate - public bool Update(byte[] data, int offset) - { - if (offset == 2 && data.Length == 2) - { - /// Data containing iPerl calibration factor - Calibration = (UInt16)(data[2 - offset] + 256 * data[3 - offset]); - return true; - } - else if (offset == 0 && data.Length == Length) - { - /// Data containing a complete CalibrationStruct - Version = data[0]; - MeterType = (MeterType)data[1]; - Calibration = (UInt16)(data[2] + 256 * data[3]); - VolumeUnits = (VolumeUnits)data[4]; - FlowArrow = (FlowArrow)data[5]; - FWVersion = (UInt16)(data[6] + 256 * data[7]); - TargetField[0] = (UInt16)(data[8] + 256 * data[9]); - TargetField[1] = (UInt16)(data[10] + 256 * data[11]); - TargetField[2] = (UInt16)(data[12] + 256 * data[13]); - RecipMeanCurrent = (UInt16)(data[14] + 256 * data[15]); - ThresholdVolume = (UInt16)(data[16] + 256 * data[17]); - ThresholdTime = (UInt16)(data[18] + 256 * data[19]); - FlowActivationThr = (UInt16)(data[20] + 256 * data[21]); - VolumeArrowThr = (UInt16)(data[22] + 256 * data[23]); - CalibrationTime = (((UInt32)data[27] * 256 + data[26]) * 256 + data[25]) * 256 + data[24]; - SerialNumber = ((((UInt64)data[32] * 256 + data[31]) * 256 + data[30]) * 256 + data[29]) * 256 + data[28]; - MeterSealed = (MeterSealed)data[33]; - CheckSum = data[34]; - return true; - } - else - return false; - } - - public string FWVersionStr() - { - int d1 = (FWVersion >> 8) & 0x000F; - int d2 = (FWVersion >> 12) & 0x000F; - int d3 = (FWVersion >> 4) & 0x000F; - int d4 = FWVersion & 0x000F; - return string.Format("{0}.{1}{2}{3}", d1, d2, d3, d4); - } - - public override string ToString() - { - return string.Format("Calibration: V{0} Type={1} Cal={2} Units={3} FlowArrow.{4} FW={5} Hi={6} Norm={7} Low={8} RMC={9} ThrVol={10} ThrTime={11} FlActThr={12} VolArrThr={13} CalTm={14} SN={15} MeterSealed={16} Chksum={17}", - Version, - MeterType, - Calibration, - VolumeUnits, - FlowArrow, - FWVersion, - TargetField[0], - TargetField[1], - TargetField[2], - RecipMeanCurrent, - ThresholdVolume, - ThresholdTime, - FlowActivationThr, - VolumeArrowThr, - CalibrationTime, - SerialNumber, - MeterSealed, - CheckSum.ToString("X2")); - } - } -} diff --git a/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/ConfigStruct.cs b/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/ConfigStruct.cs deleted file mode 100644 index 80b2d6573..000000000 --- a/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/ConfigStruct.cs +++ /dev/null @@ -1,225 +0,0 @@ -/// -/// Copyright (c) 2015-2017 Sensus Metering Systems -/// -using System; - -namespace TBF.Rig.TestMethods.GenesisCommunication.GenesisHead -{ - public class ConfigStruct - { - public const int Length = 32; - - public Byte Version; /// 0: 1 byte - public MeterState MeterState; /// 1: 1 byte - public UInt32 TargetTimeVeryLowBatt; /// 2: 4 bytes in seconds - public UInt32 TargetTimeLowBatt; /// 6: 4 bytes, in seconds - public UInt32 TestModeTime; /// 10: 4 bytes, Max. test mode time in seconds - public UInt16 EmptyPipeThreshold; /// 14: 2 bytes - public byte[] PCBNumber; /// 16: 5 bytes - public byte TestModeConfig; /// 21: 1 byte - public UInt32 RadioAddress; /// 22: 4 bytes - public UInt16 TempCalibration; /// 26: 2 bytes - public UInt16 AlarmMask; /// 28: 2 bytes, Default 0xA3F7 - public UInt16 ConfigCheckSum; /// 30: 2 bytes - - public ConfigStruct() - { - PCBNumber = new byte[5]; - } - - public byte[] ToByteArray() - { - byte[] result = new byte[Length]; - - result[0] = Version; - result[1] = (byte)MeterState; - - result[2] = (byte)(TargetTimeVeryLowBatt & 0x000000FF); - result[3] = (byte)((TargetTimeVeryLowBatt >> 8) & 0x000000FF); - result[4] = (byte)((TargetTimeVeryLowBatt >> 16) & 0x000000FF); - result[5] = (byte)((TargetTimeVeryLowBatt >> 24) & 0x000000FF); - - result[6] = (byte)(TargetTimeLowBatt & 0x000000FF); - result[7] = (byte)((TargetTimeLowBatt >> 8) & 0x000000FF); - result[8] = (byte)((TargetTimeLowBatt >> 16) & 0x000000FF); - result[9] = (byte)((TargetTimeLowBatt >> 24) & 0x000000FF); - - result[10] = (byte)(TestModeTime & 0x000000FF); - result[11] = (byte)((TestModeTime >> 8) & 0x000000FF); - result[12] = (byte)((TestModeTime >> 16) & 0x000000FF); - result[13] = (byte)((TestModeTime >> 24) & 0x000000FF); - - result[14] = (byte)(EmptyPipeThreshold & 0x00FF); - result[15] = (byte)((EmptyPipeThreshold >> 8) & 0x00FF); - - result[16] = PCBNumber[0]; - result[17] = PCBNumber[1]; - result[18] = PCBNumber[2]; - result[19] = PCBNumber[3]; - result[20] = PCBNumber[4]; - - result[21] = TestModeConfig; - - result[22] = (byte)(RadioAddress & 0x000000FF); - result[23] = (byte)((RadioAddress >> 8) & 0x000000FF); - result[24] = (byte)((RadioAddress >> 16) & 0x000000FF); - result[25] = (byte)((RadioAddress >> 24) & 0x000000FF); - - result[26] = (byte)(TempCalibration & 0x00FF); - result[27] = (byte)((TempCalibration >> 8) & 0x00FF); - - result[28] = (byte)(AlarmMask & 0x00FF); - result[29] = (byte)((AlarmMask >> 8) & 0x00FF); - - result[30] = (byte)(ConfigCheckSum & 0x00FF); - result[31] = (byte)((ConfigCheckSum >> 8) & 0x00FF); - - return result; - } - - /// - /// Create a configuration structure from a complete byte array - /// - /// A complete byte array data - /// ConfigStruct or null when byte array was not complete - public static ConfigStruct FromByteArray(byte[] data) - { - if (data.Length != Length) return null; - - ConfigStruct result = new ConfigStruct(); - - result.Version = data[0]; - result.MeterState = (MeterState)data[1]; - result.TargetTimeVeryLowBatt = (((UInt32)data[5] * 256 + data[4]) * 256 + data[3]) * 256 + data[2]; - result.TargetTimeLowBatt = (((UInt32)data[9] * 256 + data[8]) * 256 + data[7]) * 256 + data[6]; - result.TestModeTime = (((UInt32)data[13] * 256 + data[12]) * 256 + data[11]) * 256 + data[10]; - result.EmptyPipeThreshold = (UInt16)(data[15] * 256 + data[14]); - result.PCBNumber[0] = data[16]; - result.PCBNumber[1] = data[17]; - result.PCBNumber[2] = data[18]; - result.PCBNumber[3] = data[19]; - result.PCBNumber[4] = data[20]; - result.TestModeConfig = data[21]; - result.RadioAddress = (((UInt32)data[25] * 256 + data[24]) * 256 + data[23]) * 256 + data[22]; - result.TempCalibration = (UInt16)(data[27] * 256 + data[26]); - result.AlarmMask = (UInt16)(data[29] * 256 + data[28]); - result.ConfigCheckSum = (UInt16)(data[31] * 256 + data[30]); - - return result; - } - - /// - /// Update the configuration structure from an incomplete byte array - /// - /// Offset of byte array data in ConfigStruct - /// Byte array data - /// true when successful, false when data are not appropriate - public bool Update(int offset, byte[] data) - { - if (offset == 0 && data.Length == 2) - { - /// iPerl mode of function - Version = data[0]; - MeterState = (MeterState)data[1]; - return true; - } - else if (offset == 0 && data.Length == 4) - { - /// iPerl mode of function and extra 2 bytes - Version = data[0]; - MeterState = (MeterState)data[1]; - return true; - } - else if (offset == 21 && data.Length == 1) - { - /// TestModeConfig value - TestModeConfig = data[21 - offset]; - return true; - } - else if (offset == 0 && data.Length == Length) - { - /// Complete ConfigStruct - Version = data[0]; - MeterState = (MeterState)data[1]; - TargetTimeVeryLowBatt = (((UInt32)data[5] * 256 + data[4]) * 256 + data[3]) * 256 + data[2]; - TargetTimeLowBatt = (((UInt32)data[9] * 256 + data[8]) * 256 + data[7]) * 256 + data[6]; - TestModeTime = (((UInt32)data[13] * 256 + data[12]) * 256 + data[11]) * 256 + data[10]; - EmptyPipeThreshold = (UInt16)(data[15] * 256 + data[14]); - PCBNumber[0] = data[16]; - PCBNumber[1] = data[17]; - PCBNumber[2] = data[18]; - PCBNumber[3] = data[19]; - PCBNumber[4] = data[20]; - TestModeConfig = data[21]; - RadioAddress = (((UInt32)data[25] * 256 + data[24]) * 256 + data[23]) * 256 + data[22]; - TempCalibration = (UInt16)(data[27] * 256 + data[26]); - AlarmMask = (UInt16)(data[29] * 256 + data[28]); - ConfigCheckSum = (UInt16)(data[31] * 256 + data[30]); - return true; - } - else - return false; - } - - /// - /// Returns PCB number string (12 characters, 12 decimal digits) - /// - /// PCB number STRING - public string GetPcbNrString() - { - return PCBNumber2String(this.PCBNumber); - } - - /// - /// Converts PCBNumber to string (12 characters, 12 decimal digits) - /// - /// - /// PCB number string - public static string PCBNumber2String(byte[] pcbNumber) - { - if (pcbNumber.Length != 5) return string.Empty; - - Int64 number = 0; - for (int i = 4; i >= 0; i--) - { - number = 256 * number + (Int64)pcbNumber[i]; - } - - return number.ToString(); - } - - public override string ToString() - { - return string.Format("Config: V{0} State={1} VLoBattT={2}s LoBattT={3}s TestModeT={4}s EPThld={5} PCB#={6} TMCfg={7} RadioAddr={8} TempCalib={9} AlarmMask={10} CfgCheckSum={11}", - Version, - MeterState, - TargetTimeVeryLowBatt, - TargetTimeLowBatt, - TestModeTime, - EmptyPipeThreshold, - GetPcbNrString(), - TestModeConfig.ToString("X2"), - RadioAddress, - TempCalibration, - AlarmMask.ToString("X4"), - ConfigCheckSum.ToString("X4")); - } - - public string ToString(int sel) - { - return string.Format("{1} PCB#={6} TMCfg={7}", - Version, - MeterState, - TargetTimeVeryLowBatt, - TargetTimeLowBatt, - TestModeTime, - EmptyPipeThreshold, - GetPcbNrString(), - TestModeConfig.ToString("X2"), - RadioAddress, - TempCalibration, - AlarmMask.ToString("X4"), - ConfigCheckSum.ToString("X4")); - } - } -} diff --git a/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/Enums.cs b/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/Enums.cs deleted file mode 100644 index 1d3e4b009..000000000 --- a/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/Enums.cs +++ /dev/null @@ -1,110 +0,0 @@ -/// -/// Copyright (c) 2015-2017 Sensus Metering Systems -/// -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace TBF.Rig.TestMethods.GenesisCommunication.GenesisHead -{ - public enum MessageID - { - Calibration = 0x00, /// Access to stCalibration - Configuration = 0x01, /// Access to stConfig - Status = 0x02, /// Access to stStaus, read only - Power = 0x03, /// Access to stPower, containing power info from both processors - LCD = 0x04, /// Access to stLCD - EventData = 0x05, /// NOT USED - IntervalData = 0x06, /// NOT USED - Diagnostics = 0x07, /// Access tostMetroDiagArray, read onl - MetrologyMemory = 0x08, /// Memory block access, read only - Error_LongAck = 0x09, /// Error message - Command = 0x0A, /// Command to execute, with no arguments - Parameterizing = 0x0B, /// Parameterizing message is used in MCI-SPI interface only - Error_ShortAck = 0x0C, /// Short acknowledge message is used in MCI-SPI interface only - ChanelAlive = 0x0D, /// Channel alive message is used in MCI-SPI interface only - RadioPassthrough = 0x0E, /// RFID <-> Metrology <-> Radio passthrough message - ASICRegisterReadTest = 0x0F, /// ASIC Register read test - IMIDebugMessagesAccess = 0x10, /// IMI debug messages read test - ProductionChecksumsRead = 0x11, /// Production checksum read: Calibration (1 byte), Configuration (2 bytes), spare (4 bytes) - HardwareParametersTest = 0x12, /// Hardware Parameters Testing: User configurable fixed field drive time (1 byte) - /// - /// Notes: - /// 1. Short Ack message contains 1-byte error code and all the fields (Offset, Payload length, payload and password) will not be present. - /// 2. Channel Alive message does not contain the fields (Offset, Payload length, payload and password). - /// 3. Except the above two special messages, rest all the messages in the above table will follow the message format mentioned in sections 3.1 and 3.2. - /// - Count /// Number of MessageID-s - } - - public enum MeterType : byte - { - DN15 = 0, - CoaxManifold = 1, - DN20 = 2, - DN25 = 3, - DN26 = 4, /// DN25* - DN32 = 5, - DN40 = 6, - AutoDetect, - Count /// Number of meter types - } - - public enum VolumeUnits : byte - { - m3 = 0, - UK_gallon = 1, - US_gallon = 2, - Count /// Number of volume units - } - - public enum FlowArrow : byte - { - No = 0, - Right = 1, - Left = 2, - Count /// Number of flow arrows - } - - public enum MeterSealed : byte - { - InProduction = 0x00, - OutOfProduction = 0xA5, - Sealed = 0x5A, - } - - public enum MeterState : byte - { - None = 0, - Idle = 1, - Active = 2, - Test = 3, - EndOfLife = 4, - Count /// Number of meter states - } - - public enum FlowState : byte - { - No = 0, - Reverse = 1, - Forward = 2, - EmptyPipe = 3, - Count /// Number of flow states - } - - public enum OptoTelegramFlags : byte - { - OK = 0, - OK_TestStart, - OK_TestEnd, - InvalidTelegram, /// Wrong telegram format of checksum error - SyncError, - } - - public enum OptoState - { - Read, - Flush, - } -} diff --git a/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/Factory.cs b/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/Factory.cs deleted file mode 100644 index 9c32e4825..000000000 --- a/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/Factory.cs +++ /dev/null @@ -1,26 +0,0 @@ -/// -/// Copyright (c) 2015-2017 Sensus Metering Systems -/// -using System.Collections.Generic; -using TBF.Rig.Generic; - -namespace TBF.Rig.TestMethods.GenesisCommunication.GenesisHead -{ - public class Factory : IComponentFactory - { - public string ClassName { get { return "RegisterReader for Genesis"; } } - - public void ResetStaticProperties() { GenesisHead.ResetStaticProperties(); } - - public IComponent DummyComponent() { return new GenesisHead(); } - - public IComponent GetComponent(IComponentCfg cfg, IList components) { return new GenesisHead(cfg); } - - public IComponentCfg DefaultConfig() { return new GenesisHeadCfg(this); } - - public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) - { - return ComponentCfgBase.CreateFromDbEntity(GenesisHeadCfg.Serializer, component, this); - } - } -} diff --git a/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/GenesisHead.cs b/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/GenesisHead.cs deleted file mode 100644 index 332c55b91..000000000 --- a/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/GenesisHead.cs +++ /dev/null @@ -1,657 +0,0 @@ -using Config.Entities; -using log4net; -/// -/// Copyright (c) 2015-2018 Sensus Slovensko a.s. -/// -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using TBF.Rig.Generic; -using TBF.Rig.GenericDevices; -using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore; -using Xylem.Common.Hardware.WaterMeter.WaterMeterCore; -using Xylem.Common.Metrology.Measurements; -using Xylem.Common.Metrology.Measurements.Consts; -using Common; -using System.IO.Ports; - - -namespace TBF.Rig.TestMethods.GenesisCommunication.GenesisHead -{ - public static class GenesisHeadBatch - { - public static Dictionary> MeterIdDetailResults = new Dictionary>(); - private static readonly ILog log = LogManager.GetLogger(typeof(GenesisHeadBatch)); - public static readonly Lazy BatchHolder = new Lazy(() => - { - return new MeterBatch(); - }); - - internal static bool Start(IRegReader[] registerReaders, string[] lastSNTexts) - { - try - { - MeterIdDetailResults = new Dictionary>(); - int index = 0; - var ret = false; - foreach (var rr in registerReaders) - { - if (rr is TestMethods.GenesisCommunication.GenesisHead.GenesisHead) - { - if (!string.IsNullOrEmpty(lastSNTexts[index])) - { - var myGenesis = ((TestMethods.GenesisCommunication.GenesisHead.GenesisHead)rr).SetUp(); - myGenesis.SerialNumber = lastSNTexts[index]; - ret = true; - } - } - index = index + 1; - } - - return ret; - } - catch (Exception ex) - { - log.Fatal(ex.Message, ex); - return false; - } - - } - } - /// - /// This component = instance of this class is a placeholder for a combined main watermeter - /// - public class GenesisHead : ComponentBase, IDevice, GenericDevices./*IRegisterReader*/IRegReader, IOperation - { - public List DetailedResults { get; set; } - private static readonly ILog log = LogManager.GetLogger(typeof(GenesisHead)); - public override string ToString() { return string.Format("Genesis({0})", Cfg.ToString(1)); } - - public RegisterReaderType RegisterReaderType { get { return RegisterReaderType.DataStream; } } - - private readonly GenesisHeadCfg genesisHeadCfg; - public int SlotNr { get { return genesisHeadCfg.SlotNr; } } - public int OptoComPortNr { get { return genesisHeadCfg.OptoComPortNr; } } - public int HeadComPortNr { get { return genesisHeadCfg.HeadComPortNr; } } - public double PulsesPerLtr { get { return 1000.0; } } - public double LtrsPerPulse { get { return 1 / PulsesPerLtr; } } - public string QuantityUnits { get; set; } - public int Position { get; }//...MF - double IRegReader.PulsesPerLtr { get; set; } - - // Adding the missing static method to resolve the error. ...MF - public static void ResetStaticProperties() - { - // Add logic to reset static properties here, if applicable. - // If no static properties exist, this method can remain empty. - } - -#if ORACLE_DB - public int WMType_ID { get { return iperlHeadCfg.ProcParams.WMType_ID; } } /// Required by Oracle DB - public int WMType_Rev { get { return iperlHeadCfg.ProcParams.WMType_Rev; } } /// Required by Oracle DB -#endif - public float CalibTarget { get { return (ushort)genesisHeadCfg.ProcParams.CalibTarget; } } - public ushort FactorLimitLo { get { return (ushort)genesisHeadCfg.ProcParams.FactorLimitLo; } } - public ushort FactorLimitHi { get { return (ushort)genesisHeadCfg.ProcParams.FactorLimitHi; } } - - /// Properties set by the Begin and the End form - //todo rd implement - public string SerialNr; - - - public string EndState - { - get { return endState; } - set { endState = value; } - } - - private string endState; - - public string BeginState - { - get { return beginState; } - set { beginState = value; } - } - - private string beginState; - - public bool Disabled - { - get { return disabled; } - set { disabled = value; } - } - - private bool disabled; - - public bool CommFailed - { - get { return commFailed; } - set { commFailed = value; } - } - - private bool commFailed; - - public int ResultCode - { - get { return resultCode; } - } - - private int resultCode; - - - /// ConfigStruct of the water meter obtained or updated by iPerlCommunication - public ConfigStruct ConfigStruct - { - get { return configStruct; } - set { configStruct = value; } - } - - private ConfigStruct configStruct; - - /// CalibrationStruct of the water meter obtained or updated by iPerlCommunication - public CalibrationStruct CalibrationStruct - { - get { return calibrationStruct; } - set { calibrationStruct = value; } - } - - private CalibrationStruct calibrationStruct; - - public ushort OrigCalibFactor; - public ushort CalibFactor { get { return (CalibrationStruct != null) ? CalibrationStruct.Calibration : (ushort)0; } } - - public double Q2ErrWOCorrection; - public bool Q2CorrectionDone; - public double Q2Correction; - public int Q2CorrRFlow; - public int Q2CorrLFlow; - - public double Diff2Hz8Hz; - public bool Hz2CorrectionDone; - public int Hz2Correction; - - public string FWVersion { get { return (CalibrationStruct != null) ? CalibrationStruct.FWVersionStr() : string.Empty; } } - - - /// Result of the last test used to calculate Q2 correction factors, etc - public Results.Entities.MeterTestRslt LastTestResult2; - public Results.Entities.MeterTestRslt LastTestResult; - public double NominalTestFlowLph; /// in liter per hour - - - /// - /// Required for IRegisterReader interface - /// - public int WMPulses { get { return wmPulses; } } - public int WMRefPulses { get { return wmRefPulses; } } - public double WMVolume { get { return wmVolume; } } - public double BeginWMState { get { return beginWMState; } } - public double EndWMState { get { return endWMState; } } - public double WMTestTime { get { return wmTestTime; } } - - private double beginWMState; - private double endWMState; - private double wmVolume; - private int wmPulses; - private int wmRefPulses; - private double wmTestTime; - - - /// Name set by the test, to be used as a part of the opto-data log file name - public string TestName; - - /// Name set by the test, to be used as a part of the opto-data log file name - public string BenchName; - - /// - /// Volume of water from the opto telegram - /// - private Int64 lastVolumeRaw; /// Last read raw volume - private double volumeLtr; /// - private double volumeLtr0; - - - /// - /// Timestamp from the opto telegram - /// - private double timestampSec; - private double timestampSec0; - - public bool NoSamples { get { return (timestampSecEnd - timestampSecStart) < float.Epsilon; } } - public double TimestampSecStart { get { return timestampSecStart; } } - public double TimestampSecEnd { get { return timestampSecEnd; } } - - private double timestampSecStart; - private double timestampSecEnd; - - public GenesisHead() - { - } - - public GenesisHead(Generic.IComponentCfg cfg) - : base(cfg) - { - ClearData(); - - genesisHeadCfg = cfg as GenesisHeadCfg; - - log.Debug(this.ToString()); - } - - private GenesisMeter myGenesis = null; - - - - - - public GenesisMeter SetUp() - { - try - { - Log("Call SetUp()"); - if (myGenesis != null) - { - myGenesis.DisposeMeter(); - } - //add for gen - - myGenesis = new GenesisMeter(); - //myGenesis.SetupFromConfigFile(SlotNr); - //myGenesis.SetLogger(); - private, but called into basic constructor! - myGenesis.SetupGenesisMeter( - SlotNr, - new Xylem.Common.Hardware.WaterMeter.Genesis.GenesisConfig.PortConfig() - { - Type = "Xylem.Common.Hardware.Interfaces.Ports.SerialPorts.IrdaSerialPort", - PortName =$"COM{HeadComPortNr}" - }, - new Xylem.Common.Hardware.WaterMeter.Genesis.GenesisConfig.PortConfig() - { - Type = "", - PortName = $"COM{OptoComPortNr}" - } - ); - - Log("Add Meter to batch"); - GenesisHeadBatch.BatchHolder.Value.AddMeter(myGenesis); - Log("Log Raw Data"); - myGenesis.LogRawData(true); - return myGenesis; - } - catch (Exception e) - { - if (myGenesis != null) - { - Log(e.Message); - } - throw e; - } - - } - - /// - /// Clear data related to a specific water meter - /// - public void ClearData() - { - DetailedResults = new List(); - resultCode = 0; - - disabled = false; - commFailed = false; - endState = string.Empty; - beginState = string.Empty; - - configStruct = null; - calibrationStruct = null; - - LastTestResult = null; - NominalTestFlowLph = 0; - - OrigCalibFactor = 0; - Q2ErrWOCorrection = 0; - Q2CorrectionDone = false; - Q2CorrRFlow = 0; - } - - public override void Initialize() - { - ClearData(); - - if (DebugLevel == DebugMode.Normal) - { - - } - } - - public void RunDeviceBefore() - { - - - ////todo: RD- Login?? - //if (DebugLevel == DebugMode.Normal) - //{ - - - // if (myGenesis != null) - // { - // Log("TBF RunDeviceBefore"); - - // } - // else - // { - // //throw new Exception("No meter was bound!"); - // } - //} - //else if (DebugLevel == DebugMode.FailureDuringOperation) - //{ - //} - } - - public void RunDeviceAfter() { } - - public void StopDevice() - { - try - { - - if (DebugLevel == DebugMode.Normal && myGenesis != null) - { - myGenesis.DisposeMeter(); - - GenesisHeadBatch.BatchHolder.Value.RemoveMeter(myGenesis); - } - } - catch - { - } - } - - public void StopDevice2() { } - - /// - /// Events: Event.ReadRegisterDone, Event.Error - /// - /// ReadWaterMeter instance reference casted to IOperaton - public IOperation ReadRegisterOp() - { - return this; - } - - /// - /// Clear data/counters related to a specific tests - /// - public void Clear() - { - resultCode = 0; - - sampleNr = 0; - - volumeLtr = 0; - volumeLtr0 = 0; - timestampSec = 0; - timestampSec0 = 0; - - ReadPulses(); - } - - public void TestCompleted() - { - /// TODO: Implement - } - - private int sampleNr; /// This is to determine when the test start sample should be taken - - - private bool StoreStartPackage = false; - private bool StoreEndPackage = false; - private bool Enable = false; - public bool IsCalibration = false; - /// Start this operation - public void Start() - { - - - } - public void StartRead(string TestName, int batchNr, int repetitionNr) - { - StoreStartPackage = false; - StoreEndPackage = false; - //Start mesurement - if (DebugLevel == DebugMode.Normal) - { - if (myGenesis != null) - { - IsCalibration = false; - Log($"TBF Start Measurement {TestName}"); - myGenesis.CurrentActionText = $"Batch{batchNr}_Rep{repetitionNr}"; - - - if (TestName.ToLower().Contains("calib")) - { - IsCalibration = true; - //myGenesis.Login(); - myGenesis.StartCalibration(); - } - else if (TestName.ToLower().Contains("login")) - { - //myGenesis.Login(); - - myGenesis.InitMeasurement(); - } - else - { - DetailedResults = new List(); - - myGenesis.StartMeasurement(); - } - - StoreStartPackage = true; - } - } - } - - public void Log(string text) - { - log.Debug(text); - if (DebugLevel == DebugMode.Normal) - { - if (myGenesis != null) - { - myGenesis.WriteLog(text); - } - } - } - - - /// Run this operation - /// eventDone - public Event Run() - { - if (DebugLevel == DebugMode.Normal) - { - if (myGenesis != null) - { - try - { - //var results = myGenesis.GetIntermediateMeasurementResult(); - //readOutResults(results); - } - catch (Exception) - { - - - } - - } - } - - return Event.ReadRegisterDone; - } - public double RefVolume = 0.0; - - public void Stop() - { - //Stop(null); - if (DebugLevel == DebugMode.Normal && myGenesis != null) - { - if (IsCalibration) - { - myGenesis.StopCalibration(); - } - else - { - myGenesis.StopMeasurement(); - } - } - } - - /// Stop this operation - public void Stop(Double? testTimeS = null, double? refVol = null) - { - - if (DebugLevel == DebugMode.Normal && myGenesis != null) - { - Log($"TBF Stop Measurement {IsCalibration} {testTimeS} {refVol }"); - if (IsCalibration) - { - //myGenesis.StopCalibration(); - int retryCounter = 400; - while (myGenesis.GetCalibrationState() != MeasurementStates.IsCompleted) - { - if (retryCounter < 0) - { - break; - } - Thread.Sleep(10); - retryCounter = retryCounter - 1; - } - try - { - var results = myGenesis.GetMainMeasurementResult(refVol, testTimeS, false); - - readOutResults(results, testTimeS); - if (refVol.HasValue && refVol.Value != 0.0) - { - - - myGenesis.BuildAndCheckCalibFactorsAllChannels(refVol.Value / 1000, testTimeS, Q2ErrWOCorrection); - myGenesis.SetCalibFactorsAllChannels(false); - } - - } - catch (Exception ex) - { - MarkAsError(); - Log("Error while Stop Calib " + ex.Message); - if (ex.InnerException != null) - { - Log("Inner Error:" + ex.InnerException.Message); - } - - } - } - else - { - int retryCounter = 4000; - //myGenesis.StopMeasurement(); - try - { - while (myGenesis.GetMeasurementState() != MeasurementStates.IsCompleted) - { - if (retryCounter < 0) - { - break; - } - Thread.Sleep(10); - retryCounter = retryCounter - 1; - } - - try - { - if (refVol.HasValue && testTimeS.HasValue) - { - Log("GetMainMeasurementResult V" + refVol.ToString() + " and S" + testTimeS.Value); - } - else - { - Log("GetMainMeasurementResult empty"); - } - - DetailedResults = myGenesis.GetAllMeasurementResults(refVol, testTimeS); - foreach (var item in DetailedResults) - { - Log("Detail Measurement Channel =" + item.Channel + "; CorrectedDutVolumeCm= " + item.CorrectedDutVolumeCm + "; DeviationDutToRefPer= " + item.DeviationDutToRefPer); - } - - - readOutResults(DetailedResults.First(), testTimeS); - } - catch (Exception ex) - { - MarkAsError(); - Log("Error while Stop Measurement " + ex.Message); - } - } - catch (Exception ex) - { - MarkAsError(); - Log("Error while GetMeasurementState " + ex.Message); - } - - - - } - - - StoreEndPackage = true; - - } - } - - private void readOutResults(MeasurementResults results, double? testTimeS) - { - volumeLtr = results.CorrectedDutVolumeCm * 1000; - timestampSec = results.DutStopRecord.GetTimeS(); - if (testTimeS.HasValue) - { - wmTestTime = testTimeS.Value; - } - else - { - wmTestTime = results.DutTimeS; - } - - wmVolume = results.CorrectedDutVolumeCm * 1000; - Log("DutFlowRateCmPh" + results.DutFlowRateCmPh.ToString()); - Log("CorrectedDutVolumeCm=" + results.CorrectedDutVolumeCm.ToString()); - Log("DutVolumeCm=" + results.DutVolumeCm.ToString()); - ReadPulses(); - } - - private void MarkAsError() - { - volumeLtr = 0; - timestampSec = 0; - wmTestTime = 0; - wmVolume = 0; - ReadPulses(); - } - - private void ReadPulses() - { - beginWMState = volumeLtr0; - endWMState = volumeLtr; - wmPulses = (int)(wmVolume * (double)PulsesPerLtr + 0.5); - wmRefPulses = StateMachine.ControlBoardMain.RefPulses;//EtPulses(0);//...MF - } - - private bool optoSerialPortParsingEnabled; - - - - - - } -} diff --git a/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/GenesisHeadCfg.cs b/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/GenesisHeadCfg.cs deleted file mode 100644 index 1461c269a..000000000 --- a/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/GenesisHeadCfg.cs +++ /dev/null @@ -1,69 +0,0 @@ -/// -/// Copyright (c) 2015-2017 Sensus Metering Systems -/// -using System; -using System.Collections.Generic; -using System.IO; -using System.Net; -using System.Net.Sockets; -using System.Xml.Serialization; -using Config.Entities; -using TBF.Rig.Generic; -using TBF.Resources; -using Common; - -namespace TBF.Rig.TestMethods.GenesisCommunication.GenesisHead -{ - public class GenesisHeadCfg : ComponentCfgBase, Generic.IComponentCfg - { - public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(GenesisHeadCfg) })[0]; - public override XmlSerializer GetSerializer() { return Serializer; } - - - public IComponentCfgCtrl GetControl(IList cmpntEntities) { return new GenesisHeadCfgCtrl(); }//...MF - - /// - /// Serialized parameters - /// - public int SlotNr; /// Number written to QuidoRS to connct the watermeter to RfidComPort, 1 .. 10 - public int OptoComPortNr; - public int HeadComPortNr; - - /// Procedure parameters - [XmlIgnore] - public ProcParams ProcParams; - public override IParamsProvider GetRuntimeProcParamsProvider() { return ProcParams; } - public override IParamsProvider CreateProcParamsProvider() { return new ProcParams(true); } - - [XmlIgnore] - public MeterType MeterType { get { return (ProcParams != null) ? ProcParams.MeterType : MeterType.AutoDetect; } } - - - /// Private parameterless constructor invoked by all other (public) constructors - GenesisHeadCfg() - { - Name = "Genesis"; - ParentName = string.Empty; - SlotNr = 0; - OptoComPortNr = 0; - HeadComPortNr = 0; - ProcParams = new ProcParams(true); - } - - public GenesisHeadCfg(IComponentFactory factory) - : this() - { - this.Factory = factory; - } - - public string ToString(int i) - { - return string.Format("{0} SlotNr={1} OptoComPortNr={2} HeadComPortNr={3}", - Name, - SlotNr, - OptoComPortNr, - HeadComPortNr - ); - } - } -} diff --git a/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/GenesisHeadCfgCtrl.cs b/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/GenesisHeadCfgCtrl.cs deleted file mode 100644 index 4ea95d81c..000000000 --- a/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/GenesisHeadCfgCtrl.cs +++ /dev/null @@ -1,111 +0,0 @@ -/// -/// Copyright (c) 2015-2017 Sensus Metering Systems -/// -using System; -using System.Net; -using System.Net.Sockets; -using System.Windows.Forms; -using log4net; -using TBF.Rig.Generic; -using TBF.Resources; -using Config.Entities; -using Common; - -namespace TBF.Rig.TestMethods.GenesisCommunication.GenesisHead -{ - public partial class GenesisHeadCfgCtrl : UserControl, IComponentCfgCtrl - { - static readonly ILog log = LogManager.GetLogger(typeof(GenesisHeadCfgCtrl)); - - public bool ShowMore { get { return false; } } - - GenesisHeadCfg config; - public IComponentCfg Config - { - get { return config as IComponentCfg; } - set - { - config = value as GenesisHeadCfg; - Redraw(); - } - } - - public GenesisHeadCfgCtrl() - { - InitializeComponent(); - } - - private void WaterMeterCfgCtrl_Load(object sender, EventArgs e) - { - nameLabel.Text = Strings.Name; - classNameLabel.Text = config.Factory.ClassName; - slotNrTextBox.Text = config.SlotNr.ToString(); - optoSerialPortTextBox.Text = config.OptoComPortNr.ToString(); - headPortNrTextBox.Text = config.HeadComPortNr.ToString(); - Redraw(); - } - - public void Closing() - { - } - - void Redraw() - { - if (config == null) return; /// Control was not loaded, settings were not changed - nameTextBox.Text = config.Name; - optoSerialPortTextBox.Text = config.OptoComPortNr.ToString(); - headPortNrTextBox.Text = config.HeadComPortNr.ToString(); - } - - public void Unlock() - { - nameTextBox.Enabled = true; - slotNrTextBox.Enabled = true; - optoSerialPortTextBox.Enabled = true; - headPortNrTextBox.Enabled = true; - } - - public CfgUpdateFlags VerifyCfg(ref string message) - { - CfgUpdateFlags flags = CfgUpdateFlags.None; - - int dummy; - - if (!int.TryParse(slotNrTextBox.Text, out dummy) || dummy < 1 || dummy > 10) - { - flags |= CfgUpdateFlags.Error; - message += Environment.NewLine + string.Format(Strings.Invalid_0, muxBoardNrLabel.Text); - } - - if (!int.TryParse(optoSerialPortTextBox.Text, out dummy) || dummy < 1 || dummy > 999) - { - flags |= CfgUpdateFlags.Error; - message += Environment.NewLine + "'Opto serial port nr.' is not valid"; - } - - if (!int.TryParse(headPortNrTextBox.Text, out dummy) || dummy < 0 || dummy > 999) - { - flags |= CfgUpdateFlags.Error; - message += Environment.NewLine + "'Head communication serial port nr.' is not valid"; - } - - return flags; - } - - public CfgUpdateFlags UpdateCfg() - { - CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd; - - if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed - - config.Name = nameTextBox.Text; - - config.SlotNr = int.Parse(slotNrTextBox.Text); - - config.OptoComPortNr = int.Parse(optoSerialPortTextBox.Text); - config.HeadComPortNr = int.Parse(headPortNrTextBox.Text); - - return flags; - } - } -} diff --git a/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/GenesisHeadCfgCtrl.designer.cs b/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/GenesisHeadCfgCtrl.designer.cs deleted file mode 100644 index 78eae6c23..000000000 --- a/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/GenesisHeadCfgCtrl.designer.cs +++ /dev/null @@ -1,197 +0,0 @@ -/// -/// Copyright (c) 2015-2017 Sensus Metering Systems -/// -namespace TBF.Rig.TestMethods.GenesisCommunication.GenesisHead -{ - partial class GenesisHeadCfgCtrl : System.Windows.Forms.UserControl - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.nameTextBox = new System.Windows.Forms.TextBox(); - this.nameLabel = new System.Windows.Forms.Label(); - this.classNameLabel = new System.Windows.Forms.Label(); - this.slotNrTextBox = new System.Windows.Forms.TextBox(); - this.muxBoardNrLabel = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.headPortNrTextBox = new System.Windows.Forms.TextBox(); - this.rfidSerialPortNrLabel = new System.Windows.Forms.Label(); - this.optoDataGroupBox = new System.Windows.Forms.GroupBox(); - this.optoSerialPortLabel = new System.Windows.Forms.Label(); - this.optoSerialPortTextBox = new System.Windows.Forms.TextBox(); - this.groupBox1.SuspendLayout(); - this.optoDataGroupBox.SuspendLayout(); - this.SuspendLayout(); - // - // nameTextBox - // - this.nameTextBox.Enabled = false; - this.nameTextBox.Location = new System.Drawing.Point(135, 40); - this.nameTextBox.Name = "nameTextBox"; - this.nameTextBox.Size = new System.Drawing.Size(121, 20); - this.nameTextBox.TabIndex = 2; - // - // nameLabel - // - this.nameLabel.AutoSize = true; - this.nameLabel.Location = new System.Drawing.Point(25, 43); - this.nameLabel.Name = "nameLabel"; - this.nameLabel.Size = new System.Drawing.Size(35, 13); - this.nameLabel.TabIndex = 1; - this.nameLabel.Text = "Name"; - // - // classNameLabel - // - this.classNameLabel.AutoSize = true; - this.classNameLabel.Location = new System.Drawing.Point(132, 16); - this.classNameLabel.Name = "classNameLabel"; - this.classNameLabel.Size = new System.Drawing.Size(60, 13); - this.classNameLabel.TabIndex = 0; - this.classNameLabel.Text = "ClassName"; - // - // slotNrTextBox - // - this.slotNrTextBox.Enabled = false; - this.slotNrTextBox.Location = new System.Drawing.Point(135, 63); - this.slotNrTextBox.Name = "slotNrTextBox"; - this.slotNrTextBox.Size = new System.Drawing.Size(34, 20); - this.slotNrTextBox.TabIndex = 9; - // - // muxBoardNrLabel - // - this.muxBoardNrLabel.AutoSize = true; - this.muxBoardNrLabel.Location = new System.Drawing.Point(25, 66); - this.muxBoardNrLabel.Name = "muxBoardNrLabel"; - this.muxBoardNrLabel.Size = new System.Drawing.Size(37, 13); - this.muxBoardNrLabel.TabIndex = 8; - this.muxBoardNrLabel.Text = "Slot nr"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(176, 66); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(37, 13); - this.label3.TabIndex = 13; - this.label3.Text = "1 .. 10"; - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.headPortNrTextBox); - this.groupBox1.Controls.Add(this.rfidSerialPortNrLabel); - this.groupBox1.Location = new System.Drawing.Point(9, 147); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(377, 59); - this.groupBox1.TabIndex = 25; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "Head communication"; - // - // headPortNrTextBox - // - this.headPortNrTextBox.Enabled = false; - this.headPortNrTextBox.Location = new System.Drawing.Point(123, 19); - this.headPortNrTextBox.Name = "headPortNrTextBox"; - this.headPortNrTextBox.Size = new System.Drawing.Size(37, 20); - this.headPortNrTextBox.TabIndex = 7; - // - // rfidSerialPortNrLabel - // - this.rfidSerialPortNrLabel.AutoSize = true; - this.rfidSerialPortNrLabel.Location = new System.Drawing.Point(16, 26); - this.rfidSerialPortNrLabel.Name = "rfidSerialPortNrLabel"; - this.rfidSerialPortNrLabel.Size = new System.Drawing.Size(72, 13); - this.rfidSerialPortNrLabel.TabIndex = 6; - this.rfidSerialPortNrLabel.Text = "Serial port nr.:"; - // - // optoDataGroupBox - // - this.optoDataGroupBox.Controls.Add(this.optoSerialPortLabel); - this.optoDataGroupBox.Controls.Add(this.optoSerialPortTextBox); - this.optoDataGroupBox.Location = new System.Drawing.Point(9, 87); - this.optoDataGroupBox.Name = "optoDataGroupBox"; - this.optoDataGroupBox.Size = new System.Drawing.Size(377, 55); - this.optoDataGroupBox.TabIndex = 24; - this.optoDataGroupBox.TabStop = false; - this.optoDataGroupBox.Text = "Opto-data"; - // - // optoSerialPortLabel - // - this.optoSerialPortLabel.AutoSize = true; - this.optoSerialPortLabel.Location = new System.Drawing.Point(16, 22); - this.optoSerialPortLabel.Name = "optoSerialPortLabel"; - this.optoSerialPortLabel.Size = new System.Drawing.Size(72, 13); - this.optoSerialPortLabel.TabIndex = 6; - this.optoSerialPortLabel.Text = "Serial port nr.:"; - // - // optoSerialPortTextBox - // - this.optoSerialPortTextBox.Enabled = false; - this.optoSerialPortTextBox.Location = new System.Drawing.Point(126, 15); - this.optoSerialPortTextBox.Name = "optoSerialPortTextBox"; - this.optoSerialPortTextBox.Size = new System.Drawing.Size(34, 20); - this.optoSerialPortTextBox.TabIndex = 7; - // - // GenesisHeadCfgCtrl - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.groupBox1); - this.Controls.Add(this.optoDataGroupBox); - this.Controls.Add(this.label3); - this.Controls.Add(this.slotNrTextBox); - this.Controls.Add(this.muxBoardNrLabel); - this.Controls.Add(this.nameTextBox); - this.Controls.Add(this.nameLabel); - this.Controls.Add(this.classNameLabel); - this.Name = "GenesisHeadCfgCtrl"; - this.Size = new System.Drawing.Size(396, 225); - this.Load += new System.EventHandler(this.WaterMeterCfgCtrl_Load); - this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); - this.optoDataGroupBox.ResumeLayout(false); - this.optoDataGroupBox.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - } - - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.TextBox headPortNrTextBox; - private System.Windows.Forms.Label rfidSerialPortNrLabel; - private System.Windows.Forms.GroupBox optoDataGroupBox; - private System.Windows.Forms.Label optoSerialPortLabel; - private System.Windows.Forms.TextBox optoSerialPortTextBox; - - #endregion - - private System.Windows.Forms.TextBox nameTextBox; - private System.Windows.Forms.Label nameLabel; - private System.Windows.Forms.Label classNameLabel; - private System.Windows.Forms.TextBox slotNrTextBox; - private System.Windows.Forms.Label muxBoardNrLabel; - private System.Windows.Forms.Label label3; - } -} diff --git a/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/GenesisHeadCfgCtrl.resx b/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/GenesisHeadCfgCtrl.resx deleted file mode 100644 index 1af7de150..000000000 --- a/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/GenesisHeadCfgCtrl.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/OptoReceivedEventArgs.cs b/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/OptoReceivedEventArgs.cs deleted file mode 100644 index 8cd2ef105..000000000 --- a/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/OptoReceivedEventArgs.cs +++ /dev/null @@ -1,20 +0,0 @@ -/// -/// Copyright (c) 2015-2017 Sensus Metering Systems -/// -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace TBF.Rig.TestMethods.GenesisCommunication.GenesisHead -{ - public class OptoReceivedEventArgs : EventArgs - { - public string Data; - - public OptoReceivedEventArgs(string data) - { - this.Data = data; - } - } -} diff --git a/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/OptoTelegramRaw.cs b/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/OptoTelegramRaw.cs deleted file mode 100644 index 1ad44d775..000000000 --- a/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/OptoTelegramRaw.cs +++ /dev/null @@ -1,295 +0,0 @@ -/// -/// Copyright (c) 2015-2017 Sensus Metering Systems -/// -using System; -using System.Globalization; -namespace TBF.Rig.TestMethods.GenesisCommunication.GenesisHead -{ - public class OptoTelegramRaw - { - public static readonly int Length = 42; - private static CultureInfo culture; - - - /// - /// Strobed value - /// - public static decimal TestStartTimestampDec; - - /// - /// Stored values - /// - public OptoTelegramFlags Flags; - - public DateTime DateTime; /// From PC - public float RefFlow; /// [m3/h] - public int Counter; - - public UInt32 EmfRaw; /// From iPerl opto data - public Int16 MagneticFieldRaw; - public Int16 FlowRaw; - public UInt32 VolumeRaw; - public Int64 VolumeRawExt; - public Int16 Impedance; - public UInt32 Timestamp; - public Int64 TimestampExt; - public byte CheckSum; - - /// - /// Calculated values - /// - public double EMF() - { - Int32 signedEmf = (EmfRaw > 0x7FFFFF) ? ((int)EmfRaw - 0x1000000) : (int)EmfRaw; - return 0.000000333 * (double)signedEmf; - } - public double MagneticField() { return (double)MagneticFieldRaw; } - public double Flow(double scalingFactor) { return 0.225 * scalingFactor * (double)FlowRaw; } - public double Volume(double scalingFactor) { return 0.0000625 * scalingFactor * (double)VolumeRawExt; } - public Int32 FlipTime() { return Impedance; } - public decimal TimestampDec() { return (decimal)TimestampExt / (decimal)8192; } - public double VolumeDelta(double scalingFactor, OptoTelegramRaw previous) { return (previous == null) ? 0 : Volume(scalingFactor) - previous.Volume(scalingFactor); } - public decimal TimeDelta() { return TimestampDec() - TestStartTimestampDec; } - public string Label() - { - if (Flags == OptoTelegramFlags.OK_TestStart) return "#### start test ####"; - else if (Flags == OptoTelegramFlags.OK_TestEnd) return "#### end of test ####"; - else return string.Empty; - } - - - static OptoTelegramRaw() - { - culture = CultureInfo.CreateSpecificCulture("DE"); /// This is to use comma as decimal number separator - } - - public OptoTelegramRaw() - { - } - - /// - /// Parses optical telegram and returns OptoTelegramRaw object - /// - /// - /// Create a configuration structure from a complete byte array - /// - /// Telegram description: - /// - /// AAAAAA[tab]BBBB[tab]CCCC[tab]DDDDDD[tab]EEEE[tab]FFFFFFFF[tab]GG[cr][lf] (42 bytes) - /// - /// Data Comment Type Calculate to decimal - /// ---------------------------------------------------------------- - /// AAAAAA EMF Int24 Value * 0.000000333 - /// BBBB Magnetic field Int16 Value - /// CCCC Flow Int16 Value * 0.225 * Scalig factor - /// DDDDDD Volume Int24 Value / 16000 * Scaling factor - /// EEEE Impedance Int16 Value - /// FFFFFFFF Timestamp Uint32 Value / 8192 - /// GG Checksum Byte - /// ---------------------------------------------------------------- - /// - /// Example: - /// FFFFFE 51EA 0000 65324E 0087 F6319DFF 86 - /// FFDD3A 51F9 0000 65324E 0088 F631A60B 45 - /// ... - /// - /// A complete byte array data - /// true = telegram OK, false = telegram NOK - public bool UpdateFromString(string telegram, int counter, ref Int64 volumeRawExtLast, ref Int64 timestampExtLast) - { - DateTime = DateTime.Now; - Counter = counter; - RefFlow = (float)Sequences.ProcessData.RefFlow.Val; - - if ((telegram == null) || (telegram.Length < Length) || - (telegram[6] != '\t') || (telegram[11] != '\t') || (telegram[16] != '\t') || - (telegram[23] != '\t') || (telegram[28] != '\t') || (telegram[37] != '\t') || - (telegram[40] != '\r') || (telegram[41] != '\n')) - { - Flags = OptoTelegramFlags.InvalidTelegram; - return false; - } - - bool f1 = UInt32.TryParse(telegram.Substring(0, 6), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out EmfRaw); - bool f2 = Int16.TryParse(telegram.Substring(7, 4), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out MagneticFieldRaw); - bool f3 = Int16.TryParse(telegram.Substring(12, 4), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out FlowRaw); - bool f4 = UInt32.TryParse(telegram.Substring(17, 6), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out VolumeRaw); - bool f5 = Int16.TryParse(telegram.Substring(24, 4), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out Impedance); - bool f6 = UInt32.TryParse(telegram.Substring(29, 8), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out Timestamp); - bool f7 = byte.TryParse(telegram.Substring(38, 2), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out CheckSum); - - bool allOk = f1 && f2 && f3 && f4 && f5 && f6 && f7; - Flags = allOk ? OptoTelegramFlags.OK : OptoTelegramFlags.InvalidTelegram; - - /// - /// Cope with 'VolumeRaw' overflow - /// - Int64 uncorrected = (Int64)(((UInt64)volumeRawExtLast & 0xFFFFFFFFFF000000UL) | VolumeRaw); - if (Math.Abs(uncorrected - volumeRawExtLast) <= 0x800000L) - { - VolumeRawExt = volumeRawExtLast = uncorrected; - } - else if (Math.Abs(uncorrected + 0x1000000L - volumeRawExtLast) <= 0x800000L) - { - VolumeRawExt = volumeRawExtLast = uncorrected + 0x1000000L; - } - else if (Math.Abs(uncorrected - 0x1000000L - volumeRawExtLast) <= 0x800000L) - { - VolumeRawExt = volumeRawExtLast = uncorrected - 0x1000000L; - } - else - { - VolumeRawExt = volumeRawExtLast = uncorrected; - } - - /// - /// Cope with 'Timestamp' overflow - /// - uncorrected = (Int64)(((UInt64)timestampExtLast & 0xFFFFFFFF00000000UL) | Timestamp); - if (Math.Abs(uncorrected - timestampExtLast) <= 0x80000000L) - { - TimestampExt = timestampExtLast = uncorrected; - } - else if (Math.Abs(uncorrected + 0x100000000L - timestampExtLast) <= 0x80000000L) - { - TimestampExt = timestampExtLast = uncorrected + 0x100000000L; - } - else if (Math.Abs(uncorrected - 0x100000000L - timestampExtLast) <= 0x80000000L) - { - TimestampExt = timestampExtLast = uncorrected - 0x100000000L; - } - else - { - TimestampExt = timestampExtLast = uncorrected; - } - - return allOk; - } - - /// - /// Alternative to UpdateFromString(...) when data are flushed - /// - public bool UpdateFromStringDummy(string telegram) - { - DateTime = DateTime.Now; - RefFlow = (float)Sequences.ProcessData.RefFlow.Val; - - if ((telegram == null) || (telegram.Length < Length) || - (telegram[6] != '\t') || (telegram[11] != '\t') || (telegram[16] != '\t') || - (telegram[23] != '\t') || (telegram[28] != '\t') || (telegram[37] != '\t') || - (telegram[40] != '\r') || (telegram[41] != '\n')) - { - Flags = OptoTelegramFlags.InvalidTelegram; - return false; - } - - //bool f1 = UInt32.TryParse(telegram.Substring(0, 6), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out EmfRaw); - //bool f2 = Int16.TryParse(telegram.Substring(7, 4), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out MagneticFieldRaw); - //bool f3 = Int16.TryParse(telegram.Substring(12, 4), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out FlowRaw); - //bool f4 = UInt32.TryParse(telegram.Substring(17, 6), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out VolumeRaw); - //bool f5 = Int16.TryParse(telegram.Substring(24, 4), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out Impedance); - //bool f6 = UInt32.TryParse(telegram.Substring(29, 8), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out Timestamp); - //bool f7 = byte.TryParse(telegram.Substring(38, 2), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out CheckSum); - //return f1 && f2 && f3 && f4 && f5 && f6 && f7; - - return true; - } - - - public void SetFlags(OptoTelegramFlags flags) - { - this.Flags = flags; - } - - - public string ToString(double scalingFactor, OptoTelegramRaw previous) - { - if (Flags == OptoTelegramFlags.SyncError) - { - return "Sychronization error"; - } - else if (Flags == OptoTelegramFlags.InvalidTelegram) - { - return "Invalid telegram"; - } - else /// if (flags == OptoTelegramFlags.OK / OptoTelegramFlags.OK_TestStart / OptoTelegramFlags.OK_TestEnd) - { - return string.Format("{0}:{1}:{2}.{3}\t{4} :\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}\t{11}\t{12}\t{13}\t{14}\t{15}\t{16}\t{17}\t{18}\t{19}\t{20}\t{21}\t{22}", - DateTime.Hour.ToString("D2"), - DateTime.Minute.ToString("D2"), - DateTime.Second.ToString("D2"), - DateTime.Millisecond.ToString("D4"), - Counter, - EmfRaw.ToString("X6"), - MagneticFieldRaw.ToString("X4"), - FlowRaw.ToString("X4"), - VolumeRaw.ToString("X6"), - Impedance.ToString("X4"), - Timestamp.ToString("X8"), - CheckSum.ToString("X2"), - EMF().ToString("F4", culture), - MagneticField().ToString("F0", culture), - Flow(scalingFactor).ToString("F2", culture), - Volume(scalingFactor).ToString("F4", culture), - FlipTime().ToString("F0", culture), - TimestampDec().ToString("F4", culture), - (RefFlow * 1000).ToString("F2", culture), - VolumeDelta(scalingFactor, previous).ToString("F4", culture), - TimeDelta().ToString("F3", culture), - scalingFactor.ToString("F1", culture), - Label()); - } - } - - /// - /// Filter RefFlow data in an array of OptoTelegramRaw objects by a FIR filter: - /// - /// kSize = 5, kSize2 = 2 - /// - /// i k - /// --------------------------------------------------------------------------- - /// 0 -5 filtered[0] = data[0] - /// 1 -4 filtered[1] = data[1] - /// 2 -3 filtered[2] = data[0]*k[0] + ... + data[4]*k[4] - /// 3 -2 filtered[3] = data[1]*k[0] + ... + data[5]*k[4] - /// 4 -1 filtered[4] = data[2]*k[0] + ... + data[6]*k[4] - /// 5 0 data[0] = filtered[0], filtered[0] = data[3]*k[0] + ... + data[7]*k[4] - /// 6 1 data[1] = filtered[1], filtered[1] = data[4]*k[0] + ... + data[8]*k[4] - /// 7 ... - /// - /// array of OptoTelegramRaw objects - /// number of objects to process - public static void FIRFilterFlow(OptoTelegramRaw[] optoData, int optoDataCount) - { - float[] kernel = new float[] { 0.1f, 0.2f, 0.4f, 0.2f, 0.1f }; - int kSize = kernel.Length; - int kSize2 = kernel.Length / 2; - - float[] filtered = new float[kSize]; - - for (int i = 0; i < optoDataCount; i++) - { - int k = i - kSize; - if (k >= 0) optoData[k].RefFlow = filtered[i % kSize]; - - if (i < kSize2 || i >= optoDataCount - kSize2) - { - filtered[i % kSize] = optoData[i].RefFlow; - } - else - { - float weoightedSum = 0; - for (int j = -kSize2; j <= kSize2; j++) - weoightedSum += optoData[i + j].RefFlow * kernel[j + kSize2]; - - filtered[i % kSize] = weoightedSum; - } - } - - for (int k = optoDataCount - kSize; k < optoDataCount; k++) - { - if (k >= 0) optoData[k].RefFlow = filtered[k % kSize]; - } - } - } -} diff --git a/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/ProcParams.cs b/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/ProcParams.cs deleted file mode 100644 index aba7c4fc7..000000000 --- a/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/ProcParams.cs +++ /dev/null @@ -1,186 +0,0 @@ -/// -/// Copyright (c) 2015-2017 Sensus Metering Systems -/// -using System; -using System.IO; -using System.Text; -using System.Xml.Serialization; -using Config.Entities; -using TBF.Rig.Generic; -using TBF.Resources; -using Common; - -namespace TBF.Rig.TestMethods.GenesisCommunication.GenesisHead -{ - public partial class ProcParams : ProcedureParamsBase, IParamsProvider, IProcedureParams - { - public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ProcParams) })[0]; - public override XmlSerializer GetSerializer() { return Serializer; } - - public MeterType MeterType; - public float CalibTarget; /// Target error after calibration in [%] - public int FactorLimitLo; /// Lower limit for the calibration factor - public int FactorLimitHi; /// Upper limit for the calibration factor -#if ORACLE_DB - public int WMType_ID; /// Required for Oracle DB: ID_WZTyp in table VT_PRUEFPUNKT_SOLL_SD - public int WMType_Rev; /// Required for Oracle DB: Rev_WZTyp in table VT_PRUEFPUNKT_SOLL_SD -#endif - - - public override void InitializeAll() - { - MeterType = MeterType.AutoDetect; - CalibTarget = 0; - FactorLimitLo = 1000; - FactorLimitHi = 8000; -#if ORACLE_DB - WMType_ID = 2; /// Value for iPerl DN15 - WMType_Rev = 1; /// Value for iPerl DN15 -#endif - } - - string[] paramNames = new string[] - { - "iPerl type", - "Calib. target [%]", - "Calib. factor Lo", - "Calib. factor Hi", -#if ORACLE_DB - "WMType ID", - "WMType Rev.", -#endif - }; - public override string ParamName(int i) { return paramNames[i]; } - public override int ParamsCount() { return paramNames.Length; } - - public override string ToString(int i) - { - switch (i) - { - case 0: return MeterType.ToString(); - case 1: return CalibTarget.ToString(); - case 2: return FactorLimitLo.ToString(); - case 3: return FactorLimitHi.ToString(); -#if ORACLE_DB - case 4: return WMType_ID.ToString(); - case 5: return WMType_Rev.ToString(); -#endif - default: return string.Empty; - } - } - - public CfgUpdateFlags UpdateParam(int i, string strValue) - { - switch (i) - { - case 0: - for (MeterType mt = 0; mt < MeterType.Count; mt++) - { - if (mt.ToString().Equals(strValue)) { MeterType = mt; return CfgUpdateFlags.None; } - } - break; - case 1: CalibTarget = Utils.ParseSFloat(strValue); return CfgUpdateFlags.None; - case 2: FactorLimitLo = int.Parse(strValue); return CfgUpdateFlags.None; - case 3: FactorLimitHi = int.Parse(strValue); return CfgUpdateFlags.None; -#if ORACLE_DB - case 4: WMType_ID = int.Parse(strValue); return CfgUpdateFlags.None; - case 5: WMType_Rev = int.Parse(strValue); return CfgUpdateFlags.None; -#endif - default: return CfgUpdateFlags.None; - } - - return CfgUpdateFlags.None; - } - - public bool ValidateParam(int i, string strValue, out string message) - { - message = string.Empty; - - int iDummy; - float fDummy; - - switch (i) - { - case 0: - for (MeterType mt = 0; mt < MeterType.Count; mt++) if (mt.ToString().Equals(strValue)) return true; - break; - case 1: - if (Utils.TryParseSFloat(strValue, out fDummy) && fDummy >= -10.0f && fDummy <= 10.0f) return true; - break; - case 2: - case 3: - if (int.TryParse(strValue, out iDummy) && iDummy >= 1000 && iDummy <= 8000) return true; - break; - -#if ORACLE_DB - case 4: /// WMType_ID - case 5: /// WMType_Rev - if (int.TryParse(strValue, out iDummy)) return true; - break; -#endif - default: - message = "Invalid index"; - return false; - } - - message = ParamName(i) + " is invalid"; - return false; - } - - void CopyContentTo(ProcParams prms) - { - prms.MeterType = this.MeterType; - prms.CalibTarget = this.CalibTarget; - prms.FactorLimitLo = this.FactorLimitLo; - prms.FactorLimitHi = this.FactorLimitHi; -#if ORACLE_DB - prms.WMType_ID = this.WMType_ID; - prms.WMType_Rev = this.WMType_Rev; -#endif - } - - public IParamsProvider Clone() - { - ProcParams pars = new ProcParams(); - CopyContentTo(pars); - return pars; - } - - public virtual bool UpdateFromDbEntity(ComponentProcedure dbEntity) - { - if (dbEntity == null) return false; - try - { - ProcParams tmp = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as ProcParams; - - procedureParamsEntity = dbEntity; - componentName = dbEntity.CmpntName; - procedure = dbEntity.Procedure; - - if (tmp != null) tmp.CopyContentTo(this); - return true; - } - catch - { - } - return false; - } - - - public ProcParams() - { - } - - public ProcParams(bool initialize) - { - if (initialize) InitializeAll(); - } - - public ProcParams(ComponentProcedure procParamsEntity, string componentName, Procedure procedure) - { - this.procedureParamsEntity = procParamsEntity; - this.componentName = componentName; - this.procedure = procedure; - } - } -} diff --git a/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/StatusStruct.cs b/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/StatusStruct.cs deleted file mode 100644 index c02715a81..000000000 --- a/TBF/Rig/TestMethods/GenesisCommunication/GenesisHead/StatusStruct.cs +++ /dev/null @@ -1,160 +0,0 @@ -/// -/// Copyright (c) 2015-2017 Sensus Metering Systems -/// -using System; - -namespace TBF.Rig.TestMethods.GenesisCommunication.GenesisHead -{ - public class StatusStruct - { - public static readonly int Length = 48; - - public Byte Version; - public FlowState FlowState; - public UInt32 BillingVolume; - public UInt32 ForwardVolume; - public UInt32 ReverseVolume; - public UInt32 SecondsActive; - public UInt32 SecondsIdle; - public UInt32 SecondsUsed; - public UInt32 UTC; - public Int32 ScaledAvgFlowRate; - public UInt16 PeakFlowRate; - public UInt16 AlarmState; - public byte RebootCount; - public byte[] AlarmCount; - public UInt16 FlipTime; - - - public StatusStruct() - { - AlarmCount = new byte[7]; - } - - public byte[] ToByteArray() - { - byte[] result = new byte[Length]; - - result[0] = Version; - result[1] = (byte)FlowState; - - result[2] = (byte)(BillingVolume & 0x000000FF); - result[3] = (byte)((BillingVolume >> 8) & 0x000000FF); - result[4] = (byte)((BillingVolume >> 16) & 0x000000FF); - result[5] = (byte)((BillingVolume >> 24) & 0x000000FF); - - result[6] = (byte)(ForwardVolume & 0x000000FF); - result[7] = (byte)((ForwardVolume >> 8) & 0x000000FF); - result[8] = (byte)((ForwardVolume >> 16) & 0x000000FF); - result[9] = (byte)((ForwardVolume >> 24) & 0x000000FF); - - result[10] = (byte)(ReverseVolume & 0x000000FF); - result[11] = (byte)((ReverseVolume >> 8) & 0x000000FF); - result[12] = (byte)((ReverseVolume >> 16) & 0x000000FF); - result[13] = (byte)((ReverseVolume >> 24) & 0x000000FF); - - result[14] = (byte)(SecondsActive & 0x000000FF); - result[15] = (byte)((SecondsActive >> 8) & 0x000000FF); - result[16] = (byte)((SecondsActive >> 16) & 0x000000FF); - result[17] = (byte)((SecondsActive >> 24) & 0x000000FF); - - result[18] = (byte)(SecondsIdle & 0x000000FF); - result[19] = (byte)((SecondsIdle >> 8) & 0x000000FF); - result[20] = (byte)((SecondsIdle >> 16) & 0x000000FF); - result[21] = (byte)((SecondsIdle >> 24) & 0x000000FF); - - result[22] = (byte)(SecondsUsed & 0x000000FF); - result[23] = (byte)((SecondsUsed >> 8) & 0x000000FF); - result[24] = (byte)((SecondsUsed >> 16) & 0x000000FF); - result[25] = (byte)((SecondsUsed >> 24) & 0x000000FF); - - result[26] = (byte)(UTC & 0x000000FF); - result[27] = (byte)((UTC >> 8) & 0x000000FF); - result[28] = (byte)((UTC >> 16) & 0x000000FF); - result[29] = (byte)((UTC >> 24) & 0x000000FF); - - result[30] = (byte)(ScaledAvgFlowRate & 0x000000FF); - result[31] = (byte)((ScaledAvgFlowRate >> 8) & 0x000000FF); - result[32] = (byte)((ScaledAvgFlowRate >> 16) & 0x000000FF); - result[33] = (byte)((ScaledAvgFlowRate >> 24) & 0x000000FF); /// TODO: test with negative value - - result[34] = (byte)(PeakFlowRate & 0x00FF); - result[35] = (byte)((PeakFlowRate >> 8) & 0x00FF); - - result[36] = (byte)(AlarmState & 0x00FF); - result[37] = (byte)((AlarmState >> 8) & 0x00FF); - - result[38] = RebootCount; - - result[39] = AlarmCount[0]; - result[40] = AlarmCount[1]; - result[41] = AlarmCount[2]; - result[42] = AlarmCount[3]; - result[43] = AlarmCount[4]; - result[44] = AlarmCount[5]; - result[45] = AlarmCount[6]; - - result[46] = (byte)(FlipTime & 0x00FF); - result[47] = (byte)((FlipTime >> 8) & 0x00FF); - - return result; - } - - public static StatusStruct FromByteArray(byte[] data) - { - if (data.Length != Length) return null; - - StatusStruct result = new StatusStruct(); - - result.Version = data[0]; - result.FlowState = (FlowState)data[1]; - result.BillingVolume = (((UInt32)data[5] * 256 + data[4]) * 256 + data[3]) * 256 + data[2]; - result.ForwardVolume = (((UInt32)data[9] * 256 + data[8]) * 256 + data[7]) * 256 + data[6]; - result.ReverseVolume = (((UInt32)data[13] * 256 + data[12]) * 256 + data[11]) * 256 + data[10]; - result.SecondsActive = (((UInt32)data[17] * 256 + data[16]) * 256 + data[15]) * 256 + data[14]; - result.SecondsIdle = (((UInt32)data[21] * 256 + data[20]) * 256 + data[19]) * 256 + data[18]; - result.SecondsUsed = (((UInt32)data[25] * 256 + data[24]) * 256 + data[23]) * 256 + data[22]; - result.UTC = (((UInt32)data[29] * 256 + data[28]) * 256 + data[27]) * 256 + data[26]; - result.ScaledAvgFlowRate = (((Int32)data[33] * 256 + data[32]) * 256 + data[31]) * 256 + data[30]; /// TODO: test with negative value - result.PeakFlowRate = (UInt16)(data[34] + 256 * data[35]); - result.AlarmState = (UInt16)(data[36] + 256 * data[37]); - result.RebootCount = data[38]; - result.AlarmCount[0] = data[39]; - result.AlarmCount[1] = data[40]; - result.AlarmCount[2] = data[41]; - result.AlarmCount[3] = data[42]; - result.AlarmCount[4] = data[43]; - result.AlarmCount[5] = data[44]; - result.AlarmCount[6] = data[45]; - result.FlipTime = (UInt16)(data[46] * 256 + data[47]); - - return result; - } - - public override string ToString() - { - return string.Format("Status: V{0} Flow={1} BillVol={2} ForwVol={3} RevVol={4} SecActive={5}s SecIdle={6}s SecUsed={7}s UTC={8} AvgFlowRate={9} PeekFlowRate={10} AlarmState={11} RebootCount={12} A0={13} A1={14} A2={15} A3={16} A4={17} A5={18} A6={19} FlipTime={20}", - Version, - FlowState, - BillingVolume, - ForwardVolume, - ReverseVolume, - SecondsActive, - SecondsIdle, - SecondsUsed, - UTC, - ScaledAvgFlowRate, - PeakFlowRate, - AlarmState, - RebootCount, - AlarmCount[0], - AlarmCount[1], - AlarmCount[2], - AlarmCount[3], - AlarmCount[4], - AlarmCount[5], - AlarmCount[6], - FlipTime); - } - } -} diff --git a/TBF/TBF.csproj b/TBF/TBF.csproj index 5e5042d97..db6417c2e 100644 --- a/TBF/TBF.csproj +++ b/TBF/TBF.csproj @@ -10,7 +10,7 @@ Properties TBF TBF - v4.7.2 + v4.8 2.0 @@ -130,6 +130,9 @@ ..\packages\NHibernate.4.0.4.4000\lib\net40\NHibernate.dll + + ..\packages\NLog.5.2.2\lib\net46\NLog.dll + False ..\packages\Oracle\Oracle.DataAccess.dll @@ -171,22 +174,13 @@ - ..\packages\Common\Xylem.Common.CommonCore.dll - - - ..\packages\Common\Xylem.Common.Hardware.WaterMeter.Genesis.GenesisConfig.dll - - - ..\packages\Common\Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.dll - - - ..\packages\Common\Xylem.Common.Hardware.WaterMeter.WaterMeterCore.dll + ..\GenesisCordonelInterface\bin\Debug\Xylem.Common.CommonCore.dll - ..\packages\Common\Xylem.Common.Hardware.WaterMeter.WaterMeterRegisters.dll + ..\GenesisCordonelInterface\bin\Debug\Xylem.Common.Hardware.WaterMeter.WaterMeterRegisters.dll - ..\packages\Common\Xylem.Common.Metrology.Measurements.dll + ..\GenesisCordonelInterface\bin\Debug\Xylem.Common.Metrology.Measurements.dll @@ -1787,20 +1781,6 @@ TestMethodCfgCtrl.cs - - - - - - - - UserControl - - - - - - @@ -3759,7 +3739,6 @@ TestMethodCfgCtrl.cs - TestMethodCfgCtrl.cs @@ -4361,6 +4340,10 @@ {439D0878-C76E-452B-B17D-209A89E91D36} Dirichlet.Numerics + + {04201e95-90a0-4b73-a72f-379739b2a3ae} + GenesisCore + {8B10D15A-39DE-4B56-8DD1-710C1EB3A697} GemCard diff --git a/TBF/app.config b/TBF/app.config index 9b6cf398b..82be05cd6 100644 --- a/TBF/app.config +++ b/TBF/app.config @@ -35,6 +35,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TBF/packages.config b/TBF/packages.config index f347225ab..da6e33c81 100644 --- a/TBF/packages.config +++ b/TBF/packages.config @@ -5,6 +5,7 @@ + diff --git a/TBFTests/Rig/TestMethods/GenesisCommunication/GenesisHead/GenesisHeadBatchIntegrationTest.cs b/TBFTests/Rig/TestMethods/GenesisCommunication/GenesisHead/GenesisHeadBatchIntegrationTest.cs index ea6eb02ae..c0f2d8f5c 100644 --- a/TBFTests/Rig/TestMethods/GenesisCommunication/GenesisHead/GenesisHeadBatchIntegrationTest.cs +++ b/TBFTests/Rig/TestMethods/GenesisCommunication/GenesisHead/GenesisHeadBatchIntegrationTest.cs @@ -1,7 +1,6 @@ using System.IO.Ports; using JetBrains.Annotations; using Microsoft.VisualStudio.TestTools.UnitTesting; -using TBF.Rig.TestMethods.GenesisCommunication.GenesisHead; namespace TBFTests.Rig.TestMethods.GenesisCommunication.GenesisHead {