Initialization of 30 components changed, done in Initialize( ).

This commit is contained in:
Milan Hanajik
2021-04-03 00:54:27 +02:00
parent cb1a66381f
commit a58fe1f997
30 changed files with 347 additions and 445 deletions
@@ -359,28 +359,22 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
private SerialPort optoSerialPort;
public IperlHead()
{
}
public IperlHead() { }
public IperlHead(Generic.IComponentCfg cfg)
: base(cfg)
{
flowDirectionDetection = new FlowDirectionDetection();
ClearData();
iperlHeadCfg = cfg as IperlHeadCfg;
log.Warn(this.ToString());
}
public void Initialize()
public override void Initialize()
{
ClearData();
optoSerialPortParsingEnabled = false;
flowDirectionDetection = new FlowDirectionDetection();
/// Allocate memory for opto-data from iPerl
optoData = new OptoTelegramRaw[MaxOptoDataCount];
for (int i = 0; i < MaxOptoDataCount; i++) optoData[i] = new OptoTelegramRaw();
@@ -394,11 +388,16 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
if (DebugLevel == DebugMode.Normal)
{
/// Prepare serial port
optoSerialPort = new SerialPort(string.Format("COM{0}", iperlHeadCfg.OptoComPortNr),
9600, Parity.None, 8, StopBits.One);
string portName = string.Format("COM{0}", iperlHeadCfg.OptoComPortNr);
optoSerialPort = new SerialPort(portName, 9600, Parity.None, 8, StopBits.One);
optoSerialPort.Handshake = Handshake.None;
optoSerialPort.Open();
log.FatalFormat("{0} - Device successfully initialized", Name);
}
else
{
optoSerialPort = null;
log.FatalFormat("{0} - Device simulated", Name);
}
}