As I progress toward automating my observatory, I’m reaching the point where I am writing an end of sequence script. The script will close the roof, and shut off power to the mount and camera. However, before implementing the script, I need to know when SGP will call the script. For example, I currently have SGP set to park the mount and warm up the camera at the end of a sequence. However, I don’t want the script to run until the mount is parked (the roof won’t clear the mount when it’s not parked) and I don’t want to depower the camera until it has warmed up. So, my question is, does SGP wait until all of the other end-of-sequence options are performed before it runs and end-of-sequence script?
The script will, of course, have safeguards to prevent the roof from closing if the mount doesn’t report parked, but I want to make sure I get the timing right to avoid invoking the safeguards.
SGPro does not currently support end of sequence scripts. We only support pre or post event scripts (under protest). Scripting is mostly against our philosophy. While we like the idea of exposing an API for complex integration of other software, having to script your way through a useful sequence (while operating within the bounds of SGPro) often points at some type of failure (on our part).
Sorry. Poor phrasing and terminology. At the end of an event, there are post-event options that include parking the scope and calling a script. I want to automate closing of the roof and I just want to make sure that I understand the timing. So, for example, suppose I set my last event to park the scope when done and to also call my roof closing script. Will SGP wait until the scope answers “parked” before calling the script? If it does, then I only need to make my script close the roof. If it doesn’t, then I’ll want my script to park the scope on its own, verify that it is parked and then close the roof and depower the equipment.
OK. I see now. Unfortunately ASCOM does not allow for a scope to answer “Parked”. We don’t know when a scope is done parking. There is a property we can query to see if the mount is parked, but we cannot determine when the author decides to set this to true. All we can do is tell the scope to park. At this point the driver author can either immediately set the parked property to true (despite the fact that the scope is still slewing to the park position) or the author can wait until the mount is at the park position to set park to true. There is no way we can be sure that the scope is at the position you desire.
That said… and we can’t support or recommend this (just consider it friendly advice). In your shoes… if I really wanted to do this, I would work off the fact that park is called before the script is run. So… I would start my script with a delay that covers the longest period it could ever take your scope to park. Keep in mind you must use the “post-event” park and not the end of sequence park for this to work properly.
OK. thanks, Ken. I appreciate the info. I’m not particularly comfortable with the “wait and hope” approach. I would rather have some positive confirmation that the scope is in a position that would allow the roof to clear. I suppose I could have the script wait as you suggested and then query the ASCOM driver for RA and DEC coordinates and make sure they match the parked position before it closes the roof.
Once you have a great product and I wouldn’t even be considering full automation if it weren’t for SGP!
it would be safer to let SGP send the „close the roof“ command through the dome automation. Let’s suppose you have one sequence with two events and for the last event you have planned to call the roof script as an end of event script. In case of a sequence abort during the first event (rain started), your script will never get called. I do not even think it would get called if the sequence will be aborted during the last event.
You will have to write a very simple ASCOM driver (have a look at the dome driver template) for the closing electronic. There you could also implement querying the mount position. You might also implement some hardware safety lock for the telescope position. One way would be to setup a photoelectric barrier triggered when the scope is in the right position.
[quote=“Ken, post:4, topic:2774”]
OK. I see now. Unfortunately ASCOM does not allow for a scope to answer “Parked”.
[/quote] There’s the ASCOM property AtPark which returns true when the mount is parked - I see that you know of this.
I’ve always implemented Park as a blocking command. It waits until the mount has finished moving to the park position and done what needs to be done before returning.
But I’m not sure how multiple threads or multiple processes would handle things. While the thread that called scope.Park() is blocked others aren’t. I’d expect that for the mount to be parked Slewing must be false and AtPark must be true.
I’ve just checked the current Celestron driver and the AtPark property is only set right at the end of the Park method, when the park process has finished.
SGP needs to be concerned about the park state of the mount because of the synchronising of park to closing a ROR.
The sort of defensive programming I’d do would be:
Send a park command to the mount
Wait until Slewing is false and AtPark is true.
All this in one thread.
Consider the mount to be parked and move on to post park processes.
Is what you described how you implemented your driver (and how you recommend folks implement drivers) or is it something we can depend on for positive feedback? I’m only asking because the particular situation @spokeshave (and others like him) describe could be very costly if we are wrong about this… as such we have done nothing to indicate that we have any knowledge that it is safe to do stuff like close a ROR.
I just got back from the observatory and confirmed this. So the AtPark property looks like it will reliably tell me that the scope is indeed finished parking.
Being a belt-and-suspenders guy, I’m also installing a photocell bank over the scope that will look for the scope being in an unparked state. They will be interlocked with the closure mechanism so the roof will not close if one of the photocell beams is broken. I also have security cameras that feed a display in the house (the observatory is about half a mile away) so if I get up in the morning and the roof failed to close, a quick glance at the camera feed will tell me why.
I’ve no control over how other drivers are actually implemented. ASCOM generally has no control over developers of drivers. There are no ASCOM police with (brutal) methods to enforce compliance.
We would like all developers to at least run the ASCOM Conform application with their driver and pass that, but we can’t even ensure that. There are “ASCOM” drivers out there that do not pass Conform. Also passing Conform is necessary but not sufficient. It’s a protocol checker, not a general purpose hardware operation checker.
You mentioned a driver that sets AtPark as soon as Park is called. Does this driver return from Park immediately or are you calling AtPark on a separate thread? What driver is this? I might be able to investigate further.
Getting this sort of thing really reliable is difficult and, I think, requires all the interested parties to be involved.
The Application (SGP in this case) should be as kind to the driver as possible. State change operations, such as parking, should be completed on the same thread. Checks for AtPark and the slewing has stopped should cope with a driver that doesn’t block on the Park command. I’m not sure what else could be used.
The driver should handle Park and AtPark consistently. AtPark should only be true when the mount is in the parked state. But the quality and support of drivers may be spotty.
ASCOM is in the middle. We provide a protocol definition and some tools to help but aren’t in a position to force either the driver or application developers to conform to the definition.
The user needs to take care with this and check that things work as expected before trusting it. If it doesn’t then the user is probably the only person in a position to provide the information that’s needed. This could easily require contacting the driver developer as well as the application developers. Better to fix the problem than apply a band aid.
With a truly remote system there is a problem: when it starts raining is it better to close the roof and hope that the mount park worked or leave the roof open - and the observatory getting wet - if the mount hasn’t parked? Tim’s interlock solution is a good one but protects the mount from being hit by the roof at the expense of allowing it to get wet.
This is where the basic design should be defensive - have a system where the observatory can be closed safely regardless of the state of the mount. Expecting a complex system involving an application and multiple drivers connected to various pieces of hardware - all written by different people - to work seamlessly is a bit of an ask.