1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| void __fastcall TFormMEC::CPortRxChar(TObject *Sender, int Count)
{
char *cRx = new char [Count];
CPort->Read(cRx, Count);
int index = 0;
do
{
if((cRx[index++] == CHAR(0xFF))&&(Count >= 5))
{
int iVal1;
int iVal2;
double dVal;
//Débit
iVal1 = (int) cRx[index++];
iVal1 += 128;
iVal2 = (int) cRx[index++];
iVal2 += 128;
iVal2 *= 256;
iVal2 += iVal1;
dVal = (double)iVal2;
//Ajout du debit dans le graphique
//Erreur 1-> SerieDebit->AddXY(iTrame, dVal, "", clRed);
//Pression
iVal1 = (int) cRx[index++];
iVal1 += 128;
iVal2 = (int) cRx[index++];
iVal2 += 128;
iVal2 *= 256;
iVal2 += iVal1;
dVal = (double)iVal2;
//Ajout du debit dans le graphique
//Erreur 2-> SeriePression->AddXY(iTrame,iVal2, "", clRed);
iTrame++;
//Ajustement des echelles des graphiques
if(iTrame > iEchelle)
{
ChartDebit->BottomAxis->Maximum = iTrame;
ChartPression->BottomAxis->Maximum = iTrame;
ChartDebit->BottomAxis->Minimum = iTrame - iEchelle;
ChartPression->BottomAxis->Minimum = iTrame - iEchelle;
if(!iEchelle)
{
ChartDebit->BottomAxis->Maximum = iTrame;
ChartPression->BottomAxis->Maximum = iTrame;
ChartDebit->BottomAxis->Minimum = 0;
ChartPression->BottomAxis->Minimum = 0;
}
}
else
InitEchelle();
}
else
index++;
}
while(index < Count);
} |