75 lines
2.4 KiB
C#
75 lines
2.4 KiB
C#
///
|
|
/// Copyright (c) 2015 Sensus Metering Systems
|
|
/// Author: Milan Hanajík
|
|
///
|
|
using System;
|
|
using System.IO.Ports;
|
|
using System.Collections.Generic;
|
|
using log4net;
|
|
using TBF.BenchControl;
|
|
|
|
namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
|
{
|
|
public class TestMethod : ComponentBase, GenericDevices.ITestMethod, Generic.IDevice
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod));
|
|
protected static readonly ILog rfidDataLogger = LogManager.GetLogger("RfidData");
|
|
|
|
public override string ToString() { return string.Format("TestMethods.Adjustment({0})", Cfg.ToString(1)); }
|
|
|
|
readonly TestMethodCfg testMethodCfg;
|
|
|
|
public bool Evaluate { get { return false; } }
|
|
public bool Publish { get { return false; } }
|
|
public bool CanTest(Entities.MetersKind meters) { return meters == Entities.MetersKind.Single; }
|
|
|
|
public TestMethod()
|
|
{
|
|
}
|
|
|
|
public TestMethod(TestMethodCfg cfg)
|
|
: base(cfg)
|
|
{
|
|
testMethodCfg = cfg;
|
|
log.Debug(this.ToString());
|
|
}
|
|
|
|
public void Initialize()
|
|
{
|
|
if (DebugLevel == Entities.DebugMode.Normal)
|
|
{
|
|
/// Check whether RFID serial ports are free
|
|
SerialPort rfidPort;
|
|
rfidPort = new SerialPort(string.Format("COM{0}", testMethodCfg.RfidPortNrBoard1), 9600, Parity.None, 8, StopBits.One);
|
|
rfidPort.Open();
|
|
rfidPort.Close();
|
|
|
|
rfidPort = new SerialPort(string.Format("COM{0}", testMethodCfg.RfidPortNrBoard2), 9600, Parity.None, 8, StopBits.One);
|
|
rfidPort.Open();
|
|
rfidPort.Close();
|
|
|
|
rfidPort = new SerialPort(string.Format("COM{0}", testMethodCfg.RfidPortNrBoard3), 9600, Parity.None, 8, StopBits.One);
|
|
rfidPort.Open();
|
|
rfidPort.Close();
|
|
|
|
rfidPort = new SerialPort(string.Format("COM{0}", testMethodCfg.RfidPortNrBoard4), 9600, Parity.None, 8, StopBits.One);
|
|
rfidPort.Open();
|
|
rfidPort.Close();
|
|
}
|
|
|
|
Version ver = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
|
|
rfidDataLogger.Fatal("------------------------------------------------------------------------");
|
|
rfidDataLogger.FatalFormat("Test Bench Framework ver. {0}.{1}.{2}", ver.Major, ver.Minor, ver.Build);
|
|
}
|
|
|
|
public void RunDeviceBefore() { }
|
|
public void RunDeviceAfter() { }
|
|
public void StopDevice() { }
|
|
|
|
public IList<Event> Execute(Entities.Test test)
|
|
{
|
|
return (new iPerlCommunicationSeq()).Execute(test, testMethodCfg, testMethodCfg.TestParams);
|
|
}
|
|
}
|
|
}
|