Merge branch 'Connect-UI' into Thermocamera

This commit is contained in:
Samuele E. Locatelli
2020-10-30 19:08:49 +01:00
5 changed files with 1096 additions and 932 deletions
@@ -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
+3 -3
View File
@@ -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>
+91 -2
View File
@@ -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,6 +653,7 @@ namespace Thermo.Active.Config
SetpointThermo = 0,
MaxPower = riferimento.Potenza,
NumResist = 1,
refPosDistance = 999999,
refPos = new ThermoPoint(), // imposto default a 0
// 2020.07.27 applicato x tutti
CalcIchMin = true //riferimento.Modello.Contains("Quarzo") || riferimento.Modello.Contains("Alogena")
@@ -678,6 +681,7 @@ namespace Thermo.Active.Config
else
{
numCol++;
maxCol = numCol > maxCol ? numCol : maxCol;
}
// cerco il TIPO...
@@ -689,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;
}
}
@@ -716,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
@@ -727,7 +815,7 @@ namespace Thermo.Active.Config
foreach (var resist in currResist)
{
// tutti i calcoli in coordinate mm del riscaldo
punto = new ThermoPoint() { X = resist.Row * resistSizeX + resistSizeX / 2, Y = resist.Column * resistSizeY + resistSizeY / 2 };
punto = new ThermoPoint() { X = resist.Column * resistSizeX + resistSizeX / 2, Y = resist.Row * resistSizeY + resistSizeY / 2 };
puntoFlirImg = new ThermoPoint();
actDist = ThermoPoint.distance(punto, centro);
if (actDist < minDist)
@@ -744,6 +832,7 @@ namespace Thermo.Active.Config
}
}
}
#endif
}
/// <summary>
File diff suppressed because it is too large Load Diff
@@ -3,49 +3,86 @@ using Thermo.Active.Model.DTOModels.ThWarmers;
namespace Thermo.Active.Model.ConfigModels
{
public class RiskRiflettore
public class RiskBoardModel
{
public int Tipo;
public List<RiskResistenza> Resistenze;
}
public class RiskResistenza
{
public int Tipo;
public int Riga;
public int Canale;
}
public class RiskRiferimenti
{
public int Id;
public int Potenza;
public int Dimensione;
public string Modello;
}
public class RiskResistModel
{
public int Id;
public int IdChannel;
public int Column;
public int Row;
public int Dimension;
#region Public Fields
public int IdBoard;
public int NumChannels;
#endregion Public Fields
}
public class RiskChannelModel
{
public int IdChannel;
public int IdReflector;
public int SetpointRecipe;
public int SetpointThermo;
public int MaxPower;
public int NumResist;
public bool CalcIchMin;
#region Public Properties
public bool CalcIchMin { get; set; } = false;
public int IdChannel { get; set; } = 0;
public int IdReflector { get; set; } = 0;
public int MaxPower { get; set; } = 0;
public int NumResist { get; set; } = 1;
/// <summary>
/// Posizione X/Y di riferimento (della resistenza + interna)
/// </summary>
public ThermoPoint refPos = new ThermoPoint();
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;
#endregion Public Properties
}
public class RiskBoardModel
public class RiskResistenza
{
public int IdBoard;
public int NumChannels;
#region Public Fields
public int Canale;
public int Riga;
public int Tipo;
#endregion Public Fields
}
}
public class RiskResistModel
{
#region Public Fields
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
}
public class RiskRiferimenti
{
#region Public Fields
public int Dimensione;
public int Id;
public string Modello;
public int Potenza;
#endregion Public Fields
}
public class RiskRiflettore
{
#region Public Fields
public List<RiskResistenza> Resistenze;
public int Tipo;
#endregion Public Fields
}
}