gestione conf XML server x abilitazione FLIR
This commit is contained in:
@@ -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="" />
|
||||
|
||||
@@ -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<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();
|
||||
}
|
||||
}
|
||||
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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user