Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OCSimulator"/> class.
        /// Must be public for COM registration.
        /// </summary>
        public ObservingConditions()
        {
            try
            {
                TL = OCSimulator.TL;
                TL.LogMessage("ObservingConditions", "Starting initialisation");

                clientNumber = OCSimulator.GetUniqueClientNumber();
                TL.LogMessage(clientNumber, "ObservingConditions", "This instance's unique client number: " + clientNumber);

                TL.LogMessage(clientNumber, "ObservingConditions", "Completed initialisation");
            }
            catch (Exception ex)
            {
                TL.LogMessageCrLf("ObservingConditions", ex.ToString());
            }
        }
Beispiel #2
0
        /// <summary>
        /// Static initialiser to set up the objects we need at run time
        /// </summary>
        static OCSimulator()
        {
            try
            {
                // Create sensor objects ready to be populated from the Profile
                // This must be done before reading the Profile
                foreach (string Property in DriverProperties)
                {
                    Sensors.Add(Property, new Sensor(Property));
                }

                TL = new TraceLoggerPlus("", "OCSimulator"); // Trace state is set in ReadProfile, immediately after nbeing read fomr the Profile
                ReadProfile();                               // Read device configuration from the ASCOM Profile store

                TL.LogMessage("OCSimulator", "Simulator initialising");
                sensorQueryTimer            = new System.Timers.Timer();
                sensorQueryTimer.Elapsed   += RefreshTimer_Elapsed;
                averagePeriodTimer          = new System.Timers.Timer();
                averagePeriodTimer.Elapsed += AveragePeriodTimer_Elapsed;

                connectStates        = new ConcurrentDictionary <long, bool>();
                util                 = new Util(); // Create an  ASCOM Utilities object
                mostRecentUpdateTime = DateTime.Now;

                TL.LogMessage("OCSimulator", "Setting sensor initial values");
                foreach (string Property in SimulatedProperties)
                {
                    Sensors[Property].SimCurrentValue     = Sensors[Property].SimFromValue;
                    Sensors[Property].ValueCycleDirection = ValueCycleDirections.FromTowardsTo;
                    Sensors[Property].TimeOfLastUpdate    = DateTime.Now;
                }

                // Dew point is calculated from humidity so initialise that here
                Sensors[PROPERTY_DEWPOINT].IsImplemented    = Sensors[PROPERTY_HUMIDITY].IsImplemented;
                Sensors[PROPERTY_DEWPOINT].SimCurrentValue  = util.Humidity2DewPoint(Sensors[PROPERTY_HUMIDITY].SimCurrentValue, Sensors[PROPERTY_TEMPERATURE].SimCurrentValue);
                Sensors[PROPERTY_DEWPOINT].TimeOfLastUpdate = DateTime.Now;

                TL.LogMessage("OCSimulator", "Simulator initialisation complete.");
            }
            catch (Exception ex)
            {
                throw ex;
                //MessageBox.Show(ex.ToString(), "Error initialising the Observing Conditions Simulator", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }