예제 #1
0
        public static SensorMeasurement GetSensorMeasurement()
        {
            if (_sensorMeasurement == null)
            {
                _sensorMeasurement = new SensorMeasurement();
                _sensorMeasurement.DisplayName = _displayName;
                _sensorMeasurement.Guid = _guid;
                _sensorMeasurement.Location = _location;
                _sensorMeasurement.MeasureName = _measureName;
                _sensorMeasurement.Organization = _organization;
                _sensorMeasurement.UnitOfMeasure = _unitOfMeasure;
                _sensorMeasurement.Value = _random.Next(60, 91);
            }

            return _sensorMeasurement;
        }
예제 #2
0
        /// <summary>
        /// Sends an analog reading to the cloud.
        /// </summary>
        /// <param name="ratio">
        /// The ratio of the analog sensor.
        /// </param>
        /// <returns>
        /// A <see cref="SendResult"/> that indicates the result of the operation.
        /// </returns>
        static public SendResult ReportAnalog(double ratio)
        {
            // Ensure the sender has been created
            EnsureSender();

            // Create the measurement
            var measurement = new SensorMeasurement()
            {
                DisplayName = "Office",
                Guid = Guid.NewGuid(),
                Location = "Houston",
                MeasureName = "Analog",
                UnitOfMeasure = "Ratio",
                Value = ratio
            };

            // Send the measurement
            return sender.Send(measurement);
        }