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