CLP1611, TestMethods.Counter : ResetStaticProperties( ) eliminated, code from constructor moved to Initialize( ).
This commit is contained in:
@@ -73,7 +73,6 @@ namespace TBF.Rig.Network.Camera.CLP1611
|
||||
///
|
||||
static int nextCameraIdx = 0;
|
||||
static int GetCameraIdx() { return nextCameraIdx++; } /// Used in Initialize()
|
||||
public static new void ResetStaticProperties() { nextCameraIdx = 0; }
|
||||
|
||||
///
|
||||
/// Telnet support
|
||||
@@ -137,32 +136,32 @@ namespace TBF.Rig.Network.Camera.CLP1611
|
||||
public int GetResult(int roiHandle, out long timeMs) { return roisAndResults.GetResult(roiHandle, out timeMs); }
|
||||
|
||||
|
||||
public Camera() {}
|
||||
|
||||
public Camera() { }
|
||||
|
||||
public Camera(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
|
||||
: base(cfg)
|
||||
{
|
||||
CameraCfg = cfg as CameraCfg;
|
||||
NetAdapter = TbfComponents.FindComponent(cfg.ParentName, components) as GenericDevices.INetworkAdapter;
|
||||
|
||||
NetAdapter = TbfComponents.FindComponent(cfg.ParentName, components) as GenericDevices.INetworkAdapter;
|
||||
if (NetAdapter == null) throw new ArgumentNullException("no network adapter");
|
||||
|
||||
Telnet = null;
|
||||
terminalDlg = null;
|
||||
|
||||
roisAndResults = new RoisAndResults(); /// object for measurement results, writes/reads to/from this object are locked
|
||||
|
||||
running = false;
|
||||
}
|
||||
|
||||
log.Warn(this.ToString());
|
||||
}
|
||||
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
cameraIdx = GetCameraIdx();
|
||||
cameraIdx = GetCameraIdx();
|
||||
|
||||
running = false;
|
||||
Telnet = null;
|
||||
terminalDlg = null;
|
||||
roisAndResults = new RoisAndResults(); /// object for measurement results, writes/reads to/from this object are locked
|
||||
|
||||
if (CameraCfg.DebugLevel == DebugMode.Simulate)
|
||||
{
|
||||
UiBridge.Bridge.OnCameraInfo(this.cameraIdx, string.Format("{0} s/n {1} si simulated", Name, CameraCfg.HardwareAddress));
|
||||
UiBridge.Bridge.OnCameraInfo(cameraIdx, string.Format("{0} s/n {1} si simulated", Name, CameraCfg.HardwareAddress));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -181,7 +180,7 @@ namespace TBF.Rig.Network.Camera.CLP1611
|
||||
|
||||
if (cameraDetected)
|
||||
{
|
||||
UiBridge.Bridge.OnCameraInfo(this.cameraIdx, string.Format("{0} ver.{1} {2} s/n {3}", Name, sdCardVer, ipAddress, CameraCfg.HardwareAddress));
|
||||
UiBridge.Bridge.OnCameraInfo(cameraIdx, string.Format("{0} ver.{1} {2} s/n {3}", Name, sdCardVer, ipAddress, CameraCfg.HardwareAddress));
|
||||
|
||||
ClpUserName = (sdCardVer.Length > 0 && sdCardVer[0] == '1') ? "tbf" : "pi";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2019 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2019-2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -9,7 +9,7 @@ using TBF.Rig;
|
||||
|
||||
namespace TBF.Rig.TestMethods.Counter
|
||||
{
|
||||
public class TestMethod : ComponentBase, GenericDevices.ITestMethod
|
||||
public class TestMethod : ComponentBase, GenericDevices.ITestMethod, Generic.IDevice
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod));
|
||||
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
|
||||
@@ -27,12 +27,8 @@ namespace TBF.Rig.TestMethods.Counter
|
||||
/// Enumeration of counters via static fields and methods
|
||||
/// </summary>
|
||||
static int nextCounterIdx = 0;
|
||||
public static new void ResetStaticProperties()
|
||||
{
|
||||
nextCounterIdx = 0;
|
||||
}
|
||||
public static int CountersCount { get { return nextCounterIdx; } }
|
||||
public static TestMethod[] Counters;
|
||||
public static TestMethod[] Counters = new TestMethod[0];
|
||||
///
|
||||
private int counterIdx0; /// 0-based index of this counter
|
||||
|
||||
@@ -42,19 +38,30 @@ namespace TBF.Rig.TestMethods.Counter
|
||||
public TestMethod(Generic.IComponentCfg cfg)
|
||||
: base(cfg)
|
||||
{
|
||||
counterIdx0 = nextCounterIdx++;
|
||||
///
|
||||
if (Counters == null || Counters.Length < nextCounterIdx)
|
||||
{
|
||||
TestMethod[] contersSoFar = Counters;
|
||||
Counters = new TestMethod[nextCounterIdx];
|
||||
if (contersSoFar != null) for (int i = 0; i < contersSoFar.Length; i++) Counters[i] = contersSoFar[i];
|
||||
Counters[nextCounterIdx - 1] = this;
|
||||
}
|
||||
|
||||
log.Warn(this.ToString());
|
||||
}
|
||||
|
||||
///
|
||||
/// IDevice interface implementation
|
||||
///
|
||||
public void Initialize()
|
||||
{
|
||||
counterIdx0 = nextCounterIdx;
|
||||
nextCounterIdx++;
|
||||
///
|
||||
if (Counters.Length < nextCounterIdx)
|
||||
{
|
||||
var contersSoFar = Counters;
|
||||
Counters = new TestMethod[nextCounterIdx];
|
||||
for (int i = 0; i < contersSoFar.Length; i++) Counters[i] = contersSoFar[i];
|
||||
Counters[nextCounterIdx - 1] = this;
|
||||
}
|
||||
}
|
||||
public void RunDeviceBefore() { }
|
||||
public void RunDeviceAfter() { }
|
||||
public void StopDevice() { }
|
||||
public void StopDevice2() { }
|
||||
|
||||
public IList<Event> Execute(Test test, int repetNr, bool isLastRepetition)
|
||||
{
|
||||
return (new CounterSeq()).Execute(test, counterIdx0, repetNr, isLastRepetition, DebugLevel);
|
||||
|
||||
Reference in New Issue
Block a user