Ejemplo n.º 1
0
        static void Main()
        {
            DEVICE_STATUS s = new DEVICE_STATUS();



            /*for (; ; )
             * {
             *  if (ReaderXP.Connect("192.168.25.207", 30000) != Result.OK)
             *      MessageBox.Show("Error");
             *  ReaderXP.Disconnect();
             * }*/
            /*try
             * {
             *  System.Xml.Serialization.XmlSerializer mySerializer = new System.Xml.Serialization.XmlSerializer(typeof(AntennaList));
             * }
             * catch (Exception ex)
             * {
             *  Console.WriteLine(ex);
             * }*/
            CSLibrary.Constants.Result ret = CSLibrary.Constants.Result.OK;
            Application.EnableVisualStyles();
#if __DISABLE_CS468
            CSLibrary.Diagnostics.CoreDebug.Enable = true;
            XmlLoggingConfiguration xmlConfig = new XmlLoggingConfiguration(System.IO.Path.Combine(HighLevelInterface.CurrentPath, "CS468TagDebug.xml"));
            LogManager.Configuration = xmlConfig;
            tagLogger = LogManager.GetLogger("TAG_DEBUGGER");
#endif
            //First Step
            while (true)
            {
#if NET_BUILD
                using (NetFinderForm finder = new NetFinderForm())
                {
                    if (finder.ShowDialog() == DialogResult.OK)
                    {
                        IP  = finder.ConnectIP;
                        MAC = finder.MAC;
                    }
                    else
                    {
                        goto DEINIT;
                    }
                }
#endif
                CSLibrary.Windows.UI.SplashScreen.Show(CSLibrary.Windows.UI.SplashScreen.CSL.CS203);
                {
#if benchmark
                    Application.DoEvents();

                    DateTime time = DateTime.Now;
                    DateTime time1;

                    //int time = Environment.TickCount;
                    //int time1 = Environment.TickCount;
                    string timediff;

                    if ((ret = ReaderXP.Connect(IP, 30000)) != CSLibrary.Constants.Result.OK)
                    //                    if ((ret = ReaderXP.Connect("USB1", 0)) != CSLibrary.Constants.Result.OK)
                    //#else
                    //                    if ((ret = ReaderXP.Connect()) != CSLibrary.Constants.Result.OK)
                    //#endif
                    {
                        ReaderXP.Disconnect();
                        MessageBox.Show(String.Format("StartupReader Failed{0}", ret));
                        goto DEINIT;
                    }
                    time1 = DateTime.Now;

                    timediff = "Connect time tickcount" + (time1 - time).TotalMilliseconds;
                    MessageBox.Show(timediff);


                    //                    System.Diagnostics.Trace.WriteLine(string.Format("Connect time = {0}", Environment.TickCount - time));
#endif

                    Application.DoEvents();

                    //ReaderXP.EngModeEnable("CSL2006");
                    //ReaderXP.EngDebugModeSetLogFile ("CSLibraryDebug.txt");
                    //ReaderXP.EngDebugModeEnable(HighLevelInterface.DEBUGLEVEL.PERFORMANCE);

                    int time = Environment.TickCount;
#if NET_BUILD
                    if ((ret = ReaderXP.Connect(IP, 20000)) != CSLibrary.Constants.Result.OK)
#else
                    if ((ret = ReaderXP.Connect()) != CSLibrary.Constants.Result.OK)
#endif
                    {
                        ReaderXP.Disconnect();
                        MessageBox.Show(String.Format("StartupReader Failed{0}", ret));
                        goto DEINIT;
                    }
                    System.Diagnostics.Trace.WriteLine(string.Format("Connect time = {0}", Environment.TickCount - time));
                }
                //Load settings

                /*string path = Application.StartupPath;
                 * if (File.Exists(path + @"\settings.txt"))
                 * {
                 *  using (FileStream file = new FileStream(path + @"\settings.txt", FileMode.Open))
                 *  using (StreamReader sr = new StreamReader(file))
                 *  {
                 *      LocalSettings.ServerIP = sr.ReadLine();
                 *      LocalSettings.ServerName = sr.ReadLine();
                 *      LocalSettings.DBName = sr.ReadLine();
                 *      LocalSettings.UserID = sr.ReadLine();
                 *      LocalSettings.Password = sr.ReadLine();
                 *  }
                 * }
                 * else
                 * {
                 *  //Set to default
                 *  LocalSettings.ServerName = "SQLEXPRESS";
                 * }*/


                string MyDocumentFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\CSLReader";

                try
                {
                    System.IO.Directory.CreateDirectory(MyDocumentFolder);
                }
                catch (Exception ex)
                {
                }

                if ((SerialNumber = ReaderXP.GetPCBAssemblyCode()) == null)
                {
                    MessageBox.Show(String.Format("GetPCBAssemblyCode Failed"));
                }

                if (!System.IO.File.Exists(MyDocumentFolder + "\\" + SerialNumber + ".cfg"))
                {
                    LoadDefaultSettings();
                }
                else
                {
                    LoadSettings();
                }

                //Open MainForm and EnableVisualStyles
                Application.Run(new MenuForm());

                /*//Save settings
                 * using (FileStream file = new FileStream(path + @"\settings.txt", FileMode.Create))
                 * using (StreamWriter sw = new StreamWriter(file))
                 * {
                 *  sw.WriteLine(LocalSettings.ServerIP);
                 *  sw.WriteLine(LocalSettings.ServerName);
                 *  sw.WriteLine(LocalSettings.DBName);
                 *  sw.WriteLine(LocalSettings.UserID);
                 *  sw.WriteLine(LocalSettings.Password);
                 * }*/

                ReaderXP.Disconnect();
#if USB_BUILD
                break;
#endif
            }
DEINIT:
            CSLibrary.Windows.UI.SplashScreen.Stop();
        }