procedure TForm1.CommPortDriver1ReceiveData(Sender: TObject;
DataPtr: Pointer; DataSize: Cardinal);
Var
PosA: PChar;
cTimer: String;
nByte: Shortint;
// StructTime: TStructTime;
TickCount: DWORD;
pArray: ^nArray;
begin
PosA := AnsiStrScan(DataPtr, 'A');
if (PosA <> nil )
Then Begin
If Not((PosA+27)^='Z')
Then Exit;
//StatusBar1.Panels[0].Text := 'Recibiendo datos';
Trama.Pitch_Rate_Out := Ord((PosA+1)^)*256+Ord((PosA+2)^);
Trama.Pitch_Volt := Ord((PosA+3)^)*256+Ord((PosA+4)^);
Trama.Pitch_Temperature := Ord((PosA+5)^)*256+Ord((PosA+6)^);
if CheckBox2.Checked
Then Begin
StaticText1.Caption := IntToStr(Trama.Pitch_Rate_Out);
ProgressBar1.Position := Trama.Pitch_Rate_Out;
StaticText15.Caption := IntToStr(Trama.Pitch_Volt);
StaticText18.Caption := IntToStr(Trama.Pitch_Temperature);
End;
Trama.Roll_Rate_Out := Ord((PosA+7)^)*256+Ord((PosA+8)^);
Trama.Roll_Volt := Ord((PosA+9)^)*256+Ord((PosA+10)^);
Trama.Roll_Temperature := Ord((PosA+11)^)*256+Ord((PosA+12)^);
if CheckBox2.Checked
Then Begin
StaticText2.Caption := IntToStr(Trama.Roll_Rate_Out);
ProgressBar2.Position := Trama.Roll_Rate_Out;
StaticText16.Caption := IntToStr(Trama.Roll_Volt);
StaticText19.Caption := IntToStr(Trama.Roll_Temperature);
End;
Trama.Yaw_Rate_Out := Ord((PosA+13)^)*256+Ord((PosA+14)^);
Trama.Yaw_Volt := Ord((PosA+15)^)*256+Ord((PosA+16)^);
Trama.Yaw_Temperature := Ord((PosA+17)^)*256+Ord((PosA+18)^);
if CheckBox2.Checked
Then Begin
StaticText3.Caption := IntToStr(Trama.Yaw_Rate_Out);
ProgressBar3.Position := Trama.Yaw_Rate_Out;
StaticText17.Caption := IntToStr(Trama.Yaw_Volt);
StaticText20.Caption := IntToStr(Trama.Yaw_Temperature);
End;
Trama.X_acceleration := Ord((PosA+19)^)*256+Ord((PosA+20)^);
Trama.Y_acceleration := Ord((PosA+21)^)*256+Ord((PosA+22)^);
Trama.Z_acceleration := Ord((PosA+23)^)*256+Ord((PosA+24)^);
if CheckBox2.Checked
Then Begin
StaticText7.Caption := IntToStr(Trama.X_acceleration);
ProgressBar4.Position := Trama.X_acceleration;
StaticText8.Caption := IntToStr(Trama.Y_acceleration);
ProgressBar5.Position := Trama.Y_acceleration;
StaticText9.Caption := IntToStr(Trama.Z_acceleration);
ProgressBar6.Position := Trama.Z_acceleration;
End;
Trama.Battery_Reference := Ord((PosA+25)^)*256+Ord((PosA+26)^);
if CheckBox2.Checked
Then StaticText13.Caption := IntToStr(Trama.Battery_Reference);
// ¿DataLogger Activo?
If CheckBox1.Checked
Then Begin
// ¿Fichero Ascii?
If RadioButton1.Checked
Then Begin
// ¿Sacar control de tiempo?
if CheckBox3.Checked
Then cTimer := FormatCurr( '0000000000', GetTickCount )
Else cTimer := '';
Writeln(hFileT, 'A'+
cTimer +
FormatCurr('0000',Trama.Pitch_Rate_Out)+
FormatCurr('0000',Trama.Pitch_Volt)+
FormatCurr('0000',Trama.Pitch_Temperature)+
FormatCurr('0000',Trama.Roll_Rate_Out)+
FormatCurr('0000',Trama.Roll_Volt)+
FormatCurr('0000',Trama.Roll_Temperature)+
FormatCurr('0000',Trama.Yaw_Rate_Out)+
FormatCurr('0000',Trama.Yaw_Volt)+
FormatCurr('0000',Trama.Yaw_Temperature)+
FormatCurr('0000',Trama.X_acceleration)+
FormatCurr('0000',Trama.Y_acceleration)+
FormatCurr('0000',Trama.Z_acceleration)+
FormatCurr('0000',Trama.Battery_Reference)+
'Z');
End;
// ¿Fichero Binario?
If RadioButton2.Checked
Then Begin
// Sacar marcador "A"
nByte := Ord('A');
Write(hFileB, nByte);
// ¿Sacar control de tiempo?
if CheckBox3.Checked
Then Begin
TickCount := GetTickCount;
pArray := @TickCount;
nByte := (pArray^)[3];
Write(hFileB, nByte);
nByte := (pArray^)[2];
Write(hFileB, nByte);
nByte := (pArray^)[1];
Write(hFileB, nByte);
nByte := (pArray^)[0];
Write(hFileB, nByte);
End;
// Pitch_Rate_Out
nByte := Ord((PosA+1)^);
Write(hFileB, nByte);
nByte := Ord((PosA+2)^);
Write(hFileB, nByte);
// Pitch_Volt
nByte := Ord((PosA+3)^);
Write(hFileB, nByte);
nByte := Ord((PosA+4)^);
Write(hFileB, nByte);
// Pitch_Temperature
nByte := Ord((PosA+5)^);
Write(hFileB, nByte);
nByte := Ord((PosA+6)^);
Write(hFileB, nByte);
// Roll_Rate_Out
nByte := Ord((PosA+7)^);
Write(hFileB, nByte);
nByte := Ord((PosA+8)^);
Write(hFileB, nByte);
// Roll_Volt
nByte := Ord((PosA+9)^);
Write(hFileB, nByte);
nByte := Ord((PosA+10)^);
Write(hFileB, nByte);
// Roll_Temperature
nByte := Ord((PosA+11)^);
Write(hFileB, nByte);
nByte := Ord((PosA+12)^);
Write(hFileB, nByte);
// Yaw_Rate_Out
nByte := Ord((PosA+13)^);
Write(hFileB, nByte);
nByte := Ord((PosA+14)^);
Write(hFileB, nByte);
// Yaw_Volt
nByte := Ord((PosA+15)^);
Write(hFileB, nByte);
nByte := Ord((PosA+16)^);
Write(hFileB, nByte);
// Yaw_Temperature
nByte := Ord((PosA+17)^);
Write(hFileB, nByte);
nByte := Ord((PosA+18)^);
Write(hFileB, nByte);
// X_acceleration
nByte := Ord((PosA+19)^);
Write(hFileB, nByte);
nByte := Ord((PosA+20)^);
Write(hFileB, nByte);
// Y_acceleration
nByte := Ord((PosA+21)^);
Write(hFileB, nByte);
nByte := Ord((PosA+22)^);
Write(hFileB, nByte);
// Z_acceleration
nByte := Ord((PosA+23)^);
Write(hFileB, nByte);
nByte := Ord((PosA+24)^);
Write(hFileB, nByte);
// Battery_Reference
nByte := Ord((PosA+25)^);
Write(hFileB, nByte);
nByte := Ord((PosA+26)^);
Write(hFileB, nByte);
// Sacar marcador "Z"
nByte := Ord('Z');
Write(hFileB, nByte);
End;
End;
End;
end;