Ejemplo n.º 1
0
        private void cmdOK_Click(object sender, EventArgs e) // OK button event handler
        {
            // Place any validation constraint checks here
            OCSimulator.TraceState                = chkTrace.Checked;
            OCSimulator.DebugTraceState           = chkDebugTrace.Checked;
            OCSimulator.SensorQueryInterval       = Convert.ToDouble(numSensorQueryInterval.Value);
            OCSimulator.AveragePeriod             = Convert.ToDouble(numAveragePeriod.Value);
            OCSimulator.NumberOfReadingsToAverage = Convert.ToInt32(numNumberOfReadingsToAverage.Value);

            foreach (string sensor in OCSimulator.SimulatedProperties)
            {
                SensorView sv = (SensorView)this.Controls[OCSimulator.SENSORVIEW_CONTROL_PREFIX + sensor];
                OCSimulator.Sensors[sensor].SimFromValue   = sv.MinValue;
                OCSimulator.Sensors[sensor].SimToValue     = sv.MaxValue;
                OCSimulator.Sensors[sensor].IsImplemented  = sv.SensorEnabled;
                OCSimulator.Sensors[sensor].NotReadyDelay  = sv.NotReadyDelay;
                OCSimulator.Sensors[sensor].ValueCycleTime = sv.ValueCycleTime;
            }

            OCSimulator.Sensors[OCSimulator.PROPERTY_DEWPOINT].SimFromValue   = OCSimulator.Sensors[OCSimulator.PROPERTY_HUMIDITY].SimFromValue;
            OCSimulator.Sensors[OCSimulator.PROPERTY_DEWPOINT].SimToValue     = OCSimulator.Sensors[OCSimulator.PROPERTY_HUMIDITY].SimToValue;
            OCSimulator.Sensors[OCSimulator.PROPERTY_DEWPOINT].IsImplemented  = OCSimulator.Sensors[OCSimulator.PROPERTY_HUMIDITY].IsImplemented;
            OCSimulator.Sensors[OCSimulator.PROPERTY_DEWPOINT].NotReadyDelay  = OCSimulator.Sensors[OCSimulator.PROPERTY_HUMIDITY].NotReadyDelay;
            OCSimulator.Sensors[OCSimulator.PROPERTY_DEWPOINT].ValueCycleTime = OCSimulator.Sensors[OCSimulator.PROPERTY_HUMIDITY].ValueCycleTime;
        }
Ejemplo n.º 2
0
        private void ChkEnabled_CheckedChanged(object sender, EventArgs e)
        {
            if (!DesignMode)
            {
                CheckBox chk = (CheckBox)sender;
                if (OCSimulator.setupForm != null)
                {
                    SensorView svThisSensor = (SensorView)OCSimulator.setupForm.Controls[this.Name];

                    TL.LogMessage("ChkEnabled_CheckedChanged", "Checked changed: " + chk.Name + " " + this.Name);
                    svThisSensor.NotReadyControlsEnabled = chk.Checked;
                }
                else
                {
                    TL.LogMessage("ChkEnabled_CheckedChanged", "setupForm variable is null!");
                }
            }
        }
Ejemplo n.º 3
0
        private void cmdOK_Click(object sender, EventArgs e) // OK button event handler
        {
            // Check whether both dew point and humidy are either set or unset. It is not allowed for one to be available and not the other
            Hub.ConnectionType connectionTypeDewPoint = this.Controls.OfType <SensorView>().First(sv => sv.Name == "sensorView" + Hub.PROPERTY_DEWPOINT).SelectedSensor.DeviceMode;
            Hub.ConnectionType connectionTypeHumidity = this.Controls.OfType <SensorView>().First(sv => sv.Name == "sensorView" + Hub.PROPERTY_HUMIDITY).SelectedSensor.DeviceMode;

            if (((connectionTypeDewPoint == Hub.ConnectionType.None) & (connectionTypeHumidity == Hub.ConnectionType.Real)) || ((connectionTypeDewPoint == Hub.ConnectionType.Real) & (connectionTypeHumidity == Hub.ConnectionType.None)))
            {
                // We have one of dew point or humidity set to a device and the other is set to "No Device" - this violates the ASCOM spec so flash a warning
                MessageBox.Show("Dew point and Humidity must both be implemented or both must be not implemented. The ASCOM specification does not allow one to be implemented and the other not.\r\n\r\nPlease ensure that the configured Dew point and Humidity implementations match.", "DewPoint and Humnidty Issue", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.DialogResult = DialogResult.None;
            }
            else // Both humidity and dew point are either no device or real device
            {
                // Save the UI control states
                Hub.TraceState       = chkTrace.Checked;
                Hub.DebugTraceState  = chkDebugTrace.Checked;
                Hub.ConnectToDrivers = chkConnectToDrivers.Checked;
                Hub.averagePeriod    = Convert.ToDouble(numAveragePeriod.Value);
                Hub.numberOfMeasurementsPerAveragePeriod = Convert.ToInt32(numNumberOfReadingsToAverage.Value);
                Hub.overrideUISafetyLimits = chkOverrideSafetyLimits.Checked;

                // Save updated sensor control values to Hub.Sensors
                foreach (Control item in this.Controls.OfType <SensorView>())
                {
                    SensorView view = item as SensorView;
                    if (view != null)
                    {
                        var sensorname = view.SensorName;
                        Hub.Sensors[sensorname].ProgID       = view.SelectedSensor.ProgID;
                        Hub.Sensors[sensorname].SwitchNumber = view.SelectedSensor.SwitchNumber;
                        Hub.Sensors[sensorname].DeviceMode   = view.SelectedSensor.DeviceMode;
                    }
                }

                this.DialogResult = DialogResult.OK;
                Close();
            }
        }
Ejemplo n.º 4
0
        private void SetupDialogForm_Load(object sender, EventArgs e)
        {
            // Initialise current values of user settings from the ASCOM Profile
            chkTrace.Checked                   = OCSimulator.TraceState;
            chkDebugTrace.Checked              = OCSimulator.DebugTraceState;
            numSensorQueryInterval.Value       = Convert.ToDecimal(OCSimulator.SensorQueryInterval);
            numAveragePeriod.Value             = Convert.ToDecimal(OCSimulator.AveragePeriod);
            numNumberOfReadingsToAverage.Value = Convert.ToDecimal(OCSimulator.NumberOfReadingsToAverage);
            EnableNumberOfReadingsToAverage();
            // Initialise sensorview items here

            foreach (string sensor in OCSimulator.SimulatedProperties)
            {
                SensorView thisSensorView = (SensorView)this.Controls[OCSimulator.SENSORVIEW_CONTROL_PREFIX + sensor];
                thisSensorView.MinValue                = OCSimulator.Sensors[sensor].SimFromValue;
                thisSensorView.MaxValue                = OCSimulator.Sensors[sensor].SimToValue;
                thisSensorView.SensorEnabled           = OCSimulator.Sensors[sensor].IsImplemented;
                thisSensorView.NotReadyControlsEnabled = OCSimulator.Sensors[sensor].IsImplemented;
                thisSensorView.NotReadyDelay           = OCSimulator.Sensors[sensor].NotReadyDelay;
                thisSensorView.ValueCycleTime          = OCSimulator.Sensors[sensor].ValueCycleTime;
            }

            // Initialise current values of user settings from the ASCOM Profile
        }
Ejemplo n.º 5
0
        private void ReadDeviceInformation()
        {
            try
            {
                TL.LogMessage("ReadDeviceInformation", "Start");
                Type    type    = typeof(Hub);
                Profile profile = new Profile();

                // Get the list of ObservingConditions drivers
                ArrayList observingConditionsDevices = profile.RegisteredDevices(Hub.DEVICE_TYPE);
                TL.LogMessage("ReadDeviceInformation", "Found {0} ObservingConditions devices", observingConditionsDevices.Count);

                // Get the list of Switch drivers
                ArrayList switchDevices = profile.RegisteredDevices(Hub.SWITCH_DEVICE_NAME);
                TL.LogMessage("ReadDeviceInformation", "Found {0} switch devices", switchDevices.Count);

                // Construct a complete list of all drivers
                allDevices.Clear();
                // Add the "no Device" entry as the first entry in the list of devices
                KeyValuePair noDevice = new KeyValuePair(Hub.NO_DEVICE_PROGID, Hub.NO_DEVICE_DESCRIPTION);
                allDevices.Add(noDevice);

                try
                {
                    // Add the ObservingConditions devices to the overall drivers list
                    foreach (KeyValuePair device in observingConditionsDevices)
                    {
                        if (device.Key == Hub.DRIVER_PROGID)
                        {
                            continue;
                        }

                        device.Value = Hub.OBSERVING_CONDITIONS_NAME_PREFIX + ": " + device.Value;
                        allDevices.Add(device);
                    }

                    TL.LogMessage("ReadDeviceInformation", "Found {0} devices", allDevices.Count);
                }
                catch (Exception ex)
                {
                    TL.LogMessageCrLf("ReadDeviceInformation 1", "ObservingConditions description exception: {0}", ex);
                    MessageBox.Show("ReadDeviceInformatio 1: " + ex.ToString(), "ReadDeviceInformation 1");
                }

                // Add the Switch devices to the overall drivers list
                foreach (KeyValuePair device in switchDevices)
                {
                    device.Value = Hub.SWITCH_NAME_PREFIX + ": " + device.Value;
                    allDevices.Add(device);
                }

                // Log the combined list of ObservingConditions and Switch drivers
                foreach (KeyValuePair device in allDevices)
                {
                    TL.LogMessage("ReadDeviceInformation", "Found device: \"{0}\": \"{1}\"", device.Key, device.Value);
                }

                // initialise the SensorView objects
                foreach (Control item in this.Controls.OfType <SensorView>())
                {
                    SensorView view = item as SensorView;
                    if (view != null)
                    {
                        view.ConnectToDriver = chkConnectToDrivers.Checked;
                        view.InitUI();
                    }
                }

                return;
            }
            catch (Exception ex)
            {
                TL.LogMessageCrLf("ReadDeviceInformation2", ex.ToString());
                MessageBox.Show("ReadDeviceInformation2: " + ex.ToString(), "ReadDeviceInformation2");
            }
        }