Provides a managed wrapper around the USB-UIRT driver.
Inheritance: IDisposable
 public LearnCommandDlg(Controller controller)
 {
     this.controller = controller;
     this.controller.LearnCompleted += new Controller.LearnCompletedEventHandler(controller_LearnCompleted);
     this.controller.Learning += new Controller.LearningEventHandler(controller_Learning);
     InitializeComponent();
 }
Exemple #2
0
        public AnaForm()
        {
            InitializeComponent();

            usbuirtController = new Controller();

            usbuirtController.Learning += usbuirtController_Learning;
            usbuirtController.LearnCompleted += usbuirtController_LearnCompleted;
        }
Exemple #3
0
 public override void Disconnect()
 {
     if (Controller != null)
     {
         Controller.Dispose();
         Controller = null;
     }
     Connected = false;
 }
        public static void Initialize()
        {
            if (Controller.DriverVersion != 0x0100)
                throw new ApplicationException(String.Format("Unexpected Driver Version (0x%08X)", Controller.DriverVersion));

            m_irc = new Controller();

            m_irc.BlinkOnReceive = true;
            m_irc.BlinkOnTransmit = true;
        }
Exemple #5
0
 public override void Connect()
 {
     if (Controller.DriverVersion != 0x0100)
     {
         string message = string.Format("Unsupported USB-UIRT driver version found.\nFound: {0:X}, required {1:X}", Controller.DriverVersion, 0x0100);
         throw new ApplicationException(message);
     }
     Controller = new Controller();
     Connected = true;
 }
        public MainWindow()
        {
            InitializeComponent();

            usbuirtController = new Controller();
        }
 public static void Uninitialize()
 {
     m_irc.Dispose();
     m_irc = null;
 }
Exemple #8
0
        private static bool DoLoop(Controller mc)
        {
            string toDo = String.Empty;
            do
            {
                Console.WriteLine("\nUsbUirt Managed Wrapper Test Menu v0.5:");
                Console.WriteLine("---------------------------------------");
                Console.WriteLine("(1) Transmit IR Code (blocking)");
                Console.WriteLine("(2) Transmit IR Code (non-blocking)");
                Console.WriteLine("(3) Learn IR Code (Pronto Format)");
                Console.WriteLine("(4) Learn IR Code (UIRT-Raw Format)");
                Console.WriteLine("(5) Learn IR Code (UIRT-Struct Format)");
                Console.WriteLine("(6) Turn BlinkOnReceive {0}", mc.BlinkOnReceive ? "off" : "on");
                Console.WriteLine("(7) Turn BlinkOnTransmit {0}", mc.BlinkOnTransmit ? "off" : "on");
                Console.WriteLine("(8) Turn GenerateLegacyCodesOnReceive {0}", mc.GenerateLegacyCodesOnReceive ? "off" : "on");
                Console.WriteLine("(x) Exit");
                Console.WriteLine("---------------------------------------");

                Console.WriteLine("Press a key...");
                toDo = Console.ReadLine();
            } while(toDo == String.Empty);

            switch(toDo[0])
            {
                case '1':
                    Console.WriteLine("Transmitting IR Code (blocking)...");
                    try
                    {
                        mc.Transmit(irCode, transmitFormat, 10, TimeSpan.Zero);
                    }
                    catch(Exception ex)
                    {
                        Console.WriteLine("*** ERROR calling Transmit! ***");
                        throw;
                    }
                    Console.WriteLine("...Returned from call (Done)!");
                break;

                case '2':
                    using (ManualResetEvent waitEvent = new ManualResetEvent(false))
                    {
                        mc.TransmitCompleted += new UsbUirt.Controller.TransmitCompletedEventHandler(mc_TransmitCompleted);
                        Console.WriteLine("\nTransmitting IR Code (non-blocking)...");
                        try
                        {
                            mc.TransmitAsync(irCode, transmitFormat, 10, TimeSpan.Zero, waitEvent);
                            Console.WriteLine("...Returned from call...");
                            if (waitEvent.WaitOne(5000, false))
                            {
                                Console.WriteLine("...IR Transmission Complete!");
                            }
                            else
                            {
                                Console.WriteLine("*** ERROR: Timeout error waiting for IR to finish!");
                            }
                        }
                        catch(Exception ex)
                        {
                            Console.WriteLine("*** ERROR calling TransmitAsync! ***");
                            throw;
                        }
                        finally
                        {
                            mc.TransmitCompleted -= new UsbUirt.Controller.TransmitCompletedEventHandler(mc_TransmitCompleted);
                        }
                    }
                    break;

                case '3':
                    TestLearn(mc, CodeFormat.Pronto, LearnCodeModifier.None);
                    break;

                case '4':
                    TestLearn(mc, CodeFormat.Uuirt, LearnCodeModifier.None);
                    break;

                case '5':
                    TestLearn(mc, CodeFormat.Uuirt, LearnCodeModifier.ForceStruct);
                    break;

                case '6':
                    mc.BlinkOnReceive = ! mc.BlinkOnReceive;
                    break;

                case '7':
                    mc.BlinkOnTransmit = ! mc.BlinkOnTransmit;
                    break;

                case '8':
                    mc.GenerateLegacyCodesOnReceive = ! mc.GenerateLegacyCodesOnReceive;
                    break;

                case 'x':
                    return false;

                default:
                    break;
            }
            return true;
        }
Exemple #9
0
        private static void TestLearn(Controller mc, CodeFormat learnFormat, LearnCodeModifier learnCodeModifier)
        {
            learnCompletedEventArgs = null;
            Console.WriteLine("<Press x to abort Learn>");
            mc.Learning += new UsbUirt.Controller.LearningEventHandler(mc_Learning);
            mc.LearnCompleted += new UsbUirt.Controller.LearnCompletedEventHandler(mc_LearnCompleted);

            try
            {
                try
                {
                    mc.LearnAsync(learnFormat, learnCodeModifier, learnCompletedEventArgs);
                }
                catch(Exception ex)
                {
                    Console.WriteLine("*** ERROR calling LearnAsync! ***");
                    throw;
                }

                while (learnCompletedEventArgs == null)
                {
                    string s = Console.ReadLine();
                    if (s.Length != 0 && s[0] == 'x')
                    {
                        if (learnCompletedEventArgs == null)
                        {
                            Console.WriteLine("Calling LearnAsyncCancel...");
                            mc.LearnAsyncCancel(learnCompletedEventArgs);
                            Thread.Sleep(1000);
                            break;
                        }
                    }
                    else
                    {
                        Console.WriteLine("<Press x to abort Learn>");
                    }
                }

                if (learnCompletedEventArgs != null &&
                    learnCompletedEventArgs.Cancelled == false &&
                    learnCompletedEventArgs.Error == null)
                {
                    irCode = learnCompletedEventArgs.Code;
                    Console.WriteLine("...Done...IRCode = {0}", irCode);
                    transmitFormat = learnFormat;
                }

            }
            finally
            {
                mc.Learning -= new UsbUirt.Controller.LearningEventHandler(mc_Learning);
                mc.LearnCompleted -= new UsbUirt.Controller.LearnCompletedEventHandler(mc_LearnCompleted);
            }
        }
Exemple #10
0
        private static void RunTestApp()
        {
            Console.WriteLine("UUIRTDRV Example Program...");
            Console.WriteLine("===========================");

            if (Controller.DriverVersion != 0x0100)
            {
                Console.WriteLine("ERROR: Invalid uuirtdrv version!\n");
                return;
            }

            using (Controller mc = new Controller())
            {
                mc.Received += new UsbUirt.Controller.ReceivedEventHandler(mc_Received);
                Console.WriteLine("USB-UIRT Info: Protocol: Version={0} Firmware: Version={1} Date={2}",
                    mc.ProtocolVersion, mc.FirmwareVersion, mc.FirmwareDate.ToShortDateString());

                while(DoLoop(mc) == true);
                mc.Received -= new UsbUirt.Controller.ReceivedEventHandler(mc_Received);
            }
        }
 public AddDeviceDlg(Controller controller)
 {
     this.controller = controller;
     InitializeComponent();
 }
 /// <summary>
 /// Initializes the UsbUirt controller instance
 /// </summary>
 static void init()
 {
     try
     {
         if (UsbUirt.Controller.DriverVersion != 0x0100)
         {
             Console.WriteLine("ERROR: Invalid uuirtdrv version!\n");
             return;
         }
         _controller = new UsbUirt.Controller();
         //_uirtController.Received += new UsbUirt.Controller.ReceivedEventHandler(Uirt_Received);
     }
     catch //(Exception exc)
     {
         throw;
     }
 }
 public static void Test(string IRCode)
 {
     try
     {
         Controller mc = new Controller();
         mc.Transmit(IRCode, CodeFormat.Pronto, 10, TimeSpan.Zero);
         EventLog.WriteEntry("Carousel Monitor Control", "The monitor has been powered on.", EventLogEntryType.Information);
     }
     catch (Exception e)
     {
         EventLog.WriteEntry("Carousel Monitor Control", "Error powering monitor on, " + e.Message, EventLogEntryType.Error);
     }
 }
 public static void PowerOn()
 {
     try
     {
         Properties.Settings settings = new Properties.Settings();
         Controller mc = new Controller();
         mc.Transmit(settings.USBUIRTOn, CodeFormat.Pronto, 10, TimeSpan.Zero);
         EventLog.WriteEntry("Carousel Monitor Control", "The monitor has been powered on.", EventLogEntryType.Information);
     }
     catch (Exception e)
     {
         EventLog.WriteEntry("Carousel Monitor Control", "Error powering monitor on, " + e.Message, EventLogEntryType.Error);
     }
 }
        public static string Learn(System.Windows.Forms.TextBox status)
        {
            CancelLearn = false;

            string irCode = "";
            Controller mc = new Controller();
            learnCompletedEventArgs = null;
            mc.Learning += new UsbUirt.Controller.LearningEventHandler(mc_Learning);
            mc.LearnCompleted += new UsbUirt.Controller.LearnCompletedEventHandler(mc_LearnCompleted);

            try
            {
                try
                {
                    mc.LearnAsync(CodeFormat.Pronto, LearnCodeModifier.None, learnCompletedEventArgs);
                }
                catch (Exception ex)
                {
                    throw;
                }

                while (learnCompletedEventArgs == null)
                {
                    string s = Console.ReadLine();
                    if (CancelLearn == true)
                    {
                        if (learnCompletedEventArgs == null)
                        {
                            mc.LearnAsyncCancel(learnCompletedEventArgs);
                            Thread.Sleep(1000);
                            break;
                        }
                    }
                    else
                    {
                        status.Text = LearnState;
                        status.Update();
                        Thread.Sleep(100);
                    }
                }

                if (learnCompletedEventArgs != null &&
                    learnCompletedEventArgs.Cancelled == false &&
                    learnCompletedEventArgs.Error == null)
                {
                    irCode = learnCompletedEventArgs.Code;
                }

            }
            finally
            {
                mc.Learning -= new UsbUirt.Controller.LearningEventHandler(mc_Learning);
                mc.LearnCompleted -= new UsbUirt.Controller.LearnCompletedEventHandler(mc_LearnCompleted);
            }

            return irCode;
        }