Example #1
0
        public void init()
        {
            if (initialized)
            {
                return;
            }

            och = new ObservingConditions("ASCOM.OCH.ObservingConditions");
            if (tl == null)
            {
                tl = new TraceLogger("", "Wise40.SafeToOpen");
            }
            name              = "Wise40 SafeToOpen";
            driverID          = Const.wiseSafeToOperateDriverID;
            driverDescription = string.Format("ASCOM Wise40.SafeToOpen v{0}", version.ToString());

            if (_profile == null)
            {
                _profile = new Profile()
                {
                    DeviceType = "SafetyMonitor"
                };
            }

            humiditySensor          = new HumiditySensor(this);
            windSensor              = new WindSensor(this);
            sunSensor               = new SunSensor(this);
            cloudsSensor            = new CloudsSensor(this);
            rainSensor              = new RainSensor(this);
            humanInterventionSensor = new HumanInterventionSensor(this);
            _sensors = new List <Sensor>()
            {
                windSensor,
                cloudsSensor,
                rainSensor,
                humiditySensor,
                sunSensor,
                humanInterventionSensor
            };

            tl.Enabled = debugger.Tracing;
            tl.LogMessage("SafetyMonitor", "Starting initialisation");

            _connected = false;

            novas31    = new NOVAS31();
            astroutils = new AstroUtils();
            ascomutils = new Util();

            siteLatitude  = ascomutils.DMSToDegrees("30:35:50.43");
            siteLongitude = ascomutils.DMSToDegrees("34:45:43.86");
            siteElevation = 882.9;
            novas31.MakeOnSurface(siteLatitude, siteLongitude, siteElevation, 0.0, 0.0, ref onSurface);
            novas31.MakeObject(0, Convert.ToInt16(Body.Sun), "Sun", new CatEntry3(), ref Sun);

            ReadProfile(); // Read device configuration from the ASCOM Profile store
            initialized = true;

            tl.LogMessage("SafetyMonitor", "Completed initialisation");
        }
Example #2
0
        public void init()
        {
            if (initialized)
            {
                return;
            }

            name = "Wise40 SafeToOperate";
            driverDescription = string.Format("{0} v{1}", driverID, version.ToString());

            if (_profile == null)
            {
                _profile = new Profile()
                {
                    DeviceType = "SafetyMonitor"
                };
            }

            WiseSite.initOCH();
            WiseSite.och.Connected = true;

            humiditySensor          = new HumiditySensor(this);
            windSensor              = new WindSensor(this);
            sunSensor               = new SunSensor(this);
            cloudsSensor            = new CloudsSensor(this);
            rainSensor              = new RainSensor(this);
            humanInterventionSensor = new HumanInterventionSensor(this);
            computerControlSensor   = new ComputerControlSensor(this);
            platformSensor          = new PlatformSensor(this);
            doorLockSensor          = new DoorLockSensor(this);
            pressureSensor          = new PressureSensor(this);
            temperatureSensor       = new TemperatureSensor(this);

            //
            // The sensors in priotity order.  The first one that:
            //   - is enabled
            //   - not bypassed
            //   - forces decision
            //   - is not safe
            // causes SafeToOperate to be NOT SAFE
            //
            _prioritizedSensors = new List <Sensor>()
            {
                humanInterventionSensor,    // Immediate sensors
                computerControlSensor,
                platformSensor,
                doorLockSensor,

                sunSensor,                  // Weather sensors - affecting isSafe
                windSensor,
                cloudsSensor,
                rainSensor,
                humiditySensor,

                pressureSensor,             // Weather sensors - NOT affecting isSafe
                temperatureSensor,
            };

            _cumulativeSensors = new List <Sensor>();
            foreach (Sensor s in _prioritizedSensors)
            {
                if (!s.HasAttribute(Sensor.SensorAttribute.Immediate))
                {
                    _cumulativeSensors.Add(s);
                }
            }

            _connected = false;

            novas31    = new NOVAS31();
            astroutils = new AstroUtils();
            ascomutils = new Util();

            novas31.MakeObject(0, Convert.ToInt16(Body.Sun), "Sun", new CatEntry3(), ref Sun);

            ReadProfile(); // Read device configuration from the ASCOM Profile store
            _safetyState = Event.SafetyEvent.SafetyState.Unknown;
            activityMonitor.Event(new Event.SafetyEvent()
            {
                _safetyState = _safetyState,
                _details     = "WiseSafeToOperate.init()",
            });
            initialized = true;
        }