How to cancel a script operation

Somewhere to ask questions about the best way to use SharpCap
Forum rules
‍

If you have a problem or question, please check the FAQ to see if it already has an answer : https://www.sharpcap.co.uk/sharpcap-faqs
Post Reply
Merlin66
Posts: 19
Joined: Fri Sep 15, 2017 4:20 am

How to cancel a script operation

#1

Post by Merlin66 »

It trying out some SHG scripts and have to sometimes interrupt the running script.
The "Abort running script" is greyed out and I have not found a way of re-setting the script, or removing it to try it again with a slight mod.
I have to shut and re-open SharpCap to be able to use the script function.
Is there an easier way of cancelling a script and start again?
"Astronomical Spectroscopy - The Final Frontier" - to boldly go where few amateurs have gone before....
https://groups.io/g/astronomicalspectroscopy
https://groups.io/g/Spectroheliograph
Jean-Francois
Posts: 857
Joined: Sun Oct 13, 2019 10:52 am
Location: Germany

Re: How to cancel a script operation

#2

Post by Jean-Francois »

Hello,

You can try to open the IronPython console, may be the square red button can be used to stop the script.

Jean-Francois
Merlin66
Posts: 19
Joined: Fri Sep 15, 2017 4:20 am

Re: How to cancel a script operation

#3

Post by Merlin66 »

J-F,
I tried that. It shows "KeyboardInterrupt"
The original script is still "live" if you try to reload the script it shows the message " SystemError:Cannot prepare a new capture while the previous capture is in progress, Camera is currently capturing"
There's no way of "clearing" the interrupted script. The option "Abort running script" is greyed out.
"Astronomical Spectroscopy - The Final Frontier" - to boldly go where few amateurs have gone before....
https://groups.io/g/astronomicalspectroscopy
https://groups.io/g/Spectroheliograph
Jean-Francois
Posts: 857
Joined: Sun Oct 13, 2019 10:52 am
Location: Germany

Re: How to cancel a script operation

#4

Post by Jean-Francois »

Hello,

Yes, I have sometimes the same with my scripts :-)
If SharpCap says that a capture is running ... you can try to stop the capture manually with the button in SharpCap menu.
Otherwise only way is to wait or to close/stop SharpCap with Task-Manager "kill" command.

Are you using one of my script ?
Normally, it should be possible to modify the script with more user friendly stop command.

Regards,
Jean-Francois
Merlin66
Posts: 19
Joined: Fri Sep 15, 2017 4:20 am

Re: How to cancel a script operation

#5

Post by Merlin66 »

J-F,
Thanks for the reply.
I'm actually starting with Minh's SHGAutomation script.
I've been battling it for the past three hours and can still only get the first image to record. It doesn't seem to handle the reverse slew back to the beginning.
I also note that using EQMod the sidereal tracking drops out when you slew. This may be giving issues during the sleep period.
If you have any insights you can share please let me know.
regards,
Ken
I attach a copy of the modified copy of the script I'm using.
SHG automation_ken.py.txt
(2.55 KiB) Downloaded 1 time
"Astronomical Spectroscopy - The Final Frontier" - to boldly go where few amateurs have gone before....
https://groups.io/g/astronomicalspectroscopy
https://groups.io/g/Spectroheliograph
Jean-Francois
Posts: 857
Joined: Sun Oct 13, 2019 10:52 am
Location: Germany

Re: How to cancel a script operation

#6

Post by Jean-Francois »

Hello Ken,

OK for the short script of Minh. I will have a quick look. I never use it, while I have a better script :-)

Concerning the EQMOD sidereal (RA) tracking drops ... it shall be done, if the driver follows the ASCOM norm.
But only on the axis that will move. If DEC movement with MoveAxis command, then the tracking on the RA shall continue.

If a command MoveAxis(0, 0) is send, then the tracking is restarted, if it was ON before the command.

The script uses the "SharpCap" MoveAxis() commmand ... it has a small point to take in account for the speed below or above 16x.
The MoveAxis() command moves the axis without taking in account any tracking or other sky movement.
If you do MoveAxis(0, +rate) or MoveAxis(0, -rate), the telescope will have some drift with time for a rate above 16x sidereal. The reason is SharpCap take in account the star tracking for speed below 16x ... the idea is so the stars movement is similar to the + or - RA direction for small speed. Above 16x, the speed is large enough that a difference of 1x is not more visible (visually) ... but "visible" on the SHG scans sequence.

Concerning EQMOD ... you maybe test one day GSS.
GSS has all the properties and other setting activated ... and the developers are very kind to update or improve the software quickly.

Regards,
Jean-Francois
Jean-Francois
Posts: 857
Joined: Sun Oct 13, 2019 10:52 am
Location: Germany

Re: How to cancel a script operation

#7

Post by Jean-Francois »

Hello Ken,

The script is working on my computer with ASCOM Sky Simulator and GSS. I connected SharpCap and Prism software.
In Prism, I can show the trace of the mount movement(s).
I change only the number of repetition and 3 different speed.
For the better view on the graphic ... I add manually a DEC slow drift ... so that the trace does not overlap.

SHG automation_ken.jpg
SHG automation_ken.jpg (221.89 KiB) Viewed 45 times

The image shows the sun disc and the 3 sequences (5 repetitions) for 9.6x, 15.9x and 16x sidereal rate.
For the 9.6 and 15.6 (below 16x) ... it works fine. The movement come back at the same distance to the sun disc.
For a rate of 16 or above ... the MoveAxis() command does not take in account the tracking rate.

I have no intention to test it with EQMOD ... I think I did not have it on my desktop computer and I'm sure that I deinstall it on my other computers.

For the stop of the script ... the for-loop has no interruption ... that is the reason why you can not stop it until the full completion of the for-loops.

Regards,
Jean-Francois
User avatar
admin
Site Admin
Posts: 17550
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: How to cancel a script operation

#8

Post by admin »

Hi,

cancelling a script that is run from the console or the 'run script...' menu should be possible via the stop button or the 'Abort Running Script' menu, although even in that case actually getting the script to stop is an excercise in optimism... However, if your script is running from a custom button, or potentially in response to a button press in custom UI, SharpCap doesn't have that sort of control over the script code and can't reliably stop it.

The most robust solution is to probably set up the script code to check a global 'stop' variable in loops and have another custom button that sets that variable, meaning that the running script should then drop out fairly quickly.

As to why stopping a script is hard - I was surprised by that too - there is no built in mechanism in the IronPython or scripting runtimes that SharpCap uses to cleanly cancel a running script. To even get something to work I had to have code connect to the scripting runtime as if it is a debugging or tracing tool and that lets it check for a stop request between python statements. The problem is if you want to stop and the script is running some code that *isn't* pure python that takes time - the cancellation request won't happen until that bit of code finishes. So there is a workaround for that in the scripting console that will basically force stop the script after a few seconds if it is not responding to a cancellation request in the normal way. However that has potential side effects on stability of the application and can't be used in the case of custom button handlers (doing so in that case would potentially destabilise the application).

cheers,

Robin
Post Reply