Update DataGrid Slow

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
gilar
Posts: 96
Joined: Sat Sep 26, 2015 12:59 pm

Update DataGrid Slow

Post by gilar » Fri May 07, 2021 6:54 am

I'm creating a livecode apps with DataGrid tabele
This apps connect into Timing System via TCPIP
Timing system feed data (string) about 100 message / seconds
and i'm planning to populate it into DatGrid
I've tried in several ways:
- set the dgData ...
- set the dgDataOfIndex / dgDataOfIndex ....
- dispatch "SetDataOfIndex" to ....
but what i've got is DtaGrid feel slow and about 2-3 seconds freeze
is there another way to increase the speed of update/populate DataGrid table from this kind of data?
Comment and help would be appreciate


Best Regards

Gilar
Gilar | from INDONESIA

Klaus
Posts: 12354
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Update DataGrid Slow

Post by Klaus » Fri May 07, 2021 10:21 am

Hi Gilar,
- set the dgData ...
- set the dgDataOfIndex / dgDataOfIndex ...
- dispatch "SetDataOfIndex" to ...
I'm afraid these are the only commands that the DataGrid API provides for us.
100 messages per second
Does that mean you want to update the datagrid that often?
That may be a bit too optimistic. 8)

Maybe you can post your script here, so we can see if we can "pimp" it a bit.


Best

Klaus

gilar
Posts: 96
Joined: Sat Sep 26, 2015 12:59 pm

Re: Update DataGrid Slow

Post by gilar » Fri May 07, 2021 7:45 pm

Hi Klaus ... you again.
Thanks for quick replay
Klaus wrote:
Fri May 07, 2021 10:21 am
Does that mean you want to update the datagrid that often?
Yes it is, you can image that this is about time record of race.
I wanto to pull data from timing system and put it into dataGrid
every racer/competitor will push data while he passed receiver.

this is the data feed from timing system

Code: Select all

$COMP,"13A","13A",1,"KEMAL ANDREA","","BANTEN","MPS SAHARA WORKS VMX KYT R9 IM PRIMALAND"
$COMP,"99B","99B",1,"CHESSY MEILANDRI","","JABAR","PRIVATEER"
$COMP,"486","486",1,"DHITO SATRIA PRADANA","","JATIM","R-MAX-G SCA CORP MS DM 65"
$COMP,"99A","99A",1,"DESMONT JONATHAN","","JATIM","WTM NMT IM PRODUCT KISWORO MX"
$COMP,"117","117",1,"MIFTAKHUL ANDIKA HAMDANI","","JATIM","PESONA TV FRUIT WATER MELON NMT"
$COMP,"339","339",1,"RADHEVA","","BALI","BALI MX CORSA JPX MELON VMX ORCA JATIMAS"
$COMP,"79","79",1,"ANSEL RAFAY BRYAN","","JATIM","DUPONT KORTEVA S HUDA 27"
$COMP,"11","11",1,"CHRISTIAN JADEN GIOVANI","","DIY","YES MX"
$COMP,"26","26",1,"IVAN VALROSSI","","DIY","PERTAMINA PATRA NIAGA REHOBAT KYT IRC ARDIANS"
$COMP,"17","17",1,"ANGGA ATHAREIHANSYAH LUBIS","","DIY","OREL MX SINAR MAS BANK EKA SBN BOM'S 161 BRET'S RA"
$COMP,"66","66",1,"AGRAVINO NAYOTTAMA","","JATIM","GRIYA BUSANA I'M PRODUCT JPMX ACADEMY"
$COMP,"525","525",1,"DYAZ PERMNA","","NTT","MANDIRI JAYA MX JPMX ACADEMY"
$A,"13A","13A",1002,"KEMAL ANDREA","","BANTEN",1
$A,"99B","99B",1008,"CHESSY MEILANDRI","","JABAR",1
$A,"486","486",1011,"DHITO SATRIA PRADANA","","JATIM",1
$A,"99A","99A",1007,"DESMONT JONATHAN","","JATIM",1
$A,"117","117",1009,"MIFTAKHUL ANDIKA HAMDANI","","JATIM",1
$A,"339","339",1010,"RADHEVA","","BALI",1
$A,"79","79",1006,"ANSEL RAFAY BRYAN","","JATIM",1
$A,"11","11",1001,"CHRISTIAN JADEN GIOVANI","","DIY",1
$A,"26","26",1004,"IVAN VALROSSI","","DIY",1
$A,"17","17",1003,"ANGGA ATHAREIHANSYAH LUBIS","","DIY",1
$A,"66","66",1005,"AGRAVINO NAYOTTAMA","","JATIM",1
$A,"525","525",1012,"DYAZ PERMNA","","NTT",1
$B,95,"65CC NOVICE"
$G,12,"117",10,"00:08:12.875"
$G,11,"66",10,"00:08:12.203"
$G,10,"525",10,"00:08:12.141"
$G,9,"99B",10,"00:08:02.719"
$G,8,"11",10,"00:08:01.563"
$G,7,"13A",10,"00:07:54.000"
$G,6,"26",10,"00:07:53.531"
$G,5,"339",10,"00:07:45.047"
$G,4,"486",10,"00:07:44.703"
$G,3,"99A",10,"00:07:43.516"
$G,2,"17",10,"00:07:41.531"
$G,1,"79",10,"00:07:41.312"
$H,12,"117",4,"00:00:48.797"
$H,11,"66",1,"00:00:48.719"
$H,10,"525",5,"00:00:48.515"
$H,9,"99B",8,"00:00:47.703"
$H,8,"11",2,"00:00:47.547"
$H,7,"13A",7,"00:00:47.047"
$H,6,"26",10,"00:00:46.219"
$H,5,"339",5,"00:00:46.141"
$H,4,"486",2,"00:00:46.078"
$H,3,"99A",8,"00:00:45.890"
$H,2,"79",5,"00:00:45.875"
$H,1,"17",7,"00:00:45.844"
$G,1,11,,00:00:00.000
$G,2,525,,00:00:00
$G,3,66,,00:00:00
$G,4,17,,00:00:00
$G,5,26,,00:00:00
$G,2,13A,,00:00:00.000
$G,1,17,,00:00:00.000
$G,3,525,,00:00:00
$G,4,66,,00:00:00
$G,6,26,,00:00:00
$G,1,11,,00:00:00.000
$G,7,79,,00:00:00
$G,8,339,,00:00:00
$G,9,117,,00:00:00
$G,10,99A,,00:00:00
$G,11,486,,00:00:00
$G,12,99B,,00:00:00
$G,4,525,,00:00:00
$G,5,66,,00:00:00
$G,1,17,,00:00:00.000
$G,2,11,,00:00:00.000
$G,3,13A,,00:00:00.000
$G,2,26,,00:00:00.000
$G,1,66,,00:00:00.000
$G,5,525,,00:00:00
$G,1,17,,00:00:00.000
$G,3,11,,00:00:00.000
$G,4,13A,,00:00:00.000
$G,6,525,,00:00:00
$G,1,66,,00:00:00.000
$G,2,17,,00:00:00.000
$G,3,26,,00:00:00.000
$G,4,11,,00:00:00.000
$G,5,13A,,00:00:00.000
$G,5,79,,00:00:00.000
$G,6,99A,,00:00:00.000
$G,7,525,,00:00:00
$G,6,13A,,00:00:00.000
$G,7,99B,,00:00:00.000
$G,8,525,,00:00:00
$G,9,339,,00:00:00
$G,10,117,,00:00:00
$G,6,99A,,00:00:00.000
$G,7,13A,,00:00:00.000
$G,9,525,,00:00:00
$G,10,339,,00:00:00
$G,11,117,,00:00:00
$G,12,486,,00:00:00
$G,7,99B,,00:00:00.000
$G,8,13A,,00:00:00.000
$G,6,117,,00:00:00.000
$G,6,339,,00:00:00.000
$G,10,525,,00:00:00
$G,6,117,,00:00:00.000
$G,7,99A,,00:00:00.000
$G,8,99B,,00:00:00.000
$G,9,13A,,00:00:00.000
$G,9,486,,00:00:00.000
$G,11,525,,00:00:00
$G,6,339,,00:00:00.000
$G,7,117,,00:00:00.000
$G,8,99A,,00:00:00.000
$G,9,99B,,00:00:00.000
$G,10,13A,,00:00:00.000
$G,1,525,,00:00:00.000
$G,9,486,,00:00:00.000
$G,10,99B,,00:00:00.000
$G,11,13A,,00:00:00.000
$G,2,66,,00:00:00.000
$G,3,17,,00:00:00.000
$G,4,26,,00:00:00.000
$G,5,11,,00:00:00.000
$G,6,79,,00:00:00.000
$G,7,339,,00:00:00.000
$G,8,117,,00:00:00.000
$G,9,99A,,00:00:00.000
$G,10,486,,00:00:00.000
$G,11,99B,,00:00:00.000
$G,12,13A,,00:00:00.000
$G,1,17,1,00:00:46.438
$G,2,525,,00:00:00.000
$G,3,66,,00:00:00.000
$G,1,66,1,00:00:46.204
$G,3,525,,00:00:00.000
$G,2,17,1,00:00:46.438
$G,1,99B,1,00:00:46.156
$G,4,525,,00:00:00.000
$G,2,66,1,00:00:46.204
$G,3,17,1,00:00:46.438
$G,5,26,,00:00:00.000
$G,6,11,,00:00:00.000
$G,7,79,,00:00:00.000
$G,8,339,,00:00:00.000
$G,9,117,,00:00:00.000
$G,10,99A,,00:00:00.000
$G,11,486,,00:00:00.000
$G,3,525,1,00:00:46.375
$G,5,79,1,00:00:48.000
$G,5,99A,1,00:00:47.797
$G,4,17,1,00:00:46.438
$G,5,26,,00:00:00.000
$G,5,79,1,00:00:48.000
$G,5,99A,1,00:00:47.797
$G,5,486,1,00:00:47.000
$G,7,26,,00:00:00.000
$G,8,11,,00:00:00.000
$G,6,79,1,00:00:48.000
$G,9,339,,00:00:00.000
$G,10,117,,00:00:00.000
$G,5,99A,1,00:00:47.797
$G,5,486,1,00:00:47.000
$G,8,13A,1,00:00:49.687
$G,8,26,,00:00:00.000
$G,9,11,,00:00:00.000
$G,7,79,1,00:00:48.000
$G,10,339,,00:00:00.000
$G,11,117,,00:00:00.000
$G,6,99A,1,00:00:47.797
$G,8,13A,1,00:00:49.687
$G,9,11,1,00:00:50.313
$G,9,26,,00:00:00.000
$G,9,11,1,00:00:50.313
$G,11,339,,00:00:00.000
$G,12,117,,00:00:00.000
$G,8,26,1,00:00:49.406
$G,7,339,1,00:00:47.875
$G,8,13A,1,00:00:49.687
$G,9,117,1,00:00:48.250
$G,9,26,1,00:00:49.406
$G,11,11,1,00:00:50.313
$G,8,79,1,00:00:48.000
$G,9,117,1,00:00:48.250
$G,10,13A,1,00:00:49.687
$G,10,26,1,00:00:49.406
$G,12,11,1,00:00:50.313
$G,11,13A,1,00:00:49.687
Klaus wrote:
Fri May 07, 2021 10:21 am
That may be a bit too optimistic. 8)
I though so too, but i hope there is another solution for my problem ...

this the scrip to pull all thouse data

Code: Select all


on MYLAPS_Message pSocket, pMsg
   if pSocket = SocketMYLAPS Then
      put format("\r\n") into endFeed
      put pMsg before field "orbit.log_fld" of card "games_crd"
      switch
       case pMsg contains "$COMP" ----------------------------    $$COMP
            set itemdelimiter to  ","
            replace quote with empty in pMsg
            filter pMsg without empty
            replace numToChar(0x0D) with empty in pMsg
            replace numToChar(0x0A) with empty in pMsg
            MYLAPS.Data_COMP pMsg
            
            put empty into readMsg
            read from socket pSocket until endFeed with message MYLAPS_Message
            break
         case pMsg contains "$G" ----------------------------    $G
            set itemdelimiter to  ","
            replace quote with empty in pMsg
            filter pMsg without empty
            replace numToChar(0x0D) with empty in pMsg
            replace numToChar(0x0A) with empty in pMsg
            if the hilite button "race_chk" of card "games_crd" is true then
               MYLAPS.Data_G pMsg
            end if
            put empty into readMsg
            read from socket pSocket until endFeed with message MYLAPS_Message
            break
      end switch
      put empty into readMsg
      read from socket pSocket until endFeed with message MYLAPS_Message ---- perintah pengulangan
   End if
end MYLAPS_Message


on MYLAPS.Data_G pMsg
   /*
   FEED DATA CASE (Hasil Analisis Pribadi dari data $G)
   $G,POS,REG-NUMB,LAPS,TOTALTIME
   - Posisi empty,__,LAP empty, TT empty		Update POSISI,	LAP, 	TIME 
   - Posisi beda,__,LAP sama, TT sama		Update POSISI,
   - Posisi beda,__,LAP beda, TT lebih besar	Update POSISI,	LAP,	TIME
   - Posisi sama,__,LAP beda, TT lebih besar	Update 		LAP,	TIME
   
   URUTAN UPDATE DI SEMUA CASE
   Update Pos LAP dan Total Time
   Hitung DIFF dan GAP
   Update DIFF dan GAP
   Update MARK POSITION
   */
   -- deklarasi
   put item 2 of pMsg into tCompPosition
   put item 3 of pMsg into tCompRegNumber
   put item 4 of pMsg into tCompLap
   put item 5 of pMsg into tCompTotalTime
   
   put the dgNumberOfRecords of group "race.result_grd" of card "games_crd" into pLine
   put the dgData of group "term_grd" of card "setting_crd" into tTerms
   put field "standing.bar_fld" of card "games_crd" into tJumlahBarStanding
   
   dispatch "FindIndex" to group "race.result_grd" of card "games_crd" with "REGISTRATION NUMBER", tCompRegNumber
   put the result into theIndex
   put the dgDataOfIndex [theIndex] of group "race.result_grd" of card "games_crd" into tDGArrayIndex
   put tDGArrayIndex["POSITION"] into tDGPos
   put tDGArrayIndex["LAPS"] into tDGLap
   put tDGArrayIndex["TOTAL TIME"] into tDGTotalTime
   
   if theIndex = 0 then
      --- do nothing
      exit MYLAPS.Data_G
   else
      switch
         case tDGPos=empty and tDGLap=empty and tDGTotalTime=empty
            -- Posisi empty,__,LAP empty, TT empty---->Update POSISI,	LAP, 	TIME 
            --- Update $G
            dispatch "SetDataOfIndex" to group "race.result_grd" of card "games_crd" with theIndex, "POSITION", tCompPosition
            dispatch "SetDataOfIndex" to group "race.result_grd" of card "games_crd" with theIndex, "LAPS", tCompLap
            dispatch "SetDataOfIndex" to group "race.result_grd" of card "games_crd" with theIndex, "TOTAL TIME", tCompTotalTime
            -- refresh DataGrid
            dispatch "RefreshIndex" to group "race.result_grd" of card "games_crd"  with theIndex
            
            -- Calculate DIFF and GAP
            MYLAPS.Data_G_Calculate.DIFF theIndex, pLine, tCompPosition, tCompLap, tCompTotalTime, tJumlahBarStanding
            MYLAPS.Data_G_Calculate.GAP theIndex, pLine, tCompPosition, tCompLap, tCompTotalTime, tJumlahBarStanding
            
            break
         case tDGPos <> tCompPosition and  tDGLap = tCompLap and Time.Convert_TCtoSecond(tDGTotalTime) = Time.Convert_TCtoSecond(tCompTotalTime)
            -- Posisi beda,__,LAP sama, TT sama ---->Update POSISI,
            --- Update $G
            dispatch "SetDataOfIndex" to group "race.result_grd" of card "games_crd" with theIndex, "POSITION", tCompPosition
            -- refresh DataGrid
            dispatch "RefreshIndex" to group "race.result_grd" of card "games_crd"  with theIndex
            --- Calculate DIFF and GAP
            MYLAPS.Data_G_Calculate.DIFF theIndex, pLine, tCompPosition, tCompLap, tCompTotalTime, tJumlahBarStanding
            MYLAPS.Data_G_Calculate.GAP theIndex, pLine, tCompPosition, tCompLap, tCompTotalTime, tJumlahBarStanding
            break
         case tDGPos <> tCompPosition and  tDGLap <> tCompLap and Time.Convert_TCtoSecond(tDGTotalTime) < Time.Convert_TCtoSecond(tCompTotalTime)
            -- Posisi beda,__,LAP beda, TT lebih besar	---->Update POSISI,	LAP,	TIME
            --- Update $G
            dispatch "SetDataOfIndex" to group "race.result_grd" of card "games_crd" with theIndex, "POSITION", tCompPosition
            dispatch "SetDataOfIndex" to group "race.result_grd" of card "games_crd" with theIndex, "LAPS", tCompLap
            dispatch "SetDataOfIndex" to group "race.result_grd" of card "games_crd" with theIndex, "TOTAL TIME", tCompTotalTime
            -- refresh DataGrid
            dispatch "RefreshIndex" to group "race.result_grd" of card "games_crd"  with theIndex
            -- Calculate DIFF and GAP
            MYLAPS.Data_G_Calculate.DIFF theIndex, pLine, tCompPosition, tCompLap, tCompTotalTime, tJumlahBarStanding
            MYLAPS.Data_G_Calculate.GAP theIndex, pLine, tCompPosition, tCompLap, tCompTotalTime, tJumlahBarStanding
            break
         case tDGPos = tCompPosition and  tDGLap <> tCompLap and Time.Convert_TCtoSecond(tDGTotalTime) < Time.Convert_TCtoSecond(tCompTotalTime)
            -- Posisi sama,__,LAP beda, TT lebih besar	---->Update 		LAP,	TIME
            --- Update $G
            dispatch "SetDataOfIndex" to group "race.result_grd" of card "games_crd" with theIndex, "LAPS", tCompLap
            dispatch "SetDataOfIndex" to group "race.result_grd" of card "games_crd" with theIndex, "TOTAL TIME", tCompTotalTime
            -- refresh DataGrid
            dispatch "RefreshIndex" to group "race.result_grd" of card "games_crd"  with theIndex
            --- Calculate DIFF and GAP
            MYLAPS.Data_G_Calculate.DIFF theIndex, pLine, tCompPosition, tCompLap, tCompTotalTime, tJumlahBarStanding
            MYLAPS.Data_G_Calculate.GAP theIndex, pLine, tCompPosition, tCompLap, tCompTotalTime, tJumlahBarStanding
            break
      end switch
      --- sort collumn
      if tCompPosition = pLine  or tCompPosition = the round of (pLine/2) then --- 
         draco.datagrid_sortposition
         --         if tCompPosition = pLine then
         --            draco.save.result_manual
         --         end if
      end if
      if the backgroundcolor of button "standing_btn" of card "games_crd" is green and the label of button "standing_btn" of card "games_crd" contains "PAGE 1"then
         put "30" into tTemplateIndex
         CasparCGTempUpdate_StandingLeft_Pos tTemplateIndex
      end if 
      
      if the backgroundcolor of button "standleft.time_btn" of card "games_crd" is green and tCompPosition < (tJumlahBarStanding + 1) then
         put "31" into tTemplateIndex
         CasparCGTempUpdate_StandingLeft_Time tTemplateIndex, tCompPosition, tCompTotalTime
      end if
   end if
end MYLAPS.Data_G
Gilar | from INDONESIA

Klaus
Posts: 12354
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Update DataGrid Slow

Post by Klaus » Sat May 08, 2021 12:57 pm

Hi Gilar,

I will have some time tomorrow and will take a deeper look!


Best

Klaus

gilar
Posts: 96
Joined: Sat Sep 26, 2015 12:59 pm

Re: Update DataGrid Slow

Post by gilar » Sat May 08, 2021 4:11 pm

Klaus wrote:
Sat May 08, 2021 12:57 pm
I will have some time tomorrow and will take a deeper look!
Thank you very much
Gilar | from INDONESIA

Klaus
Posts: 12354
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Update DataGrid Slow

Post by Klaus » Sun May 09, 2021 1:04 pm

Hi Gilar,

please check my script.
Instead of updateing every COLUMN one by one, we only update the complete ARRAY of an INDEX
and write it back "en bloc" with -> set the dgDataOfIndex [theIndex] of group "race.result_grd" of card "games_crd" to...
That will automatically REFRESH the datagrid, so we can even save the "dispatch refresh..."

Code: Select all

on MYLAPS.Data_G pMsg
   /*
   FEED DATA CASE (Hasil Analisis Pribadi dari data $G)
   $G,POS,REG-NUMB,LAPS,TOTALTIME
   - Posisi empty,__,LAP empty, TT empty		Update POSISI,	LAP, 	TIME 
   - Posisi beda,__,LAP sama, TT sama		Update POSISI,
   - Posisi beda,__,LAP beda, TT lebih besar	Update POSISI,	LAP,	TIME
   - Posisi sama,__,LAP beda, TT lebih besar	Update 		LAP,	TIME
   
   URUTAN UPDATE DI SEMUA CASE
   Update Pos LAP dan Total Time
   Hitung DIFF dan GAP
   Update DIFF dan GAP
   Update MARK POSITION
   */
   -- deklarasi
   put item 2 of pMsg into tCompPosition
   put item 3 of pMsg into tCompRegNumber
   put item 4 of pMsg into tCompLap
   put item 5 of pMsg into tCompTotalTime
   
   put the dgNumberOfRecords of group "race.result_grd" of card "games_crd" into pLine
   put the dgData of group "term_grd" of card "setting_crd" into tTerms
   put field "standing.bar_fld" of card "games_crd" into tJumlahBarStanding
   
   dispatch "FindIndex" to group "race.result_grd" of card "games_crd" with "REGISTRATION NUMBER", tCompRegNumber
   put the result into theIndex
   
   ## Here we have the complete daa set for one record in the datagrid
   ## And we will use this later!
   put the dgDataOfIndex [theIndex] of group "race.result_grd" of card "games_crd" into tDGArrayIndex
   put tDGArrayIndex["POSITION"] into tDGPos
   put tDGArrayIndex["LAPS"] into tDGLap
   put tDGArrayIndex["TOTAL TIME"] into tDGTotalTime
   
   if theIndex = 0 then
      --- do nothing
      exit MYLAPS.Data_G
      ## No need to continue, and one END IF less to manage! :-)
   end if
   
   switch
      case tDGPos=empty and tDGLap=empty and tDGTotalTime=empty
         -- Posisi empty,__,LAP empty, TT empty---->Update POSISI,	LAP, 	TIME 
         --- Update $G
         
         ## see above, we update the complete array and write it back later
         put tCompPosition into tDGArrayIndex["POSITION"]
         put tCompLap into tDGArrayIndex["LAPS"]
         put tCompTotalTime into tDGArrayIndex["TOTAL TIME"]
         
         #dispatch "SetDataOfIndex" to group "race.result_grd" of card "games_crd" with theIndex, "POSITION", tCompPosition
         #dispatch "SetDataOfIndex" to group "race.result_grd" of card "games_crd" with theIndex, "LAPS", tCompLap
         #dispatch "SetDataOfIndex" to group "race.result_grd" of card "games_crd" with theIndex, "TOTAL TIME", tCompTotalTime
         -- refresh DataGrid
         
         ## If we set -> the dgDataOfIndex
         ## then we do not need to REFRESH, that will happen autpmatically with dgDataOfIndex
         #dispatch "RefreshIndex" to group "race.result_grd" of card "games_crd"  with theIndex
         set the dgDataOfIndex [theIndex] of group "race.result_grd" of card "games_crd" to tDGArrayIndex
         
         -- Calculate DIFF and GAP
         MYLAPS.Data_G_Calculate.DIFF theIndex, pLine, tCompPosition, tCompLap, tCompTotalTime, tJumlahBarStanding
         MYLAPS.Data_G_Calculate.GAP theIndex, pLine, tCompPosition, tCompLap, tCompTotalTime, tJumlahBarStanding
         
         break
      case tDGPos <> tCompPosition and  tDGLap = tCompLap and Time.Convert_TCtoSecond(tDGTotalTime) = Time.Convert_TCtoSecond(tCompTotalTime)
         -- Posisi beda,__,LAP sama, TT sama ---->Update POSISI,
         --- Update $G
         #dispatch "SetDataOfIndex" to group "race.result_grd" of card "games_crd" with theIndex, "POSITION", tCompPosition
         -- refresh DataGrid
         #dispatch "RefreshIndex" to group "race.result_grd" of card "games_crd"  with theIndex
         
         put tCompPosition into tDGArrayIndex["POSITION"]
         set the dgDataOfIndex [theIndex] of group "race.result_grd" of card "games_crd" to tDGArrayIndex
         
         --- Calculate DIFF and GAP
         MYLAPS.Data_G_Calculate.DIFF theIndex, pLine, tCompPosition, tCompLap, tCompTotalTime, tJumlahBarStanding
         MYLAPS.Data_G_Calculate.GAP theIndex, pLine, tCompPosition, tCompLap, tCompTotalTime, tJumlahBarStanding
         break
      case tDGPos <> tCompPosition and  tDGLap <> tCompLap and Time.Convert_TCtoSecond(tDGTotalTime) < Time.Convert_TCtoSecond(tCompTotalTime)
         -- Posisi beda,__,LAP beda, TT lebih besar	---->Update POSISI,	LAP,	TIME
         --- Update $G
         #         dispatch "SetDataOfIndex" to group "race.result_grd" of card "games_crd" with theIndex, "POSITION", tCompPosition
         #         dispatch "SetDataOfIndex" to group "race.result_grd" of card "games_crd" with theIndex, "LAPS", tCompLap
         #         dispatch "SetDataOfIndex" to group "race.result_grd" of card "games_crd" with theIndex, "TOTAL TIME", tCompTotalTime
         #         -- refresh DataGrid
         #         dispatch "RefreshIndex" to group "race.result_grd" of card "games_crd"  with theIndex
         
         put tCompPosition into tDGArrayIndex["POSITION"]
         put tCompLap into tDGArrayIndex["LAPS"]
         put tCompTotalTime into tDGArrayIndex["TOTAL TIME"]
         set the dgDataOfIndex [theIndex] of group "race.result_grd" of card "games_crd" to tDGArrayIndex
         
         -- Calculate DIFF and GAP
         MYLAPS.Data_G_Calculate.DIFF theIndex, pLine, tCompPosition, tCompLap, tCompTotalTime, tJumlahBarStanding
         MYLAPS.Data_G_Calculate.GAP theIndex, pLine, tCompPosition, tCompLap, tCompTotalTime, tJumlahBarStanding
         break
      case tDGPos = tCompPosition and  tDGLap <> tCompLap and Time.Convert_TCtoSecond(tDGTotalTime) < Time.Convert_TCtoSecond(tCompTotalTime)
         -- Posisi sama,__,LAP beda, TT lebih besar	---->Update 		LAP,	TIME
         --- Update $G
         ##dispatch "SetDataOfIndex" to group "race.result_grd" of card "games_crd" with theIndex, "LAPS", tCompLap
         ##dispatch "SetDataOfIndex" to group "race.result_grd" of card "games_crd" with theIndex, "TOTAL TIME", tCompTotalTime
         -- refresh DataGrid
         ##dispatch "RefreshIndex" to group "race.result_grd" of card "games_crd"  with theIndex
         
         put tCompPosition into tDGArrayIndex["POSITION"]
         put tCompTotalTime into tDGArrayIndex["TOTAL TIME"]
         set the dgDataOfIndex [theIndex] of group "race.result_grd" of card "games_crd" to tDGArrayIndex     
             
         --- Calculate DIFF and GAP
         MYLAPS.Data_G_Calculate.DIFF theIndex, pLine, tCompPosition, tCompLap, tCompTotalTime, tJumlahBarStanding
         MYLAPS.Data_G_Calculate.GAP theIndex, pLine, tCompPosition, tCompLap, tCompTotalTime, tJumlahBarStanding
         break
   end switch
   --- sort collumn
   if tCompPosition = pLine  or tCompPosition = the round of (pLine/2) then --- 
      draco.datagrid_sortposition
      --         if tCompPosition = pLine then
      --            draco.save.result_manual
      --         end if
   end if
   if the backgroundcolor of button "standing_btn" of card "games_crd" is green and the label of button "standing_btn" of card "games_crd" contains "PAGE 1"then
      put "30" into tTemplateIndex
      CasparCGTempUpdate_StandingLeft_Pos tTemplateIndex
   end if 
   
   if the backgroundcolor of button "standleft.time_btn" of card "games_crd" is green and tCompPosition < (tJumlahBarStanding + 1) then
      put "31" into tTemplateIndex
      CasparCGTempUpdate_StandingLeft_Time tTemplateIndex, tCompPosition, tCompTotalTime
   end if
end MYLAPS.Data_G
Not sure, but this may speed up things a bit! :-)


Best

Klaus

Klaus
Posts: 12354
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Update DataGrid Slow

Post by Klaus » Thu May 20, 2021 2:16 pm

And?
Did it help?

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”