Beispiel #1
0
        public static void Main()
        {
            bool switchToBootLoader = false;

            var mode = SystemUpdate.GetMode();

            if (mode == SystemUpdate.SystemUpdateMode.NonFormatted)
            {
                // This erases the application!
                Debug.Print("SystemUpdate.EnableBootLoader - formatting !!!!!!");
                SystemUpdate.EnableBootloader();
            }

            if (mode == SystemUpdate.SystemUpdateMode.Bootloader)
            {
                // Switch to application mode.
                Debug.Print("SystemUpdate.AccessApplication");
                SystemUpdate.AccessApplication();
            }

            if (mode == SystemUpdate.SystemUpdateMode.Application)
            {
                // Developer use only: Switch to BootLoader
                if (switchToBootLoader)
                {
                    SystemUpdate.AccessBootloader();
                }
            }

            // LED - Flashing for 5 seconds.
            LED.State = LED.LedState.FlashingData;
            Thread.Sleep(5000);

            // LED - switch on.
            LED.State = LED.LedState.On;

            // Start PDA comms thread.
            PDA.Start();

            // Start meter comms thread.
            EMR3.Start();

            while (true)
            {
                // Sleep a second
                Thread.Sleep(1000);
            }
        }
Beispiel #2
0
        static void main()
        {
            int idx = 0;

            // Poll forever
            while (true)
            {
                try
                {
                    // Poll meter for realtime litres.
                    PDA.ProcessMessage("Grl");

                    switch (idx)
                    {
                    case 0:
                        // Poll meter for status.
                        PDA.ProcessMessage("Gs");
                        break;

                    case 1:
                        // Poll meter for preset litres.
                        PDA.ProcessMessage("Gpl");
                        break;

                    case 2:
                        // Poll meter for current temperature.
                        PDA.ProcessMessage("Gt");
                        break;
                    }

                    if (++idx == 3)
                    {
                        idx = 0;
                    }
                }
                catch (Exception ex)
                {
                    Debug.Print("EMR3: Exception " + ex.Message);
                }

                // A message is sent every 100 ms
                Thread.Sleep(100);
            }
        }