//
 // Constructor - Must be public for COM registration!
 //
 public Focuser()
 {
     m_Util = new ASCOM.Utilities.Util();
     tmrFocus.AutoReset = true;
     tmrFocus.Elapsed += new System.Timers.ElapsedEventHandler(tmrFocus_Elapsed);
         // Changed to work with new timer interface
 }
        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");
        }
 private void textBoxLongitude_TextChanged(object sender, EventArgs e)
 {
     if (ts != null)
     {
         var util = new ASCOM.Utilities.Util();
         ts.SiteLongitude      = util.DMSToDegrees(textBoxLongitude.Text);
         textBoxLongitude.Text = util.DegreesToDMS(ts.SiteLongitude);
     }
 }
Exemple #4
0
        //
        // Constructor - Must be public for COM registration!
        //
        public Telescope()
        {
            try
            {
                driverID = Marshal.GenerateProgIdForType(this.GetType());

                m_Util = new ASCOM.Utilities.Util();
                // get a unique instance id
                objectId = TelescopeHardware.GetId();
                TelescopeHardware.TL.LogMessage("New", "Instance ID: " + objectId + ", new: " + "Driver ID: " + driverID);

                TrackingRates = new TrackingRateObject(TelescopeInstance.TrackingRates);
            }
            catch (Exception ex)
            {
                EventLogCode.LogEvent("ASCOM.SimulatorCore.Telescope", "Exception on New", EventLogEntryType.Error, GlobalConstants.EventLogErrors.TelescopeSimulatorNew, ex.ToString());
                System.Windows.Forms.MessageBox.Show("Telescope New: " + ex.ToString());
            }
        }
        private void ConnectForm_Load(object sender, EventArgs e)
        {
            ArrayList DeviceTypes = new ArrayList();

            cmbDeviceType.SelectedIndexChanged += new EventHandler(cmbDeviceType_SelectedIndexChanged); // Add an event handler for devicetype combo box
            this.Resize += new EventHandler(ConnectForm_Resize);                                        // Add an event handler for form resize.

            try
            {
                Util = new ASCOM.Utilities.Util();

                // Get the currently define device types
                ASCOM.Utilities.Profile Profile = new ASCOM.Utilities.Profile();
                DeviceTypes = Profile.RegisteredDeviceTypes;
                Profile.Dispose();

                DefaultDevices = new SortedList <string, string>(); // Initialise the sorted array of default drivers for each device type
                foreach (string DeviceType in DeviceTypes)          // Populate the sorted array and the UI combo boxwith the default driver values
                {
                    cmbDeviceType.Items.Add(DeviceType);
                    switch (DeviceType.ToUpperInvariant())
                    {
                    case "TELESCOPE":
                        DefaultDevices.Add(DeviceType.ToUpperInvariant(), DEFAULT_DEVICE_TELESCOPE);
                        break;

                    case "FOCUSER":
                        DefaultDevices.Add(DeviceType.ToUpperInvariant(), DEFAULT_DEVICE_FOCUSER);
                        break;

                    case "FILTERWHEEL":
                        DefaultDevices.Add(DeviceType.ToUpperInvariant(), DEFAULT_DEVICE_FILTER_WHEEL);
                        break;

                    case "ROTATOR":
                        DefaultDevices.Add(DeviceType.ToUpperInvariant(), DEFAULT_DEVICE_ROTATOR);
                        break;

                    case "DOME":
                        DefaultDevices.Add(DeviceType.ToUpperInvariant(), DEFAULT_DEVICE_DOME);
                        break;

                    case "CAMERA":
                        DefaultDevices.Add(DeviceType.ToUpperInvariant(), DEFAULT_DEVICE_CAMERA);
                        break;

                    case "VIDEO":
                        DefaultDevices.Add(DeviceType.ToUpperInvariant(), DEFAULT_DEVICE_VIDEO);
                        break;

                    case "SWITCH":
                        DefaultDevices.Add(DeviceType.ToUpperInvariant(), DEFAULT_DEVICE_SWITCH);
                        break;

                    case "SAFETYMONITOR":
                        DefaultDevices.Add(DeviceType.ToUpperInvariant(), DEFAULT_DEVICE_SAFETY_MONITOR);
                        break;

                    default:
                        DefaultDevices.Add(DeviceType.ToUpperInvariant(), "");
                        break;
                    }
                }

                CurrentDevice              = DEFAULT_DEVICE_TELESCOPE; // Initialise current value variables and UI display
                CurrentDeviceType          = DEFAULT_DEVICE_TYPE;
                cmbDeviceType.SelectedItem = CurrentDeviceType;
                txtDevice.Text             = CurrentDevice;

                // Supply an appropriate title for the form depending on the OS and application bitness
                if (Environment.Is64BitOperatingSystem) // 64bit OS
                {
                    if (Environment.Is64BitProcess)     // 64bit process
                    {
                        this.Text = "Device Connection Tester - 64bit OS - Operating in 64bit mode";
                    }
                    else // 32bit process
                    {
                        this.Text = "Device Connection Tester - 64bit OS - Operating in 32bit mode";
                    }
                }
                else // 32bit OS
                {
                    this.Text = "Device Connection Tester - 32bit OS";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        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;
        }
Exemple #7
0
 /// <summary>
 /// Atuo constructor
 /// </summary>
 static AstroUtilsASCOM()
 {
     ASCOMUtils  = new Util();
     ASCOMAUtils = new ASCOM.Astrometry.AstroUtils.AstroUtils();
 }