diff --git a/THermo.Active.Thermocamera/Thermo.Active.Thermocamera.csproj b/THermo.Active.Thermocamera/Thermo.Active.Thermocamera.csproj
index 9d299c7b..ed5c65ac 100644
--- a/THermo.Active.Thermocamera/Thermo.Active.Thermocamera.csproj
+++ b/THermo.Active.Thermocamera/Thermo.Active.Thermocamera.csproj
@@ -45,5 +45,11 @@
+
+
+ {631375DD-06D3-49BB-8130-D9DDB34C429D}
+ Thermo.Active.Model
+
+
\ No newline at end of file
diff --git a/THermo.Active.Thermocamera/ThermocameraComunicator.cs b/THermo.Active.Thermocamera/ThermocameraComunicator.cs
index 67274d43..f78b0bd0 100644
--- a/THermo.Active.Thermocamera/ThermocameraComunicator.cs
+++ b/THermo.Active.Thermocamera/ThermocameraComunicator.cs
@@ -10,6 +10,7 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
+using Thermo.Active.Model.DTOModels.ThWarmers;
namespace Thermo.Active.Thermocamera
{
@@ -130,13 +131,13 @@ namespace Thermo.Active.Thermocamera
///
/// Restituisce lettura di tutti i punti (cetroidi) richeisti
///
- /// Lista di punti medi (prima resistenza del canale)
+ /// Dictionary dei canali e relativi punti medi (centro calcolato della resistenza di riferimento del canale)
/// Timeout in ms, 10000 std, da conf
/// °C
///
- public bool readMultiTemperatures(IEnumerable points, int timeoutMS, out List temp)
+ public bool readMultiTemperatures(Dictionary points, int timeoutMS, out Dictionary temp)
{
- temp = new List();
+ temp = new Dictionary();
// modalità impiego vero sw esterno
if (useTCamSw)
{
@@ -144,9 +145,9 @@ namespace Thermo.Active.Thermocamera
string response;
string cmdRead = "";
- foreach (Point point in points)
+ foreach (var point in points)
{
- cmdRead += point.X + ";" + point.Y + ";";
+ cmdRead += point.Value.X + ";" + point.Value.Y + ";";
}
if (!writeCommand(accessor, tempCommand + ";" + cmdRead))
@@ -155,24 +156,27 @@ namespace Thermo.Active.Thermocamera
return false;
string[] respSplitted = response.Split(';');
- foreach (string str in respSplitted)
+ int idxResp = 0;
+ foreach (var item in points)
{
- float tmp;
+ string str = respSplitted[idxResp];
+ double tmp;
if (str.Trim() != "")
{
- if (float.TryParse(str.Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out tmp))
- temp.Add(tmp);
+ if (double.TryParse(str.Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out tmp))
+ temp.Add(item.Key, tmp);
else
return false;
}
+ idxResp++;
}
}
else
{
// simulo!
- for (int i = 0; i < points.Count(); i++)
+ foreach (var item in points)
{
- temp.Add(simVal);
+ temp.Add(item.Key, simVal);
}
// attende 5 sec
Thread.Sleep(5000);
diff --git a/Thermo.Active.Config/Config/serverConfig.xml b/Thermo.Active.Config/Config/serverConfig.xml
index cc6dbd26..c511d9d3 100644
--- a/Thermo.Active.Config/Config/serverConfig.xml
+++ b/Thermo.Active.Config/Config/serverConfig.xml
@@ -121,6 +121,7 @@
+
diff --git a/Thermo.Active.Config/ServerConfigController.cs b/Thermo.Active.Config/ServerConfigController.cs
index 9e2de8f2..9e80a749 100644
--- a/Thermo.Active.Config/ServerConfigController.cs
+++ b/Thermo.Active.Config/ServerConfigController.cs
@@ -913,14 +913,14 @@ namespace Thermo.Active.Config
}
// recupero parametri plate e dim resistenze
- double warmerPlanSizeX = 0;
- double warmerPlanSizeY = 0;
- double resistSizeX = 0;
- double resistSizeY = 0;
- double.TryParse(AdditionalParametersConfig["warmerPlanSizeX"], out warmerPlanSizeX);
- double.TryParse(AdditionalParametersConfig["warmerPlanSizeY"], out warmerPlanSizeY);
- double.TryParse(AdditionalParametersConfig["resistSizeX"], out resistSizeX);
- double.TryParse(AdditionalParametersConfig["resistSizeY"], out resistSizeY);
+ int warmerPlanSizeX = 0;
+ int warmerPlanSizeY = 0;
+ int resistSizeX = 0;
+ int resistSizeY = 0;
+ int.TryParse(AdditionalParametersConfig["warmerPlanSizeX"], out warmerPlanSizeX);
+ int.TryParse(AdditionalParametersConfig["warmerPlanSizeY"], out warmerPlanSizeY);
+ int.TryParse(AdditionalParametersConfig["resistSizeX"], out resistSizeX);
+ int.TryParse(AdditionalParametersConfig["resistSizeY"], out resistSizeY);
// calcolo punti!
ThermoPoint centro = new ThermoPoint() { X = warmerPlanSizeX / 2, Y = warmerPlanSizeY / 2 };
ThermoPoint punto = new ThermoPoint();
diff --git a/Thermo.Active.Core/Thermo.Active.Core.csproj b/Thermo.Active.Core/Thermo.Active.Core.csproj
index c757ec32..04c4829d 100644
--- a/Thermo.Active.Core/Thermo.Active.Core.csproj
+++ b/Thermo.Active.Core/Thermo.Active.Core.csproj
@@ -80,6 +80,10 @@
{b2366b08-96bd-4f6b-b748-b45089b87a14}
Thermo.Active.NC
+
+ {8D8EC91A-3A15-4A1D-951B-A35E7068DEBD}
+ Thermo.Active.Thermocamera
+
{cbeb631b-abfa-4042-9779-c0060b0dfefe}
Thermo.Active.Utils
diff --git a/Thermo.Active.Core/ThreadsFunctions.cs b/Thermo.Active.Core/ThreadsFunctions.cs
index 938a06a3..e2023b7e 100644
--- a/Thermo.Active.Core/ThreadsFunctions.cs
+++ b/Thermo.Active.Core/ThreadsFunctions.cs
@@ -21,11 +21,14 @@ 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;
using static Thermo.Active.Model.Constants;
using static Thermo.Active.Utils.ExceptionManager;
+using System.Windows;
+using System.Drawing;
public static class ThreadsFunctions
{
@@ -840,6 +843,79 @@ public static class ThreadsFunctions
ncAdapter.Dispose();
}
}
+ ///
+ /// Manage Requesto from PLC for FLir Image --> temp readout
+ /// 1) check if pending request
+ /// 2) give ack
+ /// 3) request image to ext sw
+ /// 4) request temp sampling from ext sw
+ ///
+ ///
+ public static void ManageFlirCamera()
+ {
+ NcAdapter ncAdapter = new NcAdapter();
+ Stopwatch sw = new Stopwatch();
+ try
+ {
+ // Try connection
+ CmsError libraryError = ncAdapter.Connect();
+ if (libraryError.errorCode != 0)
+ ManageLibraryError(libraryError);
+
+ while (true)
+ {
+ bool flirImageReq = false;
+ sw.Restart();
+ int tOut = 10000;
+
+ // Check if client is connected
+ if (ncAdapter.numericalControl.NC_IsConnected())
+ {
+ // check if there is a photo request pending
+ libraryError = ncAdapter.checkFlirImageRequest(out flirImageReq);
+ if (libraryError.IsError())
+ ManageLibraryError(libraryError);
+
+ if (flirImageReq)
+ {
+ bool done = false;
+ // if requested --> give ack!
+ ncAdapter.ManageFlirStrobe();
+ // requesto photo from library
+ done = ThermocameraComunicator.getInstance().takePicture(tOut);
+ if (done)
+ {
+ // init
+ Dictionary actualTemp = new Dictionary();
+ Dictionary chPoints = new Dictionary();
+ // recupero punti centrali resistenze
+ ncAdapter.GetWarmersChannelCenterPoints(out chPoints);
+ // richiesta temperature per i punti
+ done = ThermocameraComunicator.getInstance().readMultiTemperatures(chPoints, tOut, out actualTemp);
+ // 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));
+ }
+ }
+ catch (ThreadAbortException)
+ {
+ ncAdapter.Dispose();
+ }
+ }
public static void ReadAreaData()
{
NcAdapter ncAdapter = new NcAdapter();
diff --git a/Thermo.Active.Core/ThreadsHandler.cs b/Thermo.Active.Core/ThreadsHandler.cs
index 92c4e8b1..1727e073 100644
--- a/Thermo.Active.Core/ThreadsHandler.cs
+++ b/Thermo.Active.Core/ThreadsHandler.cs
@@ -13,6 +13,7 @@ namespace Thermo.Active.Core
ThreadsFunctions.ManageWatchdog,
ThreadsFunctions.ManageStatusCommand,
ThreadsFunctions.ManageConfRequest,
+ ThreadsFunctions.ManageFlirCamera,
ThreadsFunctions.ReadAlarms,
ThreadsFunctions.ReadPowerOnData,
ThreadsFunctions.StatThread,
diff --git a/Thermo.Active.Model/DTOModels/ThWarmers/ThermoPoint.cs b/Thermo.Active.Model/DTOModels/ThWarmers/ThermoPoint.cs
index 6c1552eb..35a7e476 100644
--- a/Thermo.Active.Model/DTOModels/ThWarmers/ThermoPoint.cs
+++ b/Thermo.Active.Model/DTOModels/ThWarmers/ThermoPoint.cs
@@ -8,13 +8,13 @@ namespace Thermo.Active.Model.DTOModels.ThWarmers
{
public class ThermoPoint
{
- public double X { get; set; } = 0;
- public double Y { get; set; } = 0;
+ public int X { get; set; } = 0;
+ public int Y { get; set; } = 0;
- public static double distance(ThermoPoint a, ThermoPoint b)
+ public static int distance(ThermoPoint a, ThermoPoint b)
{
- double answ = 0;
- answ = Math.Sqrt(Math.Pow((a.X - b.X), 2) + Math.Pow((a.Y - b.Y), 2));
+ int answ = 0;
+ answ = (int)Math.Sqrt(Math.Pow((a.X - b.X), 2) + Math.Pow((a.Y - b.Y), 2));
return answ;
}
}
diff --git a/Thermo.Active.NC/NcAdapter.cs b/Thermo.Active.NC/NcAdapter.cs
index 44299edd..587d1239 100644
--- a/Thermo.Active.NC/NcAdapter.cs
+++ b/Thermo.Active.NC/NcAdapter.cs
@@ -305,6 +305,26 @@ namespace Thermo.Active.NC
return answ;
}
}
+ private static bool ThermoFlirImageReq
+ {
+ get
+ {
+ bool answ = false;
+ if (statusCmd != null)
+ {
+ if (statusCmd.Count > 0)
+ {
+ try
+ {
+ answ = checkBitOnWord(statusCmd[0], 12);
+ }
+ catch
+ { }
+ }
+ }
+ return answ;
+ }
+ }
#endregion
@@ -1331,6 +1351,11 @@ namespace Thermo.Active.NC
setpointHmiInvalidated = ThermoSetpointHmiInvalidated;
return NO_ERROR;
}
+ public CmsError checkFlirImageRequest(out bool flirImageRequest)
+ {
+ flirImageRequest = ThermoCameraReqImage;
+ return NO_ERROR;
+ }
public CmsError doAckSetpointInvalidated()
{
@@ -2765,6 +2790,19 @@ namespace Thermo.Active.NC
return libraryError;
}
+ public CmsError GetWarmersChannelCenterPoints(out Dictionary centerPoints)
+ {
+ CmsError libraryError = NO_ERROR;
+ centerPoints = new Dictionary();
+ var upperReflectors = RiskChannelConfig.Where(x => x.IdReflector == 0);
+ foreach (var item in upperReflectors)
+ {
+ centerPoints.Add(item.IdChannel, item.refPos);
+ }
+ // chiude!
+ return libraryError;
+ }
+
///
/// Returns resistances configuration
///
@@ -3046,6 +3084,16 @@ namespace Thermo.Active.NC
return numericalControl.PLC_WScadaValue(memIndex, memType, value);
}
+ public CmsError ManageFlirStrobe()
+ {
+ return numericalControl.PLC_WStrFlirAcquired();
+ }
+ public CmsError SendTCamImageReadyStrb()
+ {
+ // FIXME TODO !!!
+ return NO_ERROR;// numericalControl.PLC_WStrFlirAcquired();
+ }
+
#endregion Write data
private int GetMaxCountBetweenLayerComponents(ScadaSchemaLayerModel layer)
diff --git a/Thermo.Active/Properties/AssemblyInfo.cs b/Thermo.Active/Properties/AssemblyInfo.cs
index f6a392b5..f0f3de08 100644
--- a/Thermo.Active/Properties/AssemblyInfo.cs
+++ b/Thermo.Active/Properties/AssemblyInfo.cs
@@ -30,4 +30,4 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
-[assembly: AssemblyVersion("0.108.136")]
\ No newline at end of file
+[assembly: AssemblyVersion("0.109.137")]
\ No newline at end of file