diff --git a/THermo.Active.Thermocamera/Properties/AssemblyInfo.cs b/THermo.Active.Thermocamera/Properties/AssemblyInfo.cs
index 3367c6c1..0cf1abc9 100644
--- a/THermo.Active.Thermocamera/Properties/AssemblyInfo.cs
+++ b/THermo.Active.Thermocamera/Properties/AssemblyInfo.cs
@@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
-[assembly: AssemblyTitle("THermo.Active.Thermocamera")]
+[assembly: AssemblyTitle("Thermo.Active.Thermocamera")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("THermo.Active.Thermocamera")]
+[assembly: AssemblyProduct("Thermo.Active.Thermocamera")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
diff --git a/THermo.Active.Thermocamera/Thermo.Active.Thermocamera.csproj b/THermo.Active.Thermocamera/Thermo.Active.Thermocamera.csproj
index 2f1da13a..4bb1df4c 100644
--- a/THermo.Active.Thermocamera/Thermo.Active.Thermocamera.csproj
+++ b/THermo.Active.Thermocamera/Thermo.Active.Thermocamera.csproj
@@ -7,8 +7,8 @@
{8D8EC91A-3A15-4A1D-951B-A35E7068DEBD}
Library
Properties
- THermo.Active.Thermocamera
- THermo.Active.Thermocamera
+ Thermo.Active.Thermocamera
+ Thermo.Active.Thermocamera
v4.6.2
512
true
@@ -44,8 +44,7 @@
-
-
+
diff --git a/THermo.Active.Thermocamera/Thermo.Active.Thermocamera.csproj.user b/THermo.Active.Thermocamera/Thermo.Active.Thermocamera.csproj.user
new file mode 100644
index 00000000..9b86104e
--- /dev/null
+++ b/THermo.Active.Thermocamera/Thermo.Active.Thermocamera.csproj.user
@@ -0,0 +1,6 @@
+
+
+
+ ShowAllFiles
+
+
\ No newline at end of file
diff --git a/THermo.Active.Thermocamera/ThermoCamComunicator.cs b/THermo.Active.Thermocamera/ThermoCamComunicator.cs
new file mode 100644
index 00000000..7f92f1ed
--- /dev/null
+++ b/THermo.Active.Thermocamera/ThermoCamComunicator.cs
@@ -0,0 +1,164 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using Thermo.Active.Model;
+using Thermo.Active.Model.DTOModels.ThWarmers;
+using Thermo.Cam.Utils;
+
+namespace Thermo.Active.Thermocamera
+{
+ public class ThermoCamComunicator
+ {
+ #region Private Fields
+
+ ///
+ /// istanza stsatica classe
+ ///
+ private static ThermoCamComunicator _instance;
+
+ #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
+ ///
+ protected TCContr TCamLive = new TCContr(BASE_PATH, BASE_PATH);
+
+ #endregion Protected Fields
+
+ #region Public Fields
+
+ public static readonly string BASE_PATH = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
+
+ #endregion Public Fields
+
+ #region Private Constructors
+
+ ///
+ /// init classe
+ ///
+ private ThermoCamComunicator()
+ {
+ // 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();
+ }
+
+ #endregion Private Constructors
+
+ #region Protected Methods
+
+ ///
+ /// Rilettura da file di tutti i dati
+ ///
+ /// Nome set file (originale + colorized + dati temperatura)
+ ///
+ protected bool loadData(string fileName)
+ {
+ bool done = false;
+ try
+ {
+ done = TCamFile.fileLoad(fileName);
+ }
+ catch
+ { }
+ return done;
+ }
+
+ #endregion Protected Methods
+
+ #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)
+ ///
+ /// Nome dei dati da leggere, se "" --> live
+ /// Dictionary id richiesta + punto (es canali + relativi punti medi come centro calcolato della resistenza di riferimento del canale)
+ /// Dizionario temperature come id + valore double in °C
+ ///
+ public bool readMultiTemperatures(string setName, Dictionary points, out Dictionary temp)
+ {
+ temp = new Dictionary();
+ List measData = new List();
+ // converto la richiesta in una lista di punti di misura...
+ List reqData = points.Select(item => new MeasurePoint()
+ {
+ Id = item.Key,
+ Coords = new System.Drawing.Point(item.Value.X, item.Value.Y),
+ Temperature = 0
+ }).ToList();
+ if (string.IsNullOrEmpty(setName) || setName == "_live")
+ {
+ // leggo valori!
+ measData = TCamLive.getPointsTemperature(false, reqData);
+ }
+ else
+ {
+ // carico file vari...
+ bool done = TCamFile.fileLoad(setName);
+ if (done)
+ {
+ // leggo valori!
+ measData = TCamFile.getPointsTemperature(false, reqData);
+ }
+ }
+ // converto valori nel formato finale
+ foreach (var item in measData)
+ {
+ temp.Add(item.Id, item.Temperature);
+ }
+ // fatto!
+ return true;
+ }
+
+ ///
+ /// Richiesta di acquisizione immagine FLIR (restituisce nome con cui sono stati salvati file)
+ ///
+ ///
+ public string takePicture()
+ {
+ string imgName = "";
+ try
+ {
+ // effettua chiamata x scattare immagine e SALVARE
+ TCamLive.takePicture();
+ TCamLive.calculateTarget();
+ imgName = TCamLive.fileSave();
+ }
+ catch
+ { }
+ return imgName;
+ }
+
+ #endregion Public Methods
+ }
+}
\ No newline at end of file
diff --git a/Thermo.Active.Core/ThreadsFunctions.cs b/Thermo.Active.Core/ThreadsFunctions.cs
index 57fa3178..e0f05095 100644
--- a/Thermo.Active.Core/ThreadsFunctions.cs
+++ b/Thermo.Active.Core/ThreadsFunctions.cs
@@ -21,7 +21,6 @@ using Thermo.Active.Model.DTOModels.ThProd;
using Thermo.Active.Model.DTOModels.ThRecipe;
using Thermo.Active.Model.DTOModels.ThWarmers;
using Thermo.Active.NC;
-using Thermo.Active.Thermocamera;
using Thermo.Active.Utils;
using static CMS_CORE_Library.Models.DataStructures;
using static Thermo.Active.Config.ServerConfig;
@@ -31,6 +30,7 @@ using System.Windows;
using System.Drawing;
using System.Configuration;
using Thermo.Active.Model.DTOModels.ThIO;
+using Thermo.Active.Thermocamera;
public static class ThreadsFunctions
{
@@ -51,8 +51,109 @@ public static class ThreadsFunctions
#endregion Public Fields
+ #region Internal Properties
+
+ ///
+ /// Swap x/y requesto from FLIR camera
+ ///
+ internal static bool cacheWarmers
+ {
+ get
+ {
+ bool answ = false;
+ bool.TryParse(ConfigurationManager.AppSettings["cacheWarmers"], out answ);
+ return answ;
+ }
+ }
+
+ #endregion Internal Properties
+
#region Private Methods
+ private static int CalcSleepTime(int maxSleep, int execTime)
+ {
+ int sleep = 0;
+ // Check if the execution time is greater than the half of the max sleep time
+ if (maxSleep - execTime < maxSleep / 2)
+ {
+ sleep = maxSleep;
+ }
+ else
+ {
+ sleep = maxSleep - execTime;
+ }
+
+ return sleep;
+ }
+
+ private static bool ClientIsRunning()
+ {
+ Process[] p = Process.GetProcessesByName(CLIENT_EXE_NAME_NOEXT);
+ foreach (Process pr in p)
+ {
+ if (pr.MainWindowHandle != IntPtr.Zero)
+ {
+ ShowWindow(pr.MainWindowHandle, 9);
+ SetForegroundWindow(pr.MainWindowHandle);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static void clientProcess()
+ {
+ string CMSClientPath = "";
+ // Check if the system is 64/32 bit
+ if (Environment.Is64BitOperatingSystem && File.Exists(CLIENT_PATH_64))
+ CMSClientPath = CLIENT_PATH_64;
+ else if (File.Exists(CLIENT_PATH_86))
+ CMSClientPath = CLIENT_PATH_86;
+
+ if (!String.IsNullOrEmpty(CMSClientPath))
+ {
+ Process pr = Process.Start(CMSClientPath, null);
+
+ if (ServerStartupConfig.AutoOpenCmsClient)
+ {
+ pr.WaitForExit();
+ MessageServices.Current.Publish(SEND_STOP_SERVER);
+ }
+ }
+ }
+
+ private static Dictionary GetPlcAlarmsTranslations(string language)
+ {
+ using (NcAdapter ncAdapter = new NcAdapter())
+ {
+ Dictionary returnValue = new Dictionary();
+
+ Dictionary messages = new Dictionary();
+ // Read data from CN
+ ncAdapter.numericalControl.NC_GetTranslatedPlcMessages(language, ref messages); // Avoid checking error because in the worst case "messages" is empty
+
+ // Id start from 1
+ for (int i = 1; i <= 1024; i++)
+ {
+ // Get configurated alarms
+ var tmpAlarmConfig = InitialAlarmsConfig.Where(x => x.PlcId == i).FirstOrDefault();
+ // Default string
+ string message = string.Format(NOT_CONFIGURATED_ALARM_MESSAGE, i);
+ // If is configurated
+ if (tmpAlarmConfig != null)
+ {
+ // Find translated string
+ message = messages.Where(x => x.Key == tmpAlarmConfig.AlarmId).FirstOrDefault().Value;
+ if (message == null)
+ message = string.Format(NOT_FOUND_ALARM_MESSAGE, i);
+ }
+ // Add to dictionary
+ returnValue.Add(i.ToString("D6") + "|900", message);
+ }
+ return returnValue;
+ }
+ }
+
///
/// restituisce il periodo di campionamento SE configurato, altrimenti 1000 ms
///
@@ -68,9 +169,106 @@ public static class ThreadsFunctions
return answ;
}
+ [DllImport("user32.dll")]
+ private static extern bool SetForegroundWindow(IntPtr hWnd);
+
+ [DllImport("user32.dll")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
+
+ private static void StatReset()
+ {
+ foreach (var value in Counter)
+ {
+ Timers[value.Key] = 0;
+ Counter[value.Key] = 0;
+ }
+ }
+
+ private static void TryNcConnection()
+ {
+ // Stop all the NC threads
+ ThreadsHandler.Stop();
+ StatReset();
+ NcAdapter ncAdapter = new NcAdapter();
+ CmsError libraryError = NO_ERROR;
+ // Run loop until NC is connected
+ while (!ncAdapter.numericalControl.NC_IsConnected())
+ {
+ // Try reconnection
+ libraryError = ncAdapter.Connect();
+ if (libraryError.errorCode == CMS_ERROR_CODES.SIEMENS_ENVIRONMENT_NOT_FOUND || libraryError.errorCode == CMS_ERROR_CODES.SIEMENS_HMI_NOT_RUNNING || libraryError.errorCode == CMS_ERROR_CODES.OSAI_TT_FOLDER_NOT_FOUND)
+ ManageLibraryError(libraryError);
+ else if (libraryError.errorCode != CMS_ERROR_CODES.OK)
+ {
+ ncAdapter.Dispose();
+ }
+
+ // Send status to UI
+ MessageServices.Current.Publish(SEND_NC_STATUS_UI, null, ncAdapter.numericalControl.NC_IsConnected());
+ // Send status to signalr
+ MessageServices.Current.Publish(SEND_NC_STATUS, null, ncAdapter.numericalControl.NC_IsConnected());
+
+ Thread.Sleep(1000);
+ }
+
+ if (!libraryError.IsError())
+ {
+ if (ServerStartupConfig.AutoOpenCmsClient)
+ StartCMSClient();
+
+ // Start/Restart NC threads
+ ThreadsHandler.StartWorkers();
+ reconnectionIsRunning = false;
+ }
+ }
+
#endregion Private Methods
- #region Functions
+ #region Internal Methods
+
+ internal static void StatThread()
+ {
+ while (true)
+ {
+ foreach (var value in Counter)
+ {
+ if (ThreadsHandler.RunningThreadStatus.ContainsKey(value.Key) && Counter[value.Key] != 0)
+ {
+ ThreadsHandler.RunningThreadStatus[value.Key] = $"{(Timers[value.Key] / Counter[value.Key])} ms x {Counter[value.Key]}";
+ Timers[value.Key] = 0;
+ Counter[value.Key] = 0;
+ }
+ }
+
+ MessageServices.Current.Publish(SEND_THREADS_STATUS, null, ThreadsHandler.RunningThreadStatus);
+
+ Thread.Sleep(2000);
+ }
+ }
+
+ internal static void UpdateStat(string functionName, long timer)
+ {
+ if (!Timers.ContainsKey(functionName))
+ Timers.TryAdd(functionName, timer);
+ else
+ Timers[functionName] += timer;
+
+ if (!Counter.ContainsKey(functionName))
+ Counter.TryAdd(functionName, 1);
+ else
+ Counter[functionName]++;
+ }
+
+ #endregion Internal Methods
+
+ #region Public Methods
+
+ public static void AbortNcConnection()
+ {
+ if (ConnThread != null && ConnThread.IsAlive)
+ ConnThread.Abort();
+ }
///
/// Manage action for conf request
@@ -138,7 +336,6 @@ public static class ThreadsFunctions
{
bool flirImageReq = false;
sw.Restart();
- int tOut = 30000;
// Check if client is connected
if (ncAdapter.numericalControl.NC_IsConnected())
@@ -154,7 +351,8 @@ public static class ThreadsFunctions
// if requested --> give ack!
ncAdapter.ManageFlirStrobe();
// requesto photo from library
- done = ThermocameraComunicator.getInstance().takePicture(tOut);
+ ncAdapter.lastThermoImage = ThermoCamComunicator.getIstance().takePicture();
+ done = !string.IsNullOrEmpty(ncAdapter.lastThermoImage);
if (done)
{
// init
@@ -163,7 +361,7 @@ public static class ThreadsFunctions
// recupero punti centrali resistenze
ncAdapter.GetWarmersChannelCenterPoints(out chPoints);
// richiesta temperature per i punti
- done = ThermocameraComunicator.getInstance().readMultiTemperatures(chPoints, tOut, out actualTemp);
+ done = ThermoCamComunicator.getIstance().readMultiTemperatures("", chPoints, out actualTemp);
// salvo dati temp sul PLC
ncAdapter.WriteRecipeWarmChTCamTempAct(actualTemp);
// give PLC strobe for uploaded Actual TEMP from image
@@ -188,6 +386,38 @@ public static class ThreadsFunctions
}
}
+ public static void ManageLibraryError(CmsError libraryError)
+ {
+ switch (libraryError.errorCode)
+ {
+ case CMS_ERROR_CODES.NC_PROD_ERROR:
+ ManageError(ERROR_LEVEL.WARNING, libraryError.localizationKey);
+ break;
+
+ case CMS_ERROR_CODES.NOT_CONNECTED:
+ RestoreConnection(); // If not connected try reconnection
+ break;
+
+ case CMS_ERROR_CODES.SIEMENS_ENVIRONMENT_NOT_FOUND:
+ case CMS_ERROR_CODES.OSAI_TT_FOLDER_NOT_FOUND:
+ case CMS_ERROR_CODES.OPTION_NOT_CONSISTENT:
+ ManageError(ERROR_LEVEL.FATAL, libraryError.localizationKey);
+ break;
+
+ case CMS_ERROR_CODES.SIEMENS_HMI_NOT_RUNNING:
+ ManageError(ERROR_LEVEL.FATAL, "SIEMENS HMI NOT RUNNING");
+ break;
+
+ case CMS_ERROR_CODES.SELECTED_PROCESS:
+ ManageError(ERROR_LEVEL.WARNING, libraryError.localizationKey);
+ break;
+
+ case CMS_ERROR_CODES.INTERNAL_ERROR:
+ ManageException(ERROR_LEVEL.FATAL, libraryError.exception);
+ break;
+ }
+ }
+
///
/// Manage status/command words for actions
///
@@ -413,6 +643,7 @@ public static class ThreadsFunctions
ncAdapter.Dispose();
}
}
+
///
/// Lettura valorichannelsIO
///
@@ -430,7 +661,6 @@ public static class ThreadsFunctions
while (true)
{
-
sw.Restart();
if (ncAdapter.numericalControl.NC_IsConnected())
@@ -1247,19 +1477,6 @@ public static class ThreadsFunctions
ncAdapter.Dispose();
}
}
- ///
- /// Swap x/y requesto from FLIR camera
- ///
- internal static bool cacheWarmers
- {
- get
- {
- bool answ = false;
- bool.TryParse(ConfigurationManager.AppSettings["cacheWarmers"], out answ);
- return answ;
- }
- }
-
public static void ReadWarmersData()
{
@@ -1313,6 +1530,21 @@ public static class ThreadsFunctions
}
}
+ public static void RestoreConnection()
+ {
+ if (reconnectionIsRunning == false)
+ { // Set thread as running state
+ reconnectionIsRunning = true;
+
+ // Start reconnection thread
+ ConnThread = new Thread(() =>
+ TryNcConnection()
+ );
+
+ ConnThread.Start();
+ }
+ }
+
public static void SetupCmsConnect()
{
NcAdapter ncAdapter = new NcAdapter();
@@ -1391,234 +1623,6 @@ public static class ThreadsFunctions
}
}
- #endregion Functions
-
- #region SupportFunctions
-
- private static int CalcSleepTime(int maxSleep, int execTime)
- {
- int sleep = 0;
- // Check if the execution time is greater than the half of the max sleep time
- if (maxSleep - execTime < maxSleep / 2)
- {
- sleep = maxSleep;
- }
- else
- {
- sleep = maxSleep - execTime;
- }
-
- return sleep;
- }
-
- private static bool ClientIsRunning()
- {
- Process[] p = Process.GetProcessesByName(CLIENT_EXE_NAME_NOEXT);
- foreach (Process pr in p)
- {
- if (pr.MainWindowHandle != IntPtr.Zero)
- {
- ShowWindow(pr.MainWindowHandle, 9);
- SetForegroundWindow(pr.MainWindowHandle);
- return true;
- }
- }
- return false;
- }
-
- private static void clientProcess()
- {
- string CMSClientPath = "";
- // Check if the system is 64/32 bit
- if (Environment.Is64BitOperatingSystem && File.Exists(CLIENT_PATH_64))
- CMSClientPath = CLIENT_PATH_64;
- else if (File.Exists(CLIENT_PATH_86))
- CMSClientPath = CLIENT_PATH_86;
-
- if (!String.IsNullOrEmpty(CMSClientPath))
- {
- Process pr = Process.Start(CMSClientPath, null);
-
- if (ServerStartupConfig.AutoOpenCmsClient)
- {
- pr.WaitForExit();
- MessageServices.Current.Publish(SEND_STOP_SERVER);
- }
- }
- }
-
- private static Dictionary GetPlcAlarmsTranslations(string language)
- {
- using (NcAdapter ncAdapter = new NcAdapter())
- {
- Dictionary returnValue = new Dictionary();
-
- Dictionary messages = new Dictionary();
- // Read data from CN
- ncAdapter.numericalControl.NC_GetTranslatedPlcMessages(language, ref messages); // Avoid checking error because in the worst case "messages" is empty
-
- // Id start from 1
- for (int i = 1; i <= 1024; i++)
- {
- // Get configurated alarms
- var tmpAlarmConfig = InitialAlarmsConfig.Where(x => x.PlcId == i).FirstOrDefault();
- // Default string
- string message = string.Format(NOT_CONFIGURATED_ALARM_MESSAGE, i);
- // If is configurated
- if (tmpAlarmConfig != null)
- {
- // Find translated string
- message = messages.Where(x => x.Key == tmpAlarmConfig.AlarmId).FirstOrDefault().Value;
- if (message == null)
- message = string.Format(NOT_FOUND_ALARM_MESSAGE, i);
- }
- // Add to dictionary
- returnValue.Add(i.ToString("D6") + "|900", message);
- }
- return returnValue;
- }
- }
-
- [DllImport("user32.dll")]
- private static extern bool SetForegroundWindow(IntPtr hWnd);
-
- [DllImport("user32.dll")]
- [return: MarshalAs(UnmanagedType.Bool)]
- private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
-
- private static void StatReset()
- {
- foreach (var value in Counter)
- {
- Timers[value.Key] = 0;
- Counter[value.Key] = 0;
- }
- }
-
- private static void TryNcConnection()
- {
- // Stop all the NC threads
- ThreadsHandler.Stop();
- StatReset();
- NcAdapter ncAdapter = new NcAdapter();
- CmsError libraryError = NO_ERROR;
- // Run loop until NC is connected
- while (!ncAdapter.numericalControl.NC_IsConnected())
- {
- // Try reconnection
- libraryError = ncAdapter.Connect();
- if (libraryError.errorCode == CMS_ERROR_CODES.SIEMENS_ENVIRONMENT_NOT_FOUND || libraryError.errorCode == CMS_ERROR_CODES.SIEMENS_HMI_NOT_RUNNING || libraryError.errorCode == CMS_ERROR_CODES.OSAI_TT_FOLDER_NOT_FOUND)
- ManageLibraryError(libraryError);
- else if (libraryError.errorCode != CMS_ERROR_CODES.OK)
- {
- ncAdapter.Dispose();
- }
-
- // Send status to UI
- MessageServices.Current.Publish(SEND_NC_STATUS_UI, null, ncAdapter.numericalControl.NC_IsConnected());
- // Send status to signalr
- MessageServices.Current.Publish(SEND_NC_STATUS, null, ncAdapter.numericalControl.NC_IsConnected());
-
- Thread.Sleep(1000);
- }
-
- if (!libraryError.IsError())
- {
- if (ServerStartupConfig.AutoOpenCmsClient)
- StartCMSClient();
-
- // Start/Restart NC threads
- ThreadsHandler.StartWorkers();
- reconnectionIsRunning = false;
- }
- }
-
- internal static void StatThread()
- {
- while (true)
- {
- foreach (var value in Counter)
- {
- if (ThreadsHandler.RunningThreadStatus.ContainsKey(value.Key) && Counter[value.Key] != 0)
- {
- ThreadsHandler.RunningThreadStatus[value.Key] = $"{(Timers[value.Key] / Counter[value.Key])} ms x {Counter[value.Key]}";
- Timers[value.Key] = 0;
- Counter[value.Key] = 0;
- }
- }
-
- MessageServices.Current.Publish(SEND_THREADS_STATUS, null, ThreadsHandler.RunningThreadStatus);
-
- Thread.Sleep(2000);
- }
- }
-
- internal static void UpdateStat(string functionName, long timer)
- {
- if (!Timers.ContainsKey(functionName))
- Timers.TryAdd(functionName, timer);
- else
- Timers[functionName] += timer;
-
- if (!Counter.ContainsKey(functionName))
- Counter.TryAdd(functionName, 1);
- else
- Counter[functionName]++;
- }
-
- public static void AbortNcConnection()
- {
- if (ConnThread != null && ConnThread.IsAlive)
- ConnThread.Abort();
- }
-
- public static void ManageLibraryError(CmsError libraryError)
- {
- switch (libraryError.errorCode)
- {
- case CMS_ERROR_CODES.NC_PROD_ERROR:
- ManageError(ERROR_LEVEL.WARNING, libraryError.localizationKey);
- break;
-
- case CMS_ERROR_CODES.NOT_CONNECTED:
- RestoreConnection(); // If not connected try reconnection
- break;
-
- case CMS_ERROR_CODES.SIEMENS_ENVIRONMENT_NOT_FOUND:
- case CMS_ERROR_CODES.OSAI_TT_FOLDER_NOT_FOUND:
- case CMS_ERROR_CODES.OPTION_NOT_CONSISTENT:
- ManageError(ERROR_LEVEL.FATAL, libraryError.localizationKey);
- break;
-
- case CMS_ERROR_CODES.SIEMENS_HMI_NOT_RUNNING:
- ManageError(ERROR_LEVEL.FATAL, "SIEMENS HMI NOT RUNNING");
- break;
-
- case CMS_ERROR_CODES.SELECTED_PROCESS:
- ManageError(ERROR_LEVEL.WARNING, libraryError.localizationKey);
- break;
-
- case CMS_ERROR_CODES.INTERNAL_ERROR:
- ManageException(ERROR_LEVEL.FATAL, libraryError.exception);
- break;
- }
- }
-
- public static void RestoreConnection()
- {
- if (reconnectionIsRunning == false)
- { // Set thread as running state
- reconnectionIsRunning = true;
-
- // Start reconnection thread
- ConnThread = new Thread(() =>
- TryNcConnection()
- );
-
- ConnThread.Start();
- }
- }
-
public static void StartCMSClient()
{
//Setup the Path Variable
@@ -1629,5 +1633,5 @@ public static class ThreadsFunctions
}
}
- #endregion SupportFunctions
+ #endregion Public Methods
}
\ No newline at end of file
diff --git a/Thermo.Active.NC/NcAdapter.cs b/Thermo.Active.NC/NcAdapter.cs
index 06d9fd01..49034447 100644
--- a/Thermo.Active.NC/NcAdapter.cs
+++ b/Thermo.Active.NC/NcAdapter.cs
@@ -100,11 +100,6 @@ namespace Thermo.Active.NC
///
protected DateTime lastProdStart;
- ///
- /// ultima immagine scattata dalla thermocam x salvataggio in PROD
- ///
- protected string lastThermoImage = "_last.jpg";
-
#endregion Protected Fields
#region Public Fields
@@ -119,6 +114,11 @@ namespace Thermo.Active.NC
///
public static LiveData RecipeLiveData = new LiveData();
+ ///
+ /// ultima immagine scattata dalla thermocam x salvataggio in PROD
+ ///
+ public string lastThermoImage = "_last";
+
///
/// Avvio prod lotto
///
diff --git a/Thermo.Active/Controllers/WebApi/ThermocameraController.cs b/Thermo.Active/Controllers/WebApi/ThermocameraController.cs
deleted file mode 100644
index d67025bd..00000000
--- a/Thermo.Active/Controllers/WebApi/ThermocameraController.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using CMS_CORE_Library.Models;
-using System;
-using System.Collections.Generic;
-using System.Web.Http;
-using System.Web.Http.Description;
-using Thermo.Active.Model.DTOModels.ThWarmers;
-using Thermo.Active.NC;
-using Thermo.Active.Provider;
-using Thermo.Active.Thermocamera;
-using Thermo.Active.Utils;
-using static Thermo.Active.Config.ServerConfig;
-using static Thermo.Active.Model.Constants;
-
-namespace Thermo.Active.Controllers.WebApi
-{
- // FIXME TODO ELIMINARE CLASSE!!!
-
- [RoutePrefix("api/thermocamera")]
- public class ThermocameraController : ApiController
- {
- #region Public Methods
-
- [Route("show"), HttpPost]
- public IHttpActionResult showCamera()
- {
- String ThermoCameraXpos = AdditionalParametersConfig["ThermoCameraXpos"];
- String ThermoCameraYpos = AdditionalParametersConfig["ThermoCameraYpos"];
- String ThermoCameraXdim = AdditionalParametersConfig["ThermoCameraXdim"];
- String ThermoCameraYdim = AdditionalParametersConfig["ThermoCameraYdim"];
- if (ThermoCameraXpos != null && ThermoCameraYpos != null && ThermoCameraXdim != null && ThermoCameraYdim != null)
- {
- if (ThermocameraComunicator.getInstance().showWindow(Int32.Parse(ThermoCameraXpos), Int32.Parse(ThermoCameraYpos), Int32.Parse(ThermoCameraXdim), Int32.Parse(ThermoCameraYdim), 3000))
- return Ok();
- else
- return BadRequest();
- }
- return BadRequest();
- }
-
- #endregion Public Methods
- }
-}
\ No newline at end of file
diff --git a/Thermo.Active/Thermo.Active.csproj b/Thermo.Active/Thermo.Active.csproj
index fd9973eb..ec50d299 100644
--- a/Thermo.Active/Thermo.Active.csproj
+++ b/Thermo.Active/Thermo.Active.csproj
@@ -228,7 +228,6 @@
-