static void Main()

in sensors/Tools/MALT/Code/MALTUtil/MALTUtil/Program.cs [19:133]


        static void Main(string[] args)
        {
            Console.WriteLine("Microsoft Ambient Light Tool");

            if (args.Length == 0)
            {
                // Expect the user to have provided a command.
                PrintHelp();
                goto Exit;
            }

            string portName = GetComPort();
            if (portName == null)
            {
                Console.WriteLine("No Arduino devices connected to the system.");
                return;
            }

            port.PortName = portName;
            port.BaudRate = 9600;
            port.Open();

            // Check the first argument for the command.
            string firstArg = args[0].ToLower();

            if (firstArg.Contains("firmwareversion"))
            {
                string version = GetVersion();
                Console.Out.WriteLine("MALT Version: %s.", version);
                goto Exit;
            }
            else if (firstArg.Contains("light"))
            {
                UInt32 lightVal = 0;
                try
                {
                    lightVal = UInt32.Parse(args[1]);
                }
                catch (Exception)
                {
                    Console.WriteLine("Failed to parse light value.");
                    goto Exit;
                }

                SetLight(lightVal);
                goto Exit;
            }
            else if (firstArg.Contains("conversiontime"))
            {
                UInt32 ct = 0;
                try
                {
                    ct = UInt32.Parse(args[1]);
                }
                catch (Exception)
                {
                    Console.WriteLine("Failed to parse conversion time value.");
                    goto Exit;
                }

                SetConversionTime(ct);
                goto Exit;
            }
            else if (firstArg.Contains("screenlux"))
            {
                double screenLux = GetScreenLux();
                Console.Out.WriteLine("Screen Lux: {0}.", screenLux);
                goto Exit;
            }
            else if (firstArg.Contains("ambientlux"))
            {
                double ambientLux = GetAmbientLux();
                Console.Out.WriteLine("Ambient Lux: {0}.", ambientLux);
                goto Exit;
            }
            else if (firstArg.Contains("screencolor"))
            {
                uint[] screenColor = GetScreenColor();
                Console.Out.WriteLine("Screen Color: [Clear: {0}, Red: {1}, Green: {2}, Blue: {3}].", screenColor[0], screenColor[1], screenColor[2], screenColor[3]);
                goto Exit;
            }
            else if (firstArg.Contains("ambientcolor"))
            {
                uint[] ambientColor = GetAmbientColor();
                Console.Out.WriteLine("Ambient Color: [Clear: {0}, Red: {1}, Green: {2}, Blue: {3}].", ambientColor[0], ambientColor[1], ambientColor[2], ambientColor[3]);
                goto Exit;
            }
            else if (firstArg.Contains("autocurve"))
            {
                TakeAutobrightnessCurve();
                goto Exit;
            }
            else if (firstArg.Contains("manualcurve"))
            {
                TakeManualCurve();
                goto Exit;
            }
            else if (firstArg.Contains("stress"))
            {
                // TODO
                //Stress(); 
                goto Exit;
            }
            else
            {
                // Unrecognized command.
                PrintHelp();
            }

            Exit:
            if (port.IsOpen)
            {
                port.Close();
            }
        }