Compare commits

...

14 Commits

Author SHA1 Message Date
Samuele E. Locatelli 3b0dd98018 modifica meccanismo dispose FLIR 2021-03-19 10:11:43 +01:00
Samuele E. Locatelli 76fdf01d38 Merge branch 'new/ThermoCamManager' into develop 2021-03-18 11:49:36 +01:00
Samuele E. Locatelli 7918787ac6 new rel 2021-03-18 11:49:30 +01:00
Samuele E. Locatelli e797afabcb impostato in recipe current stesso comportamento di area 2021-03-18 11:48:46 +01:00
Samuele E. Locatelli c31edb94d5 Merge branch 'new/ThermoCamManager' into develop 2021-03-18 09:49:59 +01:00
Samuele E. Locatelli 86fd710aaa vers 182 2021-03-18 09:49:33 +01:00
Samuele E. Locatelli f1f8f3aa97 modifiche x evitare sovrapposizione chiamate lettura ricetta 2021-03-18 09:46:56 +01:00
Samuele E. Locatelli 83d6f40491 Merge branch 'develop' into new/ThermoCamManager 2021-03-17 19:06:03 +01:00
Samuele E. Locatelli 21cb4050b0 modifica DTO x upload stato connessione FLIR cam 2021-03-17 19:05:49 +01:00
Samuele E. Locatelli 027eed8770 Aggiunta gestione status camera connessa o meno (lettura) 2021-03-17 19:01:41 +01:00
Samuele E. Locatelli 43de959bca new rel number 2021-03-17 18:42:13 +01:00
Samuele E. Locatelli 5a56d53d90 fix thread thermo flir 2021-03-16 15:21:03 +01:00
Samuele E. Locatelli 89b0ce5f96 gestione conf XML server x abilitazione FLIR 2021-03-16 15:15:58 +01:00
Samuele E. Locatelli e57d16d690 vers 180 2021-03-15 17:09:26 +01:00
9 changed files with 133 additions and 67 deletions
@@ -51,6 +51,14 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Flir.Atlas.Image, Version=2.0.14266.1000, Culture=neutral, PublicKeyToken=caa391fd8e07c76b, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\Program Files (x86)\FLIR Systems\FLIR Atlas SDK 6\bin\x86\Flir.Atlas.Image.dll</HintPath>
</Reference>
<Reference Include="Flir.Atlas.Live, Version=2.0.14266.1000, Culture=neutral, PublicKeyToken=caa391fd8e07c76b, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\Program Files (x86)\FLIR Systems\FLIR Atlas SDK 6\bin\x86\Flir.Atlas.Live.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
@@ -1,4 +1,5 @@
using System;
using Flir.Atlas.Live.Device;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -26,6 +27,11 @@ namespace Thermo.Active.Thermocamera
public static readonly string BASE_PATH = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
/// <summary>
/// Indica se la camera sia connessa
/// </summary>
public bool CameraIsConnected = false;
#endregion Public Fields
#region Public Constructors
@@ -33,12 +39,15 @@ namespace Thermo.Active.Thermocamera
/// <summary>
/// Init classe
/// </summary>
/// <param name="isLive">Indica aabilitazione alive straming vs load dati storici</param>
/// <param name="isLive">Indica aabilitazione a live straming vs load dati storici</param>
public ThermoCamComunicator(bool isLive)
{
// init classe controllo camera
TCamLive = new TCContr($"{Constants.WEBSITE_DIRECTORY}\\{Constants.THERMO_DATA_FOLDER}", $"{BASE_PATH}\\{Constants.CONFIG_DIRECTORY}");
// aggancio evento connesisone/disconnessione
TCamLive.eh_CameraConnStatusChanged += TCamLive_eh_CameraConnStatusChanged;
// avvio classe gestione thermocamera...
TCamLive.tryReloadConf();
@@ -49,6 +58,12 @@ namespace Thermo.Active.Thermocamera
}
}
private void TCamLive_eh_CameraConnStatusChanged(object sender, Flir.Atlas.Live.ConnectionStatusChangedEventArgs e)
{
// salvo stato connessione
CameraIsConnected = e.Status == ConnectionStatus.Connected;
}
#endregion Public Constructors
#region Protected Methods
+7 -3
View File
@@ -113,6 +113,10 @@
<key>RangeTempMax</key>
<value>100</value>
</entry>
<entry>
<key>EnableThermocam</key>
<value>true</value>
</entry>
</additionalParameters>
<unitOfMeasures>
<unitOfMeasure id="0" value="" />
@@ -129,7 +133,7 @@
<thread name="axis" value="200" />
<thread name="channelsIoFast" value="300" />
<thread name="channelsIoSlow" value="5000" />
<thread name="area" value="500" />
<thread name="area" value="2500" />
<thread name="confReq" value="2000" />
<thread name="expMan" value="30000" />
<thread name="functionEnab" value="300" />
@@ -141,12 +145,12 @@
<thread name="prodInfo" value="1000" />
<thread name="prodPanel" value="500" />
<thread name="modules" value="200" />
<thread name="recipe" value="4000" />
<thread name="recipe" value="1000" />
<thread name="scada" value="1000" />
<thread name="statusCommand" value="250" />
<thread name="FlirCamera" value="500" />
<thread name="userSK" value="250" />
<thread name="warmers" value="500" />
<thread name="warmers" value="2000" />
<thread name="watchdog" value="250" />
<thread name="stats" value="2000" />
</sampling>
+69 -58
View File
@@ -339,77 +339,88 @@ 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<Thermo.Cam.Utils.MeasurePoint> measuredpoints = new List<Thermo.Cam.Utils.MeasurePoint>();
Dictionary<int, double> actualTemp = new Dictionary<int, double>();
Dictionary<int, ThermoPoint> chPoints = new Dictionary<int, ThermoPoint>();
// 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<Thermo.Cam.Utils.MeasurePoint> measuredpoints = new List<Thermo.Cam.Utils.MeasurePoint>();
Dictionary<int, double> actualTemp = new Dictionary<int, double>();
Dictionary<int, ThermoPoint> chPoints = new Dictionary<int, ThermoPoint>();
// 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();
}
// salvo status thermocam...
NcAdapter.cameraIsConnected = TCCom.CameraIsConnected;
}
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)
{
ncAdapter.Dispose();
}
finally
{
// chiudo thermocam
TCCom.Dispose();
catch (ThreadAbortException)
{
ncAdapter.Dispose();
// chiudo thermocam
TCCom.Dispose();
}
finally
{
ncAdapter.Dispose();
// chiudo thermocam
TCCom.Dispose();
}
}
}
@@ -30,6 +30,11 @@ namespace Thermo.Active.Model.DTOModels.ThWarmers
/// </summary>
public bool ThermoCamOnOff { get; set; } = false;
/// <summary>
/// Stato connessione ThermoCamera (in rete)
/// </summary>
public bool ThermoCamConnected { get; set; } = false;
/// <summary>
/// Opzione ThermoCamera (set by PLC)
/// </summary>
+21 -2
View File
@@ -135,6 +135,11 @@ namespace Thermo.Active.NC
/// </summary>
public NcThermo numericalControl;
/// <summary>
/// Indica se la FLIR camera è connessa
/// </summary>
public static bool cameraIsConnected = false;
#endregion Public Fields
#region Public Constructors
@@ -1409,7 +1414,9 @@ namespace Thermo.Active.NC
// leggo la ricetta dal PLC!
var currRecipe = new Dictionary<string, DTORecipeParam>();
libraryError = ReadFullRecipe(out currRecipe);
//libraryError = ReadFullRecipe(out currRecipe);
libraryError = ReadRecipeData(true, true, out currRecipe);
if (libraryError.IsError())
return libraryError;
@@ -1680,7 +1687,7 @@ namespace Thermo.Active.NC
var currRecipe = new Dictionary<string, DTORecipeParam>();
// read recipe
libraryError = ReadRecipeData(false, true, out currRecipe);
libraryError = ReadRecipeData(true, true, out currRecipe);
if (libraryError.IsError())
return libraryError;
@@ -3120,6 +3127,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;
@@ -3153,6 +3170,8 @@ namespace Thermo.Active.NC
Min = minVal,
Max = maxVal
};
// controllo se connessa
currTCamData.ThermoCamConnected = cameraIsConnected;
}
return libraryError;
}
@@ -100,7 +100,8 @@ namespace Thermo.Active.Controllers.WebApi
}
// read recipe!
libraryError = ncAdapter.ReadFullRecipe(out Dictionary<string, DTORecipeParam> prevRecipe);
//libraryError = ncAdapter.ReadFullRecipe(out Dictionary<string, DTORecipeParam> prevRecipe);
libraryError = ncAdapter.ReadRecipeData(true, true, out Dictionary<string, DTORecipeParam> prevRecipe);
if (libraryError.IsError())
{
ThermoActiveLogger.LogError($"GetRecipeOverview error | {libraryError.exception}");
+1 -1
View File
@@ -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("1.1.179")]
[assembly: AssemblyVersion("1.1.184")]
+3
View File
@@ -0,0 +1,3 @@
{
"lockfileVersion": 1
}