Fix configurazioni x termocamera
This commit is contained in:
@@ -84,7 +84,8 @@ namespace Thermo.Active.Thermocamera
|
||||
int sleepTime = 500;
|
||||
byte[] bytesToRead = new byte[NUM_CHAR_MSG];
|
||||
|
||||
if (!accessor.CanRead) return false;
|
||||
if (!accessor.CanRead)
|
||||
return false;
|
||||
|
||||
//Read Pre-Command
|
||||
while (response != RES)
|
||||
@@ -102,11 +103,15 @@ namespace Thermo.Active.Thermocamera
|
||||
|
||||
//Elaborate String
|
||||
string textRecieved = Encoding.UTF8.GetString(bytesToRead);
|
||||
if (textRecieved == null) return false;
|
||||
if (textRecieved == null)
|
||||
return false;
|
||||
|
||||
string[] textSplitted = textRecieved.Replace("\0", string.Empty).Split(';');
|
||||
if (textSplitted.Length < 2) return false;
|
||||
if (textSplitted[0] != command) return false;
|
||||
if (textSplitted.Length < 2)
|
||||
return false;
|
||||
|
||||
if (textSplitted[0] != command)
|
||||
return false;
|
||||
|
||||
char[] bufferToClean = Enumerable.Repeat('\0', NUM_CHAR_MSG).ToArray();
|
||||
accessor.WriteArray(0, bufferToClean, 0, bufferToClean.Length);
|
||||
@@ -171,7 +176,7 @@ namespace Thermo.Active.Thermocamera
|
||||
if (!readCommand(accessorResp, tempCommand, timeoutMS, out response))
|
||||
return false;
|
||||
|
||||
string[] respSplitted = response.Replace(",",".").Split(';');
|
||||
string[] respSplitted = response.Replace(",", ".").Split(';');
|
||||
int idxResp = 0;
|
||||
foreach (var item in points)
|
||||
{
|
||||
@@ -244,7 +249,7 @@ namespace Thermo.Active.Thermocamera
|
||||
return false;
|
||||
if (!readCommand(accessorResp, tempCommand, timeoutMS, out response))
|
||||
return false;
|
||||
if (response != "1;")
|
||||
if (!response.StartsWith("1;"))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@@ -266,7 +271,7 @@ namespace Thermo.Active.Thermocamera
|
||||
return false;
|
||||
if (!readCommand(accessorResp, tempCommand, timeoutMS, out response))
|
||||
return false;
|
||||
if (response != "True;")
|
||||
if (!response.StartsWith("True;"))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -59,11 +59,11 @@
|
||||
</entry>
|
||||
<entry>
|
||||
<key>flirImgX</key>
|
||||
<value>800</value>
|
||||
<value>1000</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>flirImgY</key>
|
||||
<value>1002</value>
|
||||
<value>803</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>resistSizeX</key>
|
||||
@@ -87,7 +87,7 @@
|
||||
</entry>
|
||||
<entry>
|
||||
<key>ThermoCameraXpos</key>
|
||||
<value>68</value>
|
||||
<value>93</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>ThermoCameraYpos</key>
|
||||
|
||||
@@ -598,6 +598,8 @@ namespace Thermo.Active.Config
|
||||
int ResistId = 0;
|
||||
int oldRow = 0;
|
||||
int currIdBoard = 0;
|
||||
int maxCol = 0;
|
||||
int maxRow = 0;
|
||||
RiskBoardConfig = new List<RiskBoardModel>();
|
||||
RiskResistConfig = new List<RiskResistModel>();
|
||||
RiskChannelConfig = new List<RiskChannelModel>();
|
||||
@@ -651,8 +653,8 @@ namespace Thermo.Active.Config
|
||||
SetpointThermo = 0,
|
||||
MaxPower = riferimento.Potenza,
|
||||
NumResist = 1,
|
||||
refPosDistance = 999999,
|
||||
refPos = new ThermoPoint(), // imposto default a 0
|
||||
Dimensione = riferimento.Dimensione,
|
||||
// 2020.07.27 applicato x tutti
|
||||
CalcIchMin = true //riferimento.Modello.Contains("Quarzo") || riferimento.Modello.Contains("Alogena")
|
||||
});
|
||||
@@ -679,6 +681,7 @@ namespace Thermo.Active.Config
|
||||
else
|
||||
{
|
||||
numCol++;
|
||||
maxCol = numCol > maxCol ? numCol : maxCol;
|
||||
}
|
||||
|
||||
// cerco il TIPO...
|
||||
@@ -690,8 +693,10 @@ namespace Thermo.Active.Config
|
||||
Row = resistenza.Riga,
|
||||
Column = numCol,
|
||||
IdChannel = resistenza.Canale,
|
||||
Dimension = riferimento.Dimensione
|
||||
Dimension = riferimento.Dimensione,
|
||||
IdReflector = riflettore.Tipo
|
||||
}); ;
|
||||
maxRow = resistenza.Riga > maxRow ? resistenza.Riga : maxRow;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -717,6 +722,88 @@ namespace Thermo.Active.Config
|
||||
// ciclo ora per calcolare TUTTE le posizioni di riferimento dei canali (prendendo il centro delle resistenze)
|
||||
Dictionary<int, ThermoPoint> newPos = new Dictionary<int, ThermoPoint>();
|
||||
var listChSup = RiskChannelConfig.Where(x => x.IdReflector == 0);
|
||||
|
||||
// spazzo riga x riga da elenco resistenze...
|
||||
var listResist = RiskResistConfig.Where(x => x.IdReflector == 0);
|
||||
int currRow = -1;
|
||||
double currX = 0;
|
||||
for (int rigaCorr = 0; rigaCorr <= maxRow; rigaCorr++)
|
||||
{
|
||||
for (int colCorr = 0; colCorr <= maxCol; colCorr++)
|
||||
{
|
||||
var currResist = listResist.FirstOrDefault(x => x.Row == rigaCorr && x.Column == colCorr);
|
||||
if (currResist != null)
|
||||
{
|
||||
// se cambio riga --> mi metto a metà della prima cella
|
||||
if (currResist.Row != currRow)
|
||||
{
|
||||
currX = (currResist.Dimension * resistSizeX) / 2;
|
||||
currRow = currResist.Row;
|
||||
}
|
||||
else
|
||||
{
|
||||
// calcolo coordinata X CumSum
|
||||
currX += (currResist.Dimension * resistSizeX);
|
||||
}
|
||||
//// reset distanza
|
||||
//actDist = warmerPlanSizeX + warmerPlanSizeY;
|
||||
//minDist = warmerPlanSizeX + warmerPlanSizeY;
|
||||
|
||||
// tutti i calcoli in coordinate mm del riscaldo
|
||||
punto = new ThermoPoint() { X = (int)currX, Y = currResist.Row * resistSizeY + resistSizeY / 2 };
|
||||
puntoFlirImg = new ThermoPoint();
|
||||
actDist = ThermoPoint.distance(punto, centro);
|
||||
// cerco i dati del canale attuale...
|
||||
var currChannel = RiskChannelConfig.FirstOrDefault(x => x.IdChannel == currResist.IdChannel);
|
||||
if (currChannel.refPosDistance > actDist)
|
||||
{
|
||||
// riscalo il punto per la dimensione della FLIR
|
||||
puntoFlirImg.X = punto.X * flirImgX / warmerPlanSizeX;
|
||||
puntoFlirImg.Y = punto.Y * flirImgY / warmerPlanSizeY;
|
||||
currChannel.refPos = puntoFlirImg;
|
||||
currChannel.refPosDistance = actDist;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int zero = 0;
|
||||
#if false
|
||||
foreach (var currResist in listResist.OrderBy(x => x.Row).OrderBy(x => x.Column))
|
||||
{
|
||||
// se cambio riga --> mi metto a metà della prima cella
|
||||
if (currResist.Row != currRow)
|
||||
{
|
||||
currX = (currResist.Dimension * resistSizeX) / 2;
|
||||
currRow = currResist.Row;
|
||||
}
|
||||
else
|
||||
{
|
||||
// calcolo coordinata X CumSum
|
||||
currX += (currResist.Dimension * resistSizeX);
|
||||
}
|
||||
//// reset distanza
|
||||
//actDist = warmerPlanSizeX + warmerPlanSizeY;
|
||||
//minDist = warmerPlanSizeX + warmerPlanSizeY;
|
||||
|
||||
// tutti i calcoli in coordinate mm del riscaldo
|
||||
punto = new ThermoPoint() { X = (int)currX, Y = currResist.Row * resistSizeY + resistSizeY / 2 };
|
||||
puntoFlirImg = new ThermoPoint();
|
||||
actDist = ThermoPoint.distance(punto, centro);
|
||||
// cerco i dati del canale attuale...
|
||||
var currChannel = RiskChannelConfig.FirstOrDefault(x => x.IdChannel == currResist.IdChannel);
|
||||
if (currChannel.refPosDistance > actDist)
|
||||
{
|
||||
// riscalo il punto per la dimensione della FLIR
|
||||
puntoFlirImg.X = punto.X * flirImgX / warmerPlanSizeX;
|
||||
puntoFlirImg.Y = punto.Y * flirImgY / warmerPlanSizeY;
|
||||
currChannel.refPos = puntoFlirImg;
|
||||
currChannel.refPosDistance = actDist;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if false
|
||||
foreach (var currChannel in listChSup)
|
||||
{
|
||||
// reset distanza
|
||||
@@ -745,6 +832,7 @@ namespace Thermo.Active.Config
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,7 +18,6 @@ namespace Thermo.Active.Model.ConfigModels
|
||||
#region Public Properties
|
||||
|
||||
public bool CalcIchMin { get; set; } = false;
|
||||
public int Dimensione { get; set; } = 1;
|
||||
public int IdChannel { get; set; } = 0;
|
||||
public int IdReflector { get; set; } = 0;
|
||||
public int MaxPower { get; set; } = 0;
|
||||
@@ -29,6 +28,11 @@ namespace Thermo.Active.Model.ConfigModels
|
||||
/// </summary>
|
||||
public ThermoPoint refPos { get; set; } = new ThermoPoint();
|
||||
|
||||
/// <summary>
|
||||
/// Distanza del punto di riferimento dal centro della piastra
|
||||
/// </summary>
|
||||
public double refPosDistance { get; set; } = 0;
|
||||
|
||||
public int SetpointRecipe { get; set; } = 0;
|
||||
public int SetpointThermo { get; set; } = 0;
|
||||
|
||||
@@ -50,11 +54,12 @@ namespace Thermo.Active.Model.ConfigModels
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
public int Column;
|
||||
public int Dimension;
|
||||
public int Id;
|
||||
public int IdChannel;
|
||||
public int Row;
|
||||
public int Column { get; set; } = 0;
|
||||
public int Dimension { get; set; } = 0;
|
||||
public int Id { get; set; } = 0;
|
||||
public int IdChannel { get; set; } = 0;
|
||||
public int IdReflector { get; set; } = 0;
|
||||
public int Row { get; set; } = 0;
|
||||
|
||||
#endregion Public Fields
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user