예제 #1
0
파일: Program.cs 프로젝트: yudevan/napkin
        private void Cycle()
        {
            _cycleCount++;
            Debug.Print("Cycle: " + _cycleCount);

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("state.vitalsAndSensorsUpdated=false");

            sb.AppendLine("vitals.id=" + DeviceId);
            sb.AppendLine("vitals.currentCycle~i=" + _cycleCount);

            long memoryBytesFree = Debug.GC(false);

            sb.AppendLine("vitals.memoryBytesFree~i=" + memoryBytesFree);

            temperatureHumidity.RequestMeasurement();
            Thread.Sleep(1000);
            sb.AppendLine("sensor.temperatureHumidity.temperature~f=" + _temperature.ToString());
            sb.AppendLine("sensor.temperatureHumidity.relativeHumidity~f=" + _relativeHumidity.ToString());

            double lightSensorPercentage = lightSensor.ReadLightSensorPercentage();

            sb.AppendLine("sensor.lightSensor.lightSensorPercentage~f=" + lightSensorPercentage.ToString());

            sb.AppendLine("sensor.lastLine=" + _lastLine);

            sb.AppendLine("state.vitalsAndSensorsUpdated=true");

            string chatterText = sb.ToString();

            _bone2.Write(chatterText);

            Thread.Sleep(8 * 1000);
        }
예제 #2
0
파일: Program.cs 프로젝트: yudevan/napkin
        private void Cycle()
        {
            led7c.SetColor(LED7C.LEDColor.Blue);
            _cycleCount++;
            Debug.Print("sensor cycle: " + _cycleCount);
            UpdateDisplay("sensor cycle", _cycleCount.ToString());

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("state.vitalsAndSensorsUpdated=false");

            sb.AppendLine("vitals.id=" + DeviceId);
            sb.AppendLine("vitals.currentCycle~i=" + _cycleCount);

            _temperature2 = 0; _relativeHumidity = 0;
            temperatureHumidity.RequestMeasurement();
            Thread.Sleep(500);
            sb.AppendLine("sensor.temperatureHumidity.temperature~f=" + _temperature2.ToString());
            sb.AppendLine("sensor.temperatureHumidity.relativeHumidity~f=" + _relativeHumidity.ToString());

            _temperature = 0; _pressure = 0;
            barometer.RequestMeasurement();
            Thread.Sleep(500);
            sb.AppendLine("sensor.barometer.temperature~f=" + _temperature.ToString());
            sb.AppendLine("sensor.barometer.pressure~f=" + _pressure.ToString());

            long memoryBytesFree = Debug.GC(false);

            sb.AppendLine("vitals.memoryBytesFree~i=" + memoryBytesFree);

            _lightSensorPercentage = lightSensor.ReadLightSensorPercentage();
            sb.AppendLine("sensor.lightSensor.lightSensorPercentage~f=" + _lightSensorPercentage.ToString());

            sb.AppendLine("sensor.lastLine=" + _lastLine);

            sb.AppendLine("state.vitalsAndSensorsUpdated=true");

            string chatterText = sb.ToString();

            _bone3.Write(chatterText);

            led7c.SetColor(LED7C.LEDColor.Green);

            UpdateDisplay("temperature 1", _temperatureF.ToString("n2") + "F / " + _temperature.ToString("n2") + "C");
            Thread.Sleep(2 * 1000);

            UpdateDisplay("temperature 2", _temperature2F.ToString("n2") + "F / " + _temperature2.ToString("n2") + "C");
            Thread.Sleep(2 * 1000);

            UpdateDisplay("humidity", _relativeHumidity.ToString("n2") + "%");
            Thread.Sleep(2 * 1000);

            UpdateDisplay("barometer", _pressure.ToString("n2") + " hPa");
            Thread.Sleep(2 * 1000);

            UpdateDisplay("lightness", _lightSensorPercentage.ToString("n2") + "%");
            Thread.Sleep(2 * 1000);
        }
예제 #3
0
        private void Cycle()
        {
            _cycleCount++;
            Debug.Print("sensor cycle: " + _cycleCount);
            UpdateDisplay("sensor cycle", _cycleCount.ToString());

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("state.vitalsAndSensorsUpdated=false");

            sb.AppendLine("vitals.id=" + DeviceId);
            sb.AppendLine("vitals.currentCycle~i=" + _cycleCount);

            _temperature2 = 0; _relativeHumidity = 0;
            temperatureHumidity.RequestMeasurement();
            Thread.Sleep(500);
            sb.AppendLine("sensor.temperatureHumidity.temperature~f=" + _temperature2.ToString());
            sb.AppendLine("sensor.temperatureHumidity.relativeHumidity~f=" + _relativeHumidity.ToString());

            _temperature = 0; _pressure = 0;
            barometer.RequestMeasurement();
            Thread.Sleep(500);
            sb.AppendLine("sensor.barometer.temperature~f=" + _temperature.ToString());
            sb.AppendLine("sensor.barometer.pressure~f=" + _pressure.ToString());

            double gasSenseVoltage = gasSense.ReadVoltage();

            sb.AppendLine("sensor.gasSense.MQ-3.voltage~f=" + gasSenseVoltage.ToString());
            Thread.Sleep(200);

            double lightSensorPercentage = lightSensor.ReadLightSensorPercentage();

            sb.AppendLine("sensor.lightSensor.lightSensorPercentage~f=" + lightSensorPercentage.ToString());

            long memoryBytesFree = Debug.GC(false);

            sb.AppendLine("vitals.memoryBytesFree~i=" + memoryBytesFree);

            sb.AppendLine("sensor.lastLine=" + _lastLine);

            sb.AppendLine("state.vitalsAndSensorsUpdated=true");

            string chatterText = sb.ToString();

            _pcduino1.Write(chatterText);

            UpdateDisplay("temperature 1", _temperatureF.ToString("n2") + "F / " + _temperature.ToString("n2") + "C");
            Thread.Sleep(2 * 1000);

            UpdateDisplay("temperature 2", _temperature2F.ToString("n2") + "F / " + _temperature2.ToString("n2") + "C");
            Thread.Sleep(2 * 1000);

            UpdateDisplay("humidity", _relativeHumidity.ToString("n2") + "%");
            Thread.Sleep(2 * 1000);

            UpdateDisplay("barometer", _pressure.ToString("n2") + " hPa");
            Thread.Sleep(2 * 1000);

            UpdateDisplay("MQ-3 air sensor", gasSenseVoltage.ToString("n2") + " / 3.3 V");
            Thread.Sleep(2 * 1000);

            UpdateDisplay("lightness", lightSensorPercentage.ToString("n2") + "%");
            Thread.Sleep(2 * 1000);
        }