コード例 #1
0
        private void button_Run_Click(object sender, EventArgs e)
        {
            Diags.Customers costumer = (Diags.Customers)Enum.Parse(typeof(Diags.Customers), Properties.Settings.Default.Costumer);

            _diags = new Diags(
                dut_port_name: Properties.Settings.Default.COM_DUT,
                ble_port_name: Properties.Settings.Default.COM_BLE,
                smt_serial: textBox_Serial.Text.ToUpper(),
                customer: costumer,
                hw_version: Properties.Settings.Default.HwVer,
                tester: Properties.Settings.Default.Operator,
                hub_ip_addr: null
                );
            _diags.Status_Event += _diags_Status_Event;

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

            _diags.LED_Red_Low_Value     = Properties.Settings.Default.LED_Red_Off_Val;
            _diags.LED_Red_High_Value    = Properties.Settings.Default.LED_Red_On_Val;
            _diags.LED_Green_Low_Value   = Properties.Settings.Default.LED_Green_Off_Val;
            _diags.LED_Green_High_Value  = Properties.Settings.Default.LED_Green_On_Val;
            _diags.LED_Yellow_Low_Value  = Properties.Settings.Default.LED_Yellow_Off_Val;
            _diags.LED_Yellow_High_Value = Properties.Settings.Default.LED_Yellow_On_Val;

            _run_task = new Task(() => _diags.Run());
            _run_task.ContinueWith(runDone, TaskContinuationOptions.OnlyOnRanToCompletion);
            _run_task.ContinueWith(runError, TaskContinuationOptions.OnlyOnFaulted);


            setRunning(true);

            textBox_OutputStatus.Clear();
            textBox_OutputStatus.AppendText("Parameters:\r\n");
            textBox_OutputStatus.AppendText(string.Format("Operator: {0}\r\n", _diags.Tester));
            textBox_OutputStatus.AppendText(string.Format("DUT COM: {0}\r\n", _diags.COM_DUT_Name));
            textBox_OutputStatus.AppendText(string.Format("BT COM: {0}\r\n", _diags.COM_BT_Name));
            textBox_OutputStatus.AppendText(string.Format("Customer: {0}\r\n", _diags.Customer.ToString()));
            textBox_OutputStatus.AppendText(string.Format("HW Ver: {0}\r\n", _diags.HW_Ver));
            textBox_OutputStatus.AppendText("\r\n");

            this.timer_UpdateRunning.Start();
            _run_task.Start();
        }
コード例 #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);
            }

            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);
        }