Example #1
0
 private void Form2_Load(object sender, EventArgs e)
 {
     imeiInput1.Focus();
     if (!OEControl.connect())
     {
         MessageBox.Show("Fail to connect UI", "Error");
     }
 }
Example #2
0
 private void WizardPageInProcess_Initialize(object sender, AeroWizard.WizardPageInitEventArgs e)
 {
     this.wizardPageInProcess.Controls.Add(this.imeiInput1);
     this.imeiInput1.Focus();
     labelStatus.Text = "Scan in progress";
     this.wizardPageInProcess.Text = labelStatus.Text;
     Task t = Task.Run(() =>
     {
         Task tt   = Task.Run(() => OEControl.scan());
         bool done = false;
         int step  = 0;
         utility.IniFile avia_device = new utility.IniFile(System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("FDHOME"), "AVIA", "AviaDevice.ini"));
         while (!done)
         {
             System.Threading.Thread.Sleep(300);
             wizardControl1.Invoke(new Action(() =>
             {
                 progressBar1.Value = Math.Min(step++, progressBar1.Maximum);
                 progressBar1.Update();
             }));
             // check the progress
             string cmd = avia_device.GetString("query", "command", "");
             if (string.Compare(cmd, "PMP", true) == 0)
             {
                 wizardControl1.Invoke(new Action(() =>
                 {
                     labelStatus.Text = "Inspection in progress";
                     this.wizardPageInProcess.Text = labelStatus.Text;
                 }));
             }
             // check result
             string grade = avia_device.GetString("device", "grade", "");
             if (!string.IsNullOrEmpty(grade))
             {
                 Program.logIt($"Result: {grade}");
                 done = true;
                 step = 100;
                 wizardControl1.Invoke(new Action(() =>
                 {
                     progressBar1.Value = progressBar1.Maximum;
                     progressBar1.Update();
                 }));
             }
         }
         wizardControl1.Invoke(new Action(() =>
         {
             wizardControl1.NextPage();
         }));
         tt.Wait();
     });
 }
Example #3
0
 private void WizardPageResult_Initialize(object sender, AeroWizard.WizardPageInitEventArgs e)
 {
     Program.logIt("WizardPageResult_Initialize: ");
     this.wizardPageResult.ShowNext = false;
     //this.wizardPageResult.Controls.Add(this.imeiInput1);
     // load grade
     {
         utility.IniFile avia_device = new utility.IniFile(System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("FDHOME"), "AVIA", "AviaDevice.ini"));
         string          grade       = avia_device.GetString("device", "grade", "D");
         labelGrade.Text = grade;
     }
     tokenSource = new CancellationTokenSource();
     // start task wait for device loaded
     Task t = Task.Factory.StartNew((o) =>
     {
         CancellationToken ct = (CancellationToken)o;
         // oe control
         Task tt = Task.Run(() => OEControl.unload());
         //OEControl.unload();
         utility.IniFile avia_device = new utility.IniFile(System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("FDHOME"), "AVIA", "AviaDevice.ini"));
         bool done = false;
         while (!done)
         {
             System.Threading.Thread.Sleep(1000);
             if (ct.IsCancellationRequested)
             {
                 // camcelled.
                 break;
             }
             else
             {
                 string s = avia_device.GetString("device", "device", "");
                 if (string.Compare(s, "removed", true) == 0)
                 {
                     done = true;
                 }
             }
         }
         tt.Wait();
         // device connect.
         if (done)
         {
             //this.Invoke(new Action(() => wizardControl1.NextPage()));
             this.Invoke(new Action(() => this.wizardPageResult.ShowNext = true));
         }
     }, tokenSource.Token);
 }
Example #4
0
        private void WizardPagePlaceDevice_Initialize(object sender, AeroWizard.WizardPageInitEventArgs e)
        {
            this.wizardPagePlaceDevice.Controls.Add(this.imeiInput1);
            this.imeiInput1.clear();
            this.imeiInput1.Focus();
            //pictureBox1.Image = Image.FromFile(@"C:\Tools\logs\Rotating_earth_(large).gif");
            Program.logIt("WizardPagePlaceDevice_Initialize: ++");
#if false
            tokenSource = new CancellationTokenSource();
            // start task wait for device loaded
            Task t = Task.Factory.StartNew((o) =>
            {
                // oe control
                Task tt = Task.Run(() => OEControl.load());
                CancellationToken ct        = (CancellationToken)o;
                utility.IniFile avia_device = new utility.IniFile(System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("FDHOME"), "AVIA", "AviaDevice.ini"));
                bool done = false;
                while (!done)
                {
                    System.Threading.Thread.Sleep(1000);
                    if (ct.IsCancellationRequested)
                    {
                        // camcelled.
                        break;
                    }
                    else
                    {
                        string s = avia_device.GetString("device", "device", "");
                        if (string.Compare(s, "ready", true) == 0)
                        {
                            done = true;
                        }
                    }
                }
                // device connect.
                if (done)
                {
                    this.Invoke(new Action(() => wizardControl1.NextPage()));
                }
                tt.Wait();
            }, tokenSource.Token);
#endif
            Program.logIt("WizardPagePlaceDevice_Initialize: --");
        }
Example #5
0
 private void WizardPagePlaceDevice_Enter(object sender, EventArgs e)
 {
     Program.logIt("WizardPagePlaceDevice_Enter: ++");
     Task.Run(() => OEControl.load());
     //this.imeiInput1.clear();
     // this.imeiInput1.Focus();
     labelReady.Visible             = false;
     wizardPagePlaceDevice.ShowNext = false;
     utility.IniFile ini = new utility.IniFile(System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("FDHOME"), "AVIA", "aviaDevice.ini"));
     //ini.WriteValue("device", "select", comboBoxModels.SelectedItem.ToString());
     ini.DeleteSection("device");
     //this.wizardPagePlaceDevice.Commit += new System.EventHandler<AeroWizard.WizardPageConfirmEventArgs>(this.WizardPagePlaceDevice_Commit);
     //this.wizardPagePlaceDevice.Commit += WizardPagePlaceDevice_Commit;
     Task.Run(() =>
     {
         utility.IniFile avia_device = new utility.IniFile(System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("FDHOME"), "AVIA", "AviaDevice.ini"));
         bool done = false;
         while (!done)
         {
             System.Threading.Thread.Sleep(1000);
             {
                 string s = avia_device.GetString("device", "device", "");
                 if (string.Compare(s, "ready", true) == 0)
                 {
                     done = true;
                 }
             }
         }
         if (done)
         {
             this.Invoke(new Action(() =>
             {
                 labelReady.Visible             = true;
                 wizardPagePlaceDevice.ShowNext = true;
             }));
         }
     });
     Program.logIt("WizardPagePlaceDevice_Enter: --");
 }
Example #6
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     OEControl.stop();
     OEControl.disconnect();
     // clean up
     //if (theApp != null)
     //{
     //    try { theApp.Kill(); }
     //    catch (Exception) { }
     //}
     // shutdown FDPhoneRecognition.exe
     try
     {
         Process ui = new Process();
         ui.StartInfo.FileName        = System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("FDHOME"), "AVIA", "AviaGetPhoneSize.exe");
         ui.StartInfo.Arguments       = "-queryisp -Kill-Service";
         ui.StartInfo.UseShellExecute = false;
         ui.StartInfo.CreateNoWindow  = true;
         ui.StartInfo.WindowStyle     = ProcessWindowStyle.Hidden;
         ui.Start();
     }
     catch (Exception) { }
 }
Example #7
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.UseWaitCursor = false;
            //Bitmap b = new Bitmap(AviaFlowControl.Properties.Resources.AVIA_RGB_web);
            //pictureBox3.Paint += PictureBox3_Paint;
            //wizardControl1.Paint += WizardControl1_Paint;
            //Task.Run(() =>
            //{
            //    while (true)
            //    {
            //        System.Threading.Thread.Sleep(1000);
            //        this.Invoke(new Action(() => { this.Invalidate(); }));
            //    }
            //});
#if false
            Task.Run(() =>
            {
                // start oe app
                utility.IniFile config = new utility.IniFile(System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("FDHOME"), "AVIA", "config.ini"));
                string s = config.GetString("ui", "rect", "");
                if (string.IsNullOrEmpty(s))
                {
                    try
                    {
                        string[] ss       = s.Split(',');
                        int x             = Int32.Parse(ss[0]);
                        int y             = Int32.Parse(ss[1]);
                        int w             = Int32.Parse(ss[2]);
                        int h             = Int32.Parse(ss[3]);
                        Rectangle theRect = new Rectangle(x, y, w, h);
                    }
                    catch (Exception) { }
                }
                s             = config.GetString("ui", "app", @"evaoi-3.1.0.3\evaoi-3.1.0.3.exe");
                string ui_exe = System.IO.Path.GetFullPath(s);
                s             = System.IO.Path.GetFileNameWithoutExtension(ui_exe);
                Process[] p   = Process.GetProcessesByName(s);
                if (p.Length > 0)
                {
                    ShowWindow(p[0].MainWindowHandle, 2);
                    theApp = p[0];
                }
                else
                {
                    if (System.IO.File.Exists(ui_exe))
                    {
                        try
                        {
                            Process ui                    = new Process();
                            ui.StartInfo.FileName         = ui_exe;
                            ui.StartInfo.Arguments        = "-ControlMode";
                            ui.StartInfo.UseShellExecute  = true;
                            ui.StartInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(ui_exe);
                            theApp = ui;
                            ui.Start();
                            ui.WaitForInputIdle();
                        }
                        catch (Exception) { }
                    }
                }

                // connect to OE server
                if (!OEControl.connect())
                {
                    // fail to connect the OE server
                    this.Invoke(new Action(() =>
                    {
                        MessageBox.Show("Fail to connect UI", "Error");
                    }));
                }
                else
                {
                    // connected
                    // load models
                    s = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(ui_exe), "evaoi.xml");
                    if (System.IO.File.Exists(s))
                    {
                        XmlDocument doc = new XmlDocument();
                        try
                        {
                            doc.Load(s);
                            if (doc.DocumentElement != null)
                            {
                                s = doc.DocumentElement["system"]?["ModelDir"]?.InnerText;
                                if (System.IO.Directory.Exists(s))
                                {
                                    foreach (string m in System.IO.Directory.GetDirectories(s))
                                    {
                                        models.Add(System.IO.Path.GetFileName(m));
                                    }
                                }
                            }
                        }
                        catch (Exception) { }
                    }
                }
            });
#endif
            // connect to OE server
            if (!OEControl.connect())
            {
                // fail to connect the OE server
                this.Invoke(new Action(() =>
                {
                    MessageBox.Show("Fail to connect UI", "Error");
                    this.Close();
                }));
            }
        }
Example #8
0
        private void WizardPageLogin_Commit(object sender, AeroWizard.WizardPageConfirmEventArgs e)
        {
            //Point p = System.Windows.Forms.Cursor.Position;
            //Point p1 = new Point();
            //p1.X = p.X - this.DesktopLocation.X ;
            //p1.Y = p.Y - this.DesktopLocation.Y ;
            //Program.logIt($"position: {p1} on N {theRect}: {theRect.Contains(p1)}");

            if (wizardPageLogin.Tag == null)
            {
                this.Enabled   = false;
                Cursor.Current = Cursors.WaitCursor;
                e.Cancel       = true;
                // start log in process
                Task t = Task.Run(() =>
                {
                    try
                    {
                        // log in
                        string dir = System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("FDHOME"), "AVIA", "hydra");
                        System.IO.File.Delete(System.IO.Path.Combine(dir, "HydraLogin.xml"));
                        string exe   = System.IO.Path.Combine(dir, "HydraLogin.exe");
                        string param = $"-u={textBoxUsername.Text} -p={textBoxPassword.Text}";
                        if (System.IO.File.Exists(exe))
                        {
                            System.Collections.Specialized.StringDictionary envs = new System.Collections.Specialized.StringDictionary();
                            envs.Add("APSTHOME", System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("FDHOME"), "AVIA"));
                            //Tuple<int, string[]> res = Program.run_exe(@"c:\windows\system32\notepad.exe", param, envs);
                            Tuple <int, string[]> res = Program.run_exe(exe, param, envs);
                            if (res.Item1 == 0)
                            {
                                // login success, run OE
                                //Task tt = Task.Run(() =>
                                //{
                                //    string exe1 = System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("FDHOME"), "AVIA", "iLauncher.exe");
                                //    string param1 = $"-desktop=test -exe=\"{System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("FDHOME"), "AVIA", "AviaToolset.exe")}\" -args=\"-oecontrol -start\"";
                                //    Process p = new Process();
                                //    p.StartInfo.FileName = exe1;
                                //    p.StartInfo.Arguments = param1;
                                //    p.StartInfo.UseShellExecute = false;
                                //    p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                                //    p.StartInfo.CreateNoWindow = true;
                                //    p.Start();
                                //});
                                if (System.IO.File.Exists(System.IO.Path.Combine(dir, "HydraLogin.xml")))
                                {
                                    utility.IniFile config = new utility.IniFile(System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("FDHOME"), "AVIA", "config.ini"));
                                    // load xml
                                    try
                                    {
                                        XmlDocument doc = new XmlDocument();
                                        doc.Load(System.IO.Path.Combine(dir, "HydraLogin.xml"));
                                        string uid = doc.DocumentElement?["id"]?.InnerText;
                                        config.WriteValue("config", "uid", uid);
                                        //tt.Wait();
                                        wizardControl1.Invoke(new Action(() =>
                                        {
                                            wizardControl1.NextPage();
                                        }));
                                        // clear ini device section
                                        utility.IniFile ini = new utility.IniFile(System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("FDHOME"), "AVIA", "aviaDevice.ini"));
                                        ini.DeleteSection("device");
                                        // OE Control start
                                        OEControl.start();
                                    }
                                    catch (Exception) { }
                                }
                            }
                            else
                            {
                                wizardControl1.Invoke(new Action(() =>
                                {
                                    labelLoginStatus.Text    = $"Fail to login, error code: {res.Item1}";
                                    labelLoginStatus.Visible = true;
                                }));
                            }
                        }
                    }
                    catch (Exception) { }
                    finally
                    {
                        this.Invoke(new Action(() =>
                        {
                            this.Enabled        = true;
                            wizardPageLogin.Tag = null;
                        }));
                        //wizardPageLogin.Tag = null;
                    }
                });
                wizardPageLogin.Tag = t;
            }
            else
            {
                wizardPageLogin.Tag = null;
            }
        }
Example #9
0
 private void Form2_FormClosing(object sender, FormClosingEventArgs e)
 {
     OEControl.disconnect();
 }
Example #10
0
 private void ButtonStop_Click(object sender, EventArgs e)
 {
     OEControl.stop();
 }
Example #11
0
 private void ButtonUnload_Click(object sender, EventArgs e)
 {
     OEControl.unload();
 }
Example #12
0
 private void ButtonScan_Click(object sender, EventArgs e)
 {
     OEControl.scan();
 }