/// <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()
        {
            // Set the number of system and user threads which you want to use in your program .
            // User threads are created using the CrestronThread class
            // System threads are used for CTimers/CrestronInvoke/Async Socket operations
            // 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
            Thread.MaxNumberOfUserThreads = 20;

#if UseStaticGUID
            // Create the room object (parent of the assets and attributes). this contains all of the events you will need
            myRoom = new FusionRoom(0xf0, this, "SSP Fusion Room (Static)", "BA65B6F1-DC9B-47f5-8577-F32782045380");                    // this uses a status guid i created with the "Create GUID" tool (Tools Menu >> Create GUID). Select "Registry Format"

            // Add some assets, there are several types you can add
            myRoom.AddAsset(eAssetType.OccupancySensor, 1, "Occupancy Sensor", "Occupancy Sensor", "540E4FA9-97BE-4e21-A87E-C37E5B150FD0");
            myRoom.AddAsset(eAssetType.StaticAsset, 2, "Xpanel", "UI", "8081EA14-4869-4b86-877B-0075366BA8C6");
            myRoom.AddAsset(eAssetType.LightingLoad, 3, "Lights", "Lighting Load", "A74A1501-78E6-4a19-B0A8-F004C999F896");
#endif
#if !UseStaticGUID
            // Create the room object (parent of the assets and attributes). this contains all of the events you will need
            myRoom = new FusionRoom(0xf1, this, "SSP Fusion Room (Dynamic)", GuidManager.GetGuid("FusionRoom"));                // this is the same as above but will create a unique guid at first start up, then read from file after that

            // Add some assets, there are several types you can add
            myRoom.AddAsset(eAssetType.OccupancySensor, 1, "Occupancy Sensor", "Occupancy Sensor", GuidManager.GetGuid("SensorAsset"));
            myRoom.AddAsset(eAssetType.StaticAsset, 2, "Xpanel", "UI", GuidManager.GetGuid("XpanelAsset"));
            myRoom.AddAsset(eAssetType.LightingLoad, 3, "Lights", "Lighting Load", GuidManager.GetGuid("Lights"));
#endif

            // assign a more friendly reference to these assets and cast to the propper type
            mySensorAsset      = (FusionOccupancySensor)myRoom.UserConfigurableAssetDetails[1].Asset;
            myTouchScreenAsset = (FusionStaticAsset)myRoom.UserConfigurableAssetDetails[2].Asset;
            myLightingLoad     = (FusionLightingLoad)myRoom.UserConfigurableAssetDetails[3].Asset;

            // adjust parameters for the assets, some have required parameters
            myTouchScreenAsset.ParamMake.Value  = "Crestron";
            myTouchScreenAsset.ParamModel.Value = "TSW-1052-B-S";

            myLightingLoad.ParamDimmable  = false;
            myLightingLoad.ParamMeterType = eMeterType.Simulated;

            // Add some custom sigs (attributes)
            // the attribute IDs start at 50, just like in simpl, but the SDK will add 49 to the number you provide here. The following three lines create one attribute of each type with ID "50"
            myRoom.AddSig(eSigType.Bool, 1, "_Digital Attribute", eSigIoMask.InputOutputSig);                   // bool = digital, this is set for InputOutputSig (i.e. read from fusion / write to fusion)
            myRoom.AddSig(eSigType.String, 1, "_Serial Attribute", eSigIoMask.InputSigOnly);                    // string = serial, this is set for InputSigOnly (i.e. write to fusion)
            myRoom.AddSig(eSigType.UShort, 1, "_Analog Attribyte", eSigIoMask.OutputSigOnly);                   // ushort = analog, this is set for OutputSigOnly (i.e. read from fusion)

            // subscribe to events
            myRoom.FusionAssetStateChange += new FusionAssetStateEventHandler(myRoom_FusionAssetStateChange);
            myRoom.FusionStateChange      += new FusionStateEventHandler(myRoom_FusionStateChange);
            myRoom.OnlineStatusChange     += new OnlineStatusChangeEventHandler(myRoom_OnlineStatusChange);

            myRoom.Register();             // I usually add some sort of check to make sure it is registered okay, but i'm lazy today

            TouchscreenOnlineToggleTimer = new CTimer(TouchScreenOnlineToggleCallback, null, Timeout.Infinite, Timeout.Infinite);
        }
Ejemplo n.º 2
0
        public void SetRoomOccupancy(bool value)
        {
            try
            {
                Trace("SetRoomOccupancy() setting occupancy to: " + value);

                FusionOccupancySensor sensorAsset = (FusionOccupancySensor)room.UserConfigurableAssetDetails[SensorAssetNumber].Asset;

                if (sensorAsset != null)
                {
                    sensorAsset.RoomOccupied.InputSig.BoolValue = value;
                }
                else
                {
                    Trace("SetRoomOccupancy() Sensor asset is null.");
                }
            }
            catch (Exception e)
            {
                Trace("SetRoomOccupancy() exception caught: " + e.Message);
            }
        }