0
I have an app where I have to do a drying program for a greenhouse, where I measure and humidities of a wood, I program it and send it to the machine and so on, but when I see the report of such drying, the humidities are totally different, knowing that the only difference in the two forms should be only the "Status", thing that when programming the drying program does not have:
Programme report:
Report of the Drying:
and the code made for the drying report:
private void CarregarProgramaDeSecagem(List<FaseSecagem> listaFases)
{
try
{
for (int i = 0; i < listaFases.Count; i++)
{
dtgProgramaDaSecagem.Rows.Add(listaFases[i].Fase + 1,
listaFases[i].InicioFase,
listaFases[i].NumeroLeitura,
listaFases[i].Faixa,
listaFases[i].Via,
listaFases[i].Banho,
listaFases[i].DeltaT,
listaFases[i].ValorDesejadoSeco.ToString("00.0"),
listaFases[i].ValorDesejadoUmido.ToString("00.0"),
listaFases[i].UmidadeRelativa.ToString("00.0"),
listaFases[i].UmidadeEquilibrio.ToString("00.0"),
listaFases[i].Potencial.ToString("0.0"),
listaFases[i].VMot,
listaFases[i].TempoDaFase,
listaFases[i].Status);
dtgProgramaDaSecagem.Rows[i].DefaultCellStyle.BackColor = i % 2 == 0 ? Color.LightGreen : Color.White;
}
dtgProgramaDaSecagem.ClearSelection();
}
catch (Exception error)
{
LogErro logErro = new LogErro();
logErro.DMC = _secagem.IdDispositivo;
logErro.Descricao = "Erro ao tentar carregar programa da secagem do relatório da secagem";
string dataHora = DateTime.Now.ToString();
logErro.Data = dataHora.Substring(0, 10);
logErro.Hora = dataHora.Substring(11, 8);
logErro.MaisDetalhes = error.Message;
LogErroDAO.InserirLogErro(logErro);
}
}
And below the code with the calculations made:
////Método para o cálculo da umidade relativa
public static double[] calcularUmidadeRelativa(float bulboSeco, float bulboUmido, float umidadeMedia, int umFinal)
{
double pVu, pSs, uRu = 0, k1, k2, w, h, uEu, uE, p, pM;
double[] resultado = new double[3];
if (bulboUmido != 0)
{
pVu = (9.1466 - (2316 / (273 + bulboUmido)));
pVu = Math.Exp(pVu * Math.Log(10));
pVu = pVu - 0.5 * (bulboSeco - bulboUmido);
pSs = (9.1466 - (2316 / (273 + bulboSeco)));
pSs = Math.Exp(pSs * Math.Log(10));
uRu = (pVu / pSs) * 100;
if (uRu >= 100)
{
uRu = 99.9;
}
else if (uRu < 0)
{
uRu = 0;
}
}
else
{
uRu = 0;
}
k1 = 4.737 + (0.047734 * bulboSeco) - (0.000501228 * bulboSeco * bulboSeco);
k2 = 0.70594 + (0.00169794 * bulboSeco) - (0.00000555336 * bulboSeco * bulboSeco);
w = 223.374 + (0.69309 * bulboSeco) + (0.0185328 * bulboSeco * bulboSeco);
h = (uRu / 100);
uEu = (((k1 * k2 * h) / (1 + (k1 * k2 * h))) + ((k2 * h) / (1 - (k2 * h)))) * (1800 / w);
////Para pegar somente a fração se quiser 3numeros *1000, 2*100, 1*10 etc....
//int frac = (int)Math.Truncate((uEu - Math.Truncate(uEu)) * 10);
//if (frac==5)
// uEu = uEu + 0.05;
uE = uEu;
if (uE == 0)
{
p = 0;
}
else
{
pM = (umFinal / uE);
p = pM;
}
resultado[0] = uRu;
resultado[1] = uE;
resultado[2] = p;
return resultado;
}
EU:
public static double[] CalculaUE(float Ps, float UE, int umFinal, double P, int indice, double pU)
{
double[] resultado = new double[3];
double Bu, Uerr1, Uerr2, URAnt, Uru, PVu, PSs, pUE, PUmdRel, K1, K2;
double w, H, Pm, pUR;
K1 = 4.737 + (0.047734 * Ps) - (0.000501228 * Ps * Ps);
K2 = 0.70594 + (0.00169794 * Ps) - (5.55336E-06 * Ps * Ps);
w = 223.374 + (0.69309 * Ps) + (0.0185328 * Ps * Ps);
pUE = 100;
do
{
H = (pUE / 100);
PUmdRel = (((K1 * K2 * H) / (1 + (K1 * K2 * H))) + ((K2 * H) / (1 - (K2 * H)))) * (1800 / w);
pUE = pUE - 0.1;
} while (PUmdRel >= UE);
pUR = H * 100;
if (pUR >= 100)
{
pUR = 99.9;
}
if (pUR < 0)
{
pUR = 0.0;
}
Bu = Ps;
Uru = 100;
do
{
URAnt = Uru;
Bu = Bu - 0.1;
PVu = 9.1466 - (2316 / (273 + Bu));
PVu = Math.Exp((PVu * Math.Log(10)));
PVu = PVu - (0.5 * (Ps - Bu));
PSs = 9.1466 - (2316 / (273 + Ps));
PSs = Math.Exp((PSs * Math.Log(10)));
Uru = (PVu / PSs) * 100;
} while (Uru >= pUR);
if (Uru < pUR)
{
Uerr1 = pUR - Uru;
Uerr2 = URAnt - pUR;
if (Uerr1 > Uerr2)
{
pU = Bu + 0.1;
}
else
{
pU = Bu;
}
}
if (pU < 0)
{
pU = 0.0;
}
if (pUE == 0.0)
{
P = 0;
}
else
{
Pm = umFinal / pUE;
P = Pm;
}
resultado[0] = pU;
resultado[1] = pUR;
resultado[2] = P;
return resultado;
}
have how to post the code of the program? at'e Puc is correct, there is no extra calculation for the other columns?
– HudsonPH
@Hudsonph the code is quite extensive, I don’t know if I can post here, but yes, even Puc is right, beyond this tab, there is more indicating the data of the drying, data of treatment and interruptions occurred, where all are right, taking out the drying program that feel errors
– gbcga97
You can not know where the error is without comparing the 2 codes, at least some Pot Echo in your case 'and Pt, yes?
– HudsonPH
@Hudsonph posted the code parts where the calculations are made
– gbcga97
what is the need for the
do while
the value will be different if the condicacao is accepted, except in the first examplebulboUmido
just can’t be 0. The examples are quite different.– HudsonPH