Compare commits

...

4 Commits

35 changed files with 647 additions and 2797 deletions

View File

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

View File

@ -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()
{

View File

@ -43,6 +43,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 GciType GciExternalInterface { get { return gciExternalInterface; } }
public GciBridgeCfg GciBridgeCfg { get { return gciBridgeCfg; } }
public UdsReaderType GetReader()
{

View File

@ -77,17 +77,17 @@ namespace TBF.Rig.Input.DataStorage.UniDataStorageReader
public void Initialize()
{
throw new NotImplementedException();
//throw new NotImplementedException();
}
public void StartChangeHandler()
{
throw new NotImplementedException();
//throw new NotImplementedException();
}
public void StopChangeHandler()
{
throw new NotImplementedException();
//throw new NotImplementedException();
}
}
}

View File

@ -150,17 +150,17 @@ namespace TBF.Rig.Output.DataStorage.UniDataStorageWriter
public void Initialize()
{
throw new NotImplementedException();
// throw new NotImplementedException();
}
public void StartChangeHandler()
{
throw new NotImplementedException();
//throw new NotImplementedException();
}
public void StopChangeHandler()
{
throw new NotImplementedException();
// throw new NotImplementedException();
}
private WriterDiagnosticResult ValidateCapabilities(IDataStorageWriter writer, DataWriteRequest request)

View File

@ -28,9 +28,11 @@ 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;
public int SlotNr;
@ -50,11 +52,12 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader
{
Name = "Genesis";
ParentName = string.Empty;
SlotNr = 0;
OptoComPortNr = 10;
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 +72,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} SlotNr={SlotNr} Group1 (mux#)={MuxBoardNr}, Group2={Group}, Opto=Com{OptoComPortNr}, {CommunicationInterfaceBridge}=Com{RfidComPortNr}, EnableShowChanels={EnableShowChanels}, IBeginDataFlush={IBeginDataFlush}";
}
}
}

View File

@ -8,7 +8,7 @@ using System.Windows.Forms;
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 +31,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 +89,8 @@ 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;
textBoxSlotNr.Text = config.SlotNr.ToString();
tBBeginDataFlush.Text = config.IBeginDataFlush.ToString();
checkBox_EnableShowChanels.Checked = config.EnableShowChanels;
@ -77,6 +110,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader
muxBoardNrTextBox.Enabled = true;
groupTextBox.Enabled = true;
comboBoxCommunicationInterface.Enabled = true;
textBoxSlotNr.Enabled = true;
tBBeginDataFlush.Enabled = true;
checkBox_EnableShowChanels.Enabled = true;
}
@ -141,6 +175,18 @@ 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";
}
if (!int.TryParse(textBoxSlotNr.Text, out dummy) || dummy < 0 || dummy > 400)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format(Strings.Invalid_0, tBBeginDataFlush.Text);
}
return flags;
}
@ -167,10 +213,11 @@ 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;
config.SlotNr = int.Parse(textBoxSlotNr.Text);
return flags;
}

View File

@ -33,6 +33,8 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader
{
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.label5 = new System.Windows.Forms.Label();
this.textBoxSlotNr = new System.Windows.Forms.TextBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.headPortNrTextBox = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
@ -83,6 +85,8 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader
//
// tabPage1
//
this.tabPage1.Controls.Add(this.label5);
this.tabPage1.Controls.Add(this.textBoxSlotNr);
this.tabPage1.Controls.Add(this.groupBox2);
this.tabPage1.Controls.Add(this.label4);
this.tabPage1.Controls.Add(this.label3);
@ -104,6 +108,22 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader
this.tabPage1.Text = "Config";
this.tabPage1.UseVisualStyleBackColor = true;
//
// label5
//
this.label5.Location = new System.Drawing.Point(372, 55);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(100, 23);
this.label5.TabIndex = 28;
this.label5.Text = "Slot Nr:";
//
// textBoxSlotNr
//
this.textBoxSlotNr.Enabled = false;
this.textBoxSlotNr.Location = new System.Drawing.Point(480, 55);
this.textBoxSlotNr.Name = "textBoxSlotNr";
this.textBoxSlotNr.Size = new System.Drawing.Size(74, 26);
this.textBoxSlotNr.TabIndex = 27;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.headPortNrTextBox);
@ -175,17 +195,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);
@ -446,6 +465,9 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader
this.ResumeLayout(false);
}
private System.Windows.Forms.TextBox textBoxSlotNr;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.CheckBox checkBox_EnableShowChanels;
private System.Windows.Forms.Label labelFlush;

View File

@ -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;

View File

@ -1,10 +1,11 @@
using System;
using System.IO.Ports;
using System.Threading.Tasks;
using Common;
using GenesisCordonelInterface.API;
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;
namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
@ -15,19 +16,20 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
private static readonly ILog log = LogManager.GetLogger(typeof(OptoHeadTest));
private GenesisSmartReader genesisHead;
private SerialDriver serialDriver;
//private SerialDriver serialDriver;
public static SerialDriver BuildConnection(GenesisSmartReader genesidHead)
public void BuildConnection(GenesisSmartReader genesidHead)
{
return new SerialDriverBuilder()
.WithPort($"COM{genesidHead.RfidComPortNr}")
.WithBaudRate(9600)
.WithDataBits(8)
.WithParity(Parity.None)
.WithStopBits(StopBits.One)
.WithTimeouts(4000, 2000)
.BuildAndConnect();
GciPublicModels.GciInitSlotRequest request = new GciPublicModels.GciInitSlotRequest
{
SlotId = genesidHead.GetSlotNr,
ConfigSource = GciPublicModels.GciConfigSource.InterfaceInputConfig,
PasswordSource = GciPublicModels.GciPasswordSource.InterfaceInputPassword,
RequestPort = new GciPublicModels.GciPortConfig{ PortName = $"COM{genesidHead.RfidComPortNr}"/*, Type = "COM"*/},
StreamingPort = new GciPublicModels.GciPortConfig{ PortName = $"COM{genesidHead.OptoComPortNr}"/*, Type = "COM"*/}
};
genesidHead?.CommInterfaceBridge.InitSlotAsync(request);
slotDefined = true;
}
public OptoHeadTest(GenesisSmartReader genesisHead)
@ -37,65 +39,101 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
public void CloseConnection()
{
if (serialDriver != null)
serialDriver.CloseConnection();
serialDriver = null;
genesisHead?.CommInterfaceBridge?.DisconnectAsync(genesisHead.GetSlotNr);
DisposeSlot();
// if (serialDriver != null)
// serialDriver.CloseConnection();
// serialDriver = null;
}
public bool ReadSerialNr()
private bool slotDefined = false;
public bool IsSlotDefined { get => slotDefined; }
public void DisposeSlot()
{
slotDefined = false;
}
public async Task<bool> ReadSerialNrAsync()
{
try
{
if (genesisHead != null)
{
if (serialDriver == null)
serialDriver = BuildConnection(genesisHead);
log.Debug("ReadSerialNr called for iHead: " + genesisHead.ToString() + " serialDriver: " + serialDriver);
RadioService headService = new RadioService(serialDriver);
string serialNo = headService.ReadRequest_PCB(ref genesisHead);
if (!string.IsNullOrEmpty(serialNo))
{
log.Info($"Success Serial No: {serialNo} on COM{genesisHead.RfidComPortNr} serialDriver: {serialDriver}");
return true;
}
}
if (genesisHead == null)
return false;
if (string.IsNullOrEmpty(genesisHead.CommInterface))
return false;
if (genesisHead.CommInterfaceBridge == null)
return false;
if (!IsSlotDefined)
BuildConnection(genesisHead);
GciBridge gciBridge = genesisHead.CommInterfaceBridge;
gciBridge.GciBridgeCfg.EnableExternalAccess = true;
gciBridge.GciBridgeCfg.EnableGuiAccess = false;
gciBridge.Initialize();
RadioService headService = new RadioService(gciBridge);
string pcbId = await headService.ReadRequest_PCBAsync(genesisHead);
return !string.IsNullOrEmpty(pcbId);
}
catch (Exception ex)
{
log.Error($"ReadSerialNr(COM{genesisHead.RfidComPortNr}) - Exception:" + ex.Message);
log.Error($"ReadSerialNr(COM{genesisHead?.RfidComPortNr}) - Exception: {ex}");
return false;
}
return false;
}
public string ReadRequest_PCB()
{
if (genesisHead.DebugLevel == DebugMode.Simulate)
{
return "-OK Simulated response-";
}
// if (genesisHead.DebugLevel == DebugMode.Simulate)
// {
// log.Debug("ReadRequest_PCB() - Simulated response");
// return "-OK Simulated response-";
// }
try
{
if (genesisHead != null)
{
if (serialDriver == null)
serialDriver = BuildConnection(genesisHead);
RadioService headService = new RadioService(serialDriver);
string serialNo = headService.ReadRequest_PCB(ref genesisHead);
log.Info($"PCB Number: {serialNo} on COM{genesisHead.RfidComPortNr} serialDriver: {serialDriver}");
return serialNo;
}
log.Debug("ReadRequest_PCB called for iHead: " + genesisHead.ToString());
if (genesisHead == null)
return string.Empty;
if (string.IsNullOrEmpty(genesisHead.CommInterface))
return string.Empty;
if (genesisHead.CommInterfaceBridge == null)
return string.Empty;
if (!IsSlotDefined) { BuildConnection(genesisHead); }
GciBridge gciBridge = genesisHead.CommInterfaceBridge;
log.Debug("ReadRequest_PCB() - GciBridge created");
gciBridge.GciBridgeCfg.EnableExternalAccess = true;
gciBridge.GciBridgeCfg.EnableGuiAccess = false;
gciBridge.Initialize();
log.Debug("ReadRequest_PCB() - GciBridge initialized");
RadioService headService = new RadioService(gciBridge);
string serialNo = headService.ReadRequest_PCB(ref genesisHead);
log.Info(
$"PCB Number: {serialNo} on COM{genesisHead.RfidComPortNr} SlotNr: {genesisHead.GetSlotNr} serialDriver: {genesisHead?.CommInterfaceBridge}");
return serialNo;
}
catch (Exception ex)
{
log.Error("ReadRequest_PCB() - Exception:" + ex.StackTrace);
return (ex.Message.ToString());
}
return "";
}
/// <summary>
@ -105,6 +143,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
/// <returns></returns>
public bool SetTestMode()
{
if (!IsSlotDefined) { BuildConnection(genesisHead); }
log.Debug("SetTestMode called for iHead: " + genesisHead.ToString());
bool activityModeActive = SetActivityMode_Active();
bool optActiveMode = SetOptTestMode();
@ -120,6 +159,7 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
/// <returns></returns>
public bool SetActiveMode()
{
if (!IsSlotDefined) { BuildConnection(genesisHead); }
log.Debug("SetActiveMode called for iHead: " + genesisHead.ToString());
bool optActiveMode = SetOptActiveMode(genesisHead);
//bool activityModeIdle = SetActivityMode_Idle();
@ -176,25 +216,35 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
/// <exception cref="Exception"></exception>
private bool SetOptTestMode()
{
try
if (genesisHead.DebugLevel == DebugMode.Simulate)
{
if (genesisHead != null)
{
if (serialDriver == null)
serialDriver = BuildConnection(genesisHead);
RadioService headService = new RadioService(serialDriver);
bool optTestMode = headService.SetOptTestMode(genesisHead);
if (genesisHead.ConfigStruct != null)
genesisHead.ConfigStruct.OpthoStatusMode = optTestMode ? DiagnosticLedState.State4 : DiagnosticLedState.StatusUnknown;
return optTestMode;
}
}
catch (Exception ex)
{
log.Error("SetOptTestMode() - Exception:" + ex.StackTrace);
return true;
}
// try
// {
// if (genesisHead != null)
// {
// if(genesisHead.RfidComPortNr != 0 && !genesisHead?.CommInterfaceBridgeComponent?.GciExternalInterface?.IsConnected == false)
// BuildConnection(genesisHead);
//
//
// RadioService headService = new RadioService(genesisHead?.CommInterfaceBridgeComponent);
// bool optTestMode = headService.SetOptTestMode(genesisHead);
// if (genesisHead.ConfigStruct != null)
// genesisHead.ConfigStruct.OpthoStatusMode = optTestMode ? DiagnosticLedState.State4 : DiagnosticLedState.StatusUnknown;
// return optTestMode;
// }
// }
// catch (Exception ex)
// {
// log.Error("SetOptTestMode() - Exception:" + ex.StackTrace);
// }
return false;
}
/// <summary>
@ -211,17 +261,19 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
return "-OK Simulated response-";
}
try
{
bool activeMode = SetActiveMode();
isTestModeSuccessful = activeMode;
return activeMode ? "Set Active Mode - OK" : "Set Active Mode - FAILED";
}
catch (Exception ex)
{
log.Error("SetActiveMode() - Exception:" + ex.StackTrace);
return "Set Active Mode - Exception";
}
// try
// {
// bool activeMode = SetActiveMode();
// isTestModeSuccessful = activeMode;
// return activeMode ? "Set Active Mode - OK" : "Set Active Mode - FAILED";
// }
// catch (Exception ex)
// {
// log.Error("SetActiveMode() - Exception:" + ex.StackTrace);
// return "Set Active Mode - Exception";
// }
return "Set Active Mode - No Implemented Exception";
}
/// <summary>
/// Set Optical -> Active mode
@ -231,21 +283,21 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
/// <exception cref="Exception"></exception>
private bool SetOptActiveMode(GenesisSmartReader iHead)
{
try
{
if (iHead != null)
{
if (serialDriver == null)
serialDriver = BuildConnection(iHead);
RadioService headService = new RadioService(serialDriver);
return headService.SetOptActiveMode(iHead);
}
}
catch (Exception ex)
{
log.Error("SetOptActiveMode() - Exception:" + ex.StackTrace);
}
// try
// {
// if (iHead != null)
// {
// if(genesisHead.RfidComPortNr != 0 && !genesisHead?.CommInterfaceBridgeComponent?.GciExternalInterface?.IsConnected == false)
// BuildConnection(genesisHead);
//
// RadioService headService = new RadioService(genesisHead?.CommInterfaceBridgeComponent);
// return headService.SetOptActiveMode(iHead);
// }
// }
// catch (Exception ex)
// {
// log.Error("SetOptActiveMode() - Exception:" + ex.StackTrace);
// }
return false;
}
@ -258,22 +310,24 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
/// <exception cref="Exception"></exception>
private bool SetActivityMode_Active()
{
try
{
if (genesisHead != null)
{
if (serialDriver == null)
serialDriver = BuildConnection(genesisHead);
log.Debug("SetActivityMode_Active called for iHead: " + genesisHead.ToString() + " serialDriver: " + serialDriver);
RadioService headService = new RadioService(serialDriver);
return headService.SetActivityMode_Active(genesisHead);
}
}
catch (Exception ex)
{
log.Error("SetActivityMode_Active() - Exception:" + ex.StackTrace);
}
// try
// {
// if (genesisHead != null)
// {
// if (genesisHead.RfidComPortNr != 0 &&
// !genesisHead?.CommInterfaceBridgeComponent?.GciExternalInterface?.IsConnected == false)
// BuildConnection(genesisHead);
//
// log.Debug("SetActivityMode_Active called for iHead: " + genesisHead.ToString());
// RadioService headService = new RadioService(genesisHead?.CommInterfaceBridgeComponent);
// return headService.SetActivityMode_Active(genesisHead);
// }
// }
// catch (Exception ex)
// {
// log.Error("SetActivityMode_Active() - Exception:" + ex.StackTrace);
// }
return false;
}
@ -286,23 +340,24 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
/// <exception cref="Exception"></exception>
private bool SetActivityMode_Idle()
{
try
{
if (genesisHead != null)
{
if (serialDriver == null)
serialDriver = BuildConnection(genesisHead);
log.Debug("SetActivityMode_Idle called for iHead: " + genesisHead.ToString() + " serialDriver: " + serialDriver);
RadioService headService = new RadioService(serialDriver);
return headService.SetActivityMode_Idle(genesisHead);
}
}
catch (Exception ex)
{
log.Error("SetActivityMode_Idle() - Exception:" + ex.StackTrace);
}
// try
// {
// if (genesisHead != null)
// {
// if (genesisHead.RfidComPortNr != 0 &&
// !genesisHead?.CommInterfaceBridgeComponent?.GciExternalInterface?.IsConnected == false)
// BuildConnection(genesisHead);
//
// log.Debug("SetActivityMode_Idle called for iHead: " + genesisHead.ToString());
//
// RadioService headService = new RadioService(genesisHead?.CommInterfaceBridgeComponent);
// return headService.SetActivityMode_Idle(genesisHead);
// }
// }
// catch (Exception ex)
// {
// log.Error("SetActivityMode_Idle() - Exception:" + ex.StackTrace);
// }
return false;
}
@ -330,33 +385,34 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
try
{
if (genesisHead != null)
{
genesisHead.ConfigStruct = new ConfigStruct();
if (serialDriver == null)
serialDriver = BuildConnection(genesisHead);
RadioService headService = new RadioService(serialDriver);
genesisHead.ConfigStruct.PCBNumberString = headService.ReadRequest_PCB(ref genesisHead);
genesisHead.ConfigStruct.StatusMode = headService.GetActivityStatusMode(genesisHead);
genesisHead.ConfigStruct.Unit = headService.GetUnit(genesisHead);
if (ledState != DiagnosticLedState.StatusUnknown) // do set
{
genesisHead.ConfigStruct.OpthoStatusMode = headService.SetOptoStatusMode(genesisHead, ledState);
}
else
{
genesisHead.ConfigStruct.OpthoStatusMode = DiagnosticLedState.StatusUnknown;
}
genesisHead.ConfigStruct.Version = headService.GetVersion(genesisHead);
return true;
}
else
// if (genesisHead != null)
// {
// genesisHead.ConfigStruct = new ConfigStruct();
//
// if (genesisHead.RfidComPortNr != 0 &&
// !genesisHead?.CommInterfaceBridgeComponent?.GciExternalInterface?.IsConnected == false)
// BuildConnection(genesisHead);
//
// RadioService headService = new RadioService(genesisHead?.CommInterfaceBridgeComponent);
// genesisHead.ConfigStruct.PCBNumberString = headService.ReadRequest_PCB(ref genesisHead);
// genesisHead.ConfigStruct.StatusMode = headService.GetActivityStatusMode(genesisHead);
// genesisHead.ConfigStruct.Unit = headService.GetUnit(genesisHead);
//
// if (ledState != DiagnosticLedState.StatusUnknown) // do set
// {
// genesisHead.ConfigStruct.OpthoStatusMode = headService.SetOptoStatusMode(genesisHead, ledState);
// }
// else
// {
// genesisHead.ConfigStruct.OpthoStatusMode = DiagnosticLedState.StatusUnknown;
// }
//
// genesisHead.ConfigStruct.Version = headService.GetVersion(genesisHead);
//
// return true;
// }
//
// else
{
return false;
}

View File

@ -1,9 +1,11 @@
using System;
using System.Threading.Tasks;
using GenesisCordonelInterface.API;
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.C4.IperlHatProtocol;
using TBF.Rig.TestMethods.iPerlCommunication.communication.C4.protocolCommons;
using TBF.Rig.TestMethods.iPerlCommunication.communication.Utils;
namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
@ -15,104 +17,155 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
static string okResponse = "Command complete, no errors";
static string errorResponse = "Unable to execute";
private ISerialDriver serialDriver;
public RadioService(SerialDriver serialDriver)
private GciBridge _bridge;
public RadioService(GciBridge genesisHeadCommInterfaceBridgeComponent)
{
this.serialDriver = serialDriver;
log.Debug("RadioService created with serialDriver= " + serialDriver + "");
}
public RadioService(ISerialDriver serialDriver)
{
this.serialDriver = serialDriver;
log.Debug("RadioService created with serialDriver= " + serialDriver + "");
this._bridge = genesisHeadCommInterfaceBridgeComponent;
log.Debug("RadioService created with GciBridge= " + genesisHeadCommInterfaceBridgeComponent + "");
}
public async Task<string> ReadRequest_PCBAsync(GenesisSmartReader iHead)
{
if (iHead?.CommInterfaceBridge == null)
return null;
var connectTask = iHead.CommInterfaceBridge.ConnectAsync(iHead.GetSlotNr);
// Wait either for ConnectAsync or timeout
if (await Task.WhenAny(connectTask, Task.Delay(TimeSpan.FromMinutes(1))) != connectTask)
{
// Timed out
return null;
}
var result = await connectTask;
if (result == null || !result.Success || !result.IsLoggedOn)
return null;
string pcbId = result.PcbId;
if (!string.IsNullOrEmpty(pcbId))
{
if (iHead.ConfigStruct != null)
iHead.ConfigStruct.PCBNumberString = pcbId;
return pcbId;
}
return null;
}
public string ReadRequest_PCB(ref GenesisSmartReader iHead)
{
if (!serialDriver.IsOpen())
log.Debug("ReadRequest_PCB called for iHead: " + iHead.ToString());
if (iHead?.CommInterfaceBridge == null)
return null;
var connectTask = iHead.CommInterfaceBridge.ConnectAsync(iHead.GetSlotNr);
log.Debug("ReadRequest_PCB() - ConnectAsync created, Now waiting for result");
var completedTask = Task.WhenAny(
connectTask,
Task.Delay(TimeSpan.FromMinutes(1))
).GetAwaiter().GetResult();
log.Debug("ReadRequest_PCB() - CompletedTask: " + completedTask);
// Timeout happened
if (completedTask != connectTask)
{
serialDriver.Open();
log.Debug("ReadRequest_PCB() - Timeout happened");
return null;
}
var request = new IperlHatFrameBuilder()
.RequestResponse(true)
.AddCommand(ProtocolCommand.ViewFactoryId)
.BuildBytes();
byte[] rawData = serialDriver.SendAndWait(request, 10000);
if (rawData == null)
var result = connectTask.GetAwaiter().GetResult();
log.Debug("ReadRequest_PCB() - ConnectAsync completed");
if (result == null || !result.Success || !result.IsLoggedOn)
return null;
// parse rawData
var parser = new IperlHatFrameParser();
IperlHatResponse decoded = parser.Parse(rawData);
if (decoded.IsOk)
log.Debug("ReadRequest_PCB() - result: " + result);
string pcbId = result.PcbId;
log.Debug("ReadRequest_PCB() - pcbId: " + pcbId);
if (!string.IsNullOrEmpty(pcbId))
{
string asciiPayload = decoded.GetAsciiPayload();
if (iHead.ConfigStruct != null) // store mechanism
if (iHead.ConfigStruct != null)
{
iHead.ConfigStruct.PCBNumberString = asciiPayload;
iHead.ConfigStruct.PCBNumberString = pcbId;
log.Debug("ReadRequest_PCB() - iHead.ConfigStruct.PCBNumberString: " + iHead.ConfigStruct.PCBNumberString);
}
return asciiPayload;
return pcbId;
}
log.Debug("ReadRequest_PCB() - pcbId is empty");
return null;
}
public ProtocolStatuses GetActivityStatusMode(GenesisSmartReader iHead)
{
if (!serialDriver.IsOpen())
serialDriver.Open();
var request = new IperlHatFrameBuilder()
.RequestResponse(true)
.AddCommand(ProtocolCommand.ViewState)
.BuildBytes();
byte[] rawData = serialDriver.SendAndWait(request, 10000);
if (rawData == null)
if (iHead?.CommInterfaceBridge == null)
return ProtocolStatuses.Unknown;
var parser = new IperlHatFrameParser();
IperlHatResponse decoded = parser.Parse(rawData);
var connectResult = iHead.CommInterfaceBridge
.ConnectAsync(iHead.GetSlotNr)
.GetAwaiter()
.GetResult();
if (!decoded.IsOk)
if (connectResult == null || !connectResult.Success || !connectResult.IsLoggedOn)
return ProtocolStatuses.Unknown;
ProtocolStatuses statusMode = decoded.GetResponse<ProtocolStatuses>(out bool isOK);
if (!isOK)
return ProtocolStatuses.Unknown; // wrong payload
var pcbResult = iHead.CommInterfaceBridge
.GetPcbIdAsync(iHead.GetSlotNr)
.GetAwaiter()
.GetResult();
return statusMode;
if (pcbResult == null || !pcbResult.Success || string.IsNullOrWhiteSpace(pcbResult.PcbId))
return ProtocolStatuses.Unknown;
if (iHead.ConfigStruct != null)
{
iHead.ConfigStruct.PCBNumberString = pcbResult.PcbId;
}
return ProtocolStatuses.Active;
}
public DiagnosticLedState SetOptoStatusMode(GenesisSmartReader iHead, DiagnosticLedState opthoStatusMode)
{
if (!serialDriver.IsOpen())
serialDriver.Open();
var request = new IperlHatFrameBuilder()
.RequestResponse(true)
.AddDeviceCommand(ProtocolDeviceSubCommand.SetDiagnosticLEDState)
.AddPayload(opthoStatusMode)
.BuildBytes();
byte[] rawData = serialDriver.SendAndWait(request, 10000);
if (rawData == null)
if (iHead?.CommInterfaceBridge == null)
return DiagnosticLedState.StatusUnknown;
var parser = new IperlHatFrameParser();
IperlHatResponse decoded = parser.Parse(rawData);
var connectResult = iHead.CommInterfaceBridge
.ConnectAsync(iHead.GetSlotNr)
.GetAwaiter()
.GetResult();
log.Debug("SetOptoStatusMode isOK: " + decoded.IsOk);
// if is response ok - it set it correctly
if (!decoded.IsOk)
if (connectResult == null || !connectResult.Success || !connectResult.IsLoggedOn)
return DiagnosticLedState.StatusUnknown;
return opthoStatusMode;
//SetDiagnosticLEDState
var pcbResult = iHead.CommInterfaceBridge
.GetPcbIdAsync(iHead.GetSlotNr)
.GetAwaiter()
.GetResult();
if (pcbResult == null || !pcbResult.Success || string.IsNullOrWhiteSpace(pcbResult.PcbId))
return DiagnosticLedState.StatusUnknown;
if (iHead.ConfigStruct != null)
{
iHead.ConfigStruct.PCBNumberString = pcbResult.PcbId;
}
return DiagnosticLedState.StatusUnknown;
}
@ -127,124 +180,109 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
public string GetVersion(GenesisSmartReader iHead)
{
if (!serialDriver.IsOpen())
{
serialDriver.Open();
}
if (iHead?.CommInterfaceBridge == null)
return string.Empty;
byte[] request = new IperlHatFrameBuilder()
.RequestResponse(true)
.AddCommand(ProtocolCommand.Question)
.AddPayload(IperlHatProtocolConstants.Version)
.BuildBytes();
var connectResult = iHead.CommInterfaceBridge
.ConnectAsync(iHead.GetSlotNr)
.GetAwaiter()
.GetResult();
if (connectResult == null || !connectResult.Success || !connectResult.IsLoggedOn)
return string.Empty;
// if (!string.IsNullOrEmpty(version))
// {
// if (iHead.ConfigStruct != null) // store mechanism
// {
// iHead.ConfigStruct.Version = version;
// }
// return version;
// }
byte[] rawData = serialDriver.SendAndWait(request, 10000);
if (rawData == null)
return "";
// parse rawData
var parser = new IperlHatFrameParser();
IperlHatResponse decoded = parser.Parse(rawData);
log.Debug("GetVersion isOK: " + decoded.IsOk);
if (decoded.IsOk)
{
return decoded.GetAsciiPayload();
}
return "";
return string.Empty;
}
public bool SetActivityMode_Active(GenesisSmartReader iHead)
{
if (!serialDriver.IsOpen())
{
serialDriver.Open();
}
//Set LED to state 4
byte[] request = new IperlHatFrameBuilder()
.RequestResponse(true)
.AddCommand(ProtocolCommand.SetState)
.AddSubCommand(ProtocolStatuses.Active) // Active
.BuildBytes();
if (iHead?.CommInterfaceBridge == null)
return false;
byte[] rawData = serialDriver.SendAndWait(request, 5000);
if (rawData == null)
var connectResult = iHead.CommInterfaceBridge
.ConnectAsync(iHead.GetSlotNr)
.GetAwaiter()
.GetResult();
if (connectResult == null || !connectResult.Success || !connectResult.IsLoggedOn)
return false;
//Set LED to state 4
// string version = _bridge?.GciExternalInterface?.GetPcbId(iHead.GetSlotNr);
// if (!string.IsNullOrEmpty(version))
// {
// if (iHead.ConfigStruct != null) // store mechanism
// {
// iHead.ConfigStruct.Version = version;
// }
// return true;
// }
// parse rawData
var parser = new IperlHatFrameParser();
IperlHatResponse decoded = parser.Parse(rawData);
log.Debug("SetActivityMode_Active isOK: " + decoded.IsOk);
if (decoded.IsOk && iHead.ConfigStruct != null)
{
iHead.ConfigStruct.StatusMode = ProtocolStatuses.Active;
}
return decoded.IsOk;
return false;
}
public bool SetActivityMode_Idle(GenesisSmartReader iHead)
{
if (!serialDriver.IsOpen())
{
serialDriver.Open();
}
//Set Activity State Idle
byte[] request = new IperlHatFrameBuilder()
.RequestResponse(true)
.AddCommand(ProtocolCommand.SetState)
.AddSubCommand(ProtocolStatuses.Idle)
.BuildBytes();
if (iHead?.CommInterfaceBridge == null)
return false;
byte[] rawData = serialDriver.SendAndWait(request, 5000);
if (rawData == null)
var connectResult = iHead.CommInterfaceBridge
.ConnectAsync(iHead.GetSlotNr)
.GetAwaiter()
.GetResult();
if (connectResult == null || !connectResult.Success || !connectResult.IsLoggedOn)
return false;
//Set Activity State Idle
// string version = _bridge?.GciExternalInterface?.GetPcbId(iHead.GetSlotNr);
// if (!string.IsNullOrEmpty(version))
// {
// if (iHead.ConfigStruct != null) // store mechanism
// {
// iHead.ConfigStruct.Version = version;
// }
// return true;
// }
// parse rawData
var parser = new IperlHatFrameParser();
IperlHatResponse decoded = parser.Parse(rawData);
log.Debug("SetActivityMode_Idle isOK: " + decoded.IsOk);
if (decoded.IsOk && iHead.ConfigStruct != null)
{
iHead.ConfigStruct.StatusMode = ProtocolStatuses.Idle;
}
return decoded.IsOk;
return false;
}
public bool SetOptTestMode(GenesisSmartReader iHead)
{
if (!serialDriver.IsOpen())
{
serialDriver.Open();
}
//Set LED to state 4
var request = new IperlHatFrameBuilder()
.RequestResponse(true)
.AddDeviceCommand(ProtocolDeviceSubCommand.SetDiagnosticLEDState)
.AddPayload(DiagnosticLedState.State4)
.BuildBytes();
if (iHead?.CommInterfaceBridge == null)
return false;
byte[] rawData = serialDriver.SendAndWait(request, 5000);
if (rawData == null)
var connectResult = iHead.CommInterfaceBridge
.ConnectAsync(iHead.GetSlotNr)
.GetAwaiter()
.GetResult();
if (connectResult == null || !connectResult.Success || !connectResult.IsLoggedOn)
return false;
//Set LED to state 4
// string version = _bridge?.GciExternalInterface?.GetPcbId(iHead.GetSlotNr);
// if (!string.IsNullOrEmpty(version))
// {
// if (iHead.ConfigStruct != null) // store mechanism
// {
// iHead.ConfigStruct.Version = version;
// }
// return true;
// }
// parse rawData
var parser = new IperlHatFrameParser();
IperlHatResponse decoded = parser.Parse(rawData);
bool isOk = decoded.IsOk;
log.Debug("SetOptTestMode isOK: " + isOk);
if (decoded.IsOk && iHead.ConfigStruct != null)
{
iHead.ConfigStruct.OpthoStatusMode = DiagnosticLedState.State4;
}
return isOk;
return false;
}
@ -255,65 +293,55 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.communication
/// <returns></returns>
public bool SetOptActiveMode(GenesisSmartReader iHead)
{
if (!serialDriver.IsOpen())
{
serialDriver.Open();
}
if (iHead?.CommInterfaceBridge == null)
return false;
var connectResult = iHead.CommInterfaceBridge
.ConnectAsync(iHead.GetSlotNr)
.GetAwaiter()
.GetResult();
if (connectResult == null || !connectResult.Success || !connectResult.IsLoggedOn)
return false;
//Set LED to state 1
var request = new IperlHatFrameBuilder()
.RequestResponse(true)
.AddDeviceCommand(ProtocolDeviceSubCommand.SetDiagnosticLEDState)
.AddPayload(DiagnosticLedState.StateOFF)
.BuildBytes();
byte[] rawData = serialDriver.SendAndWait(request, 5000);
if (rawData == null)
return false;
// string version = _bridge?.GciExternalInterface?.GetPcbId(iHead.GetSlotNr);
// if (!string.IsNullOrEmpty(version))
// {
// if (iHead.ConfigStruct != null) // store mechanism
// {
// iHead.ConfigStruct.Version = version;
// }
// return true;
// }
// parse rawData
var parser = new IperlHatFrameParser();
IperlHatResponse decoded = parser.Parse(rawData);
log.Debug("SetOptActiveMode isOK: " + decoded.IsOk);
if (decoded.IsOk && iHead.ConfigStruct != null)
{
iHead.ConfigStruct.OpthoStatusMode = DiagnosticLedState.StateOFF;
}
return decoded.IsOk;
return false;
}
public string GetUnit(GenesisSmartReader iperlHead)
{
if (!serialDriver.IsOpen())
{
serialDriver.Open();
}
if (iperlHead?.CommInterfaceBridge == null)
return string.Empty;
var request = new IperlHatFrameBuilder()
.RequestResponse(true)
.AddCommand(ProtocolCommand.ViewFactoryId)
.BuildBytes();
var connectResult = iperlHead.CommInterfaceBridge
.ConnectAsync(iperlHead.GetSlotNr)
.GetAwaiter()
.GetResult();
if (connectResult == null || !connectResult.Success || !connectResult.IsLoggedOn)
return string.Empty;
// string version = _bridge?.GciExternalInterface?.GetPcbId(iperlHead.GetSlotNr);
// if (!string.IsNullOrEmpty(version))
// {
// if (iperlHead.ConfigStruct != null) // store mechanism
// {
// iperlHead.ConfigStruct.Version = version;
// }
// return version;
// }
byte[] rawData = serialDriver.SendAndWait(request, 10000);
if (rawData == null)
return null;
// parse rawData
var parser = new IperlHatFrameParser();
IperlHatResponse decoded = parser.Parse(rawData);
if (decoded.IsOk)
{
string asciiPayload = decoded.GetAsciiPayload();
if (iperlHead.ConfigStruct != null) // store mechanism
{
iperlHead.ConfigStruct.Unit = asciiPayload;
}
return asciiPayload;
}
return null;
return string.Empty;
}
}
}

View File

@ -5,6 +5,7 @@ using System.Threading;
using System.Web.UI.WebControls;
using System.Windows.Forms;
using Common;
using log4net;
using TBF.Rig.Generic;
using TBF.Rig.RegisterReaders.iPerlReaderUNI.common;
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.common;
@ -13,6 +14,9 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations
{
public class GenesisImplHeadTestCtrl : IUniHeadTestCtrl<OptoReceivedEventArgs>
{
private static readonly ILog log = LogManager.GetLogger(typeof(GenesisSmartReader));
private static readonly ILog logStream = LogManager.GetLogger("StreamData");
Thread optoThread;
//GenesisSmartReader _genesiHead;
@ -89,6 +93,8 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations
{
a.RfidOutputListBox.Items.Clear();
log.Debug($"CommandTestButtonClick called: {a?.RfidCommandComboBox?.SelectedValue}");
using (Tools.LogChecker logChecker = new Tools.LogChecker("RfidData", log4net.Core.Level.Debug))
{
ListItem rfidListItem = new ListItem();

View File

@ -114,7 +114,23 @@ 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.GciBridge CommInterfaceBridge
{
get
{
if (!string.IsNullOrEmpty((genesisHeadCfg?.CommunicationInterfaceBridge)))
{
IComponent findComponent = TbfComponents.FindComponent(genesisHeadCfg?.CommunicationInterfaceBridge);
TBF.Rig.BridgeComponents.GciBridge.GciBridge component = findComponent as TBF.Rig.BridgeComponents.GciBridge.GciBridge;
return component;
}
return null;
}
}
public bool EnableShowChanels => genesisHeadCfg?.EnableShowChanels ?? false;
@ -3086,9 +3102,9 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations
{
log.Debug($"Try get ReadSerialNr! COM: {this.RfidComPortNr}");
if (OptoHeadTest.ReadSerialNr())
SerialNr = OptoHeadTest.ReadRequest_PCB();
if (string.IsNullOrEmpty(SerialNr))
{
SerialNr = this.ConfigStruct.PCBNumberString;
log.Debug("ReadSerialNr successful");
}
@ -3937,6 +3953,8 @@ namespace TBF.Rig.RegisterReaders.GenesisRegReader.implementations
public double Q3Calib_Ch1Value { get => q3CalibCh[0]; }
public double Q3Calib_Ch2Value { get => q3CalibCh[1]; }
public double Q3Calib_Ch3Value { get => q3CalibCh[2]; }
public int GetSlotNr { get => genesisHeadCfg?.SlotNr ?? -1; }
void SetQ3Calibration(double[] q3CalibInitial) { this.q3CalibInitial = q3CalibInitial; }
@ -4063,5 +4081,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
}
}
}

View File

@ -309,6 +309,7 @@ namespace TBF.Rig
BuiltIn.Valve.Valve plainValve = (cmpnt as BuiltIn.Valve.Valve);
if ((plainValve != null) && plainValve.Inverted) valvesToInvert |= plainValve.Mask;
log.Debug( string.Format( "InitializeBoardEtc() ... {0} {1}", cmpnt.Name, cmpnt.ClassName ) );
cmpnt.StartChangeHandler(); /// Start handling parameter change events
}

View File

@ -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(),

View File

@ -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);

View File

@ -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
///

View File

@ -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;
}
/// <summary>
/// Create a calibration structure from a complete byte array
/// </summary>
/// <param name="data">A complete byte array data</param>
/// <returns>CalibrationStruct or null when byte array was not complete</returns>
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;
}
/// <summary>
/// Update the calibration structure from an incomplete byte array
/// </summary>
/// <param name="data">Byte array data</param>
/// <param name="offset">Offset of byte array data in CalibrationStruct</param>
/// <returns>true when successful, false when data are not appropriate</returns>
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"));
}
}
}

View File

@ -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;
}
/// <summary>
/// Create a configuration structure from a complete byte array
/// </summary>
/// <param name="data">A complete byte array data</param>
/// <returns>ConfigStruct or null when byte array was not complete</returns>
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;
}
/// <summary>
/// Update the configuration structure from an incomplete byte array
/// </summary>
/// <param name="offset">Offset of byte array data in ConfigStruct</param>
/// <param name="data">Byte array data</param>
/// <returns>true when successful, false when data are not appropriate</returns>
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;
}
/// <summary>
/// Returns PCB number string (12 characters, 12 decimal digits)
/// </summary>
/// <returns>PCB number STRING</returns>
public string GetPcbNrString()
{
return PCBNumber2String(this.PCBNumber);
}
/// <summary>
/// Converts PCBNumber to string (12 characters, 12 decimal digits)
/// </summary>
/// <param name="pcbNumber"></param>
/// <returns>PCB number string</returns>
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"));
}
}
}

View File

@ -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)
/// <summary>
/// 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.
/// </summary>
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,
}
}

View File

@ -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<IComponent> 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);
}
}
}

View File

@ -1,658 +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 Xylem.Common.Hardware.Interfaces.Ports.PortCore;
using Common;
using System.IO.Ports;
namespace TBF.Rig.TestMethods.GenesisCommunication.GenesisHead
{
public static class GenesisHeadBatch
{
public static Dictionary<string, List<MeasurementResults>> MeterIdDetailResults = new Dictionary<string, List<MeasurementResults>>();
private static readonly ILog log = LogManager.GetLogger(typeof(GenesisHeadBatch));
public static readonly Lazy<MeterBatch> BatchHolder = new Lazy<MeterBatch>(() =>
{
return new MeterBatch();
});
internal static bool Start(IRegReader[] registerReaders, string[] lastSNTexts)
{
try
{
MeterIdDetailResults = new Dictionary<string, List<MeasurementResults>>();
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;
}
}
}
/// <summary>
/// This component = instance of this class is a placeholder for a combined main watermeter
/// </summary>
public class GenesisHead : ComponentBase, IDevice, GenericDevices./*IRegisterReader*/IRegReader, IOperation
{
public List<MeasurementResults> 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;
/// <summary> ConfigStruct of the water meter obtained or updated by iPerlCommunication </summary>
public ConfigStruct ConfigStruct
{
get { return configStruct; }
set { configStruct = value; }
}
private ConfigStruct configStruct;
/// <summary> CalibrationStruct of the water meter obtained or updated by iPerlCommunication </summary>
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; } }
/// <summary> Result of the last test used to calculate Q2 correction factors, etc </summary>
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;
/// <summary> Name set by the test, to be used as a part of the opto-data log file name </summary>
public string TestName;
/// <summary> Name set by the test, to be used as a part of the opto-data log file name </summary>
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;
}
}
/// <summary>
/// Clear data related to a specific water meter
/// </summary>
public void ClearData()
{
DetailedResults = new List<MeasurementResults>();
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() { }
/// <summary>
/// Events: Event.ReadRegisterDone, Event.Error
/// </summary>
/// <returns>ReadWaterMeter instance reference casted to IOperaton</returns>
public IOperation ReadRegisterOp()
{
return this;
}
/// <summary>
/// Clear data/counters related to a specific tests
/// </summary>
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;
/// <summary>Start this operation</summary>
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<MeasurementResults>();
myGenesis.StartMeasurement();
}
StoreStartPackage = true;
}
}
}
public void Log(string text)
{
log.Debug(text);
if (DebugLevel == DebugMode.Normal)
{
if (myGenesis != null)
{
myGenesis.WriteLog(text);
}
}
}
/// <summary>Run this operation</summary>
/// <returns>eventDone</returns>
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();
}
}
}
/// <summary>Stop this operation</summary>
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, 0.0/*, (int?)null*/);
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;
}
}

View File

@ -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<Config.Entities.Component> 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;
/// <summary> Procedure parameters </summary>
[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
);
}
}
}

View File

@ -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;
}
}
}

View File

@ -1,197 +0,0 @@
///
/// Copyright (c) 2015-2017 Sensus Metering Systems
///
namespace TBF.Rig.TestMethods.GenesisCommunication.GenesisHead
{
partial class GenesisHeadCfgCtrl : System.Windows.Forms.UserControl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -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;
}
}
}

View File

@ -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()
{
}
/// <summary>
/// Parses optical telegram and returns OptoTelegramRaw object
/// </summary>
/// <description>
/// 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
/// ...
/// </description>
/// <param name="data">A complete byte array data</param>
/// <returns>true = telegram OK, false = telegram NOK</returns>
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;
}
/// <summary>
/// Alternative to UpdateFromString(...) when data are flushed
/// </summary>
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());
}
}
/// <summary>
/// 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 ...
/// </summary>
/// <param name="optoData">array of OptoTelegramRaw objects</param>
/// <param name="optoDataCount">number of objects to process</param>
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];
}
}
}
}

View File

@ -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;
}
}
}

View File

@ -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);
}
}
}

View File

@ -130,6 +130,9 @@
<Reference Include="NHibernate">
<HintPath>..\packages\NHibernate.4.0.4.4000\lib\net40\NHibernate.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.5.2.2\lib\net46\NLog.dll</HintPath>
</Reference>
<Reference Include="Oracle.DataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Oracle\Oracle.DataAccess.dll</HintPath>
@ -171,7 +174,7 @@
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Xylem.Common.CommonCore">
<HintPath>..\packages\Common\Xylem.Common.CommonCore.dll</HintPath>
<HintPath>..\GenesisCordonelInterface\bin\Debug\Xylem.Common.CommonCore.dll</HintPath>
</Reference>
<Reference Include="Xylem.Common.Hardware.Interfaces.Ports.PortCore, Version=2.8.18.15967, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
@ -187,10 +190,10 @@
<HintPath>..\packages\Common\Xylem.Common.Hardware.WaterMeter.WaterMeterCore.dll</HintPath>
</Reference>
<Reference Include="Xylem.Common.Hardware.WaterMeter.WaterMeterRegisters">
<HintPath>..\packages\Common\Xylem.Common.Hardware.WaterMeter.WaterMeterRegisters.dll</HintPath>
<HintPath>..\GenesisCordonelInterface\bin\Debug\Xylem.Common.Hardware.WaterMeter.WaterMeterRegisters.dll</HintPath>
</Reference>
<Reference Include="Xylem.Common.Metrology.Measurements">
<HintPath>..\packages\Common\Xylem.Common.Metrology.Measurements.dll</HintPath>
<HintPath>..\GenesisCordonelInterface\bin\Debug\Xylem.Common.Metrology.Measurements.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@ -1792,20 +1795,6 @@
<DependentUpon>TestMethodCfgCtrl.cs</DependentUpon>
</Compile>
<Compile Include="Rig\TestMethods\FlyingStartMassCollection\Single\TestParams.cs" />
<Compile Include="Rig\TestMethods\GenesisCommunication\GenesisHead\CalibrationStruct.cs" />
<Compile Include="Rig\TestMethods\GenesisCommunication\GenesisHead\ConfigStruct.cs" />
<Compile Include="Rig\TestMethods\GenesisCommunication\GenesisHead\Enums.cs" />
<Compile Include="Rig\TestMethods\GenesisCommunication\GenesisHead\Factory.cs" />
<Compile Include="Rig\TestMethods\GenesisCommunication\GenesisHead\GenesisHead.cs" />
<Compile Include="Rig\TestMethods\GenesisCommunication\GenesisHead\GenesisHeadCfg.cs" />
<Compile Include="Rig\TestMethods\GenesisCommunication\GenesisHead\GenesisHeadCfgCtrl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Rig\TestMethods\GenesisCommunication\GenesisHead\GenesisHeadCfgCtrl.designer.cs" />
<Compile Include="Rig\TestMethods\GenesisCommunication\GenesisHead\OptoReceivedEventArgs.cs" />
<Compile Include="Rig\TestMethods\GenesisCommunication\GenesisHead\OptoTelegramRaw.cs" />
<Compile Include="Rig\TestMethods\GenesisCommunication\GenesisHead\ProcParams.cs" />
<Compile Include="Rig\TestMethods\GenesisCommunication\GenesisHead\StatusStruct.cs" />
<Compile Include="Rig\TestMethods\GenesisCommunication\Factory.cs" />
<Compile Include="Rig\TestMethods\GenesisCommunication\GenesisCommunicationSeq.cs" />
<Compile Include="Rig\TestMethods\GenesisCommunication\iPerlCommunicationParams.cs" />
@ -3764,7 +3753,6 @@
<EmbeddedResource Include="Rig\TestMethods\FlyingStartTankCollection\Single\TestMethodCfgCtrl.resx">
<DependentUpon>TestMethodCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Rig\TestMethods\GenesisCommunication\GenesisHead\GenesisHeadCfgCtrl.resx" />
<EmbeddedResource Include="Rig\TestMethods\GenesisCommunication\TestMethodCfgCtrl.resx">
<DependentUpon>TestMethodCfgCtrl.cs</DependentUpon>
</EmbeddedResource>

View File

@ -35,6 +35,50 @@
<assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Logic.ProductionToProductMapper" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.0.3.24128" newVersion="1.0.3.24128" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Xylem.Common.CommonCore" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.0.3.24125" newVersion="1.0.3.24125" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.8.18.16696" newVersion="2.8.18.16696" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Xylem.Common.Hardware.WaterMeter.Genesis.DataPackages" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.8.18.16696" newVersion="2.8.18.16696" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Xylem.Common.Hardware.WaterMeter.Genesis.GenesisConfig" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.0.3.24126" newVersion="1.0.3.24126" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.0.3.24134" newVersion="1.0.3.24134" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.StreamingProtocol" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.8.18.16696" newVersion="2.8.18.16696" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Xylem.Common.Hardware.WaterMeter.WaterMeterCore" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.0.3.24126" newVersion="1.0.3.24126" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Xylem.Common.Metrology.Measurements" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.0.3.24125" newVersion="1.0.3.24125" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Xylem.Common.Utils.ByteArrayStyle" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.8.18.24507" newVersion="2.8.18.24507" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<oracle.manageddataaccess.client>

View File

@ -5,6 +5,7 @@
<package id="Iesi.Collections" version="4.0.0.4000" targetFramework="net40" />
<package id="MySql.Data" version="6.6.5" targetFramework="net20" requireReinstallation="true" />
<package id="NHibernate" version="4.0.4.4000" targetFramework="net40" />
<package id="NLog" version="5.2.2" targetFramework="net472" />
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net472" />
<package id="Oracle.ManagedDataAccess" version="19.11.0" targetFramework="net472" />
<package id="System.Data.SQLite" version="1.0.90.0" targetFramework="net40" requireReinstallation="true" />

View File

@ -79,7 +79,7 @@ namespace TBFTests.Rig.RegisterReaders.GenesisRegReader.implementations
cfg.RfidComPortNr = 8;
cfg.MuxBoardNr = 1;
cfg.Group = 1;
cfg.CommunicationInterface = CommunicationInterface.RFID;
cfg.CommunicationInterfaceBridge = string.Empty;
if (cfg.ProcParams != null)
{

View File

@ -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
{