Click or drag to resize

CsaPws10sHubEnet Class

Crestron device that provides two independent Cresnet control branches (local and master) as well as 5 separate power segments with 2 separate cresnet connectors on each segment that can be independently controlled. Valid Cresnet ID's for the master branch (branch 1) are 03 through 4F. Valid Cresnet ID's for the Local branch (branch 2) are 03 through 0C.
Inheritance Hierarchy
SystemObject
  Crestron.SimplSharpProGenericBase
    Crestron.SimplSharpProGenericDevice
      Crestron.SimplSharpPro.GeneralIOCsaPws10sHubEnetBase
        Crestron.SimplSharpPro.GeneralIOCsaPws10sHubEnet

Namespace: Crestron.SimplSharpPro.GeneralIO
Assembly: Crestron.SimplSharpPro.GeneralIO (in Crestron.SimplSharpPro.GeneralIO.dll) Version: 2.21.121
Syntax
C#
public class CsaPws10sHubEnet : CsaPws10sHubEnetBase, 
	IDeviceBranchCollection, IBridgeHelper

The CsaPws10sHubEnet type exposes the following members.

Constructors
 NameDescription
Public methodCsaPws10sHubEnet This constructor is used to create a CSA-PWS10S-HUB-ENET on a control system's ethernet.
Top
Properties
 NameDescription
Public propertyBranches Collection of cresnet CsaPws10sHubEnetCresnetBranch objects that are a part of this device. These collections will contain the Cresnet devices that are on the CSA-PWS10S-HUB-ENET. Note that the collections that contain information about the power states, etc. are in the Segments collection.
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 propertyEnablePowerReporting When set to true, this enables the reporting of the power levels on PowerUsageFeedback collections for each segment. This affects all segments. When false, reporting is disabled. It is disabled by default.
(Inherited from CsaPws10sHubEnetBase)
Public propertyFakeUpdateRequest Property to activate fake cresnet update request True = Active; False = InActive
(Inherited from CsaPws10sHubEnetBase)
Public propertyHelper Shade hub helper. This is used to assist in performing various operations on the cresnet of the hub (discover, PPN related, etc.) and return data to the program (such as the devices on the local or master cresnet branch).
Public propertyHubStatusFeedback Flag to indicate an action the hub is currently performing. See eCsaPws10sHubEnetStatus enum for further details.

The BaseEvent will trigger with HubStatusFeedbackEventId when this value changes.


(Inherited from CsaPws10sHubEnetBase)
Public propertyID Property to get the ID of the device.
(Inherited from GenericDevice)
Public propertyInTestModeFeedback Flag to indicate if this hub is currently running a test.

The BaseEvent event will trigger with InTestModeFeedbackEventId.


(Inherited from CsaPws10sHubEnetBase)
Public propertyIsOnline Property to get the current online state of the device.
(Inherited from GenericDevice)
Public propertyMasterSegmentDisableFeedback Property to indicate that the master segment is disabled.

The BaseEvent event will trigger with SegmentDisabledFeedbackEventId.

Remarks
true means the master segment is disabled, false means it is enabled. This value only will only change as a result of TestAllSegments being called.

(Inherited from CsaPws10sHubEnetBase)
Public propertyMasterSegmentFrameErrorFeedback Property to indicate that the master segment has experienced a framing error.

The BaseEvent event will trigger with SegmentFrameErrorFeedbackEventId.

Remarks
true means a framing error has occurred, false means none has occurred. The segment stays enabled when the error occurs.

(Inherited from CsaPws10sHubEnetBase)
Public propertyMasterSegmentStatusFeedback Property to indicate the results of test for the segment.

The BaseEvent event will trigger with SegmentStatusFeedbackEventId.


(Inherited from CsaPws10sHubEnetBase)
Public propertyName Get the name of this device.
(Inherited from GenericBase)
Public propertyOverTemperatureFeedback Flag to indicate that the device is running over safe temperature ratings.

The BaseEvent event will trigger with OverTemperatureFeedbackEventId.


(Inherited from CsaPws10sHubEnetBase)
Public propertyParent The parent that a given object was added to.
(Inherited from GenericBase)
Public propertyPowerMinChange The value in 10s of milliWatts (mW) for reporting changes on the PowerUsageFeedback collections for each branch. This value affects reporting on all segments. Default value is 50, which is 500mW.
(Inherited from CsaPws10sHubEnetBase)
Public propertyPowerSupplyErrorStatusFeedback Flag to indicate an error on the hub power supply. See eCsaPws10sHubEnetPowerSupplyErrorStatus enum for further details.

The BaseEvent will trigger with PowerSupplyErrorStatusFeedbackEventId when this value changes.


(Inherited from CsaPws10sHubEnetBase)
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)
Public propertySegments A collection of CsaPws10sHubEnetSegment objects. Each object contains information about an individual segment, such as the ability to power cycle and get status of the channels on the branch (failure mode and power usage), whether the branch is disabled, whether a framing error exists, the status of the branch. Note that the collection that contains information about the Cresnet devices on the hub is the Branches collection.
(Inherited from CsaPws10sHubEnetBase)
Public propertySegmentTestDoneFeedback Flag to indicate that all segment testing has completed.

The BaseEvent event will trigger with SegmentTestDoneFeedbackEventId.


(Inherited from CsaPws10sHubEnetBase)
Protected propertySIMPLDeviceImplementation Internal protected member used for actual device control.
(Inherited from GenericDevice)
Public propertyTestResultsFeedback Property to indicate the results of the segment test as textual information suitable for reporting to a touch panel, logging to a file, etc.

The BaseEvent event will trigger with TestResultsFeedbackEventId.


(Inherited from CsaPws10sHubEnetBase)
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
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 methodMemberwiseCloneCreates a shallow copy of the current Object.
(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)
Public methodTestAllSegments Method to start electrical testing on all segments. The BaseEvent will trigger with the event ID InTestModeFeedbackEventId. When the test is complete, the same handler will trigger with the event ID SegmentTestDoneFeedbackEventId.
(Inherited from CsaPws10sHubEnetBase)
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
Example
The following example instantiates a Hub with the following devices:
  • C2nCbdPKpScene at ID 09 on the Main Branch
  • C2nSdc at ID 07 on the Local Branch
  • C2nCbdPKpScene at ID 08 on the Local Branch
The devices can be controlled through an XPanel and provide feedback via Console.PrintLine(). Status of the Hub as well as control is also provided via the XPanel.
C#
// For the sample code to work be sure to include the following references:
// Crestron.SimplSharpPro.GeneralIO for the CsaPws10sHubEnet
// Crestron.SimplSharpPro.Keypads for the C2nCbdPKpScene
// Crestron.SimplSharpPro.Shades for the C2nSdc
// Crestron.SimplSharpPro.UI for the XpanelForSmartGraphics

using System;
using Crestron.SimplSharp;                                          
using Crestron.SimplSharpPro;                                       
using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharpPro.GeneralIO;
using Crestron.SimplSharpPro.Keypads;
using Crestron.SimplSharpPro.Shades;
using Crestron.SimplSharpPro.UI;

namespace CsaPws10sHubEnetTest
{
    public class ControlSystem : CrestronControlSystem
    {
        // A convenience object used to easily identify which device we are for event handler.  The enum value is also the join number
        // for the online/offline message text.
        public enum MyDeviceType
        {
            Sdc = 20,
            KeypadOnMaster = 21,
            KeypadOnLocal = 22,
            Hub = 23
        };

        // Ethernet version of the SdcShade Hub
        public CsaPws10sHubEnet Hub;

        // Keypad plugged into the Local segment of the Hub.
        public C2nCbdPKpScene KeypadOnLocal;

        // SdcShade plugged into the Local segment of the Hub.
        public C2nSdc SdcShade;

        // Keypad plugged into the Master segment of the Hub.
        public C2nCbdPKpScene KeypadOnMaster;

        // Test XPanel
        public XpanelForSmartGraphics MyXPanel;

        private bool EnablePowerReporting = true;

        public ControlSystem()
        {
            InitializeByUser();
        }

        private void InitializeByUser()
        {
            MyXPanel = new XpanelForSmartGraphics(0x05, this);
            if (MyXPanel.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
            {
                string reason = string.Format("Could not register XPanel, Reason: {0}", MyXPanel.RegistrationFailureReason);
                CrestronConsole.PrintLine(reason);
                throw new Exception(reason);
            }

            // Initialize Hub at IP ID 03 on Ethernet.
            Hub = new CsaPws10sHubEnet(0x03, this);
            Hub.UserSpecifiedObject = MyDeviceType.Hub;

            // If we wanted to, we could cast the hub to an IDeviceBranch collection.  For any arbitrary device, if this case is
            // successful, it means we have a collection of branches that contain devices.  Currently this would be useful for the CSA-PWS10S-HUB-ENET
            // and the DIN-CEN-CN-POE.
            // IDeviceBranchCollection BranchCollection = (IDeviceBranchCollection) Hub;

            // Create Keypad on Leg 1 (Master Branch) at Cresnet ID 09.
            KeypadOnMaster = new C2nCbdPKpScene(0x09, Hub.Branches[1]);
            KeypadOnMaster.UserSpecifiedObject = MyDeviceType.KeypadOnMaster;

            // Create SDC on Leg 2 (Local Branch) at Cresnet ID 07.
            SdcShade = new C2nSdc(0x07, Hub.Branches[2]);
            SdcShade.UserSpecifiedObject = MyDeviceType.Sdc;

            // Create KeypadOnLocal on Leg 2 (Local Branch) at Cresnet ID 08.
            KeypadOnLocal = new C2nCbdPKpScene(0x08, Hub.Branches[2]);
            KeypadOnLocal.UserSpecifiedObject = MyDeviceType.KeypadOnLocal;

            // Register the bridge (this will register all the devices on the 2 branches).
            if (Hub.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
            {
                string reason = string.Format("Could not register Hub, Reason: {0}", Hub.RegistrationFailureReason);
                CrestronConsole.PrintLine(reason);
                throw new Exception(reason);                
            }

            // Subscribe to the base event handler.
            Hub.BaseEvent += new BaseEventHandler(Hub_BaseEvent);

            // Subscribe to the 5 event handlers for info about each hub segment (gives status about power, etc.)
             for(uint i = 1 ; i <= Hub.Segments.Count ; i++)
                Hub.Segments[i].SegmentStateChange +=new CsaPws10sHubEnetSegmentStateChangeEventHandler(ControlSystem_SegmentStateChange);

            // Subscribe to the Online status event handler for the Hub.
            Hub.OnlineStatusChange += new OnlineStatusChangeEventHandler(OnlineStatusChange);

            // Setup the power report to the Hub and sync XPanel to the state.
            Hub.EnablePowerReporting.BoolValue = EnablePowerReporting;
            MyXPanel.BooleanInput[14].BoolValue = EnablePowerReporting;

            // Subscribe to the event handler for the SDC.
            SdcShade.BaseEvent += new BaseEventHandler(Shade_BaseEvent);

            // Subscribe to the Online status event handler for the SDC.
            SdcShade.OnlineStatusChange += new OnlineStatusChangeEventHandler(OnlineStatusChange);

            // Subscribe to the keypad's button state handler.
            KeypadOnMaster.ButtonStateChange += new ButtonEventHandler(Keypad_ButtonStateChange);

            // Subscribe to the Online status event handler for the keypad.
            KeypadOnMaster.OnlineStatusChange += new OnlineStatusChangeEventHandler(OnlineStatusChange);

            // Subscribe to the keypad's button state handler.
            KeypadOnLocal.ButtonStateChange += new ButtonEventHandler(Keypad_ButtonStateChange);

            // Subscribe to the Online status event handler for the keypad.
            KeypadOnLocal.OnlineStatusChange += new OnlineStatusChangeEventHandler(OnlineStatusChange);

            // Subscribe to the even handler for the XPanel.
            MyXPanel.SigChange += new SigEventHandler(MyXPanel_SigChange);
        }

        void OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args)
        {
            uint Join = (uint) ((MyDeviceType) (currentDevice.UserSpecifiedObject));
             if (Join > 0)
            {
                if (args.DeviceOnLine == true)
                    MyXPanel.StringInput[Join].StringValue = "Online";
                else
                    MyXPanel.StringInput[Join].StringValue = "Offline";
            }
            else
            {
                ErrorLog.Error("Could not determine device from Join for {0}", currentDevice.Name);
            }
        }

        void Shade_BaseEvent(GenericBase device, BaseEventArgs args)
        {
            switch (args.EventId)
            {
                case ShadeDrapeControllerEventIds.LastDirCloseFeedbackEventId:
                    CrestronConsole.PrintLine("Shade SDC: Value for LastDirCloseFeedback on {0} is {1}", args.Index, SdcShade.Controllers[(uint)args.Index].LastDirCloseFeedback.BoolValue);
                    break;
                case ShadeDrapeControllerEventIds.LastDirOpenFeedbackEventId:
                    CrestronConsole.PrintLine("Shade SDC: Value for LastDirOpenFeedback on {0} is {1}", args.Index, SdcShade.Controllers[(uint)args.Index].LastDirOpenFeedback.BoolValue);
                    break;
                case ShadeDrapeControllerEventIds.MovingFeedbackEventId:
                    CrestronConsole.PrintLine("Shade SDC: Value for MovingFeedback is on {0} is {1}", args.Index, SdcShade.Controllers[(uint)args.Index].MovingFeedback.BoolValue);
                    break;
            }
        }

        void MyXPanel_SigChange(BasicTriList currentDevice, SigEventArgs args)
        {
            uint JoinNumber = args.Sig.Number;
            switch (args.Sig.Type)
            {
                case eSigType.Bool:
                     if (JoinNumber >= 1 && JoinNumber <= 10)
                    {
                        if (args.Sig.BoolValue == true)
                        {
                            uint SegmentNumber = (JoinNumber - 1)/2 + 1;
                            uint ChannelNumber = (JoinNumber - 1)%2 + 1;
                            Hub.Segments[SegmentNumber].PowerCycleChannel(ChannelNumber);
                        }
                    }
                    else
                    {
                        switch (args.Sig.Number)
                        {
                            case 11:
                                // PowerMinChange set to 150mW
                                if (args.Sig.BoolValue == true)
                                {
                                    Hub.PowerMinChange.UShortValue = 15;
                                    MyXPanel.BooleanInput[11].BoolValue = true;
                                    MyXPanel.BooleanInput[12].BoolValue = false;
                                    MyXPanel.BooleanInput[13].BoolValue = false;
                                }
                                break;
                            case 12:
                                // PowerMinChange set to 500mW
                                if (args.Sig.BoolValue == true)
                                {
                                    Hub.PowerMinChange.UShortValue = 50;
                                    MyXPanel.BooleanInput[11].BoolValue = false;
                                    MyXPanel.BooleanInput[12].BoolValue = true;
                                    MyXPanel.BooleanInput[13].BoolValue = false;
                                }
                                break;
                            case 13:
                                // PowerMinChange set to 1000mW
                                if (args.Sig.BoolValue == true)
                                {
                                    Hub.PowerMinChange.UShortValue = 1000;
                                    MyXPanel.BooleanInput[11].BoolValue = false;
                                    MyXPanel.BooleanInput[12].BoolValue = false;
                                    MyXPanel.BooleanInput[13].BoolValue = true;
                                }
                                break;
                            case 14:
                                // Toggle power reporting state
                                if (args.Sig.BoolValue == true)
                                {

                                    EnablePowerReporting = !EnablePowerReporting;
                                    Hub.EnablePowerReporting.BoolValue = EnablePowerReporting;
                                    MyXPanel.BooleanInput[14].BoolValue = EnablePowerReporting;
                                }
                                break;
                            case 15:
                                if (args.Sig.BoolValue == true)
                                {
                                    Hub.TestAllSegments();
                                }
                                break;
                            case 26:
                                if (args.Sig.BoolValue == true)
                                    SdcShade.Controllers[1].Open();
                                else
                                    SdcShade.Controllers[1].Stop();
                                break;
                            case 27:
                                if (args.Sig.BoolValue == true)
                                    SdcShade.Controllers[1].Close();
                                else
                                    SdcShade.Controllers[1].Stop();
                                break;


                            case 28:
                                KeypadOnLocal.BargraphValue.UShortValue = 0;
                                break;
                            case 29:
                                KeypadOnLocal.BargraphValue.UShortValue = 65535;
                                break;

                            case 30:
                                KeypadOnMaster.BargraphValue.UShortValue = 0;
                                break;
                            case 31:
                                KeypadOnMaster.BargraphValue.UShortValue = 65535;
                                break;

                        }


                    }

                    break;
                default:
                    break;

            }
        }

        void Keypad_ButtonStateChange(GenericBase device, ButtonEventArgs args)
        {
            string WhichKeypad;
            switch ((MyDeviceType) device.UserSpecifiedObject)
            {
                case MyDeviceType.KeypadOnLocal:
                    WhichKeypad = "Local";
                    break;
                case MyDeviceType.KeypadOnMaster:
                    WhichKeypad = "Master";
                    break;
                default:
                    WhichKeypad = "UNKNOWN";
                    break;
            }

            CrestronConsole.PrintLine("Keypad {0}, button {1} {2}", WhichKeypad, args.Button.Number, args.Button.State.ToString());
        }


        void ControlSystem_SegmentStateChange(object device, CsaPws10sHubEnetSegmentStateEventArgs args)
        {
            // This will be 1-5, corresponding with Segment A-E.
            uint SegmentNumber = args.Segment.Number;

            switch (args.EventId)
            {
                case CsaPws10sHubEventIds.ChannelFailFeedbackEventId:
                    MyXPanel.UShortInput[(SegmentNumber - 1) * 2 + args.Index].UShortValue = (ushort)((Hub.Segments[SegmentNumber].ChannelFailFeedback[args.Index].BoolValue) ? 1 : 0);
                    break;
                case CsaPws10sHubEventIds.SegmentDisabledFeedbackEventId:
                    MyXPanel.UShortInput[SegmentNumber + 10].UShortValue = (ushort)(Hub.Segments[SegmentNumber].DisabledFeedback.BoolValue ? 1 : 0);
                    break;
                case CsaPws10sHubEventIds.SegmentFrameErrorFeedbackEventId:
                    MyXPanel.UShortInput[SegmentNumber + 16].UShortValue = (ushort)(Hub.Segments[SegmentNumber].DisabledFeedback.BoolValue ? 1 : 0);
                    break;
                case CsaPws10sHubEventIds.SegmentStatusFeedbackEventId:
                    MyXPanel.UShortInput[SegmentNumber + 41].UShortValue = (ushort)Hub.Segments[SegmentNumber].StatusFeedback;
                    break;
                case CsaPws10sHubEventIds.ChannelPowerUsageFeedbackEventId:
                    MyXPanel.UShortInput[(SegmentNumber - 1) * 2 + args.Index + 31].UShortValue = Hub.Segments[SegmentNumber].PowerUsageFeedback[args.Index].UShortValue;
                    break;
            }
        }

        void Hub_BaseEvent(GenericBase device, BaseEventArgs args)
        {
            switch (args.EventId)
            {
                case CsaPws10sHubEventIds.InTestModeFeedbackEventId:
                    MyXPanel.UShortInput[23].UShortValue = (ushort) (Hub.InTestModeFeedback.BoolValue ? 1 : 0);
                    break;
                case CsaPws10sHubEventIds.SegmentTestDoneFeedbackEventId:
                    MyXPanel.UShortInput[24].UShortValue = (ushort)(Hub.SegmentTestDoneFeedback.BoolValue ? 1 : 0);
                    break;
                case CsaPws10sHubEventIds.OverTemperatureFeedbackEventId:
                    MyXPanel.UShortInput[25].UShortValue = (ushort)(Hub.OverTemperatureFeedback.BoolValue ? 1 : 0);
                    break;
                case CsaPws10sHubEventIds.HubStatusFeedbackEventId:
                    MyXPanel.UShortInput[48].UShortValue = (ushort)Hub.HubStatusFeedback;
                    break;
                case CsaPws10sHubEventIds.PowerSupplyErrorStatusFeedbackEventId:
                    MyXPanel.UShortInput[49].UShortValue= (ushort)Hub.PowerSupplyErrorStatusFeedback;
                    break;
                case CsaPws10sHubEventIds.TestResultsFeedbackEventId:
                    MyXPanel.StringInput[19].StringValue = Hub.TestResultsFeedback.StringValue;
                    break;

                case CsaPws10sHubEventIds.SegmentDisabledFeedbackEventId:
                    // This is for the master segment when received at the base event.
                    MyXPanel.UShortInput[16].UShortValue = (ushort) (Hub.MasterSegmentDisableFeedback.BoolValue ? 1 : 0);
                    break;

                case CsaPws10sHubEventIds.SegmentFrameErrorFeedbackEventId:
                    // This is for the master segment when received at the base event.
                    MyXPanel.UShortInput[22].UShortValue = (ushort)(Hub.MasterSegmentFrameErrorFeedback.BoolValue ? 1 : 0);
                    break;

                case CsaPws10sHubEventIds.SegmentStatusFeedbackEventId:
                    // This is for the master segment when received at the base event.
                    MyXPanel.UShortInput[47].UShortValue = (ushort) Hub.MasterSegmentStatusFeedback;
                    break;
            }
        }
    }
}

Version Information

.NET

Supported in: 6.0

.NET Compact Framework

Supported in: 3.5
See Also