diff --git a/THermo.Active.Thermocamera/ThermoCamComunicator.cs b/THermo.Active.Thermocamera/ThermoCamComunicator.cs
index 7f92f1ed..6228160c 100644
--- a/THermo.Active.Thermocamera/ThermoCamComunicator.cs
+++ b/THermo.Active.Thermocamera/ThermoCamComunicator.cs
@@ -16,21 +16,16 @@ namespace Thermo.Active.Thermocamera
#region Private Fields
///
- /// istanza stsatica classe
+ /// Nome file da caricare (per istanza file-based)
///
- private static ThermoCamComunicator _instance;
+ private string fileName = "";
#endregion Private Fields
#region Protected Fields
///
- /// Classe gestione dati ThermoCam da file (oggetti Image + temperature calcolate in .dat)
- ///
- protected TCContr TCamFile = new TCContr(BASE_PATH, BASE_PATH);
-
- ///
- /// Classe gestione LIVE ThermoCam (oggetti Image, metodi processing...) x FlirCam
+ /// Classe gestione ThermoCam (oggetti Image, metodi processing...)
///
protected TCContr TCamLive = new TCContr(BASE_PATH, BASE_PATH);
@@ -45,21 +40,22 @@ namespace Thermo.Active.Thermocamera
#region Private Constructors
///
- /// init classe
+ /// Init classe
///
- private ThermoCamComunicator()
+ /// Indica aabilitazione alive straming vs load dati storici
+ public ThermoCamComunicator(bool isLive)
{
// init classe controllo camera
TCamLive = new TCContr($"{BASE_PATH}\\{Constants.THERMO_DATA_FOLDER}", $"{BASE_PATH}\\{Constants.CONFIG_DIRECTORY}");
- // init classe gestione file
- TCamFile = new TCContr($"{BASE_PATH}\\{Constants.THERMO_DATA_FOLDER}", $"{BASE_PATH}\\{Constants.CONFIG_DIRECTORY}");
// avvio classe gestione thermocamera...
TCamLive.tryReloadConf();
- TCamFile.tryReloadConf();
- // SOLO PER IL LIVE --> cerco camera
- TCamLive.discoveryCamera();
+ if (isLive)
+ {
+ // SOLO PER IL LIVE --> cerco camera
+ TCamLive.discoveryCamera();
+ }
}
#endregion Private Constructors
@@ -76,7 +72,7 @@ namespace Thermo.Active.Thermocamera
bool done = false;
try
{
- done = TCamFile.fileLoad(fileName);
+ done = TCamLive.fileLoad(fileName);
}
catch
{ }
@@ -87,17 +83,6 @@ namespace Thermo.Active.Thermocamera
#region Public Methods
- ///
- /// accesso esterno classe comunicazione
- ///
- ///
- public static ThermoCamComunicator getIstance()
- {
- if (_instance == null)
- _instance = new ThermoCamComunicator();
- return _instance;
- }
-
///
/// Restituisce lettura di tutti i punti richiesti (es centroidi riscaldi)
///
@@ -116,21 +101,17 @@ namespace Thermo.Active.Thermocamera
Coords = new System.Drawing.Point(item.Value.X, item.Value.Y),
Temperature = 0
}).ToList();
+ bool done = false;
if (string.IsNullOrEmpty(setName) || setName == "_live")
{
- // leggo valori!
- measData = TCamLive.getPointsTemperature(false, reqData);
+ done = true;
}
else
{
// carico file vari...
- bool done = TCamFile.fileLoad(setName);
- if (done)
- {
- // leggo valori!
- measData = TCamFile.getPointsTemperature(false, reqData);
- }
+ done = TCamLive.fileLoad(setName);
}
+ measData = TCamLive.getPointsTemperature(false, reqData);
// converto valori nel formato finale
foreach (var item in measData)
{
diff --git a/Thermo.Active.Core/ThreadsFunctions.cs b/Thermo.Active.Core/ThreadsFunctions.cs
index e0f05095..4d718f0c 100644
--- a/Thermo.Active.Core/ThreadsFunctions.cs
+++ b/Thermo.Active.Core/ThreadsFunctions.cs
@@ -324,6 +324,7 @@ public static class ThreadsFunctions
public static void ManageFlirCamera()
{
NcAdapter ncAdapter = new NcAdapter();
+ ThermoCamComunicator TCCom = new ThermoCamComunicator(true);
Stopwatch sw = new Stopwatch();
try
{
@@ -351,7 +352,7 @@ public static class ThreadsFunctions
// if requested --> give ack!
ncAdapter.ManageFlirStrobe();
// requesto photo from library
- ncAdapter.lastThermoImage = ThermoCamComunicator.getIstance().takePicture();
+ ncAdapter.lastThermoImage = TCCom.takePicture();
done = !string.IsNullOrEmpty(ncAdapter.lastThermoImage);
if (done)
{
@@ -361,7 +362,7 @@ public static class ThreadsFunctions
// recupero punti centrali resistenze
ncAdapter.GetWarmersChannelCenterPoints(out chPoints);
// richiesta temperature per i punti
- done = ThermoCamComunicator.getIstance().readMultiTemperatures("", chPoints, out actualTemp);
+ done = TCCom.readMultiTemperatures("", chPoints, out actualTemp);
// salvo dati temp sul PLC
ncAdapter.WriteRecipeWarmChTCamTempAct(actualTemp);
// give PLC strobe for uploaded Actual TEMP from image
diff --git a/Thermo.Cam.Utils/TCContr.cs b/Thermo.Cam.Utils/TCContr.cs
index 224c7d9a..714fdcf3 100644
--- a/Thermo.Cam.Utils/TCContr.cs
+++ b/Thermo.Cam.Utils/TCContr.cs
@@ -443,6 +443,7 @@ namespace Thermo.Cam.Utils
public void discoveryCamera()
{
+ try {
// se no connesso così prosegue...
if (!IRCam.ThermoCamera.IsConnected)
{
@@ -454,6 +455,11 @@ namespace Thermo.Cam.Utils
DiscoThread.Start();
}
}
+ }
+ catch(Exception exc)
+ {
+ Console.WriteLine($"EXCEPTION discoveryCamera: {Environment.NewLine}{exc}");
+ }
}
public void DisposeCamera()