diff --git a/Thermo.Active.Config/Config/serverConfig.xml b/Thermo.Active.Config/Config/serverConfig.xml index 97876e61..5dd5779f 100644 --- a/Thermo.Active.Config/Config/serverConfig.xml +++ b/Thermo.Active.Config/Config/serverConfig.xml @@ -113,6 +113,10 @@ RangeTempMax 100 + + EnableThermocam + true + diff --git a/Thermo.Active.Core/ThreadsFunctions.cs b/Thermo.Active.Core/ThreadsFunctions.cs index 3fc853e5..477a3145 100644 --- a/Thermo.Active.Core/ThreadsFunctions.cs +++ b/Thermo.Active.Core/ThreadsFunctions.cs @@ -339,67 +339,72 @@ public static class ThreadsFunctions public static void ManageFlirCamera() { NcAdapter ncAdapter = new NcAdapter(); - ThermoCamComunicator TCCom = new ThermoCamComunicator(true); - Stopwatch sw = new Stopwatch(); - try + // verifica abilitazione thermocam + if (NcAdapter.EnableThermocam) { - // Try connection - CmsError libraryError = ncAdapter.Connect(); - if (libraryError.errorCode != 0) - ManageLibraryError(libraryError); - - while (true) + // avvio oggetto thermocam + ThermoCamComunicator TCCom = new ThermoCamComunicator(true); + Stopwatch sw = new Stopwatch(); + try { - bool flirImageReq = false; - sw.Restart(); + // Try connection + CmsError libraryError = ncAdapter.Connect(); + if (libraryError.errorCode != 0) + ManageLibraryError(libraryError); - // Check if client is connected - if (ncAdapter.numericalControl.NC_IsConnected()) + while (true) { - // check if there is a photo request pending - libraryError = ncAdapter.checkFlirImageRequest(out flirImageReq); - if (libraryError.IsError()) - ManageLibraryError(libraryError); + bool flirImageReq = false; + sw.Restart(); - if (flirImageReq) + // Check if client is connected + if (ncAdapter.numericalControl.NC_IsConnected()) { - bool done = false; - // if requested --> give ack! - ncAdapter.ManageFlirStrobe(); - // requesto photo from library - NcAdapter.lastThermoImage = TCCom.takePicture(); - done = !string.IsNullOrEmpty(NcAdapter.lastThermoImage); - if (done) + // check if there is a photo request pending + libraryError = ncAdapter.checkFlirImageRequest(out flirImageReq); + if (libraryError.IsError()) + ManageLibraryError(libraryError); + + if (flirImageReq) { - // init - List measuredpoints = new List(); - Dictionary actualTemp = new Dictionary(); - Dictionary chPoints = new Dictionary(); - // recupero punti centrali resistenze - ncAdapter.GetWarmersChannelCenterPoints(out chPoints); - // richiesta temperature per i punti - done = TCCom.readMultiTemperatures("", chPoints, out measuredpoints); - // converto in actualTemp - foreach (var item in measuredpoints) + bool done = false; + // if requested --> give ack! + ncAdapter.ManageFlirStrobe(); + // requesto photo from library + NcAdapter.lastThermoImage = TCCom.takePicture(); + done = !string.IsNullOrEmpty(NcAdapter.lastThermoImage); + if (done) { - actualTemp.Add(item.Id, item.Temperature); + // init + List measuredpoints = new List(); + Dictionary actualTemp = new Dictionary(); + Dictionary chPoints = new Dictionary(); + // recupero punti centrali resistenze + ncAdapter.GetWarmersChannelCenterPoints(out chPoints); + // richiesta temperature per i punti + done = TCCom.readMultiTemperatures("", chPoints, out measuredpoints); + // converto in actualTemp + foreach (var item in measuredpoints) + { + actualTemp.Add(item.Id, item.Temperature); + } + // salvo dati temp sul PLC + ncAdapter.WriteRecipeWarmChTCamTempAct(actualTemp); + // give PLC strobe for uploaded Actual TEMP from image + ncAdapter.SendTCamImageReadyStrb(); } - // salvo dati temp sul PLC - ncAdapter.WriteRecipeWarmChTCamTempAct(actualTemp); - // give PLC strobe for uploaded Actual TEMP from image - ncAdapter.SendTCamImageReadyStrb(); } } + else + RestoreConnection(); + + sw.Stop(); + + // Update thread timer + UpdateStat(MethodBase.GetCurrentMethod().Name, sw.ElapsedMilliseconds); + // Wait + Thread.Sleep(CalcSleepTime(samplMsec("FlirCamera"), (int)sw.ElapsedMilliseconds)); } - else - RestoreConnection(); - - sw.Stop(); - - // Update thread timer - UpdateStat(MethodBase.GetCurrentMethod().Name, sw.ElapsedMilliseconds); - // Wait - Thread.Sleep(CalcSleepTime(samplMsec("FlirCamera"), (int)sw.ElapsedMilliseconds)); } } catch (ThreadAbortException) diff --git a/Thermo.Active.NC/NcAdapter.cs b/Thermo.Active.NC/NcAdapter.cs index 07733e23..9c65ca4b 100644 --- a/Thermo.Active.NC/NcAdapter.cs +++ b/Thermo.Active.NC/NcAdapter.cs @@ -3120,6 +3120,16 @@ namespace Thermo.Active.NC return libraryError; } + public static bool EnableThermocam + { + get + { + bool answ = false; + bool.TryParse(AdditionalParametersConfig["EnableThermocam"], out answ); + return answ; + } + } + public CmsError ReadTCamData(out DTOThermoCam currTCamData) { CmsError libraryError = NO_ERROR;