Example #1
0
        public static void Main(string[] args)
        {
            // NOTE: To disable debug output uncomment the following two lines
            //LogManager.Configuration.LoggingRules.RemoveAt(0);
            //LogManager.Configuration.Reload();

            Console.WriteLine("XTenLib test program, waiting for connection.");
            var x10 = new XTenManager();

            // Listen to XTenManager events
            x10.ConnectionStatusChanged += X10_ConnectionStatusChanged;
            x10.ModuleChanged           += X10_ModuleChanged;
            x10.PlcAddressReceived      += X10_PlcAddressReceived;
            x10.PlcFunctionReceived     += X10_PlcFunctionReceived;
            // These RF events are only used for CM15
            x10.RfDataReceived     += X10_RfDataReceived;
            x10.RfCommandReceived  += X10_RfCommandReceived;
            x10.RfSecurityReceived += X10_RfSecurityReceived;
            // Setup X10 interface. For CM15 set PortName = "USB"; for CM11 use serial port path intead (eg. "COM7" or "/dev/ttyUSB0")
            x10.PortName  = "USB";
            x10.HouseCode = "A,C";
            // Connect to the interface
            x10.Connect();

            // Prevent the program from quitting with a noop loop
            while (true)
            {
                Thread.Sleep(1000);
            }
        }
Example #2
0
        public X10()
        {
            if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX)
            {
                // Fix libusb symbolic link
                string assemblyFolder = MigService.GetAssemblyDirectory(this.GetType().Assembly);
                var    libUsbLink     = Path.Combine(assemblyFolder, "libusb-1.0.so");
                if (File.Exists(libUsbLink))
                {
                    File.Delete(libUsbLink);
                }
                // RaspBerry Pi arm-hf (hard-float) dependency check and needed symlink
                if (File.Exists("/lib/arm-linux-gnueabihf/libusb-1.0.so.0.1.0"))
                {
                    MigService.ShellCommand("ln", " -s \"/lib/arm-linux-gnueabihf/libusb-1.0.so.0.1.0\" \"" + libUsbLink + "\"");
                }
                // RaspBerry Pi arm-el dependency check and needed symlink
                else if (File.Exists("/lib/arm-linux-gnueabi/libusb-1.0.so.0.1.0"))
                {
                    MigService.ShellCommand("ln", " -s \"/lib/arm-linux-gnueabi/libusb-1.0.so.0.1.0\" \"" + libUsbLink + "\"");
                }
                // Debian/Ubuntu 64bit dependency and needed symlink check
                else if (File.Exists("/lib/x86_64-linux-gnu/libusb-1.0.so.0"))
                {
                    MigService.ShellCommand("ln", " -s \"/lib/x86_64-linux-gnu/libusb-1.0.so.0\" \"" + libUsbLink + "\"");
                }
                // Remove CM19 kernel drivers to allow access to the device
                MigService.ShellCommand("rmmod", " lirc_atiusb");
                MigService.ShellCommand("rmmod", " ati_remote");
                MigService.ShellCommand("rmmod", " rc_ati_x10");
            }

            // CM19 Transceiver driver
            // TODO: should "rmmod" CM19 kernel modules for CM19Lib to work (Linux)
            cm19Lib = new Cm19Manager();
            cm19Lib.RfCameraReceived   += Cm19LibOnRfCameraReceived;
            cm19Lib.RfDataReceived     += Cm19LibOnRfDataReceived;
            cm19Lib.RfCommandReceived  += Cm19LibOnRfCommandReceived;
            cm19Lib.RfSecurityReceived += Cm19LibOnRfSecurityReceived;

            // CM11 and CM15 PLC driver
            x10Lib = new XTenManager();
            x10Lib.ModuleChanged      += X10lib_ModuleChanged;
            x10Lib.RfDataReceived     += X10lib_RfDataReceived;
            x10Lib.RfSecurityReceived += X10lib_RfSecurityReceived;

            securityModules = new List <InterfaceModule>();
            // try loading cached security modules list
            DeserializeModules(SecurityModulesDb, securityModules);
            standardModules = new List <InterfaceModule>();
        }
Example #3
0
        public X10()
        {
            string assemblyFolder = MigService.GetAssemblyDirectory(this.GetType().Assembly);
            var    libusblink     = Path.Combine(assemblyFolder, "libusb-1.0.so");

            // RaspBerry Pi armel dependency check and needed symlink
            if ((File.Exists("/lib/arm-linux-gnueabi/libusb-1.0.so.0.1.0") || File.Exists("/lib/arm-linux-gnueabihf/libusb-1.0.so.0.1.0")) && !File.Exists(libusblink))
            {
                MigService.ShellCommand("ln", " -s \"/lib/arm-linux-gnueabi/libusb-1.0.so.0.1.0\" \"" + libusblink + "\"");
            }
            // Debian/Ubuntu 64bit dependency and needed symlink check
            if (File.Exists("/lib/x86_64-linux-gnu/libusb-1.0.so.0") && !File.Exists(libusblink))
            {
                MigService.ShellCommand("ln", " -s \"/lib/x86_64-linux-gnu/libusb-1.0.so.0\" \"" + libusblink + "\"");
            }

            x10lib = new XTenManager();
            x10lib.ModuleChanged      += X10lib_ModuleChanged;
            x10lib.RfDataReceived     += X10lib_RfDataReceived;
            x10lib.RfSecurityReceived += X10lib_RfSecurityReceived;
            securityModules            = new List <InterfaceModule>();
        }
Example #4
0
 public X10()
 {
     x10lib = new XTenManager();
     x10lib.ModuleChanged  += X10lib_ModuleChanged;
     x10lib.RfDataReceived += X10lib_RfDataReceived;
 }
Example #5
0
 public X10()
 {
     x10lib = new XTenManager();
     x10lib.PropertyChanged += HandlePropertyChanged;
     x10lib.RfDataReceived  += new Action <RfDataReceivedAction>(x10lib_RfDataReceived);
 }