Beispiel #1
0
        /// <summary>
        /// Main for the OWNetWatch Demo
        /// </summary>
        /// <param name="args"> command line arguments </param>
        public static void Main1(string[] args)
        {
            int delay;

            try
            {
                // get the default adapter
                DSPortAdapter adapter = OneWireAccessProvider.DefaultAdapter;

                Debug.WriteLine("");
                Debug.WriteLine("Adapter: " + adapter.AdapterName + " Port: " + adapter.PortName);
                Debug.WriteLine("");

                // clear any previous search restrictions
                adapter.setSearchAllDevices();
                adapter.targetAllFamilies();
                adapter.Speed = DSPortAdapter.SPEED_REGULAR;

                // create the watcher with this adapter
                OWNetWatch1 nw = new OWNetWatch1(adapter);

                // sleep for the specified time
                if (args.Length >= 1)
                {
                    delay = Int32.Parse(args[0]);
                }
                else
                {
                    delay = 20000;
                }

                Debug.WriteLine("Monitor run for: " + delay + "ms");
                Thread.Sleep(delay);

                // clean up
                Debug.WriteLine("Done with monitor run, now cleanup threads");
                nw.killNetWatch();

                // free port used by adapter
                adapter.freePort();
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }

            return;
        }
Beispiel #2
0
 public MainPage()
 {
     this.InitializeComponent();
     string[] args = new string[] { "2000000" };
     OWNetWatch1.Main1(args);
 }