Click or drag to resize

CsaPws10sHubEnetSlave Class

Crestron device that provides 5 separate power segment with 2 separate Cresnet connectors on each segment that can be independently controlled. All devices plugged into this shade hub exist in the same Cresnet address space of the device it is attached to (for example, if this is on the main cresnet of an RMC3, you can access ID 03 through FE, excluding the Cresnet ID assigned to the hub itself.
Inheritance Hierarchy
SystemObject
  Crestron.SimplSharpProGenericBase
    Crestron.SimplSharpProGenericDevice
      Crestron.SimplSharpPro.GeneralIOCsaPws10sHubEnetBase
        Crestron.SimplSharpPro.GeneralIOCsaPws10sHubEnetSlave

Namespace: Crestron.SimplSharpPro.GeneralIO
Assembly: Crestron.SimplSharpPro.GeneralIO (in Crestron.SimplSharpPro.GeneralIO.dll) Version: 2.21.121
Syntax
C#
public class CsaPws10sHubEnetSlave : CsaPws10sHubEnetBase

The CsaPws10sHubEnetSlave type exposes the following members.

Constructors
 NameDescription
Public methodCsaPws10sHubEnetSlave(UInt32, CrestronControlSystem) Constructor for creating a CSA-PWS10S-HUB-ENET Slave device that resides on Cresnet of a control system.
Public methodCsaPws10sHubEnetSlave(UInt32, IDeviceBranch) Constructor for creating a CSA-PWS10S-HUB-ENET Slave device that resides on the branch of an ethernet CSA-PWS10S-HUB-ENET device or DIN-CEN-CN-2.
Top
Properties
 NameDescription
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 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 at Cresnet ID 03 with a C2nSdc at ID 07: 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.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.Shades;
using Crestron.SimplSharpPro.UI;

namespace CsaPws10sHubEnetSlaveTest
{
    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,
            Hub = 23
        };

        // Cresnet version of the Shade Hub
        public CsaPws10sHubEnetSlave Hub;

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

        // 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 ID 03 on Cresnet.
            Hub = new CsaPws10sHubEnetSlave(0x03, this);
            Hub.UserSpecifiedObject = MyDeviceType.Hub;

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

            // Register the hub.
            if (Hub.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
            {
                string reason = string.Format("Could not register Hub, Reason: {0}", Hub.RegistrationFailureReason);
                CrestronConsole.PrintLine(reason);
                throw new Exception(reason);
            }

            if(SdcShade.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
            {
                string reason = string.Format("Could not register SDC, Reason: {0}", SdcShade.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 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;
                        }


                    }

                    break;
                default:
                    break;

            }
        }

        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