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
+17 -31
View File
@@ -72,9 +72,7 @@ namespace TBF.Rig.RegisterReaders.KPackE.Radio
public IReceivesDataFromRadio EntryForm;
public Radio()
{
}
public Radio() { }
/// <summary>
/// Ambient temperature / humidity / pressure meter 'Greco' connected via serial interface (RS232)
@@ -83,41 +81,29 @@ namespace TBF.Rig.RegisterReaders.KPackE.Radio
public Radio(Generic.IComponentCfg cfg)
: base(cfg)
{
RegReaders = new List<RegisterReader.RegisterReader>();
serialPort = null;
radioCfg = cfg as RadioCfg;
data = new List<byte>();
log.Warn(this.ToString());
}
~Radio()
public override void Initialize()
{
}
public void Initialize()
{
if (radioCfg.DebugLevel == DebugMode.Simulate)
{
serialPort = null;
log.FatalFormat("{0} - Device simulated", Name);
return;
}
RegReaders = new List<RegisterReader.RegisterReader>();
data = new List<byte>();
lastTelegramReceived = DateTime.MinValue;
string comPortName = "COM" + radioCfg.ComPortNr.ToString();
serialPort = new SerialPort(comPortName, radioCfg.BaudRate, radioCfg.Parity, radioCfg.DataBits, radioCfg.StopBits);
serialPort.Handshake = radioCfg.Handshake;
serialPort.Open();
//stopWorkerThread = false;
//workerThread = new Thread(Worker);
//workerThread.Start();
log.FatalFormat("{0} - Device successfully initialized", Name);
if (radioCfg.DebugLevel == DebugMode.Simulate)
{
serialPort = null;
log.FatalFormat("{0} - Device simulated", Name);
}
else
{
string portName = "COM" + radioCfg.ComPortNr.ToString();
serialPort = new SerialPort(portName, radioCfg.BaudRate, radioCfg.Parity, radioCfg.DataBits, radioCfg.StopBits);
serialPort.Handshake = radioCfg.Handshake;
serialPort.Open();
log.FatalFormat("{0} - Device successfully initialized", Name);
}
}