2015-08-11 06:50:32 +00:00
|
|
|
|
///
|
2020-04-27 10:24:54 +00:00
|
|
|
|
/// Copyright (c) 2015-2020 Sensus Slovensko a.s.
|
2015-08-11 06:50:32 +00:00
|
|
|
|
///
|
|
|
|
|
|
using System;
|
2015-08-27 17:30:22 +00:00
|
|
|
|
using System.IO.Ports;
|
2015-08-11 06:50:32 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using log4net;
|
2015-12-04 16:17:20 +00:00
|
|
|
|
using Config.Entities;
|
2015-08-11 06:50:32 +00:00
|
|
|
|
using TBF.BenchControl;
|
|
|
|
|
|
|
|
|
|
|
|
namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
|
|
|
|
|
{
|
2015-09-04 11:49:04 +00:00
|
|
|
|
public class TestMethod : ComponentBase, GenericDevices.ISimultTestMethod, Generic.IDevice
|
2015-08-11 06:50:32 +00:00
|
|
|
|
{
|
|
|
|
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod));
|
2015-08-15 21:01:26 +00:00
|
|
|
|
protected static readonly ILog rfidDataLogger = LogManager.GetLogger("RfidData");
|
2018-04-27 12:08:34 +00:00
|
|
|
|
|
2020-05-14 08:44:36 +00:00
|
|
|
|
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(1)); }
|
2015-08-11 06:50:32 +00:00
|
|
|
|
|
2017-07-25 13:10:06 +00:00
|
|
|
|
public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; }
|
2017-12-02 16:54:38 +00:00
|
|
|
|
public bool DoTransitions() { return false; }
|
2020-05-14 08:44:36 +00:00
|
|
|
|
public bool CheckDeviceCaps(Test test, OutputPath devices, out string message)
|
|
|
|
|
|
{
|
|
|
|
|
|
message = string.Format("{0}: CheckDeviceCaps() is not implemented yet", Name);
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2017-07-25 13:10:06 +00:00
|
|
|
|
|
2015-08-11 06:50:32 +00:00
|
|
|
|
|
2015-09-04 11:49:04 +00:00
|
|
|
|
public bool SimultWithPrevious { get { return testMethodCfg.TestParams.SimultWithPrevious; } }
|
|
|
|
|
|
public bool SimultWithNext { get { return testMethodCfg.TestParams.SimultWithNext; } }
|
2015-09-06 20:21:54 +00:00
|
|
|
|
|
2020-04-27 10:24:54 +00:00
|
|
|
|
#region Configuration Change Handling
|
|
|
|
|
|
|
|
|
|
|
|
public static void OnCfgChange(object sender, CfgChangeArgs args)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (CfgChangeHandler == null) return;
|
|
|
|
|
|
try { CfgChangeHandler(sender, args); }
|
|
|
|
|
|
catch (Exception e) { log.Error("CfgChangeHandler(...) failed", e); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static event EventHandler<CfgChangeArgs> CfgChangeHandler;
|
|
|
|
|
|
|
|
|
|
|
|
public override void StartChangeHandler()
|
|
|
|
|
|
{
|
|
|
|
|
|
CfgChangeHandler += delegate(object sender, CfgChangeArgs args)
|
|
|
|
|
|
{
|
|
|
|
|
|
TestMethodCfg tmpCfg = args.Cfg as TestMethodCfg;
|
|
|
|
|
|
if (tmpCfg != null && tmpCfg.Name.Equals(Name))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (args.Command == CfgChangeCmd.CfgChange)
|
|
|
|
|
|
{
|
|
|
|
|
|
testMethodCfg.CommTimeout = tmpCfg.CommTimeout;
|
|
|
|
|
|
testMethodCfg.DelayBetweenRetries = tmpCfg.DelayBetweenRetries;
|
|
|
|
|
|
testMethodCfg.MaxCommRetries = tmpCfg.MaxCommRetries;
|
|
|
|
|
|
testMethodCfg.IperlCheckErrorsToStop = tmpCfg.IperlCheckErrorsToStop;
|
|
|
|
|
|
testMethodCfg.UseWebService = tmpCfg.UseWebService;
|
|
|
|
|
|
testMethodCfg.BaseUrl = tmpCfg.BaseUrl;
|
|
|
|
|
|
testMethodCfg.RelativeUrl = tmpCfg.RelativeUrl;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion Configuration Change Handling
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-05-14 08:44:36 +00:00
|
|
|
|
readonly TestMethodCfg testMethodCfg;
|
2015-08-11 06:50:32 +00:00
|
|
|
|
|
2020-05-14 08:44:36 +00:00
|
|
|
|
public TestMethod() { }
|
|
|
|
|
|
///
|
|
|
|
|
|
public TestMethod(Generic.IComponentCfg cfg)
|
2015-08-11 06:50:32 +00:00
|
|
|
|
: base(cfg)
|
|
|
|
|
|
{
|
2016-08-05 12:32:36 +00:00
|
|
|
|
testMethodCfg = cfg as TestMethodCfg;
|
2021-02-19 08:48:00 +00:00
|
|
|
|
log.Warn(this.ToString());
|
2015-08-11 06:50:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-04-27 10:24:54 +00:00
|
|
|
|
/// IDevice interface - only Initialize() is used
|
2015-08-15 21:01:26 +00:00
|
|
|
|
public void Initialize()
|
|
|
|
|
|
{
|
2015-12-04 16:17:20 +00:00
|
|
|
|
if (DebugLevel == DebugMode.Normal)
|
2015-08-27 17:30:22 +00:00
|
|
|
|
{
|
|
|
|
|
|
/// Check whether RFID serial ports are free
|
|
|
|
|
|
SerialPort rfidPort;
|
2016-04-19 08:10:51 +00:00
|
|
|
|
if (testMethodCfg.RfidPortNrBoard1 != 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
rfidPort = new SerialPort(string.Format("COM{0}", testMethodCfg.RfidPortNrBoard1), 9600, Parity.None, 8, StopBits.One);
|
|
|
|
|
|
rfidPort.Open();
|
|
|
|
|
|
rfidPort.Close();
|
|
|
|
|
|
}
|
2015-08-27 17:30:22 +00:00
|
|
|
|
|
2016-04-19 08:10:51 +00:00
|
|
|
|
if (testMethodCfg.RfidPortNrBoard2 != 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
rfidPort = new SerialPort(string.Format("COM{0}", testMethodCfg.RfidPortNrBoard2), 9600, Parity.None, 8, StopBits.One);
|
|
|
|
|
|
rfidPort.Open();
|
|
|
|
|
|
rfidPort.Close();
|
|
|
|
|
|
}
|
2015-08-27 17:30:22 +00:00
|
|
|
|
|
2016-04-19 08:10:51 +00:00
|
|
|
|
if (testMethodCfg.RfidPortNrBoard3 != 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
rfidPort = new SerialPort(string.Format("COM{0}", testMethodCfg.RfidPortNrBoard3), 9600, Parity.None, 8, StopBits.One);
|
|
|
|
|
|
rfidPort.Open();
|
|
|
|
|
|
rfidPort.Close();
|
|
|
|
|
|
}
|
2015-08-27 17:30:22 +00:00
|
|
|
|
|
2016-04-19 08:10:51 +00:00
|
|
|
|
if (testMethodCfg.RfidPortNrBoard4 != 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
rfidPort = new SerialPort(string.Format("COM{0}", testMethodCfg.RfidPortNrBoard4), 9600, Parity.None, 8, StopBits.One);
|
|
|
|
|
|
rfidPort.Open();
|
|
|
|
|
|
rfidPort.Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2015-08-27 17:30:22 +00:00
|
|
|
|
|
2015-08-15 21:01:26 +00:00
|
|
|
|
rfidDataLogger.Fatal("------------------------------------------------------------------------");
|
2015-12-20 12:26:33 +00:00
|
|
|
|
rfidDataLogger.FatalFormat("Test Bench Framework ver. {0}", Program.Version);
|
2020-04-27 10:24:54 +00:00
|
|
|
|
}
|
2015-08-15 21:01:26 +00:00
|
|
|
|
|
2020-04-27 10:24:54 +00:00
|
|
|
|
/// IDevice interface - only Initialize() is used
|
2015-08-15 21:01:26 +00:00
|
|
|
|
public void RunDeviceBefore() { }
|
|
|
|
|
|
public void RunDeviceAfter() { }
|
|
|
|
|
|
public void StopDevice() { }
|
2017-12-05 18:26:07 +00:00
|
|
|
|
public void StopDevice2() { }
|
2015-08-15 21:01:26 +00:00
|
|
|
|
|
2017-12-02 16:54:38 +00:00
|
|
|
|
public IList<Event> Execute(Test test, int repetNr, bool isLastRepetition)
|
2015-08-11 06:50:32 +00:00
|
|
|
|
{
|
2017-12-02 16:54:38 +00:00
|
|
|
|
return (new iPerlCommunicationSeq()).Execute(test, repetNr, testMethodCfg, testMethodCfg.TestParams);
|
2015-08-11 06:50:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|