Multiple safety monitors

Since there is now a ascom driver for Tektite sky( I was wondering of it would be possible to add support for more than one safety monitors. Tektite sky is a cheap solution and it would be nice to add a redundant backup system to my setup. I only have a portable setup and reply on GNS to wake me should the clouds roll in so I can bring my gear inside so redundancy would make me a bit more comfortable. Basically use Tektite sky’s on one monitor and my normal cloud sensor on the other

There has been some discussions about a Safety Monitor “Hub” that would allow you to chain multiple safety monitors together. Currently SGP doesn’t have this built in and, I don’t believe, a Safety Monitor Hub exists. I’m not sure if one is in the works or if this was just discussion. Might be a good time to start thinking about one though.

@Chris any thoughts?


There are several ways of thinking of this:

  1. More than one SafetyMonitor interface providing different Safety
    conditions such as safe to open the observatory and safe to image but using a single data source. I’ve done this for the Boltwood monitor.
  2. A single Safety monitor that takes data from multiple sources and
    uses it to generate a safety state These sources could be safety
    monitors connected to real hardware or could be other devices such
    as Switch devices (which can act as sensors) or the new
    ObservingConditions interface that we are working on to provide
    weather data.
  3. A combination of 1 and 2 that uses multiple data sources to
    generate multiple safety states.

We discussed this on one of our ASCOM inner circle chats and Bob Denny pointed out that option 3 exists - it’s called ACP.

I’m not suggesting that you all go out and buy ACP (although if you do you will get a very well developed and supported product) but this gives an idea of the magnitude of of what’s involved to develop and support this.

I’ve been trying things myself and the amount of work is high and, because it’s inherently complex, I think that a lot of support will be needed. It feels more like a commercial product than a free addition to the ASCOM platform.

But if someone wants to try it that would be fine. The ASCOM platform is open so that anyone with the expertise can develop additional things using the platform.


I think the writer of tektite skies is working on this. We’ve talked about it quite a bit.

I don’t see why it’s that complicated. Just an if/and/or right?


Hi Chris, Jared and Wayne,

I would like to revive this old thread as in the past few days I have been creating a generic ASCOM driver for UPS, which has been tested on two observatories with two different UPSs.

Now that there are safety monitor drivers for two different applications, it would be useful to have multiple instances of the safety monitor: one for the weather, one for the UPS, and for what else may come…

More information about the Generic UPS ASCOM driver is on my website.


There’s little I can add to what I wrote in 2015. The idea of a hub looks simple but the devil is in the details.

The thing that makes it complex is that the hub should really be written as a LocalServer ASCOM driver. This allows multiple applications to connect to it and also avoids issues with mixing 32 and 64 bit applications and DLLs.

A simple hub, written as a .NET DLL, that can only connect to one application may be little more complex than any other simple driver.
It would have a list of drivers that were all managed by the hub:

  • Connect would connect and disconnect from them all
  • IsSafe would call the IsSafe property on all the drivers. If any one reports false then the hub reports false.
  • I’m not sure where the drivers would be created, possibly in the hub creator, although it may be better if it were done in set Connect. Multiple calls to set Connect would need to be managed.
  • The setup Dialog would be used to select the drivers and set them up.

Give it a go.

Hi Chris,

will give it a try. As I am pretty new to VB, I need examples. I found plenty code snippets to get most things done, apart from one: how to populate an array with available SafetyMonitors in C#

Can you direct me to such a code snippet?

The ASCOM Platform code has the ObservingConditions Hub but from a quick look that isn’t particularly clear. It’s on github.

What I’d start with is a hub with one sub device. The driver test harness code shows how to choose and create a driver. The choose code goes in the setup dialog and the code to create and connect in the driver. get IsSafe will call IsSafe on the driver code. Get that working first.

Once that’s going additional sub devices could be added. I would at least start with a small number of devices, there’s no practical need for an open ended list. Maybe copy and paste instead of delving into arrays.

There are a lot of collection classes and there may be something more appropriate than an array, perhaps a dictionary. This is a collection of Key, Value pairs, the key would the the device ID string and the value the driver class instance.

ForEach … Next is a really good way to traverse a collection or array.

Hi Chris,

yes, those parts are easy. I already have the SafetyMonitor Chooser running within the Hub, but what I would like to avoid is that the chooser is used at all as that would mean I need to check each time all previously selected SafetyMonitors on double entries. Much easier would it be to create a small table with buttons for all available SafetyMonitors, so the user can in- or exclude them, or to have my own chooser that is populated with the remaining (unused) SafetyMonitors. Currently I can easily make 5 or 10 chooser buttons, but that would require a lot of unnecessary testing and I am not even sure if I can serialise form elements with C#. Perhaps a dictionary will help with that, will dive into that.

I hope to make the Hub in a way that the hub itself can be selected as one of the SafetyMonitors, making it a kind of recursive and allowing selection of 5, 9, 13 etc SafetyMonitors. This, however may result in conflicts in writing the profiles, but I will test that thoroughly of course. I noticed that there is a limited amount of information on ASCOM C# on the internet. Yesterday I finally found the ASCOM reference site, so with that I hope to progress towards this better set-up.


You obviously don’t need to keep using the chooser because once you have chosen the devices you save their driver IDs in the hub profile. Next time you load them from the profile.

If you want to rewrite the chooser then you are on your own. The chooser does all the things that you describe and has checks to prevent users doing things they shouldn’t. Duplicating all this is a lot of unneccessary work. We have had a lot of trouble with applications and driver developers reverse engineering this.

Trying to select and use the same hub in the hub will not work. There’s only one instance of the hub.

If yu really want complexity I suggest using the DataGridView for displaying and managing an open ended list of hubs, backed up by a database. Maybe you could extend the ASCOM Profile class to handle the data.

Hi Chris,

I have come quite far, see below image. The SafetyMonitorHub setup has a fully serialised form. For the moment it generates a maximum of five comboboxes, which are all populated with all available SafetyMonitors. Selecting one allows to start the chooser using the button next to it (they do not yet have graphics, the blue lined button is the chooser button).

The problem I now face is to create an instance of the selected SafetyMonitor as within the Hub I am not allowed to use the constructor as defined in ASCOM.DriverAccess:

SafetyMonitor mySM = new SafetyMonitor(mySM-Id);

Instead I have to use

SafetyMonitor mySM = new SafetyMonitor();

But then of course I do not get the SafetyMonitor I want to include in the hub.
Is there a proper way to make this work?

Another question I have is if there is a way to, if I know the safetyMonitorId, to initiate the DialogSetup from it directly without opening the chooser first (in other words I would like to have the button in my Hub to act as the Properties… button of the Chooser)?


Using combo boxes seems like a better idea than what I was thinking, using the chooser and a text box. Had forgotten that ASCOM now provides tools to help with this.
I don’t see why new SafetyMonitor(driverId) won’t work in a hub, You may need to include DriverAccess though.

I would expect that getting to the setup dialog in the setup button should be no more complex than
var Sm = New SafetyMonitor(driverID);

Something strange - a snide message complaining about me responding too much. If other people want to get involved then fine. No problem from me.


Hi Chris,

well, I do appreciate your input, but if other want to help, that is fine as well of course. But perhaps we should take this discussion to the ASCOM developers list?

I think the problem lies in the fact that I am building a SafetyMonitor and that I want to use another SafetyMonitor within it. If I look how this SafetyMonitor template is built, we see:

public class SafetyMonitor : ISafetyMonitor
    internal static string driverID = "ASCOM.Hub.SafetyMonitor";
    /// <summary>
    /// Initializes a new instance of the <see cref="Hub"/> class.
    /// Must be public for COM registration.
    /// </summary>
    public SafetyMonitor()
        tl = new TraceLogger("", "Hub");

When I tried to implement

SafetyMonitor mySM = new SafetyMonitor(mySM-Id);

I got the message that “SafetyMonitor does not contain a constructor that takes 1 arguments”. The solution VS gave me was to add a parameter to the constructor, but as soon as I did that, the SafetyMonitorHub was no longer detected by SGP. :frowning:


PS I did add “using ASCOM.DriverAccess;” and even tried to make an explicit call to SafetyMonitor like ASCOM.DriverAccess.SafetyMonitor, but after having typed “ASCOM.DriverAccess.” the option SafetyMonitor was not in the autofill-list…


You have to add a reference to the DriverAccess class, in the references this is called ASCOM Client Toolkit and I see two, one of which is old. Use 6.4.1.x.

You need to define the object explicitly because of the name clash:

    internal static string subSmId = "ASCOM.PowerStatus.SafetyMonitor";
    internal static ASCOM.DriverAccess.SafetyMonitor subSm;

Then choosing works using the driverAccess calls:

                // TODO connect to the device
                if (string.IsNullOrEmpty(subSmId))
                    subSmId = DriverAccess.SafetyMonitor.Choose("");
                if (subSm == null)
                    subSm = new ASCOM.DriverAccess.SafetyMonitor(subSmId);
                subSm.Connected = value;

Hi Chris,

not sure if I understand you well. In my references I can see DriverAccess. It has runtime version v2.0.50727. I do not see this ASCOM Client Toolkit under references.

It tried the explicit object definition as indicated, but that straight way gave the same error

Needless to say that the rest of your proposed code does not work. Did you try this yourself and got it working?


PS the start of Driver.cs mentions
namespace ASCOM.Hub
// Your driver’s DeviceID is ASCOM.Hub.SafetyMonitor
// The Guid attribute sets the CLSID for ASCOM.Hub.SafetyMonitor
// The ClassInterface/None addribute prevents an empty interface called
// _Hub from being created and used as the [default] interface

And indeed I can create an instance of Safetymonitor as Hub.SafetyMonitor, but then again no parameters can be specified. I also tried to change [ClassInterface(ClassInterfaceType.None)] and adding an optional parameter to the constructor, but then again SGP is not seeing the driver, so that does not work either.

Update: Tim Long of the ASCOM developers group solved the issue for me. For some reason I had a DriverAccess assembly that missed the SafetyMonitor class. He suggested to delete all ASCOM references from my project and to download and install a NuGet package. Once this was done all was solved.

For those following this thread I have good news: I have just uploaded a SafetyMonitor Hub driver, which allows to monitor up to five different SafetyMonitors at the same time. My previous driver potentially causes dilemmas for those (using SGP for instance) wanting to monitor both the power conditions and the weather as currently software like SGP is only able to connect to a single SafetyMonitor. With this hub that dilemma should be solved. It does not allow to monitor itself, nor duplicates of a single SafetyMonitor. It does allow to check the status of all attached SafetyMonitors while running (just click on the properties button).

More info is on my website at:

The installer is at:

The validation file is in the zip file.

In the coming weeks I will try to integrate this driver with my Generic UPS driver in a way that the Hub will show whether or not the UPS, monitored by the Generic UPS SafetyMonitor, is on battery as that will be advantageous for those working with remote observatories.


PS (11/07/2019): As indicated above, with the newest versions the two drivers are now further integrated. The Hub now shows how many seconds the UPS is on batteries. They can be downloaded via above links. Both drivers should be updated to make it work.