示例#1
0
		private static async Task<string> InitSensorAsync(Sensor sensor)
		{
			try
			{
				await sensor.InitAsync();

				return string.Empty;
			}
			catch (Exception exception)
			{
				return exception.Message;
			}
		}
示例#2
0
		private static bool TryReadSensor(
			Sensor sensor,
			out SensorReadings readings,
			out string errorMessage)
		{
			errorMessage = string.Empty;

			if (sensor.Initiated)
			{
				try
				{
					if (sensor.Update())
					{
						readings = sensor.Readings;
						return true;
					}
				}
				catch (Exception exception)
				{
					errorMessage = exception.Message;
				}
			}

			readings = new SensorReadings();
			return false;
		}