Beispiel #1
0
        public MainPage()
        {
            this.InitializeComponent();

            OWWatch1 o = new OWWatch1();

            string[] args = new string[] { "20000" };
            o.Main1(args);
        }
Beispiel #2
0
    /// <summary>
    /// Method main
    ///
    /// </summary>
    /// <param name="args">
    ///  </param>
    public 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;

            OWWatch1 dm = new OWWatch1(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");
            dm.killWatch();

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

        return;
    }