Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hi All ,

It's my first topic.:grin:

Can you help me about the best methode for read and write Offset with FPCuser Lib.

I post 2 methodes :

the values of offset ,lenght offset ,and value offset are on a array.

//----- methode 1 -------------------------------------------------

procedure TForm1.ScanEventTQTimer(Sender: TObject);

var dwResult : DWord;

i : Word;

valeur : Word;

begin

ScanEventTQ.Enabled := False;

//--- Lecture des Offset FsUipc

For i := 89 To 105 do

begin

FSUIPC_Read(TabOffset[i,0], TabOffset[i,1], ADDR(Valeur), dwResult);

FSUIPC_Process(dwResult);

TabOffset[i,2] := Valeur; //Charge le tableau avec la valeur reçue pour l'offset correspondant

end;

ScanEventTQ.Enabled := True;

end;

//----- methode 2 -------------------------------------------------

procedure TForm1.ScanEventTQTimer(Sender: TObject);

var dwResult : DWord;

i : Word;

valeur : Word;

begin

ScanEventTQ.Enabled := False;

//--- Lecture des Offset FsUipc

For i := 89 To 105 do

begin

FSUIPC_Read(TabOffset[i,0], TabOffset[i,1], ADDR(Valeur), dwResult);

TabOffset[i,2] := Valeur; //Charge le tableau avec la valeur reçue pour l'offset correspondant

end;

FSUIPC_Process(dwResult);

ScanEventTQ.Enabled := True;

end;

Or a other ?

Thank

Best regards

Cs200 from belgium :rolleyes:

Posted

Can you help me about the best methode for read and write Offset with FPCuser Lib.

Someone may be able to help with Delphi. Sadly not I. However:

For i := 89 To 105 do

begin

FSUIPC_Read(TabOffset[i,0], TabOffset[i,1], ADDR(Valeur), dwResult);

FSUIPC_Process(dwResult);

TabOffset[i,2] := Valeur; //Charge le tableau avec la valeur reçue pour l'offset correspondant

end;

You should do all of the Reads first, THEN one process. Every Process call you make stops your program whilst control is handed over to FS/FSUIPC to get the data. It is very wasteful. The whole reason for the Process call being separated from the Reads and Writes is to allow a complete set of read/write requests to be formulated for dealing with in one efficient exchange, once per timer cycle.

For i := 89 To 105 do

begin

FSUIPC_Read(TabOffset[i,0], TabOffset[i,1], ADDR(Valeur), dwResult);

TabOffset[i,2] := Valeur; //Charge le tableau avec la valeur reçue pour l'offset correspondant

end;

FSUIPC_Process(dwResult);

that looks better, except that it won't work like that because your values won't appear in your "Valeur" variable until AFTER the Process call (obviously?).

Why not read directly into where you want them to go -- i.e. "TabOffset[i,2]". What's the point in putting them in "Valeur" then trasferring them?

Pete

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.