Exemplo n.º 1
0
        public MovieAPI(CP3Smart smartexe)
        {
            this.relayBedRoomScreenUp   = smartexe.relayBedRoomScreenUp;
            this.relayBedRoomScreenDown = smartexe.relayBedRoomScreenDown;

            this.irBedRoom = smartexe.myIROutputPort2;

            try
            {
                irBedRoom.LoadIRDriver(Crestron.SimplSharp.CrestronIO.Directory.GetApplicationDirectory() + "\\IR\\OnkyoRecv.ir");
                irBedRoom.LoadIRDriver(Crestron.SimplSharp.CrestronIO.Directory.GetApplicationDirectory() + "\\IR\\LG.ir");
            }
            catch (Exception ex)
            {
                ILiveDebug.Instance.WriteLine(ex.Message);
            }
        }
Exemplo n.º 2
0
        public ILiveORMA(IROutputPort smart)
        {
            this.irORMA51 = smart;//书房空调

            string file = Crestron.SimplSharp.CrestronIO.Directory.GetApplicationDirectory() + "\\IR\\OMAR51.ir";

            try
            {
                uint i = irORMA51.LoadIRDriver(file);
                // ILiveDebug.WriteLine("dirver"+i);
            }
            catch (Exception ex)
            {
                ILiveDebug.Instance.WriteLine(ex.Message);
            }
        }
Exemplo n.º 3
0
        private static uint LoadIRDiver(string Filename)
        {
            uint DriverID = 0;

            try
            {
                DriverID = _IROutputPort.LoadIRDriver(Filename);
            }
            catch (ArgumentException)
            {
                ErrorLog.Error("Invalid IR File being loaded: {0}", Filename);
            }
            catch (FileNotFoundException)
            {
                ErrorLog.Error("IR file being loaded was not found: {0}", Filename);
            }
            return(DriverID);
        }
Exemplo n.º 4
0
        public ClinateAPI(CP3Smart smart)
        {
            this.irStudyRoom = smart.myIROutputPort5; //书房空调
            this.irLiving    = smart.myIROutputPort6; //客厅空调

            string file = Crestron.SimplSharp.CrestronIO.Directory.GetApplicationDirectory() + "\\IR\\songxia.ir";

            // ILiveDebug.WriteLine(file);
            try
            {
                uint i = irStudyRoom.LoadIRDriver(file);
                uint j = irLiving.LoadIRDriver(file);
                // ILiveDebug.WriteLine("dirver"+i);
            }
            catch (Exception ex)
            {
                ILiveDebug.Instance.WriteLine(ex.Message);
            }
        }
Exemplo n.º 5
0
        object systemStart(object userObject)
        {
            while (ServerIP.Length < 7)
            {
                ServerIP = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0);
                CrestronConsole.PrintLine("ServerIP: Retry Until LAN Ready: {0}", ServerIP);
                Thread.Sleep(1000);
            }
            if (this.SupportsIROut)
            {
                IR1.LoadIRDriver("\\USER\\Samsung UE40J5100AK.ir");
                IR1.Register();
            }

            Xpan            = new Xpanel(0x03, this);
            Xpan.SigChange += new SigEventHandler(MyXPanSigChangeHandler);
            Xpan.Register();
            return(null);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Loads the IR driver at path
 /// </summary>
 /// <param name="path"></param>
 public void LoadDriver(string path)
 {
     if (string.IsNullOrEmpty(path))
     {
         path = DriverFilepath;
     }
     try
     {
         IrPortUid           = IrPort.LoadIRDriver(path);
         DriverFilepath      = path;
         StandardIrPulseTime = 200;
         DriverIsLoaded      = true;
     }
     catch
     {
         DriverIsLoaded = false;
         var message = string.Format("WARNING IR Driver '{0}' failed to load", path);
         Debug.Console(0, this, message);
         ErrorLog.Error(message);
     }
 }
Exemplo n.º 7
0
        public AppleTV(IROutputPort irPort)
        {
            _irPort = irPort;

            if (!File.Exists(IRFilePath))
            {
                Debug.WriteWarn("Apple TV IR File not found. Looking for file in resources...");
                var assembly = Assembly.GetExecutingAssembly();
                var stream   = assembly.GetManifestResourceStream(GetType().GetCType(), @"Apple_AppleTV_3rd_Generation.ir");
                using (var fileStream = File.Create(IRFilePath))
                {
                    var buffer = new byte[8 * 1024];
                    int len;
                    while ((len = stream.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        fileStream.Write(buffer, 0, len);
                    }
                    fileStream.Close();
                }
                Debug.WriteSuccess("Apple TV IR file saved to", IRFilePath);
            }

            var irDriverId = _irPort.LoadIRDriver(IRFilePath);

#if DEBUG
            CrestronConsole.PrintLine("Created Apple TV source control using IR port {0}", _irPort.ID);
            CrestronConsole.PrintLine("Following IR Commands are available:");

            uint count = 0;
            foreach (var irCommandName in _irPort.AvailableIRCmds(irDriverId))
            {
                CrestronConsole.PrintLine(" - {0} [{1}]", irCommandName, count);
                count++;
            }
#endif
        }
Exemplo n.º 8
0
        /// <summary>
        /// Constructor of the Control System Class. Make sure the constructor always exists.
        /// If it doesn't exit, the code will not run on your 3-Series processor.
        /// </summary>
        public ControlSystem()
            : base()
        {
            CrestronConsole.PrintLine("Hello World - Program SIMPL#Pro LinckATLSIMPLSharpPro started ...");

            // Set the number of threads which you want to use in your program - At this point the threads cannot be created but we should
            // define the max number of threads which we will use in the system.
            // the right number depends on your project; do not make this number unnecessarily large
            try
            {
                Thread.MaxNumberOfUserThreads = 20;

               //Subscribe to the controller events (System, Program, and Etherent)
                CrestronEnvironment.SystemEventHandler += new SystemEventHandler(ControlSystem_ControllerSystemEventHandler);
                CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControlSystem_ControllerProgramEventHandler);
                CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(ControlSystem_ControllerEthernetEventHandler);
                CrestronConsole.AddNewConsoleCommand(UpperCase, "ToUpper", "Replies to strings un Upper case", ConsoleAccessLevelEnum.AccessOperator);
                var returnVar = CrestronCresnetHelper.Query();
                if (returnVar == CrestronCresnetHelper.eCresnetDiscoveryReturnValues.Success)
                {
                    foreach (var item in CrestronCresnetHelper.DiscoveredElementsList)
                    {
                        CrestronConsole.PrintLine("Found Item: {0}, {1}", item.CresnetId, item.DeviceModel);
                    }
                }
            }
            catch (Exception e)
            {
                ErrorLog.Error("Error in constructor: {0}", e.Message);
            }

            // Reghister Keypad
            if (this.SupportsCresnet)
            {
                myKeypad = new C2nCbdP(0x25, this);

                myKeypad.ButtonStateChange += new ButtonEventHandler(myKeypad_ButtonStateChange);

                if (myKeypad.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                    ErrorLog.Error("myKeypad failed registration. Cause: {0}", myKeypad.RegistrationFailureReason);
            }

            // Register all devices which the program wants to use
            // Check if device supports Ethernet
            if (this.SupportsEthernet)
            {
                myXpanel = new XpanelForSmartGraphics(0xA5, this);  // Register the Xpanel on IPID 0xA5

                // Register a single eventhandler for all three UIs. This guarantees that they all operate
                // the same way.
                myXpanel.SigChange += new SigEventHandler(MySigChangeHandler);

                // Register the devices for usage. This should happen after the
                // eventhandler registration, to ensure no data is missed.
                if (myXpanel.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                    ErrorLog.Error("MyXpanel failed registration. Cause: {0}", myXpanel.RegistrationFailureReason);
            }
            // Load IR DriverC:\Users\paul\Documents\GitHubWin10\SIMPLSharp\LinckATLSIMPLSharpPro\LinckATLSIMPLSharpPro\Properties\ControlSystem.cfg
            myIROutputDevice = IROutputPorts[1];
            myIROutputDevice.LoadIRDriver(String.Format(@"{0}\IR\Samsung_LNS4051.ir", Directory.GetApplicationDirectory()));

            return;
        }
Exemplo n.º 9
0
        /// <summary>
        /// Constructor of the Control System Class. Make sure the constructor always exists.
        /// If it doesn't exit, the code will not run on your 3-Series processor.
        /// </summary>
        public ControlSystem()
            : base()
        {
            CrestronConsole.PrintLine("Hello World - Program SIMPL#Pro LinckATLSIMPLSharpPro started ...");

            // Set the number of threads which you want to use in your program - At this point the threads cannot be created but we should
            // define the max number of threads which we will use in the system.
            // the right number depends on your project; do not make this number unnecessarily large
            try
            {
                Thread.MaxNumberOfUserThreads = 20;

                //Subscribe to the controller events (System, Program, and Etherent)
                CrestronEnvironment.SystemEventHandler        += new SystemEventHandler(ControlSystem_ControllerSystemEventHandler);
                CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControlSystem_ControllerProgramEventHandler);
                CrestronEnvironment.EthernetEventHandler      += new EthernetEventHandler(ControlSystem_ControllerEthernetEventHandler);
                CrestronConsole.AddNewConsoleCommand(UpperCase, "ToUpper", "Replies to strings un Upper case", ConsoleAccessLevelEnum.AccessOperator);
                var returnVar = CrestronCresnetHelper.Query();
                if (returnVar == CrestronCresnetHelper.eCresnetDiscoveryReturnValues.Success)
                {
                    foreach (var item in CrestronCresnetHelper.DiscoveredElementsList)
                    {
                        CrestronConsole.PrintLine("Found Item: {0}, {1}", item.CresnetId, item.DeviceModel);
                    }
                }
            }
            catch (Exception e)
            {
                ErrorLog.Error("Error in constructor: {0}", e.Message);
            }


            // Reghister Keypad
            if (this.SupportsCresnet)
            {
                myKeypad = new C2nCbdP(0x25, this);

                myKeypad.ButtonStateChange += new ButtonEventHandler(myKeypad_ButtonStateChange);

                if (myKeypad.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    ErrorLog.Error("myKeypad failed registration. Cause: {0}", myKeypad.RegistrationFailureReason);
                }
            }

            // Register all devices which the program wants to use
            // Check if device supports Ethernet
            if (this.SupportsEthernet)
            {
                myXpanel = new XpanelForSmartGraphics(0xA5, this);  // Register the Xpanel on IPID 0xA5

                // Register a single eventhandler for all three UIs. This guarantees that they all operate
                // the same way.
                myXpanel.SigChange += new SigEventHandler(MySigChangeHandler);

                // Register the devices for usage. This should happen after the
                // eventhandler registration, to ensure no data is missed.
                if (myXpanel.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    ErrorLog.Error("MyXpanel failed registration. Cause: {0}", myXpanel.RegistrationFailureReason);
                }
            }
            // Load IR DriverC:\Users\paul\Documents\GitHubWin10\SIMPLSharp\LinckATLSIMPLSharpPro\LinckATLSIMPLSharpPro\Properties\ControlSystem.cfg
            myIROutputDevice = IROutputPorts[1];
            myIROutputDevice.LoadIRDriver(String.Format(@"{0}\IR\Samsung_LNS4051.ir", Directory.GetApplicationDirectory()));

            return;
        }
Exemplo n.º 10
0
        public ControlSystem()
            : base()
        {
            try
            {
                Thread.MaxNumberOfUserThreads = 20;
                //Hello World Crestron Console
                CrestronConsole.AddNewConsoleCommand(HelloPrinting, "HelloWorld", "Prints Hello & the text that follows", ConsoleAccessLevelEnum.AccessOperator);
                //Subscribe to the controller events (System, Program, and Ethernet)
                CrestronEnvironment.SystemEventHandler        += new SystemEventHandler(ControlSystem_ControllerSystemEventHandler);
                CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControlSystem_ControllerProgramEventHandler);
                CrestronEnvironment.EthernetEventHandler      += new EthernetEventHandler(ControlSystem_ControllerEthernetEventHandler);
                CrestronConsole.PrintLine("DefaultConstructor Complete"); //Hello World
                #region Keypad
                if (this.SupportsCresnet)                                 //Make sure the system has CresNet
                {
                    myKeypad = new C2nCbdP(0x25, this);
                    myKeypad.ButtonStateChange += new ButtonEventHandler(myKeypad_ButtonStateChange);
                    if (myKeypad.NumberOfVersiPorts > 0) //VersiPort addtion
                    {
                        for (uint i = 1; i < 2; i++)
                        {
                            myKeypad.VersiPorts[i].SetVersiportConfiguration(eVersiportConfiguration.DigitalInput);
                            myKeypad.VersiPorts[i].VersiportChange += new VersiportEventHandler(ControlSystem_VersiportChange);
                        }
                    }

                    if (myKeypad.Register() != eDeviceRegistrationUnRegistrationResponse.Success) // Hello World Keypad
                    {
                        ErrorLog.Error("Error Registering Keypad on ID 0x25: {0}", myKeypad.RegistrationFailureReason);
                    }
                    else
                    {
                        myKeypad.Button[1].Name = eButtonName.Up;
                        myKeypad.Button[2].Name = eButtonName.Down;
                    }
                }
                #endregion
                #region KeypadWithQuery
                //Define Keypad with Device Query
                if (this.SupportsCresnet)
                {
                    var QueryResponse = CrestronCresnetHelper.Query();
                    if (QueryResponse == CrestronCresnetHelper.eCresnetDiscoveryReturnValues.Success)
                    {
                        //foreach (CrestronCresnetHelper.DiscoveredDeviceElement Item in CrestronCresnetHelper.DiscoveredElementsList)  //Gets a little long so we do the var in instead and it works it out
                        foreach (var Item in CrestronCresnetHelper.DiscoveredElementsList)
                        {
                            if (Item.DeviceModel.ToUpper().Contains("C2N-CBD"))
                            {
                                if (myKeypad == null) //Check to make sure we have not done created it already.
                                {
                                    myKeypad = new C2nCbdP(Item.CresnetId, this);
                                    myKeypad.ButtonStateChange += new ButtonEventHandler(myKeypad_ButtonStateChange);
                                    if (myKeypad.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                                    {
                                        ErrorLog.Error("Error Registering Keypad: {0}", myKeypad.RegistrationFailureReason);
                                        myKeypad = null;
                                    }
                                }
                            }
                        }
                    }
                }
                #endregion
                #region IR
                if (this.SupportsIROut)
                {
                    if (ControllerIROutputSlot.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                    {
                        ErrorLog.Error("Error Registering IR Slot: {0}", ControllerIROutputSlot.DeviceRegistrationFailureReason);
                    }
                    else
                    {
                        myPort = IROutputPorts[1];
                        myPort.LoadIRDriver(@"\NVRAM\AppleTV.ir");
                        foreach (string s in myPort.AvailableStandardIRCmds())
                        {
                            CrestronConsole.PrintLine("AppleTV Std: {0}", s);
                        }
                        foreach (string s in myPort.AvailableIRCmds())
                        {
                            CrestronConsole.PrintLine("AppleTV Std: {0}", s);
                        }
                    }
                }
                #endregion
                #region VersiPort
                if (this.SupportsVersiport)
                {
                    for (uint i = 1; i <= 2; i++)
                    {
                        if (this.VersiPorts[i].Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                        {
                            ErrorLog.Error("Error Registering Versiport 1: {0}", this.VersiPorts[i].DeviceRegistrationFailureReason);
                        }
                        else
                        {
                            this.VersiPorts[i].SetVersiportConfiguration(eVersiportConfiguration.DigitalOutput);
                        }
                    }
                }
                #endregion
                #region ComPorts
                if (this.SupportsComPort)
                {
                    for (uint i = 1; i <= 2; i++)
                    {
                        this.ComPorts[i].SerialDataReceived += new ComPortDataReceivedEvent(ControlSystem_SerialDataReceived);
                        if (this.ComPorts[i].Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                        {
                            ErrorLog.Error("Error Registering ComPort{0}: {1}", i, ComPorts[i].DeviceRegistrationFailureReason);
                        }
                        else
                        {
                            this.ComPorts[i].SetComPortSpec(ComPort.eComBaudRates.ComspecBaudRate19200,
                                                            ComPort.eComDataBits.ComspecDataBits8,
                                                            ComPort.eComParityType.ComspecParityNone,
                                                            ComPort.eComStopBits.ComspecStopBits1,
                                                            ComPort.eComProtocolType.ComspecProtocolRS232,
                                                            ComPort.eComHardwareHandshakeType.ComspecHardwareHandshakeNone,
                                                            ComPort.eComSoftwareHandshakeType.ComspecSoftwareHandshakeNone,
                                                            false);
                        }
                    }
                }
                #endregion1
                #region Touchpanel
                if (this.SupportsEthernet)
                {
                    myPanel            = new XpanelForSmartGraphics(0x03, this);
                    myPanel.SigChange += new SigEventHandler(myPanel_SigChange);
                    if (myPanel.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                    {
                        ErrorLog.Error("Error in Registering xPanel: {0}", myPanel.RegistrationFailureReason);
                    }
                    else
                    {
                        myPanel.LoadSmartObjects(@"\NVRAM\xpnl.sgd");
                        CrestronConsole.PrintLine("Loaded SmartObjects: {0}", myPanel.SmartObjects.Count);
                        foreach (KeyValuePair <uint, SmartObject> mySmartObject in myPanel.SmartObjects)
                        {
                            mySmartObject.Value.SigChange += new SmartObjectSigChangeEventHandler(Value_SigChange);
                        }
                        MySigGroup = CreateSigGroup(1, eSigType.String);
                        MySigGroup.Add(myPanel.StringInput[1]);
                        MySigGroup.Add(myPanel.StringInput[2]);
                    }
                }
                #endregion
                #region EISC
                if (this.SupportsEthernet)
                {
                    myEISC            = new EthernetIntersystemCommunications(0x04, "127.0.0.2", this);
                    myEISC.SigChange += new SigEventHandler(myEISC_SigChange);
                    if (myEISC.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                    {
                        ErrorLog.Error("Error in Registering EISC: {0}", myEISC.RegistrationFailureReason);
                    }
                    else
                    {
                        myEISC.SigChange -= myEISC_SigChange;
                    }
                }
                #endregion
            }
            catch (Exception e)
            {
                ErrorLog.Error("Error in the constructor: {0}", e.Message);
            }
        }