fix classe ThermoCamController x live, da testare dll FLIR
This commit is contained in:
@@ -16,21 +16,16 @@ namespace Thermo.Active.Thermocamera
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// istanza stsatica classe
|
||||
/// Nome file da caricare (per istanza file-based)
|
||||
/// </summary>
|
||||
private static ThermoCamComunicator _instance;
|
||||
private string fileName = "";
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
/// <summary>
|
||||
/// Classe gestione dati ThermoCam da file (oggetti Image + temperature calcolate in .dat)
|
||||
/// </summary>
|
||||
protected TCContr TCamFile = new TCContr(BASE_PATH, BASE_PATH);
|
||||
|
||||
/// <summary>
|
||||
/// Classe gestione LIVE ThermoCam (oggetti Image, metodi processing...) x FlirCam
|
||||
/// Classe gestione ThermoCam (oggetti Image, metodi processing...)
|
||||
/// </summary>
|
||||
protected TCContr TCamLive = new TCContr(BASE_PATH, BASE_PATH);
|
||||
|
||||
@@ -45,21 +40,22 @@ namespace Thermo.Active.Thermocamera
|
||||
#region Private Constructors
|
||||
|
||||
/// <summary>
|
||||
/// init classe
|
||||
/// Init classe
|
||||
/// </summary>
|
||||
private ThermoCamComunicator()
|
||||
/// <param name="isLive">Indica aabilitazione alive straming vs load dati storici</param>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// accesso esterno classe comunicazione
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static ThermoCamComunicator getIstance()
|
||||
{
|
||||
if (_instance == null)
|
||||
_instance = new ThermoCamComunicator();
|
||||
return _instance;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce lettura di tutti i punti richiesti (es centroidi riscaldi)
|
||||
/// </summary>
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user