Beispiel #1
0
 static void Main(string[] args)
 {
     System.Configuration.Install.InstallContext _args = new System.Configuration.Install.InstallContext(null, args);
     if (_args.IsParameterTrue("debug"))
     {
         System.Console.WriteLine("Wait for debugger, press any key to continue");
         System.Console.ReadKey();
     }
     if (_args.IsParameterTrue("train"))
     {
         // train process
         train(_args.Parameters);
     }
     else if (_args.IsParameterTrue("sample"))
     {
         sample_device(_args.Parameters);
     }
     else if (_args.IsParameterTrue("predict"))
     {
         check_device_color(_args.Parameters);
     }
     else
     {
         //test();
         test_svm();
         //sample_device(_args.Parameters);
         //test_knn();
     }
 }
Beispiel #2
0
 static void Main(string[] args)
 {
     System.Configuration.Install.InstallContext _args = new System.Configuration.Install.InstallContext(null, args);
     if (_args.IsParameterTrue("start-service"))
     {
         bool own = false;
         System.Threading.EventWaitHandle evt = new System.Threading.EventWaitHandle(false, System.Threading.EventResetMode.AutoReset, NAME, out own);
         if (own)
         {
             // download db
             //Task.Run(() => download_imei2model());
             start(evt);
         }
         else
         {
             // already running.
         }
     }
     else if (_args.IsParameterTrue("kill-service"))
     {
         try
         {
             System.Threading.EventWaitHandle evt = System.Threading.EventWaitHandle.OpenExisting(NAME);
             evt.Set();
         }
         catch (Exception) { }
     }
     else
     {
     }
 }
Beispiel #3
0
 static void Main(string[] args)
 {
     System.Configuration.Install.InstallContext _args = new System.Configuration.Install.InstallContext(null, args);
     if (_args.IsParameterTrue("debug"))
     {
         System.Console.WriteLine("Wait for debugger, press any key to continue");
         System.Console.ReadKey();
     }
     if (_args.IsParameterTrue("train"))
     {
         if (_args.Parameters.ContainsKey("file") && System.IO.File.Exists(_args.Parameters["file"]))
         {
             //train(_args.Parameters["file"]);
             train_knn(_args.Parameters["file"]);
             test(@"C:\projects\local\GradeChecker\GradeChecker\bin\Debug\test_data.json");
         }
     }
     else
     {
         //train();
         test(@"C:\projects\local\GradeChecker\GradeChecker\bin\Debug\test_data.json");
     }
 }
Beispiel #4
0
 static int Main(string [] args)
 {
     System.Configuration.Install.InstallContext _args = new System.Configuration.Install.InstallContext(null, args);
     if (_args.IsParameterTrue("debug"))
     {
         MessageBox.Show("wait for debug");
     }
     Program.args = _args.Parameters;
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new Form1());
     //Application.Run(new FormTest());
     return(exit_code);
 }
Beispiel #5
0
 static void Main(string[] args)
 {
     System.Configuration.Install.InstallContext _args = new System.Configuration.Install.InstallContext(null, args);
     if (_args.IsParameterTrue("debug"))
     {
         System.Console.WriteLine("wait for debugger, press any key to continue...");
         System.Console.ReadKey();
     }
     if (_args.IsParameterTrue("start-server"))
     {
         bool own = false;
         System.Threading.EventWaitHandle evt = new System.Threading.EventWaitHandle(false, System.Threading.EventResetMode.AutoReset, TAG, out own);
         if (own)
         {
             start_server(evt, _args.Parameters);
         }
         else
         {
             // server already running.
         }
     }
     else if (_args.IsParameterTrue("kill-server"))
     {
         try
         {
             System.Threading.EventWaitHandle evt = System.Threading.EventWaitHandle.OpenExisting(TAG);
             evt.Set();
             evt.Close();
         }
         catch (Exception) { }
     }
     else
     {
         test();
     }
 }
Beispiel #6
0
 static void Main(string[] args)
 {
     System.Configuration.Install.InstallContext _args = new System.Configuration.Install.InstallContext(null, args);
     if (_args.IsParameterTrue("debug"))
     {
         System.Console.WriteLine("wait for debugger, press any key.");
         System.Console.ReadKey();
     }
     if (_args.Parameters.ContainsKey("test"))
     {
         test(_args.Parameters);
     }
     else
     {
         if (_args.Parameters.ContainsKey("xml"))
         {
             train(_args.Parameters);
         }
     }
 }
Beispiel #7
0
        static int Main(string[] args)
        {
            int ret = -1;

            System.Configuration.Install.InstallContext _args = new System.Configuration.Install.InstallContext(null, args);
            if (_args.IsParameterTrue("debug"))
            {
                System.Console.WriteLine("Press any key to continue.");
                System.Console.ReadKey();
            }
            string adb = "";

            if (_args.Parameters.ContainsKey("adb"))
            {
                if (System.IO.File.Exists(_args.Parameters["adb"]))
                {
                    adb = _args.Parameters["adb"];
                }
            }
            if (string.IsNullOrEmpty(adb))
            {
                // search for adb.exe
                ret = 1;
            }
            else
            {
                logIt($"adb = {adb}");
                string sn = "";
                if (_args.Parameters.ContainsKey("sn"))
                {
                    sn = _args.Parameters["sn"];
                    logIt($"adb = {adb}");
                }
                ret = start(adb, sn);
            }
            return(ret);
        }
Beispiel #8
0
        static void Main1(string[] args)
        {
            System.Configuration.Install.InstallContext _args = new System.Configuration.Install.InstallContext(null, args);
            if (_args.IsParameterTrue("debug"))
            {
                System.Console.WriteLine("Wait for debugger, press any key to continue...");
                System.Console.ReadKey();
            }

            System.Net.HttpListener listener = new System.Net.HttpListener();
            listener.Prefixes.Add("http://+:80/");
            listener.Start();
            listener.BeginGetContext(new AsyncCallback(httpListenerCallback), listener);
            bool quit = false;

            System.Console.WriteLine("Http starts, press x to terminate...");
            while (!quit)
            {
                if (System.Console.KeyAvailable)
                {
                    System.ConsoleKeyInfo k = System.Console.ReadKey();
                    if (k.KeyChar == 'x')
                    {
                        quit = true;
                    }
                }
                if (!quit)
                {
                    System.Threading.Thread.Sleep(1000);
                }
            }
            if (listener.IsListening)
            {
                listener.Stop();
            }
            listener.Close();
        }
Beispiel #9
0
        static int Main(string[] args)
        {
            int ret = -1;

            System.Configuration.Install.InstallContext _args = new System.Configuration.Install.InstallContext(null, args);
            if (_args.IsParameterTrue("debug"))
            {
                Console.WriteLine("Wait for debugger, press any key to continue.");
                Console.ReadKey();
            }
            if (_args.IsParameterTrue("transaction"))
            {
                ret = CmcClient.sendTransaction_BZ(_args.Parameters);
                //ret = CmcClient.sendTransaction(_args.Parameters);
                //ret = CmcClient.sendTransactionToVerizon(_args.Parameters);
            }
            else if (_args.IsParameterTrue("login"))
            {
                ret = CmcClient.cmc_login(_args.Parameters);
            }
            else if (_args.IsParameterTrue("prepareEnv"))
            {
                ret = PrepareEnv.startup(_args.Parameters);
            }
            else if (_args.IsParameterTrue("cleanEnv"))
            {
                //ret = PrepareEnv.startup(_args.Parameters);
            }
            else if (_args.IsParameterTrue("oecontrol"))
            {
                //OEControl.OE_App_3_0_2_0();
                //OEControl.startup(_args.Parameters);
                OEControl.start(_args.Parameters);
            }
            else
            {
                test();
                //OEControl.start();
            }

            return(ret);
        }
Beispiel #10
0
        static void Main(string[] args)
        {
            System.Configuration.Install.InstallContext _arg = new System.Configuration.Install.InstallContext(null, args);
            if (_arg.IsParameterTrue("debug"))
            {
                System.Console.WriteLine("Wait for debugger, press any key to continue...");
                System.Console.ReadKey();
            }
            // dump version
            logIt(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileVersionInfo.ToString());
            // dump args
            logIt(string.Format("called by arg: ({0})", args.Length));
            foreach (string s in args)
            {
                logIt(s);
            }


            IniFile ini          = new IniFile(Path.Combine(Environment.ExpandEnvironmentVariables(@"%APSTHOME%"), "config.ini"));
            String  sMaxcapacity = ini.GetString("battery", "read_ratio_reboot", "false");

            Util.IsMaxCapacity = String.Compare(sMaxcapacity, "true", true) == 0 || String.Compare(sMaxcapacity, "1", true) == 0;
            //Util.IsMaxCapacity = true;
            logIt($"config Maxcapacity = {sMaxcapacity}:{Util.IsMaxCapacity}");
            System.AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            if (_arg.IsParameterTrue("start-service"))
            {
                // start service
                Boolean bRun = false;
                try
                {
                    ewait = System.Threading.EventWaitHandle.OpenExisting(IdeviceInfoSvcHost_Event_Name);
                    ewait.Close();
                    logIt("Instance already started.");
                }
                catch (WaitHandleCannotBeOpenedException)
                {
                    bRun = true;
                }
                catch (Exception) { }
                if (bRun)
                {
                    try {
                        ewait = new EventWaitHandle(false, EventResetMode.ManualReset, IdeviceInfoSvcHost_Event_Name);
                        //Util.InitEnviroment();
                        ThreadPool.QueueUserWorkItem(new WaitCallback(Util.runMonitorExe), null);
                        using (ServiceHost host = new ServiceHost(typeof(Device)))
                        {
                            host.Open();
                            Console.WriteLine(@"go to http://localhost:1930/device to test");
                            Console.WriteLine(@"Press any key to terminate...");
                            while (!ewait.WaitOne(1000))
                            {
                                if (System.Console.KeyAvailable)
                                {
                                    ewait.Set();
                                }
                            }
                            host.Close();
                        }
                        Util.bExit = true;
                        Util.runMonitorExe("-kill-service");
                        ewait.Close();
                    } catch (Exception)
                    {
                        logIt("iTunes MobileDevice.Dll not found.************");
                    }
                    Util.bExit = true;
                    Util.runMonitorExe("-kill-service");
                    ewait.Close();
                }
            }
            else if (_arg.IsParameterTrue("kill-service"))
            {
                // stop service
                try
                {
                    ewait = System.Threading.EventWaitHandle.OpenExisting(IdeviceInfoSvcHost_Event_Name);
                    if (ewait != null)
                    {
                        ewait.Set();
                    }
                }
                catch (Exception) { }
            }
            else
            {
                System.Console.WriteLine("IdeviceInfoSvcHost.exe");
                System.Console.WriteLine("-start-service: to start the service");
                System.Console.WriteLine("-kill-service: to stop the service");
            }
        }
Beispiel #11
0
        static void Main(string[] args)
        {
            System.Configuration.Install.InstallContext _arg = new System.Configuration.Install.InstallContext(null, args);
            if (_arg.IsParameterTrue("debug"))
            {
                System.Console.WriteLine("Wait for debugger, press any key to continue...");
                System.Console.ReadKey();
            }
            // dump version
            logIt(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileVersionInfo.ToString());
            // dump args
            logIt(string.Format("called by arg: ({0})", args.Length));
            foreach (string s in args)
            {
                logIt(s);
            }

            System.AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            if (_arg.IsParameterTrue("start-service"))
            {
                // start service
                Boolean bFind = false;
                try
                {
                    ewait = System.Threading.EventWaitHandle.OpenExisting(IdeviceInfoSvcHost_Event_Name);
                    ewait.Close();
                    logIt("Instance already started.");
                }
                catch (WaitHandleCannotBeOpenedException)
                {
                    bFind = true;
                }
                catch (Exception) { }
                if (bFind)
                {
                    try
                    {
                        ewait = new EventWaitHandle(false, EventResetMode.ManualReset, IdeviceInfoSvcHost_Event_Name);
                        //Util.InitEnviroment();

                        new Thread(() =>
                        {
                            iDeviceClass.start();
                        }).Start();
                        Console.WriteLine(@"Press any key to terminate...");
                        while (!ewait.WaitOne(1000))
                        {
                            if (System.Console.KeyAvailable)
                            {
                                ewait.Set();
                            }
                        }
                        ewait.Close();
                        iDeviceClass.stop();
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            else if (_arg.IsParameterTrue("kill-service"))
            {
                // stop service
                try
                {
                    ewait = System.Threading.EventWaitHandle.OpenExisting(IdeviceInfoSvcHost_Event_Name);
                    if (ewait != null)
                    {
                        ewait.Set();
                    }
                }
                catch (Exception) { }
            }
            else
            {
                System.Console.WriteLine("MonitoriDevice.exe");
                System.Console.WriteLine("-start-service: to start the service");
                System.Console.WriteLine("-kill-service: to stop the service");
            }
        }
Beispiel #12
0
        static void Main(string[] args)
        {
            System.Configuration.Install.InstallContext _args = new System.Configuration.Install.InstallContext(null, args);
            if (_args.IsParameterTrue("debug"))
            {
                System.Console.WriteLine("Wait for debugger, press any key to continue...");
                System.Console.ReadKey();
            }

            logIt(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileVersionInfo.ToString());
            // dump args
            logIt(string.Format("called by arg: ({0})", args.Length));
            foreach (string s in args)
            {
                logIt(s);
            }

            System.Threading.EventWaitHandle e = null;
            if (_args.IsParameterTrue("start-service"))
            {
                // start service
                try
                {
                    e = System.Threading.EventWaitHandle.OpenExisting(androidServer_Event_Name);
                    e.Close();
                    logIt("Instance already started.");
                }
                catch (WaitHandleCannotBeOpenedException)
                {
                    e = new EventWaitHandle(false, EventResetMode.ManualReset, androidServer_Event_Name);
                    //argMap.Add("quitEvent", e);
                    SerialManager.Init();
                    start(args, e);
                    e.Close();
                }
                catch (Exception) { }
            }
            else if (_args.IsParameterTrue("kill-service"))
            {
                // stop service
                try
                {
                    e = System.Threading.EventWaitHandle.OpenExisting(androidServer_Event_Name);
                    if (e != null)
                    {
                        e.Set();
                    }
                }
                catch (Exception) { }
            }
            else
            {
                System.Console.WriteLine(System.Reflection.Assembly.GetExecutingAssembly().GetName().Name);
                System.Console.WriteLine("-start-service: to start the service");
                System.Console.WriteLine("-kill-service: to stop the service");
            }


//          SerialManager serialManager = new SerialManager();
//            serialManager.Init();
        }
Beispiel #13
0
        static int Main(string[] args)
        {
            int ret = 0;

            System.Configuration.Install.InstallContext _args = new System.Configuration.Install.InstallContext(null, args);
            if (_args.IsParameterTrue("debug"))
            {
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey();
            }
            if (_args.IsParameterTrue("QueryISP"))
            {
                //Tuple<bool, int> res = run_debug("QueryISP");
                //if (res.Item1)
                //{
                //    ret = res.Item2;
                //}
                //else
                //{
                //    // do real work
                //}
                handle_QueryISP_Command(_args.Parameters);
            }
            else if (_args.IsParameterTrue("QueryPMP"))
            {
                //
                ret = handle_QueryPMP_Command(_args.Parameters);
            }
            else if (_args.IsParameterTrue("detect"))
            {
                Tuple <bool, int> res = run_debug("detect");
                if (res.Item1)
                {
                    ret = res.Item2;
                }
                else
                {
                    // do real work
                }
            }
            else if (_args.IsParameterTrue("QueryFrame"))
            {
                // test
                TcpClient client = new TcpClient();
                try
                {
                    string root = System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("FDHOME"), "AVIA", "frames");
                    client.Connect(IPAddress.Loopback, 6280);
                    NetworkStream ns     = client.GetStream();
                    byte[]        cmd    = System.Text.Encoding.UTF8.GetBytes("QueryFrame\n");
                    byte[]        data   = new byte[1024];
                    DateTime      _start = DateTime.Now;
                    while ((DateTime.Now - _start).TotalSeconds < 10)
                    {
                        System.Threading.Thread.Sleep(500);
                        ns.Write(cmd, 0, cmd.Length);
                        int read = ns.Read(data, 0, data.Length);
                    }
                }
                catch (Exception) { }
            }
            else
            {
                Program.logIt($"{System.Environment.Is64BitProcess}");
            }
            return(ret);
        }
Beispiel #14
0
        static int Main(string[] args)
        {
            System.AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            System.Configuration.Install.InstallContext _args = new System.Configuration.Install.InstallContext(null, args);
            if (_args.IsParameterTrue("list"))
            {
                List <String> listdev = GetListDevices();
                foreach (var s in listdev)
                {
                    Console.WriteLine(s);
                }
            }
            else if (_args.IsParameterTrue("info"))
            {//device/information?id={id}&force={force}&type={type}
                if (_args.Parameters.ContainsKey("udid"))
                {
                    String force      = _args.IsParameterTrue("force").ToString();
                    String infobundle = _args.Parameters.ContainsKey("type") ? _args.Parameters["type"] : "info";
                    String id         = getRealUDID(_args.Parameters["udid"]);

                    UriBuilder uri = new UriBuilder("http://localhost:1930/");
                    uri.Path = "device/information";
                    var collection = HttpUtility.ParseQueryString(string.Empty);
                    var query      = new NameValueCollection
                    {
                        { "id", id },
                        { "type", infobundle },
                        { "force", force },
                    };
                    foreach (var key in query.Cast <string>().Where(key => !string.IsNullOrEmpty(query[key])))
                    {
                        collection[key] = query[key];
                    }

                    uri.Query = collection.ToString();

                    GetDeviceInfo(uri.Uri);
                }
                else
                {
                    return(2);
                }
            }
            else if (_args.IsParameterTrue("infokey"))
            {//device/info?id={id}&key={key}&domain={domain}
                if (_args.Parameters.ContainsKey("udid"))
                {
                    String key    = _args.Parameters.ContainsKey("key") ? _args.Parameters["key"] : "";
                    String domain = _args.Parameters.ContainsKey("type") ? _args.Parameters["type"] : "";
                    String id     = getRealUDID(_args.Parameters["udid"]);

                    UriBuilder uri = new UriBuilder("http://localhost:1930/");
                    uri.Path = "device/info";
                    var collection = HttpUtility.ParseQueryString(string.Empty);
                    var query      = new NameValueCollection
                    {
                        { "id", id },
                        { "key", key },
                        { "domain", domain },
                    };
                    foreach (var ky in query.Cast <string>().Where(ky => !string.IsNullOrEmpty(query[ky])))
                    {
                        collection[ky] = query[ky];
                    }

                    uri.Query = collection.ToString();

                    GetDeviceInfo(uri.Uri);
                }
                else
                {
                    return(1);
                }
            }

            return(0);
        }