Jump to content


Photo

Data constant update

update stream data

  • Please log in to reply
4 replies to this topic

#1 Toofar

Toofar
  • Members
  • 2 posts

Posted 05 May 2016 - 12:11 PM

Hi,

 

I'm trying to constantly update a nextgrid from a trading source (opened positions) and fail to achieve this.

Could you please advice the best way to do that?

//____________________________________
//
//    EVENTS ROW CHANGED
//_____________________________________
procedure TfCore.TradeDeskEventsSink1RowChanged(ASender: TObject;
  const pTableDisp: IDispatch; const sRowID: WideString);
var
    Count_ , trowcount, tcolcount: Integer;
begin
//data processing for Row Changed Events
    application.ProcessMessages;

 ....here some code to get the data


    nxtrades.ClearRows;
    nxtrades.AddRow;
     for irow := 1 to tRowCount do
          begin
          Nxtrades.Cell[nxtradeid.index,nxtrades.lastaddedrow].asstring := toRows.Item(irow).TradeID;
          Nxtrades.Cell[nxAccountID.index,nxtrades.lastaddedrow].asstring := toRows.Item(irow).AccountID;
          end;
end;


#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 7,688 posts
  • Gender:Male

Posted 05 May 2016 - 01:53 PM

Hi,

I will rather place ProcessMessages at the end of method, and also call BeginUpdate/EndUpdate before big changes.

BeginUpdate Reference: http://developer.ber...=140&lang=en-us
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Members Section: bms.bergsoft.net
Articles and Tutorials: dn.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 Toofar

Toofar
  • Members
  • 2 posts

Posted 05 May 2016 - 02:27 PM

I've moved the process message and added the begin update.

But I only got the first line. I've checked thru step by step and the two lines are updated and correctly stored in the nxtrades grid.

and the grid is blincking.

Just for precision. This process could happens many times per second.

//____________________________________
//
//    EVENTS ROW CHANGED
//_____________________________________
procedure TfCore.TradeDeskEventsSink1RowChanged(ASender: TObject;
  const pTableDisp: IDispatch; const sRowID: WideString);
var
    Count_ , trowcount, tcolcount: Integer;
begin
//data processing for Row Changed Events


 ....here some code to get the data

    nxtrades.BeginUpdate;
    nxtrades.ClearRows;
    nxtrades.AddRow;
    
     for irow := 1 to tRowCount do
          begin
          Nxtrades.Cell[nxtradeid.index,nxtrades.lastaddedrow].asstring := toRows.Item(irow).TradeID;
          Nxtrades.Cell[nxAccountID.index,nxtrades.lastaddedrow].asstring := toRows.Item(irow).AccountID;
... 20 differents lines goes here...
          end;
Nxtrades.EndUpdate;
 application.ProcessMessages;
end;


#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 7,688 posts
  • Gender:Male

Posted 05 May 2016 - 02:55 PM

Hi,

Maybe in your case BeginUpdate is not needed (since EndUpdate refresh all cells). I noticed that you are calling AddRow only once so maybe this is why only one row is added.

Not sure if is possible to send me very small demo project. Maybe you can re-create it with random data, without server and send it to me.
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Members Section: bms.bergsoft.net
Articles and Tutorials: dn.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#5 Eduard1966

Eduard1966
  • Members
  • 60 posts
  • Gender:Male

Posted 06 May 2016 - 07:01 AM

If you use:

 

nxtrades.ClearRows; // <---- Grid = 0
nxtrades.AddRow; // Grid = 1; 

 

You always see one Row...







Also tagged with one or more of these keywords: update, stream data

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users