Cs200 Posted December 1, 2010 Report Posted December 1, 2010 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:
Pete Dowson Posted December 1, 2010 Report Posted December 1, 2010 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now