Ajustado tela de parametrizacao do sensoriamento

This commit is contained in:
Diego Freitas 2024-01-30 09:09:36 -03:00
parent 35ef616767
commit 1dfab912a7
15 changed files with 102 additions and 27 deletions

Binary file not shown.

View File

@ -33,29 +33,37 @@
this.btnSalvar = new System.Windows.Forms.Button();
this.lblTensao = new System.Windows.Forms.Label();
this.lblCorrente = new System.Windows.Forms.Label();
this.lblTemperatura = new System.Windows.Forms.Label();
this.gridsTMP = new System.Windows.Forms.DataGridView();
((System.ComponentModel.ISupportInitialize)(this.gridsTEN)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.gridsCOR)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.gridsTMP)).BeginInit();
this.SuspendLayout();
//
// gridsTEN
//
this.gridsTEN.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.gridsTEN.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.gridsTEN.Location = new System.Drawing.Point(12, 25);
this.gridsTEN.Location = new System.Drawing.Point(15, 25);
this.gridsTEN.Name = "gridsTEN";
this.gridsTEN.Size = new System.Drawing.Size(270, 124);
this.gridsTEN.Size = new System.Drawing.Size(418, 124);
this.gridsTEN.TabIndex = 1;
//
// gridsCOR
//
this.gridsCOR.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.gridsCOR.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.gridsCOR.Location = new System.Drawing.Point(288, 25);
this.gridsCOR.Location = new System.Drawing.Point(15, 168);
this.gridsCOR.Name = "gridsCOR";
this.gridsCOR.Size = new System.Drawing.Size(270, 124);
this.gridsCOR.Size = new System.Drawing.Size(418, 124);
this.gridsCOR.TabIndex = 1;
//
// btnSalvar
//
this.btnSalvar.Location = new System.Drawing.Point(483, 155);
this.btnSalvar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnSalvar.Location = new System.Drawing.Point(358, 441);
this.btnSalvar.Name = "btnSalvar";
this.btnSalvar.Size = new System.Drawing.Size(75, 23);
this.btnSalvar.TabIndex = 3;
@ -75,23 +83,43 @@
// lblCorrente
//
this.lblCorrente.AutoSize = true;
this.lblCorrente.Location = new System.Drawing.Point(285, 9);
this.lblCorrente.Location = new System.Drawing.Point(12, 152);
this.lblCorrente.Name = "lblCorrente";
this.lblCorrente.Size = new System.Drawing.Size(47, 13);
this.lblCorrente.TabIndex = 5;
this.lblCorrente.Text = "Corrente";
//
// lblTemperatura
//
this.lblTemperatura.AutoSize = true;
this.lblTemperatura.Location = new System.Drawing.Point(12, 295);
this.lblTemperatura.Name = "lblTemperatura";
this.lblTemperatura.Size = new System.Drawing.Size(67, 13);
this.lblTemperatura.TabIndex = 7;
this.lblTemperatura.Text = "Temperatura";
//
// gridsTMP
//
this.gridsTMP.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.gridsTMP.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.gridsTMP.Location = new System.Drawing.Point(15, 311);
this.gridsTMP.Name = "gridsTMP";
this.gridsTMP.Size = new System.Drawing.Size(418, 124);
this.gridsTMP.TabIndex = 6;
//
// frmSenConfig
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(571, 188);
this.ClientSize = new System.Drawing.Size(445, 472);
this.Controls.Add(this.lblTemperatura);
this.Controls.Add(this.gridsTMP);
this.Controls.Add(this.lblCorrente);
this.Controls.Add(this.lblTensao);
this.Controls.Add(this.gridsCOR);
this.Controls.Add(this.gridsTEN);
this.Controls.Add(this.btnSalvar);
this.MaximizeBox = false;
this.Name = "frmSenConfig";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Sensoriamento - Parametrização";
@ -99,6 +127,7 @@
this.Load += new System.EventHandler(this.frmSenConfig_Load);
((System.ComponentModel.ISupportInitialize)(this.gridsTEN)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.gridsCOR)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.gridsTMP)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@ -110,5 +139,7 @@
private System.Windows.Forms.Button btnSalvar;
private System.Windows.Forms.Label lblTensao;
private System.Windows.Forms.Label lblCorrente;
private System.Windows.Forms.Label lblTemperatura;
private System.Windows.Forms.DataGridView gridsTMP;
}
}

View File

@ -31,25 +31,48 @@ namespace AgroBase.Forms.Sensoriamento
return;
}
PopulaParametrosSensor();
PreencheParametrosSensores();
}
private void PopulaParametrosSensor()
{
foreach (var Sensor in Disp.Dados.Sensores)
{
string gridName = "grid" + Enum.GetName(typeof(S_Code), Sensor.Componente);
DataGridView grid = this.Controls.OfType<DataGridView>().ToList().FirstOrDefault(x => x.Name == gridName);
if (grid != null)
if (grid != null && grid.Columns.Count == 0)
{
grid.Rows.Clear();
grid.Columns.Clear();
grid.Columns.Add("clParametro", "Parâmetro");
grid.Columns.Add("clValor", "Valor");
grid.Columns.Add("clSensor", "Sensor");
foreach (var Parametro in Sensor.Parametros)
{
grid.Rows.Add(Parametro[0], Parametro[1]);
grid.Columns.Add("cl" + Parametro[0], Parametro[0]);
}
//grid.Rows.RemoveAt(grid.Rows.Count - 1);
}
}
}
private void PreencheParametrosSensores()
{
foreach (var Sensor in Disp.Dados.Sensores)
{
string gridName = "grid" + Enum.GetName(typeof(S_Code), Sensor.Componente);
DataGridView grid = this.Controls.OfType<DataGridView>().ToList().FirstOrDefault(x => x.Name == gridName);
if (grid != null && grid.Columns.Count > 0)
{
int novaLinhaIndex = grid.Rows.Add();
grid.Rows[novaLinhaIndex].Cells[0].Value = Sensor.Descricao;
for (int i = 0; i < Sensor.Parametros.Count; i++)
{
grid.Rows[novaLinhaIndex].Cells[i + 1].Value = Sensor.Parametros[i][1];
}
}
}
}
private void frmSenConfig_FormClosing(object sender, FormClosingEventArgs e)
@ -71,18 +94,21 @@ namespace AgroBase.Forms.Sensoriamento
DataGridView grid = this.Controls.OfType<DataGridView>().ToList().FirstOrDefault(x => x.Name == gridName);
if (grid != null && grid.Rows.Count > 1)
{
Sensor.Parametros = new List<string[]>();
foreach (DataGridViewRow Row in grid.Rows)
{
if (Row.Cells[0].Value != null)
if (Row.Cells[0].Value != null && Row.Cells[0].Value.ToString() == Sensor.Descricao)
{
Sensor.Parametros.Add(new string[] { Row.Cells[0].Value.ToString(), Row.Cells[1].Value.ToString() });
//Sensor.Parametros.Add(new string[] { Row.Cells[0].Value.ToString(), Row.Cells[1].Value.ToString() });
for (int i = 0; i < Sensor.Parametros.Count; i++)
{
Sensor.Parametros[i][1] = Row.Cells[i + 1].Value.ToString();
}
break;
}
}
}
}
}
}
}

View File

@ -41,7 +41,10 @@ namespace AgroBase.Models.Modules
FuncoesPinout.TMP,
},
DelayAmostragem = 200,
Parametros = new List<string[]>(),
Parametros = new List<string[]>()
{
new string[] { "V offset", "-1.038" },
},
},
new SensorModel()
{
@ -57,7 +60,10 @@ namespace AgroBase.Models.Modules
FuncoesPinout.TMP,
},
DelayAmostragem = 200,
Parametros = new List<string[]>(),
Parametros = new List<string[]>()
{
new string[] { "V offset", "-1.038" },
},
},
new SensorModel()
{
@ -73,7 +79,10 @@ namespace AgroBase.Models.Modules
FuncoesPinout.TMP,
},
DelayAmostragem = 200,
Parametros = new List<string[]>(),
Parametros = new List<string[]>()
{
new string[] { "V offset", "-1.038" },
},
},
new SensorModel()
{
@ -89,7 +98,10 @@ namespace AgroBase.Models.Modules
FuncoesPinout.TMP,
},
DelayAmostragem = 200,
Parametros = new List<string[]>(),
Parametros = new List<string[]>()
{
new string[] { "V offset", "-1.038" },
},
},
new SensorModel()
{
@ -146,7 +158,10 @@ namespace AgroBase.Models.Modules
FuncoesPinout.TMP,
},
DelayAmostragem = 500,
Parametros = new List<string[]>(),
Parametros = new List<string[]>()
{
new string[] { "V offset", "0.0000" },
},
},
}
};

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"Conectado":false,"Sensores":[{"LogGrafico":[],"ID":"TMVET","Prioridade":0,"Descricao":"Temperatura Motor Esquerdo Trás","Componente":411,"Aferir":false,"DelayAmostragem":200,"Inicializado":false,"Testando":false,"Funcoes":[12],"Parametros":[],"UnidadeMedida":null,"Leituras":[81.06],"ValorMinimo":0.0,"ValorMaximo":0.0},{"LogGrafico":[],"ID":"TMVEF","Prioridade":0,"Descricao":"Temperatura Motor Esquerdo Frente","Componente":411,"Aferir":false,"DelayAmostragem":200,"Inicializado":false,"Testando":false,"Funcoes":[12],"Parametros":[],"UnidadeMedida":null,"Leituras":[88.94],"ValorMinimo":0.0,"ValorMaximo":0.0},{"LogGrafico":[],"ID":"TMVDT","Prioridade":0,"Descricao":"Temperatura Motor Direito Trás","Componente":411,"Aferir":false,"DelayAmostragem":200,"Inicializado":false,"Testando":false,"Funcoes":[12],"Parametros":[],"UnidadeMedida":null,"Leituras":[77.52],"ValorMinimo":0.0,"ValorMaximo":0.0},{"LogGrafico":[],"ID":"TMVDF","Prioridade":0,"Descricao":"Temperatura Motor Direito Frente","Componente":411,"Aferir":false,"DelayAmostragem":200,"Inicializado":false,"Testando":false,"Funcoes":[12],"Parametros":[],"UnidadeMedida":null,"Leituras":[82.86],"ValorMinimo":0.0,"ValorMaximo":0.0},{"LogGrafico":[],"ID":"VBAT","Prioridade":20,"Descricao":"Tensão da bateria","Componente":112,"Aferir":true,"DelayAmostragem":500,"Inicializado":false,"Testando":false,"Funcoes":[28],"Parametros":[["V offset","-00.90"],["R1","120000"],["R2","010000"]],"UnidadeMedida":null,"Leituras":[4095.0,3.23,42.0],"ValorMinimo":0.0,"ValorMaximo":0.0},{"LogGrafico":[],"ID":"ABAT","Prioridade":10,"Descricao":"Corrente da bateria","Componente":322,"Aferir":true,"DelayAmostragem":500,"Inicializado":false,"Testando":false,"Funcoes":[29],"Parametros":[["V offset","00.330"],["Sensibilidade","000.17"]],"UnidadeMedida":null,"Leituras":[798.0,0.64,1.84],"ValorMinimo":0.0,"ValorMaximo":0.0},{"LogGrafico":[],"ID":"TBAT","Prioridade":5,"Descricao":"Temperatura da bateria","Componente":411,"Aferir":true,"DelayAmostragem":500,"Inicializado":false,"Testando":false,"Funcoes":[12],"Parametros":[],"UnidadeMedida":null,"Leituras":[34.34],"ValorMinimo":0.0,"ValorMaximo":0.0}]}
{"Conectado":false,"Sensores":[{"LogGrafico":[],"ID":"TMVET","Prioridade":0,"Descricao":"Temperatura Motor Esquerdo Trás","Componente":411,"Aferir":true,"DelayAmostragem":200,"Inicializado":false,"Testando":false,"Funcoes":[12],"Parametros":[["V offset","-1.038"]],"UnidadeMedida":null,"Leituras":[22.13],"ValorMinimo":0.0,"ValorMaximo":125.27},{"LogGrafico":[],"ID":"TMVEF","Prioridade":0,"Descricao":"Temperatura Motor Esquerdo Frente","Componente":411,"Aferir":true,"DelayAmostragem":200,"Inicializado":false,"Testando":false,"Funcoes":[12],"Parametros":[["V offset","-1.038"]],"UnidadeMedida":null,"Leituras":[0.0],"ValorMinimo":0.0,"ValorMaximo":0.0},{"LogGrafico":[],"ID":"TMVDT","Prioridade":0,"Descricao":"Temperatura Motor Direito Trás","Componente":411,"Aferir":true,"DelayAmostragem":200,"Inicializado":false,"Testando":false,"Funcoes":[12],"Parametros":[["V offset","-1.038"]],"UnidadeMedida":null,"Leituras":[0.0],"ValorMinimo":0.0,"ValorMaximo":211.32},{"LogGrafico":[],"ID":"TMVDF","Prioridade":0,"Descricao":"Temperatura Motor Direito Frente","Componente":411,"Aferir":true,"DelayAmostragem":200,"Inicializado":false,"Testando":false,"Funcoes":[12],"Parametros":[["V offset","-1.038"]],"UnidadeMedida":null,"Leituras":[228.34],"ValorMinimo":0.0,"ValorMaximo":228.34},{"LogGrafico":[],"ID":"VBAT","Prioridade":20,"Descricao":"Tensão da bateria","Componente":112,"Aferir":true,"DelayAmostragem":500,"Inicializado":false,"Testando":false,"Funcoes":[28],"Parametros":[["V offset","-0.900"],["R1","120000"],["R2","010000"]],"UnidadeMedida":null,"Leituras":[327.0,0.33,4.28],"ValorMinimo":0.0,"ValorMaximo":13.66},{"LogGrafico":[],"ID":"ABAT","Prioridade":10,"Descricao":"Corrente da bateria","Componente":322,"Aferir":true,"DelayAmostragem":500,"Inicializado":false,"Testando":false,"Funcoes":[29],"Parametros":[["V offset","00.413"],["Sensibilidade","000.35"]],"UnidadeMedida":null,"Leituras":[446.0,0.36,-0.15],"ValorMinimo":-1.15,"ValorMaximo":1.51},{"LogGrafico":[],"ID":"TBAT","Prioridade":5,"Descricao":"Temperatura da bateria","Componente":411,"Aferir":true,"DelayAmostragem":500,"Inicializado":false,"Testando":false,"Funcoes":[12],"Parametros":[["V offset","0.0000"]],"UnidadeMedida":null,"Leituras":[179.53],"ValorMinimo":-273.15,"ValorMaximo":265.63}]}

View File

@ -26,6 +26,7 @@ class SensorTemperatura {
int _pino;
int _delayAmostragem;
int _prioridade;
float Voffset = 0.0;
bool Iniciado = false;
@ -116,7 +117,7 @@ class SensorTemperatura {
//float adcValue = tempKalman->updateEstimate(adc);
float adcValue = adc;
//CALCULOS PARA CONVERSÃO DA LEITURA RECEBIDA PELO ESP32 EM TEMPERATURA EM °C
Vout = adcValue * Vs / adcMax;
Vout = (adcValue * Vs / adcMax) + Voffset;
Rt = R1 * Vout / (Vs - Vout);
T = 1 / (1 / To + log(Rt / Ro) / Beta);
Tc = T - 273.15;
@ -427,6 +428,8 @@ void loop() {
case sTMP: {
SensorTemperatura* _sensor = STPorID(ID);
if (sensor_ativado) {
double _voffset = ((String)Protocolo[26] + (String)Protocolo[27] + (String)Protocolo[28] + (String)Protocolo[29] + (String)Protocolo[30] + (String)Protocolo[31]).toDouble();
_sensor->Voffset = (float)_voffset;
if (Conectar) {
_sensor->_pino = pino;
_sensor->_prioridade = prioridade;