Timer Stalling

Post your Gambas programming questions here.
Post Reply
Donald D Ross
Posts: 6
Joined: Sunday 29th January 2023 1:50pm

Timer Stalling

Post by Donald D Ross »

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.
screenshot-RPI2.png
screenshot-RPI2.png (623.27 KiB) Viewed 2026 times
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Timer Stalling

Post by BruceSteers »

Have you looked into Task.class?
https://gambaswiki.org/wiki/comp/gb/task

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 :)

' Gambas class file  (name = MyTask.class)

Inherits Task

' We can get and store the values for each task instance in the _new() method.
Private $Value1 As Variant
Private $Value2 As Variant

' the _new() method is run when you use hNewtask = New MyTask(Arg1,l Arg2)

Public Sub _new(Value1 As Variant, Value2 As Variant)

  $Value1 = Value1
  $Value2 = Value2
  Application.Priority = 10  ' 0 is normal, 20 is lowest

End

' After the _new method completes the Main() method is automatically run
Public Sub Main()

 '  do some code with $Value1 and $Value2

  Print "This result here is sent to the parent handler"

End



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


Public $hMyTask As MyTask

Public Sub RunTask()

  If $hMyTask.Running Then $hMyTask.Kill  ' check it's not already running. 
'  (if you want multiple tasks running at once do not use a single global $hMyTask variable, try a local one)

  $hMyTask = New MyTask(Arg1, Arg2) As "MyTaskHandle"     ' create an instance with the args and set up for the MyTaskHandle event

End


' This event is triggered when the task Prints something

Public Sub MyTaskHandle_Read(sData As String)

  ' Each Print from the task is passed as a String in sData

  Print "Task sent string: " & sData

End



But saying that , you may just be asking too much from a Pi
I think the best solution is a low priority task
If at first you don't succeed , try doing something differently.
BruceS
Donald D Ross
Posts: 6
Joined: Sunday 29th January 2023 1:50pm

Re: Timer Stalling

Post by Donald D Ross »

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.... :)
Donald D Ross
Posts: 6
Joined: Sunday 29th January 2023 1:50pm

Re: Timer Stalling

Post by Donald D Ross »

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. :!:
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Timer Stalling

Post by BruceSteers »

Have you tried here...
http://gambaswiki.org/wiki/install/raspbian#t12
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?
https://gitlab.com/bsteers4/gambas3-compile-and-install
If at first you don't succeed , try doing something differently.
BruceS
Post Reply