Click or drag to resize

CenRfgwEx Class

External ethernet CEN-RFGW-EX gateway.
Inheritance Hierarchy
SystemObject
  Crestron.SimplSharpProGenericBase
    Crestron.SimplSharpProGenericDevice
      Crestron.SimplSharpProGatewayBase
        Crestron.SimplSharpProRFExGateway
          Crestron.SimplSharpPro.GatewaysCenRfgwEx

Namespace: Crestron.SimplSharpPro.Gateways
Assembly: Crestron.SimplSharpPro.Gateways (in Crestron.SimplSharpPro.Gateways.dll) Version: 2.21.121
Syntax
C#
public sealed class CenRfgwEx : RFExGateway

The CenRfgwEx type exposes the following members.

Constructors
 NameDescription
Public methodCenRfgwEx Constructor used to generate a new Ethernet RF EX gateway attached to a controller.
Top
Properties
 NameDescription
Public propertyAttachedDevices Property to access the current list of attached devices from this program on the gateway.
(Inherited from GatewayBase)
Public propertyConnectedIpList A property containing the list of the ConnectedIpInformation objects which contain information about the devices that are connected to this IP ID. This property is only valid for an ethernet device. If this is not an ethernet device, then this property will return null. If this is an ethernet device, the list will be non-null. It will be empty if no devices are connected. The order of items in this list is not guaranteed.
(Inherited from GenericDevice)
Public propertyCode exampleDescription Get/Set the description of this device.
(Inherited from GenericBase)
Public propertyDisposed Property to indicate if the device has been disposed.
(Inherited from GenericDevice)
Public propertyExtenderBatteryLevel Reports the battery level of the RF remote.
(Inherited from RFExGateway)
Public propertyExtenderBatteryState Reports the state of the RF device's battery.
(Inherited from RFExGateway)
Public propertyExtenderCresnetMessagesOnFailure Extender to report the failed messages sent to an RF device.
(Inherited from RFExGateway)
Public propertyExtenderCresnetMessagesOnSuccess Extender to report the successful messages set to an RF device.
(Inherited from RFExGateway)
Public propertyExtenderLinkState Reports the connection status of RF devices.
(Inherited from RFExGateway)
Public propertyExtenderSetupInformation Gateway setup information.
(Inherited from RFExGateway)
Public propertyID Property to get the ID of the device.
(Inherited from GenericDevice)
Public propertyIsInternal Flag to indicate if this gateway is internal to the control system.
(Inherited from GatewayBase)
Public propertyIsOnline Property to get the current online state of the device.
(Inherited from GenericDevice)
Protected propertyIsSharable Property used to determine if this gateway is sharable.
(Inherited from GatewayBase)
Public propertyName Get the name of this device.
(Inherited from GenericBase)
Public propertyParent The parent that a given object was added to.
(Inherited from GenericBase)
Public propertyRegisterable Property to indicate that this device can be registered.
(Inherited from GenericDevice)
Public propertyRegistered Property to get the current registration state of the device.
(Inherited from GenericDevice)
Public propertyRegistrationFailureReason Property to get the Registration Failure Reason, this will match the return value from the call to register.
(Inherited from GenericDevice)
Protected propertySIMPLDeviceImplementation Internal protected member used for actual device control.
(Inherited from GenericDevice)
Public propertyType Property to determine to type of device this is.
(Inherited from GenericDevice)
Public propertyUnRegistrationFailureReason Property to get the Unregistration Failure Reason, this will match the return value from the call to unregister.
(Inherited from GenericDevice)
Public propertyUserSpecifiedObject Can be assigned anything that user wants.
(Inherited from GenericBase)
Protected propertyXioEndpointStubSIMPLDevice The SIMPL "stub" Device that the XiO Director creates for an endpoint to send the 1C/0E to the correct place in hierarchy.
(Inherited from GenericDevice)
Top
Methods
 NameDescription
Protected methodAdd Method to add a device to the list of attached devices.
(Inherited from GatewayBase)
Public methodDispose Clean up of resources.
(Inherited from GenericBase)
Protected methodDispose(Boolean) Method to perform the actual disposing of the device.
(Inherited from GenericDevice)
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Protected methodFinalize Destructor of the device.
(Inherited from GenericDevice)
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Protected methodOnBaseEvent(Int32) Protected member used to fire the BaseEvent with the default extended information.
(Inherited from GenericBase)
Protected methodOnBaseEvent(Int32, UInt16) Protected member used to fine the BaseEvent with extended event information.
(Inherited from GenericBase)
Public methodRegister Register this device with the system.
(Inherited from GenericDevice)
Protected methodRemove Method to remove a device from the attached device list.
(Inherited from GatewayBase)
Public methodToString Return the name of the device.
(Inherited from GenericDevice)
Public methodUnRegister Unregister this device with the system. This function can not be called from the device's own SigChange event handler.

On successful unregistration, if this device supports the OnlineStatusChange event, it will trigger indicating the device when offline.


(Inherited from GenericDevice)
Top
Events
 NameDescription
Public eventBaseEvent Generic base event, triggered when the there are no other handlers available for a specific EventID.
(Inherited from GenericBase)
Public eventIpInformationChange Event that tells what IP Address is connected/disconnected from an IP ID for a non-UDP device. This is only valid for an Ethernet device. An exception will be thrown if it is not.
(Inherited from GenericDevice)
Public eventOnlineStatusChange Event triggered when the Online status of the device changes.
(Inherited from GenericDevice)
Top
Fields
 NameDescription
Protected field_AttachedDevices Internal storage of the devices attached to the gateway.
(Inherited from GatewayBase)
Top
Example
C#
private static CenRfgwEx _rfGateway;

/// Helper function to initialize the rfGateway device and whatever other devices you are connecting to it.
public static bool InitializeDevice(CrestronControlSystem controller)
{
    bool returnValue = false;
    try
    {
        // If the controller is not valid (null) return right away.
        if (controller == null)
            return returnValue;

        if (!controller.SupportsEthernet)
            return returnValue;

        // Create a new object for the rfGateway connected to the Control System. ->(this)
        // Device is connected the control system by an IP_ID. 
        // In this example IP_ID 4 is used.
        // The second parameter, "this" is referring to the ControlSystem class that extends the CrestronControlSystem.
        // If you are not within the scope of such a class, make sure you have access to it. 
        _rfGateway = new CenRfgwEx(0x04, controller);

        // IMPORTANT: You must add all devices connected to the rfGateway before you register the device.

        // Reserve signals for setup info and connected device information.
        _rfGateway.ExtenderSetupInformation.Use();

        // Assign the dimmer, and rfGateway a description.
        // These descriptions will be used within the IP table constructed by the program on the control system.
        _rfGateway.Description = "GWEXER Main";

        // Initialize our rfGateway's event handlers.
        EventHandlerSetup();

        // We must register the device with the rfGateway, if it fails print to the error log
        // the reason for the failure. 
        // IMPORTANT: If you wish to add another device paired to the rfGateway, you must
        // unregister the rfGateway from the controller, create the object for your device
        // and register once again.
        if (_rfGateway.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
        {
            ErrorLog.Error("RF-Gateway cannot be registered: {0}", rfGateway.RegistrationFailureReason);
        }
        else
        {
            // If everything goes to plan, set the return value to true.
            // indication that initialization when smoothly.
            returnValue = true;
        }
    }
    catch (Exception e)
    {
        // If anything has an issue, exception will trigger and be logged within your device's error log.
        ErrorLog.Error("Error Initializing rfGateway or Registering RF Devices: {0}", e.Message);

        // Mark our return value for failure.
        returnValue = false;
    }

    // Finally, return an indication of the success of the function execution.
    return returnValue;
}

/// Initializes all event handlers for the rfGateway.
private static void EventHandlerSetup()
{
    if(_rfGateway == null){
        ErrorLog.Error("Cannot assign to a null object");
        throw new NullReferenceException();
        return;
    }

    // Listen for a change in the rfGateway's online status.
    _rfGateway.OnlineStatusChange += new OnlineStatusChangeEventHandler(OnlineStatusChange);

    // Listener for successful messages sent to the rfGateway.
    _rfGateway.ExtenderCresnetMessagesOnSuccess.DeviceExtenderSigChange += new DeviceExtenderJoinChangeEventHandler(
                                                                            rfGateway_ExtenderCresnetMessagesOnSuccess_DeviceExtenderSigChange
                                                                       );

    // Listener for failed messages sent to the rfGateway.                                                                                              
    _rfGateway.ExtenderCresnetMessagesOnFailure.DeviceExtenderSigChange += new DeviceExtenderJoinChangeEventHandler(
                                                                        rfGateway_ExtenderCresnetMessagesOnFailure_DeviceExtenderSigChange
                                                                    );
}

/// Event handler for all online status changes.
/// When the device goes online or offline this event handler will listen for it.
static void OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args)
{
    if (args.DeviceOnLine)
        ErrorLog.Notice("{0} is online", currentDevice.Description);
    else
        ErrorLog.Notice("{0} is offline", currentDevice.Description);
}

/// Event handler for IP information being changed on the device.
/// Triggered when the device is connected to the control system.
/// and whenever else the IP address of the rfGateway changes.
static void rfGateway_IpInformationChange(GenericBase currentDevice, ConnectedIpEventArgs args)
{
    ErrorLog.Warn("IP addr: {0} . Connected: {1}", args.DeviceIpAddress, args.Connected);
}

/// Event handler for Successful messages sent to the rfGateway.
static void rfGateway_ExtenderCresnetMessagesOnSuccess_DeviceExtenderSigChange(DeviceExtender currentDeviceExtender, SigEventArgs args)
{
    ErrorLog.Notice("rfGateway: {0} sent message successfully.", rfGateway.Description);
}

/// Event handler for failed messages sent to the rfGateway.
static void rfGateway_ExtenderCresnetMessagesOnFailure_DeviceExtenderSigChange(DeviceExtender currentDeviceExtender, SigEventArgs args)
{
    ErrorLog.Error("rfGateway: {0} message failed.", args.Sig.StringValue);
}

/// Returns a list of RFDeviceInformation related to each connected RF device to the gateway.
/// Important not to add devices to the List as it will not connect the device to the gateway.
public static IList[RFDeviceInformation] GetPairedRfDevices()
{
    return rfGateway.ExtenderSetupInformation.AcquiredDevices.AsReadOnly();
}

///  Puts the gateway into acquire mode.
public static void DeviceAcquireOn()
{
    // set Acquire mode on for the gateway.
    if (!_rfGateway.ExtenderSetupInformation.AcquireFeedback.BoolValue)
        _rfGateway.ExtenderSetupInformation.AcquireOn();

}

/// Turns acquire mode off on the gateway and registers itself with the controller again again.
public static void DeviceAcquireOff()
{
    int deviceCount = rfGateway.ExtenderSetupInformation.AcquiredDevices.Count;

    // Check to make sure that we are in acquire mode before attempting to turn it off.
    if (_rfGateway.ExtenderSetupInformation.AcquireFeedback.BoolValue)
        // Set acquire mode to off for the gateway.
        _rfGateway.ExtenderSetupInformation.AcquireOff();

    // IMPORTANT: You must add all devices connected to the rfGateway before you register the device.
    // Unless it's an internal gateway, in which case every device has to be registered separately. 
    // Examples of control systems with internal gateways are: MC3, DIN-AP3MEX.

    if (_rfGateway.ExtenderSetupInformation.AcquiredDevices.Count > deviceCount)
        // If execution enters this scope, we know that a new device was added when the gateway was in acquire mode.
        // you must now unregister, add said device, and register the gateway with the control system.
}

Version Information

.NET

Supported in: 6.0

.NET Compact Framework

Supported in: 3.5
See Also