Countdown with dynamic or calculated time

Questions, tips, information and discussions about using the SharpCap Sequencer and Sequence Planner tools
User avatar
admin
Site Admin
Posts: 17558
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Countdown with dynamic or calculated time

#11

Post by admin »

Hi,

thanks for sharing the update - I am planning to add a UTC wait (and a countdown, why not!) to the sequencer as part of SharpCap 4.2.

If you encounter any SharpCap API calls that crash when called from Python due to threading issues then please let me know. The python code runs in a worker thread (otherwise a 'sleep' would freeze SharpCap), but some code paths need to transition to the UI thread to work properly from python. I've caught and fixed most of these I think, but it wouldn't be surprising if there are a few left in the less used corners of the API.

cheers,

Robin
mcamilleri
Posts: 50
Joined: Thu Mar 02, 2023 12:02 am

Re: Countdown with dynamic or calculated time

#12

Post by mcamilleri »

That is fantastic - thanks!

Both UTC and Local time would be useful. Really easy to do both with Python, but not sure about other languages.

You might have a few crash reports from my development. I had quite a few crashes along the way trying to get the sequencer to RunAsync() and have a simultaneous countdown and stop button. One of the issues was the recursion used in my countdown Python code. At 1 s updates it would crash after maybe 5 minutes due to the recursion limit. The other issue was multi vs single threads. The code uses STA I think (ask CoPilot exactly what it did to get it working!)

I may have overcomplicated the tool by enabling interactive running of Sequencers. My original intention was just to generate sequences for the user to run from the SharpCap Sequencer. But then I ran into the issues of waiting for the event and not having a dynamic countdown timer which wasn't a great user experience. When I tested it myself the lack of feedback when waiting was a problem, plus the issues of what happens if I start late or have to restart the sequence at the last minute. Your new sequencer functions would completely resolve that.

Somewhere along the way I had a crash which reset the ROI for me Alpaca camera simulator. I have not been able to fix it yet.

Michael
mcamilleri
Posts: 50
Joined: Thu Mar 02, 2023 12:02 am

Re: Countdown with dynamic or calculated time

#13

Post by mcamilleri »

I have developed another SharpCap addin to run a PEP photometer with serial comm data collection. It provides a very good example of how to setup code to run a complex interface, and for setting up a GitHub repository. I used GitHub CoPilot a lot for the development which greatly accelerated progress. If anyone is interested in developing SharpCap addins it is easier than ever.

https://github.com/labstercam/pep-ssp-tools
User avatar
admin
Site Admin
Posts: 17558
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Countdown with dynamic or calculated time

#14

Post by admin »

Hi,

I wonder if the right option is a sequencer step that lets you wait until a time/date point - if you specify the time/date without 'Z' at the end then it would be treated as a local time, otherwise with the Z as a UTC time/date. Probably in ISO8601 format, since that is a standard.

The fact that you are getting recursion in your waiting sounds 'wrong' - like you are doing something the hard way, or not quite right. Still, if that will be fixed by the new wait options then there isn't a great deal of gain in digging further into that.

Async is a mixed blessing from the point of view of Python - from an internal point of view it is much easier for me to code things up with async, but it does make calling them from python harder. If you need to wait for something async to finish then there is a helper function - 'SharpCap.SafeWait' that will do that without making the UI freeze.

On the subject of bug reports, I have a flag on them that says if scripts have been running and largely ignore those that have that flag set, so they will not get any attention on why they happened. There is also an option to ignore errors that you can set from script - change the value of SharpCap.ExceptionReportStrategy, but watch out that you keep an eye on the log for any errors that are being ignored and silently logged if you do.

A crash during camera startup will make SharpCap discard any previously saved camera settings (like ROI) and go back to defaults - this avoids the situation that you have set some option that causes the camera to fail and then SharpCap trying to restore that option again and again every time you open the camera.

cheers,

Robin
mcamilleri
Posts: 50
Joined: Thu Mar 02, 2023 12:02 am

Re: Countdown with dynamic or calculated time

#15

Post by mcamilleri »

Yes, a countdown with UTC and local time in a standard format would be great.

The recursion is due to not being able to use loops in the RUN PYTHON CODE step. The alternative might be to create a Python file that creates a non-recursive function. But I would have to generate that from the sequence as I don’t want users to have to install other files to run the sequences. People will run it on remote computers or copy it from onePC to another and the more steps of files they need to manage the more likely something will fail.

The new countdown step would solve all of this.
Post Reply