Timer Stalling

Post

Posted
Rating:
#1 (In Topic #981)
Trainee
Computer is RPI 4 B+, VERSION="10 (buster)", duel screen mode 4GB.
Gambas 3.12.2
Synology Server DS-713+ running V7 OS

While moving picture screens loaded in array memory @ 10fps to Picture Box from a timer, in a select entry I call "if exist( filename )", to a external synology server, the animation timer stops updating while the existance is checked, missing frames.
also…
Information loaded into a 3D array holding [20, 500000, 10] is searched the timer updating the Picture Box stalls till the search is complete (about 3 seconds or 30 frames). (Created a complete external gambas program to do the search to get arround the problem).

Is there a way to keep the animation timer updating the PictureBox without fail while the forms in the program runs tasks for setting up the next event while playing a mp3 in MediaView or Music.Load uninterupted.

Image

(Click to enlarge)

Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
Have you looked into Task.class?
/comp/gb/task - Gambas Documentation

You can use a Task to run the method at a low priority so it does not effect the timer updates.

a Task runs as a separate process/program , within the Task code you can set Application.Priority (0 = normal, 20 = lowest, -20 highest but only superuser can set negative value)

Easiest way to run a Task is to set it up in the New statement,
see below for a simple (hand typed untested) example of using Task.class and passing a couple of arguments to it.
Maybe it will help you :)

Code (gambas)

  1. ' Gambas class file  (name = MyTask.class)
  2.  
  3.  
  4. ' We can get and store the values for each task instance in the _new() method.
  5.  
  6. ' the _new() method is run when you use hNewtask = New MyTask(Arg1,l Arg2)
  7.  
  8. Public Sub _new(Value1 As Variant, Value2 As Variant)
  9.  
  10.   $Value1 = Value1
  11.   $Value2 = Value2
  12.   Application.Priority = 10  ' 0 is normal, 20 is lowest
  13.  
  14.  
  15. ' After the _new method completes the Main() method is automatically run
  16. Public Sub Main()
  17.  
  18.  '  do some code with $Value1 and $Value2
  19.  
  20.   Print "This result here is sent to the parent handler"
  21.  
  22.  
  23.  

Then to use the above Task (say i called it MyTask.class)

Code (gambas)

  1.  
  2. Public $hMyTask As MyTask
  3.  
  4. Public Sub RunTask()
  5.  
  6.   If $hMyTask.Running Then $hMyTask.Kill  ' check it's not already running.
  7. '  (if you want multiple tasks running at once do not use a single global $hMyTask variable, try a local one)
  8.  
  9.   $hMyTask = New MyTask(Arg1, Arg2) As "MyTaskHandle"     ' create an instance with the args and set up for the MyTaskHandle event
  10.  
  11.  
  12.  
  13. ' This event is triggered when the task Prints something
  14.  
  15. Public Sub MyTaskHandle_Read(sData As String)
  16.  
  17.   ' Each Print from the task is passed as a String in sData
  18.  
  19.   Print "Task sent string: " & sData
  20.  
  21.  


But saying that , you may just be asking too much from a Pi
I think the best solution is a low priority task
Online now: No Back to the top

Post

Posted
Rating:
#3
Trainee
The Main Problem I don't think is the RPI.
The round trip if checking for a file at a location on the Synology server seems to be the delay. A exist for a file on MY RPI 4 with a 128gb M.2 is almost instant, no dropped frames but the over all DB size for MP3+G files is small (only a few thousand entry's).

I have tried checking for existance with other Form's with the main program but things stop till the existance result is checked. I wrote another program that runs independently of the program running the animation and that works for searching for a entrys in the database that match. To shell out to a program works also as long as Wait to Result is NOT used and the shell'd program ports its result to a file that can be checked for and then evaluate the answer. Checking for the result file name on the RPI and loading the text in is almost instant.

I have found ways around the problem, I'm just looking for a better way.
The hopes that a timer set at 100ms would update every 100ms no matter what is going on elsewere in the program doesn't seem to work.
Thanks though…. :)
Online now: No Back to the top

Post

Posted
Rating:
#4
Trainee
Using RPI 4 Buster, Gambas 3.12.2
Been Programming the Karaoke Program for YEARS now.

Loaded the Program into RPI 4 Bullseye with Gambas 3.18.0 and made code changes and saved. NOW the Gambas 3.12.2 programming environment won't load the program for editing, I get a error box…
Cannot open project file :
<tt>Type mismatch: wanted Integer, got String instead
Project.ReadProject.3285 Project.Open.714 FWelcome.btnOpen_Click.144 CCoolButton.Panel_MouseUp.147</tt>

I have NOT found a way to get RPI 4 Buster, Gambas 3.12.2 to upgrade to 3.18.0. Also the compiled program from 3.18.0 will NOT run on the Buster OS.
Years of writing the program, 7500+ lines of code…. :evil:
I do have a backup before the 3.18.0 modification SPLAT!!!

 YUCK! Been HERE before with a earlier update incompatablility.
I like to write programs BUT this problem is NOT fun.  :!:
Online now: No Back to the top

Post

Posted
Rating:
#5
Guru
BruceSteers is in the usergroup ‘Guru’
Have you tried here…
/install/raspbian - Gambas Documentation
instructions for raspbian buster and bullseye

Best way would be to use an ubuntu raspbian os . then upgrading to latest gambas is easy.

buster is super old now, i'd upgrade the raspbian on it.  https://www.raspberrypi.com/software/operating-systems/
newer raspbian = newer gambas.

Maybe my gambas upgrader bash script can help?
Bruce Steers / gambas3-compile-and-install · GitLab
Online now: No Back to the top
1 guest and 0 members have just viewed this.