Esempio n. 1
0
        static int Main(string[] args)
        {
            var options        = new Options();
            var parser_options = new CommandLine.ParserSettings {
                MutuallyExclusive = true
            };
            var parser = new CommandLine.Parser(parser_options);

            var isValid = parser.ParseArguments(args, options);

            if (!isValid)
            {
                Console.WriteLine(CommandLine.Text.HelpText.AutoBuild(options).ToString());
                return(-1);
            }

            if (options.Linenum >= 0)
            {
                while (true)
                {
                    double val = ZCommon.NIUtils.Read_SingelAi((uint)options.Linenum);
                    string msg = string.Format("A{0} = {1}", options.Linenum, val.ToString("G2"));
                    Console.WriteLine(msg);

                    if (!options.Continous)
                    {
                        break;
                    }
                    ;
                }
            }

            return(0);
        }
Esempio n. 2
0
        static int Main(string[] args)
        {
            var options = new Options();
            var parser_options = new CommandLine.ParserSettings { MutuallyExclusive = true };
            var parser = new CommandLine.Parser(parser_options);

            var isValid = parser.ParseArguments(args, options);
            if (!isValid)
            {
                Console.WriteLine(CommandLine.Text.HelpText.AutoBuild(options).ToString());
                return -1;
            }

             DataUtils.PrintHubLabel(
                options.SMTSerial,
                options.ZPLFile,
                options.PrinterAddres
                );

            return 0;
        }
Esempio n. 3
0
        static int Main(string[] args)
        {
            //Console.WriteLine("Press Enter to continue");
            //Console.Read();

            _log.Info("App started");

            var options        = new Options();
            var parser_options = new CommandLine.ParserSettings {
                MutuallyExclusive = true
            };
            var parser  = new CommandLine.Parser(parser_options);
            var isValid = parser.ParseArguments(args, options);

            if (!isValid)
            {
                Console.WriteLine(CommandLine.Text.HelpText.AutoBuild(options).ToString());
                return(-1);
            }

            // Don't allow lower case serial
            options.SMT_Serial = options.SMT_Serial.ToUpper();
            Console.WriteLine("SMT Serial: " + options.SMT_Serial);
            Console.WriteLine("Host: " + options.Host);
            Console.WriteLine();


            // Check board was passed diags
            try
            {
                using (CLStoreEntities cx = new CLStoreEntities())
                {
                    LowesHub h    = cx.LowesHubs.Where(lh => lh.smt_serial == options.SMT_Serial).OrderByDescending(lh => lh.date).First();
                    string   info = string.Format("Hub {0} last diags {1}", h.MacAddress.MAC.ToString("X"), h.date.ToString());
                    _log.Info(info);
                }
            }
            catch (Exception ex)
            {
                _log.Fatal("Problem retrieving Hub diag info\r\n\r\n" + ex.Message + "\r\n" + ex.StackTrace);
                return(-3);
            }


            if (options.CalibrateLEDs)
            {
                BatteryTest batcal = new BatteryTest(options.Host, options.SMT_Serial);

                char save_option = 'n';
                while (true)
                {
                    Console.WriteLine("Getting LEDs values...\r\n");
                    double[] values = batcal.GetLEDsValues();
                    int      i      = 0;

                    Console.WriteLine("Red On   : {0}", values[i++].ToString("G2"));
                    Console.WriteLine("Green On : {0}", values[i++].ToString("G2"));
                    Console.WriteLine("Yellow On: {0}", values[i++].ToString("G2"));

                    Console.WriteLine();

                    Console.WriteLine("Red Off   : {0}", values[i++].ToString("G2"));
                    Console.WriteLine("Green Off : {0}", values[i++].ToString("G2"));
                    Console.WriteLine("Yellow Off: {0}", values[i++].ToString("G2"));

                    i = 0;
                    Properties.Settings.Default.LED_Red_On_Val    = values[i++];
                    Properties.Settings.Default.LED_Green_On_Val  = values[i++];
                    Properties.Settings.Default.LED_Yellow_On_Val = values[i++];

                    Properties.Settings.Default.LED_Red_Off_Val    = values[i++];
                    Properties.Settings.Default.LED_Green_Off_Val  = values[i++];
                    Properties.Settings.Default.LED_Yellow_Off_Val = values[i++];

                    Console.WriteLine("Save Values? (y/n/r):");
                    save_option = Convert.ToChar(Console.Read());
                    if (save_option != 'r')
                    {
                        break;
                    }
                }
                if (save_option == 'y')
                {
                    Properties.Settings.Default.Save();
                }
            }

            try
            {
                if (!options.NoJigMode)
                {
                    BatteryTest battery_test = new BatteryTest(options.Host, options.SMT_Serial);

                    battery_test.InvalidateEnabled = !options.DisableInvalidate;
                    battery_test.Status_Event     += Battery_test_Status_Event;

                    battery_test.LogFolder = Properties.Settings.Default.Log_Folder;
                    Directory.CreateDirectory(battery_test.LogFolder);

                    battery_test.LED_Red.OnVal     = Properties.Settings.Default.LED_Red_On_Val;
                    battery_test.LED_Red.OffVal    = Properties.Settings.Default.LED_Red_Off_Val;
                    battery_test.LED_Green.OnVal   = Properties.Settings.Default.LED_Green_On_Val;
                    battery_test.LED_Green.OffVal  = Properties.Settings.Default.LED_Green_Off_Val;
                    battery_test.LED_Yellow.OnVal  = Properties.Settings.Default.LED_Yellow_On_Val;
                    battery_test.LED_Yellow.OffVal = Properties.Settings.Default.LED_Yellow_Off_Val;

                    battery_test.Run();
                }
                else
                {
                    BatteryTestNoJig batery_test = new BatteryTestNoJig(options.Host, options.SMT_Serial);
                    batery_test.InvalidateEnabled = !options.DisableInvalidate;

                    batery_test.Status_Event += Baterytest_Status_Event;

                    batery_test.LogFolder = Properties.Settings.Default.Log_Folder;
                    Directory.CreateDirectory(batery_test.LogFolder);

                    batery_test.Run();
                }
            }
            catch (Exception ex)
            {
                _log.Fatal(ex.Message + "\r\n" + ex.StackTrace);
                return(-2);
            }
            finally
            {
                if (!options.NoJigMode)
                {
                    BatteryJig.Set_all_relays(false);
                }
            }

            _log.Info("All Tests Passed");

            if (!options.PrintLabelDisabled)
            {
                _log.Info("Printing label...");
                try
                {
                    DataUtils.PrintHubLabel(
                        options.SMT_Serial,
                        Properties.Settings.Default.ZPL_Lable_File,
                        Properties.Settings.Default.Printer_Address);
                }
                catch (Exception ex)
                {
                    _log.Fatal(ex.Message + "\r\n" + ex.StackTrace);
                    return(-2);
                }
                finally
                {
                }
            }

            return(0);
        }
Esempio n. 4
0
        static int Main(string[] args)
        {
            var options        = new Options();
            var parser_options = new CommandLine.ParserSettings {
                MutuallyExclusive = true
            };
            var parser = new CommandLine.Parser(parser_options);

            var isValid = parser.ParseArguments(args, options);

            if (!isValid)
            {
                Console.WriteLine(CommandLine.Text.HelpText.AutoBuild(options).ToString());
                return(-1);
            }

            Console.WriteLine("Parameters used:");

            string propname = "com_dut";

            save_property(propname, options.Com_DUT);
            string valuestr = Properties.Settings.Default[propname].ToString();

            if (valuestr == null || valuestr == string.Empty)
            {
                Console.WriteLine(CommandLine.Text.HelpText.AutoBuild(options).ToString());
                Console.WriteLine(propname.ToUpper() + " not specified");
                return(-1);
            }
            Console.WriteLine(propname.ToUpper() + ": " + valuestr);
            string com_dut = valuestr;

            propname = "com_ble";
            save_property(propname, options.com_ble);
            valuestr = Properties.Settings.Default[propname].ToString();
            if (valuestr == null || valuestr == string.Empty)
            {
                Console.WriteLine(CommandLine.Text.HelpText.AutoBuild(options).ToString());
                Console.WriteLine(propname.ToUpper() + " not specified");
                return(-1);
            }
            Console.WriteLine(propname.ToUpper() + ": " + valuestr);
            string com_ble = valuestr;

            // Don't allow lower case serials
            options.SMT_Serial = options.SMT_Serial.ToUpper();
            Console.WriteLine("SMT Serial: " + options.SMT_Serial);
            Diags.Customers customer = Diags.Customers.IRIS;
            if (options.Customer_Amazon)
            {
                customer = Diags.Customers.Amazon;
            }
            else if (options.Customer_Centralite)
            {
                customer = Diags.Customers.Centralite;
            }
            Console.WriteLine("Costumer: " + customer.ToString());
            Console.WriteLine("HW Version: " + options.HW_Version);

            string tester    = DataUtils.OperatorName(options.Tester);
            int    tester_id = DataUtils.OperatorId(tester);

            Console.WriteLine("Tester: " + tester);
            Console.WriteLine();

            // For debug
            //Console.WriteLine("Press Enter to continue");
            //Console.ReadLine();

            Console.WriteLine("Run Tests...");
            try
            {
                using
                (
                    Diags diags = new Diags
                                  (
                        dut_port_name: com_dut, ble_port_name: com_ble,
                        smt_serial: options.SMT_Serial,
                        customer: customer,
                        hw_version: options.HW_Version,
                        tester: tester,
                        hub_ip_addr: options.Hub_IP
                                  )
                )
                {
                    diags.LogFolder = Properties.Settings.Default.Log_Folder;
                    Directory.CreateDirectory(diags.LogFolder);

                    diags.Status_Event  += Diags_Status_Event;
                    diags.Program_Radios = options.Program_Radios;

                    diags.BLETestDisable = options.BLETestDisabeld;

                    diags.Run();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine();
                Console.WriteLine(ex.Message);
                Console.WriteLine();
                Console.WriteLine(ex.StackTrace);

                if (ex is System.Data.Entity.Validation.DbEntityValidationException)
                {
                    var exd = (System.Data.Entity.Validation.DbEntityValidationException)ex;
                    foreach (var eves in exd.EntityValidationErrors)
                    {
                        Console.WriteLine(eves.Entry.Entity.ToString());
                        foreach (var eve in eves.ValidationErrors)
                        {
                            Console.WriteLine(eve.ErrorMessage);
                        }
                    }
                }
                else if (ex is System.Data.Entity.Infrastructure.DbUpdateException)
                {
                    var exd = (System.Data.Entity.Infrastructure.DbUpdateException)ex;
                    Console.WriteLine(exd.InnerException.InnerException.Message);
                }



                return(-1);
            }
            finally
            {
                Diags.Set_all_relays(false);
            }
            Console.WriteLine("All Tests Passed");

            return(0);
        }