示例#1
0
        private void Cycle()
        {
            _vitals.IncrementCycleCount();
            int cycleCount = _vitals.CycleCount;

            Debug.Print("Starting cycle: " + cycleCount + " on device: " + DeviceId + " with postCycle: " + _vitals.PostCycle);
            _samplers.Sample("memory");

            if (cycleCount % _vitals.PostCycle == 0)
            {
                StringBuilder sb = new StringBuilder();
                _vitals.AppendStatus(sb);
                _samplers.AppendStatus(sb);
                string chatterRequestText = sb.ToString();

                string chatterUri = NapkinServerUri + "/chatter?format=keyset";
                HttpUtil.DoHttpMethod("POST", chatterUri, _credential, chatterRequestText, false);

                _samplers.Reset();
                _samplers.Sample("memory");
            }

            _samplers.Sample("light_sensor_percentage");
            _samplers.Sample("light_sensor_voltage");
            _samplers.Sample("memory");

            temperatureHumidity.RequestMeasurement();
        }
示例#2
0
文件: Program.cs 项目: yudevan/napkin
        private void Cycle()
        {
            _vitals.IncrementCycleCount();
            int cycleCount = _vitals.CycleCount;

            Debug.Print("Starting cycle: " + cycleCount + " on device: " + DeviceId + " with postCycle: " + _vitals.PostCycle);

            _samplers.Sample("memory");

            if (cycleCount % 2 == 0)
            {
                string button_led = ConfigUtil.GetOrInitConfigValue(NapkinServerUri, DeviceId, "button_led", "off", _credential);
                if (button_led == "on")
                {
                    button.TurnLEDOn();
                }
                else
                {
                    button.TurnLEDOff();
                }
            }

            if (cycleCount % _vitals.PostCycle == 0)
            {
                StringBuilder sb = new StringBuilder();
                _vitals.AppendStatus(sb);
                _samplers.AppendStatus(sb);
                string chatterRequestText = sb.ToString();

                string chatterUri = NapkinServerUri + "/chatter?format=keyset";
                HttpUtil.DoHttpMethod("POST", chatterUri, _credential, chatterRequestText, false);

                _samplers.Reset();
                _samplers.Sample("memory");
            }

            // _gasSenseSampler.Sample();
            // _samplers.Sample("memory");

            _samplers.Sample("light_sensor_percentage");
            _samplers.Sample("light_sensor_voltage");
            _samplers.Sample("memory");

            barometer.RequestMeasurement();
            _samplers.Sample("memory");
        }