void Tx_BaseEvent(GenericBase device, BaseEventArgs args) { var id = args.EventId; if (id == EndpointTransmitterBase.VideoSourceFeedbackEventId) { Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); VideoSourceNumericFeedback.FireUpdate(); ActiveVideoInputFeedback.FireUpdate(); } // ------------------------------ incomplete ----------------------------------------- else if (id == EndpointTransmitterBase.AudioSourceFeedbackEventId) { Debug.Console(2, this, " Audio Source: {0}", Tx.AudioSourceFeedback); AudioSourceNumericFeedback.FireUpdate(); } }
public void Remote_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) { if (args.DeviceOnLine) { // if it was remote01 that triggered the event if (currentDevice == this.remote01) { // ErrorLog.Notice(string.Format(LogHeader + "{0} is online", tp01.Type)); // this.remote01.BooleanInput[11].BoolValue = args.DeviceOnLine; ErrorLog.Notice(string.Format(LogHeader + "{0} is online", remote01.Type)); } } else { // ErrorLog.Notice(string.Format(LogHeader + "{0} is offline", currentDevice.Description)); ErrorLog.Notice(string.Format(LogHeader + "{0} is offline", remote01.Type)); } }
/// <summary> /// Disposes a device, passing feedback to the console. Logs an error if it fails. /// </summary> /// <param name="device">The device to dispose.</param> /// <param name="deviceDescriptor">A description of the device for use in the console and error log.</param> public static void Dispose(this GenericBase device, string deviceDescriptor) { try { if (device == null) { CrestronConsole.PrintLine("Couldn't dispose {0}, the device was null.", deviceDescriptor); ErrorLog.Error("Couldn't dispose {0}, the device was null.", deviceDescriptor); return; } device.Dispose(); CrestronConsole.PrintLine("Disposed of the {0}", deviceDescriptor); } catch (Exception ex) { CrestronConsole.PrintLine("The device {0} potentially failed to dispose, due to an exception: {1}", deviceDescriptor, ex.Message); ErrorLog.Error("The device {0} potentially failed to dispose, due to an exception: {1}", deviceDescriptor, ex.Message); } }
void Value_SigChange(GenericBase currentDevice, SmartObjectEventArgs args) { CrestronConsole.PrintLine(@"{0} triggered", args.Sig.Name); if (args.SmartObjectArgs.ID == 2 && args.Sig.Name.ToUpper().Contains("APP")) { switch (args.Sig.BoolValue) { case true: { string[] appInfo; appInfo = args.Sig.Name.Split('-'); CrestronConsole.PrintLine(@"Launching App : {0}, with ID {1}", appInfo[0], appInfo[1]); testRoku.MakeRequest(Roku.eRokuRequest.Launch_App, appInfo[1]); break; } default: break; } } }
void EISComm_SigChange(GenericBase currentDevice, SigEventArgs args) { var sig = args.Sig; var uo = sig.UserObject; CrestronConsole.PrintLine("Event sig: {0}, Type: {1}", sig.Number, sig.GetType()); if (uo is Action <bool> ) // If the userobject for this signal with boolean { (uo as System.Action <bool>)(sig.BoolValue); // cast this signal's userobject as delegate Action<bool> // passing one parm - the value of the bool } else if (uo is Action <ushort> ) { (uo as Action <ushort>)(sig.UShortValue); } else if (uo is Action <string> ) { (uo as Action <string>)(sig.StringValue); } }//UI event handler
void Device_IpInformationChange(GenericBase currentDevice, ConnectedIpEventArgs args) { if (currentDevice is CrestronApp) { // ignore } else { if (args.Connected) { ErrorLog.Notice("UI Device {0} with ID {1} is online with IP Address {2}", currentDevice.GetType().Name, currentDevice.ID.ToString("X2"), args.DeviceIpAddress); } else { ErrorLog.Notice("UI Device {0} with ID {1} is offline with IP Address {2}", currentDevice.GetType().Name, currentDevice.ID.ToString("X2"), args.DeviceIpAddress); } } FusionUpdate(); }
} // Event Handler // Event Handler for UIs - touchpanels etc. void MySigChangeHandler(GenericBase currentDevice, SigEventArgs args) { var sig = args.Sig; var uo = sig.UserObject; }//Event Handler
// Keypad event handler void myKeypad_ButtonStateChange(GenericBase device, ButtonEventArgs args) { var btn = args.Button; var uo = btn.UserObject; CrestronConsole.PrintLine("Event sig: {0}, Type: {1}, State: {2}", btn.Number, btn.GetType(), btn.State); #region UserObject Action<> invocation // Need to fix this section so the action is not fired more than once on button press - for now it does. // for some reason if (btn.State == eButtonState.Pressed) { if (uo is System.Action<Button>) //if this userObject has been defined and is correct type (uo as System.Action<Button>)(btn); else if (uo is System.Action) (uo as System.Action)(); } #endregion #region "Hardcoded* button invocation /* // Call direction until UserObject stuff working ButtonInterfaceController myBIC = new ButtonInterfaceController(); if (sig.State == eButtonState.Pressed) { switch (sig.Number) { case 1: myBIC.ReadFile(); break; case 2: myBIC.GetHTTPFile(); break; default: myBIC.GetSFTPFile(); break; } } */ #endregion } // Event Handler
/// This method is an eventhandler. void MySigChangeHandler(GenericBase currentDevice, SigEventArgs args) { var sig = args.Sig; var uo = sig.UserObject; CrestronConsole.PrintLine("Event sig: {0}, Type: {1}", sig.Number, sig.GetType()); if (uo is Action<bool>) // If the userobject for this signal with boolean { (uo as System.Action<bool>)(sig.BoolValue); // cast this signal's userobject as delegate Action<bool> // passing one parm - the value of the bool } else if (uo is Action<ushort>) { (uo as Action<ushort>)(sig.UShortValue); } else if (uo is Action<string>) { (uo as Action<string>)(sig.StringValue); } }
/// <summary> /// Method to handle smart object events from the underscan list. /// </summary> /// <param name="currentDevice">Reference to the device raising this event.</param> /// <param name="args">Information about the event being raised.</param> void dmRmcUnderscanList_SigChange(GenericBase currentDevice, SmartObjectEventArgs args) { try { if (args.Sig.Name == "Item Clicked") dmRmc.Scaler.UnderscanMode = (eDmScanMode)(args.Sig.UShortValue - 1); } catch (Exception) { ErrorLog.Error(">>> invalid dm rmc output underscan selection"); } }
/// <summary> /// Method to handle smart object events from the aspect list. /// </summary> /// <param name="currentDevice">Reference to the device raising this event.</param> /// <param name="args">Information about the event being raised.</param> void dmRmcAspectModeList_SigChange(GenericBase currentDevice, SmartObjectEventArgs args) { try { if (args.Sig.Name == "Item Clicked") dmRmc.Scaler.DisplayMode = (EndpointScalerOutput.eDisplayMode)(args.Sig.UShortValue - 1); } catch (Exception) { ErrorLog.Error(">>> invalid dm rmc output aspect selection"); } }
/// <summary> /// Method to handle button press events from the TT-100 ConnectIt. /// </summary> /// <param name="device">Reference to the device raising this event.</param> /// <param name="args">Information about the event being raised.</param> void connectIt_ButtonStateChange(GenericBase device, ButtonEventArgs args) { // only process the press of the button, ignore the release if (args.NewButtonState == eButtonState.Released) return; // determine which button was pressed switch (args.Button.Number) { // handle both buttons the same way case (uint)eConnectItButtons.Left: case (uint)eConnectItButtons.Right: CrestronConsole.PrintLine("{0} ConnectIt button pressed while system is in \"{1}\" mode", args.Button.Number == 1 ? "Left" : "Right", SystemState.ToString()); // determine what the system state was when the button was pressed switch (SystemState) { case eSystemStates.PoweredOff: ManualStartUp(); break; case eSystemStates.InUse: // determine what input is active, then check to see if any other inputs have signal if (dmTx.VideoSourceFeedback == BaseDmTx401.eSourceSelection.HDMI) { // if another input has signal, cycle to that input if (dmTx.DisplayPortInput.SyncDetectedFeedback.BoolValue) dmTx.VideoSource = BaseDmTx401.eSourceSelection.DisplayPort; else if (dmTx.VgaInput.SyncDetectedFeedback.BoolValue) dmTx.VideoSource = BaseDmTx401.eSourceSelection.VGA; else CrestronConsole.PrintLine("no other inputs have sync, ignoring button press"); } else if (dmTx.VideoSourceFeedback == BaseDmTx401.eSourceSelection.DisplayPort) { if (dmTx.HdmiInput.SyncDetectedFeedback.BoolValue) dmTx.VideoSource = BaseDmTx401.eSourceSelection.HDMI; else if (dmTx.VgaInput.SyncDetectedFeedback.BoolValue) dmTx.VideoSource = BaseDmTx401.eSourceSelection.VGA; else CrestronConsole.PrintLine("no other inputs have sync, ignoring button press"); } else if (dmTx.VideoSourceFeedback == BaseDmTx401.eSourceSelection.VGA) { if (dmTx.HdmiInput.SyncDetectedFeedback.BoolValue) dmTx.VideoSource = BaseDmTx401.eSourceSelection.HDMI; else if (dmTx.DisplayPortInput.SyncDetectedFeedback.BoolValue) dmTx.VideoSource = BaseDmTx401.eSourceSelection.DisplayPort; else CrestronConsole.PrintLine("no other inputs have sync, ignoring button press"); } else { /* the tx should never be on any input other than vga, hdmi or displayport. if is ever gets there, * check to see if any of the valid inputs have signal and then switch to it */ CrestronConsole.PrintLine("button pressed while on an invalid dm tx input ({0})", dmTx.VideoSourceFeedback.ToString()); if (dmTx.HdmiInput.SyncDetectedFeedback.BoolValue) dmTx.VideoSource = BaseDmTx401.eSourceSelection.HDMI; else if (dmTx.DisplayPortInput.SyncDetectedFeedback.BoolValue) dmTx.VideoSource = BaseDmTx401.eSourceSelection.DisplayPort; else if (dmTx.VgaInput.SyncDetectedFeedback.BoolValue) dmTx.VideoSource = BaseDmTx401.eSourceSelection.VGA; else SetSystemState(eSystemStates.WaitingForInput); } break; case eSystemStates.WaitingForInput: connectIt.LedState1 = eLedStates.BlinksRedFiveTimes; connectIt.LedState2 = eLedStates.BlinksRedFiveTimes; break; default: break; } break; default: break; } }
/*private void volumeChanged(object sender, EventArgs e) { CrestronConsole.PrintLine("This is called when the event fires."); }*/ void MySigChangeHandler(GenericBase currentDevice, SigEventArgs args) { if (args.Event == eSigEvent.UShortChange) { if (args.Sig.Number < 20) { floorSelect(args.Sig.Number, args.Sig.UShortValue); } if (args.Sig.Number <= 40 && args.Sig.Number > 20) { sendSource(args.Sig.Number, args.Sig.UShortValue); } if (args.Sig.Number == 100) { swampIO(2, args.Sig.UShortValue); }//in, out } if (args.Event == eSigEvent.BoolChange) { if (args.Sig.Number <= 400) { if (args.Sig.BoolValue == true) { zoneSelect(args.Sig.Number); } } else if (args.Sig.Number > 400 && args.Sig.Number <= 440)// Master volume up/dowon { masterVolume(args.Sig.Number, args.Sig.BoolValue); } else if (args.Sig.Number > 440 && args.Sig.Number <= 460 && args.Sig.BoolValue == true) //master mute { mute(args.Sig.Number); } else if (args.Sig.Number > 500 && args.Sig.Number <= 1300) { //individual vol up/down singleVolUpDown(args.Sig.Number, args.Sig.BoolValue); } else if (args.Sig.Number > 1300 && args.Sig.Number <= 1700 && args.Sig.BoolValue == true) {//individual mute mute(args.Sig.Number); } else if (args.Sig.Number > 1700 && args.Sig.Number <= 2100 && args.Sig.BoolValue == true) {//individual off sendOff(args.Sig.Number); } else if (args.Sig.Number > 2100 && args.Sig.Number < 2200 && args.Sig.BoolValue == true) //select / deselect all { selectDeselectAll(args.Sig.Number); } else if (args.Sig.Number > 2200 && args.Sig.Number <= 2220) //group ungroup { groupUngroup(args.Sig.Number, args.Sig.BoolValue); } else if (args.Sig.Number > 2230 && args.Sig.Number < 2235) { //pressHold.presetNum = (ushort)(args.Sig.Number - 2230); //pressAndHold(args.Sig.BoolValue); saveCurrentStatus(args.Sig.Number - 2230); } else if (args.Sig.Number > 2234 && args.Sig.Number < 2238) { if (args.Sig.BoolValue == true) { recallPartyMode(args.Sig.Number - 2234); } } else if (args.Sig.Number > 2250 && args.Sig.Number < 2300) { onMusicMenu(args.Sig.Number, args.Sig.BoolValue);//THIS NEEDS UPDATING!!!!!!! } else if (args.Sig.Number > 2300 && args.Sig.Number < 2700) { pressAndHold(args.Sig.Number, args.Sig.BoolValue); } } }
// Keypad event handling void myKeypad_ButtonStateChange(GenericBase device, ButtonEventArgs args) { var btn = args.Button; var uo = btn.UserObject; // CrestronConsole.PrintLine("Event sig: {0}, Type: {1}, State: {2}", btn.Number, btn.GetType(), btn.State); #region UserObject Action<> invocation // I have a big issue to contend with in these methods - what do you pass as arguments to the methods // I want to keep things decoupled but how do you get access to devices created, resgitered in control system // class when you in in classes that are outside the scope e.g. Versiports, IRPorts etc. // Need to fix this section so the action is not fired more than once on button press - for now it does. // for some reason if (uo is System.Action<Button>) //if this userObject has been defined and is correct type (uo as System.Action<Button>)(btn); else if (uo is System.Action) (uo as System.Action)(); ButtonInterfaceController myBIC = new ButtonInterfaceController(); #endregion #region "Hardcoded* button invocation /* // Call direction until UserObject stuff working if (btn.State == eButtonState.Pressed) { this.VersiPorts[args.Button.Number].DigitalOut = true; switch (btn.Number) { case 1: myIRPort1.Press("UP_ARROW"); ComPorts[1].Send("Test transmition, please ignore"); break; case 2: myIRPort1.Press("DN_ARROW"); ComPorts[1].Send("\n"); break; default: CrestronConsole.PrintLine("Key Not Programmed: {0}", args.Button.Number); break; } } if (args.Button.State == eButtonState.Released) { myIRPort1.Release(); this.VersiPorts[args.Button.Number].DigitalOut = false; } */ #endregion } // Event Handler
void myEISC_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) { if (currentDevice == myEISC) { if (args.DeviceOnLine == true) { // Device is ONLINE... Go ahead and start sending data to it.. myEISC.StringInput[1].StringValue = " Hello From Remote via EISC"; CrestronConsole.PrintLine("Connected to remote via EISC"); } else { // Device just went offline CrestronConsole.PrintLine("Connection to remote EISC had been dropped!!! "); } } }
// Keypad state handler void myKeypad_ButtonStateChange(GenericBase device, ButtonEventArgs args) { var sig = args.Button; var uo = sig.UserObject; CrestronConsole.PrintLine("Event sig: {0}, Type: {1}, Name: {2}", sig.Number, sig.GetType(), sig.Name); // Read a file example CrestronConsole.PrintLine("File Read Example"); MyFileReader myFileReader = new MyFileReader(); string myFileContents; ushort i; CrestronConsole.PrintLine("Reading File example"); i = myFileReader.OpenLocalFile("\\NVRAM\\Books.xml"); myFileContents = myFileReader.myFileStringContents; CrestronConsole.PrintLine(myFileContents); // HTTP File Example CrestronConsole.PrintLine("HTTP Read Example"); OpenHTTPFile myHTTPFile; myHTTPFile = new OpenHTTPFile(); myHTTPFile.getHTTPPage(); // SFTP{ File Example CrestronConsole.PrintLine("SFTP Read Example"); CustomSFTP myCustomSFTP; myCustomSFTP = new CustomSFTP(); myCustomSFTP.getFromSFTP(@"SFTP://127.0.0.1/Books.xml"); }
/// <summary> /// This method is an eventhandler. In this sample, it handles the signal events /// from all touchpanels, and the XPanel. /// This event will not retrigger, until you exit the currently running eventhandler. /// Use threads, or dispatch to a worker, to exit this function quickly. /// </summary> /// <param name="currentDevice">This is the device that is calling this function. /// Use it to identify, for example, which room thebuttom press is associated with.</param> /// <param name="args">This is the signal event argument, it contains all the data you need /// to properly parse the event.</param> void MySigChangeHandler(GenericBase currentDevice, SigEventArgs args) { var sig = args.Sig; var uo = sig.UserObject; CrestronConsole.PrintLine("Event sig: {0}, Type: {1}", sig.Number, sig.GetType()); if (uo is Action<bool>) // If the userobject for this signal with boolean { (uo as System.Action<bool>)(sig.BoolValue); // cast this signal's userobject as delegate Action<bool> // passing one parm - the value of the bool } else if (uo is Action<ushort>) { (uo as Action<ushort>)(sig.UShortValue); } else if (uo is Action<string>) { (uo as Action<string>)(sig.StringValue); } /* switch (args.Sig.Type) { case eSigType.Bool: { if (args.Sig.BoolValue) // only process the press, not the release; { switch (args.Sig.Number) { case 5: // process boolean press 5 break; } } if (args.Sig.Type == eSigType.UShort) { switch (args.Sig.Number) { case 5: // process number 5 break; } } break; } } */ }
void swampA_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) { if (swampA.IsOnline) { for (ushort i = 1; i < 9; i++) { swampA.Zones[i].Name.StringValue = zoneNameArray[i - 1]; } for (ushort i = 1; i < 25; i++) { swampA.Sources[i].Name.StringValue = sourceNameArray[i]; } if (numberOfExpanders > 0) { ushort zonePlaceHolder = 10; for (ushort i = 1; i < numberOfExpanders; i++) { if (swampA.Expanders[i].OnlineFeedback) { for (ushort j = 1; j < swampA.Expanders[i].NumberOfZones; j++) { swampA.Expanders[i].Zones[j].Name.StringValue = zoneNameArray[zonePlaceHolder + j - 1]; } } zonePlaceHolder += (ushort)swampA.Expanders[i].NumberOfZones;//NEEDS TESTING } } } }
/// <summary> /// Method to handle online/offline events from the devices. /// </summary> /// <param name="currentDevice">Reference to the device raising the event.</param> /// <param name="args">Information about the event being raised.</param> void Device_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) { // determine which device raised this event if (currentDevice == dmTx) { // update the xpanel with new online status xPanelUi.BooleanInput[(uint)eXpanelFeedbacks.BoolDmTxOnline].BoolValue = args.DeviceOnLine; } else if (currentDevice == dmRmc) { // update the xpanel with new online status xPanelUi.BooleanInput[(uint)eXpanelFeedbacks.BoolDmRmcOnline].BoolValue = args.DeviceOnLine; if (args.DeviceOnLine) UpdateRmcConfig(); } }
void swampBaseEvent(GenericBase device, BaseEventArgs args) { uint callingZone = 0; switch (args.EventId) { case Swamp.SPDIFOut9SourceFeedbackEventId: callingZone = 9; break; case Swamp.SPDIFOut10SourceFeedbackEventId: callingZone = 10; break; default: break; } myEISC.UShortInput[40 + callingZone].UShortValue = swampA.SpdifOuts[callingZone].SPDIFOutSourceFeedback.UShortValue; UItoZone.zoneCurrentSourceNumber[callingZone] = swampA.SpdifOuts[callingZone].SPDIFOutSourceFeedback.UShortValue; UItoZone.zoneCurrentSourceText[callingZone] = sourceNameArray[swampA.SpdifOuts[callingZone].SPDIFOutSourceFeedback.UShortValue]; if (swampA.SpdifOuts[callingZone].SPDIFOutSourceFeedback.UShortValue == 0) { UItoZone.zoneCurrentOnOffStatus[callingZone] = false; } else UItoZone.zoneCurrentOnOffStatus[callingZone] = true; updateUI(callingZone, "sources"); updateUI(callingZone, "onOffStatus"); }
/// <summary> /// Method to handle smart object events from the resolution list. /// </summary> /// <param name="currentDevice">Reference to the device raising this event.</param> /// <param name="args">Information about the event being raised.</param> void dmRmcOutputResList_SigChange(GenericBase currentDevice, SmartObjectEventArgs args) { try { if (args.Sig.Name == "Item Clicked") dmRmc.Scaler.Resolution = (EndpointScalerOutput.eResolution)(args.Sig.UShortValue - 1); } catch (Exception) { ErrorLog.Error(">>> invalid dm rmc output resolution selection"); } }
void wallDimmer_ButtonStateChange(GenericBase device, ButtonEventArgs args) { CrestronConsole.PrintLine("Button #{0} was {1}", args.Button.Number, args.NewButtonState.ToString()); switch (args.Button.Number) { case 1: // do something with button 1 break; case 2: // etc... break; case 3: break; case 4: break; default: break; } }
/// <summary> /// Method to handle base events raised by the Dm Tx. /// </summary> /// <param name="device">Reference to the device raising this event.</param> /// <param name="args">Information about the event being raised.</param> void dmTx_BaseEvent(GenericBase device, BaseEventArgs args) { // determine what event has been raised switch (args.EventId) { case BaseDmTx401.VideoSourceFeedbackEventId: break; default: break; } }
void myKeypad_ButtonStateChange(GenericBase device, ButtonEventArgs args) { switch (args.Button.Number) { case 1: { if (args.Button.State == eButtonState.Pressed) if (mFC.OpenLocalFile(@"\NVRAM\Books.xml") == 0) CrestronConsole.PrintLine("Error Loading Books.xml"); break; } case 2: { if (args.Button.State == eButtonState.Pressed) if (mFC.OpenHTTPFile(@"http://textfiles.com/computers/1pt4mb.inf") == 0) CrestronConsole.PrintLine("Error Opening HTTP File"); break; } case 3: { if (args.Button.State == eButtonState.Pressed) if (mFC.OpenSFTPFile("Crestron", "", "127.0.0.1", @"/NVRAM/Books.xml") == 0) CrestronConsole.PrintLine("Error Transferring File via sFTP"); break; } default: { CrestronConsole.PrintLine("Keypad Button Triggered: {0}, {1}, {2}", device.ID, args.Button.Number, args.Button.State); break; } } }