Jump to content
The simFlight Network Forums

Best methode for read and write to FsUip with Delphi


 Share

Recommended Posts

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:

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • 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.