From 6f38f4953e70f67944fd59b6f6820a1629adde17 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Fri, 11 Apr 2025 16:04:27 -0500 Subject: [PATCH] chore(force-patch): rename sln to match workflow requirements --- PepperDashEssentials.3Series.sln | 8 +- .../Audio/EssentialsVolumeLevelConfig.cs | 0 .../Bridges/._EssentialsLightsBridge.cs | Bin .../Bridges/AirMediaControllerBridge.cs | 0 .../Bridges/AppleTvBridge.cs | 0 .../Bridges/BridgeFactory.cs | 258 +- .../Bridges/Bridges.BridgeFactory.cs | 178 +- .../Bridges/C2nRthsControllerBridge.cs | 74 +- .../Bridges/CameraControllerBridge.cs | 336 +- .../Bridges/DmChassisControllerBridge.cs | 0 .../Bridges/DmRmcControllerBridge.cs | 0 .../Bridges/DmTxControllerBridge.cs | 0 .../DmpsAudioOutputControllerBridge.cs | 0 .../Bridges/DmpsRoutingControllerBridge.cs | 0 .../Bridges/DspControllerBridge.cs | 238 +- .../Bridges/EiscBridge.cs | 0 .../Bridges/EssentialComms.cs | 286 +- .../Bridges/EssentialDM.cs | 298 +- .../Bridges/EssentialDsp.cs | 432 +- .../Bridges/EssentialTVOne.cs | 194 +- .../Bridges/GenericLightingBridge.cs | 146 +- .../Bridges/GenericRelayDeviceBridge.cs | 0 .../GlsOccupancySensorBaseControllerBridge.cs | 248 +- .../Bridges/HdMdxxxCEControllerBridge.cs | 0 .../Bridges/IBasicCommunicationBridge.cs | 0 .../PepperDashEssentials}/Bridges/IBridge.cs | 0 .../Bridges/IDigitalInputBridge.cs | 0 .../Bridges/IRSetTopBoxBaseBridge.cs | 254 +- .../JoinMaps/AirMediaControllerJoinMap.cs | 0 .../Bridges/JoinMaps/AppleTvJoinMap.cs | 0 .../JoinMaps/C2nRthsControllerJoinMap.cs | 0 .../JoinMaps/CameraControllerJoinMap.cs | 0 .../Bridges/JoinMaps/DigitalLoggerJoinMap.cs | 0 .../JoinMaps/DisplayControllerJoinMap.cs | 0 .../DmBladeChassisControllerJoinMap.cs | 0 .../JoinMaps/DmChassisControllerJoinMap.cs | 0 .../JoinMaps/DmRmcControllerJoinMap.cs | 16 +- .../Bridges/JoinMaps/DmTxControllerJoinMap.cs | 0 .../DmpsAudioOutputControllerJoinMap.cs | 0 .../JoinMaps/DmpsRoutingControllerJoinMap.cs | 0 .../JoinMaps/GenericLightingJoinMap.cs | 0 .../JoinMaps/GenericRelayControllerJoinMap.cs | 0 .../JoinMaps/GlsOccupancySensorBaseJoinMap.cs | 0 .../JoinMaps/HdMdxxxCEControllerJoinMap.cs | 0 .../JoinMaps/IBasicCommunicationJoinMap.cs | 0 .../Bridges/JoinMaps/IDigitalInputJoinMap.cs | 0 .../JoinMaps/SetTopBoxControllerJoinMap.cs | 0 .../JoinMaps/StatusSignControllerJoinMap.cs | 0 .../Bridges/JoinMaps/SystemMonitorJoinMap.cs | 0 .../Bridges/StatusSignControllerBridge.cs | 128 +- .../Bridges/SystemMonitorBridge.cs | 0 .../PepperDashEssentials}/ClassDiagram1.cd | 0 .../PepperDashEssentials}/ControlSystem.cs | 1326 +-- .../Devices/Amplifier.cs | 0 ...onfigurationFile-HuddleSpace-2-Source.json | 0 ...onFile-mockVideoCodec_din-ap3_-_dm4x1.json | 0 .../SIMPLBridgeExample_configurationFile.json | 0 ...configurationFile-dmps3300c-avRouting.json | 0 .../Factory/DeviceFactory.cs | 94 +- .../EssentialsHuddleVtc1FusionController.cs | 714 +- ...ssentialsTechRoomFusionSystemController.cs | 0 .../Fusion/FusionSystemController.cs.orig | 0 .../PepperDash Essentials TSW-760.sgd | 0 .../PepperDash Essentials iPad.sgd | 0 .../PepperDashEssentials.csproj | 464 +- .../PluginLoading/PluginLoading.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../Properties/AssemblyInfo.cs.orig | 0 .../Properties/ControlSystem.cfg | 12 +- .../Properties/UpdateAssemblyVersion.ps1 | 0 ...sentialsDualDisplayRoomPropertiesConfig.cs | 0 .../EssentialsHuddleRoomPropertiesConfig.cs | 0 .../EssentialsHuddleVtc1PropertiesConfig.cs | 0 .../EssentialsNDisplayRoomPropertiesConfig.cs | 0 .../EssentialsPresentationPropertiesConfig.cs | 0 .../Room/Config/EssentialsRoomConfig.cs | 820 +- .../Config/EssentialsRoomEmergencyConfig.cs | 0 .../Room/Config/EssentialsTechRoomConfig.cs | 0 .../Room/Config/SimplRoomPropertiesConfig.cs | 0 .../EsentialsRoomEmergencyContactClosure.cs | 0 .../Types/EssentialsCombinedHuddleVtc1Room.cs | 366 +- .../Room/Types/EssentialsDualDisplayRoom.cs | 0 .../Room/Types/EssentialsHuddleSpaceRoom.cs | 1126 +-- .../Types/EssentialsHuddleSpaceRoom.cs.orig | 0 .../Room/Types/EssentialsHuddleVtc1Room.cs | 1890 ++-- .../Types/EssentialsHuddleVtc1Room.cs.orig | 0 .../Room/Types/EssentialsNDisplayRoomBase.cs | 0 .../Room/Types/EssentialsTechRoom.cs | 0 .../Interfaces/IEssentialsHuddleSpaceRoom.cs | 0 .../Interfaces/IEssentialsHuddleVtc1Room.cs | 0 .../SGD/PepperDash Essentials TSW-560.sgd | 0 .../SGD/PepperDash Essentials TSW-760.sgd | 0 .../SGD/PepperDash Essentials iPad.sgd | 0 .../CrestronTouchpanelPropertiesConfig.cs | 0 .../DualDisplaySourceSRLController.cs | 0 .../EssentialsTouchpanelController.cs | 0 .../SubpageReferenceListActivityItem.cs | 0 .../SubpageReferenceListSourceItem.cs | 0 .../UI/DualDisplaySourceSRLController.cs | 0 .../UI/EssentialsTouchpanelController.cs | 0 .../UI/HttpLogoServer.cs | 244 +- .../UI/JoinConstants/UIBoolJoin.cs | 1980 ++--- .../UI/JoinConstants/UISmartObjectJoin.cs | 0 .../UI/JoinConstants/UIStringlJoin.cs | 0 .../UI/JoinConstants/UIUshortJoin.cs | 0 .../UI/SmartObjectHeaderButtonList.cs | 0 .../UI/SubpageReferenceListActivityItem.cs | 0 .../UI/SubpageReferenceListCallStagingItem.cs | 0 .../UI/SubpageReferenceListSourceItem.cs | 0 .../UIDrivers/DualDisplayRouting.cs | 0 .../EssentialsEnvironmentDriver.cs | 510 +- .../EssentialsLightingDriver.cs | 0 .../EssentialsShadeDriver.cs | 4 +- .../Essentials/EssentialsHeaderDriver.cs | 796 +- .../EssentialsPanelMainInterfaceDriver.cs | 334 +- ...tialsPresentationPanelAvFunctionsDriver.cs | 0 .../EssentialsHuddlePanelAvFunctionsDriver.cs | 0 .../EssentialsHuddleTechPageDriver.cs | 0 .../EssentialsHuddlePresentationUiDriver.cs | 0 ...entialsHuddleVtc1PanelAvFunctionsDriver.cs | 3304 +++---- .../UIDrivers/JoinedSigInterlock.cs | 348 +- .../SingleSubpageModalAndBackDriver.cs | 0 .../Page Drivers/SingleSubpageModalDriver.cs | 0 .../UIDrivers/ScreenSaverController.cs | 0 .../UIDrivers/SigInterlock.cs | 0 .../UIDrivers/SmartObjectRoomsList.cs | 0 .../UIDrivers/SourceChangeArgs.cs | 0 .../VC/EssentialsVideoCodecUiDriver.cs | 0 .../VC/EssentialsVideoCodecUiDriver.cs.orig | 0 .../UIDrivers/enums and base.cs | 0 .../PepperDashEssentials}/app.config | 0 .../PepperDashEssentialsBase.sln | 0 .../Bridges/BridgeBase.cs | 0 .../Bridges/IBridge.cs | 0 .../JoinMaps/AirMediaControllerJoinMap.cs | 164 +- .../Bridges/JoinMaps/AppleTvJoinMap.cs | 104 +- .../JoinMaps/C2nRthsControllerJoinMap.cs | 88 +- .../JoinMaps/CameraControllerJoinMap.cs | 0 .../CenOdtOccupancySensorBaseJoinMap.cs | 396 +- .../Bridges/JoinMaps/DigitalLoggerJoinMap.cs | 84 +- .../JoinMaps/DisplayControllerJoinMap.cs | 168 +- .../DmBladeChassisControllerJoinMap.cs | 148 +- .../JoinMaps/DmChassisControllerJoinMap.cs | 340 +- .../JoinMaps/DmRmcControllerJoinMap.cs | 182 +- .../Bridges/JoinMaps/DmTxControllerJoinMap.cs | 190 +- .../DmpsAudioOutputControllerJoinMap.cs | 346 +- .../DmpsMicrophoneControllerJoinMap.cs | 0 .../JoinMaps/DmpsRoutingControllerJoinMap.cs | 244 +- .../JoinMaps/GenericIrControllerJoinMap.cs | 0 .../JoinMaps/GenericLightingJoinMap.cs | 88 +- .../JoinMaps/GenericRelayControllerJoinMap.cs | 46 +- .../JoinMaps/GlsOccupancySensorBaseJoinMap.cs | 368 +- .../JoinMaps/GlsPartitionSensorJoinMap.cs | 598 +- .../JoinMaps/HdMdNxM4kEControllerJoinMap.cs | 130 +- .../JoinMaps/HdMdxxxCEControllerJoinMap.cs | 136 +- .../JoinMaps/HdPsXxxControllerJoinMap.cs | 0 .../Hrxxx0WirelessRemoteControllerJoinMap.cs | 490 +- .../Bridges/JoinMaps/IAnalogInputJoinMap.cs | 0 .../JoinMaps/IBasicCommunicationJoinMap.cs | 98 +- .../Bridges/JoinMaps/IDigitalInputJoinMap.cs | 60 +- .../Bridges/JoinMaps/IDigitalOutputJoinMap.cs | 0 .../Bridges/JoinMaps/IRBlurayBaseJoinMap.cs | 0 .../Bridges/JoinMaps/PduJoinMapBase.cs | 0 .../JoinMaps/SetTopBoxControllerJoinMap.cs | 478 +- .../JoinMaps/StatusSignControllerJoinMap.cs | 102 +- .../Bridges/JoinMaps/SystemMonitorJoinMap.cs | 340 +- .../JoinMaps/VideoCodecControllerJoinMap.cs | 6354 ++++++------- .../Comm and IR/CecPortController.cs | 0 .../Comm and IR/ComPortController.cs | 0 .../Comm and IR/ComSpecJsonConverter.cs | 0 .../Comm and IR/CommFactory.cs | 512 +- .../Comm and IR/CommunicationExtras.cs | 0 .../Comm and IR/ConsoleCommMockDevice.cs | 0 .../Comm and IR/GenericComm.cs | 282 +- .../Comm and IR/GenericHttpClient.cs | 0 .../Comm and IR/IRPortHelper.cs | 480 +- .../Config/BasicConfig.cs | 0 .../Config/ConfigPropertiesHelpers.cs | 0 .../Config/DeviceConfig.cs | 158 +- .../Config/Essentials/ConfigReader.cs | 506 +- .../Config/Essentials/ConfigUpdater.cs | 0 .../Config/Essentials/ConfigWriter.cs | 322 +- .../Config/Essentials/EssentialsConfig.cs | 0 .../Config/InfoConfig.cs | 0 .../SourceDevicePropertiesConfigBase.cs | 0 .../Crestron IO/C2nIo/C2nIoController.cs | 0 .../Crestron IO/C2nRts/C2nRthsController.cs | 294 +- .../Crestron IO/Cards/C3CardControllerBase.cs | 0 .../Crestron IO/Cards/C3Com3Controller.cs | 0 .../Crestron IO/Cards/C3Io16Controller.cs | 0 .../Crestron IO/Cards/C3Ir8Controller.cs | 0 .../Crestron IO/Cards/C3Ry16Controller.cs | 0 .../Crestron IO/Cards/C3Ry8Controller.cs | 0 .../Crestron IO/Cards/CenCi31Controller.cs | 0 .../Crestron IO/Cards/CenCi33Controller.cs | 0 .../Cards/InternalCardCageController.cs | 0 .../CenIoCom/CenIoComController.cs | 0 .../DinCenCn/DinCenCnController.cs | 100 +- .../DinCenCn/IHasCresnetBranches.cs | 28 +- .../Crestron IO/DinIo8/DinIo8Controller.cs | 0 .../Crestron IO/IOPortConfig.cs | 0 .../Inputs/CenIoDigIn104Controller.cs | 18 +- .../Inputs/GenericDigitalInputDevice.cs | 328 +- .../GenericVersiportAnalogInputDevice.cs | 0 .../Inputs/GenericVersiportInputDevice.cs | 0 .../Crestron IO/Inputs/IAnalogInput.cs | 0 .../Crestron IO/Inputs/IDigitalInput.cs | 0 .../Crestron IO/Ir/CenIoIr104Controller.cs | 184 +- .../Outputs/GenericVersiportOutputDevice.cs | 0 .../Crestron IO/Outputs/IDigitalOutput.cs | 0 .../Crestron IO/Relay/CenIoRy104Controller.cs | 2 +- .../Crestron IO/Relay/GenericRelayDevice.cs | 440 +- .../Crestron IO/Relay/ISwitchedOutput.cs | 0 .../StatusSign/StatusSignController.cs | 444 +- .../Crestron/CrestronGenericBaseDevice.cs | 428 +- .../CrestronGenericBaseDevice.cs.orig | 0 .../Device Info/DeviceInfo.cs | 0 .../Device Info/DeviceInfoEventArgs.cs | 0 .../Device Info/IDeviceInfoProvider.cs | 0 .../Device Info/NetworkDeviceHelpers.cs | 0 .../IPresentationSource.cs | 0 .../DeviceTypeInterfaces/IChannel.cs | 0 .../DeviceTypeInterfaces/IColorFunctions.cs | 0 .../DeviceTypeInterfaces/IDPad.cs | 0 .../IDiscPlayerControls.cs | 0 .../DeviceTypeInterfaces/IDisplayBasic.cs | 0 .../DeviceTypeInterfaces/IDumbSource.cs | 0 .../DeviceTypeInterfaces/IDvr.cs | 0 .../DeviceTypeInterfaces/IHasBranding.cs | 0 .../IHasFarEndContentStatus.cs | 0 .../DeviceTypeInterfaces/IHasPhoneDialing.cs | 0 .../ILanguageDefinition.cs | 0 .../DeviceTypeInterfaces/ILanguageProvider.cs | 0 .../DeviceTypeInterfaces/IMobileControl.cs | 0 .../DeviceTypeInterfaces/INumeric.cs | 0 .../DeviceTypeInterfaces/IPasswordPrompt.cs | 110 +- .../DeviceTypeInterfaces/IPower.cs | 0 .../ISetTopBoxControls.cs | 0 .../DeviceTypeInterfaces/ITransport.cs | 0 .../ITvPresetsProvider.cs | 0 .../DeviceTypeInterfaces/IUiDisplayInfo.cs | 0 .../DeviceTypeInterfaces/IWarmingCooling.cs | 0 .../DeviceTypeInterfaces/LanguageLabel.cs | 0 .../DeviceTypeInterfaces/Template.cs | 0 .../Devices/.IHasFeedbacks_BASE_3692.cs.swp | Bin .../Devices/.IHasFeedbacks_LOCAL_3692.cs.swp | Bin .../Devices/.IHasFeedbacks_REMOTE_3692.cs.swp | Bin .../Devices/AudioInterfaces.cs | 0 .../Devices/CodecInterfaces.cs | 0 .../Devices/CodecInterfaces.cs.orig | 0 .../Devices/CrestronProcessor.cs | 0 .../Devices/DestinationListItem.cs | 0 .../Devices/DeviceApiBase.cs | 0 .../Devices/DeviceFeedbackExtensions.cs | 0 .../Devices/DeviceJsonApi.cs | 0 .../Devices/DeviceManager.cs | 978 +- .../Devices/DeviceManager.cs.orig | 0 .../Devices/DisplayUiConstants.cs | 0 .../Devices/EssentialsBridgeableDevice.cs | 0 .../Devices/EssentialsDevice.cs | 288 +- .../Devices/FIND HOMES Interfaces.cs | 0 .../Devices/GenericIRController.cs | 0 .../Devices/GenericMonitoredTcpDevice.cs | 0 .../Devices/IAttachVideoStatusExtensions.cs | 0 .../Devices/IDspPreset.cs | 32 +- .../Devices/IHasFeedbacks.cs | 0 .../Devices/IHasFeedbacks_BACKUP_3692.cs | 0 .../Devices/IHasFeedbacks_BASE_3692.cs | 0 .../Devices/IHasFeedbacks_LOCAL_3692.cs | 0 .../Devices/IHasFeedbacks_REMOTE_3692.cs | 0 .../Devices/IProjectorInterfaces.cs | 42 +- .../Devices/IReconfigurableDevice.cs | 0 .../Devices/IUsageTracking.cs | 0 .../Devices/IUsageTracking.cs.orig | 0 .../Devices/IVolumeAndAudioInterfaces.cs | 0 .../Devices/IrOutputPortController.cs | 342 +- .../Devices/PC/InRoomPc.cs | 0 .../Devices/PC/Laptop.cs | 0 .../Devices/PduInterfaces.cs | 0 .../Devices/PowerInterfaces.cs | 0 .../Devices/PresentationDeviceType.cs | 0 .../Devices/REMOVE IHasFeedbacks.cs | 0 .../Devices/ReconfigurableDevice.cs | 0 .../Devices/SmartObjectBaseTypes.cs | 0 .../Devices/SourceListItem.cs | 0 .../Devices/VolumeDeviceChangeEventArgs.cs | 0 .../Display/BasicIrDisplay.cs | 482 +- .../Display/DisplayBase.cs | 650 +- .../Display/MockDisplay.cs | 72 +- .../Ethernet/EthernetStatistics.cs | 0 .../Extensions/JsonExtensions.cs | 82 +- .../Extensions/StringExtensions.cs | 0 .../Factory/DeviceFactory.cs | 424 +- .../Factory/IDeviceFactory.cs | 0 .../Factory/ReadyEventArgs.cs | 90 +- .../Feedbacks/BoolFeedback.cs | 0 .../Feedbacks/BoolFeedbackOneShot.cs | 0 .../Feedbacks/BoolFeedbackPulseExtender.cs | 0 .../Feedbacks/BoolOutputLogicals.cs | 0 .../Feedbacks/FeedbackBase.cs | 0 .../Feedbacks/FeedbackCollection.cs | 0 .../Feedbacks/FeedbackEventArgs.cs | 0 .../Feedbacks/IntFeedback.cs | 0 .../Feedbacks/SerialFeedback.cs | 0 .../Feedbacks/StringFeedback.cs | 0 .../PepperDashEssentialsBase/File/FileIO.cs | 0 ...lsHuddleSpaceFusionSystemControllerBase.cs | 3652 ++++---- ...entialsHuddleSpaceRoomFusionRoomJoinMap.cs | 0 .../Fusion/FusionCustomPropertiesBridge.cs | 0 .../Fusion/FusionEventHandlers.cs | 0 .../Fusion/FusionProcessorQueries.cs | 0 .../Fusion/FusionRviDataClasses.cs | 0 .../Gateways/CenCn2Controller.cs | 22 +- .../Gateways/CenRfgwController.cs | 372 +- .../Gateways/EssentialsRfGatewayConfig.cs | 36 +- .../Global/EthernetAdapterInfo.cs | 0 .../PepperDashEssentialsBase/Global/Global.cs | 560 +- .../Global/JobTimer.cs | 0 .../Global/Scheduler.cs | 0 .../InUseTracking/IInUseTracking.cs | 0 .../InUseTracking/InUseTracking.cs | 0 .../Interfaces/ILogStrings.cs | 32 +- .../Interfaces/ILogStringsWithLevel.cs | 34 +- .../JoinMaps/JoinMapBase.cs | 1280 +-- .../License/EssentialsLicenseManager.cs | 0 .../Lighting/Lighting Interfaces.cs | 0 .../Lighting/LightingBase.cs | 332 +- .../MicrophonePrivacyController.cs | 0 .../MicrophonePrivacyControllerConfig.cs | 0 ...CrestronGenericBaseCommunicationMonitor.cs | 0 .../Monitoring/GenericCommunicationMonitor.cs | 0 .../Monitoring/Interfaces.cs | 0 .../Monitoring/StatusMonitorBase.cs | 0 .../Monitoring/StatusMonitorCollection.cs | 0 .../Monitoring/SystemMonitorController.cs | 1636 ++-- .../CenOdtOccupancySensorBaseController.cs | 1548 ++-- ...lsGlsOccupancySensorBaseController.cs.orig | 0 .../GlsOccupancySensorBaseController.cs | 1076 +-- .../GlsOccupancySensorPropertiesConfig.cs | 0 .../GlsOdtOccupancySensorController.cs | 566 +- .../GlsOirOccupancySensorController.cs | 0 .../IOccupancyStatusProviderAggregator.cs | 136 +- .../Occupancy/OccupancyAggregatorConfig.cs | 0 .../EssentialsPartitionController.cs | 0 .../GlsPartitionSensorController.cs | 726 +- .../GlsPartitionSensorPropertiesConfig.cs | 8 +- .../IPartitionStateProvider.cs | 0 .../PepperDash_Essentials_Core.csproj | 864 +- ...perDash_Essentials_Core.csproj.DotSettings | 0 .../PepperDash_Essentials_Core.nuspec | 0 .../Plugins/IPluginDeviceFactory.cs | 0 .../Plugins/PluginLoader.cs | 0 .../Presets/DevicePresets.cs | 0 .../Presets/DevicePresetsView.cs | 0 .../Presets/Interfaces.cs | 0 .../Presets/PresetBase.cs | 0 .../Presets/PresetChannel.cs | 0 .../PresetsListSubpageReferenceListItem.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../Properties/ControlSystem.cfg | 0 .../Queues/ComsMessage.cs | 0 .../Queues/GenericQueue.cs | 0 .../PepperDashEssentialsBase/Queues/IQueue.cs | 0 .../Queues/IQueueMessage.cs | 0 .../Queues/ProcessStringMessage.cs | 0 .../Queues/StringResponseProcessor.cs | 0 .../Ramps and Increments/ActionIncrementer.cs | 0 .../Ramps and Increments/NumericalHelpers.cs | 0 .../UshortSigIncrementer.cs | 0 .../Remotes/ButtonExtensions.cs | 92 +- .../Remotes/CrestronRemotePropertiesConfig.cs | 32 +- .../Remotes/Hrxx0WirelessRemoteController.cs | 1040 +-- .../RoomOnToDefaultSourceWhenOccupied.cs | 0 .../Room/Combining/EssentialsRoomCombiner.cs | 0 .../EssentialsRoomCombinerPropertiesConfig.cs | 0 .../Room/Combining/IEssentialsRoomCombiner.cs | 0 .../Room/Combining/RoomCombinationScenario.cs | 0 .../EssentialsRoomScheduledEventsConfig.cs | 0 .../Room/EssentialsRoomBase.cs | 824 +- .../Room/IEssentialsRoom.cs | 0 .../Room/Interfaces.cs | 0 .../PepperDashEssentialsBase/Room/Room.cs | 0 .../Room/iOccupancyStatusProvider.cs | 0 .../Routing/DummyRoutingInputsDevice.cs | 0 .../Routing/ICardPortsDevice.cs | 0 .../Routing/IRoutingInputsExtensions.cs | 848 +- .../Routing/RoutingInterfaces.cs | 422 +- .../Routing/RoutingPort.cs | 0 .../Routing/RoutingPortCollection.cs | 0 .../Routing/RoutingPortNames.cs | 0 .../Routing/TieLine.cs | 0 .../Routing/TieLineConfig.cs | 0 .../Secrets/CrestronGlobalSecretsProvider.cs | 0 .../Secrets/CrestronLocalSecretsProvider.cs | 0 .../Secrets/CrestronSecret.cs | 0 .../Secrets/Interfaces.cs | 114 +- .../Secrets/SecretsManager.cs | 748 +- .../Secrets/SecretsPropertiesConfig.cs | 38 +- .../Shades/Shade Interfaces.cs | 30 +- .../Shades/ShadeBase.cs | 0 .../Shades/ShadeController.cs | 0 .../PepperDashEssentialsBase/SigHelper.cs | 0 .../SmartObjects/SmartObjectDPad.cs | 0 .../SmartObjects/SmartObjectDynamicList.cs | 0 .../SmartObjects/SmartObjectHelperBase.cs | 0 .../SmartObjects/SmartObjectNumeric.cs | 0 .../SourceListSubpageReferenceList.cs | 0 .../SubpageReferenceList.cs | 0 .../SubpageReferenceListItem.cs | 0 .../Timers/CountdownTimer.cs | 294 +- .../Timers/RetriggerableTimer.cs | 0 .../CrestronTouchpanelPropertiesConfig.cs | 0 .../Touchpanels/Interfaces.cs | 0 .../Keyboards/HabaneroKeyboardController.cs | 0 .../Touchpanels/ModalDialog.cs | 0 .../Touchpanels/Mpc3Touchpanel.cs | 0 .../Touchpanels/TriListExtensions.cs | 0 .../TriListBridges/HandlerBridge.cs | 0 .../UI PageManagers/BlurayPageManager.cs | 0 .../UI PageManagers/PageManager.cs | 0 .../SetTopBoxThreePanelPageManager.cs | 0 .../SetTopBoxTwoPanelPageManager.cs | 0 .../UI PageManagers/SinglePageManager.cs | 0 .../UI/TouchpanelBase.cs | 0 .../Utilities/ActionSequence.cs | 0 .../VideoStatus/VideoStatusOutputs.cs | 0 .../Web/EssemtialsWebApi.cs | 446 +- .../Web/EssentialsWebApiFactory.cs | 48 +- .../Web/EssentialsWebApiHelpers.cs | 172 +- .../Web/EssentialsWebApiPropertiesConfig.cs | 18 +- .../RequestHandlers/AppDebugRequestHandler.cs | 162 +- .../RequestHandlers/DefaultRequestHandler.cs | 234 +- .../RequestHandlers/DevJsonRequestHandler.cs | 130 +- .../RequestHandlers/DevListRequestHandler.cs | 100 +- .../RequestHandlers/DevPropsRequestHandler.cs | 150 +- .../DisableAllStreamDebugRequestHandler.cs | 62 +- .../GetFeedbacksForDeviceRequestHandler.cs | 202 +- .../GetJoinMapForBridgeKeyRequestHandler.cs | 154 +- .../GetJoinMapForDeviceKeyRequestHandler.cs | 188 +- .../GetTypesByFilterRequestHandler.cs | 134 +- .../RequestHandlers/GetTypesRequestHandler.cs | 114 +- .../ReportVersionsRequestHandler.cs | 96 +- .../SetDeviceStreamDebugRequestHandler.cs | 422 +- .../ShowConfigRequestHandler.cs | 72 +- .../PepperDashEssentialsBase/app.config | 0 .../Essentials DM/Essentials_DM.sln | 0 .../AirMedia/AirMediaController.cs | 864 +- .../AirMedia/AirMediaPropertiesConfig.cs | 0 .../Chassis/._DmChassisController.cs | Bin ...assisControllerPropertiesConfigSchema.json | 0 .../Chassis/DmBladeChassisController.cs | 1996 ++--- .../Chassis/DmCardAudioOutput.cs | 0 .../Chassis/DmCardAudioOutput.cs.orig | 0 .../Chassis/DmCardAudioOutput_BACKUP_14408.cs | 0 .../Chassis/DmCardAudioOutput_BASE_14408.cs | 0 .../Chassis/DmCardAudioOutput_LOCAL_14408.cs | 0 .../Chassis/DmCardAudioOutput_REMOTE_14408.cs | 0 .../Chassis/DmChassisController.cs | 4250 ++++----- .../Chassis/DmpsAudioOutputController.cs | 0 .../Chassis/DmpsDigitalOutputController.cs | 0 .../DmpsInternalVirtualDmTxController.cs | 0 .../Chassis/DmpsMicrophoneController.cs | 0 .../Chassis/DmpsRoutingController.cs | 0 .../Chassis/HdMd8xNController.cs | 0 .../Chassis/HdMdNxM4kEBridgeableController.cs | 1006 +-- .../Chassis/HdMdNxM4kEController.cs | 336 +- .../HdPsXxxAnalogAuxMixerController.cs | 0 .../Chassis/HdPsXxxController.cs | 0 .../Chassis/HdPsXxxOutputAudioController.cs | 0 .../Essentials_DM/Config/DMChassisConfig.cs | 0 .../Essentials_DM/Config/DeviceFactory.cs | 100 +- .../Essentials_DM/Config/DmRmcConfig.cs | 0 .../Essentials_DM/Config/DmTxConfig.cs | 0 .../Essentials_DM/Config/DmpsRoutingConfig.cs | 0 .../Config/HdMdNxM4kEPropertiesConfig.cs | 46 +- .../Config/HdPsXxxPropertiesConfig.cs | 0 .../Config/InputPropertiesConfig.cs | 30 +- .../DmLite/HdMdxxxCEController.cs | 68 +- .../Essentials DM/Essentials_DM/DmPortName.cs | 0 .../Endpoints/DGEs/Dge100Controller.cs | 414 +- .../Endpoints/DGEs/DgeJoinMap.cs | 0 .../Endpoints/DGEs/DgePropertiesConfig.cs | 0 .../Endpoints/DGEs/DmDge200CController.cs | 186 +- .../Endpoints/EndpointInterfaces.cs | 0 .../Receivers/DmHdBaseTEndpointController.cs | 0 .../Receivers/DmRmc100SController.cs | 2 +- .../Receivers/DmRmc150SController.cs | 196 +- .../Receivers/DmRmc200CController.cs | 220 +- .../Receivers/DmRmc200S2Controller.cs | 4 +- .../Receivers/DmRmc200SController.cs | 4 +- .../Receivers/DmRmc4KScalerCController.cs | 520 +- .../Receivers/DmRmc4k100C1GController.cs | 70 +- .../Receivers/DmRmc4kScalerCDspController.cs | 56 +- .../Receivers/DmRmc4kZ100CController.cs | 4 +- .../Receivers/DmRmc4kZScalerCController.cs | 488 +- .../Endpoints/Receivers/DmRmcHelper.cs | 28 +- .../Receivers/DmRmcScalerCController.cs | 4 +- .../Receivers/DmRmcScalerS2Controller.cs | 4 +- .../Receivers/DmRmcScalerSController.cs | 4 +- .../Receivers/DmRmcX100CController.cs | 4 +- .../Transmitters/DmTx200Controller.cs | 828 +- .../Transmitters/DmTx201CController.cs | 858 +- .../Transmitters/DmTx201SController.cs | 844 +- .../Transmitters/DmTx401CController.cs | 986 +-- .../Transmitters/DmTx4k100Controller.cs | 0 .../Transmitters/DmTx4k202CController.cs | 822 +- .../Transmitters/DmTx4k302CController.cs | 1000 +-- .../Transmitters/DmTx4kz100Controller.cs | 192 +- .../Transmitters/DmTx4kz202CController.cs | 810 +- .../Transmitters/DmTx4kz302CController.cs | 890 +- .../Endpoints/Transmitters/DmTxHelpers.cs | 0 .../Transmitters/HDBaseTTxController.cs | 0 .../Endpoints/Transmitters/TxInterfaces.cs | 0 .../Essentials_DM/Essentials_DM.csproj | 0 .../Essentials DM/Essentials_DM/Extensions.cs | 0 .../Essentials_DM/IDmHdmiInputExtensions.cs | 0 .../Essentials DM/Essentials_DM/IDmSwitch.cs | 62 +- .../PepperDash_Essentials_DM.csproj | 352 +- .../Essentials_DM/Properties/AssemblyInfo.cs | 0 .../Properties/ControlSystem.cfg | 0 .../Essentials_DM/VideoStatusHelpers.cs | 0 .../Essentials DM/Essentials_DM/app.config | 0 .../Essentials Devices Common.sln | 0 .../Audio/GenericAudioOut.cs | 0 .../AudioCodec/AudioCodecBase.cs | 0 .../AudioCodec/Interfaces/IAudioCodecInfo.cs | 0 .../AudioCodec/Interfaces/IHasAudioCodec.cs | 0 .../AudioCodec/MockAC/MockAC.cs | 0 .../MockAC/MockAcPropertiesConfig.cs | 0 .../Cameras/CameraBase.cs | 0 .../Cameras/CameraControl.cs | 0 .../Cameras/CameraVisca.cs | 0 .../Cameras/IHasCameraPresets.cs | 0 .../ClassDiagram1.cd | 0 .../Codec/CodecActiveCallItem.cs | 0 .../Codec/CodecActiveCallItem.cs.orig | 0 .../Codec/IHasCallHold.cs | 0 .../Codec/IHasDoNotDisturb.cs | 0 .../Codec/IHasExternalSourceSwitching.cs | 42 +- .../Codec/eCodecCallDirection.cs | 0 .../Codec/eCodecCallStatus.cs | 0 .../Codec/eCodecCallType.cs | 0 .../Codec/eMeetingPrivacy.cs | 0 .../Codec/iCodecAudio.cs | 0 .../Codec/iHasCallFavorites.cs | 0 .../Codec/iHasCallHistory.cs | 0 .../Codec/iHasContentSharing.cs | 0 .../Codec/iHasDialer.cs | 0 .../Codec/iHasDirectory.cs | 0 .../Codec/iHasScheduleAwareness.cs | 0 .../DSP/BiampTesira/BiampTesiraForteDsp.cs | 774 +- .../BiampTesira/BiampTesiraForteDspLevel.cs | 0 .../BiampTesiraFortePropertiesConfig.cs | 0 .../BiampTesira/TesiraForteControlPoint.cs | 0 .../DSP/BiampTesira/TesiraForteMuteControl.cs | 0 .../Essentials Devices Common/DSP/DspBase.cs | 14 +- .../SoundStructureBasics.cs | 0 .../DSP/QSC/QscDsp.cs | 0 .../DSP/QSC/QscDspControlPoint.cs | 0 .../DSP/QSC/QscDspDialer.cs | 0 .../DSP/QSC/QscDspLevelControl.cs | 0 .../DSP/QSC/QscDspPropertiesConfig.cs | 0 .../DSP/QscDsp/._QscDspPropertiesConfig.cs | Bin .../DSP/QscDsp/QscDsp.cs | 0 .../DSP/QscDsp/QscDspControlPoint.cs | 0 .../DSP/QscDsp/QscDspDialer.cs | 0 .../DSP/QscDsp/QscDspLevelControl.cs | 0 .../DSP/QscDsp/QscDspPropertiesConfig.cs | 0 .../DiscPlayer/IRDiscPlayerBase.cs | 0 .../Display/AvocorVTFDisplay.cs | 0 .../Display/ComTcpDisplayBase.cs | 0 .../Display/InputInterfaces.cs | 32 +- .../Display/NECPSXMDisplay.cs | 0 .../Display/NecPaSeriesProjector.cs | 0 .../Display/PanasonicThDisplay.cs | 0 .../Display/SamsungMDCDisplay.cs | 1324 +-- .../Environment/Crestron Lighting/Din8sw8.cs | 0 .../Environment/Lutron/LutronQuantum.cs | 0 .../Environment/Somfy/RelayControlledShade.cs | 0 .../Essentials Devices Common.csproj | 418 +- .../Factory/DeviceFactory.cs | 0 .../Generic/GenericSource.cs | 0 .../AnalogWayLiveCorePropertiesConfig.cs | 0 .../AnalogWay/AnalongWayLiveCore.cs | 0 .../ImageProcessors/TVOne/TVOneCorio.cs | 0 .../TVOne/TVOneCorioPropertiesConfig.cs | 0 .../ImageProcessors/TVOneCorio.cs | 0 .../TVOneCorioPropertiesConfig.cs | 0 .../DigitalLoggerPropertiesConfig.cs | 0 .../Power Controllers/Digitallogger.cs | 4 +- .../Properties/AssemblyInfo.cs | 0 .../Properties/ControlSystem.cfg | 0 .../SetTopBox/IRSetTopBoxBase.cs | 1034 +-- .../SetTopBox/SetTopBoxPropertiesConfig.cs | 0 .../SoftCodec/BlueJeansPc.cs | 0 .../Streaming/AppleTV.cs | 434 +- .../Streaming/Roku.cs | 2 +- .../CiscoCodec/BookingsDataClasses.cs | 0 .../CiscoCodec/CallHistoryDataClasses.cs | 0 .../VideoCodec/CiscoCodec/CiscoCamera.cs | 0 .../VideoCodec/CiscoCodec/CiscoCodec.cs.orig | 0 .../CiscoCodec/CiscoCodecJoinMap.cs | 0 .../VideoCodec/CiscoCodec/CiscoSparkCodec.cs | 0 .../CiscoCodec/CiscoSparkCodec.cs.orig | 0 .../CiscoSparkCodecPropertiesConfig.cs | 176 +- .../VideoCodec/CiscoCodec/HttpApiServer.cs | 0 .../CiscoCodec/PhonebookDataClasses.cs | 0 .../VideoCodec/CiscoCodec/RoomPresets.cs | 0 .../VideoCodec/CiscoCodec/xConfiguration.cs | 0 .../VideoCodec/CiscoCodec/xEvent.cs | 330 +- .../VideoCodec/CiscoCodec/xStatus.cs | 0 .../VideoCodec/CiscoCodec/xStatusSparkPlus.cs | 0 .../VideoCodec/CodecActiveCallItem.cs.orig | 0 .../VideoCodec/ConvertiblePreset.cs | 0 .../VideoCodec/Interfaces/IHasCodecLayouts.cs | 0 .../Interfaces/IHasCodecSelfview.cs | 0 .../VideoCodec/Interfaces/IHasMeetingInfo.cs | 6 +- .../VideoCodec/Interfaces/IHasMeetingLock.cs | 0 .../Interfaces/IHasMeetingRecording.cs | 0 .../VideoCodec/Interfaces/IHasParticipants.cs | 0 .../Interfaces/IHasPresentationOnlyMeeting.cs | 0 .../Interfaces/IHasSelfviewPosition.cs | 0 .../VideoCodec/Interfaces/IHasSelfviewSize.cs | 0 .../VideoCodec/Interfaces/IHasStandbyMode.cs | 0 .../VideoCodec/Interfaces/IHasStartMeeting.cs | 0 .../VideoCodec/Interfaces/IHasVideoCodec.cs | 0 .../VideoCodec/Interfaces/IJoinCalls.cs | 0 .../VideoCodec/Interfaces/iVideoCodecInfo.cs | 0 .../VideoCodec/MockVC/MockCodecDirectory.cs | 0 .../VideoCodec/MockVC/MockVC.cs | 0 .../VideoCodec/MockVC/MockVC.cs.orig | 0 .../VideoCodec/MockVC/MockVCCamera.cs | 0 .../MockVC/MockVcPropertiesConfig.cs | 0 .../VideoCodec/VideoCodecBase.cs | 4060 ++++----- .../VideoCodec/VideoCodecBase.cs.orig | 0 .../IZoomWirelessShareInstructions.cs | 54 +- .../VideoCodec/ZoomRoom/ResponseObjects.cs | 3638 ++++---- .../VideoCodec/ZoomRoom/ZoomRoom.cs | 7880 ++++++++--------- .../VideoCodec/ZoomRoom/ZoomRoomCamera.cs | 0 .../VideoCodec/ZoomRoom/ZoomRoomJoinMap.cs | 1410 +-- .../ZoomRoom/ZoomRoomPropertiesConfig.cs | 42 +- .../Essentials Framework.sln | 0 .../Bridges/Bridges.BridgeFactory.cs | 0 .../Bridges/EssentialComms.cs | 0 .../Bridges/EssentialDM.cs | 0 .../Factories/DmFactory.cs | 0 .../PepperDashEssentials/ControlSystem.cs | 0 .../PepperDashEssentials.csproj | 0 .../UIDrivers/DualDisplayRouting REMOVE.cs | 0 649 files changed, 48887 insertions(+), 48887 deletions(-) rename {PepperDashEssentials => src/PepperDashEssentials}/Audio/EssentialsVolumeLevelConfig.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/._EssentialsLightsBridge.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/AirMediaControllerBridge.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/AppleTvBridge.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/BridgeFactory.cs (97%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/Bridges.BridgeFactory.cs (96%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/C2nRthsControllerBridge.cs (97%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/CameraControllerBridge.cs (97%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/DmChassisControllerBridge.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/DmRmcControllerBridge.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/DmTxControllerBridge.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/DmpsAudioOutputControllerBridge.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/DmpsRoutingControllerBridge.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/DspControllerBridge.cs (97%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/EiscBridge.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/EssentialComms.cs (97%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/EssentialDM.cs (97%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/EssentialDsp.cs (97%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/EssentialTVOne.cs (96%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/GenericLightingBridge.cs (98%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/GenericRelayDeviceBridge.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/GlsOccupancySensorBaseControllerBridge.cs (98%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/HdMdxxxCEControllerBridge.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/IBasicCommunicationBridge.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/IBridge.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/IDigitalInputBridge.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/IRSetTopBoxBaseBridge.cs (98%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/JoinMaps/AirMediaControllerJoinMap.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/JoinMaps/AppleTvJoinMap.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/JoinMaps/C2nRthsControllerJoinMap.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/JoinMaps/CameraControllerJoinMap.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/JoinMaps/DigitalLoggerJoinMap.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/JoinMaps/DisplayControllerJoinMap.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/JoinMaps/DmBladeChassisControllerJoinMap.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/JoinMaps/DmChassisControllerJoinMap.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/JoinMaps/DmRmcControllerJoinMap.cs (99%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/JoinMaps/DmTxControllerJoinMap.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/JoinMaps/DmpsAudioOutputControllerJoinMap.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/JoinMaps/DmpsRoutingControllerJoinMap.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/JoinMaps/GenericLightingJoinMap.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/JoinMaps/GenericRelayControllerJoinMap.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/JoinMaps/GlsOccupancySensorBaseJoinMap.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/JoinMaps/HdMdxxxCEControllerJoinMap.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/JoinMaps/IDigitalInputJoinMap.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/JoinMaps/SetTopBoxControllerJoinMap.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/JoinMaps/StatusSignControllerJoinMap.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/JoinMaps/SystemMonitorJoinMap.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/StatusSignControllerBridge.cs (98%) rename {PepperDashEssentials => src/PepperDashEssentials}/Bridges/SystemMonitorBridge.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/ClassDiagram1.cd (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/ControlSystem.cs (97%) rename {PepperDashEssentials => src/PepperDashEssentials}/Devices/Amplifier.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Example Configuration/EssentialsHuddleSpaceRoom/configurationFile-HuddleSpace-2-Source.json (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Example Configuration/EssentialsHuddleVtc1Room/configurationFile-mockVideoCodec_din-ap3_-_dm4x1.json (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Example Configuration/SIMPLBridging/SIMPLBridgeExample_configurationFile.json (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Example Configuration/SIMPLBridging/configurationFile-dmps3300c-avRouting.json (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Factory/DeviceFactory.cs (96%) rename {PepperDashEssentials => src/PepperDashEssentials}/Fusion/EssentialsHuddleVtc1FusionController.cs (97%) rename {PepperDashEssentials => src/PepperDashEssentials}/Fusion/EssentialsTechRoomFusionSystemController.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Fusion/FusionSystemController.cs.orig (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/PepperDash Essentials TSW-760.sgd (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/PepperDash Essentials iPad.sgd (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/PepperDashEssentials.csproj (98%) rename {PepperDashEssentials => src/PepperDashEssentials}/PluginLoading/PluginLoading.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Properties/AssemblyInfo.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Properties/AssemblyInfo.cs.orig (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Properties/ControlSystem.cfg (97%) rename {PepperDashEssentials => src/PepperDashEssentials}/Properties/UpdateAssemblyVersion.ps1 (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Room/Config/EssentialsDualDisplayRoomPropertiesConfig.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Room/Config/EssentialsHuddleRoomPropertiesConfig.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Room/Config/EssentialsHuddleVtc1PropertiesConfig.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Room/Config/EssentialsNDisplayRoomPropertiesConfig.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Room/Config/EssentialsPresentationPropertiesConfig.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Room/Config/EssentialsRoomConfig.cs (96%) rename {PepperDashEssentials => src/PepperDashEssentials}/Room/Config/EssentialsRoomEmergencyConfig.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Room/Config/EssentialsTechRoomConfig.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Room/Config/SimplRoomPropertiesConfig.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Room/Emergency/EsentialsRoomEmergencyContactClosure.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Room/Types/EssentialsCombinedHuddleVtc1Room.cs (99%) rename {PepperDashEssentials => src/PepperDashEssentials}/Room/Types/EssentialsDualDisplayRoom.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Room/Types/EssentialsHuddleSpaceRoom.cs (97%) rename {PepperDashEssentials => src/PepperDashEssentials}/Room/Types/EssentialsHuddleSpaceRoom.cs.orig (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Room/Types/EssentialsHuddleVtc1Room.cs (97%) rename {PepperDashEssentials => src/PepperDashEssentials}/Room/Types/EssentialsHuddleVtc1Room.cs.orig (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Room/Types/EssentialsNDisplayRoomBase.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Room/Types/EssentialsTechRoom.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Room/Types/Interfaces/IEssentialsHuddleSpaceRoom.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/Room/Types/Interfaces/IEssentialsHuddleVtc1Room.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/SGD/PepperDash Essentials TSW-560.sgd (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/SGD/PepperDash Essentials TSW-760.sgd (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/SGD/PepperDash Essentials iPad.sgd (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UI - FILES ORPHANED-DELETE/CrestronTouchpanelPropertiesConfig.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UI - FILES ORPHANED-DELETE/DualDisplaySourceSRLController.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UI - FILES ORPHANED-DELETE/EssentialsTouchpanelController.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UI - FILES ORPHANED-DELETE/SubpageReferenceListActivityItem.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UI - FILES ORPHANED-DELETE/SubpageReferenceListSourceItem.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UI/DualDisplaySourceSRLController.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UI/EssentialsTouchpanelController.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UI/HttpLogoServer.cs (97%) rename {PepperDashEssentials => src/PepperDashEssentials}/UI/JoinConstants/UIBoolJoin.cs (96%) rename {PepperDashEssentials => src/PepperDashEssentials}/UI/JoinConstants/UISmartObjectJoin.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UI/JoinConstants/UIStringlJoin.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UI/JoinConstants/UIUshortJoin.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UI/SmartObjectHeaderButtonList.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UI/SubpageReferenceListActivityItem.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UI/SubpageReferenceListCallStagingItem.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UI/SubpageReferenceListSourceItem.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UIDrivers/DualDisplayRouting.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UIDrivers/Environment Drivers/EssentialsEnvironmentDriver.cs (97%) rename {PepperDashEssentials => src/PepperDashEssentials}/UIDrivers/Environment Drivers/EssentialsLightingDriver.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UIDrivers/Environment Drivers/EssentialsShadeDriver.cs (99%) rename {PepperDashEssentials => src/PepperDashEssentials}/UIDrivers/Essentials/EssentialsHeaderDriver.cs (97%) rename {PepperDashEssentials => src/PepperDashEssentials}/UIDrivers/Essentials/EssentialsPanelMainInterfaceDriver.cs (96%) rename {PepperDashEssentials => src/PepperDashEssentials}/UIDrivers/Essentials/EssentialsPresentationPanelAvFunctionsDriver.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UIDrivers/EssentialsHuddle/EssentialsHuddlePanelAvFunctionsDriver.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UIDrivers/EssentialsHuddle/EssentialsHuddleTechPageDriver.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UIDrivers/EssentialsHuddleVTC/EssentialsHuddlePresentationUiDriver.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs (97%) rename {PepperDashEssentials => src/PepperDashEssentials}/UIDrivers/JoinedSigInterlock.cs (96%) rename {PepperDashEssentials => src/PepperDashEssentials}/UIDrivers/Page Drivers/SingleSubpageModalAndBackDriver.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UIDrivers/Page Drivers/SingleSubpageModalDriver.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UIDrivers/ScreenSaverController.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UIDrivers/SigInterlock.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UIDrivers/SmartObjectRoomsList.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UIDrivers/SourceChangeArgs.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UIDrivers/VC/EssentialsVideoCodecUiDriver.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UIDrivers/VC/EssentialsVideoCodecUiDriver.cs.orig (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/UIDrivers/enums and base.cs (100%) rename {PepperDashEssentials => src/PepperDashEssentials}/app.config (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase.sln (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/BridgeBase.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/IBridge.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/AirMediaControllerJoinMap.cs (98%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/AppleTvJoinMap.cs (98%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/C2nRthsControllerJoinMap.cs (98%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/CameraControllerJoinMap.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/CenOdtOccupancySensorBaseJoinMap.cs (98%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DigitalLoggerJoinMap.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DisplayControllerJoinMap.cs (98%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmBladeChassisControllerJoinMap.cs (98%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmChassisControllerJoinMap.cs (98%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmRmcControllerJoinMap.cs (98%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmTxControllerJoinMap.cs (98%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsAudioOutputControllerJoinMap.cs (98%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsMicrophoneControllerJoinMap.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsRoutingControllerJoinMap.cs (98%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericIrControllerJoinMap.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericLightingJoinMap.cs (98%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericRelayControllerJoinMap.cs (98%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GlsOccupancySensorBaseJoinMap.cs (98%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GlsPartitionSensorJoinMap.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdMdNxM4kEControllerJoinMap.cs (98%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdMdxxxCEControllerJoinMap.cs (98%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdPsXxxControllerJoinMap.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/Hrxxx0WirelessRemoteControllerJoinMap.cs (98%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IAnalogInputJoinMap.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs (98%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IDigitalInputJoinMap.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IDigitalOutputJoinMap.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IRBlurayBaseJoinMap.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/PduJoinMapBase.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/SetTopBoxControllerJoinMap.cs (98%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/StatusSignControllerJoinMap.cs (98%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/SystemMonitorJoinMap.cs (98%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/VideoCodecControllerJoinMap.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Comm and IR/CecPortController.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Comm and IR/ComPortController.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Comm and IR/ComSpecJsonConverter.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommFactory.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommunicationExtras.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Comm and IR/ConsoleCommMockDevice.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Comm and IR/GenericComm.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Comm and IR/GenericHttpClient.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Comm and IR/IRPortHelper.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Config/BasicConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Config/ConfigPropertiesHelpers.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Config/DeviceConfig.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigReader.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigUpdater.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigWriter.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Config/Essentials/EssentialsConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Config/InfoConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Config/SourceDevicePropertiesConfigBase.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/C2nIo/C2nIoController.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/C2nRts/C2nRthsController.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3CardControllerBase.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Com3Controller.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Io16Controller.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Ir8Controller.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Ry16Controller.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Ry8Controller.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/CenCi31Controller.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/CenCi33Controller.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/InternalCardCageController.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/CenIoCom/CenIoComController.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/DinCenCnController.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/IHasCresnetBranches.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinIo8/DinIo8Controller.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/IOPortConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/CenIoDigIn104Controller.cs (99%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericDigitalInputDevice.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericVersiportAnalogInputDevice.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericVersiportInputDevice.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/IAnalogInput.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/IDigitalInput.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/Ir/CenIoIr104Controller.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/Outputs/GenericVersiportOutputDevice.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/Outputs/IDigitalOutput.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/CenIoRy104Controller.cs (99%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/GenericRelayDevice.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/ISwitchedOutput.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron IO/StatusSign/StatusSignController.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron/CrestronGenericBaseDevice.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Crestron/CrestronGenericBaseDevice.cs.orig (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Device Info/DeviceInfo.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Device Info/DeviceInfoEventArgs.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Device Info/IDeviceInfoProvider.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Device Info/NetworkDeviceHelpers.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/DeviceControlsParentInterfaces/IPresentationSource.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IChannel.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IColorFunctions.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IDPad.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IDiscPlayerControls.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IDisplayBasic.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IDumbSource.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IDvr.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IHasBranding.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IHasFarEndContentStatus.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IHasPhoneDialing.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/ILanguageDefinition.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/ILanguageProvider.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IMobileControl.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/INumeric.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IPasswordPrompt.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IPower.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/ISetTopBoxControls.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/ITransport.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/ITvPresetsProvider.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IUiDisplayInfo.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IWarmingCooling.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/LanguageLabel.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/Template.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/.IHasFeedbacks_BASE_3692.cs.swp (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/.IHasFeedbacks_LOCAL_3692.cs.swp (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/.IHasFeedbacks_REMOTE_3692.cs.swp (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/AudioInterfaces.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/CodecInterfaces.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/CodecInterfaces.cs.orig (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/CrestronProcessor.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/DestinationListItem.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/DeviceApiBase.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/DeviceFeedbackExtensions.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/DeviceJsonApi.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs.orig (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/DisplayUiConstants.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsBridgeableDevice.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/FIND HOMES Interfaces.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/GenericIRController.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/GenericMonitoredTcpDevice.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/IAttachVideoStatusExtensions.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/IDspPreset.cs (94%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/IHasFeedbacks.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/IHasFeedbacks_BACKUP_3692.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/IHasFeedbacks_BASE_3692.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/IHasFeedbacks_LOCAL_3692.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/IHasFeedbacks_REMOTE_3692.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/IProjectorInterfaces.cs (95%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/IReconfigurableDevice.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/IUsageTracking.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/IUsageTracking.cs.orig (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/IVolumeAndAudioInterfaces.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/PC/InRoomPc.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/PC/Laptop.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/PduInterfaces.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/PresentationDeviceType.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/REMOVE IHasFeedbacks.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/ReconfigurableDevice.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/SmartObjectBaseTypes.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/SourceListItem.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Devices/VolumeDeviceChangeEventArgs.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Display/BasicIrDisplay.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Display/MockDisplay.cs (99%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Ethernet/EthernetStatistics.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Extensions/JsonExtensions.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Extensions/StringExtensions.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Factory/IDeviceFactory.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Factory/ReadyEventArgs.cs (95%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Feedbacks/BoolFeedback.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Feedbacks/BoolFeedbackOneShot.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Feedbacks/BoolFeedbackPulseExtender.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Feedbacks/BoolOutputLogicals.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Feedbacks/FeedbackBase.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Feedbacks/FeedbackCollection.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Feedbacks/FeedbackEventArgs.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Feedbacks/IntFeedback.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Feedbacks/SerialFeedback.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Feedbacks/StringFeedback.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/File/FileIO.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceRoomFusionRoomJoinMap.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Fusion/FusionCustomPropertiesBridge.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Fusion/FusionEventHandlers.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Fusion/FusionProcessorQueries.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Fusion/FusionRviDataClasses.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Gateways/CenCn2Controller.cs (95%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Gateways/CenRfgwController.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Gateways/EssentialsRfGatewayConfig.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Global/EthernetAdapterInfo.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Global/Global.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Global/JobTimer.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Global/Scheduler.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/InUseTracking/IInUseTracking.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/InUseTracking/InUseTracking.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Interfaces/ILogStrings.cs (95%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Interfaces/ILogStringsWithLevel.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/License/EssentialsLicenseManager.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Lighting/Lighting Interfaces.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Lighting/LightingBase.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Microphone Privacy/MicrophonePrivacyController.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Microphone Privacy/MicrophonePrivacyControllerConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Monitoring/CrestronGenericBaseCommunicationMonitor.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Monitoring/GenericCommunicationMonitor.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Monitoring/Interfaces.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Monitoring/StatusMonitorBase.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Monitoring/StatusMonitorCollection.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Monitoring/SystemMonitorController.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Occupancy/CenOdtOccupancySensorBaseController.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Occupancy/EssentialsGlsOccupancySensorBaseController.cs.orig (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOccupancySensorBaseController.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOccupancySensorPropertiesConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOdtOccupancySensorController.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOirOccupancySensorController.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Occupancy/IOccupancyStatusProviderAggregator.cs (98%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Occupancy/OccupancyAggregatorConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/PartitionSensor/EssentialsPartitionController.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorController.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorPropertiesConfig.cs (99%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/PartitionSensor/IPartitionStateProvider.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj (98%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj.DotSettings (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.nuspec (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceFactory.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Presets/DevicePresets.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Presets/DevicePresetsView.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Presets/Interfaces.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Presets/PresetBase.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Presets/PresetChannel.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Presets/PresetsListSubpageReferenceListItem.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Properties/AssemblyInfo.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Properties/ControlSystem.cfg (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Queues/ComsMessage.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Queues/GenericQueue.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Queues/IQueue.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Queues/IQueueMessage.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Queues/ProcessStringMessage.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Queues/StringResponseProcessor.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Ramps and Increments/ActionIncrementer.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Ramps and Increments/NumericalHelpers.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Ramps and Increments/UshortSigIncrementer.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Remotes/ButtonExtensions.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Remotes/CrestronRemotePropertiesConfig.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Remotes/Hrxx0WirelessRemoteController.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Room/Behaviours/RoomOnToDefaultSourceWhenOccupied.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Room/Combining/EssentialsRoomCombiner.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Room/Combining/EssentialsRoomCombinerPropertiesConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Room/Combining/IEssentialsRoomCombiner.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Room/Combining/RoomCombinationScenario.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Room/Config/EssentialsRoomScheduledEventsConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Room/EssentialsRoomBase.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Room/IEssentialsRoom.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Room/Interfaces.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Room/Room.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Room/iOccupancyStatusProvider.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Routing/DummyRoutingInputsDevice.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Routing/ICardPortsDevice.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Routing/IRoutingInputsExtensions.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Routing/RoutingPort.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Routing/RoutingPortCollection.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Routing/RoutingPortNames.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Routing/TieLine.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Routing/TieLineConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Secrets/CrestronGlobalSecretsProvider.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Secrets/CrestronLocalSecretsProvider.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Secrets/CrestronSecret.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Secrets/Interfaces.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Secrets/SecretsManager.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Secrets/SecretsPropertiesConfig.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Shades/Shade Interfaces.cs (99%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Shades/ShadeBase.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Shades/ShadeController.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/SigHelper.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/SmartObjects/SmartObjectDPad.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/SmartObjects/SmartObjectDynamicList.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/SmartObjects/SmartObjectHelperBase.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/SmartObjects/SmartObjectNumeric.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/SmartObjects/SubpageReferencList/SourceListSubpageReferenceList.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/SmartObjects/SubpageReferencList/SubpageReferenceList.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/SmartObjects/SubpageReferencList/SubpageReferenceListItem.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Timers/CountdownTimer.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Timers/RetriggerableTimer.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Touchpanels/CrestronTouchpanelPropertiesConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Touchpanels/Interfaces.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Touchpanels/Keyboards/HabaneroKeyboardController.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Touchpanels/ModalDialog.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Touchpanels/TriListExtensions.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/TriListBridges/HandlerBridge.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/UI PageManagers/BlurayPageManager.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/UI PageManagers/PageManager.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/UI PageManagers/SetTopBoxThreePanelPageManager.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/UI PageManagers/SetTopBoxTwoPanelPageManager.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/UI PageManagers/SinglePageManager.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/UI/TouchpanelBase.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Utilities/ActionSequence.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/VideoStatus/VideoStatusOutputs.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Web/EssemtialsWebApi.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Web/EssentialsWebApiFactory.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Web/EssentialsWebApiHelpers.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Web/EssentialsWebApiPropertiesConfig.cs (95%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/AppDebugRequestHandler.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DefaultRequestHandler.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevJsonRequestHandler.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevListRequestHandler.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevPropsRequestHandler.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DisableAllStreamDebugRequestHandler.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetFeedbacksForDeviceRequestHandler.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetJoinMapForBridgeKeyRequestHandler.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetJoinMapForDeviceKeyRequestHandler.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetTypesByFilterRequestHandler.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetTypesRequestHandler.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/ReportVersionsRequestHandler.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/SetDeviceStreamDebugRequestHandler.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/ShowConfigRequestHandler.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Core/PepperDashEssentialsBase/app.config (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM.sln (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/AirMedia/AirMediaPropertiesConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Chassis/._DmChassisController.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Chassis/Config/Schema/DmChassisControllerPropertiesConfigSchema.json (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput.cs.orig (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput_BACKUP_14408.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput_BASE_14408.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput_LOCAL_14408.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput_REMOTE_14408.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Chassis/DmpsAudioOutputController.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Chassis/DmpsDigitalOutputController.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Chassis/DmpsInternalVirtualDmTxController.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Chassis/DmpsMicrophoneController.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Chassis/HdMd8xNController.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Chassis/HdMdNxM4kEBridgeableController.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Chassis/HdMdNxM4kEController.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Chassis/HdPsXxxAnalogAuxMixerController.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Chassis/HdPsXxxOutputAudioController.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Config/DMChassisConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Config/DeviceFactory.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Config/DmRmcConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Config/DmTxConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Config/DmpsRoutingConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Config/HdMdNxM4kEPropertiesConfig.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Config/InputPropertiesConfig.cs (95%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/DmLite/HdMdxxxCEController.cs (99%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/DmPortName.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/DGEs/Dge100Controller.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/DGEs/DgeJoinMap.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/DGEs/DgePropertiesConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/DGEs/DmDge200CController.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/EndpointInterfaces.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Receivers/DmHdBaseTEndpointController.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc100SController.cs (99%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc150SController.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200CController.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200S2Controller.cs (99%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200SController.cs (99%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4KScalerCController.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4k100C1GController.cs (98%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kScalerCDspController.cs (99%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZ100CController.cs (99%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZScalerCController.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs (99%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerCController.cs (99%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerS2Controller.cs (99%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerSController.cs (99%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcX100CController.cs (99%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx200Controller.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx201CController.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx201SController.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx401CController.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k100Controller.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k202CController.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k302CController.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz100Controller.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz202CController.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs (98%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Transmitters/HDBaseTTxController.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Endpoints/Transmitters/TxInterfaces.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Essentials_DM.csproj (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Extensions.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/IDmHdmiInputExtensions.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/IDmSwitch.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj (98%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Properties/AssemblyInfo.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/Properties/ControlSystem.cfg (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/VideoStatusHelpers.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials DM/Essentials_DM/app.config (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common.sln (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Audio/GenericAudioOut.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/AudioCodec/AudioCodecBase.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/AudioCodec/Interfaces/IAudioCodecInfo.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/AudioCodec/Interfaces/IHasAudioCodec.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/AudioCodec/MockAC/MockAC.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/AudioCodec/MockAC/MockAcPropertiesConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Cameras/CameraBase.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Cameras/CameraControl.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Cameras/CameraVisca.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Cameras/IHasCameraPresets.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/ClassDiagram1.cd (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Codec/CodecActiveCallItem.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Codec/CodecActiveCallItem.cs.orig (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Codec/IHasCallHold.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Codec/IHasDoNotDisturb.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Codec/IHasExternalSourceSwitching.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Codec/eCodecCallDirection.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Codec/eCodecCallStatus.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Codec/eCodecCallType.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Codec/eMeetingPrivacy.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Codec/iCodecAudio.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Codec/iHasCallFavorites.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Codec/iHasCallHistory.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Codec/iHasContentSharing.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Codec/iHasDialer.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Codec/iHasDirectory.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Codec/iHasScheduleAwareness.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDsp.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDspLevel.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraFortePropertiesConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/TesiraForteControlPoint.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/TesiraForteMuteControl.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/DSP/DspBase.cs (99%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/DSP/PolycomSoundStructure/SoundStructureBasics.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/DSP/QSC/QscDsp.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/DSP/QSC/QscDspControlPoint.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/DSP/QSC/QscDspDialer.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/DSP/QSC/QscDspLevelControl.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/DSP/QSC/QscDspPropertiesConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/._QscDspPropertiesConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/QscDsp.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/QscDspControlPoint.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/QscDspDialer.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/QscDspLevelControl.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/QscDspPropertiesConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/DiscPlayer/IRDiscPlayerBase.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Display/AvocorVTFDisplay.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Display/ComTcpDisplayBase.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Display/InputInterfaces.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Display/NECPSXMDisplay.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Display/NecPaSeriesProjector.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Display/PanasonicThDisplay.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Environment/Crestron Lighting/Din8sw8.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Environment/Lutron/LutronQuantum.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Environment/Somfy/RelayControlledShade.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj (98%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Generic/GenericSource.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/ImageProcessors/AnalogWay/AnalogWayLiveCorePropertiesConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/ImageProcessors/AnalogWay/AnalongWayLiveCore.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/ImageProcessors/TVOne/TVOneCorio.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/ImageProcessors/TVOne/TVOneCorioPropertiesConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/ImageProcessors/TVOneCorio.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/ImageProcessors/TVOneCorioPropertiesConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Power Controllers/DigitalLoggerPropertiesConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Power Controllers/Digitallogger.cs (99%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Properties/AssemblyInfo.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Properties/ControlSystem.cfg (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/SetTopBox/IRSetTopBoxBase.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/SetTopBox/SetTopBoxPropertiesConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/SoftCodec/BlueJeansPc.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/Streaming/Roku.cs (99%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/BookingsDataClasses.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CallHistoryDataClasses.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCamera.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCodec.cs.orig (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCodecJoinMap.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs.orig (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodecPropertiesConfig.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/HttpApiServer.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/PhonebookDataClasses.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/RoomPresets.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xConfiguration.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xEvent.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xStatus.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xStatusSparkPlus.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/CodecActiveCallItem.cs.orig (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/ConvertiblePreset.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasCodecLayouts.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasCodecSelfview.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasMeetingInfo.cs (99%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasMeetingLock.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasMeetingRecording.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasParticipants.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasPresentationOnlyMeeting.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasSelfviewPosition.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasSelfviewSize.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasStandbyMode.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasStartMeeting.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasVideoCodec.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IJoinCalls.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/iVideoCodecInfo.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockCodecDirectory.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVC.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVC.cs.orig (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVCCamera.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVcPropertiesConfig.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/VideoCodecBase.cs (97%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/VideoCodecBase.cs.orig (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/IZoomWirelessShareInstructions.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ResponseObjects.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoom.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomCamera.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomJoinMap.cs (96%) rename {essentials-framework => src/essentials-framework}/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomPropertiesConfig.cs (98%) rename {essentials-framework => src/essentials-framework}/Essentials Framework.sln (100%) rename {essentials-framework => src/essentials-framework}/Essentials/PepperDashEssentials/Bridges/Bridges.BridgeFactory.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials/PepperDashEssentials/Bridges/EssentialComms.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials/PepperDashEssentials/Bridges/EssentialDM.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials/PepperDashEssentials/Configuration Original/Factories/DmFactory.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials/PepperDashEssentials/ControlSystem.cs (100%) rename {essentials-framework => src/essentials-framework}/Essentials/PepperDashEssentials/PepperDashEssentials.csproj (100%) rename {essentials-framework => src/essentials-framework}/Essentials/PepperDashEssentials/UIDrivers/DualDisplayRouting REMOVE.cs (100%) diff --git a/PepperDashEssentials.3Series.sln b/PepperDashEssentials.3Series.sln index 337d06ea..b52c4c1a 100644 --- a/PepperDashEssentials.3Series.sln +++ b/PepperDashEssentials.3Series.sln @@ -1,21 +1,21 @@  Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PepperDashEssentials", "PepperDashEssentials\PepperDashEssentials.csproj", "{1BED5BA9-88C4-4365-9362-6F4B128071D3}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PepperDashEssentials", "src\PepperDashEssentials\PepperDashEssentials.csproj", "{1BED5BA9-88C4-4365-9362-6F4B128071D3}" ProjectSection(ProjectDependencies) = postProject {892B761C-E479-44CE-BD74-243E9214AF13} = {892B761C-E479-44CE-BD74-243E9214AF13} {9199CE8A-0C9F-4952-8672-3EED798B284F} = {9199CE8A-0C9F-4952-8672-3EED798B284F} {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} = {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PepperDash_Essentials_Core", "essentials-framework\Essentials Core\PepperDashEssentialsBase\PepperDash_Essentials_Core.csproj", "{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PepperDash_Essentials_Core", "src\essentials-framework\Essentials Core\PepperDashEssentialsBase\PepperDash_Essentials_Core.csproj", "{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Essentials Devices Common", "essentials-framework\Essentials Devices Common\Essentials Devices Common\Essentials Devices Common.csproj", "{892B761C-E479-44CE-BD74-243E9214AF13}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Essentials Devices Common", "src\essentials-framework\Essentials Devices Common\Essentials Devices Common\Essentials Devices Common.csproj", "{892B761C-E479-44CE-BD74-243E9214AF13}" ProjectSection(ProjectDependencies) = postProject {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} = {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PepperDash_Essentials_DM", "essentials-framework\Essentials DM\Essentials_DM\PepperDash_Essentials_DM.csproj", "{9199CE8A-0C9F-4952-8672-3EED798B284F}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PepperDash_Essentials_DM", "src\essentials-framework\Essentials DM\Essentials_DM\PepperDash_Essentials_DM.csproj", "{9199CE8A-0C9F-4952-8672-3EED798B284F}" ProjectSection(ProjectDependencies) = postProject {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} = {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} EndProjectSection diff --git a/PepperDashEssentials/Audio/EssentialsVolumeLevelConfig.cs b/src/PepperDashEssentials/Audio/EssentialsVolumeLevelConfig.cs similarity index 100% rename from PepperDashEssentials/Audio/EssentialsVolumeLevelConfig.cs rename to src/PepperDashEssentials/Audio/EssentialsVolumeLevelConfig.cs diff --git a/PepperDashEssentials/Bridges/._EssentialsLightsBridge.cs b/src/PepperDashEssentials/Bridges/._EssentialsLightsBridge.cs similarity index 100% rename from PepperDashEssentials/Bridges/._EssentialsLightsBridge.cs rename to src/PepperDashEssentials/Bridges/._EssentialsLightsBridge.cs diff --git a/PepperDashEssentials/Bridges/AirMediaControllerBridge.cs b/src/PepperDashEssentials/Bridges/AirMediaControllerBridge.cs similarity index 100% rename from PepperDashEssentials/Bridges/AirMediaControllerBridge.cs rename to src/PepperDashEssentials/Bridges/AirMediaControllerBridge.cs diff --git a/PepperDashEssentials/Bridges/AppleTvBridge.cs b/src/PepperDashEssentials/Bridges/AppleTvBridge.cs similarity index 100% rename from PepperDashEssentials/Bridges/AppleTvBridge.cs rename to src/PepperDashEssentials/Bridges/AppleTvBridge.cs diff --git a/PepperDashEssentials/Bridges/BridgeFactory.cs b/src/PepperDashEssentials/Bridges/BridgeFactory.cs similarity index 97% rename from PepperDashEssentials/Bridges/BridgeFactory.cs rename to src/PepperDashEssentials/Bridges/BridgeFactory.cs index c17d4642..f6649eec 100644 --- a/PepperDashEssentials/Bridges/BridgeFactory.cs +++ b/src/PepperDashEssentials/Bridges/BridgeFactory.cs @@ -1,129 +1,129 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Config; -using PepperDash.Core; -using PepperDash.Essentials.Core.Routing; -using PepperDash.Essentials.Bridges; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.EthernetCommunication; - -namespace PepperDash.Essentials -{ - /// - /// Responsible for loading all of the device types for this library - /// - public class BridgeFactory - { - public BridgeFactory() - { - var eiscApiAdvancedFactory = new EiscApiAdvancedFactory() as IDeviceFactory; - eiscApiAdvancedFactory.LoadTypeFactories(); - - var eiscApiFactory = new EiscApiFactory() as IDeviceFactory; - eiscApiFactory.LoadTypeFactories(); - } - - } - - public class CommBridge : Device - { - public CommBridgeProperties Properties { get; private set; } - - public List CommDevices { get; private set; } - - public CommBridge(string key, string name, JToken properties) - : base(key, name) - { - Properties = JsonConvert.DeserializeObject(properties.ToString()); - } - - public override bool CustomActivate() - { - // Create EiscApis - if (Properties.Eiscs != null) - { - foreach (var eisc in Properties.Eiscs) - { - var ApiEisc = new BridgeApiEisc(eisc.IpId, eisc.Hostname); - } - } - - foreach (var deviceKey in Properties.CommDevices) - { - var device = DeviceManager.GetDeviceForKey(deviceKey); - - if (device != null) - { - Debug.Console(0, "deviceKey {0} Found in Device Manager", device.Key); - CommDevices.Add(device as IBasicCommunication); - } - else - { - Debug.Console(0, "deviceKey {0} Not Found in Device Manager", deviceKey); - } - } - - // Iterate through all the CommDevices and link up their Actions and Feedbacks - - Debug.Console(0, "Bridge {0} Activated", this.Name); - - return true; - } - } - - - public class EiscBridgeProperties - { - public string ParentDeviceKey { get; set; } - public eApiType ApiType { get; set; } - public List Eiscs { get; set; } - public string ApiOverrideFilePath { get; set; } - - public class EiscProperties - { - public string IpId { get; set; } - public string Hostname { get; set; } - } - } - - public class CommBridgeProperties : EiscBridgeProperties - { - public List CommDevices { get; set; } - } - - public enum eApiType { Eisc = 0 } - - public class BridgeApiEisc - { - public uint Ipid { get; private set; } - public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc { get; private set; } - - public BridgeApiEisc(string ipid, string hostname) - { - Ipid = (UInt32)int.Parse(ipid, System.Globalization.NumberStyles.HexNumber); - Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(Ipid, hostname, Global.ControlSystem); - Eisc.Register(); - Eisc.SigChange += Eisc_SigChange; - Debug.Console(0, "BridgeApiEisc Created at Ipid {0}", ipid); - } - void Eisc_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args) - { - if (Debug.Level >= 1) - Debug.Console(1, "BridgeApiEisc change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue); - var uo = args.Sig.UserObject; - if (uo is Action) - (uo as Action)(args.Sig.BoolValue); - else if (uo is Action) - (uo as Action)(args.Sig.UShortValue); - else if (uo is Action) - (uo as Action)(args.Sig.StringValue); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Config; +using PepperDash.Core; +using PepperDash.Essentials.Core.Routing; +using PepperDash.Essentials.Bridges; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.EthernetCommunication; + +namespace PepperDash.Essentials +{ + /// + /// Responsible for loading all of the device types for this library + /// + public class BridgeFactory + { + public BridgeFactory() + { + var eiscApiAdvancedFactory = new EiscApiAdvancedFactory() as IDeviceFactory; + eiscApiAdvancedFactory.LoadTypeFactories(); + + var eiscApiFactory = new EiscApiFactory() as IDeviceFactory; + eiscApiFactory.LoadTypeFactories(); + } + + } + + public class CommBridge : Device + { + public CommBridgeProperties Properties { get; private set; } + + public List CommDevices { get; private set; } + + public CommBridge(string key, string name, JToken properties) + : base(key, name) + { + Properties = JsonConvert.DeserializeObject(properties.ToString()); + } + + public override bool CustomActivate() + { + // Create EiscApis + if (Properties.Eiscs != null) + { + foreach (var eisc in Properties.Eiscs) + { + var ApiEisc = new BridgeApiEisc(eisc.IpId, eisc.Hostname); + } + } + + foreach (var deviceKey in Properties.CommDevices) + { + var device = DeviceManager.GetDeviceForKey(deviceKey); + + if (device != null) + { + Debug.Console(0, "deviceKey {0} Found in Device Manager", device.Key); + CommDevices.Add(device as IBasicCommunication); + } + else + { + Debug.Console(0, "deviceKey {0} Not Found in Device Manager", deviceKey); + } + } + + // Iterate through all the CommDevices and link up their Actions and Feedbacks + + Debug.Console(0, "Bridge {0} Activated", this.Name); + + return true; + } + } + + + public class EiscBridgeProperties + { + public string ParentDeviceKey { get; set; } + public eApiType ApiType { get; set; } + public List Eiscs { get; set; } + public string ApiOverrideFilePath { get; set; } + + public class EiscProperties + { + public string IpId { get; set; } + public string Hostname { get; set; } + } + } + + public class CommBridgeProperties : EiscBridgeProperties + { + public List CommDevices { get; set; } + } + + public enum eApiType { Eisc = 0 } + + public class BridgeApiEisc + { + public uint Ipid { get; private set; } + public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc { get; private set; } + + public BridgeApiEisc(string ipid, string hostname) + { + Ipid = (UInt32)int.Parse(ipid, System.Globalization.NumberStyles.HexNumber); + Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(Ipid, hostname, Global.ControlSystem); + Eisc.Register(); + Eisc.SigChange += Eisc_SigChange; + Debug.Console(0, "BridgeApiEisc Created at Ipid {0}", ipid); + } + void Eisc_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args) + { + if (Debug.Level >= 1) + Debug.Console(1, "BridgeApiEisc change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue); + var uo = args.Sig.UserObject; + if (uo is Action) + (uo as Action)(args.Sig.BoolValue); + else if (uo is Action) + (uo as Action)(args.Sig.UShortValue); + else if (uo is Action) + (uo as Action)(args.Sig.StringValue); + } + } +} diff --git a/PepperDashEssentials/Bridges/Bridges.BridgeFactory.cs b/src/PepperDashEssentials/Bridges/Bridges.BridgeFactory.cs similarity index 96% rename from PepperDashEssentials/Bridges/Bridges.BridgeFactory.cs rename to src/PepperDashEssentials/Bridges/Bridges.BridgeFactory.cs index 18dd0c71..d99c25ef 100644 --- a/PepperDashEssentials/Bridges/Bridges.BridgeFactory.cs +++ b/src/PepperDashEssentials/Bridges/Bridges.BridgeFactory.cs @@ -1,90 +1,90 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; -using PepperDash.Core; -using PepperDash.Essentials.Core.Routing; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.EthernetCommunication; -using PepperDash.Essentials.Bridges; - -namespace PepperDash.Essentials { - public class BridgeFactory { - public static IKeyed GetDevice(PepperDash.Essentials.Core.Config.DeviceConfig dc) { - // ? why is this static JTA 2018-06-13? - - var key = dc.Key; - var name = dc.Name; - var type = dc.Type; - var properties = dc.Properties; - var propAnon = new { }; - JsonConvert.DeserializeAnonymousType(dc.Properties.ToString(), propAnon); - - var typeName = dc.Type.ToLower(); - var groupName = dc.Group.ToLower(); - - Debug.Console(2, "Name {0}, Key {1}, Type {2}, Properties {3}", name, key, type, properties.ToString()); - if (typeName == "essentialdm") - { - return new EssentialDM(key, name, properties); - } - else if (typeName == "essentialcomm") - { - Debug.Console(2, "Launch Essential Comm"); - return new EssentialComm(key, name, properties); - } - else if (typeName == "essentialdsp") - { - Debug.Console(2, "Launch EssentialDsp"); - return new EssentialDsp(key, name, properties); - } - else if (typeName == "essentialstvone") - { - Debug.Console(2, "Launch essentialstvone"); - return new EssentialsTVOne(key, name, properties); - } - else if (typeName == "essentialslighting") - { - Debug.Console(2, "Launch essentialslighting"); - return new EssentialsLightsBridge(key, name, properties); - } - else if (typeName == "eiscapi") - { - return new EiscApi(dc); - } - return null; - } - } - public class BridgeApiEisc { - public uint Ipid; - public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc; - public BridgeApiEisc(string ipid) { - Ipid = (UInt32)int.Parse(ipid, System.Globalization.NumberStyles.HexNumber); - Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(Ipid, "127.0.0.2", Global.ControlSystem); - Eisc.Register(); - Eisc.SigChange += Eisc_SigChange; - Debug.Console(2, "BridgeApiEisc Created at Ipid {0}", ipid); - } - void Eisc_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args) { - if (Debug.Level >= 1) - Debug.Console(2, "DDVC EISC change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue); - var uo = args.Sig.UserObject; - if (uo is Action) - (uo as Action)(args.Sig.BoolValue); - else if (uo is Action) - (uo as Action)(args.Sig.UShortValue); - else if (uo is Action) - (uo as Action)(args.Sig.StringValue); - } - } - - } - - - +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; +using PepperDash.Core; +using PepperDash.Essentials.Core.Routing; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.EthernetCommunication; +using PepperDash.Essentials.Bridges; + +namespace PepperDash.Essentials { + public class BridgeFactory { + public static IKeyed GetDevice(PepperDash.Essentials.Core.Config.DeviceConfig dc) { + // ? why is this static JTA 2018-06-13? + + var key = dc.Key; + var name = dc.Name; + var type = dc.Type; + var properties = dc.Properties; + var propAnon = new { }; + JsonConvert.DeserializeAnonymousType(dc.Properties.ToString(), propAnon); + + var typeName = dc.Type.ToLower(); + var groupName = dc.Group.ToLower(); + + Debug.Console(2, "Name {0}, Key {1}, Type {2}, Properties {3}", name, key, type, properties.ToString()); + if (typeName == "essentialdm") + { + return new EssentialDM(key, name, properties); + } + else if (typeName == "essentialcomm") + { + Debug.Console(2, "Launch Essential Comm"); + return new EssentialComm(key, name, properties); + } + else if (typeName == "essentialdsp") + { + Debug.Console(2, "Launch EssentialDsp"); + return new EssentialDsp(key, name, properties); + } + else if (typeName == "essentialstvone") + { + Debug.Console(2, "Launch essentialstvone"); + return new EssentialsTVOne(key, name, properties); + } + else if (typeName == "essentialslighting") + { + Debug.Console(2, "Launch essentialslighting"); + return new EssentialsLightsBridge(key, name, properties); + } + else if (typeName == "eiscapi") + { + return new EiscApi(dc); + } + return null; + } + } + public class BridgeApiEisc { + public uint Ipid; + public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc; + public BridgeApiEisc(string ipid) { + Ipid = (UInt32)int.Parse(ipid, System.Globalization.NumberStyles.HexNumber); + Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(Ipid, "127.0.0.2", Global.ControlSystem); + Eisc.Register(); + Eisc.SigChange += Eisc_SigChange; + Debug.Console(2, "BridgeApiEisc Created at Ipid {0}", ipid); + } + void Eisc_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args) { + if (Debug.Level >= 1) + Debug.Console(2, "DDVC EISC change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue); + var uo = args.Sig.UserObject; + if (uo is Action) + (uo as Action)(args.Sig.BoolValue); + else if (uo is Action) + (uo as Action)(args.Sig.UShortValue); + else if (uo is Action) + (uo as Action)(args.Sig.StringValue); + } + } + + } + + + \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/C2nRthsControllerBridge.cs b/src/PepperDashEssentials/Bridges/C2nRthsControllerBridge.cs similarity index 97% rename from PepperDashEssentials/Bridges/C2nRthsControllerBridge.cs rename to src/PepperDashEssentials/Bridges/C2nRthsControllerBridge.cs index 931ee231..ea67b6ba 100644 --- a/PepperDashEssentials/Bridges/C2nRthsControllerBridge.cs +++ b/src/PepperDashEssentials/Bridges/C2nRthsControllerBridge.cs @@ -1,38 +1,38 @@ -using Crestron.SimplSharpPro.DeviceSupport; -using Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.CrestronIO; - -namespace PepperDash.Essentials.Core.Bridges -{ - public static class C2nRthsControllerApiExtensions - { - public static void LinkToApi(this C2nRthsController device, BasicTriList triList, uint joinStart, - string joinMapKey) - { - var joinMap = new C2nRthsControllerJoinMap(); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - joinMap.OffsetJoinNumbers(joinStart); - - Debug.Console(1, device, "Linking to Trilist '{0}'", triList.ID.ToString("X")); - - - triList.SetBoolSigAction(joinMap.TemperatureFormat, device.SetTemperatureFormat); - - device.IsOnline.LinkInputSig(triList.BooleanInput[joinMap.IsOnline]); - device.TemperatureFeedback.LinkInputSig(triList.UShortInput[joinMap.Temperature]); - device.HumidityFeedback.LinkInputSig(triList.UShortInput[joinMap.Humidity]); - - triList.StringInput[joinMap.Name].StringValue = device.Name; - - - } - - } +using Crestron.SimplSharpPro.DeviceSupport; +using Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.CrestronIO; + +namespace PepperDash.Essentials.Core.Bridges +{ + public static class C2nRthsControllerApiExtensions + { + public static void LinkToApi(this C2nRthsController device, BasicTriList triList, uint joinStart, + string joinMapKey) + { + var joinMap = new C2nRthsControllerJoinMap(); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + joinMap.OffsetJoinNumbers(joinStart); + + Debug.Console(1, device, "Linking to Trilist '{0}'", triList.ID.ToString("X")); + + + triList.SetBoolSigAction(joinMap.TemperatureFormat, device.SetTemperatureFormat); + + device.IsOnline.LinkInputSig(triList.BooleanInput[joinMap.IsOnline]); + device.TemperatureFeedback.LinkInputSig(triList.UShortInput[joinMap.Temperature]); + device.HumidityFeedback.LinkInputSig(triList.UShortInput[joinMap.Humidity]); + + triList.StringInput[joinMap.Name].StringValue = device.Name; + + + } + + } } \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/CameraControllerBridge.cs b/src/PepperDashEssentials/Bridges/CameraControllerBridge.cs similarity index 97% rename from PepperDashEssentials/Bridges/CameraControllerBridge.cs rename to src/PepperDashEssentials/Bridges/CameraControllerBridge.cs index 6a3771d3..b97618c6 100644 --- a/PepperDashEssentials/Bridges/CameraControllerBridge.cs +++ b/src/PepperDashEssentials/Bridges/CameraControllerBridge.cs @@ -1,169 +1,169 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DeviceSupport; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Devices.Common; -using PepperDash.Essentials.Devices.Common.Cameras; - -using Newtonsoft.Json; - -namespace PepperDash.Essentials.Core.Bridges -{ - public static class CameraControllerApiExtensions - { - public static void LinkToApi(this PepperDash.Essentials.Devices.Common.Cameras.CameraBase cameraDevice, BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) - { - CameraControllerJoinMap joinMap = new CameraControllerJoinMap(joinStart); - - // Adds the join map to the bridge - bridge.AddJoinMap(cameraDevice.Key, joinMap); - - var customJoins = JoinMapHelper.TryGetJoinMapAdvancedForDevice(joinMapKey); - - if (customJoins != null) - { - joinMap.SetCustomJoinData(customJoins); - } - - Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - Debug.Console(0, "Linking to Bridge Type {0}", cameraDevice.GetType().Name.ToString()); - - var commMonitor = cameraDevice as ICommunicationMonitor; - commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - - var ptzCamera = cameraDevice as IHasCameraPtzControl; - - if (ptzCamera != null) - { - trilist.SetBoolSigAction(joinMap.PanLeft.JoinNumber, (b) => - { - if (b) - { - ptzCamera.PanLeft(); - } - else - { - ptzCamera.PanStop(); - } - }); - trilist.SetBoolSigAction(joinMap.PanRight.JoinNumber, (b) => - { - if (b) - { - ptzCamera.PanRight(); - } - else - { - ptzCamera.PanStop(); - } - }); - - trilist.SetBoolSigAction(joinMap.TiltUp.JoinNumber, (b) => - { - if (b) - { - ptzCamera.TiltUp(); - } - else - { - ptzCamera.TiltStop(); - } - }); - trilist.SetBoolSigAction(joinMap.TiltDown.JoinNumber, (b) => - { - if (b) - { - ptzCamera.TiltDown(); - } - else - { - ptzCamera.TiltStop(); - } - }); - - trilist.SetBoolSigAction(joinMap.ZoomIn.JoinNumber, (b) => - { - if (b) - { - ptzCamera.ZoomIn(); - } - else - { - ptzCamera.ZoomStop(); - } - }); - - trilist.SetBoolSigAction(joinMap.ZoomOut.JoinNumber, (b) => - { - if (b) - { - ptzCamera.ZoomOut(); - } - else - { - ptzCamera.ZoomStop(); - } - }); - } - - if (cameraDevice is IPower) - { - var powerCamera = cameraDevice as IPower; - trilist.SetSigTrueAction(joinMap.PowerOn.JoinNumber, () => powerCamera.PowerOn()); - trilist.SetSigTrueAction(joinMap.PowerOff.JoinNumber, () => powerCamera.PowerOff()); - - powerCamera.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn.JoinNumber]); - powerCamera.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff.JoinNumber]); - } - - if (cameraDevice is ICommunicationMonitor) - { - var monitoredCamera = cameraDevice as ICommunicationMonitor; - monitoredCamera.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - } - - if (cameraDevice is IHasCameraPresets) - { - // Set the preset lables when they change - var presetsCamera = cameraDevice as IHasCameraPresets; - presetsCamera.PresetsListHasChanged += new EventHandler((o, a) => - { - for (int i = 1; i <= joinMap.NumberOfPresets.JoinNumber; i++) - { - int tempNum = i - 1; - - string label = "" ; - - var preset = presetsCamera.Presets.FirstOrDefault(p => p.ID.Equals(i)); - - if (preset != null) - label = preset.Description; - - trilist.SetString((ushort)(joinMap.PresetLabelStart.JoinNumber + tempNum), label); - } - }); - - for (int i = 0; i < joinMap.NumberOfPresets.JoinNumber; i++) - { - int tempNum = i; - - trilist.SetSigTrueAction((ushort)(joinMap.PresetRecallStart.JoinNumber + tempNum), () => - { - presetsCamera.PresetSelect(tempNum); - }); - trilist.SetSigTrueAction((ushort)(joinMap.PresetSaveStart.JoinNumber + tempNum), () => - { - var label = trilist.GetString((ushort)(joinMap.PresetLabelStart.JoinNumber + tempNum)); - - presetsCamera.PresetStore(tempNum, label); - }); - } - } - } - } - +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DeviceSupport; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Devices.Common; +using PepperDash.Essentials.Devices.Common.Cameras; + +using Newtonsoft.Json; + +namespace PepperDash.Essentials.Core.Bridges +{ + public static class CameraControllerApiExtensions + { + public static void LinkToApi(this PepperDash.Essentials.Devices.Common.Cameras.CameraBase cameraDevice, BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) + { + CameraControllerJoinMap joinMap = new CameraControllerJoinMap(joinStart); + + // Adds the join map to the bridge + bridge.AddJoinMap(cameraDevice.Key, joinMap); + + var customJoins = JoinMapHelper.TryGetJoinMapAdvancedForDevice(joinMapKey); + + if (customJoins != null) + { + joinMap.SetCustomJoinData(customJoins); + } + + Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.Console(0, "Linking to Bridge Type {0}", cameraDevice.GetType().Name.ToString()); + + var commMonitor = cameraDevice as ICommunicationMonitor; + commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + + var ptzCamera = cameraDevice as IHasCameraPtzControl; + + if (ptzCamera != null) + { + trilist.SetBoolSigAction(joinMap.PanLeft.JoinNumber, (b) => + { + if (b) + { + ptzCamera.PanLeft(); + } + else + { + ptzCamera.PanStop(); + } + }); + trilist.SetBoolSigAction(joinMap.PanRight.JoinNumber, (b) => + { + if (b) + { + ptzCamera.PanRight(); + } + else + { + ptzCamera.PanStop(); + } + }); + + trilist.SetBoolSigAction(joinMap.TiltUp.JoinNumber, (b) => + { + if (b) + { + ptzCamera.TiltUp(); + } + else + { + ptzCamera.TiltStop(); + } + }); + trilist.SetBoolSigAction(joinMap.TiltDown.JoinNumber, (b) => + { + if (b) + { + ptzCamera.TiltDown(); + } + else + { + ptzCamera.TiltStop(); + } + }); + + trilist.SetBoolSigAction(joinMap.ZoomIn.JoinNumber, (b) => + { + if (b) + { + ptzCamera.ZoomIn(); + } + else + { + ptzCamera.ZoomStop(); + } + }); + + trilist.SetBoolSigAction(joinMap.ZoomOut.JoinNumber, (b) => + { + if (b) + { + ptzCamera.ZoomOut(); + } + else + { + ptzCamera.ZoomStop(); + } + }); + } + + if (cameraDevice is IPower) + { + var powerCamera = cameraDevice as IPower; + trilist.SetSigTrueAction(joinMap.PowerOn.JoinNumber, () => powerCamera.PowerOn()); + trilist.SetSigTrueAction(joinMap.PowerOff.JoinNumber, () => powerCamera.PowerOff()); + + powerCamera.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn.JoinNumber]); + powerCamera.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff.JoinNumber]); + } + + if (cameraDevice is ICommunicationMonitor) + { + var monitoredCamera = cameraDevice as ICommunicationMonitor; + monitoredCamera.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + } + + if (cameraDevice is IHasCameraPresets) + { + // Set the preset lables when they change + var presetsCamera = cameraDevice as IHasCameraPresets; + presetsCamera.PresetsListHasChanged += new EventHandler((o, a) => + { + for (int i = 1; i <= joinMap.NumberOfPresets.JoinNumber; i++) + { + int tempNum = i - 1; + + string label = "" ; + + var preset = presetsCamera.Presets.FirstOrDefault(p => p.ID.Equals(i)); + + if (preset != null) + label = preset.Description; + + trilist.SetString((ushort)(joinMap.PresetLabelStart.JoinNumber + tempNum), label); + } + }); + + for (int i = 0; i < joinMap.NumberOfPresets.JoinNumber; i++) + { + int tempNum = i; + + trilist.SetSigTrueAction((ushort)(joinMap.PresetRecallStart.JoinNumber + tempNum), () => + { + presetsCamera.PresetSelect(tempNum); + }); + trilist.SetSigTrueAction((ushort)(joinMap.PresetSaveStart.JoinNumber + tempNum), () => + { + var label = trilist.GetString((ushort)(joinMap.PresetLabelStart.JoinNumber + tempNum)); + + presetsCamera.PresetStore(tempNum, label); + }); + } + } + } + } + } \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/DmChassisControllerBridge.cs b/src/PepperDashEssentials/Bridges/DmChassisControllerBridge.cs similarity index 100% rename from PepperDashEssentials/Bridges/DmChassisControllerBridge.cs rename to src/PepperDashEssentials/Bridges/DmChassisControllerBridge.cs diff --git a/PepperDashEssentials/Bridges/DmRmcControllerBridge.cs b/src/PepperDashEssentials/Bridges/DmRmcControllerBridge.cs similarity index 100% rename from PepperDashEssentials/Bridges/DmRmcControllerBridge.cs rename to src/PepperDashEssentials/Bridges/DmRmcControllerBridge.cs diff --git a/PepperDashEssentials/Bridges/DmTxControllerBridge.cs b/src/PepperDashEssentials/Bridges/DmTxControllerBridge.cs similarity index 100% rename from PepperDashEssentials/Bridges/DmTxControllerBridge.cs rename to src/PepperDashEssentials/Bridges/DmTxControllerBridge.cs diff --git a/PepperDashEssentials/Bridges/DmpsAudioOutputControllerBridge.cs b/src/PepperDashEssentials/Bridges/DmpsAudioOutputControllerBridge.cs similarity index 100% rename from PepperDashEssentials/Bridges/DmpsAudioOutputControllerBridge.cs rename to src/PepperDashEssentials/Bridges/DmpsAudioOutputControllerBridge.cs diff --git a/PepperDashEssentials/Bridges/DmpsRoutingControllerBridge.cs b/src/PepperDashEssentials/Bridges/DmpsRoutingControllerBridge.cs similarity index 100% rename from PepperDashEssentials/Bridges/DmpsRoutingControllerBridge.cs rename to src/PepperDashEssentials/Bridges/DmpsRoutingControllerBridge.cs diff --git a/PepperDashEssentials/Bridges/DspControllerBridge.cs b/src/PepperDashEssentials/Bridges/DspControllerBridge.cs similarity index 97% rename from PepperDashEssentials/Bridges/DspControllerBridge.cs rename to src/PepperDashEssentials/Bridges/DspControllerBridge.cs index 9dd018fb..f31828e8 100644 --- a/PepperDashEssentials/Bridges/DspControllerBridge.cs +++ b/src/PepperDashEssentials/Bridges/DspControllerBridge.cs @@ -1,120 +1,120 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DeviceSupport; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Devices.Common; - -namespace PepperDash.Essentials.Bridges -{ - public static class SamsungDisplayControllerApiExtensions - { - public static void LinkToApi(this PepperDash.Essentials.Core.TwoWayDisplayBase displayDevice, BasicTriList trilist, uint joinStart, string joinMapKey) - { - var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as DisplayControllerJoinMap; - - if (joinMap == null) - { - joinMap = new DisplayControllerJoinMap(); - } - - joinMap.OffsetJoinNumbers(joinStart); - Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - Debug.Console(0, "Linking to lighting Type {0}", displayDevice.GetType().Name.ToString()); - - var commMonitor = displayDevice as ICommunicationMonitor; - commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); - - - // Poewer Off - trilist.SetSigTrueAction(joinMap.PowerOff, () => displayDevice.PowerOff()); - displayDevice.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff]); - - // Poewer On - trilist.SetSigTrueAction(joinMap.PowerOn, () => displayDevice.PowerOn()); - displayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn]); - - // GenericLighitng Actions & FeedBack - - // int sceneIndex = 1; - /* - foreach (var scene in displayDevice.LightingScenes) - { - var tempIndex = sceneIndex - 1; - //trilist.SetSigTrueAction((uint)(joinMap.LightingSceneOffset + sceneIndex), () => displayDevice.SelectScene(displayDevice.LightingScenes[tempIndex])); - scene.IsActiveFeedback.LinkInputSig(trilist.BooleanInput[(uint)(joinMap.LightingSceneOffset + sceneIndex)]); - trilist.StringInput[(uint)(joinMap.LightingSceneOffset + sceneIndex)].StringValue = scene.Name; - trilist.BooleanInput[(uint)(joinMap.ButtonVisibilityOffset + sceneIndex)].BoolValue = true; - sceneIndex++; - } - - if (displayDevice.GetType().Name.ToString() == "LutronQuantumArea") - { - var lutronDevice = displayDevice as PepperDash.Essentials.Devices.Common.Environment.Lutron.LutronQuantumArea; - lutronDevice.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); - trilist.SetStringSigAction(joinMap.IntegrationIdSet, s => lutronDevice.IntegrationId = s); - } - */ - //ApiEisc.Eisc.SetStringSigAction(ApiMap.integrationID, (s) => { lutronLights.IntegrationId = s; }); - - - /* - var lutronLights = displayDevice as PepperDash.Essentials.Devices.Common.Environment.Lutron.LutronQuantumArea; - - - for (uint i = 1; i <= lightingBase.CircuitCount; i++) - { - var circuit = i; - lightingBase.CircuitNameFeedbacks[circuit - 1].LinkInputSig(trilist.StringInput[joinMap.CircuitNames + circuit]); - lightingBase.CircuitIsCritical[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitIsCritical + circuit]); - lightingBase.CircuitState[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitState + circuit]); - trilist.SetSigTrueAction(joinMap.CircuitCycle + circuit, () => lightingBase.CycleCircuit(circuit - 1)); - trilist.SetSigTrueAction(joinMap.CircuitOnCmd + circuit, () => lightingBase.TurnOnCircuit(circuit - 1)); - trilist.SetSigTrueAction(joinMap.CircuitOffCmd + circuit, () => lightingBase.TurnOffCircuit(circuit - 1)); - - } - */ - } - } - public class DisplayControllerJoinMap : JoinMapBase - { - public uint IsOnline { get; set; } - public uint PowerOff { get; set; } - public uint PowerOn { get; set; } - public uint SelectScene { get; set; } - public uint LightingSceneOffset { get; set; } - public uint ButtonVisibilityOffset { get; set; } - public uint IntegrationIdSet { get; set; } - - public DisplayControllerJoinMap() - { - // Digital - IsOnline = 1; - PowerOff = 1; - PowerOn = 2; - SelectScene = 1; - IntegrationIdSet = 1; - LightingSceneOffset = 10; - ButtonVisibilityOffset = 40; - // Analog - } - - public override void OffsetJoinNumbers(uint joinStart) - { - var joinOffset = joinStart - 1; - - IsOnline = IsOnline + joinOffset; - PowerOff = PowerOff + joinOffset; - PowerOn = PowerOn + joinOffset; - SelectScene = SelectScene + joinOffset; - LightingSceneOffset = LightingSceneOffset + joinOffset; - ButtonVisibilityOffset = ButtonVisibilityOffset + joinOffset; - - - - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DeviceSupport; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Devices.Common; + +namespace PepperDash.Essentials.Bridges +{ + public static class SamsungDisplayControllerApiExtensions + { + public static void LinkToApi(this PepperDash.Essentials.Core.TwoWayDisplayBase displayDevice, BasicTriList trilist, uint joinStart, string joinMapKey) + { + var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as DisplayControllerJoinMap; + + if (joinMap == null) + { + joinMap = new DisplayControllerJoinMap(); + } + + joinMap.OffsetJoinNumbers(joinStart); + Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.Console(0, "Linking to lighting Type {0}", displayDevice.GetType().Name.ToString()); + + var commMonitor = displayDevice as ICommunicationMonitor; + commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); + + + // Poewer Off + trilist.SetSigTrueAction(joinMap.PowerOff, () => displayDevice.PowerOff()); + displayDevice.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff]); + + // Poewer On + trilist.SetSigTrueAction(joinMap.PowerOn, () => displayDevice.PowerOn()); + displayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn]); + + // GenericLighitng Actions & FeedBack + + // int sceneIndex = 1; + /* + foreach (var scene in displayDevice.LightingScenes) + { + var tempIndex = sceneIndex - 1; + //trilist.SetSigTrueAction((uint)(joinMap.LightingSceneOffset + sceneIndex), () => displayDevice.SelectScene(displayDevice.LightingScenes[tempIndex])); + scene.IsActiveFeedback.LinkInputSig(trilist.BooleanInput[(uint)(joinMap.LightingSceneOffset + sceneIndex)]); + trilist.StringInput[(uint)(joinMap.LightingSceneOffset + sceneIndex)].StringValue = scene.Name; + trilist.BooleanInput[(uint)(joinMap.ButtonVisibilityOffset + sceneIndex)].BoolValue = true; + sceneIndex++; + } + + if (displayDevice.GetType().Name.ToString() == "LutronQuantumArea") + { + var lutronDevice = displayDevice as PepperDash.Essentials.Devices.Common.Environment.Lutron.LutronQuantumArea; + lutronDevice.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); + trilist.SetStringSigAction(joinMap.IntegrationIdSet, s => lutronDevice.IntegrationId = s); + } + */ + //ApiEisc.Eisc.SetStringSigAction(ApiMap.integrationID, (s) => { lutronLights.IntegrationId = s; }); + + + /* + var lutronLights = displayDevice as PepperDash.Essentials.Devices.Common.Environment.Lutron.LutronQuantumArea; + + + for (uint i = 1; i <= lightingBase.CircuitCount; i++) + { + var circuit = i; + lightingBase.CircuitNameFeedbacks[circuit - 1].LinkInputSig(trilist.StringInput[joinMap.CircuitNames + circuit]); + lightingBase.CircuitIsCritical[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitIsCritical + circuit]); + lightingBase.CircuitState[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitState + circuit]); + trilist.SetSigTrueAction(joinMap.CircuitCycle + circuit, () => lightingBase.CycleCircuit(circuit - 1)); + trilist.SetSigTrueAction(joinMap.CircuitOnCmd + circuit, () => lightingBase.TurnOnCircuit(circuit - 1)); + trilist.SetSigTrueAction(joinMap.CircuitOffCmd + circuit, () => lightingBase.TurnOffCircuit(circuit - 1)); + + } + */ + } + } + public class DisplayControllerJoinMap : JoinMapBase + { + public uint IsOnline { get; set; } + public uint PowerOff { get; set; } + public uint PowerOn { get; set; } + public uint SelectScene { get; set; } + public uint LightingSceneOffset { get; set; } + public uint ButtonVisibilityOffset { get; set; } + public uint IntegrationIdSet { get; set; } + + public DisplayControllerJoinMap() + { + // Digital + IsOnline = 1; + PowerOff = 1; + PowerOn = 2; + SelectScene = 1; + IntegrationIdSet = 1; + LightingSceneOffset = 10; + ButtonVisibilityOffset = 40; + // Analog + } + + public override void OffsetJoinNumbers(uint joinStart) + { + var joinOffset = joinStart - 1; + + IsOnline = IsOnline + joinOffset; + PowerOff = PowerOff + joinOffset; + PowerOn = PowerOn + joinOffset; + SelectScene = SelectScene + joinOffset; + LightingSceneOffset = LightingSceneOffset + joinOffset; + ButtonVisibilityOffset = ButtonVisibilityOffset + joinOffset; + + + + } + } } \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/EiscBridge.cs b/src/PepperDashEssentials/Bridges/EiscBridge.cs similarity index 100% rename from PepperDashEssentials/Bridges/EiscBridge.cs rename to src/PepperDashEssentials/Bridges/EiscBridge.cs diff --git a/PepperDashEssentials/Bridges/EssentialComms.cs b/src/PepperDashEssentials/Bridges/EssentialComms.cs similarity index 97% rename from PepperDashEssentials/Bridges/EssentialComms.cs rename to src/PepperDashEssentials/Bridges/EssentialComms.cs index 461715fc..6d038dff 100644 --- a/PepperDashEssentials/Bridges/EssentialComms.cs +++ b/src/PepperDashEssentials/Bridges/EssentialComms.cs @@ -1,144 +1,144 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; -using PepperDash.Core; -using PepperDash.Essentials.Core.Routing; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.EthernetCommunication; -using Crestron.SimplSharpPro.CrestronThread; - -namespace PepperDash.Essentials { - public class EssentialCommConfig { - public string[] EiscApiIpids; - public EssentialCommCommConnectionConfigs[] CommConnections; - } - public class EssentialCommCommConnectionConfigs { - public uint joinNumber {get; set; } - public EssentialsControlPropertiesConfig control { get; set; } - } - - public class EssentialCommsPort { - public IBasicCommunication Comm; - public IntFeedback StatusFeedback; - public BoolFeedback ConnectedFeedback; - public List Outputs = new List(); - public String RxBuffer; - public EssentialCommsPort(EssentialsControlPropertiesConfig config, string keyPrefix) { - Comm = CommFactory.CreateCommForConfig(config, keyPrefix); - // var PortGather = new CommunicationGather(Comm, config.EndOfLineChar); - Comm.TextReceived += new EventHandler(Communication_TextReceived); - - var socket = Comm as ISocketStatus; - StatusFeedback = new IntFeedback(() => { return (int)socket.ClientStatus; }); - ConnectedFeedback = new BoolFeedback(() => { return Comm.IsConnected; }); - - if (socket != null) { - socket.ConnectionChange += new EventHandler(socket_ConnectionChange); - } else { - } - - } - void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e) { - StatusFeedback.FireUpdate(); - ConnectedFeedback.FireUpdate(); - if (e.Client.IsConnected) { - // Tasks on connect - } else { - // Cleanup items from this session - } - } - void Communication_TextReceived(object sender, GenericCommMethodReceiveTextArgs args) { - try { - foreach (var Output in Outputs) { - Output.Api.Eisc.StringInput[Output.Join].StringValue = args.Text; - } - - } - catch (Exception) { - throw new FormatException(string.Format("ERROR:{0}")); - } - } - } - - public class EssentialComm : Device { - public EssentialCommConfig Properties; - - public CommunicationGather PortGather { get; private set; } - public List Apis {get; set;} - public Dictionary CommFeedbacks {get; private set; } - public StatusMonitorBase CommunicationMonitor { get; private set; } - public Dictionary CommDictionary { get; private set; } - - public EssentialComm(string key, string name, JToken properties) : base(key, name) { - Properties = JsonConvert.DeserializeObject(properties.ToString()); - CommFeedbacks = new Dictionary(); - CommDictionary = new Dictionary(); - Apis = new List(); - int commNumber = 1; - foreach (var commConfig in Properties.CommConnections) { - var commPort = new EssentialCommsPort(commConfig.control, string.Format("{0}-{1}", this.Key, commConfig.joinNumber)); - CommDictionary.Add(commConfig.joinNumber, commPort); - - commNumber++; - } - - foreach (var Ipid in Properties.EiscApiIpids) { - var ApiEisc = new BridgeApiEisc(Ipid); - Apis.Add(ApiEisc); - foreach (var commConnection in CommDictionary) { - Debug.Console(2, "Joining Api{0} to comm {1}", Ipid, commConnection.Key); - var tempComm = commConnection.Value; - var tempJoin = (uint)commConnection.Key; - EssentialComApiMap ApiMap = new EssentialComApiMap(ApiEisc, (uint)tempJoin); - - tempComm.Outputs.Add(ApiMap); - // Check for ApiMap Overide Values here - - ApiEisc.Eisc.SetBoolSigAction(tempJoin, b => {if (b) { tempComm.Comm.Connect(); } else { tempComm.Comm.Disconnect(); }}); - ApiEisc.Eisc.SetStringSigAction(tempJoin, s => tempComm.Comm.SendText(s)); - - tempComm.StatusFeedback.LinkInputSig(ApiEisc.Eisc.UShortInput[tempJoin]); - tempComm.ConnectedFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[tempJoin]); - - - - } - ApiEisc.Eisc.Register(); - } - } - - - - public override bool CustomActivate() - { - try { - - - - Debug.Console(2, "Name {0} Activated", this.Name); - return true; - } - catch (Exception e) { - Debug.Console(0, "Bridge {0}", e); - return false; - } - } - - - } - public class EssentialComApiMap { - public uint Join; - public BridgeApiEisc Api; - public uint connectJoin; - public EssentialComApiMap(BridgeApiEisc api, uint join) { - Join = join; - Api = api; - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; +using PepperDash.Core; +using PepperDash.Essentials.Core.Routing; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.EthernetCommunication; +using Crestron.SimplSharpPro.CrestronThread; + +namespace PepperDash.Essentials { + public class EssentialCommConfig { + public string[] EiscApiIpids; + public EssentialCommCommConnectionConfigs[] CommConnections; + } + public class EssentialCommCommConnectionConfigs { + public uint joinNumber {get; set; } + public EssentialsControlPropertiesConfig control { get; set; } + } + + public class EssentialCommsPort { + public IBasicCommunication Comm; + public IntFeedback StatusFeedback; + public BoolFeedback ConnectedFeedback; + public List Outputs = new List(); + public String RxBuffer; + public EssentialCommsPort(EssentialsControlPropertiesConfig config, string keyPrefix) { + Comm = CommFactory.CreateCommForConfig(config, keyPrefix); + // var PortGather = new CommunicationGather(Comm, config.EndOfLineChar); + Comm.TextReceived += new EventHandler(Communication_TextReceived); + + var socket = Comm as ISocketStatus; + StatusFeedback = new IntFeedback(() => { return (int)socket.ClientStatus; }); + ConnectedFeedback = new BoolFeedback(() => { return Comm.IsConnected; }); + + if (socket != null) { + socket.ConnectionChange += new EventHandler(socket_ConnectionChange); + } else { + } + + } + void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e) { + StatusFeedback.FireUpdate(); + ConnectedFeedback.FireUpdate(); + if (e.Client.IsConnected) { + // Tasks on connect + } else { + // Cleanup items from this session + } + } + void Communication_TextReceived(object sender, GenericCommMethodReceiveTextArgs args) { + try { + foreach (var Output in Outputs) { + Output.Api.Eisc.StringInput[Output.Join].StringValue = args.Text; + } + + } + catch (Exception) { + throw new FormatException(string.Format("ERROR:{0}")); + } + } + } + + public class EssentialComm : Device { + public EssentialCommConfig Properties; + + public CommunicationGather PortGather { get; private set; } + public List Apis {get; set;} + public Dictionary CommFeedbacks {get; private set; } + public StatusMonitorBase CommunicationMonitor { get; private set; } + public Dictionary CommDictionary { get; private set; } + + public EssentialComm(string key, string name, JToken properties) : base(key, name) { + Properties = JsonConvert.DeserializeObject(properties.ToString()); + CommFeedbacks = new Dictionary(); + CommDictionary = new Dictionary(); + Apis = new List(); + int commNumber = 1; + foreach (var commConfig in Properties.CommConnections) { + var commPort = new EssentialCommsPort(commConfig.control, string.Format("{0}-{1}", this.Key, commConfig.joinNumber)); + CommDictionary.Add(commConfig.joinNumber, commPort); + + commNumber++; + } + + foreach (var Ipid in Properties.EiscApiIpids) { + var ApiEisc = new BridgeApiEisc(Ipid); + Apis.Add(ApiEisc); + foreach (var commConnection in CommDictionary) { + Debug.Console(2, "Joining Api{0} to comm {1}", Ipid, commConnection.Key); + var tempComm = commConnection.Value; + var tempJoin = (uint)commConnection.Key; + EssentialComApiMap ApiMap = new EssentialComApiMap(ApiEisc, (uint)tempJoin); + + tempComm.Outputs.Add(ApiMap); + // Check for ApiMap Overide Values here + + ApiEisc.Eisc.SetBoolSigAction(tempJoin, b => {if (b) { tempComm.Comm.Connect(); } else { tempComm.Comm.Disconnect(); }}); + ApiEisc.Eisc.SetStringSigAction(tempJoin, s => tempComm.Comm.SendText(s)); + + tempComm.StatusFeedback.LinkInputSig(ApiEisc.Eisc.UShortInput[tempJoin]); + tempComm.ConnectedFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[tempJoin]); + + + + } + ApiEisc.Eisc.Register(); + } + } + + + + public override bool CustomActivate() + { + try { + + + + Debug.Console(2, "Name {0} Activated", this.Name); + return true; + } + catch (Exception e) { + Debug.Console(0, "Bridge {0}", e); + return false; + } + } + + + } + public class EssentialComApiMap { + public uint Join; + public BridgeApiEisc Api; + public uint connectJoin; + public EssentialComApiMap(BridgeApiEisc api, uint join) { + Join = join; + Api = api; + } + } } \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/EssentialDM.cs b/src/PepperDashEssentials/Bridges/EssentialDM.cs similarity index 97% rename from PepperDashEssentials/Bridges/EssentialDM.cs rename to src/PepperDashEssentials/Bridges/EssentialDM.cs index f03f174b..ff753ca6 100644 --- a/PepperDashEssentials/Bridges/EssentialDM.cs +++ b/src/PepperDashEssentials/Bridges/EssentialDM.cs @@ -1,150 +1,150 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.DM; -using PepperDash.Core; -using PepperDash.Essentials.Core.Routing; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.EthernetCommunication; -using Crestron.SimplSharpPro.DM; - -namespace PepperDash.Essentials { - public class EssentialDM : PepperDash.Core.Device { - public EssentialDMProperties Properties; - public List BridgeApiEiscs; - private PepperDash.Essentials.DM.DmChassisController DmSwitch; - private EssentialDMApiMap ApiMap = new EssentialDMApiMap(); - public EssentialDM(string key, string name, JToken properties) - : base(key, name) { - Properties = JsonConvert.DeserializeObject(properties.ToString()); - - - } - public override bool CustomActivate() { - // Create EiscApis - try { - foreach (var device in DeviceManager.AllDevices) { - if (device.Key == this.Properties.connectionDeviceKey) { - Debug.Console(2, "deviceKey {0} Matches", device.Key); - DmSwitch = DeviceManager.GetDeviceForKey(device.Key) as PepperDash.Essentials.DM.DmChassisController; - - } - - - else { - Debug.Console(2, "deviceKey {0} doesn't match", device.Key); - } - } - if (Properties.EiscApiIpids != null) { - - - foreach (string Ipid in Properties.EiscApiIpids) { - var ApiEisc = new BridgeApiEisc(Ipid); - for (uint x = 1; x <= DmSwitch.Chassis.NumberOfInputs;x++ ) { - uint tempX = x; - Debug.Console(2, "Creating EiscActions {0}", tempX); - - - ApiEisc.Eisc.SetUShortSigAction(ApiMap.OutputVideoRoutes[tempX], u => DmSwitch.ExecuteSwitch(u, tempX, eRoutingSignalType.Video)); - ApiEisc.Eisc.SetUShortSigAction(ApiMap.OutputAudioRoutes[tempX], u => DmSwitch.ExecuteSwitch(u, tempX, eRoutingSignalType.Audio)); - - - if (DmSwitch.TxDictionary.ContainsKey(tempX)) { - Debug.Console(2, "Creating Tx Feedbacks {0}", tempX); - var TxKey = DmSwitch.TxDictionary[tempX]; - var TxDevice = DeviceManager.GetDeviceForKey(TxKey) as DmTxControllerBase; - TxDevice.IsOnline.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.TxOnlineStatus[tempX]]); - TxDevice.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.TxVideoSyncStatus[tempX]]); - ApiEisc.Eisc.SetUShortSigAction((ApiMap.HdcpSupport[tempX]), u => TxDevice.SetHdcpSupportAll((ePdtHdcpSupport)(u))); - TxDevice.HdcpSupportAllFeedback.LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.HdcpSupport[tempX]]); - ApiEisc.Eisc.UShortInput[ApiMap.HdcpSupportCapability[tempX]].UShortValue = TxDevice.HdcpSupportCapability; - } - else { - DmSwitch.VideoInputSyncFeedbacks[tempX].LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.TxVideoSyncStatus[tempX]]); - } - if (DmSwitch.RxDictionary.ContainsKey(tempX)) { - Debug.Console(2, "Creating Rx Feedbacks {0}", tempX); - var RxKey = DmSwitch.RxDictionary[tempX]; - var RxDevice = DeviceManager.GetDeviceForKey(RxKey) as DmRmcControllerBase; - RxDevice.IsOnline.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.RxOnlineStatus[tempX]]); - } - // DmSwitch.InputEndpointOnlineFeedbacks[(ushort)tempOutputNum].LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.OutputVideoRoutes[tempOutputNum]]); - DmSwitch.VideoOutputFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.OutputVideoRoutes[tempX]]); - DmSwitch.AudioOutputFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.OutputAudioRoutes[tempX]]); - DmSwitch.InputNameFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.StringInput[ApiMap.InputNames[tempX]]); - DmSwitch.OutputNameFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.StringInput[ApiMap.OutputNames[tempX]]); - DmSwitch.OutputRouteNameFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.StringInput[ApiMap.OutputRouteNames[tempX]]); - } - DmSwitch.IsOnline.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.ChassisOnline]); - ApiEisc.Eisc.Register(); - } - } - - - - Debug.Console(2, "Name {0} Activated", this.Name); - return true; - } - catch (Exception e) { - Debug.Console(2, "BRidge {0}", e); - return false; - } - } - } - public class EssentialDMProperties { - public string connectionDeviceKey; - public string[] EiscApiIpids; - - - } - - - public class EssentialDMApiMap { - public ushort ChassisOnline = 11; - public Dictionary OutputVideoRoutes; - public Dictionary OutputAudioRoutes; - public Dictionary TxOnlineStatus; - public Dictionary RxOnlineStatus; - public Dictionary TxVideoSyncStatus; - public Dictionary InputNames; - public Dictionary OutputNames; - public Dictionary OutputRouteNames; - public Dictionary HdcpSupport; - public Dictionary HdcpSupportCapability; - - public EssentialDMApiMap() { - OutputVideoRoutes = new Dictionary(); - OutputAudioRoutes = new Dictionary(); - TxOnlineStatus = new Dictionary(); - RxOnlineStatus = new Dictionary(); - TxVideoSyncStatus = new Dictionary(); - InputNames = new Dictionary(); - OutputNames = new Dictionary(); - OutputRouteNames = new Dictionary(); - HdcpSupport = new Dictionary(); - HdcpSupportCapability = new Dictionary(); - - for (uint x = 1; x <= 200; x++) { - // Debug.Console(0, "Init Value {0}", x); - uint tempNum = x; - HdcpSupportCapability[tempNum] = (ushort)(tempNum + 1200); - HdcpSupport[tempNum] = (ushort)(tempNum + 1000); - OutputVideoRoutes[tempNum] = (ushort)(tempNum + 100); - OutputAudioRoutes[tempNum] = (ushort)(tempNum + 300); - TxOnlineStatus[tempNum] = (ushort)(tempNum + 500); - RxOnlineStatus[tempNum] = (ushort)(tempNum + 700); - TxVideoSyncStatus[tempNum] = (ushort)(tempNum + 100); - InputNames[tempNum] = (ushort)(tempNum + 100); - OutputNames[tempNum] = (ushort)(tempNum + 300); - OutputRouteNames[tempNum] = (ushort)(tempNum + 2000); - } - } - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.DM; +using PepperDash.Core; +using PepperDash.Essentials.Core.Routing; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.EthernetCommunication; +using Crestron.SimplSharpPro.DM; + +namespace PepperDash.Essentials { + public class EssentialDM : PepperDash.Core.Device { + public EssentialDMProperties Properties; + public List BridgeApiEiscs; + private PepperDash.Essentials.DM.DmChassisController DmSwitch; + private EssentialDMApiMap ApiMap = new EssentialDMApiMap(); + public EssentialDM(string key, string name, JToken properties) + : base(key, name) { + Properties = JsonConvert.DeserializeObject(properties.ToString()); + + + } + public override bool CustomActivate() { + // Create EiscApis + try { + foreach (var device in DeviceManager.AllDevices) { + if (device.Key == this.Properties.connectionDeviceKey) { + Debug.Console(2, "deviceKey {0} Matches", device.Key); + DmSwitch = DeviceManager.GetDeviceForKey(device.Key) as PepperDash.Essentials.DM.DmChassisController; + + } + + + else { + Debug.Console(2, "deviceKey {0} doesn't match", device.Key); + } + } + if (Properties.EiscApiIpids != null) { + + + foreach (string Ipid in Properties.EiscApiIpids) { + var ApiEisc = new BridgeApiEisc(Ipid); + for (uint x = 1; x <= DmSwitch.Chassis.NumberOfInputs;x++ ) { + uint tempX = x; + Debug.Console(2, "Creating EiscActions {0}", tempX); + + + ApiEisc.Eisc.SetUShortSigAction(ApiMap.OutputVideoRoutes[tempX], u => DmSwitch.ExecuteSwitch(u, tempX, eRoutingSignalType.Video)); + ApiEisc.Eisc.SetUShortSigAction(ApiMap.OutputAudioRoutes[tempX], u => DmSwitch.ExecuteSwitch(u, tempX, eRoutingSignalType.Audio)); + + + if (DmSwitch.TxDictionary.ContainsKey(tempX)) { + Debug.Console(2, "Creating Tx Feedbacks {0}", tempX); + var TxKey = DmSwitch.TxDictionary[tempX]; + var TxDevice = DeviceManager.GetDeviceForKey(TxKey) as DmTxControllerBase; + TxDevice.IsOnline.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.TxOnlineStatus[tempX]]); + TxDevice.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.TxVideoSyncStatus[tempX]]); + ApiEisc.Eisc.SetUShortSigAction((ApiMap.HdcpSupport[tempX]), u => TxDevice.SetHdcpSupportAll((ePdtHdcpSupport)(u))); + TxDevice.HdcpSupportAllFeedback.LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.HdcpSupport[tempX]]); + ApiEisc.Eisc.UShortInput[ApiMap.HdcpSupportCapability[tempX]].UShortValue = TxDevice.HdcpSupportCapability; + } + else { + DmSwitch.VideoInputSyncFeedbacks[tempX].LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.TxVideoSyncStatus[tempX]]); + } + if (DmSwitch.RxDictionary.ContainsKey(tempX)) { + Debug.Console(2, "Creating Rx Feedbacks {0}", tempX); + var RxKey = DmSwitch.RxDictionary[tempX]; + var RxDevice = DeviceManager.GetDeviceForKey(RxKey) as DmRmcControllerBase; + RxDevice.IsOnline.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.RxOnlineStatus[tempX]]); + } + // DmSwitch.InputEndpointOnlineFeedbacks[(ushort)tempOutputNum].LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.OutputVideoRoutes[tempOutputNum]]); + DmSwitch.VideoOutputFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.OutputVideoRoutes[tempX]]); + DmSwitch.AudioOutputFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.OutputAudioRoutes[tempX]]); + DmSwitch.InputNameFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.StringInput[ApiMap.InputNames[tempX]]); + DmSwitch.OutputNameFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.StringInput[ApiMap.OutputNames[tempX]]); + DmSwitch.OutputRouteNameFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.StringInput[ApiMap.OutputRouteNames[tempX]]); + } + DmSwitch.IsOnline.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.ChassisOnline]); + ApiEisc.Eisc.Register(); + } + } + + + + Debug.Console(2, "Name {0} Activated", this.Name); + return true; + } + catch (Exception e) { + Debug.Console(2, "BRidge {0}", e); + return false; + } + } + } + public class EssentialDMProperties { + public string connectionDeviceKey; + public string[] EiscApiIpids; + + + } + + + public class EssentialDMApiMap { + public ushort ChassisOnline = 11; + public Dictionary OutputVideoRoutes; + public Dictionary OutputAudioRoutes; + public Dictionary TxOnlineStatus; + public Dictionary RxOnlineStatus; + public Dictionary TxVideoSyncStatus; + public Dictionary InputNames; + public Dictionary OutputNames; + public Dictionary OutputRouteNames; + public Dictionary HdcpSupport; + public Dictionary HdcpSupportCapability; + + public EssentialDMApiMap() { + OutputVideoRoutes = new Dictionary(); + OutputAudioRoutes = new Dictionary(); + TxOnlineStatus = new Dictionary(); + RxOnlineStatus = new Dictionary(); + TxVideoSyncStatus = new Dictionary(); + InputNames = new Dictionary(); + OutputNames = new Dictionary(); + OutputRouteNames = new Dictionary(); + HdcpSupport = new Dictionary(); + HdcpSupportCapability = new Dictionary(); + + for (uint x = 1; x <= 200; x++) { + // Debug.Console(0, "Init Value {0}", x); + uint tempNum = x; + HdcpSupportCapability[tempNum] = (ushort)(tempNum + 1200); + HdcpSupport[tempNum] = (ushort)(tempNum + 1000); + OutputVideoRoutes[tempNum] = (ushort)(tempNum + 100); + OutputAudioRoutes[tempNum] = (ushort)(tempNum + 300); + TxOnlineStatus[tempNum] = (ushort)(tempNum + 500); + RxOnlineStatus[tempNum] = (ushort)(tempNum + 700); + TxVideoSyncStatus[tempNum] = (ushort)(tempNum + 100); + InputNames[tempNum] = (ushort)(tempNum + 100); + OutputNames[tempNum] = (ushort)(tempNum + 300); + OutputRouteNames[tempNum] = (ushort)(tempNum + 2000); + } + } + } + } \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/EssentialDsp.cs b/src/PepperDashEssentials/Bridges/EssentialDsp.cs similarity index 97% rename from PepperDashEssentials/Bridges/EssentialDsp.cs rename to src/PepperDashEssentials/Bridges/EssentialDsp.cs index d8aed442..223aa34c 100644 --- a/PepperDashEssentials/Bridges/EssentialDsp.cs +++ b/src/PepperDashEssentials/Bridges/EssentialDsp.cs @@ -1,217 +1,217 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.DM; -using PepperDash.Core; -using PepperDash.Essentials.Core.Routing; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.EthernetCommunication; -using Crestron.SimplSharpPro.DM; - -namespace PepperDash.Essentials { - public class EssentialDsp : PepperDash.Core.Device { - public EssentialDspProperties Properties; - public List BridgeApiEiscs; - private PepperDash.Essentials.Devices.Common.DSP.QscDsp Dsp; - private EssentialDspApiMap ApiMap = new EssentialDspApiMap(); - public EssentialDsp(string key, string name, JToken properties) - : base(key, name) { - Properties = JsonConvert.DeserializeObject(properties.ToString()); - - - } - public override bool CustomActivate() { - // Create EiscApis - - try - { - ICommunicationMonitor comm = null; - foreach (var device in DeviceManager.AllDevices) - { - if (device.Key == this.Properties.connectionDeviceKey) - { - if (!(device is ICommunicationMonitor)) - { - comm = device as ICommunicationMonitor; - } - Debug.Console(2, "deviceKey {0} Matches", device.Key); - Dsp = DeviceManager.GetDeviceForKey(device.Key) as PepperDash.Essentials.Devices.Common.DSP.QscDsp; - break; - } - else - { - Debug.Console(2, "deviceKey {0} doesn't match", device.Key); - - } - } - if (Properties.EiscApiIpids != null && Dsp != null) - { - foreach (string Ipid in Properties.EiscApiIpids) - { - var ApiEisc = new BridgeApiEisc(Ipid); - Debug.Console(2, "Connecting EiscApi {0} to {1}", ApiEisc.Ipid, Dsp.Name); - ushort x = 1; - if (comm != null) - { - comm.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.Online]); - } - foreach (var channel in Dsp.LevelControlPoints) - { - //var QscChannel = channel.Value as PepperDash.Essentials.Devices.Common.DSP.QscDspLevelControl; - Debug.Console(2, "QscChannel {0} connect", x); - - var genericChannel = channel.Value as IBasicVolumeWithFeedback; - if (channel.Value.Enabled) - { - ApiEisc.Eisc.StringInput[ApiMap.channelName[x]].StringValue = channel.Value.LevelCustomName; - ApiEisc.Eisc.UShortInput[ApiMap.channelType[x]].UShortValue = (ushort)channel.Value.Type; - - genericChannel.MuteFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.channelMuteToggle[x]]); - genericChannel.VolumeLevelFeedback.LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.channelVolume[x]]); - - ApiEisc.Eisc.SetSigTrueAction(ApiMap.channelMuteToggle[x], () => genericChannel.MuteToggle()); - ApiEisc.Eisc.SetSigTrueAction(ApiMap.channelMuteOn[x], () => genericChannel.MuteOn()); - ApiEisc.Eisc.SetSigTrueAction(ApiMap.channelMuteOff[x], () => genericChannel.MuteOff()); - - ApiEisc.Eisc.SetBoolSigAction(ApiMap.channelVolumeUp[x], b => genericChannel.VolumeUp(b)); - ApiEisc.Eisc.SetBoolSigAction(ApiMap.channelVolumeDown[x], b => genericChannel.VolumeDown(b)); - - ApiEisc.Eisc.SetUShortSigAction(ApiMap.channelVolume[x], u => genericChannel.SetVolume(u)); - ApiEisc.Eisc.SetStringSigAction(ApiMap.presetString, s => Dsp.RunPreset(s)); - } - x++; - - } - x = 1; - foreach (var preset in Dsp.PresetList) - { - ApiEisc.Eisc.StringInput[ApiMap.presets[x]].StringValue = preset.label; - ApiEisc.Eisc.SetSigTrueAction(ApiMap.presets[x], () => Dsp.RunPresetNumber(x)); - x++; - } - foreach (var dialer in Dsp.Dialers) - { - ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad0, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num0)); - ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad1, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num1)); - ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad2, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num2)); - ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad3, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num3)); - ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad4, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num4)); - ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad5, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num5)); - ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad6, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num6)); - ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad7, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num7)); - ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad8, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num8)); - ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad9, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num9)); - ApiEisc.Eisc.SetSigTrueAction(ApiMap.KeypadStar, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Star)); - ApiEisc.Eisc.SetSigTrueAction(ApiMap.KeypadPound, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Pound)); - ApiEisc.Eisc.SetSigTrueAction(ApiMap.KeypadClear, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Clear)); - ApiEisc.Eisc.SetSigTrueAction(ApiMap.KeypadBackspace, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Backspace)); - - ApiEisc.Eisc.SetSigTrueAction(ApiMap.Dial, () => dialer.Value.Dial()); - ApiEisc.Eisc.SetSigTrueAction(ApiMap.DoNotDisturbToggle, () => dialer.Value.DoNotDisturbToggle()); - ApiEisc.Eisc.SetSigTrueAction(ApiMap.DoNotDisturbOn, () => dialer.Value.DoNotDisturbOn()); - ApiEisc.Eisc.SetSigTrueAction(ApiMap.DoNotDisturbOff, () => dialer.Value.DoNotDisturbOff()); - ApiEisc.Eisc.SetSigTrueAction(ApiMap.AutoAnswerToggle, () => dialer.Value.AutoAnswerToggle()); - ApiEisc.Eisc.SetSigTrueAction(ApiMap.AutoAnswerOn, () => dialer.Value.AutoAnswerOn()); - ApiEisc.Eisc.SetSigTrueAction(ApiMap.AutoAnswerOff, () => dialer.Value.AutoAnswerOff()); - - dialer.Value.DoNotDisturbFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.DoNotDisturbToggle]); - dialer.Value.DoNotDisturbFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.DoNotDisturbOn]); - dialer.Value.DoNotDisturbFeedback.LinkComplementInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.DoNotDisturbOff]); - - dialer.Value.AutoAnswerFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.AutoAnswerToggle]); - dialer.Value.AutoAnswerFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.AutoAnswerOn]); - dialer.Value.AutoAnswerFeedback.LinkComplementInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.AutoAnswerOff]); - - dialer.Value.OffHookFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.Dial]); - dialer.Value.DialStringFeedback.LinkInputSig(ApiEisc.Eisc.StringInput[ApiMap.DialString]); - } - } - } - - - - - Debug.Console(2, "Name {0} Activated", this.Name); - return true; - } - catch (Exception e) { - Debug.Console(0, "Bridge {0}", e); - return false; - } - } - } - public class EssentialDspProperties { - public string connectionDeviceKey; - public string[] EiscApiIpids; - - - } - - - public class EssentialDspApiMap { - public ushort Online = 1; - public ushort presetString = 2000; - public Dictionary channelMuteToggle; - public Dictionary channelMuteOn; - public Dictionary channelMuteOff; - public Dictionary channelVolume; - public Dictionary channelType; - public Dictionary channelName; - public Dictionary channelVolumeUp; - public Dictionary channelVolumeDown; - public Dictionary presets; - public ushort DialString = 3100; - public ushort Keypad0 = 3110; - public ushort Keypad1 = 3111; - public ushort Keypad2 = 3112; - public ushort Keypad3 = 3113; - public ushort Keypad4 = 3114; - public ushort Keypad5 = 3115; - public ushort Keypad6 = 3116; - public ushort Keypad7 = 3117; - public ushort Keypad8 = 3118; - public ushort Keypad9 = 3119; - public ushort KeypadStar = 3120; - public ushort KeypadPound = 3121; - public ushort KeypadClear = 3122; - public ushort KeypadBackspace = 3123; - public ushort Dial = 3124; - public ushort DoNotDisturbToggle = 3132; - public ushort DoNotDisturbOn = 3133; - public ushort DoNotDisturbOff = 3134; - public ushort AutoAnswerToggle = 3127; - public ushort AutoAnswerOn = 3125; - public ushort AutoAnswerOff = 3126; - - public EssentialDspApiMap() { - channelMuteToggle = new Dictionary(); - channelMuteOn = new Dictionary(); - channelMuteOff = new Dictionary(); - channelVolume = new Dictionary(); - channelName = new Dictionary(); - channelType = new Dictionary(); - presets = new Dictionary(); - channelVolumeUp = new Dictionary(); - channelVolumeDown = new Dictionary(); - for (uint x = 1; x <= 100; x++) { - uint tempNum = x; - presets[tempNum] = (ushort)(tempNum + 100); - channelMuteToggle[tempNum] = (ushort)(tempNum + 400); - channelMuteOn[tempNum] = (ushort)(tempNum + 600); - channelMuteOff[tempNum] = (ushort)(tempNum + 800); - channelVolume[tempNum] = (ushort)(tempNum + 200); - channelName[tempNum] = (ushort)(tempNum + 200); - channelType[tempNum] = (ushort)(tempNum + 400); - channelVolumeUp[tempNum] = (ushort)(tempNum + 1000); - channelVolumeDown[tempNum] = (ushort)(tempNum + 1200); - } - } - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.DM; +using PepperDash.Core; +using PepperDash.Essentials.Core.Routing; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.EthernetCommunication; +using Crestron.SimplSharpPro.DM; + +namespace PepperDash.Essentials { + public class EssentialDsp : PepperDash.Core.Device { + public EssentialDspProperties Properties; + public List BridgeApiEiscs; + private PepperDash.Essentials.Devices.Common.DSP.QscDsp Dsp; + private EssentialDspApiMap ApiMap = new EssentialDspApiMap(); + public EssentialDsp(string key, string name, JToken properties) + : base(key, name) { + Properties = JsonConvert.DeserializeObject(properties.ToString()); + + + } + public override bool CustomActivate() { + // Create EiscApis + + try + { + ICommunicationMonitor comm = null; + foreach (var device in DeviceManager.AllDevices) + { + if (device.Key == this.Properties.connectionDeviceKey) + { + if (!(device is ICommunicationMonitor)) + { + comm = device as ICommunicationMonitor; + } + Debug.Console(2, "deviceKey {0} Matches", device.Key); + Dsp = DeviceManager.GetDeviceForKey(device.Key) as PepperDash.Essentials.Devices.Common.DSP.QscDsp; + break; + } + else + { + Debug.Console(2, "deviceKey {0} doesn't match", device.Key); + + } + } + if (Properties.EiscApiIpids != null && Dsp != null) + { + foreach (string Ipid in Properties.EiscApiIpids) + { + var ApiEisc = new BridgeApiEisc(Ipid); + Debug.Console(2, "Connecting EiscApi {0} to {1}", ApiEisc.Ipid, Dsp.Name); + ushort x = 1; + if (comm != null) + { + comm.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.Online]); + } + foreach (var channel in Dsp.LevelControlPoints) + { + //var QscChannel = channel.Value as PepperDash.Essentials.Devices.Common.DSP.QscDspLevelControl; + Debug.Console(2, "QscChannel {0} connect", x); + + var genericChannel = channel.Value as IBasicVolumeWithFeedback; + if (channel.Value.Enabled) + { + ApiEisc.Eisc.StringInput[ApiMap.channelName[x]].StringValue = channel.Value.LevelCustomName; + ApiEisc.Eisc.UShortInput[ApiMap.channelType[x]].UShortValue = (ushort)channel.Value.Type; + + genericChannel.MuteFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.channelMuteToggle[x]]); + genericChannel.VolumeLevelFeedback.LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.channelVolume[x]]); + + ApiEisc.Eisc.SetSigTrueAction(ApiMap.channelMuteToggle[x], () => genericChannel.MuteToggle()); + ApiEisc.Eisc.SetSigTrueAction(ApiMap.channelMuteOn[x], () => genericChannel.MuteOn()); + ApiEisc.Eisc.SetSigTrueAction(ApiMap.channelMuteOff[x], () => genericChannel.MuteOff()); + + ApiEisc.Eisc.SetBoolSigAction(ApiMap.channelVolumeUp[x], b => genericChannel.VolumeUp(b)); + ApiEisc.Eisc.SetBoolSigAction(ApiMap.channelVolumeDown[x], b => genericChannel.VolumeDown(b)); + + ApiEisc.Eisc.SetUShortSigAction(ApiMap.channelVolume[x], u => genericChannel.SetVolume(u)); + ApiEisc.Eisc.SetStringSigAction(ApiMap.presetString, s => Dsp.RunPreset(s)); + } + x++; + + } + x = 1; + foreach (var preset in Dsp.PresetList) + { + ApiEisc.Eisc.StringInput[ApiMap.presets[x]].StringValue = preset.label; + ApiEisc.Eisc.SetSigTrueAction(ApiMap.presets[x], () => Dsp.RunPresetNumber(x)); + x++; + } + foreach (var dialer in Dsp.Dialers) + { + ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad0, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num0)); + ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad1, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num1)); + ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad2, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num2)); + ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad3, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num3)); + ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad4, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num4)); + ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad5, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num5)); + ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad6, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num6)); + ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad7, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num7)); + ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad8, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num8)); + ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad9, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num9)); + ApiEisc.Eisc.SetSigTrueAction(ApiMap.KeypadStar, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Star)); + ApiEisc.Eisc.SetSigTrueAction(ApiMap.KeypadPound, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Pound)); + ApiEisc.Eisc.SetSigTrueAction(ApiMap.KeypadClear, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Clear)); + ApiEisc.Eisc.SetSigTrueAction(ApiMap.KeypadBackspace, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Backspace)); + + ApiEisc.Eisc.SetSigTrueAction(ApiMap.Dial, () => dialer.Value.Dial()); + ApiEisc.Eisc.SetSigTrueAction(ApiMap.DoNotDisturbToggle, () => dialer.Value.DoNotDisturbToggle()); + ApiEisc.Eisc.SetSigTrueAction(ApiMap.DoNotDisturbOn, () => dialer.Value.DoNotDisturbOn()); + ApiEisc.Eisc.SetSigTrueAction(ApiMap.DoNotDisturbOff, () => dialer.Value.DoNotDisturbOff()); + ApiEisc.Eisc.SetSigTrueAction(ApiMap.AutoAnswerToggle, () => dialer.Value.AutoAnswerToggle()); + ApiEisc.Eisc.SetSigTrueAction(ApiMap.AutoAnswerOn, () => dialer.Value.AutoAnswerOn()); + ApiEisc.Eisc.SetSigTrueAction(ApiMap.AutoAnswerOff, () => dialer.Value.AutoAnswerOff()); + + dialer.Value.DoNotDisturbFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.DoNotDisturbToggle]); + dialer.Value.DoNotDisturbFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.DoNotDisturbOn]); + dialer.Value.DoNotDisturbFeedback.LinkComplementInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.DoNotDisturbOff]); + + dialer.Value.AutoAnswerFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.AutoAnswerToggle]); + dialer.Value.AutoAnswerFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.AutoAnswerOn]); + dialer.Value.AutoAnswerFeedback.LinkComplementInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.AutoAnswerOff]); + + dialer.Value.OffHookFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.Dial]); + dialer.Value.DialStringFeedback.LinkInputSig(ApiEisc.Eisc.StringInput[ApiMap.DialString]); + } + } + } + + + + + Debug.Console(2, "Name {0} Activated", this.Name); + return true; + } + catch (Exception e) { + Debug.Console(0, "Bridge {0}", e); + return false; + } + } + } + public class EssentialDspProperties { + public string connectionDeviceKey; + public string[] EiscApiIpids; + + + } + + + public class EssentialDspApiMap { + public ushort Online = 1; + public ushort presetString = 2000; + public Dictionary channelMuteToggle; + public Dictionary channelMuteOn; + public Dictionary channelMuteOff; + public Dictionary channelVolume; + public Dictionary channelType; + public Dictionary channelName; + public Dictionary channelVolumeUp; + public Dictionary channelVolumeDown; + public Dictionary presets; + public ushort DialString = 3100; + public ushort Keypad0 = 3110; + public ushort Keypad1 = 3111; + public ushort Keypad2 = 3112; + public ushort Keypad3 = 3113; + public ushort Keypad4 = 3114; + public ushort Keypad5 = 3115; + public ushort Keypad6 = 3116; + public ushort Keypad7 = 3117; + public ushort Keypad8 = 3118; + public ushort Keypad9 = 3119; + public ushort KeypadStar = 3120; + public ushort KeypadPound = 3121; + public ushort KeypadClear = 3122; + public ushort KeypadBackspace = 3123; + public ushort Dial = 3124; + public ushort DoNotDisturbToggle = 3132; + public ushort DoNotDisturbOn = 3133; + public ushort DoNotDisturbOff = 3134; + public ushort AutoAnswerToggle = 3127; + public ushort AutoAnswerOn = 3125; + public ushort AutoAnswerOff = 3126; + + public EssentialDspApiMap() { + channelMuteToggle = new Dictionary(); + channelMuteOn = new Dictionary(); + channelMuteOff = new Dictionary(); + channelVolume = new Dictionary(); + channelName = new Dictionary(); + channelType = new Dictionary(); + presets = new Dictionary(); + channelVolumeUp = new Dictionary(); + channelVolumeDown = new Dictionary(); + for (uint x = 1; x <= 100; x++) { + uint tempNum = x; + presets[tempNum] = (ushort)(tempNum + 100); + channelMuteToggle[tempNum] = (ushort)(tempNum + 400); + channelMuteOn[tempNum] = (ushort)(tempNum + 600); + channelMuteOff[tempNum] = (ushort)(tempNum + 800); + channelVolume[tempNum] = (ushort)(tempNum + 200); + channelName[tempNum] = (ushort)(tempNum + 200); + channelType[tempNum] = (ushort)(tempNum + 400); + channelVolumeUp[tempNum] = (ushort)(tempNum + 1000); + channelVolumeDown[tempNum] = (ushort)(tempNum + 1200); + } + } + } + } \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/EssentialTVOne.cs b/src/PepperDashEssentials/Bridges/EssentialTVOne.cs similarity index 96% rename from PepperDashEssentials/Bridges/EssentialTVOne.cs rename to src/PepperDashEssentials/Bridges/EssentialTVOne.cs index 12fb0c49..494e145d 100644 --- a/PepperDashEssentials/Bridges/EssentialTVOne.cs +++ b/src/PepperDashEssentials/Bridges/EssentialTVOne.cs @@ -1,98 +1,98 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.DM; -using PepperDash.Core; -using PepperDash.Essentials.Core.Routing; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.EthernetCommunication; -using Crestron.SimplSharpPro.DM; - -namespace PepperDash.Essentials -{ - public class EssentialsTVOne : PepperDash.Core.Device - { - public EssentialTVOneProperties Properties; - public List BridgeApiEiscs; - private PepperDash.Essentials.Devices.Common.TVOneCorio TVOneCorio; - private EssentialsTVOneApiMap ApiMap = new EssentialsTVOneApiMap(); - public EssentialsTVOne(string key, string name, JToken properties) - : base(key, name) - { - Properties = JsonConvert.DeserializeObject(properties.ToString()); - - - } - public override bool CustomActivate() { - // Create EiscApis - try - { - foreach (var device in DeviceManager.AllDevices) - { - if (device.Key == this.Properties.connectionDeviceKey) - { - Debug.Console(2, "deviceKey {0} Matches", device.Key); - TVOneCorio = DeviceManager.GetDeviceForKey(device.Key) as PepperDash.Essentials.Devices.Common.TVOneCorio; - break; - } - else - { - Debug.Console(2, "deviceKey {0} doesn't match", device.Key); - - } - } - if (Properties.EiscApiIpids != null && TVOneCorio != null) - { - foreach (string Ipid in Properties.EiscApiIpids) - { - var ApiEisc = new BridgeApiEisc(Ipid); - Debug.Console(2, "Connecting EiscApi {0} to {1}", ApiEisc.Ipid, TVOneCorio.Name); - ushort x = 1; - TVOneCorio.OnlineFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.Online]); - ApiEisc.Eisc.SetUShortSigAction(ApiMap.CallPreset, u => TVOneCorio.CallPreset(u)); - TVOneCorio.PresetFeedback.LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.PresetFeedback]); - - } - } - - - - - Debug.Console(2, "Name {0} Activated", this.Name); - return true; - } - catch (Exception e) { - Debug.Console(0, "Bridge {0}", e); - return false; - } - } - } - public class EssentialTVOneProperties - { - public string connectionDeviceKey; - public string[] EiscApiIpids; - - - } - - - public class EssentialsTVOneApiMap - { - public ushort CallPreset = 1; - public ushort PresetFeedback = 1; - public ushort Online = 1; - - public EssentialsTVOneApiMap() - { - - - } - - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.DM; +using PepperDash.Core; +using PepperDash.Essentials.Core.Routing; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.EthernetCommunication; +using Crestron.SimplSharpPro.DM; + +namespace PepperDash.Essentials +{ + public class EssentialsTVOne : PepperDash.Core.Device + { + public EssentialTVOneProperties Properties; + public List BridgeApiEiscs; + private PepperDash.Essentials.Devices.Common.TVOneCorio TVOneCorio; + private EssentialsTVOneApiMap ApiMap = new EssentialsTVOneApiMap(); + public EssentialsTVOne(string key, string name, JToken properties) + : base(key, name) + { + Properties = JsonConvert.DeserializeObject(properties.ToString()); + + + } + public override bool CustomActivate() { + // Create EiscApis + try + { + foreach (var device in DeviceManager.AllDevices) + { + if (device.Key == this.Properties.connectionDeviceKey) + { + Debug.Console(2, "deviceKey {0} Matches", device.Key); + TVOneCorio = DeviceManager.GetDeviceForKey(device.Key) as PepperDash.Essentials.Devices.Common.TVOneCorio; + break; + } + else + { + Debug.Console(2, "deviceKey {0} doesn't match", device.Key); + + } + } + if (Properties.EiscApiIpids != null && TVOneCorio != null) + { + foreach (string Ipid in Properties.EiscApiIpids) + { + var ApiEisc = new BridgeApiEisc(Ipid); + Debug.Console(2, "Connecting EiscApi {0} to {1}", ApiEisc.Ipid, TVOneCorio.Name); + ushort x = 1; + TVOneCorio.OnlineFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.Online]); + ApiEisc.Eisc.SetUShortSigAction(ApiMap.CallPreset, u => TVOneCorio.CallPreset(u)); + TVOneCorio.PresetFeedback.LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.PresetFeedback]); + + } + } + + + + + Debug.Console(2, "Name {0} Activated", this.Name); + return true; + } + catch (Exception e) { + Debug.Console(0, "Bridge {0}", e); + return false; + } + } + } + public class EssentialTVOneProperties + { + public string connectionDeviceKey; + public string[] EiscApiIpids; + + + } + + + public class EssentialsTVOneApiMap + { + public ushort CallPreset = 1; + public ushort PresetFeedback = 1; + public ushort Online = 1; + + public EssentialsTVOneApiMap() + { + + + } + + } } \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/GenericLightingBridge.cs b/src/PepperDashEssentials/Bridges/GenericLightingBridge.cs similarity index 98% rename from PepperDashEssentials/Bridges/GenericLightingBridge.cs rename to src/PepperDashEssentials/Bridges/GenericLightingBridge.cs index 5365b813..65331a65 100644 --- a/PepperDashEssentials/Bridges/GenericLightingBridge.cs +++ b/src/PepperDashEssentials/Bridges/GenericLightingBridge.cs @@ -1,74 +1,74 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DeviceSupport; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Devices.Common; - -using Newtonsoft.Json; - -namespace PepperDash.Essentials.Core.Bridges -{ - public static class GenericLightingApiExtensions - { - public static void LinkToApi(this PepperDash.Essentials.Core.Lighting.LightingBase lightingDevice, BasicTriList trilist, uint joinStart, string joinMapKey) - { - GenericLightingJoinMap joinMap = new GenericLightingJoinMap(); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - joinMap.OffsetJoinNumbers(joinStart); - - Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - Debug.Console(0, "Linking to Lighting Type {0}", lightingDevice.GetType().Name.ToString()); - - // GenericLighitng Actions & FeedBack - trilist.SetUShortSigAction(joinMap.SelectScene, u => lightingDevice.SelectScene(lightingDevice.LightingScenes[u])); - - int sceneIndex = 1; - foreach (var scene in lightingDevice.LightingScenes) - { - var tempIndex = sceneIndex - 1; - trilist.SetSigTrueAction((uint)(joinMap.LightingSceneOffset + sceneIndex), () => lightingDevice.SelectScene(lightingDevice.LightingScenes[tempIndex])); - scene.IsActiveFeedback.LinkInputSig(trilist.BooleanInput[(uint)(joinMap.LightingSceneOffset + sceneIndex)]); - trilist.StringInput[(uint)(joinMap.LightingSceneOffset + sceneIndex)].StringValue = scene.Name; - trilist.BooleanInput[(uint)(joinMap.ButtonVisibilityOffset + sceneIndex)].BoolValue = true; - sceneIndex++; - } - - if (lightingDevice.GetType().Name.ToString() == "LutronQuantumArea") - { - var lutronDevice = lightingDevice as PepperDash.Essentials.Devices.Common.Environment.Lutron.LutronQuantumArea; - lutronDevice.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); - trilist.SetStringSigAction(joinMap.IntegrationIdSet, s => lutronDevice.IntegrationId = s); - } - - //ApiEisc.Eisc.SetStringSigAction(ApiMap.integrationID, (s) => { lutronLights.IntegrationId = s; }); - - - /* - var lutronLights = lightingDevice as PepperDash.Essentials.Devices.Common.Environment.Lutron.LutronQuantumArea; - - - for (uint i = 1; i <= lightingBase.CircuitCount; i++) - { - var circuit = i; - lightingBase.CircuitNameFeedbacks[circuit - 1].LinkInputSig(trilist.StringInput[joinMap.CircuitNames + circuit]); - lightingBase.CircuitIsCritical[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitIsCritical + circuit]); - lightingBase.CircuitState[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitState + circuit]); - trilist.SetSigTrueAction(joinMap.CircuitCycle + circuit, () => lightingBase.CycleCircuit(circuit - 1)); - trilist.SetSigTrueAction(joinMap.CircuitOnCmd + circuit, () => lightingBase.TurnOnCircuit(circuit - 1)); - trilist.SetSigTrueAction(joinMap.CircuitOffCmd + circuit, () => lightingBase.TurnOffCircuit(circuit - 1)); - - } - */ - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DeviceSupport; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Devices.Common; + +using Newtonsoft.Json; + +namespace PepperDash.Essentials.Core.Bridges +{ + public static class GenericLightingApiExtensions + { + public static void LinkToApi(this PepperDash.Essentials.Core.Lighting.LightingBase lightingDevice, BasicTriList trilist, uint joinStart, string joinMapKey) + { + GenericLightingJoinMap joinMap = new GenericLightingJoinMap(); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + joinMap.OffsetJoinNumbers(joinStart); + + Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + Debug.Console(0, "Linking to Lighting Type {0}", lightingDevice.GetType().Name.ToString()); + + // GenericLighitng Actions & FeedBack + trilist.SetUShortSigAction(joinMap.SelectScene, u => lightingDevice.SelectScene(lightingDevice.LightingScenes[u])); + + int sceneIndex = 1; + foreach (var scene in lightingDevice.LightingScenes) + { + var tempIndex = sceneIndex - 1; + trilist.SetSigTrueAction((uint)(joinMap.LightingSceneOffset + sceneIndex), () => lightingDevice.SelectScene(lightingDevice.LightingScenes[tempIndex])); + scene.IsActiveFeedback.LinkInputSig(trilist.BooleanInput[(uint)(joinMap.LightingSceneOffset + sceneIndex)]); + trilist.StringInput[(uint)(joinMap.LightingSceneOffset + sceneIndex)].StringValue = scene.Name; + trilist.BooleanInput[(uint)(joinMap.ButtonVisibilityOffset + sceneIndex)].BoolValue = true; + sceneIndex++; + } + + if (lightingDevice.GetType().Name.ToString() == "LutronQuantumArea") + { + var lutronDevice = lightingDevice as PepperDash.Essentials.Devices.Common.Environment.Lutron.LutronQuantumArea; + lutronDevice.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); + trilist.SetStringSigAction(joinMap.IntegrationIdSet, s => lutronDevice.IntegrationId = s); + } + + //ApiEisc.Eisc.SetStringSigAction(ApiMap.integrationID, (s) => { lutronLights.IntegrationId = s; }); + + + /* + var lutronLights = lightingDevice as PepperDash.Essentials.Devices.Common.Environment.Lutron.LutronQuantumArea; + + + for (uint i = 1; i <= lightingBase.CircuitCount; i++) + { + var circuit = i; + lightingBase.CircuitNameFeedbacks[circuit - 1].LinkInputSig(trilist.StringInput[joinMap.CircuitNames + circuit]); + lightingBase.CircuitIsCritical[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitIsCritical + circuit]); + lightingBase.CircuitState[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitState + circuit]); + trilist.SetSigTrueAction(joinMap.CircuitCycle + circuit, () => lightingBase.CycleCircuit(circuit - 1)); + trilist.SetSigTrueAction(joinMap.CircuitOnCmd + circuit, () => lightingBase.TurnOnCircuit(circuit - 1)); + trilist.SetSigTrueAction(joinMap.CircuitOffCmd + circuit, () => lightingBase.TurnOffCircuit(circuit - 1)); + + } + */ + } + } } \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/GenericRelayDeviceBridge.cs b/src/PepperDashEssentials/Bridges/GenericRelayDeviceBridge.cs similarity index 100% rename from PepperDashEssentials/Bridges/GenericRelayDeviceBridge.cs rename to src/PepperDashEssentials/Bridges/GenericRelayDeviceBridge.cs diff --git a/PepperDashEssentials/Bridges/GlsOccupancySensorBaseControllerBridge.cs b/src/PepperDashEssentials/Bridges/GlsOccupancySensorBaseControllerBridge.cs similarity index 98% rename from PepperDashEssentials/Bridges/GlsOccupancySensorBaseControllerBridge.cs rename to src/PepperDashEssentials/Bridges/GlsOccupancySensorBaseControllerBridge.cs index b073750c..052fe669 100644 --- a/PepperDashEssentials/Bridges/GlsOccupancySensorBaseControllerBridge.cs +++ b/src/PepperDashEssentials/Bridges/GlsOccupancySensorBaseControllerBridge.cs @@ -1,125 +1,125 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DeviceSupport; - -using PepperDash.Essentials.Devices.Common.Occupancy; - -using PepperDash.Essentials.Core; -using PepperDash.Core; - -using Newtonsoft.Json; - -namespace PepperDash.Essentials.Core.Bridges -{ - public static class GlsOccupancySensorBaseControllerApiExtensions - { - public static void LinkToApi(this GlsOccupancySensorBaseController occController, BasicTriList trilist, uint joinStart, string joinMapKey) - { - GlsOccupancySensorBaseJoinMap joinMap = new GlsOccupancySensorBaseJoinMap(); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - joinMap.OffsetJoinNumbers(joinStart); - - Debug.Console(1, occController, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - #region Single and Dual Sensor Stuff - occController.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); - trilist.StringInput[joinMap.Name].StringValue = occController.Name; - - trilist.OnlineStatusChange += new Crestron.SimplSharpPro.OnlineStatusChangeEventHandler((d, args) => - { - if (args.DeviceOnLine) - { - trilist.StringInput[joinMap.Name].StringValue = occController.Name; - } - } - ); - - // Occupied status - trilist.SetSigTrueAction(joinMap.ForceOccupied, new Action(() => occController.ForceOccupied())); - trilist.SetSigTrueAction(joinMap.ForceVacant, new Action(() => occController.ForceVacant())); - occController.RoomIsOccupiedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RoomOccupiedFeedback]); - occController.RoomIsOccupiedFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.RoomVacantFeedback]); - occController.RawOccupancyFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyFeedback]); - trilist.SetBoolSigAction(joinMap.EnableRawStates, new Action((b) => occController.EnableRawStates(b))); - - // Timouts - trilist.SetUShortSigAction(joinMap.Timeout, new Action((u) => occController.SetRemoteTimeout(u))); - occController.CurrentTimeoutFeedback.LinkInputSig(trilist.UShortInput[joinMap.Timeout]); - occController.LocalTimoutFeedback.LinkInputSig(trilist.UShortInput[joinMap.TimeoutLocalFeedback]); - - // LED Flash - trilist.SetSigTrueAction(joinMap.EnableLedFlash, new Action(() => occController.SetLedFlashEnable(true))); - trilist.SetSigTrueAction(joinMap.DisableLedFlash, new Action(() => occController.SetLedFlashEnable(false))); - occController.LedFlashEnabledFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.EnableLedFlash]); - - // Short Timeout - trilist.SetSigTrueAction(joinMap.EnableShortTimeout, new Action(() => occController.SetShortTimeoutState(true))); - trilist.SetSigTrueAction(joinMap.DisableShortTimeout, new Action(() => occController.SetShortTimeoutState(false))); - occController.ShortTimeoutEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableShortTimeout]); - - // PIR Sensor - trilist.SetSigTrueAction(joinMap.EnablePir, new Action(() => occController.SetPirEnable(true))); - trilist.SetSigTrueAction(joinMap.DisablePir, new Action(() => occController.SetPirEnable(false))); - occController.PirSensorEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnablePir]); - - // PIR Sensitivity in Occupied State - trilist.SetBoolSigAction(joinMap.IncrementPirInOccupiedState, new Action((b) => occController.IncrementPirSensitivityInOccupiedState(b))); - trilist.SetBoolSigAction(joinMap.DecrementPirInOccupiedState, new Action((b) => occController.DecrementPirSensitivityInOccupiedState(b))); - occController.PirSensitivityInOccupiedStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.PirSensitivityInOccupiedState]); - - // PIR Sensitivity in Vacant State - trilist.SetBoolSigAction(joinMap.IncrementPirInVacantState, new Action((b) => occController.IncrementPirSensitivityInVacantState(b))); - trilist.SetBoolSigAction(joinMap.DecrementPirInVacantState, new Action((b) => occController.DecrementPirSensitivityInVacantState(b))); - occController.PirSensitivityInVacantStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.PirSensitivityInVacantState]); - #endregion - - #region Dual Technology Sensor Stuff - var odtOccController = occController as GlsOdtOccupancySensorController; - - if (odtOccController != null) - { - // OR When Vacated - trilist.SetBoolSigAction(joinMap.OrWhenVacated, new Action((b) => odtOccController.SetOrWhenVacatedState(b))); - odtOccController.OrWhenVacatedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.OrWhenVacated]); - - // AND When Vacated - trilist.SetBoolSigAction(joinMap.AndWhenVacated, new Action((b) => odtOccController.SetAndWhenVacatedState(b))); - odtOccController.AndWhenVacatedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.AndWhenVacated]); - - // Ultrasonic A Sensor - trilist.SetSigTrueAction(joinMap.EnableUsA, new Action(() => odtOccController.SetUsAEnable(true))); - trilist.SetSigTrueAction(joinMap.DisableUsA, new Action(() => odtOccController.SetUsAEnable(false))); - odtOccController.UltrasonicAEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableUsA]); - - // Ultrasonic B Sensor - trilist.SetSigTrueAction(joinMap.EnableUsB, new Action(() => odtOccController.SetUsBEnable(true))); - trilist.SetSigTrueAction(joinMap.DisableUsB, new Action(() => odtOccController.SetUsBEnable(false))); - odtOccController.UltrasonicAEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableUsB]); - - // US Sensitivity in Occupied State - trilist.SetBoolSigAction(joinMap.IncrementUsInOccupiedState, new Action((b) => odtOccController.IncrementUsSensitivityInOccupiedState(b))); - trilist.SetBoolSigAction(joinMap.DecrementUsInOccupiedState, new Action((b) => odtOccController.DecrementUsSensitivityInOccupiedState(b))); - odtOccController.UltrasonicSensitivityInOccupiedStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.UsSensitivityInOccupiedState]); - - // US Sensitivity in Vacant State - trilist.SetBoolSigAction(joinMap.IncrementUsInVacantState, new Action((b) => odtOccController.IncrementUsSensitivityInVacantState(b))); - trilist.SetBoolSigAction(joinMap.DecrementUsInVacantState, new Action((b) => odtOccController.DecrementUsSensitivityInVacantState(b))); - odtOccController.UltrasonicSensitivityInVacantStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.UsSensitivityInVacantState]); - - //Sensor Raw States - odtOccController.RawOccupancyPirFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyPirFeedback]); - odtOccController.RawOccupancyUsFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyUsFeedback]); - - } - #endregion - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DeviceSupport; + +using PepperDash.Essentials.Devices.Common.Occupancy; + +using PepperDash.Essentials.Core; +using PepperDash.Core; + +using Newtonsoft.Json; + +namespace PepperDash.Essentials.Core.Bridges +{ + public static class GlsOccupancySensorBaseControllerApiExtensions + { + public static void LinkToApi(this GlsOccupancySensorBaseController occController, BasicTriList trilist, uint joinStart, string joinMapKey) + { + GlsOccupancySensorBaseJoinMap joinMap = new GlsOccupancySensorBaseJoinMap(); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + joinMap.OffsetJoinNumbers(joinStart); + + Debug.Console(1, occController, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + #region Single and Dual Sensor Stuff + occController.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); + trilist.StringInput[joinMap.Name].StringValue = occController.Name; + + trilist.OnlineStatusChange += new Crestron.SimplSharpPro.OnlineStatusChangeEventHandler((d, args) => + { + if (args.DeviceOnLine) + { + trilist.StringInput[joinMap.Name].StringValue = occController.Name; + } + } + ); + + // Occupied status + trilist.SetSigTrueAction(joinMap.ForceOccupied, new Action(() => occController.ForceOccupied())); + trilist.SetSigTrueAction(joinMap.ForceVacant, new Action(() => occController.ForceVacant())); + occController.RoomIsOccupiedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RoomOccupiedFeedback]); + occController.RoomIsOccupiedFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.RoomVacantFeedback]); + occController.RawOccupancyFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyFeedback]); + trilist.SetBoolSigAction(joinMap.EnableRawStates, new Action((b) => occController.EnableRawStates(b))); + + // Timouts + trilist.SetUShortSigAction(joinMap.Timeout, new Action((u) => occController.SetRemoteTimeout(u))); + occController.CurrentTimeoutFeedback.LinkInputSig(trilist.UShortInput[joinMap.Timeout]); + occController.LocalTimoutFeedback.LinkInputSig(trilist.UShortInput[joinMap.TimeoutLocalFeedback]); + + // LED Flash + trilist.SetSigTrueAction(joinMap.EnableLedFlash, new Action(() => occController.SetLedFlashEnable(true))); + trilist.SetSigTrueAction(joinMap.DisableLedFlash, new Action(() => occController.SetLedFlashEnable(false))); + occController.LedFlashEnabledFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.EnableLedFlash]); + + // Short Timeout + trilist.SetSigTrueAction(joinMap.EnableShortTimeout, new Action(() => occController.SetShortTimeoutState(true))); + trilist.SetSigTrueAction(joinMap.DisableShortTimeout, new Action(() => occController.SetShortTimeoutState(false))); + occController.ShortTimeoutEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableShortTimeout]); + + // PIR Sensor + trilist.SetSigTrueAction(joinMap.EnablePir, new Action(() => occController.SetPirEnable(true))); + trilist.SetSigTrueAction(joinMap.DisablePir, new Action(() => occController.SetPirEnable(false))); + occController.PirSensorEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnablePir]); + + // PIR Sensitivity in Occupied State + trilist.SetBoolSigAction(joinMap.IncrementPirInOccupiedState, new Action((b) => occController.IncrementPirSensitivityInOccupiedState(b))); + trilist.SetBoolSigAction(joinMap.DecrementPirInOccupiedState, new Action((b) => occController.DecrementPirSensitivityInOccupiedState(b))); + occController.PirSensitivityInOccupiedStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.PirSensitivityInOccupiedState]); + + // PIR Sensitivity in Vacant State + trilist.SetBoolSigAction(joinMap.IncrementPirInVacantState, new Action((b) => occController.IncrementPirSensitivityInVacantState(b))); + trilist.SetBoolSigAction(joinMap.DecrementPirInVacantState, new Action((b) => occController.DecrementPirSensitivityInVacantState(b))); + occController.PirSensitivityInVacantStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.PirSensitivityInVacantState]); + #endregion + + #region Dual Technology Sensor Stuff + var odtOccController = occController as GlsOdtOccupancySensorController; + + if (odtOccController != null) + { + // OR When Vacated + trilist.SetBoolSigAction(joinMap.OrWhenVacated, new Action((b) => odtOccController.SetOrWhenVacatedState(b))); + odtOccController.OrWhenVacatedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.OrWhenVacated]); + + // AND When Vacated + trilist.SetBoolSigAction(joinMap.AndWhenVacated, new Action((b) => odtOccController.SetAndWhenVacatedState(b))); + odtOccController.AndWhenVacatedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.AndWhenVacated]); + + // Ultrasonic A Sensor + trilist.SetSigTrueAction(joinMap.EnableUsA, new Action(() => odtOccController.SetUsAEnable(true))); + trilist.SetSigTrueAction(joinMap.DisableUsA, new Action(() => odtOccController.SetUsAEnable(false))); + odtOccController.UltrasonicAEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableUsA]); + + // Ultrasonic B Sensor + trilist.SetSigTrueAction(joinMap.EnableUsB, new Action(() => odtOccController.SetUsBEnable(true))); + trilist.SetSigTrueAction(joinMap.DisableUsB, new Action(() => odtOccController.SetUsBEnable(false))); + odtOccController.UltrasonicAEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableUsB]); + + // US Sensitivity in Occupied State + trilist.SetBoolSigAction(joinMap.IncrementUsInOccupiedState, new Action((b) => odtOccController.IncrementUsSensitivityInOccupiedState(b))); + trilist.SetBoolSigAction(joinMap.DecrementUsInOccupiedState, new Action((b) => odtOccController.DecrementUsSensitivityInOccupiedState(b))); + odtOccController.UltrasonicSensitivityInOccupiedStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.UsSensitivityInOccupiedState]); + + // US Sensitivity in Vacant State + trilist.SetBoolSigAction(joinMap.IncrementUsInVacantState, new Action((b) => odtOccController.IncrementUsSensitivityInVacantState(b))); + trilist.SetBoolSigAction(joinMap.DecrementUsInVacantState, new Action((b) => odtOccController.DecrementUsSensitivityInVacantState(b))); + odtOccController.UltrasonicSensitivityInVacantStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.UsSensitivityInVacantState]); + + //Sensor Raw States + odtOccController.RawOccupancyPirFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyPirFeedback]); + odtOccController.RawOccupancyUsFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyUsFeedback]); + + } + #endregion + } + } } \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/HdMdxxxCEControllerBridge.cs b/src/PepperDashEssentials/Bridges/HdMdxxxCEControllerBridge.cs similarity index 100% rename from PepperDashEssentials/Bridges/HdMdxxxCEControllerBridge.cs rename to src/PepperDashEssentials/Bridges/HdMdxxxCEControllerBridge.cs diff --git a/PepperDashEssentials/Bridges/IBasicCommunicationBridge.cs b/src/PepperDashEssentials/Bridges/IBasicCommunicationBridge.cs similarity index 100% rename from PepperDashEssentials/Bridges/IBasicCommunicationBridge.cs rename to src/PepperDashEssentials/Bridges/IBasicCommunicationBridge.cs diff --git a/PepperDashEssentials/Bridges/IBridge.cs b/src/PepperDashEssentials/Bridges/IBridge.cs similarity index 100% rename from PepperDashEssentials/Bridges/IBridge.cs rename to src/PepperDashEssentials/Bridges/IBridge.cs diff --git a/PepperDashEssentials/Bridges/IDigitalInputBridge.cs b/src/PepperDashEssentials/Bridges/IDigitalInputBridge.cs similarity index 100% rename from PepperDashEssentials/Bridges/IDigitalInputBridge.cs rename to src/PepperDashEssentials/Bridges/IDigitalInputBridge.cs diff --git a/PepperDashEssentials/Bridges/IRSetTopBoxBaseBridge.cs b/src/PepperDashEssentials/Bridges/IRSetTopBoxBaseBridge.cs similarity index 98% rename from PepperDashEssentials/Bridges/IRSetTopBoxBaseBridge.cs rename to src/PepperDashEssentials/Bridges/IRSetTopBoxBaseBridge.cs index 76e5b5ee..68455e57 100644 --- a/PepperDashEssentials/Bridges/IRSetTopBoxBaseBridge.cs +++ b/src/PepperDashEssentials/Bridges/IRSetTopBoxBaseBridge.cs @@ -1,128 +1,128 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DeviceSupport; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Devices.Common; - -using Newtonsoft.Json; - -namespace PepperDash.Essentials.Core.Bridges -{ - public static class IRSetTopBoxBaseApiExtensions - { - public static void LinkToApi(this PepperDash.Essentials.Devices.Common.IRSetTopBoxBase stbDevice, BasicTriList trilist, uint joinStart, string joinMapKey) - { - SetTopBoxControllerJoinMap joinMap = new SetTopBoxControllerJoinMap(); - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - joinMap.OffsetJoinNumbers(joinStart); - - Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - Debug.Console(0, "Linking to Display: {0}", stbDevice.Name); - - trilist.StringInput[joinMap.Name].StringValue = stbDevice.Name; - - var stbBase = stbDevice as ISetTopBoxControls; - if (stbBase != null) - { - trilist.BooleanInput[joinMap.HasDpad].BoolValue = stbBase.HasDpad; - trilist.BooleanInput[joinMap.HasNumeric].BoolValue = stbBase.HasNumeric; - trilist.BooleanInput[joinMap.HasDvr].BoolValue = stbBase.HasDvr; - trilist.BooleanInput[joinMap.HasPresets].BoolValue = stbBase.HasPresets; - - trilist.SetBoolSigAction(joinMap.DvrList, (b) => stbBase.DvrList(b)); - trilist.SetBoolSigAction(joinMap.Replay, (b) => stbBase.Replay(b)); - - trilist.SetStringSigAction(joinMap.LoadPresets, (s) => stbBase.LoadPresets(s)); - } - - var stbPower = stbDevice as IPower; - if (stbPower != null) - { - trilist.SetSigTrueAction(joinMap.PowerOn, () => stbPower.PowerOn()); - trilist.SetSigTrueAction(joinMap.PowerOff, () => stbPower.PowerOff()); - trilist.SetSigTrueAction(joinMap.PowerToggle, () => stbPower.PowerToggle()); - - } - - var stbDPad = stbDevice as IDPad; - if (stbDPad != null) - { - trilist.SetBoolSigAction(joinMap.Up, (b) => stbDPad.Up(b)); - trilist.SetBoolSigAction(joinMap.Down, (b) => stbDPad.Down(b)); - trilist.SetBoolSigAction(joinMap.Left, (b) => stbDPad.Left(b)); - trilist.SetBoolSigAction(joinMap.Right, (b) => stbDPad.Right(b)); - trilist.SetBoolSigAction(joinMap.Select, (b) => stbDPad.Select(b)); - trilist.SetBoolSigAction(joinMap.Menu, (b) => stbDPad.Menu(b)); - trilist.SetBoolSigAction(joinMap.Exit, (b) => stbDPad.Exit(b)); - } - - var stbChannel = stbDevice as IChannel; - if (stbChannel != null) - { - trilist.SetBoolSigAction(joinMap.ChannelUp, (b) => stbChannel.ChannelUp(b)); - trilist.SetBoolSigAction(joinMap.ChannelDown, (b) => stbChannel.ChannelDown(b)); - trilist.SetBoolSigAction(joinMap.LastChannel, (b) => stbChannel.LastChannel(b)); - trilist.SetBoolSigAction(joinMap.Guide, (b) => stbChannel.Guide(b)); - trilist.SetBoolSigAction(joinMap.Info, (b) => stbChannel.Info(b)); - trilist.SetBoolSigAction(joinMap.Exit, (b) => stbChannel.Exit(b)); - } - - var stbColor = stbDevice as IColor; - if (stbColor != null) - { - trilist.SetBoolSigAction(joinMap.Red, (b) => stbColor.Red(b)); - trilist.SetBoolSigAction(joinMap.Green, (b) => stbColor.Green(b)); - trilist.SetBoolSigAction(joinMap.Yellow, (b) => stbColor.Yellow(b)); - trilist.SetBoolSigAction(joinMap.Blue, (b) => stbColor.Blue(b)); - } - - var stbKeypad = stbDevice as ISetTopBoxNumericKeypad; - if (stbKeypad != null) - { - trilist.StringInput[joinMap.KeypadAccessoryButton1Label].StringValue = stbKeypad.KeypadAccessoryButton1Label; - trilist.StringInput[joinMap.KeypadAccessoryButton2Label].StringValue = stbKeypad.KeypadAccessoryButton2Label; - - trilist.BooleanInput[joinMap.HasKeypadAccessoryButton1].BoolValue = stbKeypad.HasKeypadAccessoryButton1; - trilist.BooleanInput[joinMap.HasKeypadAccessoryButton2].BoolValue = stbKeypad.HasKeypadAccessoryButton2; - - trilist.SetBoolSigAction(joinMap.Digit0, (b) => stbKeypad.Digit0(b)); - trilist.SetBoolSigAction(joinMap.Digit1, (b) => stbKeypad.Digit1(b)); - trilist.SetBoolSigAction(joinMap.Digit2, (b) => stbKeypad.Digit2(b)); - trilist.SetBoolSigAction(joinMap.Digit3, (b) => stbKeypad.Digit3(b)); - trilist.SetBoolSigAction(joinMap.Digit4, (b) => stbKeypad.Digit4(b)); - trilist.SetBoolSigAction(joinMap.Digit5, (b) => stbKeypad.Digit5(b)); - trilist.SetBoolSigAction(joinMap.Digit6, (b) => stbKeypad.Digit6(b)); - trilist.SetBoolSigAction(joinMap.Digit7, (b) => stbKeypad.Digit7(b)); - trilist.SetBoolSigAction(joinMap.Digit8, (b) => stbKeypad.Digit8(b)); - trilist.SetBoolSigAction(joinMap.Digit9, (b) => stbKeypad.Digit9(b)); - trilist.SetBoolSigAction(joinMap.KeypadAccessoryButton1Press, (b) => stbKeypad.KeypadAccessoryButton1(b)); - trilist.SetBoolSigAction(joinMap.KeypadAccessoryButton2Press, (b) => stbKeypad.KeypadAccessoryButton1(b)); - trilist.SetBoolSigAction(joinMap.Dash, (b) => stbKeypad.Dash(b)); - trilist.SetBoolSigAction(joinMap.KeypadEnter, (b) => stbKeypad.KeypadEnter(b)); - } - - var stbTransport = stbDevice as ITransport; - if (stbTransport != null) - { - trilist.SetBoolSigAction(joinMap.Play, (b) => stbTransport.Play(b)); - trilist.SetBoolSigAction(joinMap.Pause, (b) => stbTransport.Pause(b)); - trilist.SetBoolSigAction(joinMap.Rewind, (b) => stbTransport.Rewind(b)); - trilist.SetBoolSigAction(joinMap.FFwd, (b) => stbTransport.FFwd(b)); - trilist.SetBoolSigAction(joinMap.ChapMinus, (b) => stbTransport.ChapMinus(b)); - trilist.SetBoolSigAction(joinMap.ChapPlus, (b) => stbTransport.ChapPlus(b)); - trilist.SetBoolSigAction(joinMap.Stop, (b) => stbTransport.Stop(b)); - trilist.SetBoolSigAction(joinMap.Record, (b) => stbTransport.Record(b)); - - } - - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DeviceSupport; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Devices.Common; + +using Newtonsoft.Json; + +namespace PepperDash.Essentials.Core.Bridges +{ + public static class IRSetTopBoxBaseApiExtensions + { + public static void LinkToApi(this PepperDash.Essentials.Devices.Common.IRSetTopBoxBase stbDevice, BasicTriList trilist, uint joinStart, string joinMapKey) + { + SetTopBoxControllerJoinMap joinMap = new SetTopBoxControllerJoinMap(); + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + joinMap.OffsetJoinNumbers(joinStart); + + Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.Console(0, "Linking to Display: {0}", stbDevice.Name); + + trilist.StringInput[joinMap.Name].StringValue = stbDevice.Name; + + var stbBase = stbDevice as ISetTopBoxControls; + if (stbBase != null) + { + trilist.BooleanInput[joinMap.HasDpad].BoolValue = stbBase.HasDpad; + trilist.BooleanInput[joinMap.HasNumeric].BoolValue = stbBase.HasNumeric; + trilist.BooleanInput[joinMap.HasDvr].BoolValue = stbBase.HasDvr; + trilist.BooleanInput[joinMap.HasPresets].BoolValue = stbBase.HasPresets; + + trilist.SetBoolSigAction(joinMap.DvrList, (b) => stbBase.DvrList(b)); + trilist.SetBoolSigAction(joinMap.Replay, (b) => stbBase.Replay(b)); + + trilist.SetStringSigAction(joinMap.LoadPresets, (s) => stbBase.LoadPresets(s)); + } + + var stbPower = stbDevice as IPower; + if (stbPower != null) + { + trilist.SetSigTrueAction(joinMap.PowerOn, () => stbPower.PowerOn()); + trilist.SetSigTrueAction(joinMap.PowerOff, () => stbPower.PowerOff()); + trilist.SetSigTrueAction(joinMap.PowerToggle, () => stbPower.PowerToggle()); + + } + + var stbDPad = stbDevice as IDPad; + if (stbDPad != null) + { + trilist.SetBoolSigAction(joinMap.Up, (b) => stbDPad.Up(b)); + trilist.SetBoolSigAction(joinMap.Down, (b) => stbDPad.Down(b)); + trilist.SetBoolSigAction(joinMap.Left, (b) => stbDPad.Left(b)); + trilist.SetBoolSigAction(joinMap.Right, (b) => stbDPad.Right(b)); + trilist.SetBoolSigAction(joinMap.Select, (b) => stbDPad.Select(b)); + trilist.SetBoolSigAction(joinMap.Menu, (b) => stbDPad.Menu(b)); + trilist.SetBoolSigAction(joinMap.Exit, (b) => stbDPad.Exit(b)); + } + + var stbChannel = stbDevice as IChannel; + if (stbChannel != null) + { + trilist.SetBoolSigAction(joinMap.ChannelUp, (b) => stbChannel.ChannelUp(b)); + trilist.SetBoolSigAction(joinMap.ChannelDown, (b) => stbChannel.ChannelDown(b)); + trilist.SetBoolSigAction(joinMap.LastChannel, (b) => stbChannel.LastChannel(b)); + trilist.SetBoolSigAction(joinMap.Guide, (b) => stbChannel.Guide(b)); + trilist.SetBoolSigAction(joinMap.Info, (b) => stbChannel.Info(b)); + trilist.SetBoolSigAction(joinMap.Exit, (b) => stbChannel.Exit(b)); + } + + var stbColor = stbDevice as IColor; + if (stbColor != null) + { + trilist.SetBoolSigAction(joinMap.Red, (b) => stbColor.Red(b)); + trilist.SetBoolSigAction(joinMap.Green, (b) => stbColor.Green(b)); + trilist.SetBoolSigAction(joinMap.Yellow, (b) => stbColor.Yellow(b)); + trilist.SetBoolSigAction(joinMap.Blue, (b) => stbColor.Blue(b)); + } + + var stbKeypad = stbDevice as ISetTopBoxNumericKeypad; + if (stbKeypad != null) + { + trilist.StringInput[joinMap.KeypadAccessoryButton1Label].StringValue = stbKeypad.KeypadAccessoryButton1Label; + trilist.StringInput[joinMap.KeypadAccessoryButton2Label].StringValue = stbKeypad.KeypadAccessoryButton2Label; + + trilist.BooleanInput[joinMap.HasKeypadAccessoryButton1].BoolValue = stbKeypad.HasKeypadAccessoryButton1; + trilist.BooleanInput[joinMap.HasKeypadAccessoryButton2].BoolValue = stbKeypad.HasKeypadAccessoryButton2; + + trilist.SetBoolSigAction(joinMap.Digit0, (b) => stbKeypad.Digit0(b)); + trilist.SetBoolSigAction(joinMap.Digit1, (b) => stbKeypad.Digit1(b)); + trilist.SetBoolSigAction(joinMap.Digit2, (b) => stbKeypad.Digit2(b)); + trilist.SetBoolSigAction(joinMap.Digit3, (b) => stbKeypad.Digit3(b)); + trilist.SetBoolSigAction(joinMap.Digit4, (b) => stbKeypad.Digit4(b)); + trilist.SetBoolSigAction(joinMap.Digit5, (b) => stbKeypad.Digit5(b)); + trilist.SetBoolSigAction(joinMap.Digit6, (b) => stbKeypad.Digit6(b)); + trilist.SetBoolSigAction(joinMap.Digit7, (b) => stbKeypad.Digit7(b)); + trilist.SetBoolSigAction(joinMap.Digit8, (b) => stbKeypad.Digit8(b)); + trilist.SetBoolSigAction(joinMap.Digit9, (b) => stbKeypad.Digit9(b)); + trilist.SetBoolSigAction(joinMap.KeypadAccessoryButton1Press, (b) => stbKeypad.KeypadAccessoryButton1(b)); + trilist.SetBoolSigAction(joinMap.KeypadAccessoryButton2Press, (b) => stbKeypad.KeypadAccessoryButton1(b)); + trilist.SetBoolSigAction(joinMap.Dash, (b) => stbKeypad.Dash(b)); + trilist.SetBoolSigAction(joinMap.KeypadEnter, (b) => stbKeypad.KeypadEnter(b)); + } + + var stbTransport = stbDevice as ITransport; + if (stbTransport != null) + { + trilist.SetBoolSigAction(joinMap.Play, (b) => stbTransport.Play(b)); + trilist.SetBoolSigAction(joinMap.Pause, (b) => stbTransport.Pause(b)); + trilist.SetBoolSigAction(joinMap.Rewind, (b) => stbTransport.Rewind(b)); + trilist.SetBoolSigAction(joinMap.FFwd, (b) => stbTransport.FFwd(b)); + trilist.SetBoolSigAction(joinMap.ChapMinus, (b) => stbTransport.ChapMinus(b)); + trilist.SetBoolSigAction(joinMap.ChapPlus, (b) => stbTransport.ChapPlus(b)); + trilist.SetBoolSigAction(joinMap.Stop, (b) => stbTransport.Stop(b)); + trilist.SetBoolSigAction(joinMap.Record, (b) => stbTransport.Record(b)); + + } + + } + } } \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/JoinMaps/AirMediaControllerJoinMap.cs b/src/PepperDashEssentials/Bridges/JoinMaps/AirMediaControllerJoinMap.cs similarity index 100% rename from PepperDashEssentials/Bridges/JoinMaps/AirMediaControllerJoinMap.cs rename to src/PepperDashEssentials/Bridges/JoinMaps/AirMediaControllerJoinMap.cs diff --git a/PepperDashEssentials/Bridges/JoinMaps/AppleTvJoinMap.cs b/src/PepperDashEssentials/Bridges/JoinMaps/AppleTvJoinMap.cs similarity index 100% rename from PepperDashEssentials/Bridges/JoinMaps/AppleTvJoinMap.cs rename to src/PepperDashEssentials/Bridges/JoinMaps/AppleTvJoinMap.cs diff --git a/PepperDashEssentials/Bridges/JoinMaps/C2nRthsControllerJoinMap.cs b/src/PepperDashEssentials/Bridges/JoinMaps/C2nRthsControllerJoinMap.cs similarity index 100% rename from PepperDashEssentials/Bridges/JoinMaps/C2nRthsControllerJoinMap.cs rename to src/PepperDashEssentials/Bridges/JoinMaps/C2nRthsControllerJoinMap.cs diff --git a/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs b/src/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs similarity index 100% rename from PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs rename to src/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs diff --git a/PepperDashEssentials/Bridges/JoinMaps/DigitalLoggerJoinMap.cs b/src/PepperDashEssentials/Bridges/JoinMaps/DigitalLoggerJoinMap.cs similarity index 100% rename from PepperDashEssentials/Bridges/JoinMaps/DigitalLoggerJoinMap.cs rename to src/PepperDashEssentials/Bridges/JoinMaps/DigitalLoggerJoinMap.cs diff --git a/PepperDashEssentials/Bridges/JoinMaps/DisplayControllerJoinMap.cs b/src/PepperDashEssentials/Bridges/JoinMaps/DisplayControllerJoinMap.cs similarity index 100% rename from PepperDashEssentials/Bridges/JoinMaps/DisplayControllerJoinMap.cs rename to src/PepperDashEssentials/Bridges/JoinMaps/DisplayControllerJoinMap.cs diff --git a/PepperDashEssentials/Bridges/JoinMaps/DmBladeChassisControllerJoinMap.cs b/src/PepperDashEssentials/Bridges/JoinMaps/DmBladeChassisControllerJoinMap.cs similarity index 100% rename from PepperDashEssentials/Bridges/JoinMaps/DmBladeChassisControllerJoinMap.cs rename to src/PepperDashEssentials/Bridges/JoinMaps/DmBladeChassisControllerJoinMap.cs diff --git a/PepperDashEssentials/Bridges/JoinMaps/DmChassisControllerJoinMap.cs b/src/PepperDashEssentials/Bridges/JoinMaps/DmChassisControllerJoinMap.cs similarity index 100% rename from PepperDashEssentials/Bridges/JoinMaps/DmChassisControllerJoinMap.cs rename to src/PepperDashEssentials/Bridges/JoinMaps/DmChassisControllerJoinMap.cs diff --git a/PepperDashEssentials/Bridges/JoinMaps/DmRmcControllerJoinMap.cs b/src/PepperDashEssentials/Bridges/JoinMaps/DmRmcControllerJoinMap.cs similarity index 99% rename from PepperDashEssentials/Bridges/JoinMaps/DmRmcControllerJoinMap.cs rename to src/PepperDashEssentials/Bridges/JoinMaps/DmRmcControllerJoinMap.cs index 3d7cec8d..ae9592ec 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/DmRmcControllerJoinMap.cs +++ b/src/PepperDashEssentials/Bridges/JoinMaps/DmRmcControllerJoinMap.cs @@ -38,12 +38,12 @@ namespace PepperDash.Essentials.Bridges /// Reports the EDID serial number value /// public uint EdidSerialNumber { get; set; } - #endregion - - #region Analogs - public uint AudioVideoSource { get; set; } - #endregion - + #endregion + + #region Analogs + public uint AudioVideoSource { get; set; } + #endregion + public DmRmcControllerJoinMap() { // Digital @@ -56,7 +56,7 @@ namespace PepperDash.Essentials.Bridges EdidPrefferedTiming = 4; EdidSerialNumber = 5; - //Analog + //Analog AudioVideoSource = 1; } @@ -69,7 +69,7 @@ namespace PepperDash.Essentials.Bridges EdidManufacturer = EdidManufacturer + joinOffset; EdidName = EdidName + joinOffset; EdidPrefferedTiming = EdidPrefferedTiming + joinOffset; - EdidSerialNumber = EdidSerialNumber + joinOffset; + EdidSerialNumber = EdidSerialNumber + joinOffset; AudioVideoSource = AudioVideoSource + joinOffset; } } diff --git a/PepperDashEssentials/Bridges/JoinMaps/DmTxControllerJoinMap.cs b/src/PepperDashEssentials/Bridges/JoinMaps/DmTxControllerJoinMap.cs similarity index 100% rename from PepperDashEssentials/Bridges/JoinMaps/DmTxControllerJoinMap.cs rename to src/PepperDashEssentials/Bridges/JoinMaps/DmTxControllerJoinMap.cs diff --git a/PepperDashEssentials/Bridges/JoinMaps/DmpsAudioOutputControllerJoinMap.cs b/src/PepperDashEssentials/Bridges/JoinMaps/DmpsAudioOutputControllerJoinMap.cs similarity index 100% rename from PepperDashEssentials/Bridges/JoinMaps/DmpsAudioOutputControllerJoinMap.cs rename to src/PepperDashEssentials/Bridges/JoinMaps/DmpsAudioOutputControllerJoinMap.cs diff --git a/PepperDashEssentials/Bridges/JoinMaps/DmpsRoutingControllerJoinMap.cs b/src/PepperDashEssentials/Bridges/JoinMaps/DmpsRoutingControllerJoinMap.cs similarity index 100% rename from PepperDashEssentials/Bridges/JoinMaps/DmpsRoutingControllerJoinMap.cs rename to src/PepperDashEssentials/Bridges/JoinMaps/DmpsRoutingControllerJoinMap.cs diff --git a/PepperDashEssentials/Bridges/JoinMaps/GenericLightingJoinMap.cs b/src/PepperDashEssentials/Bridges/JoinMaps/GenericLightingJoinMap.cs similarity index 100% rename from PepperDashEssentials/Bridges/JoinMaps/GenericLightingJoinMap.cs rename to src/PepperDashEssentials/Bridges/JoinMaps/GenericLightingJoinMap.cs diff --git a/PepperDashEssentials/Bridges/JoinMaps/GenericRelayControllerJoinMap.cs b/src/PepperDashEssentials/Bridges/JoinMaps/GenericRelayControllerJoinMap.cs similarity index 100% rename from PepperDashEssentials/Bridges/JoinMaps/GenericRelayControllerJoinMap.cs rename to src/PepperDashEssentials/Bridges/JoinMaps/GenericRelayControllerJoinMap.cs diff --git a/PepperDashEssentials/Bridges/JoinMaps/GlsOccupancySensorBaseJoinMap.cs b/src/PepperDashEssentials/Bridges/JoinMaps/GlsOccupancySensorBaseJoinMap.cs similarity index 100% rename from PepperDashEssentials/Bridges/JoinMaps/GlsOccupancySensorBaseJoinMap.cs rename to src/PepperDashEssentials/Bridges/JoinMaps/GlsOccupancySensorBaseJoinMap.cs diff --git a/PepperDashEssentials/Bridges/JoinMaps/HdMdxxxCEControllerJoinMap.cs b/src/PepperDashEssentials/Bridges/JoinMaps/HdMdxxxCEControllerJoinMap.cs similarity index 100% rename from PepperDashEssentials/Bridges/JoinMaps/HdMdxxxCEControllerJoinMap.cs rename to src/PepperDashEssentials/Bridges/JoinMaps/HdMdxxxCEControllerJoinMap.cs diff --git a/PepperDashEssentials/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs b/src/PepperDashEssentials/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs similarity index 100% rename from PepperDashEssentials/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs rename to src/PepperDashEssentials/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs diff --git a/PepperDashEssentials/Bridges/JoinMaps/IDigitalInputJoinMap.cs b/src/PepperDashEssentials/Bridges/JoinMaps/IDigitalInputJoinMap.cs similarity index 100% rename from PepperDashEssentials/Bridges/JoinMaps/IDigitalInputJoinMap.cs rename to src/PepperDashEssentials/Bridges/JoinMaps/IDigitalInputJoinMap.cs diff --git a/PepperDashEssentials/Bridges/JoinMaps/SetTopBoxControllerJoinMap.cs b/src/PepperDashEssentials/Bridges/JoinMaps/SetTopBoxControllerJoinMap.cs similarity index 100% rename from PepperDashEssentials/Bridges/JoinMaps/SetTopBoxControllerJoinMap.cs rename to src/PepperDashEssentials/Bridges/JoinMaps/SetTopBoxControllerJoinMap.cs diff --git a/PepperDashEssentials/Bridges/JoinMaps/StatusSignControllerJoinMap.cs b/src/PepperDashEssentials/Bridges/JoinMaps/StatusSignControllerJoinMap.cs similarity index 100% rename from PepperDashEssentials/Bridges/JoinMaps/StatusSignControllerJoinMap.cs rename to src/PepperDashEssentials/Bridges/JoinMaps/StatusSignControllerJoinMap.cs diff --git a/PepperDashEssentials/Bridges/JoinMaps/SystemMonitorJoinMap.cs b/src/PepperDashEssentials/Bridges/JoinMaps/SystemMonitorJoinMap.cs similarity index 100% rename from PepperDashEssentials/Bridges/JoinMaps/SystemMonitorJoinMap.cs rename to src/PepperDashEssentials/Bridges/JoinMaps/SystemMonitorJoinMap.cs diff --git a/PepperDashEssentials/Bridges/StatusSignControllerBridge.cs b/src/PepperDashEssentials/Bridges/StatusSignControllerBridge.cs similarity index 98% rename from PepperDashEssentials/Bridges/StatusSignControllerBridge.cs rename to src/PepperDashEssentials/Bridges/StatusSignControllerBridge.cs index 0b35677d..4c7c3d29 100644 --- a/PepperDashEssentials/Bridges/StatusSignControllerBridge.cs +++ b/src/PepperDashEssentials/Bridges/StatusSignControllerBridge.cs @@ -1,65 +1,65 @@ -using Crestron.SimplSharpPro.DeviceSupport; -using Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.CrestronIO; - -namespace PepperDash.Essentials.Core.Bridges -{ - public static class StatusSignDeviceApiExtensions - { - public static void LinkToApi(this StatusSignController ssDevice, BasicTriList trilist, uint joinStart, - string joinMapKey) - { - var joinMap = new StatusSignControllerJoinMap(); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - joinMap.OffsetJoinNumbers(joinStart); - - Debug.Console(1, ssDevice, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - trilist.SetBoolSigAction(joinMap.RedControl, b => EnableControl(trilist, joinMap, ssDevice)); - trilist.SetBoolSigAction(joinMap.GreenControl, b => EnableControl(trilist, joinMap, ssDevice)); - trilist.SetBoolSigAction(joinMap.BlueControl, b => EnableControl(trilist, joinMap, ssDevice)); - - trilist.SetUShortSigAction(joinMap.RedLed, u => SetColor(trilist, joinMap, ssDevice)); - trilist.SetUShortSigAction(joinMap.GreenLed, u => SetColor(trilist, joinMap, ssDevice)); - trilist.SetUShortSigAction(joinMap.BlueLed, u => SetColor(trilist, joinMap, ssDevice)); - - trilist.StringInput[joinMap.Name].StringValue = ssDevice.Name; - - ssDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); - ssDevice.RedLedEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RedControl]); - ssDevice.BlueLedEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.BlueControl]); - ssDevice.GreenLedEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.GreenControl]); - - ssDevice.RedLedBrightnessFeedback.LinkInputSig(trilist.UShortInput[joinMap.RedLed]); - ssDevice.BlueLedBrightnessFeedback.LinkInputSig(trilist.UShortInput[joinMap.BlueLed]); - ssDevice.GreenLedBrightnessFeedback.LinkInputSig(trilist.UShortInput[joinMap.GreenLed]); - - } - - private static void EnableControl(BasicTriList triList, StatusSignControllerJoinMap joinMap, - StatusSignController device) - { - var redEnable = triList.BooleanOutput[joinMap.RedControl].BoolValue; - var greenEnable = triList.BooleanOutput[joinMap.GreenControl].BoolValue; - var blueEnable = triList.BooleanOutput[joinMap.BlueControl].BoolValue; - device.EnableLedControl(redEnable, greenEnable, blueEnable); - } - - private static void SetColor(BasicTriList triList, StatusSignControllerJoinMap joinMap, - StatusSignController device) - { - var redBrightness = triList.UShortOutput[joinMap.RedLed].UShortValue; - var greenBrightness = triList.UShortOutput[joinMap.GreenLed].UShortValue; - var blueBrightness = triList.UShortOutput[joinMap.BlueLed].UShortValue; - - device.SetColor(redBrightness, greenBrightness, blueBrightness); - } - } +using Crestron.SimplSharpPro.DeviceSupport; +using Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.CrestronIO; + +namespace PepperDash.Essentials.Core.Bridges +{ + public static class StatusSignDeviceApiExtensions + { + public static void LinkToApi(this StatusSignController ssDevice, BasicTriList trilist, uint joinStart, + string joinMapKey) + { + var joinMap = new StatusSignControllerJoinMap(); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + joinMap.OffsetJoinNumbers(joinStart); + + Debug.Console(1, ssDevice, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + trilist.SetBoolSigAction(joinMap.RedControl, b => EnableControl(trilist, joinMap, ssDevice)); + trilist.SetBoolSigAction(joinMap.GreenControl, b => EnableControl(trilist, joinMap, ssDevice)); + trilist.SetBoolSigAction(joinMap.BlueControl, b => EnableControl(trilist, joinMap, ssDevice)); + + trilist.SetUShortSigAction(joinMap.RedLed, u => SetColor(trilist, joinMap, ssDevice)); + trilist.SetUShortSigAction(joinMap.GreenLed, u => SetColor(trilist, joinMap, ssDevice)); + trilist.SetUShortSigAction(joinMap.BlueLed, u => SetColor(trilist, joinMap, ssDevice)); + + trilist.StringInput[joinMap.Name].StringValue = ssDevice.Name; + + ssDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); + ssDevice.RedLedEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RedControl]); + ssDevice.BlueLedEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.BlueControl]); + ssDevice.GreenLedEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.GreenControl]); + + ssDevice.RedLedBrightnessFeedback.LinkInputSig(trilist.UShortInput[joinMap.RedLed]); + ssDevice.BlueLedBrightnessFeedback.LinkInputSig(trilist.UShortInput[joinMap.BlueLed]); + ssDevice.GreenLedBrightnessFeedback.LinkInputSig(trilist.UShortInput[joinMap.GreenLed]); + + } + + private static void EnableControl(BasicTriList triList, StatusSignControllerJoinMap joinMap, + StatusSignController device) + { + var redEnable = triList.BooleanOutput[joinMap.RedControl].BoolValue; + var greenEnable = triList.BooleanOutput[joinMap.GreenControl].BoolValue; + var blueEnable = triList.BooleanOutput[joinMap.BlueControl].BoolValue; + device.EnableLedControl(redEnable, greenEnable, blueEnable); + } + + private static void SetColor(BasicTriList triList, StatusSignControllerJoinMap joinMap, + StatusSignController device) + { + var redBrightness = triList.UShortOutput[joinMap.RedLed].UShortValue; + var greenBrightness = triList.UShortOutput[joinMap.GreenLed].UShortValue; + var blueBrightness = triList.UShortOutput[joinMap.BlueLed].UShortValue; + + device.SetColor(redBrightness, greenBrightness, blueBrightness); + } + } } \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/SystemMonitorBridge.cs b/src/PepperDashEssentials/Bridges/SystemMonitorBridge.cs similarity index 100% rename from PepperDashEssentials/Bridges/SystemMonitorBridge.cs rename to src/PepperDashEssentials/Bridges/SystemMonitorBridge.cs diff --git a/PepperDashEssentials/ClassDiagram1.cd b/src/PepperDashEssentials/ClassDiagram1.cd similarity index 100% rename from PepperDashEssentials/ClassDiagram1.cd rename to src/PepperDashEssentials/ClassDiagram1.cd diff --git a/PepperDashEssentials/ControlSystem.cs b/src/PepperDashEssentials/ControlSystem.cs similarity index 97% rename from PepperDashEssentials/ControlSystem.cs rename to src/PepperDashEssentials/ControlSystem.cs index 1bafbbac..43b10fee 100644 --- a/PepperDashEssentials/ControlSystem.cs +++ b/src/PepperDashEssentials/ControlSystem.cs @@ -1,663 +1,663 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Crestron.SimplSharp; -using Crestron.SimplSharp.CrestronIO; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.CrestronThread; -using Crestron.SimplSharpPro.Diagnostics; -using Crestron.SimplSharp.Reflection; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.Core.Fusion; -using PepperDash.Essentials.Core.Web; -using PepperDash.Essentials.Devices.Common; -using PepperDash.Essentials.DM; -using PepperDash.Essentials.Fusion; -using PepperDash.Essentials.Room.Config; - -using Newtonsoft.Json; -using PepperDash.Essentials.Core.DeviceTypeInterfaces; - -namespace PepperDash.Essentials -{ - public class ControlSystem : CrestronControlSystem - { - HttpLogoServer LogoServer; - - private CTimer _startTimer; - private CEvent _initializeEvent; - private const long StartupTime = 500; - - public ControlSystem() - : base() - { - Thread.MaxNumberOfUserThreads = 400; - Global.ControlSystem = this; - DeviceManager.Initialize(this); - SecretsManager.Initialize(); - SystemMonitor.ProgramInitialization.ProgramInitializationUnderUserControl = true; - } - - /// - /// Entry point for the program - /// - public override void InitializeSystem() - { - // If the control system is a DMPS type, we need to wait to exit this method until all devices have had time to activate - // to allow any HD-BaseT DM endpoints to register first. - bool preventInitializationComplete = Global.ControlSystemIsDmpsType; - if (preventInitializationComplete) - { - Debug.Console(1, "******************* InitializeSystem() Entering **********************"); - _startTimer = new CTimer(StartSystem, preventInitializationComplete, StartupTime); - _initializeEvent = new CEvent(true, false); - DeviceManager.AllDevicesRegistered += (o, a) => - { - _initializeEvent.Set(); - }; - _initializeEvent.Wait(30000); - Debug.Console(1, "******************* InitializeSystem() Exiting **********************"); - SystemMonitor.ProgramInitialization.ProgramInitializationComplete = true; - } - else - { - _startTimer = new CTimer(StartSystem, preventInitializationComplete, StartupTime); - } - } - - private void StartSystem(object preventInitialization) - { - DeterminePlatform(); - - if (Debug.DoNotLoadOnNextBoot) - { - CrestronConsole.AddNewConsoleCommand(s => CrestronInvoke.BeginInvoke((o) => GoWithLoad()), "go", "Loads configuration file", - ConsoleAccessLevelEnum.AccessOperator); - } - - CrestronConsole.AddNewConsoleCommand(PluginLoader.ReportAssemblyVersions, "reportversions", "Reports the versions of the loaded assemblies", ConsoleAccessLevelEnum.AccessOperator); - - CrestronConsole.AddNewConsoleCommand(Core.DeviceFactory.GetDeviceFactoryTypes, "gettypes", "Gets the device types that can be built. Accepts a filter string.", ConsoleAccessLevelEnum.AccessOperator); - - CrestronConsole.AddNewConsoleCommand(BridgeHelper.PrintJoinMap, "getjoinmap", "map(s) for bridge or device on bridge [brKey [devKey]]", ConsoleAccessLevelEnum.AccessOperator); - - CrestronConsole.AddNewConsoleCommand(BridgeHelper.JoinmapMarkdown, "getjoinmapmarkdown" - , "generate markdown of map(s) for bridge or device on bridge [brKey [devKey]]", ConsoleAccessLevelEnum.AccessOperator); - - CrestronConsole.AddNewConsoleCommand(s => Debug.Console(0, Debug.ErrorLogLevel.Notice, "CONSOLE MESSAGE: {0}", s), "appdebugmessage", "Writes message to log", ConsoleAccessLevelEnum.AccessOperator); - - CrestronConsole.AddNewConsoleCommand(s => - { - foreach (var tl in TieLineCollection.Default) - CrestronConsole.ConsoleCommandResponse(" {0}{1}", tl, CrestronEnvironment.NewLine); - }, - "listtielines", "Prints out all tie lines", ConsoleAccessLevelEnum.AccessOperator); - - CrestronConsole.AddNewConsoleCommand(s => - { - CrestronConsole.ConsoleCommandResponse - ("Current running configuration. This is the merged system and template configuration" + CrestronEnvironment.NewLine); - CrestronConsole.ConsoleCommandResponse(Newtonsoft.Json.JsonConvert.SerializeObject - (ConfigReader.ConfigObject, Newtonsoft.Json.Formatting.Indented)); - }, "showconfig", "Shows the current running merged config", ConsoleAccessLevelEnum.AccessOperator); - - CrestronConsole.AddNewConsoleCommand(s => - CrestronConsole.ConsoleCommandResponse( - "This system can be found at the following URLs:{2}" + - "System URL: {0}{2}" + - "Template URL: {1}{2}", - ConfigReader.ConfigObject.SystemUrl, - ConfigReader.ConfigObject.TemplateUrl, - CrestronEnvironment.NewLine), - "portalinfo", - "Shows portal URLS from configuration", - ConsoleAccessLevelEnum.AccessOperator); - - - CrestronConsole.AddNewConsoleCommand(DeviceManager.GetRoutingPorts, - "getroutingports", "Reports all routing ports, if any. Requires a device key", ConsoleAccessLevelEnum.AccessOperator); - - if (!Debug.DoNotLoadOnNextBoot) - { - GoWithLoad(); - return; - } - - if (!(bool)preventInitialization) - { - SystemMonitor.ProgramInitialization.ProgramInitializationComplete = true; - } - } - - /// - /// Determines if the program is running on a processor (appliance) or server (VC-4). - /// - /// Sets Global.FilePathPrefix and Global.ApplicationDirectoryPathPrefix based on platform - /// - public void DeterminePlatform() - { - try - { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Determining Platform...."); - - string filePathPrefix; - - var dirSeparator = Global.DirectorySeparator; - - string directoryPrefix; - - directoryPrefix = Crestron.SimplSharp.CrestronIO.Directory.GetApplicationRootDirectory(); - - var fullVersion = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false); - - AssemblyInformationalVersionAttribute fullVersionAtt = fullVersion[0] as AssemblyInformationalVersionAttribute; - - Global.SetAssemblyVersion(fullVersionAtt.InformationalVersion); - - if (CrestronEnvironment.DevicePlatform != eDevicePlatform.Server) // Handles 3-series running Windows CE OS - { - string userFolder; - string nvramFolder; - bool is4series = false; - - if (eCrestronSeries.Series4 == (Global.ProcessorSeries & eCrestronSeries.Series4)) // Handle 4-series - { - is4series = true; - // Set path to user/ - userFolder = "user"; - nvramFolder = "nvram"; - } - else - { - userFolder = "User"; - nvramFolder = "Nvram"; - } - - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials v{0} on {1} Appliance", Global.AssemblyVersion, is4series ? "4-series" : "3-series"); - - // Check if User/ProgramX exists - if (Directory.Exists(Global.ApplicationDirectoryPathPrefix + dirSeparator + userFolder - + dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber))) - { - Debug.Console(0, @"{0}/program{1} directory found", userFolder, InitialParametersClass.ApplicationNumber); - filePathPrefix = directoryPrefix + dirSeparator + userFolder - + dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber) + dirSeparator; - } - // Check if Nvram/Programx exists - else if (Directory.Exists(directoryPrefix + dirSeparator + nvramFolder - + dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber))) - { - Debug.Console(0, @"{0}/program{1} directory found", nvramFolder, InitialParametersClass.ApplicationNumber); - filePathPrefix = directoryPrefix + dirSeparator + nvramFolder - + dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber) + dirSeparator; - } - // If neither exists, set path to User/ProgramX - else - { - Debug.Console(0, @"No previous directory found. Using {0}/program{1}", userFolder, InitialParametersClass.ApplicationNumber); - filePathPrefix = directoryPrefix + dirSeparator + userFolder - + dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber) + dirSeparator; - } - } - else // Handles Linux OS (Virtual Control) - { - Debug.SetDebugLevel(2); - - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials v{0} on Virtual Control Server", Global.AssemblyVersion); - - // Set path to User/ - filePathPrefix = directoryPrefix + dirSeparator + "User" + dirSeparator; - } - - Global.SetFilePathPrefix(filePathPrefix); - } - catch (Exception e) - { - Debug.Console(0, "Unable to Determine Platform due to Exception: {0}", e.Message); - } - } - - /// - /// Begins the process of loading resources including plugins and configuration data - /// - public void GoWithLoad() - { - try - { - Debug.SetDoNotLoadOnNextBoot(false); - - PluginLoader.AddProgramAssemblies(); - - new Core.DeviceFactory(); - new Devices.Common.DeviceFactory(); - new DM.DeviceFactory(); - new DeviceFactory(); - - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials load from configuration"); - - var filesReady = SetupFilesystem(); - if (filesReady) - { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Checking for plugins"); - PluginLoader.LoadPlugins(); - - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Folder structure verified. Loading config..."); - if (!ConfigReader.LoadConfig2()) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Essentials Load complete with errors"); - return; - } - - Load(); - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Essentials load complete\r\n" + - "-------------------------------------------------------------"); - } - else - { - Debug.Console(0, - @"---------------------------------------------- - ------------------------------------------------ - ------------------------------------------------ - Essentials file structure setup completed. - Please load config, sgd and ir files and - restart program. - ------------------------------------------------ - ------------------------------------------------ - ------------------------------------------------"); - } - - } - catch (Exception e) - { - Debug.Console(0, "FATAL INITIALIZE ERROR. System is in an inconsistent state:\r\n{0}", e); - } - finally - { - // Notify the OS that the program intitialization has completed - SystemMonitor.ProgramInitialization.ProgramInitializationComplete = true; - } - - } - - - - /// - /// Verifies filesystem is set up. IR, SGD, and programX folders - /// - bool SetupFilesystem() - { - Debug.Console(0, "Verifying and/or creating folder structure"); - var configDir = Global.FilePathPrefix; - var configExists = Directory.Exists(configDir); - if (!configExists) - Directory.Create(configDir); - - var irDir = Global.FilePathPrefix + "ir"; - if (!Directory.Exists(irDir)) - Directory.Create(irDir); - - var sgdDir = Global.FilePathPrefix + "sgd"; - if (!Directory.Exists(sgdDir)) - Directory.Create(sgdDir); - - var pluginDir = Global.FilePathPrefix + "plugins"; - if (!Directory.Exists(pluginDir)) - Directory.Create(pluginDir); - - var joinmapDir = Global.FilePathPrefix + "joinmaps"; - if(!Directory.Exists(joinmapDir)) - Directory.Create(joinmapDir); - - return configExists; - } - - /// - /// - /// - public void TearDown() - { - Debug.Console(0, "Tearing down existing system"); - DeviceManager.DeactivateAll(); - - TieLineCollection.Default.Clear(); - - foreach (var key in DeviceManager.GetDevices()) - DeviceManager.RemoveDevice(key); - - Debug.Console(0, "Tear down COMPLETE"); - } - - /// - /// - /// - void Load() - { - LoadDevices(); - LoadTieLines(); - LoadRooms(); - LoadLogoServer(); - - DeviceManager.ActivateAll(); - - var mobileControl = GetMobileControlDevice(); - - if (mobileControl == null) return; - - mobileControl.LinkSystemMonitorToAppServer(); - - } - - /// - /// Reads all devices from config and adds them to DeviceManager - /// - public void LoadDevices() - { - - // Build the processor wrapper class - DeviceManager.AddDevice(new PepperDash.Essentials.Core.Devices.CrestronProcessor("processor")); - DeviceManager.AddDevice(new EssemtialsWebApi("essentialsWebApi","Essentials Web API")); - - // Add global System Monitor device - if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance) - { - DeviceManager.AddDevice( - new PepperDash.Essentials.Core.Monitoring.SystemMonitorController("systemMonitor")); - } - - foreach (var devConf in ConfigReader.ConfigObject.Devices) - { - - try - { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Creating device '{0}', type '{1}'", devConf.Key, devConf.Type); - // Skip this to prevent unnecessary warnings - if (devConf.Key == "processor") - { - var prompt = Global.ControlSystem.ControllerPrompt; - - var typeMatch = String.Equals(devConf.Type, prompt, StringComparison.OrdinalIgnoreCase) || - String.Equals(devConf.Type, prompt.Replace("-", ""), StringComparison.OrdinalIgnoreCase); - - if (!typeMatch) - Debug.Console(0, - "WARNING: Config file defines processor type as '{0}' but actual processor is '{1}'! Some ports may not be available", - devConf.Type.ToUpper(), Global.ControlSystem.ControllerPrompt.ToUpper()); - - // Check if the processor is a DMPS model - if (this.ControllerPrompt.IndexOf("dmps", StringComparison.OrdinalIgnoreCase) > -1) - { - Debug.Console(2, "Adding DmpsRoutingController for {0} to Device Manager.", this.ControllerPrompt); - - var propertiesConfig = JsonConvert.DeserializeObject(devConf.Properties.ToString()); - - if(propertiesConfig == null) - propertiesConfig = new DM.Config.DmpsRoutingPropertiesConfig(); - - DeviceManager.AddDevice(DmpsRoutingController.GetDmpsRoutingController("processor-avRouting", this.ControllerPrompt, propertiesConfig)); - } - else if (this.ControllerPrompt.IndexOf("mpc3", StringComparison.OrdinalIgnoreCase) > -1) - { - Debug.Console(2, "MPC3 processor type detected. Adding Mpc3TouchpanelController."); - - var butToken = devConf.Properties["buttons"]; - if (butToken == null) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, - "Error: Unable to deserialize buttons collection for device: {0}", devConf.Key); - continue; - } - - var buttons = butToken.ToObject>(); - var tpController = new Core.Touchpanels.Mpc3TouchpanelController( - string.Format("{0}-keypadButtons", devConf.Key), devConf.Name, Global.ControlSystem, buttons); - - DeviceManager.AddDevice(tpController); - } - else - { - Debug.Console(2, "************Processor is not DMPS type***************"); - } - - - - continue; - } - - // Try local factories first - IKeyed newDev = null; - - if (newDev == null) - newDev = PepperDash.Essentials.Core.DeviceFactory.GetDevice(devConf); - - if (newDev != null) - DeviceManager.AddDevice(newDev); - else - Debug.Console(0, Debug.ErrorLogLevel.Error, "ERROR: Cannot load unknown device type '{0}', key '{1}'.", devConf.Type, devConf.Key); - } - catch (Exception e) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, "ERROR: Creating device {0}. Skipping device. \r{1}", devConf.Key, e); - } - } - Debug.Console(0, Debug.ErrorLogLevel.Notice, "All Devices Loaded."); - - } - - - /// - /// Helper method to load tie lines. This should run after devices have loaded - /// - public void LoadTieLines() - { - // In the future, we can't necessarily just clear here because devices - // might be making their own internal sources/tie lines - - var tlc = TieLineCollection.Default; - //tlc.Clear(); - if (ConfigReader.ConfigObject.TieLines == null) - { - return; - } - - foreach (var tieLineConfig in ConfigReader.ConfigObject.TieLines) - { - var newTL = tieLineConfig.GetTieLine(); - if (newTL != null) - tlc.Add(newTL); - } - - Debug.Console(0, Debug.ErrorLogLevel.Notice, "All Tie Lines Loaded."); - - } - - /// - /// Reads all rooms from config and adds them to DeviceManager - /// - public void LoadRooms() - { - if (ConfigReader.ConfigObject.Rooms == null) - { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Notice: Configuration contains no rooms - Is this intentional? This may be a valid configuration."); - return; - } - - uint fusionIpId = 0xf1; - - foreach (var roomConfig in ConfigReader.ConfigObject.Rooms) - { - var room = EssentialsRoomConfigHelper.GetRoomObject(roomConfig) as IEssentialsRoom; - if (room != null) - { - // default to no join map key - string fusionJoinMapKey = string.Empty; - - if (room.Config.Properties["fusion"] != null) - { - Debug.Console(2, "Custom Fusion config found. Using custom values"); - - var fusionConfig = room.Config.Properties["fusion"].ToObject(); - - if (fusionConfig != null) - { - fusionIpId = fusionConfig.IpIdInt; - fusionJoinMapKey = fusionConfig.JoinMapKey; - } - } - - AddRoomAndBuildMC(room); - - if (room is IEssentialsHuddleSpaceRoom) - { - - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Room is EssentialsHuddleSpaceRoom, attempting to add to DeviceManager with Fusion with IP-ID {0:X2}", fusionIpId); - DeviceManager.AddDevice(new Core.Fusion.EssentialsHuddleSpaceFusionSystemControllerBase(room, fusionIpId, fusionJoinMapKey)); - - } - else if (room is IEssentialsHuddleVtc1Room) - { - - if (!(room is EssentialsCombinedHuddleVtc1Room)) - { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Room is EssentialsHuddleVtc1Room, attempting to add to DeviceManager with Fusion with IP-ID {0:X2}", fusionIpId); - DeviceManager.AddDevice(new EssentialsHuddleVtc1FusionController((IEssentialsHuddleVtc1Room)room, fusionIpId, fusionJoinMapKey)); - } - - } - else if (room is EssentialsTechRoom) - { - - Debug.Console(0, Debug.ErrorLogLevel.Notice, - "Room is EssentialsTechRoom, Attempting to add to DeviceManager with Fusion with IP-ID {0:X2}", fusionIpId); - DeviceManager.AddDevice(new EssentialsTechRoomFusionSystemController((EssentialsTechRoom)room, fusionIpId, fusionJoinMapKey)); - - } - fusionIpId += 1; - } - else - { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Notice: Cannot create room from config, key '{0}' - Is this intentional? This may be a valid configuration.", roomConfig.Key); - - } - } - - Debug.Console(0, Debug.ErrorLogLevel.Notice, "All Rooms Loaded."); - - } - - private static void AddRoomAndBuildMC(IEssentialsRoom room) - { - DeviceManager.AddDevice(room); - - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to build Mobile Control Bridge"); - - CreateMobileControlBridge(room); - } - - private static void CreateMobileControlBridge(object room) - { - var mobileControl = GetMobileControlDevice(); - - if (mobileControl == null) return; - - var mobileControl3 = mobileControl as IMobileControl3; - - if (mobileControl3 != null) - { - mobileControl3.CreateMobileControlRoomBridge(room as IEssentialsRoom, mobileControl); - } - else - { - mobileControl.CreateMobileControlRoomBridge(room as EssentialsRoomBase, mobileControl); - } - - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Mobile Control Bridge Added..."); - } - - private static IMobileControl GetMobileControlDevice() - { - var mobileControlList = DeviceManager.AllDevices.OfType().ToList(); - - if (mobileControlList.Count > 1) - { - Debug.Console(0, Debug.ErrorLogLevel.Warning, - "Multiple instances of Mobile Control Server found."); - - return null; - } - - if (mobileControlList.Count > 0) - { - return mobileControlList[0]; - } - - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Mobile Control not enabled for this system"); - return null; - } - - /// - /// Fires up a logo server if not already running - /// - void LoadLogoServer() - { - if (ConfigReader.ConfigObject.Rooms == null) - { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "No rooms configured. Bypassing Logo server startup."); - return; - } - - if ( - !ConfigReader.ConfigObject.Rooms.Any( - CheckRoomConfig)) - { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "No rooms configured to use system Logo server. Bypassing Logo server startup"); - return; - } - - try - { - LogoServer = new HttpLogoServer(8080, Global.DirectorySeparator + "html" + Global.DirectorySeparator + "logo"); - } - catch (Exception) - { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "NOTICE: Logo server cannot be started. Likely already running in another program"); - } - } - - private bool CheckRoomConfig(DeviceConfig c) - { - string logoDark = null; - string logoLight = null; - string logo = null; - - try - { - if (c.Properties["logoDark"] != null) - { - logoDark = c.Properties["logoDark"].Value("type"); - } - - if (c.Properties["logoLight"] != null) - { - logoLight = c.Properties["logoLight"].Value("type"); - } - - if (c.Properties["logo"] != null) - { - logo = c.Properties["logo"].Value("type"); - } - - return ((logoDark != null && logoDark == "system") || - (logoLight != null && logoLight == "system") || (logo != null && logo == "system")); - } - catch - { - Debug.Console(1, Debug.ErrorLogLevel.Notice, "Unable to find logo information in any room config"); - return false; - } - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using Crestron.SimplSharp; +using Crestron.SimplSharp.CrestronIO; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.CrestronThread; +using Crestron.SimplSharpPro.Diagnostics; +using Crestron.SimplSharp.Reflection; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.Core.Fusion; +using PepperDash.Essentials.Core.Web; +using PepperDash.Essentials.Devices.Common; +using PepperDash.Essentials.DM; +using PepperDash.Essentials.Fusion; +using PepperDash.Essentials.Room.Config; + +using Newtonsoft.Json; +using PepperDash.Essentials.Core.DeviceTypeInterfaces; + +namespace PepperDash.Essentials +{ + public class ControlSystem : CrestronControlSystem + { + HttpLogoServer LogoServer; + + private CTimer _startTimer; + private CEvent _initializeEvent; + private const long StartupTime = 500; + + public ControlSystem() + : base() + { + Thread.MaxNumberOfUserThreads = 400; + Global.ControlSystem = this; + DeviceManager.Initialize(this); + SecretsManager.Initialize(); + SystemMonitor.ProgramInitialization.ProgramInitializationUnderUserControl = true; + } + + /// + /// Entry point for the program + /// + public override void InitializeSystem() + { + // If the control system is a DMPS type, we need to wait to exit this method until all devices have had time to activate + // to allow any HD-BaseT DM endpoints to register first. + bool preventInitializationComplete = Global.ControlSystemIsDmpsType; + if (preventInitializationComplete) + { + Debug.Console(1, "******************* InitializeSystem() Entering **********************"); + _startTimer = new CTimer(StartSystem, preventInitializationComplete, StartupTime); + _initializeEvent = new CEvent(true, false); + DeviceManager.AllDevicesRegistered += (o, a) => + { + _initializeEvent.Set(); + }; + _initializeEvent.Wait(30000); + Debug.Console(1, "******************* InitializeSystem() Exiting **********************"); + SystemMonitor.ProgramInitialization.ProgramInitializationComplete = true; + } + else + { + _startTimer = new CTimer(StartSystem, preventInitializationComplete, StartupTime); + } + } + + private void StartSystem(object preventInitialization) + { + DeterminePlatform(); + + if (Debug.DoNotLoadOnNextBoot) + { + CrestronConsole.AddNewConsoleCommand(s => CrestronInvoke.BeginInvoke((o) => GoWithLoad()), "go", "Loads configuration file", + ConsoleAccessLevelEnum.AccessOperator); + } + + CrestronConsole.AddNewConsoleCommand(PluginLoader.ReportAssemblyVersions, "reportversions", "Reports the versions of the loaded assemblies", ConsoleAccessLevelEnum.AccessOperator); + + CrestronConsole.AddNewConsoleCommand(Core.DeviceFactory.GetDeviceFactoryTypes, "gettypes", "Gets the device types that can be built. Accepts a filter string.", ConsoleAccessLevelEnum.AccessOperator); + + CrestronConsole.AddNewConsoleCommand(BridgeHelper.PrintJoinMap, "getjoinmap", "map(s) for bridge or device on bridge [brKey [devKey]]", ConsoleAccessLevelEnum.AccessOperator); + + CrestronConsole.AddNewConsoleCommand(BridgeHelper.JoinmapMarkdown, "getjoinmapmarkdown" + , "generate markdown of map(s) for bridge or device on bridge [brKey [devKey]]", ConsoleAccessLevelEnum.AccessOperator); + + CrestronConsole.AddNewConsoleCommand(s => Debug.Console(0, Debug.ErrorLogLevel.Notice, "CONSOLE MESSAGE: {0}", s), "appdebugmessage", "Writes message to log", ConsoleAccessLevelEnum.AccessOperator); + + CrestronConsole.AddNewConsoleCommand(s => + { + foreach (var tl in TieLineCollection.Default) + CrestronConsole.ConsoleCommandResponse(" {0}{1}", tl, CrestronEnvironment.NewLine); + }, + "listtielines", "Prints out all tie lines", ConsoleAccessLevelEnum.AccessOperator); + + CrestronConsole.AddNewConsoleCommand(s => + { + CrestronConsole.ConsoleCommandResponse + ("Current running configuration. This is the merged system and template configuration" + CrestronEnvironment.NewLine); + CrestronConsole.ConsoleCommandResponse(Newtonsoft.Json.JsonConvert.SerializeObject + (ConfigReader.ConfigObject, Newtonsoft.Json.Formatting.Indented)); + }, "showconfig", "Shows the current running merged config", ConsoleAccessLevelEnum.AccessOperator); + + CrestronConsole.AddNewConsoleCommand(s => + CrestronConsole.ConsoleCommandResponse( + "This system can be found at the following URLs:{2}" + + "System URL: {0}{2}" + + "Template URL: {1}{2}", + ConfigReader.ConfigObject.SystemUrl, + ConfigReader.ConfigObject.TemplateUrl, + CrestronEnvironment.NewLine), + "portalinfo", + "Shows portal URLS from configuration", + ConsoleAccessLevelEnum.AccessOperator); + + + CrestronConsole.AddNewConsoleCommand(DeviceManager.GetRoutingPorts, + "getroutingports", "Reports all routing ports, if any. Requires a device key", ConsoleAccessLevelEnum.AccessOperator); + + if (!Debug.DoNotLoadOnNextBoot) + { + GoWithLoad(); + return; + } + + if (!(bool)preventInitialization) + { + SystemMonitor.ProgramInitialization.ProgramInitializationComplete = true; + } + } + + /// + /// Determines if the program is running on a processor (appliance) or server (VC-4). + /// + /// Sets Global.FilePathPrefix and Global.ApplicationDirectoryPathPrefix based on platform + /// + public void DeterminePlatform() + { + try + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Determining Platform...."); + + string filePathPrefix; + + var dirSeparator = Global.DirectorySeparator; + + string directoryPrefix; + + directoryPrefix = Crestron.SimplSharp.CrestronIO.Directory.GetApplicationRootDirectory(); + + var fullVersion = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false); + + AssemblyInformationalVersionAttribute fullVersionAtt = fullVersion[0] as AssemblyInformationalVersionAttribute; + + Global.SetAssemblyVersion(fullVersionAtt.InformationalVersion); + + if (CrestronEnvironment.DevicePlatform != eDevicePlatform.Server) // Handles 3-series running Windows CE OS + { + string userFolder; + string nvramFolder; + bool is4series = false; + + if (eCrestronSeries.Series4 == (Global.ProcessorSeries & eCrestronSeries.Series4)) // Handle 4-series + { + is4series = true; + // Set path to user/ + userFolder = "user"; + nvramFolder = "nvram"; + } + else + { + userFolder = "User"; + nvramFolder = "Nvram"; + } + + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials v{0} on {1} Appliance", Global.AssemblyVersion, is4series ? "4-series" : "3-series"); + + // Check if User/ProgramX exists + if (Directory.Exists(Global.ApplicationDirectoryPathPrefix + dirSeparator + userFolder + + dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber))) + { + Debug.Console(0, @"{0}/program{1} directory found", userFolder, InitialParametersClass.ApplicationNumber); + filePathPrefix = directoryPrefix + dirSeparator + userFolder + + dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber) + dirSeparator; + } + // Check if Nvram/Programx exists + else if (Directory.Exists(directoryPrefix + dirSeparator + nvramFolder + + dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber))) + { + Debug.Console(0, @"{0}/program{1} directory found", nvramFolder, InitialParametersClass.ApplicationNumber); + filePathPrefix = directoryPrefix + dirSeparator + nvramFolder + + dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber) + dirSeparator; + } + // If neither exists, set path to User/ProgramX + else + { + Debug.Console(0, @"No previous directory found. Using {0}/program{1}", userFolder, InitialParametersClass.ApplicationNumber); + filePathPrefix = directoryPrefix + dirSeparator + userFolder + + dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber) + dirSeparator; + } + } + else // Handles Linux OS (Virtual Control) + { + Debug.SetDebugLevel(2); + + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials v{0} on Virtual Control Server", Global.AssemblyVersion); + + // Set path to User/ + filePathPrefix = directoryPrefix + dirSeparator + "User" + dirSeparator; + } + + Global.SetFilePathPrefix(filePathPrefix); + } + catch (Exception e) + { + Debug.Console(0, "Unable to Determine Platform due to Exception: {0}", e.Message); + } + } + + /// + /// Begins the process of loading resources including plugins and configuration data + /// + public void GoWithLoad() + { + try + { + Debug.SetDoNotLoadOnNextBoot(false); + + PluginLoader.AddProgramAssemblies(); + + new Core.DeviceFactory(); + new Devices.Common.DeviceFactory(); + new DM.DeviceFactory(); + new DeviceFactory(); + + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials load from configuration"); + + var filesReady = SetupFilesystem(); + if (filesReady) + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Checking for plugins"); + PluginLoader.LoadPlugins(); + + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Folder structure verified. Loading config..."); + if (!ConfigReader.LoadConfig2()) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "Essentials Load complete with errors"); + return; + } + + Load(); + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Essentials load complete\r\n" + + "-------------------------------------------------------------"); + } + else + { + Debug.Console(0, + @"---------------------------------------------- + ------------------------------------------------ + ------------------------------------------------ + Essentials file structure setup completed. + Please load config, sgd and ir files and + restart program. + ------------------------------------------------ + ------------------------------------------------ + ------------------------------------------------"); + } + + } + catch (Exception e) + { + Debug.Console(0, "FATAL INITIALIZE ERROR. System is in an inconsistent state:\r\n{0}", e); + } + finally + { + // Notify the OS that the program intitialization has completed + SystemMonitor.ProgramInitialization.ProgramInitializationComplete = true; + } + + } + + + + /// + /// Verifies filesystem is set up. IR, SGD, and programX folders + /// + bool SetupFilesystem() + { + Debug.Console(0, "Verifying and/or creating folder structure"); + var configDir = Global.FilePathPrefix; + var configExists = Directory.Exists(configDir); + if (!configExists) + Directory.Create(configDir); + + var irDir = Global.FilePathPrefix + "ir"; + if (!Directory.Exists(irDir)) + Directory.Create(irDir); + + var sgdDir = Global.FilePathPrefix + "sgd"; + if (!Directory.Exists(sgdDir)) + Directory.Create(sgdDir); + + var pluginDir = Global.FilePathPrefix + "plugins"; + if (!Directory.Exists(pluginDir)) + Directory.Create(pluginDir); + + var joinmapDir = Global.FilePathPrefix + "joinmaps"; + if(!Directory.Exists(joinmapDir)) + Directory.Create(joinmapDir); + + return configExists; + } + + /// + /// + /// + public void TearDown() + { + Debug.Console(0, "Tearing down existing system"); + DeviceManager.DeactivateAll(); + + TieLineCollection.Default.Clear(); + + foreach (var key in DeviceManager.GetDevices()) + DeviceManager.RemoveDevice(key); + + Debug.Console(0, "Tear down COMPLETE"); + } + + /// + /// + /// + void Load() + { + LoadDevices(); + LoadTieLines(); + LoadRooms(); + LoadLogoServer(); + + DeviceManager.ActivateAll(); + + var mobileControl = GetMobileControlDevice(); + + if (mobileControl == null) return; + + mobileControl.LinkSystemMonitorToAppServer(); + + } + + /// + /// Reads all devices from config and adds them to DeviceManager + /// + public void LoadDevices() + { + + // Build the processor wrapper class + DeviceManager.AddDevice(new PepperDash.Essentials.Core.Devices.CrestronProcessor("processor")); + DeviceManager.AddDevice(new EssemtialsWebApi("essentialsWebApi","Essentials Web API")); + + // Add global System Monitor device + if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance) + { + DeviceManager.AddDevice( + new PepperDash.Essentials.Core.Monitoring.SystemMonitorController("systemMonitor")); + } + + foreach (var devConf in ConfigReader.ConfigObject.Devices) + { + + try + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Creating device '{0}', type '{1}'", devConf.Key, devConf.Type); + // Skip this to prevent unnecessary warnings + if (devConf.Key == "processor") + { + var prompt = Global.ControlSystem.ControllerPrompt; + + var typeMatch = String.Equals(devConf.Type, prompt, StringComparison.OrdinalIgnoreCase) || + String.Equals(devConf.Type, prompt.Replace("-", ""), StringComparison.OrdinalIgnoreCase); + + if (!typeMatch) + Debug.Console(0, + "WARNING: Config file defines processor type as '{0}' but actual processor is '{1}'! Some ports may not be available", + devConf.Type.ToUpper(), Global.ControlSystem.ControllerPrompt.ToUpper()); + + // Check if the processor is a DMPS model + if (this.ControllerPrompt.IndexOf("dmps", StringComparison.OrdinalIgnoreCase) > -1) + { + Debug.Console(2, "Adding DmpsRoutingController for {0} to Device Manager.", this.ControllerPrompt); + + var propertiesConfig = JsonConvert.DeserializeObject(devConf.Properties.ToString()); + + if(propertiesConfig == null) + propertiesConfig = new DM.Config.DmpsRoutingPropertiesConfig(); + + DeviceManager.AddDevice(DmpsRoutingController.GetDmpsRoutingController("processor-avRouting", this.ControllerPrompt, propertiesConfig)); + } + else if (this.ControllerPrompt.IndexOf("mpc3", StringComparison.OrdinalIgnoreCase) > -1) + { + Debug.Console(2, "MPC3 processor type detected. Adding Mpc3TouchpanelController."); + + var butToken = devConf.Properties["buttons"]; + if (butToken == null) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, + "Error: Unable to deserialize buttons collection for device: {0}", devConf.Key); + continue; + } + + var buttons = butToken.ToObject>(); + var tpController = new Core.Touchpanels.Mpc3TouchpanelController( + string.Format("{0}-keypadButtons", devConf.Key), devConf.Name, Global.ControlSystem, buttons); + + DeviceManager.AddDevice(tpController); + } + else + { + Debug.Console(2, "************Processor is not DMPS type***************"); + } + + + + continue; + } + + // Try local factories first + IKeyed newDev = null; + + if (newDev == null) + newDev = PepperDash.Essentials.Core.DeviceFactory.GetDevice(devConf); + + if (newDev != null) + DeviceManager.AddDevice(newDev); + else + Debug.Console(0, Debug.ErrorLogLevel.Error, "ERROR: Cannot load unknown device type '{0}', key '{1}'.", devConf.Type, devConf.Key); + } + catch (Exception e) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "ERROR: Creating device {0}. Skipping device. \r{1}", devConf.Key, e); + } + } + Debug.Console(0, Debug.ErrorLogLevel.Notice, "All Devices Loaded."); + + } + + + /// + /// Helper method to load tie lines. This should run after devices have loaded + /// + public void LoadTieLines() + { + // In the future, we can't necessarily just clear here because devices + // might be making their own internal sources/tie lines + + var tlc = TieLineCollection.Default; + //tlc.Clear(); + if (ConfigReader.ConfigObject.TieLines == null) + { + return; + } + + foreach (var tieLineConfig in ConfigReader.ConfigObject.TieLines) + { + var newTL = tieLineConfig.GetTieLine(); + if (newTL != null) + tlc.Add(newTL); + } + + Debug.Console(0, Debug.ErrorLogLevel.Notice, "All Tie Lines Loaded."); + + } + + /// + /// Reads all rooms from config and adds them to DeviceManager + /// + public void LoadRooms() + { + if (ConfigReader.ConfigObject.Rooms == null) + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Notice: Configuration contains no rooms - Is this intentional? This may be a valid configuration."); + return; + } + + uint fusionIpId = 0xf1; + + foreach (var roomConfig in ConfigReader.ConfigObject.Rooms) + { + var room = EssentialsRoomConfigHelper.GetRoomObject(roomConfig) as IEssentialsRoom; + if (room != null) + { + // default to no join map key + string fusionJoinMapKey = string.Empty; + + if (room.Config.Properties["fusion"] != null) + { + Debug.Console(2, "Custom Fusion config found. Using custom values"); + + var fusionConfig = room.Config.Properties["fusion"].ToObject(); + + if (fusionConfig != null) + { + fusionIpId = fusionConfig.IpIdInt; + fusionJoinMapKey = fusionConfig.JoinMapKey; + } + } + + AddRoomAndBuildMC(room); + + if (room is IEssentialsHuddleSpaceRoom) + { + + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Room is EssentialsHuddleSpaceRoom, attempting to add to DeviceManager with Fusion with IP-ID {0:X2}", fusionIpId); + DeviceManager.AddDevice(new Core.Fusion.EssentialsHuddleSpaceFusionSystemControllerBase(room, fusionIpId, fusionJoinMapKey)); + + } + else if (room is IEssentialsHuddleVtc1Room) + { + + if (!(room is EssentialsCombinedHuddleVtc1Room)) + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Room is EssentialsHuddleVtc1Room, attempting to add to DeviceManager with Fusion with IP-ID {0:X2}", fusionIpId); + DeviceManager.AddDevice(new EssentialsHuddleVtc1FusionController((IEssentialsHuddleVtc1Room)room, fusionIpId, fusionJoinMapKey)); + } + + } + else if (room is EssentialsTechRoom) + { + + Debug.Console(0, Debug.ErrorLogLevel.Notice, + "Room is EssentialsTechRoom, Attempting to add to DeviceManager with Fusion with IP-ID {0:X2}", fusionIpId); + DeviceManager.AddDevice(new EssentialsTechRoomFusionSystemController((EssentialsTechRoom)room, fusionIpId, fusionJoinMapKey)); + + } + fusionIpId += 1; + } + else + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Notice: Cannot create room from config, key '{0}' - Is this intentional? This may be a valid configuration.", roomConfig.Key); + + } + } + + Debug.Console(0, Debug.ErrorLogLevel.Notice, "All Rooms Loaded."); + + } + + private static void AddRoomAndBuildMC(IEssentialsRoom room) + { + DeviceManager.AddDevice(room); + + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to build Mobile Control Bridge"); + + CreateMobileControlBridge(room); + } + + private static void CreateMobileControlBridge(object room) + { + var mobileControl = GetMobileControlDevice(); + + if (mobileControl == null) return; + + var mobileControl3 = mobileControl as IMobileControl3; + + if (mobileControl3 != null) + { + mobileControl3.CreateMobileControlRoomBridge(room as IEssentialsRoom, mobileControl); + } + else + { + mobileControl.CreateMobileControlRoomBridge(room as EssentialsRoomBase, mobileControl); + } + + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Mobile Control Bridge Added..."); + } + + private static IMobileControl GetMobileControlDevice() + { + var mobileControlList = DeviceManager.AllDevices.OfType().ToList(); + + if (mobileControlList.Count > 1) + { + Debug.Console(0, Debug.ErrorLogLevel.Warning, + "Multiple instances of Mobile Control Server found."); + + return null; + } + + if (mobileControlList.Count > 0) + { + return mobileControlList[0]; + } + + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Mobile Control not enabled for this system"); + return null; + } + + /// + /// Fires up a logo server if not already running + /// + void LoadLogoServer() + { + if (ConfigReader.ConfigObject.Rooms == null) + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "No rooms configured. Bypassing Logo server startup."); + return; + } + + if ( + !ConfigReader.ConfigObject.Rooms.Any( + CheckRoomConfig)) + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "No rooms configured to use system Logo server. Bypassing Logo server startup"); + return; + } + + try + { + LogoServer = new HttpLogoServer(8080, Global.DirectorySeparator + "html" + Global.DirectorySeparator + "logo"); + } + catch (Exception) + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "NOTICE: Logo server cannot be started. Likely already running in another program"); + } + } + + private bool CheckRoomConfig(DeviceConfig c) + { + string logoDark = null; + string logoLight = null; + string logo = null; + + try + { + if (c.Properties["logoDark"] != null) + { + logoDark = c.Properties["logoDark"].Value("type"); + } + + if (c.Properties["logoLight"] != null) + { + logoLight = c.Properties["logoLight"].Value("type"); + } + + if (c.Properties["logo"] != null) + { + logo = c.Properties["logo"].Value("type"); + } + + return ((logoDark != null && logoDark == "system") || + (logoLight != null && logoLight == "system") || (logo != null && logo == "system")); + } + catch + { + Debug.Console(1, Debug.ErrorLogLevel.Notice, "Unable to find logo information in any room config"); + return false; + } + } + } +} diff --git a/PepperDashEssentials/Devices/Amplifier.cs b/src/PepperDashEssentials/Devices/Amplifier.cs similarity index 100% rename from PepperDashEssentials/Devices/Amplifier.cs rename to src/PepperDashEssentials/Devices/Amplifier.cs diff --git a/PepperDashEssentials/Example Configuration/EssentialsHuddleSpaceRoom/configurationFile-HuddleSpace-2-Source.json b/src/PepperDashEssentials/Example Configuration/EssentialsHuddleSpaceRoom/configurationFile-HuddleSpace-2-Source.json similarity index 100% rename from PepperDashEssentials/Example Configuration/EssentialsHuddleSpaceRoom/configurationFile-HuddleSpace-2-Source.json rename to src/PepperDashEssentials/Example Configuration/EssentialsHuddleSpaceRoom/configurationFile-HuddleSpace-2-Source.json diff --git a/PepperDashEssentials/Example Configuration/EssentialsHuddleVtc1Room/configurationFile-mockVideoCodec_din-ap3_-_dm4x1.json b/src/PepperDashEssentials/Example Configuration/EssentialsHuddleVtc1Room/configurationFile-mockVideoCodec_din-ap3_-_dm4x1.json similarity index 100% rename from PepperDashEssentials/Example Configuration/EssentialsHuddleVtc1Room/configurationFile-mockVideoCodec_din-ap3_-_dm4x1.json rename to src/PepperDashEssentials/Example Configuration/EssentialsHuddleVtc1Room/configurationFile-mockVideoCodec_din-ap3_-_dm4x1.json diff --git a/PepperDashEssentials/Example Configuration/SIMPLBridging/SIMPLBridgeExample_configurationFile.json b/src/PepperDashEssentials/Example Configuration/SIMPLBridging/SIMPLBridgeExample_configurationFile.json similarity index 100% rename from PepperDashEssentials/Example Configuration/SIMPLBridging/SIMPLBridgeExample_configurationFile.json rename to src/PepperDashEssentials/Example Configuration/SIMPLBridging/SIMPLBridgeExample_configurationFile.json diff --git a/PepperDashEssentials/Example Configuration/SIMPLBridging/configurationFile-dmps3300c-avRouting.json b/src/PepperDashEssentials/Example Configuration/SIMPLBridging/configurationFile-dmps3300c-avRouting.json similarity index 100% rename from PepperDashEssentials/Example Configuration/SIMPLBridging/configurationFile-dmps3300c-avRouting.json rename to src/PepperDashEssentials/Example Configuration/SIMPLBridging/configurationFile-dmps3300c-avRouting.json diff --git a/PepperDashEssentials/Factory/DeviceFactory.cs b/src/PepperDashEssentials/Factory/DeviceFactory.cs similarity index 96% rename from PepperDashEssentials/Factory/DeviceFactory.cs rename to src/PepperDashEssentials/Factory/DeviceFactory.cs index 98c2dd13..425d0bdc 100644 --- a/PepperDashEssentials/Factory/DeviceFactory.cs +++ b/src/PepperDashEssentials/Factory/DeviceFactory.cs @@ -1,47 +1,47 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Crestron.SimplSharp; -using Crestron.SimplSharp.CrestronIO; -using Crestron.SimplSharpPro; -using Crestron.SimplSharp.Reflection; - -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; - -namespace PepperDash.Essentials -{ - /// - /// Responsible for loading all of the device types for this library - /// - public class DeviceFactory - { - - public DeviceFactory() - { - var assy = Assembly.GetExecutingAssembly(); - PluginLoader.SetEssentialsAssembly(assy.GetName().Name, assy); - - var types = assy.GetTypes().Where(ct => typeof(IDeviceFactory).IsAssignableFrom(ct) && !ct.IsInterface && !ct.IsAbstract); - - if (types != null) - { - foreach (var type in types) - { - try - { - var factory = (IDeviceFactory)Crestron.SimplSharp.Reflection.Activator.CreateInstance(type); - factory.LoadTypeFactories(); - } - catch (Exception e) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to load type: '{1}' DeviceFactory: {0}", e, type.Name); - } - } - } - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using Crestron.SimplSharp; +using Crestron.SimplSharp.CrestronIO; +using Crestron.SimplSharpPro; +using Crestron.SimplSharp.Reflection; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials +{ + /// + /// Responsible for loading all of the device types for this library + /// + public class DeviceFactory + { + + public DeviceFactory() + { + var assy = Assembly.GetExecutingAssembly(); + PluginLoader.SetEssentialsAssembly(assy.GetName().Name, assy); + + var types = assy.GetTypes().Where(ct => typeof(IDeviceFactory).IsAssignableFrom(ct) && !ct.IsInterface && !ct.IsAbstract); + + if (types != null) + { + foreach (var type in types) + { + try + { + var factory = (IDeviceFactory)Crestron.SimplSharp.Reflection.Activator.CreateInstance(type); + factory.LoadTypeFactories(); + } + catch (Exception e) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to load type: '{1}' DeviceFactory: {0}", e, type.Name); + } + } + } + } + } +} diff --git a/PepperDashEssentials/Fusion/EssentialsHuddleVtc1FusionController.cs b/src/PepperDashEssentials/Fusion/EssentialsHuddleVtc1FusionController.cs similarity index 97% rename from PepperDashEssentials/Fusion/EssentialsHuddleVtc1FusionController.cs rename to src/PepperDashEssentials/Fusion/EssentialsHuddleVtc1FusionController.cs index c3877706..5ee5a893 100644 --- a/PepperDashEssentials/Fusion/EssentialsHuddleVtc1FusionController.cs +++ b/src/PepperDashEssentials/Fusion/EssentialsHuddleVtc1FusionController.cs @@ -1,358 +1,358 @@ -using System; -using System.Linq; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.Fusion; - - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.Core.Fusion; - -namespace PepperDash.Essentials.Fusion -{ - public class EssentialsHuddleVtc1FusionController : EssentialsHuddleSpaceFusionSystemControllerBase - { - BooleanSigData CodecIsInCall; - - public EssentialsHuddleVtc1FusionController(IEssentialsHuddleVtc1Room room, uint ipId, string joinMapKey) - : base(room, ipId, joinMapKey) - { - - } - - /// - /// Called in base class constructor before RVI and GUID files are built - /// - protected override void ExecuteCustomSteps() - { - SetUpCodec(); - } - - /// - /// Creates a static asset for the codec and maps the joins to the main room symbol - /// - void SetUpCodec() - { - try - { - var codec = (Room as IEssentialsHuddleVtc1Room).VideoCodec; - - if (codec == null) - { - Debug.Console(1, this, "Cannot link codec to Fusion because codec is null"); - return; - } - - codec.UsageTracker = new UsageTracking(codec); - codec.UsageTracker.UsageIsTracked = true; - codec.UsageTracker.DeviceUsageEnded += UsageTracker_DeviceUsageEnded; - - var codecPowerOnAction = new Action(b => { if (!b) codec.StandbyDeactivate(); }); - var codecPowerOffAction = new Action(b => { if (!b) codec.StandbyActivate(); }); - - // Map FusionRoom Attributes: - - // Codec volume - var codecVolume = FusionRoom.CreateOffsetUshortSig(JoinMap.VolumeFader1.JoinNumber, JoinMap.VolumeFader1.AttributeName, eSigIoMask.InputOutputSig); - codecVolume.OutputSig.UserObject = new Action(b => (codec as IBasicVolumeWithFeedback).SetVolume(b)); - (codec as IBasicVolumeWithFeedback).VolumeLevelFeedback.LinkInputSig(codecVolume.InputSig); - - // In Call Status - CodecIsInCall = FusionRoom.CreateOffsetBoolSig(JoinMap.VcCodecInCall.JoinNumber, JoinMap.VcCodecInCall.AttributeName, eSigIoMask.InputSigOnly); - codec.CallStatusChange += new EventHandler(codec_CallStatusChange); - - // Online status - if (codec is ICommunicationMonitor) - { - var c = codec as ICommunicationMonitor; - var codecOnline = FusionRoom.CreateOffsetBoolSig(JoinMap.VcCodecOnline.JoinNumber, JoinMap.VcCodecOnline.AttributeName, eSigIoMask.InputSigOnly); - codecOnline.InputSig.BoolValue = c.CommunicationMonitor.Status == MonitorStatus.IsOk; - c.CommunicationMonitor.StatusChange += (o, a) => - { - codecOnline.InputSig.BoolValue = a.Status == MonitorStatus.IsOk; - }; - Debug.Console(0, this, "Linking '{0}' communication monitor to Fusion '{1}'", codec.Key, JoinMap.VcCodecOnline.AttributeName); - } - - // Codec IP Address - bool codecHasIpInfo = false; - var codecComm = codec.Communication; - - string codecIpAddress = string.Empty; - int codecIpPort = 0; - - StringSigData codecIpAddressSig; - StringSigData codecIpPortSig; - - if(codecComm is GenericSshClient) - { - codecIpAddress = (codecComm as GenericSshClient).Hostname; - codecIpPort = (codecComm as GenericSshClient).Port; - codecHasIpInfo = true; - } - else if (codecComm is GenericTcpIpClient) - { - codecIpAddress = (codecComm as GenericTcpIpClient).Hostname; - codecIpPort = (codecComm as GenericTcpIpClient).Port; - codecHasIpInfo = true; - } - - if (codecHasIpInfo) - { - codecIpAddressSig = FusionRoom.CreateOffsetStringSig(JoinMap.VcCodecIpAddress.JoinNumber, JoinMap.VcCodecIpAddress.AttributeName, eSigIoMask.InputSigOnly); - codecIpAddressSig.InputSig.StringValue = codecIpAddress; - - codecIpPortSig = FusionRoom.CreateOffsetStringSig(JoinMap.VcCodecIpPort.JoinNumber, JoinMap.VcCodecIpPort.AttributeName, eSigIoMask.InputSigOnly); - codecIpPortSig.InputSig.StringValue = codecIpPort.ToString(); - } - - var tempAsset = new FusionAsset(); - - var deviceConfig = ConfigReader.ConfigObject.Devices.FirstOrDefault(c => c.Key.Equals(codec.Key)); - - if (FusionStaticAssets.ContainsKey(deviceConfig.Uid)) - { - tempAsset = FusionStaticAssets[deviceConfig.Uid]; - } - else - { - // Create a new asset - tempAsset = new FusionAsset(FusionRoomGuids.GetNextAvailableAssetNumber(FusionRoom), codec.Name, "Codec", ""); - FusionStaticAssets.Add(deviceConfig.Uid, tempAsset); - } - - var codecAsset = FusionRoom.CreateStaticAsset(tempAsset.SlotNumber, tempAsset.Name, "Codec", tempAsset.InstanceId); - codecAsset.PowerOn.OutputSig.UserObject = codecPowerOnAction; - codecAsset.PowerOff.OutputSig.UserObject = codecPowerOffAction; - codec.StandbyIsOnFeedback.LinkComplementInputSig(codecAsset.PowerOn.InputSig); - - // TODO: Map relevant attributes on asset symbol - - codecAsset.TrySetMakeModel(codec); - codecAsset.TryLinkAssetErrorToCommunication(codec); - } - catch (Exception e) - { - Debug.Console(1, this, "Error setting up codec in Fusion: {0}", e); - } - } - - void codec_CallStatusChange(object sender, PepperDash.Essentials.Devices.Common.Codec.CodecCallStatusItemChangeEventArgs e) - { - var codec = (Room as IEssentialsHuddleVtc1Room).VideoCodec; - - CodecIsInCall.InputSig.BoolValue = codec.IsInCall; - } - - // These methods are overridden because they access the room class which is of a different type - - protected override void CreateSymbolAndBasicSigs(uint ipId) - { - Debug.Console(0, this, "Creating Fusion Room symbol with GUID: {0} and IP-ID {1:X2}", RoomGuid, ipId); - - FusionRoom = new FusionRoom(ipId, Global.ControlSystem, Room.Name, RoomGuid); - FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.Use(); - FusionRoom.ExtenderFusionRoomDataReservedSigs.Use(); - - FusionRoom.Register(); - - FusionRoom.FusionStateChange += FusionRoom_FusionStateChange; - - FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.DeviceExtenderSigChange += FusionRoomSchedule_DeviceExtenderSigChange; - FusionRoom.ExtenderFusionRoomDataReservedSigs.DeviceExtenderSigChange += ExtenderFusionRoomDataReservedSigs_DeviceExtenderSigChange; - FusionRoom.OnlineStatusChange += FusionRoom_OnlineStatusChange; - - CrestronConsole.AddNewConsoleCommand(RequestFullRoomSchedule, "FusReqRoomSchedule", "Requests schedule of the room for the next 24 hours", ConsoleAccessLevelEnum.AccessOperator); - CrestronConsole.AddNewConsoleCommand(ModifyMeetingEndTimeConsoleHelper, "FusReqRoomSchMod", "Ends or extends a meeting by the specified time", ConsoleAccessLevelEnum.AccessOperator); - CrestronConsole.AddNewConsoleCommand(CreateAdHocMeeting, "FusCreateMeeting", "Creates and Ad Hoc meeting for on hour or until the next meeting", ConsoleAccessLevelEnum.AccessOperator); - - // Room to fusion room - Room.OnFeedback.LinkInputSig(FusionRoom.SystemPowerOn.InputSig); - - // Moved to - CurrentRoomSourceNameSig = FusionRoom.CreateOffsetStringSig(JoinMap.Display1CurrentSourceName.JoinNumber, JoinMap.Display1CurrentSourceName.AttributeName, eSigIoMask.InputSigOnly); - // Don't think we need to get current status of this as nothing should be alive yet. - (Room as IEssentialsHuddleVtc1Room).CurrentSourceChange += Room_CurrentSourceInfoChange; - - - FusionRoom.SystemPowerOn.OutputSig.SetSigFalseAction((Room as IEssentialsHuddleVtc1Room).PowerOnToDefaultOrLastSource); - FusionRoom.SystemPowerOff.OutputSig.SetSigFalseAction(() => (Room as IEssentialsHuddleVtc1Room).RunRouteAction("roomOff", Room.SourceListKey)); - - - CrestronEnvironment.EthernetEventHandler += CrestronEnvironment_EthernetEventHandler; - } - - protected override void SetUpSources() - { - // Sources - var dict = ConfigReader.ConfigObject.GetSourceListForKey((Room as IEssentialsHuddleVtc1Room).SourceListKey); - if (dict != null) - { - // NEW PROCESS: - // Make these lists and insert the fusion attributes by iterating these - var setTopBoxes = dict.Where(d => d.Value.SourceDevice is ISetTopBoxControls); - uint i = 1; - foreach (var kvp in setTopBoxes) - { - TryAddRouteActionSigs(JoinMap.Display1DiscPlayerSourceStart.AttributeName + " " + i, JoinMap.Display1DiscPlayerSourceStart.JoinNumber + i, kvp.Key, kvp.Value.SourceDevice); - i++; - if (i > JoinMap.Display1SetTopBoxSourceStart.JoinSpan) // We only have five spots - break; - } - - var discPlayers = dict.Where(d => d.Value.SourceDevice is IDiscPlayerControls); - i = 1; - foreach (var kvp in discPlayers) - { - TryAddRouteActionSigs(JoinMap.Display1DiscPlayerSourceStart.AttributeName + " " + i, JoinMap.Display1DiscPlayerSourceStart.JoinNumber + i, kvp.Key, kvp.Value.SourceDevice); - i++; - if (i > 5) // We only have five spots - break; - } - - var laptops = dict.Where(d => d.Value.SourceDevice is Core.Devices.Laptop); - i = 1; - foreach (var kvp in laptops) - { - TryAddRouteActionSigs(JoinMap.Display1LaptopSourceStart.AttributeName + " " + i, JoinMap.Display1LaptopSourceStart.JoinNumber + i, kvp.Key, kvp.Value.SourceDevice); - i++; - if (i > JoinMap.Display1LaptopSourceStart.JoinSpan) // We only have ten spots??? - break; - } - - foreach (var kvp in dict) - { - var usageDevice = kvp.Value.SourceDevice as IUsageTracking; - - if (usageDevice != null) - { - usageDevice.UsageTracker = new UsageTracking(usageDevice as Device); - usageDevice.UsageTracker.UsageIsTracked = true; - usageDevice.UsageTracker.DeviceUsageEnded += new EventHandler(UsageTracker_DeviceUsageEnded); - } - } - - } - else - { - Debug.Console(1, this, "WARNING: Config source list '{0}' not found for room '{1}'", - (Room as IEssentialsHuddleVtc1Room).SourceListKey, Room.Key); - } - } - - protected override void SetUpDisplay() - { - try - { - //Setup Display Usage Monitoring - - var displays = DeviceManager.AllDevices.Where(d => d is DisplayBase); - - // Consider updating this in multiple display systems - - foreach (DisplayBase display in displays) - { - display.UsageTracker = new UsageTracking(display); - display.UsageTracker.UsageIsTracked = true; - display.UsageTracker.DeviceUsageEnded += new EventHandler(UsageTracker_DeviceUsageEnded); - } - - var defaultDisplay = (Room as IEssentialsHuddleVtc1Room).DefaultDisplay as DisplayBase; - if (defaultDisplay == null) - { - Debug.Console(1, this, "Cannot link null display to Fusion because default display is null"); - return; - } - - var dispPowerOnAction = new Action(b => { if (!b) defaultDisplay.PowerOn(); }); - var dispPowerOffAction = new Action(b => { if (!b) defaultDisplay.PowerOff(); }); - - // Display to fusion room sigs - FusionRoom.DisplayPowerOn.OutputSig.UserObject = dispPowerOnAction; - FusionRoom.DisplayPowerOff.OutputSig.UserObject = dispPowerOffAction; - - var defaultDisplayTwoWay = defaultDisplay as IHasPowerControlWithFeedback; - if (defaultDisplayTwoWay != null) - { - defaultDisplayTwoWay.PowerIsOnFeedback.LinkInputSig(FusionRoom.DisplayPowerOn.InputSig); - } - - if (defaultDisplay is IDisplayUsage) - (defaultDisplay as IDisplayUsage).LampHours.LinkInputSig(FusionRoom.DisplayUsage.InputSig); - - MapDisplayToRoomJoins(1, JoinMap.Display1Start.JoinNumber, defaultDisplay); - - var deviceConfig = ConfigReader.ConfigObject.Devices.FirstOrDefault(d => d.Key.Equals(defaultDisplay.Key)); - - //Check for existing asset in GUIDs collection - - var tempAsset = new FusionAsset(); - - if (FusionStaticAssets.ContainsKey(deviceConfig.Uid)) - { - tempAsset = FusionStaticAssets[deviceConfig.Uid]; - } - else - { - // Create a new asset - tempAsset = new FusionAsset(FusionRoomGuids.GetNextAvailableAssetNumber(FusionRoom), defaultDisplay.Name, "Display", ""); - FusionStaticAssets.Add(deviceConfig.Uid, tempAsset); - } - - var dispAsset = FusionRoom.CreateStaticAsset(tempAsset.SlotNumber, tempAsset.Name, "Display", tempAsset.InstanceId); - dispAsset.PowerOn.OutputSig.UserObject = dispPowerOnAction; - dispAsset.PowerOff.OutputSig.UserObject = dispPowerOffAction; - - - var defaultTwoWayDisplay = defaultDisplay as IHasPowerControlWithFeedback; - if (defaultTwoWayDisplay != null) - { - defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(FusionRoom.DisplayPowerOn.InputSig); - if (defaultDisplay is IDisplayUsage) - (defaultDisplay as IDisplayUsage).LampHours.LinkInputSig(FusionRoom.DisplayUsage.InputSig); - - defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(dispAsset.PowerOn.InputSig); - } - - // Use extension methods - dispAsset.TrySetMakeModel(defaultDisplay); - dispAsset.TryLinkAssetErrorToCommunication(defaultDisplay); - } - catch (Exception e) - { - Debug.Console(1, this, "Error setting up display in Fusion: {0}", e); - } - - } - - protected override void MapDisplayToRoomJoins(int displayIndex, uint joinOffset, DisplayBase display) - { - string displayName = string.Format("Display {0} - ", displayIndex); - - - if (display == (Room as IEssentialsHuddleVtc1Room).DefaultDisplay) - { - // Power on - var defaultDisplayPowerOn = FusionRoom.CreateOffsetBoolSig((uint)joinOffset, displayName + "Power On", eSigIoMask.InputOutputSig); - defaultDisplayPowerOn.OutputSig.UserObject = new Action(b => { if (!b) display.PowerOn(); }); - - // Power Off - var defaultDisplayPowerOff = FusionRoom.CreateOffsetBoolSig((uint)joinOffset + 1, displayName + "Power Off", eSigIoMask.InputOutputSig); - defaultDisplayPowerOn.OutputSig.UserObject = new Action(b => { if (!b) display.PowerOff(); }); ; - - var displayTwoWay = display as IHasPowerControlWithFeedback; - if (displayTwoWay != null) - { - displayTwoWay.PowerIsOnFeedback.LinkInputSig(defaultDisplayPowerOn.InputSig); - displayTwoWay.PowerIsOnFeedback.LinkInputSig(defaultDisplayPowerOn.InputSig); - } - - // Current Source - var defaultDisplaySourceNone = FusionRoom.CreateOffsetBoolSig((uint)joinOffset + 8, displayName + "Source None", eSigIoMask.InputOutputSig); - defaultDisplaySourceNone.OutputSig.UserObject = new Action(b => { if (!b) (Room as IEssentialsHuddleVtc1Room).RunRouteAction("roomOff", Room.SourceListKey); }); ; - } - } - } +using System; +using System.Linq; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.Fusion; + + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.Core.Fusion; + +namespace PepperDash.Essentials.Fusion +{ + public class EssentialsHuddleVtc1FusionController : EssentialsHuddleSpaceFusionSystemControllerBase + { + BooleanSigData CodecIsInCall; + + public EssentialsHuddleVtc1FusionController(IEssentialsHuddleVtc1Room room, uint ipId, string joinMapKey) + : base(room, ipId, joinMapKey) + { + + } + + /// + /// Called in base class constructor before RVI and GUID files are built + /// + protected override void ExecuteCustomSteps() + { + SetUpCodec(); + } + + /// + /// Creates a static asset for the codec and maps the joins to the main room symbol + /// + void SetUpCodec() + { + try + { + var codec = (Room as IEssentialsHuddleVtc1Room).VideoCodec; + + if (codec == null) + { + Debug.Console(1, this, "Cannot link codec to Fusion because codec is null"); + return; + } + + codec.UsageTracker = new UsageTracking(codec); + codec.UsageTracker.UsageIsTracked = true; + codec.UsageTracker.DeviceUsageEnded += UsageTracker_DeviceUsageEnded; + + var codecPowerOnAction = new Action(b => { if (!b) codec.StandbyDeactivate(); }); + var codecPowerOffAction = new Action(b => { if (!b) codec.StandbyActivate(); }); + + // Map FusionRoom Attributes: + + // Codec volume + var codecVolume = FusionRoom.CreateOffsetUshortSig(JoinMap.VolumeFader1.JoinNumber, JoinMap.VolumeFader1.AttributeName, eSigIoMask.InputOutputSig); + codecVolume.OutputSig.UserObject = new Action(b => (codec as IBasicVolumeWithFeedback).SetVolume(b)); + (codec as IBasicVolumeWithFeedback).VolumeLevelFeedback.LinkInputSig(codecVolume.InputSig); + + // In Call Status + CodecIsInCall = FusionRoom.CreateOffsetBoolSig(JoinMap.VcCodecInCall.JoinNumber, JoinMap.VcCodecInCall.AttributeName, eSigIoMask.InputSigOnly); + codec.CallStatusChange += new EventHandler(codec_CallStatusChange); + + // Online status + if (codec is ICommunicationMonitor) + { + var c = codec as ICommunicationMonitor; + var codecOnline = FusionRoom.CreateOffsetBoolSig(JoinMap.VcCodecOnline.JoinNumber, JoinMap.VcCodecOnline.AttributeName, eSigIoMask.InputSigOnly); + codecOnline.InputSig.BoolValue = c.CommunicationMonitor.Status == MonitorStatus.IsOk; + c.CommunicationMonitor.StatusChange += (o, a) => + { + codecOnline.InputSig.BoolValue = a.Status == MonitorStatus.IsOk; + }; + Debug.Console(0, this, "Linking '{0}' communication monitor to Fusion '{1}'", codec.Key, JoinMap.VcCodecOnline.AttributeName); + } + + // Codec IP Address + bool codecHasIpInfo = false; + var codecComm = codec.Communication; + + string codecIpAddress = string.Empty; + int codecIpPort = 0; + + StringSigData codecIpAddressSig; + StringSigData codecIpPortSig; + + if(codecComm is GenericSshClient) + { + codecIpAddress = (codecComm as GenericSshClient).Hostname; + codecIpPort = (codecComm as GenericSshClient).Port; + codecHasIpInfo = true; + } + else if (codecComm is GenericTcpIpClient) + { + codecIpAddress = (codecComm as GenericTcpIpClient).Hostname; + codecIpPort = (codecComm as GenericTcpIpClient).Port; + codecHasIpInfo = true; + } + + if (codecHasIpInfo) + { + codecIpAddressSig = FusionRoom.CreateOffsetStringSig(JoinMap.VcCodecIpAddress.JoinNumber, JoinMap.VcCodecIpAddress.AttributeName, eSigIoMask.InputSigOnly); + codecIpAddressSig.InputSig.StringValue = codecIpAddress; + + codecIpPortSig = FusionRoom.CreateOffsetStringSig(JoinMap.VcCodecIpPort.JoinNumber, JoinMap.VcCodecIpPort.AttributeName, eSigIoMask.InputSigOnly); + codecIpPortSig.InputSig.StringValue = codecIpPort.ToString(); + } + + var tempAsset = new FusionAsset(); + + var deviceConfig = ConfigReader.ConfigObject.Devices.FirstOrDefault(c => c.Key.Equals(codec.Key)); + + if (FusionStaticAssets.ContainsKey(deviceConfig.Uid)) + { + tempAsset = FusionStaticAssets[deviceConfig.Uid]; + } + else + { + // Create a new asset + tempAsset = new FusionAsset(FusionRoomGuids.GetNextAvailableAssetNumber(FusionRoom), codec.Name, "Codec", ""); + FusionStaticAssets.Add(deviceConfig.Uid, tempAsset); + } + + var codecAsset = FusionRoom.CreateStaticAsset(tempAsset.SlotNumber, tempAsset.Name, "Codec", tempAsset.InstanceId); + codecAsset.PowerOn.OutputSig.UserObject = codecPowerOnAction; + codecAsset.PowerOff.OutputSig.UserObject = codecPowerOffAction; + codec.StandbyIsOnFeedback.LinkComplementInputSig(codecAsset.PowerOn.InputSig); + + // TODO: Map relevant attributes on asset symbol + + codecAsset.TrySetMakeModel(codec); + codecAsset.TryLinkAssetErrorToCommunication(codec); + } + catch (Exception e) + { + Debug.Console(1, this, "Error setting up codec in Fusion: {0}", e); + } + } + + void codec_CallStatusChange(object sender, PepperDash.Essentials.Devices.Common.Codec.CodecCallStatusItemChangeEventArgs e) + { + var codec = (Room as IEssentialsHuddleVtc1Room).VideoCodec; + + CodecIsInCall.InputSig.BoolValue = codec.IsInCall; + } + + // These methods are overridden because they access the room class which is of a different type + + protected override void CreateSymbolAndBasicSigs(uint ipId) + { + Debug.Console(0, this, "Creating Fusion Room symbol with GUID: {0} and IP-ID {1:X2}", RoomGuid, ipId); + + FusionRoom = new FusionRoom(ipId, Global.ControlSystem, Room.Name, RoomGuid); + FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.Use(); + FusionRoom.ExtenderFusionRoomDataReservedSigs.Use(); + + FusionRoom.Register(); + + FusionRoom.FusionStateChange += FusionRoom_FusionStateChange; + + FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.DeviceExtenderSigChange += FusionRoomSchedule_DeviceExtenderSigChange; + FusionRoom.ExtenderFusionRoomDataReservedSigs.DeviceExtenderSigChange += ExtenderFusionRoomDataReservedSigs_DeviceExtenderSigChange; + FusionRoom.OnlineStatusChange += FusionRoom_OnlineStatusChange; + + CrestronConsole.AddNewConsoleCommand(RequestFullRoomSchedule, "FusReqRoomSchedule", "Requests schedule of the room for the next 24 hours", ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(ModifyMeetingEndTimeConsoleHelper, "FusReqRoomSchMod", "Ends or extends a meeting by the specified time", ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(CreateAdHocMeeting, "FusCreateMeeting", "Creates and Ad Hoc meeting for on hour or until the next meeting", ConsoleAccessLevelEnum.AccessOperator); + + // Room to fusion room + Room.OnFeedback.LinkInputSig(FusionRoom.SystemPowerOn.InputSig); + + // Moved to + CurrentRoomSourceNameSig = FusionRoom.CreateOffsetStringSig(JoinMap.Display1CurrentSourceName.JoinNumber, JoinMap.Display1CurrentSourceName.AttributeName, eSigIoMask.InputSigOnly); + // Don't think we need to get current status of this as nothing should be alive yet. + (Room as IEssentialsHuddleVtc1Room).CurrentSourceChange += Room_CurrentSourceInfoChange; + + + FusionRoom.SystemPowerOn.OutputSig.SetSigFalseAction((Room as IEssentialsHuddleVtc1Room).PowerOnToDefaultOrLastSource); + FusionRoom.SystemPowerOff.OutputSig.SetSigFalseAction(() => (Room as IEssentialsHuddleVtc1Room).RunRouteAction("roomOff", Room.SourceListKey)); + + + CrestronEnvironment.EthernetEventHandler += CrestronEnvironment_EthernetEventHandler; + } + + protected override void SetUpSources() + { + // Sources + var dict = ConfigReader.ConfigObject.GetSourceListForKey((Room as IEssentialsHuddleVtc1Room).SourceListKey); + if (dict != null) + { + // NEW PROCESS: + // Make these lists and insert the fusion attributes by iterating these + var setTopBoxes = dict.Where(d => d.Value.SourceDevice is ISetTopBoxControls); + uint i = 1; + foreach (var kvp in setTopBoxes) + { + TryAddRouteActionSigs(JoinMap.Display1DiscPlayerSourceStart.AttributeName + " " + i, JoinMap.Display1DiscPlayerSourceStart.JoinNumber + i, kvp.Key, kvp.Value.SourceDevice); + i++; + if (i > JoinMap.Display1SetTopBoxSourceStart.JoinSpan) // We only have five spots + break; + } + + var discPlayers = dict.Where(d => d.Value.SourceDevice is IDiscPlayerControls); + i = 1; + foreach (var kvp in discPlayers) + { + TryAddRouteActionSigs(JoinMap.Display1DiscPlayerSourceStart.AttributeName + " " + i, JoinMap.Display1DiscPlayerSourceStart.JoinNumber + i, kvp.Key, kvp.Value.SourceDevice); + i++; + if (i > 5) // We only have five spots + break; + } + + var laptops = dict.Where(d => d.Value.SourceDevice is Core.Devices.Laptop); + i = 1; + foreach (var kvp in laptops) + { + TryAddRouteActionSigs(JoinMap.Display1LaptopSourceStart.AttributeName + " " + i, JoinMap.Display1LaptopSourceStart.JoinNumber + i, kvp.Key, kvp.Value.SourceDevice); + i++; + if (i > JoinMap.Display1LaptopSourceStart.JoinSpan) // We only have ten spots??? + break; + } + + foreach (var kvp in dict) + { + var usageDevice = kvp.Value.SourceDevice as IUsageTracking; + + if (usageDevice != null) + { + usageDevice.UsageTracker = new UsageTracking(usageDevice as Device); + usageDevice.UsageTracker.UsageIsTracked = true; + usageDevice.UsageTracker.DeviceUsageEnded += new EventHandler(UsageTracker_DeviceUsageEnded); + } + } + + } + else + { + Debug.Console(1, this, "WARNING: Config source list '{0}' not found for room '{1}'", + (Room as IEssentialsHuddleVtc1Room).SourceListKey, Room.Key); + } + } + + protected override void SetUpDisplay() + { + try + { + //Setup Display Usage Monitoring + + var displays = DeviceManager.AllDevices.Where(d => d is DisplayBase); + + // Consider updating this in multiple display systems + + foreach (DisplayBase display in displays) + { + display.UsageTracker = new UsageTracking(display); + display.UsageTracker.UsageIsTracked = true; + display.UsageTracker.DeviceUsageEnded += new EventHandler(UsageTracker_DeviceUsageEnded); + } + + var defaultDisplay = (Room as IEssentialsHuddleVtc1Room).DefaultDisplay as DisplayBase; + if (defaultDisplay == null) + { + Debug.Console(1, this, "Cannot link null display to Fusion because default display is null"); + return; + } + + var dispPowerOnAction = new Action(b => { if (!b) defaultDisplay.PowerOn(); }); + var dispPowerOffAction = new Action(b => { if (!b) defaultDisplay.PowerOff(); }); + + // Display to fusion room sigs + FusionRoom.DisplayPowerOn.OutputSig.UserObject = dispPowerOnAction; + FusionRoom.DisplayPowerOff.OutputSig.UserObject = dispPowerOffAction; + + var defaultDisplayTwoWay = defaultDisplay as IHasPowerControlWithFeedback; + if (defaultDisplayTwoWay != null) + { + defaultDisplayTwoWay.PowerIsOnFeedback.LinkInputSig(FusionRoom.DisplayPowerOn.InputSig); + } + + if (defaultDisplay is IDisplayUsage) + (defaultDisplay as IDisplayUsage).LampHours.LinkInputSig(FusionRoom.DisplayUsage.InputSig); + + MapDisplayToRoomJoins(1, JoinMap.Display1Start.JoinNumber, defaultDisplay); + + var deviceConfig = ConfigReader.ConfigObject.Devices.FirstOrDefault(d => d.Key.Equals(defaultDisplay.Key)); + + //Check for existing asset in GUIDs collection + + var tempAsset = new FusionAsset(); + + if (FusionStaticAssets.ContainsKey(deviceConfig.Uid)) + { + tempAsset = FusionStaticAssets[deviceConfig.Uid]; + } + else + { + // Create a new asset + tempAsset = new FusionAsset(FusionRoomGuids.GetNextAvailableAssetNumber(FusionRoom), defaultDisplay.Name, "Display", ""); + FusionStaticAssets.Add(deviceConfig.Uid, tempAsset); + } + + var dispAsset = FusionRoom.CreateStaticAsset(tempAsset.SlotNumber, tempAsset.Name, "Display", tempAsset.InstanceId); + dispAsset.PowerOn.OutputSig.UserObject = dispPowerOnAction; + dispAsset.PowerOff.OutputSig.UserObject = dispPowerOffAction; + + + var defaultTwoWayDisplay = defaultDisplay as IHasPowerControlWithFeedback; + if (defaultTwoWayDisplay != null) + { + defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(FusionRoom.DisplayPowerOn.InputSig); + if (defaultDisplay is IDisplayUsage) + (defaultDisplay as IDisplayUsage).LampHours.LinkInputSig(FusionRoom.DisplayUsage.InputSig); + + defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(dispAsset.PowerOn.InputSig); + } + + // Use extension methods + dispAsset.TrySetMakeModel(defaultDisplay); + dispAsset.TryLinkAssetErrorToCommunication(defaultDisplay); + } + catch (Exception e) + { + Debug.Console(1, this, "Error setting up display in Fusion: {0}", e); + } + + } + + protected override void MapDisplayToRoomJoins(int displayIndex, uint joinOffset, DisplayBase display) + { + string displayName = string.Format("Display {0} - ", displayIndex); + + + if (display == (Room as IEssentialsHuddleVtc1Room).DefaultDisplay) + { + // Power on + var defaultDisplayPowerOn = FusionRoom.CreateOffsetBoolSig((uint)joinOffset, displayName + "Power On", eSigIoMask.InputOutputSig); + defaultDisplayPowerOn.OutputSig.UserObject = new Action(b => { if (!b) display.PowerOn(); }); + + // Power Off + var defaultDisplayPowerOff = FusionRoom.CreateOffsetBoolSig((uint)joinOffset + 1, displayName + "Power Off", eSigIoMask.InputOutputSig); + defaultDisplayPowerOn.OutputSig.UserObject = new Action(b => { if (!b) display.PowerOff(); }); ; + + var displayTwoWay = display as IHasPowerControlWithFeedback; + if (displayTwoWay != null) + { + displayTwoWay.PowerIsOnFeedback.LinkInputSig(defaultDisplayPowerOn.InputSig); + displayTwoWay.PowerIsOnFeedback.LinkInputSig(defaultDisplayPowerOn.InputSig); + } + + // Current Source + var defaultDisplaySourceNone = FusionRoom.CreateOffsetBoolSig((uint)joinOffset + 8, displayName + "Source None", eSigIoMask.InputOutputSig); + defaultDisplaySourceNone.OutputSig.UserObject = new Action(b => { if (!b) (Room as IEssentialsHuddleVtc1Room).RunRouteAction("roomOff", Room.SourceListKey); }); ; + } + } + } } \ No newline at end of file diff --git a/PepperDashEssentials/Fusion/EssentialsTechRoomFusionSystemController.cs b/src/PepperDashEssentials/Fusion/EssentialsTechRoomFusionSystemController.cs similarity index 100% rename from PepperDashEssentials/Fusion/EssentialsTechRoomFusionSystemController.cs rename to src/PepperDashEssentials/Fusion/EssentialsTechRoomFusionSystemController.cs diff --git a/PepperDashEssentials/Fusion/FusionSystemController.cs.orig b/src/PepperDashEssentials/Fusion/FusionSystemController.cs.orig similarity index 100% rename from PepperDashEssentials/Fusion/FusionSystemController.cs.orig rename to src/PepperDashEssentials/Fusion/FusionSystemController.cs.orig diff --git a/PepperDashEssentials/PepperDash Essentials TSW-760.sgd b/src/PepperDashEssentials/PepperDash Essentials TSW-760.sgd similarity index 100% rename from PepperDashEssentials/PepperDash Essentials TSW-760.sgd rename to src/PepperDashEssentials/PepperDash Essentials TSW-760.sgd diff --git a/PepperDashEssentials/PepperDash Essentials iPad.sgd b/src/PepperDashEssentials/PepperDash Essentials iPad.sgd similarity index 100% rename from PepperDashEssentials/PepperDash Essentials iPad.sgd rename to src/PepperDashEssentials/PepperDash Essentials iPad.sgd diff --git a/PepperDashEssentials/PepperDashEssentials.csproj b/src/PepperDashEssentials/PepperDashEssentials.csproj similarity index 98% rename from PepperDashEssentials/PepperDashEssentials.csproj rename to src/PepperDashEssentials/PepperDashEssentials.csproj index 66a20f72..90d81dc4 100644 --- a/PepperDashEssentials/PepperDashEssentials.csproj +++ b/src/PepperDashEssentials/PepperDashEssentials.csproj @@ -1,233 +1,233 @@ - - - Release - AnyCPU - 9.0.30729 - 2.0 - {1BED5BA9-88C4-4365-9362-6F4B128071D3} - Library - Properties - PepperDashEssentials - PepperDashEssentials - {0B4745B0-194B-4BB6-8E21-E9057CA92230};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - WindowsCE - E2BECB1F-8C8C-41ba-B736-9BE7D946A398 - 5.0 - SmartDeviceProject1 - v3.5 - Windows CE - - - - - .allowedReferenceRelatedFileExtensions - true - full - false - bin\ - DEBUG;TRACE; - prompt - 4 - 512 - true - true - off - - - .allowedReferenceRelatedFileExtensions - none - true - bin\ - prompt - 4 - 512 - true - true - off - - - - False - ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll - - - False - ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DM.dll - - - False - ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.EthernetCommunications.dll - - - False - ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Fusion.dll - - - False - ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Remotes.dll - - - False - ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll - - - - False - ..\packages\PepperDashCore\lib\net35\PepperDash_Core.dll - - - False - ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll - - - False - ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll - - - False - ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll - - - False - ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe - - - False - ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll - - - False - ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpTimerEventInterface.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Always - - - Always - - - Always - - - Always - - - - Always - - - Always - - - Always - - - - - {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} - PepperDash_Essentials_Core - - - {892B761C-E479-44CE-BD74-243E9214AF13} - Essentials Devices Common - - - {9199CE8A-0C9F-4952-8672-3EED798B284F} - PepperDash_Essentials_DM - - - - - - - - - rem S# Pro preparation will execute after these operations - + + + Release + AnyCPU + 9.0.30729 + 2.0 + {1BED5BA9-88C4-4365-9362-6F4B128071D3} + Library + Properties + PepperDashEssentials + PepperDashEssentials + {0B4745B0-194B-4BB6-8E21-E9057CA92230};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + WindowsCE + E2BECB1F-8C8C-41ba-B736-9BE7D946A398 + 5.0 + SmartDeviceProject1 + v3.5 + Windows CE + + + + + .allowedReferenceRelatedFileExtensions + true + full + false + bin\ + DEBUG;TRACE; + prompt + 4 + 512 + true + true + off + + + .allowedReferenceRelatedFileExtensions + none + true + bin\ + prompt + 4 + 512 + true + true + off + + + + False + ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll + + + False + ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DM.dll + + + False + ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.EthernetCommunications.dll + + + False + ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Fusion.dll + + + False + ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Remotes.dll + + + False + ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll + + + + False + ..\packages\PepperDashCore\lib\net35\PepperDash_Core.dll + + + False + ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll + + + False + ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll + + + False + ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll + + + False + ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe + + + False + ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll + + + False + ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpTimerEventInterface.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Always + + + Always + + + Always + + + Always + + + + Always + + + Always + + + Always + + + + + {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} + PepperDash_Essentials_Core + + + {892B761C-E479-44CE-BD74-243E9214AF13} + Essentials Devices Common + + + {9199CE8A-0C9F-4952-8672-3EED798B284F} + PepperDash_Essentials_DM + + + + + + + + + rem S# Pro preparation will execute after these operations + \ No newline at end of file diff --git a/PepperDashEssentials/PluginLoading/PluginLoading.cs b/src/PepperDashEssentials/PluginLoading/PluginLoading.cs similarity index 100% rename from PepperDashEssentials/PluginLoading/PluginLoading.cs rename to src/PepperDashEssentials/PluginLoading/PluginLoading.cs diff --git a/PepperDashEssentials/Properties/AssemblyInfo.cs b/src/PepperDashEssentials/Properties/AssemblyInfo.cs similarity index 100% rename from PepperDashEssentials/Properties/AssemblyInfo.cs rename to src/PepperDashEssentials/Properties/AssemblyInfo.cs diff --git a/PepperDashEssentials/Properties/AssemblyInfo.cs.orig b/src/PepperDashEssentials/Properties/AssemblyInfo.cs.orig similarity index 100% rename from PepperDashEssentials/Properties/AssemblyInfo.cs.orig rename to src/PepperDashEssentials/Properties/AssemblyInfo.cs.orig diff --git a/PepperDashEssentials/Properties/ControlSystem.cfg b/src/PepperDashEssentials/Properties/ControlSystem.cfg similarity index 97% rename from PepperDashEssentials/Properties/ControlSystem.cfg rename to src/PepperDashEssentials/Properties/ControlSystem.cfg index 384bf949..63f26150 100644 --- a/PepperDashEssentials/Properties/ControlSystem.cfg +++ b/src/PepperDashEssentials/Properties/ControlSystem.cfg @@ -1,7 +1,7 @@ - - - Test RMC3 -
auto 192.168.1.40;username crestron
- Program01 - Internal Flash + + + Test RMC3 +
auto 192.168.1.40;username crestron
+ Program01 + Internal Flash
\ No newline at end of file diff --git a/PepperDashEssentials/Properties/UpdateAssemblyVersion.ps1 b/src/PepperDashEssentials/Properties/UpdateAssemblyVersion.ps1 similarity index 100% rename from PepperDashEssentials/Properties/UpdateAssemblyVersion.ps1 rename to src/PepperDashEssentials/Properties/UpdateAssemblyVersion.ps1 diff --git a/PepperDashEssentials/Room/Config/EssentialsDualDisplayRoomPropertiesConfig.cs b/src/PepperDashEssentials/Room/Config/EssentialsDualDisplayRoomPropertiesConfig.cs similarity index 100% rename from PepperDashEssentials/Room/Config/EssentialsDualDisplayRoomPropertiesConfig.cs rename to src/PepperDashEssentials/Room/Config/EssentialsDualDisplayRoomPropertiesConfig.cs diff --git a/PepperDashEssentials/Room/Config/EssentialsHuddleRoomPropertiesConfig.cs b/src/PepperDashEssentials/Room/Config/EssentialsHuddleRoomPropertiesConfig.cs similarity index 100% rename from PepperDashEssentials/Room/Config/EssentialsHuddleRoomPropertiesConfig.cs rename to src/PepperDashEssentials/Room/Config/EssentialsHuddleRoomPropertiesConfig.cs diff --git a/PepperDashEssentials/Room/Config/EssentialsHuddleVtc1PropertiesConfig.cs b/src/PepperDashEssentials/Room/Config/EssentialsHuddleVtc1PropertiesConfig.cs similarity index 100% rename from PepperDashEssentials/Room/Config/EssentialsHuddleVtc1PropertiesConfig.cs rename to src/PepperDashEssentials/Room/Config/EssentialsHuddleVtc1PropertiesConfig.cs diff --git a/PepperDashEssentials/Room/Config/EssentialsNDisplayRoomPropertiesConfig.cs b/src/PepperDashEssentials/Room/Config/EssentialsNDisplayRoomPropertiesConfig.cs similarity index 100% rename from PepperDashEssentials/Room/Config/EssentialsNDisplayRoomPropertiesConfig.cs rename to src/PepperDashEssentials/Room/Config/EssentialsNDisplayRoomPropertiesConfig.cs diff --git a/PepperDashEssentials/Room/Config/EssentialsPresentationPropertiesConfig.cs b/src/PepperDashEssentials/Room/Config/EssentialsPresentationPropertiesConfig.cs similarity index 100% rename from PepperDashEssentials/Room/Config/EssentialsPresentationPropertiesConfig.cs rename to src/PepperDashEssentials/Room/Config/EssentialsPresentationPropertiesConfig.cs diff --git a/PepperDashEssentials/Room/Config/EssentialsRoomConfig.cs b/src/PepperDashEssentials/Room/Config/EssentialsRoomConfig.cs similarity index 96% rename from PepperDashEssentials/Room/Config/EssentialsRoomConfig.cs rename to src/PepperDashEssentials/Room/Config/EssentialsRoomConfig.cs index 38067528..1739a45f 100644 --- a/PepperDashEssentials/Room/Config/EssentialsRoomConfig.cs +++ b/src/PepperDashEssentials/Room/Config/EssentialsRoomConfig.cs @@ -1,411 +1,411 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Crestron.SimplSharp; -using Newtonsoft.Json; - -using PepperDash.Core; -using PepperDash.Essentials; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; - -namespace PepperDash.Essentials.Room.Config -{ - public class EssentialsRoomConfigHelper - { - /// - /// Returns a room object from this config data - /// - /// - public static IKeyed GetRoomObject(DeviceConfig roomConfig) - { - var typeName = roomConfig.Type.ToLower(); - - switch (typeName) - { - case "huddle" : - { - return new EssentialsHuddleSpaceRoom(roomConfig); - } - case "huddlevtc1" : - { - return new EssentialsHuddleVtc1Room(roomConfig); - } - case "ddvc01bridge" : - { - return new Device(roomConfig.Key, roomConfig.Name); // placeholder device that does nothing. - } - case "dualdisplay" : - { - return new EssentialsDualDisplayRoom(roomConfig); - } - case "combinedhuddlevtc1" : - { - return new EssentialsCombinedHuddleVtc1Room(roomConfig); - } - case "techroom" : - { - return new EssentialsTechRoom(roomConfig); - } - default : - { - return Core.DeviceFactory.GetDevice(roomConfig); - } - } - } - - /// - /// Gets and operating, standalone emergegncy object that can be plugged into a room. - /// Returns null if there is no emergency defined - /// - public static EssentialsRoomEmergencyBase GetEmergency(EssentialsRoomPropertiesConfig props, IEssentialsRoom room) - { - // This emergency - var emergency = props.Emergency; - if (emergency != null) - { - //switch on emergency type here. Right now only contact and shutdown - var e = new EssentialsRoomEmergencyContactClosure(room.Key + "-emergency", props.Emergency, room); - DeviceManager.AddDevice(e); - } - return null; - } - - /// - /// - /// - /// - /// - /// - public static Core.Privacy.MicrophonePrivacyController GetMicrophonePrivacy( - EssentialsRoomPropertiesConfig props, IPrivacy room) - { - var microphonePrivacy = props.MicrophonePrivacy; - if (microphonePrivacy == null) - { - Debug.Console(0, "Cannot create microphone privacy with null properties"); - return null; - } - // Get the MicrophonePrivacy device from the device manager - var mP = (DeviceManager.GetDeviceForKey(props.MicrophonePrivacy.DeviceKey) as - Core.Privacy.MicrophonePrivacyController); - // Set this room as the IPrivacy device - if (mP == null) - { - Debug.Console(0, "ERROR: Selected device {0} is not MicrophonePrivacyController", props.MicrophonePrivacy.DeviceKey); - return null; - } - mP.SetPrivacyDevice(room); - - var behaviour = props.MicrophonePrivacy.Behaviour.ToLower(); - - if (behaviour == null) - { - Debug.Console(0, "WARNING: No behaviour defined for MicrophonePrivacyController"); - return null; - } - if (behaviour == "trackroomstate") - { - // Tie LED enable to room power state - var essRoom = room as IEssentialsRoom; - essRoom.OnFeedback.OutputChange += (o, a) => - { - if (essRoom.OnFeedback.BoolValue) - mP.EnableLeds = true; - else - mP.EnableLeds = false; - }; - - mP.EnableLeds = essRoom.OnFeedback.BoolValue; - } - else if (behaviour == "trackcallstate") - { - // Tie LED enable to room power state - var inCallRoom = room as IHasInCallFeedback; - inCallRoom.InCallFeedback.OutputChange += (o, a) => - { - if (inCallRoom.InCallFeedback.BoolValue) - mP.EnableLeds = true; - else - mP.EnableLeds = false; - }; - - mP.EnableLeds = inCallRoom.InCallFeedback.BoolValue; - } - - return mP; - } - - } - - /// - /// - /// - public class EssentialsRoomPropertiesConfig - { - [JsonProperty("addresses")] - public EssentialsRoomAddressPropertiesConfig Addresses { get; set; } - - [JsonProperty("description")] - public string Description { get; set; } - - [JsonProperty("emergency")] - public EssentialsRoomEmergencyConfig Emergency { get; set; } - - [JsonProperty("help")] - public EssentialsHelpPropertiesConfig Help { get; set; } - - [JsonProperty("helpMessage")] - public string HelpMessage { get; set; } - - /// - /// Read this value to get the help message. It checks for the old and new config format. - /// - public string HelpMessageForDisplay - { - get - { - if(Help != null && !string.IsNullOrEmpty(Help.Message)) - { - return Help.Message; - } - else - { - return HelpMessage; - } - } - } - - [JsonProperty("environment")] - public EssentialsEnvironmentPropertiesConfig Environment { get; set; } - - [JsonProperty("logo")] - public EssentialsLogoPropertiesConfig LogoLight { get; set; } - - [JsonProperty("logoDark")] - public EssentialsLogoPropertiesConfig LogoDark { get; set; } - - [JsonProperty("microphonePrivacy")] - public EssentialsRoomMicrophonePrivacyConfig MicrophonePrivacy { get; set; } - - [JsonProperty("occupancy")] - public EssentialsRoomOccSensorConfig Occupancy { get; set; } - - [JsonProperty("oneButtonMeeting")] - public EssentialsOneButtonMeetingPropertiesConfig OneButtonMeeting { get; set; } - - [JsonProperty("shutdownVacancySeconds")] - public int ShutdownVacancySeconds { get; set; } - - [JsonProperty("shutdownPromptSeconds")] - public int ShutdownPromptSeconds { get; set; } - - [JsonProperty("tech")] - public EssentialsRoomTechConfig Tech { get; set; } - - [JsonProperty("volumes")] - public EssentialsRoomVolumesConfig Volumes { get; set; } - - [JsonProperty("fusion")] - public EssentialsRoomFusionConfig Fusion { get; set; } - - [JsonProperty("essentialsRoomUiBehaviorConfig", NullValueHandling=NullValueHandling.Ignore)] - public EssentialsRoomUiBehaviorConfig UiBehavior { get; set; } - - [JsonProperty("zeroVolumeWhenSwtichingVolumeDevices")] - public bool ZeroVolumeWhenSwtichingVolumeDevices { get; set; } - - /// - /// Indicates if this room represents a combination of other rooms - /// - [JsonProperty("isRoomCombinationScenario")] - public bool IsRoomCombinationScenario { get; set; } - - public EssentialsRoomPropertiesConfig() - { - LogoLight = new EssentialsLogoPropertiesConfig(); - LogoDark = new EssentialsLogoPropertiesConfig(); - } - } - - public class EssentialsRoomUiBehaviorConfig - { - [JsonProperty("disableActivityButtonsWhileWarmingCooling")] - public bool DisableActivityButtonsWhileWarmingCooling { get; set; } - } - - public class EssentialsAvRoomPropertiesConfig : EssentialsRoomPropertiesConfig - { - [JsonProperty("defaultAudioKey")] - public string DefaultAudioKey { get; set; } - [JsonProperty("sourceListKey")] - public string SourceListKey { get; set; } - [JsonProperty("destinationListKey")] - public string DestinationListKey { get; set; } - [JsonProperty("defaultSourceItem")] - public string DefaultSourceItem { get; set; } - /// - /// Indicates if the room supports advanced sharing - /// - [JsonProperty("supportsAdvancedSharing")] - public bool SupportsAdvancedSharing { get; set; } - /// - /// Indicates if non-tech users can change the share mode - /// - [JsonProperty("userCanChangeShareMode")] - public bool UserCanChangeShareMode { get; set; } - } - - public class EssentialsConferenceRoomPropertiesConfig : EssentialsAvRoomPropertiesConfig - { - [JsonProperty("videoCodecKey")] - public string VideoCodecKey { get; set; } - [JsonProperty("audioCodecKey")] - public string AudioCodecKey { get; set; } - } - - public class EssentialsEnvironmentPropertiesConfig - { - public bool Enabled { get; set; } - - [JsonProperty("deviceKeys")] - public List DeviceKeys { get; set; } - - public EssentialsEnvironmentPropertiesConfig() - { - DeviceKeys = new List(); - } - - } - - public class EssentialsRoomFusionConfig - { - public uint IpIdInt - { - get - { - try - { - return Convert.ToUInt32(IpId, 16); - } - catch (Exception) - { - throw new FormatException(string.Format("ERROR:Unable to convert IP ID: {0} to hex. Error:\n{1}", IpId)); - } - - } - } - - [JsonProperty("ipId")] - public string IpId { get; set; } - - [JsonProperty("joinMapKey")] - public string JoinMapKey { get; set; } - - } - - public class EssentialsRoomMicrophonePrivacyConfig - { - [JsonProperty("deviceKey")] - public string DeviceKey { get; set; } - - [JsonProperty("behaviour")] - public string Behaviour { get; set; } - } - - /// - /// Properties for the help text box - /// - public class EssentialsHelpPropertiesConfig - { - [JsonProperty("message")] - public string Message { get; set; } - - [JsonProperty("showCallButton")] - public bool ShowCallButton { get; set; } - - /// - /// Defaults to "Call Help Desk" - /// - [JsonProperty("callButtonText")] - public string CallButtonText { get; set; } - - public EssentialsHelpPropertiesConfig() - { - CallButtonText = "Call Help Desk"; - } - } - - /// - /// - /// - public class EssentialsOneButtonMeetingPropertiesConfig - { - [JsonProperty("enable")] - public bool Enable { get; set; } - } - - public class EssentialsRoomAddressPropertiesConfig - { - [JsonProperty("phoneNumber")] - public string PhoneNumber { get; set; } - - [JsonProperty("sipAddress")] - public string SipAddress { get; set; } - } - - - /// - /// Properties for the room's logo on panels - /// - public class EssentialsLogoPropertiesConfig - { - [JsonProperty("type")] - public string Type { get; set; } - - [JsonProperty("url")] - public string Url { get; set; } - /// - /// Gets either the custom URL, a local-to-processor URL, or null if it's a default logo - /// - public string GetLogoUrlLight() - { - if (Type == "url") - return Url; - if (Type == "system") - return string.Format("http://{0}:8080/logo.png", - CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0)); - return null; - } - - public string GetLogoUrlDark() - { - if (Type == "url") - return Url; - if (Type == "system") - return string.Format("http://{0}:8080/logo-dark.png", - CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0)); - return null; - } - } - - /// - /// Represents occupancy sensor(s) setup for a room - /// - public class EssentialsRoomOccSensorConfig - { - [JsonProperty("deviceKey")] - public string DeviceKey { get; set; } - - [JsonProperty("timeoutMinutes")] - public int TimeoutMinutes { get; set; } - } - - public class EssentialsRoomTechConfig - { - [JsonProperty("password")] - public string Password { get; set; } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Crestron.SimplSharp; +using Newtonsoft.Json; + +using PepperDash.Core; +using PepperDash.Essentials; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Room.Config +{ + public class EssentialsRoomConfigHelper + { + /// + /// Returns a room object from this config data + /// + /// + public static IKeyed GetRoomObject(DeviceConfig roomConfig) + { + var typeName = roomConfig.Type.ToLower(); + + switch (typeName) + { + case "huddle" : + { + return new EssentialsHuddleSpaceRoom(roomConfig); + } + case "huddlevtc1" : + { + return new EssentialsHuddleVtc1Room(roomConfig); + } + case "ddvc01bridge" : + { + return new Device(roomConfig.Key, roomConfig.Name); // placeholder device that does nothing. + } + case "dualdisplay" : + { + return new EssentialsDualDisplayRoom(roomConfig); + } + case "combinedhuddlevtc1" : + { + return new EssentialsCombinedHuddleVtc1Room(roomConfig); + } + case "techroom" : + { + return new EssentialsTechRoom(roomConfig); + } + default : + { + return Core.DeviceFactory.GetDevice(roomConfig); + } + } + } + + /// + /// Gets and operating, standalone emergegncy object that can be plugged into a room. + /// Returns null if there is no emergency defined + /// + public static EssentialsRoomEmergencyBase GetEmergency(EssentialsRoomPropertiesConfig props, IEssentialsRoom room) + { + // This emergency + var emergency = props.Emergency; + if (emergency != null) + { + //switch on emergency type here. Right now only contact and shutdown + var e = new EssentialsRoomEmergencyContactClosure(room.Key + "-emergency", props.Emergency, room); + DeviceManager.AddDevice(e); + } + return null; + } + + /// + /// + /// + /// + /// + /// + public static Core.Privacy.MicrophonePrivacyController GetMicrophonePrivacy( + EssentialsRoomPropertiesConfig props, IPrivacy room) + { + var microphonePrivacy = props.MicrophonePrivacy; + if (microphonePrivacy == null) + { + Debug.Console(0, "Cannot create microphone privacy with null properties"); + return null; + } + // Get the MicrophonePrivacy device from the device manager + var mP = (DeviceManager.GetDeviceForKey(props.MicrophonePrivacy.DeviceKey) as + Core.Privacy.MicrophonePrivacyController); + // Set this room as the IPrivacy device + if (mP == null) + { + Debug.Console(0, "ERROR: Selected device {0} is not MicrophonePrivacyController", props.MicrophonePrivacy.DeviceKey); + return null; + } + mP.SetPrivacyDevice(room); + + var behaviour = props.MicrophonePrivacy.Behaviour.ToLower(); + + if (behaviour == null) + { + Debug.Console(0, "WARNING: No behaviour defined for MicrophonePrivacyController"); + return null; + } + if (behaviour == "trackroomstate") + { + // Tie LED enable to room power state + var essRoom = room as IEssentialsRoom; + essRoom.OnFeedback.OutputChange += (o, a) => + { + if (essRoom.OnFeedback.BoolValue) + mP.EnableLeds = true; + else + mP.EnableLeds = false; + }; + + mP.EnableLeds = essRoom.OnFeedback.BoolValue; + } + else if (behaviour == "trackcallstate") + { + // Tie LED enable to room power state + var inCallRoom = room as IHasInCallFeedback; + inCallRoom.InCallFeedback.OutputChange += (o, a) => + { + if (inCallRoom.InCallFeedback.BoolValue) + mP.EnableLeds = true; + else + mP.EnableLeds = false; + }; + + mP.EnableLeds = inCallRoom.InCallFeedback.BoolValue; + } + + return mP; + } + + } + + /// + /// + /// + public class EssentialsRoomPropertiesConfig + { + [JsonProperty("addresses")] + public EssentialsRoomAddressPropertiesConfig Addresses { get; set; } + + [JsonProperty("description")] + public string Description { get; set; } + + [JsonProperty("emergency")] + public EssentialsRoomEmergencyConfig Emergency { get; set; } + + [JsonProperty("help")] + public EssentialsHelpPropertiesConfig Help { get; set; } + + [JsonProperty("helpMessage")] + public string HelpMessage { get; set; } + + /// + /// Read this value to get the help message. It checks for the old and new config format. + /// + public string HelpMessageForDisplay + { + get + { + if(Help != null && !string.IsNullOrEmpty(Help.Message)) + { + return Help.Message; + } + else + { + return HelpMessage; + } + } + } + + [JsonProperty("environment")] + public EssentialsEnvironmentPropertiesConfig Environment { get; set; } + + [JsonProperty("logo")] + public EssentialsLogoPropertiesConfig LogoLight { get; set; } + + [JsonProperty("logoDark")] + public EssentialsLogoPropertiesConfig LogoDark { get; set; } + + [JsonProperty("microphonePrivacy")] + public EssentialsRoomMicrophonePrivacyConfig MicrophonePrivacy { get; set; } + + [JsonProperty("occupancy")] + public EssentialsRoomOccSensorConfig Occupancy { get; set; } + + [JsonProperty("oneButtonMeeting")] + public EssentialsOneButtonMeetingPropertiesConfig OneButtonMeeting { get; set; } + + [JsonProperty("shutdownVacancySeconds")] + public int ShutdownVacancySeconds { get; set; } + + [JsonProperty("shutdownPromptSeconds")] + public int ShutdownPromptSeconds { get; set; } + + [JsonProperty("tech")] + public EssentialsRoomTechConfig Tech { get; set; } + + [JsonProperty("volumes")] + public EssentialsRoomVolumesConfig Volumes { get; set; } + + [JsonProperty("fusion")] + public EssentialsRoomFusionConfig Fusion { get; set; } + + [JsonProperty("essentialsRoomUiBehaviorConfig", NullValueHandling=NullValueHandling.Ignore)] + public EssentialsRoomUiBehaviorConfig UiBehavior { get; set; } + + [JsonProperty("zeroVolumeWhenSwtichingVolumeDevices")] + public bool ZeroVolumeWhenSwtichingVolumeDevices { get; set; } + + /// + /// Indicates if this room represents a combination of other rooms + /// + [JsonProperty("isRoomCombinationScenario")] + public bool IsRoomCombinationScenario { get; set; } + + public EssentialsRoomPropertiesConfig() + { + LogoLight = new EssentialsLogoPropertiesConfig(); + LogoDark = new EssentialsLogoPropertiesConfig(); + } + } + + public class EssentialsRoomUiBehaviorConfig + { + [JsonProperty("disableActivityButtonsWhileWarmingCooling")] + public bool DisableActivityButtonsWhileWarmingCooling { get; set; } + } + + public class EssentialsAvRoomPropertiesConfig : EssentialsRoomPropertiesConfig + { + [JsonProperty("defaultAudioKey")] + public string DefaultAudioKey { get; set; } + [JsonProperty("sourceListKey")] + public string SourceListKey { get; set; } + [JsonProperty("destinationListKey")] + public string DestinationListKey { get; set; } + [JsonProperty("defaultSourceItem")] + public string DefaultSourceItem { get; set; } + /// + /// Indicates if the room supports advanced sharing + /// + [JsonProperty("supportsAdvancedSharing")] + public bool SupportsAdvancedSharing { get; set; } + /// + /// Indicates if non-tech users can change the share mode + /// + [JsonProperty("userCanChangeShareMode")] + public bool UserCanChangeShareMode { get; set; } + } + + public class EssentialsConferenceRoomPropertiesConfig : EssentialsAvRoomPropertiesConfig + { + [JsonProperty("videoCodecKey")] + public string VideoCodecKey { get; set; } + [JsonProperty("audioCodecKey")] + public string AudioCodecKey { get; set; } + } + + public class EssentialsEnvironmentPropertiesConfig + { + public bool Enabled { get; set; } + + [JsonProperty("deviceKeys")] + public List DeviceKeys { get; set; } + + public EssentialsEnvironmentPropertiesConfig() + { + DeviceKeys = new List(); + } + + } + + public class EssentialsRoomFusionConfig + { + public uint IpIdInt + { + get + { + try + { + return Convert.ToUInt32(IpId, 16); + } + catch (Exception) + { + throw new FormatException(string.Format("ERROR:Unable to convert IP ID: {0} to hex. Error:\n{1}", IpId)); + } + + } + } + + [JsonProperty("ipId")] + public string IpId { get; set; } + + [JsonProperty("joinMapKey")] + public string JoinMapKey { get; set; } + + } + + public class EssentialsRoomMicrophonePrivacyConfig + { + [JsonProperty("deviceKey")] + public string DeviceKey { get; set; } + + [JsonProperty("behaviour")] + public string Behaviour { get; set; } + } + + /// + /// Properties for the help text box + /// + public class EssentialsHelpPropertiesConfig + { + [JsonProperty("message")] + public string Message { get; set; } + + [JsonProperty("showCallButton")] + public bool ShowCallButton { get; set; } + + /// + /// Defaults to "Call Help Desk" + /// + [JsonProperty("callButtonText")] + public string CallButtonText { get; set; } + + public EssentialsHelpPropertiesConfig() + { + CallButtonText = "Call Help Desk"; + } + } + + /// + /// + /// + public class EssentialsOneButtonMeetingPropertiesConfig + { + [JsonProperty("enable")] + public bool Enable { get; set; } + } + + public class EssentialsRoomAddressPropertiesConfig + { + [JsonProperty("phoneNumber")] + public string PhoneNumber { get; set; } + + [JsonProperty("sipAddress")] + public string SipAddress { get; set; } + } + + + /// + /// Properties for the room's logo on panels + /// + public class EssentialsLogoPropertiesConfig + { + [JsonProperty("type")] + public string Type { get; set; } + + [JsonProperty("url")] + public string Url { get; set; } + /// + /// Gets either the custom URL, a local-to-processor URL, or null if it's a default logo + /// + public string GetLogoUrlLight() + { + if (Type == "url") + return Url; + if (Type == "system") + return string.Format("http://{0}:8080/logo.png", + CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0)); + return null; + } + + public string GetLogoUrlDark() + { + if (Type == "url") + return Url; + if (Type == "system") + return string.Format("http://{0}:8080/logo-dark.png", + CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0)); + return null; + } + } + + /// + /// Represents occupancy sensor(s) setup for a room + /// + public class EssentialsRoomOccSensorConfig + { + [JsonProperty("deviceKey")] + public string DeviceKey { get; set; } + + [JsonProperty("timeoutMinutes")] + public int TimeoutMinutes { get; set; } + } + + public class EssentialsRoomTechConfig + { + [JsonProperty("password")] + public string Password { get; set; } + } } \ No newline at end of file diff --git a/PepperDashEssentials/Room/Config/EssentialsRoomEmergencyConfig.cs b/src/PepperDashEssentials/Room/Config/EssentialsRoomEmergencyConfig.cs similarity index 100% rename from PepperDashEssentials/Room/Config/EssentialsRoomEmergencyConfig.cs rename to src/PepperDashEssentials/Room/Config/EssentialsRoomEmergencyConfig.cs diff --git a/PepperDashEssentials/Room/Config/EssentialsTechRoomConfig.cs b/src/PepperDashEssentials/Room/Config/EssentialsTechRoomConfig.cs similarity index 100% rename from PepperDashEssentials/Room/Config/EssentialsTechRoomConfig.cs rename to src/PepperDashEssentials/Room/Config/EssentialsTechRoomConfig.cs diff --git a/PepperDashEssentials/Room/Config/SimplRoomPropertiesConfig.cs b/src/PepperDashEssentials/Room/Config/SimplRoomPropertiesConfig.cs similarity index 100% rename from PepperDashEssentials/Room/Config/SimplRoomPropertiesConfig.cs rename to src/PepperDashEssentials/Room/Config/SimplRoomPropertiesConfig.cs diff --git a/PepperDashEssentials/Room/Emergency/EsentialsRoomEmergencyContactClosure.cs b/src/PepperDashEssentials/Room/Emergency/EsentialsRoomEmergencyContactClosure.cs similarity index 100% rename from PepperDashEssentials/Room/Emergency/EsentialsRoomEmergencyContactClosure.cs rename to src/PepperDashEssentials/Room/Emergency/EsentialsRoomEmergencyContactClosure.cs diff --git a/PepperDashEssentials/Room/Types/EssentialsCombinedHuddleVtc1Room.cs b/src/PepperDashEssentials/Room/Types/EssentialsCombinedHuddleVtc1Room.cs similarity index 99% rename from PepperDashEssentials/Room/Types/EssentialsCombinedHuddleVtc1Room.cs rename to src/PepperDashEssentials/Room/Types/EssentialsCombinedHuddleVtc1Room.cs index cbe1b579..0256d35f 100644 --- a/PepperDashEssentials/Room/Types/EssentialsCombinedHuddleVtc1Room.cs +++ b/src/PepperDashEssentials/Room/Types/EssentialsCombinedHuddleVtc1Room.cs @@ -297,8 +297,8 @@ namespace PepperDash.Essentials { //DefaultDisplay = DeviceManager.GetDeviceForKey(PropertiesConfig.DefaultDisplayKey) as IRoutingSinkWithSwitching; - var destinationList = ConfigReader.ConfigObject.DestinationLists[PropertiesConfig.DestinationListKey]; - + var destinationList = ConfigReader.ConfigObject.DestinationLists[PropertiesConfig.DestinationListKey]; + Displays.Clear(); foreach (var destination in destinationList) @@ -316,48 +316,48 @@ namespace PepperDash.Essentials // Link power, warming, cooling to display var dispTwoWay = display as IHasPowerControlWithFeedback; if (dispTwoWay != null) - { - dispTwoWay.PowerIsOnFeedback.OutputChange -= PowerIsOnFeedback_OutputChange; - dispTwoWay.PowerIsOnFeedback.OutputChange += PowerIsOnFeedback_OutputChange; - - if (dispTwoWay.PowerIsOnFeedback.BoolValue) - { - SetDefaultLevels(); + { + dispTwoWay.PowerIsOnFeedback.OutputChange -= PowerIsOnFeedback_OutputChange; + dispTwoWay.PowerIsOnFeedback.OutputChange += PowerIsOnFeedback_OutputChange; + + if (dispTwoWay.PowerIsOnFeedback.BoolValue) + { + SetDefaultLevels(); } - } - - display.IsWarmingUpFeedback.OutputChange -= IsWarmingUpFeedback_OutputChange; - display.IsWarmingUpFeedback.OutputChange += IsWarmingUpFeedback_OutputChange; - - display.IsCoolingDownFeedback.OutputChange -= IsCoolingDownFeedback_OutputChange; + } + + display.IsWarmingUpFeedback.OutputChange -= IsWarmingUpFeedback_OutputChange; + display.IsWarmingUpFeedback.OutputChange += IsWarmingUpFeedback_OutputChange; + + display.IsCoolingDownFeedback.OutputChange -= IsCoolingDownFeedback_OutputChange; display.IsCoolingDownFeedback.OutputChange += IsCoolingDownFeedback_OutputChange; } } - } - - void IsCoolingDownFeedback_OutputChange(object sender, FeedbackEventArgs e) - { - IsCoolingDownFeedback.FireUpdate(); - } - - void IsWarmingUpFeedback_OutputChange(object sender, FeedbackEventArgs e) - { - IsWarmingUpFeedback.FireUpdate(); - if (!IsWarmingUpFeedback.BoolValue) - (CurrentVolumeControls as IBasicVolumeWithFeedback).SetVolume(DefaultVolume); - } - - void PowerIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e) - { - var dispTwoWay = sender as IHasPowerControlWithFeedback; - - if (dispTwoWay != null && dispTwoWay.PowerIsOnFeedback.BoolValue != OnFeedback.BoolValue) - { - //if (!dispTwoWay.PowerIsOnFeedback.BoolValue) - // CurrentSourceInfo = null; - OnFeedback.FireUpdate(); - } + } + + void IsCoolingDownFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + IsCoolingDownFeedback.FireUpdate(); + } + + void IsWarmingUpFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + IsWarmingUpFeedback.FireUpdate(); + if (!IsWarmingUpFeedback.BoolValue) + (CurrentVolumeControls as IBasicVolumeWithFeedback).SetVolume(DefaultVolume); + } + + void PowerIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + var dispTwoWay = sender as IHasPowerControlWithFeedback; + + if (dispTwoWay != null && dispTwoWay.PowerIsOnFeedback.BoolValue != OnFeedback.BoolValue) + { + //if (!dispTwoWay.PowerIsOnFeedback.BoolValue) + // CurrentSourceInfo = null; + OnFeedback.FireUpdate(); + } } @@ -373,8 +373,8 @@ namespace PepperDash.Essentials else { SetSourceListKey(Key); - } - + } + SetUpVideoCodec(); } @@ -386,149 +386,149 @@ namespace PepperDash.Essentials PropertiesConfig = newPropertiesConfig; ConfigWriter.UpdateRoomConfig(config); - } - - public override bool Deactivate() - { - // Stop listining to this event when room deactivated - VideoCodec.IsReadyChange -= VideoCodec_IsReadyChange; - - // Clear occupancy - RoomOccupancy = null; - - Debug.Console(0, this, "Room '{0}' Deactivated", Name); - - return base.Deactivate(); + } + + public override bool Deactivate() + { + // Stop listining to this event when room deactivated + VideoCodec.IsReadyChange -= VideoCodec_IsReadyChange; + + // Clear occupancy + RoomOccupancy = null; + + Debug.Console(0, this, "Room '{0}' Deactivated", Name); + + return base.Deactivate(); } public override bool CustomActivate() - { - try - { - if (DefaultAudioDevice is IBasicVolumeControls) - DefaultVolumeControls = DefaultAudioDevice as IBasicVolumeControls; - else if (DefaultAudioDevice is IHasVolumeDevice) - DefaultVolumeControls = (DefaultAudioDevice as IHasVolumeDevice).VolumeDevice; - CurrentVolumeControls = DefaultVolumeControls; - - - // Combines call feedback from both codecs if available - InCallFeedback = new BoolFeedback(() => - { - bool inAudioCall = false; - bool inVideoCall = false; - - if (AudioCodec != null) - inAudioCall = AudioCodec.IsInCall; - - if (VideoCodec != null) - inVideoCall = VideoCodec.IsInCall; - - if (inAudioCall || inVideoCall) - return true; - else - return false; - }); - - SetupDisplays(); - - // Get Microphone Privacy object, if any MUST HAPPEN AFTER setting InCallFeedback - this.MicrophonePrivacy = EssentialsRoomConfigHelper.GetMicrophonePrivacy(PropertiesConfig, this); - - Debug.Console(2, this, "Microphone Privacy Config evaluated."); - - // Get emergency object, if any - this.Emergency = EssentialsRoomConfigHelper.GetEmergency(PropertiesConfig, this); - - Debug.Console(2, this, "Emergency Config evaluated."); - - if (AudioCodec != null) - { - AudioCodec.CallStatusChange -= AudioCodec_CallStatusChange; - AudioCodec.CallStatusChange += AudioCodec_CallStatusChange; - } - - VideoCodec.CallStatusChange -= VideoCodec_CallStatusChange; - VideoCodec.CallStatusChange += VideoCodec_CallStatusChange; - - VideoCodec.IsReadyChange -= VideoCodec_IsReadyChange; - VideoCodec.IsReadyChange += VideoCodec_IsReadyChange; - - VideoCodec.SharingContentIsOnFeedback.OutputChange -= SharingContentIsOnFeedback_OutputChange; - VideoCodec.SharingContentIsOnFeedback.OutputChange += SharingContentIsOnFeedback_OutputChange; - - - IsSharingFeedback = new BoolFeedback(() => VideoCodec.SharingContentIsOnFeedback.BoolValue); - - // link privacy to VC (for now?) - PrivacyModeIsOnFeedback = new BoolFeedback(() => VideoCodec.PrivacyModeIsOnFeedback.BoolValue); - - VideoCodec.PrivacyModeIsOnFeedback.OutputChange -= PrivacyModeIsOnFeedback_OutputChange; - VideoCodec.PrivacyModeIsOnFeedback.OutputChange += PrivacyModeIsOnFeedback_OutputChange; - - CallTypeFeedback = new IntFeedback(() => 0); - - SetSourceListKey(); - - EnablePowerOnToLastSource = true; - - - // Add Occupancy object from config - if (PropertiesConfig.Occupancy != null) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Setting Occupancy Provider for room"); - this.SetRoomOccupancy(DeviceManager.GetDeviceForKey(PropertiesConfig.Occupancy.DeviceKey) as - IOccupancyStatusProvider, PropertiesConfig.Occupancy.TimeoutMinutes); - } - - this.LogoUrlLightBkgnd = PropertiesConfig.LogoLight.GetLogoUrlLight(); - this.LogoUrlDarkBkgnd = PropertiesConfig.LogoDark.GetLogoUrlDark(); - - this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem; - this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100); - - } - catch (Exception e) - { - Debug.Console(0, this, "Error Activiating Room: {0}", e); - } - - - Debug.Console(0, this, "Room '{0}' Activated", Name); + { + try + { + if (DefaultAudioDevice is IBasicVolumeControls) + DefaultVolumeControls = DefaultAudioDevice as IBasicVolumeControls; + else if (DefaultAudioDevice is IHasVolumeDevice) + DefaultVolumeControls = (DefaultAudioDevice as IHasVolumeDevice).VolumeDevice; + CurrentVolumeControls = DefaultVolumeControls; + + + // Combines call feedback from both codecs if available + InCallFeedback = new BoolFeedback(() => + { + bool inAudioCall = false; + bool inVideoCall = false; + + if (AudioCodec != null) + inAudioCall = AudioCodec.IsInCall; + + if (VideoCodec != null) + inVideoCall = VideoCodec.IsInCall; + + if (inAudioCall || inVideoCall) + return true; + else + return false; + }); + + SetupDisplays(); + + // Get Microphone Privacy object, if any MUST HAPPEN AFTER setting InCallFeedback + this.MicrophonePrivacy = EssentialsRoomConfigHelper.GetMicrophonePrivacy(PropertiesConfig, this); + + Debug.Console(2, this, "Microphone Privacy Config evaluated."); + + // Get emergency object, if any + this.Emergency = EssentialsRoomConfigHelper.GetEmergency(PropertiesConfig, this); + + Debug.Console(2, this, "Emergency Config evaluated."); + + if (AudioCodec != null) + { + AudioCodec.CallStatusChange -= AudioCodec_CallStatusChange; + AudioCodec.CallStatusChange += AudioCodec_CallStatusChange; + } + + VideoCodec.CallStatusChange -= VideoCodec_CallStatusChange; + VideoCodec.CallStatusChange += VideoCodec_CallStatusChange; + + VideoCodec.IsReadyChange -= VideoCodec_IsReadyChange; + VideoCodec.IsReadyChange += VideoCodec_IsReadyChange; + + VideoCodec.SharingContentIsOnFeedback.OutputChange -= SharingContentIsOnFeedback_OutputChange; + VideoCodec.SharingContentIsOnFeedback.OutputChange += SharingContentIsOnFeedback_OutputChange; + + + IsSharingFeedback = new BoolFeedback(() => VideoCodec.SharingContentIsOnFeedback.BoolValue); + + // link privacy to VC (for now?) + PrivacyModeIsOnFeedback = new BoolFeedback(() => VideoCodec.PrivacyModeIsOnFeedback.BoolValue); + + VideoCodec.PrivacyModeIsOnFeedback.OutputChange -= PrivacyModeIsOnFeedback_OutputChange; + VideoCodec.PrivacyModeIsOnFeedback.OutputChange += PrivacyModeIsOnFeedback_OutputChange; + + CallTypeFeedback = new IntFeedback(() => 0); + + SetSourceListKey(); + + EnablePowerOnToLastSource = true; + + + // Add Occupancy object from config + if (PropertiesConfig.Occupancy != null) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Setting Occupancy Provider for room"); + this.SetRoomOccupancy(DeviceManager.GetDeviceForKey(PropertiesConfig.Occupancy.DeviceKey) as + IOccupancyStatusProvider, PropertiesConfig.Occupancy.TimeoutMinutes); + } + + this.LogoUrlLightBkgnd = PropertiesConfig.LogoLight.GetLogoUrlLight(); + this.LogoUrlDarkBkgnd = PropertiesConfig.LogoDark.GetLogoUrlDark(); + + this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem; + this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100); + + } + catch (Exception e) + { + Debug.Console(0, this, "Error Activiating Room: {0}", e); + } + + + Debug.Console(0, this, "Room '{0}' Activated", Name); return base.CustomActivate(); - } - - void AudioCodec_CallStatusChange(object sender, CodecCallStatusItemChangeEventArgs e) - { - InCallFeedback.FireUpdate(); - } - - void PrivacyModeIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e) - { - PrivacyModeIsOnFeedback.FireUpdate(); - } - - void VideoCodec_IsReadyChange(object sender, EventArgs e) - { - SetUpVideoCodec(); - } - - void SetUpVideoCodec() - { - SetCodecExternalSources(); - SetCodecBranding(); - } - - void VideoCodec_CallStatusChange(object sender, CodecCallStatusItemChangeEventArgs e) - { - InCallFeedback.FireUpdate(); - } - - void SharingContentIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e) - { - IsSharingFeedback.FireUpdate(); - } - + } + + void AudioCodec_CallStatusChange(object sender, CodecCallStatusItemChangeEventArgs e) + { + InCallFeedback.FireUpdate(); + } + + void PrivacyModeIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + PrivacyModeIsOnFeedback.FireUpdate(); + } + + void VideoCodec_IsReadyChange(object sender, EventArgs e) + { + SetUpVideoCodec(); + } + + void SetUpVideoCodec() + { + SetCodecExternalSources(); + SetCodecBranding(); + } + + void VideoCodec_CallStatusChange(object sender, CodecCallStatusItemChangeEventArgs e) + { + InCallFeedback.FireUpdate(); + } + + void SharingContentIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + IsSharingFeedback.FireUpdate(); + } + /// @@ -922,9 +922,9 @@ namespace PepperDash.Essentials videoCodecWithExternalSwitching.AddExternalSource(codecInputConnectorName, kvp.Key, srcConfig.PreferredName, PepperDash.Essentials.Devices.Common.VideoCodec.Cisco.eExternalSourceType.desktop); videoCodecWithExternalSwitching.SetExternalSourceState(kvp.Key, PepperDash.Essentials.Devices.Common.VideoCodec.Cisco.eExternalSourceMode.Ready); } - } - - Debug.Console(1, this, "Successfully set up codec external sources for room: {0}", Name); + } + + Debug.Console(1, this, "Successfully set up codec external sources for room: {0}", Name); } catch (Exception e) { diff --git a/PepperDashEssentials/Room/Types/EssentialsDualDisplayRoom.cs b/src/PepperDashEssentials/Room/Types/EssentialsDualDisplayRoom.cs similarity index 100% rename from PepperDashEssentials/Room/Types/EssentialsDualDisplayRoom.cs rename to src/PepperDashEssentials/Room/Types/EssentialsDualDisplayRoom.cs diff --git a/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs b/src/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs similarity index 97% rename from PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs rename to src/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs index 5dbe7600..4ed3da6b 100644 --- a/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs +++ b/src/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs @@ -1,564 +1,564 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -using Newtonsoft.Json; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.Room.Config; - -namespace PepperDash.Essentials -{ - public class EssentialsHuddleSpaceRoom : EssentialsRoomBase, IEssentialsHuddleSpaceRoom - { - public event EventHandler CurrentVolumeDeviceChange; - public event SourceInfoChangeHandler CurrentSourceChange; - - protected override Func OnFeedbackFunc - { - get - { - return () => - { - var disp = DefaultDisplay as DisplayBase; - var val = CurrentSourceInfo != null - && CurrentSourceInfo.Type == eSourceListItemType.Route - && disp != null; - //&& disp.PowerIsOnFeedback.BoolValue; - return val; - }; - } - } - /// - /// - /// - protected override Func IsWarmingFeedbackFunc - { - get - { - return () => - { - var disp = DefaultDisplay as DisplayBase; - if (disp != null) - return disp.IsWarmingUpFeedback.BoolValue; - else - return false; - }; - } - } - /// - /// - /// - protected override Func IsCoolingFeedbackFunc - { - get - { - return () => - { - var disp = DefaultDisplay as DisplayBase; - if (disp != null) - return disp.IsCoolingDownFeedback.BoolValue; - else - return false; - }; - } - } - - public EssentialsHuddleRoomPropertiesConfig PropertiesConfig { get; private set; } - - public IRoutingSinkWithSwitching DefaultDisplay { get; private set; } - public IRoutingSink DefaultAudioDevice { get; private set; } - public IBasicVolumeControls DefaultVolumeControls { get; private set; } - - public bool ExcludeFromGlobalFunctions { get; set; } - - public string DefaultSourceItem { get; set; } - - public ushort DefaultVolume { get; set; } - - /// - /// If room is off, enables power on to last source. Default true - /// - public bool EnablePowerOnToLastSource { get; set; } - string LastSourceKey; - - /// - /// - /// - public IBasicVolumeControls CurrentVolumeControls - { - get { return _CurrentAudioDevice; } - set - { - if (value == _CurrentAudioDevice) return; - - var oldDev = _CurrentAudioDevice; - // derigister this room from the device, if it can - if (oldDev is IInUseTracking) - (oldDev as IInUseTracking).InUseTracker.RemoveUser(this, "audio"); - var handler = CurrentVolumeDeviceChange; - if (handler != null) - CurrentVolumeDeviceChange(this, new VolumeDeviceChangeEventArgs(oldDev, value, ChangeType.WillChange)); - _CurrentAudioDevice = value; - if (handler != null) - CurrentVolumeDeviceChange(this, new VolumeDeviceChangeEventArgs(oldDev, value, ChangeType.DidChange)); - // register this room with new device, if it can - if (_CurrentAudioDevice is IInUseTracking) - (_CurrentAudioDevice as IInUseTracking).InUseTracker.AddUser(this, "audio"); - } - } - IBasicVolumeControls _CurrentAudioDevice; - - /// - /// The SourceListItem last run - containing names and icons - /// - public SourceListItem CurrentSourceInfo - { - get { return _CurrentSourceInfo; } - set - { - if (value == _CurrentSourceInfo) return; - - var handler = CurrentSourceChange; - // remove from in-use tracker, if so equipped - if(_CurrentSourceInfo != null && _CurrentSourceInfo.SourceDevice is IInUseTracking) - (_CurrentSourceInfo.SourceDevice as IInUseTracking).InUseTracker.RemoveUser(this, "control"); - - if (handler != null) - handler(_CurrentSourceInfo, ChangeType.WillChange); - - _CurrentSourceInfo = value; - - // add to in-use tracking - if (_CurrentSourceInfo != null && _CurrentSourceInfo.SourceDevice is IInUseTracking) - (_CurrentSourceInfo.SourceDevice as IInUseTracking).InUseTracker.AddUser(this, "control"); - if (handler != null) - handler( _CurrentSourceInfo, ChangeType.DidChange); - } - } - SourceListItem _CurrentSourceInfo; - - public string CurrentSourceInfoKey { get; set; } - - public EssentialsHuddleSpaceRoom(DeviceConfig config) - : base(config) - { - try - { - PropertiesConfig = JsonConvert.DeserializeObject - (config.Properties.ToString()); - DefaultDisplay = DeviceManager.GetDeviceForKey(PropertiesConfig.DefaultDisplayKey) as IRoutingSinkWithSwitching; - - - DefaultAudioDevice = DeviceManager.GetDeviceForKey(PropertiesConfig.DefaultAudioKey) as IRoutingSinkWithSwitching; - - InitializeRoom(); - } - catch (Exception e) - { - Debug.Console(1, this, "Error building room: \n{0}", e); - } - } - - void InitializeRoom() - { - if (DefaultAudioDevice is IBasicVolumeControls) - DefaultVolumeControls = DefaultAudioDevice as IBasicVolumeControls; - else if (DefaultAudioDevice is IHasVolumeDevice) - DefaultVolumeControls = (DefaultAudioDevice as IHasVolumeDevice).VolumeDevice; - CurrentVolumeControls = DefaultVolumeControls; - - var disp = DefaultDisplay as DisplayBase; - if (disp != null) - { - // Link power, warming, cooling to display - var dispTwoWay = disp as IHasPowerControlWithFeedback; - if (dispTwoWay != null) - { - dispTwoWay.PowerIsOnFeedback.OutputChange += (o, a) => - { - if (dispTwoWay.PowerIsOnFeedback.BoolValue != OnFeedback.BoolValue) - { - if (!dispTwoWay.PowerIsOnFeedback.BoolValue) - CurrentSourceInfo = null; - OnFeedback.FireUpdate(); - } - }; - } - - disp.IsWarmingUpFeedback.OutputChange += (o, a) => - { - IsWarmingUpFeedback.FireUpdate(); - if (!IsWarmingUpFeedback.BoolValue) - (DefaultDisplay as IBasicVolumeWithFeedback).SetVolume(DefaultVolume); - }; - disp.IsCoolingDownFeedback.OutputChange += (o, a) => - { - IsCoolingDownFeedback.FireUpdate(); - }; - } - - SetupEnvironmentalControlDevices(); - - SetSourceListKey(); - - EnablePowerOnToLastSource = true; - } - - private void SetupEnvironmentalControlDevices() - { - if (PropertiesConfig.Environment != null) - { - if (PropertiesConfig.Environment.Enabled) - { - foreach (var d in PropertiesConfig.Environment.DeviceKeys) - { - var envDevice = DeviceManager.GetDeviceForKey(d) as EssentialsDevice; - EnvironmentalControlDevices.Add(envDevice); - } - } - } - } - - private void SetSourceListKey() - { - if (!string.IsNullOrEmpty(PropertiesConfig.SourceListKey)) - { - SetSourceListKey(PropertiesConfig.SourceListKey); - } - else - { - SetSourceListKey(Key); - } - - } - - protected override void CustomSetConfig(DeviceConfig config) - { - var newPropertiesConfig = JsonConvert.DeserializeObject(config.Properties.ToString()); - - if (newPropertiesConfig != null) - PropertiesConfig = newPropertiesConfig; - - ConfigWriter.UpdateRoomConfig(config); - } - - /// - /// - /// - protected override void EndShutdown() - { - SetDefaultLevels(); - - RunDefaultPresentRoute(); - - CrestronEnvironment.Sleep(1000); - - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Shutting down room"); - - RunRouteAction("roomOff"); - } - - /// - /// Routes the default source item, if any - /// - public override bool RunDefaultPresentRoute() - { - if (DefaultSourceItem == null) - { - Debug.Console(0, this, "Unable to run default present route, DefaultSourceItem is null."); - return false; - } - - RunRouteAction(DefaultSourceItem); - return true; - } - - public override bool CustomActivate() - { - // Add Occupancy object from config - if (PropertiesConfig.Occupancy != null) - this.SetRoomOccupancy(DeviceManager.GetDeviceForKey(PropertiesConfig.Occupancy.DeviceKey) as - IOccupancyStatusProvider, PropertiesConfig.Occupancy.TimeoutMinutes); - - this.LogoUrlLightBkgnd = PropertiesConfig.LogoLight.GetLogoUrlLight(); - this.LogoUrlDarkBkgnd = PropertiesConfig.LogoDark.GetLogoUrlDark(); - this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem; - this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100); - - return base.CustomActivate(); - } - - /// - /// - /// - /// - public void RunRouteAction(string routeKey) - { - RunRouteAction(routeKey, new Action(() => { })); - } - - /// - /// - /// - /// - /// - /// - public void RunRouteAction(string routeKey, string sourceListKey) - { - RunRouteAction(routeKey, new Action(() => { })); - } - - /// - /// - /// - /// - /// - /// - public void RunRouteAction(string routeKey, string sourceListKey, Action successCallback) - { - if (string.IsNullOrEmpty(sourceListKey)) - { - RunRouteAction(routeKey, successCallback); - } - else - throw new NotImplementedException(); - } - - /// - /// Gets a source from config list SourceListKey and dynamically build and executes the - /// route or commands - /// - /// - public void RunRouteAction(string routeKey, Action successCallback) - { - // Run this on a separate thread - new CTimer(o => - { - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Run route action '{0}'", routeKey); - var dict = ConfigReader.ConfigObject.GetSourceListForKey(SourceListKey); - if(dict == null) - { - Debug.Console(1, this, "WARNING: Config source list '{0}' not found", SourceListKey); - return; - } - - // Try to get the list item by it's string key - if (!dict.ContainsKey(routeKey)) - { - Debug.Console(1, this, "WARNING: No item '{0}' found on config list '{1}'", - routeKey, SourceListKey); - return; - } - - var item = dict[routeKey]; - //Debug.Console(2, this, "Action {0} has {1} steps", - // item.SourceKey, item.RouteList.Count); - - // End usage timer on last source - if (!string.IsNullOrEmpty(LastSourceKey)) - { - var lastSource = dict[LastSourceKey].SourceDevice; - - try - { - if (lastSource != null && lastSource is IUsageTracking) - (lastSource as IUsageTracking).UsageTracker.EndDeviceUsage(); - } - catch (Exception e) - { - Debug.Console(1, this, "*#* EXCEPTION in end usage tracking (257):\r{0}", e); - } - } - - // Let's run it - if (routeKey.ToLower() != "roomoff") - { - LastSourceKey = routeKey; - } - else - { - CurrentSourceInfoKey = null; - } - - foreach (var route in item.RouteList) - { - // if there is a $defaultAll on route, run two separate - if (route.DestinationKey.Equals("$defaultAll", StringComparison.OrdinalIgnoreCase)) - { - // Going to assume a single-path route for now - var tempVideo = new SourceRouteListItem - { - DestinationKey = "$defaultDisplay", - SourceKey = route.SourceKey, - Type = eRoutingSignalType.Video - }; - DoRoute(tempVideo); - - //var tempAudio = new SourceRouteListItem - //{ - // DestinationKey = "$defaultAudio", - // SourceKey = route.SourceKey, - // Type = eRoutingSignalType.Audio - //}; - //DoRoute(tempAudio); - //continue; -- not sure why this was here - } - else - DoRoute(route); - } - - // Start usage timer on routed source - if (item.SourceDevice is IUsageTracking) - { - (item.SourceDevice as IUsageTracking).UsageTracker.StartDeviceUsage(); - } - - - - - // Set volume control, using default if non provided - IBasicVolumeControls volDev = null; - // Handle special cases for volume control - if (string.IsNullOrEmpty(item.VolumeControlKey) - || item.VolumeControlKey.Equals("$defaultAudio", StringComparison.OrdinalIgnoreCase)) - volDev = DefaultVolumeControls; - else if (item.VolumeControlKey.Equals("$defaultDisplay", StringComparison.OrdinalIgnoreCase)) - volDev = DefaultDisplay as IBasicVolumeControls; - // Or a specific device, probably rarely used. - else - { - var dev = DeviceManager.GetDeviceForKey(item.VolumeControlKey); - if (dev is IBasicVolumeControls) - volDev = dev as IBasicVolumeControls; - else if (dev is IHasVolumeDevice) - volDev = (dev as IHasVolumeDevice).VolumeDevice; - } - - if (volDev != CurrentVolumeControls) - { - // zero the volume on the device we are leaving. - // Set the volume to default on device we are entering - if (ZeroVolumeWhenSwtichingVolumeDevices && CurrentVolumeControls is IBasicVolumeWithFeedback) - { - var vd = CurrentVolumeControls as IBasicVolumeWithFeedback; - SavedVolumeLevels[vd] = (uint)vd.VolumeLevelFeedback.IntValue; - vd.SetVolume(0); - } - CurrentVolumeControls = volDev; - if (ZeroVolumeWhenSwtichingVolumeDevices && CurrentVolumeControls is IBasicVolumeWithFeedback) - { - var vd = CurrentVolumeControls as IBasicVolumeWithFeedback; - ushort vol = (SavedVolumeLevels.ContainsKey(vd) ? (ushort)SavedVolumeLevels[vd] : DefaultVolume); - vd.SetVolume(vol); - } - } - - - - // store the name and UI info for routes - if (item.SourceKey == "$off") - { - CurrentSourceInfoKey = routeKey; - CurrentSourceInfo = null; - } - else if (item.SourceKey != null) - { - CurrentSourceInfoKey = routeKey; - CurrentSourceInfo = item; - } - // And finally, set the "control". This will trigger event - //CurrentControlDevice = DeviceManager.GetDeviceForKey(item.SourceKey) as Device; - - OnFeedback.FireUpdate(); - - // report back when done - if (successCallback != null) - successCallback(); - - }, 0); // end of CTimer - } - - /// - /// Will power the room on with the last-used source - /// - public override void PowerOnToDefaultOrLastSource() - { - if (!EnablePowerOnToLastSource || LastSourceKey == null) - return; - RunRouteAction(LastSourceKey); - } - - /// - /// Does what it says - /// - public override void SetDefaultLevels() - { - Debug.Console(1, this, "Restoring default levels"); - var vc = CurrentVolumeControls as IBasicVolumeWithFeedback; - if (vc != null) - vc.SetVolume(DefaultVolume); - } - - /// - /// - /// - /// - /// - bool DoRoute(SourceRouteListItem route) - { - IRoutingSink dest = null; - - if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase)) - dest = DefaultAudioDevice; - else if (route.DestinationKey.Equals("$defaultDisplay", StringComparison.OrdinalIgnoreCase)) - dest = DefaultDisplay; - else - dest = DeviceManager.GetDeviceForKey(route.DestinationKey) as IRoutingSink; - - if (dest == null) - { - Debug.Console(1, this, "Cannot route, unknown destination '{0}'", route.DestinationKey); - return false; - } - - if (route.SourceKey.Equals("$off", StringComparison.OrdinalIgnoreCase)) - { - dest.ReleaseRoute(); - if (dest is IHasPowerControl) - (dest as IHasPowerControl).PowerOff(); - } - else - { - var source = DeviceManager.GetDeviceForKey(route.SourceKey) as IRoutingOutputs; - if (source == null) - { - Debug.Console(1, this, "Cannot route unknown source '{0}' to {1}", route.SourceKey, route.DestinationKey); - return false; - } - dest.ReleaseAndMakeRoute(source, route.Type); - } - return true; - } - - public override void RoomVacatedForTimeoutPeriod(object o) - { - //Implement this - } - - /// - /// Runs "roomOff" action on all rooms not set to ExcludeFromGlobalFunctions - /// - public static void AllRoomsOff() - { - var allRooms = DeviceManager.AllDevices.Where(d => - d is EssentialsHuddleSpaceRoom && !(d as EssentialsHuddleSpaceRoom).ExcludeFromGlobalFunctions); - foreach (var room in allRooms) - (room as EssentialsHuddleSpaceRoom).RunRouteAction("roomOff"); - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using Newtonsoft.Json; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.Room.Config; + +namespace PepperDash.Essentials +{ + public class EssentialsHuddleSpaceRoom : EssentialsRoomBase, IEssentialsHuddleSpaceRoom + { + public event EventHandler CurrentVolumeDeviceChange; + public event SourceInfoChangeHandler CurrentSourceChange; + + protected override Func OnFeedbackFunc + { + get + { + return () => + { + var disp = DefaultDisplay as DisplayBase; + var val = CurrentSourceInfo != null + && CurrentSourceInfo.Type == eSourceListItemType.Route + && disp != null; + //&& disp.PowerIsOnFeedback.BoolValue; + return val; + }; + } + } + /// + /// + /// + protected override Func IsWarmingFeedbackFunc + { + get + { + return () => + { + var disp = DefaultDisplay as DisplayBase; + if (disp != null) + return disp.IsWarmingUpFeedback.BoolValue; + else + return false; + }; + } + } + /// + /// + /// + protected override Func IsCoolingFeedbackFunc + { + get + { + return () => + { + var disp = DefaultDisplay as DisplayBase; + if (disp != null) + return disp.IsCoolingDownFeedback.BoolValue; + else + return false; + }; + } + } + + public EssentialsHuddleRoomPropertiesConfig PropertiesConfig { get; private set; } + + public IRoutingSinkWithSwitching DefaultDisplay { get; private set; } + public IRoutingSink DefaultAudioDevice { get; private set; } + public IBasicVolumeControls DefaultVolumeControls { get; private set; } + + public bool ExcludeFromGlobalFunctions { get; set; } + + public string DefaultSourceItem { get; set; } + + public ushort DefaultVolume { get; set; } + + /// + /// If room is off, enables power on to last source. Default true + /// + public bool EnablePowerOnToLastSource { get; set; } + string LastSourceKey; + + /// + /// + /// + public IBasicVolumeControls CurrentVolumeControls + { + get { return _CurrentAudioDevice; } + set + { + if (value == _CurrentAudioDevice) return; + + var oldDev = _CurrentAudioDevice; + // derigister this room from the device, if it can + if (oldDev is IInUseTracking) + (oldDev as IInUseTracking).InUseTracker.RemoveUser(this, "audio"); + var handler = CurrentVolumeDeviceChange; + if (handler != null) + CurrentVolumeDeviceChange(this, new VolumeDeviceChangeEventArgs(oldDev, value, ChangeType.WillChange)); + _CurrentAudioDevice = value; + if (handler != null) + CurrentVolumeDeviceChange(this, new VolumeDeviceChangeEventArgs(oldDev, value, ChangeType.DidChange)); + // register this room with new device, if it can + if (_CurrentAudioDevice is IInUseTracking) + (_CurrentAudioDevice as IInUseTracking).InUseTracker.AddUser(this, "audio"); + } + } + IBasicVolumeControls _CurrentAudioDevice; + + /// + /// The SourceListItem last run - containing names and icons + /// + public SourceListItem CurrentSourceInfo + { + get { return _CurrentSourceInfo; } + set + { + if (value == _CurrentSourceInfo) return; + + var handler = CurrentSourceChange; + // remove from in-use tracker, if so equipped + if(_CurrentSourceInfo != null && _CurrentSourceInfo.SourceDevice is IInUseTracking) + (_CurrentSourceInfo.SourceDevice as IInUseTracking).InUseTracker.RemoveUser(this, "control"); + + if (handler != null) + handler(_CurrentSourceInfo, ChangeType.WillChange); + + _CurrentSourceInfo = value; + + // add to in-use tracking + if (_CurrentSourceInfo != null && _CurrentSourceInfo.SourceDevice is IInUseTracking) + (_CurrentSourceInfo.SourceDevice as IInUseTracking).InUseTracker.AddUser(this, "control"); + if (handler != null) + handler( _CurrentSourceInfo, ChangeType.DidChange); + } + } + SourceListItem _CurrentSourceInfo; + + public string CurrentSourceInfoKey { get; set; } + + public EssentialsHuddleSpaceRoom(DeviceConfig config) + : base(config) + { + try + { + PropertiesConfig = JsonConvert.DeserializeObject + (config.Properties.ToString()); + DefaultDisplay = DeviceManager.GetDeviceForKey(PropertiesConfig.DefaultDisplayKey) as IRoutingSinkWithSwitching; + + + DefaultAudioDevice = DeviceManager.GetDeviceForKey(PropertiesConfig.DefaultAudioKey) as IRoutingSinkWithSwitching; + + InitializeRoom(); + } + catch (Exception e) + { + Debug.Console(1, this, "Error building room: \n{0}", e); + } + } + + void InitializeRoom() + { + if (DefaultAudioDevice is IBasicVolumeControls) + DefaultVolumeControls = DefaultAudioDevice as IBasicVolumeControls; + else if (DefaultAudioDevice is IHasVolumeDevice) + DefaultVolumeControls = (DefaultAudioDevice as IHasVolumeDevice).VolumeDevice; + CurrentVolumeControls = DefaultVolumeControls; + + var disp = DefaultDisplay as DisplayBase; + if (disp != null) + { + // Link power, warming, cooling to display + var dispTwoWay = disp as IHasPowerControlWithFeedback; + if (dispTwoWay != null) + { + dispTwoWay.PowerIsOnFeedback.OutputChange += (o, a) => + { + if (dispTwoWay.PowerIsOnFeedback.BoolValue != OnFeedback.BoolValue) + { + if (!dispTwoWay.PowerIsOnFeedback.BoolValue) + CurrentSourceInfo = null; + OnFeedback.FireUpdate(); + } + }; + } + + disp.IsWarmingUpFeedback.OutputChange += (o, a) => + { + IsWarmingUpFeedback.FireUpdate(); + if (!IsWarmingUpFeedback.BoolValue) + (DefaultDisplay as IBasicVolumeWithFeedback).SetVolume(DefaultVolume); + }; + disp.IsCoolingDownFeedback.OutputChange += (o, a) => + { + IsCoolingDownFeedback.FireUpdate(); + }; + } + + SetupEnvironmentalControlDevices(); + + SetSourceListKey(); + + EnablePowerOnToLastSource = true; + } + + private void SetupEnvironmentalControlDevices() + { + if (PropertiesConfig.Environment != null) + { + if (PropertiesConfig.Environment.Enabled) + { + foreach (var d in PropertiesConfig.Environment.DeviceKeys) + { + var envDevice = DeviceManager.GetDeviceForKey(d) as EssentialsDevice; + EnvironmentalControlDevices.Add(envDevice); + } + } + } + } + + private void SetSourceListKey() + { + if (!string.IsNullOrEmpty(PropertiesConfig.SourceListKey)) + { + SetSourceListKey(PropertiesConfig.SourceListKey); + } + else + { + SetSourceListKey(Key); + } + + } + + protected override void CustomSetConfig(DeviceConfig config) + { + var newPropertiesConfig = JsonConvert.DeserializeObject(config.Properties.ToString()); + + if (newPropertiesConfig != null) + PropertiesConfig = newPropertiesConfig; + + ConfigWriter.UpdateRoomConfig(config); + } + + /// + /// + /// + protected override void EndShutdown() + { + SetDefaultLevels(); + + RunDefaultPresentRoute(); + + CrestronEnvironment.Sleep(1000); + + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Shutting down room"); + + RunRouteAction("roomOff"); + } + + /// + /// Routes the default source item, if any + /// + public override bool RunDefaultPresentRoute() + { + if (DefaultSourceItem == null) + { + Debug.Console(0, this, "Unable to run default present route, DefaultSourceItem is null."); + return false; + } + + RunRouteAction(DefaultSourceItem); + return true; + } + + public override bool CustomActivate() + { + // Add Occupancy object from config + if (PropertiesConfig.Occupancy != null) + this.SetRoomOccupancy(DeviceManager.GetDeviceForKey(PropertiesConfig.Occupancy.DeviceKey) as + IOccupancyStatusProvider, PropertiesConfig.Occupancy.TimeoutMinutes); + + this.LogoUrlLightBkgnd = PropertiesConfig.LogoLight.GetLogoUrlLight(); + this.LogoUrlDarkBkgnd = PropertiesConfig.LogoDark.GetLogoUrlDark(); + this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem; + this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100); + + return base.CustomActivate(); + } + + /// + /// + /// + /// + public void RunRouteAction(string routeKey) + { + RunRouteAction(routeKey, new Action(() => { })); + } + + /// + /// + /// + /// + /// + /// + public void RunRouteAction(string routeKey, string sourceListKey) + { + RunRouteAction(routeKey, new Action(() => { })); + } + + /// + /// + /// + /// + /// + /// + public void RunRouteAction(string routeKey, string sourceListKey, Action successCallback) + { + if (string.IsNullOrEmpty(sourceListKey)) + { + RunRouteAction(routeKey, successCallback); + } + else + throw new NotImplementedException(); + } + + /// + /// Gets a source from config list SourceListKey and dynamically build and executes the + /// route or commands + /// + /// + public void RunRouteAction(string routeKey, Action successCallback) + { + // Run this on a separate thread + new CTimer(o => + { + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Run route action '{0}'", routeKey); + var dict = ConfigReader.ConfigObject.GetSourceListForKey(SourceListKey); + if(dict == null) + { + Debug.Console(1, this, "WARNING: Config source list '{0}' not found", SourceListKey); + return; + } + + // Try to get the list item by it's string key + if (!dict.ContainsKey(routeKey)) + { + Debug.Console(1, this, "WARNING: No item '{0}' found on config list '{1}'", + routeKey, SourceListKey); + return; + } + + var item = dict[routeKey]; + //Debug.Console(2, this, "Action {0} has {1} steps", + // item.SourceKey, item.RouteList.Count); + + // End usage timer on last source + if (!string.IsNullOrEmpty(LastSourceKey)) + { + var lastSource = dict[LastSourceKey].SourceDevice; + + try + { + if (lastSource != null && lastSource is IUsageTracking) + (lastSource as IUsageTracking).UsageTracker.EndDeviceUsage(); + } + catch (Exception e) + { + Debug.Console(1, this, "*#* EXCEPTION in end usage tracking (257):\r{0}", e); + } + } + + // Let's run it + if (routeKey.ToLower() != "roomoff") + { + LastSourceKey = routeKey; + } + else + { + CurrentSourceInfoKey = null; + } + + foreach (var route in item.RouteList) + { + // if there is a $defaultAll on route, run two separate + if (route.DestinationKey.Equals("$defaultAll", StringComparison.OrdinalIgnoreCase)) + { + // Going to assume a single-path route for now + var tempVideo = new SourceRouteListItem + { + DestinationKey = "$defaultDisplay", + SourceKey = route.SourceKey, + Type = eRoutingSignalType.Video + }; + DoRoute(tempVideo); + + //var tempAudio = new SourceRouteListItem + //{ + // DestinationKey = "$defaultAudio", + // SourceKey = route.SourceKey, + // Type = eRoutingSignalType.Audio + //}; + //DoRoute(tempAudio); + //continue; -- not sure why this was here + } + else + DoRoute(route); + } + + // Start usage timer on routed source + if (item.SourceDevice is IUsageTracking) + { + (item.SourceDevice as IUsageTracking).UsageTracker.StartDeviceUsage(); + } + + + + + // Set volume control, using default if non provided + IBasicVolumeControls volDev = null; + // Handle special cases for volume control + if (string.IsNullOrEmpty(item.VolumeControlKey) + || item.VolumeControlKey.Equals("$defaultAudio", StringComparison.OrdinalIgnoreCase)) + volDev = DefaultVolumeControls; + else if (item.VolumeControlKey.Equals("$defaultDisplay", StringComparison.OrdinalIgnoreCase)) + volDev = DefaultDisplay as IBasicVolumeControls; + // Or a specific device, probably rarely used. + else + { + var dev = DeviceManager.GetDeviceForKey(item.VolumeControlKey); + if (dev is IBasicVolumeControls) + volDev = dev as IBasicVolumeControls; + else if (dev is IHasVolumeDevice) + volDev = (dev as IHasVolumeDevice).VolumeDevice; + } + + if (volDev != CurrentVolumeControls) + { + // zero the volume on the device we are leaving. + // Set the volume to default on device we are entering + if (ZeroVolumeWhenSwtichingVolumeDevices && CurrentVolumeControls is IBasicVolumeWithFeedback) + { + var vd = CurrentVolumeControls as IBasicVolumeWithFeedback; + SavedVolumeLevels[vd] = (uint)vd.VolumeLevelFeedback.IntValue; + vd.SetVolume(0); + } + CurrentVolumeControls = volDev; + if (ZeroVolumeWhenSwtichingVolumeDevices && CurrentVolumeControls is IBasicVolumeWithFeedback) + { + var vd = CurrentVolumeControls as IBasicVolumeWithFeedback; + ushort vol = (SavedVolumeLevels.ContainsKey(vd) ? (ushort)SavedVolumeLevels[vd] : DefaultVolume); + vd.SetVolume(vol); + } + } + + + + // store the name and UI info for routes + if (item.SourceKey == "$off") + { + CurrentSourceInfoKey = routeKey; + CurrentSourceInfo = null; + } + else if (item.SourceKey != null) + { + CurrentSourceInfoKey = routeKey; + CurrentSourceInfo = item; + } + // And finally, set the "control". This will trigger event + //CurrentControlDevice = DeviceManager.GetDeviceForKey(item.SourceKey) as Device; + + OnFeedback.FireUpdate(); + + // report back when done + if (successCallback != null) + successCallback(); + + }, 0); // end of CTimer + } + + /// + /// Will power the room on with the last-used source + /// + public override void PowerOnToDefaultOrLastSource() + { + if (!EnablePowerOnToLastSource || LastSourceKey == null) + return; + RunRouteAction(LastSourceKey); + } + + /// + /// Does what it says + /// + public override void SetDefaultLevels() + { + Debug.Console(1, this, "Restoring default levels"); + var vc = CurrentVolumeControls as IBasicVolumeWithFeedback; + if (vc != null) + vc.SetVolume(DefaultVolume); + } + + /// + /// + /// + /// + /// + bool DoRoute(SourceRouteListItem route) + { + IRoutingSink dest = null; + + if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase)) + dest = DefaultAudioDevice; + else if (route.DestinationKey.Equals("$defaultDisplay", StringComparison.OrdinalIgnoreCase)) + dest = DefaultDisplay; + else + dest = DeviceManager.GetDeviceForKey(route.DestinationKey) as IRoutingSink; + + if (dest == null) + { + Debug.Console(1, this, "Cannot route, unknown destination '{0}'", route.DestinationKey); + return false; + } + + if (route.SourceKey.Equals("$off", StringComparison.OrdinalIgnoreCase)) + { + dest.ReleaseRoute(); + if (dest is IHasPowerControl) + (dest as IHasPowerControl).PowerOff(); + } + else + { + var source = DeviceManager.GetDeviceForKey(route.SourceKey) as IRoutingOutputs; + if (source == null) + { + Debug.Console(1, this, "Cannot route unknown source '{0}' to {1}", route.SourceKey, route.DestinationKey); + return false; + } + dest.ReleaseAndMakeRoute(source, route.Type); + } + return true; + } + + public override void RoomVacatedForTimeoutPeriod(object o) + { + //Implement this + } + + /// + /// Runs "roomOff" action on all rooms not set to ExcludeFromGlobalFunctions + /// + public static void AllRoomsOff() + { + var allRooms = DeviceManager.AllDevices.Where(d => + d is EssentialsHuddleSpaceRoom && !(d as EssentialsHuddleSpaceRoom).ExcludeFromGlobalFunctions); + foreach (var room in allRooms) + (room as EssentialsHuddleSpaceRoom).RunRouteAction("roomOff"); + } + } } \ No newline at end of file diff --git a/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs.orig b/src/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs.orig similarity index 100% rename from PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs.orig rename to src/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs.orig diff --git a/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs b/src/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs similarity index 97% rename from PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs rename to src/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs index 2aae2f75..d5c5319d 100644 --- a/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs +++ b/src/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs @@ -1,946 +1,946 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -using Newtonsoft.Json; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.Room.Config; -using PepperDash.Essentials.Devices.Common.Codec; -using PepperDash.Essentials.Devices.Common.VideoCodec; -using PepperDash.Essentials.Devices.Common.AudioCodec; -using PepperDash.Essentials.Core.DeviceTypeInterfaces; - -namespace PepperDash.Essentials -{ - public class EssentialsHuddleVtc1Room : EssentialsRoomBase, IEssentialsHuddleVtc1Room - { - private IEssentialsRoomCombiner _roomCombiner; - - private bool _codecExternalSourceChange; - public event EventHandler CurrentVolumeDeviceChange; - public event SourceInfoChangeHandler CurrentSourceChange; - - - //************************ - // Call-related stuff - - public BoolFeedback InCallFeedback { get; private set; } - - ///// - ///// Make this more specific - ///// - //public List ActiveCalls { get; private set; } - - /// - /// States: 0 for on hook, 1 for video, 2 for audio, 3 for telekenesis - /// - public IntFeedback CallTypeFeedback { get; private set; } - - /// - /// - /// - public BoolFeedback PrivacyModeIsOnFeedback { get; private set; } - - /// - /// When something in the room is sharing with the far end or through other means - /// - public BoolFeedback IsSharingFeedback { get; private set; } - - //************************ - - protected override Func OnFeedbackFunc - { - get - { - return () => - { - var disp = DefaultDisplay as DisplayBase; - var val = CurrentSourceInfo != null - && CurrentSourceInfo.Type == eSourceListItemType.Route - && disp != null; - //&& disp.PowerIsOnFeedback.BoolValue; - return val; - }; - } - } - /// - /// - /// - protected override Func IsWarmingFeedbackFunc - { - get - { - return () => - { - var disp = DefaultDisplay as DisplayBase; - if (disp != null) - return disp.IsWarmingUpFeedback.BoolValue; - else - return false; - }; - } - } - /// - /// - /// - protected override Func IsCoolingFeedbackFunc - { - get - { - return () => - { - var disp = DefaultDisplay as DisplayBase; - if (disp != null) - return disp.IsCoolingDownFeedback.BoolValue; - else - return false; - }; - } - } - - public EssentialsHuddleVtc1PropertiesConfig PropertiesConfig { get; private set; } - - public IRoutingSinkWithSwitching DefaultDisplay { get; private set; } - public IBasicVolumeControls DefaultAudioDevice { get; private set; } - public IBasicVolumeControls DefaultVolumeControls { get; private set; } - - public VideoCodecBase VideoCodec { get; private set; } - - public AudioCodecBase AudioCodec { get; private set; } - - public bool ExcludeFromGlobalFunctions { get; set; } - - public string DefaultSourceItem { get; set; } - - public ushort DefaultVolume { get; set; } - - /// - /// If room is off, enables power on to last source. Default true - /// - public bool EnablePowerOnToLastSource { get; set; } - string LastSourceKey; - - /// - /// Sets the volume control device, and attaches/removes InUseTrackers with "audio" - /// tag to device. - /// - public IBasicVolumeControls CurrentVolumeControls - { - get { return _CurrentAudioDevice; } - set - { - if (value == _CurrentAudioDevice) return; - - var oldDev = _CurrentAudioDevice; - // derigister this room from the device, if it can - if (oldDev is IInUseTracking) - (oldDev as IInUseTracking).InUseTracker.RemoveUser(this, "audio"); - var handler = CurrentVolumeDeviceChange; - if (handler != null) - CurrentVolumeDeviceChange(this, new VolumeDeviceChangeEventArgs(oldDev, value, ChangeType.WillChange)); - _CurrentAudioDevice = value; - if (handler != null) - CurrentVolumeDeviceChange(this, new VolumeDeviceChangeEventArgs(oldDev, value, ChangeType.DidChange)); - // register this room with new device, if it can - if (_CurrentAudioDevice is IInUseTracking) - (_CurrentAudioDevice as IInUseTracking).InUseTracker.AddUser(this, "audio"); - } - } - IBasicVolumeControls _CurrentAudioDevice; - - /// - /// The SourceListItem last run - containing names and icons - /// - public SourceListItem CurrentSourceInfo - { - get { return _CurrentSourceInfo; } - set - { - if (value == _CurrentSourceInfo) return; - - var handler = CurrentSourceChange; - // remove from in-use tracker, if so equipped - if(_CurrentSourceInfo != null && _CurrentSourceInfo.SourceDevice is IInUseTracking) - (_CurrentSourceInfo.SourceDevice as IInUseTracking).InUseTracker.RemoveUser(this, "control"); - - if (handler != null) - handler(_CurrentSourceInfo, ChangeType.WillChange); - - _CurrentSourceInfo = value; - - // add to in-use tracking - if (_CurrentSourceInfo != null && _CurrentSourceInfo.SourceDevice is IInUseTracking) - (_CurrentSourceInfo.SourceDevice as IInUseTracking).InUseTracker.AddUser(this, "control"); - if (handler != null) - handler(_CurrentSourceInfo, ChangeType.DidChange); - - var vc = VideoCodec as IHasExternalSourceSwitching; - if (vc != null && !_codecExternalSourceChange) - { - vc.SetSelectedSource(CurrentSourceInfoKey); - } - - _codecExternalSourceChange = false; - } - } - SourceListItem _CurrentSourceInfo; - - public string CurrentSourceInfoKey { get; set; } - - /// - /// "codecOsd" - /// - public string DefaultCodecRouteString { get { return "codecOsd"; } } - - /// - /// Temporary implementation. Returns the schedule-ready object or null if none. Fow now, - /// always returns the VideoCodec if it is capable - /// - public IHasScheduleAwareness ScheduleSource { get { return VideoCodec as IHasScheduleAwareness; } } - - CCriticalSection SourceSelectLock = new CCriticalSection(); - - public EssentialsHuddleVtc1Room(DeviceConfig config) - : base(config) - { - try - { - PropertiesConfig = JsonConvert.DeserializeObject - (config.Properties.ToString()); - DefaultDisplay = DeviceManager.GetDeviceForKey((PropertiesConfig as EssentialsHuddleVtc1PropertiesConfig).DefaultDisplayKey) as IRoutingSinkWithSwitching; - - VideoCodec = DeviceManager.GetDeviceForKey(PropertiesConfig.VideoCodecKey) as - PepperDash.Essentials.Devices.Common.VideoCodec.VideoCodecBase; - - - if (VideoCodec == null) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, "No Video Codec set. Please check 'videoCodecKey' property in room config"); - throw new ArgumentNullException("VideoCodec cannot be null"); - } - - AudioCodec = DeviceManager.GetDeviceForKey(PropertiesConfig.AudioCodecKey) as - PepperDash.Essentials.Devices.Common.AudioCodec.AudioCodecBase; - if (AudioCodec == null) - Debug.Console(0, this, "No Audio Codec Found"); - - DefaultAudioDevice = DeviceManager.GetDeviceForKey(PropertiesConfig.DefaultAudioKey) as IBasicVolumeControls; - if (DefaultAudioDevice == null) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, "No Default Audio Device set. Please check 'defaultAudioKey' property in room config"); - throw new ArgumentNullException("DefaultAudioDevice cannot be null"); - } - - Initialize(); - } - catch (Exception e) - { - Debug.Console(1, this, "Error building room: \n{0}", e); - } - } - - - private void SetupEnvironmentalControlDevices() - { - if (PropertiesConfig.Environment != null) - { - if (PropertiesConfig.Environment.Enabled) - { - EnvironmentalControlDevices.Clear(); - - foreach (var d in PropertiesConfig.Environment.DeviceKeys) - { - var envDevice = DeviceManager.GetDeviceForKey(d) as EssentialsDevice; - EnvironmentalControlDevices.Add(envDevice); - } - } - } - } - - - private void SetSourceListKey() - { - if (!string.IsNullOrEmpty(PropertiesConfig.SourceListKey)) - { - SetSourceListKey(PropertiesConfig.SourceListKey); - } - else - { - SetSourceListKey(Key); - } - - SetUpVideoCodec(); - } - - protected override void CustomSetConfig(DeviceConfig config) - { - var newPropertiesConfig = JsonConvert.DeserializeObject(config.Properties.ToString()); - - if (newPropertiesConfig != null) - PropertiesConfig = newPropertiesConfig; - - ConfigWriter.UpdateRoomConfig(config); - } - - public override bool Deactivate() - { - - // Stop listining to this event when room deactivated - VideoCodec.IsReadyChange -= VideoCodec_IsReadyChange; - - // Clear occupancy - RoomOccupancy = null; - - Debug.Console(0, this, "Room '{0}' Deactivated", Name); - - return base.Deactivate(); - } - - public override bool CustomActivate() - { - try - { - if (DefaultAudioDevice is IBasicVolumeControls) - DefaultVolumeControls = DefaultAudioDevice as IBasicVolumeControls; - else if (DefaultAudioDevice is IHasVolumeDevice) - DefaultVolumeControls = (DefaultAudioDevice as IHasVolumeDevice).VolumeDevice; - CurrentVolumeControls = DefaultVolumeControls; - - - // Combines call feedback from both codecs if available - InCallFeedback = new BoolFeedback(() => - { - bool inAudioCall = false; - bool inVideoCall = false; - - if (AudioCodec != null) - inAudioCall = AudioCodec.IsInCall; - - if (VideoCodec != null) - inVideoCall = VideoCodec.IsInCall; - - if (inAudioCall || inVideoCall) - return true; - else - return false; - }); - - var disp = DefaultDisplay as DisplayBase; - if (disp != null) - { - // Link power, warming, cooling to display - var dispTwoWay = disp as IHasPowerControlWithFeedback; - if (dispTwoWay != null) - { - dispTwoWay.PowerIsOnFeedback.OutputChange -= PowerIsOnFeedback_OutputChange; - dispTwoWay.PowerIsOnFeedback.OutputChange += PowerIsOnFeedback_OutputChange; - } - - disp.IsWarmingUpFeedback.OutputChange -= IsWarmingUpFeedback_OutputChange; - disp.IsWarmingUpFeedback.OutputChange += IsWarmingUpFeedback_OutputChange; - - disp.IsCoolingDownFeedback.OutputChange -= IsCoolingDownFeedback_OutputChange; - disp.IsCoolingDownFeedback.OutputChange += IsCoolingDownFeedback_OutputChange; - } - - - - // Get Microphone Privacy object, if any MUST HAPPEN AFTER setting InCallFeedback - this.MicrophonePrivacy = EssentialsRoomConfigHelper.GetMicrophonePrivacy(PropertiesConfig, this); - - Debug.Console(2, this, "Microphone Privacy Config evaluated."); - - // Get emergency object, if any - this.Emergency = EssentialsRoomConfigHelper.GetEmergency(PropertiesConfig, this); - - Debug.Console(2, this, "Emergency Config evaluated."); - - if (AudioCodec != null) - { - AudioCodec.CallStatusChange -= AudioCodec_CallStatusChange; - AudioCodec.CallStatusChange += AudioCodec_CallStatusChange; - } - - VideoCodec.CallStatusChange -= VideoCodec_CallStatusChange; - VideoCodec.CallStatusChange += VideoCodec_CallStatusChange; - - VideoCodec.IsReadyChange -= VideoCodec_IsReadyChange; - VideoCodec.IsReadyChange += VideoCodec_IsReadyChange; - - VideoCodec.SharingContentIsOnFeedback.OutputChange -= SharingContentIsOnFeedback_OutputChange; - VideoCodec.SharingContentIsOnFeedback.OutputChange += SharingContentIsOnFeedback_OutputChange; - - - IsSharingFeedback = new BoolFeedback(() => VideoCodec.SharingContentIsOnFeedback.BoolValue); - - // link privacy to VC (for now?) - PrivacyModeIsOnFeedback = new BoolFeedback(() => VideoCodec.PrivacyModeIsOnFeedback.BoolValue); - - VideoCodec.PrivacyModeIsOnFeedback.OutputChange -= PrivacyModeIsOnFeedback_OutputChange; - VideoCodec.PrivacyModeIsOnFeedback.OutputChange += PrivacyModeIsOnFeedback_OutputChange; - - CallTypeFeedback = new IntFeedback(() => 0); - - SetupEnvironmentalControlDevices(); - - SetSourceListKey(); - - EnablePowerOnToLastSource = true; - - - // Add Occupancy object from config - if (PropertiesConfig.Occupancy != null) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Setting Occupancy Provider for room"); - this.SetRoomOccupancy(DeviceManager.GetDeviceForKey(PropertiesConfig.Occupancy.DeviceKey) as - IOccupancyStatusProvider, PropertiesConfig.Occupancy.TimeoutMinutes); - } - - this.LogoUrlLightBkgnd = PropertiesConfig.LogoLight.GetLogoUrlLight(); - this.LogoUrlDarkBkgnd = PropertiesConfig.LogoDark.GetLogoUrlDark(); - - this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem; - this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100); - } - catch (Exception e) - { - Debug.Console(0, this, "Error Activiating Room: {0}", e); - } - - Debug.Console(0, this, "Room '{0}' Activated", Name); - return base.CustomActivate(); - } - - void PrivacyModeIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e) - { - PrivacyModeIsOnFeedback.FireUpdate(); - } - - void SharingContentIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e) - { - IsSharingFeedback.FireUpdate(); - } - - void AudioCodec_CallStatusChange(object sender, CodecCallStatusItemChangeEventArgs e) - { - InCallFeedback.FireUpdate(); - } - - void VideoCodec_IsReadyChange(object sender, EventArgs e) - { - SetUpVideoCodec(); - } - - void SetUpVideoCodec() - { - SetCodecExternalSources(); - SetCodecBranding(); - } - - void VideoCodec_CallStatusChange(object sender, CodecCallStatusItemChangeEventArgs e) - { - InCallFeedback.FireUpdate(); - } - - void IsCoolingDownFeedback_OutputChange(object sender, FeedbackEventArgs e) - { - IsCoolingDownFeedback.FireUpdate(); - } - - void IsWarmingUpFeedback_OutputChange(object sender, FeedbackEventArgs e) - { - IsWarmingUpFeedback.FireUpdate(); - if (!IsWarmingUpFeedback.BoolValue) - (CurrentVolumeControls as IBasicVolumeWithFeedback).SetVolume(DefaultVolume); - - } - - void PowerIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e) - { - var dispTwoWay = DefaultDisplay as IHasPowerControlWithFeedback; - - if (dispTwoWay.PowerIsOnFeedback.BoolValue != OnFeedback.BoolValue) - { - if (!dispTwoWay.PowerIsOnFeedback.BoolValue) - CurrentSourceInfo = null; - OnFeedback.FireUpdate(); - } - if (dispTwoWay.PowerIsOnFeedback.BoolValue) - { - SetDefaultLevels(); - } - - } - - - - /// - /// - /// - protected override void EndShutdown() - { - VideoCodec.EndAllCalls(); - - SetDefaultLevels(); - - RunDefaultPresentRoute(); - - CrestronEnvironment.Sleep(1000); - - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Shutting down room"); - - RunRouteAction("roomOff"); - VideoCodec.StopSharing(); - VideoCodec.StandbyActivate(); - } - - /// - /// Routes the default source item, if any. Returns true when default route exists - /// - public override bool RunDefaultPresentRoute() - { - if (DefaultSourceItem != null) - RunRouteAction(DefaultSourceItem); - - return DefaultSourceItem != null; - } - - /// - /// Sets up the room when started into call mode without presenting a source - /// - /// - public bool RunDefaultCallRoute() - { - Debug.Console(2, this, "RunDefaultCallRoute() Currently Sharing Content: {0}", VideoCodec.SharingContentIsOnFeedback.BoolValue); - - if (VideoCodec.SharingContentIsOnFeedback.BoolValue) - { - Debug.Console(2, this, "Currently sharing content. Ignoring request to run default call route."); - return false; - } - - RunRouteAction(DefaultCodecRouteString); - return true; - } - - public void RunRouteActionCodec(string routeKey, string sourceListKey) - { - _codecExternalSourceChange = true; - RunRouteAction(routeKey, sourceListKey); - } - - /// - /// - /// - /// - public void RunRouteAction(string routeKey) - { - RunRouteAction(routeKey, new Action(() => { })); - } - - /// - /// - /// - /// - /// - /// - public void RunRouteAction(string routeKey, string sourceListKey) - { - if (string.IsNullOrEmpty(sourceListKey)) - { - Debug.Console(1, this, "No sourceListKey present. RunRouteAction assumes default source list."); - RunRouteAction(routeKey, new Action(() => { })); - } - else - { - Debug.Console(1, this, "sourceListKey present but not yet implemented"); - - RunRouteAction(routeKey, new Action(() => { })); - } - } - - /// - /// - /// - /// - /// - /// - public void RunRouteAction(string routeKey, string sourceListKey, Action successCallback) - { - if (string.IsNullOrEmpty(sourceListKey)) - { - RunRouteAction(routeKey, successCallback); - } - else - { - Debug.Console(1, this, "sourceListKey present but not yet implemented"); - - RunRouteAction(routeKey, successCallback); - } - } - - /// - /// Gets a source from config list SourceListKey and dynamically build and executes the - /// route or commands - /// - /// - public void RunRouteAction(string routeKey, Action successCallback) - { - // Run this on a separate thread - new CTimer(o => - { - // try to prevent multiple simultaneous selections - SourceSelectLock.TryEnter(); - - try - { - - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Run route action '{0}'", routeKey); - var dict = ConfigReader.ConfigObject.GetSourceListForKey(SourceListKey); - if (dict == null) - { - Debug.Console(1, this, "WARNING: Config source list '{0}' not found", SourceListKey); - return; - } - - // Try to get the list item by it's string key - if (!dict.ContainsKey(routeKey)) - { - Debug.Console(1, this, "WARNING: No item '{0}' found on config list '{1}'", - routeKey, SourceListKey); - return; - } - - // End usage timer on last source - if (!string.IsNullOrEmpty(LastSourceKey)) - { - var usageLastSource = dict[LastSourceKey].SourceDevice as IUsageTracking; - if (usageLastSource != null && usageLastSource.UsageTracker != null) - { - try - { - // There MAY have been failures in here. Protect - usageLastSource.UsageTracker.EndDeviceUsage(); - } - catch (Exception e) - { - Debug.Console(1, this, "*#* EXCEPTION in end usage tracking:\r{0}", e); - } - } - } - - // Let's run it - var item = dict[routeKey]; - if (routeKey.ToLower() != "roomoff") - { - - LastSourceKey = routeKey; - } - else - CurrentSourceInfoKey = null; - - // hand off the individual routes to this helper - foreach (var route in item.RouteList) - DoRouteItem(route); - - // Start usage timer on routed source - var usageNewSource = item.SourceDevice as IUsageTracking; - if (usageNewSource != null && usageNewSource.UsageTracker != null) // Have to make sure there is a usage tracker! - { - (item.SourceDevice as IUsageTracking).UsageTracker.StartDeviceUsage(); - } - - // See if this can be moved into common, base-class method ------------- - - - // Set volume control, using default if non provided - IBasicVolumeControls volDev = null; - // Handle special cases for volume control - if (string.IsNullOrEmpty(item.VolumeControlKey) - || item.VolumeControlKey.Equals("$defaultAudio", StringComparison.OrdinalIgnoreCase)) - volDev = DefaultVolumeControls; - else if (item.VolumeControlKey.Equals("$defaultDisplay", StringComparison.OrdinalIgnoreCase)) - volDev = DefaultDisplay as IBasicVolumeControls; - // Or a specific device, probably rarely used. - else - { - var dev = DeviceManager.GetDeviceForKey(item.VolumeControlKey); - if (dev is IBasicVolumeControls) - volDev = dev as IBasicVolumeControls; - else if (dev is IHasVolumeDevice) - volDev = (dev as IHasVolumeDevice).VolumeDevice; - } - - if (volDev != CurrentVolumeControls) - { - // zero the volume on the device we are leaving. - // Set the volume to default on device we are entering - if (ZeroVolumeWhenSwtichingVolumeDevices && CurrentVolumeControls is IBasicVolumeWithFeedback) - { - var vd = CurrentVolumeControls as IBasicVolumeWithFeedback; - SavedVolumeLevels[vd] = (uint)vd.VolumeLevelFeedback.IntValue; - vd.SetVolume(0); - } - - CurrentVolumeControls = volDev; - if (ZeroVolumeWhenSwtichingVolumeDevices && CurrentVolumeControls is IBasicVolumeWithFeedback) - { - var vd = CurrentVolumeControls as IBasicVolumeWithFeedback; - ushort vol = (SavedVolumeLevels.ContainsKey(vd) ? (ushort)SavedVolumeLevels[vd] : DefaultVolume); - vd.SetVolume(vol); - } - } - // ----------------------------------------------------------------------- - - - - // store the name and UI info for routes - if (item.SourceKey == "$off") - { - CurrentSourceInfoKey = routeKey; - CurrentSourceInfo = null; - } - else if (item.SourceKey != null) - { - CurrentSourceInfoKey = routeKey; - CurrentSourceInfo = item; - } - - OnFeedback.FireUpdate(); - - if (OnFeedback.BoolValue) - { - if (VideoCodec.UsageTracker.InUseTracker.InUseFeedback.BoolValue) - { - Debug.Console(1, this, "Video Codec in use, deactivating standby on codec"); - VideoCodec.StandbyDeactivate(); - } - - if (VideoCodec.StandbyIsOnFeedback.BoolValue) - { - VideoCodec.StandbyDeactivate(); - } - else - { - Debug.Console(1, this, "Video codec not in standby. No need to wake."); - } - } - else - { - Debug.Console(1, this, "Room OnFeedback state: {0}", OnFeedback.BoolValue); - } - - // report back when done - if (successCallback != null) - successCallback(); - } - catch (Exception e) - { - Debug.Console(1, this, "ERROR in routing: {0}", e); - } - - SourceSelectLock.Leave(); - }, 0); // end of CTimer - } - - /// - /// - /// - /// - void DoRouteItem(SourceRouteListItem route) - { - // if there is a $defaultAll on route, run two separate - if (route.DestinationKey.Equals("$defaultAll", StringComparison.OrdinalIgnoreCase)) - { - // Going to assume a single-path route for now - var tempVideo = new SourceRouteListItem - { - DestinationKey = "$defaultDisplay", - SourceKey = route.SourceKey, - Type = eRoutingSignalType.Video - }; - DoRoute(tempVideo); - } - else - DoRoute(route); - } - - /// - /// - /// - /// - /// - bool DoRoute(SourceRouteListItem route) - { - IRoutingSink dest = null; - - if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase)) - dest = DefaultAudioDevice as IRoutingSink; - else if (route.DestinationKey.Equals("$defaultDisplay", StringComparison.OrdinalIgnoreCase)) - dest = DefaultDisplay; - else - dest = DeviceManager.GetDeviceForKey(route.DestinationKey) as IRoutingSink; - - - if (dest == null) - { - Debug.Console(1, this, "Cannot route, unknown destination '{0}'", route.DestinationKey); - return false; - } - - if (route.SourceKey.Equals("$off", StringComparison.OrdinalIgnoreCase)) - { - dest.ReleaseRoute(); - if (dest is IHasPowerControl) - (dest as IHasPowerControl).PowerOff(); - - } - else - { - var source = DeviceManager.GetDeviceForKey(route.SourceKey) as IRoutingOutputs; - if (source == null) - { - Debug.Console(1, this, "Cannot route unknown source '{0}' to {1}", route.SourceKey, route.DestinationKey); - return false; - } - dest.ReleaseAndMakeRoute(source, route.Type); - } - return true; - } - - public override void RoomVacatedForTimeoutPeriod(object o) - { - //Implement this - } - - protected override bool AllowVacancyTimerToStart() - { - bool allowVideo = true; - bool allowAudio = true; - - if (VideoCodec != null) - { - Debug.Console(2,this, Debug.ErrorLogLevel.Notice, "Room {0} {1} in a video call", Key, VideoCodec.IsInCall ? "is" : "is not"); - allowVideo = !VideoCodec.IsInCall; - } - - if (AudioCodec != null) - { - Debug.Console(2,this, Debug.ErrorLogLevel.Notice, "Room {0} {1} in an audio call", Key, AudioCodec.IsInCall ? "is" : "is not"); - allowAudio = !AudioCodec.IsInCall; - } - - Debug.Console(2, this, "Room {0} allowing vacancy timer to start: {1}", Key, allowVideo && allowAudio); - - return allowVideo && allowAudio; - } - - /// - /// Does what it says - /// - public override void SetDefaultLevels() - { - Debug.Console(1, this, "Restoring default levels"); - var vc = CurrentVolumeControls as IBasicVolumeWithFeedback; - if (vc != null) - vc.SetVolume(DefaultVolume); - } - /// - /// Will power the room on with the last-used source - /// - public override void PowerOnToDefaultOrLastSource() - { - if (!EnablePowerOnToLastSource || LastSourceKey == null) - return; - RunRouteAction(LastSourceKey); - } - - /// - /// Runs "roomOff" action on all rooms not set to ExcludeFromGlobalFunctions - /// - public static void AllRoomsOff() - { - var allRooms = DeviceManager.AllDevices.Where(d => - d is IEssentialsRoom && !(d as IEssentialsHuddleSpaceRoom).ExcludeFromGlobalFunctions); - foreach (var room in allRooms) - (room as IEssentialsHuddleSpaceRoom).RunRouteAction("roomOff"); - } - - - /// - /// Setup the external sources for the Cisco Touch 10 devices that support IHasExternalSourceSwitch - /// - private void SetCodecExternalSources() - { - var videoCodecWithExternalSwitching = VideoCodec as IHasExternalSourceSwitching; - - if (videoCodecWithExternalSwitching == null || !videoCodecWithExternalSwitching.ExternalSourceListEnabled) - { - return; - } - - try - { - // Get the tie line that the external switcher is connected to - string codecInputConnectorName = ConfigReader.ConfigObject.TieLines.SingleOrDefault( - x => x.DestinationKey == VideoCodec.Key && x.DestinationPort == videoCodecWithExternalSwitching.ExternalSourceInputPort).DestinationPort; - - videoCodecWithExternalSwitching.ClearExternalSources(); - videoCodecWithExternalSwitching.RunRouteAction = RunRouteActionCodec; - var srcList = ConfigReader.ConfigObject.SourceLists.SingleOrDefault(x => x.Key == SourceListKey).Value.OrderBy(kv => kv.Value.Order); ; - - foreach (var kvp in srcList) - { - var srcConfig = kvp.Value; - - if (kvp.Key != DefaultCodecRouteString && kvp.Key != "roomOff") - { - videoCodecWithExternalSwitching.AddExternalSource(codecInputConnectorName, kvp.Key, srcConfig.PreferredName, PepperDash.Essentials.Devices.Common.VideoCodec.Cisco.eExternalSourceType.desktop); - videoCodecWithExternalSwitching.SetExternalSourceState(kvp.Key, PepperDash.Essentials.Devices.Common.VideoCodec.Cisco.eExternalSourceMode.Ready); - } - } - Debug.Console(1, this, "Successfully set up codec external sources for room: {0}", Name); - - } - catch (Exception e) - { - Debug.Console(2, this, "Error setting codec external sources: {0}", e); - } - } - - private void SetCodecBranding() - { - var vcWithBranding = VideoCodec as IHasBranding; - - if (vcWithBranding == null) return; - - Debug.Console(1, this, "Setting Codec Branding"); - vcWithBranding.InitializeBranding(Key); - } - - #region IPrivacy Members - - - public void PrivacyModeOff() - { - VideoCodec.PrivacyModeOff(); - } - - public void PrivacyModeOn() - { - VideoCodec.PrivacyModeOn(); - } - - public void PrivacyModeToggle() - { - VideoCodec.PrivacyModeToggle(); - } - - #endregion - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using Newtonsoft.Json; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.Room.Config; +using PepperDash.Essentials.Devices.Common.Codec; +using PepperDash.Essentials.Devices.Common.VideoCodec; +using PepperDash.Essentials.Devices.Common.AudioCodec; +using PepperDash.Essentials.Core.DeviceTypeInterfaces; + +namespace PepperDash.Essentials +{ + public class EssentialsHuddleVtc1Room : EssentialsRoomBase, IEssentialsHuddleVtc1Room + { + private IEssentialsRoomCombiner _roomCombiner; + + private bool _codecExternalSourceChange; + public event EventHandler CurrentVolumeDeviceChange; + public event SourceInfoChangeHandler CurrentSourceChange; + + + //************************ + // Call-related stuff + + public BoolFeedback InCallFeedback { get; private set; } + + ///// + ///// Make this more specific + ///// + //public List ActiveCalls { get; private set; } + + /// + /// States: 0 for on hook, 1 for video, 2 for audio, 3 for telekenesis + /// + public IntFeedback CallTypeFeedback { get; private set; } + + /// + /// + /// + public BoolFeedback PrivacyModeIsOnFeedback { get; private set; } + + /// + /// When something in the room is sharing with the far end or through other means + /// + public BoolFeedback IsSharingFeedback { get; private set; } + + //************************ + + protected override Func OnFeedbackFunc + { + get + { + return () => + { + var disp = DefaultDisplay as DisplayBase; + var val = CurrentSourceInfo != null + && CurrentSourceInfo.Type == eSourceListItemType.Route + && disp != null; + //&& disp.PowerIsOnFeedback.BoolValue; + return val; + }; + } + } + /// + /// + /// + protected override Func IsWarmingFeedbackFunc + { + get + { + return () => + { + var disp = DefaultDisplay as DisplayBase; + if (disp != null) + return disp.IsWarmingUpFeedback.BoolValue; + else + return false; + }; + } + } + /// + /// + /// + protected override Func IsCoolingFeedbackFunc + { + get + { + return () => + { + var disp = DefaultDisplay as DisplayBase; + if (disp != null) + return disp.IsCoolingDownFeedback.BoolValue; + else + return false; + }; + } + } + + public EssentialsHuddleVtc1PropertiesConfig PropertiesConfig { get; private set; } + + public IRoutingSinkWithSwitching DefaultDisplay { get; private set; } + public IBasicVolumeControls DefaultAudioDevice { get; private set; } + public IBasicVolumeControls DefaultVolumeControls { get; private set; } + + public VideoCodecBase VideoCodec { get; private set; } + + public AudioCodecBase AudioCodec { get; private set; } + + public bool ExcludeFromGlobalFunctions { get; set; } + + public string DefaultSourceItem { get; set; } + + public ushort DefaultVolume { get; set; } + + /// + /// If room is off, enables power on to last source. Default true + /// + public bool EnablePowerOnToLastSource { get; set; } + string LastSourceKey; + + /// + /// Sets the volume control device, and attaches/removes InUseTrackers with "audio" + /// tag to device. + /// + public IBasicVolumeControls CurrentVolumeControls + { + get { return _CurrentAudioDevice; } + set + { + if (value == _CurrentAudioDevice) return; + + var oldDev = _CurrentAudioDevice; + // derigister this room from the device, if it can + if (oldDev is IInUseTracking) + (oldDev as IInUseTracking).InUseTracker.RemoveUser(this, "audio"); + var handler = CurrentVolumeDeviceChange; + if (handler != null) + CurrentVolumeDeviceChange(this, new VolumeDeviceChangeEventArgs(oldDev, value, ChangeType.WillChange)); + _CurrentAudioDevice = value; + if (handler != null) + CurrentVolumeDeviceChange(this, new VolumeDeviceChangeEventArgs(oldDev, value, ChangeType.DidChange)); + // register this room with new device, if it can + if (_CurrentAudioDevice is IInUseTracking) + (_CurrentAudioDevice as IInUseTracking).InUseTracker.AddUser(this, "audio"); + } + } + IBasicVolumeControls _CurrentAudioDevice; + + /// + /// The SourceListItem last run - containing names and icons + /// + public SourceListItem CurrentSourceInfo + { + get { return _CurrentSourceInfo; } + set + { + if (value == _CurrentSourceInfo) return; + + var handler = CurrentSourceChange; + // remove from in-use tracker, if so equipped + if(_CurrentSourceInfo != null && _CurrentSourceInfo.SourceDevice is IInUseTracking) + (_CurrentSourceInfo.SourceDevice as IInUseTracking).InUseTracker.RemoveUser(this, "control"); + + if (handler != null) + handler(_CurrentSourceInfo, ChangeType.WillChange); + + _CurrentSourceInfo = value; + + // add to in-use tracking + if (_CurrentSourceInfo != null && _CurrentSourceInfo.SourceDevice is IInUseTracking) + (_CurrentSourceInfo.SourceDevice as IInUseTracking).InUseTracker.AddUser(this, "control"); + if (handler != null) + handler(_CurrentSourceInfo, ChangeType.DidChange); + + var vc = VideoCodec as IHasExternalSourceSwitching; + if (vc != null && !_codecExternalSourceChange) + { + vc.SetSelectedSource(CurrentSourceInfoKey); + } + + _codecExternalSourceChange = false; + } + } + SourceListItem _CurrentSourceInfo; + + public string CurrentSourceInfoKey { get; set; } + + /// + /// "codecOsd" + /// + public string DefaultCodecRouteString { get { return "codecOsd"; } } + + /// + /// Temporary implementation. Returns the schedule-ready object or null if none. Fow now, + /// always returns the VideoCodec if it is capable + /// + public IHasScheduleAwareness ScheduleSource { get { return VideoCodec as IHasScheduleAwareness; } } + + CCriticalSection SourceSelectLock = new CCriticalSection(); + + public EssentialsHuddleVtc1Room(DeviceConfig config) + : base(config) + { + try + { + PropertiesConfig = JsonConvert.DeserializeObject + (config.Properties.ToString()); + DefaultDisplay = DeviceManager.GetDeviceForKey((PropertiesConfig as EssentialsHuddleVtc1PropertiesConfig).DefaultDisplayKey) as IRoutingSinkWithSwitching; + + VideoCodec = DeviceManager.GetDeviceForKey(PropertiesConfig.VideoCodecKey) as + PepperDash.Essentials.Devices.Common.VideoCodec.VideoCodecBase; + + + if (VideoCodec == null) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "No Video Codec set. Please check 'videoCodecKey' property in room config"); + throw new ArgumentNullException("VideoCodec cannot be null"); + } + + AudioCodec = DeviceManager.GetDeviceForKey(PropertiesConfig.AudioCodecKey) as + PepperDash.Essentials.Devices.Common.AudioCodec.AudioCodecBase; + if (AudioCodec == null) + Debug.Console(0, this, "No Audio Codec Found"); + + DefaultAudioDevice = DeviceManager.GetDeviceForKey(PropertiesConfig.DefaultAudioKey) as IBasicVolumeControls; + if (DefaultAudioDevice == null) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "No Default Audio Device set. Please check 'defaultAudioKey' property in room config"); + throw new ArgumentNullException("DefaultAudioDevice cannot be null"); + } + + Initialize(); + } + catch (Exception e) + { + Debug.Console(1, this, "Error building room: \n{0}", e); + } + } + + + private void SetupEnvironmentalControlDevices() + { + if (PropertiesConfig.Environment != null) + { + if (PropertiesConfig.Environment.Enabled) + { + EnvironmentalControlDevices.Clear(); + + foreach (var d in PropertiesConfig.Environment.DeviceKeys) + { + var envDevice = DeviceManager.GetDeviceForKey(d) as EssentialsDevice; + EnvironmentalControlDevices.Add(envDevice); + } + } + } + } + + + private void SetSourceListKey() + { + if (!string.IsNullOrEmpty(PropertiesConfig.SourceListKey)) + { + SetSourceListKey(PropertiesConfig.SourceListKey); + } + else + { + SetSourceListKey(Key); + } + + SetUpVideoCodec(); + } + + protected override void CustomSetConfig(DeviceConfig config) + { + var newPropertiesConfig = JsonConvert.DeserializeObject(config.Properties.ToString()); + + if (newPropertiesConfig != null) + PropertiesConfig = newPropertiesConfig; + + ConfigWriter.UpdateRoomConfig(config); + } + + public override bool Deactivate() + { + + // Stop listining to this event when room deactivated + VideoCodec.IsReadyChange -= VideoCodec_IsReadyChange; + + // Clear occupancy + RoomOccupancy = null; + + Debug.Console(0, this, "Room '{0}' Deactivated", Name); + + return base.Deactivate(); + } + + public override bool CustomActivate() + { + try + { + if (DefaultAudioDevice is IBasicVolumeControls) + DefaultVolumeControls = DefaultAudioDevice as IBasicVolumeControls; + else if (DefaultAudioDevice is IHasVolumeDevice) + DefaultVolumeControls = (DefaultAudioDevice as IHasVolumeDevice).VolumeDevice; + CurrentVolumeControls = DefaultVolumeControls; + + + // Combines call feedback from both codecs if available + InCallFeedback = new BoolFeedback(() => + { + bool inAudioCall = false; + bool inVideoCall = false; + + if (AudioCodec != null) + inAudioCall = AudioCodec.IsInCall; + + if (VideoCodec != null) + inVideoCall = VideoCodec.IsInCall; + + if (inAudioCall || inVideoCall) + return true; + else + return false; + }); + + var disp = DefaultDisplay as DisplayBase; + if (disp != null) + { + // Link power, warming, cooling to display + var dispTwoWay = disp as IHasPowerControlWithFeedback; + if (dispTwoWay != null) + { + dispTwoWay.PowerIsOnFeedback.OutputChange -= PowerIsOnFeedback_OutputChange; + dispTwoWay.PowerIsOnFeedback.OutputChange += PowerIsOnFeedback_OutputChange; + } + + disp.IsWarmingUpFeedback.OutputChange -= IsWarmingUpFeedback_OutputChange; + disp.IsWarmingUpFeedback.OutputChange += IsWarmingUpFeedback_OutputChange; + + disp.IsCoolingDownFeedback.OutputChange -= IsCoolingDownFeedback_OutputChange; + disp.IsCoolingDownFeedback.OutputChange += IsCoolingDownFeedback_OutputChange; + } + + + + // Get Microphone Privacy object, if any MUST HAPPEN AFTER setting InCallFeedback + this.MicrophonePrivacy = EssentialsRoomConfigHelper.GetMicrophonePrivacy(PropertiesConfig, this); + + Debug.Console(2, this, "Microphone Privacy Config evaluated."); + + // Get emergency object, if any + this.Emergency = EssentialsRoomConfigHelper.GetEmergency(PropertiesConfig, this); + + Debug.Console(2, this, "Emergency Config evaluated."); + + if (AudioCodec != null) + { + AudioCodec.CallStatusChange -= AudioCodec_CallStatusChange; + AudioCodec.CallStatusChange += AudioCodec_CallStatusChange; + } + + VideoCodec.CallStatusChange -= VideoCodec_CallStatusChange; + VideoCodec.CallStatusChange += VideoCodec_CallStatusChange; + + VideoCodec.IsReadyChange -= VideoCodec_IsReadyChange; + VideoCodec.IsReadyChange += VideoCodec_IsReadyChange; + + VideoCodec.SharingContentIsOnFeedback.OutputChange -= SharingContentIsOnFeedback_OutputChange; + VideoCodec.SharingContentIsOnFeedback.OutputChange += SharingContentIsOnFeedback_OutputChange; + + + IsSharingFeedback = new BoolFeedback(() => VideoCodec.SharingContentIsOnFeedback.BoolValue); + + // link privacy to VC (for now?) + PrivacyModeIsOnFeedback = new BoolFeedback(() => VideoCodec.PrivacyModeIsOnFeedback.BoolValue); + + VideoCodec.PrivacyModeIsOnFeedback.OutputChange -= PrivacyModeIsOnFeedback_OutputChange; + VideoCodec.PrivacyModeIsOnFeedback.OutputChange += PrivacyModeIsOnFeedback_OutputChange; + + CallTypeFeedback = new IntFeedback(() => 0); + + SetupEnvironmentalControlDevices(); + + SetSourceListKey(); + + EnablePowerOnToLastSource = true; + + + // Add Occupancy object from config + if (PropertiesConfig.Occupancy != null) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Setting Occupancy Provider for room"); + this.SetRoomOccupancy(DeviceManager.GetDeviceForKey(PropertiesConfig.Occupancy.DeviceKey) as + IOccupancyStatusProvider, PropertiesConfig.Occupancy.TimeoutMinutes); + } + + this.LogoUrlLightBkgnd = PropertiesConfig.LogoLight.GetLogoUrlLight(); + this.LogoUrlDarkBkgnd = PropertiesConfig.LogoDark.GetLogoUrlDark(); + + this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem; + this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100); + } + catch (Exception e) + { + Debug.Console(0, this, "Error Activiating Room: {0}", e); + } + + Debug.Console(0, this, "Room '{0}' Activated", Name); + return base.CustomActivate(); + } + + void PrivacyModeIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + PrivacyModeIsOnFeedback.FireUpdate(); + } + + void SharingContentIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + IsSharingFeedback.FireUpdate(); + } + + void AudioCodec_CallStatusChange(object sender, CodecCallStatusItemChangeEventArgs e) + { + InCallFeedback.FireUpdate(); + } + + void VideoCodec_IsReadyChange(object sender, EventArgs e) + { + SetUpVideoCodec(); + } + + void SetUpVideoCodec() + { + SetCodecExternalSources(); + SetCodecBranding(); + } + + void VideoCodec_CallStatusChange(object sender, CodecCallStatusItemChangeEventArgs e) + { + InCallFeedback.FireUpdate(); + } + + void IsCoolingDownFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + IsCoolingDownFeedback.FireUpdate(); + } + + void IsWarmingUpFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + IsWarmingUpFeedback.FireUpdate(); + if (!IsWarmingUpFeedback.BoolValue) + (CurrentVolumeControls as IBasicVolumeWithFeedback).SetVolume(DefaultVolume); + + } + + void PowerIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + var dispTwoWay = DefaultDisplay as IHasPowerControlWithFeedback; + + if (dispTwoWay.PowerIsOnFeedback.BoolValue != OnFeedback.BoolValue) + { + if (!dispTwoWay.PowerIsOnFeedback.BoolValue) + CurrentSourceInfo = null; + OnFeedback.FireUpdate(); + } + if (dispTwoWay.PowerIsOnFeedback.BoolValue) + { + SetDefaultLevels(); + } + + } + + + + /// + /// + /// + protected override void EndShutdown() + { + VideoCodec.EndAllCalls(); + + SetDefaultLevels(); + + RunDefaultPresentRoute(); + + CrestronEnvironment.Sleep(1000); + + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Shutting down room"); + + RunRouteAction("roomOff"); + VideoCodec.StopSharing(); + VideoCodec.StandbyActivate(); + } + + /// + /// Routes the default source item, if any. Returns true when default route exists + /// + public override bool RunDefaultPresentRoute() + { + if (DefaultSourceItem != null) + RunRouteAction(DefaultSourceItem); + + return DefaultSourceItem != null; + } + + /// + /// Sets up the room when started into call mode without presenting a source + /// + /// + public bool RunDefaultCallRoute() + { + Debug.Console(2, this, "RunDefaultCallRoute() Currently Sharing Content: {0}", VideoCodec.SharingContentIsOnFeedback.BoolValue); + + if (VideoCodec.SharingContentIsOnFeedback.BoolValue) + { + Debug.Console(2, this, "Currently sharing content. Ignoring request to run default call route."); + return false; + } + + RunRouteAction(DefaultCodecRouteString); + return true; + } + + public void RunRouteActionCodec(string routeKey, string sourceListKey) + { + _codecExternalSourceChange = true; + RunRouteAction(routeKey, sourceListKey); + } + + /// + /// + /// + /// + public void RunRouteAction(string routeKey) + { + RunRouteAction(routeKey, new Action(() => { })); + } + + /// + /// + /// + /// + /// + /// + public void RunRouteAction(string routeKey, string sourceListKey) + { + if (string.IsNullOrEmpty(sourceListKey)) + { + Debug.Console(1, this, "No sourceListKey present. RunRouteAction assumes default source list."); + RunRouteAction(routeKey, new Action(() => { })); + } + else + { + Debug.Console(1, this, "sourceListKey present but not yet implemented"); + + RunRouteAction(routeKey, new Action(() => { })); + } + } + + /// + /// + /// + /// + /// + /// + public void RunRouteAction(string routeKey, string sourceListKey, Action successCallback) + { + if (string.IsNullOrEmpty(sourceListKey)) + { + RunRouteAction(routeKey, successCallback); + } + else + { + Debug.Console(1, this, "sourceListKey present but not yet implemented"); + + RunRouteAction(routeKey, successCallback); + } + } + + /// + /// Gets a source from config list SourceListKey and dynamically build and executes the + /// route or commands + /// + /// + public void RunRouteAction(string routeKey, Action successCallback) + { + // Run this on a separate thread + new CTimer(o => + { + // try to prevent multiple simultaneous selections + SourceSelectLock.TryEnter(); + + try + { + + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Run route action '{0}'", routeKey); + var dict = ConfigReader.ConfigObject.GetSourceListForKey(SourceListKey); + if (dict == null) + { + Debug.Console(1, this, "WARNING: Config source list '{0}' not found", SourceListKey); + return; + } + + // Try to get the list item by it's string key + if (!dict.ContainsKey(routeKey)) + { + Debug.Console(1, this, "WARNING: No item '{0}' found on config list '{1}'", + routeKey, SourceListKey); + return; + } + + // End usage timer on last source + if (!string.IsNullOrEmpty(LastSourceKey)) + { + var usageLastSource = dict[LastSourceKey].SourceDevice as IUsageTracking; + if (usageLastSource != null && usageLastSource.UsageTracker != null) + { + try + { + // There MAY have been failures in here. Protect + usageLastSource.UsageTracker.EndDeviceUsage(); + } + catch (Exception e) + { + Debug.Console(1, this, "*#* EXCEPTION in end usage tracking:\r{0}", e); + } + } + } + + // Let's run it + var item = dict[routeKey]; + if (routeKey.ToLower() != "roomoff") + { + + LastSourceKey = routeKey; + } + else + CurrentSourceInfoKey = null; + + // hand off the individual routes to this helper + foreach (var route in item.RouteList) + DoRouteItem(route); + + // Start usage timer on routed source + var usageNewSource = item.SourceDevice as IUsageTracking; + if (usageNewSource != null && usageNewSource.UsageTracker != null) // Have to make sure there is a usage tracker! + { + (item.SourceDevice as IUsageTracking).UsageTracker.StartDeviceUsage(); + } + + // See if this can be moved into common, base-class method ------------- + + + // Set volume control, using default if non provided + IBasicVolumeControls volDev = null; + // Handle special cases for volume control + if (string.IsNullOrEmpty(item.VolumeControlKey) + || item.VolumeControlKey.Equals("$defaultAudio", StringComparison.OrdinalIgnoreCase)) + volDev = DefaultVolumeControls; + else if (item.VolumeControlKey.Equals("$defaultDisplay", StringComparison.OrdinalIgnoreCase)) + volDev = DefaultDisplay as IBasicVolumeControls; + // Or a specific device, probably rarely used. + else + { + var dev = DeviceManager.GetDeviceForKey(item.VolumeControlKey); + if (dev is IBasicVolumeControls) + volDev = dev as IBasicVolumeControls; + else if (dev is IHasVolumeDevice) + volDev = (dev as IHasVolumeDevice).VolumeDevice; + } + + if (volDev != CurrentVolumeControls) + { + // zero the volume on the device we are leaving. + // Set the volume to default on device we are entering + if (ZeroVolumeWhenSwtichingVolumeDevices && CurrentVolumeControls is IBasicVolumeWithFeedback) + { + var vd = CurrentVolumeControls as IBasicVolumeWithFeedback; + SavedVolumeLevels[vd] = (uint)vd.VolumeLevelFeedback.IntValue; + vd.SetVolume(0); + } + + CurrentVolumeControls = volDev; + if (ZeroVolumeWhenSwtichingVolumeDevices && CurrentVolumeControls is IBasicVolumeWithFeedback) + { + var vd = CurrentVolumeControls as IBasicVolumeWithFeedback; + ushort vol = (SavedVolumeLevels.ContainsKey(vd) ? (ushort)SavedVolumeLevels[vd] : DefaultVolume); + vd.SetVolume(vol); + } + } + // ----------------------------------------------------------------------- + + + + // store the name and UI info for routes + if (item.SourceKey == "$off") + { + CurrentSourceInfoKey = routeKey; + CurrentSourceInfo = null; + } + else if (item.SourceKey != null) + { + CurrentSourceInfoKey = routeKey; + CurrentSourceInfo = item; + } + + OnFeedback.FireUpdate(); + + if (OnFeedback.BoolValue) + { + if (VideoCodec.UsageTracker.InUseTracker.InUseFeedback.BoolValue) + { + Debug.Console(1, this, "Video Codec in use, deactivating standby on codec"); + VideoCodec.StandbyDeactivate(); + } + + if (VideoCodec.StandbyIsOnFeedback.BoolValue) + { + VideoCodec.StandbyDeactivate(); + } + else + { + Debug.Console(1, this, "Video codec not in standby. No need to wake."); + } + } + else + { + Debug.Console(1, this, "Room OnFeedback state: {0}", OnFeedback.BoolValue); + } + + // report back when done + if (successCallback != null) + successCallback(); + } + catch (Exception e) + { + Debug.Console(1, this, "ERROR in routing: {0}", e); + } + + SourceSelectLock.Leave(); + }, 0); // end of CTimer + } + + /// + /// + /// + /// + void DoRouteItem(SourceRouteListItem route) + { + // if there is a $defaultAll on route, run two separate + if (route.DestinationKey.Equals("$defaultAll", StringComparison.OrdinalIgnoreCase)) + { + // Going to assume a single-path route for now + var tempVideo = new SourceRouteListItem + { + DestinationKey = "$defaultDisplay", + SourceKey = route.SourceKey, + Type = eRoutingSignalType.Video + }; + DoRoute(tempVideo); + } + else + DoRoute(route); + } + + /// + /// + /// + /// + /// + bool DoRoute(SourceRouteListItem route) + { + IRoutingSink dest = null; + + if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase)) + dest = DefaultAudioDevice as IRoutingSink; + else if (route.DestinationKey.Equals("$defaultDisplay", StringComparison.OrdinalIgnoreCase)) + dest = DefaultDisplay; + else + dest = DeviceManager.GetDeviceForKey(route.DestinationKey) as IRoutingSink; + + + if (dest == null) + { + Debug.Console(1, this, "Cannot route, unknown destination '{0}'", route.DestinationKey); + return false; + } + + if (route.SourceKey.Equals("$off", StringComparison.OrdinalIgnoreCase)) + { + dest.ReleaseRoute(); + if (dest is IHasPowerControl) + (dest as IHasPowerControl).PowerOff(); + + } + else + { + var source = DeviceManager.GetDeviceForKey(route.SourceKey) as IRoutingOutputs; + if (source == null) + { + Debug.Console(1, this, "Cannot route unknown source '{0}' to {1}", route.SourceKey, route.DestinationKey); + return false; + } + dest.ReleaseAndMakeRoute(source, route.Type); + } + return true; + } + + public override void RoomVacatedForTimeoutPeriod(object o) + { + //Implement this + } + + protected override bool AllowVacancyTimerToStart() + { + bool allowVideo = true; + bool allowAudio = true; + + if (VideoCodec != null) + { + Debug.Console(2,this, Debug.ErrorLogLevel.Notice, "Room {0} {1} in a video call", Key, VideoCodec.IsInCall ? "is" : "is not"); + allowVideo = !VideoCodec.IsInCall; + } + + if (AudioCodec != null) + { + Debug.Console(2,this, Debug.ErrorLogLevel.Notice, "Room {0} {1} in an audio call", Key, AudioCodec.IsInCall ? "is" : "is not"); + allowAudio = !AudioCodec.IsInCall; + } + + Debug.Console(2, this, "Room {0} allowing vacancy timer to start: {1}", Key, allowVideo && allowAudio); + + return allowVideo && allowAudio; + } + + /// + /// Does what it says + /// + public override void SetDefaultLevels() + { + Debug.Console(1, this, "Restoring default levels"); + var vc = CurrentVolumeControls as IBasicVolumeWithFeedback; + if (vc != null) + vc.SetVolume(DefaultVolume); + } + /// + /// Will power the room on with the last-used source + /// + public override void PowerOnToDefaultOrLastSource() + { + if (!EnablePowerOnToLastSource || LastSourceKey == null) + return; + RunRouteAction(LastSourceKey); + } + + /// + /// Runs "roomOff" action on all rooms not set to ExcludeFromGlobalFunctions + /// + public static void AllRoomsOff() + { + var allRooms = DeviceManager.AllDevices.Where(d => + d is IEssentialsRoom && !(d as IEssentialsHuddleSpaceRoom).ExcludeFromGlobalFunctions); + foreach (var room in allRooms) + (room as IEssentialsHuddleSpaceRoom).RunRouteAction("roomOff"); + } + + + /// + /// Setup the external sources for the Cisco Touch 10 devices that support IHasExternalSourceSwitch + /// + private void SetCodecExternalSources() + { + var videoCodecWithExternalSwitching = VideoCodec as IHasExternalSourceSwitching; + + if (videoCodecWithExternalSwitching == null || !videoCodecWithExternalSwitching.ExternalSourceListEnabled) + { + return; + } + + try + { + // Get the tie line that the external switcher is connected to + string codecInputConnectorName = ConfigReader.ConfigObject.TieLines.SingleOrDefault( + x => x.DestinationKey == VideoCodec.Key && x.DestinationPort == videoCodecWithExternalSwitching.ExternalSourceInputPort).DestinationPort; + + videoCodecWithExternalSwitching.ClearExternalSources(); + videoCodecWithExternalSwitching.RunRouteAction = RunRouteActionCodec; + var srcList = ConfigReader.ConfigObject.SourceLists.SingleOrDefault(x => x.Key == SourceListKey).Value.OrderBy(kv => kv.Value.Order); ; + + foreach (var kvp in srcList) + { + var srcConfig = kvp.Value; + + if (kvp.Key != DefaultCodecRouteString && kvp.Key != "roomOff") + { + videoCodecWithExternalSwitching.AddExternalSource(codecInputConnectorName, kvp.Key, srcConfig.PreferredName, PepperDash.Essentials.Devices.Common.VideoCodec.Cisco.eExternalSourceType.desktop); + videoCodecWithExternalSwitching.SetExternalSourceState(kvp.Key, PepperDash.Essentials.Devices.Common.VideoCodec.Cisco.eExternalSourceMode.Ready); + } + } + Debug.Console(1, this, "Successfully set up codec external sources for room: {0}", Name); + + } + catch (Exception e) + { + Debug.Console(2, this, "Error setting codec external sources: {0}", e); + } + } + + private void SetCodecBranding() + { + var vcWithBranding = VideoCodec as IHasBranding; + + if (vcWithBranding == null) return; + + Debug.Console(1, this, "Setting Codec Branding"); + vcWithBranding.InitializeBranding(Key); + } + + #region IPrivacy Members + + + public void PrivacyModeOff() + { + VideoCodec.PrivacyModeOff(); + } + + public void PrivacyModeOn() + { + VideoCodec.PrivacyModeOn(); + } + + public void PrivacyModeToggle() + { + VideoCodec.PrivacyModeToggle(); + } + + #endregion + } } \ No newline at end of file diff --git a/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs.orig b/src/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs.orig similarity index 100% rename from PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs.orig rename to src/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs.orig diff --git a/PepperDashEssentials/Room/Types/EssentialsNDisplayRoomBase.cs b/src/PepperDashEssentials/Room/Types/EssentialsNDisplayRoomBase.cs similarity index 100% rename from PepperDashEssentials/Room/Types/EssentialsNDisplayRoomBase.cs rename to src/PepperDashEssentials/Room/Types/EssentialsNDisplayRoomBase.cs diff --git a/PepperDashEssentials/Room/Types/EssentialsTechRoom.cs b/src/PepperDashEssentials/Room/Types/EssentialsTechRoom.cs similarity index 100% rename from PepperDashEssentials/Room/Types/EssentialsTechRoom.cs rename to src/PepperDashEssentials/Room/Types/EssentialsTechRoom.cs diff --git a/PepperDashEssentials/Room/Types/Interfaces/IEssentialsHuddleSpaceRoom.cs b/src/PepperDashEssentials/Room/Types/Interfaces/IEssentialsHuddleSpaceRoom.cs similarity index 100% rename from PepperDashEssentials/Room/Types/Interfaces/IEssentialsHuddleSpaceRoom.cs rename to src/PepperDashEssentials/Room/Types/Interfaces/IEssentialsHuddleSpaceRoom.cs diff --git a/PepperDashEssentials/Room/Types/Interfaces/IEssentialsHuddleVtc1Room.cs b/src/PepperDashEssentials/Room/Types/Interfaces/IEssentialsHuddleVtc1Room.cs similarity index 100% rename from PepperDashEssentials/Room/Types/Interfaces/IEssentialsHuddleVtc1Room.cs rename to src/PepperDashEssentials/Room/Types/Interfaces/IEssentialsHuddleVtc1Room.cs diff --git a/PepperDashEssentials/SGD/PepperDash Essentials TSW-560.sgd b/src/PepperDashEssentials/SGD/PepperDash Essentials TSW-560.sgd similarity index 100% rename from PepperDashEssentials/SGD/PepperDash Essentials TSW-560.sgd rename to src/PepperDashEssentials/SGD/PepperDash Essentials TSW-560.sgd diff --git a/PepperDashEssentials/SGD/PepperDash Essentials TSW-760.sgd b/src/PepperDashEssentials/SGD/PepperDash Essentials TSW-760.sgd similarity index 100% rename from PepperDashEssentials/SGD/PepperDash Essentials TSW-760.sgd rename to src/PepperDashEssentials/SGD/PepperDash Essentials TSW-760.sgd diff --git a/PepperDashEssentials/SGD/PepperDash Essentials iPad.sgd b/src/PepperDashEssentials/SGD/PepperDash Essentials iPad.sgd similarity index 100% rename from PepperDashEssentials/SGD/PepperDash Essentials iPad.sgd rename to src/PepperDashEssentials/SGD/PepperDash Essentials iPad.sgd diff --git a/PepperDashEssentials/UI - FILES ORPHANED-DELETE/CrestronTouchpanelPropertiesConfig.cs b/src/PepperDashEssentials/UI - FILES ORPHANED-DELETE/CrestronTouchpanelPropertiesConfig.cs similarity index 100% rename from PepperDashEssentials/UI - FILES ORPHANED-DELETE/CrestronTouchpanelPropertiesConfig.cs rename to src/PepperDashEssentials/UI - FILES ORPHANED-DELETE/CrestronTouchpanelPropertiesConfig.cs diff --git a/PepperDashEssentials/UI - FILES ORPHANED-DELETE/DualDisplaySourceSRLController.cs b/src/PepperDashEssentials/UI - FILES ORPHANED-DELETE/DualDisplaySourceSRLController.cs similarity index 100% rename from PepperDashEssentials/UI - FILES ORPHANED-DELETE/DualDisplaySourceSRLController.cs rename to src/PepperDashEssentials/UI - FILES ORPHANED-DELETE/DualDisplaySourceSRLController.cs diff --git a/PepperDashEssentials/UI - FILES ORPHANED-DELETE/EssentialsTouchpanelController.cs b/src/PepperDashEssentials/UI - FILES ORPHANED-DELETE/EssentialsTouchpanelController.cs similarity index 100% rename from PepperDashEssentials/UI - FILES ORPHANED-DELETE/EssentialsTouchpanelController.cs rename to src/PepperDashEssentials/UI - FILES ORPHANED-DELETE/EssentialsTouchpanelController.cs diff --git a/PepperDashEssentials/UI - FILES ORPHANED-DELETE/SubpageReferenceListActivityItem.cs b/src/PepperDashEssentials/UI - FILES ORPHANED-DELETE/SubpageReferenceListActivityItem.cs similarity index 100% rename from PepperDashEssentials/UI - FILES ORPHANED-DELETE/SubpageReferenceListActivityItem.cs rename to src/PepperDashEssentials/UI - FILES ORPHANED-DELETE/SubpageReferenceListActivityItem.cs diff --git a/PepperDashEssentials/UI - FILES ORPHANED-DELETE/SubpageReferenceListSourceItem.cs b/src/PepperDashEssentials/UI - FILES ORPHANED-DELETE/SubpageReferenceListSourceItem.cs similarity index 100% rename from PepperDashEssentials/UI - FILES ORPHANED-DELETE/SubpageReferenceListSourceItem.cs rename to src/PepperDashEssentials/UI - FILES ORPHANED-DELETE/SubpageReferenceListSourceItem.cs diff --git a/PepperDashEssentials/UI/DualDisplaySourceSRLController.cs b/src/PepperDashEssentials/UI/DualDisplaySourceSRLController.cs similarity index 100% rename from PepperDashEssentials/UI/DualDisplaySourceSRLController.cs rename to src/PepperDashEssentials/UI/DualDisplaySourceSRLController.cs diff --git a/PepperDashEssentials/UI/EssentialsTouchpanelController.cs b/src/PepperDashEssentials/UI/EssentialsTouchpanelController.cs similarity index 100% rename from PepperDashEssentials/UI/EssentialsTouchpanelController.cs rename to src/PepperDashEssentials/UI/EssentialsTouchpanelController.cs diff --git a/PepperDashEssentials/UI/HttpLogoServer.cs b/src/PepperDashEssentials/UI/HttpLogoServer.cs similarity index 97% rename from PepperDashEssentials/UI/HttpLogoServer.cs rename to src/PepperDashEssentials/UI/HttpLogoServer.cs index b81a51f4..0ff60e93 100644 --- a/PepperDashEssentials/UI/HttpLogoServer.cs +++ b/src/PepperDashEssentials/UI/HttpLogoServer.cs @@ -1,123 +1,123 @@ -using System; -using System.Collections.Generic; -using Crestron.SimplSharp; -using Crestron.SimplSharp.CrestronIO; -using Crestron.SimplSharp.Net.Http; - -using PepperDash.Core; - -namespace PepperDash.Essentials -{ - public class HttpLogoServer - { - /// - /// - /// - readonly HttpServer _server; - - /// - /// - /// - readonly string _fileDirectory; - - /// - /// - /// - public static Dictionary ExtensionContentTypes; - - /// - /// - /// - /// - /// - public HttpLogoServer(int port, string directory) - { - ExtensionContentTypes = new Dictionary - { - //{ ".css", "text/css" }, - //{ ".htm", "text/html" }, - //{ ".html", "text/html" }, - { ".jpg", "image/jpeg" }, - { ".jpeg", "image/jpeg" }, - //{ ".js", "application/javascript" }, - //{ ".json", "application/json" }, - //{ ".map", "application/x-navimap" }, - { ".pdf", "application/pdf" }, - { ".png", "image/png" }, - //{ ".txt", "text/plain" }, - }; - - _server = new HttpServer {Port = port}; - _fileDirectory = directory; - _server.OnHttpRequest += Server_OnHttpRequest; - _server.Open(); - - CrestronEnvironment.ProgramStatusEventHandler += CrestronEnvironment_ProgramStatusEventHandler; - } - - /// - /// - /// - void Server_OnHttpRequest(object sender, OnHttpRequestArgs args) - { - var path = args.Request.Path; - Debug.Console(2, "HTTP Request with path: '{0}'", args.Request.Path); - - try - { - if (File.Exists(_fileDirectory + path)) - { - var filePath = path.Replace('/', '\\'); - var localPath = string.Format(@"{0}{1}", _fileDirectory, filePath); - - Debug.Console(2, "HTTP Logo Server attempting to find file: '{0}'", localPath); - if (File.Exists(localPath)) - { - args.Response.Header.ContentType = GetContentType(new FileInfo(localPath).Extension); - args.Response.ContentStream = new FileStream(localPath, FileMode.Open, FileAccess.Read); - } - else - { - Debug.Console(2, "HTTP Logo Server Cannot find file '{0}'", localPath); - args.Response.ContentString = string.Format("Not found: '{0}'", filePath); - args.Response.Code = 404; - } - } - else - { - Debug.Console(2, "HTTP Logo Server: '{0}' does not exist", _fileDirectory + path); - args.Response.ContentString = string.Format("Not found: '{0}'", _fileDirectory + path); - args.Response.Code = 404; - } - } - catch (Exception ex) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Exception getting file: {0}", ex.Message); - Debug.Console(0, Debug.ErrorLogLevel.Error, "Stack Trace: {0}", ex.StackTrace); - - args.Response.Code = 400; - args.Response.ContentString = string.Format("invalid request"); - } - } - - /// - /// - /// - void CrestronEnvironment_ProgramStatusEventHandler(eProgramStatusEventType programEventType) - { - if (programEventType == eProgramStatusEventType.Stopping) - _server.Close(); - } - - /// - /// - /// - /// - /// - public static string GetContentType(string extension) - { - var type = ExtensionContentTypes.ContainsKey(extension) ? ExtensionContentTypes[extension] : "text/plain"; - return type; - } - } +using System; +using System.Collections.Generic; +using Crestron.SimplSharp; +using Crestron.SimplSharp.CrestronIO; +using Crestron.SimplSharp.Net.Http; + +using PepperDash.Core; + +namespace PepperDash.Essentials +{ + public class HttpLogoServer + { + /// + /// + /// + readonly HttpServer _server; + + /// + /// + /// + readonly string _fileDirectory; + + /// + /// + /// + public static Dictionary ExtensionContentTypes; + + /// + /// + /// + /// + /// + public HttpLogoServer(int port, string directory) + { + ExtensionContentTypes = new Dictionary + { + //{ ".css", "text/css" }, + //{ ".htm", "text/html" }, + //{ ".html", "text/html" }, + { ".jpg", "image/jpeg" }, + { ".jpeg", "image/jpeg" }, + //{ ".js", "application/javascript" }, + //{ ".json", "application/json" }, + //{ ".map", "application/x-navimap" }, + { ".pdf", "application/pdf" }, + { ".png", "image/png" }, + //{ ".txt", "text/plain" }, + }; + + _server = new HttpServer {Port = port}; + _fileDirectory = directory; + _server.OnHttpRequest += Server_OnHttpRequest; + _server.Open(); + + CrestronEnvironment.ProgramStatusEventHandler += CrestronEnvironment_ProgramStatusEventHandler; + } + + /// + /// + /// + void Server_OnHttpRequest(object sender, OnHttpRequestArgs args) + { + var path = args.Request.Path; + Debug.Console(2, "HTTP Request with path: '{0}'", args.Request.Path); + + try + { + if (File.Exists(_fileDirectory + path)) + { + var filePath = path.Replace('/', '\\'); + var localPath = string.Format(@"{0}{1}", _fileDirectory, filePath); + + Debug.Console(2, "HTTP Logo Server attempting to find file: '{0}'", localPath); + if (File.Exists(localPath)) + { + args.Response.Header.ContentType = GetContentType(new FileInfo(localPath).Extension); + args.Response.ContentStream = new FileStream(localPath, FileMode.Open, FileAccess.Read); + } + else + { + Debug.Console(2, "HTTP Logo Server Cannot find file '{0}'", localPath); + args.Response.ContentString = string.Format("Not found: '{0}'", filePath); + args.Response.Code = 404; + } + } + else + { + Debug.Console(2, "HTTP Logo Server: '{0}' does not exist", _fileDirectory + path); + args.Response.ContentString = string.Format("Not found: '{0}'", _fileDirectory + path); + args.Response.Code = 404; + } + } + catch (Exception ex) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "Exception getting file: {0}", ex.Message); + Debug.Console(0, Debug.ErrorLogLevel.Error, "Stack Trace: {0}", ex.StackTrace); + + args.Response.Code = 400; + args.Response.ContentString = string.Format("invalid request"); + } + } + + /// + /// + /// + void CrestronEnvironment_ProgramStatusEventHandler(eProgramStatusEventType programEventType) + { + if (programEventType == eProgramStatusEventType.Stopping) + _server.Close(); + } + + /// + /// + /// + /// + /// + public static string GetContentType(string extension) + { + var type = ExtensionContentTypes.ContainsKey(extension) ? ExtensionContentTypes[extension] : "text/plain"; + return type; + } + } } \ No newline at end of file diff --git a/PepperDashEssentials/UI/JoinConstants/UIBoolJoin.cs b/src/PepperDashEssentials/UI/JoinConstants/UIBoolJoin.cs similarity index 96% rename from PepperDashEssentials/UI/JoinConstants/UIBoolJoin.cs rename to src/PepperDashEssentials/UI/JoinConstants/UIBoolJoin.cs index 1a127000..a76f5bcb 100644 --- a/PepperDashEssentials/UI/JoinConstants/UIBoolJoin.cs +++ b/src/PepperDashEssentials/UI/JoinConstants/UIBoolJoin.cs @@ -1,991 +1,991 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; - -namespace PepperDash.Essentials -{ - /// - /// Where all UI element common joins are defined - /// - public class UIBoolJoin - { - /// - /// 901 - /// - public const uint VolumeUpPress = 901; - /// - /// 902 - /// - public const uint VolumeDownPress = 902; - - //**************************************************** - // Codec General - - /// - /// 1001 - /// - public const uint CallEndPress = 1001; - /// - /// 1002 - /// - public const uint CallEndAllConfirmPress = 1002; - /// - /// 1003 - For tapping the text field to reveal the keyboard - /// - public const uint CodecDirectorySearchTextPress = 1003; - /// - /// 1004 - /// - public const uint CallStopSharingPress = 1004; - /// - /// 1005 - /// - public const uint CallSharedSourceInfoVisible = 1005; - /// - /// 1006 - /// - public const uint CallEndAllConfirmVisible = 1006; - /// - /// 1007 - /// - public const uint MeetingPasswordVisible = 1007; - /// - /// 1008 - /// - public const uint MeetingLeavePress = 1008; - - - - - - // Audio Conference - /// - /// 1101 - /// - public const uint ACKeypadVisible = 1101; - /// - /// 1102 - /// - public const uint ACStagingPopoverVisible = 1102; - /// - /// 1111 - /// - public const uint ACSpeedDial1Press = 1111; - /// - /// 1112 - /// - public const uint ACSpeedDial2Press = 1112; - /// - /// 1113 - /// - public const uint ACSpeedDial3Press = 1113; - /// - /// 1114 - /// - public const uint ACSpeedDial4Press = 1114; - /// - /// 1121 - /// - public const uint ACSpeedDial1Visible = 1121; - /// - /// 1122 - /// - public const uint ACSpeedDial2Visible = 1122; - /// - /// 1123 - /// - public const uint ACSpeedDial3Visible = 1123; - /// - /// 1124 - /// - public const uint ACSpeedDial4Visible = 1124; - - //****************************************************** - // Video Conference - /// - /// 1201 - /// - public const uint VCKeypadWithFavoritesVisible = 1201; - /// - /// 1202 - /// - public const uint VCStagingInactivePopoverWithRecentsVisible = 1202; - /// - /// - /// - public const uint VCStagingActivePopoverVisible = 1203; - /// - /// - /// - public const uint VCKeypadVisible = 1204; - /// - /// 1205 - /// - public const uint VCDirectoryVisible = 1205; - /// - /// 1206 - /// - public const uint VCRecentsVisible = 1206; - - /// - /// 1202 - /// - public const uint VCStagingInactivePopoverWithoutRecentsVisible = 1207; - - /// - /// 1208 - /// - public const uint VCCameraAutoVisible = 1208; - - /// - /// 1209 - /// - public const uint VCCameraManualVisible = 1209; - - /// - /// 1210 - /// - public const uint VCCameraOffVisible = 1210; - - /// - /// 1211 - 1215 - /// - public const uint VCFavoritePressStart = 1211; - // RANGE IN USE - public const uint VCFavoritePressEnd = 1215; - /// - /// 1221 - 1225 - /// - public const uint VCFavoriteVisibleStart = 1221; - // RANGE IN USE - public const uint VCFavoriteVisibleEnd = 1225; - - /// - /// 1230 - /// - public const uint VCStagingMeetNowPress = 1230; - /// - /// 1231 - /// - public const uint VCStagingRecentsPress = 1231; - /// - /// 1232 - /// - public const uint VCStagingDirectoryPress = 1232; - /// - /// 1233 - /// - public const uint VCStagingKeypadPress = 1233; - /// - /// 1234 - /// - public const uint VCStagingConnectPress = 1234; - /// - /// 1235 - /// - public const uint VCStagingCameraPress = 1235; - /// - /// 1236 - /// - public const uint VCStagingConnectEnable = 1236; - /// - /// 1237 - When the user touches the text field, should trigger keyboard - /// - public const uint VCKeypadTextPress = 1237; - /// - /// 1238 - /// - public const uint VCKeypadBackspacePress = 1238; - /// - /// 1239 - /// - public const uint VCKeypadBackspaceVisible = 1239; - /// - /// 1240 - /// - public const uint VCDirectoryBackPress = 1240; - /// - /// 1241 For touching the text area to bring up keyboard - /// - public const uint VCDirectorySearchTextPress = 1241; - /// - /// 1242 - /// - public const uint VCStagingSelfViewLayoutPress = 1242; - /// - /// 1243 - /// - public const uint VCDirectoryBackVisible = 1243; - /// - /// 1244 - /// - public const uint VCDirectoryBackspacePress = 1244; - /// - /// 1245 - /// - public const uint VCDirectoryBackspaceVisible = 1245; - /// - /// 1251 - /// - public const uint VCSelfViewTogglePress = 1251; - /// - /// 1252 - /// - public const uint VCLayoutTogglePress = 1252; - /// - /// 1253 - /// - public const uint VCSelfViewPipTogglePress = 1253; - /// - /// 1254 - /// - public const uint VCLayoutToggleEnable = 1254; - /// - /// 1255 - /// - public const uint VCMinMaxPress = 1255; - /// - /// 1256 - /// - public const uint VCMinMaxEnable = 1256; - - /// - /// 1260 - /// - public const uint VCCameraModeBarVisible = 1260; - - /// - /// 1261 - /// - public const uint VCCameraSelectBarWithoutModeVisible = 1261; - - /// - /// 1262 - /// - public const uint VCCameraAutoModeIsOnFb = 1262; - - /// - /// 1271 - /// - public const uint VCCameraZoomIn = 1271; - /// - /// 1272 - /// - public const uint VCCameraZoomOut = 1272; - - - /// - /// 1280 - /// - public const uint VCCameraPresetSavedLabelVisible = 1280; - /// - /// 1281 - /// - public const uint VCCameraPreset1 = 1281; - /// - /// 1282 - /// - public const uint VCCameraPreset2 = 1282; - /// - /// 1283 - /// - public const uint VCCameraPreset3 = 1283; - - - /// - /// 1291 - /// - public const uint VCCameraPreset1Visible = 1291; - /// - /// 1292 - /// - public const uint VCCameraPreset2Visible = 1292; - /// - /// 1293 - /// - public const uint VCCameraPreset3Visible = 1293; - - - // Letter joins start at 2921; - - //****************************************************** - - // Environment Joins - - // Popup Container - - /// - /// 2001 - 2004 - /// - public const uint EnvironmentBackgroundSubpageVisibleBase = 2000; - - - // ColumnOne - - /// - /// 2011 - 2015 - /// - public const uint EnvironmentColumnOneLightingTypeVisibleBase = 2010; - - /// - /// 2016 - 2020 - /// - public const uint EnvironmentColumnOneShadingTypeVisibleBase = 2015; - - // ColumnTwo - - /// - /// 2021 - 2025 - /// - public const uint EnvironmentColumnTwoLightingTypeVisibleBase = 2020; - - /// - /// 2026 - 2030 - /// - public const uint EnvironmentColumnTwoShadingTypeVisibleBase = 2025; - - // ColumnThree - - /// - /// 2031 - 2035 - /// - public const uint EnvironmentColumnThreeLightingTypeVisibleBase = 2030; - - /// - /// 2036 - 2040 - /// - public const uint EnvironmentColumnThreeShadingTypeVisibleBase = 2035; - - // ColumnFour - - /// - /// 2041 - 2045 - /// - public const uint EnvironmentColumnFourLightingTypeVisibleBase = 2040; - - /// - /// 2046 - 2050 - /// - public const uint EnvironmentColumnFourShadingTypeVisibleBase = 2045; - - // Button press - - /// - /// 2051 - 2060 - /// - public const uint EnvironmentColumnOneButtonPressBase = 2050; - - /// - /// 2061 - 2070 - /// - public const uint EnvironmentColumnTwoButtonPressBase = 2060; - - /// - /// 2071 - 2080 - /// - public const uint EnvironmentColumnThreeButtonPressBase = 2070; - - /// - /// 2081 - 2090 - /// - public const uint EnvironmentColumnFourButtonPressBase = 2080; - - // Button visibility - - /// - /// 2151 - 2160 - /// - public const uint EnvironmentColumnOneButtonVisibleBase = 2150; - - /// - /// 2161 - 2170 - /// - public const uint EnvironmentColumnTwoButtonVisibleBase = 2160; - - /// - /// 2171 - 2180 - /// - public const uint EnvironmentColumnThreeButtonVisibleBase = 2170; - - /// - /// 2181 - 2190 - /// - public const uint EnvironmentColumnFourButtonVisibleBase = 2180; - - - //****************************************************** - - /// - /// 3101 - /// - public const uint TechExitButton = 3101; - /// - /// 3106 - /// - public const uint TechCommonItemsVisbible = 3106; - /// - /// 3107 - /// - public const uint TechSystemStatusVisible = 3107; - /// - /// 3108 - /// - public const uint TechDisplayControlsVisible = 3108; - /// - /// 3109 - /// - public const uint TechPanelSetupVisible = 3109; - /// - /// 3110 - /// - public const uint TechAdvancedVolumeVisible = 3110; - /// - /// 3111 - /// - public const uint TechAboutVisible = 3111; - /// - /// 3112 - /// - public const uint TechSchedulerVisible = 3112; - - //***************************************************** - /// - /// 3811 - /// - public const uint VolumeSingleMute1Visible = 3811; - /// - /// 3812 - /// - public const uint VolumeSlider1Press = 3812; - /// - /// 3813 - /// - public const uint Volume1ProgramMutePressAndFB = 3813; - /// - /// 3821 - /// - public const uint Volume2Visible = 3821; - /// - /// 3822 - /// - public const uint VolumeSlider2Press = 3822; - /// - /// 3823 - /// - public const uint Volume2MutePressAndFB = 3823; - /// - /// 3831 - /// - public const uint Volume3Visible = 3831; - /// - /// 3832 - /// - public const uint VolumeSlider3Press = 3832; - /// - /// 3833 - /// - public const uint Volume3MutePressAndFB = 3833; - /// - /// 3841 - /// - public const uint Volume4Visible = 3841; - /// - /// 3842 - /// - public const uint VolumeSlider4Press = 3842; - /// - /// 3843 - /// - public const uint Volume4MutePressAndFB = 3843; - /// - /// 3851 - /// - public const uint Volume5Visible = 3851; - /// - /// 3852 - /// - public const uint VolumeSlider5Press = 3852; - /// - /// 3853 - /// - public const uint Volume5MutePressAndFB = 3853; - /// - /// 3861 - /// - public const uint Volume6Visible = 3861; - /// - /// 3862 - /// - public const uint VolumeSlider6Press = 3862; - /// - /// 3863 - /// - public const uint Volume6MutePressAndFB = 3863; - - /// - /// 3869 - when the system is off and the gear is pressed - /// - public const uint VolumesPagePowerOffVisible = 3869; - /// - /// 3870 - /// - public const uint VolumesPageVisible = 3870; - /// - /// 3871 - /// - public const uint VolumeDualMute1Visible = 3871; - /// - /// 3874 - /// - public const uint Volume1SpeechMutePressAndFB = 3874; - /// - /// 3875 - /// - public const uint Volume1BackerVisibility = 3875; - /// - /// 3891 - /// - public const uint VolumeDefaultPress = 3891; - /// - /// 3951 - /// - /// 3952 - /// - public const uint HeaderIcon2Press = 3952; - /// - /// 3953 - /// - public const uint HeaderIcon3Press = 3953; - /// - /// 3954 - /// - public const uint HeaderIcon4Press = 3954; - /// - /// 3955 - /// - public const uint HeaderIcon5Press = 3955; - - /// 3960 - /// - public const uint HeaderPopupCaretsSubpageVisibile = 3960; - /// - /// 3961 - /// - public const uint HeaderCaret1Visible = 3961; - /// - /// 3962 - /// - public const uint HeaderCaret2Visible = 3962; - /// - /// 3963 - /// - public const uint HeaderCaret3Visible = 3963; - /// - /// 3964 - /// - public const uint HeaderCaret4Visible = 3964; - /// - /// 3965 - /// - public const uint HeaderCaret5Visible = 3965; - - /// - /// 3999 - /// - public const uint GenericModalVisible = 3999; - /// - /// 12345 - /// - public const uint AvNoControlsSubVisible = 12345; - - // 10000 - 14999 are general "source" pages - - /// - /// 15001 - /// - public const uint StartPageVisible = 15001; - /// - /// 15002 Shows the start page in the source controls area of the screen - /// - public const uint TapToBeginVisible = 15002; - /// - /// 15003 Message text when no source is showing - /// - public const uint SelectASourceVisible = 15003; - /// - /// 15004 - /// - public const uint RoomIsOn = 15004; - /// - /// 15005 Shows always-on volume control subpage with only audio mute - /// - public const uint VolumeControlsSingleMuteVisible = 15005; - /// - /// 15006 Shows always-on volume control subpage with mic and audio mutes - /// - public const uint VolumeControlsDualMuteVisible = 15006; - /// - /// 15010 - /// - public const uint ShowPanelSetupPress = 15010; - /// - /// 15011 - Top bar with room name and button that pops up dialog with room data - /// - public const uint TopBarHabaneroVisible = 15011; - /// - /// 15012 - /// - public const uint SourceStagingBarVisible = 15012; - /// - /// 15013 - /// - public const uint PowerOffStep1Visible = 15013; - /// - /// 15014 - /// - public const uint PowerOffStep2Visible = 15014; - /// - /// 15015 - /// - public const uint ShowPowerOffPress = 15015; - /// - /// 15016 - /// - public const uint PowerOffMorePress = 15016; - /// - /// 15017 - /// - public const uint StagingPageAdditionalArrowsVisible = 15017; - /// - /// 15018 The Header with dynamic buttons - /// - public const uint TopBarHabaneroDynamicVisible = 15018; - /// - /// 15019 Shown when system is starting and not ready for use - /// - public const uint SystemInitializingVisible = 15019; - /// - /// 15020 - /// - public const uint PanelSetupVisible = 15020; - /// - /// 15021 - /// - public const uint SourceWaitOverlayVisible = 15021; - /// - /// 15022 - /// - public const uint ActivityFooterVisible = 15022; - /// - /// 15024 - /// - public const uint HeaderCallStatusLeftPositionVisible = 15024; - /// - /// 15025 - /// - public const uint HeaderCallStatusRightPositionVisible = 15025; - /// - /// 15027 - /// - public const uint HeaderCallStatusLabelPress = 15027; - /// - /// 15028 The gear button in header - /// - public const uint FIXFIX_HeaderGearButtonPress_FIXFIX = 15028; - /// - /// 15029 the room button in header - /// - public const uint HeaderRoomButtonPress = 15029; - /// - /// 15030 Visibility for room data popup - /// - public const uint RoomHeaderInfoPageVisible = 15030; - /// - /// 15031 - /// - public const uint AllRoomsOffPress = 15031; - /// - /// 15032 - /// - public const uint DisplayPowerTogglePress = 15032; - /// - /// 15033 - /// - public const uint PowerOffCancelPress = 15033; - /// - /// 15034 - /// - public const uint PowerOffConfirmPress = 15034; - /// - /// 15035 - /// - public const uint VolumeButtonPopupPress = 15035; - /// - /// 15035 - /// - public const uint VolumeButtonPopupVisible = 15035; - /// - /// 15036 - /// - public const uint VolumeGaugePopupVisible = 15036; - /// - /// 15037 - /// - public const uint GearButtonVisible = 15037; - /// - /// 15038 - /// - public const uint CalendarHeaderButtonVisible = 15038; - /// - /// 15039 - /// - public const uint CalendarHeaderButtonPress = 15039; - /// - /// 15040 - /// - public const uint CallStatusPageVisible = 15040; - /// - /// 15041 - /// - public const uint LightsPageVisible = 15041; - /// - /// 15042 Closes whichever interlocked modal is open - /// - public const uint InterlockedModalClosePress = 15042; - /// - /// 15043 Vis for modal backer for full-screen source - /// - public const uint SourceBackgroundOverlayVisible = 15043; - /// - /// 15044 Close button for source modal overlay - /// - public const uint SourceBackgroundOverlayClosePress = 15044; - /// - /// 15045 - /// - public const uint ZoomRoomContentSharingVisible = 15045; - /// - /// 15046 - /// - public const uint MeetingsOrContacMethodsListVisible = 15046; - /// - /// 15047 The "Join" button on the next meeting ribbon - /// - public const uint NextMeetingJoinPress = 15047; - /// - /// 15048 Dismisses the ribbon - /// - public const uint NextMeetingModalClosePress = 15048; - /// - /// 15049 - /// - public const uint NextMeetingModalVisible = 15049; - /// - /// 15050 - /// - public const uint NextMeetingNotificationRibbonVisible = 15050; - /// - /// 15051 - /// - public const uint Display1SelectPressAndFb = 15051; - /// - /// 15052 - /// - public const uint Display1ControlButtonEnable = 15052; - /// - /// 15053 - /// - public const uint Display1ControlButtonPress = 15053; - /// - /// 15054 - /// - public const uint Display1AudioButtonEnable = 15054; - /// - /// 15055 - /// - public const uint Display1AudioButtonPressAndFb = 15055; - /// - /// 15056 - /// - public const uint Display2SelectPressAndFb = 15056; - /// - /// 15057 - /// - public const uint Display2ControlButtonEnable = 15057; - /// - /// 15058 - /// - public const uint Display2ControlButtonPress = 15058; - /// - /// 15059 - /// - public const uint Display2AudioButtonEnable = 15059; - /// - /// 15060 - /// - public const uint Display2AudioButtonPressAndFb = 15060; - /// - /// 15061 Reveals the dual-display subpage - /// - public const uint DualDisplayPageVisible = 15061; - /// - /// 15062 Reveals the toggle switch for the sharing mode - /// - public const uint ToggleSharingModeVisible = 15062; - /// - /// 15063 Press for the toggle mode switch - /// - public const uint ToggleSharingModePress = 15063; - /// - /// 15064 - /// - public const uint LogoDefaultVisible = 15064; - /// - /// 15065 - /// - public const uint LogoUrlVisible = 15065; - /// - /// 15066 - Reveals the active calls header item - /// - public const uint HeaderActiveCallsListVisible = 15066; - /// - /// 15067 - /// - public const uint NotificationRibbonVisible = 15067; - /// - /// 15068 - /// - public const uint HeaderMeetingInfoVisible = 15068; - - /// - /// 15083 - Press for Call help desk on AC/VC - /// - public const uint HelpPageShowCallButtonPress = 15083; - /// - /// 15084 - Show the "call help desk" button on help page - /// - public const uint HelpPageShowCallButtonVisible = 15084; - /// - /// 15085 Visibility join for help subpage - /// - public const uint HelpPageVisible = 15085; - /// - /// 15086 Press for help header button - /// - public const uint HelpPress = 15086; - /// - /// 15088 - /// - public const uint DateOnlyVisible = 15088; - /// - /// 15089 - /// - public const uint TimeOnlyVisible = 15089; - /// - /// 15090 - /// - public const uint DateAndTimeVisible = 15090; - /// - /// 15091 - /// - public const uint SetupFullDistrib = 15091; - - /// - /// 15092 - /// - public const uint StartMCPageVisible = 15092; - - - /// - /// 15093 - /// - public const uint RoomHeaderInfoMCPageVisible = 15093; - - /// - /// 15094 - /// - public const uint MCScreenSaverVisible = 15094; - - /// - /// 15095 - /// - public const uint MCScreenSaverPosition1Visible = 15095; - - /// - /// 15096 - /// - public const uint MCScreenSaverPosition2Visible = 15096; - - /// - /// 15097 - /// - public const uint MCScreenSaverPosition3Visible = 15097; - - /// - /// 15098 - /// - public const uint MCScreenSaverPosition4Visible = 15098; - - /// - /// 15099 - /// - public const uint MCScreenSaverClosePress = 15099; - - // PIN dialogs ************************************ - - /// - /// 15201 - /// - public const uint PinDialog4DigitVisible = 15201; - /// - /// 15206 - /// - public const uint PinDialogCancelPress = 15206; - /// - /// 15207 - /// - public const uint PinDialogErrorVisible = 15207; - /// - /// 15211 - /// - public const uint PinDialogDot1 = 15211; - /// - /// 15212 - /// - public const uint PinDialogDot2 = 15212; - /// - /// 15213 - /// - public const uint PinDialogDot3 = 15213; - /// - /// 15214 - /// - public const uint PinDialogDot4 = 15214; - - // Password Prompt Dialog ************************** - - /// - /// 15301 - /// - public const uint PasswordPromptDialogVisible = 15301; - /// - /// 15302 - /// - public const uint PasswordPromptTextPress = 15302; - /// - /// 15306 - /// - public const uint PasswordPromptCancelPress = 15306; - /// - /// 15307 - /// - public const uint PasswordPromptErrorVisible = 15307; - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; + +namespace PepperDash.Essentials +{ + /// + /// Where all UI element common joins are defined + /// + public class UIBoolJoin + { + /// + /// 901 + /// + public const uint VolumeUpPress = 901; + /// + /// 902 + /// + public const uint VolumeDownPress = 902; + + //**************************************************** + // Codec General + + /// + /// 1001 + /// + public const uint CallEndPress = 1001; + /// + /// 1002 + /// + public const uint CallEndAllConfirmPress = 1002; + /// + /// 1003 - For tapping the text field to reveal the keyboard + /// + public const uint CodecDirectorySearchTextPress = 1003; + /// + /// 1004 + /// + public const uint CallStopSharingPress = 1004; + /// + /// 1005 + /// + public const uint CallSharedSourceInfoVisible = 1005; + /// + /// 1006 + /// + public const uint CallEndAllConfirmVisible = 1006; + /// + /// 1007 + /// + public const uint MeetingPasswordVisible = 1007; + /// + /// 1008 + /// + public const uint MeetingLeavePress = 1008; + + + + + + // Audio Conference + /// + /// 1101 + /// + public const uint ACKeypadVisible = 1101; + /// + /// 1102 + /// + public const uint ACStagingPopoverVisible = 1102; + /// + /// 1111 + /// + public const uint ACSpeedDial1Press = 1111; + /// + /// 1112 + /// + public const uint ACSpeedDial2Press = 1112; + /// + /// 1113 + /// + public const uint ACSpeedDial3Press = 1113; + /// + /// 1114 + /// + public const uint ACSpeedDial4Press = 1114; + /// + /// 1121 + /// + public const uint ACSpeedDial1Visible = 1121; + /// + /// 1122 + /// + public const uint ACSpeedDial2Visible = 1122; + /// + /// 1123 + /// + public const uint ACSpeedDial3Visible = 1123; + /// + /// 1124 + /// + public const uint ACSpeedDial4Visible = 1124; + + //****************************************************** + // Video Conference + /// + /// 1201 + /// + public const uint VCKeypadWithFavoritesVisible = 1201; + /// + /// 1202 + /// + public const uint VCStagingInactivePopoverWithRecentsVisible = 1202; + /// + /// + /// + public const uint VCStagingActivePopoverVisible = 1203; + /// + /// + /// + public const uint VCKeypadVisible = 1204; + /// + /// 1205 + /// + public const uint VCDirectoryVisible = 1205; + /// + /// 1206 + /// + public const uint VCRecentsVisible = 1206; + + /// + /// 1202 + /// + public const uint VCStagingInactivePopoverWithoutRecentsVisible = 1207; + + /// + /// 1208 + /// + public const uint VCCameraAutoVisible = 1208; + + /// + /// 1209 + /// + public const uint VCCameraManualVisible = 1209; + + /// + /// 1210 + /// + public const uint VCCameraOffVisible = 1210; + + /// + /// 1211 - 1215 + /// + public const uint VCFavoritePressStart = 1211; + // RANGE IN USE + public const uint VCFavoritePressEnd = 1215; + /// + /// 1221 - 1225 + /// + public const uint VCFavoriteVisibleStart = 1221; + // RANGE IN USE + public const uint VCFavoriteVisibleEnd = 1225; + + /// + /// 1230 + /// + public const uint VCStagingMeetNowPress = 1230; + /// + /// 1231 + /// + public const uint VCStagingRecentsPress = 1231; + /// + /// 1232 + /// + public const uint VCStagingDirectoryPress = 1232; + /// + /// 1233 + /// + public const uint VCStagingKeypadPress = 1233; + /// + /// 1234 + /// + public const uint VCStagingConnectPress = 1234; + /// + /// 1235 + /// + public const uint VCStagingCameraPress = 1235; + /// + /// 1236 + /// + public const uint VCStagingConnectEnable = 1236; + /// + /// 1237 - When the user touches the text field, should trigger keyboard + /// + public const uint VCKeypadTextPress = 1237; + /// + /// 1238 + /// + public const uint VCKeypadBackspacePress = 1238; + /// + /// 1239 + /// + public const uint VCKeypadBackspaceVisible = 1239; + /// + /// 1240 + /// + public const uint VCDirectoryBackPress = 1240; + /// + /// 1241 For touching the text area to bring up keyboard + /// + public const uint VCDirectorySearchTextPress = 1241; + /// + /// 1242 + /// + public const uint VCStagingSelfViewLayoutPress = 1242; + /// + /// 1243 + /// + public const uint VCDirectoryBackVisible = 1243; + /// + /// 1244 + /// + public const uint VCDirectoryBackspacePress = 1244; + /// + /// 1245 + /// + public const uint VCDirectoryBackspaceVisible = 1245; + /// + /// 1251 + /// + public const uint VCSelfViewTogglePress = 1251; + /// + /// 1252 + /// + public const uint VCLayoutTogglePress = 1252; + /// + /// 1253 + /// + public const uint VCSelfViewPipTogglePress = 1253; + /// + /// 1254 + /// + public const uint VCLayoutToggleEnable = 1254; + /// + /// 1255 + /// + public const uint VCMinMaxPress = 1255; + /// + /// 1256 + /// + public const uint VCMinMaxEnable = 1256; + + /// + /// 1260 + /// + public const uint VCCameraModeBarVisible = 1260; + + /// + /// 1261 + /// + public const uint VCCameraSelectBarWithoutModeVisible = 1261; + + /// + /// 1262 + /// + public const uint VCCameraAutoModeIsOnFb = 1262; + + /// + /// 1271 + /// + public const uint VCCameraZoomIn = 1271; + /// + /// 1272 + /// + public const uint VCCameraZoomOut = 1272; + + + /// + /// 1280 + /// + public const uint VCCameraPresetSavedLabelVisible = 1280; + /// + /// 1281 + /// + public const uint VCCameraPreset1 = 1281; + /// + /// 1282 + /// + public const uint VCCameraPreset2 = 1282; + /// + /// 1283 + /// + public const uint VCCameraPreset3 = 1283; + + + /// + /// 1291 + /// + public const uint VCCameraPreset1Visible = 1291; + /// + /// 1292 + /// + public const uint VCCameraPreset2Visible = 1292; + /// + /// 1293 + /// + public const uint VCCameraPreset3Visible = 1293; + + + // Letter joins start at 2921; + + //****************************************************** + + // Environment Joins + + // Popup Container + + /// + /// 2001 - 2004 + /// + public const uint EnvironmentBackgroundSubpageVisibleBase = 2000; + + + // ColumnOne + + /// + /// 2011 - 2015 + /// + public const uint EnvironmentColumnOneLightingTypeVisibleBase = 2010; + + /// + /// 2016 - 2020 + /// + public const uint EnvironmentColumnOneShadingTypeVisibleBase = 2015; + + // ColumnTwo + + /// + /// 2021 - 2025 + /// + public const uint EnvironmentColumnTwoLightingTypeVisibleBase = 2020; + + /// + /// 2026 - 2030 + /// + public const uint EnvironmentColumnTwoShadingTypeVisibleBase = 2025; + + // ColumnThree + + /// + /// 2031 - 2035 + /// + public const uint EnvironmentColumnThreeLightingTypeVisibleBase = 2030; + + /// + /// 2036 - 2040 + /// + public const uint EnvironmentColumnThreeShadingTypeVisibleBase = 2035; + + // ColumnFour + + /// + /// 2041 - 2045 + /// + public const uint EnvironmentColumnFourLightingTypeVisibleBase = 2040; + + /// + /// 2046 - 2050 + /// + public const uint EnvironmentColumnFourShadingTypeVisibleBase = 2045; + + // Button press + + /// + /// 2051 - 2060 + /// + public const uint EnvironmentColumnOneButtonPressBase = 2050; + + /// + /// 2061 - 2070 + /// + public const uint EnvironmentColumnTwoButtonPressBase = 2060; + + /// + /// 2071 - 2080 + /// + public const uint EnvironmentColumnThreeButtonPressBase = 2070; + + /// + /// 2081 - 2090 + /// + public const uint EnvironmentColumnFourButtonPressBase = 2080; + + // Button visibility + + /// + /// 2151 - 2160 + /// + public const uint EnvironmentColumnOneButtonVisibleBase = 2150; + + /// + /// 2161 - 2170 + /// + public const uint EnvironmentColumnTwoButtonVisibleBase = 2160; + + /// + /// 2171 - 2180 + /// + public const uint EnvironmentColumnThreeButtonVisibleBase = 2170; + + /// + /// 2181 - 2190 + /// + public const uint EnvironmentColumnFourButtonVisibleBase = 2180; + + + //****************************************************** + + /// + /// 3101 + /// + public const uint TechExitButton = 3101; + /// + /// 3106 + /// + public const uint TechCommonItemsVisbible = 3106; + /// + /// 3107 + /// + public const uint TechSystemStatusVisible = 3107; + /// + /// 3108 + /// + public const uint TechDisplayControlsVisible = 3108; + /// + /// 3109 + /// + public const uint TechPanelSetupVisible = 3109; + /// + /// 3110 + /// + public const uint TechAdvancedVolumeVisible = 3110; + /// + /// 3111 + /// + public const uint TechAboutVisible = 3111; + /// + /// 3112 + /// + public const uint TechSchedulerVisible = 3112; + + //***************************************************** + /// + /// 3811 + /// + public const uint VolumeSingleMute1Visible = 3811; + /// + /// 3812 + /// + public const uint VolumeSlider1Press = 3812; + /// + /// 3813 + /// + public const uint Volume1ProgramMutePressAndFB = 3813; + /// + /// 3821 + /// + public const uint Volume2Visible = 3821; + /// + /// 3822 + /// + public const uint VolumeSlider2Press = 3822; + /// + /// 3823 + /// + public const uint Volume2MutePressAndFB = 3823; + /// + /// 3831 + /// + public const uint Volume3Visible = 3831; + /// + /// 3832 + /// + public const uint VolumeSlider3Press = 3832; + /// + /// 3833 + /// + public const uint Volume3MutePressAndFB = 3833; + /// + /// 3841 + /// + public const uint Volume4Visible = 3841; + /// + /// 3842 + /// + public const uint VolumeSlider4Press = 3842; + /// + /// 3843 + /// + public const uint Volume4MutePressAndFB = 3843; + /// + /// 3851 + /// + public const uint Volume5Visible = 3851; + /// + /// 3852 + /// + public const uint VolumeSlider5Press = 3852; + /// + /// 3853 + /// + public const uint Volume5MutePressAndFB = 3853; + /// + /// 3861 + /// + public const uint Volume6Visible = 3861; + /// + /// 3862 + /// + public const uint VolumeSlider6Press = 3862; + /// + /// 3863 + /// + public const uint Volume6MutePressAndFB = 3863; + + /// + /// 3869 - when the system is off and the gear is pressed + /// + public const uint VolumesPagePowerOffVisible = 3869; + /// + /// 3870 + /// + public const uint VolumesPageVisible = 3870; + /// + /// 3871 + /// + public const uint VolumeDualMute1Visible = 3871; + /// + /// 3874 + /// + public const uint Volume1SpeechMutePressAndFB = 3874; + /// + /// 3875 + /// + public const uint Volume1BackerVisibility = 3875; + /// + /// 3891 + /// + public const uint VolumeDefaultPress = 3891; + /// + /// 3951 + /// + /// 3952 + /// + public const uint HeaderIcon2Press = 3952; + /// + /// 3953 + /// + public const uint HeaderIcon3Press = 3953; + /// + /// 3954 + /// + public const uint HeaderIcon4Press = 3954; + /// + /// 3955 + /// + public const uint HeaderIcon5Press = 3955; + + /// 3960 + /// + public const uint HeaderPopupCaretsSubpageVisibile = 3960; + /// + /// 3961 + /// + public const uint HeaderCaret1Visible = 3961; + /// + /// 3962 + /// + public const uint HeaderCaret2Visible = 3962; + /// + /// 3963 + /// + public const uint HeaderCaret3Visible = 3963; + /// + /// 3964 + /// + public const uint HeaderCaret4Visible = 3964; + /// + /// 3965 + /// + public const uint HeaderCaret5Visible = 3965; + + /// + /// 3999 + /// + public const uint GenericModalVisible = 3999; + /// + /// 12345 + /// + public const uint AvNoControlsSubVisible = 12345; + + // 10000 - 14999 are general "source" pages + + /// + /// 15001 + /// + public const uint StartPageVisible = 15001; + /// + /// 15002 Shows the start page in the source controls area of the screen + /// + public const uint TapToBeginVisible = 15002; + /// + /// 15003 Message text when no source is showing + /// + public const uint SelectASourceVisible = 15003; + /// + /// 15004 + /// + public const uint RoomIsOn = 15004; + /// + /// 15005 Shows always-on volume control subpage with only audio mute + /// + public const uint VolumeControlsSingleMuteVisible = 15005; + /// + /// 15006 Shows always-on volume control subpage with mic and audio mutes + /// + public const uint VolumeControlsDualMuteVisible = 15006; + /// + /// 15010 + /// + public const uint ShowPanelSetupPress = 15010; + /// + /// 15011 - Top bar with room name and button that pops up dialog with room data + /// + public const uint TopBarHabaneroVisible = 15011; + /// + /// 15012 + /// + public const uint SourceStagingBarVisible = 15012; + /// + /// 15013 + /// + public const uint PowerOffStep1Visible = 15013; + /// + /// 15014 + /// + public const uint PowerOffStep2Visible = 15014; + /// + /// 15015 + /// + public const uint ShowPowerOffPress = 15015; + /// + /// 15016 + /// + public const uint PowerOffMorePress = 15016; + /// + /// 15017 + /// + public const uint StagingPageAdditionalArrowsVisible = 15017; + /// + /// 15018 The Header with dynamic buttons + /// + public const uint TopBarHabaneroDynamicVisible = 15018; + /// + /// 15019 Shown when system is starting and not ready for use + /// + public const uint SystemInitializingVisible = 15019; + /// + /// 15020 + /// + public const uint PanelSetupVisible = 15020; + /// + /// 15021 + /// + public const uint SourceWaitOverlayVisible = 15021; + /// + /// 15022 + /// + public const uint ActivityFooterVisible = 15022; + /// + /// 15024 + /// + public const uint HeaderCallStatusLeftPositionVisible = 15024; + /// + /// 15025 + /// + public const uint HeaderCallStatusRightPositionVisible = 15025; + /// + /// 15027 + /// + public const uint HeaderCallStatusLabelPress = 15027; + /// + /// 15028 The gear button in header + /// + public const uint FIXFIX_HeaderGearButtonPress_FIXFIX = 15028; + /// + /// 15029 the room button in header + /// + public const uint HeaderRoomButtonPress = 15029; + /// + /// 15030 Visibility for room data popup + /// + public const uint RoomHeaderInfoPageVisible = 15030; + /// + /// 15031 + /// + public const uint AllRoomsOffPress = 15031; + /// + /// 15032 + /// + public const uint DisplayPowerTogglePress = 15032; + /// + /// 15033 + /// + public const uint PowerOffCancelPress = 15033; + /// + /// 15034 + /// + public const uint PowerOffConfirmPress = 15034; + /// + /// 15035 + /// + public const uint VolumeButtonPopupPress = 15035; + /// + /// 15035 + /// + public const uint VolumeButtonPopupVisible = 15035; + /// + /// 15036 + /// + public const uint VolumeGaugePopupVisible = 15036; + /// + /// 15037 + /// + public const uint GearButtonVisible = 15037; + /// + /// 15038 + /// + public const uint CalendarHeaderButtonVisible = 15038; + /// + /// 15039 + /// + public const uint CalendarHeaderButtonPress = 15039; + /// + /// 15040 + /// + public const uint CallStatusPageVisible = 15040; + /// + /// 15041 + /// + public const uint LightsPageVisible = 15041; + /// + /// 15042 Closes whichever interlocked modal is open + /// + public const uint InterlockedModalClosePress = 15042; + /// + /// 15043 Vis for modal backer for full-screen source + /// + public const uint SourceBackgroundOverlayVisible = 15043; + /// + /// 15044 Close button for source modal overlay + /// + public const uint SourceBackgroundOverlayClosePress = 15044; + /// + /// 15045 + /// + public const uint ZoomRoomContentSharingVisible = 15045; + /// + /// 15046 + /// + public const uint MeetingsOrContacMethodsListVisible = 15046; + /// + /// 15047 The "Join" button on the next meeting ribbon + /// + public const uint NextMeetingJoinPress = 15047; + /// + /// 15048 Dismisses the ribbon + /// + public const uint NextMeetingModalClosePress = 15048; + /// + /// 15049 + /// + public const uint NextMeetingModalVisible = 15049; + /// + /// 15050 + /// + public const uint NextMeetingNotificationRibbonVisible = 15050; + /// + /// 15051 + /// + public const uint Display1SelectPressAndFb = 15051; + /// + /// 15052 + /// + public const uint Display1ControlButtonEnable = 15052; + /// + /// 15053 + /// + public const uint Display1ControlButtonPress = 15053; + /// + /// 15054 + /// + public const uint Display1AudioButtonEnable = 15054; + /// + /// 15055 + /// + public const uint Display1AudioButtonPressAndFb = 15055; + /// + /// 15056 + /// + public const uint Display2SelectPressAndFb = 15056; + /// + /// 15057 + /// + public const uint Display2ControlButtonEnable = 15057; + /// + /// 15058 + /// + public const uint Display2ControlButtonPress = 15058; + /// + /// 15059 + /// + public const uint Display2AudioButtonEnable = 15059; + /// + /// 15060 + /// + public const uint Display2AudioButtonPressAndFb = 15060; + /// + /// 15061 Reveals the dual-display subpage + /// + public const uint DualDisplayPageVisible = 15061; + /// + /// 15062 Reveals the toggle switch for the sharing mode + /// + public const uint ToggleSharingModeVisible = 15062; + /// + /// 15063 Press for the toggle mode switch + /// + public const uint ToggleSharingModePress = 15063; + /// + /// 15064 + /// + public const uint LogoDefaultVisible = 15064; + /// + /// 15065 + /// + public const uint LogoUrlVisible = 15065; + /// + /// 15066 - Reveals the active calls header item + /// + public const uint HeaderActiveCallsListVisible = 15066; + /// + /// 15067 + /// + public const uint NotificationRibbonVisible = 15067; + /// + /// 15068 + /// + public const uint HeaderMeetingInfoVisible = 15068; + + /// + /// 15083 - Press for Call help desk on AC/VC + /// + public const uint HelpPageShowCallButtonPress = 15083; + /// + /// 15084 - Show the "call help desk" button on help page + /// + public const uint HelpPageShowCallButtonVisible = 15084; + /// + /// 15085 Visibility join for help subpage + /// + public const uint HelpPageVisible = 15085; + /// + /// 15086 Press for help header button + /// + public const uint HelpPress = 15086; + /// + /// 15088 + /// + public const uint DateOnlyVisible = 15088; + /// + /// 15089 + /// + public const uint TimeOnlyVisible = 15089; + /// + /// 15090 + /// + public const uint DateAndTimeVisible = 15090; + /// + /// 15091 + /// + public const uint SetupFullDistrib = 15091; + + /// + /// 15092 + /// + public const uint StartMCPageVisible = 15092; + + + /// + /// 15093 + /// + public const uint RoomHeaderInfoMCPageVisible = 15093; + + /// + /// 15094 + /// + public const uint MCScreenSaverVisible = 15094; + + /// + /// 15095 + /// + public const uint MCScreenSaverPosition1Visible = 15095; + + /// + /// 15096 + /// + public const uint MCScreenSaverPosition2Visible = 15096; + + /// + /// 15097 + /// + public const uint MCScreenSaverPosition3Visible = 15097; + + /// + /// 15098 + /// + public const uint MCScreenSaverPosition4Visible = 15098; + + /// + /// 15099 + /// + public const uint MCScreenSaverClosePress = 15099; + + // PIN dialogs ************************************ + + /// + /// 15201 + /// + public const uint PinDialog4DigitVisible = 15201; + /// + /// 15206 + /// + public const uint PinDialogCancelPress = 15206; + /// + /// 15207 + /// + public const uint PinDialogErrorVisible = 15207; + /// + /// 15211 + /// + public const uint PinDialogDot1 = 15211; + /// + /// 15212 + /// + public const uint PinDialogDot2 = 15212; + /// + /// 15213 + /// + public const uint PinDialogDot3 = 15213; + /// + /// 15214 + /// + public const uint PinDialogDot4 = 15214; + + // Password Prompt Dialog ************************** + + /// + /// 15301 + /// + public const uint PasswordPromptDialogVisible = 15301; + /// + /// 15302 + /// + public const uint PasswordPromptTextPress = 15302; + /// + /// 15306 + /// + public const uint PasswordPromptCancelPress = 15306; + /// + /// 15307 + /// + public const uint PasswordPromptErrorVisible = 15307; + } } \ No newline at end of file diff --git a/PepperDashEssentials/UI/JoinConstants/UISmartObjectJoin.cs b/src/PepperDashEssentials/UI/JoinConstants/UISmartObjectJoin.cs similarity index 100% rename from PepperDashEssentials/UI/JoinConstants/UISmartObjectJoin.cs rename to src/PepperDashEssentials/UI/JoinConstants/UISmartObjectJoin.cs diff --git a/PepperDashEssentials/UI/JoinConstants/UIStringlJoin.cs b/src/PepperDashEssentials/UI/JoinConstants/UIStringlJoin.cs similarity index 100% rename from PepperDashEssentials/UI/JoinConstants/UIStringlJoin.cs rename to src/PepperDashEssentials/UI/JoinConstants/UIStringlJoin.cs diff --git a/PepperDashEssentials/UI/JoinConstants/UIUshortJoin.cs b/src/PepperDashEssentials/UI/JoinConstants/UIUshortJoin.cs similarity index 100% rename from PepperDashEssentials/UI/JoinConstants/UIUshortJoin.cs rename to src/PepperDashEssentials/UI/JoinConstants/UIUshortJoin.cs diff --git a/PepperDashEssentials/UI/SmartObjectHeaderButtonList.cs b/src/PepperDashEssentials/UI/SmartObjectHeaderButtonList.cs similarity index 100% rename from PepperDashEssentials/UI/SmartObjectHeaderButtonList.cs rename to src/PepperDashEssentials/UI/SmartObjectHeaderButtonList.cs diff --git a/PepperDashEssentials/UI/SubpageReferenceListActivityItem.cs b/src/PepperDashEssentials/UI/SubpageReferenceListActivityItem.cs similarity index 100% rename from PepperDashEssentials/UI/SubpageReferenceListActivityItem.cs rename to src/PepperDashEssentials/UI/SubpageReferenceListActivityItem.cs diff --git a/PepperDashEssentials/UI/SubpageReferenceListCallStagingItem.cs b/src/PepperDashEssentials/UI/SubpageReferenceListCallStagingItem.cs similarity index 100% rename from PepperDashEssentials/UI/SubpageReferenceListCallStagingItem.cs rename to src/PepperDashEssentials/UI/SubpageReferenceListCallStagingItem.cs diff --git a/PepperDashEssentials/UI/SubpageReferenceListSourceItem.cs b/src/PepperDashEssentials/UI/SubpageReferenceListSourceItem.cs similarity index 100% rename from PepperDashEssentials/UI/SubpageReferenceListSourceItem.cs rename to src/PepperDashEssentials/UI/SubpageReferenceListSourceItem.cs diff --git a/PepperDashEssentials/UIDrivers/DualDisplayRouting.cs b/src/PepperDashEssentials/UIDrivers/DualDisplayRouting.cs similarity index 100% rename from PepperDashEssentials/UIDrivers/DualDisplayRouting.cs rename to src/PepperDashEssentials/UIDrivers/DualDisplayRouting.cs diff --git a/PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsEnvironmentDriver.cs b/src/PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsEnvironmentDriver.cs similarity index 97% rename from PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsEnvironmentDriver.cs rename to src/PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsEnvironmentDriver.cs index 6b908739..978206eb 100644 --- a/PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsEnvironmentDriver.cs +++ b/src/PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsEnvironmentDriver.cs @@ -1,256 +1,256 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.Core.Shades; -using PepperDash.Essentials.Core.Lighting; - -namespace PepperDash.Essentials -{ - public class EssentialsEnvironmentDriver : PanelDriverBase - { - /// - /// Do I need this here? - /// - CrestronTouchpanelPropertiesConfig Config; - - /// - /// The list of devices this driver is responsible for controlling - /// - public List Devices { get; private set; } - - /// - /// The parent driver for this - /// - EssentialsPanelMainInterfaceDriver Parent; - - /// - /// The list of sub drivers for the devices - /// - public List DeviceSubDrivers { get; private set; } - - public uint BackgroundSubpageJoin { get; private set; } - - public EssentialsEnvironmentDriver(EssentialsPanelMainInterfaceDriver parent, CrestronTouchpanelPropertiesConfig config) - : base(parent.TriList) - { - Config = config; - Parent = parent; - - Devices = new List(); - DeviceSubDrivers = new List(); - - Parent.AvDriver.PopupInterlock.StatusChanged += new EventHandler(PopupInterlock_CurrentJoinChanged); - - // Calculate the join offests for each device page and assign join actions for each button - } - - void PopupInterlock_CurrentJoinChanged(object sender, StatusChangedEventArgs e) - { - // Hide this driver and all sub drivers if popup interlock is not shown - if (!e.IsShown || e.NewJoin != BackgroundSubpageJoin) - { - foreach (var driver in DeviceSubDrivers) - { - driver.Hide(); - } - - base.Hide(); - } - } - - void IsShownFeedback_OutputChange(object sender, EventArgs e) - { - - } - - /// - /// Shows this driver and all sub drivers - /// - public override void Show() - { - Parent.AvDriver.PopupInterlock.ShowInterlocked(BackgroundSubpageJoin); - - foreach (var driver in DeviceSubDrivers) - { - driver.Show(); - } - - base.Show(); - } - - /// - /// Hides this driver and all sub drivers - /// - public override void Hide() - { - Parent.AvDriver.PopupInterlock.HideAndClear(); - - foreach (var driver in DeviceSubDrivers) - { - driver.Hide(); - } - - base.Hide(); - } - - public override void Toggle() - { - if (IsVisible) - Hide(); - else - Show(); - } - - - /// - /// Reads the device keys from the config and gets the devices by key - /// - public void GetDevicesFromConfig(Room.Config.EssentialsEnvironmentPropertiesConfig EnvironmentPropertiesConfig) - { - if (EnvironmentPropertiesConfig != null) - { - Devices.Clear(); - DeviceSubDrivers.Clear(); - - uint column = 1; - - foreach (var dKey in EnvironmentPropertiesConfig.DeviceKeys) - { - var device = DeviceManager.GetDeviceForKey(dKey); - - if (device != null) - { - // Build the driver - var devicePanelDriver = GetPanelDriverForDevice(device, column); - - // Add new PanelDriverBase SubDriver - if (devicePanelDriver != null) - { - Devices.Add(device); - DeviceSubDrivers.Add(devicePanelDriver); - - Debug.Console(1, "Adding '{0}' to Environment Devices", device.Key); - - column++; - - - // Quit if device count is exceeded - if (column > 4) - break; - } - else - Debug.Console(1, "Unable to build environment driver for device: '{0}'", device.Key); - - } - - } - - SetupEnvironmentUiJoins(); - } - else - { - Debug.Console(1, "Unable to get devices from config. No EnvironmentPropertiesConfig object in room config"); - } - } - - /// - /// Returns the appropriate panel driver for the device - /// - /// - /// - /// - PanelDriverBase GetPanelDriverForDevice(IKeyed device, uint column) - { - PanelDriverBase panelDriver = null; - - uint buttonPressJoinBase = 0; - uint buttonVisibleJoinBase = 0; - uint stringJoinBase = 0; - uint shadeTypeVisibleBase = 0; - uint lightingTypeVisibleBase = 0; - - switch (column) - { - case 1: - { - buttonPressJoinBase = UIBoolJoin.EnvironmentColumnOneButtonPressBase; - buttonVisibleJoinBase = UIBoolJoin.EnvironmentColumnOneButtonVisibleBase; - stringJoinBase = UIStringJoin.EnvironmentColumnOneLabelBase; - shadeTypeVisibleBase = UIBoolJoin.EnvironmentColumnOneShadingTypeVisibleBase; - lightingTypeVisibleBase = UIBoolJoin.EnvironmentColumnOneLightingTypeVisibleBase; - break; - } - case 2: - { - buttonPressJoinBase = UIBoolJoin.EnvironmentColumnTwoButtonPressBase; - buttonVisibleJoinBase = UIBoolJoin.EnvironmentColumnTwoButtonVisibleBase; - stringJoinBase = UIStringJoin.EnvironmentColumnTwoLabelBase; - shadeTypeVisibleBase = UIBoolJoin.EnvironmentColumnTwoShadingTypeVisibleBase; - lightingTypeVisibleBase = UIBoolJoin.EnvironmentColumnTwoLightingTypeVisibleBase; - break; - } - case 3: - { - buttonPressJoinBase = UIBoolJoin.EnvironmentColumnThreeButtonPressBase; - buttonVisibleJoinBase = UIBoolJoin.EnvironmentColumnThreeButtonVisibleBase; - stringJoinBase = UIStringJoin.EnvironmentColumnThreeLabelBase; - shadeTypeVisibleBase = UIBoolJoin.EnvironmentColumnThreeShadingTypeVisibleBase; - lightingTypeVisibleBase = UIBoolJoin.EnvironmentColumnThreeLightingTypeVisibleBase; - break; - } - case 4: - { - buttonPressJoinBase = UIBoolJoin.EnvironmentColumnFourButtonPressBase; - buttonVisibleJoinBase = UIBoolJoin.EnvironmentColumnFourButtonVisibleBase; - stringJoinBase = UIStringJoin.EnvironmentColumnFourLabelBase; - shadeTypeVisibleBase = UIBoolJoin.EnvironmentColumnFourShadingTypeVisibleBase; - lightingTypeVisibleBase = UIBoolJoin.EnvironmentColumnFourLightingTypeVisibleBase; - break; - } - default: - { - Debug.Console(1, "Environment Driver: Invalid column number specified"); - break; - } - } - - // Determine if device is a shade or lighting type and construct the appropriate driver - if (device is ShadeBase) - { - panelDriver = new EssentialsShadeDriver(this, device.Key, buttonPressJoinBase, stringJoinBase, shadeTypeVisibleBase); - } - else if (device is LightingBase) - { - panelDriver = new EssentialsLightingDriver(this, device.Key, buttonPressJoinBase, buttonVisibleJoinBase, stringJoinBase, lightingTypeVisibleBase); - } - - // Return the driver - - return panelDriver; - } - - /// - /// Determines the join values for the generic environment subpages - /// - void SetupEnvironmentUiJoins() - { - // Calculate which background subpage join to use - BackgroundSubpageJoin = UIBoolJoin.EnvironmentBackgroundSubpageVisibleBase + (uint)DeviceSubDrivers.Count; - - - } - - } - - public interface IEnvironmentSubdriver - { - uint SubpageVisibleJoin { get; } - } - +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.Core.Shades; +using PepperDash.Essentials.Core.Lighting; + +namespace PepperDash.Essentials +{ + public class EssentialsEnvironmentDriver : PanelDriverBase + { + /// + /// Do I need this here? + /// + CrestronTouchpanelPropertiesConfig Config; + + /// + /// The list of devices this driver is responsible for controlling + /// + public List Devices { get; private set; } + + /// + /// The parent driver for this + /// + EssentialsPanelMainInterfaceDriver Parent; + + /// + /// The list of sub drivers for the devices + /// + public List DeviceSubDrivers { get; private set; } + + public uint BackgroundSubpageJoin { get; private set; } + + public EssentialsEnvironmentDriver(EssentialsPanelMainInterfaceDriver parent, CrestronTouchpanelPropertiesConfig config) + : base(parent.TriList) + { + Config = config; + Parent = parent; + + Devices = new List(); + DeviceSubDrivers = new List(); + + Parent.AvDriver.PopupInterlock.StatusChanged += new EventHandler(PopupInterlock_CurrentJoinChanged); + + // Calculate the join offests for each device page and assign join actions for each button + } + + void PopupInterlock_CurrentJoinChanged(object sender, StatusChangedEventArgs e) + { + // Hide this driver and all sub drivers if popup interlock is not shown + if (!e.IsShown || e.NewJoin != BackgroundSubpageJoin) + { + foreach (var driver in DeviceSubDrivers) + { + driver.Hide(); + } + + base.Hide(); + } + } + + void IsShownFeedback_OutputChange(object sender, EventArgs e) + { + + } + + /// + /// Shows this driver and all sub drivers + /// + public override void Show() + { + Parent.AvDriver.PopupInterlock.ShowInterlocked(BackgroundSubpageJoin); + + foreach (var driver in DeviceSubDrivers) + { + driver.Show(); + } + + base.Show(); + } + + /// + /// Hides this driver and all sub drivers + /// + public override void Hide() + { + Parent.AvDriver.PopupInterlock.HideAndClear(); + + foreach (var driver in DeviceSubDrivers) + { + driver.Hide(); + } + + base.Hide(); + } + + public override void Toggle() + { + if (IsVisible) + Hide(); + else + Show(); + } + + + /// + /// Reads the device keys from the config and gets the devices by key + /// + public void GetDevicesFromConfig(Room.Config.EssentialsEnvironmentPropertiesConfig EnvironmentPropertiesConfig) + { + if (EnvironmentPropertiesConfig != null) + { + Devices.Clear(); + DeviceSubDrivers.Clear(); + + uint column = 1; + + foreach (var dKey in EnvironmentPropertiesConfig.DeviceKeys) + { + var device = DeviceManager.GetDeviceForKey(dKey); + + if (device != null) + { + // Build the driver + var devicePanelDriver = GetPanelDriverForDevice(device, column); + + // Add new PanelDriverBase SubDriver + if (devicePanelDriver != null) + { + Devices.Add(device); + DeviceSubDrivers.Add(devicePanelDriver); + + Debug.Console(1, "Adding '{0}' to Environment Devices", device.Key); + + column++; + + + // Quit if device count is exceeded + if (column > 4) + break; + } + else + Debug.Console(1, "Unable to build environment driver for device: '{0}'", device.Key); + + } + + } + + SetupEnvironmentUiJoins(); + } + else + { + Debug.Console(1, "Unable to get devices from config. No EnvironmentPropertiesConfig object in room config"); + } + } + + /// + /// Returns the appropriate panel driver for the device + /// + /// + /// + /// + PanelDriverBase GetPanelDriverForDevice(IKeyed device, uint column) + { + PanelDriverBase panelDriver = null; + + uint buttonPressJoinBase = 0; + uint buttonVisibleJoinBase = 0; + uint stringJoinBase = 0; + uint shadeTypeVisibleBase = 0; + uint lightingTypeVisibleBase = 0; + + switch (column) + { + case 1: + { + buttonPressJoinBase = UIBoolJoin.EnvironmentColumnOneButtonPressBase; + buttonVisibleJoinBase = UIBoolJoin.EnvironmentColumnOneButtonVisibleBase; + stringJoinBase = UIStringJoin.EnvironmentColumnOneLabelBase; + shadeTypeVisibleBase = UIBoolJoin.EnvironmentColumnOneShadingTypeVisibleBase; + lightingTypeVisibleBase = UIBoolJoin.EnvironmentColumnOneLightingTypeVisibleBase; + break; + } + case 2: + { + buttonPressJoinBase = UIBoolJoin.EnvironmentColumnTwoButtonPressBase; + buttonVisibleJoinBase = UIBoolJoin.EnvironmentColumnTwoButtonVisibleBase; + stringJoinBase = UIStringJoin.EnvironmentColumnTwoLabelBase; + shadeTypeVisibleBase = UIBoolJoin.EnvironmentColumnTwoShadingTypeVisibleBase; + lightingTypeVisibleBase = UIBoolJoin.EnvironmentColumnTwoLightingTypeVisibleBase; + break; + } + case 3: + { + buttonPressJoinBase = UIBoolJoin.EnvironmentColumnThreeButtonPressBase; + buttonVisibleJoinBase = UIBoolJoin.EnvironmentColumnThreeButtonVisibleBase; + stringJoinBase = UIStringJoin.EnvironmentColumnThreeLabelBase; + shadeTypeVisibleBase = UIBoolJoin.EnvironmentColumnThreeShadingTypeVisibleBase; + lightingTypeVisibleBase = UIBoolJoin.EnvironmentColumnThreeLightingTypeVisibleBase; + break; + } + case 4: + { + buttonPressJoinBase = UIBoolJoin.EnvironmentColumnFourButtonPressBase; + buttonVisibleJoinBase = UIBoolJoin.EnvironmentColumnFourButtonVisibleBase; + stringJoinBase = UIStringJoin.EnvironmentColumnFourLabelBase; + shadeTypeVisibleBase = UIBoolJoin.EnvironmentColumnFourShadingTypeVisibleBase; + lightingTypeVisibleBase = UIBoolJoin.EnvironmentColumnFourLightingTypeVisibleBase; + break; + } + default: + { + Debug.Console(1, "Environment Driver: Invalid column number specified"); + break; + } + } + + // Determine if device is a shade or lighting type and construct the appropriate driver + if (device is ShadeBase) + { + panelDriver = new EssentialsShadeDriver(this, device.Key, buttonPressJoinBase, stringJoinBase, shadeTypeVisibleBase); + } + else if (device is LightingBase) + { + panelDriver = new EssentialsLightingDriver(this, device.Key, buttonPressJoinBase, buttonVisibleJoinBase, stringJoinBase, lightingTypeVisibleBase); + } + + // Return the driver + + return panelDriver; + } + + /// + /// Determines the join values for the generic environment subpages + /// + void SetupEnvironmentUiJoins() + { + // Calculate which background subpage join to use + BackgroundSubpageJoin = UIBoolJoin.EnvironmentBackgroundSubpageVisibleBase + (uint)DeviceSubDrivers.Count; + + + } + + } + + public interface IEnvironmentSubdriver + { + uint SubpageVisibleJoin { get; } + } + } \ No newline at end of file diff --git a/PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsLightingDriver.cs b/src/PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsLightingDriver.cs similarity index 100% rename from PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsLightingDriver.cs rename to src/PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsLightingDriver.cs diff --git a/PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsShadeDriver.cs b/src/PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsShadeDriver.cs similarity index 99% rename from PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsShadeDriver.cs rename to src/PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsShadeDriver.cs index fb40252c..9ab9ad54 100644 --- a/PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsShadeDriver.cs +++ b/src/PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsShadeDriver.cs @@ -97,8 +97,8 @@ namespace PepperDash.Essentials { TriList.SetSigFalseAction(ButtonPressJoinBase + 1, ShadeDevice.Open); - TriList.SetSigFalseAction(ButtonPressJoinBase + 2, (ShadeDevice as IShadesOpenCloseStop).Stop); - + TriList.SetSigFalseAction(ButtonPressJoinBase + 2, (ShadeDevice as IShadesOpenCloseStop).Stop); + if (ShadeDevice is IShadesOpenCloseStop) TriList.SetString(StringJoinBase + 2, "Stop"); diff --git a/PepperDashEssentials/UIDrivers/Essentials/EssentialsHeaderDriver.cs b/src/PepperDashEssentials/UIDrivers/Essentials/EssentialsHeaderDriver.cs similarity index 97% rename from PepperDashEssentials/UIDrivers/Essentials/EssentialsHeaderDriver.cs rename to src/PepperDashEssentials/UIDrivers/Essentials/EssentialsHeaderDriver.cs index c63af9d5..4b4ed6b8 100644 --- a/PepperDashEssentials/UIDrivers/Essentials/EssentialsHeaderDriver.cs +++ b/src/PepperDashEssentials/UIDrivers/Essentials/EssentialsHeaderDriver.cs @@ -1,399 +1,399 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.UI; -using Crestron.SimplSharpPro.DeviceSupport; - - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.SmartObjects; -using PepperDash.Essentials.Core.PageManagers; -using PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces; -using PepperDash.Essentials.Room.Config; -using PepperDash.Essentials.Devices.Common.Codec; -using PepperDash.Essentials.Devices.Common.VideoCodec; - - -namespace PepperDash.Essentials -{ - /// - /// - /// - public class EssentialsHeaderDriver : PanelDriverBase - { - uint EnvironmentCaretVisible; - uint CalendarCaretVisible; - uint CallCaretVisible; - - JoinedSigInterlock CaretInterlock; - - CrestronTouchpanelPropertiesConfig Config; - - /// - /// The parent driver for this - /// - EssentialsPanelMainInterfaceDriver Parent; - - /// - /// Indicates that the SetHeaderButtons method has completed successfully - /// - public bool HeaderButtonsAreSetUp { get; private set; } - - StringInputSig HeaderCallButtonIconSig; - - public EssentialsHeaderDriver(EssentialsPanelMainInterfaceDriver parent, CrestronTouchpanelPropertiesConfig config) - : base(parent.TriList) - { - Config = config; - Parent = parent; - CaretInterlock = new JoinedSigInterlock(TriList); - } - - void SetUpGear(IAVDriver avDriver, IEssentialsRoom currentRoom) - { - // Gear - TriList.SetString(UIStringJoin.HeaderButtonIcon5, "Gear"); - TriList.SetSigHeldAction(UIBoolJoin.HeaderIcon5Press, 2000, - avDriver.ShowTech, - null, - () => - { - if (currentRoom.OnFeedback.BoolValue) - { - avDriver.PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.VolumesPageVisible); - CaretInterlock.ShowInterlocked(UIBoolJoin.HeaderCaret5Visible); - } - else - { - avDriver.PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.VolumesPagePowerOffVisible); - CaretInterlock.ShowInterlocked(UIBoolJoin.HeaderCaret5Visible); - } - }); - TriList.SetSigFalseAction(UIBoolJoin.TechExitButton, () => - avDriver.PopupInterlock.HideAndClear()); - } - - public void SetUpHelpButton(EssentialsRoomPropertiesConfig roomConf) - { - // Help roomConf and popup - if (roomConf.Help != null) - { - TriList.SetString(UIStringJoin.HelpMessage, roomConf.Help.Message); - TriList.SetBool(UIBoolJoin.HelpPageShowCallButtonVisible, roomConf.Help.ShowCallButton); - TriList.SetString(UIStringJoin.HelpPageCallButtonText, roomConf.Help.CallButtonText); - if (roomConf.Help.ShowCallButton) - { - TriList.SetSigFalseAction(UIBoolJoin.HelpPageShowCallButtonPress, () => { }); // ************ FILL IN - } - else - { - TriList.ClearBoolSigAction(UIBoolJoin.HelpPageShowCallButtonPress); - } - } - else // older config - { - TriList.SetString(UIStringJoin.HelpMessage, roomConf.HelpMessage); - TriList.SetBool(UIBoolJoin.HelpPageShowCallButtonVisible, false); - TriList.SetString(UIStringJoin.HelpPageCallButtonText, null); - TriList.ClearBoolSigAction(UIBoolJoin.HelpPageShowCallButtonPress); - } - TriList.SetString(UIStringJoin.HeaderButtonIcon4, "Help"); - TriList.SetSigFalseAction(UIBoolJoin.HeaderIcon4Press, () => - { - string message = null; - var room = DeviceManager.GetDeviceForKey(Config.DefaultRoomKey) - as IEssentialsHuddleSpaceRoom; - if (room != null) - message = room.PropertiesConfig.HelpMessage; - else - message = "Sorry, no help message available. No room connected."; - //TriList.StringInput[UIStringJoin.HelpMessage].StringValue = message; - Parent.AvDriver.PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.HelpPageVisible); - CaretInterlock.ShowInterlocked(UIBoolJoin.HeaderCaret4Visible); - }); - } - - uint SetUpEnvironmentButton(EssentialsEnvironmentDriver environmentDriver, uint nextJoin) - { - if (environmentDriver != null) - { - var tempJoin = nextJoin; - TriList.SetString(tempJoin, "Lights"); - EnvironmentCaretVisible = tempJoin + 10; - TriList.SetSigFalseAction(tempJoin, () => - { - environmentDriver.Toggle(); - CaretInterlock.ShowInterlocked(EnvironmentCaretVisible); - }); - nextJoin--; - return nextJoin; - } - else - return nextJoin; - } - - uint SetUpCalendarButton(EssentialsHuddleVtc1PanelAvFunctionsDriver avDriver, uint nextJoin) - { - // Calendar button - if (avDriver.CurrentRoom.ScheduleSource != null) - { - var tempJoin = nextJoin; - TriList.SetString(tempJoin, "Calendar"); - CalendarCaretVisible = tempJoin + 10; - TriList.SetSigFalseAction(tempJoin, () => - { - avDriver.CalendarPress(); - CaretInterlock.ShowInterlocked(CalendarCaretVisible); - }); - - nextJoin--; - return nextJoin; - } - else - return nextJoin; - } - - uint SetUpCallButton(EssentialsHuddleVtc1PanelAvFunctionsDriver avDriver, uint nextJoin) - { - // Call button - var tempJoin = nextJoin; - TriList.SetString(tempJoin, "DND"); - CallCaretVisible = tempJoin + 10; - TriList.SetSigFalseAction(tempJoin, () => - { - avDriver.ShowActiveCallsListOrMeetingInfo(); - if(avDriver.CurrentRoom.InCallFeedback.BoolValue) - CaretInterlock.ShowInterlocked(CallCaretVisible); - }); - HeaderCallButtonIconSig = TriList.StringInput[tempJoin]; - - nextJoin--; - return nextJoin; - } - - /// - /// Evaluates the call status and sets the icon mode and text label - /// - public void ComputeHeaderCallStatus(VideoCodecBase codec) - { - if (codec == null) - { - Debug.Console(1, "ComputeHeaderCallStatus() cannot execute. codec is null"); - return; - } - - if (HeaderCallButtonIconSig == null) - { - Debug.Console(1, "ComputeHeaderCallStatus() cannot execute. HeaderCallButtonIconSig is null"); - return; - } - - var meetingInfoCodec = codec as IHasMeetingInfo; - - // Set mode of header button - SetHeaderCallIcon(codec); - - // Set the call status text - Debug.Console(1, "Active Call Count: {0}", codec.ActiveCalls.Count); - - if (codec.ActiveCalls.Count > 0) - { - if (codec.ActiveCalls.Count == 1 && meetingInfoCodec == null) - TriList.SetString(UIStringJoin.HeaderCallStatusLabel, "1 Active Call"); - else if (codec.ActiveCalls.Count == 1 && meetingInfoCodec != null) - { - var headerCallStatusLabel = meetingInfoCodec.MeetingInfo.IsSharingMeeting - ? "Sharing-Only Meeting" - : "Active Meeting"; - - headerCallStatusLabel = meetingInfoCodec.MeetingInfo.WaitingForHost - ? "Waiting For Host" - : headerCallStatusLabel; - - TriList.SetString(UIStringJoin.HeaderCallStatusLabel, headerCallStatusLabel); - } - else if (codec.ActiveCalls.Count > 1) - TriList.SetString(UIStringJoin.HeaderCallStatusLabel, string.Format("{0} Active Calls", codec.ActiveCalls.Count)); - } - else - TriList.SetString(UIStringJoin.HeaderCallStatusLabel, "No Active Calls"); - } - - private void SetHeaderCallIcon(VideoCodecBase codec) - { - if (!codec.IsInCall) - { - HeaderCallButtonIconSig.StringValue = "DND"; - //HeaderCallButton.SetIcon(HeaderListButton.OnHook); - } - else if (codec.ActiveCalls.Any(c => c.Type == eCodecCallType.Video)) - { - HeaderCallButtonIconSig.StringValue = "Misc-06_Dark"; - } - //HeaderCallButton.SetIcon(HeaderListButton.Camera); - //TriList.SetUshort(UIUshortJoin.CallHeaderButtonMode, 2); - else - { - HeaderCallButtonIconSig.StringValue = "Misc-09_Dark"; - } - //HeaderCallButton.SetIcon(HeaderListButton.Phone); - //TriList.SetUshort(UIUshortJoin.CallHeaderButtonMode, 1); - } - - /// - /// Sets up Header Buttons for the EssentialsHuddleVtc1Room type - /// - public void SetupHeaderButtons(EssentialsHuddleVtc1PanelAvFunctionsDriver avDriver, IEssentialsHuddleVtc1Room currentRoom) - { - HeaderButtonsAreSetUp = false; - - TriList.SetBool(UIBoolJoin.TopBarHabaneroDynamicVisible, true); - - var roomConf = currentRoom.PropertiesConfig; - - // Register for the PopupInterlock IsShowsFeedback event to tie the header carets subpage visiblity to it - Parent.AvDriver.PopupInterlock.StatusChanged -= PopupInterlock_StatusChanged; - Parent.AvDriver.PopupInterlock.StatusChanged += PopupInterlock_StatusChanged; - - SetUpGear(avDriver, currentRoom); - - SetUpHelpButton(roomConf); - - uint nextJoin = 3953; - - nextJoin = SetUpEnvironmentButton(Parent.EnvironmentDriver, nextJoin); - - nextJoin = SetUpCalendarButton(avDriver, nextJoin); - - nextJoin = SetUpCallButton(avDriver, nextJoin); - - // blank any that remain - for (var i = nextJoin; i > 3950; i--) - { - TriList.SetString(i, "Blank"); - TriList.SetSigFalseAction(i, () => { }); - } - - TriList.SetSigFalseAction(UIBoolJoin.HeaderCallStatusLabelPress, - () => - { - avDriver.ShowActiveCallsListOrMeetingInfo(); - if (avDriver.CurrentRoom.InCallFeedback.BoolValue) - CaretInterlock.ShowInterlocked(CallCaretVisible); - }); - - // Set Call Status Subpage Position - - if (nextJoin == 3951) - { - // Set to right position - TriList.SetBool(UIBoolJoin.HeaderCallStatusLeftPositionVisible, false); - TriList.SetBool(UIBoolJoin.HeaderCallStatusRightPositionVisible, true); - } - else if (nextJoin == 3950) - { - // Set to left position - TriList.SetBool(UIBoolJoin.HeaderCallStatusLeftPositionVisible, true); - TriList.SetBool(UIBoolJoin.HeaderCallStatusRightPositionVisible, false); - } - - HeaderButtonsAreSetUp = true; - - ComputeHeaderCallStatus(currentRoom.VideoCodec); - } - - /// - /// Sets up Header Buttons for the EssentialsHuddleSpaceRoom type - /// - public void SetupHeaderButtons(EssentialsHuddlePanelAvFunctionsDriver avDriver, IEssentialsHuddleSpaceRoom currentRoom) - { - HeaderButtonsAreSetUp = false; - - TriList.SetBool(UIBoolJoin.TopBarHabaneroDynamicVisible, true); - - var roomConf = currentRoom.PropertiesConfig; - - // Register for the PopupInterlock IsShowsFeedback event to tie the header carets subpage visiblity to it - Parent.AvDriver.PopupInterlock.StatusChanged -= PopupInterlock_StatusChanged; - Parent.AvDriver.PopupInterlock.StatusChanged += PopupInterlock_StatusChanged; - - SetUpGear(avDriver, currentRoom); - - SetUpHelpButton(roomConf); - - uint nextJoin = 3953; - - nextJoin = SetUpEnvironmentButton(Parent.EnvironmentDriver, nextJoin); - - // blank any that remain - for (var i = nextJoin; i > 3950; i--) - { - TriList.SetString(i, "Blank"); - TriList.SetSigFalseAction(i, () => { }); - } - - HeaderButtonsAreSetUp = true; - } - - ///// - ///// Whenever a popup is shown/hidden, show/hide the header carets subpage and set the visibility of the correct caret - ///// - ///// - ///// - //void IsShownFeedback_OutputChange(object sender, EventArgs e) - //{ - // var popupInterlockIsShown = Parent.AvDriver.PopupInterlock.IsShown; - // // Set the visible state for the HeaderPopupCaretsSubpage to match that of the PopupInterlock state - // TriList.SetBool(UIBoolJoin.HeaderPopupCaretsSubpageVisibile, popupInterlockIsShown); - - // // Clear all caret visibility - // for (uint i = UIBoolJoin.HeaderCaret5Visible; i >= UIBoolJoin.HeaderCaret1Visible; i--) - // { - // TriList.SetBool(i, false); - // } - - // // Set the current caret visible if the popup is still shown - // if (popupInterlockIsShown) - // TriList.SetBool(NextCaretVisible, true); - //} - - /// - /// Whenever a popup is shown/hidden, show/hide the header carets subpage and set the visibility of the correct caret - /// - /// - /// - void PopupInterlock_StatusChanged(object sender, StatusChangedEventArgs e) - { - // Set the visible state for the HeaderPopupCaretsSubpage to match that of the PopupInterlock state - - bool headerPopupShown = false; - - // Check if the popup interlock is shown, and if one of the header popups is current, then show the carets subpage - if (e.IsShown) - { - if (Parent.EnvironmentDriver != null && e.NewJoin == Parent.EnvironmentDriver.BackgroundSubpageJoin) - headerPopupShown = true; - else if (e.NewJoin == UIBoolJoin.HeaderActiveCallsListVisible) - headerPopupShown = true; - else if (e.NewJoin == UIBoolJoin.HeaderMeetingInfoVisible) - headerPopupShown = true; - else if (e.NewJoin == UIBoolJoin.HelpPageVisible) - headerPopupShown = true; - else if (e.NewJoin == UIBoolJoin.MeetingsOrContacMethodsListVisible) - headerPopupShown = true; - else if (e.NewJoin == UIBoolJoin.VolumesPagePowerOffVisible || e.NewJoin == UIBoolJoin.VolumesPageVisible) - headerPopupShown = true; - } - - // Set the carets subpage visibility - TriList.SetBool(UIBoolJoin.HeaderPopupCaretsSubpageVisibile, headerPopupShown); - - if (!e.IsShown) - CaretInterlock.HideAndClear(); - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.UI; +using Crestron.SimplSharpPro.DeviceSupport; + + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.SmartObjects; +using PepperDash.Essentials.Core.PageManagers; +using PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces; +using PepperDash.Essentials.Room.Config; +using PepperDash.Essentials.Devices.Common.Codec; +using PepperDash.Essentials.Devices.Common.VideoCodec; + + +namespace PepperDash.Essentials +{ + /// + /// + /// + public class EssentialsHeaderDriver : PanelDriverBase + { + uint EnvironmentCaretVisible; + uint CalendarCaretVisible; + uint CallCaretVisible; + + JoinedSigInterlock CaretInterlock; + + CrestronTouchpanelPropertiesConfig Config; + + /// + /// The parent driver for this + /// + EssentialsPanelMainInterfaceDriver Parent; + + /// + /// Indicates that the SetHeaderButtons method has completed successfully + /// + public bool HeaderButtonsAreSetUp { get; private set; } + + StringInputSig HeaderCallButtonIconSig; + + public EssentialsHeaderDriver(EssentialsPanelMainInterfaceDriver parent, CrestronTouchpanelPropertiesConfig config) + : base(parent.TriList) + { + Config = config; + Parent = parent; + CaretInterlock = new JoinedSigInterlock(TriList); + } + + void SetUpGear(IAVDriver avDriver, IEssentialsRoom currentRoom) + { + // Gear + TriList.SetString(UIStringJoin.HeaderButtonIcon5, "Gear"); + TriList.SetSigHeldAction(UIBoolJoin.HeaderIcon5Press, 2000, + avDriver.ShowTech, + null, + () => + { + if (currentRoom.OnFeedback.BoolValue) + { + avDriver.PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.VolumesPageVisible); + CaretInterlock.ShowInterlocked(UIBoolJoin.HeaderCaret5Visible); + } + else + { + avDriver.PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.VolumesPagePowerOffVisible); + CaretInterlock.ShowInterlocked(UIBoolJoin.HeaderCaret5Visible); + } + }); + TriList.SetSigFalseAction(UIBoolJoin.TechExitButton, () => + avDriver.PopupInterlock.HideAndClear()); + } + + public void SetUpHelpButton(EssentialsRoomPropertiesConfig roomConf) + { + // Help roomConf and popup + if (roomConf.Help != null) + { + TriList.SetString(UIStringJoin.HelpMessage, roomConf.Help.Message); + TriList.SetBool(UIBoolJoin.HelpPageShowCallButtonVisible, roomConf.Help.ShowCallButton); + TriList.SetString(UIStringJoin.HelpPageCallButtonText, roomConf.Help.CallButtonText); + if (roomConf.Help.ShowCallButton) + { + TriList.SetSigFalseAction(UIBoolJoin.HelpPageShowCallButtonPress, () => { }); // ************ FILL IN + } + else + { + TriList.ClearBoolSigAction(UIBoolJoin.HelpPageShowCallButtonPress); + } + } + else // older config + { + TriList.SetString(UIStringJoin.HelpMessage, roomConf.HelpMessage); + TriList.SetBool(UIBoolJoin.HelpPageShowCallButtonVisible, false); + TriList.SetString(UIStringJoin.HelpPageCallButtonText, null); + TriList.ClearBoolSigAction(UIBoolJoin.HelpPageShowCallButtonPress); + } + TriList.SetString(UIStringJoin.HeaderButtonIcon4, "Help"); + TriList.SetSigFalseAction(UIBoolJoin.HeaderIcon4Press, () => + { + string message = null; + var room = DeviceManager.GetDeviceForKey(Config.DefaultRoomKey) + as IEssentialsHuddleSpaceRoom; + if (room != null) + message = room.PropertiesConfig.HelpMessage; + else + message = "Sorry, no help message available. No room connected."; + //TriList.StringInput[UIStringJoin.HelpMessage].StringValue = message; + Parent.AvDriver.PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.HelpPageVisible); + CaretInterlock.ShowInterlocked(UIBoolJoin.HeaderCaret4Visible); + }); + } + + uint SetUpEnvironmentButton(EssentialsEnvironmentDriver environmentDriver, uint nextJoin) + { + if (environmentDriver != null) + { + var tempJoin = nextJoin; + TriList.SetString(tempJoin, "Lights"); + EnvironmentCaretVisible = tempJoin + 10; + TriList.SetSigFalseAction(tempJoin, () => + { + environmentDriver.Toggle(); + CaretInterlock.ShowInterlocked(EnvironmentCaretVisible); + }); + nextJoin--; + return nextJoin; + } + else + return nextJoin; + } + + uint SetUpCalendarButton(EssentialsHuddleVtc1PanelAvFunctionsDriver avDriver, uint nextJoin) + { + // Calendar button + if (avDriver.CurrentRoom.ScheduleSource != null) + { + var tempJoin = nextJoin; + TriList.SetString(tempJoin, "Calendar"); + CalendarCaretVisible = tempJoin + 10; + TriList.SetSigFalseAction(tempJoin, () => + { + avDriver.CalendarPress(); + CaretInterlock.ShowInterlocked(CalendarCaretVisible); + }); + + nextJoin--; + return nextJoin; + } + else + return nextJoin; + } + + uint SetUpCallButton(EssentialsHuddleVtc1PanelAvFunctionsDriver avDriver, uint nextJoin) + { + // Call button + var tempJoin = nextJoin; + TriList.SetString(tempJoin, "DND"); + CallCaretVisible = tempJoin + 10; + TriList.SetSigFalseAction(tempJoin, () => + { + avDriver.ShowActiveCallsListOrMeetingInfo(); + if(avDriver.CurrentRoom.InCallFeedback.BoolValue) + CaretInterlock.ShowInterlocked(CallCaretVisible); + }); + HeaderCallButtonIconSig = TriList.StringInput[tempJoin]; + + nextJoin--; + return nextJoin; + } + + /// + /// Evaluates the call status and sets the icon mode and text label + /// + public void ComputeHeaderCallStatus(VideoCodecBase codec) + { + if (codec == null) + { + Debug.Console(1, "ComputeHeaderCallStatus() cannot execute. codec is null"); + return; + } + + if (HeaderCallButtonIconSig == null) + { + Debug.Console(1, "ComputeHeaderCallStatus() cannot execute. HeaderCallButtonIconSig is null"); + return; + } + + var meetingInfoCodec = codec as IHasMeetingInfo; + + // Set mode of header button + SetHeaderCallIcon(codec); + + // Set the call status text + Debug.Console(1, "Active Call Count: {0}", codec.ActiveCalls.Count); + + if (codec.ActiveCalls.Count > 0) + { + if (codec.ActiveCalls.Count == 1 && meetingInfoCodec == null) + TriList.SetString(UIStringJoin.HeaderCallStatusLabel, "1 Active Call"); + else if (codec.ActiveCalls.Count == 1 && meetingInfoCodec != null) + { + var headerCallStatusLabel = meetingInfoCodec.MeetingInfo.IsSharingMeeting + ? "Sharing-Only Meeting" + : "Active Meeting"; + + headerCallStatusLabel = meetingInfoCodec.MeetingInfo.WaitingForHost + ? "Waiting For Host" + : headerCallStatusLabel; + + TriList.SetString(UIStringJoin.HeaderCallStatusLabel, headerCallStatusLabel); + } + else if (codec.ActiveCalls.Count > 1) + TriList.SetString(UIStringJoin.HeaderCallStatusLabel, string.Format("{0} Active Calls", codec.ActiveCalls.Count)); + } + else + TriList.SetString(UIStringJoin.HeaderCallStatusLabel, "No Active Calls"); + } + + private void SetHeaderCallIcon(VideoCodecBase codec) + { + if (!codec.IsInCall) + { + HeaderCallButtonIconSig.StringValue = "DND"; + //HeaderCallButton.SetIcon(HeaderListButton.OnHook); + } + else if (codec.ActiveCalls.Any(c => c.Type == eCodecCallType.Video)) + { + HeaderCallButtonIconSig.StringValue = "Misc-06_Dark"; + } + //HeaderCallButton.SetIcon(HeaderListButton.Camera); + //TriList.SetUshort(UIUshortJoin.CallHeaderButtonMode, 2); + else + { + HeaderCallButtonIconSig.StringValue = "Misc-09_Dark"; + } + //HeaderCallButton.SetIcon(HeaderListButton.Phone); + //TriList.SetUshort(UIUshortJoin.CallHeaderButtonMode, 1); + } + + /// + /// Sets up Header Buttons for the EssentialsHuddleVtc1Room type + /// + public void SetupHeaderButtons(EssentialsHuddleVtc1PanelAvFunctionsDriver avDriver, IEssentialsHuddleVtc1Room currentRoom) + { + HeaderButtonsAreSetUp = false; + + TriList.SetBool(UIBoolJoin.TopBarHabaneroDynamicVisible, true); + + var roomConf = currentRoom.PropertiesConfig; + + // Register for the PopupInterlock IsShowsFeedback event to tie the header carets subpage visiblity to it + Parent.AvDriver.PopupInterlock.StatusChanged -= PopupInterlock_StatusChanged; + Parent.AvDriver.PopupInterlock.StatusChanged += PopupInterlock_StatusChanged; + + SetUpGear(avDriver, currentRoom); + + SetUpHelpButton(roomConf); + + uint nextJoin = 3953; + + nextJoin = SetUpEnvironmentButton(Parent.EnvironmentDriver, nextJoin); + + nextJoin = SetUpCalendarButton(avDriver, nextJoin); + + nextJoin = SetUpCallButton(avDriver, nextJoin); + + // blank any that remain + for (var i = nextJoin; i > 3950; i--) + { + TriList.SetString(i, "Blank"); + TriList.SetSigFalseAction(i, () => { }); + } + + TriList.SetSigFalseAction(UIBoolJoin.HeaderCallStatusLabelPress, + () => + { + avDriver.ShowActiveCallsListOrMeetingInfo(); + if (avDriver.CurrentRoom.InCallFeedback.BoolValue) + CaretInterlock.ShowInterlocked(CallCaretVisible); + }); + + // Set Call Status Subpage Position + + if (nextJoin == 3951) + { + // Set to right position + TriList.SetBool(UIBoolJoin.HeaderCallStatusLeftPositionVisible, false); + TriList.SetBool(UIBoolJoin.HeaderCallStatusRightPositionVisible, true); + } + else if (nextJoin == 3950) + { + // Set to left position + TriList.SetBool(UIBoolJoin.HeaderCallStatusLeftPositionVisible, true); + TriList.SetBool(UIBoolJoin.HeaderCallStatusRightPositionVisible, false); + } + + HeaderButtonsAreSetUp = true; + + ComputeHeaderCallStatus(currentRoom.VideoCodec); + } + + /// + /// Sets up Header Buttons for the EssentialsHuddleSpaceRoom type + /// + public void SetupHeaderButtons(EssentialsHuddlePanelAvFunctionsDriver avDriver, IEssentialsHuddleSpaceRoom currentRoom) + { + HeaderButtonsAreSetUp = false; + + TriList.SetBool(UIBoolJoin.TopBarHabaneroDynamicVisible, true); + + var roomConf = currentRoom.PropertiesConfig; + + // Register for the PopupInterlock IsShowsFeedback event to tie the header carets subpage visiblity to it + Parent.AvDriver.PopupInterlock.StatusChanged -= PopupInterlock_StatusChanged; + Parent.AvDriver.PopupInterlock.StatusChanged += PopupInterlock_StatusChanged; + + SetUpGear(avDriver, currentRoom); + + SetUpHelpButton(roomConf); + + uint nextJoin = 3953; + + nextJoin = SetUpEnvironmentButton(Parent.EnvironmentDriver, nextJoin); + + // blank any that remain + for (var i = nextJoin; i > 3950; i--) + { + TriList.SetString(i, "Blank"); + TriList.SetSigFalseAction(i, () => { }); + } + + HeaderButtonsAreSetUp = true; + } + + ///// + ///// Whenever a popup is shown/hidden, show/hide the header carets subpage and set the visibility of the correct caret + ///// + ///// + ///// + //void IsShownFeedback_OutputChange(object sender, EventArgs e) + //{ + // var popupInterlockIsShown = Parent.AvDriver.PopupInterlock.IsShown; + // // Set the visible state for the HeaderPopupCaretsSubpage to match that of the PopupInterlock state + // TriList.SetBool(UIBoolJoin.HeaderPopupCaretsSubpageVisibile, popupInterlockIsShown); + + // // Clear all caret visibility + // for (uint i = UIBoolJoin.HeaderCaret5Visible; i >= UIBoolJoin.HeaderCaret1Visible; i--) + // { + // TriList.SetBool(i, false); + // } + + // // Set the current caret visible if the popup is still shown + // if (popupInterlockIsShown) + // TriList.SetBool(NextCaretVisible, true); + //} + + /// + /// Whenever a popup is shown/hidden, show/hide the header carets subpage and set the visibility of the correct caret + /// + /// + /// + void PopupInterlock_StatusChanged(object sender, StatusChangedEventArgs e) + { + // Set the visible state for the HeaderPopupCaretsSubpage to match that of the PopupInterlock state + + bool headerPopupShown = false; + + // Check if the popup interlock is shown, and if one of the header popups is current, then show the carets subpage + if (e.IsShown) + { + if (Parent.EnvironmentDriver != null && e.NewJoin == Parent.EnvironmentDriver.BackgroundSubpageJoin) + headerPopupShown = true; + else if (e.NewJoin == UIBoolJoin.HeaderActiveCallsListVisible) + headerPopupShown = true; + else if (e.NewJoin == UIBoolJoin.HeaderMeetingInfoVisible) + headerPopupShown = true; + else if (e.NewJoin == UIBoolJoin.HelpPageVisible) + headerPopupShown = true; + else if (e.NewJoin == UIBoolJoin.MeetingsOrContacMethodsListVisible) + headerPopupShown = true; + else if (e.NewJoin == UIBoolJoin.VolumesPagePowerOffVisible || e.NewJoin == UIBoolJoin.VolumesPageVisible) + headerPopupShown = true; + } + + // Set the carets subpage visibility + TriList.SetBool(UIBoolJoin.HeaderPopupCaretsSubpageVisibile, headerPopupShown); + + if (!e.IsShown) + CaretInterlock.HideAndClear(); + } + } } \ No newline at end of file diff --git a/PepperDashEssentials/UIDrivers/Essentials/EssentialsPanelMainInterfaceDriver.cs b/src/PepperDashEssentials/UIDrivers/Essentials/EssentialsPanelMainInterfaceDriver.cs similarity index 96% rename from PepperDashEssentials/UIDrivers/Essentials/EssentialsPanelMainInterfaceDriver.cs rename to src/PepperDashEssentials/UIDrivers/Essentials/EssentialsPanelMainInterfaceDriver.cs index 2b787063..6b9ae605 100644 --- a/PepperDashEssentials/UIDrivers/Essentials/EssentialsPanelMainInterfaceDriver.cs +++ b/src/PepperDashEssentials/UIDrivers/Essentials/EssentialsPanelMainInterfaceDriver.cs @@ -1,168 +1,168 @@ -using System; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.UI; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.SmartObjects; - -namespace PepperDash.Essentials -{ - /// - /// - /// - public class EssentialsPanelMainInterfaceDriver : PanelDriverBase, IHasScreenSaverController, IDisposable - { - CTimer InactivityTimer; - - /// - /// Assign the appropriate A/V driver. - /// Want to keep the AvDriver alive, because it may hold states - /// - public IAVDriver AvDriver { get; set;} - - public EssentialsHeaderDriver HeaderDriver { get; set; } - - public EssentialsEnvironmentDriver EnvironmentDriver { get; set; } - - public PanelDriverBase CurrentChildDriver { get; private set; } - - public ScreenSaverController ScreenSaverController { get; set; } - - private readonly long _timeoutMs; - - CrestronTouchpanelPropertiesConfig Config; - - /// - /// The main interlock for popups - /// - //public JoinedSigInterlock PopupInterlock { get; private set; } - - public EssentialsPanelMainInterfaceDriver(BasicTriListWithSmartObject trilist, - CrestronTouchpanelPropertiesConfig config) - : base(trilist) - { - Config = config; - - _timeoutMs = Config.ScreenSaverTimeoutMin * 60 * 1000; - - var tsx52or60 = trilist as Tswx52ButtonVoiceControl; - - if (tsx52or60 != null) - { - tsx52or60.ExtenderTouchDetectionReservedSigs.Use(); - tsx52or60.ExtenderTouchDetectionReservedSigs.DeviceExtenderSigChange += ExtenderTouchDetectionReservedSigs_DeviceExtenderSigChange; - tsx52or60.ExtenderTouchDetectionReservedSigs.Time.UShortValue = 1; - ManageInactivityTimer(); - - } - else - { - var tswx70 = trilist as TswX70Base; - if (tswx70 != null) - { - tswx70.ExtenderTouchDetectionReservedSigs.Use(); - tswx70.ExtenderTouchDetectionReservedSigs.DeviceExtenderSigChange += ExtenderTouchDetectionReservedSigs_DeviceExtenderSigChange; - tswx70.ExtenderTouchDetectionReservedSigs.Time.UShortValue = 1; - ManageInactivityTimer(); - } - } - } - - #region IDisposable Members - - public void Dispose() - { - var avDriver = AvDriver as PanelDriverBase; - if (avDriver != null) - { - avDriver.Hide(); - } - if (ScreenSaverController != null) - { - ScreenSaverController.Dispose(); - } - if (HeaderDriver != null) - { - HeaderDriver.Hide(); - } - if (EnvironmentDriver != null) - { - EnvironmentDriver.Hide(); - } - if (CurrentChildDriver != null) - { - CurrentChildDriver.Hide(); - } - } - - #endregion - - void ExtenderTouchDetectionReservedSigs_DeviceExtenderSigChange(Crestron.SimplSharpPro.DeviceExtender currentDeviceExtender, Crestron.SimplSharpPro.SigEventArgs args) - { - - if (args.Sig.BoolValue) - { - ManageInactivityTimer(); - } - } - - private void ManageInactivityTimer() - { - if (InactivityTimer != null) - { - InactivityTimer.Reset(_timeoutMs); - } - else - { - InactivityTimer = new CTimer((o) => InactivityTimerExpired(), _timeoutMs); - } - } - - void InactivityTimerExpired() - { - InactivityTimer.Stop(); - InactivityTimer.Dispose(); - InactivityTimer = null; - - ScreenSaverController.Show(); - } - - public override void Show() - { - CurrentChildDriver = null; - ShowSubDriver(AvDriver as PanelDriverBase); - - base.Show(); - } - - public override void Hide() - { - TriList.BooleanInput[AvDriver.StartPageVisibleJoin].BoolValue = false; - base.Hide(); - } - - void ShowSubDriver(PanelDriverBase driver) - { - CurrentChildDriver = driver; - if (driver == null) - return; - this.Hide(); - driver.Show(); - } - - /// - /// - /// - public override void BackButtonPressed() - { - if(CurrentChildDriver != null) - CurrentChildDriver.BackButtonPressed(); - } - } - - public interface IHasScreenSaverController - { - ScreenSaverController ScreenSaverController { get; } - } +using System; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.UI; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.SmartObjects; + +namespace PepperDash.Essentials +{ + /// + /// + /// + public class EssentialsPanelMainInterfaceDriver : PanelDriverBase, IHasScreenSaverController, IDisposable + { + CTimer InactivityTimer; + + /// + /// Assign the appropriate A/V driver. + /// Want to keep the AvDriver alive, because it may hold states + /// + public IAVDriver AvDriver { get; set;} + + public EssentialsHeaderDriver HeaderDriver { get; set; } + + public EssentialsEnvironmentDriver EnvironmentDriver { get; set; } + + public PanelDriverBase CurrentChildDriver { get; private set; } + + public ScreenSaverController ScreenSaverController { get; set; } + + private readonly long _timeoutMs; + + CrestronTouchpanelPropertiesConfig Config; + + /// + /// The main interlock for popups + /// + //public JoinedSigInterlock PopupInterlock { get; private set; } + + public EssentialsPanelMainInterfaceDriver(BasicTriListWithSmartObject trilist, + CrestronTouchpanelPropertiesConfig config) + : base(trilist) + { + Config = config; + + _timeoutMs = Config.ScreenSaverTimeoutMin * 60 * 1000; + + var tsx52or60 = trilist as Tswx52ButtonVoiceControl; + + if (tsx52or60 != null) + { + tsx52or60.ExtenderTouchDetectionReservedSigs.Use(); + tsx52or60.ExtenderTouchDetectionReservedSigs.DeviceExtenderSigChange += ExtenderTouchDetectionReservedSigs_DeviceExtenderSigChange; + tsx52or60.ExtenderTouchDetectionReservedSigs.Time.UShortValue = 1; + ManageInactivityTimer(); + + } + else + { + var tswx70 = trilist as TswX70Base; + if (tswx70 != null) + { + tswx70.ExtenderTouchDetectionReservedSigs.Use(); + tswx70.ExtenderTouchDetectionReservedSigs.DeviceExtenderSigChange += ExtenderTouchDetectionReservedSigs_DeviceExtenderSigChange; + tswx70.ExtenderTouchDetectionReservedSigs.Time.UShortValue = 1; + ManageInactivityTimer(); + } + } + } + + #region IDisposable Members + + public void Dispose() + { + var avDriver = AvDriver as PanelDriverBase; + if (avDriver != null) + { + avDriver.Hide(); + } + if (ScreenSaverController != null) + { + ScreenSaverController.Dispose(); + } + if (HeaderDriver != null) + { + HeaderDriver.Hide(); + } + if (EnvironmentDriver != null) + { + EnvironmentDriver.Hide(); + } + if (CurrentChildDriver != null) + { + CurrentChildDriver.Hide(); + } + } + + #endregion + + void ExtenderTouchDetectionReservedSigs_DeviceExtenderSigChange(Crestron.SimplSharpPro.DeviceExtender currentDeviceExtender, Crestron.SimplSharpPro.SigEventArgs args) + { + + if (args.Sig.BoolValue) + { + ManageInactivityTimer(); + } + } + + private void ManageInactivityTimer() + { + if (InactivityTimer != null) + { + InactivityTimer.Reset(_timeoutMs); + } + else + { + InactivityTimer = new CTimer((o) => InactivityTimerExpired(), _timeoutMs); + } + } + + void InactivityTimerExpired() + { + InactivityTimer.Stop(); + InactivityTimer.Dispose(); + InactivityTimer = null; + + ScreenSaverController.Show(); + } + + public override void Show() + { + CurrentChildDriver = null; + ShowSubDriver(AvDriver as PanelDriverBase); + + base.Show(); + } + + public override void Hide() + { + TriList.BooleanInput[AvDriver.StartPageVisibleJoin].BoolValue = false; + base.Hide(); + } + + void ShowSubDriver(PanelDriverBase driver) + { + CurrentChildDriver = driver; + if (driver == null) + return; + this.Hide(); + driver.Show(); + } + + /// + /// + /// + public override void BackButtonPressed() + { + if(CurrentChildDriver != null) + CurrentChildDriver.BackButtonPressed(); + } + } + + public interface IHasScreenSaverController + { + ScreenSaverController ScreenSaverController { get; } + } } \ No newline at end of file diff --git a/PepperDashEssentials/UIDrivers/Essentials/EssentialsPresentationPanelAvFunctionsDriver.cs b/src/PepperDashEssentials/UIDrivers/Essentials/EssentialsPresentationPanelAvFunctionsDriver.cs similarity index 100% rename from PepperDashEssentials/UIDrivers/Essentials/EssentialsPresentationPanelAvFunctionsDriver.cs rename to src/PepperDashEssentials/UIDrivers/Essentials/EssentialsPresentationPanelAvFunctionsDriver.cs diff --git a/PepperDashEssentials/UIDrivers/EssentialsHuddle/EssentialsHuddlePanelAvFunctionsDriver.cs b/src/PepperDashEssentials/UIDrivers/EssentialsHuddle/EssentialsHuddlePanelAvFunctionsDriver.cs similarity index 100% rename from PepperDashEssentials/UIDrivers/EssentialsHuddle/EssentialsHuddlePanelAvFunctionsDriver.cs rename to src/PepperDashEssentials/UIDrivers/EssentialsHuddle/EssentialsHuddlePanelAvFunctionsDriver.cs diff --git a/PepperDashEssentials/UIDrivers/EssentialsHuddle/EssentialsHuddleTechPageDriver.cs b/src/PepperDashEssentials/UIDrivers/EssentialsHuddle/EssentialsHuddleTechPageDriver.cs similarity index 100% rename from PepperDashEssentials/UIDrivers/EssentialsHuddle/EssentialsHuddleTechPageDriver.cs rename to src/PepperDashEssentials/UIDrivers/EssentialsHuddle/EssentialsHuddleTechPageDriver.cs diff --git a/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddlePresentationUiDriver.cs b/src/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddlePresentationUiDriver.cs similarity index 100% rename from PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddlePresentationUiDriver.cs rename to src/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddlePresentationUiDriver.cs diff --git a/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs b/src/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs similarity index 97% rename from PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs rename to src/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs index 80fb0ba8..78aeb311 100644 --- a/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs +++ b/src/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs @@ -1,1652 +1,1652 @@ -using System; -using System.Linq; -using System.Collections.Generic; -using System.Globalization; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.UI; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.Core.DeviceTypeInterfaces; -using PepperDash.Essentials.Core.SmartObjects; -using PepperDash.Essentials.Core.PageManagers; -using PepperDash.Essentials.Room.Config; -using PepperDash.Essentials.Devices.Common.Codec; -using PepperDash.Essentials.Devices.Common.VideoCodec; -using PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces; - -namespace PepperDash.Essentials -{ - /// - /// - /// - public class EssentialsHuddleVtc1PanelAvFunctionsDriver : PanelDriverBase, IAVWithVCDriver - { - CrestronTouchpanelPropertiesConfig Config; - - public enum UiDisplayMode - { - Presentation, AudioSetup, Call, Start - } - - public uint StartPageVisibleJoin { get; private set; } - - /// - /// Whether volume ramping from this panel will show the volume - /// gauge popup. - /// - public bool ShowVolumeGauge { get; set; } - - /// - /// - /// - public uint PowerOffTimeout { get; set; } - - /// - /// - /// - public string DefaultRoomKey { get; set; } - - - /// - /// - /// - public IEssentialsHuddleVtc1Room CurrentRoom - { - get { return _CurrentRoom; } - set - { - SetCurrentRoom(value); - } - } - IEssentialsHuddleVtc1Room _CurrentRoom; - - /// - /// For hitting feedbacks - /// - BoolInputSig CallButtonSig; - BoolInputSig ShareButtonSig; - BoolInputSig EndMeetingButtonSig; - - BoolFeedback CallSharingInfoVisibleFeedback; - - /// - /// The parent driver for this - /// - public PanelDriverBase Parent { get; private set; } - - /// - /// All children attached to this driver. For hiding and showing as a group. - /// - List ChildDrivers = new List(); - - List CurrentDisplayModeSigsInUse = new List(); - - //// Important smart objects - - /// - /// Smart Object 3200 - /// - SubpageReferenceList SourceStagingSrl; - - /// - /// Smart Object 15022 - /// - SubpageReferenceList ActivityFooterSrl; - - /// - /// - /// - public SubpageReferenceList MeetingOrContactMethodModalSrl { get; set; } - - public uint CallListOrMeetingInfoPopoverVisibilityJoin { get; private set; } - - - /// - /// The list of buttons on the header. Managed with visibility only - /// - //SmartObjectHeaderButtonList HeaderButtonsList; - - /// - /// The AV page mangagers that have been used, to keep them alive for later - /// - Dictionary PageManagers = new Dictionary(); - - /// - /// Current page manager running for a source - /// - PageManager CurrentSourcePageManager; - - /// - /// Will auto-timeout a power off - /// - CTimer PowerOffTimer; - - /// - /// - /// - ModalDialog PowerDownModal; - - /// - /// - /// - //ModalDialog WarmingCoolingModal; - - /// - /// Represents - /// - public JoinedSigInterlock PopupInterlock { get; private set; } - - /// - /// Interlock for various source, camera, call control bars. The bar above the activity footer. This is also - /// used to show start page - /// - JoinedSigInterlock StagingBarInterlock; - - /// - /// Interlocks the various call-related subpages - /// - JoinedSigInterlock CallPagesInterlock; - - /// - /// The Video codec driver - /// - PepperDash.Essentials.UIDrivers.VC.EssentialsVideoCodecUiDriver VCDriver; - - /// - /// The driver for the tech page. Lazy getter for memory usage - /// - PepperDash.Essentials.UIDrivers.EssentialsHuddleTechPageDriver TechDriver - { - get - { - if (_TechDriver == null) - _TechDriver = new PepperDash.Essentials.UIDrivers.EssentialsHuddleTechPageDriver(TriList, CurrentRoom.PropertiesConfig.Tech); - return _TechDriver; - } - } - PepperDash.Essentials.UIDrivers.EssentialsHuddleTechPageDriver _TechDriver; - - /// - /// Controls timeout of notification ribbon timer - /// - CTimer RibbonTimer; - - /// - /// The keyboard - /// - public PepperDash.Essentials.Core.Touchpanels.Keyboards.HabaneroKeyboardController Keyboard { get; private set; } - - - private UiDisplayMode _currentMode; - - private bool _isZoomRoomWithNoExternalSources - { - get - { - return CurrentRoom.VideoCodec is Essentials.Devices.Common.VideoCodec.ZoomRoom.ZoomRoom && _sourceListCount <= 1; - } - } - - private uint _sourceListCount; - - /// - /// The mode showing. Presentation or call. - /// - UiDisplayMode CurrentMode - { - get - { - return _currentMode; - } - set - { - if (value != _currentMode) - { - _currentMode = value; - - SetActivityFooterFeedbacks(); - } - } - } - - CTimer NextMeetingTimer; - - /// - /// Tracks the last meeting that was cancelled - /// - string LastMeetingDismissedId; - - /// - /// Constructor - /// - public EssentialsHuddleVtc1PanelAvFunctionsDriver(PanelDriverBase parent, CrestronTouchpanelPropertiesConfig config) - : base(parent.TriList) - { - Config = config; - Parent = parent; - - PopupInterlock = new JoinedSigInterlock(TriList); - StagingBarInterlock = new JoinedSigInterlock(TriList); - CallPagesInterlock = new JoinedSigInterlock(TriList); - - SourceStagingSrl = new SubpageReferenceList(TriList, UISmartObjectJoin.SourceStagingSRL, 3, 3, 3); - - ActivityFooterSrl = new SubpageReferenceList(TriList, UISmartObjectJoin.ActivityFooterSRL, 3, 3, 3); - CallButtonSig = ActivityFooterSrl.BoolInputSig(2, 1); - ShareButtonSig = ActivityFooterSrl.BoolInputSig(1, 1); - EndMeetingButtonSig = ActivityFooterSrl.BoolInputSig(3, 1); - - MeetingOrContactMethodModalSrl = new SubpageReferenceList(TriList, UISmartObjectJoin.MeetingListSRL, 3, 3, 5); - - CurrentMode = UiDisplayMode.Start; - - // buttons are added in SetCurrentRoom - //HeaderButtonsList = new SmartObjectHeaderButtonList(TriList.SmartObjects[UISmartObjectJoin.HeaderButtonList]); - - SetupActivityFooterWhenRoomOff(); - - ShowVolumeGauge = true; - Keyboard = new PepperDash.Essentials.Core.Touchpanels.Keyboards.HabaneroKeyboardController(TriList); - } - - /// - /// Add a video codec driver to this - /// - /// - public void SetVideoCodecDriver(PepperDash.Essentials.UIDrivers.VC.EssentialsVideoCodecUiDriver vcd) - { - VCDriver = vcd; - } - - /// - /// - /// - public override void Show() - { - if (CurrentRoom == null) - { - Debug.Console(1, "ERROR: AVUIFunctionsDriver, Cannot show. No room assigned"); - return; - } - - var roomConf = CurrentRoom.PropertiesConfig; - - if (Config.HeaderStyle.ToLower() == CrestronTouchpanelPropertiesConfig.Habanero) - { - TriList.SetSigFalseAction(UIBoolJoin.HeaderRoomButtonPress, () => - { - if (CurrentRoom.IsMobileControlEnabled) - { - Debug.Console(1, "Showing Mobile Control Header Info"); - PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.RoomHeaderInfoMCPageVisible); - } - else - { - Debug.Console(1, "Showing Non Mobile Control Header Info"); - PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.RoomHeaderInfoPageVisible); - } - }); - } - else if (Config.HeaderStyle.ToLower() == CrestronTouchpanelPropertiesConfig.Verbose) - { - TriList.SetSigFalseAction(UIBoolJoin.HeaderRoomButtonPress, () => - { - if (CurrentRoom.IsMobileControlEnabled) - { - Debug.Console(1, "Showing Mobile Control Header Info"); - PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.RoomHeaderInfoMCPageVisible); - } - else - { - Debug.Console(1, "Showing Non Mobile Control Header Info"); - PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.RoomHeaderInfoPageVisible); - } - }); - } - - TriList.SetBool(UIBoolJoin.DateAndTimeVisible, Config.ShowDate && Config.ShowTime); - TriList.SetBool(UIBoolJoin.DateOnlyVisible, Config.ShowDate && !Config.ShowTime); - TriList.SetBool(UIBoolJoin.TimeOnlyVisible, !Config.ShowDate && Config.ShowTime); - - TriList.SetBool(UIBoolJoin.TopBarHabaneroDynamicVisible, true); - - TriList.SetBool(UIBoolJoin.ActivityFooterVisible, true); - - // Privacy mute button - TriList.SetSigFalseAction(UIBoolJoin.Volume1SpeechMutePressAndFB, CurrentRoom.PrivacyModeToggle); - CurrentRoom.PrivacyModeIsOnFeedback.LinkInputSig(TriList.BooleanInput[UIBoolJoin.Volume1SpeechMutePressAndFB]); - - // Default to showing rooms/sources now. - if (CurrentRoom.OnFeedback.BoolValue) - { - TriList.SetBool(UIBoolJoin.TapToBeginVisible, false); - SetupActivityFooterWhenRoomOn(); - } - else - { - TriList.SetBool(StartPageVisibleJoin, true); - TriList.SetBool(UIBoolJoin.TapToBeginVisible, true); - SetupActivityFooterWhenRoomOff(); - } - ShowCurrentDisplayModeSigsInUse(); - - // *** Header Buttons *** - - // Generic "close" button for popup modals - TriList.SetSigFalseAction(UIBoolJoin.InterlockedModalClosePress, PopupInterlock.HideAndClear); - - // Volume related things - TriList.SetSigFalseAction(UIBoolJoin.VolumeDefaultPress, () => CurrentRoom.SetDefaultLevels()); - TriList.SetString(UIStringJoin.AdvancedVolumeSlider1Text, "Room"); - - //if (TriList is CrestronApp) - // TriList.BooleanInput[UIBoolJoin.GearButtonVisible].BoolValue = false; - //else - // TriList.BooleanInput[UIBoolJoin.GearButtonVisible].BoolValue = true; - - // power-related functions - // Note: some of these are not directly-related to the huddle space UI, but are held over - // in case - TriList.SetSigFalseAction(UIBoolJoin.ShowPowerOffPress, EndMeetingPress); - - TriList.SetSigFalseAction(UIBoolJoin.DisplayPowerTogglePress, () => - { - if (CurrentRoom != null && CurrentRoom.DefaultDisplay != null && CurrentRoom.DefaultDisplay is IHasPowerControl) - (CurrentRoom.DefaultDisplay as IHasPowerControl).PowerToggle(); - }); - - SetupNextMeetingTimer(); - - base.Show(); - } - - /// - /// Allows PopupInterlock to be toggled if the calls list is already visible, or if the codec is in a call - /// - public void ShowActiveCallsListOrMeetingInfo() - { - TriList.SetBool(UIBoolJoin.CallEndAllConfirmVisible, true); - - - if(PopupInterlock.CurrentJoin == CallListOrMeetingInfoPopoverVisibilityJoin) - PopupInterlock.ShowInterlockedWithToggle(CallListOrMeetingInfoPopoverVisibilityJoin); - else - { - if(CurrentRoom.VideoCodec.IsInCall) - PopupInterlock.ShowInterlockedWithToggle(CallListOrMeetingInfoPopoverVisibilityJoin); - } - } - - /// - /// - /// - void ShowLogo() - { - if (CurrentRoom.LogoUrlLightBkgnd == null) - { - TriList.SetBool(UIBoolJoin.LogoDefaultVisible, true); - TriList.SetBool(UIBoolJoin.LogoUrlVisible, false); - } - else - { - TriList.SetBool(UIBoolJoin.LogoDefaultVisible, false); - TriList.SetBool(UIBoolJoin.LogoUrlVisible, true); - TriList.SetString(UIStringJoin.LogoUrlLightBkgnd, _CurrentRoom.LogoUrlLightBkgnd); - TriList.SetString(UIStringJoin.LogoUrlDarkBkgnd, _CurrentRoom.LogoUrlDarkBkgnd); - } - } - - /// - /// - /// - void HideLogo() - { - TriList.SetBool(UIBoolJoin.LogoDefaultVisible, false); - TriList.SetBool(UIBoolJoin.LogoUrlVisible, false); - } - - /// - /// - /// - public override void Hide() - { - HideAndClearCurrentDisplayModeSigsInUse(); - TriList.SetBool(UIBoolJoin.TopBarHabaneroDynamicVisible, false); - TriList.BooleanInput[UIBoolJoin.ActivityFooterVisible].BoolValue = false; - TriList.BooleanInput[StartPageVisibleJoin].BoolValue = false; - TriList.BooleanInput[UIBoolJoin.TapToBeginVisible].BoolValue = false; - TriList.BooleanInput[UIBoolJoin.SelectASourceVisible].BoolValue = false; - if (NextMeetingTimer != null) - NextMeetingTimer.Stop(); - HideNextMeetingPopup(); - base.Hide(); - } - - /// - /// Reveals a message on the notification ribbon until cleared - /// - /// Text to display - /// Time in ms to display. 0 to keep on screen - public void ShowNotificationRibbon(string message, int timeout) - { - TriList.SetString(UIStringJoin.NotificationRibbonText, message); - TriList.SetBool(UIBoolJoin.NotificationRibbonVisible, true); - if (timeout > 0) - { - if (RibbonTimer != null) - RibbonTimer.Stop(); - RibbonTimer = new CTimer(o => { - TriList.SetBool(UIBoolJoin.NotificationRibbonVisible, false); - RibbonTimer = null; - }, timeout); - } - } - - /// - /// Hides the notification ribbon - /// - public void HideNotificationRibbon() - { - TriList.SetBool(UIBoolJoin.NotificationRibbonVisible, false); - if (RibbonTimer != null) - { - RibbonTimer.Stop(); - RibbonTimer = null; - } - } - - void SetupNextMeetingTimer() - { - var ss = CurrentRoom.ScheduleSource; - if (ss != null) - { - NextMeetingTimer = new CTimer(o => ShowNextMeetingTimerCallback(), null, 0, 60000); - } - } - - /// - /// - /// - void ShowNextMeetingTimerCallback() - { - //Update calendar for Zoom. Zoom doesn't automatically update when meetings are in the past - if (_isZoomRoomWithNoExternalSources) - { - CurrentRoom.ScheduleSource.GetSchedule(); - } - - // Every 60 seconds, refresh the calendar - RefreshMeetingsList(); - // check meetings list for the closest, joinable meeting - var ss = CurrentRoom.ScheduleSource; - var meetings = ss.CodecSchedule.Meetings; - - if (meetings.Count <= 0) - { - return; - } - // If the room is off pester the user - // If the room is on, and the meeting is joinable - // and the LastMeetingDismissed != this meeting - - var lastMeetingDismissed = meetings.FirstOrDefault(m => m.Id == LastMeetingDismissedId); - //Debug.Console(0, "*#* Room on: {0}, lastMeetingDismissedId: {1} {2} *#*", - // CurrentRoom.OnFeedback.BoolValue, - // LastMeetingDismissedId, - // lastMeetingDismissed != null ? lastMeetingDismissed.StartTime.ToString("t", Global.Culture) : ""); - - var meeting = meetings.LastOrDefault(m => m.Joinable); - if (CurrentRoom.OnFeedback.BoolValue - && lastMeetingDismissed == meeting) - { - // meeting no longer joinable, hide popup - if(meeting == null) - HideNextMeetingPopup(); - - return; - } - - LastMeetingDismissedId = null; - // Clear the popup when we run out of meetings - if (meeting == null) - { - HideNextMeetingPopup(); - } - else - { - - - TriList.SetString(UIStringJoin.MeetingsOrContactMethodListTitleText, "Upcoming meeting"); - TriList.SetString(UIStringJoin.NextMeetingStartTimeText, meeting.StartTime.ToString("t", Global.Culture)); - TriList.SetString(UIStringJoin.NextMeetingEndTimeText, meeting.EndTime.ToString("t", Global.Culture)); - TriList.SetString(UIStringJoin.NextMeetingTitleText, meeting.Title); - TriList.SetString(UIStringJoin.NextMeetingNameText, meeting.Organizer); - TriList.SetString(UIStringJoin.NextMeetingButtonLabel, "Join"); - TriList.SetSigFalseAction(UIBoolJoin.NextMeetingJoinPress, () => - { - HideNextMeetingPopup(); - PopupInterlock.Hide(); - RoomOnAndDialMeeting(meeting); - }); - TriList.SetString(UIStringJoin.NextMeetingSecondaryButtonLabel, "Show Schedule"); - TriList.SetSigFalseAction(UIBoolJoin.CalendarHeaderButtonPress, () => - { - HideNextMeetingPopup(); - //CalendarPress(); - RefreshMeetingsList(); - PopupInterlock.ShowInterlocked(UIBoolJoin.MeetingsOrContacMethodsListVisible); - }); - var indexOfNext = meetings.IndexOf(meeting) + 1; - - // indexOf = 3, 4 meetings : - if (indexOfNext < meetings.Count) - TriList.SetString(UIStringJoin.NextMeetingFollowingMeetingText, - meetings[indexOfNext].StartTime.ToString("t", Global.Culture)); - else - TriList.SetString(UIStringJoin.NextMeetingFollowingMeetingText, "No more meetings today"); - - TriList.SetSigFalseAction(UIBoolJoin.NextMeetingModalClosePress, () => - { - // Mark the meeting to not re-harass the user - if(CurrentRoom.OnFeedback.BoolValue) - LastMeetingDismissedId = meeting.Id; - HideNextMeetingPopup(); - }); - - TriList.SetBool(UIBoolJoin.NextMeetingModalVisible, true); - } - } - - /// - /// - /// - void HideNextMeetingPopup() - { - TriList.SetBool(UIBoolJoin.NextMeetingModalVisible, false); - - } - - /// - /// Calendar should only be visible when it's supposed to - /// - public void CalendarPress() - { - //RefreshMeetingsList(); // List should be up-to-date - PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.MeetingsOrContacMethodsListVisible); - } - - /// - /// Dials a meeting after turning on room (if necessary) - /// - void RoomOnAndDialMeeting(Meeting meeting) - { - Debug.Console(1, "[RoomOnAndDialMeeting] Joining meeting [{0}]", meeting); - Action dialAction = () => - { - var d = CurrentRoom.ScheduleSource as VideoCodecBase; - if (d != null) - { - Debug.Console(1, - "[RoomOnAndDialMeeting] [dialAction] Sending command to codec to join meeting {0}", meeting); - d.Dial(meeting); - LastMeetingDismissedId = meeting.Id; // To prevent prompts for already-joined call - } - }; - if (CurrentRoom.OnFeedback.BoolValue) - { - Debug.Console(1, "[RoomOnAndDialMeeting] Room is on."); - dialAction(); - } - else - { - Debug.Console(1, "RoomOnAndDialMeeting] Room is off or warming. Registering for Warming Feedback"); - // Rig a one-time handler to catch when the room is warmed and then dial call - EventHandler oneTimeHandler = null; - oneTimeHandler = (o, a) => - { - if (!CurrentRoom.IsWarmingUpFeedback.BoolValue) - { - CurrentRoom.IsWarmingUpFeedback.OutputChange -= oneTimeHandler; - dialAction(); - } - }; - CurrentRoom.IsWarmingUpFeedback.OutputChange += oneTimeHandler; - ActivityCallButtonPressed(); - } - } - - /// - /// Reveals the tech page and puts away anything that's in the way. - /// - public void ShowTech() - { - PopupInterlock.HideAndClear(); - TechDriver.Show(); - } - - /// - /// When the room is off, set the footer SRL - /// - void SetupActivityFooterWhenRoomOff() - { - ActivityFooterSrl.Clear(); - ActivityFooterSrl.AddItem(new SubpageReferenceListActivityItem(1, ActivityFooterSrl, 0, - b => { if (!b) ActivityShareButtonPressed(); })); - ActivityFooterSrl.AddItem(new SubpageReferenceListActivityItem(2, ActivityFooterSrl, 3, - b => { if (!b) ActivityCallButtonPressed(); })); - ActivityFooterSrl.Count = 2; - TriList.SetUshort(UIUshortJoin.PresentationStagingCaretMode, 1); // right one slot - TriList.SetUshort(UIUshortJoin.CallStagingCaretMode, 5); // left one slot - } - - /// - /// Sets up the footer SRL for when the room is on - /// - void SetupActivityFooterWhenRoomOn() - { - ActivityFooterSrl.Clear(); - ActivityFooterSrl.AddItem(new SubpageReferenceListActivityItem(1, ActivityFooterSrl, 0, - b => { if (!b) ActivityShareButtonPressed(); })); - ActivityFooterSrl.AddItem(new SubpageReferenceListActivityItem(2, ActivityFooterSrl, 3, - b => { if (!b) ActivityCallButtonPressed(); })); - ActivityFooterSrl.AddItem(new SubpageReferenceListActivityItem(3, ActivityFooterSrl, 4, - b => { if (!b) EndMeetingPress(); })); - ActivityFooterSrl.Count = 3; - TriList.SetUshort(UIUshortJoin.PresentationStagingCaretMode, 2); // center - TriList.SetUshort(UIUshortJoin.CallStagingCaretMode, 0); // left -2 - } - - /// - /// Single point call for setting the feedbacks on the activity buttons - /// - void SetActivityFooterFeedbacks() - { - if (CurrentRoom != null) - { - var startMode = CurrentMode == UiDisplayMode.Start; - var presentationMode = CurrentMode == UiDisplayMode.Presentation; - var callMode = CurrentMode == UiDisplayMode.Call; - - TriList.SetBool(StartPageVisibleJoin, startMode ? true : false); - - if (presentationMode &&_isZoomRoomWithNoExternalSources) - { - // For now, if this is a Zoom Room and there are no shareable sources just display the informational subpage - TriList.SetBool(UIBoolJoin.SourceStagingBarVisible, false); - TriList.SetBool(UIBoolJoin.ZoomRoomContentSharingVisible, true); - } - else - { - // Otherwise, show the staging bar - TriList.SetBool(UIBoolJoin.ZoomRoomContentSharingVisible, false); - TriList.SetBool(UIBoolJoin.SourceStagingBarVisible, presentationMode ? true : false); - - } - if (!presentationMode) - { - TriList.SetBool(UIBoolJoin.ZoomRoomContentSharingVisible, false); - TriList.SetBool(UIBoolJoin.SelectASourceVisible, false); - } - - CallButtonSig.BoolValue = callMode - && CurrentRoom.ShutdownType == eShutdownType.None; - ShareButtonSig.BoolValue = presentationMode - && CurrentRoom.ShutdownType == eShutdownType.None; - EndMeetingButtonSig.BoolValue = CurrentRoom.ShutdownType != eShutdownType.None; - } - } - - /// - /// - /// - public void ActivityCallButtonPressed() - { - if (VCDriver.IsVisible) - return; - HideLogo(); - HideNextMeetingPopup(); - //TriList.SetBool(StartPageVisibleJoin, false); - //TriList.SetBool(UIBoolJoin.SourceStagingBarVisible, false); - //TriList.SetBool(UIBoolJoin.SelectASourceVisible, false); - if (CurrentSourcePageManager != null) - CurrentSourcePageManager.Hide(); - PowerOnFromCall(); - CurrentMode = UiDisplayMode.Call; - VCDriver.Show(); - } - - /// - /// Attached to activity list share button - /// - void ActivityShareButtonPressed() - { - SetupSourceList(); - if (VCDriver.IsVisible) - VCDriver.Hide(); - HideNextMeetingPopup(); - - - if (_isZoomRoomWithNoExternalSources) - { - if (!CurrentRoom.OnFeedback.BoolValue) - { - CurrentRoom.RunDefaultPresentRoute(); - } - // For now, if this is a Zoom Room and there are no shareable sources just display the informational subpage - TriList.SetBool(UIBoolJoin.ZoomRoomContentSharingVisible, true); - - var presentationMeetingCodec = CurrentRoom.VideoCodec as IHasPresentationOnlyMeeting; - var farEndContentStatusCodec = CurrentRoom.VideoCodec as IHasFarEndContentStatus; - var receivingContent = false; - - if (farEndContentStatusCodec != null) - { - receivingContent = farEndContentStatusCodec.ReceivingContent.BoolValue; - } - - if (presentationMeetingCodec != null && !CurrentRoom.VideoCodec.IsInCall) - { - presentationMeetingCodec.StartSharingOnlyMeeting(eSharingMeetingMode.Laptop); - } - else if (CurrentRoom.VideoCodec.IsInCall && !CurrentRoom.VideoCodec.SharingContentIsOnFeedback.BoolValue && - !receivingContent) - { - CurrentRoom.VideoCodec.StartSharing(); - } - - if (CurrentSourcePageManager != null) - CurrentSourcePageManager.Hide(); - } - else - { - // Run default source when room is off and share is pressed - if (!CurrentRoom.OnFeedback.BoolValue) - { - // If there's no default, show UI elements - if (!(CurrentRoom as IRunDefaultPresentRoute).RunDefaultPresentRoute()) - TriList.SetBool(UIBoolJoin.SelectASourceVisible, true); - } - else // room is on show what's active or select a source if nothing is yet active - { - if (CurrentRoom.CurrentSourceInfo == null || - (CurrentRoom.VideoCodec != null && - CurrentRoom.CurrentSourceInfo.SourceDevice.Key == CurrentRoom.VideoCodec.OsdSource.Key)) - TriList.SetBool(UIBoolJoin.SelectASourceVisible, true); - else if (CurrentSourcePageManager != null) - { - TriList.SetBool(UIBoolJoin.SelectASourceVisible, false); - CurrentSourcePageManager.Show(); - } - } - SetupSourceList(); - } - CurrentMode = UiDisplayMode.Presentation; - } - - /// - /// Powers up the system to the codec route, if not already on. - /// - void PowerOnFromCall() - { - if (!CurrentRoom.OnFeedback.BoolValue) - { - CurrentRoom.RunDefaultCallRoute(); - } - } - - /// - /// Shows all sigs that are in CurrentDisplayModeSigsInUse - /// - void ShowCurrentDisplayModeSigsInUse() - { - foreach (var sig in CurrentDisplayModeSigsInUse) - sig.BoolValue = true; - } - - /// - /// Hides all CurrentDisplayModeSigsInUse sigs and clears the array - /// - void HideAndClearCurrentDisplayModeSigsInUse() - { - foreach (var sig in CurrentDisplayModeSigsInUse) - sig.BoolValue = false; - CurrentDisplayModeSigsInUse.Clear(); - } - - - /// - /// Loads the appropriate Sigs into CurrentDisplayModeSigsInUse and shows them - /// - void ShowCurrentSource() - { - if (CurrentRoom.CurrentSourceInfo == null || _isZoomRoomWithNoExternalSources) - return; - - CurrentMode = UiDisplayMode.Presentation; - - if (CurrentRoom.CurrentSourceInfo.SourceDevice == null) - { - TriList.SetBool(UIBoolJoin.SelectASourceVisible, true); - return; - } - - var uiDev = CurrentRoom.CurrentSourceInfo.SourceDevice as IUiDisplayInfo; - PageManager pm = null; - // If we need a page manager, get an appropriate one - if (uiDev != null) - { - TriList.SetBool(UIBoolJoin.SelectASourceVisible, false); - // Got an existing page manager, get it - if (PageManagers.ContainsKey(uiDev)) - pm = PageManagers[uiDev]; - // Otherwise make an apporiate one - else if (uiDev is ISetTopBoxControls) - pm = new SetTopBoxThreePanelPageManager(uiDev as ISetTopBoxControls, TriList); - else if (uiDev is IDiscPlayerControls) - pm = new DiscPlayerMediumPageManager(uiDev as IDiscPlayerControls, TriList); - else - pm = new DefaultPageManager(uiDev, TriList); - PageManagers[uiDev] = pm; - CurrentSourcePageManager = pm; - pm.Show(); - } - } - - /// - /// Called from button presses on source, where We can assume we want - /// to change to the proper screen. - /// - /// The key name of the route to run - void UiSelectSource(string key) - { - // Run the route and when it calls back, show the source - CurrentRoom.RunRouteAction(key); - } - - /// - /// - /// - public void EndMeetingPress() - { - if (!CurrentRoom.OnFeedback.BoolValue - || CurrentRoom.ShutdownPromptTimer.IsRunningFeedback.BoolValue) - return; - - CurrentRoom.StartShutdown(eShutdownType.Manual); - } - - /// - /// Puts away modals and things that might be up when call comes in - /// - public void PrepareForCodecIncomingCall() - { - if (PowerDownModal != null && PowerDownModal.ModalIsVisible) - PowerDownModal.CancelDialog(); - PopupInterlock.Hide(); - } - - /// - /// - /// - /// - /// - void ShutdownPromptTimer_HasStarted(object sender, EventArgs e) - { - // Do we need to check where the UI is? No? - var timer = CurrentRoom.ShutdownPromptTimer; - SetActivityFooterFeedbacks(); - - if (CurrentRoom.ShutdownType == eShutdownType.Manual || CurrentRoom.ShutdownType == eShutdownType.Vacancy) - { - PowerDownModal = new ModalDialog(TriList); - var message = string.Format("Meeting will end in {0} seconds", CurrentRoom.ShutdownPromptSeconds); - - // Attach timer things to modal - CurrentRoom.ShutdownPromptTimer.TimeRemainingFeedback.OutputChange += ShutdownPromptTimer_TimeRemainingFeedback_OutputChange; - CurrentRoom.ShutdownPromptTimer.PercentFeedback.OutputChange += ShutdownPromptTimer_PercentFeedback_OutputChange; - - // respond to offs by cancelling dialog - var onFb = CurrentRoom.OnFeedback; - EventHandler offHandler = null; - offHandler = (o, a) => - { - if (!onFb.BoolValue) - { - PowerDownModal.HideDialog(); - SetActivityFooterFeedbacks(); - onFb.OutputChange -= offHandler; - } - }; - onFb.OutputChange += offHandler; - - PowerDownModal.PresentModalDialog(2, "End Meeting", "Power", message, "Cancel", "End Meeting Now", true, true, - but => - { - if (but != 2) // any button except for End cancels - timer.Cancel(); - else - timer.Finish(); - }); - } - } - - /// - /// - /// - /// - /// - void ShutdownPromptTimer_HasFinished(object sender, EventArgs e) - { - SetActivityFooterFeedbacks(); - CurrentRoom.ShutdownPromptTimer.TimeRemainingFeedback.OutputChange -= ShutdownPromptTimer_TimeRemainingFeedback_OutputChange; - CurrentRoom.ShutdownPromptTimer.PercentFeedback.OutputChange -= ShutdownPromptTimer_PercentFeedback_OutputChange; - } - - /// - /// - /// - /// - /// - void ShutdownPromptTimer_WasCancelled(object sender, EventArgs e) - { - if (PowerDownModal != null) - PowerDownModal.HideDialog(); - SetActivityFooterFeedbacks(); - - CurrentRoom.ShutdownPromptTimer.TimeRemainingFeedback.OutputChange += ShutdownPromptTimer_TimeRemainingFeedback_OutputChange; - CurrentRoom.ShutdownPromptTimer.PercentFeedback.OutputChange -= ShutdownPromptTimer_PercentFeedback_OutputChange; - } - - /// - /// Event handler for countdown timer on power off modal - /// - void ShutdownPromptTimer_TimeRemainingFeedback_OutputChange(object sender, EventArgs e) - { - - var message = string.Format("Meeting will end in {0} seconds", (sender as StringFeedback).StringValue); - TriList.StringInput[ModalDialog.MessageTextJoin].StringValue = message; - } - - /// - /// Event handler for percentage on power off countdown - /// - void ShutdownPromptTimer_PercentFeedback_OutputChange(object sender, EventArgs e) - { - var value = (ushort)((sender as IntFeedback).UShortValue * 65535 / 100); - TriList.UShortInput[ModalDialog.TimerGaugeJoin].UShortValue = value; - } - - /// - /// - /// - void CancelPowerOffTimer() - { - if (PowerOffTimer != null) - { - PowerOffTimer.Stop(); - PowerOffTimer = null; - } - } - - /// - /// - /// - /// - public void VolumeUpPress(bool state) - { - if (CurrentRoom.CurrentVolumeControls != null) - CurrentRoom.CurrentVolumeControls.VolumeUp(state); - } - - /// - /// - /// - /// - public void VolumeDownPress(bool state) - { - if (CurrentRoom.CurrentVolumeControls != null) - CurrentRoom.CurrentVolumeControls.VolumeDown(state); - } - - /// - /// Helper for property setter. Sets the panel to the given room, latching up all functionality - /// - void RefreshCurrentRoom(IEssentialsHuddleVtc1Room room) - { - - if (_CurrentRoom != null) - { - // Disconnect current room - _CurrentRoom.CurrentVolumeDeviceChange -= this.CurrentRoom_CurrentAudioDeviceChange; - ClearAudioDeviceConnections(); - _CurrentRoom.CurrentSourceChange -= this.CurrentRoom_SourceInfoChange; - DisconnectSource(_CurrentRoom.CurrentSourceInfo); - _CurrentRoom.ShutdownPromptTimer.HasStarted -= ShutdownPromptTimer_HasStarted; - _CurrentRoom.ShutdownPromptTimer.HasFinished -= ShutdownPromptTimer_HasFinished; - _CurrentRoom.ShutdownPromptTimer.WasCancelled -= ShutdownPromptTimer_WasCancelled; - - _CurrentRoom.OnFeedback.OutputChange -= CurrentRoom_OnFeedback_OutputChange; - _CurrentRoom.IsWarmingUpFeedback.OutputChange -= CurrentRoom_IsWarmingFeedback_OutputChange; - _CurrentRoom.IsCoolingDownFeedback.OutputChange -= CurrentRoom_IsCoolingDownFeedback_OutputChange; - _CurrentRoom.InCallFeedback.OutputChange -= CurrentRoom_InCallFeedback_OutputChange; - - var scheduleAwareCodec = _CurrentRoom.VideoCodec as IHasScheduleAwareness; - if (scheduleAwareCodec != null) - { - scheduleAwareCodec.CodecSchedule.MeetingsListHasChanged -= CodecSchedule_MeetingsListHasChanged; - } - - var meetingInfoCodec = _CurrentRoom.VideoCodec as IHasMeetingInfo; - if (meetingInfoCodec != null) - { - meetingInfoCodec.MeetingInfoChanged -= meetingInfoCodec_MeetingInfoChanged; - } - } - - _CurrentRoom = room; - - if (_CurrentRoom != null) - { - // get the source list config and set up the source list - - SetupSourceList(); - - // Name and logo - TriList.StringInput[UIStringJoin.CurrentRoomName].StringValue = _CurrentRoom.Name; - ShowLogo(); - - // Shutdown timer - _CurrentRoom.ShutdownPromptTimer.HasStarted += ShutdownPromptTimer_HasStarted; - _CurrentRoom.ShutdownPromptTimer.HasFinished += ShutdownPromptTimer_HasFinished; - _CurrentRoom.ShutdownPromptTimer.WasCancelled += ShutdownPromptTimer_WasCancelled; - - // Link up all the change events from the room - _CurrentRoom.OnFeedback.OutputChange += CurrentRoom_OnFeedback_OutputChange; - CurrentRoom_SyncOnFeedback(); - _CurrentRoom.IsWarmingUpFeedback.OutputChange += CurrentRoom_IsWarmingFeedback_OutputChange; - _CurrentRoom.IsCoolingDownFeedback.OutputChange += CurrentRoom_IsCoolingDownFeedback_OutputChange; - _CurrentRoom.InCallFeedback.OutputChange += CurrentRoom_InCallFeedback_OutputChange; - - - _CurrentRoom.CurrentVolumeDeviceChange += CurrentRoom_CurrentAudioDeviceChange; - RefreshAudioDeviceConnections(); - _CurrentRoom.CurrentSourceChange += CurrentRoom_SourceInfoChange; - RefreshSourceInfo(); - - - var scheduleAwareCodec = _CurrentRoom.VideoCodec as IHasScheduleAwareness; - if (scheduleAwareCodec != null) - { - scheduleAwareCodec.CodecSchedule.MeetingsListHasChanged += CodecSchedule_MeetingsListHasChanged; - } - - var meetingInfoCodec = _CurrentRoom.VideoCodec as IHasMeetingInfo; - if (meetingInfoCodec != null) - { - meetingInfoCodec.MeetingInfoChanged += new EventHandler(meetingInfoCodec_MeetingInfoChanged); - - CallListOrMeetingInfoPopoverVisibilityJoin = UIBoolJoin.HeaderMeetingInfoVisible; - } - else - { - CallListOrMeetingInfoPopoverVisibilityJoin = UIBoolJoin.HeaderActiveCallsListVisible; - } - - CallSharingInfoVisibleFeedback = new BoolFeedback(() => _CurrentRoom.VideoCodec.SharingContentIsOnFeedback.BoolValue); - _CurrentRoom.VideoCodec.SharingContentIsOnFeedback.OutputChange += SharingContentIsOnFeedback_OutputChange; - CallSharingInfoVisibleFeedback.LinkInputSig(TriList.BooleanInput[UIBoolJoin.CallSharedSourceInfoVisible]); - - SetActiveCallListSharingContentStatus(); - - if (_CurrentRoom != null) - _CurrentRoom.CurrentSourceChange += new SourceInfoChangeHandler(CurrentRoom_CurrentSingleSourceChange); - - // Moved to EssentialsVideoCodecUiDriver - //TriList.SetSigFalseAction(UIBoolJoin.CallStopSharingPress, () => _CurrentRoom.RunRouteAction("codecOsd", _CurrentRoom.SourceListKey)); - - (Parent as EssentialsPanelMainInterfaceDriver).HeaderDriver.SetupHeaderButtons(this, CurrentRoom); - } - else - { - // Clear sigs that need to be - TriList.StringInput[UIStringJoin.CurrentRoomName].StringValue = "Select a room"; - } - } - - void meetingInfoCodec_MeetingInfoChanged(object sender, MeetingInfoEventArgs e) - { - if (e.Info == null) - { - return; - } - - TriList.SetString(UIStringJoin.MeetingIdText, e.Info.Id); - TriList.SetString(UIStringJoin.MeetingHostText, e.Info.Host); - TriList.SetString(UIStringJoin.MeetingNameText, e.Info.Name); - - TriList.SetString(UIStringJoin.MeetingPasswordText, e.Info.Password); - // Show the password fields if one is present - TriList.SetBool(UIBoolJoin.MeetingPasswordVisible, !string.IsNullOrEmpty(e.Info.Password)); - - TriList.SetString(UIStringJoin.CallSharedSourceNameText, e.Info.ShareStatus); - - TriList.SetString(UIStringJoin.MeetingLeaveText, e.Info.IsHost ? "End Meeting" : "Leave Meeting"); - } - - void SetCurrentRoom(IEssentialsHuddleVtc1Room room) - { - if (_CurrentRoom == room) return; - // Disconnect current (probably never called) - - if(_CurrentRoom != null) - _CurrentRoom.ConfigChanged -= room_ConfigChanged; - - room.ConfigChanged -= room_ConfigChanged; - room.ConfigChanged += room_ConfigChanged; - - if (room.IsMobileControlEnabled) - { - StartPageVisibleJoin = UIBoolJoin.StartMCPageVisible; - UpdateMCJoins(room); - - if (_CurrentRoom != null) - _CurrentRoom.MobileControlRoomBridge.UserCodeChanged -= MobileControlRoomBridge_UserCodeChanged; - - room.MobileControlRoomBridge.UserCodeChanged -= MobileControlRoomBridge_UserCodeChanged; - room.MobileControlRoomBridge.UserCodeChanged += MobileControlRoomBridge_UserCodeChanged; - } - else - { - StartPageVisibleJoin = UIBoolJoin.StartPageVisible; - } - - RefreshCurrentRoom(room); - } - - void MobileControlRoomBridge_UserCodeChanged(object sender, EventArgs e) - { - UpdateMCJoins(_CurrentRoom); - } - - void UpdateMCJoins(IEssentialsHuddleVtc1Room room) - { - TriList.SetString(UIStringJoin.RoomMcUrl, room.MobileControlRoomBridge.McServerUrl); - TriList.SetString(UIStringJoin.RoomMcQrCodeUrl, room.MobileControlRoomBridge.QrCodeUrl); - TriList.SetString(UIStringJoin.RoomUserCode, room.MobileControlRoomBridge.UserCode); - } - - /// - /// Fires when room config of current room has changed. Meant to refresh room values to propegate any updates to UI - /// - /// - /// - void room_ConfigChanged(object sender, EventArgs e) - { - RefreshCurrentRoom(_CurrentRoom); - } - - /// - /// - /// - /// - /// - void CurrentRoom_InCallFeedback_OutputChange(object sender, EventArgs e) - { - var inCall = CurrentRoom.InCallFeedback.BoolValue; - if (inCall) - { - // Check if transitioning to in call - and non-sharable source is in use - if (CurrentRoom.CurrentSourceInfo != null && CurrentRoom.CurrentSourceInfo.DisableCodecSharing) - { - Debug.Console(1, CurrentRoom, "Transitioning to in-call, cancelling non-sharable source"); - CurrentRoom.RunRouteAction("codecOsd"); - } - } - - SetupSourceList(); - } - - /// - /// - /// - void SetupSourceList() - { - - var inCall = CurrentRoom.InCallFeedback.BoolValue; - var config = ConfigReader.ConfigObject.SourceLists; - - - if (config.ContainsKey(_CurrentRoom.SourceListKey)) - { - var srcList = config[_CurrentRoom.SourceListKey].OrderBy(kv => kv.Value.Order); - - - // Setup sources list - SourceStagingSrl.Clear(); - uint i = 1; // counter for UI list - foreach (var kvp in srcList) - { - var srcConfig = kvp.Value; - Debug.Console(1, "**** {0}, {1}, {2}, {3}, {4}", srcConfig.PreferredName, srcConfig.IncludeInSourceList, - srcConfig.DisableCodecSharing, inCall, this.CurrentMode); - // Skip sources marked as not included, and filter list of non-sharable sources when in call - // or on share screen - if (!srcConfig.IncludeInSourceList || (inCall && srcConfig.DisableCodecSharing) - || this.CurrentMode == UiDisplayMode.Call && srcConfig.DisableCodecSharing) - { - Debug.Console(1, "Skipping {0}", srcConfig.PreferredName); - continue; - } - - var routeKey = kvp.Key; - var item = new SubpageReferenceListSourceItem(i++, SourceStagingSrl, srcConfig, - b => { if (!b) UiSelectSource(routeKey); }); - SourceStagingSrl.AddItem(item); // add to the SRL - item.RegisterForSourceChange(_CurrentRoom); - Debug.Console(1, "**** KEY {0}", kvp.Key); - - } - _sourceListCount = (i - 1); - SourceStagingSrl.Count = (ushort)_sourceListCount; - } - - } - - /// - /// If the schedule changes, this event will fire - /// - /// - /// - void CodecSchedule_MeetingsListHasChanged(object sender, EventArgs e) - { - RefreshMeetingsList(); - } - - /// - /// Updates the current shared source label on the call list when the source changes - /// - /// - /// - /// - void CurrentRoom_CurrentSingleSourceChange(SourceListItem info, ChangeType type) - { - Debug.Console(1, "AvFunctionsDriver: CurrentSingleSourceChange"); - - // Show the Select a source subpage - if (TriList.BooleanInput[UIBoolJoin.SourceStagingBarVisible].BoolValue) - { - Debug.Console(1, "AvFunctionsDriver: CurrentSingleSourceChange SourceStagingBarVisisble: true"); - - if (_CurrentRoom.CurrentSourceInfo == null || (_CurrentRoom.VideoCodec != null && _CurrentRoom.CurrentSourceInfo.SourceDevice.Key == _CurrentRoom.VideoCodec.OsdSource.Key)) - { - Debug.Console(1, "AvFunctionsDriver: CurrentSingleSourceChange Showing SelectASourceVisible"); - TriList.SetBool(UIBoolJoin.SelectASourceVisible, true); - } - else - { - TriList.SetBool(UIBoolJoin.SelectASourceVisible, false); - Debug.Console(1, "AvFunctionsDriver: CurrentSingleSourceChange Hiding SelectASourceVisible"); - } - } - else - { - Debug.Console(1, "AvFunctionsDriver: CurrentSingleSourceChange Hiding SelectASourceVisible"); - TriList.SetBool(UIBoolJoin.SelectASourceVisible, false); - } - - if (_CurrentRoom.VideoCodec.SharingContentIsOnFeedback.BoolValue && _CurrentRoom.CurrentSourceInfo != null) - TriList.StringInput[UIStringJoin.CallSharedSourceNameText].StringValue = _CurrentRoom.CurrentSourceInfo.PreferredName; - } - - /// - /// Fires when the sharing source feedback of the codec changes - /// - /// - /// - void SharingContentIsOnFeedback_OutputChange(object sender, EventArgs e) - { - SetActiveCallListSharingContentStatus(); - } - - /// - /// Sets the values for the text and button visibilty for the active call list source sharing info - /// - void SetActiveCallListSharingContentStatus() - { - CallSharingInfoVisibleFeedback.FireUpdate(); - - string callListSharedSourceLabel; - - if (_CurrentRoom.VideoCodec.SharingContentIsOnFeedback.BoolValue && _CurrentRoom.CurrentSourceInfo != null) - { - Debug.Console(0, "*#* CurrentRoom.CurrentSourceInfo = {0}", - _CurrentRoom.CurrentSourceInfo != null ? _CurrentRoom.CurrentSourceInfo.SourceKey : "Nada!"); - callListSharedSourceLabel = _CurrentRoom.CurrentSourceInfo.PreferredName; - } - else - callListSharedSourceLabel = "None"; - - TriList.StringInput[UIStringJoin.CallSharedSourceNameText].StringValue = callListSharedSourceLabel; - } - - /// - /// - /// - void RefreshMeetingsList() - { - // See if this is helpful or if the callback response in the codec class maybe doesn't come it time? - // Let's build list from event - - TriList.SetString(UIStringJoin.MeetingsOrContactMethodListIcon, "Calendar"); - TriList.SetString(UIStringJoin.MeetingsOrContactMethodListTitleText, "Today's Meetings"); - - ushort i = 0; - foreach (var m in CurrentRoom.ScheduleSource.CodecSchedule.Meetings) - { - i++; - MeetingOrContactMethodModalSrl.StringInputSig(i, 1).StringValue = m.StartTime.ToString("t", Global.Culture); - MeetingOrContactMethodModalSrl.StringInputSig(i, 2).StringValue = m.EndTime.ToString("t", Global.Culture); - MeetingOrContactMethodModalSrl.StringInputSig(i, 3).StringValue = m.Title; - MeetingOrContactMethodModalSrl.StringInputSig(i, 4).StringValue = string.Format("
{0}",m.Organizer); - MeetingOrContactMethodModalSrl.StringInputSig(i, 5).StringValue = "Join"; - MeetingOrContactMethodModalSrl.BoolInputSig(i, 2).BoolValue = m.Joinable; - var mm = m; // lambda scope - MeetingOrContactMethodModalSrl.GetBoolFeedbackSig(i, 1).SetSigFalseAction(() => - { - PopupInterlock.Hide(); - ActivityCallButtonPressed(); - var d = CurrentRoom.ScheduleSource as VideoCodecBase; - if (d != null) - RoomOnAndDialMeeting(mm); - }); - } - MeetingOrContactMethodModalSrl.Count = i; - - if (i == 0) // Show item indicating no meetings are booked for rest of day - { - MeetingOrContactMethodModalSrl.Count = 1; - - MeetingOrContactMethodModalSrl.StringInputSig(1, 1).StringValue = string.Empty; - MeetingOrContactMethodModalSrl.StringInputSig(1, 2).StringValue = string.Empty; - MeetingOrContactMethodModalSrl.StringInputSig(1, 3).StringValue = "No Meetings are booked for the remainder of the day."; - MeetingOrContactMethodModalSrl.StringInputSig(1, 4).StringValue = string.Empty; - MeetingOrContactMethodModalSrl.StringInputSig(1, 5).StringValue = string.Empty; - } - } - - /// - /// For room on/off changes - /// - void CurrentRoom_OnFeedback_OutputChange(object sender, EventArgs e) - { - CurrentRoom_SyncOnFeedback(); - } - - /// - /// - /// - void CurrentRoom_SyncOnFeedback() - { - var value = _CurrentRoom.OnFeedback.BoolValue; - TriList.BooleanInput[UIBoolJoin.RoomIsOn].BoolValue = value; - - //TriList.BooleanInput[StartPageVisibleJoin].BoolValue = !value; - - if (value) //ON - { - SetupActivityFooterWhenRoomOn(); - //TriList.BooleanInput[UIBoolJoin.SelectASourceVisible].BoolValue = false; - TriList.BooleanInput[UIBoolJoin.VolumeDualMute1Visible].BoolValue = true; - - } - else - { - CurrentMode = UiDisplayMode.Start; - if (VCDriver.IsVisible) - VCDriver.Hide(); - SetupActivityFooterWhenRoomOff(); - ShowLogo(); - //TriList.BooleanInput[UIBoolJoin.VolumeDualMute1Visible].BoolValue = false; - //TriList.BooleanInput[UIBoolJoin.SourceStagingBarVisible].BoolValue = false; - // Clear this so that the pesky meeting warning can resurface every minute when off - LastMeetingDismissedId = null; - } - } - - /// - /// - /// - void CurrentRoom_IsWarmingFeedback_OutputChange(object sender, EventArgs e) - { - if (CurrentRoom.IsWarmingUpFeedback.BoolValue) - { - ShowNotificationRibbon("Room is powering on. Please wait...", 0); - } - else - { - ShowNotificationRibbon("Room is powered on. Welcome.", 2000); - } - } - - /// - /// - /// - /// - /// - void CurrentRoom_IsCoolingDownFeedback_OutputChange(object sender, EventArgs e) - { - if (CurrentRoom.IsCoolingDownFeedback.BoolValue) - { - ShowNotificationRibbon("Room is powering off. Please wait.", 0); - } - else - { - HideNotificationRibbon(); - } - } - - /// - /// Hides source for provided source info - /// - /// - void DisconnectSource(SourceListItem previousInfo) - { - if (previousInfo == null) return; - - // Hide whatever is showing - if (IsVisible) - { - if (CurrentSourcePageManager != null) - { - CurrentSourcePageManager.Hide(); - CurrentSourcePageManager = null; - } - } - - if (previousInfo == null) return; - var previousDev = previousInfo.SourceDevice; - - // device type interfaces - if (previousDev is ISetTopBoxControls) - (previousDev as ISetTopBoxControls).UnlinkButtons(TriList); - // common interfaces - if (previousDev is IChannel) - (previousDev as IChannel).UnlinkButtons(TriList); - if (previousDev is IColor) - (previousDev as IColor).UnlinkButtons(TriList); - if (previousDev is IDPad) - (previousDev as IDPad).UnlinkButtons(TriList); - if (previousDev is IDvr) - (previousDev as IDvr).UnlinkButtons(TriList); - if (previousDev is INumericKeypad) - (previousDev as INumericKeypad).UnlinkButtons(TriList); - if (previousDev is IHasPowerControl) - (previousDev as IHasPowerControl).UnlinkButtons(TriList); - if (previousDev is ITransport) - (previousDev as ITransport).UnlinkButtons(TriList); - } - - /// - /// Refreshes and shows the room's current source - /// - void RefreshSourceInfo() - { - var routeInfo = CurrentRoom.CurrentSourceInfo; - // This will show off popup too - if (this.IsVisible && !VCDriver.IsVisible) - ShowCurrentSource(); - - if (routeInfo == null)// || !CurrentRoom.OnFeedback.BoolValue) - { - // Check for power off and insert "Room is off" - TriList.StringInput[UIStringJoin.CurrentSourceName].StringValue = "Room is off"; - TriList.StringInput[UIStringJoin.CurrentSourceIcon].StringValue = "Power"; - this.Hide(); - Parent.Show(); - return; - } - else if (routeInfo != null) - { - TriList.StringInput[UIStringJoin.CurrentSourceName].StringValue = routeInfo.PreferredName; - TriList.StringInput[UIStringJoin.CurrentSourceIcon].StringValue = routeInfo.Icon; // defaults to "blank" - } - else // This never gets hit???!!! - { - TriList.StringInput[UIStringJoin.CurrentSourceName].StringValue = "---"; - TriList.StringInput[UIStringJoin.CurrentSourceIcon].StringValue = "Blank"; - } - - // Connect controls - if (routeInfo.SourceDevice != null) - ConnectControlDeviceMethods(routeInfo.SourceDevice); - } - - /// - /// Attach the source to the buttons and things - /// - void ConnectControlDeviceMethods(Device dev) - { - if (dev is ISetTopBoxControls) - (dev as ISetTopBoxControls).LinkButtons(TriList); - if (dev is IChannel) - (dev as IChannel).LinkButtons(TriList); - if (dev is IColor) - (dev as IColor).LinkButtons(TriList); - if (dev is IDPad) - (dev as IDPad).LinkButtons(TriList); - if (dev is IDvr) - (dev as IDvr).LinkButtons(TriList); - if (dev is INumericKeypad) - (dev as INumericKeypad).LinkButtons(TriList); - if (dev is IHasPowerControl) - (dev as IHasPowerControl).LinkButtons(TriList); - if (dev is ITransport) - (dev as ITransport).LinkButtons(TriList); - } - - /// - /// Detaches the buttons and feedback from the room's current audio device - /// - void ClearAudioDeviceConnections() - { - TriList.ClearBoolSigAction(UIBoolJoin.VolumeUpPress); - TriList.ClearBoolSigAction(UIBoolJoin.VolumeDownPress); - TriList.ClearBoolSigAction(UIBoolJoin.Volume1ProgramMutePressAndFB); - - var fDev = CurrentRoom.CurrentVolumeControls as IBasicVolumeWithFeedback; - if (fDev != null) - { - TriList.ClearUShortSigAction(UIUshortJoin.VolumeSlider1Value); - fDev.VolumeLevelFeedback.UnlinkInputSig( - TriList.UShortInput[UIUshortJoin.VolumeSlider1Value]); - } - } - - /// - /// Attaches the buttons and feedback to the room's current audio device - /// - void RefreshAudioDeviceConnections() - { - var dev = CurrentRoom.CurrentVolumeControls; - if (dev != null) // connect buttons - { - TriList.SetBoolSigAction(UIBoolJoin.VolumeUpPress, VolumeUpPress); - TriList.SetBoolSigAction(UIBoolJoin.VolumeDownPress, VolumeDownPress); - TriList.SetSigFalseAction(UIBoolJoin.Volume1ProgramMutePressAndFB, dev.MuteToggle); - } - - var fbDev = dev as IBasicVolumeWithFeedback; - if (fbDev == null) // this should catch both IBasicVolume and IBasicVolumeWithFeeback - TriList.UShortInput[UIUshortJoin.VolumeSlider1Value].UShortValue = 0; - else - { - // slider - TriList.SetUShortSigAction(UIUshortJoin.VolumeSlider1Value, fbDev.SetVolume); - // feedbacks - fbDev.MuteFeedback.LinkInputSig(TriList.BooleanInput[UIBoolJoin.Volume1ProgramMutePressAndFB]); - fbDev.VolumeLevelFeedback.LinkInputSig( - TriList.UShortInput[UIUshortJoin.VolumeSlider1Value]); - } - } - - /// - /// Handler for when the room's volume control device changes - /// - void CurrentRoom_CurrentAudioDeviceChange(object sender, VolumeDeviceChangeEventArgs args) - { - if (args.Type == ChangeType.WillChange) - ClearAudioDeviceConnections(); - else // did change - RefreshAudioDeviceConnections(); - } - - /// - /// Handles source change - /// - void CurrentRoom_SourceInfoChange(SourceListItem info, ChangeType change) - { - if (change == ChangeType.WillChange) - DisconnectSource(info); - else - RefreshSourceInfo(); - } - } - - /// - /// For hanging off various common AV things that child drivers might need from a parent AV driver - /// - public interface IAVDriver - { - PanelDriverBase Parent { get; } - JoinedSigInterlock PopupInterlock { get; } - void ShowNotificationRibbon(string message, int timeout); - void HideNotificationRibbon(); - void ShowTech(); - uint StartPageVisibleJoin { get; } - } - - /// - /// For hanging off various common VC things that child drivers might need from a parent AV driver - /// - public interface IAVWithVCDriver : IAVDriver - { - IEssentialsHuddleVtc1Room CurrentRoom { get; } - - PepperDash.Essentials.Core.Touchpanels.Keyboards.HabaneroKeyboardController Keyboard { get; } - /// - /// Exposes the ability to switch into call mode - /// - void ActivityCallButtonPressed(); - /// - /// Allows the codec to trigger the main UI to clear up if call is coming in. - /// - void PrepareForCodecIncomingCall(); - - uint CallListOrMeetingInfoPopoverVisibilityJoin { get; } - - SubpageReferenceList MeetingOrContactMethodModalSrl { get; } - } -} +using System; +using System.Linq; +using System.Collections.Generic; +using System.Globalization; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.UI; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.Core.DeviceTypeInterfaces; +using PepperDash.Essentials.Core.SmartObjects; +using PepperDash.Essentials.Core.PageManagers; +using PepperDash.Essentials.Room.Config; +using PepperDash.Essentials.Devices.Common.Codec; +using PepperDash.Essentials.Devices.Common.VideoCodec; +using PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces; + +namespace PepperDash.Essentials +{ + /// + /// + /// + public class EssentialsHuddleVtc1PanelAvFunctionsDriver : PanelDriverBase, IAVWithVCDriver + { + CrestronTouchpanelPropertiesConfig Config; + + public enum UiDisplayMode + { + Presentation, AudioSetup, Call, Start + } + + public uint StartPageVisibleJoin { get; private set; } + + /// + /// Whether volume ramping from this panel will show the volume + /// gauge popup. + /// + public bool ShowVolumeGauge { get; set; } + + /// + /// + /// + public uint PowerOffTimeout { get; set; } + + /// + /// + /// + public string DefaultRoomKey { get; set; } + + + /// + /// + /// + public IEssentialsHuddleVtc1Room CurrentRoom + { + get { return _CurrentRoom; } + set + { + SetCurrentRoom(value); + } + } + IEssentialsHuddleVtc1Room _CurrentRoom; + + /// + /// For hitting feedbacks + /// + BoolInputSig CallButtonSig; + BoolInputSig ShareButtonSig; + BoolInputSig EndMeetingButtonSig; + + BoolFeedback CallSharingInfoVisibleFeedback; + + /// + /// The parent driver for this + /// + public PanelDriverBase Parent { get; private set; } + + /// + /// All children attached to this driver. For hiding and showing as a group. + /// + List ChildDrivers = new List(); + + List CurrentDisplayModeSigsInUse = new List(); + + //// Important smart objects + + /// + /// Smart Object 3200 + /// + SubpageReferenceList SourceStagingSrl; + + /// + /// Smart Object 15022 + /// + SubpageReferenceList ActivityFooterSrl; + + /// + /// + /// + public SubpageReferenceList MeetingOrContactMethodModalSrl { get; set; } + + public uint CallListOrMeetingInfoPopoverVisibilityJoin { get; private set; } + + + /// + /// The list of buttons on the header. Managed with visibility only + /// + //SmartObjectHeaderButtonList HeaderButtonsList; + + /// + /// The AV page mangagers that have been used, to keep them alive for later + /// + Dictionary PageManagers = new Dictionary(); + + /// + /// Current page manager running for a source + /// + PageManager CurrentSourcePageManager; + + /// + /// Will auto-timeout a power off + /// + CTimer PowerOffTimer; + + /// + /// + /// + ModalDialog PowerDownModal; + + /// + /// + /// + //ModalDialog WarmingCoolingModal; + + /// + /// Represents + /// + public JoinedSigInterlock PopupInterlock { get; private set; } + + /// + /// Interlock for various source, camera, call control bars. The bar above the activity footer. This is also + /// used to show start page + /// + JoinedSigInterlock StagingBarInterlock; + + /// + /// Interlocks the various call-related subpages + /// + JoinedSigInterlock CallPagesInterlock; + + /// + /// The Video codec driver + /// + PepperDash.Essentials.UIDrivers.VC.EssentialsVideoCodecUiDriver VCDriver; + + /// + /// The driver for the tech page. Lazy getter for memory usage + /// + PepperDash.Essentials.UIDrivers.EssentialsHuddleTechPageDriver TechDriver + { + get + { + if (_TechDriver == null) + _TechDriver = new PepperDash.Essentials.UIDrivers.EssentialsHuddleTechPageDriver(TriList, CurrentRoom.PropertiesConfig.Tech); + return _TechDriver; + } + } + PepperDash.Essentials.UIDrivers.EssentialsHuddleTechPageDriver _TechDriver; + + /// + /// Controls timeout of notification ribbon timer + /// + CTimer RibbonTimer; + + /// + /// The keyboard + /// + public PepperDash.Essentials.Core.Touchpanels.Keyboards.HabaneroKeyboardController Keyboard { get; private set; } + + + private UiDisplayMode _currentMode; + + private bool _isZoomRoomWithNoExternalSources + { + get + { + return CurrentRoom.VideoCodec is Essentials.Devices.Common.VideoCodec.ZoomRoom.ZoomRoom && _sourceListCount <= 1; + } + } + + private uint _sourceListCount; + + /// + /// The mode showing. Presentation or call. + /// + UiDisplayMode CurrentMode + { + get + { + return _currentMode; + } + set + { + if (value != _currentMode) + { + _currentMode = value; + + SetActivityFooterFeedbacks(); + } + } + } + + CTimer NextMeetingTimer; + + /// + /// Tracks the last meeting that was cancelled + /// + string LastMeetingDismissedId; + + /// + /// Constructor + /// + public EssentialsHuddleVtc1PanelAvFunctionsDriver(PanelDriverBase parent, CrestronTouchpanelPropertiesConfig config) + : base(parent.TriList) + { + Config = config; + Parent = parent; + + PopupInterlock = new JoinedSigInterlock(TriList); + StagingBarInterlock = new JoinedSigInterlock(TriList); + CallPagesInterlock = new JoinedSigInterlock(TriList); + + SourceStagingSrl = new SubpageReferenceList(TriList, UISmartObjectJoin.SourceStagingSRL, 3, 3, 3); + + ActivityFooterSrl = new SubpageReferenceList(TriList, UISmartObjectJoin.ActivityFooterSRL, 3, 3, 3); + CallButtonSig = ActivityFooterSrl.BoolInputSig(2, 1); + ShareButtonSig = ActivityFooterSrl.BoolInputSig(1, 1); + EndMeetingButtonSig = ActivityFooterSrl.BoolInputSig(3, 1); + + MeetingOrContactMethodModalSrl = new SubpageReferenceList(TriList, UISmartObjectJoin.MeetingListSRL, 3, 3, 5); + + CurrentMode = UiDisplayMode.Start; + + // buttons are added in SetCurrentRoom + //HeaderButtonsList = new SmartObjectHeaderButtonList(TriList.SmartObjects[UISmartObjectJoin.HeaderButtonList]); + + SetupActivityFooterWhenRoomOff(); + + ShowVolumeGauge = true; + Keyboard = new PepperDash.Essentials.Core.Touchpanels.Keyboards.HabaneroKeyboardController(TriList); + } + + /// + /// Add a video codec driver to this + /// + /// + public void SetVideoCodecDriver(PepperDash.Essentials.UIDrivers.VC.EssentialsVideoCodecUiDriver vcd) + { + VCDriver = vcd; + } + + /// + /// + /// + public override void Show() + { + if (CurrentRoom == null) + { + Debug.Console(1, "ERROR: AVUIFunctionsDriver, Cannot show. No room assigned"); + return; + } + + var roomConf = CurrentRoom.PropertiesConfig; + + if (Config.HeaderStyle.ToLower() == CrestronTouchpanelPropertiesConfig.Habanero) + { + TriList.SetSigFalseAction(UIBoolJoin.HeaderRoomButtonPress, () => + { + if (CurrentRoom.IsMobileControlEnabled) + { + Debug.Console(1, "Showing Mobile Control Header Info"); + PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.RoomHeaderInfoMCPageVisible); + } + else + { + Debug.Console(1, "Showing Non Mobile Control Header Info"); + PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.RoomHeaderInfoPageVisible); + } + }); + } + else if (Config.HeaderStyle.ToLower() == CrestronTouchpanelPropertiesConfig.Verbose) + { + TriList.SetSigFalseAction(UIBoolJoin.HeaderRoomButtonPress, () => + { + if (CurrentRoom.IsMobileControlEnabled) + { + Debug.Console(1, "Showing Mobile Control Header Info"); + PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.RoomHeaderInfoMCPageVisible); + } + else + { + Debug.Console(1, "Showing Non Mobile Control Header Info"); + PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.RoomHeaderInfoPageVisible); + } + }); + } + + TriList.SetBool(UIBoolJoin.DateAndTimeVisible, Config.ShowDate && Config.ShowTime); + TriList.SetBool(UIBoolJoin.DateOnlyVisible, Config.ShowDate && !Config.ShowTime); + TriList.SetBool(UIBoolJoin.TimeOnlyVisible, !Config.ShowDate && Config.ShowTime); + + TriList.SetBool(UIBoolJoin.TopBarHabaneroDynamicVisible, true); + + TriList.SetBool(UIBoolJoin.ActivityFooterVisible, true); + + // Privacy mute button + TriList.SetSigFalseAction(UIBoolJoin.Volume1SpeechMutePressAndFB, CurrentRoom.PrivacyModeToggle); + CurrentRoom.PrivacyModeIsOnFeedback.LinkInputSig(TriList.BooleanInput[UIBoolJoin.Volume1SpeechMutePressAndFB]); + + // Default to showing rooms/sources now. + if (CurrentRoom.OnFeedback.BoolValue) + { + TriList.SetBool(UIBoolJoin.TapToBeginVisible, false); + SetupActivityFooterWhenRoomOn(); + } + else + { + TriList.SetBool(StartPageVisibleJoin, true); + TriList.SetBool(UIBoolJoin.TapToBeginVisible, true); + SetupActivityFooterWhenRoomOff(); + } + ShowCurrentDisplayModeSigsInUse(); + + // *** Header Buttons *** + + // Generic "close" button for popup modals + TriList.SetSigFalseAction(UIBoolJoin.InterlockedModalClosePress, PopupInterlock.HideAndClear); + + // Volume related things + TriList.SetSigFalseAction(UIBoolJoin.VolumeDefaultPress, () => CurrentRoom.SetDefaultLevels()); + TriList.SetString(UIStringJoin.AdvancedVolumeSlider1Text, "Room"); + + //if (TriList is CrestronApp) + // TriList.BooleanInput[UIBoolJoin.GearButtonVisible].BoolValue = false; + //else + // TriList.BooleanInput[UIBoolJoin.GearButtonVisible].BoolValue = true; + + // power-related functions + // Note: some of these are not directly-related to the huddle space UI, but are held over + // in case + TriList.SetSigFalseAction(UIBoolJoin.ShowPowerOffPress, EndMeetingPress); + + TriList.SetSigFalseAction(UIBoolJoin.DisplayPowerTogglePress, () => + { + if (CurrentRoom != null && CurrentRoom.DefaultDisplay != null && CurrentRoom.DefaultDisplay is IHasPowerControl) + (CurrentRoom.DefaultDisplay as IHasPowerControl).PowerToggle(); + }); + + SetupNextMeetingTimer(); + + base.Show(); + } + + /// + /// Allows PopupInterlock to be toggled if the calls list is already visible, or if the codec is in a call + /// + public void ShowActiveCallsListOrMeetingInfo() + { + TriList.SetBool(UIBoolJoin.CallEndAllConfirmVisible, true); + + + if(PopupInterlock.CurrentJoin == CallListOrMeetingInfoPopoverVisibilityJoin) + PopupInterlock.ShowInterlockedWithToggle(CallListOrMeetingInfoPopoverVisibilityJoin); + else + { + if(CurrentRoom.VideoCodec.IsInCall) + PopupInterlock.ShowInterlockedWithToggle(CallListOrMeetingInfoPopoverVisibilityJoin); + } + } + + /// + /// + /// + void ShowLogo() + { + if (CurrentRoom.LogoUrlLightBkgnd == null) + { + TriList.SetBool(UIBoolJoin.LogoDefaultVisible, true); + TriList.SetBool(UIBoolJoin.LogoUrlVisible, false); + } + else + { + TriList.SetBool(UIBoolJoin.LogoDefaultVisible, false); + TriList.SetBool(UIBoolJoin.LogoUrlVisible, true); + TriList.SetString(UIStringJoin.LogoUrlLightBkgnd, _CurrentRoom.LogoUrlLightBkgnd); + TriList.SetString(UIStringJoin.LogoUrlDarkBkgnd, _CurrentRoom.LogoUrlDarkBkgnd); + } + } + + /// + /// + /// + void HideLogo() + { + TriList.SetBool(UIBoolJoin.LogoDefaultVisible, false); + TriList.SetBool(UIBoolJoin.LogoUrlVisible, false); + } + + /// + /// + /// + public override void Hide() + { + HideAndClearCurrentDisplayModeSigsInUse(); + TriList.SetBool(UIBoolJoin.TopBarHabaneroDynamicVisible, false); + TriList.BooleanInput[UIBoolJoin.ActivityFooterVisible].BoolValue = false; + TriList.BooleanInput[StartPageVisibleJoin].BoolValue = false; + TriList.BooleanInput[UIBoolJoin.TapToBeginVisible].BoolValue = false; + TriList.BooleanInput[UIBoolJoin.SelectASourceVisible].BoolValue = false; + if (NextMeetingTimer != null) + NextMeetingTimer.Stop(); + HideNextMeetingPopup(); + base.Hide(); + } + + /// + /// Reveals a message on the notification ribbon until cleared + /// + /// Text to display + /// Time in ms to display. 0 to keep on screen + public void ShowNotificationRibbon(string message, int timeout) + { + TriList.SetString(UIStringJoin.NotificationRibbonText, message); + TriList.SetBool(UIBoolJoin.NotificationRibbonVisible, true); + if (timeout > 0) + { + if (RibbonTimer != null) + RibbonTimer.Stop(); + RibbonTimer = new CTimer(o => { + TriList.SetBool(UIBoolJoin.NotificationRibbonVisible, false); + RibbonTimer = null; + }, timeout); + } + } + + /// + /// Hides the notification ribbon + /// + public void HideNotificationRibbon() + { + TriList.SetBool(UIBoolJoin.NotificationRibbonVisible, false); + if (RibbonTimer != null) + { + RibbonTimer.Stop(); + RibbonTimer = null; + } + } + + void SetupNextMeetingTimer() + { + var ss = CurrentRoom.ScheduleSource; + if (ss != null) + { + NextMeetingTimer = new CTimer(o => ShowNextMeetingTimerCallback(), null, 0, 60000); + } + } + + /// + /// + /// + void ShowNextMeetingTimerCallback() + { + //Update calendar for Zoom. Zoom doesn't automatically update when meetings are in the past + if (_isZoomRoomWithNoExternalSources) + { + CurrentRoom.ScheduleSource.GetSchedule(); + } + + // Every 60 seconds, refresh the calendar + RefreshMeetingsList(); + // check meetings list for the closest, joinable meeting + var ss = CurrentRoom.ScheduleSource; + var meetings = ss.CodecSchedule.Meetings; + + if (meetings.Count <= 0) + { + return; + } + // If the room is off pester the user + // If the room is on, and the meeting is joinable + // and the LastMeetingDismissed != this meeting + + var lastMeetingDismissed = meetings.FirstOrDefault(m => m.Id == LastMeetingDismissedId); + //Debug.Console(0, "*#* Room on: {0}, lastMeetingDismissedId: {1} {2} *#*", + // CurrentRoom.OnFeedback.BoolValue, + // LastMeetingDismissedId, + // lastMeetingDismissed != null ? lastMeetingDismissed.StartTime.ToString("t", Global.Culture) : ""); + + var meeting = meetings.LastOrDefault(m => m.Joinable); + if (CurrentRoom.OnFeedback.BoolValue + && lastMeetingDismissed == meeting) + { + // meeting no longer joinable, hide popup + if(meeting == null) + HideNextMeetingPopup(); + + return; + } + + LastMeetingDismissedId = null; + // Clear the popup when we run out of meetings + if (meeting == null) + { + HideNextMeetingPopup(); + } + else + { + + + TriList.SetString(UIStringJoin.MeetingsOrContactMethodListTitleText, "Upcoming meeting"); + TriList.SetString(UIStringJoin.NextMeetingStartTimeText, meeting.StartTime.ToString("t", Global.Culture)); + TriList.SetString(UIStringJoin.NextMeetingEndTimeText, meeting.EndTime.ToString("t", Global.Culture)); + TriList.SetString(UIStringJoin.NextMeetingTitleText, meeting.Title); + TriList.SetString(UIStringJoin.NextMeetingNameText, meeting.Organizer); + TriList.SetString(UIStringJoin.NextMeetingButtonLabel, "Join"); + TriList.SetSigFalseAction(UIBoolJoin.NextMeetingJoinPress, () => + { + HideNextMeetingPopup(); + PopupInterlock.Hide(); + RoomOnAndDialMeeting(meeting); + }); + TriList.SetString(UIStringJoin.NextMeetingSecondaryButtonLabel, "Show Schedule"); + TriList.SetSigFalseAction(UIBoolJoin.CalendarHeaderButtonPress, () => + { + HideNextMeetingPopup(); + //CalendarPress(); + RefreshMeetingsList(); + PopupInterlock.ShowInterlocked(UIBoolJoin.MeetingsOrContacMethodsListVisible); + }); + var indexOfNext = meetings.IndexOf(meeting) + 1; + + // indexOf = 3, 4 meetings : + if (indexOfNext < meetings.Count) + TriList.SetString(UIStringJoin.NextMeetingFollowingMeetingText, + meetings[indexOfNext].StartTime.ToString("t", Global.Culture)); + else + TriList.SetString(UIStringJoin.NextMeetingFollowingMeetingText, "No more meetings today"); + + TriList.SetSigFalseAction(UIBoolJoin.NextMeetingModalClosePress, () => + { + // Mark the meeting to not re-harass the user + if(CurrentRoom.OnFeedback.BoolValue) + LastMeetingDismissedId = meeting.Id; + HideNextMeetingPopup(); + }); + + TriList.SetBool(UIBoolJoin.NextMeetingModalVisible, true); + } + } + + /// + /// + /// + void HideNextMeetingPopup() + { + TriList.SetBool(UIBoolJoin.NextMeetingModalVisible, false); + + } + + /// + /// Calendar should only be visible when it's supposed to + /// + public void CalendarPress() + { + //RefreshMeetingsList(); // List should be up-to-date + PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.MeetingsOrContacMethodsListVisible); + } + + /// + /// Dials a meeting after turning on room (if necessary) + /// + void RoomOnAndDialMeeting(Meeting meeting) + { + Debug.Console(1, "[RoomOnAndDialMeeting] Joining meeting [{0}]", meeting); + Action dialAction = () => + { + var d = CurrentRoom.ScheduleSource as VideoCodecBase; + if (d != null) + { + Debug.Console(1, + "[RoomOnAndDialMeeting] [dialAction] Sending command to codec to join meeting {0}", meeting); + d.Dial(meeting); + LastMeetingDismissedId = meeting.Id; // To prevent prompts for already-joined call + } + }; + if (CurrentRoom.OnFeedback.BoolValue) + { + Debug.Console(1, "[RoomOnAndDialMeeting] Room is on."); + dialAction(); + } + else + { + Debug.Console(1, "RoomOnAndDialMeeting] Room is off or warming. Registering for Warming Feedback"); + // Rig a one-time handler to catch when the room is warmed and then dial call + EventHandler oneTimeHandler = null; + oneTimeHandler = (o, a) => + { + if (!CurrentRoom.IsWarmingUpFeedback.BoolValue) + { + CurrentRoom.IsWarmingUpFeedback.OutputChange -= oneTimeHandler; + dialAction(); + } + }; + CurrentRoom.IsWarmingUpFeedback.OutputChange += oneTimeHandler; + ActivityCallButtonPressed(); + } + } + + /// + /// Reveals the tech page and puts away anything that's in the way. + /// + public void ShowTech() + { + PopupInterlock.HideAndClear(); + TechDriver.Show(); + } + + /// + /// When the room is off, set the footer SRL + /// + void SetupActivityFooterWhenRoomOff() + { + ActivityFooterSrl.Clear(); + ActivityFooterSrl.AddItem(new SubpageReferenceListActivityItem(1, ActivityFooterSrl, 0, + b => { if (!b) ActivityShareButtonPressed(); })); + ActivityFooterSrl.AddItem(new SubpageReferenceListActivityItem(2, ActivityFooterSrl, 3, + b => { if (!b) ActivityCallButtonPressed(); })); + ActivityFooterSrl.Count = 2; + TriList.SetUshort(UIUshortJoin.PresentationStagingCaretMode, 1); // right one slot + TriList.SetUshort(UIUshortJoin.CallStagingCaretMode, 5); // left one slot + } + + /// + /// Sets up the footer SRL for when the room is on + /// + void SetupActivityFooterWhenRoomOn() + { + ActivityFooterSrl.Clear(); + ActivityFooterSrl.AddItem(new SubpageReferenceListActivityItem(1, ActivityFooterSrl, 0, + b => { if (!b) ActivityShareButtonPressed(); })); + ActivityFooterSrl.AddItem(new SubpageReferenceListActivityItem(2, ActivityFooterSrl, 3, + b => { if (!b) ActivityCallButtonPressed(); })); + ActivityFooterSrl.AddItem(new SubpageReferenceListActivityItem(3, ActivityFooterSrl, 4, + b => { if (!b) EndMeetingPress(); })); + ActivityFooterSrl.Count = 3; + TriList.SetUshort(UIUshortJoin.PresentationStagingCaretMode, 2); // center + TriList.SetUshort(UIUshortJoin.CallStagingCaretMode, 0); // left -2 + } + + /// + /// Single point call for setting the feedbacks on the activity buttons + /// + void SetActivityFooterFeedbacks() + { + if (CurrentRoom != null) + { + var startMode = CurrentMode == UiDisplayMode.Start; + var presentationMode = CurrentMode == UiDisplayMode.Presentation; + var callMode = CurrentMode == UiDisplayMode.Call; + + TriList.SetBool(StartPageVisibleJoin, startMode ? true : false); + + if (presentationMode &&_isZoomRoomWithNoExternalSources) + { + // For now, if this is a Zoom Room and there are no shareable sources just display the informational subpage + TriList.SetBool(UIBoolJoin.SourceStagingBarVisible, false); + TriList.SetBool(UIBoolJoin.ZoomRoomContentSharingVisible, true); + } + else + { + // Otherwise, show the staging bar + TriList.SetBool(UIBoolJoin.ZoomRoomContentSharingVisible, false); + TriList.SetBool(UIBoolJoin.SourceStagingBarVisible, presentationMode ? true : false); + + } + if (!presentationMode) + { + TriList.SetBool(UIBoolJoin.ZoomRoomContentSharingVisible, false); + TriList.SetBool(UIBoolJoin.SelectASourceVisible, false); + } + + CallButtonSig.BoolValue = callMode + && CurrentRoom.ShutdownType == eShutdownType.None; + ShareButtonSig.BoolValue = presentationMode + && CurrentRoom.ShutdownType == eShutdownType.None; + EndMeetingButtonSig.BoolValue = CurrentRoom.ShutdownType != eShutdownType.None; + } + } + + /// + /// + /// + public void ActivityCallButtonPressed() + { + if (VCDriver.IsVisible) + return; + HideLogo(); + HideNextMeetingPopup(); + //TriList.SetBool(StartPageVisibleJoin, false); + //TriList.SetBool(UIBoolJoin.SourceStagingBarVisible, false); + //TriList.SetBool(UIBoolJoin.SelectASourceVisible, false); + if (CurrentSourcePageManager != null) + CurrentSourcePageManager.Hide(); + PowerOnFromCall(); + CurrentMode = UiDisplayMode.Call; + VCDriver.Show(); + } + + /// + /// Attached to activity list share button + /// + void ActivityShareButtonPressed() + { + SetupSourceList(); + if (VCDriver.IsVisible) + VCDriver.Hide(); + HideNextMeetingPopup(); + + + if (_isZoomRoomWithNoExternalSources) + { + if (!CurrentRoom.OnFeedback.BoolValue) + { + CurrentRoom.RunDefaultPresentRoute(); + } + // For now, if this is a Zoom Room and there are no shareable sources just display the informational subpage + TriList.SetBool(UIBoolJoin.ZoomRoomContentSharingVisible, true); + + var presentationMeetingCodec = CurrentRoom.VideoCodec as IHasPresentationOnlyMeeting; + var farEndContentStatusCodec = CurrentRoom.VideoCodec as IHasFarEndContentStatus; + var receivingContent = false; + + if (farEndContentStatusCodec != null) + { + receivingContent = farEndContentStatusCodec.ReceivingContent.BoolValue; + } + + if (presentationMeetingCodec != null && !CurrentRoom.VideoCodec.IsInCall) + { + presentationMeetingCodec.StartSharingOnlyMeeting(eSharingMeetingMode.Laptop); + } + else if (CurrentRoom.VideoCodec.IsInCall && !CurrentRoom.VideoCodec.SharingContentIsOnFeedback.BoolValue && + !receivingContent) + { + CurrentRoom.VideoCodec.StartSharing(); + } + + if (CurrentSourcePageManager != null) + CurrentSourcePageManager.Hide(); + } + else + { + // Run default source when room is off and share is pressed + if (!CurrentRoom.OnFeedback.BoolValue) + { + // If there's no default, show UI elements + if (!(CurrentRoom as IRunDefaultPresentRoute).RunDefaultPresentRoute()) + TriList.SetBool(UIBoolJoin.SelectASourceVisible, true); + } + else // room is on show what's active or select a source if nothing is yet active + { + if (CurrentRoom.CurrentSourceInfo == null || + (CurrentRoom.VideoCodec != null && + CurrentRoom.CurrentSourceInfo.SourceDevice.Key == CurrentRoom.VideoCodec.OsdSource.Key)) + TriList.SetBool(UIBoolJoin.SelectASourceVisible, true); + else if (CurrentSourcePageManager != null) + { + TriList.SetBool(UIBoolJoin.SelectASourceVisible, false); + CurrentSourcePageManager.Show(); + } + } + SetupSourceList(); + } + CurrentMode = UiDisplayMode.Presentation; + } + + /// + /// Powers up the system to the codec route, if not already on. + /// + void PowerOnFromCall() + { + if (!CurrentRoom.OnFeedback.BoolValue) + { + CurrentRoom.RunDefaultCallRoute(); + } + } + + /// + /// Shows all sigs that are in CurrentDisplayModeSigsInUse + /// + void ShowCurrentDisplayModeSigsInUse() + { + foreach (var sig in CurrentDisplayModeSigsInUse) + sig.BoolValue = true; + } + + /// + /// Hides all CurrentDisplayModeSigsInUse sigs and clears the array + /// + void HideAndClearCurrentDisplayModeSigsInUse() + { + foreach (var sig in CurrentDisplayModeSigsInUse) + sig.BoolValue = false; + CurrentDisplayModeSigsInUse.Clear(); + } + + + /// + /// Loads the appropriate Sigs into CurrentDisplayModeSigsInUse and shows them + /// + void ShowCurrentSource() + { + if (CurrentRoom.CurrentSourceInfo == null || _isZoomRoomWithNoExternalSources) + return; + + CurrentMode = UiDisplayMode.Presentation; + + if (CurrentRoom.CurrentSourceInfo.SourceDevice == null) + { + TriList.SetBool(UIBoolJoin.SelectASourceVisible, true); + return; + } + + var uiDev = CurrentRoom.CurrentSourceInfo.SourceDevice as IUiDisplayInfo; + PageManager pm = null; + // If we need a page manager, get an appropriate one + if (uiDev != null) + { + TriList.SetBool(UIBoolJoin.SelectASourceVisible, false); + // Got an existing page manager, get it + if (PageManagers.ContainsKey(uiDev)) + pm = PageManagers[uiDev]; + // Otherwise make an apporiate one + else if (uiDev is ISetTopBoxControls) + pm = new SetTopBoxThreePanelPageManager(uiDev as ISetTopBoxControls, TriList); + else if (uiDev is IDiscPlayerControls) + pm = new DiscPlayerMediumPageManager(uiDev as IDiscPlayerControls, TriList); + else + pm = new DefaultPageManager(uiDev, TriList); + PageManagers[uiDev] = pm; + CurrentSourcePageManager = pm; + pm.Show(); + } + } + + /// + /// Called from button presses on source, where We can assume we want + /// to change to the proper screen. + /// + /// The key name of the route to run + void UiSelectSource(string key) + { + // Run the route and when it calls back, show the source + CurrentRoom.RunRouteAction(key); + } + + /// + /// + /// + public void EndMeetingPress() + { + if (!CurrentRoom.OnFeedback.BoolValue + || CurrentRoom.ShutdownPromptTimer.IsRunningFeedback.BoolValue) + return; + + CurrentRoom.StartShutdown(eShutdownType.Manual); + } + + /// + /// Puts away modals and things that might be up when call comes in + /// + public void PrepareForCodecIncomingCall() + { + if (PowerDownModal != null && PowerDownModal.ModalIsVisible) + PowerDownModal.CancelDialog(); + PopupInterlock.Hide(); + } + + /// + /// + /// + /// + /// + void ShutdownPromptTimer_HasStarted(object sender, EventArgs e) + { + // Do we need to check where the UI is? No? + var timer = CurrentRoom.ShutdownPromptTimer; + SetActivityFooterFeedbacks(); + + if (CurrentRoom.ShutdownType == eShutdownType.Manual || CurrentRoom.ShutdownType == eShutdownType.Vacancy) + { + PowerDownModal = new ModalDialog(TriList); + var message = string.Format("Meeting will end in {0} seconds", CurrentRoom.ShutdownPromptSeconds); + + // Attach timer things to modal + CurrentRoom.ShutdownPromptTimer.TimeRemainingFeedback.OutputChange += ShutdownPromptTimer_TimeRemainingFeedback_OutputChange; + CurrentRoom.ShutdownPromptTimer.PercentFeedback.OutputChange += ShutdownPromptTimer_PercentFeedback_OutputChange; + + // respond to offs by cancelling dialog + var onFb = CurrentRoom.OnFeedback; + EventHandler offHandler = null; + offHandler = (o, a) => + { + if (!onFb.BoolValue) + { + PowerDownModal.HideDialog(); + SetActivityFooterFeedbacks(); + onFb.OutputChange -= offHandler; + } + }; + onFb.OutputChange += offHandler; + + PowerDownModal.PresentModalDialog(2, "End Meeting", "Power", message, "Cancel", "End Meeting Now", true, true, + but => + { + if (but != 2) // any button except for End cancels + timer.Cancel(); + else + timer.Finish(); + }); + } + } + + /// + /// + /// + /// + /// + void ShutdownPromptTimer_HasFinished(object sender, EventArgs e) + { + SetActivityFooterFeedbacks(); + CurrentRoom.ShutdownPromptTimer.TimeRemainingFeedback.OutputChange -= ShutdownPromptTimer_TimeRemainingFeedback_OutputChange; + CurrentRoom.ShutdownPromptTimer.PercentFeedback.OutputChange -= ShutdownPromptTimer_PercentFeedback_OutputChange; + } + + /// + /// + /// + /// + /// + void ShutdownPromptTimer_WasCancelled(object sender, EventArgs e) + { + if (PowerDownModal != null) + PowerDownModal.HideDialog(); + SetActivityFooterFeedbacks(); + + CurrentRoom.ShutdownPromptTimer.TimeRemainingFeedback.OutputChange += ShutdownPromptTimer_TimeRemainingFeedback_OutputChange; + CurrentRoom.ShutdownPromptTimer.PercentFeedback.OutputChange -= ShutdownPromptTimer_PercentFeedback_OutputChange; + } + + /// + /// Event handler for countdown timer on power off modal + /// + void ShutdownPromptTimer_TimeRemainingFeedback_OutputChange(object sender, EventArgs e) + { + + var message = string.Format("Meeting will end in {0} seconds", (sender as StringFeedback).StringValue); + TriList.StringInput[ModalDialog.MessageTextJoin].StringValue = message; + } + + /// + /// Event handler for percentage on power off countdown + /// + void ShutdownPromptTimer_PercentFeedback_OutputChange(object sender, EventArgs e) + { + var value = (ushort)((sender as IntFeedback).UShortValue * 65535 / 100); + TriList.UShortInput[ModalDialog.TimerGaugeJoin].UShortValue = value; + } + + /// + /// + /// + void CancelPowerOffTimer() + { + if (PowerOffTimer != null) + { + PowerOffTimer.Stop(); + PowerOffTimer = null; + } + } + + /// + /// + /// + /// + public void VolumeUpPress(bool state) + { + if (CurrentRoom.CurrentVolumeControls != null) + CurrentRoom.CurrentVolumeControls.VolumeUp(state); + } + + /// + /// + /// + /// + public void VolumeDownPress(bool state) + { + if (CurrentRoom.CurrentVolumeControls != null) + CurrentRoom.CurrentVolumeControls.VolumeDown(state); + } + + /// + /// Helper for property setter. Sets the panel to the given room, latching up all functionality + /// + void RefreshCurrentRoom(IEssentialsHuddleVtc1Room room) + { + + if (_CurrentRoom != null) + { + // Disconnect current room + _CurrentRoom.CurrentVolumeDeviceChange -= this.CurrentRoom_CurrentAudioDeviceChange; + ClearAudioDeviceConnections(); + _CurrentRoom.CurrentSourceChange -= this.CurrentRoom_SourceInfoChange; + DisconnectSource(_CurrentRoom.CurrentSourceInfo); + _CurrentRoom.ShutdownPromptTimer.HasStarted -= ShutdownPromptTimer_HasStarted; + _CurrentRoom.ShutdownPromptTimer.HasFinished -= ShutdownPromptTimer_HasFinished; + _CurrentRoom.ShutdownPromptTimer.WasCancelled -= ShutdownPromptTimer_WasCancelled; + + _CurrentRoom.OnFeedback.OutputChange -= CurrentRoom_OnFeedback_OutputChange; + _CurrentRoom.IsWarmingUpFeedback.OutputChange -= CurrentRoom_IsWarmingFeedback_OutputChange; + _CurrentRoom.IsCoolingDownFeedback.OutputChange -= CurrentRoom_IsCoolingDownFeedback_OutputChange; + _CurrentRoom.InCallFeedback.OutputChange -= CurrentRoom_InCallFeedback_OutputChange; + + var scheduleAwareCodec = _CurrentRoom.VideoCodec as IHasScheduleAwareness; + if (scheduleAwareCodec != null) + { + scheduleAwareCodec.CodecSchedule.MeetingsListHasChanged -= CodecSchedule_MeetingsListHasChanged; + } + + var meetingInfoCodec = _CurrentRoom.VideoCodec as IHasMeetingInfo; + if (meetingInfoCodec != null) + { + meetingInfoCodec.MeetingInfoChanged -= meetingInfoCodec_MeetingInfoChanged; + } + } + + _CurrentRoom = room; + + if (_CurrentRoom != null) + { + // get the source list config and set up the source list + + SetupSourceList(); + + // Name and logo + TriList.StringInput[UIStringJoin.CurrentRoomName].StringValue = _CurrentRoom.Name; + ShowLogo(); + + // Shutdown timer + _CurrentRoom.ShutdownPromptTimer.HasStarted += ShutdownPromptTimer_HasStarted; + _CurrentRoom.ShutdownPromptTimer.HasFinished += ShutdownPromptTimer_HasFinished; + _CurrentRoom.ShutdownPromptTimer.WasCancelled += ShutdownPromptTimer_WasCancelled; + + // Link up all the change events from the room + _CurrentRoom.OnFeedback.OutputChange += CurrentRoom_OnFeedback_OutputChange; + CurrentRoom_SyncOnFeedback(); + _CurrentRoom.IsWarmingUpFeedback.OutputChange += CurrentRoom_IsWarmingFeedback_OutputChange; + _CurrentRoom.IsCoolingDownFeedback.OutputChange += CurrentRoom_IsCoolingDownFeedback_OutputChange; + _CurrentRoom.InCallFeedback.OutputChange += CurrentRoom_InCallFeedback_OutputChange; + + + _CurrentRoom.CurrentVolumeDeviceChange += CurrentRoom_CurrentAudioDeviceChange; + RefreshAudioDeviceConnections(); + _CurrentRoom.CurrentSourceChange += CurrentRoom_SourceInfoChange; + RefreshSourceInfo(); + + + var scheduleAwareCodec = _CurrentRoom.VideoCodec as IHasScheduleAwareness; + if (scheduleAwareCodec != null) + { + scheduleAwareCodec.CodecSchedule.MeetingsListHasChanged += CodecSchedule_MeetingsListHasChanged; + } + + var meetingInfoCodec = _CurrentRoom.VideoCodec as IHasMeetingInfo; + if (meetingInfoCodec != null) + { + meetingInfoCodec.MeetingInfoChanged += new EventHandler(meetingInfoCodec_MeetingInfoChanged); + + CallListOrMeetingInfoPopoverVisibilityJoin = UIBoolJoin.HeaderMeetingInfoVisible; + } + else + { + CallListOrMeetingInfoPopoverVisibilityJoin = UIBoolJoin.HeaderActiveCallsListVisible; + } + + CallSharingInfoVisibleFeedback = new BoolFeedback(() => _CurrentRoom.VideoCodec.SharingContentIsOnFeedback.BoolValue); + _CurrentRoom.VideoCodec.SharingContentIsOnFeedback.OutputChange += SharingContentIsOnFeedback_OutputChange; + CallSharingInfoVisibleFeedback.LinkInputSig(TriList.BooleanInput[UIBoolJoin.CallSharedSourceInfoVisible]); + + SetActiveCallListSharingContentStatus(); + + if (_CurrentRoom != null) + _CurrentRoom.CurrentSourceChange += new SourceInfoChangeHandler(CurrentRoom_CurrentSingleSourceChange); + + // Moved to EssentialsVideoCodecUiDriver + //TriList.SetSigFalseAction(UIBoolJoin.CallStopSharingPress, () => _CurrentRoom.RunRouteAction("codecOsd", _CurrentRoom.SourceListKey)); + + (Parent as EssentialsPanelMainInterfaceDriver).HeaderDriver.SetupHeaderButtons(this, CurrentRoom); + } + else + { + // Clear sigs that need to be + TriList.StringInput[UIStringJoin.CurrentRoomName].StringValue = "Select a room"; + } + } + + void meetingInfoCodec_MeetingInfoChanged(object sender, MeetingInfoEventArgs e) + { + if (e.Info == null) + { + return; + } + + TriList.SetString(UIStringJoin.MeetingIdText, e.Info.Id); + TriList.SetString(UIStringJoin.MeetingHostText, e.Info.Host); + TriList.SetString(UIStringJoin.MeetingNameText, e.Info.Name); + + TriList.SetString(UIStringJoin.MeetingPasswordText, e.Info.Password); + // Show the password fields if one is present + TriList.SetBool(UIBoolJoin.MeetingPasswordVisible, !string.IsNullOrEmpty(e.Info.Password)); + + TriList.SetString(UIStringJoin.CallSharedSourceNameText, e.Info.ShareStatus); + + TriList.SetString(UIStringJoin.MeetingLeaveText, e.Info.IsHost ? "End Meeting" : "Leave Meeting"); + } + + void SetCurrentRoom(IEssentialsHuddleVtc1Room room) + { + if (_CurrentRoom == room) return; + // Disconnect current (probably never called) + + if(_CurrentRoom != null) + _CurrentRoom.ConfigChanged -= room_ConfigChanged; + + room.ConfigChanged -= room_ConfigChanged; + room.ConfigChanged += room_ConfigChanged; + + if (room.IsMobileControlEnabled) + { + StartPageVisibleJoin = UIBoolJoin.StartMCPageVisible; + UpdateMCJoins(room); + + if (_CurrentRoom != null) + _CurrentRoom.MobileControlRoomBridge.UserCodeChanged -= MobileControlRoomBridge_UserCodeChanged; + + room.MobileControlRoomBridge.UserCodeChanged -= MobileControlRoomBridge_UserCodeChanged; + room.MobileControlRoomBridge.UserCodeChanged += MobileControlRoomBridge_UserCodeChanged; + } + else + { + StartPageVisibleJoin = UIBoolJoin.StartPageVisible; + } + + RefreshCurrentRoom(room); + } + + void MobileControlRoomBridge_UserCodeChanged(object sender, EventArgs e) + { + UpdateMCJoins(_CurrentRoom); + } + + void UpdateMCJoins(IEssentialsHuddleVtc1Room room) + { + TriList.SetString(UIStringJoin.RoomMcUrl, room.MobileControlRoomBridge.McServerUrl); + TriList.SetString(UIStringJoin.RoomMcQrCodeUrl, room.MobileControlRoomBridge.QrCodeUrl); + TriList.SetString(UIStringJoin.RoomUserCode, room.MobileControlRoomBridge.UserCode); + } + + /// + /// Fires when room config of current room has changed. Meant to refresh room values to propegate any updates to UI + /// + /// + /// + void room_ConfigChanged(object sender, EventArgs e) + { + RefreshCurrentRoom(_CurrentRoom); + } + + /// + /// + /// + /// + /// + void CurrentRoom_InCallFeedback_OutputChange(object sender, EventArgs e) + { + var inCall = CurrentRoom.InCallFeedback.BoolValue; + if (inCall) + { + // Check if transitioning to in call - and non-sharable source is in use + if (CurrentRoom.CurrentSourceInfo != null && CurrentRoom.CurrentSourceInfo.DisableCodecSharing) + { + Debug.Console(1, CurrentRoom, "Transitioning to in-call, cancelling non-sharable source"); + CurrentRoom.RunRouteAction("codecOsd"); + } + } + + SetupSourceList(); + } + + /// + /// + /// + void SetupSourceList() + { + + var inCall = CurrentRoom.InCallFeedback.BoolValue; + var config = ConfigReader.ConfigObject.SourceLists; + + + if (config.ContainsKey(_CurrentRoom.SourceListKey)) + { + var srcList = config[_CurrentRoom.SourceListKey].OrderBy(kv => kv.Value.Order); + + + // Setup sources list + SourceStagingSrl.Clear(); + uint i = 1; // counter for UI list + foreach (var kvp in srcList) + { + var srcConfig = kvp.Value; + Debug.Console(1, "**** {0}, {1}, {2}, {3}, {4}", srcConfig.PreferredName, srcConfig.IncludeInSourceList, + srcConfig.DisableCodecSharing, inCall, this.CurrentMode); + // Skip sources marked as not included, and filter list of non-sharable sources when in call + // or on share screen + if (!srcConfig.IncludeInSourceList || (inCall && srcConfig.DisableCodecSharing) + || this.CurrentMode == UiDisplayMode.Call && srcConfig.DisableCodecSharing) + { + Debug.Console(1, "Skipping {0}", srcConfig.PreferredName); + continue; + } + + var routeKey = kvp.Key; + var item = new SubpageReferenceListSourceItem(i++, SourceStagingSrl, srcConfig, + b => { if (!b) UiSelectSource(routeKey); }); + SourceStagingSrl.AddItem(item); // add to the SRL + item.RegisterForSourceChange(_CurrentRoom); + Debug.Console(1, "**** KEY {0}", kvp.Key); + + } + _sourceListCount = (i - 1); + SourceStagingSrl.Count = (ushort)_sourceListCount; + } + + } + + /// + /// If the schedule changes, this event will fire + /// + /// + /// + void CodecSchedule_MeetingsListHasChanged(object sender, EventArgs e) + { + RefreshMeetingsList(); + } + + /// + /// Updates the current shared source label on the call list when the source changes + /// + /// + /// + /// + void CurrentRoom_CurrentSingleSourceChange(SourceListItem info, ChangeType type) + { + Debug.Console(1, "AvFunctionsDriver: CurrentSingleSourceChange"); + + // Show the Select a source subpage + if (TriList.BooleanInput[UIBoolJoin.SourceStagingBarVisible].BoolValue) + { + Debug.Console(1, "AvFunctionsDriver: CurrentSingleSourceChange SourceStagingBarVisisble: true"); + + if (_CurrentRoom.CurrentSourceInfo == null || (_CurrentRoom.VideoCodec != null && _CurrentRoom.CurrentSourceInfo.SourceDevice.Key == _CurrentRoom.VideoCodec.OsdSource.Key)) + { + Debug.Console(1, "AvFunctionsDriver: CurrentSingleSourceChange Showing SelectASourceVisible"); + TriList.SetBool(UIBoolJoin.SelectASourceVisible, true); + } + else + { + TriList.SetBool(UIBoolJoin.SelectASourceVisible, false); + Debug.Console(1, "AvFunctionsDriver: CurrentSingleSourceChange Hiding SelectASourceVisible"); + } + } + else + { + Debug.Console(1, "AvFunctionsDriver: CurrentSingleSourceChange Hiding SelectASourceVisible"); + TriList.SetBool(UIBoolJoin.SelectASourceVisible, false); + } + + if (_CurrentRoom.VideoCodec.SharingContentIsOnFeedback.BoolValue && _CurrentRoom.CurrentSourceInfo != null) + TriList.StringInput[UIStringJoin.CallSharedSourceNameText].StringValue = _CurrentRoom.CurrentSourceInfo.PreferredName; + } + + /// + /// Fires when the sharing source feedback of the codec changes + /// + /// + /// + void SharingContentIsOnFeedback_OutputChange(object sender, EventArgs e) + { + SetActiveCallListSharingContentStatus(); + } + + /// + /// Sets the values for the text and button visibilty for the active call list source sharing info + /// + void SetActiveCallListSharingContentStatus() + { + CallSharingInfoVisibleFeedback.FireUpdate(); + + string callListSharedSourceLabel; + + if (_CurrentRoom.VideoCodec.SharingContentIsOnFeedback.BoolValue && _CurrentRoom.CurrentSourceInfo != null) + { + Debug.Console(0, "*#* CurrentRoom.CurrentSourceInfo = {0}", + _CurrentRoom.CurrentSourceInfo != null ? _CurrentRoom.CurrentSourceInfo.SourceKey : "Nada!"); + callListSharedSourceLabel = _CurrentRoom.CurrentSourceInfo.PreferredName; + } + else + callListSharedSourceLabel = "None"; + + TriList.StringInput[UIStringJoin.CallSharedSourceNameText].StringValue = callListSharedSourceLabel; + } + + /// + /// + /// + void RefreshMeetingsList() + { + // See if this is helpful or if the callback response in the codec class maybe doesn't come it time? + // Let's build list from event + + TriList.SetString(UIStringJoin.MeetingsOrContactMethodListIcon, "Calendar"); + TriList.SetString(UIStringJoin.MeetingsOrContactMethodListTitleText, "Today's Meetings"); + + ushort i = 0; + foreach (var m in CurrentRoom.ScheduleSource.CodecSchedule.Meetings) + { + i++; + MeetingOrContactMethodModalSrl.StringInputSig(i, 1).StringValue = m.StartTime.ToString("t", Global.Culture); + MeetingOrContactMethodModalSrl.StringInputSig(i, 2).StringValue = m.EndTime.ToString("t", Global.Culture); + MeetingOrContactMethodModalSrl.StringInputSig(i, 3).StringValue = m.Title; + MeetingOrContactMethodModalSrl.StringInputSig(i, 4).StringValue = string.Format("
{0}",m.Organizer); + MeetingOrContactMethodModalSrl.StringInputSig(i, 5).StringValue = "Join"; + MeetingOrContactMethodModalSrl.BoolInputSig(i, 2).BoolValue = m.Joinable; + var mm = m; // lambda scope + MeetingOrContactMethodModalSrl.GetBoolFeedbackSig(i, 1).SetSigFalseAction(() => + { + PopupInterlock.Hide(); + ActivityCallButtonPressed(); + var d = CurrentRoom.ScheduleSource as VideoCodecBase; + if (d != null) + RoomOnAndDialMeeting(mm); + }); + } + MeetingOrContactMethodModalSrl.Count = i; + + if (i == 0) // Show item indicating no meetings are booked for rest of day + { + MeetingOrContactMethodModalSrl.Count = 1; + + MeetingOrContactMethodModalSrl.StringInputSig(1, 1).StringValue = string.Empty; + MeetingOrContactMethodModalSrl.StringInputSig(1, 2).StringValue = string.Empty; + MeetingOrContactMethodModalSrl.StringInputSig(1, 3).StringValue = "No Meetings are booked for the remainder of the day."; + MeetingOrContactMethodModalSrl.StringInputSig(1, 4).StringValue = string.Empty; + MeetingOrContactMethodModalSrl.StringInputSig(1, 5).StringValue = string.Empty; + } + } + + /// + /// For room on/off changes + /// + void CurrentRoom_OnFeedback_OutputChange(object sender, EventArgs e) + { + CurrentRoom_SyncOnFeedback(); + } + + /// + /// + /// + void CurrentRoom_SyncOnFeedback() + { + var value = _CurrentRoom.OnFeedback.BoolValue; + TriList.BooleanInput[UIBoolJoin.RoomIsOn].BoolValue = value; + + //TriList.BooleanInput[StartPageVisibleJoin].BoolValue = !value; + + if (value) //ON + { + SetupActivityFooterWhenRoomOn(); + //TriList.BooleanInput[UIBoolJoin.SelectASourceVisible].BoolValue = false; + TriList.BooleanInput[UIBoolJoin.VolumeDualMute1Visible].BoolValue = true; + + } + else + { + CurrentMode = UiDisplayMode.Start; + if (VCDriver.IsVisible) + VCDriver.Hide(); + SetupActivityFooterWhenRoomOff(); + ShowLogo(); + //TriList.BooleanInput[UIBoolJoin.VolumeDualMute1Visible].BoolValue = false; + //TriList.BooleanInput[UIBoolJoin.SourceStagingBarVisible].BoolValue = false; + // Clear this so that the pesky meeting warning can resurface every minute when off + LastMeetingDismissedId = null; + } + } + + /// + /// + /// + void CurrentRoom_IsWarmingFeedback_OutputChange(object sender, EventArgs e) + { + if (CurrentRoom.IsWarmingUpFeedback.BoolValue) + { + ShowNotificationRibbon("Room is powering on. Please wait...", 0); + } + else + { + ShowNotificationRibbon("Room is powered on. Welcome.", 2000); + } + } + + /// + /// + /// + /// + /// + void CurrentRoom_IsCoolingDownFeedback_OutputChange(object sender, EventArgs e) + { + if (CurrentRoom.IsCoolingDownFeedback.BoolValue) + { + ShowNotificationRibbon("Room is powering off. Please wait.", 0); + } + else + { + HideNotificationRibbon(); + } + } + + /// + /// Hides source for provided source info + /// + /// + void DisconnectSource(SourceListItem previousInfo) + { + if (previousInfo == null) return; + + // Hide whatever is showing + if (IsVisible) + { + if (CurrentSourcePageManager != null) + { + CurrentSourcePageManager.Hide(); + CurrentSourcePageManager = null; + } + } + + if (previousInfo == null) return; + var previousDev = previousInfo.SourceDevice; + + // device type interfaces + if (previousDev is ISetTopBoxControls) + (previousDev as ISetTopBoxControls).UnlinkButtons(TriList); + // common interfaces + if (previousDev is IChannel) + (previousDev as IChannel).UnlinkButtons(TriList); + if (previousDev is IColor) + (previousDev as IColor).UnlinkButtons(TriList); + if (previousDev is IDPad) + (previousDev as IDPad).UnlinkButtons(TriList); + if (previousDev is IDvr) + (previousDev as IDvr).UnlinkButtons(TriList); + if (previousDev is INumericKeypad) + (previousDev as INumericKeypad).UnlinkButtons(TriList); + if (previousDev is IHasPowerControl) + (previousDev as IHasPowerControl).UnlinkButtons(TriList); + if (previousDev is ITransport) + (previousDev as ITransport).UnlinkButtons(TriList); + } + + /// + /// Refreshes and shows the room's current source + /// + void RefreshSourceInfo() + { + var routeInfo = CurrentRoom.CurrentSourceInfo; + // This will show off popup too + if (this.IsVisible && !VCDriver.IsVisible) + ShowCurrentSource(); + + if (routeInfo == null)// || !CurrentRoom.OnFeedback.BoolValue) + { + // Check for power off and insert "Room is off" + TriList.StringInput[UIStringJoin.CurrentSourceName].StringValue = "Room is off"; + TriList.StringInput[UIStringJoin.CurrentSourceIcon].StringValue = "Power"; + this.Hide(); + Parent.Show(); + return; + } + else if (routeInfo != null) + { + TriList.StringInput[UIStringJoin.CurrentSourceName].StringValue = routeInfo.PreferredName; + TriList.StringInput[UIStringJoin.CurrentSourceIcon].StringValue = routeInfo.Icon; // defaults to "blank" + } + else // This never gets hit???!!! + { + TriList.StringInput[UIStringJoin.CurrentSourceName].StringValue = "---"; + TriList.StringInput[UIStringJoin.CurrentSourceIcon].StringValue = "Blank"; + } + + // Connect controls + if (routeInfo.SourceDevice != null) + ConnectControlDeviceMethods(routeInfo.SourceDevice); + } + + /// + /// Attach the source to the buttons and things + /// + void ConnectControlDeviceMethods(Device dev) + { + if (dev is ISetTopBoxControls) + (dev as ISetTopBoxControls).LinkButtons(TriList); + if (dev is IChannel) + (dev as IChannel).LinkButtons(TriList); + if (dev is IColor) + (dev as IColor).LinkButtons(TriList); + if (dev is IDPad) + (dev as IDPad).LinkButtons(TriList); + if (dev is IDvr) + (dev as IDvr).LinkButtons(TriList); + if (dev is INumericKeypad) + (dev as INumericKeypad).LinkButtons(TriList); + if (dev is IHasPowerControl) + (dev as IHasPowerControl).LinkButtons(TriList); + if (dev is ITransport) + (dev as ITransport).LinkButtons(TriList); + } + + /// + /// Detaches the buttons and feedback from the room's current audio device + /// + void ClearAudioDeviceConnections() + { + TriList.ClearBoolSigAction(UIBoolJoin.VolumeUpPress); + TriList.ClearBoolSigAction(UIBoolJoin.VolumeDownPress); + TriList.ClearBoolSigAction(UIBoolJoin.Volume1ProgramMutePressAndFB); + + var fDev = CurrentRoom.CurrentVolumeControls as IBasicVolumeWithFeedback; + if (fDev != null) + { + TriList.ClearUShortSigAction(UIUshortJoin.VolumeSlider1Value); + fDev.VolumeLevelFeedback.UnlinkInputSig( + TriList.UShortInput[UIUshortJoin.VolumeSlider1Value]); + } + } + + /// + /// Attaches the buttons and feedback to the room's current audio device + /// + void RefreshAudioDeviceConnections() + { + var dev = CurrentRoom.CurrentVolumeControls; + if (dev != null) // connect buttons + { + TriList.SetBoolSigAction(UIBoolJoin.VolumeUpPress, VolumeUpPress); + TriList.SetBoolSigAction(UIBoolJoin.VolumeDownPress, VolumeDownPress); + TriList.SetSigFalseAction(UIBoolJoin.Volume1ProgramMutePressAndFB, dev.MuteToggle); + } + + var fbDev = dev as IBasicVolumeWithFeedback; + if (fbDev == null) // this should catch both IBasicVolume and IBasicVolumeWithFeeback + TriList.UShortInput[UIUshortJoin.VolumeSlider1Value].UShortValue = 0; + else + { + // slider + TriList.SetUShortSigAction(UIUshortJoin.VolumeSlider1Value, fbDev.SetVolume); + // feedbacks + fbDev.MuteFeedback.LinkInputSig(TriList.BooleanInput[UIBoolJoin.Volume1ProgramMutePressAndFB]); + fbDev.VolumeLevelFeedback.LinkInputSig( + TriList.UShortInput[UIUshortJoin.VolumeSlider1Value]); + } + } + + /// + /// Handler for when the room's volume control device changes + /// + void CurrentRoom_CurrentAudioDeviceChange(object sender, VolumeDeviceChangeEventArgs args) + { + if (args.Type == ChangeType.WillChange) + ClearAudioDeviceConnections(); + else // did change + RefreshAudioDeviceConnections(); + } + + /// + /// Handles source change + /// + void CurrentRoom_SourceInfoChange(SourceListItem info, ChangeType change) + { + if (change == ChangeType.WillChange) + DisconnectSource(info); + else + RefreshSourceInfo(); + } + } + + /// + /// For hanging off various common AV things that child drivers might need from a parent AV driver + /// + public interface IAVDriver + { + PanelDriverBase Parent { get; } + JoinedSigInterlock PopupInterlock { get; } + void ShowNotificationRibbon(string message, int timeout); + void HideNotificationRibbon(); + void ShowTech(); + uint StartPageVisibleJoin { get; } + } + + /// + /// For hanging off various common VC things that child drivers might need from a parent AV driver + /// + public interface IAVWithVCDriver : IAVDriver + { + IEssentialsHuddleVtc1Room CurrentRoom { get; } + + PepperDash.Essentials.Core.Touchpanels.Keyboards.HabaneroKeyboardController Keyboard { get; } + /// + /// Exposes the ability to switch into call mode + /// + void ActivityCallButtonPressed(); + /// + /// Allows the codec to trigger the main UI to clear up if call is coming in. + /// + void PrepareForCodecIncomingCall(); + + uint CallListOrMeetingInfoPopoverVisibilityJoin { get; } + + SubpageReferenceList MeetingOrContactMethodModalSrl { get; } + } +} diff --git a/PepperDashEssentials/UIDrivers/JoinedSigInterlock.cs b/src/PepperDashEssentials/UIDrivers/JoinedSigInterlock.cs similarity index 96% rename from PepperDashEssentials/UIDrivers/JoinedSigInterlock.cs rename to src/PepperDashEssentials/UIDrivers/JoinedSigInterlock.cs index a7dba246..bdcaa84e 100644 --- a/PepperDashEssentials/UIDrivers/JoinedSigInterlock.cs +++ b/src/PepperDashEssentials/UIDrivers/JoinedSigInterlock.cs @@ -1,175 +1,175 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DeviceSupport; - -using PepperDash.Core; -using PepperDash.Essentials.Core; - -namespace PepperDash.Essentials -{ - public class JoinedSigInterlock - { - public uint CurrentJoin { get; private set; } - - BasicTriList TriList; - - public BoolFeedback IsShownFeedback; - - public event EventHandler StatusChanged; - - bool _IsShown; - - public bool IsShown - { - get - { - return _IsShown; - } - private set - { - _IsShown = value; - IsShownFeedback.FireUpdate(); - } - } - - //public BoolFeedback ShownFeedback { get; private set; } - - public JoinedSigInterlock(BasicTriList triList) - { - TriList = triList; - - IsShownFeedback = new BoolFeedback(new Func( () => _IsShown)); - } - - /// - /// Hides CurrentJoin and shows join. Will check and re-set signal if join - /// equals CurrentJoin - /// - public void ShowInterlocked(uint join) - { - var prevJoin = CurrentJoin; - var wasShown = _IsShown; - //Debug.Console(2, "Trilist {0:X2}, interlock swapping {1} for {2}", TriList.ID, CurrentJoin, join); - if (CurrentJoin == join && TriList.BooleanInput[join].BoolValue) - return; - SetButDontShow(join); - TriList.SetBool(CurrentJoin, true); - IsShown = true; - - OnStatusChange(prevJoin, CurrentJoin, wasShown, IsShown); - } - - /// - /// - /// - /// - public void ShowInterlockedWithToggle(uint join) - { - var prevJoin = CurrentJoin; - var wasShown = IsShown; - - //Debug.Console(2, "Trilist {0:X2}, interlock swapping {1} for {2}", TriList.ID, CurrentJoin, join); - if (CurrentJoin == join) - HideAndClear(); - else - { - if (CurrentJoin > 0) - TriList.BooleanInput[CurrentJoin].BoolValue = false; - CurrentJoin = join; - TriList.BooleanInput[CurrentJoin].BoolValue = true; - IsShown = true; - - OnStatusChange(prevJoin, CurrentJoin, wasShown, IsShown); - } - } - /// - /// Hides current join and clears CurrentJoin - /// - public void HideAndClear() - { - var prevJoin = CurrentJoin; - var wasShown = IsShown; - //Debug.Console(2, "Trilist {0:X2}, interlock hiding {1}", TriList.ID, CurrentJoin); - Hide(); - CurrentJoin = 0; - - OnStatusChange(prevJoin, CurrentJoin, wasShown, IsShown); - } - - /// - /// Hides the current join but does not clear the selected join in case - /// it needs to be reshown - /// - public void Hide() - { - var prevJoin = CurrentJoin; - var wasShown = IsShown; - - //Debug.Console(2, "Trilist {0:X2}, interlock hiding {1}", TriList.ID, CurrentJoin); - if (CurrentJoin > 0) - { - TriList.BooleanInput[CurrentJoin].BoolValue = false; - IsShown = false; - OnStatusChange(prevJoin, CurrentJoin, wasShown, IsShown); - } - } - - /// - /// If CurrentJoin is set, it restores that join - /// - public void Show() - { - var prevJoin = CurrentJoin; - var wasShown = IsShown; - - //Debug.Console(2, "Trilist {0:X2}, interlock showing {1}", TriList.ID, CurrentJoin); - if (CurrentJoin > 0) - { - TriList.BooleanInput[CurrentJoin].BoolValue = true; - IsShown = true; - - OnStatusChange(prevJoin, CurrentJoin, wasShown, IsShown); - } - } - - /// - /// Useful for pre-setting the interlock but not enabling it. Sets CurrentJoin - /// - /// - public void SetButDontShow(uint join) - { - if (CurrentJoin > 0) - { - TriList.BooleanInput[CurrentJoin].BoolValue = false; - IsShown = false; - } - CurrentJoin = join; - } - - void OnStatusChange(uint prevJoin, uint newJoin, bool wasShown, bool isShown) - { - var handler = StatusChanged; - if (handler != null) - handler(this, new StatusChangedEventArgs(prevJoin, newJoin, wasShown, isShown)); - } - } - - public class StatusChangedEventArgs : EventArgs - { - public uint PreviousJoin { get; set; } - public uint NewJoin { get; set; } - public bool WasShown { get; set; } - public bool IsShown { get; set; } - - public StatusChangedEventArgs(uint prevJoin, uint newJoin, bool wasShown, bool isShown) - { - PreviousJoin = prevJoin; - NewJoin = newJoin; - WasShown = wasShown; - IsShown = isShown; - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DeviceSupport; + +using PepperDash.Core; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials +{ + public class JoinedSigInterlock + { + public uint CurrentJoin { get; private set; } + + BasicTriList TriList; + + public BoolFeedback IsShownFeedback; + + public event EventHandler StatusChanged; + + bool _IsShown; + + public bool IsShown + { + get + { + return _IsShown; + } + private set + { + _IsShown = value; + IsShownFeedback.FireUpdate(); + } + } + + //public BoolFeedback ShownFeedback { get; private set; } + + public JoinedSigInterlock(BasicTriList triList) + { + TriList = triList; + + IsShownFeedback = new BoolFeedback(new Func( () => _IsShown)); + } + + /// + /// Hides CurrentJoin and shows join. Will check and re-set signal if join + /// equals CurrentJoin + /// + public void ShowInterlocked(uint join) + { + var prevJoin = CurrentJoin; + var wasShown = _IsShown; + //Debug.Console(2, "Trilist {0:X2}, interlock swapping {1} for {2}", TriList.ID, CurrentJoin, join); + if (CurrentJoin == join && TriList.BooleanInput[join].BoolValue) + return; + SetButDontShow(join); + TriList.SetBool(CurrentJoin, true); + IsShown = true; + + OnStatusChange(prevJoin, CurrentJoin, wasShown, IsShown); + } + + /// + /// + /// + /// + public void ShowInterlockedWithToggle(uint join) + { + var prevJoin = CurrentJoin; + var wasShown = IsShown; + + //Debug.Console(2, "Trilist {0:X2}, interlock swapping {1} for {2}", TriList.ID, CurrentJoin, join); + if (CurrentJoin == join) + HideAndClear(); + else + { + if (CurrentJoin > 0) + TriList.BooleanInput[CurrentJoin].BoolValue = false; + CurrentJoin = join; + TriList.BooleanInput[CurrentJoin].BoolValue = true; + IsShown = true; + + OnStatusChange(prevJoin, CurrentJoin, wasShown, IsShown); + } + } + /// + /// Hides current join and clears CurrentJoin + /// + public void HideAndClear() + { + var prevJoin = CurrentJoin; + var wasShown = IsShown; + //Debug.Console(2, "Trilist {0:X2}, interlock hiding {1}", TriList.ID, CurrentJoin); + Hide(); + CurrentJoin = 0; + + OnStatusChange(prevJoin, CurrentJoin, wasShown, IsShown); + } + + /// + /// Hides the current join but does not clear the selected join in case + /// it needs to be reshown + /// + public void Hide() + { + var prevJoin = CurrentJoin; + var wasShown = IsShown; + + //Debug.Console(2, "Trilist {0:X2}, interlock hiding {1}", TriList.ID, CurrentJoin); + if (CurrentJoin > 0) + { + TriList.BooleanInput[CurrentJoin].BoolValue = false; + IsShown = false; + OnStatusChange(prevJoin, CurrentJoin, wasShown, IsShown); + } + } + + /// + /// If CurrentJoin is set, it restores that join + /// + public void Show() + { + var prevJoin = CurrentJoin; + var wasShown = IsShown; + + //Debug.Console(2, "Trilist {0:X2}, interlock showing {1}", TriList.ID, CurrentJoin); + if (CurrentJoin > 0) + { + TriList.BooleanInput[CurrentJoin].BoolValue = true; + IsShown = true; + + OnStatusChange(prevJoin, CurrentJoin, wasShown, IsShown); + } + } + + /// + /// Useful for pre-setting the interlock but not enabling it. Sets CurrentJoin + /// + /// + public void SetButDontShow(uint join) + { + if (CurrentJoin > 0) + { + TriList.BooleanInput[CurrentJoin].BoolValue = false; + IsShown = false; + } + CurrentJoin = join; + } + + void OnStatusChange(uint prevJoin, uint newJoin, bool wasShown, bool isShown) + { + var handler = StatusChanged; + if (handler != null) + handler(this, new StatusChangedEventArgs(prevJoin, newJoin, wasShown, isShown)); + } + } + + public class StatusChangedEventArgs : EventArgs + { + public uint PreviousJoin { get; set; } + public uint NewJoin { get; set; } + public bool WasShown { get; set; } + public bool IsShown { get; set; } + + public StatusChangedEventArgs(uint prevJoin, uint newJoin, bool wasShown, bool isShown) + { + PreviousJoin = prevJoin; + NewJoin = newJoin; + WasShown = wasShown; + IsShown = isShown; + } + } } \ No newline at end of file diff --git a/PepperDashEssentials/UIDrivers/Page Drivers/SingleSubpageModalAndBackDriver.cs b/src/PepperDashEssentials/UIDrivers/Page Drivers/SingleSubpageModalAndBackDriver.cs similarity index 100% rename from PepperDashEssentials/UIDrivers/Page Drivers/SingleSubpageModalAndBackDriver.cs rename to src/PepperDashEssentials/UIDrivers/Page Drivers/SingleSubpageModalAndBackDriver.cs diff --git a/PepperDashEssentials/UIDrivers/Page Drivers/SingleSubpageModalDriver.cs b/src/PepperDashEssentials/UIDrivers/Page Drivers/SingleSubpageModalDriver.cs similarity index 100% rename from PepperDashEssentials/UIDrivers/Page Drivers/SingleSubpageModalDriver.cs rename to src/PepperDashEssentials/UIDrivers/Page Drivers/SingleSubpageModalDriver.cs diff --git a/PepperDashEssentials/UIDrivers/ScreenSaverController.cs b/src/PepperDashEssentials/UIDrivers/ScreenSaverController.cs similarity index 100% rename from PepperDashEssentials/UIDrivers/ScreenSaverController.cs rename to src/PepperDashEssentials/UIDrivers/ScreenSaverController.cs diff --git a/PepperDashEssentials/UIDrivers/SigInterlock.cs b/src/PepperDashEssentials/UIDrivers/SigInterlock.cs similarity index 100% rename from PepperDashEssentials/UIDrivers/SigInterlock.cs rename to src/PepperDashEssentials/UIDrivers/SigInterlock.cs diff --git a/PepperDashEssentials/UIDrivers/SmartObjectRoomsList.cs b/src/PepperDashEssentials/UIDrivers/SmartObjectRoomsList.cs similarity index 100% rename from PepperDashEssentials/UIDrivers/SmartObjectRoomsList.cs rename to src/PepperDashEssentials/UIDrivers/SmartObjectRoomsList.cs diff --git a/PepperDashEssentials/UIDrivers/SourceChangeArgs.cs b/src/PepperDashEssentials/UIDrivers/SourceChangeArgs.cs similarity index 100% rename from PepperDashEssentials/UIDrivers/SourceChangeArgs.cs rename to src/PepperDashEssentials/UIDrivers/SourceChangeArgs.cs diff --git a/PepperDashEssentials/UIDrivers/VC/EssentialsVideoCodecUiDriver.cs b/src/PepperDashEssentials/UIDrivers/VC/EssentialsVideoCodecUiDriver.cs similarity index 100% rename from PepperDashEssentials/UIDrivers/VC/EssentialsVideoCodecUiDriver.cs rename to src/PepperDashEssentials/UIDrivers/VC/EssentialsVideoCodecUiDriver.cs diff --git a/PepperDashEssentials/UIDrivers/VC/EssentialsVideoCodecUiDriver.cs.orig b/src/PepperDashEssentials/UIDrivers/VC/EssentialsVideoCodecUiDriver.cs.orig similarity index 100% rename from PepperDashEssentials/UIDrivers/VC/EssentialsVideoCodecUiDriver.cs.orig rename to src/PepperDashEssentials/UIDrivers/VC/EssentialsVideoCodecUiDriver.cs.orig diff --git a/PepperDashEssentials/UIDrivers/enums and base.cs b/src/PepperDashEssentials/UIDrivers/enums and base.cs similarity index 100% rename from PepperDashEssentials/UIDrivers/enums and base.cs rename to src/PepperDashEssentials/UIDrivers/enums and base.cs diff --git a/PepperDashEssentials/app.config b/src/PepperDashEssentials/app.config similarity index 100% rename from PepperDashEssentials/app.config rename to src/PepperDashEssentials/app.config diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase.sln b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase.sln similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase.sln rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase.sln diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/BridgeBase.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/BridgeBase.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/BridgeBase.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/BridgeBase.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/IBridge.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/IBridge.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/IBridge.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/IBridge.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/AirMediaControllerJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/AirMediaControllerJoinMap.cs similarity index 98% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/AirMediaControllerJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/AirMediaControllerJoinMap.cs index 170da721..2e4e9e1c 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/AirMediaControllerJoinMap.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/AirMediaControllerJoinMap.cs @@ -1,83 +1,83 @@ -using System; - -namespace PepperDash.Essentials.Core.Bridges -{ - public class AirMediaControllerJoinMap : JoinMapBaseAdvanced - { - [JoinName("IsOnline")] - public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Air Media Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("IsInSession")] - public JoinDataComplete IsInSession = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "Air Media In Sharing Session", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("HdmiVideoSync")] - public JoinDataComplete HdmiVideoSync = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, - new JoinMetadata { Description = "Air Media Has HDMI Video Sync", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("AutomaticInputRoutingEnabled")] - public JoinDataComplete AutomaticInputRoutingEnabled = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, - new JoinMetadata { Description = "Air Media Automatic Input Routing Enable(d)", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("HdmiInHdcpSupportOn")] - public JoinDataComplete HdmiInHdcpSupportOn = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, - new JoinMetadata { Description = "Turns on HDCP support for HDMI in. Reports state as FB", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("HdmiInHdcpSupportOff")] - public JoinDataComplete HdmiInHdcpSupportOff = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, - new JoinMetadata { Description = "Turns off HDCP support for HDMI in. Reports state as FB", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("HdmiInDisabledByHdcp")] - public JoinDataComplete HdmiInDisabledByHdcp = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, - new JoinMetadata { Description = "Reports if ", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("VideoOut")] - public JoinDataComplete VideoOut = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Air Media Video Route Select / Feedback", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("ErrorFB")] - public JoinDataComplete ErrorFB = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "Air Media Error Status", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("NumberOfUsersConnectedFB")] - public JoinDataComplete NumberOfUsersConnectedFB = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, - new JoinMetadata { Description = "Air Media Number of Users Connected", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("LoginCode")] - public JoinDataComplete LoginCode = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, - new JoinMetadata { Description = "Air Media Login Code Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("Name")] - public JoinDataComplete Name = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Air Media Device Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("ConnectionAddressFB")] - public JoinDataComplete ConnectionAddressFB = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "Air Media IP Address", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("HostnameFB")] - public JoinDataComplete HostnameFB = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, - new JoinMetadata { Description = "Air Media Hostname", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("SerialNumberFeedback")] - public JoinDataComplete SerialNumberFeedback = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, - new JoinMetadata { Description = "Air Media Serial Number", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - /// - /// Constructor to use when instantiating this Join Map without inheriting from it - /// - /// Join this join map will start at - public AirMediaControllerJoinMap(uint joinStart) - : this(joinStart, typeof(AirMediaControllerJoinMap)) - { - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// Type of the child join map - protected AirMediaControllerJoinMap(uint joinStart, Type type) : base(joinStart, type){} - } +using System; + +namespace PepperDash.Essentials.Core.Bridges +{ + public class AirMediaControllerJoinMap : JoinMapBaseAdvanced + { + [JoinName("IsOnline")] + public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Air Media Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("IsInSession")] + public JoinDataComplete IsInSession = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "Air Media In Sharing Session", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("HdmiVideoSync")] + public JoinDataComplete HdmiVideoSync = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "Air Media Has HDMI Video Sync", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("AutomaticInputRoutingEnabled")] + public JoinDataComplete AutomaticInputRoutingEnabled = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "Air Media Automatic Input Routing Enable(d)", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("HdmiInHdcpSupportOn")] + public JoinDataComplete HdmiInHdcpSupportOn = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "Turns on HDCP support for HDMI in. Reports state as FB", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("HdmiInHdcpSupportOff")] + public JoinDataComplete HdmiInHdcpSupportOff = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata { Description = "Turns off HDCP support for HDMI in. Reports state as FB", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("HdmiInDisabledByHdcp")] + public JoinDataComplete HdmiInDisabledByHdcp = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, + new JoinMetadata { Description = "Reports if ", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("VideoOut")] + public JoinDataComplete VideoOut = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Air Media Video Route Select / Feedback", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("ErrorFB")] + public JoinDataComplete ErrorFB = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "Air Media Error Status", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("NumberOfUsersConnectedFB")] + public JoinDataComplete NumberOfUsersConnectedFB = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "Air Media Number of Users Connected", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("LoginCode")] + public JoinDataComplete LoginCode = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "Air Media Login Code Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("Name")] + public JoinDataComplete Name = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Air Media Device Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("ConnectionAddressFB")] + public JoinDataComplete ConnectionAddressFB = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "Air Media IP Address", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("HostnameFB")] + public JoinDataComplete HostnameFB = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "Air Media Hostname", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("SerialNumberFeedback")] + public JoinDataComplete SerialNumberFeedback = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "Air Media Serial Number", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + /// + /// Constructor to use when instantiating this Join Map without inheriting from it + /// + /// Join this join map will start at + public AirMediaControllerJoinMap(uint joinStart) + : this(joinStart, typeof(AirMediaControllerJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected AirMediaControllerJoinMap(uint joinStart, Type type) : base(joinStart, type){} + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/AppleTvJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/AppleTvJoinMap.cs similarity index 98% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/AppleTvJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/AppleTvJoinMap.cs index 478f4e29..7a9dfa74 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/AppleTvJoinMap.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/AppleTvJoinMap.cs @@ -1,53 +1,53 @@ -using System; - -namespace PepperDash.Essentials.Core.Bridges -{ - public class AppleTvJoinMap : JoinMapBaseAdvanced - { - [JoinName("UpArrow")] - public JoinDataComplete UpArrow = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "AppleTv Nav Up", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("DnArrow")] - public JoinDataComplete DnArrow = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "AppleTv Nav Down", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("LeftArrow")] - public JoinDataComplete LeftArrow = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, - new JoinMetadata { Description = "AppleTv Nav Left", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("RightArrow")] - public JoinDataComplete RightArrow = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, - new JoinMetadata { Description = "AppleTv Nav Right", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Menu")] - public JoinDataComplete Menu = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, - new JoinMetadata { Description = "AppleTv Menu", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Select")] - public JoinDataComplete Select = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, - new JoinMetadata { Description = "AppleTv Select", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("PlayPause")] - public JoinDataComplete PlayPause = new JoinDataComplete(new JoinData { JoinNumber = 7, JoinSpan = 1 }, - new JoinMetadata { Description = "AppleTv Play/Pause", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - /// - /// Constructor to use when instantiating this Join Map without inheriting from it - /// - /// Join this join map will start at - public AppleTvJoinMap(uint joinStart) - : base(joinStart, typeof(AppleTvJoinMap)) - { - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// Type of the child join map - public AppleTvJoinMap(uint joinStart, Type type) : base(joinStart, type) - { - } - } +using System; + +namespace PepperDash.Essentials.Core.Bridges +{ + public class AppleTvJoinMap : JoinMapBaseAdvanced + { + [JoinName("UpArrow")] + public JoinDataComplete UpArrow = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "AppleTv Nav Up", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("DnArrow")] + public JoinDataComplete DnArrow = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "AppleTv Nav Down", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("LeftArrow")] + public JoinDataComplete LeftArrow = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "AppleTv Nav Left", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("RightArrow")] + public JoinDataComplete RightArrow = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "AppleTv Nav Right", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Menu")] + public JoinDataComplete Menu = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata { Description = "AppleTv Menu", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Select")] + public JoinDataComplete Select = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, + new JoinMetadata { Description = "AppleTv Select", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("PlayPause")] + public JoinDataComplete PlayPause = new JoinDataComplete(new JoinData { JoinNumber = 7, JoinSpan = 1 }, + new JoinMetadata { Description = "AppleTv Play/Pause", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + /// + /// Constructor to use when instantiating this Join Map without inheriting from it + /// + /// Join this join map will start at + public AppleTvJoinMap(uint joinStart) + : base(joinStart, typeof(AppleTvJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + public AppleTvJoinMap(uint joinStart, Type type) : base(joinStart, type) + { + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/C2nRthsControllerJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/C2nRthsControllerJoinMap.cs similarity index 98% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/C2nRthsControllerJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/C2nRthsControllerJoinMap.cs index f9618035..dd141c8e 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/C2nRthsControllerJoinMap.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/C2nRthsControllerJoinMap.cs @@ -1,45 +1,45 @@ -using System; - -namespace PepperDash.Essentials.Core.Bridges -{ - public class C2nRthsControllerJoinMap : JoinMapBaseAdvanced - { - [JoinName("IsOnline")] - public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Temp Sensor Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("TemperatureFormat")] - public JoinDataComplete TemperatureFormat = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "Temp Sensor Unit Format", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Temperature")] - public JoinDataComplete Temperature = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "Temp Sensor Temperature Feedback", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("Humidity")] - public JoinDataComplete Humidity = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, - new JoinMetadata { Description = "Temp Sensor Humidity Feedback", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("Name")] - public JoinDataComplete Name = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Temp Sensor Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - /// - /// Constructor to use when instantiating this Join Map without inheriting from it - /// - /// Join this join map will start at - public C2nRthsControllerJoinMap(uint joinStart) - : this(joinStart, typeof(C2nRthsControllerJoinMap)) - { - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// Type of the child join map - protected C2nRthsControllerJoinMap(uint joinStart, Type type) : base(joinStart, type) - { - } - } +using System; + +namespace PepperDash.Essentials.Core.Bridges +{ + public class C2nRthsControllerJoinMap : JoinMapBaseAdvanced + { + [JoinName("IsOnline")] + public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Temp Sensor Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("TemperatureFormat")] + public JoinDataComplete TemperatureFormat = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "Temp Sensor Unit Format", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Temperature")] + public JoinDataComplete Temperature = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "Temp Sensor Temperature Feedback", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("Humidity")] + public JoinDataComplete Humidity = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "Temp Sensor Humidity Feedback", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("Name")] + public JoinDataComplete Name = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Temp Sensor Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + /// + /// Constructor to use when instantiating this Join Map without inheriting from it + /// + /// Join this join map will start at + public C2nRthsControllerJoinMap(uint joinStart) + : this(joinStart, typeof(C2nRthsControllerJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected C2nRthsControllerJoinMap(uint joinStart, Type type) : base(joinStart, type) + { + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/CameraControllerJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/CameraControllerJoinMap.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/CameraControllerJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/CameraControllerJoinMap.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/CenOdtOccupancySensorBaseJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/CenOdtOccupancySensorBaseJoinMap.cs similarity index 98% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/CenOdtOccupancySensorBaseJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/CenOdtOccupancySensorBaseJoinMap.cs index 63684837..e306bf85 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/CenOdtOccupancySensorBaseJoinMap.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/CenOdtOccupancySensorBaseJoinMap.cs @@ -1,198 +1,198 @@ -using System; - -namespace PepperDash.Essentials.Core.Bridges -{ - public class CenOdtOccupancySensorBaseJoinMap : JoinMapBaseAdvanced - { - #region Digitals - - [JoinName("Online")] - public JoinDataComplete Online = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("ForceOccupied")] - public JoinDataComplete ForceOccupied = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "Force Occupied", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("ForceVacant")] - public JoinDataComplete ForceVacant = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, - new JoinMetadata { Description = "Force Vacant", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("EnableRawStates")] - public JoinDataComplete EnableRawStates = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, - new JoinMetadata { Description = "Enable Raw States", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("RoomOccupiedFeedback")] - public JoinDataComplete RoomOccupiedFeedback = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "Room Occupied Feedback", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("GraceOccupancyDetectedFeedback")] - public JoinDataComplete GraceOccupancyDetectedFeedback = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, - new JoinMetadata { Description = "Grace Occupancy Detected Feedback", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("RoomVacantFeedback")] - public JoinDataComplete RoomVacantFeedback = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, - new JoinMetadata { Description = "Room Vacant Feedback", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("RawOccupancyFeedback")] - public JoinDataComplete RawOccupancyFeedback = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, - new JoinMetadata { Description = "Raw Occupancy Feedback", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("RawOccupancyPirFeedback")] - public JoinDataComplete RawOccupancyPirFeedback = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, - new JoinMetadata { Description = "Raw Occupancy Pir Feedback", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("RawOccupancyUsFeedback")] - public JoinDataComplete RawOccupancyUsFeedback = new JoinDataComplete(new JoinData { JoinNumber = 7, JoinSpan = 1 }, - new JoinMetadata { Description = "Raw Occupancy Us Feedback", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("IdentityModeOn")] - public JoinDataComplete IdentityMode = new JoinDataComplete(new JoinData { JoinNumber = 8, JoinSpan = 1 }, - new JoinMetadata { Description = "Enable Identity Mode", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("IdentityModeFeedback")] - public JoinDataComplete IdentityModeFeedback = new JoinDataComplete(new JoinData { JoinNumber = 8, JoinSpan = 1 }, - new JoinMetadata { Description = "Identity Mode Feedback", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("EnableLedFlash")] - public JoinDataComplete EnableLedFlash = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, - new JoinMetadata { Description = "Enable Led Flash", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("DisableLedFlash")] - public JoinDataComplete DisableLedFlash = new JoinDataComplete(new JoinData { JoinNumber = 12, JoinSpan = 1 }, - new JoinMetadata { Description = "Disable Led Flash", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("EnableShortTimeout")] - public JoinDataComplete EnableShortTimeout = new JoinDataComplete(new JoinData { JoinNumber = 13, JoinSpan = 1 }, - new JoinMetadata { Description = "Enable Short Timeout", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("DisableShortTimeout")] - public JoinDataComplete DisableShortTimeout = new JoinDataComplete(new JoinData { JoinNumber = 14, JoinSpan = 1 }, - new JoinMetadata { Description = "Disable Short Timeout", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("OrWhenVacated")] - public JoinDataComplete OrWhenVacated = new JoinDataComplete(new JoinData { JoinNumber = 15, JoinSpan = 1 }, - new JoinMetadata { Description = "Or When Vacated", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("AndWhenVacated")] - public JoinDataComplete AndWhenVacated = new JoinDataComplete(new JoinData { JoinNumber = 16, JoinSpan = 1 }, - new JoinMetadata { Description = "AndWhenVacated", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("EnableUsA")] - public JoinDataComplete EnableUsA = new JoinDataComplete(new JoinData { JoinNumber = 17, JoinSpan = 1 }, - new JoinMetadata { Description = "Enable Us A", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("DisableUsA")] - public JoinDataComplete DisableUsA = new JoinDataComplete(new JoinData { JoinNumber = 18, JoinSpan = 1 }, - new JoinMetadata { Description = "Disable Us A", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("EnableUsB")] - public JoinDataComplete EnableUsB = new JoinDataComplete(new JoinData { JoinNumber = 19, JoinSpan = 1 }, - new JoinMetadata { Description = "Enable Us B", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("DisableUsB")] - public JoinDataComplete DisableUsB = new JoinDataComplete(new JoinData { JoinNumber = 20, JoinSpan = 1 }, - new JoinMetadata { Description = "Disable Us B", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("EnablePir")] - public JoinDataComplete EnablePir = new JoinDataComplete(new JoinData { JoinNumber = 21, JoinSpan = 1 }, - new JoinMetadata { Description = "Enable Pir", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("DisablePir")] - public JoinDataComplete DisablePir = new JoinDataComplete(new JoinData { JoinNumber = 22, JoinSpan = 1 }, - new JoinMetadata { Description = "Disable Pir", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("IncrementUsInOccupiedState")] - public JoinDataComplete IncrementUsInOccupiedState = new JoinDataComplete(new JoinData { JoinNumber = 23, JoinSpan = 1 }, - new JoinMetadata { Description = "Increment Us In OccupiedState", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("DecrementUsInOccupiedState")] - public JoinDataComplete DecrementUsInOccupiedState = new JoinDataComplete(new JoinData { JoinNumber = 24, JoinSpan = 1 }, - new JoinMetadata { Description = "Dencrement Us In Occupied State", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("IncrementUsInVacantState")] - public JoinDataComplete IncrementUsInVacantState = new JoinDataComplete(new JoinData { JoinNumber = 25, JoinSpan = 1 }, - new JoinMetadata { Description = "Increment Us In VacantState", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("DecrementUsInVacantState")] - public JoinDataComplete DecrementUsInVacantState = new JoinDataComplete(new JoinData { JoinNumber = 26, JoinSpan = 1 }, - new JoinMetadata { Description = "Decrement Us In VacantState", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("IncrementPirInOccupiedState")] - public JoinDataComplete IncrementPirInOccupiedState = new JoinDataComplete(new JoinData { JoinNumber = 27, JoinSpan = 1 }, - new JoinMetadata { Description = "Increment Pir In Occupied State", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("DecrementPirInOccupiedState")] - public JoinDataComplete DecrementPirInOccupiedState = new JoinDataComplete(new JoinData { JoinNumber = 28, JoinSpan = 1 }, - new JoinMetadata { Description = "Decrement Pir In OccupiedState", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("IncrementPirInVacantState")] - public JoinDataComplete IncrementPirInVacantState = new JoinDataComplete(new JoinData { JoinNumber = 29, JoinSpan = 1 }, - new JoinMetadata { Description = "Increment Pir In Vacant State", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("DecrementPirInVacantState")] - public JoinDataComplete DecrementPirInVacantState = new JoinDataComplete(new JoinData { JoinNumber = 30, JoinSpan = 1 }, - new JoinMetadata { Description = "Decrement Pir In Vacant State", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - #endregion - - #region Analog - - [JoinName("Timeout")] - public JoinDataComplete Timeout = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Timeout", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("TimeoutLocalFeedback")] - public JoinDataComplete TimeoutLocalFeedback = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "Timeout Local Feedback", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("InternalPhotoSensorValue")] - public JoinDataComplete InternalPhotoSensorValue = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, - new JoinMetadata { Description = "Internal PhotoSensor Value", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("UsSensitivityInOccupiedState")] - public JoinDataComplete UsSensitivityInOccupiedState = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, - new JoinMetadata { Description = "Us Sensitivity In Occupied State", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("UsSensitivityInVacantState")] - public JoinDataComplete UsSensitivityInVacantState = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, - new JoinMetadata { Description = "Us Sensitivity In Vacant State", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("PirSensitivityInOccupiedState")] - public JoinDataComplete PirSensitivityInOccupiedState = new JoinDataComplete(new JoinData { JoinNumber = 7, JoinSpan = 1 }, - new JoinMetadata { Description = "Pir Sensitivity In Occupied State", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("PirSensitivityInVacantState")] - public JoinDataComplete PirSensitivityInVacantState = new JoinDataComplete(new JoinData { JoinNumber = 8, JoinSpan = 1 }, - new JoinMetadata { Description = "Pir Sensitivity In Vacant State", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - #endregion - - #region Serial - - [JoinName("Name")] - public JoinDataComplete Name = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - #endregion - - /// - /// Constructor to use when instantiating this Join Map without inheriting from it - /// - /// Join this join map will start at - public CenOdtOccupancySensorBaseJoinMap(uint joinStart) - : this(joinStart, typeof(CenOdtOccupancySensorBaseJoinMap)) - { - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// Type of the child join map - protected CenOdtOccupancySensorBaseJoinMap(uint joinStart, Type type) : base(joinStart, type) - { - } - } - -} +using System; + +namespace PepperDash.Essentials.Core.Bridges +{ + public class CenOdtOccupancySensorBaseJoinMap : JoinMapBaseAdvanced + { + #region Digitals + + [JoinName("Online")] + public JoinDataComplete Online = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("ForceOccupied")] + public JoinDataComplete ForceOccupied = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "Force Occupied", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("ForceVacant")] + public JoinDataComplete ForceVacant = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "Force Vacant", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("EnableRawStates")] + public JoinDataComplete EnableRawStates = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "Enable Raw States", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("RoomOccupiedFeedback")] + public JoinDataComplete RoomOccupiedFeedback = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "Room Occupied Feedback", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("GraceOccupancyDetectedFeedback")] + public JoinDataComplete GraceOccupancyDetectedFeedback = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "Grace Occupancy Detected Feedback", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("RoomVacantFeedback")] + public JoinDataComplete RoomVacantFeedback = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "Room Vacant Feedback", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("RawOccupancyFeedback")] + public JoinDataComplete RawOccupancyFeedback = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata { Description = "Raw Occupancy Feedback", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("RawOccupancyPirFeedback")] + public JoinDataComplete RawOccupancyPirFeedback = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, + new JoinMetadata { Description = "Raw Occupancy Pir Feedback", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("RawOccupancyUsFeedback")] + public JoinDataComplete RawOccupancyUsFeedback = new JoinDataComplete(new JoinData { JoinNumber = 7, JoinSpan = 1 }, + new JoinMetadata { Description = "Raw Occupancy Us Feedback", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("IdentityModeOn")] + public JoinDataComplete IdentityMode = new JoinDataComplete(new JoinData { JoinNumber = 8, JoinSpan = 1 }, + new JoinMetadata { Description = "Enable Identity Mode", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("IdentityModeFeedback")] + public JoinDataComplete IdentityModeFeedback = new JoinDataComplete(new JoinData { JoinNumber = 8, JoinSpan = 1 }, + new JoinMetadata { Description = "Identity Mode Feedback", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("EnableLedFlash")] + public JoinDataComplete EnableLedFlash = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, + new JoinMetadata { Description = "Enable Led Flash", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("DisableLedFlash")] + public JoinDataComplete DisableLedFlash = new JoinDataComplete(new JoinData { JoinNumber = 12, JoinSpan = 1 }, + new JoinMetadata { Description = "Disable Led Flash", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("EnableShortTimeout")] + public JoinDataComplete EnableShortTimeout = new JoinDataComplete(new JoinData { JoinNumber = 13, JoinSpan = 1 }, + new JoinMetadata { Description = "Enable Short Timeout", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("DisableShortTimeout")] + public JoinDataComplete DisableShortTimeout = new JoinDataComplete(new JoinData { JoinNumber = 14, JoinSpan = 1 }, + new JoinMetadata { Description = "Disable Short Timeout", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("OrWhenVacated")] + public JoinDataComplete OrWhenVacated = new JoinDataComplete(new JoinData { JoinNumber = 15, JoinSpan = 1 }, + new JoinMetadata { Description = "Or When Vacated", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("AndWhenVacated")] + public JoinDataComplete AndWhenVacated = new JoinDataComplete(new JoinData { JoinNumber = 16, JoinSpan = 1 }, + new JoinMetadata { Description = "AndWhenVacated", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("EnableUsA")] + public JoinDataComplete EnableUsA = new JoinDataComplete(new JoinData { JoinNumber = 17, JoinSpan = 1 }, + new JoinMetadata { Description = "Enable Us A", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("DisableUsA")] + public JoinDataComplete DisableUsA = new JoinDataComplete(new JoinData { JoinNumber = 18, JoinSpan = 1 }, + new JoinMetadata { Description = "Disable Us A", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("EnableUsB")] + public JoinDataComplete EnableUsB = new JoinDataComplete(new JoinData { JoinNumber = 19, JoinSpan = 1 }, + new JoinMetadata { Description = "Enable Us B", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("DisableUsB")] + public JoinDataComplete DisableUsB = new JoinDataComplete(new JoinData { JoinNumber = 20, JoinSpan = 1 }, + new JoinMetadata { Description = "Disable Us B", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("EnablePir")] + public JoinDataComplete EnablePir = new JoinDataComplete(new JoinData { JoinNumber = 21, JoinSpan = 1 }, + new JoinMetadata { Description = "Enable Pir", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("DisablePir")] + public JoinDataComplete DisablePir = new JoinDataComplete(new JoinData { JoinNumber = 22, JoinSpan = 1 }, + new JoinMetadata { Description = "Disable Pir", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("IncrementUsInOccupiedState")] + public JoinDataComplete IncrementUsInOccupiedState = new JoinDataComplete(new JoinData { JoinNumber = 23, JoinSpan = 1 }, + new JoinMetadata { Description = "Increment Us In OccupiedState", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("DecrementUsInOccupiedState")] + public JoinDataComplete DecrementUsInOccupiedState = new JoinDataComplete(new JoinData { JoinNumber = 24, JoinSpan = 1 }, + new JoinMetadata { Description = "Dencrement Us In Occupied State", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("IncrementUsInVacantState")] + public JoinDataComplete IncrementUsInVacantState = new JoinDataComplete(new JoinData { JoinNumber = 25, JoinSpan = 1 }, + new JoinMetadata { Description = "Increment Us In VacantState", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("DecrementUsInVacantState")] + public JoinDataComplete DecrementUsInVacantState = new JoinDataComplete(new JoinData { JoinNumber = 26, JoinSpan = 1 }, + new JoinMetadata { Description = "Decrement Us In VacantState", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("IncrementPirInOccupiedState")] + public JoinDataComplete IncrementPirInOccupiedState = new JoinDataComplete(new JoinData { JoinNumber = 27, JoinSpan = 1 }, + new JoinMetadata { Description = "Increment Pir In Occupied State", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("DecrementPirInOccupiedState")] + public JoinDataComplete DecrementPirInOccupiedState = new JoinDataComplete(new JoinData { JoinNumber = 28, JoinSpan = 1 }, + new JoinMetadata { Description = "Decrement Pir In OccupiedState", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("IncrementPirInVacantState")] + public JoinDataComplete IncrementPirInVacantState = new JoinDataComplete(new JoinData { JoinNumber = 29, JoinSpan = 1 }, + new JoinMetadata { Description = "Increment Pir In Vacant State", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("DecrementPirInVacantState")] + public JoinDataComplete DecrementPirInVacantState = new JoinDataComplete(new JoinData { JoinNumber = 30, JoinSpan = 1 }, + new JoinMetadata { Description = "Decrement Pir In Vacant State", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + #endregion + + #region Analog + + [JoinName("Timeout")] + public JoinDataComplete Timeout = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Timeout", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("TimeoutLocalFeedback")] + public JoinDataComplete TimeoutLocalFeedback = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "Timeout Local Feedback", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("InternalPhotoSensorValue")] + public JoinDataComplete InternalPhotoSensorValue = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "Internal PhotoSensor Value", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("UsSensitivityInOccupiedState")] + public JoinDataComplete UsSensitivityInOccupiedState = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata { Description = "Us Sensitivity In Occupied State", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("UsSensitivityInVacantState")] + public JoinDataComplete UsSensitivityInVacantState = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, + new JoinMetadata { Description = "Us Sensitivity In Vacant State", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("PirSensitivityInOccupiedState")] + public JoinDataComplete PirSensitivityInOccupiedState = new JoinDataComplete(new JoinData { JoinNumber = 7, JoinSpan = 1 }, + new JoinMetadata { Description = "Pir Sensitivity In Occupied State", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("PirSensitivityInVacantState")] + public JoinDataComplete PirSensitivityInVacantState = new JoinDataComplete(new JoinData { JoinNumber = 8, JoinSpan = 1 }, + new JoinMetadata { Description = "Pir Sensitivity In Vacant State", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + #endregion + + #region Serial + + [JoinName("Name")] + public JoinDataComplete Name = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + #endregion + + /// + /// Constructor to use when instantiating this Join Map without inheriting from it + /// + /// Join this join map will start at + public CenOdtOccupancySensorBaseJoinMap(uint joinStart) + : this(joinStart, typeof(CenOdtOccupancySensorBaseJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected CenOdtOccupancySensorBaseJoinMap(uint joinStart, Type type) : base(joinStart, type) + { + } + } + +} diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DigitalLoggerJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DigitalLoggerJoinMap.cs similarity index 97% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DigitalLoggerJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DigitalLoggerJoinMap.cs index 5a7d00a6..7959a511 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DigitalLoggerJoinMap.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DigitalLoggerJoinMap.cs @@ -1,43 +1,43 @@ -using System; - -namespace PepperDash.Essentials.Core.Bridges -{ - [Obsolete("This Device will be moved to a plugin in a future update")] - public class DigitalLoggerJoinMap : JoinMapBase - { - public uint IsOnline { get; set; } - public uint CircuitNames { get; set; } - public uint CircuitState { get; set; } - public uint CircuitCycle { get; set; } - public uint CircuitIsCritical { get; set; } - public uint CircuitOnCmd { get; set; } - public uint CircuitOffCmd { get; set; } - - public DigitalLoggerJoinMap() - { - // Digital - IsOnline = 9; - CircuitState = 0; - CircuitCycle = 0; - CircuitIsCritical = 10; - CircuitOnCmd = 10; - CircuitOffCmd = 20; - // Serial - CircuitNames = 0; - // Analog - } - - public override void OffsetJoinNumbers(uint joinStart) - { - var joinOffset = joinStart - 1; - - IsOnline = IsOnline + joinOffset; - CircuitNames = CircuitNames + joinOffset; - CircuitState = CircuitState + joinOffset; - CircuitCycle = CircuitCycle + joinOffset; - CircuitIsCritical = CircuitIsCritical + joinOffset; - CircuitOnCmd = CircuitOnCmd + joinOffset; - CircuitOffCmd = CircuitOffCmd + joinOffset; - } - } +using System; + +namespace PepperDash.Essentials.Core.Bridges +{ + [Obsolete("This Device will be moved to a plugin in a future update")] + public class DigitalLoggerJoinMap : JoinMapBase + { + public uint IsOnline { get; set; } + public uint CircuitNames { get; set; } + public uint CircuitState { get; set; } + public uint CircuitCycle { get; set; } + public uint CircuitIsCritical { get; set; } + public uint CircuitOnCmd { get; set; } + public uint CircuitOffCmd { get; set; } + + public DigitalLoggerJoinMap() + { + // Digital + IsOnline = 9; + CircuitState = 0; + CircuitCycle = 0; + CircuitIsCritical = 10; + CircuitOnCmd = 10; + CircuitOffCmd = 20; + // Serial + CircuitNames = 0; + // Analog + } + + public override void OffsetJoinNumbers(uint joinStart) + { + var joinOffset = joinStart - 1; + + IsOnline = IsOnline + joinOffset; + CircuitNames = CircuitNames + joinOffset; + CircuitState = CircuitState + joinOffset; + CircuitCycle = CircuitCycle + joinOffset; + CircuitIsCritical = CircuitIsCritical + joinOffset; + CircuitOnCmd = CircuitOnCmd + joinOffset; + CircuitOffCmd = CircuitOffCmd + joinOffset; + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DisplayControllerJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DisplayControllerJoinMap.cs similarity index 98% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DisplayControllerJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DisplayControllerJoinMap.cs index eaf77ed8..8e51c952 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DisplayControllerJoinMap.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DisplayControllerJoinMap.cs @@ -1,85 +1,85 @@ -using System; - -namespace PepperDash.Essentials.Core.Bridges -{ - public class DisplayControllerJoinMap : JoinMapBaseAdvanced - { - [JoinName("Name")] - public JoinDataComplete Name = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("PowerOff")] - public JoinDataComplete PowerOff = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Power Off", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("PowerOn")] - public JoinDataComplete PowerOn = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "Power On", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("IsTwoWayDisplay")] - public JoinDataComplete IsTwoWayDisplay = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, - new JoinMetadata { Description = "Is Two Way Display", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("VolumeUp")] - public JoinDataComplete VolumeUp = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, - new JoinMetadata { Description = "Volume Up", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("VolumeLevel")] - public JoinDataComplete VolumeLevel = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, - new JoinMetadata { Description = "Volume Level", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("VolumeDown")] - public JoinDataComplete VolumeDown = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, - new JoinMetadata { Description = "Volume Down", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("VolumeMute")] - public JoinDataComplete VolumeMute = new JoinDataComplete(new JoinData { JoinNumber = 7, JoinSpan = 1 }, - new JoinMetadata { Description = "Volume Mute", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("VolumeMuteOn")] - public JoinDataComplete VolumeMuteOn = new JoinDataComplete(new JoinData { JoinNumber = 8, JoinSpan = 1 }, - new JoinMetadata { Description = "Volume Mute On", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("VolumeMuteOff")] - public JoinDataComplete VolumeMuteOff = new JoinDataComplete(new JoinData { JoinNumber = 9, JoinSpan = 1 }, - new JoinMetadata { Description = "Volume Mute Off", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("InputSelectOffset")] - public JoinDataComplete InputSelectOffset = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 10 }, - new JoinMetadata { Description = "Input Select", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("InputNamesOffset")] - public JoinDataComplete InputNamesOffset = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 10 }, - new JoinMetadata { Description = "Input Names Offset", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("InputSelect")] - public JoinDataComplete InputSelect = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, - new JoinMetadata { Description = "Input Select", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("ButtonVisibilityOffset")] - public JoinDataComplete ButtonVisibilityOffset = new JoinDataComplete(new JoinData { JoinNumber = 41, JoinSpan = 10 }, - new JoinMetadata { Description = "Button Visibility Offset", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.DigitalSerial }); - - [JoinName("IsOnline")] - public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 50, JoinSpan = 1 }, - new JoinMetadata { Description = "Is Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - /// - /// Constructor to use when instantiating this Join Map without inheriting from it - /// - /// Join this join map will start at - public DisplayControllerJoinMap(uint joinStart) - : this(joinStart, typeof(DisplayControllerJoinMap)) - { - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// Type of the child join map - protected DisplayControllerJoinMap(uint joinStart, Type type) : base(joinStart, type) - { - } - } +using System; + +namespace PepperDash.Essentials.Core.Bridges +{ + public class DisplayControllerJoinMap : JoinMapBaseAdvanced + { + [JoinName("Name")] + public JoinDataComplete Name = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("PowerOff")] + public JoinDataComplete PowerOff = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Power Off", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("PowerOn")] + public JoinDataComplete PowerOn = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "Power On", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("IsTwoWayDisplay")] + public JoinDataComplete IsTwoWayDisplay = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "Is Two Way Display", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("VolumeUp")] + public JoinDataComplete VolumeUp = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata { Description = "Volume Up", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("VolumeLevel")] + public JoinDataComplete VolumeLevel = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata { Description = "Volume Level", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("VolumeDown")] + public JoinDataComplete VolumeDown = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, + new JoinMetadata { Description = "Volume Down", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("VolumeMute")] + public JoinDataComplete VolumeMute = new JoinDataComplete(new JoinData { JoinNumber = 7, JoinSpan = 1 }, + new JoinMetadata { Description = "Volume Mute", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("VolumeMuteOn")] + public JoinDataComplete VolumeMuteOn = new JoinDataComplete(new JoinData { JoinNumber = 8, JoinSpan = 1 }, + new JoinMetadata { Description = "Volume Mute On", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("VolumeMuteOff")] + public JoinDataComplete VolumeMuteOff = new JoinDataComplete(new JoinData { JoinNumber = 9, JoinSpan = 1 }, + new JoinMetadata { Description = "Volume Mute Off", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("InputSelectOffset")] + public JoinDataComplete InputSelectOffset = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 10 }, + new JoinMetadata { Description = "Input Select", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("InputNamesOffset")] + public JoinDataComplete InputNamesOffset = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 10 }, + new JoinMetadata { Description = "Input Names Offset", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("InputSelect")] + public JoinDataComplete InputSelect = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, + new JoinMetadata { Description = "Input Select", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("ButtonVisibilityOffset")] + public JoinDataComplete ButtonVisibilityOffset = new JoinDataComplete(new JoinData { JoinNumber = 41, JoinSpan = 10 }, + new JoinMetadata { Description = "Button Visibility Offset", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.DigitalSerial }); + + [JoinName("IsOnline")] + public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 50, JoinSpan = 1 }, + new JoinMetadata { Description = "Is Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + /// + /// Constructor to use when instantiating this Join Map without inheriting from it + /// + /// Join this join map will start at + public DisplayControllerJoinMap(uint joinStart) + : this(joinStart, typeof(DisplayControllerJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected DisplayControllerJoinMap(uint joinStart, Type type) : base(joinStart, type) + { + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmBladeChassisControllerJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmBladeChassisControllerJoinMap.cs similarity index 98% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmBladeChassisControllerJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmBladeChassisControllerJoinMap.cs index 4c9cba41..3a4c4255 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmBladeChassisControllerJoinMap.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmBladeChassisControllerJoinMap.cs @@ -1,74 +1,74 @@ -using System; - -namespace PepperDash.Essentials.Core.Bridges { - public class DmBladeChassisControllerJoinMap : JoinMapBaseAdvanced { - - [JoinName("IsOnline")] - public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, - new JoinMetadata { Description = "DM Blade Chassis Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("VideoSyncStatus")] - public JoinDataComplete VideoSyncStatus = new JoinDataComplete(new JoinData { JoinNumber = 101, JoinSpan = 128 }, - new JoinMetadata { Description = "DM Blade Input Video Sync", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("InputEndpointOnline")] - public JoinDataComplete InputEndpointOnline = new JoinDataComplete(new JoinData { JoinNumber = 501, JoinSpan = 128 }, - new JoinMetadata { Description = "DM Blade Chassis Input Endpoint Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("OutputEndpointOnline")] - public JoinDataComplete OutputEndpointOnline = new JoinDataComplete(new JoinData { JoinNumber = 701, JoinSpan = 128 }, - new JoinMetadata { Description = "DM Blade Chassis Output Endpoint Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("TxAdvancedIsPresent")] - public JoinDataComplete TxAdvancedIsPresent = new JoinDataComplete(new JoinData { JoinNumber = 1001, JoinSpan = 128 }, - new JoinMetadata { Description = "DM Blade Chassis Tx Advanced Is Present", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("OutputVideo")] - public JoinDataComplete OutputVideo = new JoinDataComplete(new JoinData { JoinNumber = 101, JoinSpan = 128 }, - new JoinMetadata { Description = "DM Blade Chassis Output Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("HdcpSupportState")] - public JoinDataComplete HdcpSupportState = new JoinDataComplete(new JoinData { JoinNumber = 1001, JoinSpan = 128 }, - new JoinMetadata { Description = "DM Blade Chassis Input HDCP Support State", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("HdcpSupportCapability")] - public JoinDataComplete HdcpSupportCapability = new JoinDataComplete(new JoinData { JoinNumber = 1201, JoinSpan = 128 }, - new JoinMetadata { Description = "DM Blade Chassis Input HDCP Support Capability", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("InputNames")] - public JoinDataComplete InputNames = new JoinDataComplete(new JoinData { JoinNumber = 101, JoinSpan = 128 }, - new JoinMetadata { Description = "DM Blade Chassis Input Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("OutputNames")] - public JoinDataComplete OutputNames = new JoinDataComplete(new JoinData { JoinNumber = 301, JoinSpan = 128 }, - new JoinMetadata { Description = "DM Blade Chassis Output Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("OutputCurrentVideoInputNames")] - public JoinDataComplete OutputCurrentVideoInputNames = new JoinDataComplete(new JoinData { JoinNumber = 2001, JoinSpan = 128 }, - new JoinMetadata { Description = "DM Blade Chassis Video Output Currently Routed Video Input Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("InputCurrentResolution")] - public JoinDataComplete InputCurrentResolution = new JoinDataComplete(new JoinData { JoinNumber = 2401, JoinSpan = 128 }, - new JoinMetadata { Description = "DM Blade Chassis Input Current Resolution", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - - /// - /// Constructor to use when instantiating this Join Map without inheriting from it - /// - /// Join this join map will start at - public DmBladeChassisControllerJoinMap(uint joinStart) - : this(joinStart, typeof(DmBladeChassisControllerJoinMap)) - { - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// Type of the child join map - protected DmBladeChassisControllerJoinMap(uint joinStart, Type type) : base(joinStart, type) - { - } - - } -} +using System; + +namespace PepperDash.Essentials.Core.Bridges { + public class DmBladeChassisControllerJoinMap : JoinMapBaseAdvanced { + + [JoinName("IsOnline")] + public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, + new JoinMetadata { Description = "DM Blade Chassis Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("VideoSyncStatus")] + public JoinDataComplete VideoSyncStatus = new JoinDataComplete(new JoinData { JoinNumber = 101, JoinSpan = 128 }, + new JoinMetadata { Description = "DM Blade Input Video Sync", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("InputEndpointOnline")] + public JoinDataComplete InputEndpointOnline = new JoinDataComplete(new JoinData { JoinNumber = 501, JoinSpan = 128 }, + new JoinMetadata { Description = "DM Blade Chassis Input Endpoint Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("OutputEndpointOnline")] + public JoinDataComplete OutputEndpointOnline = new JoinDataComplete(new JoinData { JoinNumber = 701, JoinSpan = 128 }, + new JoinMetadata { Description = "DM Blade Chassis Output Endpoint Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("TxAdvancedIsPresent")] + public JoinDataComplete TxAdvancedIsPresent = new JoinDataComplete(new JoinData { JoinNumber = 1001, JoinSpan = 128 }, + new JoinMetadata { Description = "DM Blade Chassis Tx Advanced Is Present", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("OutputVideo")] + public JoinDataComplete OutputVideo = new JoinDataComplete(new JoinData { JoinNumber = 101, JoinSpan = 128 }, + new JoinMetadata { Description = "DM Blade Chassis Output Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("HdcpSupportState")] + public JoinDataComplete HdcpSupportState = new JoinDataComplete(new JoinData { JoinNumber = 1001, JoinSpan = 128 }, + new JoinMetadata { Description = "DM Blade Chassis Input HDCP Support State", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("HdcpSupportCapability")] + public JoinDataComplete HdcpSupportCapability = new JoinDataComplete(new JoinData { JoinNumber = 1201, JoinSpan = 128 }, + new JoinMetadata { Description = "DM Blade Chassis Input HDCP Support Capability", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("InputNames")] + public JoinDataComplete InputNames = new JoinDataComplete(new JoinData { JoinNumber = 101, JoinSpan = 128 }, + new JoinMetadata { Description = "DM Blade Chassis Input Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("OutputNames")] + public JoinDataComplete OutputNames = new JoinDataComplete(new JoinData { JoinNumber = 301, JoinSpan = 128 }, + new JoinMetadata { Description = "DM Blade Chassis Output Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("OutputCurrentVideoInputNames")] + public JoinDataComplete OutputCurrentVideoInputNames = new JoinDataComplete(new JoinData { JoinNumber = 2001, JoinSpan = 128 }, + new JoinMetadata { Description = "DM Blade Chassis Video Output Currently Routed Video Input Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("InputCurrentResolution")] + public JoinDataComplete InputCurrentResolution = new JoinDataComplete(new JoinData { JoinNumber = 2401, JoinSpan = 128 }, + new JoinMetadata { Description = "DM Blade Chassis Input Current Resolution", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + + /// + /// Constructor to use when instantiating this Join Map without inheriting from it + /// + /// Join this join map will start at + public DmBladeChassisControllerJoinMap(uint joinStart) + : this(joinStart, typeof(DmBladeChassisControllerJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected DmBladeChassisControllerJoinMap(uint joinStart, Type type) : base(joinStart, type) + { + } + + } +} diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmChassisControllerJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmChassisControllerJoinMap.cs similarity index 98% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmChassisControllerJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmChassisControllerJoinMap.cs index 114a8a9d..539e8d29 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmChassisControllerJoinMap.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmChassisControllerJoinMap.cs @@ -1,170 +1,170 @@ -using System; - -namespace PepperDash.Essentials.Core.Bridges -{ - public class DmChassisControllerJoinMap : JoinMapBaseAdvanced - { - [JoinName("EnableAudioBreakaway")] - public JoinDataComplete EnableAudioBreakaway = new JoinDataComplete( - new JoinData {JoinNumber = 4, JoinSpan = 1}, - new JoinMetadata - { - Description = "DM Chassis enable audio breakaway routing", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("EnableUsbBreakaway")] - public JoinDataComplete EnableUsbBreakaway = new JoinDataComplete( - new JoinData { JoinNumber = 5, JoinSpan = 1 }, - new JoinMetadata - { - Description = "DM Chassis enable USB breakaway routing", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("Name")] - public JoinDataComplete Name = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "DM Chassis Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("SystemId")] - public JoinDataComplete SystemId = new JoinDataComplete(new JoinData { JoinNumber = 10, JoinSpan = 1 }, - new JoinMetadata { Description = "DM Chassis SystemId Get/Set/Trigger/", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.DigitalAnalog }); - - [JoinName("IsOnline")] - public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, - new JoinMetadata { Description = "DM Chassis Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("VideoSyncStatus")] - public JoinDataComplete VideoSyncStatus = new JoinDataComplete(new JoinData { JoinNumber = 101, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Input Video Sync", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("InputEndpointOnline")] - public JoinDataComplete InputEndpointOnline = new JoinDataComplete(new JoinData { JoinNumber = 501, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Chassis Input Endpoint Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("OutputEndpointOnline")] - public JoinDataComplete OutputEndpointOnline = new JoinDataComplete(new JoinData { JoinNumber = 701, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Chassis Output Endpoint Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("TxAdvancedIsPresent")] - public JoinDataComplete TxAdvancedIsPresent = new JoinDataComplete(new JoinData { JoinNumber = 1001, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Chassis Tx Advanced Is Present", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("OutputDisabledByHdcp")] - public JoinDataComplete OutputDisabledByHdcp = new JoinDataComplete(new JoinData { JoinNumber = 1201, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Chassis Output Disabled by HDCP", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("OutputVideo")] - public JoinDataComplete OutputVideo = new JoinDataComplete(new JoinData { JoinNumber = 101, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Chassis Output Video Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("OutputAudio")] - public JoinDataComplete OutputAudio = new JoinDataComplete(new JoinData { JoinNumber = 301, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Chassis Output Audio Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("OutputUsb")] - public JoinDataComplete OutputUsb = new JoinDataComplete(new JoinData { JoinNumber = 501, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Chassis Output USB Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("InputUsb")] - public JoinDataComplete InputUsb = new JoinDataComplete(new JoinData { JoinNumber = 701, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Chassis Input Usb Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("HdcpSupportState")] - public JoinDataComplete HdcpSupportState = new JoinDataComplete(new JoinData { JoinNumber = 1001, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Chassis Input HDCP Support State", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("HdcpSupportCapability")] - public JoinDataComplete HdcpSupportCapability = new JoinDataComplete(new JoinData { JoinNumber = 1201, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Chassis Input HDCP Support Capability", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("InputStreamCardState")] - public JoinDataComplete InputStreamCardState = new JoinDataComplete(new JoinData { JoinNumber = 1501, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Chassis Stream Input Start (1), Stop (2), Pause (3) with Feedback", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("OutputStreamCardState")] - public JoinDataComplete OutputStreamCardState = new JoinDataComplete(new JoinData { JoinNumber = 1601, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Chassis Stream Output Start (1), Stop (2), Pause (3) with Feedback", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("NoRouteName")] - public JoinDataComplete NoRouteName = new JoinDataComplete(new JoinData { JoinNumber = 100, JoinSpan = 1 }, - new JoinMetadata { Description = "DM Chassis Input Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("InputNames")] - public JoinDataComplete InputNames = new JoinDataComplete(new JoinData { JoinNumber = 101, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Chassis Input Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("OutputNames")] - public JoinDataComplete OutputNames = new JoinDataComplete(new JoinData { JoinNumber = 301, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Chassis Output Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("InputVideoNames")] public JoinDataComplete InputVideoNames = - new JoinDataComplete(new JoinData {JoinNumber = 501, JoinSpan = 200}, - new JoinMetadata - { - Description = "DM Chassis Video Input Names", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("InputAudioNames")] - public JoinDataComplete InputAudioNames = - new JoinDataComplete(new JoinData { JoinNumber = 701, JoinSpan = 200 }, - new JoinMetadata - { - Description = "DM Chassis Audio Input Names", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Serial - }); - [JoinName("OutputVideoNames")] - public JoinDataComplete OutputVideoNames = - new JoinDataComplete(new JoinData { JoinNumber = 901, JoinSpan = 200 }, - new JoinMetadata - { - Description = "DM Chassis Video Output Names", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Serial - }); - [JoinName("OutputAudioNames")] - public JoinDataComplete OutputAudioNames = - new JoinDataComplete(new JoinData { JoinNumber = 1101, JoinSpan = 200 }, - new JoinMetadata - { - Description = "DM Chassis Audio Output Names", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("OutputCurrentVideoInputNames")] - public JoinDataComplete OutputCurrentVideoInputNames = new JoinDataComplete(new JoinData { JoinNumber = 2001, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Chassis Video Output Currently Routed Video Input Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("OutputCurrentAudioInputNames")] - public JoinDataComplete OutputCurrentAudioInputNames = new JoinDataComplete(new JoinData { JoinNumber = 2201, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Chassis Audio Output Currently Routed Video Input Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("InputCurrentResolution")] - public JoinDataComplete InputCurrentResolution = new JoinDataComplete(new JoinData { JoinNumber = 2401, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Chassis Input Current Resolution", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - /// - /// Constructor to use when instantiating this Join Map without inheriting from it - /// - /// Join this join map will start at - public DmChassisControllerJoinMap(uint joinStart) - : this(joinStart, typeof(DmChassisControllerJoinMap)) - { - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// Type of the child join map - protected DmChassisControllerJoinMap(uint joinStart, Type type) : base(joinStart, type) - { - } - } -} +using System; + +namespace PepperDash.Essentials.Core.Bridges +{ + public class DmChassisControllerJoinMap : JoinMapBaseAdvanced + { + [JoinName("EnableAudioBreakaway")] + public JoinDataComplete EnableAudioBreakaway = new JoinDataComplete( + new JoinData {JoinNumber = 4, JoinSpan = 1}, + new JoinMetadata + { + Description = "DM Chassis enable audio breakaway routing", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("EnableUsbBreakaway")] + public JoinDataComplete EnableUsbBreakaway = new JoinDataComplete( + new JoinData { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata + { + Description = "DM Chassis enable USB breakaway routing", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("Name")] + public JoinDataComplete Name = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "DM Chassis Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("SystemId")] + public JoinDataComplete SystemId = new JoinDataComplete(new JoinData { JoinNumber = 10, JoinSpan = 1 }, + new JoinMetadata { Description = "DM Chassis SystemId Get/Set/Trigger/", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.DigitalAnalog }); + + [JoinName("IsOnline")] + public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, + new JoinMetadata { Description = "DM Chassis Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("VideoSyncStatus")] + public JoinDataComplete VideoSyncStatus = new JoinDataComplete(new JoinData { JoinNumber = 101, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Input Video Sync", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("InputEndpointOnline")] + public JoinDataComplete InputEndpointOnline = new JoinDataComplete(new JoinData { JoinNumber = 501, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Chassis Input Endpoint Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("OutputEndpointOnline")] + public JoinDataComplete OutputEndpointOnline = new JoinDataComplete(new JoinData { JoinNumber = 701, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Chassis Output Endpoint Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("TxAdvancedIsPresent")] + public JoinDataComplete TxAdvancedIsPresent = new JoinDataComplete(new JoinData { JoinNumber = 1001, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Chassis Tx Advanced Is Present", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("OutputDisabledByHdcp")] + public JoinDataComplete OutputDisabledByHdcp = new JoinDataComplete(new JoinData { JoinNumber = 1201, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Chassis Output Disabled by HDCP", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("OutputVideo")] + public JoinDataComplete OutputVideo = new JoinDataComplete(new JoinData { JoinNumber = 101, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Chassis Output Video Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("OutputAudio")] + public JoinDataComplete OutputAudio = new JoinDataComplete(new JoinData { JoinNumber = 301, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Chassis Output Audio Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("OutputUsb")] + public JoinDataComplete OutputUsb = new JoinDataComplete(new JoinData { JoinNumber = 501, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Chassis Output USB Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("InputUsb")] + public JoinDataComplete InputUsb = new JoinDataComplete(new JoinData { JoinNumber = 701, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Chassis Input Usb Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("HdcpSupportState")] + public JoinDataComplete HdcpSupportState = new JoinDataComplete(new JoinData { JoinNumber = 1001, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Chassis Input HDCP Support State", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("HdcpSupportCapability")] + public JoinDataComplete HdcpSupportCapability = new JoinDataComplete(new JoinData { JoinNumber = 1201, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Chassis Input HDCP Support Capability", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("InputStreamCardState")] + public JoinDataComplete InputStreamCardState = new JoinDataComplete(new JoinData { JoinNumber = 1501, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Chassis Stream Input Start (1), Stop (2), Pause (3) with Feedback", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("OutputStreamCardState")] + public JoinDataComplete OutputStreamCardState = new JoinDataComplete(new JoinData { JoinNumber = 1601, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Chassis Stream Output Start (1), Stop (2), Pause (3) with Feedback", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("NoRouteName")] + public JoinDataComplete NoRouteName = new JoinDataComplete(new JoinData { JoinNumber = 100, JoinSpan = 1 }, + new JoinMetadata { Description = "DM Chassis Input Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("InputNames")] + public JoinDataComplete InputNames = new JoinDataComplete(new JoinData { JoinNumber = 101, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Chassis Input Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("OutputNames")] + public JoinDataComplete OutputNames = new JoinDataComplete(new JoinData { JoinNumber = 301, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Chassis Output Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("InputVideoNames")] public JoinDataComplete InputVideoNames = + new JoinDataComplete(new JoinData {JoinNumber = 501, JoinSpan = 200}, + new JoinMetadata + { + Description = "DM Chassis Video Input Names", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("InputAudioNames")] + public JoinDataComplete InputAudioNames = + new JoinDataComplete(new JoinData { JoinNumber = 701, JoinSpan = 200 }, + new JoinMetadata + { + Description = "DM Chassis Audio Input Names", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Serial + }); + [JoinName("OutputVideoNames")] + public JoinDataComplete OutputVideoNames = + new JoinDataComplete(new JoinData { JoinNumber = 901, JoinSpan = 200 }, + new JoinMetadata + { + Description = "DM Chassis Video Output Names", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Serial + }); + [JoinName("OutputAudioNames")] + public JoinDataComplete OutputAudioNames = + new JoinDataComplete(new JoinData { JoinNumber = 1101, JoinSpan = 200 }, + new JoinMetadata + { + Description = "DM Chassis Audio Output Names", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("OutputCurrentVideoInputNames")] + public JoinDataComplete OutputCurrentVideoInputNames = new JoinDataComplete(new JoinData { JoinNumber = 2001, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Chassis Video Output Currently Routed Video Input Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("OutputCurrentAudioInputNames")] + public JoinDataComplete OutputCurrentAudioInputNames = new JoinDataComplete(new JoinData { JoinNumber = 2201, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Chassis Audio Output Currently Routed Video Input Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("InputCurrentResolution")] + public JoinDataComplete InputCurrentResolution = new JoinDataComplete(new JoinData { JoinNumber = 2401, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Chassis Input Current Resolution", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + /// + /// Constructor to use when instantiating this Join Map without inheriting from it + /// + /// Join this join map will start at + public DmChassisControllerJoinMap(uint joinStart) + : this(joinStart, typeof(DmChassisControllerJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected DmChassisControllerJoinMap(uint joinStart, Type type) : base(joinStart, type) + { + } + } +} diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmRmcControllerJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmRmcControllerJoinMap.cs similarity index 98% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmRmcControllerJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmRmcControllerJoinMap.cs index c0e7141f..56f0825c 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmRmcControllerJoinMap.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmRmcControllerJoinMap.cs @@ -1,92 +1,92 @@ -using System; - -namespace PepperDash.Essentials.Core.Bridges -{ - public class DmRmcControllerJoinMap : JoinMapBaseAdvanced - { - [JoinName("IsOnline")] - public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "DM RMC Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("VideoMuteOn")] - public JoinDataComplete VideoMuteOn = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, - new JoinMetadata { Description = "DM RMC Mute Video", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("VideoMuteOff")] - public JoinDataComplete VideoMuteOff = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, - new JoinMetadata { Description = "DM RMC UnMute Video", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("VideoMuteToggle")] - public JoinDataComplete VideoMuteToggle = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, - new JoinMetadata { Description = "DM RMC Mute Video Toggle", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("CurrentOutputResolution")] - public JoinDataComplete CurrentOutputResolution = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "DM RMC Current Output Resolution", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("EdidManufacturer")] - public JoinDataComplete EdidManufacturer = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "DM RMC EDID Manufacturer", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("EdidName")] - public JoinDataComplete EdidName = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, - new JoinMetadata { Description = "DM RMC EDID Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("EdidPrefferedTiming")] - public JoinDataComplete EdidPrefferedTiming = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, - new JoinMetadata { Description = "DM RMC EDID Preferred Timing", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("EdidSerialNumber")] - public JoinDataComplete EdidSerialNumber = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, - new JoinMetadata { Description = "DM RMC EDID Serial Number", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("Name")] - public JoinDataComplete Name = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, - new JoinMetadata { Description = "DM RMC Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("AudioVideoSource")] - public JoinDataComplete AudioVideoSource = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "DM RMC Audio Video Source Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("HdcpSupportCapability")] - public JoinDataComplete HdcpSupportCapability = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "DM RMC HDCP Support Capability", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("Port1HdcpState")] - public JoinDataComplete Port1HdcpState = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, - new JoinMetadata { Description = "DM RMC Port 1 (DM) HDCP State Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("Port2HdcpState")] - public JoinDataComplete Port2HdcpState = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, - new JoinMetadata { Description = "DM TX Port 2 (HDMI) HDCP State Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("HdmiInputSync")] - public JoinDataComplete HdmiInputSync = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "DM RMC HDMI Input Sync", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("HdcpInputPortCount")] - public JoinDataComplete HdcpInputPortCount = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, - new JoinMetadata { Description = "Number of Input Ports that support HDCP", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - - - /// - /// Constructor to use when instantiating this Join Map without inheriting from it - /// - /// Join this join map will start at - public DmRmcControllerJoinMap(uint joinStart) - : this(joinStart, typeof(DmRmcControllerJoinMap)) - { - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// Type of the child join map - protected DmRmcControllerJoinMap(uint joinStart, Type type) - : base(joinStart, type) - { - } - } +using System; + +namespace PepperDash.Essentials.Core.Bridges +{ + public class DmRmcControllerJoinMap : JoinMapBaseAdvanced + { + [JoinName("IsOnline")] + public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "DM RMC Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("VideoMuteOn")] + public JoinDataComplete VideoMuteOn = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "DM RMC Mute Video", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("VideoMuteOff")] + public JoinDataComplete VideoMuteOff = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "DM RMC UnMute Video", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("VideoMuteToggle")] + public JoinDataComplete VideoMuteToggle = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata { Description = "DM RMC Mute Video Toggle", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("CurrentOutputResolution")] + public JoinDataComplete CurrentOutputResolution = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "DM RMC Current Output Resolution", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("EdidManufacturer")] + public JoinDataComplete EdidManufacturer = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "DM RMC EDID Manufacturer", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("EdidName")] + public JoinDataComplete EdidName = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "DM RMC EDID Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("EdidPrefferedTiming")] + public JoinDataComplete EdidPrefferedTiming = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "DM RMC EDID Preferred Timing", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("EdidSerialNumber")] + public JoinDataComplete EdidSerialNumber = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata { Description = "DM RMC EDID Serial Number", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("Name")] + public JoinDataComplete Name = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, + new JoinMetadata { Description = "DM RMC Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("AudioVideoSource")] + public JoinDataComplete AudioVideoSource = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "DM RMC Audio Video Source Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("HdcpSupportCapability")] + public JoinDataComplete HdcpSupportCapability = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "DM RMC HDCP Support Capability", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("Port1HdcpState")] + public JoinDataComplete Port1HdcpState = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "DM RMC Port 1 (DM) HDCP State Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("Port2HdcpState")] + public JoinDataComplete Port2HdcpState = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "DM TX Port 2 (HDMI) HDCP State Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("HdmiInputSync")] + public JoinDataComplete HdmiInputSync = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "DM RMC HDMI Input Sync", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("HdcpInputPortCount")] + public JoinDataComplete HdcpInputPortCount = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata { Description = "Number of Input Ports that support HDCP", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + + + /// + /// Constructor to use when instantiating this Join Map without inheriting from it + /// + /// Join this join map will start at + public DmRmcControllerJoinMap(uint joinStart) + : this(joinStart, typeof(DmRmcControllerJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected DmRmcControllerJoinMap(uint joinStart, Type type) + : base(joinStart, type) + { + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmTxControllerJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmTxControllerJoinMap.cs similarity index 98% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmTxControllerJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmTxControllerJoinMap.cs index d75d0dad..c6f8f89f 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmTxControllerJoinMap.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmTxControllerJoinMap.cs @@ -1,96 +1,96 @@ -using System; - -namespace PepperDash.Essentials.Core.Bridges -{ - public class DmTxControllerJoinMap : JoinMapBaseAdvanced - { - [JoinName("IsOnline")] - public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "DM TX Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("VideoSyncStatus")] - public JoinDataComplete VideoSyncStatus = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "DM TX Video Sync", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("FreeRunEnabled")] - public JoinDataComplete FreeRunEnabled = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, - new JoinMetadata { Description = "DM TX Enable Free Run Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Input1VideoSyncStatus")] - public JoinDataComplete Input1VideoSyncStatus = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, - new JoinMetadata { Description = "Input 1 Video Sync Status", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Input2VideoSyncStatus")] - public JoinDataComplete Input2VideoSyncStatus = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, - new JoinMetadata { Description = "Input 2 Video Sync Status", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Input3VideoSyncStatus")] - public JoinDataComplete Input3VideoSyncStatus = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, - new JoinMetadata { Description = "Input 3 Video Sync Status", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("CurrentInputResolution")] - public JoinDataComplete CurrentInputResolution = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "DM TX Current Input Resolution", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("Name")] - public JoinDataComplete Name = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "DM TX Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("VideoInput")] - public JoinDataComplete VideoInput = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "DM TX Video Input Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("AudioInput")] - public JoinDataComplete AudioInput = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "DM TX Audio Input Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("HdcpSupportCapability")] - public JoinDataComplete HdcpSupportCapability = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, - new JoinMetadata { Description = "DM TX HDCP Support Capability", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("Port1HdcpState")] - public JoinDataComplete Port1HdcpState = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, - new JoinMetadata { Description = "DM TX Port 1 HDCP State Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("Port2HdcpState")] - public JoinDataComplete Port2HdcpState = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, - new JoinMetadata { Description = "DM TX Port 2 HDCP State Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("VgaBrightness")] - public JoinDataComplete VgaBrightness = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, - new JoinMetadata { Description = "DM TX VGA Brightness", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("VgaContrast")] - public JoinDataComplete VgaContrast = new JoinDataComplete(new JoinData { JoinNumber = 7, JoinSpan = 1 }, - new JoinMetadata { Description = "DM TX Online", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("Port3HdcpState")] - public JoinDataComplete Port3HdcpState = new JoinDataComplete(new JoinData { JoinNumber = 8, JoinSpan = 1 }, - new JoinMetadata { Description = "DM TX Port 3 HDCP State Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("HdcpInputPortCount")] - public JoinDataComplete HdcpInputPortCount = new JoinDataComplete(new JoinData { JoinNumber = 9, JoinSpan = 1 }, - new JoinMetadata { Description = "Number of Input Ports that support HDCP", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - - - /// - /// Constructor to use when instantiating this Join Map without inheriting from it - /// - /// Join this join map will start at - public DmTxControllerJoinMap(uint joinStart) - : this(joinStart, typeof(DmTxControllerJoinMap)) - { - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// Type of the child join map - protected DmTxControllerJoinMap(uint joinStart, Type type) - : base(joinStart, type) - { - } - } +using System; + +namespace PepperDash.Essentials.Core.Bridges +{ + public class DmTxControllerJoinMap : JoinMapBaseAdvanced + { + [JoinName("IsOnline")] + public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "DM TX Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("VideoSyncStatus")] + public JoinDataComplete VideoSyncStatus = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "DM TX Video Sync", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("FreeRunEnabled")] + public JoinDataComplete FreeRunEnabled = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "DM TX Enable Free Run Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Input1VideoSyncStatus")] + public JoinDataComplete Input1VideoSyncStatus = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "Input 1 Video Sync Status", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Input2VideoSyncStatus")] + public JoinDataComplete Input2VideoSyncStatus = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata { Description = "Input 2 Video Sync Status", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Input3VideoSyncStatus")] + public JoinDataComplete Input3VideoSyncStatus = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, + new JoinMetadata { Description = "Input 3 Video Sync Status", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("CurrentInputResolution")] + public JoinDataComplete CurrentInputResolution = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "DM TX Current Input Resolution", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("Name")] + public JoinDataComplete Name = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "DM TX Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("VideoInput")] + public JoinDataComplete VideoInput = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "DM TX Video Input Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("AudioInput")] + public JoinDataComplete AudioInput = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "DM TX Audio Input Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("HdcpSupportCapability")] + public JoinDataComplete HdcpSupportCapability = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "DM TX HDCP Support Capability", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("Port1HdcpState")] + public JoinDataComplete Port1HdcpState = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "DM TX Port 1 HDCP State Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("Port2HdcpState")] + public JoinDataComplete Port2HdcpState = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata { Description = "DM TX Port 2 HDCP State Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("VgaBrightness")] + public JoinDataComplete VgaBrightness = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, + new JoinMetadata { Description = "DM TX VGA Brightness", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("VgaContrast")] + public JoinDataComplete VgaContrast = new JoinDataComplete(new JoinData { JoinNumber = 7, JoinSpan = 1 }, + new JoinMetadata { Description = "DM TX Online", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("Port3HdcpState")] + public JoinDataComplete Port3HdcpState = new JoinDataComplete(new JoinData { JoinNumber = 8, JoinSpan = 1 }, + new JoinMetadata { Description = "DM TX Port 3 HDCP State Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("HdcpInputPortCount")] + public JoinDataComplete HdcpInputPortCount = new JoinDataComplete(new JoinData { JoinNumber = 9, JoinSpan = 1 }, + new JoinMetadata { Description = "Number of Input Ports that support HDCP", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + + + /// + /// Constructor to use when instantiating this Join Map without inheriting from it + /// + /// Join this join map will start at + public DmTxControllerJoinMap(uint joinStart) + : this(joinStart, typeof(DmTxControllerJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected DmTxControllerJoinMap(uint joinStart, Type type) + : base(joinStart, type) + { + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsAudioOutputControllerJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsAudioOutputControllerJoinMap.cs similarity index 98% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsAudioOutputControllerJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsAudioOutputControllerJoinMap.cs index a6100700..11509acf 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsAudioOutputControllerJoinMap.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsAudioOutputControllerJoinMap.cs @@ -1,174 +1,174 @@ -using System; - -namespace PepperDash.Essentials.Core.Bridges -{ - public class DmpsAudioOutputControllerJoinMap : JoinMapBaseAdvanced - { - - [JoinName("MasterVolumeLevel")] - public JoinDataComplete MasterVolumeLevel = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Master Volume Signed dB Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("MasterVolumeLevelScaled")] - public JoinDataComplete MasterVolumeLevelScaled = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "Master Volume 16bit Scaled Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("MixerPresetRecall")] - public JoinDataComplete MixerPresetRecall = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, - new JoinMetadata { Description = "Mixer Preset Recall Set", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("MixerEqPresetRecall")] - public JoinDataComplete MixerEqPresetRecall = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, - new JoinMetadata { Description = "Mixer Eq Preset Recall Set", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("MasterVolumeMuteOn")] - public JoinDataComplete MasterVolumeMuteOn = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Master Volume Mute On Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("MasterVolumeMuteOff")] - public JoinDataComplete MasterVolumeMuteOff = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "Master Volume Mute Off Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("MasterVolumeUp")] - public JoinDataComplete MasterVolumeUp = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, - new JoinMetadata { Description = "Master Volume Level Up", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("MasterVolumeDown")] - public JoinDataComplete MasterVolumeDown = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, - new JoinMetadata { Description = "Master Volume Level Down", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("MasterVolumeLevelScaledSend")] - public JoinDataComplete MasterVolumeLevelScaledSend = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, - new JoinMetadata { Description = "Master Volume Scaled Send Enable/Disable", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("SourceVolumeLevel")] - public JoinDataComplete SourceVolumeLevel = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, - new JoinMetadata { Description = "Source Volume Signed dB Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("SourceVolumeLevelScaled")] - public JoinDataComplete SourceVolumeLevelScaled = new JoinDataComplete(new JoinData { JoinNumber = 12, JoinSpan = 1 }, - new JoinMetadata { Description = "Source Volume 16bit Scaled Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("SourceVolumeMuteOn")] - public JoinDataComplete SourceVolumeMuteOn = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, - new JoinMetadata { Description = "Source Volume Mute On Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("SourceVolumeMuteOff")] - public JoinDataComplete SourceVolumeMuteOff = new JoinDataComplete(new JoinData { JoinNumber = 12, JoinSpan = 1 }, - new JoinMetadata { Description = "Source Volume Mute Off Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("SourceVolumeUp")] - public JoinDataComplete SourceVolumeUp = new JoinDataComplete(new JoinData { JoinNumber = 13, JoinSpan = 1 }, - new JoinMetadata { Description = "Source Volume Level Up", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("SourceVolumeDown")] - public JoinDataComplete SourceVolumeDown = new JoinDataComplete(new JoinData { JoinNumber = 14, JoinSpan = 1 }, - new JoinMetadata { Description = "Source Volume Level Down", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("SourceVolumeLevelScaledSend")] - public JoinDataComplete SourceVolumeLevelScaledSend = new JoinDataComplete(new JoinData { JoinNumber = 15, JoinSpan = 1 }, - new JoinMetadata { Description = "Source Volume Scaled Send Enable/Disable", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Codec1VolumeLevel")] - public JoinDataComplete Codec1VolumeLevel = new JoinDataComplete(new JoinData { JoinNumber = 21, JoinSpan = 1 }, - new JoinMetadata { Description = "Codec1 Volume Signed dB Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("Codec1VolumeLevelScaled")] - public JoinDataComplete Codec1VolumeLevelScaled = new JoinDataComplete(new JoinData { JoinNumber = 22, JoinSpan = 1 }, - new JoinMetadata { Description = "Codec1 Volume 16bit Scaled Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("Codec1VolumeMuteOn")] - public JoinDataComplete Codec1VolumeMuteOn = new JoinDataComplete(new JoinData { JoinNumber = 21, JoinSpan = 1 }, - new JoinMetadata { Description = "Codec1 Volume Mute On Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Codec1VolumeMuteOff")] - public JoinDataComplete Codec1VolumeMuteOff = new JoinDataComplete(new JoinData { JoinNumber = 22, JoinSpan = 1 }, - new JoinMetadata { Description = "Codec1 Volume Mute Off Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Codec1VolumeUp")] - public JoinDataComplete Codec1VolumeUp = new JoinDataComplete(new JoinData { JoinNumber = 23, JoinSpan = 1 }, - new JoinMetadata { Description = "Codec1 Volume Level Up", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Codec1VolumeDown")] - public JoinDataComplete Codec1VolumeDown = new JoinDataComplete(new JoinData { JoinNumber = 24, JoinSpan = 1 }, - new JoinMetadata { Description = "Codec1 Volume Level Down", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Codec1VolumeLevelScaledSend")] - public JoinDataComplete Codec1VolumeLevelScaledSend = new JoinDataComplete(new JoinData { JoinNumber = 25, JoinSpan = 1 }, - new JoinMetadata { Description = "Codec1 Volume Scaled Send Enable/Disable", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Codec2VolumeLevel")] - public JoinDataComplete Codec2VolumeLevel = new JoinDataComplete(new JoinData { JoinNumber = 31, JoinSpan = 1 }, - new JoinMetadata { Description = "Codec2 Volume Signed dB Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("Codec2VolumeLevelScaled")] - public JoinDataComplete Codec2VolumeLevelScaled = new JoinDataComplete(new JoinData { JoinNumber = 32, JoinSpan = 1 }, - new JoinMetadata { Description = "Codec2 Volume 16bit Scaled Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("Codec2VolumeMuteOn")] - public JoinDataComplete Codec2VolumeMuteOn = new JoinDataComplete(new JoinData { JoinNumber = 31, JoinSpan = 1 }, - new JoinMetadata { Description = "Codec2 Volume Mute On Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Codec2VolumeMuteOff")] - public JoinDataComplete Codec2VolumeMuteOff = new JoinDataComplete(new JoinData { JoinNumber = 32, JoinSpan = 1 }, - new JoinMetadata { Description = "Codec2 Volume Mute Off Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Codec2VolumeUp")] - public JoinDataComplete Codec2VolumeUp = new JoinDataComplete(new JoinData { JoinNumber = 33, JoinSpan = 1 }, - new JoinMetadata { Description = "Codec2 Volume Level Up", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Codec2VolumeDown")] - public JoinDataComplete Codec2VolumeDown = new JoinDataComplete(new JoinData { JoinNumber = 34, JoinSpan = 1 }, - new JoinMetadata { Description = "Codec2 Volume Level Down", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Codec2VolumeLevelScaledSend")] - public JoinDataComplete Codec2VolumeLevelScaledSend = new JoinDataComplete(new JoinData { JoinNumber = 35, JoinSpan = 1 }, - new JoinMetadata { Description = "Codec2 Volume Scaled Send Enable/Disable", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("MicsMasterVolumeLevel")] - public JoinDataComplete MicsMasterVolumeLevel = new JoinDataComplete(new JoinData { JoinNumber = 41, JoinSpan = 1 }, - new JoinMetadata { Description = "MicsMaster Volume Signed dB Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("MicsMasterVolumeLevelScaled")] - public JoinDataComplete MicsMasterVolumeLevelScaled = new JoinDataComplete(new JoinData { JoinNumber = 42, JoinSpan = 1 }, - new JoinMetadata { Description = "MicsMaster Volume 16bit Scaled Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("MicsMasterVolumeMuteOn")] - public JoinDataComplete MicsMasterVolumeMuteOn = new JoinDataComplete(new JoinData { JoinNumber = 41, JoinSpan = 1 }, - new JoinMetadata { Description = "MicsMaster Volume Mute On Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("MicsMasterVolumeMuteOff")] - public JoinDataComplete MicsMasterVolumeMuteOff = new JoinDataComplete(new JoinData { JoinNumber = 42, JoinSpan = 1 }, - new JoinMetadata { Description = "MicsMaster Volume Mute Off Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("MicsMasterVolumeUp")] - public JoinDataComplete MicsMasterVolumeUp = new JoinDataComplete(new JoinData { JoinNumber = 43, JoinSpan = 1 }, - new JoinMetadata { Description = "MicsMaster Volume Level Up", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("MicsMasterVolumeDown")] - public JoinDataComplete MicsMasterVolumeDown = new JoinDataComplete(new JoinData { JoinNumber = 44, JoinSpan = 1 }, - new JoinMetadata { Description = "MicsMaster Volume Level Down", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("MicsMasterVolumeLevelScaledSend")] - public JoinDataComplete MicsMasterVolumeLevelScaledSend = new JoinDataComplete(new JoinData { JoinNumber = 45, JoinSpan = 1 }, - new JoinMetadata { Description = "Mics Master Volume Scaled Send Enable/Disable", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - /// - /// Constructor to use when instantiating this Join Map without inheriting from it - /// - /// Join this join map will start at - public DmpsAudioOutputControllerJoinMap(uint joinStart) - : this(joinStart, typeof(DmpsAudioOutputControllerJoinMap)) - { - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// Type of the child join map - protected DmpsAudioOutputControllerJoinMap(uint joinStart, Type type) : base(joinStart, type) - { - } - } +using System; + +namespace PepperDash.Essentials.Core.Bridges +{ + public class DmpsAudioOutputControllerJoinMap : JoinMapBaseAdvanced + { + + [JoinName("MasterVolumeLevel")] + public JoinDataComplete MasterVolumeLevel = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Master Volume Signed dB Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("MasterVolumeLevelScaled")] + public JoinDataComplete MasterVolumeLevelScaled = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "Master Volume 16bit Scaled Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("MixerPresetRecall")] + public JoinDataComplete MixerPresetRecall = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "Mixer Preset Recall Set", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("MixerEqPresetRecall")] + public JoinDataComplete MixerEqPresetRecall = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "Mixer Eq Preset Recall Set", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("MasterVolumeMuteOn")] + public JoinDataComplete MasterVolumeMuteOn = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Master Volume Mute On Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("MasterVolumeMuteOff")] + public JoinDataComplete MasterVolumeMuteOff = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "Master Volume Mute Off Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("MasterVolumeUp")] + public JoinDataComplete MasterVolumeUp = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "Master Volume Level Up", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("MasterVolumeDown")] + public JoinDataComplete MasterVolumeDown = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "Master Volume Level Down", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("MasterVolumeLevelScaledSend")] + public JoinDataComplete MasterVolumeLevelScaledSend = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata { Description = "Master Volume Scaled Send Enable/Disable", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("SourceVolumeLevel")] + public JoinDataComplete SourceVolumeLevel = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, + new JoinMetadata { Description = "Source Volume Signed dB Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("SourceVolumeLevelScaled")] + public JoinDataComplete SourceVolumeLevelScaled = new JoinDataComplete(new JoinData { JoinNumber = 12, JoinSpan = 1 }, + new JoinMetadata { Description = "Source Volume 16bit Scaled Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("SourceVolumeMuteOn")] + public JoinDataComplete SourceVolumeMuteOn = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, + new JoinMetadata { Description = "Source Volume Mute On Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("SourceVolumeMuteOff")] + public JoinDataComplete SourceVolumeMuteOff = new JoinDataComplete(new JoinData { JoinNumber = 12, JoinSpan = 1 }, + new JoinMetadata { Description = "Source Volume Mute Off Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("SourceVolumeUp")] + public JoinDataComplete SourceVolumeUp = new JoinDataComplete(new JoinData { JoinNumber = 13, JoinSpan = 1 }, + new JoinMetadata { Description = "Source Volume Level Up", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("SourceVolumeDown")] + public JoinDataComplete SourceVolumeDown = new JoinDataComplete(new JoinData { JoinNumber = 14, JoinSpan = 1 }, + new JoinMetadata { Description = "Source Volume Level Down", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("SourceVolumeLevelScaledSend")] + public JoinDataComplete SourceVolumeLevelScaledSend = new JoinDataComplete(new JoinData { JoinNumber = 15, JoinSpan = 1 }, + new JoinMetadata { Description = "Source Volume Scaled Send Enable/Disable", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Codec1VolumeLevel")] + public JoinDataComplete Codec1VolumeLevel = new JoinDataComplete(new JoinData { JoinNumber = 21, JoinSpan = 1 }, + new JoinMetadata { Description = "Codec1 Volume Signed dB Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("Codec1VolumeLevelScaled")] + public JoinDataComplete Codec1VolumeLevelScaled = new JoinDataComplete(new JoinData { JoinNumber = 22, JoinSpan = 1 }, + new JoinMetadata { Description = "Codec1 Volume 16bit Scaled Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("Codec1VolumeMuteOn")] + public JoinDataComplete Codec1VolumeMuteOn = new JoinDataComplete(new JoinData { JoinNumber = 21, JoinSpan = 1 }, + new JoinMetadata { Description = "Codec1 Volume Mute On Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Codec1VolumeMuteOff")] + public JoinDataComplete Codec1VolumeMuteOff = new JoinDataComplete(new JoinData { JoinNumber = 22, JoinSpan = 1 }, + new JoinMetadata { Description = "Codec1 Volume Mute Off Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Codec1VolumeUp")] + public JoinDataComplete Codec1VolumeUp = new JoinDataComplete(new JoinData { JoinNumber = 23, JoinSpan = 1 }, + new JoinMetadata { Description = "Codec1 Volume Level Up", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Codec1VolumeDown")] + public JoinDataComplete Codec1VolumeDown = new JoinDataComplete(new JoinData { JoinNumber = 24, JoinSpan = 1 }, + new JoinMetadata { Description = "Codec1 Volume Level Down", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Codec1VolumeLevelScaledSend")] + public JoinDataComplete Codec1VolumeLevelScaledSend = new JoinDataComplete(new JoinData { JoinNumber = 25, JoinSpan = 1 }, + new JoinMetadata { Description = "Codec1 Volume Scaled Send Enable/Disable", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Codec2VolumeLevel")] + public JoinDataComplete Codec2VolumeLevel = new JoinDataComplete(new JoinData { JoinNumber = 31, JoinSpan = 1 }, + new JoinMetadata { Description = "Codec2 Volume Signed dB Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("Codec2VolumeLevelScaled")] + public JoinDataComplete Codec2VolumeLevelScaled = new JoinDataComplete(new JoinData { JoinNumber = 32, JoinSpan = 1 }, + new JoinMetadata { Description = "Codec2 Volume 16bit Scaled Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("Codec2VolumeMuteOn")] + public JoinDataComplete Codec2VolumeMuteOn = new JoinDataComplete(new JoinData { JoinNumber = 31, JoinSpan = 1 }, + new JoinMetadata { Description = "Codec2 Volume Mute On Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Codec2VolumeMuteOff")] + public JoinDataComplete Codec2VolumeMuteOff = new JoinDataComplete(new JoinData { JoinNumber = 32, JoinSpan = 1 }, + new JoinMetadata { Description = "Codec2 Volume Mute Off Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Codec2VolumeUp")] + public JoinDataComplete Codec2VolumeUp = new JoinDataComplete(new JoinData { JoinNumber = 33, JoinSpan = 1 }, + new JoinMetadata { Description = "Codec2 Volume Level Up", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Codec2VolumeDown")] + public JoinDataComplete Codec2VolumeDown = new JoinDataComplete(new JoinData { JoinNumber = 34, JoinSpan = 1 }, + new JoinMetadata { Description = "Codec2 Volume Level Down", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Codec2VolumeLevelScaledSend")] + public JoinDataComplete Codec2VolumeLevelScaledSend = new JoinDataComplete(new JoinData { JoinNumber = 35, JoinSpan = 1 }, + new JoinMetadata { Description = "Codec2 Volume Scaled Send Enable/Disable", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("MicsMasterVolumeLevel")] + public JoinDataComplete MicsMasterVolumeLevel = new JoinDataComplete(new JoinData { JoinNumber = 41, JoinSpan = 1 }, + new JoinMetadata { Description = "MicsMaster Volume Signed dB Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("MicsMasterVolumeLevelScaled")] + public JoinDataComplete MicsMasterVolumeLevelScaled = new JoinDataComplete(new JoinData { JoinNumber = 42, JoinSpan = 1 }, + new JoinMetadata { Description = "MicsMaster Volume 16bit Scaled Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("MicsMasterVolumeMuteOn")] + public JoinDataComplete MicsMasterVolumeMuteOn = new JoinDataComplete(new JoinData { JoinNumber = 41, JoinSpan = 1 }, + new JoinMetadata { Description = "MicsMaster Volume Mute On Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("MicsMasterVolumeMuteOff")] + public JoinDataComplete MicsMasterVolumeMuteOff = new JoinDataComplete(new JoinData { JoinNumber = 42, JoinSpan = 1 }, + new JoinMetadata { Description = "MicsMaster Volume Mute Off Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("MicsMasterVolumeUp")] + public JoinDataComplete MicsMasterVolumeUp = new JoinDataComplete(new JoinData { JoinNumber = 43, JoinSpan = 1 }, + new JoinMetadata { Description = "MicsMaster Volume Level Up", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("MicsMasterVolumeDown")] + public JoinDataComplete MicsMasterVolumeDown = new JoinDataComplete(new JoinData { JoinNumber = 44, JoinSpan = 1 }, + new JoinMetadata { Description = "MicsMaster Volume Level Down", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("MicsMasterVolumeLevelScaledSend")] + public JoinDataComplete MicsMasterVolumeLevelScaledSend = new JoinDataComplete(new JoinData { JoinNumber = 45, JoinSpan = 1 }, + new JoinMetadata { Description = "Mics Master Volume Scaled Send Enable/Disable", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + /// + /// Constructor to use when instantiating this Join Map without inheriting from it + /// + /// Join this join map will start at + public DmpsAudioOutputControllerJoinMap(uint joinStart) + : this(joinStart, typeof(DmpsAudioOutputControllerJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected DmpsAudioOutputControllerJoinMap(uint joinStart, Type type) : base(joinStart, type) + { + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsMicrophoneControllerJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsMicrophoneControllerJoinMap.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsMicrophoneControllerJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsMicrophoneControllerJoinMap.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsRoutingControllerJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsRoutingControllerJoinMap.cs similarity index 98% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsRoutingControllerJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsRoutingControllerJoinMap.cs index 44917899..a0d8d7b8 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsRoutingControllerJoinMap.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsRoutingControllerJoinMap.cs @@ -1,123 +1,123 @@ -using System; - -namespace PepperDash.Essentials.Core.Bridges -{ - public class DmpsRoutingControllerJoinMap : JoinMapBaseAdvanced - { - [JoinName("EnableRouting")] - public JoinDataComplete EnableRouting = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "DMPS Enable Audio and Video Routing", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("SystemPowerOn")] - public JoinDataComplete SystemPowerOn = new JoinDataComplete(new JoinData { JoinNumber = 12, JoinSpan = 1 }, - new JoinMetadata { Description = "DMPS System Power On Get/Set", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("SystemPowerOff")] - public JoinDataComplete SystemPowerOff = new JoinDataComplete(new JoinData { JoinNumber = 13, JoinSpan = 1 }, - new JoinMetadata { Description = "DMPS System Power Off Get/Set", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("FrontPanelLockOn")] - public JoinDataComplete FrontPanelLockOn = new JoinDataComplete(new JoinData { JoinNumber = 14, JoinSpan = 1 }, - new JoinMetadata { Description = "DMPS Front Panel Lock On Get/Set", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("FrontPanelLockOff")] - public JoinDataComplete FrontPanelLockOff = new JoinDataComplete(new JoinData { JoinNumber = 15, JoinSpan = 1 }, - new JoinMetadata { Description = "DMPS Front Panel Lock Off Get/Set", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("VideoSyncStatus")] - public JoinDataComplete VideoSyncStatus = new JoinDataComplete(new JoinData { JoinNumber = 101, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Input Video Sync", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("InputEndpointOnline")] - public JoinDataComplete InputEndpointOnline = new JoinDataComplete(new JoinData { JoinNumber = 501, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Chassis Input Endpoint Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("OutputEndpointOnline")] - public JoinDataComplete OutputEndpointOnline = new JoinDataComplete(new JoinData { JoinNumber = 701, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Chassis Output Endpoint Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("OutputVideo")] - public JoinDataComplete OutputVideo = new JoinDataComplete(new JoinData { JoinNumber = 101, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Chassis Output Video Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("OutputAudio")] - public JoinDataComplete OutputAudio = new JoinDataComplete(new JoinData { JoinNumber = 301, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Chassis Output Audio Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("InputNames")] - public JoinDataComplete InputNames = new JoinDataComplete(new JoinData { JoinNumber = 101, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Chassis Input Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("OutputNames")] - public JoinDataComplete OutputNames = new JoinDataComplete(new JoinData { JoinNumber = 301, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Chassis Output Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("InputVideoNames")] - public JoinDataComplete InputVideoNames = - new JoinDataComplete(new JoinData { JoinNumber = 501, JoinSpan = 32 }, - new JoinMetadata - { - Description = "Video Input Name", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("InputAudioNames")] - public JoinDataComplete InputAudioNames = - new JoinDataComplete(new JoinData { JoinNumber = 701, JoinSpan = 32 }, - new JoinMetadata - { - Description = "Audio Input Name", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - [JoinName("OutputVideoNames")] - public JoinDataComplete OutputVideoNames = - new JoinDataComplete(new JoinData { JoinNumber = 901, JoinSpan = 32 }, - new JoinMetadata - { - Description = "Video Output Name", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - [JoinName("OutputAudioNames")] - public JoinDataComplete OutputAudioNames = - new JoinDataComplete(new JoinData { JoinNumber = 1101, JoinSpan = 32 }, - new JoinMetadata - { - Description = "Audio Output Name", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("OutputCurrentVideoInputNames")] - public JoinDataComplete OutputCurrentVideoInputNames = new JoinDataComplete(new JoinData { JoinNumber = 2001, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Chassis Video Output Currently Routed Video Input Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("OutputCurrentAudioInputNames")] - public JoinDataComplete OutputCurrentAudioInputNames = new JoinDataComplete(new JoinData { JoinNumber = 2201, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Chassis Audio Output Currently Routed Video Input Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("InputCurrentResolution")] - public JoinDataComplete InputCurrentResolution = new JoinDataComplete(new JoinData { JoinNumber = 2401, JoinSpan = 32 }, - new JoinMetadata { Description = "DM Chassis Input Current Resolution", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - /// - /// Constructor to use when instantiating this Join Map without inheriting from it - /// - /// Join this join map will start at - public DmpsRoutingControllerJoinMap(uint joinStart) - : this(joinStart, typeof(DmpsRoutingControllerJoinMap)) - { - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// Type of the child join map - protected DmpsRoutingControllerJoinMap(uint joinStart, Type type) : base(joinStart, type) - { - } - } +using System; + +namespace PepperDash.Essentials.Core.Bridges +{ + public class DmpsRoutingControllerJoinMap : JoinMapBaseAdvanced + { + [JoinName("EnableRouting")] + public JoinDataComplete EnableRouting = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "DMPS Enable Audio and Video Routing", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("SystemPowerOn")] + public JoinDataComplete SystemPowerOn = new JoinDataComplete(new JoinData { JoinNumber = 12, JoinSpan = 1 }, + new JoinMetadata { Description = "DMPS System Power On Get/Set", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("SystemPowerOff")] + public JoinDataComplete SystemPowerOff = new JoinDataComplete(new JoinData { JoinNumber = 13, JoinSpan = 1 }, + new JoinMetadata { Description = "DMPS System Power Off Get/Set", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("FrontPanelLockOn")] + public JoinDataComplete FrontPanelLockOn = new JoinDataComplete(new JoinData { JoinNumber = 14, JoinSpan = 1 }, + new JoinMetadata { Description = "DMPS Front Panel Lock On Get/Set", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("FrontPanelLockOff")] + public JoinDataComplete FrontPanelLockOff = new JoinDataComplete(new JoinData { JoinNumber = 15, JoinSpan = 1 }, + new JoinMetadata { Description = "DMPS Front Panel Lock Off Get/Set", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("VideoSyncStatus")] + public JoinDataComplete VideoSyncStatus = new JoinDataComplete(new JoinData { JoinNumber = 101, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Input Video Sync", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("InputEndpointOnline")] + public JoinDataComplete InputEndpointOnline = new JoinDataComplete(new JoinData { JoinNumber = 501, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Chassis Input Endpoint Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("OutputEndpointOnline")] + public JoinDataComplete OutputEndpointOnline = new JoinDataComplete(new JoinData { JoinNumber = 701, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Chassis Output Endpoint Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("OutputVideo")] + public JoinDataComplete OutputVideo = new JoinDataComplete(new JoinData { JoinNumber = 101, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Chassis Output Video Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("OutputAudio")] + public JoinDataComplete OutputAudio = new JoinDataComplete(new JoinData { JoinNumber = 301, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Chassis Output Audio Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("InputNames")] + public JoinDataComplete InputNames = new JoinDataComplete(new JoinData { JoinNumber = 101, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Chassis Input Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("OutputNames")] + public JoinDataComplete OutputNames = new JoinDataComplete(new JoinData { JoinNumber = 301, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Chassis Output Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("InputVideoNames")] + public JoinDataComplete InputVideoNames = + new JoinDataComplete(new JoinData { JoinNumber = 501, JoinSpan = 32 }, + new JoinMetadata + { + Description = "Video Input Name", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("InputAudioNames")] + public JoinDataComplete InputAudioNames = + new JoinDataComplete(new JoinData { JoinNumber = 701, JoinSpan = 32 }, + new JoinMetadata + { + Description = "Audio Input Name", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + [JoinName("OutputVideoNames")] + public JoinDataComplete OutputVideoNames = + new JoinDataComplete(new JoinData { JoinNumber = 901, JoinSpan = 32 }, + new JoinMetadata + { + Description = "Video Output Name", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + [JoinName("OutputAudioNames")] + public JoinDataComplete OutputAudioNames = + new JoinDataComplete(new JoinData { JoinNumber = 1101, JoinSpan = 32 }, + new JoinMetadata + { + Description = "Audio Output Name", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("OutputCurrentVideoInputNames")] + public JoinDataComplete OutputCurrentVideoInputNames = new JoinDataComplete(new JoinData { JoinNumber = 2001, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Chassis Video Output Currently Routed Video Input Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("OutputCurrentAudioInputNames")] + public JoinDataComplete OutputCurrentAudioInputNames = new JoinDataComplete(new JoinData { JoinNumber = 2201, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Chassis Audio Output Currently Routed Video Input Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("InputCurrentResolution")] + public JoinDataComplete InputCurrentResolution = new JoinDataComplete(new JoinData { JoinNumber = 2401, JoinSpan = 32 }, + new JoinMetadata { Description = "DM Chassis Input Current Resolution", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + /// + /// Constructor to use when instantiating this Join Map without inheriting from it + /// + /// Join this join map will start at + public DmpsRoutingControllerJoinMap(uint joinStart) + : this(joinStart, typeof(DmpsRoutingControllerJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected DmpsRoutingControllerJoinMap(uint joinStart, Type type) : base(joinStart, type) + { + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericIrControllerJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericIrControllerJoinMap.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericIrControllerJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericIrControllerJoinMap.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericLightingJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericLightingJoinMap.cs similarity index 98% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericLightingJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericLightingJoinMap.cs index 9a14c332..2a3015f1 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericLightingJoinMap.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericLightingJoinMap.cs @@ -1,49 +1,49 @@ -using System; - - +using System; + + namespace PepperDash.Essentials.Core.Bridges { public class GenericLightingJoinMap : JoinMapBaseAdvanced - { - - [JoinName("IsOnline")] - public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Lighting Controller Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("SelectScene")] - public JoinDataComplete SelectScene = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Lighting Controller Select Scene By Index", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("SelectSceneDirect")] - public JoinDataComplete SelectSceneDirect = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 10 }, - new JoinMetadata { Description = "Lighting Controller Select Scene", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.DigitalSerial }); - - [JoinName("ButtonVisibility")] - public JoinDataComplete ButtonVisibility = new JoinDataComplete(new JoinData { JoinNumber = 41, JoinSpan = 10 }, - new JoinMetadata { Description = "Lighting Controller Button Visibility", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("IntegrationIdSet")] - public JoinDataComplete IntegrationIdSet = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Lighting Controller Set Integration Id", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); - - - - /// - /// Constructor to use when instantiating this Join Map without inheriting from it - /// - /// Join this join map will start at - public GenericLightingJoinMap(uint joinStart) - : this(joinStart, typeof(GenericLightingJoinMap)) - { - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// Type of the child join map - protected GenericLightingJoinMap(uint joinStart, Type type) : base(joinStart, type) - { - } + { + + [JoinName("IsOnline")] + public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Lighting Controller Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("SelectScene")] + public JoinDataComplete SelectScene = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Lighting Controller Select Scene By Index", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("SelectSceneDirect")] + public JoinDataComplete SelectSceneDirect = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 10 }, + new JoinMetadata { Description = "Lighting Controller Select Scene", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.DigitalSerial }); + + [JoinName("ButtonVisibility")] + public JoinDataComplete ButtonVisibility = new JoinDataComplete(new JoinData { JoinNumber = 41, JoinSpan = 10 }, + new JoinMetadata { Description = "Lighting Controller Button Visibility", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("IntegrationIdSet")] + public JoinDataComplete IntegrationIdSet = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Lighting Controller Set Integration Id", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + + + + /// + /// Constructor to use when instantiating this Join Map without inheriting from it + /// + /// Join this join map will start at + public GenericLightingJoinMap(uint joinStart) + : this(joinStart, typeof(GenericLightingJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected GenericLightingJoinMap(uint joinStart, Type type) : base(joinStart, type) + { + } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericRelayControllerJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericRelayControllerJoinMap.cs similarity index 98% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericRelayControllerJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericRelayControllerJoinMap.cs index 0dc830bb..68897767 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericRelayControllerJoinMap.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericRelayControllerJoinMap.cs @@ -1,31 +1,31 @@ -using System; - +using System; + namespace PepperDash.Essentials.Core.Bridges { public class GenericRelayControllerJoinMap : JoinMapBaseAdvanced { - [JoinName("Relay")] - public JoinDataComplete Relay = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Device Relay State Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - /// - /// Constructor to use when instantiating this Join Map without inheriting from it - /// - /// Join this join map will start at - public GenericRelayControllerJoinMap(uint joinStart) - : this(joinStart, typeof(GenericRelayControllerJoinMap)) - { - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// Type of the child join map - protected GenericRelayControllerJoinMap(uint joinStart, Type type) : base(joinStart, type) - { - + [JoinName("Relay")] + public JoinDataComplete Relay = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Device Relay State Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + /// + /// Constructor to use when instantiating this Join Map without inheriting from it + /// + /// Join this join map will start at + public GenericRelayControllerJoinMap(uint joinStart) + : this(joinStart, typeof(GenericRelayControllerJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected GenericRelayControllerJoinMap(uint joinStart, Type type) : base(joinStart, type) + { + } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GlsOccupancySensorBaseJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GlsOccupancySensorBaseJoinMap.cs similarity index 98% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GlsOccupancySensorBaseJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GlsOccupancySensorBaseJoinMap.cs index 72cb1433..ded7343f 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GlsOccupancySensorBaseJoinMap.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GlsOccupancySensorBaseJoinMap.cs @@ -1,184 +1,184 @@ -using System; - -namespace PepperDash.Essentials.Core.Bridges -{ - public class GlsOccupancySensorBaseJoinMap : JoinMapBaseAdvanced - { - [JoinName("IsOnline")] - public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Is Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("ForceOccupied")] - public JoinDataComplete ForceOccupied = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Set to Occupied", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("ForceVacant")] - public JoinDataComplete ForceVacant = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Set to Vacant", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("EnableRawStates")] - public JoinDataComplete EnableRawStates = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Enable Raw", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("RoomOccupiedFeedback")] - public JoinDataComplete RoomOccupiedFeedback = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Room Is Occupied", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("GraceOccupancyDetectedFeedback")] - public JoinDataComplete GraceOccupancyDetectedFeedback = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Grace Occupancy Detected", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("RoomVacantFeedback")] - public JoinDataComplete RoomVacantFeedback = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Room Is Vacant", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("RawOccupancyFeedback")] - public JoinDataComplete RawOccupancyFeedback = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Raw Occupancy Detected", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("RawOccupancyPirFeedback")] - public JoinDataComplete RawOccupancyPirFeedback = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Raw PIR Occupancy Detected", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("RawOccupancyUsFeedback")] - public JoinDataComplete RawOccupancyUsFeedback = new JoinDataComplete(new JoinData { JoinNumber = 7, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Raw US Occupancy Detected", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("EnableLedFlash")] - public JoinDataComplete EnableLedFlash = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Enable LED Flash", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("DisableLedFlash")] - public JoinDataComplete DisableLedFlash = new JoinDataComplete(new JoinData { JoinNumber = 12, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Disable LED Flash", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("EnableShortTimeout")] - public JoinDataComplete EnableShortTimeout = new JoinDataComplete(new JoinData { JoinNumber = 13, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Enable Short Timeout", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("DisableShortTimeout")] - public JoinDataComplete DisableShortTimeout = new JoinDataComplete(new JoinData { JoinNumber = 14, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Disable Short Timeout", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("OrWhenVacated")] - public JoinDataComplete OrWhenVacated = new JoinDataComplete(new JoinData { JoinNumber = 15, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Set To Vacant when Either Sensor is Vacant", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("AndWhenVacated")] - public JoinDataComplete AndWhenVacated = new JoinDataComplete(new JoinData { JoinNumber = 16, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Set To Vacant when Both Sensors are Vacant", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("EnableUsA")] - public JoinDataComplete EnableUsA = new JoinDataComplete(new JoinData { JoinNumber = 17, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Enable Ultrasonic Sensor A", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("DisableUsA")] - public JoinDataComplete DisableUsA = new JoinDataComplete(new JoinData { JoinNumber = 18, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Disable Ultrasonic Sensor A", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("EnableUsB")] - public JoinDataComplete EnableUsB = new JoinDataComplete(new JoinData { JoinNumber = 19, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Enable Ultrasonic Sensor B", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("DisableUsB")] - public JoinDataComplete DisableUsB = new JoinDataComplete(new JoinData { JoinNumber = 20, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Disable Ultrasonic Sensor B", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("EnablePir")] - public JoinDataComplete EnablePir = new JoinDataComplete(new JoinData { JoinNumber = 21, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Enable IR Sensor", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("DisablePir")] - public JoinDataComplete DisablePir = new JoinDataComplete(new JoinData { JoinNumber = 22, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Disable IR Sensor", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("IncrementUsInOccupiedState")] - public JoinDataComplete IncrementUsInOccupiedState = new JoinDataComplete(new JoinData { JoinNumber = 23, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Increment US Occupied State Sensitivity", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("DecrementUsInOccupiedState")] - public JoinDataComplete DecrementUsInOccupiedState = new JoinDataComplete(new JoinData { JoinNumber = 24, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Decrement US Occupied State Sensitivity", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("IncrementUsInVacantState")] - public JoinDataComplete IncrementUsInVacantState = new JoinDataComplete(new JoinData { JoinNumber = 25, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Increment US Vacant State Sensitivity", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("DecrementUsInVacantState")] - public JoinDataComplete DecrementUsInVacantState = new JoinDataComplete(new JoinData { JoinNumber = 26, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Decrement US Vacant State Sensitivity", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("IncrementPirInOccupiedState")] - public JoinDataComplete IncrementPirInOccupiedState = new JoinDataComplete(new JoinData { JoinNumber = 27, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Increment IR Occupied State Sensitivity", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("DecrementPirInOccupiedState")] - public JoinDataComplete DecrementPirInOccupiedState = new JoinDataComplete(new JoinData { JoinNumber = 28, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Decrement IR Occupied State Sensitivity", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("IncrementPirInVacantState")] - public JoinDataComplete IncrementPirInVacantState = new JoinDataComplete(new JoinData { JoinNumber = 29, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Increment IR Vacant State Sensitivity", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("DecrementPirInVacantState")] - public JoinDataComplete DecrementPirInVacantState = new JoinDataComplete(new JoinData { JoinNumber = 30, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Decrement IR Vacant State Sensitivity", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Timeout")] - public JoinDataComplete Timeout = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Timeout Value", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("TimeoutLocalFeedback")] - public JoinDataComplete TimeoutLocalFeedback = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Local Timeout Value", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("InternalPhotoSensorValue")] - public JoinDataComplete InternalPhotoSensorValue = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Internal PhotoSensor Value", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("ExternalPhotoSensorValue")] - public JoinDataComplete ExternalPhotoSensorValue = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor External PhotoSensor Value", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("UsSensitivityInOccupiedState")] - public JoinDataComplete UsSensitivityInOccupiedState = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Ultrasonic Sensitivity in Occupied State", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("UsSensitivityInVacantState")] - public JoinDataComplete UsSensitivityInVacantState = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Ultrasonic Sensitivity in Vacant State", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("PirSensitivityInOccupiedState")] - public JoinDataComplete PirSensitivityInOccupiedState = new JoinDataComplete(new JoinData { JoinNumber = 7, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor PIR Sensitivity in Occupied State", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("PirSensitivityInVacantState")] - public JoinDataComplete PirSensitivityInVacantState = new JoinDataComplete(new JoinData { JoinNumber = 8, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor PIR Sensitivity in Vacant State", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("Name")] - public JoinDataComplete Name = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Occ Sensor Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - - /// - /// Constructor to use when instantiating this Join Map without inheriting from it - /// - /// Join this join map will start at - public GlsOccupancySensorBaseJoinMap(uint joinStart) - : this(joinStart, typeof(GlsOccupancySensorBaseJoinMap)) - { - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// Type of the child join map - protected GlsOccupancySensorBaseJoinMap(uint joinStart, Type type) - : base(joinStart, type) - { - } - - } -} +using System; + +namespace PepperDash.Essentials.Core.Bridges +{ + public class GlsOccupancySensorBaseJoinMap : JoinMapBaseAdvanced + { + [JoinName("IsOnline")] + public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Is Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("ForceOccupied")] + public JoinDataComplete ForceOccupied = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Set to Occupied", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("ForceVacant")] + public JoinDataComplete ForceVacant = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Set to Vacant", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("EnableRawStates")] + public JoinDataComplete EnableRawStates = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Enable Raw", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("RoomOccupiedFeedback")] + public JoinDataComplete RoomOccupiedFeedback = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Room Is Occupied", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("GraceOccupancyDetectedFeedback")] + public JoinDataComplete GraceOccupancyDetectedFeedback = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Grace Occupancy Detected", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("RoomVacantFeedback")] + public JoinDataComplete RoomVacantFeedback = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Room Is Vacant", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("RawOccupancyFeedback")] + public JoinDataComplete RawOccupancyFeedback = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Raw Occupancy Detected", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("RawOccupancyPirFeedback")] + public JoinDataComplete RawOccupancyPirFeedback = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Raw PIR Occupancy Detected", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("RawOccupancyUsFeedback")] + public JoinDataComplete RawOccupancyUsFeedback = new JoinDataComplete(new JoinData { JoinNumber = 7, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Raw US Occupancy Detected", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("EnableLedFlash")] + public JoinDataComplete EnableLedFlash = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Enable LED Flash", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("DisableLedFlash")] + public JoinDataComplete DisableLedFlash = new JoinDataComplete(new JoinData { JoinNumber = 12, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Disable LED Flash", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("EnableShortTimeout")] + public JoinDataComplete EnableShortTimeout = new JoinDataComplete(new JoinData { JoinNumber = 13, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Enable Short Timeout", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("DisableShortTimeout")] + public JoinDataComplete DisableShortTimeout = new JoinDataComplete(new JoinData { JoinNumber = 14, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Disable Short Timeout", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("OrWhenVacated")] + public JoinDataComplete OrWhenVacated = new JoinDataComplete(new JoinData { JoinNumber = 15, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Set To Vacant when Either Sensor is Vacant", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("AndWhenVacated")] + public JoinDataComplete AndWhenVacated = new JoinDataComplete(new JoinData { JoinNumber = 16, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Set To Vacant when Both Sensors are Vacant", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("EnableUsA")] + public JoinDataComplete EnableUsA = new JoinDataComplete(new JoinData { JoinNumber = 17, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Enable Ultrasonic Sensor A", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("DisableUsA")] + public JoinDataComplete DisableUsA = new JoinDataComplete(new JoinData { JoinNumber = 18, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Disable Ultrasonic Sensor A", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("EnableUsB")] + public JoinDataComplete EnableUsB = new JoinDataComplete(new JoinData { JoinNumber = 19, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Enable Ultrasonic Sensor B", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("DisableUsB")] + public JoinDataComplete DisableUsB = new JoinDataComplete(new JoinData { JoinNumber = 20, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Disable Ultrasonic Sensor B", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("EnablePir")] + public JoinDataComplete EnablePir = new JoinDataComplete(new JoinData { JoinNumber = 21, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Enable IR Sensor", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("DisablePir")] + public JoinDataComplete DisablePir = new JoinDataComplete(new JoinData { JoinNumber = 22, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Disable IR Sensor", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("IncrementUsInOccupiedState")] + public JoinDataComplete IncrementUsInOccupiedState = new JoinDataComplete(new JoinData { JoinNumber = 23, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Increment US Occupied State Sensitivity", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("DecrementUsInOccupiedState")] + public JoinDataComplete DecrementUsInOccupiedState = new JoinDataComplete(new JoinData { JoinNumber = 24, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Decrement US Occupied State Sensitivity", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("IncrementUsInVacantState")] + public JoinDataComplete IncrementUsInVacantState = new JoinDataComplete(new JoinData { JoinNumber = 25, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Increment US Vacant State Sensitivity", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("DecrementUsInVacantState")] + public JoinDataComplete DecrementUsInVacantState = new JoinDataComplete(new JoinData { JoinNumber = 26, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Decrement US Vacant State Sensitivity", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("IncrementPirInOccupiedState")] + public JoinDataComplete IncrementPirInOccupiedState = new JoinDataComplete(new JoinData { JoinNumber = 27, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Increment IR Occupied State Sensitivity", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("DecrementPirInOccupiedState")] + public JoinDataComplete DecrementPirInOccupiedState = new JoinDataComplete(new JoinData { JoinNumber = 28, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Decrement IR Occupied State Sensitivity", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("IncrementPirInVacantState")] + public JoinDataComplete IncrementPirInVacantState = new JoinDataComplete(new JoinData { JoinNumber = 29, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Increment IR Vacant State Sensitivity", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("DecrementPirInVacantState")] + public JoinDataComplete DecrementPirInVacantState = new JoinDataComplete(new JoinData { JoinNumber = 30, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Decrement IR Vacant State Sensitivity", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Timeout")] + public JoinDataComplete Timeout = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Timeout Value", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("TimeoutLocalFeedback")] + public JoinDataComplete TimeoutLocalFeedback = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Local Timeout Value", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("InternalPhotoSensorValue")] + public JoinDataComplete InternalPhotoSensorValue = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Internal PhotoSensor Value", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("ExternalPhotoSensorValue")] + public JoinDataComplete ExternalPhotoSensorValue = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor External PhotoSensor Value", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("UsSensitivityInOccupiedState")] + public JoinDataComplete UsSensitivityInOccupiedState = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Ultrasonic Sensitivity in Occupied State", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("UsSensitivityInVacantState")] + public JoinDataComplete UsSensitivityInVacantState = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Ultrasonic Sensitivity in Vacant State", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("PirSensitivityInOccupiedState")] + public JoinDataComplete PirSensitivityInOccupiedState = new JoinDataComplete(new JoinData { JoinNumber = 7, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor PIR Sensitivity in Occupied State", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("PirSensitivityInVacantState")] + public JoinDataComplete PirSensitivityInVacantState = new JoinDataComplete(new JoinData { JoinNumber = 8, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor PIR Sensitivity in Vacant State", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("Name")] + public JoinDataComplete Name = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Occ Sensor Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + + /// + /// Constructor to use when instantiating this Join Map without inheriting from it + /// + /// Join this join map will start at + public GlsOccupancySensorBaseJoinMap(uint joinStart) + : this(joinStart, typeof(GlsOccupancySensorBaseJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected GlsOccupancySensorBaseJoinMap(uint joinStart, Type type) + : base(joinStart, type) + { + } + + } +} diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GlsPartitionSensorJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GlsPartitionSensorJoinMap.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GlsPartitionSensorJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GlsPartitionSensorJoinMap.cs index 5a583d69..0ee3d049 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GlsPartitionSensorJoinMap.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GlsPartitionSensorJoinMap.cs @@ -1,300 +1,300 @@ -using System; -using PepperDash.Essentials.Core; - -namespace PepperDash.Essentials.Core.Bridges.JoinMaps -{ - public class GlsPartitionSensorJoinMap : JoinMapBaseAdvanced - { - - #region Digital - - [JoinName("IsOnline")] - public JoinDataComplete IsOnline = new JoinDataComplete( - new JoinData - { - JoinNumber = 1, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Sensor Is Online", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - - [JoinName("Enable")] - public JoinDataComplete Enable = new JoinDataComplete( - new JoinData - { - JoinNumber = 2, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Sensor Enable", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("PartitionSensed")] - public JoinDataComplete PartitionSensed = new JoinDataComplete( - new JoinData - { - JoinNumber = 3, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Sensor Partition Sensed", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("PartitionNotSensed")] - public JoinDataComplete PartitionNotSensed = new JoinDataComplete( - new JoinData - { - JoinNumber = 4, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Sensor Partition Not Sensed", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("IncreaseSensitivity")] - public JoinDataComplete IncreaseSensitivity = new JoinDataComplete( - new JoinData - { - JoinNumber = 6, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Sensor Increase Sensitivity", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DecreaseSensitivity")] - public JoinDataComplete DecreaseSensitivity = new JoinDataComplete( - new JoinData - { - JoinNumber = 7, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Sensor Decrease Sensitivity", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - #endregion - - #region Analog - - [JoinName("Sensitivity")] - public JoinDataComplete Sensitivity = new JoinDataComplete( - new JoinData - { - JoinNumber = 2, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Sensor Sensitivity", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Analog - }); - - #endregion - - - #region Serial - - [JoinName("Name")] - public JoinDataComplete Name = new JoinDataComplete( - new JoinData - { - JoinNumber = 1, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Sensor Name", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - #endregion - - - /// - /// Constructor to use when instantiating this Join Map without inheriting from it - /// - /// Join this join map will start at - public GlsPartitionSensorJoinMap(uint joinStart) - : this(joinStart, typeof(GlsPartitionSensorJoinMap)) - { - - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// Type of the child join map - protected GlsPartitionSensorJoinMap(uint joinStart, Type type) - : base(joinStart, type) - { - - } - } -} - -namespace PepperDash_Essentials_Core.Bridges.JoinMaps -{ - /// - /// - /// - [Obsolete("use PepperDash.Essentials.Core.Bridges.JoinMaps version")] - public class GlsPartitionSensorJoinMap:JoinMapBaseAdvanced - { - [JoinName("IsOnline")] - public JoinDataComplete IsOnline = new JoinDataComplete( - new JoinData - { - JoinNumber = 1, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Sensor Is Online", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("Name")] - public JoinDataComplete Name = new JoinDataComplete( - new JoinData - { - JoinNumber = 1, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Sensor Name", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("Enable")] - public JoinDataComplete Enable = new JoinDataComplete( - new JoinData - { - JoinNumber = 2, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Sensor Enable", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("PartitionSensed")] - public JoinDataComplete PartitionSensed = new JoinDataComplete( - new JoinData - { - JoinNumber = 3, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Sensor Partition Sensed", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("PartitionNotSensed")] - public JoinDataComplete PartitionNotSensed = new JoinDataComplete( - new JoinData - { - JoinNumber = 4, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Sensor Partition Not Sensed", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("IncreaseSensitivity")] - public JoinDataComplete IncreaseSensitivity = new JoinDataComplete( - new JoinData - { - JoinNumber = 6, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Sensor Increase Sensitivity", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DecreaseSensitivity")] - public JoinDataComplete DecreaseSensitivity = new JoinDataComplete( - new JoinData - { - JoinNumber = 7, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Sensor Decrease Sensitivity", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("Sensitivity")] - public JoinDataComplete Sensitivity = new JoinDataComplete( - new JoinData - { - JoinNumber = 2, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Sensor Sensitivity", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Analog - }); - - /// - /// Constructor to use when instantiating this Join Map without inheriting from it - /// - /// Join this join map will start at - public GlsPartitionSensorJoinMap(uint joinStart) - : this(joinStart, typeof(GlsPartitionSensorJoinMap)) - { - - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// Type of the child join map - protected GlsPartitionSensorJoinMap(uint joinStart, Type type) - : base(joinStart, type) - { - - } - } +using System; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Core.Bridges.JoinMaps +{ + public class GlsPartitionSensorJoinMap : JoinMapBaseAdvanced + { + + #region Digital + + [JoinName("IsOnline")] + public JoinDataComplete IsOnline = new JoinDataComplete( + new JoinData + { + JoinNumber = 1, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Sensor Is Online", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + + [JoinName("Enable")] + public JoinDataComplete Enable = new JoinDataComplete( + new JoinData + { + JoinNumber = 2, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Sensor Enable", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("PartitionSensed")] + public JoinDataComplete PartitionSensed = new JoinDataComplete( + new JoinData + { + JoinNumber = 3, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Sensor Partition Sensed", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("PartitionNotSensed")] + public JoinDataComplete PartitionNotSensed = new JoinDataComplete( + new JoinData + { + JoinNumber = 4, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Sensor Partition Not Sensed", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("IncreaseSensitivity")] + public JoinDataComplete IncreaseSensitivity = new JoinDataComplete( + new JoinData + { + JoinNumber = 6, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Sensor Increase Sensitivity", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DecreaseSensitivity")] + public JoinDataComplete DecreaseSensitivity = new JoinDataComplete( + new JoinData + { + JoinNumber = 7, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Sensor Decrease Sensitivity", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + #endregion + + #region Analog + + [JoinName("Sensitivity")] + public JoinDataComplete Sensitivity = new JoinDataComplete( + new JoinData + { + JoinNumber = 2, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Sensor Sensitivity", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Analog + }); + + #endregion + + + #region Serial + + [JoinName("Name")] + public JoinDataComplete Name = new JoinDataComplete( + new JoinData + { + JoinNumber = 1, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Sensor Name", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + #endregion + + + /// + /// Constructor to use when instantiating this Join Map without inheriting from it + /// + /// Join this join map will start at + public GlsPartitionSensorJoinMap(uint joinStart) + : this(joinStart, typeof(GlsPartitionSensorJoinMap)) + { + + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected GlsPartitionSensorJoinMap(uint joinStart, Type type) + : base(joinStart, type) + { + + } + } +} + +namespace PepperDash_Essentials_Core.Bridges.JoinMaps +{ + /// + /// + /// + [Obsolete("use PepperDash.Essentials.Core.Bridges.JoinMaps version")] + public class GlsPartitionSensorJoinMap:JoinMapBaseAdvanced + { + [JoinName("IsOnline")] + public JoinDataComplete IsOnline = new JoinDataComplete( + new JoinData + { + JoinNumber = 1, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Sensor Is Online", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("Name")] + public JoinDataComplete Name = new JoinDataComplete( + new JoinData + { + JoinNumber = 1, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Sensor Name", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("Enable")] + public JoinDataComplete Enable = new JoinDataComplete( + new JoinData + { + JoinNumber = 2, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Sensor Enable", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("PartitionSensed")] + public JoinDataComplete PartitionSensed = new JoinDataComplete( + new JoinData + { + JoinNumber = 3, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Sensor Partition Sensed", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("PartitionNotSensed")] + public JoinDataComplete PartitionNotSensed = new JoinDataComplete( + new JoinData + { + JoinNumber = 4, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Sensor Partition Not Sensed", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("IncreaseSensitivity")] + public JoinDataComplete IncreaseSensitivity = new JoinDataComplete( + new JoinData + { + JoinNumber = 6, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Sensor Increase Sensitivity", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DecreaseSensitivity")] + public JoinDataComplete DecreaseSensitivity = new JoinDataComplete( + new JoinData + { + JoinNumber = 7, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Sensor Decrease Sensitivity", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("Sensitivity")] + public JoinDataComplete Sensitivity = new JoinDataComplete( + new JoinData + { + JoinNumber = 2, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Sensor Sensitivity", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Analog + }); + + /// + /// Constructor to use when instantiating this Join Map without inheriting from it + /// + /// Join this join map will start at + public GlsPartitionSensorJoinMap(uint joinStart) + : this(joinStart, typeof(GlsPartitionSensorJoinMap)) + { + + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected GlsPartitionSensorJoinMap(uint joinStart, Type type) + : base(joinStart, type) + { + + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdMdNxM4kEControllerJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdMdNxM4kEControllerJoinMap.cs similarity index 98% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdMdNxM4kEControllerJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdMdNxM4kEControllerJoinMap.cs index a0406982..e69946ea 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdMdNxM4kEControllerJoinMap.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdMdNxM4kEControllerJoinMap.cs @@ -1,66 +1,66 @@ -using System; - -namespace PepperDash.Essentials.Core.Bridges -{ - public class HdMdNxM4kEControllerJoinMap : JoinMapBaseAdvanced - { - [JoinName("Name")] - public JoinDataComplete Name = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Device Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("EnableAutoRoute")] - public JoinDataComplete EnableAutoRoute = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Enable Automatic Routing on 4x1 Switchers", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("InputName")] - public JoinDataComplete InputName = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 8 }, - new JoinMetadata { Description = "Device Input Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("InputSync")] - public JoinDataComplete InputSync = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 8 }, - new JoinMetadata { Description = "Device Input Sync", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("OutputName")] - public JoinDataComplete OutputName = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 2 }, - new JoinMetadata { Description = "Device Output Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("OutputRoute")] - public JoinDataComplete OutputRoute = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 2 }, - new JoinMetadata { Description = "Device Output Route Set/Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("OutputRoutedName")] - public JoinDataComplete OutputRoutedName = new JoinDataComplete(new JoinData { JoinNumber = 16, JoinSpan = 2 }, - new JoinMetadata { Description = "Device Output Route Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("EnableInputHdcp")] - public JoinDataComplete EnableInputHdcp = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 8 }, - new JoinMetadata { Description = "Device Enable Input Hdcp", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("DisableInputHdcp")] - public JoinDataComplete DisableInputHdcp = new JoinDataComplete(new JoinData { JoinNumber = 21, JoinSpan = 8 }, - new JoinMetadata { Description = "Device Disnable Input Hdcp", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("IsOnline")] - public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 30, JoinSpan = 1 }, - new JoinMetadata { Description = "Device Onlne", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - /// - /// Constructor to use when instantiating this Join Map without inheriting from it - /// - /// Join this join map will start at - public HdMdNxM4kEControllerJoinMap(uint joinStart) - : this(joinStart, typeof(HdMdNxM4kEControllerJoinMap)) - { - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// Type of the child join map - protected HdMdNxM4kEControllerJoinMap(uint joinStart, Type type) - : base(joinStart, type) - { - } - } +using System; + +namespace PepperDash.Essentials.Core.Bridges +{ + public class HdMdNxM4kEControllerJoinMap : JoinMapBaseAdvanced + { + [JoinName("Name")] + public JoinDataComplete Name = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Device Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("EnableAutoRoute")] + public JoinDataComplete EnableAutoRoute = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Enable Automatic Routing on 4x1 Switchers", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("InputName")] + public JoinDataComplete InputName = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 8 }, + new JoinMetadata { Description = "Device Input Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("InputSync")] + public JoinDataComplete InputSync = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 8 }, + new JoinMetadata { Description = "Device Input Sync", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("OutputName")] + public JoinDataComplete OutputName = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 2 }, + new JoinMetadata { Description = "Device Output Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("OutputRoute")] + public JoinDataComplete OutputRoute = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 2 }, + new JoinMetadata { Description = "Device Output Route Set/Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("OutputRoutedName")] + public JoinDataComplete OutputRoutedName = new JoinDataComplete(new JoinData { JoinNumber = 16, JoinSpan = 2 }, + new JoinMetadata { Description = "Device Output Route Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("EnableInputHdcp")] + public JoinDataComplete EnableInputHdcp = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 8 }, + new JoinMetadata { Description = "Device Enable Input Hdcp", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("DisableInputHdcp")] + public JoinDataComplete DisableInputHdcp = new JoinDataComplete(new JoinData { JoinNumber = 21, JoinSpan = 8 }, + new JoinMetadata { Description = "Device Disnable Input Hdcp", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("IsOnline")] + public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 30, JoinSpan = 1 }, + new JoinMetadata { Description = "Device Onlne", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + /// + /// Constructor to use when instantiating this Join Map without inheriting from it + /// + /// Join this join map will start at + public HdMdNxM4kEControllerJoinMap(uint joinStart) + : this(joinStart, typeof(HdMdNxM4kEControllerJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected HdMdNxM4kEControllerJoinMap(uint joinStart, Type type) + : base(joinStart, type) + { + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdMdxxxCEControllerJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdMdxxxCEControllerJoinMap.cs similarity index 98% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdMdxxxCEControllerJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdMdxxxCEControllerJoinMap.cs index 61a66e05..0936f75d 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdMdxxxCEControllerJoinMap.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdMdxxxCEControllerJoinMap.cs @@ -1,76 +1,76 @@ -using System; - +using System; + namespace PepperDash.Essentials.Core.Bridges { public class HdMdxxxCEControllerJoinMap : JoinMapBaseAdvanced { - [JoinName("IsOnline")] - public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Device Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("RemoteEndDetected")] - public JoinDataComplete RemoteEndDetected = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "Device Remote End Detected", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("AutoRouteOn")] - public JoinDataComplete AutoRouteOn = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, - new JoinMetadata { Description = "Device Auto Route On", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("AutoRouteOff")] - public JoinDataComplete AutoRouteOff = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, - new JoinMetadata { Description = "Device Auto Route Off", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("PriorityRoutingOn")] - public JoinDataComplete PriorityRoutingOn = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, - new JoinMetadata { Description = "Device Priority Routing On", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("PriorityRoutingOff")] - public JoinDataComplete PriorityRoutingOff = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, - new JoinMetadata { Description = "Device Priority Routing Off", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("InputOnScreenDisplayEnabled")] - public JoinDataComplete InputOnScreenDisplayEnabled = new JoinDataComplete(new JoinData { JoinNumber = 7, JoinSpan = 1 }, - new JoinMetadata { Description = "Device Input OSD Enabled", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("InputOnScreenDisplayDisabled")] - public JoinDataComplete InputOnScreenDisplayDisabled = new JoinDataComplete(new JoinData { JoinNumber = 8, JoinSpan = 1 }, - new JoinMetadata { Description = "Device Input OSD Disabled", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("SyncDetected")] - public JoinDataComplete SyncDetected = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 5 }, - new JoinMetadata { Description = "Device Sync Detected", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("VideoSource")] - public JoinDataComplete VideoSource = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 5 }, - new JoinMetadata { Description = "Device Video Source Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("SourceCount")] - public JoinDataComplete SourceCount = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 5 }, - new JoinMetadata { Description = "Device Video Source Count", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("SourceNames")] - public JoinDataComplete SourceNames = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 5 }, - new JoinMetadata { Description = "Device Video Source Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - - /// - /// Constructor to use when instantiating this Join Map without inheriting from it - /// - /// Join this join map will start at - public HdMdxxxCEControllerJoinMap(uint joinStart) - : this(joinStart, typeof(HdMdxxxCEControllerJoinMap)) - { - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// Type of the child join map - protected HdMdxxxCEControllerJoinMap(uint joinStart, Type type) - : base(joinStart, type) - { + [JoinName("IsOnline")] + public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Device Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("RemoteEndDetected")] + public JoinDataComplete RemoteEndDetected = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "Device Remote End Detected", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("AutoRouteOn")] + public JoinDataComplete AutoRouteOn = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "Device Auto Route On", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("AutoRouteOff")] + public JoinDataComplete AutoRouteOff = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "Device Auto Route Off", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("PriorityRoutingOn")] + public JoinDataComplete PriorityRoutingOn = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata { Description = "Device Priority Routing On", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("PriorityRoutingOff")] + public JoinDataComplete PriorityRoutingOff = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, + new JoinMetadata { Description = "Device Priority Routing Off", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("InputOnScreenDisplayEnabled")] + public JoinDataComplete InputOnScreenDisplayEnabled = new JoinDataComplete(new JoinData { JoinNumber = 7, JoinSpan = 1 }, + new JoinMetadata { Description = "Device Input OSD Enabled", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("InputOnScreenDisplayDisabled")] + public JoinDataComplete InputOnScreenDisplayDisabled = new JoinDataComplete(new JoinData { JoinNumber = 8, JoinSpan = 1 }, + new JoinMetadata { Description = "Device Input OSD Disabled", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("SyncDetected")] + public JoinDataComplete SyncDetected = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 5 }, + new JoinMetadata { Description = "Device Sync Detected", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("VideoSource")] + public JoinDataComplete VideoSource = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 5 }, + new JoinMetadata { Description = "Device Video Source Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("SourceCount")] + public JoinDataComplete SourceCount = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 5 }, + new JoinMetadata { Description = "Device Video Source Count", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("SourceNames")] + public JoinDataComplete SourceNames = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 5 }, + new JoinMetadata { Description = "Device Video Source Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + + /// + /// Constructor to use when instantiating this Join Map without inheriting from it + /// + /// Join this join map will start at + public HdMdxxxCEControllerJoinMap(uint joinStart) + : this(joinStart, typeof(HdMdxxxCEControllerJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected HdMdxxxCEControllerJoinMap(uint joinStart, Type type) + : base(joinStart, type) + { } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdPsXxxControllerJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdPsXxxControllerJoinMap.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdPsXxxControllerJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdPsXxxControllerJoinMap.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/Hrxxx0WirelessRemoteControllerJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/Hrxxx0WirelessRemoteControllerJoinMap.cs similarity index 98% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/Hrxxx0WirelessRemoteControllerJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/Hrxxx0WirelessRemoteControllerJoinMap.cs index c001733e..23305b20 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/Hrxxx0WirelessRemoteControllerJoinMap.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/Hrxxx0WirelessRemoteControllerJoinMap.cs @@ -1,246 +1,246 @@ -using System; - -namespace PepperDash.Essentials.Core.Bridges -{ - public class Hrxxx0WirelessRemoteControllerJoinMap : JoinMapBaseAdvanced - { - [JoinName("Power")] - public JoinDataComplete Power = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Power", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Menu")] - public JoinDataComplete Menu = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "Menu", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Guide")] - public JoinDataComplete Guide = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, - new JoinMetadata { Description = "Guide", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Info")] - public JoinDataComplete Info = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, - new JoinMetadata { Description = "Info", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("VolumeUp")] - public JoinDataComplete VolumeUp = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, - new JoinMetadata { Description = "VolumeUp", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("VolumeDown")] - public JoinDataComplete VolumeDown = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, - new JoinMetadata { Description = "VolumeDown", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("DialPadUp")] - public JoinDataComplete DialPadUp = new JoinDataComplete(new JoinData { JoinNumber = 7, JoinSpan = 1 }, - new JoinMetadata { Description = "DialPadUp", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("DialPadDown")] - public JoinDataComplete DialPadDown = new JoinDataComplete(new JoinData { JoinNumber = 8, JoinSpan = 1 }, - new JoinMetadata { Description = "DialPadDown", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("DialPadLeft")] - public JoinDataComplete DialPadLeft = new JoinDataComplete(new JoinData { JoinNumber = 9, JoinSpan = 1 }, - new JoinMetadata { Description = "DialPadLeft", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("DialPadRight")] - public JoinDataComplete DialPadRight = new JoinDataComplete(new JoinData { JoinNumber = 10, JoinSpan = 1 }, - new JoinMetadata { Description = "DialPadRight", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("DialPadSelect")] - public JoinDataComplete DialPadSelect = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, - new JoinMetadata { Description = "DialPadSelect", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("ChannelUp")] - public JoinDataComplete ChannelUp = new JoinDataComplete(new JoinData { JoinNumber = 12, JoinSpan = 1 }, - new JoinMetadata { Description = "ChannelUp", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("ChannelDown")] - public JoinDataComplete ChannelDown = new JoinDataComplete(new JoinData { JoinNumber = 13, JoinSpan = 1 }, - new JoinMetadata { Description = "ChannelDown", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Mute")] - public JoinDataComplete Mute = new JoinDataComplete(new JoinData { JoinNumber = 14, JoinSpan = 1 }, - new JoinMetadata { Description = "Mute", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Exit")] - public JoinDataComplete Exit = new JoinDataComplete(new JoinData { JoinNumber = 15, JoinSpan = 1 }, - new JoinMetadata { Description = "Exit", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Last")] - public JoinDataComplete Last = new JoinDataComplete(new JoinData { JoinNumber = 16, JoinSpan = 1 }, - new JoinMetadata { Description = "Last", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Play")] - public JoinDataComplete Play = new JoinDataComplete(new JoinData { JoinNumber = 17, JoinSpan = 1 }, - new JoinMetadata { Description = "Play", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Pause")] - public JoinDataComplete Pause = new JoinDataComplete(new JoinData { JoinNumber = 18, JoinSpan = 1 }, - new JoinMetadata { Description = "Pause", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Rewind")] - public JoinDataComplete Rewind = new JoinDataComplete(new JoinData { JoinNumber = 19, JoinSpan = 1 }, - new JoinMetadata { Description = "Rewind", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("FastForward")] - public JoinDataComplete FastForward = new JoinDataComplete(new JoinData { JoinNumber = 20, JoinSpan = 1 }, - new JoinMetadata { Description = "FastForward", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("PreviousTrack")] - public JoinDataComplete PreviousTrack = new JoinDataComplete(new JoinData { JoinNumber = 21, JoinSpan = 1 }, - new JoinMetadata { Description = "PreviousTrack", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("NextTrack")] - public JoinDataComplete NextTrack = new JoinDataComplete(new JoinData { JoinNumber = 22, JoinSpan = 1 }, - new JoinMetadata { Description = "NextTrack", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Stop")] - public JoinDataComplete Stop = new JoinDataComplete(new JoinData { JoinNumber = 23, JoinSpan = 1 }, - new JoinMetadata { Description = "Stop", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Record")] - public JoinDataComplete Record = new JoinDataComplete(new JoinData { JoinNumber = 24, JoinSpan = 1 }, - new JoinMetadata { Description = "Record", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Dvr")] - public JoinDataComplete Dvr = new JoinDataComplete(new JoinData { JoinNumber = 25, JoinSpan = 1 }, - new JoinMetadata { Description = "Dvr", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Keypad1")] - public JoinDataComplete Keypad1 = new JoinDataComplete(new JoinData { JoinNumber = 26, JoinSpan = 1 }, - new JoinMetadata { Description = "Keypad1", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Keypad2Abc")] - public JoinDataComplete Keypad2 = new JoinDataComplete(new JoinData { JoinNumber = 27, JoinSpan = 1 }, - new JoinMetadata { Description = "Keypad2Abc", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Keypad3Def")] - public JoinDataComplete Keypad3Def = new JoinDataComplete(new JoinData { JoinNumber = 28, JoinSpan = 1 }, - new JoinMetadata { Description = "Keypad3Def", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Keypad4Ghi")] - public JoinDataComplete Keypad4Ghi = new JoinDataComplete(new JoinData { JoinNumber = 29, JoinSpan = 1 }, - new JoinMetadata { Description = "Keypad4Ghi", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Keypad5Jkl")] - public JoinDataComplete Keypad5Jkl = new JoinDataComplete(new JoinData { JoinNumber = 30, JoinSpan = 1 }, - new JoinMetadata { Description = "Keypad5Jkl", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Keypad6Mno")] - public JoinDataComplete Keypad6Mno = new JoinDataComplete(new JoinData { JoinNumber = 31, JoinSpan = 1 }, - new JoinMetadata { Description = "Keypad6Mno", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Keypad7Pqrs")] - public JoinDataComplete Keypad7Pqrs = new JoinDataComplete(new JoinData { JoinNumber = 32, JoinSpan = 1 }, - new JoinMetadata { Description = "Keypad7Pqrs", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Keypad8Tuv")] - public JoinDataComplete Keypad8Tuv = new JoinDataComplete(new JoinData { JoinNumber = 33, JoinSpan = 1 }, - new JoinMetadata { Description = "Keypad8Tuv", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Keypad9Wxyz")] - public JoinDataComplete Keypad9Wxyz = new JoinDataComplete(new JoinData { JoinNumber = 34, JoinSpan = 1 }, - new JoinMetadata { Description = "Keypad9Wxyz", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Keypad0")] - public JoinDataComplete Keypad0 = new JoinDataComplete(new JoinData { JoinNumber = 35, JoinSpan = 1 }, - new JoinMetadata { Description = "Keypad0", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Clear")] - public JoinDataComplete Clear = new JoinDataComplete(new JoinData { JoinNumber = 36, JoinSpan = 1 }, - new JoinMetadata { Description = "Clear", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Enter")] - public JoinDataComplete Enter = new JoinDataComplete(new JoinData { JoinNumber = 37, JoinSpan = 1 }, - new JoinMetadata { Description = "Enter", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Red")] - public JoinDataComplete Red = new JoinDataComplete(new JoinData { JoinNumber = 38, JoinSpan = 1 }, - new JoinMetadata { Description = "Red", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Green")] - public JoinDataComplete Green = new JoinDataComplete(new JoinData { JoinNumber = 39, JoinSpan = 1 }, - new JoinMetadata { Description = "Green", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Yellow")] - public JoinDataComplete Yellow = new JoinDataComplete(new JoinData { JoinNumber = 40, JoinSpan = 1 }, - new JoinMetadata { Description = "Yellow", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Blue")] - public JoinDataComplete Blue = new JoinDataComplete(new JoinData { JoinNumber = 41, JoinSpan = 1 }, - new JoinMetadata { Description = "Blue", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Custom1")] - public JoinDataComplete Custom1 = new JoinDataComplete(new JoinData { JoinNumber = 42, JoinSpan = 1 }, - new JoinMetadata { Description = "Custom1", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Custom2")] - public JoinDataComplete Custom2 = new JoinDataComplete(new JoinData { JoinNumber = 43, JoinSpan = 1 }, - new JoinMetadata { Description = "Custom2", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Custom3")] - public JoinDataComplete Custom3 = new JoinDataComplete(new JoinData { JoinNumber = 44, JoinSpan = 1 }, - new JoinMetadata { Description = "Custom3", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Custom4")] - public JoinDataComplete Custom4 = new JoinDataComplete(new JoinData { JoinNumber = 45, JoinSpan = 1 }, - new JoinMetadata { Description = "Custom4", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Custom5")] - public JoinDataComplete Custom5 = new JoinDataComplete(new JoinData { JoinNumber = 46, JoinSpan = 1 }, - new JoinMetadata { Description = "Custom5", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Custom6")] - public JoinDataComplete Custom6 = new JoinDataComplete(new JoinData { JoinNumber = 47, JoinSpan = 1 }, - new JoinMetadata { Description = "Custom6", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Custom7")] - public JoinDataComplete Custom7 = new JoinDataComplete(new JoinData { JoinNumber = 48, JoinSpan = 1 }, - new JoinMetadata { Description = "Custom7", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Custom8")] - public JoinDataComplete Custom8 = new JoinDataComplete(new JoinData { JoinNumber = 49, JoinSpan = 1 }, - new JoinMetadata { Description = "Custom8", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Custom9")] - public JoinDataComplete Custom9 = new JoinDataComplete(new JoinData { JoinNumber = 50, JoinSpan = 1 }, - new JoinMetadata { Description = "Custom9", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Fav")] - public JoinDataComplete Fav = new JoinDataComplete(new JoinData { JoinNumber = 51, JoinSpan = 1 }, - new JoinMetadata { Description = "Fav", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Home")] - public JoinDataComplete Home = new JoinDataComplete(new JoinData { JoinNumber = 52, JoinSpan = 1 }, - new JoinMetadata { Description = "Home", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("BatteryLow")] - public JoinDataComplete BatteryLow = new JoinDataComplete(new JoinData { JoinNumber = 53, JoinSpan = 1 }, - new JoinMetadata { Description = "BatteryLow", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("BatteryCritical")] - public JoinDataComplete BatteryCritical = new JoinDataComplete(new JoinData { JoinNumber = 54, JoinSpan = 1 }, - new JoinMetadata { Description = "BatteryCritical", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("BatteryVoltage")] - public JoinDataComplete BatteryVoltage = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "BatteryVoltage", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - /// - /// Constructor to use when instantiating this Join Map without inheriting from it - /// - /// Join this join map will start at - public Hrxxx0WirelessRemoteControllerJoinMap(uint joinStart) - : this(joinStart, typeof(Hrxxx0WirelessRemoteControllerJoinMap)) - { - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// Type of the child join map - protected Hrxxx0WirelessRemoteControllerJoinMap(uint joinStart, Type type) - : base(joinStart, type) - { - } - } +using System; + +namespace PepperDash.Essentials.Core.Bridges +{ + public class Hrxxx0WirelessRemoteControllerJoinMap : JoinMapBaseAdvanced + { + [JoinName("Power")] + public JoinDataComplete Power = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Power", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Menu")] + public JoinDataComplete Menu = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "Menu", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Guide")] + public JoinDataComplete Guide = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "Guide", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Info")] + public JoinDataComplete Info = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "Info", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("VolumeUp")] + public JoinDataComplete VolumeUp = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata { Description = "VolumeUp", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("VolumeDown")] + public JoinDataComplete VolumeDown = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, + new JoinMetadata { Description = "VolumeDown", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("DialPadUp")] + public JoinDataComplete DialPadUp = new JoinDataComplete(new JoinData { JoinNumber = 7, JoinSpan = 1 }, + new JoinMetadata { Description = "DialPadUp", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("DialPadDown")] + public JoinDataComplete DialPadDown = new JoinDataComplete(new JoinData { JoinNumber = 8, JoinSpan = 1 }, + new JoinMetadata { Description = "DialPadDown", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("DialPadLeft")] + public JoinDataComplete DialPadLeft = new JoinDataComplete(new JoinData { JoinNumber = 9, JoinSpan = 1 }, + new JoinMetadata { Description = "DialPadLeft", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("DialPadRight")] + public JoinDataComplete DialPadRight = new JoinDataComplete(new JoinData { JoinNumber = 10, JoinSpan = 1 }, + new JoinMetadata { Description = "DialPadRight", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("DialPadSelect")] + public JoinDataComplete DialPadSelect = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, + new JoinMetadata { Description = "DialPadSelect", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("ChannelUp")] + public JoinDataComplete ChannelUp = new JoinDataComplete(new JoinData { JoinNumber = 12, JoinSpan = 1 }, + new JoinMetadata { Description = "ChannelUp", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("ChannelDown")] + public JoinDataComplete ChannelDown = new JoinDataComplete(new JoinData { JoinNumber = 13, JoinSpan = 1 }, + new JoinMetadata { Description = "ChannelDown", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Mute")] + public JoinDataComplete Mute = new JoinDataComplete(new JoinData { JoinNumber = 14, JoinSpan = 1 }, + new JoinMetadata { Description = "Mute", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Exit")] + public JoinDataComplete Exit = new JoinDataComplete(new JoinData { JoinNumber = 15, JoinSpan = 1 }, + new JoinMetadata { Description = "Exit", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Last")] + public JoinDataComplete Last = new JoinDataComplete(new JoinData { JoinNumber = 16, JoinSpan = 1 }, + new JoinMetadata { Description = "Last", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Play")] + public JoinDataComplete Play = new JoinDataComplete(new JoinData { JoinNumber = 17, JoinSpan = 1 }, + new JoinMetadata { Description = "Play", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Pause")] + public JoinDataComplete Pause = new JoinDataComplete(new JoinData { JoinNumber = 18, JoinSpan = 1 }, + new JoinMetadata { Description = "Pause", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Rewind")] + public JoinDataComplete Rewind = new JoinDataComplete(new JoinData { JoinNumber = 19, JoinSpan = 1 }, + new JoinMetadata { Description = "Rewind", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("FastForward")] + public JoinDataComplete FastForward = new JoinDataComplete(new JoinData { JoinNumber = 20, JoinSpan = 1 }, + new JoinMetadata { Description = "FastForward", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("PreviousTrack")] + public JoinDataComplete PreviousTrack = new JoinDataComplete(new JoinData { JoinNumber = 21, JoinSpan = 1 }, + new JoinMetadata { Description = "PreviousTrack", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("NextTrack")] + public JoinDataComplete NextTrack = new JoinDataComplete(new JoinData { JoinNumber = 22, JoinSpan = 1 }, + new JoinMetadata { Description = "NextTrack", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Stop")] + public JoinDataComplete Stop = new JoinDataComplete(new JoinData { JoinNumber = 23, JoinSpan = 1 }, + new JoinMetadata { Description = "Stop", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Record")] + public JoinDataComplete Record = new JoinDataComplete(new JoinData { JoinNumber = 24, JoinSpan = 1 }, + new JoinMetadata { Description = "Record", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Dvr")] + public JoinDataComplete Dvr = new JoinDataComplete(new JoinData { JoinNumber = 25, JoinSpan = 1 }, + new JoinMetadata { Description = "Dvr", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Keypad1")] + public JoinDataComplete Keypad1 = new JoinDataComplete(new JoinData { JoinNumber = 26, JoinSpan = 1 }, + new JoinMetadata { Description = "Keypad1", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Keypad2Abc")] + public JoinDataComplete Keypad2 = new JoinDataComplete(new JoinData { JoinNumber = 27, JoinSpan = 1 }, + new JoinMetadata { Description = "Keypad2Abc", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Keypad3Def")] + public JoinDataComplete Keypad3Def = new JoinDataComplete(new JoinData { JoinNumber = 28, JoinSpan = 1 }, + new JoinMetadata { Description = "Keypad3Def", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Keypad4Ghi")] + public JoinDataComplete Keypad4Ghi = new JoinDataComplete(new JoinData { JoinNumber = 29, JoinSpan = 1 }, + new JoinMetadata { Description = "Keypad4Ghi", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Keypad5Jkl")] + public JoinDataComplete Keypad5Jkl = new JoinDataComplete(new JoinData { JoinNumber = 30, JoinSpan = 1 }, + new JoinMetadata { Description = "Keypad5Jkl", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Keypad6Mno")] + public JoinDataComplete Keypad6Mno = new JoinDataComplete(new JoinData { JoinNumber = 31, JoinSpan = 1 }, + new JoinMetadata { Description = "Keypad6Mno", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Keypad7Pqrs")] + public JoinDataComplete Keypad7Pqrs = new JoinDataComplete(new JoinData { JoinNumber = 32, JoinSpan = 1 }, + new JoinMetadata { Description = "Keypad7Pqrs", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Keypad8Tuv")] + public JoinDataComplete Keypad8Tuv = new JoinDataComplete(new JoinData { JoinNumber = 33, JoinSpan = 1 }, + new JoinMetadata { Description = "Keypad8Tuv", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Keypad9Wxyz")] + public JoinDataComplete Keypad9Wxyz = new JoinDataComplete(new JoinData { JoinNumber = 34, JoinSpan = 1 }, + new JoinMetadata { Description = "Keypad9Wxyz", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Keypad0")] + public JoinDataComplete Keypad0 = new JoinDataComplete(new JoinData { JoinNumber = 35, JoinSpan = 1 }, + new JoinMetadata { Description = "Keypad0", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Clear")] + public JoinDataComplete Clear = new JoinDataComplete(new JoinData { JoinNumber = 36, JoinSpan = 1 }, + new JoinMetadata { Description = "Clear", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Enter")] + public JoinDataComplete Enter = new JoinDataComplete(new JoinData { JoinNumber = 37, JoinSpan = 1 }, + new JoinMetadata { Description = "Enter", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Red")] + public JoinDataComplete Red = new JoinDataComplete(new JoinData { JoinNumber = 38, JoinSpan = 1 }, + new JoinMetadata { Description = "Red", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Green")] + public JoinDataComplete Green = new JoinDataComplete(new JoinData { JoinNumber = 39, JoinSpan = 1 }, + new JoinMetadata { Description = "Green", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Yellow")] + public JoinDataComplete Yellow = new JoinDataComplete(new JoinData { JoinNumber = 40, JoinSpan = 1 }, + new JoinMetadata { Description = "Yellow", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Blue")] + public JoinDataComplete Blue = new JoinDataComplete(new JoinData { JoinNumber = 41, JoinSpan = 1 }, + new JoinMetadata { Description = "Blue", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Custom1")] + public JoinDataComplete Custom1 = new JoinDataComplete(new JoinData { JoinNumber = 42, JoinSpan = 1 }, + new JoinMetadata { Description = "Custom1", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Custom2")] + public JoinDataComplete Custom2 = new JoinDataComplete(new JoinData { JoinNumber = 43, JoinSpan = 1 }, + new JoinMetadata { Description = "Custom2", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Custom3")] + public JoinDataComplete Custom3 = new JoinDataComplete(new JoinData { JoinNumber = 44, JoinSpan = 1 }, + new JoinMetadata { Description = "Custom3", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Custom4")] + public JoinDataComplete Custom4 = new JoinDataComplete(new JoinData { JoinNumber = 45, JoinSpan = 1 }, + new JoinMetadata { Description = "Custom4", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Custom5")] + public JoinDataComplete Custom5 = new JoinDataComplete(new JoinData { JoinNumber = 46, JoinSpan = 1 }, + new JoinMetadata { Description = "Custom5", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Custom6")] + public JoinDataComplete Custom6 = new JoinDataComplete(new JoinData { JoinNumber = 47, JoinSpan = 1 }, + new JoinMetadata { Description = "Custom6", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Custom7")] + public JoinDataComplete Custom7 = new JoinDataComplete(new JoinData { JoinNumber = 48, JoinSpan = 1 }, + new JoinMetadata { Description = "Custom7", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Custom8")] + public JoinDataComplete Custom8 = new JoinDataComplete(new JoinData { JoinNumber = 49, JoinSpan = 1 }, + new JoinMetadata { Description = "Custom8", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Custom9")] + public JoinDataComplete Custom9 = new JoinDataComplete(new JoinData { JoinNumber = 50, JoinSpan = 1 }, + new JoinMetadata { Description = "Custom9", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Fav")] + public JoinDataComplete Fav = new JoinDataComplete(new JoinData { JoinNumber = 51, JoinSpan = 1 }, + new JoinMetadata { Description = "Fav", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Home")] + public JoinDataComplete Home = new JoinDataComplete(new JoinData { JoinNumber = 52, JoinSpan = 1 }, + new JoinMetadata { Description = "Home", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("BatteryLow")] + public JoinDataComplete BatteryLow = new JoinDataComplete(new JoinData { JoinNumber = 53, JoinSpan = 1 }, + new JoinMetadata { Description = "BatteryLow", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("BatteryCritical")] + public JoinDataComplete BatteryCritical = new JoinDataComplete(new JoinData { JoinNumber = 54, JoinSpan = 1 }, + new JoinMetadata { Description = "BatteryCritical", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("BatteryVoltage")] + public JoinDataComplete BatteryVoltage = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "BatteryVoltage", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + /// + /// Constructor to use when instantiating this Join Map without inheriting from it + /// + /// Join this join map will start at + public Hrxxx0WirelessRemoteControllerJoinMap(uint joinStart) + : this(joinStart, typeof(Hrxxx0WirelessRemoteControllerJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected Hrxxx0WirelessRemoteControllerJoinMap(uint joinStart, Type type) + : base(joinStart, type) + { + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IAnalogInputJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IAnalogInputJoinMap.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IAnalogInputJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IAnalogInputJoinMap.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs similarity index 98% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs index 18b98fe6..0d077284 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs @@ -1,50 +1,50 @@ -using System; - -namespace PepperDash.Essentials.Core.Bridges -{ - public class IBasicCommunicationJoinMap : JoinMapBaseAdvanced - { - [JoinName("TextReceived")] - public JoinDataComplete TextReceived = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Text Received From Remote Device", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("SendText")] - public JoinDataComplete SendText = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Text Sent To Remote Device", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("SetPortConfig")] - public JoinDataComplete SetPortConfig = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "Set Port Config", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("Connect")] - public JoinDataComplete Connect = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Connect", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Connected")] - public JoinDataComplete Connected = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Connected", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Status")] - public JoinDataComplete Status = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Status", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - /// - /// Constructor to use when instantiating this Join Map without inheriting from it - /// - /// Join this join map will start at - public IBasicCommunicationJoinMap(uint joinStart) - : this(joinStart, typeof(IBasicCommunicationJoinMap)) - { - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// Type of the child join map - protected IBasicCommunicationJoinMap(uint joinStart, Type type) - : base(joinStart, type) - { - } - } +using System; + +namespace PepperDash.Essentials.Core.Bridges +{ + public class IBasicCommunicationJoinMap : JoinMapBaseAdvanced + { + [JoinName("TextReceived")] + public JoinDataComplete TextReceived = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Text Received From Remote Device", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("SendText")] + public JoinDataComplete SendText = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Text Sent To Remote Device", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("SetPortConfig")] + public JoinDataComplete SetPortConfig = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "Set Port Config", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("Connect")] + public JoinDataComplete Connect = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Connect", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Connected")] + public JoinDataComplete Connected = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Connected", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Status")] + public JoinDataComplete Status = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Status", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + /// + /// Constructor to use when instantiating this Join Map without inheriting from it + /// + /// Join this join map will start at + public IBasicCommunicationJoinMap(uint joinStart) + : this(joinStart, typeof(IBasicCommunicationJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected IBasicCommunicationJoinMap(uint joinStart, Type type) + : base(joinStart, type) + { + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IDigitalInputJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IDigitalInputJoinMap.cs similarity index 97% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IDigitalInputJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IDigitalInputJoinMap.cs index 83e6cdab..aa31ac76 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IDigitalInputJoinMap.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IDigitalInputJoinMap.cs @@ -1,31 +1,31 @@ -using System; - -namespace PepperDash.Essentials.Core.Bridges -{ - public class IDigitalInputJoinMap : JoinMapBaseAdvanced - { - - [JoinName("InputState")] - public JoinDataComplete InputState = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Input State", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - /// - /// Constructor to use when instantiating this Join Map without inheriting from it - /// - /// Join this join map will start at - public IDigitalInputJoinMap(uint joinStart) - : this(joinStart, typeof(IDigitalInputJoinMap)) - { - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// Type of the child join map - protected IDigitalInputJoinMap(uint joinStart, Type type) - : base(joinStart, type) - { - } - } +using System; + +namespace PepperDash.Essentials.Core.Bridges +{ + public class IDigitalInputJoinMap : JoinMapBaseAdvanced + { + + [JoinName("InputState")] + public JoinDataComplete InputState = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Input State", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + /// + /// Constructor to use when instantiating this Join Map without inheriting from it + /// + /// Join this join map will start at + public IDigitalInputJoinMap(uint joinStart) + : this(joinStart, typeof(IDigitalInputJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected IDigitalInputJoinMap(uint joinStart, Type type) + : base(joinStart, type) + { + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IDigitalOutputJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IDigitalOutputJoinMap.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IDigitalOutputJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IDigitalOutputJoinMap.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IRBlurayBaseJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IRBlurayBaseJoinMap.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IRBlurayBaseJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IRBlurayBaseJoinMap.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/PduJoinMapBase.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/PduJoinMapBase.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/PduJoinMapBase.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/PduJoinMapBase.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/SetTopBoxControllerJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/SetTopBoxControllerJoinMap.cs similarity index 98% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/SetTopBoxControllerJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/SetTopBoxControllerJoinMap.cs index a65c537c..ec0ff8d2 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/SetTopBoxControllerJoinMap.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/SetTopBoxControllerJoinMap.cs @@ -1,240 +1,240 @@ -using System; - - -namespace PepperDash.Essentials.Core.Bridges -{ - public class SetTopBoxControllerJoinMap : JoinMapBaseAdvanced - { - [JoinName("PowerOn")] - public JoinDataComplete PowerOn = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Power On", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("PowerOff")] - public JoinDataComplete PowerOff = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Power Off", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("PowerToggle")] - public JoinDataComplete PowerToggle = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Power Toggle", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("HasDpad")] - public JoinDataComplete HasDpad = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Has DPad", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Up")] - public JoinDataComplete Up = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Nav Up", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Down")] - public JoinDataComplete Down = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Nav Down", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Left")] - public JoinDataComplete Left = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Nav Left", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Right")] - public JoinDataComplete Right = new JoinDataComplete(new JoinData { JoinNumber = 7, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Nav Right", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Select")] - public JoinDataComplete Select = new JoinDataComplete(new JoinData { JoinNumber = 8, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Select", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Menu")] - public JoinDataComplete Menu = new JoinDataComplete(new JoinData { JoinNumber = 9, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Menu", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Exit")] - public JoinDataComplete Exit = new JoinDataComplete(new JoinData { JoinNumber = 10, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Exit", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("HasNumeric")] - public JoinDataComplete HasNumeric = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Has Numeric", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Digit0")] - public JoinDataComplete Digit0 = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Digit 0", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Digit1")] - public JoinDataComplete Digit1 = new JoinDataComplete(new JoinData { JoinNumber = 12, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Digit 1", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Digit2")] - public JoinDataComplete Digit2 = new JoinDataComplete(new JoinData { JoinNumber = 13, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Digit 2", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Digit3")] - public JoinDataComplete Digit3 = new JoinDataComplete(new JoinData { JoinNumber = 14, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Digit 3", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Digit4")] - public JoinDataComplete Digit4 = new JoinDataComplete(new JoinData { JoinNumber = 15, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Digit 4", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Digit5")] - public JoinDataComplete Digit5 = new JoinDataComplete(new JoinData { JoinNumber = 16, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Digit 5", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Digit6")] - public JoinDataComplete Digit6 = new JoinDataComplete(new JoinData { JoinNumber = 17, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Digit 6", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Digit7")] - public JoinDataComplete Digit7 = new JoinDataComplete(new JoinData { JoinNumber = 18, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Digit 7", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Digit8")] - public JoinDataComplete Digit8 = new JoinDataComplete(new JoinData { JoinNumber = 19, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Digit 8", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Digit9")] - public JoinDataComplete Digit9 = new JoinDataComplete(new JoinData { JoinNumber = 20, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Digit 9", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Dash")] - public JoinDataComplete Dash = new JoinDataComplete(new JoinData { JoinNumber = 21, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Dash", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("KeypadEnter")] - public JoinDataComplete KeypadEnter = new JoinDataComplete(new JoinData { JoinNumber = 22, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Keypad Enter", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("ChannelUp")] - public JoinDataComplete ChannelUp = new JoinDataComplete(new JoinData { JoinNumber = 23, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Channel Up", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("ChannelDown")] - public JoinDataComplete ChannelDown = new JoinDataComplete(new JoinData { JoinNumber = 24, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Channel Down", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("LastChannel")] - public JoinDataComplete LastChannel = new JoinDataComplete(new JoinData { JoinNumber = 25, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Last Channel", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Guide")] - public JoinDataComplete Guide = new JoinDataComplete(new JoinData { JoinNumber = 26, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Guide", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Info")] - public JoinDataComplete Info = new JoinDataComplete(new JoinData { JoinNumber = 27, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Info", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Red")] - public JoinDataComplete Red = new JoinDataComplete(new JoinData { JoinNumber = 28, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Red", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Green")] - public JoinDataComplete Green = new JoinDataComplete(new JoinData { JoinNumber = 29, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Green", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Yellow")] - public JoinDataComplete Yellow = new JoinDataComplete(new JoinData { JoinNumber = 30, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Yellow", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Blue")] - public JoinDataComplete Blue = new JoinDataComplete(new JoinData { JoinNumber = 31, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Blue", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("HasDvr")] - public JoinDataComplete HasDvr = new JoinDataComplete(new JoinData { JoinNumber = 32, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Has DVR", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("DvrList")] - public JoinDataComplete DvrList = new JoinDataComplete(new JoinData { JoinNumber = 32, JoinSpan = 1 }, - new JoinMetadata { Description = "STB DvrList", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Play")] - public JoinDataComplete Play = new JoinDataComplete(new JoinData { JoinNumber = 33, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Play", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Pause")] - public JoinDataComplete Pause = new JoinDataComplete(new JoinData { JoinNumber = 34, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Pause", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Stop")] - public JoinDataComplete Stop = new JoinDataComplete(new JoinData { JoinNumber = 35, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Stop", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("FFwd")] - public JoinDataComplete FFwd = new JoinDataComplete(new JoinData { JoinNumber = 36, JoinSpan = 1 }, - new JoinMetadata { Description = "STB FFwd", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Rewind")] - public JoinDataComplete Rewind = new JoinDataComplete(new JoinData { JoinNumber = 37, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Rewind", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("ChapPlus")] - public JoinDataComplete ChapPlus = new JoinDataComplete(new JoinData { JoinNumber = 38, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Chapter Plus", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("ChapMinus")] - public JoinDataComplete ChapMinus = new JoinDataComplete(new JoinData { JoinNumber = 39, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Chapter Minus", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Replay")] - public JoinDataComplete Replay = new JoinDataComplete(new JoinData { JoinNumber = 40, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Replay", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Record")] - public JoinDataComplete Record = new JoinDataComplete(new JoinData { JoinNumber = 41, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Record", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("HasKeypadAccessoryButton1")] - public JoinDataComplete HasKeypadAccessoryButton1 = new JoinDataComplete(new JoinData { JoinNumber = 42, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Has Keypad Accessory Button 1", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("HasKeypadAccessoryButton2")] - public JoinDataComplete HasKeypadAccessoryButton2 = new JoinDataComplete(new JoinData { JoinNumber = 43, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Has Keypad Accessory Button 2", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("KeypadAccessoryButton1Press")] - public JoinDataComplete KeypadAccessoryButton1Press = new JoinDataComplete(new JoinData { JoinNumber = 42, JoinSpan = 2 }, - new JoinMetadata { Description = "STB Keypad Accessory Button 1 Press", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("KeypadAccessoryButton2Press")] - public JoinDataComplete KeypadAccessoryButton2Press = new JoinDataComplete(new JoinData { JoinNumber = 43, JoinSpan = 2 }, - new JoinMetadata { Description = "STB Keypad Accessory Button 2 Press", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Name")] - public JoinDataComplete Name = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("KeypadAccessoryButton1Label")] - public JoinDataComplete KeypadAccessoryButton1Label = new JoinDataComplete(new JoinData { JoinNumber = 42, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Keypad Accessory Button 1 Label", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("KeypadAccessoryButton2Label")] - public JoinDataComplete KeypadAccessoryButton2Label = new JoinDataComplete(new JoinData { JoinNumber = 43, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Keypad Accessory Button 1 Label", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("LoadPresets")] - public JoinDataComplete LoadPresets = new JoinDataComplete(new JoinData { JoinNumber = 50, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Load Presets", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("HasPresets")] - public JoinDataComplete HasPresets = new JoinDataComplete(new JoinData { JoinNumber = 50, JoinSpan = 1 }, - new JoinMetadata { Description = "STB Load Presets", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - - /// - /// Constructor to use when instantiating this Join Map without inheriting from it - /// - /// Join this join map will start at - public SetTopBoxControllerJoinMap(uint joinStart) - : this(joinStart, typeof(SetTopBoxControllerJoinMap)) - { - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// Type of the child join map - protected SetTopBoxControllerJoinMap(uint joinStart, Type type) - : base(joinStart, type) - { - } - } +using System; + + +namespace PepperDash.Essentials.Core.Bridges +{ + public class SetTopBoxControllerJoinMap : JoinMapBaseAdvanced + { + [JoinName("PowerOn")] + public JoinDataComplete PowerOn = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Power On", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("PowerOff")] + public JoinDataComplete PowerOff = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Power Off", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("PowerToggle")] + public JoinDataComplete PowerToggle = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Power Toggle", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("HasDpad")] + public JoinDataComplete HasDpad = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Has DPad", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Up")] + public JoinDataComplete Up = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Nav Up", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Down")] + public JoinDataComplete Down = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Nav Down", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Left")] + public JoinDataComplete Left = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Nav Left", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Right")] + public JoinDataComplete Right = new JoinDataComplete(new JoinData { JoinNumber = 7, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Nav Right", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Select")] + public JoinDataComplete Select = new JoinDataComplete(new JoinData { JoinNumber = 8, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Select", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Menu")] + public JoinDataComplete Menu = new JoinDataComplete(new JoinData { JoinNumber = 9, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Menu", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Exit")] + public JoinDataComplete Exit = new JoinDataComplete(new JoinData { JoinNumber = 10, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Exit", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("HasNumeric")] + public JoinDataComplete HasNumeric = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Has Numeric", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Digit0")] + public JoinDataComplete Digit0 = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Digit 0", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Digit1")] + public JoinDataComplete Digit1 = new JoinDataComplete(new JoinData { JoinNumber = 12, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Digit 1", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Digit2")] + public JoinDataComplete Digit2 = new JoinDataComplete(new JoinData { JoinNumber = 13, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Digit 2", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Digit3")] + public JoinDataComplete Digit3 = new JoinDataComplete(new JoinData { JoinNumber = 14, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Digit 3", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Digit4")] + public JoinDataComplete Digit4 = new JoinDataComplete(new JoinData { JoinNumber = 15, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Digit 4", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Digit5")] + public JoinDataComplete Digit5 = new JoinDataComplete(new JoinData { JoinNumber = 16, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Digit 5", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Digit6")] + public JoinDataComplete Digit6 = new JoinDataComplete(new JoinData { JoinNumber = 17, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Digit 6", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Digit7")] + public JoinDataComplete Digit7 = new JoinDataComplete(new JoinData { JoinNumber = 18, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Digit 7", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Digit8")] + public JoinDataComplete Digit8 = new JoinDataComplete(new JoinData { JoinNumber = 19, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Digit 8", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Digit9")] + public JoinDataComplete Digit9 = new JoinDataComplete(new JoinData { JoinNumber = 20, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Digit 9", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Dash")] + public JoinDataComplete Dash = new JoinDataComplete(new JoinData { JoinNumber = 21, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Dash", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("KeypadEnter")] + public JoinDataComplete KeypadEnter = new JoinDataComplete(new JoinData { JoinNumber = 22, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Keypad Enter", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("ChannelUp")] + public JoinDataComplete ChannelUp = new JoinDataComplete(new JoinData { JoinNumber = 23, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Channel Up", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("ChannelDown")] + public JoinDataComplete ChannelDown = new JoinDataComplete(new JoinData { JoinNumber = 24, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Channel Down", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("LastChannel")] + public JoinDataComplete LastChannel = new JoinDataComplete(new JoinData { JoinNumber = 25, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Last Channel", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Guide")] + public JoinDataComplete Guide = new JoinDataComplete(new JoinData { JoinNumber = 26, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Guide", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Info")] + public JoinDataComplete Info = new JoinDataComplete(new JoinData { JoinNumber = 27, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Info", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Red")] + public JoinDataComplete Red = new JoinDataComplete(new JoinData { JoinNumber = 28, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Red", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Green")] + public JoinDataComplete Green = new JoinDataComplete(new JoinData { JoinNumber = 29, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Green", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Yellow")] + public JoinDataComplete Yellow = new JoinDataComplete(new JoinData { JoinNumber = 30, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Yellow", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Blue")] + public JoinDataComplete Blue = new JoinDataComplete(new JoinData { JoinNumber = 31, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Blue", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("HasDvr")] + public JoinDataComplete HasDvr = new JoinDataComplete(new JoinData { JoinNumber = 32, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Has DVR", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("DvrList")] + public JoinDataComplete DvrList = new JoinDataComplete(new JoinData { JoinNumber = 32, JoinSpan = 1 }, + new JoinMetadata { Description = "STB DvrList", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Play")] + public JoinDataComplete Play = new JoinDataComplete(new JoinData { JoinNumber = 33, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Play", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Pause")] + public JoinDataComplete Pause = new JoinDataComplete(new JoinData { JoinNumber = 34, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Pause", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Stop")] + public JoinDataComplete Stop = new JoinDataComplete(new JoinData { JoinNumber = 35, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Stop", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("FFwd")] + public JoinDataComplete FFwd = new JoinDataComplete(new JoinData { JoinNumber = 36, JoinSpan = 1 }, + new JoinMetadata { Description = "STB FFwd", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Rewind")] + public JoinDataComplete Rewind = new JoinDataComplete(new JoinData { JoinNumber = 37, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Rewind", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("ChapPlus")] + public JoinDataComplete ChapPlus = new JoinDataComplete(new JoinData { JoinNumber = 38, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Chapter Plus", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("ChapMinus")] + public JoinDataComplete ChapMinus = new JoinDataComplete(new JoinData { JoinNumber = 39, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Chapter Minus", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Replay")] + public JoinDataComplete Replay = new JoinDataComplete(new JoinData { JoinNumber = 40, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Replay", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Record")] + public JoinDataComplete Record = new JoinDataComplete(new JoinData { JoinNumber = 41, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Record", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("HasKeypadAccessoryButton1")] + public JoinDataComplete HasKeypadAccessoryButton1 = new JoinDataComplete(new JoinData { JoinNumber = 42, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Has Keypad Accessory Button 1", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("HasKeypadAccessoryButton2")] + public JoinDataComplete HasKeypadAccessoryButton2 = new JoinDataComplete(new JoinData { JoinNumber = 43, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Has Keypad Accessory Button 2", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("KeypadAccessoryButton1Press")] + public JoinDataComplete KeypadAccessoryButton1Press = new JoinDataComplete(new JoinData { JoinNumber = 42, JoinSpan = 2 }, + new JoinMetadata { Description = "STB Keypad Accessory Button 1 Press", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("KeypadAccessoryButton2Press")] + public JoinDataComplete KeypadAccessoryButton2Press = new JoinDataComplete(new JoinData { JoinNumber = 43, JoinSpan = 2 }, + new JoinMetadata { Description = "STB Keypad Accessory Button 2 Press", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Name")] + public JoinDataComplete Name = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("KeypadAccessoryButton1Label")] + public JoinDataComplete KeypadAccessoryButton1Label = new JoinDataComplete(new JoinData { JoinNumber = 42, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Keypad Accessory Button 1 Label", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("KeypadAccessoryButton2Label")] + public JoinDataComplete KeypadAccessoryButton2Label = new JoinDataComplete(new JoinData { JoinNumber = 43, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Keypad Accessory Button 1 Label", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("LoadPresets")] + public JoinDataComplete LoadPresets = new JoinDataComplete(new JoinData { JoinNumber = 50, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Load Presets", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("HasPresets")] + public JoinDataComplete HasPresets = new JoinDataComplete(new JoinData { JoinNumber = 50, JoinSpan = 1 }, + new JoinMetadata { Description = "STB Load Presets", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + + /// + /// Constructor to use when instantiating this Join Map without inheriting from it + /// + /// Join this join map will start at + public SetTopBoxControllerJoinMap(uint joinStart) + : this(joinStart, typeof(SetTopBoxControllerJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected SetTopBoxControllerJoinMap(uint joinStart, Type type) + : base(joinStart, type) + { + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/StatusSignControllerJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/StatusSignControllerJoinMap.cs similarity index 98% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/StatusSignControllerJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/StatusSignControllerJoinMap.cs index ea844732..ba441ef0 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/StatusSignControllerJoinMap.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/StatusSignControllerJoinMap.cs @@ -1,58 +1,58 @@ -using System; - +using System; + namespace PepperDash.Essentials.Core.Bridges { public class StatusSignControllerJoinMap : JoinMapBaseAdvanced { - [JoinName("IsOnline")] - public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Status Sign Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("Name")] - public JoinDataComplete Name = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Status Sign Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("RedControl")] - public JoinDataComplete RedControl = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "Status Red LED Enable / Disable", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("RedLed")] - public JoinDataComplete RedLed = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "Status Red LED Intensity", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("GreenControl")] - public JoinDataComplete GreenControl = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, - new JoinMetadata { Description = "Status Green LED Enable / Disable", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("GreenLed")] - public JoinDataComplete GreenLed = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, - new JoinMetadata { Description = "Status Green LED Intensity", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("BlueControl")] - public JoinDataComplete BlueControl = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, - new JoinMetadata { Description = "Status Blue LED Enable / Disable", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("BlueLed")] - public JoinDataComplete BlueLed = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, - new JoinMetadata { Description = "Status Blue LED Intensity", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); - - /// - /// Constructor to use when instantiating this Join Map without inheriting from it - /// - /// Join this join map will start at - public StatusSignControllerJoinMap(uint joinStart) - : this(joinStart, typeof(StatusSignControllerJoinMap)) - { - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// Type of the child join map - protected StatusSignControllerJoinMap(uint joinStart, Type type) - : base(joinStart, type) - { + [JoinName("IsOnline")] + public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Status Sign Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Name")] + public JoinDataComplete Name = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Status Sign Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("RedControl")] + public JoinDataComplete RedControl = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "Status Red LED Enable / Disable", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("RedLed")] + public JoinDataComplete RedLed = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "Status Red LED Intensity", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("GreenControl")] + public JoinDataComplete GreenControl = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "Status Green LED Enable / Disable", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("GreenLed")] + public JoinDataComplete GreenLed = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "Status Green LED Intensity", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("BlueControl")] + public JoinDataComplete BlueControl = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "Status Blue LED Enable / Disable", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("BlueLed")] + public JoinDataComplete BlueLed = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "Status Blue LED Intensity", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + /// + /// Constructor to use when instantiating this Join Map without inheriting from it + /// + /// Join this join map will start at + public StatusSignControllerJoinMap(uint joinStart) + : this(joinStart, typeof(StatusSignControllerJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected StatusSignControllerJoinMap(uint joinStart, Type type) + : base(joinStart, type) + { } } diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/SystemMonitorJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/SystemMonitorJoinMap.cs similarity index 98% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/SystemMonitorJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/SystemMonitorJoinMap.cs index 8e352bc5..9adabfce 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/SystemMonitorJoinMap.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/SystemMonitorJoinMap.cs @@ -1,171 +1,171 @@ -using System; - -namespace PepperDash.Essentials.Core.Bridges -{ - public class SystemMonitorJoinMap : JoinMapBaseAdvanced - { - [JoinName("TimeZone")] - public JoinDataComplete TimeZone = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Timezone", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); - - [JoinName("TimeZoneName")] - public JoinDataComplete TimeZoneName = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Timezone Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("IOControllerVersion")] - public JoinDataComplete IOControllerVersion = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor IO Controller Version", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("SnmpAppVersion")] - public JoinDataComplete SnmpAppVersion = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor SNMP App Version", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("BACnetAppVersion")] - public JoinDataComplete BACnetAppVersion = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor BACNet App Version", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("ControllerVersion")] - public JoinDataComplete ControllerVersion = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Controller Version", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("SerialNumber")] - public JoinDataComplete SerialNumber = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Serial Number", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("Model")] - public JoinDataComplete Model = new JoinDataComplete(new JoinData { JoinNumber = 7, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Model", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("Uptime")] - public JoinDataComplete Uptime = new JoinDataComplete(new JoinData { JoinNumber = 8, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Uptime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("LastBoot")] - public JoinDataComplete LastBoot = new JoinDataComplete(new JoinData { JoinNumber = 9, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Last Boot", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("ProgramOffsetJoin")] - public JoinDataComplete ProgramOffsetJoin = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 5 }, - new JoinMetadata { Description = "All Program Data is offset between slots by 5 - First Joins Start at 11", JoinCapabilities = eJoinCapabilities.None, JoinType = eJoinType.None }); - - [JoinName("ProgramStart")] - public JoinDataComplete ProgramStart = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Program Start / Fb", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("ProgramStop")] - public JoinDataComplete ProgramStop = new JoinDataComplete(new JoinData { JoinNumber = 12, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Program Stop / Fb", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("ProgramRegister")] - public JoinDataComplete ProgramRegister = new JoinDataComplete(new JoinData { JoinNumber = 13, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Program Register / Fb", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("ProgramUnregister")] - public JoinDataComplete ProgramUnregister = new JoinDataComplete(new JoinData { JoinNumber = 14, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Program UnRegister / Fb", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("ProgramName")] - public JoinDataComplete ProgramName = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Program Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("ProgramCompiledTime")] - public JoinDataComplete ProgramCompiledTime = new JoinDataComplete(new JoinData { JoinNumber = 12, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Program Compile Time", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("ProgramCrestronDatabaseVersion")] - public JoinDataComplete ProgramCrestronDatabaseVersion = new JoinDataComplete(new JoinData { JoinNumber = 13, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Program Database Version", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("ProgramEnvironmentVersion")] - public JoinDataComplete ProgramEnvironmentVersion = new JoinDataComplete(new JoinData { JoinNumber = 14, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Program Environment Version", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("AggregatedProgramInfo")] - public JoinDataComplete AggregatedProgramInfo = new JoinDataComplete(new JoinData { JoinNumber = 15, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Program Aggregate Info Json", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("EthernetOffsetJoin")] - public JoinDataComplete EthernetOffsetJoin = new JoinDataComplete(new JoinData { JoinNumber = 15, JoinSpan = 1 }, - new JoinMetadata { Description = "All Ethernet Data is offset between Nics by 5 - First Joins Start at 76", JoinCapabilities = eJoinCapabilities.None, JoinType = eJoinType.None }); - - [JoinName("HostName")] - public JoinDataComplete HostName = new JoinDataComplete(new JoinData { JoinNumber = 76, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Ethernet Hostname", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("CurrentIpAddress")] - public JoinDataComplete CurrentIpAddress = new JoinDataComplete(new JoinData { JoinNumber = 77, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Ethernet Current Ip Address", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("CurrentSubnetMask")] - public JoinDataComplete CurrentSubnetMask = new JoinDataComplete(new JoinData { JoinNumber = 78, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Ethernet Current Subnet Mask", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("CurrentDefaultGateway")] - public JoinDataComplete CurrentDefaultGateway = new JoinDataComplete(new JoinData { JoinNumber = 79, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Ethernet Current Default Gateway", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("StaticIpAddress")] - public JoinDataComplete StaticIpAddress = new JoinDataComplete(new JoinData { JoinNumber = 80, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Ethernet Static Ip Address", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("StaticSubnetMask")] - public JoinDataComplete StaticSubnetMask = new JoinDataComplete(new JoinData { JoinNumber = 81, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Ethernet Static Subnet Mask", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("StaticDefaultGateway")] - public JoinDataComplete StaticDefaultGateway = new JoinDataComplete(new JoinData { JoinNumber = 82, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Ethernet Static Default Gateway", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("Domain")] - public JoinDataComplete Domain = new JoinDataComplete(new JoinData { JoinNumber = 83, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Ethernet Domain", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("DnsServer")] - public JoinDataComplete DnsServer = new JoinDataComplete(new JoinData { JoinNumber = 84, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Ethernet Dns Server", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("MacAddress")] - public JoinDataComplete MacAddress = new JoinDataComplete(new JoinData { JoinNumber = 85, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Ethernet Mac Address", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("DhcpStatus")] - public JoinDataComplete DhcpStatus = new JoinDataComplete(new JoinData { JoinNumber = 86, JoinSpan = 1 }, - new JoinMetadata { Description = "Processor Ethernet Dhcp Status", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("ProcessorRebot")] - public JoinDataComplete ProcessorReboot = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Reboot processor", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("IsAppliance")] - public JoinDataComplete IsAppliance = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "Is appliance Fb", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("IsServer")] - public JoinDataComplete IsServer = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "Is server Fb", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("ProgramReset")] - public JoinDataComplete ProgramReset = new JoinDataComplete(new JoinData { JoinNumber = 15, JoinSpan = 1 }, - new JoinMetadata { Description = "Resets the program", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - - /// - /// Constructor to use when instantiating this Join Map without inheriting from it - /// - /// Join this join map will start at - public SystemMonitorJoinMap(uint joinStart) - : this(joinStart, typeof(SystemMonitorJoinMap)) - { - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// Type of the child join map - protected SystemMonitorJoinMap(uint joinStart, Type type) - : base(joinStart, type) - { - } - } +using System; + +namespace PepperDash.Essentials.Core.Bridges +{ + public class SystemMonitorJoinMap : JoinMapBaseAdvanced + { + [JoinName("TimeZone")] + public JoinDataComplete TimeZone = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Timezone", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("TimeZoneName")] + public JoinDataComplete TimeZoneName = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Timezone Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("IOControllerVersion")] + public JoinDataComplete IOControllerVersion = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor IO Controller Version", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("SnmpAppVersion")] + public JoinDataComplete SnmpAppVersion = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor SNMP App Version", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("BACnetAppVersion")] + public JoinDataComplete BACnetAppVersion = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor BACNet App Version", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("ControllerVersion")] + public JoinDataComplete ControllerVersion = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Controller Version", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("SerialNumber")] + public JoinDataComplete SerialNumber = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Serial Number", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("Model")] + public JoinDataComplete Model = new JoinDataComplete(new JoinData { JoinNumber = 7, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Model", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("Uptime")] + public JoinDataComplete Uptime = new JoinDataComplete(new JoinData { JoinNumber = 8, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Uptime", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("LastBoot")] + public JoinDataComplete LastBoot = new JoinDataComplete(new JoinData { JoinNumber = 9, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Last Boot", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("ProgramOffsetJoin")] + public JoinDataComplete ProgramOffsetJoin = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 5 }, + new JoinMetadata { Description = "All Program Data is offset between slots by 5 - First Joins Start at 11", JoinCapabilities = eJoinCapabilities.None, JoinType = eJoinType.None }); + + [JoinName("ProgramStart")] + public JoinDataComplete ProgramStart = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Program Start / Fb", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("ProgramStop")] + public JoinDataComplete ProgramStop = new JoinDataComplete(new JoinData { JoinNumber = 12, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Program Stop / Fb", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("ProgramRegister")] + public JoinDataComplete ProgramRegister = new JoinDataComplete(new JoinData { JoinNumber = 13, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Program Register / Fb", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("ProgramUnregister")] + public JoinDataComplete ProgramUnregister = new JoinDataComplete(new JoinData { JoinNumber = 14, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Program UnRegister / Fb", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("ProgramName")] + public JoinDataComplete ProgramName = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Program Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("ProgramCompiledTime")] + public JoinDataComplete ProgramCompiledTime = new JoinDataComplete(new JoinData { JoinNumber = 12, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Program Compile Time", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("ProgramCrestronDatabaseVersion")] + public JoinDataComplete ProgramCrestronDatabaseVersion = new JoinDataComplete(new JoinData { JoinNumber = 13, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Program Database Version", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("ProgramEnvironmentVersion")] + public JoinDataComplete ProgramEnvironmentVersion = new JoinDataComplete(new JoinData { JoinNumber = 14, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Program Environment Version", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("AggregatedProgramInfo")] + public JoinDataComplete AggregatedProgramInfo = new JoinDataComplete(new JoinData { JoinNumber = 15, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Program Aggregate Info Json", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("EthernetOffsetJoin")] + public JoinDataComplete EthernetOffsetJoin = new JoinDataComplete(new JoinData { JoinNumber = 15, JoinSpan = 1 }, + new JoinMetadata { Description = "All Ethernet Data is offset between Nics by 5 - First Joins Start at 76", JoinCapabilities = eJoinCapabilities.None, JoinType = eJoinType.None }); + + [JoinName("HostName")] + public JoinDataComplete HostName = new JoinDataComplete(new JoinData { JoinNumber = 76, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Ethernet Hostname", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("CurrentIpAddress")] + public JoinDataComplete CurrentIpAddress = new JoinDataComplete(new JoinData { JoinNumber = 77, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Ethernet Current Ip Address", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("CurrentSubnetMask")] + public JoinDataComplete CurrentSubnetMask = new JoinDataComplete(new JoinData { JoinNumber = 78, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Ethernet Current Subnet Mask", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("CurrentDefaultGateway")] + public JoinDataComplete CurrentDefaultGateway = new JoinDataComplete(new JoinData { JoinNumber = 79, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Ethernet Current Default Gateway", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("StaticIpAddress")] + public JoinDataComplete StaticIpAddress = new JoinDataComplete(new JoinData { JoinNumber = 80, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Ethernet Static Ip Address", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("StaticSubnetMask")] + public JoinDataComplete StaticSubnetMask = new JoinDataComplete(new JoinData { JoinNumber = 81, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Ethernet Static Subnet Mask", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("StaticDefaultGateway")] + public JoinDataComplete StaticDefaultGateway = new JoinDataComplete(new JoinData { JoinNumber = 82, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Ethernet Static Default Gateway", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("Domain")] + public JoinDataComplete Domain = new JoinDataComplete(new JoinData { JoinNumber = 83, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Ethernet Domain", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("DnsServer")] + public JoinDataComplete DnsServer = new JoinDataComplete(new JoinData { JoinNumber = 84, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Ethernet Dns Server", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("MacAddress")] + public JoinDataComplete MacAddress = new JoinDataComplete(new JoinData { JoinNumber = 85, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Ethernet Mac Address", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("DhcpStatus")] + public JoinDataComplete DhcpStatus = new JoinDataComplete(new JoinData { JoinNumber = 86, JoinSpan = 1 }, + new JoinMetadata { Description = "Processor Ethernet Dhcp Status", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("ProcessorRebot")] + public JoinDataComplete ProcessorReboot = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Reboot processor", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("IsAppliance")] + public JoinDataComplete IsAppliance = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Is appliance Fb", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("IsServer")] + public JoinDataComplete IsServer = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "Is server Fb", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("ProgramReset")] + public JoinDataComplete ProgramReset = new JoinDataComplete(new JoinData { JoinNumber = 15, JoinSpan = 1 }, + new JoinMetadata { Description = "Resets the program", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + + /// + /// Constructor to use when instantiating this Join Map without inheriting from it + /// + /// Join this join map will start at + public SystemMonitorJoinMap(uint joinStart) + : this(joinStart, typeof(SystemMonitorJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected SystemMonitorJoinMap(uint joinStart, Type type) + : base(joinStart, type) + { + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/VideoCodecControllerJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/VideoCodecControllerJoinMap.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/VideoCodecControllerJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/VideoCodecControllerJoinMap.cs index e208e371..74131e2b 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/VideoCodecControllerJoinMap.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/VideoCodecControllerJoinMap.cs @@ -1,3178 +1,3178 @@ -using System; -using PepperDash.Essentials.Core; -namespace PepperDash.Essentials.Core.Bridges.JoinMaps -{ - public class VideoCodecControllerJoinMap : JoinMapBaseAdvanced - { - #region Digital - - [JoinName("IsOnline")] - public JoinDataComplete IsOnline = new JoinDataComplete( - new JoinData - { - JoinNumber = 1, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Device is Online", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("SendDtmfToSpecificCallIndex")] - public JoinDataComplete SendDtmfToSpecificCallIndex = new JoinDataComplete( - new JoinData - { - JoinNumber = 10, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "If High, will send DTMF tones to the call set by SelectCall analog. If low sends DTMF tones to last connected call.", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("Dtmf1")] - public JoinDataComplete Dtmf1 = new JoinDataComplete( - new JoinData - { - JoinNumber = 11, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "DTMF 1", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("Dtmf2")] - public JoinDataComplete Dtmf2 = new JoinDataComplete( - new JoinData - { - JoinNumber = 12, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "DTMF 2", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("Dtmf3")] - public JoinDataComplete Dtmf3 = new JoinDataComplete( - new JoinData - { - JoinNumber = 13, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "DTMF 3", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("Dtmf4")] - public JoinDataComplete Dtmf4 = new JoinDataComplete( - new JoinData - { - JoinNumber = 14, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "DTMF 4", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("Dtmf5")] - public JoinDataComplete Dtmf5 = new JoinDataComplete( - new JoinData - { - JoinNumber = 15, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "DTMF 5", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("Dtmf6")] - public JoinDataComplete Dtmf6 = new JoinDataComplete( - new JoinData - { - JoinNumber = 16, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "DTMF 6", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("Dtmf7")] - public JoinDataComplete Dtmf7 = new JoinDataComplete( - new JoinData - { - JoinNumber = 17, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "DTMF 7", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("Dtmf8")] - public JoinDataComplete Dtmf8 = new JoinDataComplete( - new JoinData - { - JoinNumber = 18, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "DTMF 8", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("Dtmf9")] - public JoinDataComplete Dtmf9 = new JoinDataComplete( - new JoinData - { - JoinNumber = 19, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "DTMF 9", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("Dtmf0")] - public JoinDataComplete Dtmf0 = new JoinDataComplete( - new JoinData - { - JoinNumber = 20, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "DTMF 0", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DtmfStar")] - public JoinDataComplete DtmfStar = new JoinDataComplete( - new JoinData - { - JoinNumber = 21, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "DTMF *", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DtmfPound")] - public JoinDataComplete DtmfPound = new JoinDataComplete( - new JoinData - { - JoinNumber = 22, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "DTMF #", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("EndAllCalls")] - public JoinDataComplete EndAllCalls = new JoinDataComplete( - new JoinData - { - JoinNumber = 24, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "End All Calls", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("HookState")] - public JoinDataComplete HookState = new JoinDataComplete( - new JoinData - { - JoinNumber = 31, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Current Hook State", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("SpeedDialStart")] - public JoinDataComplete SpeedDialStart = new JoinDataComplete( - new JoinData - { - JoinNumber = 41, - JoinSpan = 4 - }, - new JoinMetadata - { - Description = "Speed Dial", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("IncomingCall")] - public JoinDataComplete IncomingCall = new JoinDataComplete( - new JoinData - { - JoinNumber = 50, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Incoming Call", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("IncomingAnswer")] - public JoinDataComplete IncomingAnswer = new JoinDataComplete( - new JoinData - { - JoinNumber = 51, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Answer Incoming Call", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("IncomingReject")] - public JoinDataComplete IncomingReject = new JoinDataComplete( - new JoinData - { - JoinNumber = 52, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Reject Incoming Call", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("ManualDial")] - public JoinDataComplete ManualDial = new JoinDataComplete( - new JoinData - { - JoinNumber = 71, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Dial manual string specified by CurrentDialString serial join", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DialPhone")] - public JoinDataComplete DialPhone = new JoinDataComplete( - new JoinData - { - JoinNumber = 72, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Dial Phone", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("PhoneHookState")] - public JoinDataComplete PhoneHookState = new JoinDataComplete( - new JoinData - { - JoinNumber = 72, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Dial Phone", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("HangUpPhone")] - public JoinDataComplete HangUpPhone = new JoinDataComplete( - new JoinData - { - JoinNumber = 73, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Hang Up Phone", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("EndCallStart")] - public JoinDataComplete EndCallStart = new JoinDataComplete( - new JoinData - { - JoinNumber = 81, - JoinSpan = 8 - }, - new JoinMetadata - { - Description = "End a specific call by call index. ", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("JoinAllCalls")] - public JoinDataComplete JoinAllCalls = new JoinDataComplete( - new JoinData - { - JoinNumber = 90, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Join all calls", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("JoinCallStart")] - public JoinDataComplete JoinCallStart = new JoinDataComplete( - new JoinData - { - JoinNumber = 91, - JoinSpan = 8 - }, - new JoinMetadata - { - Description = "Join a specific call by call index. ", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DirectorySearchBusy")] - public JoinDataComplete DirectorySearchBusy = new JoinDataComplete( - new JoinData - { - JoinNumber = 100, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Directory Search Busy FB", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - - [JoinName("DirectoryEntryIsContact")] - public JoinDataComplete DirectoryEntryIsContact = new JoinDataComplete( - new JoinData - { - JoinNumber = 101, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Directory Selected Entry Is Contact FB", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DirectoryLineSelected")] - public JoinDataComplete DirectoryLineSelected = new JoinDataComplete( - new JoinData - { - JoinNumber = 101, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Directory Line Selected FB", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DirectoryIsRoot")] - public JoinDataComplete DirectoryIsRoot = new JoinDataComplete( - new JoinData - { - JoinNumber = 102, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Directory is on Root FB", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DirectoryHasChanged")] - public JoinDataComplete DirectoryHasChanged = new JoinDataComplete( - new JoinData - { - JoinNumber = 103, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Directory has changed FB", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DirectoryRoot")] - public JoinDataComplete DirectoryRoot = new JoinDataComplete( - new JoinData - { - JoinNumber = 104, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Go to Directory Root", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DirectoryFolderBack")] - public JoinDataComplete DirectoryFolderBack = new JoinDataComplete( - new JoinData - { - JoinNumber = 105, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Go back one directory level", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DirectoryDialSelectedLine")] - public JoinDataComplete DirectoryDialSelectedLine = new JoinDataComplete( - new JoinData - { - JoinNumber = 106, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Dial selected directory line", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DirectoryDisableAutoDialSelectedLine")] - public JoinDataComplete DirectoryDisableAutoDialSelectedLine = new JoinDataComplete( - new JoinData - { - JoinNumber = 107, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Set high to disable automatic dialing of a contact when selected", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DirectoryDialSelectedContactMethod")] - public JoinDataComplete DirectoryDialSelectedContactMethod = new JoinDataComplete( - new JoinData - { - JoinNumber = 108, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Pulse to dial the selected contact method", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DirectoryClearSelected")] - public JoinDataComplete DirectoryClearSelected = new JoinDataComplete( - new JoinData - { - JoinNumber = 110, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Clear Selected Entry and String from Search", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - - [JoinName("CameraTiltUp")] - public JoinDataComplete CameraTiltUp = new JoinDataComplete( - new JoinData - { - JoinNumber = 111, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Tilt Up", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraTiltDown")] - public JoinDataComplete CameraTiltDown = new JoinDataComplete( - new JoinData - { - JoinNumber = 112, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Tilt Down", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraPanLeft")] - public JoinDataComplete CameraPanLeft = new JoinDataComplete( - new JoinData - { - JoinNumber = 113, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Pan Left", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraPanRight")] - public JoinDataComplete CameraPanRight = new JoinDataComplete( - new JoinData - { - JoinNumber = 114, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Pan Right", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraZoomIn")] - public JoinDataComplete CameraZoomIn = new JoinDataComplete( - new JoinData - { - JoinNumber = 115, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Zoom In", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraZoomOut")] - public JoinDataComplete CameraZoomOut = new JoinDataComplete( - new JoinData - { - JoinNumber = 116, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Zoom Out", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraFocusNear")] - public JoinDataComplete CameraFocusNear = new JoinDataComplete( - new JoinData - { - JoinNumber = 117, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Focus Near", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraFocusFar")] - public JoinDataComplete CameraFocusFar = new JoinDataComplete( - new JoinData - { - JoinNumber = 118, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Focus Far", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraFocusAuto")] - public JoinDataComplete CameraFocusAuto = new JoinDataComplete( - new JoinData - { - JoinNumber = 119, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Auto Focus Trigger", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraPresetSave")] - public JoinDataComplete CameraPresetSave = new JoinDataComplete( - new JoinData - { - JoinNumber = 121, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Pulse to save selected preset spcified by CameraPresetSelect analog join. FB will pulse for 3s when preset saved.", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraModeAuto")] - public JoinDataComplete CameraModeAuto = new JoinDataComplete( - new JoinData - { - JoinNumber = 131, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Mode Auto. Enables camera auto tracking mode, with feedback", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraModeManual")] - public JoinDataComplete CameraModeManual = new JoinDataComplete( - new JoinData - { - JoinNumber = 132, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Mode Manual. Disables camera auto tracking mode, with feedback", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraModeOff")] - public JoinDataComplete CameraModeOff = new JoinDataComplete( - new JoinData - { - JoinNumber = 133, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Mode Off. Disables camera video, with feedback. Works like video mute.", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraSelfView")] - public JoinDataComplete CameraSelfView = new JoinDataComplete( - new JoinData - { - JoinNumber = 141, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Self View Toggle/FB", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraLayout")] - public JoinDataComplete CameraLayout = new JoinDataComplete( - new JoinData - { - JoinNumber = 142, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Layout Toggle", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraSupportsAutoMode")] - public JoinDataComplete CameraSupportsAutoMode = new JoinDataComplete( - new JoinData - { - JoinNumber = 143, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Supports Auto Mode FB", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraSupportsOffMode")] - public JoinDataComplete CameraSupportsOffMode = new JoinDataComplete( - new JoinData - { - JoinNumber = 144, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Supports Off Mode FB", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("UpdateMeetings")] - public JoinDataComplete UpdateMeetings = new JoinDataComplete( - new JoinData - { - JoinNumber = 160, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Update Meetings", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DialMeetingStart")] - public JoinDataComplete DialMeetingStart = new JoinDataComplete( - new JoinData - { - JoinNumber = 161, - JoinSpan = 10 - }, - new JoinMetadata - { - Description = "Join meeting", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("MicMuteOn")] - public JoinDataComplete MicMuteOn = new JoinDataComplete( - new JoinData - { - JoinNumber = 171, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Mic Mute On", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("MicMuteOff")] - public JoinDataComplete MicMuteOff = new JoinDataComplete( - new JoinData - { - JoinNumber = 172, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Mic Mute Off", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("MicMuteToggle")] - public JoinDataComplete MicMuteToggle = new JoinDataComplete( - new JoinData - { - JoinNumber = 173, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Mic Mute Toggle", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("VolumeUp")] - public JoinDataComplete VolumeUp = new JoinDataComplete( - new JoinData - { - JoinNumber = 174, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Volume Up", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("VolumeDown")] - public JoinDataComplete VolumeDown = new JoinDataComplete( - new JoinData - { - JoinNumber = 175, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Volume Down", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("VolumeMuteOn")] - public JoinDataComplete VolumeMuteOn = new JoinDataComplete( - new JoinData - { - JoinNumber = 176, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Volume Mute On", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("VolumeMuteOff")] - public JoinDataComplete VolumeMuteOff = new JoinDataComplete( - new JoinData - { - JoinNumber = 177, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Volume Mute Off", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("VolumeMuteToggle")] - public JoinDataComplete VolumeMuteToggle = new JoinDataComplete( - new JoinData - { - JoinNumber = 178, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Volume Mute Toggle", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("RemoveSelectedRecentCallItem")] - public JoinDataComplete RemoveSelectedRecentCallItem = new JoinDataComplete( - new JoinData - { - JoinNumber = 181, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Pulse to remove the selected recent call item specified by the SelectRecentCallItem analog join", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DialSelectedRecentCallItem")] - public JoinDataComplete DialSelectedRecentCallItem = new JoinDataComplete( - new JoinData - { - JoinNumber = 182, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Pulse to dial the selected recent call item specified by the SelectRecentCallItem analog join", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("SourceShareStart")] - public JoinDataComplete SourceShareStart = new JoinDataComplete( - new JoinData - { - JoinNumber = 201, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Start Sharing & Feedback", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("SourceShareEnd")] - public JoinDataComplete SourceShareEnd = new JoinDataComplete( - new JoinData - { - JoinNumber = 202, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Stop Sharing & Feedback", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("AutoShareWhileInCall")] - public JoinDataComplete SourceShareAutoStart = new JoinDataComplete( - new JoinData - { - JoinNumber = 203, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "When high, will autostart sharing when a call is joined", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("RecievingContent")] - public JoinDataComplete RecievingContent = new JoinDataComplete( - new JoinData - { - JoinNumber = 204, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Recieving content from the far end", - JoinType = eJoinType.Digital, - JoinCapabilities = eJoinCapabilities.ToSIMPL - }); - - [JoinName("SelfviewPosition")] - public JoinDataComplete SelfviewPosition = new JoinDataComplete( - new JoinData - { - JoinNumber = 211, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Toggles selfview position", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("HoldAllCalls")] - public JoinDataComplete HoldAllCalls = new JoinDataComplete( - new JoinData - { - JoinNumber = 220, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Holds all calls", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("HoldCallsStart")] - public JoinDataComplete HoldCallsStart = new JoinDataComplete( - new JoinData - { - JoinNumber = 221, - JoinSpan = 8 - }, - new JoinMetadata - { - Description = "Holds Call at specified index. FB reported on Call Status XSIG", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("ResumeCallsStart")] - public JoinDataComplete ResumeCallsStart = new JoinDataComplete( - new JoinData - { - JoinNumber = 231, - JoinSpan = 8 - }, - new JoinMetadata - { - Description = "Resume Call at specified index", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("MultiSiteOptionIsEnabled")] - public JoinDataComplete MultiSiteOptionIsEnabled = new JoinDataComplete( - new JoinData - { - JoinNumber = 301, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Multi site option is enabled FB", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("AutoAnswerEnabled")] - public JoinDataComplete AutoAnswerEnabled = new JoinDataComplete( - new JoinData - { - JoinNumber = 302, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Auto Answer is enabled FB", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("ParticipantAudioMuteToggleStart")] - public JoinDataComplete ParticipantAudioMuteToggleStart = new JoinDataComplete( - new JoinData - { - JoinNumber = 501, - JoinSpan = 50 - }, - new JoinMetadata - { - Description = "Toggles the participant's audio mute status", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("ParticipantVideoMuteToggleStart")] - public JoinDataComplete ParticipantVideoMuteToggleStart = new JoinDataComplete( - new JoinData - { - JoinNumber = 801, - JoinSpan = 50 - }, - new JoinMetadata - { - Description = "Toggles the participant's video mute status", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("ParticipantPinToggleStart")] - public JoinDataComplete ParticipantPinToggleStart = new JoinDataComplete( - new JoinData - { - JoinNumber = 1101, - JoinSpan = 50 - }, - new JoinMetadata - { - Description = "Toggles the participant's pin status", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - - #endregion - - - - #region Analog - - // TODO [ ] hotfix/videocodecbase-max-meeting-xsig-set - [JoinName("MeetingsToDisplay")] - public JoinDataComplete MeetingsToDisplay = new JoinDataComplete( - new JoinData - { - JoinNumber = 40, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Set/FB the number of meetings to display via the bridge xsig; default: 3 meetings.", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Analog - }); - - [JoinName("SelectCall")] - public JoinDataComplete SelectCall = new JoinDataComplete( - new JoinData - { - JoinNumber = 24, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Sets the selected Call for DTMF commands. Valid values 1-8", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Analog - }); - - - [JoinName("ConnectedCallCount")] - public JoinDataComplete ConnectedCallCount = new JoinDataComplete( - new JoinData - { - JoinNumber = 25, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Reports the number of currently connected calls", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Analog - }); - - [JoinName("MinutesBeforeMeetingStart")] - public JoinDataComplete MinutesBeforeMeetingStart = new JoinDataComplete( - new JoinData - { - JoinNumber = 41, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Minutes before meeting start that a meeting is joinable", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Analog - }); - - [JoinName("CameraNumberSelect")] - public JoinDataComplete CameraNumberSelect = new JoinDataComplete( - new JoinData - { - JoinNumber = 60, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Number Select/FB. 1 based index. Valid range is 1 to the value reported by CameraCount.", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Analog - }); - - [JoinName("CameraCount")] - public JoinDataComplete CameraCount = new JoinDataComplete( - new JoinData - { - JoinNumber = 61, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Reports the number of cameras", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Analog - }); - - [JoinName("DirectoryRowCount")] - public JoinDataComplete DirectoryRowCount = new JoinDataComplete( - new JoinData - { - JoinNumber = 101, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Directory Row Count FB", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Analog - }); - - [JoinName("DirectorySelectRow")] - public JoinDataComplete DirectorySelectRow = new JoinDataComplete( - new JoinData - { - JoinNumber = 101, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Directory Select Row and Feedback", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Analog - }); - - - [JoinName("SelectedContactMethodCount")] - public JoinDataComplete SelectedContactMethodCount = new JoinDataComplete( - new JoinData - { - JoinNumber = 102, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Reports the number of contact methods for the selected contact", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Analog - }); - - [JoinName("SelectContactMethod")] - public JoinDataComplete SelectContactMethod = new JoinDataComplete( - new JoinData - { - JoinNumber = 103, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Selects a contact method by index", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Analog - }); - - [JoinName("DirectorySelectRowFeedback")] - public JoinDataComplete DirectorySelectRowFeedback = new JoinDataComplete( - new JoinData - { - JoinNumber = 104, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Directory Select Row and Feedback", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Analog - }); - - - - [JoinName("CameraPresetSelect")] - public JoinDataComplete CameraPresetSelect = new JoinDataComplete( - new JoinData - { - JoinNumber = 121, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Preset Select", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Analog - }); - - [JoinName("FarEndPresetSelect")] - public JoinDataComplete FarEndPresetSelect = new JoinDataComplete( - new JoinData - { - JoinNumber = 122, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Far End Preset Preset Select", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Analog - }); - - [JoinName("ParticipantCount")] - public JoinDataComplete ParticipantCount = new JoinDataComplete( - new JoinData - { - JoinNumber = 151, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Current Participant Count", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Analog - }); - - [JoinName("Meeting Count Fb")] - public JoinDataComplete MeetingCount = new JoinDataComplete( - new JoinData - { - JoinNumber = 161, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Meeting Count", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Analog - }); - - [JoinName("VolumeLevel")] - public JoinDataComplete VolumeLevel = new JoinDataComplete( - new JoinData - { - JoinNumber = 174, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Volume Level", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Analog - }); - - [JoinName("SelectRecentCallItem")] - public JoinDataComplete SelectRecentCallItem = new JoinDataComplete( - new JoinData - { - JoinNumber = 180, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Select/FB for Recent Call Item. Valid values 1 - 10", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Analog - }); - - [JoinName("RecentCallOccurrenceType")] - public JoinDataComplete RecentCallOccurrenceType = new JoinDataComplete( - new JoinData - { - JoinNumber = 181, - JoinSpan = 10 - }, - new JoinMetadata - { - Description = "Recent Call Occurrence Type. [0-3] 0 = Unknown, 1 = Placed, 2 = Received, 3 = NoAnswer", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Analog - }); - - [JoinName("RecentCallCount")] - public JoinDataComplete RecentCallCount = new JoinDataComplete( - new JoinData - { - JoinNumber = 191, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Recent Call Count", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Analog - }); - - #endregion - - - - #region Serials - - [JoinName("CurrentDialString")] - public JoinDataComplete CurrentDialString = new JoinDataComplete( - new JoinData - { - JoinNumber = 1, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Value to dial when ManualDial digital join is pulsed", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("PhoneDialString")] - public JoinDataComplete PhoneDialString = new JoinDataComplete( - new JoinData - { - JoinNumber = 2, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Phone Dial String", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("CurrentCallData")] - public JoinDataComplete CurrentCallData = new JoinDataComplete( - new JoinData - { - JoinNumber = 2, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Current Call Data - XSIG", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("CallDirection")] - public JoinDataComplete CallDirection = new JoinDataComplete( - new JoinData - { - JoinNumber = 22, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Current Call Direction", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("IncomingCallName")] - public JoinDataComplete IncomingCallName = new JoinDataComplete( - new JoinData - { - JoinNumber = 51, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Incoming Call Name", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("IncomingCallNumber")] - public JoinDataComplete IncomingCallNumber = new JoinDataComplete( - new JoinData - { - JoinNumber = 52, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Incoming Call Number", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - - [JoinName("DirectorySearchString")] - public JoinDataComplete DirectorySearchString = new JoinDataComplete( - new JoinData - { - JoinNumber = 100, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Directory Search String", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("DirectoryEntries")] - public JoinDataComplete DirectoryEntries = new JoinDataComplete( - new JoinData - { - JoinNumber = 101, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Directory Entries - XSig, 255 entries", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("Schedule")] - public JoinDataComplete Schedule = new JoinDataComplete( - new JoinData - { - JoinNumber = 102, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Schedule Data - XSIG", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("ContactMethods")] - public JoinDataComplete ContactMethods = new JoinDataComplete( - new JoinData - { - JoinNumber = 103, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Contact Methods - XSig, 10 entries", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("CameraPresetNames")] - public JoinDataComplete CameraPresetNames = new JoinDataComplete( - new JoinData - { - JoinNumber = 121, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Preset Names - XSIG, max of 15", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("CurrentLayoutStringFb")] - public JoinDataComplete CurrentLayoutStringFb = new JoinDataComplete( - new JoinData - { - JoinNumber = 141, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Current Layout Fb", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("AvailableLayoutsFb")] - public JoinDataComplete AvailableLayoutsFb = new JoinDataComplete( - new JoinData - { - JoinNumber = 142, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "xSig of all available layouts", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("SelectLayout")] - public JoinDataComplete SelectLayout = new JoinDataComplete( - new JoinData - { - JoinNumber = 142, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Select Layout by string", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Serial - }); - - - - [JoinName("CurrentParticipants")] - public JoinDataComplete CurrentParticipants = new JoinDataComplete( - new JoinData - { - JoinNumber = 151, - JoinSpan = 1 - }, - new JoinMetadata() - { - Description = "Current Participants XSig", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("CameraNamesFb")] - public JoinDataComplete CameraNamesFb = new JoinDataComplete( - new JoinData - { - JoinNumber = 161, - JoinSpan = 10 - }, - new JoinMetadata - { - Description = "Camera Name Fb", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("SelectedRecentCallName")] - public JoinDataComplete SelectedRecentCallName = new JoinDataComplete( - new JoinData - { - JoinNumber = 171, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Selected Recent Call Name", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("SelectedRecentCallNumber")] - public JoinDataComplete SelectedRecentCallNumber = new JoinDataComplete( - new JoinData - { - JoinNumber = 172, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Selected Recent Call Number", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("RecentCallNamesStart")] - public JoinDataComplete RecentCallNamesStart = new JoinDataComplete( - new JoinData - { - JoinNumber = 181, - JoinSpan = 10 - }, - new JoinMetadata - { - Description = "Recent Call Names", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("RecentCallTimesStart")] - public JoinDataComplete RecentCallTimesStart = new JoinDataComplete( - new JoinData - { - JoinNumber = 191, - JoinSpan = 10 - }, - new JoinMetadata - { - Description = "Recent Calls Times", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("CurrentSource")] - public JoinDataComplete CurrentSource = new JoinDataComplete( - new JoinData - { - JoinNumber = 201, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Current Source", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("SelfviewPositionFb")] - public JoinDataComplete SelfviewPositionFb = new JoinDataComplete( - new JoinData - { - JoinNumber = 211, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "advance selfview position", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("DeviceIpAddresss")] - public JoinDataComplete DeviceIpAddresss = new JoinDataComplete( - new JoinData - { - JoinNumber = 301, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "IP Address of device", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("SipPhoneNumber")] - public JoinDataComplete SipPhoneNumber = new JoinDataComplete( - new JoinData - { - JoinNumber = 302, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "SIP phone number of device", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("E164Alias")] - public JoinDataComplete E164Alias = new JoinDataComplete( - new JoinData - { - JoinNumber = 303, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "E164 alias of device", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("H323Id")] - public JoinDataComplete H323Id = new JoinDataComplete( - new JoinData - { - JoinNumber = 304, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "H323 ID of device", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("SipUri")] - public JoinDataComplete SipUri = new JoinDataComplete( - new JoinData - { - JoinNumber = 305, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "SIP URI of device", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("DirectoryEntrySelectedName")] - public JoinDataComplete DirectoryEntrySelectedName = new JoinDataComplete( - new JoinData - { - JoinNumber = 356, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Selected Directory Entry Name", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("DirectoryEntrySelectedNumber")] - public JoinDataComplete DirectoryEntrySelectedNumber = new JoinDataComplete( - new JoinData - { - JoinNumber = 357, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Selected Directory Entry Number", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("DirectorySelectedFolderName")] - public JoinDataComplete DirectorySelectedFolderName = new JoinDataComplete( - new JoinData - { - JoinNumber = 358, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Selected Directory Folder Name", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - #endregion - - - public VideoCodecControllerJoinMap(uint joinStart) - : base(joinStart, typeof(VideoCodecControllerJoinMap)) - { - } - - public VideoCodecControllerJoinMap(uint joinStart, Type type) - : base(joinStart, type) - { - } - } -} - - -namespace PepperDash_Essentials_Core.Bridges.JoinMaps -{ - [Obsolete("Use PepperDash.Essentials.Core.Bridges.JoinMaps")] - public class VideoCodecControllerJoinMap : JoinMapBaseAdvanced - { - - #region Digital - - [JoinName("IsOnline")] - public JoinDataComplete IsOnline = new JoinDataComplete( - new JoinData - { - JoinNumber = 1, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Device is Online", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("1")] - public JoinDataComplete Dtmf1 = new JoinDataComplete( - new JoinData - { - JoinNumber = 11, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "DTMF 1", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("2")] - public JoinDataComplete Dtmf2 = new JoinDataComplete( - new JoinData - { - JoinNumber = 12, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "DTMF 2", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("3")] - public JoinDataComplete Dtmf3 = new JoinDataComplete( - new JoinData - { - JoinNumber = 13, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "DTMF 3", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("4")] - public JoinDataComplete Dtmf4 = new JoinDataComplete( - new JoinData - { - JoinNumber = 14, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "DTMF 4", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("5")] - public JoinDataComplete Dtmf5 = new JoinDataComplete( - new JoinData - { - JoinNumber = 15, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "DTMF 5", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("6")] - public JoinDataComplete Dtmf6 = new JoinDataComplete( - new JoinData - { - JoinNumber = 16, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "DTMF 6", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("7")] - public JoinDataComplete Dtmf7 = new JoinDataComplete( - new JoinData - { - JoinNumber = 17, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "DTMF 7", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("8")] - public JoinDataComplete Dtmf8 = new JoinDataComplete( - new JoinData - { - JoinNumber = 18, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "DTMF 8", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("9")] - public JoinDataComplete Dtmf9 = new JoinDataComplete( - new JoinData - { - JoinNumber = 19, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "DTMF 9", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("0")] - public JoinDataComplete Dtmf0 = new JoinDataComplete( - new JoinData - { - JoinNumber = 20, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "DTMF 0", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("*")] - public JoinDataComplete DtmfStar = new JoinDataComplete( - new JoinData - { - JoinNumber = 21, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "DTMF *", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("#")] - public JoinDataComplete DtmfPound = new JoinDataComplete( - new JoinData - { - JoinNumber = 22, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "DTMF #", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("EndCall")] - public JoinDataComplete EndCall = new JoinDataComplete( - new JoinData - { - JoinNumber = 24, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Hang Up", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("HookState")] - public JoinDataComplete HookState = new JoinDataComplete( - new JoinData - { - JoinNumber = 31, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Current Hook State", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("SpeedDialStart")] - public JoinDataComplete SpeedDialStart = new JoinDataComplete( - new JoinData - { - JoinNumber = 41, - JoinSpan = 4 - }, - new JoinMetadata - { - Description = "Speed Dial", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("IncomingCall")] - public JoinDataComplete IncomingCall = new JoinDataComplete( - new JoinData - { - JoinNumber = 50, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Incoming Call", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("IncomingAnswer")] - public JoinDataComplete IncomingAnswer = new JoinDataComplete( - new JoinData - { - JoinNumber = 51, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Answer Incoming Call", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("IncomingReject")] - public JoinDataComplete IncomingReject = new JoinDataComplete( - new JoinData - { - JoinNumber = 52, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Reject Incoming Call", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("ManualDial")] - public JoinDataComplete ManualDial = new JoinDataComplete( - new JoinData - { - JoinNumber = 71, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Dial manual string", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DialPhoneCall")] - public JoinDataComplete DialPhone = new JoinDataComplete( - new JoinData - { - JoinNumber = 72, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Dial Phone", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("PhoneHookState")] - public JoinDataComplete PhoneHookState = new JoinDataComplete( - new JoinData - { - JoinNumber = 72, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Dial Phone", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("EndPhoneCall")] - public JoinDataComplete HangUpPhone = new JoinDataComplete( - new JoinData - { - JoinNumber = 73, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Hang Up PHone", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DirectorySearchBusy")] - public JoinDataComplete DirectorySearchBusy = new JoinDataComplete( - new JoinData - { - JoinNumber = 100, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Directory Search Busy FB", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DirectoryEntryIsContact")] - public JoinDataComplete DirectoryEntryIsContact = new JoinDataComplete( - new JoinData - { - JoinNumber = 101, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Directory Selected Entry Is Contact FB", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DirectoryLineSelected")] - public JoinDataComplete DirectoryLineSelected = new JoinDataComplete( - new JoinData - { - JoinNumber = 101, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Directory Line Selected FB", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DirectoryIsRoot")] - public JoinDataComplete DirectoryIsRoot = new JoinDataComplete( - new JoinData - { - JoinNumber = 102, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Directory is on Root FB", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DirectoryHasChanged")] - public JoinDataComplete DirectoryHasChanged = new JoinDataComplete( - new JoinData - { - JoinNumber = 103, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Directory has changed FB", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DirectoryRoot")] - public JoinDataComplete DirectoryRoot = new JoinDataComplete( - new JoinData - { - JoinNumber = 104, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Go to Directory Root", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DirectoryFolderBack")] - public JoinDataComplete DirectoryFolderBack = new JoinDataComplete( - new JoinData - { - JoinNumber = 105, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Go back one directory level", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DirectoryDialSelectedLine")] - public JoinDataComplete DirectoryDialSelectedLine = new JoinDataComplete( - new JoinData - { - JoinNumber = 106, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Dial selected directory line", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - - [JoinName("CameraTiltUp")] - public JoinDataComplete CameraTiltUp = new JoinDataComplete( - new JoinData - { - JoinNumber = 111, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Tilt Up", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraTiltDown")] - public JoinDataComplete CameraTiltDown = new JoinDataComplete( - new JoinData - { - JoinNumber = 112, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Tilt Down", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraPanLeft")] - public JoinDataComplete CameraPanLeft = new JoinDataComplete( - new JoinData - { - JoinNumber = 113, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Pan Left", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraPanRight")] - public JoinDataComplete CameraPanRight = new JoinDataComplete( - new JoinData - { - JoinNumber = 114, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Pan Right", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraZoomIn")] - public JoinDataComplete CameraZoomIn = new JoinDataComplete( - new JoinData - { - JoinNumber = 115, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Zoom In", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraZoomOut")] - public JoinDataComplete CameraZoomOut = new JoinDataComplete( - new JoinData - { - JoinNumber = 116, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Zoom Out", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraPresetSave")] - public JoinDataComplete CameraPresetSave = new JoinDataComplete( - new JoinData - { - JoinNumber = 121, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Save Selected Preset", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraModeAuto")] - public JoinDataComplete CameraModeAuto = new JoinDataComplete( - new JoinData - { - JoinNumber = 131, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Mode Auto", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraModeManual")] - public JoinDataComplete CameraModeManual = new JoinDataComplete( - new JoinData - { - JoinNumber = 132, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Mode Manual", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraModeOff")] - public JoinDataComplete CameraModeOff = new JoinDataComplete( - new JoinData - { - JoinNumber = 133, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Mode Off", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraSelfView")] - public JoinDataComplete CameraSelfView = new JoinDataComplete( - new JoinData - { - JoinNumber = 141, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Self View Toggle/FB", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraLayout")] - public JoinDataComplete CameraLayout = new JoinDataComplete( - new JoinData - { - JoinNumber = 142, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Layout Toggle", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraSupportsAutoMode")] - public JoinDataComplete CameraSupportsAutoMode = new JoinDataComplete( - new JoinData - { - JoinNumber = 143, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Supports Auto Mode FB", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CameraSupportsOffMode")] - public JoinDataComplete CameraSupportsOffMode = new JoinDataComplete( - new JoinData - { - JoinNumber = 144, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Supports Off Mode FB", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("UpdateMeetings")] - public JoinDataComplete UpdateMeetings = new JoinDataComplete( - new JoinData - { - JoinNumber = 160, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Update Meetings", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DialMeeting1")] - public JoinDataComplete DialMeeting1 = new JoinDataComplete( - new JoinData - { - JoinNumber = 161, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Join first meeting", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DialMeeting2")] - public JoinDataComplete DialMeeting2 = new JoinDataComplete( - new JoinData - { - JoinNumber = 162, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Join second meeting", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("DialMeeting3")] - public JoinDataComplete DialMeeting3 = new JoinDataComplete( - new JoinData - { - JoinNumber = 163, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Join third meeting", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("MicMuteOn")] - public JoinDataComplete MicMuteOn = new JoinDataComplete( - new JoinData - { - JoinNumber = 171, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Mic Mute On", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("MicMuteOff")] - public JoinDataComplete MicMuteOff = new JoinDataComplete( - new JoinData - { - JoinNumber = 172, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Mic Mute Off", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("MicMuteToggle")] - public JoinDataComplete MicMuteToggle = new JoinDataComplete( - new JoinData - { - JoinNumber = 173, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Mic Mute Toggle", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("VolumeUp")] - public JoinDataComplete VolumeUp = new JoinDataComplete( - new JoinData - { - JoinNumber = 174, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Volume Up", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("VolumeDown")] - public JoinDataComplete VolumeDown = new JoinDataComplete( - new JoinData - { - JoinNumber = 175, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Volume Down", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("VolumeMuteOn")] - public JoinDataComplete VolumeMuteOn = new JoinDataComplete( - new JoinData - { - JoinNumber = 176, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Volume Mute On", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("VolumeMuteOff")] - public JoinDataComplete VolumeMuteOff = new JoinDataComplete( - new JoinData - { - JoinNumber = 177, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Volume Mute Off", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("VolumeMuteToggle")] - public JoinDataComplete VolumeMuteToggle = new JoinDataComplete( - new JoinData - { - JoinNumber = 178, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Volume Mute Toggle", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("SourceShareStart")] - public JoinDataComplete SourceShareStart = new JoinDataComplete( - new JoinData - { - JoinNumber = 201, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Start Sharing & Feedback", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("SourceShareEnd")] - public JoinDataComplete SourceShareEnd = new JoinDataComplete( - new JoinData - { - JoinNumber = 202, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Stop Sharing & Feedback", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("AutoShareWhileInCall")] - public JoinDataComplete SourceShareAutoStart = new JoinDataComplete( - new JoinData - { - JoinNumber = 203, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "When high, will autostart sharing when a call is joined", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("RecievingContent")] - public JoinDataComplete RecievingContent = new JoinDataComplete( - new JoinData - { - JoinNumber = 204, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Recieving content from the far end", - JoinType = eJoinType.Digital, - JoinCapabilities = eJoinCapabilities.ToSIMPL - }); - - [JoinName("SelfviewPosition")] - public JoinDataComplete SelfviewPosition = new JoinDataComplete( - new JoinData - { - JoinNumber = 211, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "advance selfview position", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("ParticipantAudioMuteToggleStart")] - public JoinDataComplete ParticipantAudioMuteToggleStart = new JoinDataComplete( - new JoinData - { - JoinNumber = 500, - JoinSpan = 50 - }, - new JoinMetadata - { - Description = "Toggles the participant's audio mute status", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("ParticipantVideoMuteToggleStart")] - public JoinDataComplete ParticipantVideoMuteToggleStart = new JoinDataComplete( - new JoinData - { - JoinNumber = 800, - JoinSpan = 50 - }, - new JoinMetadata - { - Description = "Toggles the participant's video mute status", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("ParticipantPinToggleStart")] - public JoinDataComplete ParticipantPinToggleStart = new JoinDataComplete( - new JoinData - { - JoinNumber = 1100, - JoinSpan = 50 - }, - new JoinMetadata - { - Description = "Toggles the participant's pin status", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - #endregion - - - - #region Analog - - [JoinName("MinutesBeforeMeetingStart")] - public JoinDataComplete MinutesBeforeMeetingStart = new JoinDataComplete( - new JoinData - { - JoinNumber = 41, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Minutes before meeting start that a meeting is joinable", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Analog - }); - - [JoinName("CameraNumberSelect")] - public JoinDataComplete CameraNumberSelect = new JoinDataComplete( - new JoinData - { - JoinNumber = 60, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Number Select/FB", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Analog - }); - - [JoinName("DirectoryRowCount")] - public JoinDataComplete DirectoryRowCount = new JoinDataComplete( - new JoinData - { - JoinNumber = 101, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Directory Row Count FB", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Analog - }); - - [JoinName("DirectorySelectRow")] - public JoinDataComplete DirectorySelectRow = new JoinDataComplete( - new JoinData - { - JoinNumber = 101, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Directory Select Row", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Analog - }); - - [JoinName("CameraPresetSelect")] - public JoinDataComplete CameraPresetSelect = new JoinDataComplete( - new JoinData - { - JoinNumber = 121, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Preset Select", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Analog - }); - - [JoinName("ParticipantCount")] - public JoinDataComplete ParticipantCount = new JoinDataComplete( - new JoinData - { - JoinNumber = 151, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Current Participant Count", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Analog - }); - - [JoinName("Meeting Count Fb")] - public JoinDataComplete MeetingCount = new JoinDataComplete( - new JoinData - { - JoinNumber = 161, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Meeting Count", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Analog - }); - - [JoinName("VolumeLevel")] - public JoinDataComplete VolumeLevel = new JoinDataComplete( - new JoinData - { - JoinNumber = 174, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Volume Level", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Analog - }); - - #endregion - - - - #region Serials - - [JoinName("CurrentDialString")] - public JoinDataComplete CurrentDialString = new JoinDataComplete( - new JoinData - { - JoinNumber = 1, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Current Dial String", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("PhoneString")] - public JoinDataComplete PhoneDialString = new JoinDataComplete( - new JoinData - { - JoinNumber = 2, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Phone Dial String", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("CurrentCallName")] - public JoinDataComplete CurrentCallData = new JoinDataComplete( - new JoinData - { - JoinNumber = 2, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Current Call Data - XSIG", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("CallDirection")] - public JoinDataComplete CallDirection = new JoinDataComplete( - new JoinData - { - JoinNumber = 22, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Current Call Direction", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("IncomingCallName")] - public JoinDataComplete IncomingCallName = new JoinDataComplete( - new JoinData - { - JoinNumber = 51, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Incoming Call Name", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("IncomingCallNumber")] - public JoinDataComplete IncomingCallNumber = new JoinDataComplete( - new JoinData - { - JoinNumber = 52, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Incoming Call Number", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - - [JoinName("DirectorySearchString")] - public JoinDataComplete DirectorySearchString = new JoinDataComplete( - new JoinData - { - JoinNumber = 100, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Directory Search String", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("DirectoryEntries")] - public JoinDataComplete DirectoryEntries = new JoinDataComplete( - new JoinData - { - JoinNumber = 101, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Directory Entries - XSig, 255 entries", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("Schedule")] - public JoinDataComplete Schedule = new JoinDataComplete( - new JoinData - { - JoinNumber = 102, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Schedule Data - XSIG", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("CameraPresetNames")] - public JoinDataComplete CameraPresetNames = new JoinDataComplete( - new JoinData - { - JoinNumber = 121, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Camera Preset Names - XSIG, max of 15", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("CameraLayoutStringFb")] - public JoinDataComplete CameraLayoutStringFb = new JoinDataComplete( - new JoinData - { - JoinNumber = 141, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Current Layout Fb", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("AvailableLayoutsFb")] - public JoinDataComplete AvailableLayoutsFb = new JoinDataComplete( - new JoinData - { - JoinNumber = 142, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "xSig of all available layouts", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("SelectLayout")] - public JoinDataComplete SelectLayout = new JoinDataComplete( - new JoinData - { - JoinNumber = 142, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Select Layout by string", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Serial - }); - - - [JoinName("CurrentParticipants")] - public JoinDataComplete CurrentParticipants = new JoinDataComplete( - new JoinData - { - JoinNumber = 151, - JoinSpan = 1 - }, - new JoinMetadata() - { - Description = "Current Participants XSig", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("CurrentSource")] - public JoinDataComplete CurrentSource = new JoinDataComplete( - new JoinData - { - JoinNumber = 201, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Current Source", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("SelfviewPositionFb")] - public JoinDataComplete SelfviewPositionFb = new JoinDataComplete( - new JoinData - { - JoinNumber = 211, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "advance selfview position", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("DirectoryEntrySelectedName")] - public JoinDataComplete DirectoryEntrySelectedName = new JoinDataComplete( - new JoinData - { - JoinNumber = 356, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Selected Directory Entry Name", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("DirectoryEntrySelectedNumber")] - public JoinDataComplete DirectoryEntrySelectedNumber = new JoinDataComplete( - new JoinData - { - JoinNumber = 357, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Selected Directory Entry Number", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("DirectorySelectedFolderName")] - public JoinDataComplete DirectorySelectedFolderName = new JoinDataComplete( - new JoinData - { - JoinNumber = 358, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Selected Directory Folder Name", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - #endregion - - - public VideoCodecControllerJoinMap(uint joinStart) - : base(joinStart, typeof(VideoCodecControllerJoinMap)) - { - } - - public VideoCodecControllerJoinMap(uint joinStart, Type type) - : base(joinStart, type) - { - } - } +using System; +using PepperDash.Essentials.Core; +namespace PepperDash.Essentials.Core.Bridges.JoinMaps +{ + public class VideoCodecControllerJoinMap : JoinMapBaseAdvanced + { + #region Digital + + [JoinName("IsOnline")] + public JoinDataComplete IsOnline = new JoinDataComplete( + new JoinData + { + JoinNumber = 1, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Device is Online", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("SendDtmfToSpecificCallIndex")] + public JoinDataComplete SendDtmfToSpecificCallIndex = new JoinDataComplete( + new JoinData + { + JoinNumber = 10, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "If High, will send DTMF tones to the call set by SelectCall analog. If low sends DTMF tones to last connected call.", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("Dtmf1")] + public JoinDataComplete Dtmf1 = new JoinDataComplete( + new JoinData + { + JoinNumber = 11, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "DTMF 1", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("Dtmf2")] + public JoinDataComplete Dtmf2 = new JoinDataComplete( + new JoinData + { + JoinNumber = 12, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "DTMF 2", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("Dtmf3")] + public JoinDataComplete Dtmf3 = new JoinDataComplete( + new JoinData + { + JoinNumber = 13, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "DTMF 3", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("Dtmf4")] + public JoinDataComplete Dtmf4 = new JoinDataComplete( + new JoinData + { + JoinNumber = 14, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "DTMF 4", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("Dtmf5")] + public JoinDataComplete Dtmf5 = new JoinDataComplete( + new JoinData + { + JoinNumber = 15, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "DTMF 5", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("Dtmf6")] + public JoinDataComplete Dtmf6 = new JoinDataComplete( + new JoinData + { + JoinNumber = 16, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "DTMF 6", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("Dtmf7")] + public JoinDataComplete Dtmf7 = new JoinDataComplete( + new JoinData + { + JoinNumber = 17, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "DTMF 7", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("Dtmf8")] + public JoinDataComplete Dtmf8 = new JoinDataComplete( + new JoinData + { + JoinNumber = 18, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "DTMF 8", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("Dtmf9")] + public JoinDataComplete Dtmf9 = new JoinDataComplete( + new JoinData + { + JoinNumber = 19, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "DTMF 9", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("Dtmf0")] + public JoinDataComplete Dtmf0 = new JoinDataComplete( + new JoinData + { + JoinNumber = 20, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "DTMF 0", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DtmfStar")] + public JoinDataComplete DtmfStar = new JoinDataComplete( + new JoinData + { + JoinNumber = 21, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "DTMF *", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DtmfPound")] + public JoinDataComplete DtmfPound = new JoinDataComplete( + new JoinData + { + JoinNumber = 22, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "DTMF #", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("EndAllCalls")] + public JoinDataComplete EndAllCalls = new JoinDataComplete( + new JoinData + { + JoinNumber = 24, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "End All Calls", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("HookState")] + public JoinDataComplete HookState = new JoinDataComplete( + new JoinData + { + JoinNumber = 31, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Current Hook State", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("SpeedDialStart")] + public JoinDataComplete SpeedDialStart = new JoinDataComplete( + new JoinData + { + JoinNumber = 41, + JoinSpan = 4 + }, + new JoinMetadata + { + Description = "Speed Dial", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("IncomingCall")] + public JoinDataComplete IncomingCall = new JoinDataComplete( + new JoinData + { + JoinNumber = 50, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Incoming Call", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("IncomingAnswer")] + public JoinDataComplete IncomingAnswer = new JoinDataComplete( + new JoinData + { + JoinNumber = 51, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Answer Incoming Call", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("IncomingReject")] + public JoinDataComplete IncomingReject = new JoinDataComplete( + new JoinData + { + JoinNumber = 52, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Reject Incoming Call", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("ManualDial")] + public JoinDataComplete ManualDial = new JoinDataComplete( + new JoinData + { + JoinNumber = 71, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Dial manual string specified by CurrentDialString serial join", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DialPhone")] + public JoinDataComplete DialPhone = new JoinDataComplete( + new JoinData + { + JoinNumber = 72, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Dial Phone", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("PhoneHookState")] + public JoinDataComplete PhoneHookState = new JoinDataComplete( + new JoinData + { + JoinNumber = 72, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Dial Phone", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("HangUpPhone")] + public JoinDataComplete HangUpPhone = new JoinDataComplete( + new JoinData + { + JoinNumber = 73, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Hang Up Phone", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("EndCallStart")] + public JoinDataComplete EndCallStart = new JoinDataComplete( + new JoinData + { + JoinNumber = 81, + JoinSpan = 8 + }, + new JoinMetadata + { + Description = "End a specific call by call index. ", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("JoinAllCalls")] + public JoinDataComplete JoinAllCalls = new JoinDataComplete( + new JoinData + { + JoinNumber = 90, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Join all calls", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("JoinCallStart")] + public JoinDataComplete JoinCallStart = new JoinDataComplete( + new JoinData + { + JoinNumber = 91, + JoinSpan = 8 + }, + new JoinMetadata + { + Description = "Join a specific call by call index. ", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DirectorySearchBusy")] + public JoinDataComplete DirectorySearchBusy = new JoinDataComplete( + new JoinData + { + JoinNumber = 100, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Directory Search Busy FB", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + + [JoinName("DirectoryEntryIsContact")] + public JoinDataComplete DirectoryEntryIsContact = new JoinDataComplete( + new JoinData + { + JoinNumber = 101, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Directory Selected Entry Is Contact FB", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DirectoryLineSelected")] + public JoinDataComplete DirectoryLineSelected = new JoinDataComplete( + new JoinData + { + JoinNumber = 101, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Directory Line Selected FB", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DirectoryIsRoot")] + public JoinDataComplete DirectoryIsRoot = new JoinDataComplete( + new JoinData + { + JoinNumber = 102, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Directory is on Root FB", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DirectoryHasChanged")] + public JoinDataComplete DirectoryHasChanged = new JoinDataComplete( + new JoinData + { + JoinNumber = 103, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Directory has changed FB", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DirectoryRoot")] + public JoinDataComplete DirectoryRoot = new JoinDataComplete( + new JoinData + { + JoinNumber = 104, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Go to Directory Root", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DirectoryFolderBack")] + public JoinDataComplete DirectoryFolderBack = new JoinDataComplete( + new JoinData + { + JoinNumber = 105, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Go back one directory level", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DirectoryDialSelectedLine")] + public JoinDataComplete DirectoryDialSelectedLine = new JoinDataComplete( + new JoinData + { + JoinNumber = 106, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Dial selected directory line", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DirectoryDisableAutoDialSelectedLine")] + public JoinDataComplete DirectoryDisableAutoDialSelectedLine = new JoinDataComplete( + new JoinData + { + JoinNumber = 107, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Set high to disable automatic dialing of a contact when selected", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DirectoryDialSelectedContactMethod")] + public JoinDataComplete DirectoryDialSelectedContactMethod = new JoinDataComplete( + new JoinData + { + JoinNumber = 108, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Pulse to dial the selected contact method", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DirectoryClearSelected")] + public JoinDataComplete DirectoryClearSelected = new JoinDataComplete( + new JoinData + { + JoinNumber = 110, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Clear Selected Entry and String from Search", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + + [JoinName("CameraTiltUp")] + public JoinDataComplete CameraTiltUp = new JoinDataComplete( + new JoinData + { + JoinNumber = 111, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Tilt Up", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraTiltDown")] + public JoinDataComplete CameraTiltDown = new JoinDataComplete( + new JoinData + { + JoinNumber = 112, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Tilt Down", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraPanLeft")] + public JoinDataComplete CameraPanLeft = new JoinDataComplete( + new JoinData + { + JoinNumber = 113, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Pan Left", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraPanRight")] + public JoinDataComplete CameraPanRight = new JoinDataComplete( + new JoinData + { + JoinNumber = 114, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Pan Right", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraZoomIn")] + public JoinDataComplete CameraZoomIn = new JoinDataComplete( + new JoinData + { + JoinNumber = 115, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Zoom In", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraZoomOut")] + public JoinDataComplete CameraZoomOut = new JoinDataComplete( + new JoinData + { + JoinNumber = 116, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Zoom Out", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraFocusNear")] + public JoinDataComplete CameraFocusNear = new JoinDataComplete( + new JoinData + { + JoinNumber = 117, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Focus Near", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraFocusFar")] + public JoinDataComplete CameraFocusFar = new JoinDataComplete( + new JoinData + { + JoinNumber = 118, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Focus Far", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraFocusAuto")] + public JoinDataComplete CameraFocusAuto = new JoinDataComplete( + new JoinData + { + JoinNumber = 119, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Auto Focus Trigger", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraPresetSave")] + public JoinDataComplete CameraPresetSave = new JoinDataComplete( + new JoinData + { + JoinNumber = 121, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Pulse to save selected preset spcified by CameraPresetSelect analog join. FB will pulse for 3s when preset saved.", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraModeAuto")] + public JoinDataComplete CameraModeAuto = new JoinDataComplete( + new JoinData + { + JoinNumber = 131, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Mode Auto. Enables camera auto tracking mode, with feedback", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraModeManual")] + public JoinDataComplete CameraModeManual = new JoinDataComplete( + new JoinData + { + JoinNumber = 132, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Mode Manual. Disables camera auto tracking mode, with feedback", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraModeOff")] + public JoinDataComplete CameraModeOff = new JoinDataComplete( + new JoinData + { + JoinNumber = 133, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Mode Off. Disables camera video, with feedback. Works like video mute.", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraSelfView")] + public JoinDataComplete CameraSelfView = new JoinDataComplete( + new JoinData + { + JoinNumber = 141, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Self View Toggle/FB", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraLayout")] + public JoinDataComplete CameraLayout = new JoinDataComplete( + new JoinData + { + JoinNumber = 142, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Layout Toggle", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraSupportsAutoMode")] + public JoinDataComplete CameraSupportsAutoMode = new JoinDataComplete( + new JoinData + { + JoinNumber = 143, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Supports Auto Mode FB", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraSupportsOffMode")] + public JoinDataComplete CameraSupportsOffMode = new JoinDataComplete( + new JoinData + { + JoinNumber = 144, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Supports Off Mode FB", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("UpdateMeetings")] + public JoinDataComplete UpdateMeetings = new JoinDataComplete( + new JoinData + { + JoinNumber = 160, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Update Meetings", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DialMeetingStart")] + public JoinDataComplete DialMeetingStart = new JoinDataComplete( + new JoinData + { + JoinNumber = 161, + JoinSpan = 10 + }, + new JoinMetadata + { + Description = "Join meeting", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("MicMuteOn")] + public JoinDataComplete MicMuteOn = new JoinDataComplete( + new JoinData + { + JoinNumber = 171, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Mic Mute On", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("MicMuteOff")] + public JoinDataComplete MicMuteOff = new JoinDataComplete( + new JoinData + { + JoinNumber = 172, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Mic Mute Off", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("MicMuteToggle")] + public JoinDataComplete MicMuteToggle = new JoinDataComplete( + new JoinData + { + JoinNumber = 173, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Mic Mute Toggle", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("VolumeUp")] + public JoinDataComplete VolumeUp = new JoinDataComplete( + new JoinData + { + JoinNumber = 174, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Volume Up", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("VolumeDown")] + public JoinDataComplete VolumeDown = new JoinDataComplete( + new JoinData + { + JoinNumber = 175, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Volume Down", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("VolumeMuteOn")] + public JoinDataComplete VolumeMuteOn = new JoinDataComplete( + new JoinData + { + JoinNumber = 176, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Volume Mute On", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("VolumeMuteOff")] + public JoinDataComplete VolumeMuteOff = new JoinDataComplete( + new JoinData + { + JoinNumber = 177, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Volume Mute Off", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("VolumeMuteToggle")] + public JoinDataComplete VolumeMuteToggle = new JoinDataComplete( + new JoinData + { + JoinNumber = 178, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Volume Mute Toggle", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("RemoveSelectedRecentCallItem")] + public JoinDataComplete RemoveSelectedRecentCallItem = new JoinDataComplete( + new JoinData + { + JoinNumber = 181, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Pulse to remove the selected recent call item specified by the SelectRecentCallItem analog join", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DialSelectedRecentCallItem")] + public JoinDataComplete DialSelectedRecentCallItem = new JoinDataComplete( + new JoinData + { + JoinNumber = 182, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Pulse to dial the selected recent call item specified by the SelectRecentCallItem analog join", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("SourceShareStart")] + public JoinDataComplete SourceShareStart = new JoinDataComplete( + new JoinData + { + JoinNumber = 201, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Start Sharing & Feedback", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("SourceShareEnd")] + public JoinDataComplete SourceShareEnd = new JoinDataComplete( + new JoinData + { + JoinNumber = 202, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Stop Sharing & Feedback", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("AutoShareWhileInCall")] + public JoinDataComplete SourceShareAutoStart = new JoinDataComplete( + new JoinData + { + JoinNumber = 203, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "When high, will autostart sharing when a call is joined", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("RecievingContent")] + public JoinDataComplete RecievingContent = new JoinDataComplete( + new JoinData + { + JoinNumber = 204, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Recieving content from the far end", + JoinType = eJoinType.Digital, + JoinCapabilities = eJoinCapabilities.ToSIMPL + }); + + [JoinName("SelfviewPosition")] + public JoinDataComplete SelfviewPosition = new JoinDataComplete( + new JoinData + { + JoinNumber = 211, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Toggles selfview position", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("HoldAllCalls")] + public JoinDataComplete HoldAllCalls = new JoinDataComplete( + new JoinData + { + JoinNumber = 220, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Holds all calls", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("HoldCallsStart")] + public JoinDataComplete HoldCallsStart = new JoinDataComplete( + new JoinData + { + JoinNumber = 221, + JoinSpan = 8 + }, + new JoinMetadata + { + Description = "Holds Call at specified index. FB reported on Call Status XSIG", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("ResumeCallsStart")] + public JoinDataComplete ResumeCallsStart = new JoinDataComplete( + new JoinData + { + JoinNumber = 231, + JoinSpan = 8 + }, + new JoinMetadata + { + Description = "Resume Call at specified index", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("MultiSiteOptionIsEnabled")] + public JoinDataComplete MultiSiteOptionIsEnabled = new JoinDataComplete( + new JoinData + { + JoinNumber = 301, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Multi site option is enabled FB", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("AutoAnswerEnabled")] + public JoinDataComplete AutoAnswerEnabled = new JoinDataComplete( + new JoinData + { + JoinNumber = 302, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Auto Answer is enabled FB", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("ParticipantAudioMuteToggleStart")] + public JoinDataComplete ParticipantAudioMuteToggleStart = new JoinDataComplete( + new JoinData + { + JoinNumber = 501, + JoinSpan = 50 + }, + new JoinMetadata + { + Description = "Toggles the participant's audio mute status", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("ParticipantVideoMuteToggleStart")] + public JoinDataComplete ParticipantVideoMuteToggleStart = new JoinDataComplete( + new JoinData + { + JoinNumber = 801, + JoinSpan = 50 + }, + new JoinMetadata + { + Description = "Toggles the participant's video mute status", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("ParticipantPinToggleStart")] + public JoinDataComplete ParticipantPinToggleStart = new JoinDataComplete( + new JoinData + { + JoinNumber = 1101, + JoinSpan = 50 + }, + new JoinMetadata + { + Description = "Toggles the participant's pin status", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + + #endregion + + + + #region Analog + + // TODO [ ] hotfix/videocodecbase-max-meeting-xsig-set + [JoinName("MeetingsToDisplay")] + public JoinDataComplete MeetingsToDisplay = new JoinDataComplete( + new JoinData + { + JoinNumber = 40, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Set/FB the number of meetings to display via the bridge xsig; default: 3 meetings.", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Analog + }); + + [JoinName("SelectCall")] + public JoinDataComplete SelectCall = new JoinDataComplete( + new JoinData + { + JoinNumber = 24, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Sets the selected Call for DTMF commands. Valid values 1-8", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Analog + }); + + + [JoinName("ConnectedCallCount")] + public JoinDataComplete ConnectedCallCount = new JoinDataComplete( + new JoinData + { + JoinNumber = 25, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Reports the number of currently connected calls", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Analog + }); + + [JoinName("MinutesBeforeMeetingStart")] + public JoinDataComplete MinutesBeforeMeetingStart = new JoinDataComplete( + new JoinData + { + JoinNumber = 41, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Minutes before meeting start that a meeting is joinable", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Analog + }); + + [JoinName("CameraNumberSelect")] + public JoinDataComplete CameraNumberSelect = new JoinDataComplete( + new JoinData + { + JoinNumber = 60, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Number Select/FB. 1 based index. Valid range is 1 to the value reported by CameraCount.", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Analog + }); + + [JoinName("CameraCount")] + public JoinDataComplete CameraCount = new JoinDataComplete( + new JoinData + { + JoinNumber = 61, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Reports the number of cameras", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Analog + }); + + [JoinName("DirectoryRowCount")] + public JoinDataComplete DirectoryRowCount = new JoinDataComplete( + new JoinData + { + JoinNumber = 101, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Directory Row Count FB", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Analog + }); + + [JoinName("DirectorySelectRow")] + public JoinDataComplete DirectorySelectRow = new JoinDataComplete( + new JoinData + { + JoinNumber = 101, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Directory Select Row and Feedback", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Analog + }); + + + [JoinName("SelectedContactMethodCount")] + public JoinDataComplete SelectedContactMethodCount = new JoinDataComplete( + new JoinData + { + JoinNumber = 102, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Reports the number of contact methods for the selected contact", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Analog + }); + + [JoinName("SelectContactMethod")] + public JoinDataComplete SelectContactMethod = new JoinDataComplete( + new JoinData + { + JoinNumber = 103, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Selects a contact method by index", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Analog + }); + + [JoinName("DirectorySelectRowFeedback")] + public JoinDataComplete DirectorySelectRowFeedback = new JoinDataComplete( + new JoinData + { + JoinNumber = 104, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Directory Select Row and Feedback", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Analog + }); + + + + [JoinName("CameraPresetSelect")] + public JoinDataComplete CameraPresetSelect = new JoinDataComplete( + new JoinData + { + JoinNumber = 121, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Preset Select", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Analog + }); + + [JoinName("FarEndPresetSelect")] + public JoinDataComplete FarEndPresetSelect = new JoinDataComplete( + new JoinData + { + JoinNumber = 122, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Far End Preset Preset Select", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Analog + }); + + [JoinName("ParticipantCount")] + public JoinDataComplete ParticipantCount = new JoinDataComplete( + new JoinData + { + JoinNumber = 151, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Current Participant Count", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Analog + }); + + [JoinName("Meeting Count Fb")] + public JoinDataComplete MeetingCount = new JoinDataComplete( + new JoinData + { + JoinNumber = 161, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Meeting Count", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Analog + }); + + [JoinName("VolumeLevel")] + public JoinDataComplete VolumeLevel = new JoinDataComplete( + new JoinData + { + JoinNumber = 174, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Volume Level", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Analog + }); + + [JoinName("SelectRecentCallItem")] + public JoinDataComplete SelectRecentCallItem = new JoinDataComplete( + new JoinData + { + JoinNumber = 180, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Select/FB for Recent Call Item. Valid values 1 - 10", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Analog + }); + + [JoinName("RecentCallOccurrenceType")] + public JoinDataComplete RecentCallOccurrenceType = new JoinDataComplete( + new JoinData + { + JoinNumber = 181, + JoinSpan = 10 + }, + new JoinMetadata + { + Description = "Recent Call Occurrence Type. [0-3] 0 = Unknown, 1 = Placed, 2 = Received, 3 = NoAnswer", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Analog + }); + + [JoinName("RecentCallCount")] + public JoinDataComplete RecentCallCount = new JoinDataComplete( + new JoinData + { + JoinNumber = 191, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Recent Call Count", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Analog + }); + + #endregion + + + + #region Serials + + [JoinName("CurrentDialString")] + public JoinDataComplete CurrentDialString = new JoinDataComplete( + new JoinData + { + JoinNumber = 1, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Value to dial when ManualDial digital join is pulsed", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("PhoneDialString")] + public JoinDataComplete PhoneDialString = new JoinDataComplete( + new JoinData + { + JoinNumber = 2, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Phone Dial String", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("CurrentCallData")] + public JoinDataComplete CurrentCallData = new JoinDataComplete( + new JoinData + { + JoinNumber = 2, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Current Call Data - XSIG", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("CallDirection")] + public JoinDataComplete CallDirection = new JoinDataComplete( + new JoinData + { + JoinNumber = 22, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Current Call Direction", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("IncomingCallName")] + public JoinDataComplete IncomingCallName = new JoinDataComplete( + new JoinData + { + JoinNumber = 51, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Incoming Call Name", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("IncomingCallNumber")] + public JoinDataComplete IncomingCallNumber = new JoinDataComplete( + new JoinData + { + JoinNumber = 52, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Incoming Call Number", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + + [JoinName("DirectorySearchString")] + public JoinDataComplete DirectorySearchString = new JoinDataComplete( + new JoinData + { + JoinNumber = 100, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Directory Search String", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("DirectoryEntries")] + public JoinDataComplete DirectoryEntries = new JoinDataComplete( + new JoinData + { + JoinNumber = 101, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Directory Entries - XSig, 255 entries", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("Schedule")] + public JoinDataComplete Schedule = new JoinDataComplete( + new JoinData + { + JoinNumber = 102, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Schedule Data - XSIG", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("ContactMethods")] + public JoinDataComplete ContactMethods = new JoinDataComplete( + new JoinData + { + JoinNumber = 103, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Contact Methods - XSig, 10 entries", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("CameraPresetNames")] + public JoinDataComplete CameraPresetNames = new JoinDataComplete( + new JoinData + { + JoinNumber = 121, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Preset Names - XSIG, max of 15", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("CurrentLayoutStringFb")] + public JoinDataComplete CurrentLayoutStringFb = new JoinDataComplete( + new JoinData + { + JoinNumber = 141, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Current Layout Fb", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("AvailableLayoutsFb")] + public JoinDataComplete AvailableLayoutsFb = new JoinDataComplete( + new JoinData + { + JoinNumber = 142, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "xSig of all available layouts", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("SelectLayout")] + public JoinDataComplete SelectLayout = new JoinDataComplete( + new JoinData + { + JoinNumber = 142, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Select Layout by string", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Serial + }); + + + + [JoinName("CurrentParticipants")] + public JoinDataComplete CurrentParticipants = new JoinDataComplete( + new JoinData + { + JoinNumber = 151, + JoinSpan = 1 + }, + new JoinMetadata() + { + Description = "Current Participants XSig", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("CameraNamesFb")] + public JoinDataComplete CameraNamesFb = new JoinDataComplete( + new JoinData + { + JoinNumber = 161, + JoinSpan = 10 + }, + new JoinMetadata + { + Description = "Camera Name Fb", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("SelectedRecentCallName")] + public JoinDataComplete SelectedRecentCallName = new JoinDataComplete( + new JoinData + { + JoinNumber = 171, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Selected Recent Call Name", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("SelectedRecentCallNumber")] + public JoinDataComplete SelectedRecentCallNumber = new JoinDataComplete( + new JoinData + { + JoinNumber = 172, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Selected Recent Call Number", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("RecentCallNamesStart")] + public JoinDataComplete RecentCallNamesStart = new JoinDataComplete( + new JoinData + { + JoinNumber = 181, + JoinSpan = 10 + }, + new JoinMetadata + { + Description = "Recent Call Names", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("RecentCallTimesStart")] + public JoinDataComplete RecentCallTimesStart = new JoinDataComplete( + new JoinData + { + JoinNumber = 191, + JoinSpan = 10 + }, + new JoinMetadata + { + Description = "Recent Calls Times", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("CurrentSource")] + public JoinDataComplete CurrentSource = new JoinDataComplete( + new JoinData + { + JoinNumber = 201, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Current Source", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("SelfviewPositionFb")] + public JoinDataComplete SelfviewPositionFb = new JoinDataComplete( + new JoinData + { + JoinNumber = 211, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "advance selfview position", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("DeviceIpAddresss")] + public JoinDataComplete DeviceIpAddresss = new JoinDataComplete( + new JoinData + { + JoinNumber = 301, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "IP Address of device", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("SipPhoneNumber")] + public JoinDataComplete SipPhoneNumber = new JoinDataComplete( + new JoinData + { + JoinNumber = 302, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "SIP phone number of device", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("E164Alias")] + public JoinDataComplete E164Alias = new JoinDataComplete( + new JoinData + { + JoinNumber = 303, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "E164 alias of device", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("H323Id")] + public JoinDataComplete H323Id = new JoinDataComplete( + new JoinData + { + JoinNumber = 304, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "H323 ID of device", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("SipUri")] + public JoinDataComplete SipUri = new JoinDataComplete( + new JoinData + { + JoinNumber = 305, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "SIP URI of device", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("DirectoryEntrySelectedName")] + public JoinDataComplete DirectoryEntrySelectedName = new JoinDataComplete( + new JoinData + { + JoinNumber = 356, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Selected Directory Entry Name", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("DirectoryEntrySelectedNumber")] + public JoinDataComplete DirectoryEntrySelectedNumber = new JoinDataComplete( + new JoinData + { + JoinNumber = 357, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Selected Directory Entry Number", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("DirectorySelectedFolderName")] + public JoinDataComplete DirectorySelectedFolderName = new JoinDataComplete( + new JoinData + { + JoinNumber = 358, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Selected Directory Folder Name", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + #endregion + + + public VideoCodecControllerJoinMap(uint joinStart) + : base(joinStart, typeof(VideoCodecControllerJoinMap)) + { + } + + public VideoCodecControllerJoinMap(uint joinStart, Type type) + : base(joinStart, type) + { + } + } +} + + +namespace PepperDash_Essentials_Core.Bridges.JoinMaps +{ + [Obsolete("Use PepperDash.Essentials.Core.Bridges.JoinMaps")] + public class VideoCodecControllerJoinMap : JoinMapBaseAdvanced + { + + #region Digital + + [JoinName("IsOnline")] + public JoinDataComplete IsOnline = new JoinDataComplete( + new JoinData + { + JoinNumber = 1, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Device is Online", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("1")] + public JoinDataComplete Dtmf1 = new JoinDataComplete( + new JoinData + { + JoinNumber = 11, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "DTMF 1", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("2")] + public JoinDataComplete Dtmf2 = new JoinDataComplete( + new JoinData + { + JoinNumber = 12, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "DTMF 2", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("3")] + public JoinDataComplete Dtmf3 = new JoinDataComplete( + new JoinData + { + JoinNumber = 13, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "DTMF 3", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("4")] + public JoinDataComplete Dtmf4 = new JoinDataComplete( + new JoinData + { + JoinNumber = 14, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "DTMF 4", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("5")] + public JoinDataComplete Dtmf5 = new JoinDataComplete( + new JoinData + { + JoinNumber = 15, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "DTMF 5", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("6")] + public JoinDataComplete Dtmf6 = new JoinDataComplete( + new JoinData + { + JoinNumber = 16, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "DTMF 6", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("7")] + public JoinDataComplete Dtmf7 = new JoinDataComplete( + new JoinData + { + JoinNumber = 17, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "DTMF 7", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("8")] + public JoinDataComplete Dtmf8 = new JoinDataComplete( + new JoinData + { + JoinNumber = 18, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "DTMF 8", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("9")] + public JoinDataComplete Dtmf9 = new JoinDataComplete( + new JoinData + { + JoinNumber = 19, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "DTMF 9", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("0")] + public JoinDataComplete Dtmf0 = new JoinDataComplete( + new JoinData + { + JoinNumber = 20, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "DTMF 0", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("*")] + public JoinDataComplete DtmfStar = new JoinDataComplete( + new JoinData + { + JoinNumber = 21, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "DTMF *", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("#")] + public JoinDataComplete DtmfPound = new JoinDataComplete( + new JoinData + { + JoinNumber = 22, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "DTMF #", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("EndCall")] + public JoinDataComplete EndCall = new JoinDataComplete( + new JoinData + { + JoinNumber = 24, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Hang Up", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("HookState")] + public JoinDataComplete HookState = new JoinDataComplete( + new JoinData + { + JoinNumber = 31, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Current Hook State", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("SpeedDialStart")] + public JoinDataComplete SpeedDialStart = new JoinDataComplete( + new JoinData + { + JoinNumber = 41, + JoinSpan = 4 + }, + new JoinMetadata + { + Description = "Speed Dial", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("IncomingCall")] + public JoinDataComplete IncomingCall = new JoinDataComplete( + new JoinData + { + JoinNumber = 50, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Incoming Call", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("IncomingAnswer")] + public JoinDataComplete IncomingAnswer = new JoinDataComplete( + new JoinData + { + JoinNumber = 51, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Answer Incoming Call", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("IncomingReject")] + public JoinDataComplete IncomingReject = new JoinDataComplete( + new JoinData + { + JoinNumber = 52, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Reject Incoming Call", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("ManualDial")] + public JoinDataComplete ManualDial = new JoinDataComplete( + new JoinData + { + JoinNumber = 71, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Dial manual string", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DialPhoneCall")] + public JoinDataComplete DialPhone = new JoinDataComplete( + new JoinData + { + JoinNumber = 72, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Dial Phone", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("PhoneHookState")] + public JoinDataComplete PhoneHookState = new JoinDataComplete( + new JoinData + { + JoinNumber = 72, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Dial Phone", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("EndPhoneCall")] + public JoinDataComplete HangUpPhone = new JoinDataComplete( + new JoinData + { + JoinNumber = 73, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Hang Up PHone", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DirectorySearchBusy")] + public JoinDataComplete DirectorySearchBusy = new JoinDataComplete( + new JoinData + { + JoinNumber = 100, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Directory Search Busy FB", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DirectoryEntryIsContact")] + public JoinDataComplete DirectoryEntryIsContact = new JoinDataComplete( + new JoinData + { + JoinNumber = 101, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Directory Selected Entry Is Contact FB", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DirectoryLineSelected")] + public JoinDataComplete DirectoryLineSelected = new JoinDataComplete( + new JoinData + { + JoinNumber = 101, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Directory Line Selected FB", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DirectoryIsRoot")] + public JoinDataComplete DirectoryIsRoot = new JoinDataComplete( + new JoinData + { + JoinNumber = 102, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Directory is on Root FB", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DirectoryHasChanged")] + public JoinDataComplete DirectoryHasChanged = new JoinDataComplete( + new JoinData + { + JoinNumber = 103, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Directory has changed FB", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DirectoryRoot")] + public JoinDataComplete DirectoryRoot = new JoinDataComplete( + new JoinData + { + JoinNumber = 104, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Go to Directory Root", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DirectoryFolderBack")] + public JoinDataComplete DirectoryFolderBack = new JoinDataComplete( + new JoinData + { + JoinNumber = 105, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Go back one directory level", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DirectoryDialSelectedLine")] + public JoinDataComplete DirectoryDialSelectedLine = new JoinDataComplete( + new JoinData + { + JoinNumber = 106, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Dial selected directory line", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + + [JoinName("CameraTiltUp")] + public JoinDataComplete CameraTiltUp = new JoinDataComplete( + new JoinData + { + JoinNumber = 111, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Tilt Up", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraTiltDown")] + public JoinDataComplete CameraTiltDown = new JoinDataComplete( + new JoinData + { + JoinNumber = 112, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Tilt Down", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraPanLeft")] + public JoinDataComplete CameraPanLeft = new JoinDataComplete( + new JoinData + { + JoinNumber = 113, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Pan Left", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraPanRight")] + public JoinDataComplete CameraPanRight = new JoinDataComplete( + new JoinData + { + JoinNumber = 114, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Pan Right", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraZoomIn")] + public JoinDataComplete CameraZoomIn = new JoinDataComplete( + new JoinData + { + JoinNumber = 115, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Zoom In", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraZoomOut")] + public JoinDataComplete CameraZoomOut = new JoinDataComplete( + new JoinData + { + JoinNumber = 116, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Zoom Out", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraPresetSave")] + public JoinDataComplete CameraPresetSave = new JoinDataComplete( + new JoinData + { + JoinNumber = 121, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Save Selected Preset", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraModeAuto")] + public JoinDataComplete CameraModeAuto = new JoinDataComplete( + new JoinData + { + JoinNumber = 131, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Mode Auto", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraModeManual")] + public JoinDataComplete CameraModeManual = new JoinDataComplete( + new JoinData + { + JoinNumber = 132, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Mode Manual", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraModeOff")] + public JoinDataComplete CameraModeOff = new JoinDataComplete( + new JoinData + { + JoinNumber = 133, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Mode Off", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraSelfView")] + public JoinDataComplete CameraSelfView = new JoinDataComplete( + new JoinData + { + JoinNumber = 141, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Self View Toggle/FB", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraLayout")] + public JoinDataComplete CameraLayout = new JoinDataComplete( + new JoinData + { + JoinNumber = 142, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Layout Toggle", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraSupportsAutoMode")] + public JoinDataComplete CameraSupportsAutoMode = new JoinDataComplete( + new JoinData + { + JoinNumber = 143, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Supports Auto Mode FB", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CameraSupportsOffMode")] + public JoinDataComplete CameraSupportsOffMode = new JoinDataComplete( + new JoinData + { + JoinNumber = 144, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Supports Off Mode FB", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("UpdateMeetings")] + public JoinDataComplete UpdateMeetings = new JoinDataComplete( + new JoinData + { + JoinNumber = 160, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Update Meetings", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DialMeeting1")] + public JoinDataComplete DialMeeting1 = new JoinDataComplete( + new JoinData + { + JoinNumber = 161, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Join first meeting", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DialMeeting2")] + public JoinDataComplete DialMeeting2 = new JoinDataComplete( + new JoinData + { + JoinNumber = 162, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Join second meeting", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DialMeeting3")] + public JoinDataComplete DialMeeting3 = new JoinDataComplete( + new JoinData + { + JoinNumber = 163, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Join third meeting", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("MicMuteOn")] + public JoinDataComplete MicMuteOn = new JoinDataComplete( + new JoinData + { + JoinNumber = 171, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Mic Mute On", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("MicMuteOff")] + public JoinDataComplete MicMuteOff = new JoinDataComplete( + new JoinData + { + JoinNumber = 172, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Mic Mute Off", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("MicMuteToggle")] + public JoinDataComplete MicMuteToggle = new JoinDataComplete( + new JoinData + { + JoinNumber = 173, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Mic Mute Toggle", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("VolumeUp")] + public JoinDataComplete VolumeUp = new JoinDataComplete( + new JoinData + { + JoinNumber = 174, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Volume Up", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("VolumeDown")] + public JoinDataComplete VolumeDown = new JoinDataComplete( + new JoinData + { + JoinNumber = 175, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Volume Down", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("VolumeMuteOn")] + public JoinDataComplete VolumeMuteOn = new JoinDataComplete( + new JoinData + { + JoinNumber = 176, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Volume Mute On", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("VolumeMuteOff")] + public JoinDataComplete VolumeMuteOff = new JoinDataComplete( + new JoinData + { + JoinNumber = 177, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Volume Mute Off", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("VolumeMuteToggle")] + public JoinDataComplete VolumeMuteToggle = new JoinDataComplete( + new JoinData + { + JoinNumber = 178, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Volume Mute Toggle", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("SourceShareStart")] + public JoinDataComplete SourceShareStart = new JoinDataComplete( + new JoinData + { + JoinNumber = 201, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Start Sharing & Feedback", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("SourceShareEnd")] + public JoinDataComplete SourceShareEnd = new JoinDataComplete( + new JoinData + { + JoinNumber = 202, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Stop Sharing & Feedback", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("AutoShareWhileInCall")] + public JoinDataComplete SourceShareAutoStart = new JoinDataComplete( + new JoinData + { + JoinNumber = 203, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "When high, will autostart sharing when a call is joined", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("RecievingContent")] + public JoinDataComplete RecievingContent = new JoinDataComplete( + new JoinData + { + JoinNumber = 204, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Recieving content from the far end", + JoinType = eJoinType.Digital, + JoinCapabilities = eJoinCapabilities.ToSIMPL + }); + + [JoinName("SelfviewPosition")] + public JoinDataComplete SelfviewPosition = new JoinDataComplete( + new JoinData + { + JoinNumber = 211, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "advance selfview position", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("ParticipantAudioMuteToggleStart")] + public JoinDataComplete ParticipantAudioMuteToggleStart = new JoinDataComplete( + new JoinData + { + JoinNumber = 500, + JoinSpan = 50 + }, + new JoinMetadata + { + Description = "Toggles the participant's audio mute status", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("ParticipantVideoMuteToggleStart")] + public JoinDataComplete ParticipantVideoMuteToggleStart = new JoinDataComplete( + new JoinData + { + JoinNumber = 800, + JoinSpan = 50 + }, + new JoinMetadata + { + Description = "Toggles the participant's video mute status", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("ParticipantPinToggleStart")] + public JoinDataComplete ParticipantPinToggleStart = new JoinDataComplete( + new JoinData + { + JoinNumber = 1100, + JoinSpan = 50 + }, + new JoinMetadata + { + Description = "Toggles the participant's pin status", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + #endregion + + + + #region Analog + + [JoinName("MinutesBeforeMeetingStart")] + public JoinDataComplete MinutesBeforeMeetingStart = new JoinDataComplete( + new JoinData + { + JoinNumber = 41, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Minutes before meeting start that a meeting is joinable", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Analog + }); + + [JoinName("CameraNumberSelect")] + public JoinDataComplete CameraNumberSelect = new JoinDataComplete( + new JoinData + { + JoinNumber = 60, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Number Select/FB", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Analog + }); + + [JoinName("DirectoryRowCount")] + public JoinDataComplete DirectoryRowCount = new JoinDataComplete( + new JoinData + { + JoinNumber = 101, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Directory Row Count FB", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Analog + }); + + [JoinName("DirectorySelectRow")] + public JoinDataComplete DirectorySelectRow = new JoinDataComplete( + new JoinData + { + JoinNumber = 101, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Directory Select Row", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Analog + }); + + [JoinName("CameraPresetSelect")] + public JoinDataComplete CameraPresetSelect = new JoinDataComplete( + new JoinData + { + JoinNumber = 121, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Preset Select", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Analog + }); + + [JoinName("ParticipantCount")] + public JoinDataComplete ParticipantCount = new JoinDataComplete( + new JoinData + { + JoinNumber = 151, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Current Participant Count", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Analog + }); + + [JoinName("Meeting Count Fb")] + public JoinDataComplete MeetingCount = new JoinDataComplete( + new JoinData + { + JoinNumber = 161, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Meeting Count", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Analog + }); + + [JoinName("VolumeLevel")] + public JoinDataComplete VolumeLevel = new JoinDataComplete( + new JoinData + { + JoinNumber = 174, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Volume Level", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Analog + }); + + #endregion + + + + #region Serials + + [JoinName("CurrentDialString")] + public JoinDataComplete CurrentDialString = new JoinDataComplete( + new JoinData + { + JoinNumber = 1, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Current Dial String", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("PhoneString")] + public JoinDataComplete PhoneDialString = new JoinDataComplete( + new JoinData + { + JoinNumber = 2, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Phone Dial String", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("CurrentCallName")] + public JoinDataComplete CurrentCallData = new JoinDataComplete( + new JoinData + { + JoinNumber = 2, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Current Call Data - XSIG", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("CallDirection")] + public JoinDataComplete CallDirection = new JoinDataComplete( + new JoinData + { + JoinNumber = 22, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Current Call Direction", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("IncomingCallName")] + public JoinDataComplete IncomingCallName = new JoinDataComplete( + new JoinData + { + JoinNumber = 51, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Incoming Call Name", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("IncomingCallNumber")] + public JoinDataComplete IncomingCallNumber = new JoinDataComplete( + new JoinData + { + JoinNumber = 52, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Incoming Call Number", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + + [JoinName("DirectorySearchString")] + public JoinDataComplete DirectorySearchString = new JoinDataComplete( + new JoinData + { + JoinNumber = 100, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Directory Search String", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("DirectoryEntries")] + public JoinDataComplete DirectoryEntries = new JoinDataComplete( + new JoinData + { + JoinNumber = 101, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Directory Entries - XSig, 255 entries", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("Schedule")] + public JoinDataComplete Schedule = new JoinDataComplete( + new JoinData + { + JoinNumber = 102, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Schedule Data - XSIG", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("CameraPresetNames")] + public JoinDataComplete CameraPresetNames = new JoinDataComplete( + new JoinData + { + JoinNumber = 121, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Camera Preset Names - XSIG, max of 15", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("CameraLayoutStringFb")] + public JoinDataComplete CameraLayoutStringFb = new JoinDataComplete( + new JoinData + { + JoinNumber = 141, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Current Layout Fb", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("AvailableLayoutsFb")] + public JoinDataComplete AvailableLayoutsFb = new JoinDataComplete( + new JoinData + { + JoinNumber = 142, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "xSig of all available layouts", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("SelectLayout")] + public JoinDataComplete SelectLayout = new JoinDataComplete( + new JoinData + { + JoinNumber = 142, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Select Layout by string", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Serial + }); + + + [JoinName("CurrentParticipants")] + public JoinDataComplete CurrentParticipants = new JoinDataComplete( + new JoinData + { + JoinNumber = 151, + JoinSpan = 1 + }, + new JoinMetadata() + { + Description = "Current Participants XSig", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("CurrentSource")] + public JoinDataComplete CurrentSource = new JoinDataComplete( + new JoinData + { + JoinNumber = 201, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Current Source", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("SelfviewPositionFb")] + public JoinDataComplete SelfviewPositionFb = new JoinDataComplete( + new JoinData + { + JoinNumber = 211, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "advance selfview position", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("DirectoryEntrySelectedName")] + public JoinDataComplete DirectoryEntrySelectedName = new JoinDataComplete( + new JoinData + { + JoinNumber = 356, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Selected Directory Entry Name", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("DirectoryEntrySelectedNumber")] + public JoinDataComplete DirectoryEntrySelectedNumber = new JoinDataComplete( + new JoinData + { + JoinNumber = 357, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Selected Directory Entry Number", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("DirectorySelectedFolderName")] + public JoinDataComplete DirectorySelectedFolderName = new JoinDataComplete( + new JoinData + { + JoinNumber = 358, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Selected Directory Folder Name", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + #endregion + + + public VideoCodecControllerJoinMap(uint joinStart) + : base(joinStart, typeof(VideoCodecControllerJoinMap)) + { + } + + public VideoCodecControllerJoinMap(uint joinStart, Type type) + : base(joinStart, type) + { + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CecPortController.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CecPortController.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CecPortController.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CecPortController.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/ComPortController.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/ComPortController.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/ComPortController.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/ComPortController.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/ComSpecJsonConverter.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/ComSpecJsonConverter.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/ComSpecJsonConverter.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/ComSpecJsonConverter.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommFactory.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommFactory.cs similarity index 97% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommFactory.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommFactory.cs index d5bc56fe..5203d416 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommFactory.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommFactory.cs @@ -1,257 +1,257 @@ -using System; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DM; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using PepperDash.Core; -using PepperDash.Essentials.Core.Config; - -namespace PepperDash.Essentials.Core -{ - /// - /// - /// - public class CommFactory - { - public static EssentialsControlPropertiesConfig GetControlPropertiesConfig(DeviceConfig deviceConfig) - { - try - { - return JsonConvert.DeserializeObject - (deviceConfig.Properties["control"].ToString()); - //Debug.Console(2, "Control TEST: {0}", JsonConvert.SerializeObject(controlConfig)); - } - catch (Exception e) - { - - Debug.Console(0, "ERROR: [{0}] Control properties deserialize failed:\r{1}", deviceConfig.Key, e); - return null; - } - } - - - /// - /// Returns a comm method of either com port, TCP, SSH, and puts this into the DeviceManager - /// - /// The Device config object - public static IBasicCommunication CreateCommForDevice(DeviceConfig deviceConfig) - { - EssentialsControlPropertiesConfig controlConfig = GetControlPropertiesConfig(deviceConfig); - if (controlConfig == null) - return null; - - IBasicCommunication comm = null; - try - { - var c = controlConfig.TcpSshProperties; - switch (controlConfig.Method) - { - case eControlMethod.Com: - comm = new ComPortController(deviceConfig.Key + "-com", GetComPort, controlConfig.ComParams, controlConfig); - break; - case eControlMethod.Cec: - comm = new CecPortController(deviceConfig.Key + "-cec", GetCecPort, controlConfig); - break; - case eControlMethod.IR: - break; - case eControlMethod.Ssh: - { - var ssh = new GenericSshClient(deviceConfig.Key + "-ssh", c.Address, c.Port, c.Username, c.Password); - ssh.AutoReconnect = c.AutoReconnect; - if(ssh.AutoReconnect) - ssh.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs; - comm = ssh; - break; - } - case eControlMethod.Tcpip: - { - var tcp = new GenericTcpIpClient(deviceConfig.Key + "-tcp", c.Address, c.Port, c.BufferSize); - tcp.AutoReconnect = c.AutoReconnect; - if (tcp.AutoReconnect) - tcp.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs; - comm = tcp; - break; - } - case eControlMethod.Udp: - { - var udp = new GenericUdpServer(deviceConfig.Key + "-udp", c.Address, c.Port, c.BufferSize); - comm = udp; - break; - } - case eControlMethod.Telnet: - break; - case eControlMethod.SecureTcpIp: - { - var secureTcp = new GenericSecureTcpIpClient(deviceConfig.Key + "-secureTcp", c.Address, c.Port, c.BufferSize); - secureTcp.AutoReconnect = c.AutoReconnect; - if (secureTcp.AutoReconnect) - secureTcp.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs; - comm = secureTcp; - break; - } - default: - break; - } - } - catch (Exception e) - { - Debug.Console(0, "Cannot create communication from JSON:\r{0}\r\rException:\r{1}", - deviceConfig.Properties.ToString(), e); - } - - // put it in the device manager if it's the right flavor - var comDev = comm as Device; - if (comDev != null) - DeviceManager.AddDevice(comDev); - return comm; - } - - public static ComPort GetComPort(EssentialsControlPropertiesConfig config) - { - var comPar = config.ComParams; - var dev = GetIComPortsDeviceFromManagedDevice(config.ControlPortDevKey); - if (dev != null && config.ControlPortNumber <= dev.NumberOfComPorts) - return dev.ComPorts[config.ControlPortNumber]; - Debug.Console(0,Debug.ErrorLogLevel.Notice, "GetComPort: Device '{0}' does not have com port {1}", config.ControlPortDevKey, config.ControlPortNumber); - return null; - } - - /// - /// Gets an ICec port from a RoutingInput or RoutingOutput on a device - /// - /// - /// - public static ICec GetCecPort(ControlPropertiesConfig config) - { - try - { - var dev = DeviceManager.GetDeviceForKey(config.ControlPortDevKey); - - Debug.Console(0, "GetCecPort: device '{0}' {1}", config.ControlPortDevKey, dev == null - ? "is not valid, failed to get cec port" - : "found in device manager, attempting to get cec port"); - - if (dev == null) - return null; - - if (String.IsNullOrEmpty(config.ControlPortName)) - { - Debug.Console(0, "GetCecPort: '{0}' - Configuration missing 'ControlPortName'", config.ControlPortDevKey); - return null; - } - - - var inputsOutputs = dev as IRoutingInputsOutputs; - if (inputsOutputs == null) - { - Debug.Console(0, "GetCecPort: Device '{0}' does not support IRoutingInputsOutputs, failed to get CEC port called '{1}'", - config.ControlPortDevKey, config.ControlPortName); - - return null; - } - - var inputPort = inputsOutputs.InputPorts[config.ControlPortName]; - if (inputPort != null && inputPort.Port is ICec) - return inputPort.Port as ICec; - - - var outputPort = inputsOutputs.OutputPorts[config.ControlPortName]; - if (outputPort != null && outputPort.Port is ICec) - return outputPort.Port as ICec; - } - catch (Exception ex) - { - Debug.Console(1, "GetCecPort Exception Message: {0}", ex.Message); - Debug.Console(2, "GetCecPort Exception StackTrace: {0}", ex.StackTrace); - if (ex.InnerException != null) - Debug.Console(0, "GetCecPort Exception InnerException: {0}", ex.InnerException); - } - - Debug.Console(0, "GetCecPort: Device '{0}' does not have a CEC port called '{1}'", - config.ControlPortDevKey, config.ControlPortName); - - return null; - } - - /// - /// Helper to grab the IComPorts device for this PortDeviceKey. Key "controlSystem" will - /// return the ControlSystem object from the Global class. - /// - /// IComPorts device or null if the device is not found or does not implement IComPorts - public static IComPorts GetIComPortsDeviceFromManagedDevice(string ComPortDevKey) - { - if ((ComPortDevKey.Equals("controlSystem", System.StringComparison.OrdinalIgnoreCase) - || ComPortDevKey.Equals("processor", System.StringComparison.OrdinalIgnoreCase)) - && Global.ControlSystem is IComPorts) - return Global.ControlSystem; - else - { - var dev = DeviceManager.GetDeviceForKey(ComPortDevKey) as IComPorts; - if (dev == null) - Debug.Console(0, "ComPortConfig: Cannot find com port device '{0}'", ComPortDevKey); - return dev; - } - } - } - - /// - /// - /// - public class EssentialsControlPropertiesConfig : - PepperDash.Core.ControlPropertiesConfig - { - - [JsonConverter(typeof(ComSpecJsonConverter))] - public ComPort.ComPortSpec ComParams { get; set; } - - public string RoomId { get; set; } - - public string CresnetId { get; set; } - - /// - /// Attempts to provide uint conversion of string CresnetId - /// - public uint CresnetIdInt - { - get - { - try - { - return Convert.ToUInt32(CresnetId, 16); - } - catch (Exception) - { - throw new FormatException(string.Format("ERROR:Unable to convert Cresnet ID: {0} to hex. Error:\n{1}", CresnetId)); - } - } - } - - public string InfinetId { get; set; } - - /// - /// Attepmts to provide uiont conversion of string InifinetId - /// - public uint InfinetIdInt - { - get - { - try - { - return Convert.ToUInt32(InfinetId, 16); - } - catch (Exception) - { - throw new FormatException(string.Format("ERROR:Unable to conver Infinet ID: {0} to hex. Error:\n{1}", InfinetId)); - } - } - } - } - - public class IrControlSpec - { - public string PortDeviceKey { get; set; } - public uint PortNumber { get; set; } - public string File { get; set; } - } +using System; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DM; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core +{ + /// + /// + /// + public class CommFactory + { + public static EssentialsControlPropertiesConfig GetControlPropertiesConfig(DeviceConfig deviceConfig) + { + try + { + return JsonConvert.DeserializeObject + (deviceConfig.Properties["control"].ToString()); + //Debug.Console(2, "Control TEST: {0}", JsonConvert.SerializeObject(controlConfig)); + } + catch (Exception e) + { + + Debug.Console(0, "ERROR: [{0}] Control properties deserialize failed:\r{1}", deviceConfig.Key, e); + return null; + } + } + + + /// + /// Returns a comm method of either com port, TCP, SSH, and puts this into the DeviceManager + /// + /// The Device config object + public static IBasicCommunication CreateCommForDevice(DeviceConfig deviceConfig) + { + EssentialsControlPropertiesConfig controlConfig = GetControlPropertiesConfig(deviceConfig); + if (controlConfig == null) + return null; + + IBasicCommunication comm = null; + try + { + var c = controlConfig.TcpSshProperties; + switch (controlConfig.Method) + { + case eControlMethod.Com: + comm = new ComPortController(deviceConfig.Key + "-com", GetComPort, controlConfig.ComParams, controlConfig); + break; + case eControlMethod.Cec: + comm = new CecPortController(deviceConfig.Key + "-cec", GetCecPort, controlConfig); + break; + case eControlMethod.IR: + break; + case eControlMethod.Ssh: + { + var ssh = new GenericSshClient(deviceConfig.Key + "-ssh", c.Address, c.Port, c.Username, c.Password); + ssh.AutoReconnect = c.AutoReconnect; + if(ssh.AutoReconnect) + ssh.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs; + comm = ssh; + break; + } + case eControlMethod.Tcpip: + { + var tcp = new GenericTcpIpClient(deviceConfig.Key + "-tcp", c.Address, c.Port, c.BufferSize); + tcp.AutoReconnect = c.AutoReconnect; + if (tcp.AutoReconnect) + tcp.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs; + comm = tcp; + break; + } + case eControlMethod.Udp: + { + var udp = new GenericUdpServer(deviceConfig.Key + "-udp", c.Address, c.Port, c.BufferSize); + comm = udp; + break; + } + case eControlMethod.Telnet: + break; + case eControlMethod.SecureTcpIp: + { + var secureTcp = new GenericSecureTcpIpClient(deviceConfig.Key + "-secureTcp", c.Address, c.Port, c.BufferSize); + secureTcp.AutoReconnect = c.AutoReconnect; + if (secureTcp.AutoReconnect) + secureTcp.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs; + comm = secureTcp; + break; + } + default: + break; + } + } + catch (Exception e) + { + Debug.Console(0, "Cannot create communication from JSON:\r{0}\r\rException:\r{1}", + deviceConfig.Properties.ToString(), e); + } + + // put it in the device manager if it's the right flavor + var comDev = comm as Device; + if (comDev != null) + DeviceManager.AddDevice(comDev); + return comm; + } + + public static ComPort GetComPort(EssentialsControlPropertiesConfig config) + { + var comPar = config.ComParams; + var dev = GetIComPortsDeviceFromManagedDevice(config.ControlPortDevKey); + if (dev != null && config.ControlPortNumber <= dev.NumberOfComPorts) + return dev.ComPorts[config.ControlPortNumber]; + Debug.Console(0,Debug.ErrorLogLevel.Notice, "GetComPort: Device '{0}' does not have com port {1}", config.ControlPortDevKey, config.ControlPortNumber); + return null; + } + + /// + /// Gets an ICec port from a RoutingInput or RoutingOutput on a device + /// + /// + /// + public static ICec GetCecPort(ControlPropertiesConfig config) + { + try + { + var dev = DeviceManager.GetDeviceForKey(config.ControlPortDevKey); + + Debug.Console(0, "GetCecPort: device '{0}' {1}", config.ControlPortDevKey, dev == null + ? "is not valid, failed to get cec port" + : "found in device manager, attempting to get cec port"); + + if (dev == null) + return null; + + if (String.IsNullOrEmpty(config.ControlPortName)) + { + Debug.Console(0, "GetCecPort: '{0}' - Configuration missing 'ControlPortName'", config.ControlPortDevKey); + return null; + } + + + var inputsOutputs = dev as IRoutingInputsOutputs; + if (inputsOutputs == null) + { + Debug.Console(0, "GetCecPort: Device '{0}' does not support IRoutingInputsOutputs, failed to get CEC port called '{1}'", + config.ControlPortDevKey, config.ControlPortName); + + return null; + } + + var inputPort = inputsOutputs.InputPorts[config.ControlPortName]; + if (inputPort != null && inputPort.Port is ICec) + return inputPort.Port as ICec; + + + var outputPort = inputsOutputs.OutputPorts[config.ControlPortName]; + if (outputPort != null && outputPort.Port is ICec) + return outputPort.Port as ICec; + } + catch (Exception ex) + { + Debug.Console(1, "GetCecPort Exception Message: {0}", ex.Message); + Debug.Console(2, "GetCecPort Exception StackTrace: {0}", ex.StackTrace); + if (ex.InnerException != null) + Debug.Console(0, "GetCecPort Exception InnerException: {0}", ex.InnerException); + } + + Debug.Console(0, "GetCecPort: Device '{0}' does not have a CEC port called '{1}'", + config.ControlPortDevKey, config.ControlPortName); + + return null; + } + + /// + /// Helper to grab the IComPorts device for this PortDeviceKey. Key "controlSystem" will + /// return the ControlSystem object from the Global class. + /// + /// IComPorts device or null if the device is not found or does not implement IComPorts + public static IComPorts GetIComPortsDeviceFromManagedDevice(string ComPortDevKey) + { + if ((ComPortDevKey.Equals("controlSystem", System.StringComparison.OrdinalIgnoreCase) + || ComPortDevKey.Equals("processor", System.StringComparison.OrdinalIgnoreCase)) + && Global.ControlSystem is IComPorts) + return Global.ControlSystem; + else + { + var dev = DeviceManager.GetDeviceForKey(ComPortDevKey) as IComPorts; + if (dev == null) + Debug.Console(0, "ComPortConfig: Cannot find com port device '{0}'", ComPortDevKey); + return dev; + } + } + } + + /// + /// + /// + public class EssentialsControlPropertiesConfig : + PepperDash.Core.ControlPropertiesConfig + { + + [JsonConverter(typeof(ComSpecJsonConverter))] + public ComPort.ComPortSpec ComParams { get; set; } + + public string RoomId { get; set; } + + public string CresnetId { get; set; } + + /// + /// Attempts to provide uint conversion of string CresnetId + /// + public uint CresnetIdInt + { + get + { + try + { + return Convert.ToUInt32(CresnetId, 16); + } + catch (Exception) + { + throw new FormatException(string.Format("ERROR:Unable to convert Cresnet ID: {0} to hex. Error:\n{1}", CresnetId)); + } + } + } + + public string InfinetId { get; set; } + + /// + /// Attepmts to provide uiont conversion of string InifinetId + /// + public uint InfinetIdInt + { + get + { + try + { + return Convert.ToUInt32(InfinetId, 16); + } + catch (Exception) + { + throw new FormatException(string.Format("ERROR:Unable to conver Infinet ID: {0} to hex. Error:\n{1}", InfinetId)); + } + } + } + } + + public class IrControlSpec + { + public string PortDeviceKey { get; set; } + public uint PortNumber { get; set; } + public string File { get; set; } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommunicationExtras.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommunicationExtras.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommunicationExtras.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommunicationExtras.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/ConsoleCommMockDevice.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/ConsoleCommMockDevice.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/ConsoleCommMockDevice.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/ConsoleCommMockDevice.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/GenericComm.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/GenericComm.cs similarity index 97% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/GenericComm.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/GenericComm.cs index 7648a379..309d5659 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/GenericComm.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/GenericComm.cs @@ -1,142 +1,142 @@ -using System; -using System.Collections.Generic; -using Crestron.SimplSharp.CrestronSockets; -using Crestron.SimplSharpPro.DeviceSupport; -using Newtonsoft.Json; - -using PepperDash.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Devices; -using PepperDash.Essentials.Core.Config; - - -namespace PepperDash.Essentials.Core -{ - /// - /// Serves as a generic wrapper class for all styles of IBasicCommuncation ports - /// - [Description("Generic communication wrapper class for any IBasicCommunication type")] - public class GenericComm : ReconfigurableBridgableDevice - { - EssentialsControlPropertiesConfig PropertiesConfig; - - public IBasicCommunication CommPort { get; private set; } - - public GenericComm(DeviceConfig config) - : base(config) - { - - PropertiesConfig = CommFactory.GetControlPropertiesConfig(config); - - var commPort = CommFactory.CreateCommForDevice(config); - - //Fixing decision to require '-comPorts' in delcaration for DGE in order to get a device with comports included - if (commPort == null) - { - config.Key = config.Key + "-comPorts"; - commPort = CommFactory.CreateCommForDevice(config); - } - - CommPort = commPort; - - } - - public static IKeyed BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); - return new GenericComm(dc); - } - - public void SetPortConfig(string portConfig) - { - // TODO: Deserialize new EssentialsControlPropertiesConfig and handle as necessary - try - { - PropertiesConfig = JsonConvert.DeserializeObject - (portConfig); - } - catch (Exception e) - { - Debug.Console(2, this, "Error deserializing port config: {0}", e); - } - } - - protected override void CustomSetConfig(DeviceConfig config) - { - PropertiesConfig = CommFactory.GetControlPropertiesConfig(config); - - ConfigWriter.UpdateDeviceConfig(config); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new IBasicCommunicationJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - if (CommPort == null) - { - Debug.Console(1, this, "Unable to link device '{0}'. CommPort is null", Key); - return; - } - - Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - // this is a permanent event handler. This cannot be -= from event - CommPort.TextReceived += (s, a) => - { - trilist.SetString(joinMap.TextReceived.JoinNumber, a.Text); - }; - trilist.SetStringSigAction(joinMap.SendText.JoinNumber, s => CommPort.SendText(s)); - trilist.SetStringSigAction(joinMap.SetPortConfig.JoinNumber, SetPortConfig); - - - var sComm = CommPort as ISocketStatus; - if (sComm == null) return; - sComm.ConnectionChange += (s, a) => - { - trilist.SetUshort(joinMap.Status.JoinNumber, (ushort)(a.Client.ClientStatus)); - trilist.SetBool(joinMap.Connected.JoinNumber, a.Client.ClientStatus == - SocketStatus.SOCKET_STATUS_CONNECTED); - }; - - trilist.SetBoolSigAction(joinMap.Connect.JoinNumber, b => - { - if (b) - { - sComm.Connect(); - } - else - { - sComm.Disconnect(); - } - }); - } - } - - public class GenericCommFactory : EssentialsDeviceFactory - { - public GenericCommFactory() - { - TypeNames = new List() { "genericComm" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); - return new GenericComm(dc); - } - } +using System; +using System.Collections.Generic; +using Crestron.SimplSharp.CrestronSockets; +using Crestron.SimplSharpPro.DeviceSupport; +using Newtonsoft.Json; + +using PepperDash.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Devices; +using PepperDash.Essentials.Core.Config; + + +namespace PepperDash.Essentials.Core +{ + /// + /// Serves as a generic wrapper class for all styles of IBasicCommuncation ports + /// + [Description("Generic communication wrapper class for any IBasicCommunication type")] + public class GenericComm : ReconfigurableBridgableDevice + { + EssentialsControlPropertiesConfig PropertiesConfig; + + public IBasicCommunication CommPort { get; private set; } + + public GenericComm(DeviceConfig config) + : base(config) + { + + PropertiesConfig = CommFactory.GetControlPropertiesConfig(config); + + var commPort = CommFactory.CreateCommForDevice(config); + + //Fixing decision to require '-comPorts' in delcaration for DGE in order to get a device with comports included + if (commPort == null) + { + config.Key = config.Key + "-comPorts"; + commPort = CommFactory.CreateCommForDevice(config); + } + + CommPort = commPort; + + } + + public static IKeyed BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); + return new GenericComm(dc); + } + + public void SetPortConfig(string portConfig) + { + // TODO: Deserialize new EssentialsControlPropertiesConfig and handle as necessary + try + { + PropertiesConfig = JsonConvert.DeserializeObject + (portConfig); + } + catch (Exception e) + { + Debug.Console(2, this, "Error deserializing port config: {0}", e); + } + } + + protected override void CustomSetConfig(DeviceConfig config) + { + PropertiesConfig = CommFactory.GetControlPropertiesConfig(config); + + ConfigWriter.UpdateDeviceConfig(config); + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new IBasicCommunicationJoinMap(joinStart); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + else + { + Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + } + + if (CommPort == null) + { + Debug.Console(1, this, "Unable to link device '{0}'. CommPort is null", Key); + return; + } + + Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + // this is a permanent event handler. This cannot be -= from event + CommPort.TextReceived += (s, a) => + { + trilist.SetString(joinMap.TextReceived.JoinNumber, a.Text); + }; + trilist.SetStringSigAction(joinMap.SendText.JoinNumber, s => CommPort.SendText(s)); + trilist.SetStringSigAction(joinMap.SetPortConfig.JoinNumber, SetPortConfig); + + + var sComm = CommPort as ISocketStatus; + if (sComm == null) return; + sComm.ConnectionChange += (s, a) => + { + trilist.SetUshort(joinMap.Status.JoinNumber, (ushort)(a.Client.ClientStatus)); + trilist.SetBool(joinMap.Connected.JoinNumber, a.Client.ClientStatus == + SocketStatus.SOCKET_STATUS_CONNECTED); + }; + + trilist.SetBoolSigAction(joinMap.Connect.JoinNumber, b => + { + if (b) + { + sComm.Connect(); + } + else + { + sComm.Disconnect(); + } + }); + } + } + + public class GenericCommFactory : EssentialsDeviceFactory + { + public GenericCommFactory() + { + TypeNames = new List() { "genericComm" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); + return new GenericComm(dc); + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/GenericHttpClient.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/GenericHttpClient.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/GenericHttpClient.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/GenericHttpClient.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/IRPortHelper.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/IRPortHelper.cs similarity index 97% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/IRPortHelper.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/IRPortHelper.cs index 80ee2a2c..9ddbf27a 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/IRPortHelper.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/IRPortHelper.cs @@ -1,241 +1,241 @@ -using System; -using System.Collections.Generic; -using Crestron.SimplSharp; -using Crestron.SimplSharp.CrestronIO; -using Crestron.SimplSharpPro; - -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using PepperDash.Core; -using PepperDash.Essentials.Core.Config; - -namespace PepperDash.Essentials.Core -{ - /// - /// - /// - public static class IRPortHelper - { - public static string IrDriverPathPrefix - { - get - { - return Global.FilePathPrefix + "IR" + Global.DirectorySeparator; - } - } - - /// - /// Finds either the ControlSystem or a device controller that contains IR ports and - /// returns a port from the hardware device - /// - /// - /// IrPortConfig object. The port and or filename will be empty/null - /// if valid values don't exist on config - public static IrOutPortConfig GetIrPort(JToken propsToken) - { - var control = propsToken["control"]; - if (control == null) - return null; - if (control["method"].Value() != "ir") - { - Debug.Console(0, "IRPortHelper called with non-IR properties"); - return null; - } - - var port = new IrOutPortConfig(); - - var portDevKey = control.Value("controlPortDevKey"); - var portNum = control.Value("controlPortNumber"); - if (portDevKey == null || portNum == 0) - { - Debug.Console(1, "WARNING: Properties is missing port device or port number"); - return port; - } - - IIROutputPorts irDev = null; - if (portDevKey.Equals("controlSystem", StringComparison.OrdinalIgnoreCase) - || portDevKey.Equals("processor", StringComparison.OrdinalIgnoreCase)) - irDev = Global.ControlSystem; - else - irDev = DeviceManager.GetDeviceForKey(portDevKey) as IIROutputPorts; - - if (irDev == null) - { - Debug.Console(1, "[Config] Error, device with IR ports '{0}' not found", portDevKey); - return port; - } - - if (portNum <= irDev.NumberOfIROutputPorts) // success! - { - var file = IrDriverPathPrefix + control["irFile"].Value(); - port.Port = irDev.IROutputPorts[portNum]; - port.FileName = file; - return port; // new IrOutPortConfig { Port = irDev.IROutputPorts[portNum], FileName = file }; - } - else - { - Debug.Console(1, "[Config] Error, device '{0}' IR port {1} out of range", - portDevKey, portNum); - return port; - } - } - - public static IROutputPort GetIrOutputPort(DeviceConfig dc) - { - var irControllerKey = dc.Key + "-ir"; - if (dc.Properties == null) - { - Debug.Console(0, "[{0}] WARNING: Device config does not include properties. IR will not function.", dc.Key); - return null; - } - - var control = dc.Properties["control"]; - if (control == null) - { - Debug.Console(0, - "WARNING: Device config does not include control properties. IR will not function for {0}", dc.Key); - return null; - } - - var portDevKey = control.Value("controlPortDevKey"); - var portNum = control.Value("controlPortNumber"); - IIROutputPorts irDev = null; - - if (portDevKey == null) - { - Debug.Console(0, "WARNING: control properties is missing ir device for {0}", dc.Key); - return null; - } - - if (portNum == 0) - { - Debug.Console(0, "WARNING: control properties is missing ir port number for {0}", dc.Key); - return null; - } - - if (portDevKey.Equals("controlSystem", StringComparison.OrdinalIgnoreCase) - || portDevKey.Equals("processor", StringComparison.OrdinalIgnoreCase)) - irDev = Global.ControlSystem; - else - irDev = DeviceManager.GetDeviceForKey(portDevKey) as IIROutputPorts; - - if (irDev == null) - { - Debug.Console(0, "WARNING: device with IR ports '{0}' not found", portDevKey); - return null; - } - if (portNum > irDev.NumberOfIROutputPorts) - { - Debug.Console(0, "WARNING: device '{0}' IR port {1} out of range", - portDevKey, portNum); - return null; - } - - - var port = irDev.IROutputPorts[portNum]; - - - - return port; - } - - public static IrOutputPortController GetIrOutputPortController(DeviceConfig config) - { - Debug.Console(1, "Attempting to create new Ir Port Controller"); - - if (config == null) - { - return null; - } - - var postActivationFunc = new Func (GetIrOutputPort); - var irDevice = new IrOutputPortController(config.Key + "-ir", postActivationFunc, config); - - return irDevice; - } - - /* - /// - /// Returns a ready-to-go IrOutputPortController from a DeviceConfig object. - /// - public static IrOutputPortController GetIrOutputPortController(DeviceConfig devConf) - { - var irControllerKey = devConf.Key + "-ir"; - if (devConf.Properties == null) - { - Debug.Console(0, "[{0}] WARNING: Device config does not include properties. IR will not function.", devConf.Key); - return new IrOutputPortController(irControllerKey, null, ""); - } - - var control = devConf.Properties["control"]; - if (control == null) - { - var c = new IrOutputPortController(irControllerKey, null, ""); - Debug.Console(0, c, "WARNING: Device config does not include control properties. IR will not function"); - return c; - } - - var portDevKey = control.Value("controlPortDevKey"); - var portNum = control.Value("controlPortNumber"); - IIROutputPorts irDev = null; - - if (portDevKey == null) - { - var c = new IrOutputPortController(irControllerKey, null, ""); - Debug.Console(0, c, "WARNING: control properties is missing ir device"); - return c; - } - - if (portNum == 0) - { - var c = new IrOutputPortController(irControllerKey, null, ""); - Debug.Console(0, c, "WARNING: control properties is missing ir port number"); - return c; - } - - if (portDevKey.Equals("controlSystem", StringComparison.OrdinalIgnoreCase) - || portDevKey.Equals("processor", StringComparison.OrdinalIgnoreCase)) - irDev = Global.ControlSystem; - else - irDev = DeviceManager.GetDeviceForKey(portDevKey) as IIROutputPorts; - - if (irDev == null) - { - var c = new IrOutputPortController(irControllerKey, null, ""); - Debug.Console(0, c, "WARNING: device with IR ports '{0}' not found", portDevKey); - return c; - } - - if (portNum <= irDev.NumberOfIROutputPorts) // success! - return new IrOutputPortController(irControllerKey, irDev.IROutputPorts[portNum], - IrDriverPathPrefix + control["irFile"].Value()); - else - { - var c = new IrOutputPortController(irControllerKey, null, ""); - Debug.Console(0, c, "WARNING: device '{0}' IR port {1} out of range", - portDevKey, portNum); - return c; - } - }*/ - } - - /// - /// Wrapper to help in IR port creation - /// - public class IrOutPortConfig - { - [JsonProperty("port")] - public IROutputPort Port { get; set; } - - [JsonProperty("fileName")] - public string FileName { get; set; } - - [JsonProperty("useBridgeJoinMap")] - public bool UseBridgeJoinMap { get; set; } - - public IrOutPortConfig() - { - FileName = ""; - } - } +using System; +using System.Collections.Generic; +using Crestron.SimplSharp; +using Crestron.SimplSharp.CrestronIO; +using Crestron.SimplSharpPro; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core +{ + /// + /// + /// + public static class IRPortHelper + { + public static string IrDriverPathPrefix + { + get + { + return Global.FilePathPrefix + "IR" + Global.DirectorySeparator; + } + } + + /// + /// Finds either the ControlSystem or a device controller that contains IR ports and + /// returns a port from the hardware device + /// + /// + /// IrPortConfig object. The port and or filename will be empty/null + /// if valid values don't exist on config + public static IrOutPortConfig GetIrPort(JToken propsToken) + { + var control = propsToken["control"]; + if (control == null) + return null; + if (control["method"].Value() != "ir") + { + Debug.Console(0, "IRPortHelper called with non-IR properties"); + return null; + } + + var port = new IrOutPortConfig(); + + var portDevKey = control.Value("controlPortDevKey"); + var portNum = control.Value("controlPortNumber"); + if (portDevKey == null || portNum == 0) + { + Debug.Console(1, "WARNING: Properties is missing port device or port number"); + return port; + } + + IIROutputPorts irDev = null; + if (portDevKey.Equals("controlSystem", StringComparison.OrdinalIgnoreCase) + || portDevKey.Equals("processor", StringComparison.OrdinalIgnoreCase)) + irDev = Global.ControlSystem; + else + irDev = DeviceManager.GetDeviceForKey(portDevKey) as IIROutputPorts; + + if (irDev == null) + { + Debug.Console(1, "[Config] Error, device with IR ports '{0}' not found", portDevKey); + return port; + } + + if (portNum <= irDev.NumberOfIROutputPorts) // success! + { + var file = IrDriverPathPrefix + control["irFile"].Value(); + port.Port = irDev.IROutputPorts[portNum]; + port.FileName = file; + return port; // new IrOutPortConfig { Port = irDev.IROutputPorts[portNum], FileName = file }; + } + else + { + Debug.Console(1, "[Config] Error, device '{0}' IR port {1} out of range", + portDevKey, portNum); + return port; + } + } + + public static IROutputPort GetIrOutputPort(DeviceConfig dc) + { + var irControllerKey = dc.Key + "-ir"; + if (dc.Properties == null) + { + Debug.Console(0, "[{0}] WARNING: Device config does not include properties. IR will not function.", dc.Key); + return null; + } + + var control = dc.Properties["control"]; + if (control == null) + { + Debug.Console(0, + "WARNING: Device config does not include control properties. IR will not function for {0}", dc.Key); + return null; + } + + var portDevKey = control.Value("controlPortDevKey"); + var portNum = control.Value("controlPortNumber"); + IIROutputPorts irDev = null; + + if (portDevKey == null) + { + Debug.Console(0, "WARNING: control properties is missing ir device for {0}", dc.Key); + return null; + } + + if (portNum == 0) + { + Debug.Console(0, "WARNING: control properties is missing ir port number for {0}", dc.Key); + return null; + } + + if (portDevKey.Equals("controlSystem", StringComparison.OrdinalIgnoreCase) + || portDevKey.Equals("processor", StringComparison.OrdinalIgnoreCase)) + irDev = Global.ControlSystem; + else + irDev = DeviceManager.GetDeviceForKey(portDevKey) as IIROutputPorts; + + if (irDev == null) + { + Debug.Console(0, "WARNING: device with IR ports '{0}' not found", portDevKey); + return null; + } + if (portNum > irDev.NumberOfIROutputPorts) + { + Debug.Console(0, "WARNING: device '{0}' IR port {1} out of range", + portDevKey, portNum); + return null; + } + + + var port = irDev.IROutputPorts[portNum]; + + + + return port; + } + + public static IrOutputPortController GetIrOutputPortController(DeviceConfig config) + { + Debug.Console(1, "Attempting to create new Ir Port Controller"); + + if (config == null) + { + return null; + } + + var postActivationFunc = new Func (GetIrOutputPort); + var irDevice = new IrOutputPortController(config.Key + "-ir", postActivationFunc, config); + + return irDevice; + } + + /* + /// + /// Returns a ready-to-go IrOutputPortController from a DeviceConfig object. + /// + public static IrOutputPortController GetIrOutputPortController(DeviceConfig devConf) + { + var irControllerKey = devConf.Key + "-ir"; + if (devConf.Properties == null) + { + Debug.Console(0, "[{0}] WARNING: Device config does not include properties. IR will not function.", devConf.Key); + return new IrOutputPortController(irControllerKey, null, ""); + } + + var control = devConf.Properties["control"]; + if (control == null) + { + var c = new IrOutputPortController(irControllerKey, null, ""); + Debug.Console(0, c, "WARNING: Device config does not include control properties. IR will not function"); + return c; + } + + var portDevKey = control.Value("controlPortDevKey"); + var portNum = control.Value("controlPortNumber"); + IIROutputPorts irDev = null; + + if (portDevKey == null) + { + var c = new IrOutputPortController(irControllerKey, null, ""); + Debug.Console(0, c, "WARNING: control properties is missing ir device"); + return c; + } + + if (portNum == 0) + { + var c = new IrOutputPortController(irControllerKey, null, ""); + Debug.Console(0, c, "WARNING: control properties is missing ir port number"); + return c; + } + + if (portDevKey.Equals("controlSystem", StringComparison.OrdinalIgnoreCase) + || portDevKey.Equals("processor", StringComparison.OrdinalIgnoreCase)) + irDev = Global.ControlSystem; + else + irDev = DeviceManager.GetDeviceForKey(portDevKey) as IIROutputPorts; + + if (irDev == null) + { + var c = new IrOutputPortController(irControllerKey, null, ""); + Debug.Console(0, c, "WARNING: device with IR ports '{0}' not found", portDevKey); + return c; + } + + if (portNum <= irDev.NumberOfIROutputPorts) // success! + return new IrOutputPortController(irControllerKey, irDev.IROutputPorts[portNum], + IrDriverPathPrefix + control["irFile"].Value()); + else + { + var c = new IrOutputPortController(irControllerKey, null, ""); + Debug.Console(0, c, "WARNING: device '{0}' IR port {1} out of range", + portDevKey, portNum); + return c; + } + }*/ + } + + /// + /// Wrapper to help in IR port creation + /// + public class IrOutPortConfig + { + [JsonProperty("port")] + public IROutputPort Port { get; set; } + + [JsonProperty("fileName")] + public string FileName { get; set; } + + [JsonProperty("useBridgeJoinMap")] + public bool UseBridgeJoinMap { get; set; } + + public IrOutPortConfig() + { + FileName = ""; + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/BasicConfig.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/BasicConfig.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/BasicConfig.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/BasicConfig.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/ConfigPropertiesHelpers.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/ConfigPropertiesHelpers.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/ConfigPropertiesHelpers.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/ConfigPropertiesHelpers.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/DeviceConfig.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/DeviceConfig.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/DeviceConfig.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/DeviceConfig.cs index 5c1ee54c..3071a306 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/DeviceConfig.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/DeviceConfig.cs @@ -1,80 +1,80 @@ -using System; -using System.Collections.Generic; -using Crestron.SimplSharp; -using Crestron.SimplSharp.CrestronIO; -using Crestron.SimplSharpPro; - -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using PepperDash.Core; -using PepperDash.Essentials.Core; - -namespace PepperDash.Essentials.Core.Config -{ - public class DeviceConfig - { - [JsonProperty("key")] - public string Key { get; set; } - - [JsonProperty("uid")] - public int Uid { get; set; } - - [JsonProperty("name")] - public string Name { get; set; } - - [JsonProperty("group")] - public string Group { get; set; } - - [JsonProperty("type")] - public string Type { get; set; } - - [JsonProperty("properties")] - [JsonConverter(typeof(DevicePropertiesConverter))] - public JToken Properties { get; set; } - - public DeviceConfig(DeviceConfig dc) - { - Key = dc.Key; - Uid = dc.Uid; - Name = dc.Name; - Group = dc.Group; - Type = dc.Type; - - Properties = JToken.Parse(dc.Properties.ToString()); - - //Properties = JToken.FromObject(dc.Properties); - } - - public DeviceConfig() {} - } - - /// - /// - /// - public class DevicePropertiesConverter : JsonConverter - { - - public override bool CanConvert(Type objectType) - { - return objectType == typeof(JToken); - } - - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) - { - return JToken.ReadFrom(reader); - } - - public override bool CanWrite - { - get - { - return false; - } - } - - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - throw new NotImplementedException("SOD OFF HOSER"); - } - } +using System; +using System.Collections.Generic; +using Crestron.SimplSharp; +using Crestron.SimplSharp.CrestronIO; +using Crestron.SimplSharpPro; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PepperDash.Core; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Core.Config +{ + public class DeviceConfig + { + [JsonProperty("key")] + public string Key { get; set; } + + [JsonProperty("uid")] + public int Uid { get; set; } + + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("group")] + public string Group { get; set; } + + [JsonProperty("type")] + public string Type { get; set; } + + [JsonProperty("properties")] + [JsonConverter(typeof(DevicePropertiesConverter))] + public JToken Properties { get; set; } + + public DeviceConfig(DeviceConfig dc) + { + Key = dc.Key; + Uid = dc.Uid; + Name = dc.Name; + Group = dc.Group; + Type = dc.Type; + + Properties = JToken.Parse(dc.Properties.ToString()); + + //Properties = JToken.FromObject(dc.Properties); + } + + public DeviceConfig() {} + } + + /// + /// + /// + public class DevicePropertiesConverter : JsonConverter + { + + public override bool CanConvert(Type objectType) + { + return objectType == typeof(JToken); + } + + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + return JToken.ReadFrom(reader); + } + + public override bool CanWrite + { + get + { + return false; + } + } + + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + throw new NotImplementedException("SOD OFF HOSER"); + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigReader.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigReader.cs similarity index 97% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigReader.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigReader.cs index e99206e8..c9cec345 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigReader.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigReader.cs @@ -1,254 +1,254 @@ -using System; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharp.CrestronIO; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using PepperDash.Core; -using PepperDash.Core.Config; - -namespace PepperDash.Essentials.Core.Config -{ - /// - /// Loads the ConfigObject from the file - /// - public class ConfigReader - { - public const string LocalConfigPresent = - @" -*************************************************** -************* Using Local config file ************* -***************************************************"; - - public static EssentialsConfig ConfigObject { get; private set; } - - public static bool LoadConfig2() - { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading unmerged system/template portal configuration file."); - try - { - // Check for local config file first - var filePath = Global.FilePathPrefix + ConfigWriter.LocalConfigFolder + Global.DirectorySeparator + Global.ConfigFileName; - - bool localConfigFound = false; - - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to load Local config file: '{0}'", filePath); - - // Check for local config directory first - - var configFiles = GetConfigFiles(filePath); - - if (configFiles != null) - { - if (configFiles.Length > 1) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, - "****Error: Multiple Local Configuration files present. Please ensure only a single file exists and reset program.****"); - return false; - } - if(configFiles.Length == 1) - { - localConfigFound = true; - - } - } - else - { - Debug.Console(0, Debug.ErrorLogLevel.Notice, - "Local Configuration file not present.", filePath); - - } - - // Check for Portal Config - if(!localConfigFound) - { - filePath = Global.FilePathPrefix + Global.ConfigFileName; - - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to load Portal config file: '{0}'", filePath); - - configFiles = GetConfigFiles(filePath); - - if (configFiles != null) - { - Debug.Console(2, "{0} config files found matching pattern", configFiles.Length); - - if (configFiles.Length > 1) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, - "****Error: Multiple Portal Configuration files present. Please ensure only a single file exists and reset program.****"); - return false; - } - else if (configFiles.Length == 1) - { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Found Portal config file: '{0}'", filePath); - } - else - { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "No config file found."); - return false; - } - } - else - { - Debug.Console(0, Debug.ErrorLogLevel.Error, - "ERROR: Portal Configuration file not present. Please load file and reset program."); - return false; - } - } - - // Get the actual file path - filePath = configFiles[0].FullName; - - // Generate debug statement if using a local file. - if (localConfigFound) - { - GetLocalFileMessage(filePath); - } - - // Read the file - using (StreamReader fs = new StreamReader(filePath)) - { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading config file: '{0}'", filePath); - - if (localConfigFound) - { - ConfigObject = JObject.Parse(fs.ReadToEnd()).ToObject(); - - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Successfully Loaded Local Config"); - - return true; - } - else - { - var doubleObj = JObject.Parse(fs.ReadToEnd()); - ConfigObject = PortalConfigReader.MergeConfigs(doubleObj).ToObject(); - - // Extract SystemUrl and TemplateUrl into final config output - - if (doubleObj["system_url"] != null) - { - ConfigObject.SystemUrl = doubleObj["system_url"].Value(); - } - - if (doubleObj["template_url"] != null) - { - ConfigObject.TemplateUrl = doubleObj["template_url"].Value(); - } - } - - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Successfully Loaded Merged Config"); - - return true; - } - } - catch (Exception e) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, "ERROR: Config load failed: \r{0}", e); - return false; - } - } - - /// - /// Returns all the files from the directory specified. - /// - /// - /// - public static FileInfo[] GetConfigFiles(string filePath) - { - // Get the directory - var dir = Path.GetDirectoryName(filePath); - - if (Directory.Exists(dir)) - { - Debug.Console(1, "Searching in Directory '{0}'", dir); - // Get the directory info - var dirInfo = new DirectoryInfo(dir); - - // Get the file name - var fileName = Path.GetFileName(filePath); - Debug.Console(1, "For Config Files matching: '{0}'", fileName); - - // Get the files that match from the directory - return dirInfo.GetFiles(fileName); - } - else - { - Debug.Console(0, Debug.ErrorLogLevel.Notice, - "Directory not found: ", dir); - - return null; - } - } - - /// - /// Returns the group for a given device key in config - /// - /// - /// - public static string GetGroupForDeviceKey(string key) - { - var dev = ConfigObject.Devices.FirstOrDefault(d => d.Key.Equals(key, StringComparison.OrdinalIgnoreCase)); - return dev == null ? null : dev.Group; - } - - private static void GetLocalFileMessage(string filePath) - { - var filePathLength = filePath.Length + 2; - var debugStringWidth = filePathLength + 12; - - if (debugStringWidth < 51) - { - debugStringWidth = 51; - } - var qualifier = (filePathLength % 2 != 0) - ? " Using Local Config File " - : " Using Local Config File "; - var bookend1 = (debugStringWidth - qualifier.Length) / 2; - var bookend2 = (debugStringWidth - filePathLength) / 2; - - - var newDebugString = new StringBuilder() - .Append(CrestronEnvironment.NewLine) - // Line 1 - .Append(new string('*', debugStringWidth)) - .Append(CrestronEnvironment.NewLine) - // Line 2 - .Append(new string('*', debugStringWidth)) - .Append(CrestronEnvironment.NewLine) - // Line 3 - .Append(new string('*', 2)) - .Append(new string(' ', debugStringWidth - 4)) - .Append(new string('*', 2)) - .Append(CrestronEnvironment.NewLine) - // Line 4 - .Append(new string('*', 2)) - .Append(new string(' ', bookend1 - 2)) - .Append(qualifier) - .Append(new string(' ', bookend1 - 2)) - .Append(new string('*', 2)) - .Append(CrestronEnvironment.NewLine) - // Line 5 - .Append(new string('*', 2)) - .Append(new string(' ', bookend2 - 2)) - .Append(" " + filePath + " ") - .Append(new string(' ', bookend2 - 2)) - .Append(new string('*', 2)) - .Append(CrestronEnvironment.NewLine) - // Line 6 - .Append(new string('*', 2)) - .Append(new string(' ', debugStringWidth - 4)) - .Append(new string('*', 2)) - .Append(CrestronEnvironment.NewLine) - // Line 7 - .Append(new string('*', debugStringWidth)) - .Append(CrestronEnvironment.NewLine) - // Line 8 - .Append(new string('*', debugStringWidth)); - - Debug.Console(2, Debug.ErrorLogLevel.Notice, "Found Local config file: '{0}'", filePath); - Debug.Console(0, newDebugString.ToString()); - } - - } +using System; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharp.CrestronIO; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PepperDash.Core; +using PepperDash.Core.Config; + +namespace PepperDash.Essentials.Core.Config +{ + /// + /// Loads the ConfigObject from the file + /// + public class ConfigReader + { + public const string LocalConfigPresent = + @" +*************************************************** +************* Using Local config file ************* +***************************************************"; + + public static EssentialsConfig ConfigObject { get; private set; } + + public static bool LoadConfig2() + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading unmerged system/template portal configuration file."); + try + { + // Check for local config file first + var filePath = Global.FilePathPrefix + ConfigWriter.LocalConfigFolder + Global.DirectorySeparator + Global.ConfigFileName; + + bool localConfigFound = false; + + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to load Local config file: '{0}'", filePath); + + // Check for local config directory first + + var configFiles = GetConfigFiles(filePath); + + if (configFiles != null) + { + if (configFiles.Length > 1) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, + "****Error: Multiple Local Configuration files present. Please ensure only a single file exists and reset program.****"); + return false; + } + if(configFiles.Length == 1) + { + localConfigFound = true; + + } + } + else + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, + "Local Configuration file not present.", filePath); + + } + + // Check for Portal Config + if(!localConfigFound) + { + filePath = Global.FilePathPrefix + Global.ConfigFileName; + + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to load Portal config file: '{0}'", filePath); + + configFiles = GetConfigFiles(filePath); + + if (configFiles != null) + { + Debug.Console(2, "{0} config files found matching pattern", configFiles.Length); + + if (configFiles.Length > 1) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, + "****Error: Multiple Portal Configuration files present. Please ensure only a single file exists and reset program.****"); + return false; + } + else if (configFiles.Length == 1) + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Found Portal config file: '{0}'", filePath); + } + else + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "No config file found."); + return false; + } + } + else + { + Debug.Console(0, Debug.ErrorLogLevel.Error, + "ERROR: Portal Configuration file not present. Please load file and reset program."); + return false; + } + } + + // Get the actual file path + filePath = configFiles[0].FullName; + + // Generate debug statement if using a local file. + if (localConfigFound) + { + GetLocalFileMessage(filePath); + } + + // Read the file + using (StreamReader fs = new StreamReader(filePath)) + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading config file: '{0}'", filePath); + + if (localConfigFound) + { + ConfigObject = JObject.Parse(fs.ReadToEnd()).ToObject(); + + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Successfully Loaded Local Config"); + + return true; + } + else + { + var doubleObj = JObject.Parse(fs.ReadToEnd()); + ConfigObject = PortalConfigReader.MergeConfigs(doubleObj).ToObject(); + + // Extract SystemUrl and TemplateUrl into final config output + + if (doubleObj["system_url"] != null) + { + ConfigObject.SystemUrl = doubleObj["system_url"].Value(); + } + + if (doubleObj["template_url"] != null) + { + ConfigObject.TemplateUrl = doubleObj["template_url"].Value(); + } + } + + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Successfully Loaded Merged Config"); + + return true; + } + } + catch (Exception e) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "ERROR: Config load failed: \r{0}", e); + return false; + } + } + + /// + /// Returns all the files from the directory specified. + /// + /// + /// + public static FileInfo[] GetConfigFiles(string filePath) + { + // Get the directory + var dir = Path.GetDirectoryName(filePath); + + if (Directory.Exists(dir)) + { + Debug.Console(1, "Searching in Directory '{0}'", dir); + // Get the directory info + var dirInfo = new DirectoryInfo(dir); + + // Get the file name + var fileName = Path.GetFileName(filePath); + Debug.Console(1, "For Config Files matching: '{0}'", fileName); + + // Get the files that match from the directory + return dirInfo.GetFiles(fileName); + } + else + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, + "Directory not found: ", dir); + + return null; + } + } + + /// + /// Returns the group for a given device key in config + /// + /// + /// + public static string GetGroupForDeviceKey(string key) + { + var dev = ConfigObject.Devices.FirstOrDefault(d => d.Key.Equals(key, StringComparison.OrdinalIgnoreCase)); + return dev == null ? null : dev.Group; + } + + private static void GetLocalFileMessage(string filePath) + { + var filePathLength = filePath.Length + 2; + var debugStringWidth = filePathLength + 12; + + if (debugStringWidth < 51) + { + debugStringWidth = 51; + } + var qualifier = (filePathLength % 2 != 0) + ? " Using Local Config File " + : " Using Local Config File "; + var bookend1 = (debugStringWidth - qualifier.Length) / 2; + var bookend2 = (debugStringWidth - filePathLength) / 2; + + + var newDebugString = new StringBuilder() + .Append(CrestronEnvironment.NewLine) + // Line 1 + .Append(new string('*', debugStringWidth)) + .Append(CrestronEnvironment.NewLine) + // Line 2 + .Append(new string('*', debugStringWidth)) + .Append(CrestronEnvironment.NewLine) + // Line 3 + .Append(new string('*', 2)) + .Append(new string(' ', debugStringWidth - 4)) + .Append(new string('*', 2)) + .Append(CrestronEnvironment.NewLine) + // Line 4 + .Append(new string('*', 2)) + .Append(new string(' ', bookend1 - 2)) + .Append(qualifier) + .Append(new string(' ', bookend1 - 2)) + .Append(new string('*', 2)) + .Append(CrestronEnvironment.NewLine) + // Line 5 + .Append(new string('*', 2)) + .Append(new string(' ', bookend2 - 2)) + .Append(" " + filePath + " ") + .Append(new string(' ', bookend2 - 2)) + .Append(new string('*', 2)) + .Append(CrestronEnvironment.NewLine) + // Line 6 + .Append(new string('*', 2)) + .Append(new string(' ', debugStringWidth - 4)) + .Append(new string('*', 2)) + .Append(CrestronEnvironment.NewLine) + // Line 7 + .Append(new string('*', debugStringWidth)) + .Append(CrestronEnvironment.NewLine) + // Line 8 + .Append(new string('*', debugStringWidth)); + + Debug.Console(2, Debug.ErrorLogLevel.Notice, "Found Local config file: '{0}'", filePath); + Debug.Console(0, newDebugString.ToString()); + } + + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigUpdater.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigUpdater.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigUpdater.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigUpdater.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigWriter.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigWriter.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigWriter.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigWriter.cs index c6224859..30c0244c 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigWriter.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigWriter.cs @@ -1,162 +1,162 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharp.CrestronIO; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using PepperDash.Core; - -namespace PepperDash.Essentials.Core.Config -{ - /// - /// Responsible for updating config at runtime, and writing the updates out to a local file - /// - public class ConfigWriter - { - public const string LocalConfigFolder = "LocalConfig"; - - public const long WriteTimeout = 30000; - - public static CTimer WriteTimer; - static CCriticalSection fileLock = new CCriticalSection(); - - /// - /// Updates the config properties of a device - /// - /// - /// - /// - public static bool UpdateDeviceProperties(string deviceKey, JToken properties) - { - bool success = false; - - // Get the current device config - var deviceConfig = ConfigReader.ConfigObject.Devices.FirstOrDefault(d => d.Key.Equals(deviceKey)); - - if (deviceConfig != null) - { - // Replace the current properties JToken with the new one passed into this method - deviceConfig.Properties = properties; - - Debug.Console(1, "Updated properties of device: '{0}'", deviceKey); - - success = true; - } - - ResetTimer(); - - return success; - } - - public static bool UpdateDeviceConfig(DeviceConfig config) - { - bool success = false; - - var deviceConfigIndex = ConfigReader.ConfigObject.Devices.FindIndex(d => d.Key.Equals(config.Key)); - - if (deviceConfigIndex >= 0) - { - ConfigReader.ConfigObject.Devices[deviceConfigIndex] = config; - - Debug.Console(1, "Updated config of device: '{0}'", config.Key); - - success = true; - } - - ResetTimer(); - - return success; - } - - public static bool UpdateRoomConfig(DeviceConfig config) - { - bool success = false; - - var roomConfigIndex = ConfigReader.ConfigObject.Rooms.FindIndex(d => d.Key.Equals(config.Key)); - - if (roomConfigIndex >= 0) - { - ConfigReader.ConfigObject.Rooms[roomConfigIndex] = config; - - Debug.Console(1, "Updated room of device: '{0}'", config.Key); - - success = true; - } - - ResetTimer(); - - return success; - } - - /// - /// Resets (or starts) the write timer - /// - static void ResetTimer() - { - if (WriteTimer == null) - WriteTimer = new CTimer(WriteConfigFile, WriteTimeout); - - WriteTimer.Reset(WriteTimeout); - - Debug.Console(1, "Config File write timer has been reset."); - } - - /// - /// Writes the current config to a file in the LocalConfig subfolder - /// - /// - private static void WriteConfigFile(object o) - { - var filePath = Global.FilePathPrefix + LocalConfigFolder + Global.DirectorySeparator + "configurationFile.json"; - - var configData = JsonConvert.SerializeObject(ConfigReader.ConfigObject); - - WriteFile(filePath, configData); - } - - /// - /// Writes - /// - /// - /// - public static void WriteFile(string filePath, string configData) - { - if (WriteTimer != null) - WriteTimer.Stop(); - - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Writing Configuration to file"); - - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to write config file: '{0}'", filePath); - - try - { - if (fileLock.TryEnter()) - { - using (StreamWriter sw = new StreamWriter(filePath)) - { - sw.Write(configData); - sw.Flush(); - } - } - else - { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to enter FileLock"); - } - } - catch (Exception e) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: Config write failed: \r{0}", e); - } - finally - { - if (fileLock != null && !fileLock.Disposed) - fileLock.Leave(); - - } - } - - - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharp.CrestronIO; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PepperDash.Core; + +namespace PepperDash.Essentials.Core.Config +{ + /// + /// Responsible for updating config at runtime, and writing the updates out to a local file + /// + public class ConfigWriter + { + public const string LocalConfigFolder = "LocalConfig"; + + public const long WriteTimeout = 30000; + + public static CTimer WriteTimer; + static CCriticalSection fileLock = new CCriticalSection(); + + /// + /// Updates the config properties of a device + /// + /// + /// + /// + public static bool UpdateDeviceProperties(string deviceKey, JToken properties) + { + bool success = false; + + // Get the current device config + var deviceConfig = ConfigReader.ConfigObject.Devices.FirstOrDefault(d => d.Key.Equals(deviceKey)); + + if (deviceConfig != null) + { + // Replace the current properties JToken with the new one passed into this method + deviceConfig.Properties = properties; + + Debug.Console(1, "Updated properties of device: '{0}'", deviceKey); + + success = true; + } + + ResetTimer(); + + return success; + } + + public static bool UpdateDeviceConfig(DeviceConfig config) + { + bool success = false; + + var deviceConfigIndex = ConfigReader.ConfigObject.Devices.FindIndex(d => d.Key.Equals(config.Key)); + + if (deviceConfigIndex >= 0) + { + ConfigReader.ConfigObject.Devices[deviceConfigIndex] = config; + + Debug.Console(1, "Updated config of device: '{0}'", config.Key); + + success = true; + } + + ResetTimer(); + + return success; + } + + public static bool UpdateRoomConfig(DeviceConfig config) + { + bool success = false; + + var roomConfigIndex = ConfigReader.ConfigObject.Rooms.FindIndex(d => d.Key.Equals(config.Key)); + + if (roomConfigIndex >= 0) + { + ConfigReader.ConfigObject.Rooms[roomConfigIndex] = config; + + Debug.Console(1, "Updated room of device: '{0}'", config.Key); + + success = true; + } + + ResetTimer(); + + return success; + } + + /// + /// Resets (or starts) the write timer + /// + static void ResetTimer() + { + if (WriteTimer == null) + WriteTimer = new CTimer(WriteConfigFile, WriteTimeout); + + WriteTimer.Reset(WriteTimeout); + + Debug.Console(1, "Config File write timer has been reset."); + } + + /// + /// Writes the current config to a file in the LocalConfig subfolder + /// + /// + private static void WriteConfigFile(object o) + { + var filePath = Global.FilePathPrefix + LocalConfigFolder + Global.DirectorySeparator + "configurationFile.json"; + + var configData = JsonConvert.SerializeObject(ConfigReader.ConfigObject); + + WriteFile(filePath, configData); + } + + /// + /// Writes + /// + /// + /// + public static void WriteFile(string filePath, string configData) + { + if (WriteTimer != null) + WriteTimer.Stop(); + + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Writing Configuration to file"); + + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to write config file: '{0}'", filePath); + + try + { + if (fileLock.TryEnter()) + { + using (StreamWriter sw = new StreamWriter(filePath)) + { + sw.Write(configData); + sw.Flush(); + } + } + else + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to enter FileLock"); + } + } + catch (Exception e) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: Config write failed: \r{0}", e); + } + finally + { + if (fileLock != null && !fileLock.Disposed) + fileLock.Leave(); + + } + } + + + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/EssentialsConfig.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/EssentialsConfig.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/EssentialsConfig.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/EssentialsConfig.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/InfoConfig.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/InfoConfig.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/InfoConfig.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/InfoConfig.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/SourceDevicePropertiesConfigBase.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/SourceDevicePropertiesConfigBase.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/SourceDevicePropertiesConfigBase.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/SourceDevicePropertiesConfigBase.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/C2nIo/C2nIoController.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/C2nIo/C2nIoController.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/C2nIo/C2nIoController.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/C2nIo/C2nIoController.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/C2nRts/C2nRthsController.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/C2nRts/C2nRthsController.cs similarity index 97% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/C2nRts/C2nRthsController.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/C2nRts/C2nRthsController.cs index e1aa545e..803e466b 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/C2nRts/C2nRthsController.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/C2nRts/C2nRthsController.cs @@ -1,148 +1,148 @@ -using System; -using System.Collections.Generic; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.GeneralIO; -using Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Config; - - -namespace PepperDash.Essentials.Core.CrestronIO -{ - [Description("Wrapper class for the C2N-RTHS sensor")] - public class C2nRthsController : CrestronGenericBridgeableBaseDevice - { - private C2nRths _device; - - public IntFeedback TemperatureFeedback { get; private set; } - public IntFeedback HumidityFeedback { get; private set; } - - public C2nRthsController(string key, Func preActivationFunc, - DeviceConfig config) - : base(key, config.Name) - { - - AddPreActivationAction(() => - { - _device = preActivationFunc(config); - - RegisterCrestronGenericBase(_device); - - TemperatureFeedback = new IntFeedback(() => _device.TemperatureFeedback.UShortValue); - HumidityFeedback = new IntFeedback(() => _device.HumidityFeedback.UShortValue); - - if (_device != null) _device.BaseEvent += DeviceOnBaseEvent; - }); - } - - - private void DeviceOnBaseEvent(GenericBase device, BaseEventArgs args) - { - switch (args.EventId) - { - case C2nRths.TemperatureFeedbackEventId: - TemperatureFeedback.FireUpdate(); - break; - case C2nRths.HumidityFeedbackEventId: - HumidityFeedback.FireUpdate(); - break; - } - } - - public void SetTemperatureFormat(bool setToC) - { - _device.TemperatureFormat.BoolValue = setToC; - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new C2nRthsControllerJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - - trilist.SetBoolSigAction(joinMap.TemperatureFormat.JoinNumber, SetTemperatureFormat); - - - - IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - TemperatureFeedback.LinkInputSig(trilist.UShortInput[joinMap.Temperature.JoinNumber]); - HumidityFeedback.LinkInputSig(trilist.UShortInput[joinMap.Humidity.JoinNumber]); - - trilist.StringInput[joinMap.Name.JoinNumber].StringValue = Name; - - trilist.OnlineStatusChange += (d, args) => - { - if (!args.DeviceOnLine) return; - - UpdateFeedbacksWhenOnline(); - - trilist.StringInput[joinMap.Name.JoinNumber].StringValue = Name; - }; - } - - private void UpdateFeedbacksWhenOnline() - { - IsOnline.FireUpdate(); - TemperatureFeedback.FireUpdate(); - HumidityFeedback.FireUpdate(); - } - - #region PreActivation - - private static C2nRths GetC2nRthsDevice(DeviceConfig dc) - { - var control = CommFactory.GetControlPropertiesConfig(dc); - var cresnetId = control.CresnetIdInt; - var branchId = control.ControlPortNumber; - var parentKey = string.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey; - - if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase)) - { - Debug.Console(0, "Device {0} is a valid cresnet master - creating new C2nRths", parentKey); - return new C2nRths(cresnetId, Global.ControlSystem); - } - var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches; - - if (cresnetBridge != null) - { - Debug.Console(0, "Device {0} is a valid cresnet master - creating new C2nRths", parentKey); - return new C2nRths(cresnetId, cresnetBridge.CresnetBranches[branchId]); - } - Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); - return null; - } - #endregion - - public class C2nRthsControllerFactory : EssentialsDeviceFactory - { - public C2nRthsControllerFactory() - { - TypeNames = new List() { "c2nrths" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new C2N-RTHS Device"); - - return new C2nRthsController(dc.Key, GetC2nRthsDevice, dc); - } - } - } +using System; +using System.Collections.Generic; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.GeneralIO; +using Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Config; + + +namespace PepperDash.Essentials.Core.CrestronIO +{ + [Description("Wrapper class for the C2N-RTHS sensor")] + public class C2nRthsController : CrestronGenericBridgeableBaseDevice + { + private C2nRths _device; + + public IntFeedback TemperatureFeedback { get; private set; } + public IntFeedback HumidityFeedback { get; private set; } + + public C2nRthsController(string key, Func preActivationFunc, + DeviceConfig config) + : base(key, config.Name) + { + + AddPreActivationAction(() => + { + _device = preActivationFunc(config); + + RegisterCrestronGenericBase(_device); + + TemperatureFeedback = new IntFeedback(() => _device.TemperatureFeedback.UShortValue); + HumidityFeedback = new IntFeedback(() => _device.HumidityFeedback.UShortValue); + + if (_device != null) _device.BaseEvent += DeviceOnBaseEvent; + }); + } + + + private void DeviceOnBaseEvent(GenericBase device, BaseEventArgs args) + { + switch (args.EventId) + { + case C2nRths.TemperatureFeedbackEventId: + TemperatureFeedback.FireUpdate(); + break; + case C2nRths.HumidityFeedbackEventId: + HumidityFeedback.FireUpdate(); + break; + } + } + + public void SetTemperatureFormat(bool setToC) + { + _device.TemperatureFormat.BoolValue = setToC; + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new C2nRthsControllerJoinMap(joinStart); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + else + { + Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + } + + Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + + trilist.SetBoolSigAction(joinMap.TemperatureFormat.JoinNumber, SetTemperatureFormat); + + + + IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + TemperatureFeedback.LinkInputSig(trilist.UShortInput[joinMap.Temperature.JoinNumber]); + HumidityFeedback.LinkInputSig(trilist.UShortInput[joinMap.Humidity.JoinNumber]); + + trilist.StringInput[joinMap.Name.JoinNumber].StringValue = Name; + + trilist.OnlineStatusChange += (d, args) => + { + if (!args.DeviceOnLine) return; + + UpdateFeedbacksWhenOnline(); + + trilist.StringInput[joinMap.Name.JoinNumber].StringValue = Name; + }; + } + + private void UpdateFeedbacksWhenOnline() + { + IsOnline.FireUpdate(); + TemperatureFeedback.FireUpdate(); + HumidityFeedback.FireUpdate(); + } + + #region PreActivation + + private static C2nRths GetC2nRthsDevice(DeviceConfig dc) + { + var control = CommFactory.GetControlPropertiesConfig(dc); + var cresnetId = control.CresnetIdInt; + var branchId = control.ControlPortNumber; + var parentKey = string.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey; + + if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase)) + { + Debug.Console(0, "Device {0} is a valid cresnet master - creating new C2nRths", parentKey); + return new C2nRths(cresnetId, Global.ControlSystem); + } + var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches; + + if (cresnetBridge != null) + { + Debug.Console(0, "Device {0} is a valid cresnet master - creating new C2nRths", parentKey); + return new C2nRths(cresnetId, cresnetBridge.CresnetBranches[branchId]); + } + Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); + return null; + } + #endregion + + public class C2nRthsControllerFactory : EssentialsDeviceFactory + { + public C2nRthsControllerFactory() + { + TypeNames = new List() { "c2nrths" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new C2N-RTHS Device"); + + return new C2nRthsController(dc.Key, GetC2nRthsDevice, dc); + } + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3CardControllerBase.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3CardControllerBase.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3CardControllerBase.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3CardControllerBase.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Com3Controller.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Com3Controller.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Com3Controller.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Com3Controller.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Io16Controller.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Io16Controller.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Io16Controller.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Io16Controller.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Ir8Controller.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Ir8Controller.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Ir8Controller.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Ir8Controller.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Ry16Controller.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Ry16Controller.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Ry16Controller.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Ry16Controller.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Ry8Controller.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Ry8Controller.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Ry8Controller.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Ry8Controller.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/CenCi31Controller.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/CenCi31Controller.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/CenCi31Controller.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/CenCi31Controller.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/CenCi33Controller.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/CenCi33Controller.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/CenCi33Controller.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/CenCi33Controller.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/InternalCardCageController.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/InternalCardCageController.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/InternalCardCageController.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/InternalCardCageController.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/CenIoCom/CenIoComController.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/CenIoCom/CenIoComController.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/CenIoCom/CenIoComController.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/CenIoCom/CenIoComController.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/DinCenCnController.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/DinCenCnController.cs similarity index 97% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/DinCenCnController.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/DinCenCnController.cs index 7e9179fe..414b5432 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/DinCenCnController.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/DinCenCnController.cs @@ -1,51 +1,51 @@ -using System.Collections.Generic; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.GeneralIO; -using PepperDash.Core; -using PepperDash.Essentials.Core.Config; - - -namespace PepperDash.Essentials.Core -{ - public class DinCenCn2Controller : CrestronGenericBaseDevice, IHasCresnetBranches - { - private readonly DinCenCn2 _device; - - public CrestronCollection CresnetBranches - { - get { - return _device != null ? _device.Branches : null; - } - } - - public DinCenCn2Controller(string key, string name, DinCenCn2 device, DeviceConfig config) - : base(key, name, device) - { - _device = device; - } - - public class DinCenCn2ControllerFactory : EssentialsDeviceFactory - { - public DinCenCn2ControllerFactory() - { - TypeNames = new List() { "dincencn2", "dincencn2poe", "din-cencn2", "din-cencn2-poe" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new DIN-CEN-CN2 Device"); - - var control = CommFactory.GetControlPropertiesConfig(dc); - var ipid = control.IpIdInt; - - if (dc.Type.ToLower().Contains("poe")) - { - return new DinCenCn2Controller(dc.Key, dc.Name, new DinCenCn2Poe(ipid, Global.ControlSystem), dc); - } - - return new DinCenCn2Controller(dc.Key, dc.Name, new DinCenCn2(ipid, Global.ControlSystem), dc); - } - } - } +using System.Collections.Generic; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.GeneralIO; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + + +namespace PepperDash.Essentials.Core +{ + public class DinCenCn2Controller : CrestronGenericBaseDevice, IHasCresnetBranches + { + private readonly DinCenCn2 _device; + + public CrestronCollection CresnetBranches + { + get { + return _device != null ? _device.Branches : null; + } + } + + public DinCenCn2Controller(string key, string name, DinCenCn2 device, DeviceConfig config) + : base(key, name, device) + { + _device = device; + } + + public class DinCenCn2ControllerFactory : EssentialsDeviceFactory + { + public DinCenCn2ControllerFactory() + { + TypeNames = new List() { "dincencn2", "dincencn2poe", "din-cencn2", "din-cencn2-poe" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new DIN-CEN-CN2 Device"); + + var control = CommFactory.GetControlPropertiesConfig(dc); + var ipid = control.IpIdInt; + + if (dc.Type.ToLower().Contains("poe")) + { + return new DinCenCn2Controller(dc.Key, dc.Name, new DinCenCn2Poe(ipid, Global.ControlSystem), dc); + } + + return new DinCenCn2Controller(dc.Key, dc.Name, new DinCenCn2(ipid, Global.ControlSystem), dc); + } + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/IHasCresnetBranches.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/IHasCresnetBranches.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/IHasCresnetBranches.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/IHasCresnetBranches.cs index 11e1b707..a13aca1a 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/IHasCresnetBranches.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/IHasCresnetBranches.cs @@ -1,15 +1,15 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; - -namespace PepperDash.Essentials.Core -{ - public interface IHasCresnetBranches - { - CrestronCollection CresnetBranches { get; } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; + +namespace PepperDash.Essentials.Core +{ + public interface IHasCresnetBranches + { + CrestronCollection CresnetBranches { get; } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinIo8/DinIo8Controller.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinIo8/DinIo8Controller.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinIo8/DinIo8Controller.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinIo8/DinIo8Controller.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/IOPortConfig.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/IOPortConfig.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/IOPortConfig.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/IOPortConfig.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/CenIoDigIn104Controller.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/CenIoDigIn104Controller.cs similarity index 99% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/CenIoDigIn104Controller.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/CenIoDigIn104Controller.cs index bdbcc2e9..50647126 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/CenIoDigIn104Controller.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/CenIoDigIn104Controller.cs @@ -52,16 +52,16 @@ namespace PepperDash.Essentials.Core { Debug.Console(1, "Factory Attempting to create new CEN-DIGIN-104 Device"); - var control = CommFactory.GetControlPropertiesConfig(dc); - if (control == null) - { - Debug.Console(1, "Factory failed to create a new CEN-DIGIN-104 Device, control properties not found"); - return null; + var control = CommFactory.GetControlPropertiesConfig(dc); + if (control == null) + { + Debug.Console(1, "Factory failed to create a new CEN-DIGIN-104 Device, control properties not found"); + return null; } - var ipid = control.IpIdInt; - if (ipid != 0) return new CenIoDigIn104Controller(dc.Key, dc.Name, new CenIoDi104(ipid, Global.ControlSystem)); - - Debug.Console(1, "Factory failed to create a new CEN-IO-IR-104 Device using IP-ID-{0}", ipid); + var ipid = control.IpIdInt; + if (ipid != 0) return new CenIoDigIn104Controller(dc.Key, dc.Name, new CenIoDi104(ipid, Global.ControlSystem)); + + Debug.Console(1, "Factory failed to create a new CEN-IO-IR-104 Device using IP-ID-{0}", ipid); return null; } } diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericDigitalInputDevice.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericDigitalInputDevice.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericDigitalInputDevice.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericDigitalInputDevice.cs index db905bfa..72210429 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericDigitalInputDevice.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericDigitalInputDevice.cs @@ -1,165 +1,165 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Config; - - -namespace PepperDash.Essentials.Core.CrestronIO -{ - [Description("Wrapper class for Digital Input")] - public class GenericDigitalInputDevice : EssentialsBridgeableDevice, IDigitalInput - { - public DigitalInput InputPort { get; private set; } - - public BoolFeedback InputStateFeedback { get; private set; } - - Func InputStateFeedbackFunc - { - get - { - return () => InputPort.State; - } - } - - - public GenericDigitalInputDevice(string key, string name, Func postActivationFunc, - IOPortConfig config) - : base(key, name) - { - InputStateFeedback = new BoolFeedback(InputStateFeedbackFunc); - - AddPostActivationAction(() => - { - InputPort = postActivationFunc(config); - - InputPort.Register(); - - InputPort.StateChange += InputPort_StateChange; - - }); - } - - #region Events - - void InputPort_StateChange(DigitalInput digitalInput, DigitalInputEventArgs args) - { - InputStateFeedback.FireUpdate(); - } - - #endregion - - #region PreActivate - - private static DigitalInput GetDigitalInput(IOPortConfig dc) - { - IDigitalInputPorts ioPortDevice; - - if (dc.PortDeviceKey.Equals("processor")) - { - if (!Global.ControlSystem.SupportsDigitalInput) - { - Debug.Console(0, "GetDigitalInput: Processor does not support Digital Inputs"); - return null; - } - ioPortDevice = Global.ControlSystem; - } - else - { - var ioPortDev = DeviceManager.GetDeviceForKey(dc.PortDeviceKey) as IDigitalInputPorts; - if (ioPortDev == null) - { - Debug.Console(0, "GetDigitalInput: Device {0} is not a valid device", dc.PortDeviceKey); - return null; - } - ioPortDevice = ioPortDev; - } - if (ioPortDevice == null) - { - Debug.Console(0, "GetDigitalInput: Device '0' is not a valid IDigitalInputPorts Device", dc.PortDeviceKey); - return null; - } - - if (dc.PortNumber > ioPortDevice.NumberOfDigitalInputPorts) - { - Debug.Console(0, "GetDigitalInput: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber); - } - - return ioPortDevice.DigitalInputPorts[dc.PortNumber]; - - - } - - #endregion - - #region Bridge Linking - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new IDigitalInputJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - try - { - Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - // Link feedback for input state - InputStateFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputState.JoinNumber]); - } - catch (Exception e) - { - Debug.Console(1, this, "Unable to link device '{0}'. Input is null", Key); - Debug.Console(1, this, "Error: {0}", e); - } - } - - #endregion - - #region Factory - - public class GenericDigitalInputDeviceFactory : EssentialsDeviceFactory - { - public GenericDigitalInputDeviceFactory() - { - TypeNames = new List() { "digitalinput" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new Generic Digital Input Device"); - - var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); - - if (props == null) return null; - - var portDevice = new GenericDigitalInputDevice(dc.Key, dc.Name, GetDigitalInput, props); - - return portDevice; - } - } - - #endregion - - } - - +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Config; + + +namespace PepperDash.Essentials.Core.CrestronIO +{ + [Description("Wrapper class for Digital Input")] + public class GenericDigitalInputDevice : EssentialsBridgeableDevice, IDigitalInput + { + public DigitalInput InputPort { get; private set; } + + public BoolFeedback InputStateFeedback { get; private set; } + + Func InputStateFeedbackFunc + { + get + { + return () => InputPort.State; + } + } + + + public GenericDigitalInputDevice(string key, string name, Func postActivationFunc, + IOPortConfig config) + : base(key, name) + { + InputStateFeedback = new BoolFeedback(InputStateFeedbackFunc); + + AddPostActivationAction(() => + { + InputPort = postActivationFunc(config); + + InputPort.Register(); + + InputPort.StateChange += InputPort_StateChange; + + }); + } + + #region Events + + void InputPort_StateChange(DigitalInput digitalInput, DigitalInputEventArgs args) + { + InputStateFeedback.FireUpdate(); + } + + #endregion + + #region PreActivate + + private static DigitalInput GetDigitalInput(IOPortConfig dc) + { + IDigitalInputPorts ioPortDevice; + + if (dc.PortDeviceKey.Equals("processor")) + { + if (!Global.ControlSystem.SupportsDigitalInput) + { + Debug.Console(0, "GetDigitalInput: Processor does not support Digital Inputs"); + return null; + } + ioPortDevice = Global.ControlSystem; + } + else + { + var ioPortDev = DeviceManager.GetDeviceForKey(dc.PortDeviceKey) as IDigitalInputPorts; + if (ioPortDev == null) + { + Debug.Console(0, "GetDigitalInput: Device {0} is not a valid device", dc.PortDeviceKey); + return null; + } + ioPortDevice = ioPortDev; + } + if (ioPortDevice == null) + { + Debug.Console(0, "GetDigitalInput: Device '0' is not a valid IDigitalInputPorts Device", dc.PortDeviceKey); + return null; + } + + if (dc.PortNumber > ioPortDevice.NumberOfDigitalInputPorts) + { + Debug.Console(0, "GetDigitalInput: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber); + } + + return ioPortDevice.DigitalInputPorts[dc.PortNumber]; + + + } + + #endregion + + #region Bridge Linking + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new IDigitalInputJoinMap(joinStart); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + else + { + Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + } + + try + { + Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + // Link feedback for input state + InputStateFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputState.JoinNumber]); + } + catch (Exception e) + { + Debug.Console(1, this, "Unable to link device '{0}'. Input is null", Key); + Debug.Console(1, this, "Error: {0}", e); + } + } + + #endregion + + #region Factory + + public class GenericDigitalInputDeviceFactory : EssentialsDeviceFactory + { + public GenericDigitalInputDeviceFactory() + { + TypeNames = new List() { "digitalinput" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Generic Digital Input Device"); + + var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); + + if (props == null) return null; + + var portDevice = new GenericDigitalInputDevice(dc.Key, dc.Name, GetDigitalInput, props); + + return portDevice; + } + } + + #endregion + + } + + } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericVersiportAnalogInputDevice.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericVersiportAnalogInputDevice.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericVersiportAnalogInputDevice.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericVersiportAnalogInputDevice.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericVersiportInputDevice.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericVersiportInputDevice.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericVersiportInputDevice.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericVersiportInputDevice.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/IAnalogInput.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/IAnalogInput.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/IAnalogInput.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/IAnalogInput.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/IDigitalInput.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/IDigitalInput.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/IDigitalInput.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/IDigitalInput.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Ir/CenIoIr104Controller.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Ir/CenIoIr104Controller.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Ir/CenIoIr104Controller.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Ir/CenIoIr104Controller.cs index 3fa45dd7..d994a11c 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Ir/CenIoIr104Controller.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Ir/CenIoIr104Controller.cs @@ -1,93 +1,93 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.GeneralIO; -using PepperDash.Essentials.Core.Config; - - -using PepperDash.Core; - -namespace PepperDash.Essentials.Core -{ - /// - /// Wrapper class for CEN-IO-IR-104 module - /// - [Description("Wrapper class for the CEN-IO-IR-104 module")] - public class CenIoIr104Controller : CrestronGenericBaseDevice, IIROutputPorts - { - private readonly CenIoIr104 _ir104; - - /// - /// Constructor - /// - /// - /// - /// - public CenIoIr104Controller(string key, string name, CenIoIr104 ir104) - : base(key, name, ir104) - { - _ir104 = ir104; - } - - #region IDigitalInputPorts Members - - /// - /// IR port collection - /// - public CrestronCollection IROutputPorts - { - get { return _ir104.IROutputPorts; } - } - - /// - /// Number of relay ports property - /// - public int NumberOfIROutputPorts - { - get { return _ir104.NumberOfIROutputPorts; } - } - - #endregion - } - - /// - /// CEN-IO-IR-104 controller fatory - /// - public class CenIoIr104ControllerFactory : EssentialsDeviceFactory - { - /// - /// Constructor - /// - public CenIoIr104ControllerFactory() - { - TypeNames = new List() { "cenioir104" }; - } - - /// - /// Build device CEN-IO-IR-104 - /// - /// - /// - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new CEN-IO-IR-104 Device"); - - var control = CommFactory.GetControlPropertiesConfig(dc); - if (control == null) - { - Debug.Console(1, "Factory failed to create a new CEN-IO-IR-104 Device, control properties not found"); - return null; - } - - var ipid = control.IpIdInt; - if(ipid != 0) return new CenIoIr104Controller(dc.Key, dc.Name, new CenIoIr104(ipid, Global.ControlSystem)); - - Debug.Console(1, "Factory failed to create a new CEN-IO-IR-104 Device using IP-ID-{0}", ipid); - return null; - } - } - +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.GeneralIO; +using PepperDash.Essentials.Core.Config; + + +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + /// + /// Wrapper class for CEN-IO-IR-104 module + /// + [Description("Wrapper class for the CEN-IO-IR-104 module")] + public class CenIoIr104Controller : CrestronGenericBaseDevice, IIROutputPorts + { + private readonly CenIoIr104 _ir104; + + /// + /// Constructor + /// + /// + /// + /// + public CenIoIr104Controller(string key, string name, CenIoIr104 ir104) + : base(key, name, ir104) + { + _ir104 = ir104; + } + + #region IDigitalInputPorts Members + + /// + /// IR port collection + /// + public CrestronCollection IROutputPorts + { + get { return _ir104.IROutputPorts; } + } + + /// + /// Number of relay ports property + /// + public int NumberOfIROutputPorts + { + get { return _ir104.NumberOfIROutputPorts; } + } + + #endregion + } + + /// + /// CEN-IO-IR-104 controller fatory + /// + public class CenIoIr104ControllerFactory : EssentialsDeviceFactory + { + /// + /// Constructor + /// + public CenIoIr104ControllerFactory() + { + TypeNames = new List() { "cenioir104" }; + } + + /// + /// Build device CEN-IO-IR-104 + /// + /// + /// + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new CEN-IO-IR-104 Device"); + + var control = CommFactory.GetControlPropertiesConfig(dc); + if (control == null) + { + Debug.Console(1, "Factory failed to create a new CEN-IO-IR-104 Device, control properties not found"); + return null; + } + + var ipid = control.IpIdInt; + if(ipid != 0) return new CenIoIr104Controller(dc.Key, dc.Name, new CenIoIr104(ipid, Global.ControlSystem)); + + Debug.Console(1, "Factory failed to create a new CEN-IO-IR-104 Device using IP-ID-{0}", ipid); + return null; + } + } + } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Outputs/GenericVersiportOutputDevice.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Outputs/GenericVersiportOutputDevice.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Outputs/GenericVersiportOutputDevice.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Outputs/GenericVersiportOutputDevice.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Outputs/IDigitalOutput.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Outputs/IDigitalOutput.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Outputs/IDigitalOutput.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Outputs/IDigitalOutput.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/CenIoRy104Controller.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/CenIoRy104Controller.cs similarity index 99% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/CenIoRy104Controller.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/CenIoRy104Controller.cs index e9963f4d..ba13ede8 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/CenIoRy104Controller.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/CenIoRy104Controller.cs @@ -62,7 +62,7 @@ namespace PepperDash.Essentials.Core var controlPropertiesConfig = CommFactory.GetControlPropertiesConfig(dc); if (controlPropertiesConfig == null) - { + { Debug.Console(1, "Factory failed to create a new CEN-IO-RY-104 Device, control properties not found"); return null; } diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/GenericRelayDevice.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/GenericRelayDevice.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/GenericRelayDevice.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/GenericRelayDevice.cs index 69c588ae..421aa3b1 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/GenericRelayDevice.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/GenericRelayDevice.cs @@ -1,221 +1,221 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Config; - -namespace PepperDash.Essentials.Core.CrestronIO -{ - /// - /// Represents a generic device controlled by relays - /// - [Description("Wrapper class for a Relay")] - public class GenericRelayDevice : EssentialsBridgeableDevice, ISwitchedOutput - { - public Relay RelayOutput { get; private set; } - - public BoolFeedback OutputIsOnFeedback { get; private set; } - - //Maintained for compatibility with PepperDash.Essentials.Core.Devices.CrestronProcessor - public GenericRelayDevice(string key, Relay relay) : - base(key) - { - OutputIsOnFeedback = new BoolFeedback(new Func(() => RelayOutput.State)); - - RelayOutput = relay; - RelayOutput.Register(); - - RelayOutput.StateChange += RelayOutput_StateChange; - } - - public GenericRelayDevice(string key, string name, Func postActivationFunc, - IOPortConfig config) - : base(key, name) - { - OutputIsOnFeedback = new BoolFeedback(() => RelayOutput.State); - - AddPostActivationAction(() => - { - RelayOutput = postActivationFunc(config); - - if (RelayOutput == null) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Unable to get parent relay device for device key {0} and port {1}", config.PortDeviceKey, config.PortNumber); - return; - } - - RelayOutput.Register(); - - RelayOutput.StateChange += RelayOutput_StateChange; - }); - } - - #region PreActivate - - private static Relay GetRelay(IOPortConfig dc) - { - - IRelayPorts relayDevice; - - if(dc.PortDeviceKey.Equals("processor")) - { - if (!Global.ControlSystem.SupportsRelay) - { - Debug.Console(0, "Processor does not support relays"); - return null; - } - relayDevice = Global.ControlSystem; - - return relayDevice.RelayPorts[dc.PortNumber]; - } - - var essentialsDevice = DeviceManager.GetDeviceForKey(dc.PortDeviceKey); - if (essentialsDevice == null) - { - Debug.Console(0, "Device {0} was not found in Device Manager. Check configuration or for errors with device.", dc.PortDeviceKey); - return null; - } - - relayDevice = essentialsDevice as IRelayPorts; - - if (relayDevice == null) - { - Debug.Console(0, "Device {0} is not a valid relay parent. Please check configuration.", dc.PortDeviceKey); - return null; - } - - if (dc.PortNumber <= relayDevice.NumberOfRelayPorts) - { - return relayDevice.RelayPorts[dc.PortNumber]; - } - - Debug.Console(0, "Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber); - return null; - } - - #endregion - - #region Events - - void RelayOutput_StateChange(Relay relay, RelayEventArgs args) - { - OutputIsOnFeedback.FireUpdate(); - } - - #endregion - - #region Methods - - public void OpenRelay() - { - RelayOutput.State = false; - } - - public void CloseRelay() - { - RelayOutput.State = true; - } - - public void ToggleRelayState() - { - if (RelayOutput.State == true) - OpenRelay(); - else - CloseRelay(); - } - - #endregion - - #region ISwitchedOutput Members - - void ISwitchedOutput.On() - { - CloseRelay(); - } - - void ISwitchedOutput.Off() - { - OpenRelay(); - } - - #endregion - - #region Bridge Linking - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new GenericRelayControllerJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - if (RelayOutput == null) - { - Debug.Console(1, this, "Unable to link device '{0}'. Relay is null", Key); - return; - } - - Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - trilist.SetBoolSigAction(joinMap.Relay.JoinNumber, b => - { - if (b) - CloseRelay(); - else - OpenRelay(); - }); - - // feedback for relay state - - OutputIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Relay.JoinNumber]); - } - - #endregion - - #region Factory - - public class GenericRelayDeviceFactory : EssentialsDeviceFactory - { - public GenericRelayDeviceFactory() - { - TypeNames = new List() { "relayoutput" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new Generic Relay Device"); - - var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); - - if (props == null) return null; - - var portDevice = new GenericRelayDevice(dc.Key, dc.Name, GetRelay, props); - - return portDevice; - } - } - - #endregion - - - } - - +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core.CrestronIO +{ + /// + /// Represents a generic device controlled by relays + /// + [Description("Wrapper class for a Relay")] + public class GenericRelayDevice : EssentialsBridgeableDevice, ISwitchedOutput + { + public Relay RelayOutput { get; private set; } + + public BoolFeedback OutputIsOnFeedback { get; private set; } + + //Maintained for compatibility with PepperDash.Essentials.Core.Devices.CrestronProcessor + public GenericRelayDevice(string key, Relay relay) : + base(key) + { + OutputIsOnFeedback = new BoolFeedback(new Func(() => RelayOutput.State)); + + RelayOutput = relay; + RelayOutput.Register(); + + RelayOutput.StateChange += RelayOutput_StateChange; + } + + public GenericRelayDevice(string key, string name, Func postActivationFunc, + IOPortConfig config) + : base(key, name) + { + OutputIsOnFeedback = new BoolFeedback(() => RelayOutput.State); + + AddPostActivationAction(() => + { + RelayOutput = postActivationFunc(config); + + if (RelayOutput == null) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Unable to get parent relay device for device key {0} and port {1}", config.PortDeviceKey, config.PortNumber); + return; + } + + RelayOutput.Register(); + + RelayOutput.StateChange += RelayOutput_StateChange; + }); + } + + #region PreActivate + + private static Relay GetRelay(IOPortConfig dc) + { + + IRelayPorts relayDevice; + + if(dc.PortDeviceKey.Equals("processor")) + { + if (!Global.ControlSystem.SupportsRelay) + { + Debug.Console(0, "Processor does not support relays"); + return null; + } + relayDevice = Global.ControlSystem; + + return relayDevice.RelayPorts[dc.PortNumber]; + } + + var essentialsDevice = DeviceManager.GetDeviceForKey(dc.PortDeviceKey); + if (essentialsDevice == null) + { + Debug.Console(0, "Device {0} was not found in Device Manager. Check configuration or for errors with device.", dc.PortDeviceKey); + return null; + } + + relayDevice = essentialsDevice as IRelayPorts; + + if (relayDevice == null) + { + Debug.Console(0, "Device {0} is not a valid relay parent. Please check configuration.", dc.PortDeviceKey); + return null; + } + + if (dc.PortNumber <= relayDevice.NumberOfRelayPorts) + { + return relayDevice.RelayPorts[dc.PortNumber]; + } + + Debug.Console(0, "Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber); + return null; + } + + #endregion + + #region Events + + void RelayOutput_StateChange(Relay relay, RelayEventArgs args) + { + OutputIsOnFeedback.FireUpdate(); + } + + #endregion + + #region Methods + + public void OpenRelay() + { + RelayOutput.State = false; + } + + public void CloseRelay() + { + RelayOutput.State = true; + } + + public void ToggleRelayState() + { + if (RelayOutput.State == true) + OpenRelay(); + else + CloseRelay(); + } + + #endregion + + #region ISwitchedOutput Members + + void ISwitchedOutput.On() + { + CloseRelay(); + } + + void ISwitchedOutput.Off() + { + OpenRelay(); + } + + #endregion + + #region Bridge Linking + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new GenericRelayControllerJoinMap(joinStart); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + else + { + Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + } + + if (RelayOutput == null) + { + Debug.Console(1, this, "Unable to link device '{0}'. Relay is null", Key); + return; + } + + Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + trilist.SetBoolSigAction(joinMap.Relay.JoinNumber, b => + { + if (b) + CloseRelay(); + else + OpenRelay(); + }); + + // feedback for relay state + + OutputIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Relay.JoinNumber]); + } + + #endregion + + #region Factory + + public class GenericRelayDeviceFactory : EssentialsDeviceFactory + { + public GenericRelayDeviceFactory() + { + TypeNames = new List() { "relayoutput" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Generic Relay Device"); + + var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); + + if (props == null) return null; + + var portDevice = new GenericRelayDevice(dc.Key, dc.Name, GetRelay, props); + + return portDevice; + } + } + + #endregion + + + } + + } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/ISwitchedOutput.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/ISwitchedOutput.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/ISwitchedOutput.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/ISwitchedOutput.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/StatusSign/StatusSignController.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/StatusSign/StatusSignController.cs similarity index 97% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/StatusSign/StatusSignController.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/StatusSign/StatusSignController.cs index 6f0cf80e..fc8f9a90 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/StatusSign/StatusSignController.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/StatusSign/StatusSignController.cs @@ -1,223 +1,223 @@ -using System; -using System.Collections.Generic; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.GeneralIO; -using Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Config; - -namespace PepperDash.Essentials.Core.CrestronIO -{ - [Description("Wrapper class for the Crestron StatusSign device")] - public class StatusSignController : CrestronGenericBridgeableBaseDevice - { - private StatusSign _device; - - public BoolFeedback RedLedEnabledFeedback { get; private set; } - public BoolFeedback GreenLedEnabledFeedback { get; private set; } - public BoolFeedback BlueLedEnabledFeedback { get; private set; } - - public IntFeedback RedLedBrightnessFeedback { get; private set; } - public IntFeedback GreenLedBrightnessFeedback { get; private set; } - public IntFeedback BlueLedBrightnessFeedback { get; private set; } - - public StatusSignController(string key, Func preActivationFunc, DeviceConfig config) : base(key, config.Name) - { - AddPreActivationAction(() => - { - _device = preActivationFunc(config); - - RegisterCrestronGenericBase(_device); - - RedLedEnabledFeedback = - new BoolFeedback( - () => - _device.Leds[(uint)StatusSign.Led.eLedColor.Red] - .ControlFeedback.BoolValue); - GreenLedEnabledFeedback = - new BoolFeedback( - () => - _device.Leds[(uint)StatusSign.Led.eLedColor.Green] - .ControlFeedback.BoolValue); - BlueLedEnabledFeedback = - new BoolFeedback( - () => - _device.Leds[(uint)StatusSign.Led.eLedColor.Blue] - .ControlFeedback.BoolValue); - - RedLedBrightnessFeedback = - new IntFeedback(() => (int)_device.Leds[(uint)StatusSign.Led.eLedColor.Red].BrightnessFeedback); - GreenLedBrightnessFeedback = - new IntFeedback(() => (int)_device.Leds[(uint)StatusSign.Led.eLedColor.Green].BrightnessFeedback); - BlueLedBrightnessFeedback = - new IntFeedback(() => (int)_device.Leds[(uint)StatusSign.Led.eLedColor.Blue].BrightnessFeedback); - - if (_device != null) _device.BaseEvent += _device_BaseEvent; - - }); - } - - void _device_BaseEvent(GenericBase device, BaseEventArgs args) - { - switch (args.EventId) - { - case StatusSign.LedBrightnessFeedbackEventId: - RedLedBrightnessFeedback.FireUpdate(); - GreenLedBrightnessFeedback.FireUpdate(); - BlueLedBrightnessFeedback.FireUpdate(); - break; - case StatusSign.LedControlFeedbackEventId: - RedLedEnabledFeedback.FireUpdate(); - GreenLedEnabledFeedback.FireUpdate(); - BlueLedEnabledFeedback.FireUpdate(); - break; - } - } - - public void EnableLedControl(bool red, bool green, bool blue) - { - _device.Leds[(uint) StatusSign.Led.eLedColor.Red].Control.BoolValue = red; - _device.Leds[(uint)StatusSign.Led.eLedColor.Green].Control.BoolValue = green; - _device.Leds[(uint)StatusSign.Led.eLedColor.Blue].Control.BoolValue = blue; - } - - public void SetColor(uint red, uint green, uint blue) - { - try - { - _device.Leds[(uint)StatusSign.Led.eLedColor.Red].Brightness = - (StatusSign.Led.eBrightnessPercentageValues)SimplSharpDeviceHelper.PercentToUshort(red); - } - catch (InvalidOperationException) - { - Debug.Console(1, this, "Error converting value to Red LED brightness. value: {0}", red); - } - try - { - _device.Leds[(uint)StatusSign.Led.eLedColor.Green].Brightness = - (StatusSign.Led.eBrightnessPercentageValues)SimplSharpDeviceHelper.PercentToUshort(green); - } - catch (InvalidOperationException) - { - Debug.Console(1, this, "Error converting value to Green LED brightness. value: {0}", green); - } - - try - { - _device.Leds[(uint)StatusSign.Led.eLedColor.Blue].Brightness = - (StatusSign.Led.eBrightnessPercentageValues)SimplSharpDeviceHelper.PercentToUshort(blue); - } - catch (InvalidOperationException) - { - Debug.Console(1, this, "Error converting value to Blue LED brightness. value: {0}", blue); - } - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new StatusSignControllerJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - trilist.SetBoolSigAction(joinMap.RedControl.JoinNumber, b => EnableControl(trilist, joinMap, this)); - trilist.SetBoolSigAction(joinMap.GreenControl.JoinNumber, b => EnableControl(trilist, joinMap, this)); - trilist.SetBoolSigAction(joinMap.BlueControl.JoinNumber, b => EnableControl(trilist, joinMap, this)); - - trilist.SetUShortSigAction(joinMap.RedLed.JoinNumber, u => SetColor(trilist, joinMap, this)); - trilist.SetUShortSigAction(joinMap.GreenLed.JoinNumber, u => SetColor(trilist, joinMap, this)); - trilist.SetUShortSigAction(joinMap.BlueLed.JoinNumber, u => SetColor(trilist, joinMap, this)); - - trilist.StringInput[joinMap.Name.JoinNumber].StringValue = Name; - - IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - RedLedEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RedControl.JoinNumber]); - BlueLedEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.BlueControl.JoinNumber]); - GreenLedEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.GreenControl.JoinNumber]); - - RedLedBrightnessFeedback.LinkInputSig(trilist.UShortInput[joinMap.RedLed.JoinNumber]); - BlueLedBrightnessFeedback.LinkInputSig(trilist.UShortInput[joinMap.BlueLed.JoinNumber]); - GreenLedBrightnessFeedback.LinkInputSig(trilist.UShortInput[joinMap.GreenLed.JoinNumber]); - } - - private static void EnableControl(BasicTriList triList, StatusSignControllerJoinMap joinMap, - StatusSignController device) - { - var redEnable = triList.BooleanOutput[joinMap.RedControl.JoinNumber].BoolValue; - var greenEnable = triList.BooleanOutput[joinMap.GreenControl.JoinNumber].BoolValue; - var blueEnable = triList.BooleanOutput[joinMap.BlueControl.JoinNumber].BoolValue; - device.EnableLedControl(redEnable, greenEnable, blueEnable); - } - - private static void SetColor(BasicTriList triList, StatusSignControllerJoinMap joinMap, - StatusSignController device) - { - var redBrightness = triList.UShortOutput[joinMap.RedLed.JoinNumber].UShortValue; - var greenBrightness = triList.UShortOutput[joinMap.GreenLed.JoinNumber].UShortValue; - var blueBrightness = triList.UShortOutput[joinMap.BlueLed.JoinNumber].UShortValue; - - device.SetColor(redBrightness, greenBrightness, blueBrightness); - } - - #region PreActivation - - private static StatusSign GetStatusSignDevice(DeviceConfig dc) - { - var control = CommFactory.GetControlPropertiesConfig(dc); - var cresnetId = control.CresnetIdInt; - var branchId = control.ControlPortNumber; - var parentKey = string.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey; - - if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase)) - { - Debug.Console(0, "Device {0} is a valid cresnet master - creating new StatusSign", parentKey); - return new StatusSign(cresnetId, Global.ControlSystem); - } - var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches; - - if (cresnetBridge != null) - { - Debug.Console(0, "Device {0} is a valid cresnet master - creating new StatusSign", parentKey); - return new StatusSign(cresnetId, cresnetBridge.CresnetBranches[branchId]); - } - Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); - return null; - } - #endregion - - public class StatusSignControllerFactory : EssentialsDeviceFactory - { - public StatusSignControllerFactory() - { - TypeNames = new List() { "statussign" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new StatusSign Device"); - - var control = CommFactory.GetControlPropertiesConfig(dc); - var cresnetId = control.CresnetIdInt; - - return new StatusSignController(dc.Key, GetStatusSignDevice, dc); - } - } - } - - +using System; +using System.Collections.Generic; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.GeneralIO; +using Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core.CrestronIO +{ + [Description("Wrapper class for the Crestron StatusSign device")] + public class StatusSignController : CrestronGenericBridgeableBaseDevice + { + private StatusSign _device; + + public BoolFeedback RedLedEnabledFeedback { get; private set; } + public BoolFeedback GreenLedEnabledFeedback { get; private set; } + public BoolFeedback BlueLedEnabledFeedback { get; private set; } + + public IntFeedback RedLedBrightnessFeedback { get; private set; } + public IntFeedback GreenLedBrightnessFeedback { get; private set; } + public IntFeedback BlueLedBrightnessFeedback { get; private set; } + + public StatusSignController(string key, Func preActivationFunc, DeviceConfig config) : base(key, config.Name) + { + AddPreActivationAction(() => + { + _device = preActivationFunc(config); + + RegisterCrestronGenericBase(_device); + + RedLedEnabledFeedback = + new BoolFeedback( + () => + _device.Leds[(uint)StatusSign.Led.eLedColor.Red] + .ControlFeedback.BoolValue); + GreenLedEnabledFeedback = + new BoolFeedback( + () => + _device.Leds[(uint)StatusSign.Led.eLedColor.Green] + .ControlFeedback.BoolValue); + BlueLedEnabledFeedback = + new BoolFeedback( + () => + _device.Leds[(uint)StatusSign.Led.eLedColor.Blue] + .ControlFeedback.BoolValue); + + RedLedBrightnessFeedback = + new IntFeedback(() => (int)_device.Leds[(uint)StatusSign.Led.eLedColor.Red].BrightnessFeedback); + GreenLedBrightnessFeedback = + new IntFeedback(() => (int)_device.Leds[(uint)StatusSign.Led.eLedColor.Green].BrightnessFeedback); + BlueLedBrightnessFeedback = + new IntFeedback(() => (int)_device.Leds[(uint)StatusSign.Led.eLedColor.Blue].BrightnessFeedback); + + if (_device != null) _device.BaseEvent += _device_BaseEvent; + + }); + } + + void _device_BaseEvent(GenericBase device, BaseEventArgs args) + { + switch (args.EventId) + { + case StatusSign.LedBrightnessFeedbackEventId: + RedLedBrightnessFeedback.FireUpdate(); + GreenLedBrightnessFeedback.FireUpdate(); + BlueLedBrightnessFeedback.FireUpdate(); + break; + case StatusSign.LedControlFeedbackEventId: + RedLedEnabledFeedback.FireUpdate(); + GreenLedEnabledFeedback.FireUpdate(); + BlueLedEnabledFeedback.FireUpdate(); + break; + } + } + + public void EnableLedControl(bool red, bool green, bool blue) + { + _device.Leds[(uint) StatusSign.Led.eLedColor.Red].Control.BoolValue = red; + _device.Leds[(uint)StatusSign.Led.eLedColor.Green].Control.BoolValue = green; + _device.Leds[(uint)StatusSign.Led.eLedColor.Blue].Control.BoolValue = blue; + } + + public void SetColor(uint red, uint green, uint blue) + { + try + { + _device.Leds[(uint)StatusSign.Led.eLedColor.Red].Brightness = + (StatusSign.Led.eBrightnessPercentageValues)SimplSharpDeviceHelper.PercentToUshort(red); + } + catch (InvalidOperationException) + { + Debug.Console(1, this, "Error converting value to Red LED brightness. value: {0}", red); + } + try + { + _device.Leds[(uint)StatusSign.Led.eLedColor.Green].Brightness = + (StatusSign.Led.eBrightnessPercentageValues)SimplSharpDeviceHelper.PercentToUshort(green); + } + catch (InvalidOperationException) + { + Debug.Console(1, this, "Error converting value to Green LED brightness. value: {0}", green); + } + + try + { + _device.Leds[(uint)StatusSign.Led.eLedColor.Blue].Brightness = + (StatusSign.Led.eBrightnessPercentageValues)SimplSharpDeviceHelper.PercentToUshort(blue); + } + catch (InvalidOperationException) + { + Debug.Console(1, this, "Error converting value to Blue LED brightness. value: {0}", blue); + } + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new StatusSignControllerJoinMap(joinStart); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + else + { + Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + } + + Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + trilist.SetBoolSigAction(joinMap.RedControl.JoinNumber, b => EnableControl(trilist, joinMap, this)); + trilist.SetBoolSigAction(joinMap.GreenControl.JoinNumber, b => EnableControl(trilist, joinMap, this)); + trilist.SetBoolSigAction(joinMap.BlueControl.JoinNumber, b => EnableControl(trilist, joinMap, this)); + + trilist.SetUShortSigAction(joinMap.RedLed.JoinNumber, u => SetColor(trilist, joinMap, this)); + trilist.SetUShortSigAction(joinMap.GreenLed.JoinNumber, u => SetColor(trilist, joinMap, this)); + trilist.SetUShortSigAction(joinMap.BlueLed.JoinNumber, u => SetColor(trilist, joinMap, this)); + + trilist.StringInput[joinMap.Name.JoinNumber].StringValue = Name; + + IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + RedLedEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RedControl.JoinNumber]); + BlueLedEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.BlueControl.JoinNumber]); + GreenLedEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.GreenControl.JoinNumber]); + + RedLedBrightnessFeedback.LinkInputSig(trilist.UShortInput[joinMap.RedLed.JoinNumber]); + BlueLedBrightnessFeedback.LinkInputSig(trilist.UShortInput[joinMap.BlueLed.JoinNumber]); + GreenLedBrightnessFeedback.LinkInputSig(trilist.UShortInput[joinMap.GreenLed.JoinNumber]); + } + + private static void EnableControl(BasicTriList triList, StatusSignControllerJoinMap joinMap, + StatusSignController device) + { + var redEnable = triList.BooleanOutput[joinMap.RedControl.JoinNumber].BoolValue; + var greenEnable = triList.BooleanOutput[joinMap.GreenControl.JoinNumber].BoolValue; + var blueEnable = triList.BooleanOutput[joinMap.BlueControl.JoinNumber].BoolValue; + device.EnableLedControl(redEnable, greenEnable, blueEnable); + } + + private static void SetColor(BasicTriList triList, StatusSignControllerJoinMap joinMap, + StatusSignController device) + { + var redBrightness = triList.UShortOutput[joinMap.RedLed.JoinNumber].UShortValue; + var greenBrightness = triList.UShortOutput[joinMap.GreenLed.JoinNumber].UShortValue; + var blueBrightness = triList.UShortOutput[joinMap.BlueLed.JoinNumber].UShortValue; + + device.SetColor(redBrightness, greenBrightness, blueBrightness); + } + + #region PreActivation + + private static StatusSign GetStatusSignDevice(DeviceConfig dc) + { + var control = CommFactory.GetControlPropertiesConfig(dc); + var cresnetId = control.CresnetIdInt; + var branchId = control.ControlPortNumber; + var parentKey = string.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey; + + if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase)) + { + Debug.Console(0, "Device {0} is a valid cresnet master - creating new StatusSign", parentKey); + return new StatusSign(cresnetId, Global.ControlSystem); + } + var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches; + + if (cresnetBridge != null) + { + Debug.Console(0, "Device {0} is a valid cresnet master - creating new StatusSign", parentKey); + return new StatusSign(cresnetId, cresnetBridge.CresnetBranches[branchId]); + } + Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); + return null; + } + #endregion + + public class StatusSignControllerFactory : EssentialsDeviceFactory + { + public StatusSignControllerFactory() + { + TypeNames = new List() { "statussign" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new StatusSign Device"); + + var control = CommFactory.GetControlPropertiesConfig(dc); + var cresnetId = control.CresnetIdInt; + + return new StatusSignController(dc.Key, GetStatusSignDevice, dc); + } + } + } + + } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron/CrestronGenericBaseDevice.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron/CrestronGenericBaseDevice.cs similarity index 97% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron/CrestronGenericBaseDevice.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron/CrestronGenericBaseDevice.cs index 32407ba3..d9650e63 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron/CrestronGenericBaseDevice.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron/CrestronGenericBaseDevice.cs @@ -1,215 +1,215 @@ -using System; -using System.Linq; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using PepperDash.Core; -using PepperDash.Core.JsonStandardObjects; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.Core -{ - /// - /// A bridge class to cover the basic features of GenericBase hardware - /// - public abstract class CrestronGenericBaseDevice : EssentialsDevice, IOnline, IHasFeedback, ICommunicationMonitor, IUsageTracking - { - protected GenericBase Hardware; - - /// - /// Returns a list containing the Outputs that we want to expose. - /// - public FeedbackCollection Feedbacks { get; private set; } - - public BoolFeedback IsOnline { get; private set; } - public BoolFeedback IsRegistered { get; private set; } - public StringFeedback IpConnectionsText { get; private set; } - - /// - /// Used by implementing classes to prevent registration with Crestron TLDM. For - /// devices like RMCs and TXs attached to a chassis. - /// - public bool PreventRegistration { get; protected set; } - - protected CrestronGenericBaseDevice(string key, string name, GenericBase hardware) - : base(key, name) - { - Feedbacks = new FeedbackCollection(); - - Hardware = hardware; - IsOnline = new BoolFeedback("IsOnlineFeedback", () => Hardware.IsOnline); - IsRegistered = new BoolFeedback("IsRegistered", () => Hardware.Registered); - IpConnectionsText = new StringFeedback("IpConnectionsText", () => Hardware.ConnectedIpList != null ? string.Join(",", Hardware.ConnectedIpList.Select(cip => cip.DeviceIpAddress).ToArray()) : string.Empty); - AddToFeedbackList(IsOnline, IpConnectionsText); - - CommunicationMonitor = new CrestronGenericBaseCommunicationMonitor(this, hardware, 120000, 300000); - } - - protected CrestronGenericBaseDevice(string key, string name) - : base(key, name) - { - Feedbacks = new FeedbackCollection(); - - } - - protected void RegisterCrestronGenericBase(GenericBase hardware) - { - Hardware = hardware; - IsOnline = new BoolFeedback("IsOnlineFeedback", () => Hardware.IsOnline); - IsRegistered = new BoolFeedback("IsRegistered", () => Hardware.Registered); - IpConnectionsText = new StringFeedback("IpConnectionsText", () => Hardware.ConnectedIpList != null ? string.Join(",", Hardware.ConnectedIpList.Select(cip => cip.DeviceIpAddress).ToArray()) : string.Empty); - AddToFeedbackList(IsOnline, IpConnectionsText); - - CommunicationMonitor = new CrestronGenericBaseCommunicationMonitor(this, hardware, 120000, 300000); - } - - /// - /// Make sure that overriding classes call this! - /// Registers the Crestron device, connects up to the base events, starts communication monitor - /// - public override bool CustomActivate() - { - Debug.Console(0, this, "Activating"); - if (!PreventRegistration) - { - //Debug.Console(1, this, " Does not require registration. Skipping"); - - if (Hardware.Registerable && !Hardware.Registered) - { - var response = Hardware.RegisterWithLogging(Key); - if (response != eDeviceRegistrationUnRegistrationResponse.Success) - { - //Debug.Console(0, this, "ERROR: Cannot register Crestron device: {0}", response); - return false; - } - } - - IsRegistered.FireUpdate(); - } - else - { - AddPostActivationAction(() => - { - if (Hardware.Registerable && !Hardware.Registered) - { - var response = Hardware.RegisterWithLogging(Key); - } - - IsRegistered.FireUpdate(); - }); - } - - foreach (var f in Feedbacks) - { - f.FireUpdate(); - } - - Hardware.OnlineStatusChange += Hardware_OnlineStatusChange; - CommunicationMonitor.Start(); - - return true; - } - - /// - /// This disconnects events and unregisters the base hardware device. - /// - /// - public override bool Deactivate() - { - CommunicationMonitor.Stop(); - Hardware.OnlineStatusChange -= Hardware_OnlineStatusChange; - - var success = Hardware.UnRegister() == eDeviceRegistrationUnRegistrationResponse.Success; - - IsRegistered.FireUpdate(); - - return success; - } - - /// - /// Adds feedback(s) to the list - /// - /// - public void AddToFeedbackList(params Feedback[] newFbs) - { - foreach (var f in newFbs) - { - if (f == null) continue; - - if (!Feedbacks.Contains(f)) - { - Feedbacks.Add(f); - } - } - } - - void Hardware_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) - { - Debug.Console(2, this, "OnlineStatusChange Event. Online = {0}", args.DeviceOnLine); - - if (!Hardware.Registered) - { - return; // protects in cases where device has been unregistered and feedbacks would attempt to access null sigs. - } - - foreach (var feedback in Feedbacks) - { - if (feedback != null) - feedback.FireUpdate(); - } - } - - #region IStatusMonitor Members - - public StatusMonitorBase CommunicationMonitor { get; private set; } - #endregion - - #region IUsageTracking Members - - public UsageTracking UsageTracker { get; set; } - - #endregion - } - - public abstract class CrestronGenericBridgeableBaseDevice : CrestronGenericBaseDevice, IBridgeAdvanced - { - protected CrestronGenericBridgeableBaseDevice(string key, string name, GenericBase hardware) : base(key, name, hardware) - { - } - - protected CrestronGenericBridgeableBaseDevice(string key, string name) - : base(key, name) - { - } - - - public abstract void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge); - } - - - //*********************************************************************************** - public class CrestronGenericBaseDeviceEventIds - { - public const uint IsOnline = 1; - public const uint IpConnectionsText =2; - } - - /// - /// Adds logging to Register() failure - /// - public static class GenericBaseExtensions - { - public static eDeviceRegistrationUnRegistrationResponse RegisterWithLogging(this GenericBase device, string key) - { - var result = device.Register(); - var level = result == eDeviceRegistrationUnRegistrationResponse.Success ? - Debug.ErrorLogLevel.Notice : Debug.ErrorLogLevel.Error; - Debug.Console(0, level, "Register device result: '{0}', type '{1}', result {2}", key, device, result); - //if (result != eDeviceRegistrationUnRegistrationResponse.Success) - //{ - // Debug.Console(0, Debug.ErrorLogLevel.Error, "Cannot register device '{0}': {1}", key, result); - //} - return result; - } - - } +using System; +using System.Linq; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using PepperDash.Core; +using PepperDash.Core.JsonStandardObjects; +using PepperDash.Essentials.Core.Bridges; + +namespace PepperDash.Essentials.Core +{ + /// + /// A bridge class to cover the basic features of GenericBase hardware + /// + public abstract class CrestronGenericBaseDevice : EssentialsDevice, IOnline, IHasFeedback, ICommunicationMonitor, IUsageTracking + { + protected GenericBase Hardware; + + /// + /// Returns a list containing the Outputs that we want to expose. + /// + public FeedbackCollection Feedbacks { get; private set; } + + public BoolFeedback IsOnline { get; private set; } + public BoolFeedback IsRegistered { get; private set; } + public StringFeedback IpConnectionsText { get; private set; } + + /// + /// Used by implementing classes to prevent registration with Crestron TLDM. For + /// devices like RMCs and TXs attached to a chassis. + /// + public bool PreventRegistration { get; protected set; } + + protected CrestronGenericBaseDevice(string key, string name, GenericBase hardware) + : base(key, name) + { + Feedbacks = new FeedbackCollection(); + + Hardware = hardware; + IsOnline = new BoolFeedback("IsOnlineFeedback", () => Hardware.IsOnline); + IsRegistered = new BoolFeedback("IsRegistered", () => Hardware.Registered); + IpConnectionsText = new StringFeedback("IpConnectionsText", () => Hardware.ConnectedIpList != null ? string.Join(",", Hardware.ConnectedIpList.Select(cip => cip.DeviceIpAddress).ToArray()) : string.Empty); + AddToFeedbackList(IsOnline, IpConnectionsText); + + CommunicationMonitor = new CrestronGenericBaseCommunicationMonitor(this, hardware, 120000, 300000); + } + + protected CrestronGenericBaseDevice(string key, string name) + : base(key, name) + { + Feedbacks = new FeedbackCollection(); + + } + + protected void RegisterCrestronGenericBase(GenericBase hardware) + { + Hardware = hardware; + IsOnline = new BoolFeedback("IsOnlineFeedback", () => Hardware.IsOnline); + IsRegistered = new BoolFeedback("IsRegistered", () => Hardware.Registered); + IpConnectionsText = new StringFeedback("IpConnectionsText", () => Hardware.ConnectedIpList != null ? string.Join(",", Hardware.ConnectedIpList.Select(cip => cip.DeviceIpAddress).ToArray()) : string.Empty); + AddToFeedbackList(IsOnline, IpConnectionsText); + + CommunicationMonitor = new CrestronGenericBaseCommunicationMonitor(this, hardware, 120000, 300000); + } + + /// + /// Make sure that overriding classes call this! + /// Registers the Crestron device, connects up to the base events, starts communication monitor + /// + public override bool CustomActivate() + { + Debug.Console(0, this, "Activating"); + if (!PreventRegistration) + { + //Debug.Console(1, this, " Does not require registration. Skipping"); + + if (Hardware.Registerable && !Hardware.Registered) + { + var response = Hardware.RegisterWithLogging(Key); + if (response != eDeviceRegistrationUnRegistrationResponse.Success) + { + //Debug.Console(0, this, "ERROR: Cannot register Crestron device: {0}", response); + return false; + } + } + + IsRegistered.FireUpdate(); + } + else + { + AddPostActivationAction(() => + { + if (Hardware.Registerable && !Hardware.Registered) + { + var response = Hardware.RegisterWithLogging(Key); + } + + IsRegistered.FireUpdate(); + }); + } + + foreach (var f in Feedbacks) + { + f.FireUpdate(); + } + + Hardware.OnlineStatusChange += Hardware_OnlineStatusChange; + CommunicationMonitor.Start(); + + return true; + } + + /// + /// This disconnects events and unregisters the base hardware device. + /// + /// + public override bool Deactivate() + { + CommunicationMonitor.Stop(); + Hardware.OnlineStatusChange -= Hardware_OnlineStatusChange; + + var success = Hardware.UnRegister() == eDeviceRegistrationUnRegistrationResponse.Success; + + IsRegistered.FireUpdate(); + + return success; + } + + /// + /// Adds feedback(s) to the list + /// + /// + public void AddToFeedbackList(params Feedback[] newFbs) + { + foreach (var f in newFbs) + { + if (f == null) continue; + + if (!Feedbacks.Contains(f)) + { + Feedbacks.Add(f); + } + } + } + + void Hardware_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) + { + Debug.Console(2, this, "OnlineStatusChange Event. Online = {0}", args.DeviceOnLine); + + if (!Hardware.Registered) + { + return; // protects in cases where device has been unregistered and feedbacks would attempt to access null sigs. + } + + foreach (var feedback in Feedbacks) + { + if (feedback != null) + feedback.FireUpdate(); + } + } + + #region IStatusMonitor Members + + public StatusMonitorBase CommunicationMonitor { get; private set; } + #endregion + + #region IUsageTracking Members + + public UsageTracking UsageTracker { get; set; } + + #endregion + } + + public abstract class CrestronGenericBridgeableBaseDevice : CrestronGenericBaseDevice, IBridgeAdvanced + { + protected CrestronGenericBridgeableBaseDevice(string key, string name, GenericBase hardware) : base(key, name, hardware) + { + } + + protected CrestronGenericBridgeableBaseDevice(string key, string name) + : base(key, name) + { + } + + + public abstract void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge); + } + + + //*********************************************************************************** + public class CrestronGenericBaseDeviceEventIds + { + public const uint IsOnline = 1; + public const uint IpConnectionsText =2; + } + + /// + /// Adds logging to Register() failure + /// + public static class GenericBaseExtensions + { + public static eDeviceRegistrationUnRegistrationResponse RegisterWithLogging(this GenericBase device, string key) + { + var result = device.Register(); + var level = result == eDeviceRegistrationUnRegistrationResponse.Success ? + Debug.ErrorLogLevel.Notice : Debug.ErrorLogLevel.Error; + Debug.Console(0, level, "Register device result: '{0}', type '{1}', result {2}", key, device, result); + //if (result != eDeviceRegistrationUnRegistrationResponse.Success) + //{ + // Debug.Console(0, Debug.ErrorLogLevel.Error, "Cannot register device '{0}': {1}", key, result); + //} + return result; + } + + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron/CrestronGenericBaseDevice.cs.orig b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron/CrestronGenericBaseDevice.cs.orig similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron/CrestronGenericBaseDevice.cs.orig rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron/CrestronGenericBaseDevice.cs.orig diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Device Info/DeviceInfo.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Device Info/DeviceInfo.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Device Info/DeviceInfo.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Device Info/DeviceInfo.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Device Info/DeviceInfoEventArgs.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Device Info/DeviceInfoEventArgs.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Device Info/DeviceInfoEventArgs.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Device Info/DeviceInfoEventArgs.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Device Info/IDeviceInfoProvider.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Device Info/IDeviceInfoProvider.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Device Info/IDeviceInfoProvider.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Device Info/IDeviceInfoProvider.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Device Info/NetworkDeviceHelpers.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Device Info/NetworkDeviceHelpers.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Device Info/NetworkDeviceHelpers.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Device Info/NetworkDeviceHelpers.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceControlsParentInterfaces/IPresentationSource.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceControlsParentInterfaces/IPresentationSource.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceControlsParentInterfaces/IPresentationSource.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceControlsParentInterfaces/IPresentationSource.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IChannel.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IChannel.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IChannel.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IChannel.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IColorFunctions.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IColorFunctions.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IColorFunctions.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IColorFunctions.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IDPad.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IDPad.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IDPad.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IDPad.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IDiscPlayerControls.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IDiscPlayerControls.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IDiscPlayerControls.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IDiscPlayerControls.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IDisplayBasic.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IDisplayBasic.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IDisplayBasic.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IDisplayBasic.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IDumbSource.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IDumbSource.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IDumbSource.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IDumbSource.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IDvr.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IDvr.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IDvr.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IDvr.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IHasBranding.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IHasBranding.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IHasBranding.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IHasBranding.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IHasFarEndContentStatus.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IHasFarEndContentStatus.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IHasFarEndContentStatus.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IHasFarEndContentStatus.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IHasPhoneDialing.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IHasPhoneDialing.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IHasPhoneDialing.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IHasPhoneDialing.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/ILanguageDefinition.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/ILanguageDefinition.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/ILanguageDefinition.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/ILanguageDefinition.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/ILanguageProvider.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/ILanguageProvider.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/ILanguageProvider.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/ILanguageProvider.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IMobileControl.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IMobileControl.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IMobileControl.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IMobileControl.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/INumeric.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/INumeric.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/INumeric.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/INumeric.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IPasswordPrompt.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IPasswordPrompt.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IPasswordPrompt.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IPasswordPrompt.cs index da61bbc0..6ecdd775 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IPasswordPrompt.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IPasswordPrompt.cs @@ -1,56 +1,56 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -namespace PepperDash.Essentials.Core -{ - /// - /// Describes the functionality required to prompt a user to enter a password - /// - public interface IPasswordPrompt - { - /// - /// Notifies when a password is required or is entered incorrectly - /// - event EventHandler PasswordRequired; - - /// - /// Submits the password - /// - /// - void SubmitPassword(string password); - } - - public class PasswordPromptEventArgs : EventArgs - { - /// - /// Indicates if the last submitted password was incorrect - /// - public bool LastAttemptWasIncorrect { get; private set; } - - /// - /// Indicates that the login attempt has failed - /// - public bool LoginAttemptFailed { get; private set; } - - /// - /// Indicates that the process was cancelled and the prompt should be dismissed - /// - public bool LoginAttemptCancelled { get; private set; } - - /// - /// A message to be displayed to the user - /// - public string Message { get; private set; } - - public PasswordPromptEventArgs(bool lastAttemptIncorrect, bool loginFailed, bool loginCancelled, string message) - { - LastAttemptWasIncorrect = lastAttemptIncorrect; - LoginAttemptFailed = loginFailed; - LoginAttemptCancelled = loginCancelled; - Message = message; - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +namespace PepperDash.Essentials.Core +{ + /// + /// Describes the functionality required to prompt a user to enter a password + /// + public interface IPasswordPrompt + { + /// + /// Notifies when a password is required or is entered incorrectly + /// + event EventHandler PasswordRequired; + + /// + /// Submits the password + /// + /// + void SubmitPassword(string password); + } + + public class PasswordPromptEventArgs : EventArgs + { + /// + /// Indicates if the last submitted password was incorrect + /// + public bool LastAttemptWasIncorrect { get; private set; } + + /// + /// Indicates that the login attempt has failed + /// + public bool LoginAttemptFailed { get; private set; } + + /// + /// Indicates that the process was cancelled and the prompt should be dismissed + /// + public bool LoginAttemptCancelled { get; private set; } + + /// + /// A message to be displayed to the user + /// + public string Message { get; private set; } + + public PasswordPromptEventArgs(bool lastAttemptIncorrect, bool loginFailed, bool loginCancelled, string message) + { + LastAttemptWasIncorrect = lastAttemptIncorrect; + LoginAttemptFailed = loginFailed; + LoginAttemptCancelled = loginCancelled; + Message = message; + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IPower.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IPower.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IPower.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IPower.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/ISetTopBoxControls.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/ISetTopBoxControls.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/ISetTopBoxControls.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/ISetTopBoxControls.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/ITransport.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/ITransport.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/ITransport.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/ITransport.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/ITvPresetsProvider.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/ITvPresetsProvider.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/ITvPresetsProvider.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/ITvPresetsProvider.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IUiDisplayInfo.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IUiDisplayInfo.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IUiDisplayInfo.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IUiDisplayInfo.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IWarmingCooling.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IWarmingCooling.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IWarmingCooling.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/IWarmingCooling.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/LanguageLabel.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/LanguageLabel.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/LanguageLabel.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/LanguageLabel.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/Template.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/Template.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/Template.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/DeviceTypeInterfaces/Template.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/.IHasFeedbacks_BASE_3692.cs.swp b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/.IHasFeedbacks_BASE_3692.cs.swp similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/.IHasFeedbacks_BASE_3692.cs.swp rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/.IHasFeedbacks_BASE_3692.cs.swp diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/.IHasFeedbacks_LOCAL_3692.cs.swp b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/.IHasFeedbacks_LOCAL_3692.cs.swp similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/.IHasFeedbacks_LOCAL_3692.cs.swp rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/.IHasFeedbacks_LOCAL_3692.cs.swp diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/.IHasFeedbacks_REMOTE_3692.cs.swp b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/.IHasFeedbacks_REMOTE_3692.cs.swp similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/.IHasFeedbacks_REMOTE_3692.cs.swp rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/.IHasFeedbacks_REMOTE_3692.cs.swp diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/AudioInterfaces.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/AudioInterfaces.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/AudioInterfaces.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/AudioInterfaces.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/CodecInterfaces.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/CodecInterfaces.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/CodecInterfaces.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/CodecInterfaces.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/CodecInterfaces.cs.orig b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/CodecInterfaces.cs.orig similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/CodecInterfaces.cs.orig rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/CodecInterfaces.cs.orig diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/CrestronProcessor.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/CrestronProcessor.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/CrestronProcessor.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/CrestronProcessor.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DestinationListItem.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DestinationListItem.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DestinationListItem.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DestinationListItem.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceApiBase.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceApiBase.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceApiBase.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceApiBase.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceFeedbackExtensions.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceFeedbackExtensions.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceFeedbackExtensions.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceFeedbackExtensions.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceJsonApi.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceJsonApi.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceJsonApi.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceJsonApi.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs similarity index 97% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs index 55237496..f0101c6c 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs @@ -1,490 +1,490 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; - -using PepperDash.Core; - - -namespace PepperDash.Essentials.Core -{ - public static class DeviceManager - { - public static event EventHandler AllDevicesActivated; - public static event EventHandler AllDevicesRegistered; - - private static readonly CCriticalSection DeviceCriticalSection = new CCriticalSection(); - private static readonly CEvent AllowAddDevicesCEvent = new CEvent(false, true); - //public static List Devices { get { return _Devices; } } - //static List _Devices = new List(); - - static readonly Dictionary Devices = new Dictionary(StringComparer.OrdinalIgnoreCase); - - /// - /// Returns a copy of all the devices in a list - /// - public static List AllDevices { get { return new List(Devices.Values); } } - - public static bool AddDeviceEnabled; - - public static void Initialize(CrestronControlSystem cs) - { - AddDeviceEnabled = true; - CrestronConsole.AddNewConsoleCommand(ListDeviceCommStatuses, "devcommstatus", "Lists the communication status of all devices", - ConsoleAccessLevelEnum.AccessOperator); - CrestronConsole.AddNewConsoleCommand(ListDeviceFeedbacks, "devfb", "Lists current feedbacks", - ConsoleAccessLevelEnum.AccessOperator); - CrestronConsole.AddNewConsoleCommand(ListDevices, "devlist", "Lists current managed devices", - ConsoleAccessLevelEnum.AccessOperator); - CrestronConsole.AddNewConsoleCommand(DeviceJsonApi.DoDeviceActionWithJson, "devjson", "", - ConsoleAccessLevelEnum.AccessOperator); - CrestronConsole.AddNewConsoleCommand(s => CrestronConsole.ConsoleCommandResponse(DeviceJsonApi.GetProperties(s)), "devprops", "", ConsoleAccessLevelEnum.AccessOperator); - CrestronConsole.AddNewConsoleCommand(s => CrestronConsole.ConsoleCommandResponse(DeviceJsonApi.GetMethods(s)), "devmethods", "", ConsoleAccessLevelEnum.AccessOperator); - CrestronConsole.AddNewConsoleCommand(s => CrestronConsole.ConsoleCommandResponse(DeviceJsonApi.GetApiMethods(s)), "apimethods", "", ConsoleAccessLevelEnum.AccessOperator); - CrestronConsole.AddNewConsoleCommand(SimulateComReceiveOnDevice, "devsimreceive", - "Simulates incoming data on a com device", ConsoleAccessLevelEnum.AccessOperator); - - CrestronConsole.AddNewConsoleCommand(SetDeviceStreamDebugging, "setdevicestreamdebug", "set comm debug [deviceKey] [off/rx/tx/both] ([minutes])", ConsoleAccessLevelEnum.AccessOperator); - CrestronConsole.AddNewConsoleCommand(s => DisableAllDeviceStreamDebugging(), "disableallstreamdebug", "disables stream debugging on all devices", ConsoleAccessLevelEnum.AccessOperator); - } - - /// - /// Calls activate steps on all Device class items - /// - public static void ActivateAll() - { - try - { - OnAllDevicesRegistered(); - - DeviceCriticalSection.Enter(); - AddDeviceEnabled = false; - // PreActivate all devices - Debug.Console(0,"****PreActivation starting...****"); - foreach (var d in Devices.Values) - { - try - { - if (d is Device) - (d as Device).PreActivate(); - } - catch (Exception e) - { - Debug.Console(0, d, "ERROR: Device {1} PreActivation failure: {0}", e.Message, d.Key); - Debug.Console(1, d, "Stack Trace: {0}", e.StackTrace); - } - } - Debug.Console(0, "****PreActivation complete****"); - Debug.Console(0, "****Activation starting...****"); - - // Activate all devices - foreach (var d in Devices.Values) - { - try - { - if (d is Device) - (d as Device).Activate(); - } - catch (Exception e) - { - Debug.Console(0, d, "ERROR: Device {1} Activation failure: {0}", e.Message, d.Key); - Debug.Console(1, d, "Stack Trace: {0}", e.StackTrace); - } - } - - Debug.Console(0, "****Activation complete****"); - Debug.Console(0, "****PostActivation starting...****"); - - // PostActivate all devices - foreach (var d in Devices.Values) - { - try - { - if (d is Device) - (d as Device).PostActivate(); - } - catch (Exception e) - { - Debug.Console(0, d, "ERROR: Device {1} PostActivation failure: {0}", e.Message, d.Key); - Debug.Console(1, d, "Stack Trace: {0}", e.StackTrace); - } - } - - Debug.Console(0, "****PostActivation complete****"); - - OnAllDevicesActivated(); - } - finally - { - DeviceCriticalSection.Leave(); - } - } - - private static void OnAllDevicesActivated() - { - var handler = AllDevicesActivated; - if (handler != null) - { - handler(null, new EventArgs()); - } - } - - private static void OnAllDevicesRegistered() - { - var handler = AllDevicesRegistered; - if (handler != null) - { - handler(null, new EventArgs()); - } - } - - /// - /// Calls activate on all Device class items - /// - public static void DeactivateAll() - { - try - { - DeviceCriticalSection.Enter(); - foreach (var d in Devices.Values.OfType()) - { - d.Deactivate(); - } - } - finally - { - DeviceCriticalSection.Leave(); - } - } - - //static void ListMethods(string devKey) - //{ - // var dev = GetDeviceForKey(devKey); - // if(dev != null) - // { - // var type = dev.GetType().GetCType(); - // var methods = type.GetMethods(BindingFlags.Public|BindingFlags.Instance); - // var sb = new StringBuilder(); - // sb.AppendLine(string.Format("{2} methods on [{0}] ({1}):", dev.Key, type.Name, methods.Length)); - // foreach (var m in methods) - // { - // sb.Append(string.Format("{0}(", m.Name)); - // var pars = m.GetParameters(); - // foreach (var p in pars) - // sb.Append(string.Format("({1}){0} ", p.Name, p.ParameterType.Name)); - // sb.AppendLine(")"); - // } - // CrestronConsole.ConsoleCommandResponse(sb.ToString()); - // } - //} - - private static void ListDevices(string s) - { - Debug.Console(0, "{0} Devices registered with Device Manager:", Devices.Count); - var sorted = Devices.Values.ToList(); - sorted.Sort((a, b) => a.Key.CompareTo(b.Key)); - - foreach (var d in sorted) - { - var name = d is IKeyName ? (d as IKeyName).Name : "---"; - Debug.Console(0, " [{0}] {1}", d.Key, name); - } - } - - private static void ListDeviceFeedbacks(string devKey) - { - var dev = GetDeviceForKey(devKey); - if (dev == null) - { - Debug.Console(0, "Device '{0}' not found", devKey); - return; - } - var statusDev = dev as IHasFeedback; - if (statusDev == null) - { - Debug.Console(0, "Device '{0}' does not have visible feedbacks", devKey); - return; - } - statusDev.DumpFeedbacksToConsole(true); - } - - //static void ListDeviceCommands(string devKey) - //{ - // var dev = GetDeviceForKey(devKey); - // if (dev == null) - // { - // Debug.Console(0, "Device '{0}' not found", devKey); - // return; - // } - // Debug.Console(0, "This needs to be reworked. Stay tuned.", devKey); - //} - - private static void ListDeviceCommStatuses(string input) - { - var sb = new StringBuilder(); - foreach (var dev in Devices.Values.OfType()) - { - sb.Append(string.Format("{0}: {1}\r", dev, - dev.CommunicationMonitor.Status)); - } - CrestronConsole.ConsoleCommandResponse(sb.ToString()); - } - - - //static void DoDeviceCommand(string command) - //{ - // Debug.Console(0, "Not yet implemented. Stay tuned"); - //} - - public static void AddDevice(IKeyed newDev) - { - try - { - if (!DeviceCriticalSection.TryEnter()) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Currently unable to add devices to Device Manager. Please try again"); - return; - } - // Check for device with same key - //var existingDevice = _Devices.FirstOrDefault(d => d.Key.Equals(newDev.Key, StringComparison.OrdinalIgnoreCase)); - ////// If it exists, remove or warn?? - //if (existingDevice != null) - - if (!AddDeviceEnabled) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, "All devices have been activated. Adding new devices is not allowed."); - return; - } - - if (Devices.ContainsKey(newDev.Key)) - { - Debug.Console(0, newDev, "WARNING: A device with this key already exists. Not added to manager"); - return; - } - Devices.Add(newDev.Key, newDev); - //if (!(_Devices.Contains(newDev))) - // _Devices.Add(newDev); - } - finally - { - DeviceCriticalSection.Leave(); - } - } - - public static void AddDevice(IEnumerable devicesToAdd) - { - try - { - if (!DeviceCriticalSection.TryEnter()) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, - "Currently unable to add devices to Device Manager. Please try again"); - return; - } - if (!AddDeviceEnabled) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, - "All devices have been activated. Adding new devices is not allowed."); - return; - } - - foreach (var dev in devicesToAdd) - { - try - { - Devices.Add(dev.Key, dev); - } - catch (ArgumentException ex) - { - Debug.Console(0, "Error adding device with key {0} to Device Manager: {1}\r\nStack Trace: {2}", - dev.Key, ex.Message, ex.StackTrace); - } - } - } - finally - { - DeviceCriticalSection.Leave(); - } - } - - public static void RemoveDevice(IKeyed newDev) - { - try - { - DeviceCriticalSection.Enter(); - if (newDev == null) - return; - if (Devices.ContainsKey(newDev.Key)) - Devices.Remove(newDev.Key); - //if (_Devices.Contains(newDev)) - // _Devices.Remove(newDev); - else - Debug.Console(0, "Device manager: Device '{0}' does not exist in manager. Cannot remove", newDev.Key); - } - finally - { - DeviceCriticalSection.Leave(); - } - } - - public static IEnumerable GetDeviceKeys() - { - //return _Devices.Select(d => d.Key).ToList(); - return Devices.Keys; - } - - public static IEnumerable GetDevices() - { - //return _Devices.Select(d => d.Key).ToList(); - return Devices.Values; - } - - public static IKeyed GetDeviceForKey(string key) - { - //return _Devices.FirstOrDefault(d => d.Key.Equals(key, StringComparison.OrdinalIgnoreCase)); - if (key != null && Devices.ContainsKey(key)) - return Devices[key]; - - return null; - } - - /// - /// Console handler that simulates com port data receive - /// - /// - public static void SimulateComReceiveOnDevice(string s) - { - // devcomsim:1 xyzabc - var match = Regex.Match(s, @"(\S*)\s*(.*)"); - if (match.Groups.Count < 3) - { - CrestronConsole.ConsoleCommandResponse(" Format: devsimreceive:P "); - return; - } - //Debug.Console(2, "**** {0} - {1} ****", match.Groups[1].Value, match.Groups[2].Value); - - var com = GetDeviceForKey(match.Groups[1].Value) as ComPortController; - if (com == null) - { - CrestronConsole.ConsoleCommandResponse("'{0}' is not a comm port device", match.Groups[1].Value); - return; - } - com.SimulateReceive(match.Groups[2].Value); - } - - /// - /// Prints a list of routing inputs and outputs by device key. - /// - /// Device key from which to report data - public static void GetRoutingPorts(string s) - { - var device = GetDeviceForKey(s); - - if (device == null) return; - var inputPorts = ((device as IRoutingInputs) != null) ? (device as IRoutingInputs).InputPorts : null; - var outputPorts = ((device as IRoutingOutputs) != null) ? (device as IRoutingOutputs).OutputPorts : null; - if (inputPorts != null) - { - CrestronConsole.ConsoleCommandResponse("Device {0} has {1} Input Ports:{2}", s, inputPorts.Count, CrestronEnvironment.NewLine); - foreach (var routingInputPort in inputPorts) - { - CrestronConsole.ConsoleCommandResponse("{0}{1}", routingInputPort.Key, CrestronEnvironment.NewLine); - } - } - if (outputPorts == null) return; - CrestronConsole.ConsoleCommandResponse("Device {0} has {1} Output Ports:{2}", s, outputPorts.Count, CrestronEnvironment.NewLine); - foreach (var routingOutputPort in outputPorts) - { - CrestronConsole.ConsoleCommandResponse("{0}{1}", routingOutputPort.Key, CrestronEnvironment.NewLine); - } - } - - /// - /// Attempts to set the debug level of a device - /// - /// - public static void SetDeviceStreamDebugging(string s) - { - if (String.IsNullOrEmpty(s) || s.Contains("?")) - { - CrestronConsole.ConsoleCommandResponse( - @"SETDEVICESTREAMDEBUG [{deviceKey}] [OFF |TX | RX | BOTH] [timeOutInMinutes] - {deviceKey} [OFF | TX | RX | BOTH] - Device to set stream debugging on, and which setting to use - timeOutInMinutes - Set timeout for stream debugging. Default is 30 minutes"); - return; - } - - var args = s.Split(' '); - - var deviceKey = args[0]; - var setting = args[1]; - - var timeout= String.Empty; - - if (args.Length >= 3) - { - timeout = args[2]; - } - - var device = GetDeviceForKey(deviceKey) as IStreamDebugging; - - if (device == null) - { - CrestronConsole.ConsoleCommandResponse("Unable to get device with key: {0}", deviceKey); - return; - } - - eStreamDebuggingSetting debugSetting; - - try - { - debugSetting = (eStreamDebuggingSetting)Enum.Parse(typeof(eStreamDebuggingSetting), setting, true); - } - catch - { - CrestronConsole.ConsoleCommandResponse("Unable to convert setting value. Please use off/rx/tx/both"); - return; - } - - if (!string.IsNullOrEmpty(timeout)) - { - try - { - var min = Convert.ToUInt32(timeout); - - device.StreamDebugging.SetDebuggingWithSpecificTimeout(debugSetting, min); - CrestronConsole.ConsoleCommandResponse("Device: '{0}' debug level set to {1} for {2} minutes", deviceKey, debugSetting, min); - - } - catch (Exception e) - { - CrestronConsole.ConsoleCommandResponse("Unable to convert minutes or settings value. Please use an integer value for minutes. Error: {0}", e); - } - } - else - { - device.StreamDebugging.SetDebuggingWithDefaultTimeout(debugSetting); - CrestronConsole.ConsoleCommandResponse("Device: '{0}' debug level set to {1} for default time (30 minutes)", deviceKey, debugSetting); - } - } - - /// - /// Sets stream debugging settings to off for all devices - /// - public static void DisableAllDeviceStreamDebugging() - { - foreach (var device in AllDevices) - { - var streamDevice = device as IStreamDebugging; - - if (streamDevice != null) - { - streamDevice.StreamDebugging.SetDebuggingWithDefaultTimeout(eStreamDebuggingSetting.Off); - } - } - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; + +using PepperDash.Core; + + +namespace PepperDash.Essentials.Core +{ + public static class DeviceManager + { + public static event EventHandler AllDevicesActivated; + public static event EventHandler AllDevicesRegistered; + + private static readonly CCriticalSection DeviceCriticalSection = new CCriticalSection(); + private static readonly CEvent AllowAddDevicesCEvent = new CEvent(false, true); + //public static List Devices { get { return _Devices; } } + //static List _Devices = new List(); + + static readonly Dictionary Devices = new Dictionary(StringComparer.OrdinalIgnoreCase); + + /// + /// Returns a copy of all the devices in a list + /// + public static List AllDevices { get { return new List(Devices.Values); } } + + public static bool AddDeviceEnabled; + + public static void Initialize(CrestronControlSystem cs) + { + AddDeviceEnabled = true; + CrestronConsole.AddNewConsoleCommand(ListDeviceCommStatuses, "devcommstatus", "Lists the communication status of all devices", + ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(ListDeviceFeedbacks, "devfb", "Lists current feedbacks", + ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(ListDevices, "devlist", "Lists current managed devices", + ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(DeviceJsonApi.DoDeviceActionWithJson, "devjson", "", + ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(s => CrestronConsole.ConsoleCommandResponse(DeviceJsonApi.GetProperties(s)), "devprops", "", ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(s => CrestronConsole.ConsoleCommandResponse(DeviceJsonApi.GetMethods(s)), "devmethods", "", ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(s => CrestronConsole.ConsoleCommandResponse(DeviceJsonApi.GetApiMethods(s)), "apimethods", "", ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(SimulateComReceiveOnDevice, "devsimreceive", + "Simulates incoming data on a com device", ConsoleAccessLevelEnum.AccessOperator); + + CrestronConsole.AddNewConsoleCommand(SetDeviceStreamDebugging, "setdevicestreamdebug", "set comm debug [deviceKey] [off/rx/tx/both] ([minutes])", ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(s => DisableAllDeviceStreamDebugging(), "disableallstreamdebug", "disables stream debugging on all devices", ConsoleAccessLevelEnum.AccessOperator); + } + + /// + /// Calls activate steps on all Device class items + /// + public static void ActivateAll() + { + try + { + OnAllDevicesRegistered(); + + DeviceCriticalSection.Enter(); + AddDeviceEnabled = false; + // PreActivate all devices + Debug.Console(0,"****PreActivation starting...****"); + foreach (var d in Devices.Values) + { + try + { + if (d is Device) + (d as Device).PreActivate(); + } + catch (Exception e) + { + Debug.Console(0, d, "ERROR: Device {1} PreActivation failure: {0}", e.Message, d.Key); + Debug.Console(1, d, "Stack Trace: {0}", e.StackTrace); + } + } + Debug.Console(0, "****PreActivation complete****"); + Debug.Console(0, "****Activation starting...****"); + + // Activate all devices + foreach (var d in Devices.Values) + { + try + { + if (d is Device) + (d as Device).Activate(); + } + catch (Exception e) + { + Debug.Console(0, d, "ERROR: Device {1} Activation failure: {0}", e.Message, d.Key); + Debug.Console(1, d, "Stack Trace: {0}", e.StackTrace); + } + } + + Debug.Console(0, "****Activation complete****"); + Debug.Console(0, "****PostActivation starting...****"); + + // PostActivate all devices + foreach (var d in Devices.Values) + { + try + { + if (d is Device) + (d as Device).PostActivate(); + } + catch (Exception e) + { + Debug.Console(0, d, "ERROR: Device {1} PostActivation failure: {0}", e.Message, d.Key); + Debug.Console(1, d, "Stack Trace: {0}", e.StackTrace); + } + } + + Debug.Console(0, "****PostActivation complete****"); + + OnAllDevicesActivated(); + } + finally + { + DeviceCriticalSection.Leave(); + } + } + + private static void OnAllDevicesActivated() + { + var handler = AllDevicesActivated; + if (handler != null) + { + handler(null, new EventArgs()); + } + } + + private static void OnAllDevicesRegistered() + { + var handler = AllDevicesRegistered; + if (handler != null) + { + handler(null, new EventArgs()); + } + } + + /// + /// Calls activate on all Device class items + /// + public static void DeactivateAll() + { + try + { + DeviceCriticalSection.Enter(); + foreach (var d in Devices.Values.OfType()) + { + d.Deactivate(); + } + } + finally + { + DeviceCriticalSection.Leave(); + } + } + + //static void ListMethods(string devKey) + //{ + // var dev = GetDeviceForKey(devKey); + // if(dev != null) + // { + // var type = dev.GetType().GetCType(); + // var methods = type.GetMethods(BindingFlags.Public|BindingFlags.Instance); + // var sb = new StringBuilder(); + // sb.AppendLine(string.Format("{2} methods on [{0}] ({1}):", dev.Key, type.Name, methods.Length)); + // foreach (var m in methods) + // { + // sb.Append(string.Format("{0}(", m.Name)); + // var pars = m.GetParameters(); + // foreach (var p in pars) + // sb.Append(string.Format("({1}){0} ", p.Name, p.ParameterType.Name)); + // sb.AppendLine(")"); + // } + // CrestronConsole.ConsoleCommandResponse(sb.ToString()); + // } + //} + + private static void ListDevices(string s) + { + Debug.Console(0, "{0} Devices registered with Device Manager:", Devices.Count); + var sorted = Devices.Values.ToList(); + sorted.Sort((a, b) => a.Key.CompareTo(b.Key)); + + foreach (var d in sorted) + { + var name = d is IKeyName ? (d as IKeyName).Name : "---"; + Debug.Console(0, " [{0}] {1}", d.Key, name); + } + } + + private static void ListDeviceFeedbacks(string devKey) + { + var dev = GetDeviceForKey(devKey); + if (dev == null) + { + Debug.Console(0, "Device '{0}' not found", devKey); + return; + } + var statusDev = dev as IHasFeedback; + if (statusDev == null) + { + Debug.Console(0, "Device '{0}' does not have visible feedbacks", devKey); + return; + } + statusDev.DumpFeedbacksToConsole(true); + } + + //static void ListDeviceCommands(string devKey) + //{ + // var dev = GetDeviceForKey(devKey); + // if (dev == null) + // { + // Debug.Console(0, "Device '{0}' not found", devKey); + // return; + // } + // Debug.Console(0, "This needs to be reworked. Stay tuned.", devKey); + //} + + private static void ListDeviceCommStatuses(string input) + { + var sb = new StringBuilder(); + foreach (var dev in Devices.Values.OfType()) + { + sb.Append(string.Format("{0}: {1}\r", dev, + dev.CommunicationMonitor.Status)); + } + CrestronConsole.ConsoleCommandResponse(sb.ToString()); + } + + + //static void DoDeviceCommand(string command) + //{ + // Debug.Console(0, "Not yet implemented. Stay tuned"); + //} + + public static void AddDevice(IKeyed newDev) + { + try + { + if (!DeviceCriticalSection.TryEnter()) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "Currently unable to add devices to Device Manager. Please try again"); + return; + } + // Check for device with same key + //var existingDevice = _Devices.FirstOrDefault(d => d.Key.Equals(newDev.Key, StringComparison.OrdinalIgnoreCase)); + ////// If it exists, remove or warn?? + //if (existingDevice != null) + + if (!AddDeviceEnabled) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "All devices have been activated. Adding new devices is not allowed."); + return; + } + + if (Devices.ContainsKey(newDev.Key)) + { + Debug.Console(0, newDev, "WARNING: A device with this key already exists. Not added to manager"); + return; + } + Devices.Add(newDev.Key, newDev); + //if (!(_Devices.Contains(newDev))) + // _Devices.Add(newDev); + } + finally + { + DeviceCriticalSection.Leave(); + } + } + + public static void AddDevice(IEnumerable devicesToAdd) + { + try + { + if (!DeviceCriticalSection.TryEnter()) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, + "Currently unable to add devices to Device Manager. Please try again"); + return; + } + if (!AddDeviceEnabled) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, + "All devices have been activated. Adding new devices is not allowed."); + return; + } + + foreach (var dev in devicesToAdd) + { + try + { + Devices.Add(dev.Key, dev); + } + catch (ArgumentException ex) + { + Debug.Console(0, "Error adding device with key {0} to Device Manager: {1}\r\nStack Trace: {2}", + dev.Key, ex.Message, ex.StackTrace); + } + } + } + finally + { + DeviceCriticalSection.Leave(); + } + } + + public static void RemoveDevice(IKeyed newDev) + { + try + { + DeviceCriticalSection.Enter(); + if (newDev == null) + return; + if (Devices.ContainsKey(newDev.Key)) + Devices.Remove(newDev.Key); + //if (_Devices.Contains(newDev)) + // _Devices.Remove(newDev); + else + Debug.Console(0, "Device manager: Device '{0}' does not exist in manager. Cannot remove", newDev.Key); + } + finally + { + DeviceCriticalSection.Leave(); + } + } + + public static IEnumerable GetDeviceKeys() + { + //return _Devices.Select(d => d.Key).ToList(); + return Devices.Keys; + } + + public static IEnumerable GetDevices() + { + //return _Devices.Select(d => d.Key).ToList(); + return Devices.Values; + } + + public static IKeyed GetDeviceForKey(string key) + { + //return _Devices.FirstOrDefault(d => d.Key.Equals(key, StringComparison.OrdinalIgnoreCase)); + if (key != null && Devices.ContainsKey(key)) + return Devices[key]; + + return null; + } + + /// + /// Console handler that simulates com port data receive + /// + /// + public static void SimulateComReceiveOnDevice(string s) + { + // devcomsim:1 xyzabc + var match = Regex.Match(s, @"(\S*)\s*(.*)"); + if (match.Groups.Count < 3) + { + CrestronConsole.ConsoleCommandResponse(" Format: devsimreceive:P "); + return; + } + //Debug.Console(2, "**** {0} - {1} ****", match.Groups[1].Value, match.Groups[2].Value); + + var com = GetDeviceForKey(match.Groups[1].Value) as ComPortController; + if (com == null) + { + CrestronConsole.ConsoleCommandResponse("'{0}' is not a comm port device", match.Groups[1].Value); + return; + } + com.SimulateReceive(match.Groups[2].Value); + } + + /// + /// Prints a list of routing inputs and outputs by device key. + /// + /// Device key from which to report data + public static void GetRoutingPorts(string s) + { + var device = GetDeviceForKey(s); + + if (device == null) return; + var inputPorts = ((device as IRoutingInputs) != null) ? (device as IRoutingInputs).InputPorts : null; + var outputPorts = ((device as IRoutingOutputs) != null) ? (device as IRoutingOutputs).OutputPorts : null; + if (inputPorts != null) + { + CrestronConsole.ConsoleCommandResponse("Device {0} has {1} Input Ports:{2}", s, inputPorts.Count, CrestronEnvironment.NewLine); + foreach (var routingInputPort in inputPorts) + { + CrestronConsole.ConsoleCommandResponse("{0}{1}", routingInputPort.Key, CrestronEnvironment.NewLine); + } + } + if (outputPorts == null) return; + CrestronConsole.ConsoleCommandResponse("Device {0} has {1} Output Ports:{2}", s, outputPorts.Count, CrestronEnvironment.NewLine); + foreach (var routingOutputPort in outputPorts) + { + CrestronConsole.ConsoleCommandResponse("{0}{1}", routingOutputPort.Key, CrestronEnvironment.NewLine); + } + } + + /// + /// Attempts to set the debug level of a device + /// + /// + public static void SetDeviceStreamDebugging(string s) + { + if (String.IsNullOrEmpty(s) || s.Contains("?")) + { + CrestronConsole.ConsoleCommandResponse( + @"SETDEVICESTREAMDEBUG [{deviceKey}] [OFF |TX | RX | BOTH] [timeOutInMinutes] + {deviceKey} [OFF | TX | RX | BOTH] - Device to set stream debugging on, and which setting to use + timeOutInMinutes - Set timeout for stream debugging. Default is 30 minutes"); + return; + } + + var args = s.Split(' '); + + var deviceKey = args[0]; + var setting = args[1]; + + var timeout= String.Empty; + + if (args.Length >= 3) + { + timeout = args[2]; + } + + var device = GetDeviceForKey(deviceKey) as IStreamDebugging; + + if (device == null) + { + CrestronConsole.ConsoleCommandResponse("Unable to get device with key: {0}", deviceKey); + return; + } + + eStreamDebuggingSetting debugSetting; + + try + { + debugSetting = (eStreamDebuggingSetting)Enum.Parse(typeof(eStreamDebuggingSetting), setting, true); + } + catch + { + CrestronConsole.ConsoleCommandResponse("Unable to convert setting value. Please use off/rx/tx/both"); + return; + } + + if (!string.IsNullOrEmpty(timeout)) + { + try + { + var min = Convert.ToUInt32(timeout); + + device.StreamDebugging.SetDebuggingWithSpecificTimeout(debugSetting, min); + CrestronConsole.ConsoleCommandResponse("Device: '{0}' debug level set to {1} for {2} minutes", deviceKey, debugSetting, min); + + } + catch (Exception e) + { + CrestronConsole.ConsoleCommandResponse("Unable to convert minutes or settings value. Please use an integer value for minutes. Error: {0}", e); + } + } + else + { + device.StreamDebugging.SetDebuggingWithDefaultTimeout(debugSetting); + CrestronConsole.ConsoleCommandResponse("Device: '{0}' debug level set to {1} for default time (30 minutes)", deviceKey, debugSetting); + } + } + + /// + /// Sets stream debugging settings to off for all devices + /// + public static void DisableAllDeviceStreamDebugging() + { + foreach (var device in AllDevices) + { + var streamDevice = device as IStreamDebugging; + + if (streamDevice != null) + { + streamDevice.StreamDebugging.SetDebuggingWithDefaultTimeout(eStreamDebuggingSetting.Off); + } + } + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs.orig b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs.orig similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs.orig rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs.orig diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DisplayUiConstants.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DisplayUiConstants.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DisplayUiConstants.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DisplayUiConstants.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsBridgeableDevice.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsBridgeableDevice.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsBridgeableDevice.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsBridgeableDevice.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs similarity index 97% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs index a3ca94f3..bc8af721 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs @@ -1,145 +1,145 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharp.Reflection; - -using PepperDash.Core; -using PepperDash.Essentials.Core.Config; - -namespace PepperDash.Essentials.Core -{ - /// - /// Defines the basic needs for an EssentialsDevice to enable it to be build by an IDeviceFactory class - /// - [Description("The base Essentials Device Class")] - public abstract class EssentialsDevice : Device - { - protected EssentialsDevice(string key) - : base(key) - { - SubscribeToActivateComplete(); - } - - protected EssentialsDevice(string key, string name) - : base(key, name) - { - SubscribeToActivateComplete(); - } - - private void SubscribeToActivateComplete() - { - DeviceManager.AllDevicesActivated += DeviceManagerOnAllDevicesActivated; - } - - private void DeviceManagerOnAllDevicesActivated(object sender, EventArgs eventArgs) - { - CrestronInvoke.BeginInvoke((o) => - { - try - { - Initialize(); - } - catch (Exception ex) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Exception initializing device: {0}", ex.Message); - Debug.Console(1, this, Debug.ErrorLogLevel.Error, "Stack Trace: {0}", ex.StackTrace); - } - }); - } - } - - [AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = true)] - public class DescriptionAttribute : Attribute - { - private string _Description; - - public DescriptionAttribute(string description) - { - //Debug.Console(2, "Setting Description: {0}", description); - _Description = description; - } - - public string Description - { - get { return _Description; } - } - } - - [AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = true)] - public class ConfigSnippetAttribute : Attribute - { - private string _ConfigSnippet; - - public ConfigSnippetAttribute(string configSnippet) - { - //Debug.Console(2, "Setting Config Snippet {0}", configSnippet); - _ConfigSnippet = configSnippet; - } - - public string ConfigSnippet - { - get { return _ConfigSnippet; } - } - } - - /// - /// Devices the basic needs for a Device Factory - /// - public abstract class EssentialsDeviceFactory : IDeviceFactory where T:EssentialsDevice - { - #region IDeviceFactory Members - - /// - /// A list of strings that can be used in the type property of a DeviceConfig object to build an instance of this device - /// - public List TypeNames { get; protected set; } - - /// - /// Loads an item to the DeviceFactory.FactoryMethods dictionary for each entry in the TypeNames list - /// - public void LoadTypeFactories() - { - foreach (var typeName in TypeNames) - { - //Debug.Console(2, "Getting Description Attribute from class: '{0}'", typeof(T).FullName); - var descriptionAttribute = typeof(T).GetCustomAttributes(typeof(DescriptionAttribute), true) as DescriptionAttribute[]; - string description = descriptionAttribute[0].Description; - var snippetAttribute = typeof(T).GetCustomAttributes(typeof(ConfigSnippetAttribute), true) as ConfigSnippetAttribute[]; - DeviceFactory.AddFactoryForType(typeName.ToLower(), description, typeof(T), BuildDevice); - } - } - - /// - /// The method that will build the device - /// - /// The device config - /// An instance of the device - public abstract EssentialsDevice BuildDevice(DeviceConfig dc); - - #endregion - } - - /// - /// Devices the basic needs for a Device Factory - /// - public abstract class EssentialsPluginDeviceFactory : EssentialsDeviceFactory, IPluginDeviceFactory where T : EssentialsDevice - { - /// - /// Specifies the minimum version of Essentials required for a plugin to run. Must use the format Major.Minor.Build (ex. "1.4.33") - /// - public string MinimumEssentialsFrameworkVersion { get; protected set; } - } - - public abstract class EssentialsPluginDevelopmentDeviceFactory : EssentialsDeviceFactory, IPluginDevelopmentDeviceFactory where T : EssentialsDevice - { - /// - /// Specifies the minimum version of Essentials required for a plugin to run. Must use the format Major.Minor.Build (ex. "1.4.33") - /// - public string MinimumEssentialsFrameworkVersion { get; protected set; } - - public List DevelopmentEssentialsFrameworkVersions { get; protected set; } - } - +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharp.Reflection; + +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core +{ + /// + /// Defines the basic needs for an EssentialsDevice to enable it to be build by an IDeviceFactory class + /// + [Description("The base Essentials Device Class")] + public abstract class EssentialsDevice : Device + { + protected EssentialsDevice(string key) + : base(key) + { + SubscribeToActivateComplete(); + } + + protected EssentialsDevice(string key, string name) + : base(key, name) + { + SubscribeToActivateComplete(); + } + + private void SubscribeToActivateComplete() + { + DeviceManager.AllDevicesActivated += DeviceManagerOnAllDevicesActivated; + } + + private void DeviceManagerOnAllDevicesActivated(object sender, EventArgs eventArgs) + { + CrestronInvoke.BeginInvoke((o) => + { + try + { + Initialize(); + } + catch (Exception ex) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Exception initializing device: {0}", ex.Message); + Debug.Console(1, this, Debug.ErrorLogLevel.Error, "Stack Trace: {0}", ex.StackTrace); + } + }); + } + } + + [AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = true)] + public class DescriptionAttribute : Attribute + { + private string _Description; + + public DescriptionAttribute(string description) + { + //Debug.Console(2, "Setting Description: {0}", description); + _Description = description; + } + + public string Description + { + get { return _Description; } + } + } + + [AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = true)] + public class ConfigSnippetAttribute : Attribute + { + private string _ConfigSnippet; + + public ConfigSnippetAttribute(string configSnippet) + { + //Debug.Console(2, "Setting Config Snippet {0}", configSnippet); + _ConfigSnippet = configSnippet; + } + + public string ConfigSnippet + { + get { return _ConfigSnippet; } + } + } + + /// + /// Devices the basic needs for a Device Factory + /// + public abstract class EssentialsDeviceFactory : IDeviceFactory where T:EssentialsDevice + { + #region IDeviceFactory Members + + /// + /// A list of strings that can be used in the type property of a DeviceConfig object to build an instance of this device + /// + public List TypeNames { get; protected set; } + + /// + /// Loads an item to the DeviceFactory.FactoryMethods dictionary for each entry in the TypeNames list + /// + public void LoadTypeFactories() + { + foreach (var typeName in TypeNames) + { + //Debug.Console(2, "Getting Description Attribute from class: '{0}'", typeof(T).FullName); + var descriptionAttribute = typeof(T).GetCustomAttributes(typeof(DescriptionAttribute), true) as DescriptionAttribute[]; + string description = descriptionAttribute[0].Description; + var snippetAttribute = typeof(T).GetCustomAttributes(typeof(ConfigSnippetAttribute), true) as ConfigSnippetAttribute[]; + DeviceFactory.AddFactoryForType(typeName.ToLower(), description, typeof(T), BuildDevice); + } + } + + /// + /// The method that will build the device + /// + /// The device config + /// An instance of the device + public abstract EssentialsDevice BuildDevice(DeviceConfig dc); + + #endregion + } + + /// + /// Devices the basic needs for a Device Factory + /// + public abstract class EssentialsPluginDeviceFactory : EssentialsDeviceFactory, IPluginDeviceFactory where T : EssentialsDevice + { + /// + /// Specifies the minimum version of Essentials required for a plugin to run. Must use the format Major.Minor.Build (ex. "1.4.33") + /// + public string MinimumEssentialsFrameworkVersion { get; protected set; } + } + + public abstract class EssentialsPluginDevelopmentDeviceFactory : EssentialsDeviceFactory, IPluginDevelopmentDeviceFactory where T : EssentialsDevice + { + /// + /// Specifies the minimum version of Essentials required for a plugin to run. Must use the format Major.Minor.Build (ex. "1.4.33") + /// + public string MinimumEssentialsFrameworkVersion { get; protected set; } + + public List DevelopmentEssentialsFrameworkVersions { get; protected set; } + } + } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/FIND HOMES Interfaces.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/FIND HOMES Interfaces.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/FIND HOMES Interfaces.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/FIND HOMES Interfaces.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericIRController.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericIRController.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericIRController.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericIRController.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericMonitoredTcpDevice.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericMonitoredTcpDevice.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericMonitoredTcpDevice.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericMonitoredTcpDevice.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IAttachVideoStatusExtensions.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IAttachVideoStatusExtensions.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IAttachVideoStatusExtensions.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IAttachVideoStatusExtensions.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IDspPreset.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IDspPreset.cs similarity index 94% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IDspPreset.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IDspPreset.cs index 2ec63fcb..645339bb 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IDspPreset.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IDspPreset.cs @@ -1,17 +1,17 @@ -using System.Collections.Generic; - -namespace PepperDash.Essentials.Core -{ - public interface IHasDspPresets - { - List Presets { get; } - - void RecallPreset(IDspPreset preset); - - } - - public interface IDspPreset - { - string Name { get; } - } +using System.Collections.Generic; + +namespace PepperDash.Essentials.Core +{ + public interface IHasDspPresets + { + List Presets { get; } + + void RecallPreset(IDspPreset preset); + + } + + public interface IDspPreset + { + string Name { get; } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IHasFeedbacks.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IHasFeedbacks.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IHasFeedbacks.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IHasFeedbacks.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IHasFeedbacks_BACKUP_3692.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IHasFeedbacks_BACKUP_3692.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IHasFeedbacks_BACKUP_3692.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IHasFeedbacks_BACKUP_3692.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IHasFeedbacks_BASE_3692.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IHasFeedbacks_BASE_3692.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IHasFeedbacks_BASE_3692.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IHasFeedbacks_BASE_3692.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IHasFeedbacks_LOCAL_3692.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IHasFeedbacks_LOCAL_3692.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IHasFeedbacks_LOCAL_3692.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IHasFeedbacks_LOCAL_3692.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IHasFeedbacks_REMOTE_3692.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IHasFeedbacks_REMOTE_3692.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IHasFeedbacks_REMOTE_3692.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IHasFeedbacks_REMOTE_3692.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IProjectorInterfaces.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IProjectorInterfaces.cs similarity index 95% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IProjectorInterfaces.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IProjectorInterfaces.cs index 70e2e215..c0cb33ed 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IProjectorInterfaces.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IProjectorInterfaces.cs @@ -1,22 +1,22 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -namespace PepperDash.Essentials.Core -{ - public interface IBasicVideoMute - { - void VideoMuteToggle(); - } - - public interface IBasicVideoMuteWithFeedback : IBasicVideoMute - { - BoolFeedback VideoMuteIsOn { get; } - - void VideoMuteOn(); - void VideoMuteOff(); - - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +namespace PepperDash.Essentials.Core +{ + public interface IBasicVideoMute + { + void VideoMuteToggle(); + } + + public interface IBasicVideoMuteWithFeedback : IBasicVideoMute + { + BoolFeedback VideoMuteIsOn { get; } + + void VideoMuteOn(); + void VideoMuteOff(); + + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IReconfigurableDevice.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IReconfigurableDevice.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IReconfigurableDevice.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IReconfigurableDevice.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IUsageTracking.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IUsageTracking.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IUsageTracking.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IUsageTracking.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IUsageTracking.cs.orig b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IUsageTracking.cs.orig similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IUsageTracking.cs.orig rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IUsageTracking.cs.orig diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IVolumeAndAudioInterfaces.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IVolumeAndAudioInterfaces.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IVolumeAndAudioInterfaces.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IVolumeAndAudioInterfaces.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs index d404b3ea..c4505d54 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs @@ -1,172 +1,172 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Newtonsoft.Json.Linq; -using PepperDash.Essentials.Core.Config; - - -using PepperDash.Core; - -namespace PepperDash.Essentials.Core -{ - - /// - /// IR port wrapper. May act standalone - /// - public class IrOutputPortController : Device - { - uint IrPortUid; - IROutputPort IrPort; - - public BoolFeedback DriverLoaded { get; private set; } - - public ushort StandardIrPulseTime { get; set; } - public string DriverFilepath { get; private set; } - public bool DriverIsLoaded { get; private set; } - - public string[] IrFileCommands { get { return IrPort.AvailableStandardIRCmds(IrPortUid); } } - - public bool UseBridgeJoinMap { get; private set; } - - /// - /// Constructor for IrDevice base class. If a null port is provided, this class will - /// still function without trying to talk to a port. - /// - public IrOutputPortController(string key, IROutputPort port, string irDriverFilepath) - : base(key) - { - //if (port == null) throw new ArgumentNullException("port"); - - DriverLoaded = new BoolFeedback(() => DriverIsLoaded); - IrPort = port; - if (port == null) - { - Debug.Console(0, this, "WARNING No valid IR Port assigned to controller. IR will not function"); - return; - } - LoadDriver(irDriverFilepath); - } - - public IrOutputPortController(string key, Func postActivationFunc, - DeviceConfig config) - : base(key) - { - DriverLoaded = new BoolFeedback(() => DriverIsLoaded); - UseBridgeJoinMap = config.Properties["control"].Value("useBridgeJoinMap"); - AddPostActivationAction(() => - { - IrPort = postActivationFunc(config); - - if (IrPort == null) - { - Debug.Console(0, this, "WARNING No valid IR Port assigned to controller. IR will not function"); - return; - } - - var filePath = Global.FilePathPrefix + "ir" + Global.DirectorySeparator + config.Properties["control"]["irFile"].Value(); - Debug.Console(1, "*************Attempting to load IR file: {0}***************", filePath); - - LoadDriver(filePath); - - PrintAvailableCommands(); - }); - } - - public void PrintAvailableCommands() - { - Debug.Console(2, this, "Available IR Commands in IR File {0}", IrPortUid); - foreach (var cmd in IrPort.AvailableIRCmds()) - { - Debug.Console(2, this, "{0}", cmd); - } - } - - - /// - /// Loads the IR driver at path - /// - /// - public void LoadDriver(string path) - { - Debug.Console(2, this, "***Loading IR File***"); - if (string.IsNullOrEmpty(path)) path = DriverFilepath; - try - { - IrPortUid = IrPort.LoadIRDriver(path); - DriverFilepath = path; - StandardIrPulseTime = 200; - DriverIsLoaded = true; - - DriverLoaded.FireUpdate(); - } - catch - { - DriverIsLoaded = false; - var message = string.Format("WARNING IR Driver '{0}' failed to load", path); - Debug.Console(0, this, Debug.ErrorLogLevel.Error, message); - DriverLoaded.FireUpdate(); - } - } - - - /// - /// Starts and stops IR command on driver. Safe for missing commands - /// - public virtual void PressRelease(string command, bool state) - { - Debug.Console(2, this, "IR:'{0}'={1}", command, state); - if (IrPort == null) - { - Debug.Console(2, this, "WARNING No IR Port assigned to controller"); - return; - } - if (!DriverIsLoaded) - { - Debug.Console(2, this, "WARNING IR driver is not loaded"); - return; - } - if (state) - { - if (IrPort.IsIRCommandAvailable(IrPortUid, command)) - IrPort.Press(IrPortUid, command); - else - NoIrCommandError(command); - } - else - IrPort.Release(); - } - - /// - /// Pulses a command on driver. Safe for missing commands - /// - public virtual void Pulse(string command, ushort time) - { - if (IrPort == null) - { - Debug.Console(2, this, "WARNING No IR Port assigned to controller"); - return; - } - if (!DriverIsLoaded) - { - Debug.Console(2, this, "WARNING IR driver is not loaded"); - return; - } - if (IrPort.IsIRCommandAvailable(IrPortUid, command)) - IrPort.PressAndRelease(IrPortUid, command, time); - else - NoIrCommandError(command); - } - - /// - /// Notifies the console when a bad command is used. - /// - protected void NoIrCommandError(string command) - { - Debug.Console(2, this, "Device {0}: IR Driver {1} does not contain command {2}", - Key, IrPort.IRDriverFileNameByIRDriverId(IrPortUid), command); - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Newtonsoft.Json.Linq; +using PepperDash.Essentials.Core.Config; + + +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + + /// + /// IR port wrapper. May act standalone + /// + public class IrOutputPortController : Device + { + uint IrPortUid; + IROutputPort IrPort; + + public BoolFeedback DriverLoaded { get; private set; } + + public ushort StandardIrPulseTime { get; set; } + public string DriverFilepath { get; private set; } + public bool DriverIsLoaded { get; private set; } + + public string[] IrFileCommands { get { return IrPort.AvailableStandardIRCmds(IrPortUid); } } + + public bool UseBridgeJoinMap { get; private set; } + + /// + /// Constructor for IrDevice base class. If a null port is provided, this class will + /// still function without trying to talk to a port. + /// + public IrOutputPortController(string key, IROutputPort port, string irDriverFilepath) + : base(key) + { + //if (port == null) throw new ArgumentNullException("port"); + + DriverLoaded = new BoolFeedback(() => DriverIsLoaded); + IrPort = port; + if (port == null) + { + Debug.Console(0, this, "WARNING No valid IR Port assigned to controller. IR will not function"); + return; + } + LoadDriver(irDriverFilepath); + } + + public IrOutputPortController(string key, Func postActivationFunc, + DeviceConfig config) + : base(key) + { + DriverLoaded = new BoolFeedback(() => DriverIsLoaded); + UseBridgeJoinMap = config.Properties["control"].Value("useBridgeJoinMap"); + AddPostActivationAction(() => + { + IrPort = postActivationFunc(config); + + if (IrPort == null) + { + Debug.Console(0, this, "WARNING No valid IR Port assigned to controller. IR will not function"); + return; + } + + var filePath = Global.FilePathPrefix + "ir" + Global.DirectorySeparator + config.Properties["control"]["irFile"].Value(); + Debug.Console(1, "*************Attempting to load IR file: {0}***************", filePath); + + LoadDriver(filePath); + + PrintAvailableCommands(); + }); + } + + public void PrintAvailableCommands() + { + Debug.Console(2, this, "Available IR Commands in IR File {0}", IrPortUid); + foreach (var cmd in IrPort.AvailableIRCmds()) + { + Debug.Console(2, this, "{0}", cmd); + } + } + + + /// + /// Loads the IR driver at path + /// + /// + public void LoadDriver(string path) + { + Debug.Console(2, this, "***Loading IR File***"); + if (string.IsNullOrEmpty(path)) path = DriverFilepath; + try + { + IrPortUid = IrPort.LoadIRDriver(path); + DriverFilepath = path; + StandardIrPulseTime = 200; + DriverIsLoaded = true; + + DriverLoaded.FireUpdate(); + } + catch + { + DriverIsLoaded = false; + var message = string.Format("WARNING IR Driver '{0}' failed to load", path); + Debug.Console(0, this, Debug.ErrorLogLevel.Error, message); + DriverLoaded.FireUpdate(); + } + } + + + /// + /// Starts and stops IR command on driver. Safe for missing commands + /// + public virtual void PressRelease(string command, bool state) + { + Debug.Console(2, this, "IR:'{0}'={1}", command, state); + if (IrPort == null) + { + Debug.Console(2, this, "WARNING No IR Port assigned to controller"); + return; + } + if (!DriverIsLoaded) + { + Debug.Console(2, this, "WARNING IR driver is not loaded"); + return; + } + if (state) + { + if (IrPort.IsIRCommandAvailable(IrPortUid, command)) + IrPort.Press(IrPortUid, command); + else + NoIrCommandError(command); + } + else + IrPort.Release(); + } + + /// + /// Pulses a command on driver. Safe for missing commands + /// + public virtual void Pulse(string command, ushort time) + { + if (IrPort == null) + { + Debug.Console(2, this, "WARNING No IR Port assigned to controller"); + return; + } + if (!DriverIsLoaded) + { + Debug.Console(2, this, "WARNING IR driver is not loaded"); + return; + } + if (IrPort.IsIRCommandAvailable(IrPortUid, command)) + IrPort.PressAndRelease(IrPortUid, command, time); + else + NoIrCommandError(command); + } + + /// + /// Notifies the console when a bad command is used. + /// + protected void NoIrCommandError(string command) + { + Debug.Console(2, this, "Device {0}: IR Driver {1} does not contain command {2}", + Key, IrPort.IRDriverFileNameByIRDriverId(IrPortUid), command); + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PC/InRoomPc.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PC/InRoomPc.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PC/InRoomPc.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PC/InRoomPc.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PC/Laptop.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PC/Laptop.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PC/Laptop.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PC/Laptop.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PduInterfaces.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PduInterfaces.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PduInterfaces.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PduInterfaces.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PresentationDeviceType.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PresentationDeviceType.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PresentationDeviceType.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PresentationDeviceType.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/REMOVE IHasFeedbacks.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/REMOVE IHasFeedbacks.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/REMOVE IHasFeedbacks.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/REMOVE IHasFeedbacks.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/ReconfigurableDevice.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/ReconfigurableDevice.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/ReconfigurableDevice.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/ReconfigurableDevice.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/SmartObjectBaseTypes.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/SmartObjectBaseTypes.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/SmartObjectBaseTypes.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/SmartObjectBaseTypes.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/SourceListItem.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/SourceListItem.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/SourceListItem.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/SourceListItem.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/VolumeDeviceChangeEventArgs.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/VolumeDeviceChangeEventArgs.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/VolumeDeviceChangeEventArgs.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/VolumeDeviceChangeEventArgs.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/BasicIrDisplay.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/BasicIrDisplay.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/BasicIrDisplay.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/BasicIrDisplay.cs index 3c691c19..7a8eb8b1 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/BasicIrDisplay.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/BasicIrDisplay.cs @@ -1,242 +1,242 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Routing; - -namespace PepperDash.Essentials.Core -{ - [Description("Wrapper class for a Basic IR Display")] - public class BasicIrDisplay : DisplayBase, IBasicVolumeControls, IBridgeAdvanced - { - public IrOutputPortController IrPort { get; private set; } - public ushort IrPulseTime { get; set; } - - [Obsolete("This property will be removed in version 2.0.0")] - public override BoolFeedback PowerIsOnFeedback { get; protected set; } - - protected Func PowerIsOnFeedbackFunc - { - get { return () => _PowerIsOn; } - } - protected override Func IsCoolingDownFeedbackFunc - { - get { return () => _IsCoolingDown; } - } - protected override Func IsWarmingUpFeedbackFunc - { - get { return () => _IsWarmingUp; } - } - - bool _PowerIsOn; - bool _IsWarmingUp; - bool _IsCoolingDown; - - public BasicIrDisplay(string key, string name, IROutputPort port, string irDriverFilepath) - : base(key, name) - { - IrPort = new IrOutputPortController(key + "-ir", port, irDriverFilepath); - DeviceManager.AddDevice(IrPort); - - PowerIsOnFeedback = new BoolFeedback(PowerIsOnFeedbackFunc); - - PowerIsOnFeedback.OutputChange += (o, a) => - { - Debug.Console(2, this, "Power on={0}", _PowerIsOn); - if (_PowerIsOn) StartWarmingTimer(); - else StartCoolingTimer(); - }; - IsWarmingUpFeedback.OutputChange += (o, a) => Debug.Console(2, this, "Warming up={0}", _IsWarmingUp); - IsCoolingDownFeedback.OutputChange += (o, a) => Debug.Console(2, this, "Cooling down={0}", _IsCoolingDown); - - InputPorts.AddRange(new RoutingPortCollection - { - new RoutingInputPort(RoutingPortNames.HdmiIn1, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, new Action(Hdmi1), this, false), - new RoutingInputPort(RoutingPortNames.HdmiIn2, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, new Action(Hdmi2), this, false), - new RoutingInputPort(RoutingPortNames.HdmiIn3, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, new Action(Hdmi3), this, false), - new RoutingInputPort(RoutingPortNames.HdmiIn4, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, new Action(Hdmi4), this, false), - new RoutingInputPort(RoutingPortNames.ComponentIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, new Action(Component1), this, false), - new RoutingInputPort(RoutingPortNames.CompositeIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, new Action(Video1), this, false), - new RoutingInputPort(RoutingPortNames.AntennaIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, new Action(Antenna), this, false), - }); - } - - public void Hdmi1() - { - IrPort.Pulse(IROutputStandardCommands.IROut_HDMI_1, IrPulseTime); - } - - public void Hdmi2() - { - IrPort.Pulse(IROutputStandardCommands.IROut_HDMI_2, IrPulseTime); - } - - public void Hdmi3() - { - IrPort.Pulse(IROutputStandardCommands.IROut_HDMI_3, IrPulseTime); - } - - public void Hdmi4() - { - IrPort.Pulse(IROutputStandardCommands.IROut_HDMI_4, IrPulseTime); - } - - public void Component1() - { - IrPort.Pulse(IROutputStandardCommands.IROut_COMPONENT_1, IrPulseTime); - } - - public void Video1() - { - IrPort.Pulse(IROutputStandardCommands.IROut_VIDEO_1, IrPulseTime); - } - - public void Antenna() - { - IrPort.Pulse(IROutputStandardCommands.IROut_ANTENNA, IrPulseTime); - } - - #region IPower Members - - public override void PowerOn() - { - IrPort.Pulse(IROutputStandardCommands.IROut_POWER_ON, IrPulseTime); - _PowerIsOn = true; - PowerIsOnFeedback.FireUpdate(); - } - - public override void PowerOff() - { - _PowerIsOn = false; - PowerIsOnFeedback.FireUpdate(); - IrPort.Pulse(IROutputStandardCommands.IROut_POWER_OFF, IrPulseTime); - } - - public override void PowerToggle() - { - _PowerIsOn = false; - PowerIsOnFeedback.FireUpdate(); - IrPort.Pulse(IROutputStandardCommands.IROut_POWER, IrPulseTime); - } - - #endregion - - #region IBasicVolumeControls Members - - public void VolumeUp(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_VOL_PLUS, pressRelease); - } - - public void VolumeDown(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_VOL_MINUS, pressRelease); - } - - public void MuteToggle() - { - IrPort.Pulse(IROutputStandardCommands.IROut_MUTE, 200); - } - - #endregion - - void StartWarmingTimer() - { - _IsWarmingUp = true; - IsWarmingUpFeedback.FireUpdate(); - new CTimer(o => { - _IsWarmingUp = false; - IsWarmingUpFeedback.FireUpdate(); - }, 10000); - } - - void StartCoolingTimer() - { - _IsCoolingDown = true; - IsCoolingDownFeedback.FireUpdate(); - new CTimer(o => - { - _IsCoolingDown = false; - IsCoolingDownFeedback.FireUpdate(); - }, 7000); - } - - #region IRoutingSink Members - - /// - /// Typically called by the discovery routing algorithm. - /// - /// A delegate containing the input selector method to call - public override void ExecuteSwitch(object inputSelector) - { - Debug.Console(2, this, "Switching to input '{0}'", (inputSelector as Action).ToString()); - - Action finishSwitch = () => - { - var action = inputSelector as Action; - if (action != null) - action(); - }; - - if (!PowerIsOnFeedback.BoolValue) - { - PowerOn(); - EventHandler oneTimer = null; - oneTimer = (o, a) => - { - if (IsWarmingUpFeedback.BoolValue) return; // Only catch done warming - IsWarmingUpFeedback.OutputChange -= oneTimer; - finishSwitch(); - }; - IsWarmingUpFeedback.OutputChange += oneTimer; - } - else // Do it! - finishSwitch(); - } - - #endregion - - public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - LinkDisplayToApi(this, trilist, joinStart, joinMapKey, bridge); - } - } - - public class BasicIrDisplayFactory : EssentialsDeviceFactory - { - public BasicIrDisplayFactory() - { - TypeNames = new List() { "basicirdisplay" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new BasicIrDisplay Device"); - var ir = IRPortHelper.GetIrPort(dc.Properties); - if (ir != null) - { - var display = new BasicIrDisplay(dc.Key, dc.Name, ir.Port, ir.FileName); - display.IrPulseTime = 200; // Set default pulse time for IR commands. - return display; - } - - return null; - } - } - +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Routing; + +namespace PepperDash.Essentials.Core +{ + [Description("Wrapper class for a Basic IR Display")] + public class BasicIrDisplay : DisplayBase, IBasicVolumeControls, IBridgeAdvanced + { + public IrOutputPortController IrPort { get; private set; } + public ushort IrPulseTime { get; set; } + + [Obsolete("This property will be removed in version 2.0.0")] + public override BoolFeedback PowerIsOnFeedback { get; protected set; } + + protected Func PowerIsOnFeedbackFunc + { + get { return () => _PowerIsOn; } + } + protected override Func IsCoolingDownFeedbackFunc + { + get { return () => _IsCoolingDown; } + } + protected override Func IsWarmingUpFeedbackFunc + { + get { return () => _IsWarmingUp; } + } + + bool _PowerIsOn; + bool _IsWarmingUp; + bool _IsCoolingDown; + + public BasicIrDisplay(string key, string name, IROutputPort port, string irDriverFilepath) + : base(key, name) + { + IrPort = new IrOutputPortController(key + "-ir", port, irDriverFilepath); + DeviceManager.AddDevice(IrPort); + + PowerIsOnFeedback = new BoolFeedback(PowerIsOnFeedbackFunc); + + PowerIsOnFeedback.OutputChange += (o, a) => + { + Debug.Console(2, this, "Power on={0}", _PowerIsOn); + if (_PowerIsOn) StartWarmingTimer(); + else StartCoolingTimer(); + }; + IsWarmingUpFeedback.OutputChange += (o, a) => Debug.Console(2, this, "Warming up={0}", _IsWarmingUp); + IsCoolingDownFeedback.OutputChange += (o, a) => Debug.Console(2, this, "Cooling down={0}", _IsCoolingDown); + + InputPorts.AddRange(new RoutingPortCollection + { + new RoutingInputPort(RoutingPortNames.HdmiIn1, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, new Action(Hdmi1), this, false), + new RoutingInputPort(RoutingPortNames.HdmiIn2, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, new Action(Hdmi2), this, false), + new RoutingInputPort(RoutingPortNames.HdmiIn3, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, new Action(Hdmi3), this, false), + new RoutingInputPort(RoutingPortNames.HdmiIn4, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, new Action(Hdmi4), this, false), + new RoutingInputPort(RoutingPortNames.ComponentIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, new Action(Component1), this, false), + new RoutingInputPort(RoutingPortNames.CompositeIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, new Action(Video1), this, false), + new RoutingInputPort(RoutingPortNames.AntennaIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, new Action(Antenna), this, false), + }); + } + + public void Hdmi1() + { + IrPort.Pulse(IROutputStandardCommands.IROut_HDMI_1, IrPulseTime); + } + + public void Hdmi2() + { + IrPort.Pulse(IROutputStandardCommands.IROut_HDMI_2, IrPulseTime); + } + + public void Hdmi3() + { + IrPort.Pulse(IROutputStandardCommands.IROut_HDMI_3, IrPulseTime); + } + + public void Hdmi4() + { + IrPort.Pulse(IROutputStandardCommands.IROut_HDMI_4, IrPulseTime); + } + + public void Component1() + { + IrPort.Pulse(IROutputStandardCommands.IROut_COMPONENT_1, IrPulseTime); + } + + public void Video1() + { + IrPort.Pulse(IROutputStandardCommands.IROut_VIDEO_1, IrPulseTime); + } + + public void Antenna() + { + IrPort.Pulse(IROutputStandardCommands.IROut_ANTENNA, IrPulseTime); + } + + #region IPower Members + + public override void PowerOn() + { + IrPort.Pulse(IROutputStandardCommands.IROut_POWER_ON, IrPulseTime); + _PowerIsOn = true; + PowerIsOnFeedback.FireUpdate(); + } + + public override void PowerOff() + { + _PowerIsOn = false; + PowerIsOnFeedback.FireUpdate(); + IrPort.Pulse(IROutputStandardCommands.IROut_POWER_OFF, IrPulseTime); + } + + public override void PowerToggle() + { + _PowerIsOn = false; + PowerIsOnFeedback.FireUpdate(); + IrPort.Pulse(IROutputStandardCommands.IROut_POWER, IrPulseTime); + } + + #endregion + + #region IBasicVolumeControls Members + + public void VolumeUp(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_VOL_PLUS, pressRelease); + } + + public void VolumeDown(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_VOL_MINUS, pressRelease); + } + + public void MuteToggle() + { + IrPort.Pulse(IROutputStandardCommands.IROut_MUTE, 200); + } + + #endregion + + void StartWarmingTimer() + { + _IsWarmingUp = true; + IsWarmingUpFeedback.FireUpdate(); + new CTimer(o => { + _IsWarmingUp = false; + IsWarmingUpFeedback.FireUpdate(); + }, 10000); + } + + void StartCoolingTimer() + { + _IsCoolingDown = true; + IsCoolingDownFeedback.FireUpdate(); + new CTimer(o => + { + _IsCoolingDown = false; + IsCoolingDownFeedback.FireUpdate(); + }, 7000); + } + + #region IRoutingSink Members + + /// + /// Typically called by the discovery routing algorithm. + /// + /// A delegate containing the input selector method to call + public override void ExecuteSwitch(object inputSelector) + { + Debug.Console(2, this, "Switching to input '{0}'", (inputSelector as Action).ToString()); + + Action finishSwitch = () => + { + var action = inputSelector as Action; + if (action != null) + action(); + }; + + if (!PowerIsOnFeedback.BoolValue) + { + PowerOn(); + EventHandler oneTimer = null; + oneTimer = (o, a) => + { + if (IsWarmingUpFeedback.BoolValue) return; // Only catch done warming + IsWarmingUpFeedback.OutputChange -= oneTimer; + finishSwitch(); + }; + IsWarmingUpFeedback.OutputChange += oneTimer; + } + else // Do it! + finishSwitch(); + } + + #endregion + + public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + LinkDisplayToApi(this, trilist, joinStart, joinMapKey, bridge); + } + } + + public class BasicIrDisplayFactory : EssentialsDeviceFactory + { + public BasicIrDisplayFactory() + { + TypeNames = new List() { "basicirdisplay" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new BasicIrDisplay Device"); + var ir = IRPortHelper.GetIrPort(dc.Properties); + if (ir != null) + { + var display = new BasicIrDisplay(dc.Key, dc.Name, ir.Port, ir.FileName); + display.IrPulseTime = 200; // Set default pulse time for IR commands. + return display; + } + + return null; + } + } + } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs similarity index 97% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs index d374099f..ef1462ec 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs @@ -1,326 +1,326 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; -using Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core.Bridges; - - -namespace PepperDash.Essentials.Core -{ - /// - /// - /// - public abstract class DisplayBase : EssentialsDevice, IHasFeedback, IRoutingSinkWithSwitching, IHasPowerControl, IWarmingCooling, IUsageTracking, IPower - { - public event SourceInfoChangeHandler CurrentSourceChange; - - public string CurrentSourceInfoKey { get; set; } - public SourceListItem CurrentSourceInfo - { - get - { - return _CurrentSourceInfo; - } - set - { - if (value == _CurrentSourceInfo) return; - - var handler = CurrentSourceChange; - - if (handler != null) - handler(_CurrentSourceInfo, ChangeType.WillChange); - - _CurrentSourceInfo = value; - - if (handler != null) - handler(_CurrentSourceInfo, ChangeType.DidChange); - } - } - SourceListItem _CurrentSourceInfo; - - public BoolFeedback IsCoolingDownFeedback { get; protected set; } - public BoolFeedback IsWarmingUpFeedback { get; private set; } - - [Obsolete("This property will be removed in version 2.0.0")] - public abstract BoolFeedback PowerIsOnFeedback { get; protected set; } - - public UsageTracking UsageTracker { get; set; } - - public uint WarmupTime { get; set; } - public uint CooldownTime { get; set; } - - /// - /// Bool Func that will provide a value for the PowerIsOn Output. Must be implemented - /// by concrete sub-classes - /// - abstract protected Func IsCoolingDownFeedbackFunc { get; } - abstract protected Func IsWarmingUpFeedbackFunc { get; } - - - protected CTimer WarmupTimer; - protected CTimer CooldownTimer; - - #region IRoutingInputs Members - - public RoutingPortCollection InputPorts { get; private set; } - - #endregion - - protected DisplayBase(string key, string name) - : base(key, name) - { - IsCoolingDownFeedback = new BoolFeedback("IsCoolingDown", IsCoolingDownFeedbackFunc); - IsWarmingUpFeedback = new BoolFeedback("IsWarmingUp", IsWarmingUpFeedbackFunc); - - InputPorts = new RoutingPortCollection(); - - } - - public abstract void PowerOn(); - public abstract void PowerOff(); - public abstract void PowerToggle(); - - public virtual FeedbackCollection Feedbacks - { - get - { - return new FeedbackCollection - { - IsCoolingDownFeedback, - IsWarmingUpFeedback - }; - } - } - - public abstract void ExecuteSwitch(object selector); - - protected void LinkDisplayToApi(DisplayBase displayDevice, BasicTriList trilist, uint joinStart, string joinMapKey, - EiscApiAdvanced bridge) - { - var joinMap = new DisplayControllerJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0,this,"Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - LinkDisplayToApi(displayDevice, trilist, joinMap); - } - - protected void LinkDisplayToApi(DisplayBase displayDevice, BasicTriList trilist, DisplayControllerJoinMap joinMap) - { - Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - Debug.Console(0, "Linking to Display: {0}", displayDevice.Name); - - trilist.StringInput[joinMap.Name.JoinNumber].StringValue = displayDevice.Name; - - var commMonitor = displayDevice as ICommunicationMonitor; - if (commMonitor != null) - { - commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - } - - var inputNumber = 0; - var inputKeys = new List(); - - var inputNumberFeedback = new IntFeedback(() => inputNumber); - - // Two way feedbacks - var twoWayDisplay = displayDevice as TwoWayDisplayBase; - - if (twoWayDisplay != null) - { - trilist.SetBool(joinMap.IsTwoWayDisplay.JoinNumber, true); - - twoWayDisplay.CurrentInputFeedback.OutputChange += (o, a) => Debug.Console(0, "CurrentInputFeedback_OutputChange {0}", a.StringValue); - - - inputNumberFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputSelect.JoinNumber]); - } - - // Power Off - trilist.SetSigTrueAction(joinMap.PowerOff.JoinNumber, () => - { - inputNumber = 102; - inputNumberFeedback.FireUpdate(); - displayDevice.PowerOff(); - }); - - var twoWayDisplayDevice = displayDevice as TwoWayDisplayBase; - if (twoWayDisplayDevice != null) - { - twoWayDisplayDevice.PowerIsOnFeedback.OutputChange += (o, a) => - { - if (!a.BoolValue) - { - inputNumber = 102; - inputNumberFeedback.FireUpdate(); - - } - else - { - inputNumber = 0; - inputNumberFeedback.FireUpdate(); - } - }; - - twoWayDisplayDevice.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff.JoinNumber]); - twoWayDisplayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn.JoinNumber]); - } - - // PowerOn - trilist.SetSigTrueAction(joinMap.PowerOn.JoinNumber, () => - { - inputNumber = 0; - inputNumberFeedback.FireUpdate(); - displayDevice.PowerOn(); - }); - - - - for (int i = 0; i < displayDevice.InputPorts.Count; i++) - { - if (i < joinMap.InputNamesOffset.JoinSpan) - { - inputKeys.Add(displayDevice.InputPorts[i].Key); - var tempKey = inputKeys.ElementAt(i); - trilist.SetSigTrueAction((ushort)(joinMap.InputSelectOffset.JoinNumber + i), - () => displayDevice.ExecuteSwitch(displayDevice.InputPorts[tempKey].Selector)); - Debug.Console(2, displayDevice, "Setting Input Select Action on Digital Join {0} to Input: {1}", - joinMap.InputSelectOffset.JoinNumber + i, displayDevice.InputPorts[tempKey].Key.ToString()); - trilist.StringInput[(ushort)(joinMap.InputNamesOffset.JoinNumber + i)].StringValue = displayDevice.InputPorts[i].Key.ToString(); - } - else - Debug.Console(0, displayDevice, Debug.ErrorLogLevel.Warning, "Device has {0} inputs. The Join Map allows up to {1} inputs. Discarding inputs {2} - {3} from bridge.", - displayDevice.InputPorts.Count, joinMap.InputNamesOffset.JoinSpan, i + 1, displayDevice.InputPorts.Count); - } - - Debug.Console(2, displayDevice, "Setting Input Select Action on Analog Join {0}", joinMap.InputSelect); - trilist.SetUShortSigAction(joinMap.InputSelect.JoinNumber, (a) => - { - if (a == 0) - { - displayDevice.PowerOff(); - inputNumber = 0; - } - else if (a > 0 && a < displayDevice.InputPorts.Count && a != inputNumber) - { - displayDevice.ExecuteSwitch(displayDevice.InputPorts.ElementAt(a - 1).Selector); - inputNumber = a; - } - else if (a == 102) - { - displayDevice.PowerToggle(); - - } - if (twoWayDisplay != null) - inputNumberFeedback.FireUpdate(); - }); - - - var volumeDisplay = displayDevice as IBasicVolumeControls; - if (volumeDisplay == null) return; - - trilist.SetBoolSigAction(joinMap.VolumeUp.JoinNumber, volumeDisplay.VolumeUp); - trilist.SetBoolSigAction(joinMap.VolumeDown.JoinNumber, volumeDisplay.VolumeDown); - trilist.SetSigTrueAction(joinMap.VolumeMute.JoinNumber, volumeDisplay.MuteToggle); - - var volumeDisplayWithFeedback = volumeDisplay as IBasicVolumeWithFeedback; - - if (volumeDisplayWithFeedback == null) return; - trilist.SetSigTrueAction(joinMap.VolumeMuteOn.JoinNumber, volumeDisplayWithFeedback.MuteOn); - trilist.SetSigTrueAction(joinMap.VolumeMuteOff.JoinNumber, volumeDisplayWithFeedback.MuteOff); - - - trilist.SetUShortSigAction(joinMap.VolumeLevel.JoinNumber, volumeDisplayWithFeedback.SetVolume); - volumeDisplayWithFeedback.VolumeLevelFeedback.LinkInputSig(trilist.UShortInput[joinMap.VolumeLevel.JoinNumber]); - volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMute.JoinNumber]); - volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMuteOn.JoinNumber]); - volumeDisplayWithFeedback.MuteFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.VolumeMuteOff.JoinNumber]); - } - - } - - /// - /// - /// - public abstract class TwoWayDisplayBase : DisplayBase, IRoutingFeedback, IHasPowerControlWithFeedback - { - public StringFeedback CurrentInputFeedback { get; private set; } - - abstract protected Func CurrentInputFeedbackFunc { get; } - - public override BoolFeedback PowerIsOnFeedback { get; protected set; } - - abstract protected Func PowerIsOnFeedbackFunc { get; } - - - public static MockDisplay DefaultDisplay - { - get - { - if (_DefaultDisplay == null) - _DefaultDisplay = new MockDisplay("default", "Default Display"); - return _DefaultDisplay; - } - } - static MockDisplay _DefaultDisplay; - - public TwoWayDisplayBase(string key, string name) - : base(key, name) - { - CurrentInputFeedback = new StringFeedback(CurrentInputFeedbackFunc); - - WarmupTime = 7000; - CooldownTime = 15000; - - PowerIsOnFeedback = new BoolFeedback("PowerOnFeedback", PowerIsOnFeedbackFunc); - - Feedbacks.Add(CurrentInputFeedback); - Feedbacks.Add(PowerIsOnFeedback); - - PowerIsOnFeedback.OutputChange += PowerIsOnFeedback_OutputChange; - - } - - void PowerIsOnFeedback_OutputChange(object sender, EventArgs e) - { - if (UsageTracker != null) - { - if (PowerIsOnFeedback.BoolValue) - UsageTracker.StartDeviceUsage(); - else - UsageTracker.EndDeviceUsage(); - } - } - - public event EventHandler NumericSwitchChange; - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - protected void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; +using Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core.Bridges; + + +namespace PepperDash.Essentials.Core +{ + /// + /// + /// + public abstract class DisplayBase : EssentialsDevice, IHasFeedback, IRoutingSinkWithSwitching, IHasPowerControl, IWarmingCooling, IUsageTracking, IPower + { + public event SourceInfoChangeHandler CurrentSourceChange; + + public string CurrentSourceInfoKey { get; set; } + public SourceListItem CurrentSourceInfo + { + get + { + return _CurrentSourceInfo; + } + set + { + if (value == _CurrentSourceInfo) return; + + var handler = CurrentSourceChange; + + if (handler != null) + handler(_CurrentSourceInfo, ChangeType.WillChange); + + _CurrentSourceInfo = value; + + if (handler != null) + handler(_CurrentSourceInfo, ChangeType.DidChange); + } + } + SourceListItem _CurrentSourceInfo; + + public BoolFeedback IsCoolingDownFeedback { get; protected set; } + public BoolFeedback IsWarmingUpFeedback { get; private set; } + + [Obsolete("This property will be removed in version 2.0.0")] + public abstract BoolFeedback PowerIsOnFeedback { get; protected set; } + + public UsageTracking UsageTracker { get; set; } + + public uint WarmupTime { get; set; } + public uint CooldownTime { get; set; } + + /// + /// Bool Func that will provide a value for the PowerIsOn Output. Must be implemented + /// by concrete sub-classes + /// + abstract protected Func IsCoolingDownFeedbackFunc { get; } + abstract protected Func IsWarmingUpFeedbackFunc { get; } + + + protected CTimer WarmupTimer; + protected CTimer CooldownTimer; + + #region IRoutingInputs Members + + public RoutingPortCollection InputPorts { get; private set; } + + #endregion + + protected DisplayBase(string key, string name) + : base(key, name) + { + IsCoolingDownFeedback = new BoolFeedback("IsCoolingDown", IsCoolingDownFeedbackFunc); + IsWarmingUpFeedback = new BoolFeedback("IsWarmingUp", IsWarmingUpFeedbackFunc); + + InputPorts = new RoutingPortCollection(); + + } + + public abstract void PowerOn(); + public abstract void PowerOff(); + public abstract void PowerToggle(); + + public virtual FeedbackCollection Feedbacks + { + get + { + return new FeedbackCollection + { + IsCoolingDownFeedback, + IsWarmingUpFeedback + }; + } + } + + public abstract void ExecuteSwitch(object selector); + + protected void LinkDisplayToApi(DisplayBase displayDevice, BasicTriList trilist, uint joinStart, string joinMapKey, + EiscApiAdvanced bridge) + { + var joinMap = new DisplayControllerJoinMap(joinStart); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + else + { + Debug.Console(0,this,"Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + } + + LinkDisplayToApi(displayDevice, trilist, joinMap); + } + + protected void LinkDisplayToApi(DisplayBase displayDevice, BasicTriList trilist, DisplayControllerJoinMap joinMap) + { + Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.Console(0, "Linking to Display: {0}", displayDevice.Name); + + trilist.StringInput[joinMap.Name.JoinNumber].StringValue = displayDevice.Name; + + var commMonitor = displayDevice as ICommunicationMonitor; + if (commMonitor != null) + { + commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + } + + var inputNumber = 0; + var inputKeys = new List(); + + var inputNumberFeedback = new IntFeedback(() => inputNumber); + + // Two way feedbacks + var twoWayDisplay = displayDevice as TwoWayDisplayBase; + + if (twoWayDisplay != null) + { + trilist.SetBool(joinMap.IsTwoWayDisplay.JoinNumber, true); + + twoWayDisplay.CurrentInputFeedback.OutputChange += (o, a) => Debug.Console(0, "CurrentInputFeedback_OutputChange {0}", a.StringValue); + + + inputNumberFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputSelect.JoinNumber]); + } + + // Power Off + trilist.SetSigTrueAction(joinMap.PowerOff.JoinNumber, () => + { + inputNumber = 102; + inputNumberFeedback.FireUpdate(); + displayDevice.PowerOff(); + }); + + var twoWayDisplayDevice = displayDevice as TwoWayDisplayBase; + if (twoWayDisplayDevice != null) + { + twoWayDisplayDevice.PowerIsOnFeedback.OutputChange += (o, a) => + { + if (!a.BoolValue) + { + inputNumber = 102; + inputNumberFeedback.FireUpdate(); + + } + else + { + inputNumber = 0; + inputNumberFeedback.FireUpdate(); + } + }; + + twoWayDisplayDevice.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff.JoinNumber]); + twoWayDisplayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn.JoinNumber]); + } + + // PowerOn + trilist.SetSigTrueAction(joinMap.PowerOn.JoinNumber, () => + { + inputNumber = 0; + inputNumberFeedback.FireUpdate(); + displayDevice.PowerOn(); + }); + + + + for (int i = 0; i < displayDevice.InputPorts.Count; i++) + { + if (i < joinMap.InputNamesOffset.JoinSpan) + { + inputKeys.Add(displayDevice.InputPorts[i].Key); + var tempKey = inputKeys.ElementAt(i); + trilist.SetSigTrueAction((ushort)(joinMap.InputSelectOffset.JoinNumber + i), + () => displayDevice.ExecuteSwitch(displayDevice.InputPorts[tempKey].Selector)); + Debug.Console(2, displayDevice, "Setting Input Select Action on Digital Join {0} to Input: {1}", + joinMap.InputSelectOffset.JoinNumber + i, displayDevice.InputPorts[tempKey].Key.ToString()); + trilist.StringInput[(ushort)(joinMap.InputNamesOffset.JoinNumber + i)].StringValue = displayDevice.InputPorts[i].Key.ToString(); + } + else + Debug.Console(0, displayDevice, Debug.ErrorLogLevel.Warning, "Device has {0} inputs. The Join Map allows up to {1} inputs. Discarding inputs {2} - {3} from bridge.", + displayDevice.InputPorts.Count, joinMap.InputNamesOffset.JoinSpan, i + 1, displayDevice.InputPorts.Count); + } + + Debug.Console(2, displayDevice, "Setting Input Select Action on Analog Join {0}", joinMap.InputSelect); + trilist.SetUShortSigAction(joinMap.InputSelect.JoinNumber, (a) => + { + if (a == 0) + { + displayDevice.PowerOff(); + inputNumber = 0; + } + else if (a > 0 && a < displayDevice.InputPorts.Count && a != inputNumber) + { + displayDevice.ExecuteSwitch(displayDevice.InputPorts.ElementAt(a - 1).Selector); + inputNumber = a; + } + else if (a == 102) + { + displayDevice.PowerToggle(); + + } + if (twoWayDisplay != null) + inputNumberFeedback.FireUpdate(); + }); + + + var volumeDisplay = displayDevice as IBasicVolumeControls; + if (volumeDisplay == null) return; + + trilist.SetBoolSigAction(joinMap.VolumeUp.JoinNumber, volumeDisplay.VolumeUp); + trilist.SetBoolSigAction(joinMap.VolumeDown.JoinNumber, volumeDisplay.VolumeDown); + trilist.SetSigTrueAction(joinMap.VolumeMute.JoinNumber, volumeDisplay.MuteToggle); + + var volumeDisplayWithFeedback = volumeDisplay as IBasicVolumeWithFeedback; + + if (volumeDisplayWithFeedback == null) return; + trilist.SetSigTrueAction(joinMap.VolumeMuteOn.JoinNumber, volumeDisplayWithFeedback.MuteOn); + trilist.SetSigTrueAction(joinMap.VolumeMuteOff.JoinNumber, volumeDisplayWithFeedback.MuteOff); + + + trilist.SetUShortSigAction(joinMap.VolumeLevel.JoinNumber, volumeDisplayWithFeedback.SetVolume); + volumeDisplayWithFeedback.VolumeLevelFeedback.LinkInputSig(trilist.UShortInput[joinMap.VolumeLevel.JoinNumber]); + volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMute.JoinNumber]); + volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMuteOn.JoinNumber]); + volumeDisplayWithFeedback.MuteFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.VolumeMuteOff.JoinNumber]); + } + + } + + /// + /// + /// + public abstract class TwoWayDisplayBase : DisplayBase, IRoutingFeedback, IHasPowerControlWithFeedback + { + public StringFeedback CurrentInputFeedback { get; private set; } + + abstract protected Func CurrentInputFeedbackFunc { get; } + + public override BoolFeedback PowerIsOnFeedback { get; protected set; } + + abstract protected Func PowerIsOnFeedbackFunc { get; } + + + public static MockDisplay DefaultDisplay + { + get + { + if (_DefaultDisplay == null) + _DefaultDisplay = new MockDisplay("default", "Default Display"); + return _DefaultDisplay; + } + } + static MockDisplay _DefaultDisplay; + + public TwoWayDisplayBase(string key, string name) + : base(key, name) + { + CurrentInputFeedback = new StringFeedback(CurrentInputFeedbackFunc); + + WarmupTime = 7000; + CooldownTime = 15000; + + PowerIsOnFeedback = new BoolFeedback("PowerOnFeedback", PowerIsOnFeedbackFunc); + + Feedbacks.Add(CurrentInputFeedback); + Feedbacks.Add(PowerIsOnFeedback); + + PowerIsOnFeedback.OutputChange += PowerIsOnFeedback_OutputChange; + + } + + void PowerIsOnFeedback_OutputChange(object sender, EventArgs e) + { + if (UsageTracker != null) + { + if (PowerIsOnFeedback.BoolValue) + UsageTracker.StartDeviceUsage(); + else + UsageTracker.EndDeviceUsage(); + } + } + + public event EventHandler NumericSwitchChange; + + /// + /// Raise an event when the status of a switch object changes. + /// + /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType + protected void OnSwitchChange(RoutingNumericEventArgs e) + { + var newEvent = NumericSwitchChange; + if (newEvent != null) newEvent(this, e); + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/MockDisplay.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/MockDisplay.cs similarity index 99% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/MockDisplay.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/MockDisplay.cs index 266c1cbb..d7f36f13 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/MockDisplay.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/MockDisplay.cs @@ -30,39 +30,39 @@ namespace PepperDash.Essentials.Core bool _PowerIsOn; bool _IsWarmingUp; - bool _IsCoolingDown; - - protected override Func PowerIsOnFeedbackFunc - { - get - { - return () => - { - Debug.Console(2, this, "*************************************************** Display Power is {0}", _PowerIsOn ? "on" : "off"); - return _PowerIsOn; + bool _IsCoolingDown; + + protected override Func PowerIsOnFeedbackFunc + { + get + { + return () => + { + Debug.Console(2, this, "*************************************************** Display Power is {0}", _PowerIsOn ? "on" : "off"); + return _PowerIsOn; }; } } - protected override Func IsCoolingDownFeedbackFunc - { - get - { - return () => - { - Debug.Console(2, this, "*************************************************** {0}", _IsCoolingDown ? "Display is cooling down" : "Display has finished cooling down"); - return _IsCoolingDown; - }; - } + protected override Func IsCoolingDownFeedbackFunc + { + get + { + return () => + { + Debug.Console(2, this, "*************************************************** {0}", _IsCoolingDown ? "Display is cooling down" : "Display has finished cooling down"); + return _IsCoolingDown; + }; + } } protected override Func IsWarmingUpFeedbackFunc - { - get - { - return () => - { - Debug.Console(2, this, "*************************************************** {0}", _IsWarmingUp ? "Display is warming up" : "Display has finished warming up"); - return _IsWarmingUp; - }; - } + { + get + { + return () => + { + Debug.Console(2, this, "*************************************************** {0}", _IsWarmingUp ? "Display is warming up" : "Display has finished warming up"); + return _IsWarmingUp; + }; + } } protected override Func CurrentInputFeedbackFunc { get { return () => "Not Implemented"; } } @@ -123,8 +123,8 @@ namespace PepperDash.Essentials.Core { Debug.Console(2, this, "Cooldown timer ending"); _IsCoolingDown = false; - IsCoolingDownFeedback.InvokeFireUpdate(); - _PowerIsOn = false; + IsCoolingDownFeedback.InvokeFireUpdate(); + _PowerIsOn = false; PowerIsOnFeedback.InvokeFireUpdate(); }, CooldownTime); } @@ -140,11 +140,11 @@ namespace PepperDash.Essentials.Core public override void ExecuteSwitch(object selector) { - Debug.Console(2, this, "ExecuteSwitch: {0}", selector); - - if (!_PowerIsOn) - { - PowerOn(); + Debug.Console(2, this, "ExecuteSwitch: {0}", selector); + + if (!_PowerIsOn) + { + PowerOn(); } } diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Ethernet/EthernetStatistics.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Ethernet/EthernetStatistics.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Ethernet/EthernetStatistics.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Ethernet/EthernetStatistics.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Extensions/JsonExtensions.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Extensions/JsonExtensions.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Extensions/JsonExtensions.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Extensions/JsonExtensions.cs index cdf723ea..05d0044e 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Extensions/JsonExtensions.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Extensions/JsonExtensions.cs @@ -1,42 +1,42 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace PepperDash.Essentials.Core -{ - public static class JsonExtensions - { - public static List FindTokens(this JToken containerToken, string name) - { - List matches = new List(); - FindTokens(containerToken, name, matches); - return matches; - } - - private static void FindTokens(JToken containerToken, string name, List matches) - { - if (containerToken.Type == JTokenType.Object) - { - foreach (JProperty child in containerToken.Children()) - { - if (child.Name == name) - { - matches.Add(child.Value); - } - FindTokens(child.Value, name, matches); - } - } - else if (containerToken.Type == JTokenType.Array) - { - foreach (JToken child in containerToken.Children()) - { - FindTokens(child, name, matches); - } - } - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace PepperDash.Essentials.Core +{ + public static class JsonExtensions + { + public static List FindTokens(this JToken containerToken, string name) + { + List matches = new List(); + FindTokens(containerToken, name, matches); + return matches; + } + + private static void FindTokens(JToken containerToken, string name, List matches) + { + if (containerToken.Type == JTokenType.Object) + { + foreach (JProperty child in containerToken.Children()) + { + if (child.Name == name) + { + matches.Add(child.Value); + } + FindTokens(child.Value, name, matches); + } + } + else if (containerToken.Type == JTokenType.Array) + { + foreach (JToken child in containerToken.Children()) + { + FindTokens(child, name, matches); + } + } + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Extensions/StringExtensions.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Extensions/StringExtensions.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Extensions/StringExtensions.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Extensions/StringExtensions.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs similarity index 97% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs index 5948de2b..e3c767df 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs @@ -1,213 +1,213 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.GeneralIO; -using Crestron.SimplSharp.Reflection; -using PepperDash.Core; -using Newtonsoft.Json.Linq; -using Newtonsoft.Json; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.Core.CrestronIO; -using PepperDash.Essentials.Core.Touchpanels; - -namespace PepperDash.Essentials.Core -{ - public class DeviceFactoryWrapper - { - public CType CType { get; set; } - public string Description { get; set; } - public Func FactoryMethod { get; set; } - - public DeviceFactoryWrapper() - { - CType = null; - Description = "Not Available"; - } - } - - public class DeviceFactory - { - public DeviceFactory() - { - var assy = Assembly.GetExecutingAssembly(); - PluginLoader.SetEssentialsAssembly(assy.GetName().Name, assy); - - var types = assy.GetTypes().Where(ct => typeof(IDeviceFactory).IsAssignableFrom(ct) && !ct.IsInterface && !ct.IsAbstract); - - if (types != null) - { - foreach (var type in types) - { - try - { - var factory = (IDeviceFactory)Crestron.SimplSharp.Reflection.Activator.CreateInstance(type); - factory.LoadTypeFactories(); - } - catch (Exception e) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to load type: '{1}' DeviceFactory: {0}", e, type.Name); - } - } - } - } - - /// - /// A dictionary of factory methods, keyed by config types, added by plugins. - /// These methods are looked up and called by GetDevice in this class. - /// - static Dictionary FactoryMethods = - new Dictionary(StringComparer.OrdinalIgnoreCase); - - /// - /// Adds a plugin factory method - /// - /// - /// - public static void AddFactoryForType(string typeName, Func method) - { - //Debug.Console(1, Debug.ErrorLogLevel.Notice, "Adding factory method for type '{0}'", typeName); - DeviceFactory.FactoryMethods.Add(typeName, new DeviceFactoryWrapper() { FactoryMethod = method}); - } - - public static void AddFactoryForType(string typeName, string description, CType cType, Func method) - { - //Debug.Console(1, Debug.ErrorLogLevel.Notice, "Adding factory method for type '{0}'", typeName); - - if(FactoryMethods.ContainsKey(typeName)) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to add type: '{0}'. Already exists in DeviceFactory", typeName); - return; - } - - var wrapper = new DeviceFactoryWrapper() { CType = cType, Description = description, FactoryMethod = method }; - DeviceFactory.FactoryMethods.Add(typeName, wrapper); - } - - private static void CheckForSecrets(IEnumerable obj) - { - foreach (var prop in obj.Where(prop => prop.Value as JObject != null)) - { - if (prop.Name.ToLower() == "secret") - { - var secret = GetSecret(prop.Children().First().ToObject()); - //var secret = GetSecret(JsonConvert.DeserializeObject(prop.Children().First().ToString())); - prop.Parent.Replace(secret); - } - var recurseProp = prop.Value as JObject; - if (recurseProp == null) return; - CheckForSecrets(recurseProp.Properties()); - } - } - - private static string GetSecret(SecretsPropertiesConfig data) - { - var secretProvider = SecretsManager.GetSecretProviderByKey(data.Provider); - if (secretProvider == null) return null; - var secret = secretProvider.GetSecret(data.Key); - if (secret != null) return (string) secret.Value; - Debug.Console(1, - "Unable to retrieve secret {0}{1} - Make sure you've added it to the secrets provider", - data.Provider, data.Key); - return String.Empty; - } - - - /// - /// The factory method for Core "things". Also iterates the Factory methods that have - /// been loaded from plugins - /// - /// - /// - public static IKeyed GetDevice(DeviceConfig dc) - { - try - { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading '{0}' from Essentials Core", dc.Type); - - var localDc = new DeviceConfig(dc); - - var key = localDc.Key; - var name = localDc.Name; - var type = localDc.Type; - var properties = localDc.Properties; - //var propRecurse = properties; - - var typeName = localDc.Type.ToLower(); - - - var jObject = properties as JObject; - if (jObject != null) - { - var jProp = jObject.Properties(); - - CheckForSecrets(jProp); - } - - Debug.Console(2, "typeName = {0}", typeName); - // Check for types that have been added by plugin dlls. - return !FactoryMethods.ContainsKey(typeName) ? null : FactoryMethods[typeName].FactoryMethod(localDc); - } - catch (Exception ex) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Exception occurred while creating device {0}: {1}", dc.Key, ex.Message); - - Debug.Console(2, "{0}", ex.StackTrace); - - if (ex.InnerException == null) - { - return null; - } - - Debug.Console(0, Debug.ErrorLogLevel.Error, "Inner exception while creating device {0}: {1}", dc.Key, - ex.InnerException.Message); - Debug.Console(2, "{0}", ex.InnerException.StackTrace); - return null; - } - } - - /// - /// Prints the type names and associated metadata from the FactoryMethods collection. - /// - /// - public static void GetDeviceFactoryTypes(string filter) - { - var types = !string.IsNullOrEmpty(filter) - ? FactoryMethods.Where(k => k.Key.Contains(filter)).ToDictionary(k => k.Key, k => k.Value) - : FactoryMethods; - - CrestronConsole.ConsoleCommandResponse("Device Types:"); - - foreach (var type in types.OrderBy(t => t.Key)) - { - var description = type.Value.Description; - var cType = "Not Specified by Plugin"; - - if (type.Value.CType != null) - { - cType = type.Value.CType.FullName; - } - - CrestronConsole.ConsoleCommandResponse( - @"Type: '{0}' - CType: '{1}' - Description: {2}", type.Key, cType, description); - } - } - - /// - /// Returns the device factory dictionary - /// - /// - /// - public static Dictionary GetDeviceFactoryDictionary(string filter) - { - return string.IsNullOrEmpty(filter) - ? FactoryMethods - : FactoryMethods.Where(k => k.Key.Contains(filter)).ToDictionary(k => k.Key, k => k.Value); - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.GeneralIO; +using Crestron.SimplSharp.Reflection; +using PepperDash.Core; +using Newtonsoft.Json.Linq; +using Newtonsoft.Json; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.Core.CrestronIO; +using PepperDash.Essentials.Core.Touchpanels; + +namespace PepperDash.Essentials.Core +{ + public class DeviceFactoryWrapper + { + public CType CType { get; set; } + public string Description { get; set; } + public Func FactoryMethod { get; set; } + + public DeviceFactoryWrapper() + { + CType = null; + Description = "Not Available"; + } + } + + public class DeviceFactory + { + public DeviceFactory() + { + var assy = Assembly.GetExecutingAssembly(); + PluginLoader.SetEssentialsAssembly(assy.GetName().Name, assy); + + var types = assy.GetTypes().Where(ct => typeof(IDeviceFactory).IsAssignableFrom(ct) && !ct.IsInterface && !ct.IsAbstract); + + if (types != null) + { + foreach (var type in types) + { + try + { + var factory = (IDeviceFactory)Crestron.SimplSharp.Reflection.Activator.CreateInstance(type); + factory.LoadTypeFactories(); + } + catch (Exception e) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to load type: '{1}' DeviceFactory: {0}", e, type.Name); + } + } + } + } + + /// + /// A dictionary of factory methods, keyed by config types, added by plugins. + /// These methods are looked up and called by GetDevice in this class. + /// + static Dictionary FactoryMethods = + new Dictionary(StringComparer.OrdinalIgnoreCase); + + /// + /// Adds a plugin factory method + /// + /// + /// + public static void AddFactoryForType(string typeName, Func method) + { + //Debug.Console(1, Debug.ErrorLogLevel.Notice, "Adding factory method for type '{0}'", typeName); + DeviceFactory.FactoryMethods.Add(typeName, new DeviceFactoryWrapper() { FactoryMethod = method}); + } + + public static void AddFactoryForType(string typeName, string description, CType cType, Func method) + { + //Debug.Console(1, Debug.ErrorLogLevel.Notice, "Adding factory method for type '{0}'", typeName); + + if(FactoryMethods.ContainsKey(typeName)) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to add type: '{0}'. Already exists in DeviceFactory", typeName); + return; + } + + var wrapper = new DeviceFactoryWrapper() { CType = cType, Description = description, FactoryMethod = method }; + DeviceFactory.FactoryMethods.Add(typeName, wrapper); + } + + private static void CheckForSecrets(IEnumerable obj) + { + foreach (var prop in obj.Where(prop => prop.Value as JObject != null)) + { + if (prop.Name.ToLower() == "secret") + { + var secret = GetSecret(prop.Children().First().ToObject()); + //var secret = GetSecret(JsonConvert.DeserializeObject(prop.Children().First().ToString())); + prop.Parent.Replace(secret); + } + var recurseProp = prop.Value as JObject; + if (recurseProp == null) return; + CheckForSecrets(recurseProp.Properties()); + } + } + + private static string GetSecret(SecretsPropertiesConfig data) + { + var secretProvider = SecretsManager.GetSecretProviderByKey(data.Provider); + if (secretProvider == null) return null; + var secret = secretProvider.GetSecret(data.Key); + if (secret != null) return (string) secret.Value; + Debug.Console(1, + "Unable to retrieve secret {0}{1} - Make sure you've added it to the secrets provider", + data.Provider, data.Key); + return String.Empty; + } + + + /// + /// The factory method for Core "things". Also iterates the Factory methods that have + /// been loaded from plugins + /// + /// + /// + public static IKeyed GetDevice(DeviceConfig dc) + { + try + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading '{0}' from Essentials Core", dc.Type); + + var localDc = new DeviceConfig(dc); + + var key = localDc.Key; + var name = localDc.Name; + var type = localDc.Type; + var properties = localDc.Properties; + //var propRecurse = properties; + + var typeName = localDc.Type.ToLower(); + + + var jObject = properties as JObject; + if (jObject != null) + { + var jProp = jObject.Properties(); + + CheckForSecrets(jProp); + } + + Debug.Console(2, "typeName = {0}", typeName); + // Check for types that have been added by plugin dlls. + return !FactoryMethods.ContainsKey(typeName) ? null : FactoryMethods[typeName].FactoryMethod(localDc); + } + catch (Exception ex) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "Exception occurred while creating device {0}: {1}", dc.Key, ex.Message); + + Debug.Console(2, "{0}", ex.StackTrace); + + if (ex.InnerException == null) + { + return null; + } + + Debug.Console(0, Debug.ErrorLogLevel.Error, "Inner exception while creating device {0}: {1}", dc.Key, + ex.InnerException.Message); + Debug.Console(2, "{0}", ex.InnerException.StackTrace); + return null; + } + } + + /// + /// Prints the type names and associated metadata from the FactoryMethods collection. + /// + /// + public static void GetDeviceFactoryTypes(string filter) + { + var types = !string.IsNullOrEmpty(filter) + ? FactoryMethods.Where(k => k.Key.Contains(filter)).ToDictionary(k => k.Key, k => k.Value) + : FactoryMethods; + + CrestronConsole.ConsoleCommandResponse("Device Types:"); + + foreach (var type in types.OrderBy(t => t.Key)) + { + var description = type.Value.Description; + var cType = "Not Specified by Plugin"; + + if (type.Value.CType != null) + { + cType = type.Value.CType.FullName; + } + + CrestronConsole.ConsoleCommandResponse( + @"Type: '{0}' + CType: '{1}' + Description: {2}", type.Key, cType, description); + } + } + + /// + /// Returns the device factory dictionary + /// + /// + /// + public static Dictionary GetDeviceFactoryDictionary(string filter) + { + return string.IsNullOrEmpty(filter) + ? FactoryMethods + : FactoryMethods.Where(k => k.Key.Contains(filter)).ToDictionary(k => k.Key, k => k.Value); + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/IDeviceFactory.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/IDeviceFactory.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/IDeviceFactory.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/IDeviceFactory.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/ReadyEventArgs.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/ReadyEventArgs.cs similarity index 95% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/ReadyEventArgs.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/ReadyEventArgs.cs index 3c107f6e..be8369d2 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/ReadyEventArgs.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/ReadyEventArgs.cs @@ -1,46 +1,46 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using PepperDash.Essentials.Core; - -namespace PepperDash.Essentials.Core -{ - public class IsReadyEventArgs : EventArgs - { - public bool IsReady { get; set; } - - public IsReadyEventArgs(bool data) - { - IsReady = data; - } - } - - public interface IHasReady - { - event EventHandler IsReadyEvent; - bool IsReady { get; } - } -} - -namespace PepperDash_Essentials_Core -{ - [Obsolete("Use PepperDash.Essentials.Core")] - public class IsReadyEventArgs : EventArgs - { - public bool IsReady { get; set; } - - public IsReadyEventArgs(bool data) - { - IsReady = data; - } - } - - [Obsolete("Use PepperDash.Essentials.Core")] - public interface IHasReady - { - event EventHandler IsReadyEvent; - bool IsReady { get; } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Core +{ + public class IsReadyEventArgs : EventArgs + { + public bool IsReady { get; set; } + + public IsReadyEventArgs(bool data) + { + IsReady = data; + } + } + + public interface IHasReady + { + event EventHandler IsReadyEvent; + bool IsReady { get; } + } +} + +namespace PepperDash_Essentials_Core +{ + [Obsolete("Use PepperDash.Essentials.Core")] + public class IsReadyEventArgs : EventArgs + { + public bool IsReady { get; set; } + + public IsReadyEventArgs(bool data) + { + IsReady = data; + } + } + + [Obsolete("Use PepperDash.Essentials.Core")] + public interface IHasReady + { + event EventHandler IsReadyEvent; + bool IsReady { get; } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/BoolFeedback.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/BoolFeedback.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/BoolFeedback.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/BoolFeedback.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/BoolFeedbackOneShot.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/BoolFeedbackOneShot.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/BoolFeedbackOneShot.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/BoolFeedbackOneShot.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/BoolFeedbackPulseExtender.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/BoolFeedbackPulseExtender.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/BoolFeedbackPulseExtender.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/BoolFeedbackPulseExtender.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/BoolOutputLogicals.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/BoolOutputLogicals.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/BoolOutputLogicals.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/BoolOutputLogicals.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/FeedbackBase.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/FeedbackBase.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/FeedbackBase.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/FeedbackBase.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/FeedbackCollection.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/FeedbackCollection.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/FeedbackCollection.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/FeedbackCollection.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/FeedbackEventArgs.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/FeedbackEventArgs.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/FeedbackEventArgs.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/FeedbackEventArgs.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/IntFeedback.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/IntFeedback.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/IntFeedback.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/IntFeedback.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/SerialFeedback.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/SerialFeedback.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/SerialFeedback.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/SerialFeedback.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/StringFeedback.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/StringFeedback.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/StringFeedback.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Feedbacks/StringFeedback.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/File/FileIO.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/File/FileIO.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/File/FileIO.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/File/FileIO.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs similarity index 97% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs index a675f765..f8b170c4 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs @@ -1,1827 +1,1827 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharp.CrestronIO; -using Crestron.SimplSharp.CrestronXml; -using Crestron.SimplSharp.CrestronXml.Serialization; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.Fusion; -using Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core.Config; - -namespace PepperDash.Essentials.Core.Fusion -{ - public class EssentialsHuddleSpaceFusionSystemControllerBase : Device, IOccupancyStatusProvider - { - protected EssentialsHuddleSpaceRoomFusionRoomJoinMap JoinMap; - - private const string RemoteOccupancyXml = "Local{0}"; - private readonly bool _guidFileExists; - - private readonly Dictionary _sourceToFeedbackSigs = - new Dictionary(); - - protected StringSigData CurrentRoomSourceNameSig; - - public FusionCustomPropertiesBridge CustomPropertiesBridge = new FusionCustomPropertiesBridge(); - protected FusionOccupancySensorAsset FusionOccSensor; - protected FusionRemoteOccupancySensor FusionRemoteOccSensor; - - protected FusionRoom FusionRoom; - protected Dictionary FusionStaticAssets; - public long PushNotificationTimeout = 5000; - protected IEssentialsRoom Room; - public long SchedulePollInterval = 300000; - - private Event _currentMeeting; - private RoomSchedule _currentSchedule; - private CTimer _dailyTimeRequestTimer; - private StatusMonitorCollection _errorMessageRollUp; - - private FusionRoomGuids _guiDs; - private uint _ipId; - - private bool _isRegisteredForSchedulePushNotifications; - private Event _nextMeeting; - - private CTimer _pollTimer; - - private CTimer _pushNotificationTimer; - - private string _roomOccupancyRemoteString; - - #region System Info Sigs - - //StringSigData SystemName; - //StringSigData Model; - //StringSigData SerialNumber; - //StringSigData Uptime; - - #endregion - - #region Processor Info Sigs - - private readonly StringSigData[] _program = new StringSigData[10]; - private StringSigData _dns1; - private StringSigData _dns2; - private StringSigData _domain; - private StringSigData _firmware; - private StringSigData _gateway; - private StringSigData _hostname; - private StringSigData _ip1; - private StringSigData _ip2; - private StringSigData _mac1; - private StringSigData _mac2; - private StringSigData _netMask1; - private StringSigData _netMask2; - - #endregion - - #region Default Display Source Sigs - - private BooleanSigData[] _source = new BooleanSigData[10]; - - #endregion - - public EssentialsHuddleSpaceFusionSystemControllerBase(IEssentialsRoom room, uint ipId, string joinMapKey) - : base(room.Key + "-fusion") - { - try - { - JoinMap = new EssentialsHuddleSpaceRoomFusionRoomJoinMap(1); - - CrestronConsole.AddNewConsoleCommand((o) => JoinMap.PrintJoinMapInfo(), string.Format("ptjnmp-{0}", Key), "Prints Attribute Join Map", ConsoleAccessLevelEnum.AccessOperator); - - if (!string.IsNullOrEmpty(joinMapKey)) - { - var customJoins = JoinMapHelper.TryGetJoinMapAdvancedForDevice(joinMapKey); - if (customJoins != null) - { - JoinMap.SetCustomJoinData(customJoins); - } - } - - Room = room; - - _ipId = ipId; - - FusionStaticAssets = new Dictionary(); - - _guiDs = new FusionRoomGuids(); - - var mac = - CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, 0); - - var slot = Global.ControlSystem.ProgramNumber; - - var guidFilePath = Global.FilePathPrefix + - string.Format(@"{0}-FusionGuids-{1:X2}.json", InitialParametersClass.ProgramIDTag, _ipId); - - var oldGuidFilePath = Global.FilePathPrefix + - string.Format(@"{0}-FusionGuids.json", InitialParametersClass.ProgramIDTag); - - if (File.Exists(oldGuidFilePath)) - { - Debug.Console(0, this, "Migrating from old Fusion GUID file to new Fusion GUID File"); - - File.Copy(oldGuidFilePath, guidFilePath); - - File.Delete(oldGuidFilePath); - } - - _guidFileExists = File.Exists(guidFilePath); - - // Check if file exists - if (!_guidFileExists) - { - // Does not exist. Create GUIDs - _guiDs = new FusionRoomGuids(Room.Name, ipId, _guiDs.GenerateNewRoomGuid(slot, mac), - FusionStaticAssets); - } - else - { - // Exists. Read GUIDs - ReadGuidFile(guidFilePath); - } - - var occupancyRoom = Room as IRoomOccupancy; - - if (occupancyRoom != null) - { - if (occupancyRoom.RoomOccupancy != null) - { - if (occupancyRoom.OccupancyStatusProviderIsRemote) - { - SetUpRemoteOccupancy(); - } - else - { - SetUpLocalOccupancy(); - } - } - } - - - AddPostActivationAction(() => PostActivate(guidFilePath)); - } - catch (Exception e) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Error Building Fusion System Controller: {0}", e); - } - } - - private void PostActivate(string guidFilePath) - { - CreateSymbolAndBasicSigs(_ipId); - SetUpSources(); - SetUpCommunitcationMonitors(); - SetUpDisplay(); - SetUpError(); - ExecuteCustomSteps(); - - FusionRVI.GenerateFileForAllFusionDevices(); - - GenerateGuidFile(guidFilePath); - } - - protected string RoomGuid - { - get { return _guiDs.RoomGuid; } - } - - public StringFeedback RoomOccupancyRemoteStringFeedback { get; private set; } - - protected Func RoomIsOccupiedFeedbackFunc - { - get { return () => FusionRemoteOccSensor.RoomOccupied.OutputSig.BoolValue; } - } - - #region IOccupancyStatusProvider Members - - public BoolFeedback RoomIsOccupiedFeedback { get; private set; } - - #endregion - - public event EventHandler ScheduleChange; - //public event EventHandler MeetingEndWarning; - //public event EventHandler NextMeetingBeginWarning; - - public event EventHandler RoomInfoChange; - - //ScheduleResponseEvent NextMeeting; - - /// - /// Used for extension classes to execute whatever steps are necessary before generating the RVI and GUID files - /// - protected virtual void ExecuteCustomSteps() - { - } - - /// - /// Generates the guid file in NVRAM. If the file already exists it will be overwritten. - /// - /// path for the file - private void GenerateGuidFile(string filePath) - { - if (string.IsNullOrEmpty(filePath)) - { - Debug.Console(0, this, "Error writing guid file. No path specified."); - return; - } - - var fileLock = new CCriticalSection(); - - try - { - if (fileLock.Disposed) - { - return; - } - - fileLock.Enter(); - - Debug.Console(1, this, "Writing GUIDs to file"); - - _guiDs = FusionOccSensor == null - ? new FusionRoomGuids(Room.Name, _ipId, RoomGuid, FusionStaticAssets) - : new FusionRoomGuids(Room.Name, _ipId, RoomGuid, FusionStaticAssets, FusionOccSensor); - - var json = JsonConvert.SerializeObject(_guiDs, Newtonsoft.Json.Formatting.Indented); - - using (var sw = new StreamWriter(filePath)) - { - sw.Write(json); - sw.Flush(); - } - - Debug.Console(1, this, "Guids successfully written to file '{0}'", filePath); - } - catch (Exception e) - { - Debug.Console(0, this, "Error writing guid file: {0}", e); - } - finally - { - if (!fileLock.Disposed) - { - fileLock.Leave(); - } - } - } - - /// - /// Reads the guid file from NVRAM - /// - /// path for te file - private void ReadGuidFile(string filePath) - { - if (string.IsNullOrEmpty(filePath)) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Error reading guid file. No path specified."); - return; - } - - var fileLock = new CCriticalSection(); - - try - { - if (fileLock.Disposed) - { - return; - } - - fileLock.Enter(); - - if (File.Exists(filePath)) - { - var json = File.ReadToEnd(filePath, Encoding.ASCII); - - _guiDs = JsonConvert.DeserializeObject(json); - - _ipId = _guiDs.IpId; - - FusionStaticAssets = _guiDs.StaticAssets; - } - - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Fusion Guids successfully read from file: {0}", - filePath); - - Debug.Console(1, this, "\r\n********************\r\n\tRoom Name: {0}\r\n\tIPID: {1:X}\r\n\tRoomGuid: {2}\r\n*******************", Room.Name, _ipId, RoomGuid); - - foreach (var item in FusionStaticAssets) - { - Debug.Console(1, this, "\nAsset Name: {0}\nAsset No: {1}\n Guid: {2}", item.Value.Name, - item.Value.SlotNumber, item.Value.InstanceId); - } - } - catch (Exception e) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Error reading guid file: {0}", e); - } - finally - { - if (!fileLock.Disposed) - { - fileLock.Leave(); - } - } - } - - protected virtual void CreateSymbolAndBasicSigs(uint ipId) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Creating Fusion Room symbol with GUID: {0} and IP-ID {1:X2}", RoomGuid, ipId); - - FusionRoom = new FusionRoom(ipId, Global.ControlSystem, Room.Name, RoomGuid); - FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.Use(); - FusionRoom.ExtenderFusionRoomDataReservedSigs.Use(); - - FusionRoom.Register(); - - FusionRoom.FusionStateChange += FusionRoom_FusionStateChange; - - FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.DeviceExtenderSigChange += - FusionRoomSchedule_DeviceExtenderSigChange; - FusionRoom.ExtenderFusionRoomDataReservedSigs.DeviceExtenderSigChange += - ExtenderFusionRoomDataReservedSigs_DeviceExtenderSigChange; - FusionRoom.OnlineStatusChange += FusionRoom_OnlineStatusChange; - - CrestronConsole.AddNewConsoleCommand(RequestFullRoomSchedule, "FusReqRoomSchedule", - "Requests schedule of the room for the next 24 hours", ConsoleAccessLevelEnum.AccessOperator); - CrestronConsole.AddNewConsoleCommand(ModifyMeetingEndTimeConsoleHelper, "FusReqRoomSchMod", - "Ends or extends a meeting by the specified time", ConsoleAccessLevelEnum.AccessOperator); - CrestronConsole.AddNewConsoleCommand(CreateAdHocMeeting, "FusCreateMeeting", - "Creates and Ad Hoc meeting for on hour or until the next meeting", - ConsoleAccessLevelEnum.AccessOperator); - - // Room to fusion room - Room.OnFeedback.LinkInputSig(FusionRoom.SystemPowerOn.InputSig); - - // Moved to - CurrentRoomSourceNameSig = FusionRoom.CreateOffsetStringSig(JoinMap.Display1CurrentSourceName.JoinNumber, JoinMap.Display1CurrentSourceName.AttributeName, - eSigIoMask.InputSigOnly); - // Don't think we need to get current status of this as nothing should be alive yet. - var hasCurrentSourceInfoChange = Room as IHasCurrentSourceInfoChange; - if (hasCurrentSourceInfoChange != null) - { - hasCurrentSourceInfoChange.CurrentSourceChange += Room_CurrentSourceInfoChange; - } - - - FusionRoom.SystemPowerOn.OutputSig.SetSigFalseAction(Room.PowerOnToDefaultOrLastSource); - FusionRoom.SystemPowerOff.OutputSig.SetSigFalseAction(() => - { - var runRouteAction = Room as IRunRouteAction; - if (runRouteAction != null) - { - runRouteAction.RunRouteAction("roomOff", Room.SourceListKey); - } - }); - // NO!! room.RoomIsOn.LinkComplementInputSig(FusionRoom.SystemPowerOff.InputSig); - FusionRoom.ErrorMessage.InputSig.StringValue = - "3: 7 Errors: This is a really long error message;This is a really long error message;This is a really long error message;This is a really long error message;This is a really long error message;This is a really long error message;This is a really long error message;"; - - SetUpEthernetValues(); - - GetProcessorEthernetValues(); - - GetSystemInfo(); - - GetProcessorInfo(); - - CrestronEnvironment.EthernetEventHandler += CrestronEnvironment_EthernetEventHandler; - } - - protected void CrestronEnvironment_EthernetEventHandler(EthernetEventArgs ethernetEventArgs) - { - if (ethernetEventArgs.EthernetEventType == eEthernetEventType.LinkUp) - { - GetProcessorEthernetValues(); - } - } - - protected void GetSystemInfo() - { - //SystemName.InputSig.StringValue = Room.Name; - //Model.InputSig.StringValue = InitialParametersClass.ControllerPromptName; - //SerialNumber.InputSig.StringValue = InitialParametersClass. - - var response = string.Empty; - - var systemReboot = FusionRoom.CreateOffsetBoolSig(JoinMap.ProcessorReboot.JoinNumber, JoinMap.ProcessorReboot.AttributeName, eSigIoMask.OutputSigOnly); - systemReboot.OutputSig.SetSigFalseAction( - () => CrestronConsole.SendControlSystemCommand("reboot", ref response)); - } - - protected void SetUpEthernetValues() - { - _ip1 = FusionRoom.CreateOffsetStringSig(JoinMap.ProcessorIp1.JoinNumber, JoinMap.ProcessorIp1.AttributeName, eSigIoMask.InputSigOnly); - _ip2 = FusionRoom.CreateOffsetStringSig(JoinMap.ProcessorIp2.JoinNumber, JoinMap.ProcessorIp2.AttributeName, eSigIoMask.InputSigOnly); - _gateway = FusionRoom.CreateOffsetStringSig(JoinMap.ProcessorGateway.JoinNumber, JoinMap.ProcessorGateway.AttributeName, eSigIoMask.InputSigOnly); - _hostname = FusionRoom.CreateOffsetStringSig(JoinMap.ProcessorHostname.JoinNumber, JoinMap.ProcessorHostname.AttributeName, eSigIoMask.InputSigOnly); - _domain = FusionRoom.CreateOffsetStringSig(JoinMap.ProcessorDomain.JoinNumber, JoinMap.ProcessorDomain.AttributeName, eSigIoMask.InputSigOnly); - _dns1 = FusionRoom.CreateOffsetStringSig(JoinMap.ProcessorDns1.JoinNumber, JoinMap.ProcessorDns1.AttributeName, eSigIoMask.InputSigOnly); - _dns2 = FusionRoom.CreateOffsetStringSig(JoinMap.ProcessorDns2.JoinNumber, JoinMap.ProcessorDns2.AttributeName, eSigIoMask.InputSigOnly); - _mac1 = FusionRoom.CreateOffsetStringSig(JoinMap.ProcessorMac1.JoinNumber, JoinMap.ProcessorMac1.AttributeName, eSigIoMask.InputSigOnly); - _mac2 = FusionRoom.CreateOffsetStringSig(JoinMap.ProcessorMac2.JoinNumber, JoinMap.ProcessorMac2.AttributeName, eSigIoMask.InputSigOnly); - _netMask1 = FusionRoom.CreateOffsetStringSig(JoinMap.ProcessorNetMask1.JoinNumber, JoinMap.ProcessorNetMask1.AttributeName, eSigIoMask.InputSigOnly); - _netMask2 = FusionRoom.CreateOffsetStringSig(JoinMap.ProcessorNetMask2.JoinNumber, JoinMap.ProcessorNetMask2.AttributeName, eSigIoMask.InputSigOnly); - } - - protected void GetProcessorEthernetValues() - { - _ip1.InputSig.StringValue = - CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0); - _gateway.InputSig.StringValue = - CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_ROUTER, 0); - _hostname.InputSig.StringValue = - CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, 0); - _domain.InputSig.StringValue = - CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DOMAIN_NAME, 0); - - var dnsServers = - CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DNS_SERVER, 0).Split(','); - _dns1.InputSig.StringValue = dnsServers[0]; - if (dnsServers.Length > 1) - { - _dns2.InputSig.StringValue = dnsServers[1]; - } - - _mac1.InputSig.StringValue = - CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, 0); - _netMask1.InputSig.StringValue = - CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, 0); - - // Interface 1 - - if (InitialParametersClass.NumberOfEthernetInterfaces > 1) - // Only get these values if the processor has more than 1 NIC - { - _ip2.InputSig.StringValue = - CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 1); - _mac2.InputSig.StringValue = - CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, 1); - _netMask2.InputSig.StringValue = - CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, 1); - } - } - - protected void GetProcessorInfo() - { - _firmware = FusionRoom.CreateOffsetStringSig(JoinMap.ProcessorFirmware.JoinNumber, JoinMap.ProcessorFirmware.AttributeName, eSigIoMask.InputSigOnly); - - if (CrestronEnvironment.DevicePlatform != eDevicePlatform.Server) - { - for (var i = 0; i < Global.ControlSystem.NumProgramsSupported; i++) - { - var join = JoinMap.ProgramNameStart.JoinNumber + i; - var progNum = i + 1; - _program[i] = FusionRoom.CreateOffsetStringSig((uint) join, - string.Format("{0} {1}", JoinMap.ProgramNameStart.AttributeName, progNum), eSigIoMask.InputSigOnly); - } - } - - _firmware.InputSig.StringValue = InitialParametersClass.FirmwareVersion; - } - - protected void GetCustomProperties() - { - if (FusionRoom.IsOnline) - { - const string fusionRoomCustomPropertiesRequest = - @"RoomConfigurationRequest"; - - FusionRoom.ExtenderFusionRoomDataReservedSigs.RoomConfigQuery.StringValue = - fusionRoomCustomPropertiesRequest; - } - } - - private void GetTouchpanelInfo() - { - // TODO: Get IP and Project Name from TP - } - - protected void FusionRoom_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) - { - if (args.DeviceOnLine) - { - CrestronInvoke.BeginInvoke( (o) => - { - CrestronEnvironment.Sleep(200); - - // Send Push Notification Action request: - - const string requestId = "InitialPushRequest"; - - - var actionRequest = - string.Format("\n{0}\n", requestId) + - "RegisterPushModel\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n"; - - Debug.Console(2, this, "Sending Fusion ActionRequest: \n{0}", actionRequest); - - FusionRoom.ExtenderFusionRoomDataReservedSigs.ActionQuery.StringValue = actionRequest; - - GetCustomProperties(); - - // Request current Fusion Server Time - RequestLocalDateTime(null); - - // Setup timer to request time daily - if (_dailyTimeRequestTimer != null && !_dailyTimeRequestTimer.Disposed) - { - _dailyTimeRequestTimer.Stop(); - _dailyTimeRequestTimer.Dispose(); - } - - _dailyTimeRequestTimer = new CTimer(RequestLocalDateTime, null, 86400000, 86400000); - - _dailyTimeRequestTimer.Reset(86400000, 86400000); - }); - } - } - - /// - /// Requests the local date and time from the Fusion Server - /// - /// - public void RequestLocalDateTime(object callbackObject) - { - const string timeRequestId = "TimeRequest"; - - var timeRequest = string.Format("{0}", - timeRequestId); - - FusionRoom.ExtenderFusionRoomDataReservedSigs.LocalDateTimeQuery.StringValue = timeRequest; - } - - /// - /// Generates a room schedule request for this room for the next 24 hours. - /// - public void RequestFullRoomSchedule(object callbackObject) - { - var now = DateTime.Today; - - var currentTime = now.ToString("s"); - - var requestTest = - string.Format( - "FullSchedleRequest{0}{1}24", - RoomGuid, currentTime); - - Debug.Console(2, this, "Sending Fusion ScheduleQuery: \n{0}", requestTest); - - FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.ScheduleQuery.StringValue = requestTest; - - if (_isRegisteredForSchedulePushNotifications) - { - _pushNotificationTimer.Stop(); - } - } - - /// - /// Wrapper method to allow console commands to modify the current meeting end time - /// - /// meetingID extendTime - public void ModifyMeetingEndTimeConsoleHelper(string command) - { - var extendMinutes = -1; - - const string requestId = "ModifyMeetingTest12345"; - - try - { - var tokens = command.Split(' '); - - extendMinutes = Int32.Parse(tokens[1]); - } - catch (Exception e) - { - Debug.Console(1, this, "Error parsing console command: {0}", e); - } - - ModifyMeetingEndTime(requestId, extendMinutes); - } - - /// - /// Ends or Extends the current meeting by the specified number of minutes. - /// - /// - /// Number of minutes to extend the meeting. A value of 0 will end the meeting. - public void ModifyMeetingEndTime(string requestId, int extendMinutes) - { - if (_currentMeeting == null) - { - Debug.Console(1, this, "No meeting in progress. Unable to modify end time."); - return; - } - - if (extendMinutes > -1) - { - if (extendMinutes > 0) - { - var extendTime = _currentMeeting.dtEnd - DateTime.Now; - var extendMinutesRaw = extendTime.TotalMinutes; - - extendMinutes = extendMinutes + (int) Math.Round(extendMinutesRaw); - } - - - var requestTest = string.Format( - "{0}{1}MeetingChange" - , requestId, RoomGuid, _currentMeeting.MeetingID, extendMinutes); - - Debug.Console(1, this, "Sending MeetingChange Request: \n{0}", requestTest); - - FusionRoom.ExtenderFusionRoomDataReservedSigs.ActionQuery.StringValue = requestTest; - } - else - { - Debug.Console(1, this, "Invalid time specified"); - } - } - - /// - /// Creates and Ad Hoc meeting with a duration of 1 hour, or until the next meeting if in less than 1 hour. - /// - public void CreateAdHocMeeting(string command) - { - const string requestId = "CreateAdHocMeeting"; - - var now = DateTime.Now.AddMinutes(1); - - now.AddSeconds(-now.Second); - - // Assume 1 hour meeting if possible - var dtEnd = now.AddHours(1); - - // Check if room is available for 1 hour before next meeting - if (_nextMeeting != null) - { - var roomAvailable = _nextMeeting.dtEnd.Subtract(dtEnd); - - if (roomAvailable.TotalMinutes < 60) - { - // Room not available for full hour, book until next meeting starts - dtEnd = _nextMeeting.dtEnd; - } - } - - var createMeetingRequest = - "" + - string.Format("{0}", requestId) + - string.Format("{0}", RoomGuid) + - "" + - string.Format("{0}", now.ToString("s")) + - string.Format("{0}", dtEnd.ToString("s")) + - "AdHoc Meeting" + - "Room User" + - "Example Message" + - "" + - ""; - - Debug.Console(2, this, "Sending CreateMeeting Request: \n{0}", createMeetingRequest); - - FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.CreateMeeting.StringValue = createMeetingRequest; - - //Debug.Console(1, this, "Sending CreateMeeting Request: \n{0}", command); - - //FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.CreateMeeting.StringValue = command; - } - - /// - /// Event handler method for Device Extender sig changes - /// - /// - /// - protected void ExtenderFusionRoomDataReservedSigs_DeviceExtenderSigChange(DeviceExtender currentDeviceExtender, - SigEventArgs args) - { - Debug.Console(2, this, "Event: {0}\n Sig: {1}\nFusionResponse:\n{2}", args.Event, args.Sig.Name, - args.Sig.StringValue); - - - if (args.Sig == FusionRoom.ExtenderFusionRoomDataReservedSigs.ActionQueryResponse) - { - try - { - var message = new XmlDocument(); - - message.LoadXml(args.Sig.StringValue); - - var actionResponse = message["ActionResponse"]; - - if (actionResponse == null) - { - return; - } - - var requestId = actionResponse["RequestID"]; - - if (requestId.InnerText != "InitialPushRequest") - { - return; - } - - if (actionResponse["ActionID"].InnerText != "RegisterPushModel") - { - return; - } - - var parameters = actionResponse["Parameters"]; - - foreach (var isRegistered in from XmlElement parameter in parameters - where parameter.HasAttributes - select parameter.Attributes - into attributes - where attributes["ID"].Value == "Registered" - select Int32.Parse(attributes["Value"].Value)) - { - switch (isRegistered) - { - case 1: - _isRegisteredForSchedulePushNotifications = true; - if (_pollTimer != null && !_pollTimer.Disposed) - { - _pollTimer.Stop(); - _pollTimer.Dispose(); - } - _pushNotificationTimer = new CTimer(RequestFullRoomSchedule, null, - PushNotificationTimeout, PushNotificationTimeout); - _pushNotificationTimer.Reset(PushNotificationTimeout, PushNotificationTimeout); - break; - case 0: - _isRegisteredForSchedulePushNotifications = false; - if (_pushNotificationTimer != null && !_pushNotificationTimer.Disposed) - { - _pushNotificationTimer.Stop(); - _pushNotificationTimer.Dispose(); - } - _pollTimer = new CTimer(RequestFullRoomSchedule, null, SchedulePollInterval, - SchedulePollInterval); - _pollTimer.Reset(SchedulePollInterval, SchedulePollInterval); - break; - } - } - } - catch (Exception e) - { - Debug.Console(1, this, "Error parsing ActionQueryResponse: {0}", e); - } - } - else if (args.Sig == FusionRoom.ExtenderFusionRoomDataReservedSigs.LocalDateTimeQueryResponse) - { - try - { - var message = new XmlDocument(); - - message.LoadXml(args.Sig.StringValue); - - var localDateTimeResponse = message["LocalTimeResponse"]; - - if (localDateTimeResponse != null) - { - var localDateTime = localDateTimeResponse["LocalDateTime"]; - - if (localDateTime != null) - { - var tempLocalDateTime = localDateTime.InnerText; - - var currentTime = DateTime.Parse(tempLocalDateTime); - - Debug.Console(1, this, "DateTime from Fusion Server: {0}", currentTime); - - // Parse time and date from response and insert values - CrestronEnvironment.SetTimeAndDate((ushort) currentTime.Hour, (ushort) currentTime.Minute, - (ushort) currentTime.Second, (ushort) currentTime.Month, (ushort) currentTime.Day, - (ushort) currentTime.Year); - - Debug.Console(1, this, "Processor time set to {0}", CrestronEnvironment.GetLocalTime()); - } - } - } - catch (Exception e) - { - Debug.Console(1, this, "Error parsing LocalDateTimeQueryResponse: {0}", e); - } - } - else if (args.Sig == FusionRoom.ExtenderFusionRoomDataReservedSigs.RoomConfigResponse) - { - // Room info response with custom properties - - var roomConfigResponseArgs = args.Sig.StringValue.Replace("&", "and"); - - Debug.Console(2, this, "Fusion Response: \n {0}", roomConfigResponseArgs); - - try - { - var roomConfigResponse = new XmlDocument(); - - roomConfigResponse.LoadXml(roomConfigResponseArgs); - - var requestRoomConfiguration = roomConfigResponse["RoomConfigurationResponse"]; - - if (requestRoomConfiguration != null) - { - var roomInformation = new RoomInformation(); - - foreach (XmlElement e in roomConfigResponse.FirstChild.ChildNodes) - { - if (e.Name == "RoomInformation") - { - var roomInfo = new XmlReader(e.OuterXml); - - roomInformation = CrestronXMLSerialization.DeSerializeObject(roomInfo); - } - else if (e.Name == "CustomFields") - { - foreach (XmlElement el in e) - { - var customProperty = new FusionCustomProperty(); - - if (el.Name == "CustomField") - { - customProperty.ID = el.Attributes["ID"].Value; - } - - foreach (XmlElement elm in el) - { - if (elm.Name == "CustomFieldName") - { - customProperty.CustomFieldName = elm.InnerText; - } - if (elm.Name == "CustomFieldType") - { - customProperty.CustomFieldType = elm.InnerText; - } - if (elm.Name == "CustomFieldValue") - { - customProperty.CustomFieldValue = elm.InnerText; - } - } - - roomInformation.FusionCustomProperties.Add(customProperty); - } - } - } - - var handler = RoomInfoChange; - if (handler != null) - { - handler(this, new EventArgs()); - } - - CustomPropertiesBridge.EvaluateRoomInfo(Room.Key, roomInformation); - } - } - catch (Exception e) - { - Debug.Console(1, this, "Error parsing Custom Properties response: {0}", e); - } - //PrintRoomInfo(); - //getRoomInfoBusy = false; - //_DynFusion.API.EISC.BooleanInput[Constants.GetRoomInfo].BoolValue = getRoomInfoBusy; - } - } - - /// - /// Event handler method for Device Extender sig changes - /// - /// - /// - protected void FusionRoomSchedule_DeviceExtenderSigChange(DeviceExtender currentDeviceExtender, - SigEventArgs args) - { - Debug.Console(2, this, "Scehdule Response Event: {0}\n Sig: {1}\nFusionResponse:\n{2}", args.Event, - args.Sig.Name, args.Sig.StringValue); - - - if (args.Sig == FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.ScheduleResponse) - { - try - { - var scheduleResponse = new ScheduleResponse(); - - var message = new XmlDocument(); - - message.LoadXml(args.Sig.StringValue); - - var response = message["ScheduleResponse"]; - - if (response != null) - { - // Check for push notification - if (response["RequestID"].InnerText == "RVRequest") - { - var action = response["Action"]; - - if (action.OuterXml.IndexOf("RequestSchedule", StringComparison.Ordinal) > -1) - { - _pushNotificationTimer.Reset(PushNotificationTimeout, PushNotificationTimeout); - } - } - else // Not a push notification - { - _currentSchedule = new RoomSchedule(); // Clear Current Schedule - _currentMeeting = null; // Clear Current Meeting - _nextMeeting = null; // Clear Next Meeting - - var isNextMeeting = false; - - foreach (XmlElement element in message.FirstChild.ChildNodes) - { - if (element.Name == "RequestID") - { - scheduleResponse.RequestID = element.InnerText; - } - else if (element.Name == "RoomID") - { - scheduleResponse.RoomID = element.InnerText; - } - else if (element.Name == "RoomName") - { - scheduleResponse.RoomName = element.InnerText; - } - else if (element.Name == "Event") - { - Debug.Console(2, this, "Event Found:\n{0}", element.OuterXml); - - var reader = new XmlReader(element.OuterXml); - - var tempEvent = CrestronXMLSerialization.DeSerializeObject(reader); - - scheduleResponse.Events.Add(tempEvent); - - // Check is this is the current event - if (tempEvent.dtStart <= DateTime.Now && tempEvent.dtEnd >= DateTime.Now) - { - _currentMeeting = tempEvent; // Set Current Meeting - isNextMeeting = true; // Flag that next element is next meeting - } - - if (isNextMeeting) - { - _nextMeeting = tempEvent; // Set Next Meeting - isNextMeeting = false; - } - - _currentSchedule.Meetings.Add(tempEvent); - } - } - - PrintTodaysSchedule(); - - if (!_isRegisteredForSchedulePushNotifications) - { - _pollTimer.Reset(SchedulePollInterval, SchedulePollInterval); - } - - // Fire Schedule Change Event - var handler = ScheduleChange; - - if (handler != null) - { - handler(this, new ScheduleChangeEventArgs {Schedule = _currentSchedule}); - } - } - } - } - catch (Exception e) - { - Debug.Console(1, this, "Error parsing ScheduleResponse: {0}", e); - } - } - else if (args.Sig == FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.CreateResponse) - { - Debug.Console(2, this, "Create Meeting Response Event: {0}\n Sig: {1}\nFusionResponse:\n{2}", args.Event, - args.Sig.Name, args.Sig.StringValue); - } - } - - /// - /// Prints today's schedule to console for debugging - /// - private void PrintTodaysSchedule() - { - if (Debug.Level > 1) - { - if (_currentSchedule.Meetings.Count > 0) - { - Debug.Console(1, this, "Today's Schedule for '{0}'\n", Room.Name); - - foreach (var e in _currentSchedule.Meetings) - { - Debug.Console(1, this, "Subject: {0}", e.Subject); - Debug.Console(1, this, "Organizer: {0}", e.Organizer); - Debug.Console(1, this, "MeetingID: {0}", e.MeetingID); - Debug.Console(1, this, "Start Time: {0}", e.dtStart); - Debug.Console(1, this, "End Time: {0}", e.dtEnd); - Debug.Console(1, this, "Duration: {0}\n", e.DurationInMinutes); - } - } - } - } - - protected virtual void SetUpSources() - { - // Sources - var dict = ConfigReader.ConfigObject.GetSourceListForKey(Room.SourceListKey); - if (dict != null) - { - // NEW PROCESS: - // Make these lists and insert the fusion attributes by iterating these - var setTopBoxes = dict.Where(d => d.Value.SourceDevice is ISetTopBoxControls); - uint i = 1; - foreach (var kvp in setTopBoxes) - { - TryAddRouteActionSigs(JoinMap.Display1SetTopBoxSourceStart.AttributeName + " " + i, JoinMap.Display1SetTopBoxSourceStart.JoinNumber + i, kvp.Key, kvp.Value.SourceDevice); - i++; - if (i > JoinMap.Display1SetTopBoxSourceStart.JoinSpan) // We only have five spots - { - break; - } - } - - var discPlayers = dict.Where(d => d.Value.SourceDevice is IDiscPlayerControls); - i = 1; - foreach (var kvp in discPlayers) - { - TryAddRouteActionSigs(JoinMap.Display1DiscPlayerSourceStart.AttributeName + " " + i, JoinMap.Display1DiscPlayerSourceStart.JoinNumber + i, kvp.Key, kvp.Value.SourceDevice); - i++; - if (i > JoinMap.Display1DiscPlayerSourceStart.JoinSpan) // We only have five spots - { - break; - } - } - - var laptops = dict.Where(d => d.Value.SourceDevice is Devices.Laptop); - i = 1; - foreach (var kvp in laptops) - { - TryAddRouteActionSigs(JoinMap.Display1LaptopSourceStart.AttributeName + " " + i, JoinMap.Display1LaptopSourceStart.JoinNumber + i, kvp.Key, kvp.Value.SourceDevice); - i++; - if (i > JoinMap.Display1LaptopSourceStart.JoinSpan) // We only have ten spots??? - { - break; - } - } - - foreach (var usageDevice in dict.Select(kvp => kvp.Value.SourceDevice).OfType()) - { - usageDevice.UsageTracker = new UsageTracking(usageDevice as Device) {UsageIsTracked = true}; - usageDevice.UsageTracker.DeviceUsageEnded += UsageTracker_DeviceUsageEnded; - } - } - else - { - Debug.Console(1, this, "WARNING: Config source list '{0}' not found for room '{1}'", - Room.SourceListKey, Room.Key); - } - } - - /// - /// Collects usage data from source and sends to Fusion - /// - /// - /// - protected void UsageTracker_DeviceUsageEnded(object sender, DeviceUsageEventArgs e) - { - var deviceTracker = sender as UsageTracking; - - if (deviceTracker == null) - { - return; - } - - var group = ConfigReader.GetGroupForDeviceKey(deviceTracker.Parent.Key); - - var currentMeetingId = "-"; - - if (_currentMeeting != null) - { - currentMeetingId = _currentMeeting.MeetingID; - } - - //String Format: "USAGE||[Date YYYY-MM-DD]||[Time HH-mm-ss]||TIME||[Asset_Type]||[Asset_Name]||[Minutes_used]||[Asset_ID]||[Meeting_ID]" - // [Asset_ID] property does not appear to be used in Crestron SSI examples. They are sending "-" instead so that's what is replicated here - var deviceUsage = string.Format("USAGE||{0}||{1}||TIME||{2}||{3}||-||{4}||-||{5}||{6}||\r\n", - e.UsageEndTime.ToString("yyyy-MM-dd"), e.UsageEndTime.ToString("HH:mm:ss"), - @group, deviceTracker.Parent.Name, e.MinutesUsed, "-", currentMeetingId); - - Debug.Console(1, this, "Device usage for: {0} ended at {1}. In use for {2} minutes", - deviceTracker.Parent.Name, e.UsageEndTime, e.MinutesUsed); - - FusionRoom.DeviceUsage.InputSig.StringValue = deviceUsage; - - Debug.Console(1, this, "Device usage string: {0}", deviceUsage); - } - - - protected void TryAddRouteActionSigs(string attrName, uint attrNum, string routeKey, Device pSrc) - { - Debug.Console(2, this, "Creating attribute '{0}' with join {1} for source {2}", - attrName, attrNum, pSrc.Key); - try - { - var sigD = FusionRoom.CreateOffsetBoolSig(attrNum, attrName, eSigIoMask.InputOutputSig); - // Need feedback when this source is selected - // Event handler, added below, will compare source changes with this sig dict - _sourceToFeedbackSigs.Add(pSrc, sigD.InputSig); - - // And respond to selection in Fusion - sigD.OutputSig.SetSigFalseAction(() => - { - var runRouteAction = Room as IRunRouteAction; - if (runRouteAction != null) - { - runRouteAction.RunRouteAction(routeKey, Room.SourceListKey); - } - }); - } - catch (Exception) - { - Debug.Console(2, this, "Error creating Fusion signal {0} {1} for device '{2}'. THIS NEEDS REWORKING", - attrNum, attrName, pSrc.Key); - } - } - - /// - /// - /// - private void SetUpCommunitcationMonitors() - { - uint displayNum = 0; - uint touchpanelNum = 0; - uint xpanelNum = 0; - - // Attach to all room's devices with monitors. - //foreach (var dev in DeviceManager.Devices) - foreach (var dev in DeviceManager.GetDevices()) - { - if (!(dev is ICommunicationMonitor)) - { - continue; - } - - string attrName = null; - uint attrNum = 1; - - //var keyNum = ExtractNumberFromKey(dev.Key); - //if (keyNum == -1) - //{ - // Debug.Console(1, this, "WARNING: Cannot link device '{0}' to numbered Fusion monitoring attributes", - // dev.Key); - // continue; - //} - //uint attrNum = Convert.ToUInt32(keyNum); - - // Check for UI devices - var uiDev = dev as IHasBasicTriListWithSmartObject; - if (uiDev != null) - { - if (uiDev.Panel is Crestron.SimplSharpPro.UI.XpanelForSmartGraphics) - { - attrNum = attrNum + touchpanelNum; - - if (attrNum > JoinMap.XpanelOnlineStart.JoinSpan) - { - continue; - } - attrName = JoinMap.XpanelOnlineStart.AttributeName + " " + attrNum; - attrNum += JoinMap.XpanelOnlineStart.JoinNumber; - - touchpanelNum++; - } - else - { - attrNum = attrNum + xpanelNum; - - if (attrNum > JoinMap.TouchpanelOnlineStart.JoinSpan) - { - continue; - } - attrName = JoinMap.TouchpanelOnlineStart.AttributeName + " " + attrNum; - attrNum += JoinMap.TouchpanelOnlineStart.JoinNumber; - - xpanelNum++; - } - } - - //else - if (dev is DisplayBase) - { - attrNum = attrNum + displayNum; - if (attrNum > JoinMap.DisplayOnlineStart.JoinSpan) - { - continue; - } - attrName = JoinMap.DisplayOnlineStart.AttributeName + " " + attrNum; - attrNum += JoinMap.DisplayOnlineStart.JoinNumber; - - displayNum++; - } - //else if (dev is DvdDeviceBase) - //{ - // if (attrNum > 5) - // continue; - // attrName = "Device Ok - DVD " + attrNum; - // attrNum += 260; - //} - // add set top box - - // add Cresnet roll-up - - // add DM-devices roll-up - - if (attrName != null) - { - // Link comm status to sig and update - var sigD = FusionRoom.CreateOffsetBoolSig(attrNum, attrName, eSigIoMask.InputSigOnly); - var smd = dev as ICommunicationMonitor; - sigD.InputSig.BoolValue = smd.CommunicationMonitor.Status == MonitorStatus.IsOk; - smd.CommunicationMonitor.StatusChange += - (o, a) => { sigD.InputSig.BoolValue = a.Status == MonitorStatus.IsOk; }; - Debug.Console(0, this, "Linking '{0}' communication monitor to Fusion '{1}'", dev.Key, attrName); - } - } - } - - protected virtual void SetUpDisplay() - { - try - { - //Setup Display Usage Monitoring - - var displays = DeviceManager.AllDevices.Where(d => d is DisplayBase); - - // Consider updating this in multiple display systems - - foreach (var display in displays.Cast()) - { - display.UsageTracker = new UsageTracking(display) {UsageIsTracked = true}; - display.UsageTracker.DeviceUsageEnded += UsageTracker_DeviceUsageEnded; - } - - var hasDefaultDisplay = Room as IHasDefaultDisplay; - if (hasDefaultDisplay == null) - { - return; - } - var defaultDisplay = hasDefaultDisplay.DefaultDisplay as DisplayBase; - if (defaultDisplay == null) - { - Debug.Console(1, this, "Cannot link null display to Fusion because default display is null"); - return; - } - - var dispPowerOnAction = new Action(b => - { - if (!b) - { - defaultDisplay.PowerOn(); - } - }); - var dispPowerOffAction = new Action(b => - { - if (!b) - { - defaultDisplay.PowerOff(); - } - }); - - // Display to fusion room sigs - FusionRoom.DisplayPowerOn.OutputSig.UserObject = dispPowerOnAction; - FusionRoom.DisplayPowerOff.OutputSig.UserObject = dispPowerOffAction; - - MapDisplayToRoomJoins(1, JoinMap.Display1Start.JoinNumber, defaultDisplay); - - - var deviceConfig = - ConfigReader.ConfigObject.Devices.FirstOrDefault(d => d.Key.Equals(defaultDisplay.Key)); - - //Check for existing asset in GUIDs collection - - FusionAsset tempAsset; - - if (FusionStaticAssets.ContainsKey(deviceConfig.Uid)) - { - tempAsset = FusionStaticAssets[deviceConfig.Uid]; - } - else - { - // Create a new asset - tempAsset = new FusionAsset(FusionRoomGuids.GetNextAvailableAssetNumber(FusionRoom), - defaultDisplay.Name, "Display", ""); - FusionStaticAssets.Add(deviceConfig.Uid, tempAsset); - } - - var dispAsset = FusionRoom.CreateStaticAsset(tempAsset.SlotNumber, tempAsset.Name, "Display", - tempAsset.InstanceId); - dispAsset.PowerOn.OutputSig.UserObject = dispPowerOnAction; - dispAsset.PowerOff.OutputSig.UserObject = dispPowerOffAction; - - var defaultTwoWayDisplay = defaultDisplay as IHasPowerControlWithFeedback; - if (defaultTwoWayDisplay != null) - { - defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(FusionRoom.DisplayPowerOn.InputSig); - if (defaultDisplay is IDisplayUsage) - { - (defaultDisplay as IDisplayUsage).LampHours.LinkInputSig(FusionRoom.DisplayUsage.InputSig); - } - - defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(dispAsset.PowerOn.InputSig); - } - - // Use extension methods - dispAsset.TrySetMakeModel(defaultDisplay); - dispAsset.TryLinkAssetErrorToCommunication(defaultDisplay); - } - catch (Exception e) - { - Debug.Console(1, this, "Error setting up display in Fusion: {0}", e); - } - } - - /// - /// Maps room attributes to a display at a specified index - /// - /// - /// - /// - /// a - protected virtual void MapDisplayToRoomJoins(int displayIndex, uint joinOffset, DisplayBase display) - { - var displayName = string.Format("Display {0} - ", displayIndex); - - - var hasDefaultDisplay = Room as IHasDefaultDisplay; - if (hasDefaultDisplay == null || display != hasDefaultDisplay.DefaultDisplay) - { - return; - } - // Display volume - var defaultDisplayVolume = FusionRoom.CreateOffsetUshortSig(JoinMap.VolumeFader1.JoinNumber, JoinMap.VolumeFader1.AttributeName, - eSigIoMask.InputOutputSig); - defaultDisplayVolume.OutputSig.UserObject = new Action(b => - { - var basicVolumeWithFeedback = display as IBasicVolumeWithFeedback; - if (basicVolumeWithFeedback == null) - { - return; - } - - basicVolumeWithFeedback.SetVolume(b); - basicVolumeWithFeedback.VolumeLevelFeedback.LinkInputSig(defaultDisplayVolume.InputSig); - }); - - - // Power on - var defaultDisplayPowerOn = FusionRoom.CreateOffsetBoolSig((uint) joinOffset, displayName + "Power On", - eSigIoMask.InputOutputSig); - defaultDisplayPowerOn.OutputSig.UserObject = new Action(b => - { - if (!b) - { - display.PowerOn(); - } - }); - - // Power Off - var defaultDisplayPowerOff = FusionRoom.CreateOffsetBoolSig((uint) joinOffset + 1, displayName + "Power Off", - eSigIoMask.InputOutputSig); - defaultDisplayPowerOn.OutputSig.UserObject = new Action(b => - { - if (!b) - { - display.PowerOff(); - } - }); - - - var defaultTwoWayDisplay = display as IHasPowerControlWithFeedback; - if (defaultTwoWayDisplay != null) - { - defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(defaultDisplayPowerOn.InputSig); - defaultTwoWayDisplay.PowerIsOnFeedback.LinkComplementInputSig(defaultDisplayPowerOff.InputSig); - } - - // Current Source - var defaultDisplaySourceNone = FusionRoom.CreateOffsetBoolSig((uint) joinOffset + 8, - displayName + "Source None", eSigIoMask.InputOutputSig); - defaultDisplaySourceNone.OutputSig.UserObject = new Action(b => - { - if (!b) - { - var runRouteAction = Room as IRunRouteAction; - if (runRouteAction != null) - { - runRouteAction.RunRouteAction("roomOff", Room.SourceListKey); - } - } - }); - } - - private void SetUpError() - { - // Roll up ALL device errors - _errorMessageRollUp = new StatusMonitorCollection(this); - foreach (var dev in DeviceManager.GetDevices()) - { - var md = dev as ICommunicationMonitor; - if (md != null) - { - _errorMessageRollUp.AddMonitor(md.CommunicationMonitor); - Debug.Console(2, this, "Adding '{0}' to room's overall error monitor", - md.CommunicationMonitor.Parent.Key); - } - } - _errorMessageRollUp.Start(); - FusionRoom.ErrorMessage.InputSig.StringValue = _errorMessageRollUp.Message; - _errorMessageRollUp.StatusChange += - (o, a) => { FusionRoom.ErrorMessage.InputSig.StringValue = _errorMessageRollUp.Message; }; - } - - /// - /// Sets up a local occupancy sensor, such as one attached to a Fusion Scheduling panel. The occupancy status of the room will be read from Fusion - /// - private void SetUpLocalOccupancy() - { - RoomIsOccupiedFeedback = new BoolFeedback(RoomIsOccupiedFeedbackFunc); - - FusionRoom.FusionAssetStateChange += FusionRoom_FusionAssetStateChange; - - // Build Occupancy Asset? - // Link sigs? - - //Room.SetRoomOccupancy(this as IOccupancyStatusProvider, 0); - } - - private void FusionRoom_FusionAssetStateChange(FusionBase device, FusionAssetStateEventArgs args) - { - if (args.EventId == FusionAssetEventId.RoomOccupiedReceivedEventId || - args.EventId == FusionAssetEventId.RoomUnoccupiedReceivedEventId) - { - RoomIsOccupiedFeedback.FireUpdate(); - } - } - - /// - /// Sets up remote occupancy that will relay the occupancy status determined by local system devices to Fusion - /// - private void SetUpRemoteOccupancy() - { - // Need to have the room occupancy object first and somehow determine the slot number of the Occupancy asset but will not be able to use the UID from config likely. - // Consider defining an object just for Room Occupancy (either eAssetType.Occupancy Sensor (local) or eAssetType.RemoteOccupancySensor (from Fusion sched. panel)) and reserving slot 4 for that asset (statics would start at 5) - - //if (Room.OccupancyObj != null) - //{ - - var tempOccAsset = _guiDs.OccupancyAsset; - - if (tempOccAsset == null) - { - FusionOccSensor = new FusionOccupancySensorAsset(eAssetType.OccupancySensor); - tempOccAsset = FusionOccSensor; - } - - var occSensorAsset = FusionRoom.CreateOccupancySensorAsset(tempOccAsset.SlotNumber, tempOccAsset.Name, - "Occupancy Sensor", tempOccAsset.InstanceId); - - occSensorAsset.RoomOccupied.AddSigToRVIFile = true; - - //var occSensorShutdownMinutes = FusionRoom.CreateOffsetUshortSig(70, "Occ Shutdown - Minutes", eSigIoMask.InputOutputSig); - - // Tie to method on occupancy object - //occSensorShutdownMinutes.OutputSig.UserObject(new Action(ushort)(b => Room.OccupancyObj.SetShutdownMinutes(b)); - - var occRoom = Room as IRoomOccupancy; - - if (occRoom != null) - { - occRoom.RoomOccupancy.RoomIsOccupiedFeedback.LinkInputSig(occSensorAsset.RoomOccupied.InputSig); - occRoom.RoomOccupancy.RoomIsOccupiedFeedback.OutputChange += RoomIsOccupiedFeedback_OutputChange; - } - RoomOccupancyRemoteStringFeedback = new StringFeedback(() => _roomOccupancyRemoteString); - - RoomOccupancyRemoteStringFeedback.LinkInputSig(occSensorAsset.RoomOccupancyInfo.InputSig); - - //} - } - - private void RoomIsOccupiedFeedback_OutputChange(object sender, FeedbackEventArgs e) - { - _roomOccupancyRemoteString = String.Format(RemoteOccupancyXml, e.BoolValue ? "Occupied" : "Unoccupied"); - RoomOccupancyRemoteStringFeedback.FireUpdate(); - } - - /// - /// Helper to get the number from the end of a device's key string - /// - /// -1 if no number matched - private int ExtractNumberFromKey(string key) - { - var capture = System.Text.RegularExpressions.Regex.Match(key, @"\b(\d+)"); - if (!capture.Success) - { - return -1; - } - return Convert.ToInt32(capture.Groups[1].Value); - } - - /// - /// Event handler for when room source changes - /// - protected void Room_CurrentSourceInfoChange(SourceListItem info, ChangeType type) - { - // Handle null. Nothing to do when switching from or to null - if (info == null || info.SourceDevice == null) - { - return; - } - - var dev = info.SourceDevice; - if (type == ChangeType.WillChange) - { - if (_sourceToFeedbackSigs.ContainsKey(dev)) - { - _sourceToFeedbackSigs[dev].BoolValue = false; - } - } - else - { - if (_sourceToFeedbackSigs.ContainsKey(dev)) - { - _sourceToFeedbackSigs[dev].BoolValue = true; - } - //var name = (room == null ? "" : room.Name); - CurrentRoomSourceNameSig.InputSig.StringValue = info.SourceDevice.Name; - } - } - - protected void FusionRoom_FusionStateChange(FusionBase device, FusionStateEventArgs args) - { - // The sig/UO method: Need separate handlers for fixed and user sigs, all flavors, - // even though they all contain sigs. - - var sigData = args.UserConfiguredSigDetail as BooleanSigDataFixedName; - - BoolOutputSig outSig; - if (sigData != null) - { - outSig = sigData.OutputSig; - if (outSig.UserObject is Action) - { - (outSig.UserObject as Action).Invoke(outSig.BoolValue); - } - else if (outSig.UserObject is Action) - { - (outSig.UserObject as Action).Invoke(outSig.UShortValue); - } - else if (outSig.UserObject is Action) - { - (outSig.UserObject as Action).Invoke(outSig.StringValue); - } - return; - } - - var attrData = (args.UserConfiguredSigDetail as BooleanSigData); - if (attrData == null) - { - return; - } - outSig = attrData.OutputSig; - if (outSig.UserObject is Action) - { - (outSig.UserObject as Action).Invoke(outSig.BoolValue); - } - else if (outSig.UserObject is Action) - { - (outSig.UserObject as Action).Invoke(outSig.UShortValue); - } - else if (outSig.UserObject is Action) - { - (outSig.UserObject as Action).Invoke(outSig.StringValue); - } - } - } - - - public static class FusionRoomExtensions - { - /// - /// Creates and returns a fusion attribute. The join number will match the established Simpl - /// standard of 50+, and will generate a 50+ join in the RVI. It calls - /// FusionRoom.AddSig with join number - 49 - /// - /// The new attribute - public static BooleanSigData CreateOffsetBoolSig(this FusionRoom fr, uint number, string name, eSigIoMask mask) - { - if (number < 50) - { - throw new ArgumentOutOfRangeException("number", "Cannot be less than 50"); - } - number -= 49; - fr.AddSig(eSigType.Bool, number, name, mask); - return fr.UserDefinedBooleanSigDetails[number]; - } - - /// - /// Creates and returns a fusion attribute. The join number will match the established Simpl - /// standard of 50+, and will generate a 50+ join in the RVI. It calls - /// FusionRoom.AddSig with join number - 49 - /// - /// The new attribute - public static UShortSigData CreateOffsetUshortSig(this FusionRoom fr, uint number, string name, eSigIoMask mask) - { - if (number < 50) - { - throw new ArgumentOutOfRangeException("number", "Cannot be less than 50"); - } - number -= 49; - fr.AddSig(eSigType.UShort, number, name, mask); - return fr.UserDefinedUShortSigDetails[number]; - } - - /// - /// Creates and returns a fusion attribute. The join number will match the established Simpl - /// standard of 50+, and will generate a 50+ join in the RVI. It calls - /// FusionRoom.AddSig with join number - 49 - /// - /// The new attribute - public static StringSigData CreateOffsetStringSig(this FusionRoom fr, uint number, string name, eSigIoMask mask) - { - if (number < 50) - { - throw new ArgumentOutOfRangeException("number", "Cannot be less than 50"); - } - number -= 49; - fr.AddSig(eSigType.String, number, name, mask); - return fr.UserDefinedStringSigDetails[number]; - } - - /// - /// Creates and returns a static asset - /// - /// the new asset - public static FusionStaticAsset CreateStaticAsset(this FusionRoom fr, uint number, string name, string type, - string instanceId) - { - try - { - Debug.Console(0, "Adding Fusion Static Asset '{0}' to slot {1} with GUID: '{2}'", name, number, instanceId); - - fr.AddAsset(eAssetType.StaticAsset, number, name, type, instanceId); - return fr.UserConfigurableAssetDetails[number].Asset as FusionStaticAsset; - } - catch (InvalidOperationException ex) - { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Error creating Static Asset for device: '{0}'. Check that multiple devices don't have missing or duplicate uid properties in configuration. /r/nError: {1}", name, ex); - return null; - } - catch (Exception e) - { - Debug.Console(2, Debug.ErrorLogLevel.Error, "Error creating Static Asset: {0}", e); - return null; - } - } - - public static FusionOccupancySensor CreateOccupancySensorAsset(this FusionRoom fr, uint number, string name, - string type, string instanceId) - { - try - { - Debug.Console(0, "Adding Fusion Occupancy Sensor Asset '{0}' to slot {1} with GUID: '{2}'", name, number, - instanceId); - - fr.AddAsset(eAssetType.OccupancySensor, number, name, type, instanceId); - return fr.UserConfigurableAssetDetails[number].Asset as FusionOccupancySensor; - } - catch (InvalidOperationException ex) - { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Error creating Static Asset for device: '{0}'. Check that multiple devices don't have missing or duplicate uid properties in configuration. Error: {1}", name, ex); - return null; - } - catch (Exception e) - { - Debug.Console(2, Debug.ErrorLogLevel.Error, "Error creating Static Asset: {0}", e); - return null; - } - } - } - - //************************************************************************************************ - /// - /// Extensions to enhance Fusion room, asset and signal creation. - /// - public static class FusionStaticAssetExtensions - { - /// - /// Tries to set a Fusion asset with the make and model of a device. - /// If the provided Device is IMakeModel, will set the corresponding parameters on the fusion static asset. - /// Otherwise, does nothing. - /// - public static void TrySetMakeModel(this FusionStaticAsset asset, Device device) - { - var mm = device as IMakeModel; - if (mm != null) - { - asset.ParamMake.Value = mm.DeviceMake; - asset.ParamModel.Value = mm.DeviceModel; - } - } - - /// - /// Tries to attach the AssetError input on a Fusion asset to a Device's - /// CommunicationMonitor.StatusChange event. Does nothing if the device is not - /// IStatusMonitor - /// - /// - /// - public static void TryLinkAssetErrorToCommunication(this FusionStaticAsset asset, Device device) - { - if (device is ICommunicationMonitor) - { - var monitor = (device as ICommunicationMonitor).CommunicationMonitor; - monitor.StatusChange += (o, a) => - { - // Link connected and error inputs on asset - asset.Connected.InputSig.BoolValue = a.Status == MonitorStatus.IsOk; - asset.AssetError.InputSig.StringValue = a.Status.ToString(); - }; - // set current value - asset.Connected.InputSig.BoolValue = monitor.Status == MonitorStatus.IsOk; - asset.AssetError.InputSig.StringValue = monitor.Status.ToString(); - } - } - } - - public class RoomInformation - { - public RoomInformation() - { - FusionCustomProperties = new List(); - } - - public string ID { get; set; } - public string Name { get; set; } - public string Location { get; set; } - public string Description { get; set; } - public string TimeZone { get; set; } - public string WebcamURL { get; set; } - public string BacklogMsg { get; set; } - public string SubErrorMsg { get; set; } - public string EmailInfo { get; set; } - public List FusionCustomProperties { get; set; } - } - - public class FusionCustomProperty - { - public FusionCustomProperty() - { - } - - public FusionCustomProperty(string id) - { - ID = id; - } - - public string ID { get; set; } - public string CustomFieldName { get; set; } - public string CustomFieldType { get; set; } - public string CustomFieldValue { get; set; } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharp.CrestronIO; +using Crestron.SimplSharp.CrestronXml; +using Crestron.SimplSharp.CrestronXml.Serialization; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.Fusion; +using Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core.Fusion +{ + public class EssentialsHuddleSpaceFusionSystemControllerBase : Device, IOccupancyStatusProvider + { + protected EssentialsHuddleSpaceRoomFusionRoomJoinMap JoinMap; + + private const string RemoteOccupancyXml = "Local{0}"; + private readonly bool _guidFileExists; + + private readonly Dictionary _sourceToFeedbackSigs = + new Dictionary(); + + protected StringSigData CurrentRoomSourceNameSig; + + public FusionCustomPropertiesBridge CustomPropertiesBridge = new FusionCustomPropertiesBridge(); + protected FusionOccupancySensorAsset FusionOccSensor; + protected FusionRemoteOccupancySensor FusionRemoteOccSensor; + + protected FusionRoom FusionRoom; + protected Dictionary FusionStaticAssets; + public long PushNotificationTimeout = 5000; + protected IEssentialsRoom Room; + public long SchedulePollInterval = 300000; + + private Event _currentMeeting; + private RoomSchedule _currentSchedule; + private CTimer _dailyTimeRequestTimer; + private StatusMonitorCollection _errorMessageRollUp; + + private FusionRoomGuids _guiDs; + private uint _ipId; + + private bool _isRegisteredForSchedulePushNotifications; + private Event _nextMeeting; + + private CTimer _pollTimer; + + private CTimer _pushNotificationTimer; + + private string _roomOccupancyRemoteString; + + #region System Info Sigs + + //StringSigData SystemName; + //StringSigData Model; + //StringSigData SerialNumber; + //StringSigData Uptime; + + #endregion + + #region Processor Info Sigs + + private readonly StringSigData[] _program = new StringSigData[10]; + private StringSigData _dns1; + private StringSigData _dns2; + private StringSigData _domain; + private StringSigData _firmware; + private StringSigData _gateway; + private StringSigData _hostname; + private StringSigData _ip1; + private StringSigData _ip2; + private StringSigData _mac1; + private StringSigData _mac2; + private StringSigData _netMask1; + private StringSigData _netMask2; + + #endregion + + #region Default Display Source Sigs + + private BooleanSigData[] _source = new BooleanSigData[10]; + + #endregion + + public EssentialsHuddleSpaceFusionSystemControllerBase(IEssentialsRoom room, uint ipId, string joinMapKey) + : base(room.Key + "-fusion") + { + try + { + JoinMap = new EssentialsHuddleSpaceRoomFusionRoomJoinMap(1); + + CrestronConsole.AddNewConsoleCommand((o) => JoinMap.PrintJoinMapInfo(), string.Format("ptjnmp-{0}", Key), "Prints Attribute Join Map", ConsoleAccessLevelEnum.AccessOperator); + + if (!string.IsNullOrEmpty(joinMapKey)) + { + var customJoins = JoinMapHelper.TryGetJoinMapAdvancedForDevice(joinMapKey); + if (customJoins != null) + { + JoinMap.SetCustomJoinData(customJoins); + } + } + + Room = room; + + _ipId = ipId; + + FusionStaticAssets = new Dictionary(); + + _guiDs = new FusionRoomGuids(); + + var mac = + CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, 0); + + var slot = Global.ControlSystem.ProgramNumber; + + var guidFilePath = Global.FilePathPrefix + + string.Format(@"{0}-FusionGuids-{1:X2}.json", InitialParametersClass.ProgramIDTag, _ipId); + + var oldGuidFilePath = Global.FilePathPrefix + + string.Format(@"{0}-FusionGuids.json", InitialParametersClass.ProgramIDTag); + + if (File.Exists(oldGuidFilePath)) + { + Debug.Console(0, this, "Migrating from old Fusion GUID file to new Fusion GUID File"); + + File.Copy(oldGuidFilePath, guidFilePath); + + File.Delete(oldGuidFilePath); + } + + _guidFileExists = File.Exists(guidFilePath); + + // Check if file exists + if (!_guidFileExists) + { + // Does not exist. Create GUIDs + _guiDs = new FusionRoomGuids(Room.Name, ipId, _guiDs.GenerateNewRoomGuid(slot, mac), + FusionStaticAssets); + } + else + { + // Exists. Read GUIDs + ReadGuidFile(guidFilePath); + } + + var occupancyRoom = Room as IRoomOccupancy; + + if (occupancyRoom != null) + { + if (occupancyRoom.RoomOccupancy != null) + { + if (occupancyRoom.OccupancyStatusProviderIsRemote) + { + SetUpRemoteOccupancy(); + } + else + { + SetUpLocalOccupancy(); + } + } + } + + + AddPostActivationAction(() => PostActivate(guidFilePath)); + } + catch (Exception e) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Error Building Fusion System Controller: {0}", e); + } + } + + private void PostActivate(string guidFilePath) + { + CreateSymbolAndBasicSigs(_ipId); + SetUpSources(); + SetUpCommunitcationMonitors(); + SetUpDisplay(); + SetUpError(); + ExecuteCustomSteps(); + + FusionRVI.GenerateFileForAllFusionDevices(); + + GenerateGuidFile(guidFilePath); + } + + protected string RoomGuid + { + get { return _guiDs.RoomGuid; } + } + + public StringFeedback RoomOccupancyRemoteStringFeedback { get; private set; } + + protected Func RoomIsOccupiedFeedbackFunc + { + get { return () => FusionRemoteOccSensor.RoomOccupied.OutputSig.BoolValue; } + } + + #region IOccupancyStatusProvider Members + + public BoolFeedback RoomIsOccupiedFeedback { get; private set; } + + #endregion + + public event EventHandler ScheduleChange; + //public event EventHandler MeetingEndWarning; + //public event EventHandler NextMeetingBeginWarning; + + public event EventHandler RoomInfoChange; + + //ScheduleResponseEvent NextMeeting; + + /// + /// Used for extension classes to execute whatever steps are necessary before generating the RVI and GUID files + /// + protected virtual void ExecuteCustomSteps() + { + } + + /// + /// Generates the guid file in NVRAM. If the file already exists it will be overwritten. + /// + /// path for the file + private void GenerateGuidFile(string filePath) + { + if (string.IsNullOrEmpty(filePath)) + { + Debug.Console(0, this, "Error writing guid file. No path specified."); + return; + } + + var fileLock = new CCriticalSection(); + + try + { + if (fileLock.Disposed) + { + return; + } + + fileLock.Enter(); + + Debug.Console(1, this, "Writing GUIDs to file"); + + _guiDs = FusionOccSensor == null + ? new FusionRoomGuids(Room.Name, _ipId, RoomGuid, FusionStaticAssets) + : new FusionRoomGuids(Room.Name, _ipId, RoomGuid, FusionStaticAssets, FusionOccSensor); + + var json = JsonConvert.SerializeObject(_guiDs, Newtonsoft.Json.Formatting.Indented); + + using (var sw = new StreamWriter(filePath)) + { + sw.Write(json); + sw.Flush(); + } + + Debug.Console(1, this, "Guids successfully written to file '{0}'", filePath); + } + catch (Exception e) + { + Debug.Console(0, this, "Error writing guid file: {0}", e); + } + finally + { + if (!fileLock.Disposed) + { + fileLock.Leave(); + } + } + } + + /// + /// Reads the guid file from NVRAM + /// + /// path for te file + private void ReadGuidFile(string filePath) + { + if (string.IsNullOrEmpty(filePath)) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Error reading guid file. No path specified."); + return; + } + + var fileLock = new CCriticalSection(); + + try + { + if (fileLock.Disposed) + { + return; + } + + fileLock.Enter(); + + if (File.Exists(filePath)) + { + var json = File.ReadToEnd(filePath, Encoding.ASCII); + + _guiDs = JsonConvert.DeserializeObject(json); + + _ipId = _guiDs.IpId; + + FusionStaticAssets = _guiDs.StaticAssets; + } + + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Fusion Guids successfully read from file: {0}", + filePath); + + Debug.Console(1, this, "\r\n********************\r\n\tRoom Name: {0}\r\n\tIPID: {1:X}\r\n\tRoomGuid: {2}\r\n*******************", Room.Name, _ipId, RoomGuid); + + foreach (var item in FusionStaticAssets) + { + Debug.Console(1, this, "\nAsset Name: {0}\nAsset No: {1}\n Guid: {2}", item.Value.Name, + item.Value.SlotNumber, item.Value.InstanceId); + } + } + catch (Exception e) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Error reading guid file: {0}", e); + } + finally + { + if (!fileLock.Disposed) + { + fileLock.Leave(); + } + } + } + + protected virtual void CreateSymbolAndBasicSigs(uint ipId) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Creating Fusion Room symbol with GUID: {0} and IP-ID {1:X2}", RoomGuid, ipId); + + FusionRoom = new FusionRoom(ipId, Global.ControlSystem, Room.Name, RoomGuid); + FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.Use(); + FusionRoom.ExtenderFusionRoomDataReservedSigs.Use(); + + FusionRoom.Register(); + + FusionRoom.FusionStateChange += FusionRoom_FusionStateChange; + + FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.DeviceExtenderSigChange += + FusionRoomSchedule_DeviceExtenderSigChange; + FusionRoom.ExtenderFusionRoomDataReservedSigs.DeviceExtenderSigChange += + ExtenderFusionRoomDataReservedSigs_DeviceExtenderSigChange; + FusionRoom.OnlineStatusChange += FusionRoom_OnlineStatusChange; + + CrestronConsole.AddNewConsoleCommand(RequestFullRoomSchedule, "FusReqRoomSchedule", + "Requests schedule of the room for the next 24 hours", ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(ModifyMeetingEndTimeConsoleHelper, "FusReqRoomSchMod", + "Ends or extends a meeting by the specified time", ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(CreateAdHocMeeting, "FusCreateMeeting", + "Creates and Ad Hoc meeting for on hour or until the next meeting", + ConsoleAccessLevelEnum.AccessOperator); + + // Room to fusion room + Room.OnFeedback.LinkInputSig(FusionRoom.SystemPowerOn.InputSig); + + // Moved to + CurrentRoomSourceNameSig = FusionRoom.CreateOffsetStringSig(JoinMap.Display1CurrentSourceName.JoinNumber, JoinMap.Display1CurrentSourceName.AttributeName, + eSigIoMask.InputSigOnly); + // Don't think we need to get current status of this as nothing should be alive yet. + var hasCurrentSourceInfoChange = Room as IHasCurrentSourceInfoChange; + if (hasCurrentSourceInfoChange != null) + { + hasCurrentSourceInfoChange.CurrentSourceChange += Room_CurrentSourceInfoChange; + } + + + FusionRoom.SystemPowerOn.OutputSig.SetSigFalseAction(Room.PowerOnToDefaultOrLastSource); + FusionRoom.SystemPowerOff.OutputSig.SetSigFalseAction(() => + { + var runRouteAction = Room as IRunRouteAction; + if (runRouteAction != null) + { + runRouteAction.RunRouteAction("roomOff", Room.SourceListKey); + } + }); + // NO!! room.RoomIsOn.LinkComplementInputSig(FusionRoom.SystemPowerOff.InputSig); + FusionRoom.ErrorMessage.InputSig.StringValue = + "3: 7 Errors: This is a really long error message;This is a really long error message;This is a really long error message;This is a really long error message;This is a really long error message;This is a really long error message;This is a really long error message;"; + + SetUpEthernetValues(); + + GetProcessorEthernetValues(); + + GetSystemInfo(); + + GetProcessorInfo(); + + CrestronEnvironment.EthernetEventHandler += CrestronEnvironment_EthernetEventHandler; + } + + protected void CrestronEnvironment_EthernetEventHandler(EthernetEventArgs ethernetEventArgs) + { + if (ethernetEventArgs.EthernetEventType == eEthernetEventType.LinkUp) + { + GetProcessorEthernetValues(); + } + } + + protected void GetSystemInfo() + { + //SystemName.InputSig.StringValue = Room.Name; + //Model.InputSig.StringValue = InitialParametersClass.ControllerPromptName; + //SerialNumber.InputSig.StringValue = InitialParametersClass. + + var response = string.Empty; + + var systemReboot = FusionRoom.CreateOffsetBoolSig(JoinMap.ProcessorReboot.JoinNumber, JoinMap.ProcessorReboot.AttributeName, eSigIoMask.OutputSigOnly); + systemReboot.OutputSig.SetSigFalseAction( + () => CrestronConsole.SendControlSystemCommand("reboot", ref response)); + } + + protected void SetUpEthernetValues() + { + _ip1 = FusionRoom.CreateOffsetStringSig(JoinMap.ProcessorIp1.JoinNumber, JoinMap.ProcessorIp1.AttributeName, eSigIoMask.InputSigOnly); + _ip2 = FusionRoom.CreateOffsetStringSig(JoinMap.ProcessorIp2.JoinNumber, JoinMap.ProcessorIp2.AttributeName, eSigIoMask.InputSigOnly); + _gateway = FusionRoom.CreateOffsetStringSig(JoinMap.ProcessorGateway.JoinNumber, JoinMap.ProcessorGateway.AttributeName, eSigIoMask.InputSigOnly); + _hostname = FusionRoom.CreateOffsetStringSig(JoinMap.ProcessorHostname.JoinNumber, JoinMap.ProcessorHostname.AttributeName, eSigIoMask.InputSigOnly); + _domain = FusionRoom.CreateOffsetStringSig(JoinMap.ProcessorDomain.JoinNumber, JoinMap.ProcessorDomain.AttributeName, eSigIoMask.InputSigOnly); + _dns1 = FusionRoom.CreateOffsetStringSig(JoinMap.ProcessorDns1.JoinNumber, JoinMap.ProcessorDns1.AttributeName, eSigIoMask.InputSigOnly); + _dns2 = FusionRoom.CreateOffsetStringSig(JoinMap.ProcessorDns2.JoinNumber, JoinMap.ProcessorDns2.AttributeName, eSigIoMask.InputSigOnly); + _mac1 = FusionRoom.CreateOffsetStringSig(JoinMap.ProcessorMac1.JoinNumber, JoinMap.ProcessorMac1.AttributeName, eSigIoMask.InputSigOnly); + _mac2 = FusionRoom.CreateOffsetStringSig(JoinMap.ProcessorMac2.JoinNumber, JoinMap.ProcessorMac2.AttributeName, eSigIoMask.InputSigOnly); + _netMask1 = FusionRoom.CreateOffsetStringSig(JoinMap.ProcessorNetMask1.JoinNumber, JoinMap.ProcessorNetMask1.AttributeName, eSigIoMask.InputSigOnly); + _netMask2 = FusionRoom.CreateOffsetStringSig(JoinMap.ProcessorNetMask2.JoinNumber, JoinMap.ProcessorNetMask2.AttributeName, eSigIoMask.InputSigOnly); + } + + protected void GetProcessorEthernetValues() + { + _ip1.InputSig.StringValue = + CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0); + _gateway.InputSig.StringValue = + CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_ROUTER, 0); + _hostname.InputSig.StringValue = + CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, 0); + _domain.InputSig.StringValue = + CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DOMAIN_NAME, 0); + + var dnsServers = + CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DNS_SERVER, 0).Split(','); + _dns1.InputSig.StringValue = dnsServers[0]; + if (dnsServers.Length > 1) + { + _dns2.InputSig.StringValue = dnsServers[1]; + } + + _mac1.InputSig.StringValue = + CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, 0); + _netMask1.InputSig.StringValue = + CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, 0); + + // Interface 1 + + if (InitialParametersClass.NumberOfEthernetInterfaces > 1) + // Only get these values if the processor has more than 1 NIC + { + _ip2.InputSig.StringValue = + CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 1); + _mac2.InputSig.StringValue = + CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, 1); + _netMask2.InputSig.StringValue = + CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, 1); + } + } + + protected void GetProcessorInfo() + { + _firmware = FusionRoom.CreateOffsetStringSig(JoinMap.ProcessorFirmware.JoinNumber, JoinMap.ProcessorFirmware.AttributeName, eSigIoMask.InputSigOnly); + + if (CrestronEnvironment.DevicePlatform != eDevicePlatform.Server) + { + for (var i = 0; i < Global.ControlSystem.NumProgramsSupported; i++) + { + var join = JoinMap.ProgramNameStart.JoinNumber + i; + var progNum = i + 1; + _program[i] = FusionRoom.CreateOffsetStringSig((uint) join, + string.Format("{0} {1}", JoinMap.ProgramNameStart.AttributeName, progNum), eSigIoMask.InputSigOnly); + } + } + + _firmware.InputSig.StringValue = InitialParametersClass.FirmwareVersion; + } + + protected void GetCustomProperties() + { + if (FusionRoom.IsOnline) + { + const string fusionRoomCustomPropertiesRequest = + @"RoomConfigurationRequest"; + + FusionRoom.ExtenderFusionRoomDataReservedSigs.RoomConfigQuery.StringValue = + fusionRoomCustomPropertiesRequest; + } + } + + private void GetTouchpanelInfo() + { + // TODO: Get IP and Project Name from TP + } + + protected void FusionRoom_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) + { + if (args.DeviceOnLine) + { + CrestronInvoke.BeginInvoke( (o) => + { + CrestronEnvironment.Sleep(200); + + // Send Push Notification Action request: + + const string requestId = "InitialPushRequest"; + + + var actionRequest = + string.Format("\n{0}\n", requestId) + + "RegisterPushModel\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n"; + + Debug.Console(2, this, "Sending Fusion ActionRequest: \n{0}", actionRequest); + + FusionRoom.ExtenderFusionRoomDataReservedSigs.ActionQuery.StringValue = actionRequest; + + GetCustomProperties(); + + // Request current Fusion Server Time + RequestLocalDateTime(null); + + // Setup timer to request time daily + if (_dailyTimeRequestTimer != null && !_dailyTimeRequestTimer.Disposed) + { + _dailyTimeRequestTimer.Stop(); + _dailyTimeRequestTimer.Dispose(); + } + + _dailyTimeRequestTimer = new CTimer(RequestLocalDateTime, null, 86400000, 86400000); + + _dailyTimeRequestTimer.Reset(86400000, 86400000); + }); + } + } + + /// + /// Requests the local date and time from the Fusion Server + /// + /// + public void RequestLocalDateTime(object callbackObject) + { + const string timeRequestId = "TimeRequest"; + + var timeRequest = string.Format("{0}", + timeRequestId); + + FusionRoom.ExtenderFusionRoomDataReservedSigs.LocalDateTimeQuery.StringValue = timeRequest; + } + + /// + /// Generates a room schedule request for this room for the next 24 hours. + /// + public void RequestFullRoomSchedule(object callbackObject) + { + var now = DateTime.Today; + + var currentTime = now.ToString("s"); + + var requestTest = + string.Format( + "FullSchedleRequest{0}{1}24", + RoomGuid, currentTime); + + Debug.Console(2, this, "Sending Fusion ScheduleQuery: \n{0}", requestTest); + + FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.ScheduleQuery.StringValue = requestTest; + + if (_isRegisteredForSchedulePushNotifications) + { + _pushNotificationTimer.Stop(); + } + } + + /// + /// Wrapper method to allow console commands to modify the current meeting end time + /// + /// meetingID extendTime + public void ModifyMeetingEndTimeConsoleHelper(string command) + { + var extendMinutes = -1; + + const string requestId = "ModifyMeetingTest12345"; + + try + { + var tokens = command.Split(' '); + + extendMinutes = Int32.Parse(tokens[1]); + } + catch (Exception e) + { + Debug.Console(1, this, "Error parsing console command: {0}", e); + } + + ModifyMeetingEndTime(requestId, extendMinutes); + } + + /// + /// Ends or Extends the current meeting by the specified number of minutes. + /// + /// + /// Number of minutes to extend the meeting. A value of 0 will end the meeting. + public void ModifyMeetingEndTime(string requestId, int extendMinutes) + { + if (_currentMeeting == null) + { + Debug.Console(1, this, "No meeting in progress. Unable to modify end time."); + return; + } + + if (extendMinutes > -1) + { + if (extendMinutes > 0) + { + var extendTime = _currentMeeting.dtEnd - DateTime.Now; + var extendMinutesRaw = extendTime.TotalMinutes; + + extendMinutes = extendMinutes + (int) Math.Round(extendMinutesRaw); + } + + + var requestTest = string.Format( + "{0}{1}MeetingChange" + , requestId, RoomGuid, _currentMeeting.MeetingID, extendMinutes); + + Debug.Console(1, this, "Sending MeetingChange Request: \n{0}", requestTest); + + FusionRoom.ExtenderFusionRoomDataReservedSigs.ActionQuery.StringValue = requestTest; + } + else + { + Debug.Console(1, this, "Invalid time specified"); + } + } + + /// + /// Creates and Ad Hoc meeting with a duration of 1 hour, or until the next meeting if in less than 1 hour. + /// + public void CreateAdHocMeeting(string command) + { + const string requestId = "CreateAdHocMeeting"; + + var now = DateTime.Now.AddMinutes(1); + + now.AddSeconds(-now.Second); + + // Assume 1 hour meeting if possible + var dtEnd = now.AddHours(1); + + // Check if room is available for 1 hour before next meeting + if (_nextMeeting != null) + { + var roomAvailable = _nextMeeting.dtEnd.Subtract(dtEnd); + + if (roomAvailable.TotalMinutes < 60) + { + // Room not available for full hour, book until next meeting starts + dtEnd = _nextMeeting.dtEnd; + } + } + + var createMeetingRequest = + "" + + string.Format("{0}", requestId) + + string.Format("{0}", RoomGuid) + + "" + + string.Format("{0}", now.ToString("s")) + + string.Format("{0}", dtEnd.ToString("s")) + + "AdHoc Meeting" + + "Room User" + + "Example Message" + + "" + + ""; + + Debug.Console(2, this, "Sending CreateMeeting Request: \n{0}", createMeetingRequest); + + FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.CreateMeeting.StringValue = createMeetingRequest; + + //Debug.Console(1, this, "Sending CreateMeeting Request: \n{0}", command); + + //FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.CreateMeeting.StringValue = command; + } + + /// + /// Event handler method for Device Extender sig changes + /// + /// + /// + protected void ExtenderFusionRoomDataReservedSigs_DeviceExtenderSigChange(DeviceExtender currentDeviceExtender, + SigEventArgs args) + { + Debug.Console(2, this, "Event: {0}\n Sig: {1}\nFusionResponse:\n{2}", args.Event, args.Sig.Name, + args.Sig.StringValue); + + + if (args.Sig == FusionRoom.ExtenderFusionRoomDataReservedSigs.ActionQueryResponse) + { + try + { + var message = new XmlDocument(); + + message.LoadXml(args.Sig.StringValue); + + var actionResponse = message["ActionResponse"]; + + if (actionResponse == null) + { + return; + } + + var requestId = actionResponse["RequestID"]; + + if (requestId.InnerText != "InitialPushRequest") + { + return; + } + + if (actionResponse["ActionID"].InnerText != "RegisterPushModel") + { + return; + } + + var parameters = actionResponse["Parameters"]; + + foreach (var isRegistered in from XmlElement parameter in parameters + where parameter.HasAttributes + select parameter.Attributes + into attributes + where attributes["ID"].Value == "Registered" + select Int32.Parse(attributes["Value"].Value)) + { + switch (isRegistered) + { + case 1: + _isRegisteredForSchedulePushNotifications = true; + if (_pollTimer != null && !_pollTimer.Disposed) + { + _pollTimer.Stop(); + _pollTimer.Dispose(); + } + _pushNotificationTimer = new CTimer(RequestFullRoomSchedule, null, + PushNotificationTimeout, PushNotificationTimeout); + _pushNotificationTimer.Reset(PushNotificationTimeout, PushNotificationTimeout); + break; + case 0: + _isRegisteredForSchedulePushNotifications = false; + if (_pushNotificationTimer != null && !_pushNotificationTimer.Disposed) + { + _pushNotificationTimer.Stop(); + _pushNotificationTimer.Dispose(); + } + _pollTimer = new CTimer(RequestFullRoomSchedule, null, SchedulePollInterval, + SchedulePollInterval); + _pollTimer.Reset(SchedulePollInterval, SchedulePollInterval); + break; + } + } + } + catch (Exception e) + { + Debug.Console(1, this, "Error parsing ActionQueryResponse: {0}", e); + } + } + else if (args.Sig == FusionRoom.ExtenderFusionRoomDataReservedSigs.LocalDateTimeQueryResponse) + { + try + { + var message = new XmlDocument(); + + message.LoadXml(args.Sig.StringValue); + + var localDateTimeResponse = message["LocalTimeResponse"]; + + if (localDateTimeResponse != null) + { + var localDateTime = localDateTimeResponse["LocalDateTime"]; + + if (localDateTime != null) + { + var tempLocalDateTime = localDateTime.InnerText; + + var currentTime = DateTime.Parse(tempLocalDateTime); + + Debug.Console(1, this, "DateTime from Fusion Server: {0}", currentTime); + + // Parse time and date from response and insert values + CrestronEnvironment.SetTimeAndDate((ushort) currentTime.Hour, (ushort) currentTime.Minute, + (ushort) currentTime.Second, (ushort) currentTime.Month, (ushort) currentTime.Day, + (ushort) currentTime.Year); + + Debug.Console(1, this, "Processor time set to {0}", CrestronEnvironment.GetLocalTime()); + } + } + } + catch (Exception e) + { + Debug.Console(1, this, "Error parsing LocalDateTimeQueryResponse: {0}", e); + } + } + else if (args.Sig == FusionRoom.ExtenderFusionRoomDataReservedSigs.RoomConfigResponse) + { + // Room info response with custom properties + + var roomConfigResponseArgs = args.Sig.StringValue.Replace("&", "and"); + + Debug.Console(2, this, "Fusion Response: \n {0}", roomConfigResponseArgs); + + try + { + var roomConfigResponse = new XmlDocument(); + + roomConfigResponse.LoadXml(roomConfigResponseArgs); + + var requestRoomConfiguration = roomConfigResponse["RoomConfigurationResponse"]; + + if (requestRoomConfiguration != null) + { + var roomInformation = new RoomInformation(); + + foreach (XmlElement e in roomConfigResponse.FirstChild.ChildNodes) + { + if (e.Name == "RoomInformation") + { + var roomInfo = new XmlReader(e.OuterXml); + + roomInformation = CrestronXMLSerialization.DeSerializeObject(roomInfo); + } + else if (e.Name == "CustomFields") + { + foreach (XmlElement el in e) + { + var customProperty = new FusionCustomProperty(); + + if (el.Name == "CustomField") + { + customProperty.ID = el.Attributes["ID"].Value; + } + + foreach (XmlElement elm in el) + { + if (elm.Name == "CustomFieldName") + { + customProperty.CustomFieldName = elm.InnerText; + } + if (elm.Name == "CustomFieldType") + { + customProperty.CustomFieldType = elm.InnerText; + } + if (elm.Name == "CustomFieldValue") + { + customProperty.CustomFieldValue = elm.InnerText; + } + } + + roomInformation.FusionCustomProperties.Add(customProperty); + } + } + } + + var handler = RoomInfoChange; + if (handler != null) + { + handler(this, new EventArgs()); + } + + CustomPropertiesBridge.EvaluateRoomInfo(Room.Key, roomInformation); + } + } + catch (Exception e) + { + Debug.Console(1, this, "Error parsing Custom Properties response: {0}", e); + } + //PrintRoomInfo(); + //getRoomInfoBusy = false; + //_DynFusion.API.EISC.BooleanInput[Constants.GetRoomInfo].BoolValue = getRoomInfoBusy; + } + } + + /// + /// Event handler method for Device Extender sig changes + /// + /// + /// + protected void FusionRoomSchedule_DeviceExtenderSigChange(DeviceExtender currentDeviceExtender, + SigEventArgs args) + { + Debug.Console(2, this, "Scehdule Response Event: {0}\n Sig: {1}\nFusionResponse:\n{2}", args.Event, + args.Sig.Name, args.Sig.StringValue); + + + if (args.Sig == FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.ScheduleResponse) + { + try + { + var scheduleResponse = new ScheduleResponse(); + + var message = new XmlDocument(); + + message.LoadXml(args.Sig.StringValue); + + var response = message["ScheduleResponse"]; + + if (response != null) + { + // Check for push notification + if (response["RequestID"].InnerText == "RVRequest") + { + var action = response["Action"]; + + if (action.OuterXml.IndexOf("RequestSchedule", StringComparison.Ordinal) > -1) + { + _pushNotificationTimer.Reset(PushNotificationTimeout, PushNotificationTimeout); + } + } + else // Not a push notification + { + _currentSchedule = new RoomSchedule(); // Clear Current Schedule + _currentMeeting = null; // Clear Current Meeting + _nextMeeting = null; // Clear Next Meeting + + var isNextMeeting = false; + + foreach (XmlElement element in message.FirstChild.ChildNodes) + { + if (element.Name == "RequestID") + { + scheduleResponse.RequestID = element.InnerText; + } + else if (element.Name == "RoomID") + { + scheduleResponse.RoomID = element.InnerText; + } + else if (element.Name == "RoomName") + { + scheduleResponse.RoomName = element.InnerText; + } + else if (element.Name == "Event") + { + Debug.Console(2, this, "Event Found:\n{0}", element.OuterXml); + + var reader = new XmlReader(element.OuterXml); + + var tempEvent = CrestronXMLSerialization.DeSerializeObject(reader); + + scheduleResponse.Events.Add(tempEvent); + + // Check is this is the current event + if (tempEvent.dtStart <= DateTime.Now && tempEvent.dtEnd >= DateTime.Now) + { + _currentMeeting = tempEvent; // Set Current Meeting + isNextMeeting = true; // Flag that next element is next meeting + } + + if (isNextMeeting) + { + _nextMeeting = tempEvent; // Set Next Meeting + isNextMeeting = false; + } + + _currentSchedule.Meetings.Add(tempEvent); + } + } + + PrintTodaysSchedule(); + + if (!_isRegisteredForSchedulePushNotifications) + { + _pollTimer.Reset(SchedulePollInterval, SchedulePollInterval); + } + + // Fire Schedule Change Event + var handler = ScheduleChange; + + if (handler != null) + { + handler(this, new ScheduleChangeEventArgs {Schedule = _currentSchedule}); + } + } + } + } + catch (Exception e) + { + Debug.Console(1, this, "Error parsing ScheduleResponse: {0}", e); + } + } + else if (args.Sig == FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.CreateResponse) + { + Debug.Console(2, this, "Create Meeting Response Event: {0}\n Sig: {1}\nFusionResponse:\n{2}", args.Event, + args.Sig.Name, args.Sig.StringValue); + } + } + + /// + /// Prints today's schedule to console for debugging + /// + private void PrintTodaysSchedule() + { + if (Debug.Level > 1) + { + if (_currentSchedule.Meetings.Count > 0) + { + Debug.Console(1, this, "Today's Schedule for '{0}'\n", Room.Name); + + foreach (var e in _currentSchedule.Meetings) + { + Debug.Console(1, this, "Subject: {0}", e.Subject); + Debug.Console(1, this, "Organizer: {0}", e.Organizer); + Debug.Console(1, this, "MeetingID: {0}", e.MeetingID); + Debug.Console(1, this, "Start Time: {0}", e.dtStart); + Debug.Console(1, this, "End Time: {0}", e.dtEnd); + Debug.Console(1, this, "Duration: {0}\n", e.DurationInMinutes); + } + } + } + } + + protected virtual void SetUpSources() + { + // Sources + var dict = ConfigReader.ConfigObject.GetSourceListForKey(Room.SourceListKey); + if (dict != null) + { + // NEW PROCESS: + // Make these lists and insert the fusion attributes by iterating these + var setTopBoxes = dict.Where(d => d.Value.SourceDevice is ISetTopBoxControls); + uint i = 1; + foreach (var kvp in setTopBoxes) + { + TryAddRouteActionSigs(JoinMap.Display1SetTopBoxSourceStart.AttributeName + " " + i, JoinMap.Display1SetTopBoxSourceStart.JoinNumber + i, kvp.Key, kvp.Value.SourceDevice); + i++; + if (i > JoinMap.Display1SetTopBoxSourceStart.JoinSpan) // We only have five spots + { + break; + } + } + + var discPlayers = dict.Where(d => d.Value.SourceDevice is IDiscPlayerControls); + i = 1; + foreach (var kvp in discPlayers) + { + TryAddRouteActionSigs(JoinMap.Display1DiscPlayerSourceStart.AttributeName + " " + i, JoinMap.Display1DiscPlayerSourceStart.JoinNumber + i, kvp.Key, kvp.Value.SourceDevice); + i++; + if (i > JoinMap.Display1DiscPlayerSourceStart.JoinSpan) // We only have five spots + { + break; + } + } + + var laptops = dict.Where(d => d.Value.SourceDevice is Devices.Laptop); + i = 1; + foreach (var kvp in laptops) + { + TryAddRouteActionSigs(JoinMap.Display1LaptopSourceStart.AttributeName + " " + i, JoinMap.Display1LaptopSourceStart.JoinNumber + i, kvp.Key, kvp.Value.SourceDevice); + i++; + if (i > JoinMap.Display1LaptopSourceStart.JoinSpan) // We only have ten spots??? + { + break; + } + } + + foreach (var usageDevice in dict.Select(kvp => kvp.Value.SourceDevice).OfType()) + { + usageDevice.UsageTracker = new UsageTracking(usageDevice as Device) {UsageIsTracked = true}; + usageDevice.UsageTracker.DeviceUsageEnded += UsageTracker_DeviceUsageEnded; + } + } + else + { + Debug.Console(1, this, "WARNING: Config source list '{0}' not found for room '{1}'", + Room.SourceListKey, Room.Key); + } + } + + /// + /// Collects usage data from source and sends to Fusion + /// + /// + /// + protected void UsageTracker_DeviceUsageEnded(object sender, DeviceUsageEventArgs e) + { + var deviceTracker = sender as UsageTracking; + + if (deviceTracker == null) + { + return; + } + + var group = ConfigReader.GetGroupForDeviceKey(deviceTracker.Parent.Key); + + var currentMeetingId = "-"; + + if (_currentMeeting != null) + { + currentMeetingId = _currentMeeting.MeetingID; + } + + //String Format: "USAGE||[Date YYYY-MM-DD]||[Time HH-mm-ss]||TIME||[Asset_Type]||[Asset_Name]||[Minutes_used]||[Asset_ID]||[Meeting_ID]" + // [Asset_ID] property does not appear to be used in Crestron SSI examples. They are sending "-" instead so that's what is replicated here + var deviceUsage = string.Format("USAGE||{0}||{1}||TIME||{2}||{3}||-||{4}||-||{5}||{6}||\r\n", + e.UsageEndTime.ToString("yyyy-MM-dd"), e.UsageEndTime.ToString("HH:mm:ss"), + @group, deviceTracker.Parent.Name, e.MinutesUsed, "-", currentMeetingId); + + Debug.Console(1, this, "Device usage for: {0} ended at {1}. In use for {2} minutes", + deviceTracker.Parent.Name, e.UsageEndTime, e.MinutesUsed); + + FusionRoom.DeviceUsage.InputSig.StringValue = deviceUsage; + + Debug.Console(1, this, "Device usage string: {0}", deviceUsage); + } + + + protected void TryAddRouteActionSigs(string attrName, uint attrNum, string routeKey, Device pSrc) + { + Debug.Console(2, this, "Creating attribute '{0}' with join {1} for source {2}", + attrName, attrNum, pSrc.Key); + try + { + var sigD = FusionRoom.CreateOffsetBoolSig(attrNum, attrName, eSigIoMask.InputOutputSig); + // Need feedback when this source is selected + // Event handler, added below, will compare source changes with this sig dict + _sourceToFeedbackSigs.Add(pSrc, sigD.InputSig); + + // And respond to selection in Fusion + sigD.OutputSig.SetSigFalseAction(() => + { + var runRouteAction = Room as IRunRouteAction; + if (runRouteAction != null) + { + runRouteAction.RunRouteAction(routeKey, Room.SourceListKey); + } + }); + } + catch (Exception) + { + Debug.Console(2, this, "Error creating Fusion signal {0} {1} for device '{2}'. THIS NEEDS REWORKING", + attrNum, attrName, pSrc.Key); + } + } + + /// + /// + /// + private void SetUpCommunitcationMonitors() + { + uint displayNum = 0; + uint touchpanelNum = 0; + uint xpanelNum = 0; + + // Attach to all room's devices with monitors. + //foreach (var dev in DeviceManager.Devices) + foreach (var dev in DeviceManager.GetDevices()) + { + if (!(dev is ICommunicationMonitor)) + { + continue; + } + + string attrName = null; + uint attrNum = 1; + + //var keyNum = ExtractNumberFromKey(dev.Key); + //if (keyNum == -1) + //{ + // Debug.Console(1, this, "WARNING: Cannot link device '{0}' to numbered Fusion monitoring attributes", + // dev.Key); + // continue; + //} + //uint attrNum = Convert.ToUInt32(keyNum); + + // Check for UI devices + var uiDev = dev as IHasBasicTriListWithSmartObject; + if (uiDev != null) + { + if (uiDev.Panel is Crestron.SimplSharpPro.UI.XpanelForSmartGraphics) + { + attrNum = attrNum + touchpanelNum; + + if (attrNum > JoinMap.XpanelOnlineStart.JoinSpan) + { + continue; + } + attrName = JoinMap.XpanelOnlineStart.AttributeName + " " + attrNum; + attrNum += JoinMap.XpanelOnlineStart.JoinNumber; + + touchpanelNum++; + } + else + { + attrNum = attrNum + xpanelNum; + + if (attrNum > JoinMap.TouchpanelOnlineStart.JoinSpan) + { + continue; + } + attrName = JoinMap.TouchpanelOnlineStart.AttributeName + " " + attrNum; + attrNum += JoinMap.TouchpanelOnlineStart.JoinNumber; + + xpanelNum++; + } + } + + //else + if (dev is DisplayBase) + { + attrNum = attrNum + displayNum; + if (attrNum > JoinMap.DisplayOnlineStart.JoinSpan) + { + continue; + } + attrName = JoinMap.DisplayOnlineStart.AttributeName + " " + attrNum; + attrNum += JoinMap.DisplayOnlineStart.JoinNumber; + + displayNum++; + } + //else if (dev is DvdDeviceBase) + //{ + // if (attrNum > 5) + // continue; + // attrName = "Device Ok - DVD " + attrNum; + // attrNum += 260; + //} + // add set top box + + // add Cresnet roll-up + + // add DM-devices roll-up + + if (attrName != null) + { + // Link comm status to sig and update + var sigD = FusionRoom.CreateOffsetBoolSig(attrNum, attrName, eSigIoMask.InputSigOnly); + var smd = dev as ICommunicationMonitor; + sigD.InputSig.BoolValue = smd.CommunicationMonitor.Status == MonitorStatus.IsOk; + smd.CommunicationMonitor.StatusChange += + (o, a) => { sigD.InputSig.BoolValue = a.Status == MonitorStatus.IsOk; }; + Debug.Console(0, this, "Linking '{0}' communication monitor to Fusion '{1}'", dev.Key, attrName); + } + } + } + + protected virtual void SetUpDisplay() + { + try + { + //Setup Display Usage Monitoring + + var displays = DeviceManager.AllDevices.Where(d => d is DisplayBase); + + // Consider updating this in multiple display systems + + foreach (var display in displays.Cast()) + { + display.UsageTracker = new UsageTracking(display) {UsageIsTracked = true}; + display.UsageTracker.DeviceUsageEnded += UsageTracker_DeviceUsageEnded; + } + + var hasDefaultDisplay = Room as IHasDefaultDisplay; + if (hasDefaultDisplay == null) + { + return; + } + var defaultDisplay = hasDefaultDisplay.DefaultDisplay as DisplayBase; + if (defaultDisplay == null) + { + Debug.Console(1, this, "Cannot link null display to Fusion because default display is null"); + return; + } + + var dispPowerOnAction = new Action(b => + { + if (!b) + { + defaultDisplay.PowerOn(); + } + }); + var dispPowerOffAction = new Action(b => + { + if (!b) + { + defaultDisplay.PowerOff(); + } + }); + + // Display to fusion room sigs + FusionRoom.DisplayPowerOn.OutputSig.UserObject = dispPowerOnAction; + FusionRoom.DisplayPowerOff.OutputSig.UserObject = dispPowerOffAction; + + MapDisplayToRoomJoins(1, JoinMap.Display1Start.JoinNumber, defaultDisplay); + + + var deviceConfig = + ConfigReader.ConfigObject.Devices.FirstOrDefault(d => d.Key.Equals(defaultDisplay.Key)); + + //Check for existing asset in GUIDs collection + + FusionAsset tempAsset; + + if (FusionStaticAssets.ContainsKey(deviceConfig.Uid)) + { + tempAsset = FusionStaticAssets[deviceConfig.Uid]; + } + else + { + // Create a new asset + tempAsset = new FusionAsset(FusionRoomGuids.GetNextAvailableAssetNumber(FusionRoom), + defaultDisplay.Name, "Display", ""); + FusionStaticAssets.Add(deviceConfig.Uid, tempAsset); + } + + var dispAsset = FusionRoom.CreateStaticAsset(tempAsset.SlotNumber, tempAsset.Name, "Display", + tempAsset.InstanceId); + dispAsset.PowerOn.OutputSig.UserObject = dispPowerOnAction; + dispAsset.PowerOff.OutputSig.UserObject = dispPowerOffAction; + + var defaultTwoWayDisplay = defaultDisplay as IHasPowerControlWithFeedback; + if (defaultTwoWayDisplay != null) + { + defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(FusionRoom.DisplayPowerOn.InputSig); + if (defaultDisplay is IDisplayUsage) + { + (defaultDisplay as IDisplayUsage).LampHours.LinkInputSig(FusionRoom.DisplayUsage.InputSig); + } + + defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(dispAsset.PowerOn.InputSig); + } + + // Use extension methods + dispAsset.TrySetMakeModel(defaultDisplay); + dispAsset.TryLinkAssetErrorToCommunication(defaultDisplay); + } + catch (Exception e) + { + Debug.Console(1, this, "Error setting up display in Fusion: {0}", e); + } + } + + /// + /// Maps room attributes to a display at a specified index + /// + /// + /// + /// + /// a + protected virtual void MapDisplayToRoomJoins(int displayIndex, uint joinOffset, DisplayBase display) + { + var displayName = string.Format("Display {0} - ", displayIndex); + + + var hasDefaultDisplay = Room as IHasDefaultDisplay; + if (hasDefaultDisplay == null || display != hasDefaultDisplay.DefaultDisplay) + { + return; + } + // Display volume + var defaultDisplayVolume = FusionRoom.CreateOffsetUshortSig(JoinMap.VolumeFader1.JoinNumber, JoinMap.VolumeFader1.AttributeName, + eSigIoMask.InputOutputSig); + defaultDisplayVolume.OutputSig.UserObject = new Action(b => + { + var basicVolumeWithFeedback = display as IBasicVolumeWithFeedback; + if (basicVolumeWithFeedback == null) + { + return; + } + + basicVolumeWithFeedback.SetVolume(b); + basicVolumeWithFeedback.VolumeLevelFeedback.LinkInputSig(defaultDisplayVolume.InputSig); + }); + + + // Power on + var defaultDisplayPowerOn = FusionRoom.CreateOffsetBoolSig((uint) joinOffset, displayName + "Power On", + eSigIoMask.InputOutputSig); + defaultDisplayPowerOn.OutputSig.UserObject = new Action(b => + { + if (!b) + { + display.PowerOn(); + } + }); + + // Power Off + var defaultDisplayPowerOff = FusionRoom.CreateOffsetBoolSig((uint) joinOffset + 1, displayName + "Power Off", + eSigIoMask.InputOutputSig); + defaultDisplayPowerOn.OutputSig.UserObject = new Action(b => + { + if (!b) + { + display.PowerOff(); + } + }); + + + var defaultTwoWayDisplay = display as IHasPowerControlWithFeedback; + if (defaultTwoWayDisplay != null) + { + defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(defaultDisplayPowerOn.InputSig); + defaultTwoWayDisplay.PowerIsOnFeedback.LinkComplementInputSig(defaultDisplayPowerOff.InputSig); + } + + // Current Source + var defaultDisplaySourceNone = FusionRoom.CreateOffsetBoolSig((uint) joinOffset + 8, + displayName + "Source None", eSigIoMask.InputOutputSig); + defaultDisplaySourceNone.OutputSig.UserObject = new Action(b => + { + if (!b) + { + var runRouteAction = Room as IRunRouteAction; + if (runRouteAction != null) + { + runRouteAction.RunRouteAction("roomOff", Room.SourceListKey); + } + } + }); + } + + private void SetUpError() + { + // Roll up ALL device errors + _errorMessageRollUp = new StatusMonitorCollection(this); + foreach (var dev in DeviceManager.GetDevices()) + { + var md = dev as ICommunicationMonitor; + if (md != null) + { + _errorMessageRollUp.AddMonitor(md.CommunicationMonitor); + Debug.Console(2, this, "Adding '{0}' to room's overall error monitor", + md.CommunicationMonitor.Parent.Key); + } + } + _errorMessageRollUp.Start(); + FusionRoom.ErrorMessage.InputSig.StringValue = _errorMessageRollUp.Message; + _errorMessageRollUp.StatusChange += + (o, a) => { FusionRoom.ErrorMessage.InputSig.StringValue = _errorMessageRollUp.Message; }; + } + + /// + /// Sets up a local occupancy sensor, such as one attached to a Fusion Scheduling panel. The occupancy status of the room will be read from Fusion + /// + private void SetUpLocalOccupancy() + { + RoomIsOccupiedFeedback = new BoolFeedback(RoomIsOccupiedFeedbackFunc); + + FusionRoom.FusionAssetStateChange += FusionRoom_FusionAssetStateChange; + + // Build Occupancy Asset? + // Link sigs? + + //Room.SetRoomOccupancy(this as IOccupancyStatusProvider, 0); + } + + private void FusionRoom_FusionAssetStateChange(FusionBase device, FusionAssetStateEventArgs args) + { + if (args.EventId == FusionAssetEventId.RoomOccupiedReceivedEventId || + args.EventId == FusionAssetEventId.RoomUnoccupiedReceivedEventId) + { + RoomIsOccupiedFeedback.FireUpdate(); + } + } + + /// + /// Sets up remote occupancy that will relay the occupancy status determined by local system devices to Fusion + /// + private void SetUpRemoteOccupancy() + { + // Need to have the room occupancy object first and somehow determine the slot number of the Occupancy asset but will not be able to use the UID from config likely. + // Consider defining an object just for Room Occupancy (either eAssetType.Occupancy Sensor (local) or eAssetType.RemoteOccupancySensor (from Fusion sched. panel)) and reserving slot 4 for that asset (statics would start at 5) + + //if (Room.OccupancyObj != null) + //{ + + var tempOccAsset = _guiDs.OccupancyAsset; + + if (tempOccAsset == null) + { + FusionOccSensor = new FusionOccupancySensorAsset(eAssetType.OccupancySensor); + tempOccAsset = FusionOccSensor; + } + + var occSensorAsset = FusionRoom.CreateOccupancySensorAsset(tempOccAsset.SlotNumber, tempOccAsset.Name, + "Occupancy Sensor", tempOccAsset.InstanceId); + + occSensorAsset.RoomOccupied.AddSigToRVIFile = true; + + //var occSensorShutdownMinutes = FusionRoom.CreateOffsetUshortSig(70, "Occ Shutdown - Minutes", eSigIoMask.InputOutputSig); + + // Tie to method on occupancy object + //occSensorShutdownMinutes.OutputSig.UserObject(new Action(ushort)(b => Room.OccupancyObj.SetShutdownMinutes(b)); + + var occRoom = Room as IRoomOccupancy; + + if (occRoom != null) + { + occRoom.RoomOccupancy.RoomIsOccupiedFeedback.LinkInputSig(occSensorAsset.RoomOccupied.InputSig); + occRoom.RoomOccupancy.RoomIsOccupiedFeedback.OutputChange += RoomIsOccupiedFeedback_OutputChange; + } + RoomOccupancyRemoteStringFeedback = new StringFeedback(() => _roomOccupancyRemoteString); + + RoomOccupancyRemoteStringFeedback.LinkInputSig(occSensorAsset.RoomOccupancyInfo.InputSig); + + //} + } + + private void RoomIsOccupiedFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + _roomOccupancyRemoteString = String.Format(RemoteOccupancyXml, e.BoolValue ? "Occupied" : "Unoccupied"); + RoomOccupancyRemoteStringFeedback.FireUpdate(); + } + + /// + /// Helper to get the number from the end of a device's key string + /// + /// -1 if no number matched + private int ExtractNumberFromKey(string key) + { + var capture = System.Text.RegularExpressions.Regex.Match(key, @"\b(\d+)"); + if (!capture.Success) + { + return -1; + } + return Convert.ToInt32(capture.Groups[1].Value); + } + + /// + /// Event handler for when room source changes + /// + protected void Room_CurrentSourceInfoChange(SourceListItem info, ChangeType type) + { + // Handle null. Nothing to do when switching from or to null + if (info == null || info.SourceDevice == null) + { + return; + } + + var dev = info.SourceDevice; + if (type == ChangeType.WillChange) + { + if (_sourceToFeedbackSigs.ContainsKey(dev)) + { + _sourceToFeedbackSigs[dev].BoolValue = false; + } + } + else + { + if (_sourceToFeedbackSigs.ContainsKey(dev)) + { + _sourceToFeedbackSigs[dev].BoolValue = true; + } + //var name = (room == null ? "" : room.Name); + CurrentRoomSourceNameSig.InputSig.StringValue = info.SourceDevice.Name; + } + } + + protected void FusionRoom_FusionStateChange(FusionBase device, FusionStateEventArgs args) + { + // The sig/UO method: Need separate handlers for fixed and user sigs, all flavors, + // even though they all contain sigs. + + var sigData = args.UserConfiguredSigDetail as BooleanSigDataFixedName; + + BoolOutputSig outSig; + if (sigData != null) + { + outSig = sigData.OutputSig; + if (outSig.UserObject is Action) + { + (outSig.UserObject as Action).Invoke(outSig.BoolValue); + } + else if (outSig.UserObject is Action) + { + (outSig.UserObject as Action).Invoke(outSig.UShortValue); + } + else if (outSig.UserObject is Action) + { + (outSig.UserObject as Action).Invoke(outSig.StringValue); + } + return; + } + + var attrData = (args.UserConfiguredSigDetail as BooleanSigData); + if (attrData == null) + { + return; + } + outSig = attrData.OutputSig; + if (outSig.UserObject is Action) + { + (outSig.UserObject as Action).Invoke(outSig.BoolValue); + } + else if (outSig.UserObject is Action) + { + (outSig.UserObject as Action).Invoke(outSig.UShortValue); + } + else if (outSig.UserObject is Action) + { + (outSig.UserObject as Action).Invoke(outSig.StringValue); + } + } + } + + + public static class FusionRoomExtensions + { + /// + /// Creates and returns a fusion attribute. The join number will match the established Simpl + /// standard of 50+, and will generate a 50+ join in the RVI. It calls + /// FusionRoom.AddSig with join number - 49 + /// + /// The new attribute + public static BooleanSigData CreateOffsetBoolSig(this FusionRoom fr, uint number, string name, eSigIoMask mask) + { + if (number < 50) + { + throw new ArgumentOutOfRangeException("number", "Cannot be less than 50"); + } + number -= 49; + fr.AddSig(eSigType.Bool, number, name, mask); + return fr.UserDefinedBooleanSigDetails[number]; + } + + /// + /// Creates and returns a fusion attribute. The join number will match the established Simpl + /// standard of 50+, and will generate a 50+ join in the RVI. It calls + /// FusionRoom.AddSig with join number - 49 + /// + /// The new attribute + public static UShortSigData CreateOffsetUshortSig(this FusionRoom fr, uint number, string name, eSigIoMask mask) + { + if (number < 50) + { + throw new ArgumentOutOfRangeException("number", "Cannot be less than 50"); + } + number -= 49; + fr.AddSig(eSigType.UShort, number, name, mask); + return fr.UserDefinedUShortSigDetails[number]; + } + + /// + /// Creates and returns a fusion attribute. The join number will match the established Simpl + /// standard of 50+, and will generate a 50+ join in the RVI. It calls + /// FusionRoom.AddSig with join number - 49 + /// + /// The new attribute + public static StringSigData CreateOffsetStringSig(this FusionRoom fr, uint number, string name, eSigIoMask mask) + { + if (number < 50) + { + throw new ArgumentOutOfRangeException("number", "Cannot be less than 50"); + } + number -= 49; + fr.AddSig(eSigType.String, number, name, mask); + return fr.UserDefinedStringSigDetails[number]; + } + + /// + /// Creates and returns a static asset + /// + /// the new asset + public static FusionStaticAsset CreateStaticAsset(this FusionRoom fr, uint number, string name, string type, + string instanceId) + { + try + { + Debug.Console(0, "Adding Fusion Static Asset '{0}' to slot {1} with GUID: '{2}'", name, number, instanceId); + + fr.AddAsset(eAssetType.StaticAsset, number, name, type, instanceId); + return fr.UserConfigurableAssetDetails[number].Asset as FusionStaticAsset; + } + catch (InvalidOperationException ex) + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Error creating Static Asset for device: '{0}'. Check that multiple devices don't have missing or duplicate uid properties in configuration. /r/nError: {1}", name, ex); + return null; + } + catch (Exception e) + { + Debug.Console(2, Debug.ErrorLogLevel.Error, "Error creating Static Asset: {0}", e); + return null; + } + } + + public static FusionOccupancySensor CreateOccupancySensorAsset(this FusionRoom fr, uint number, string name, + string type, string instanceId) + { + try + { + Debug.Console(0, "Adding Fusion Occupancy Sensor Asset '{0}' to slot {1} with GUID: '{2}'", name, number, + instanceId); + + fr.AddAsset(eAssetType.OccupancySensor, number, name, type, instanceId); + return fr.UserConfigurableAssetDetails[number].Asset as FusionOccupancySensor; + } + catch (InvalidOperationException ex) + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Error creating Static Asset for device: '{0}'. Check that multiple devices don't have missing or duplicate uid properties in configuration. Error: {1}", name, ex); + return null; + } + catch (Exception e) + { + Debug.Console(2, Debug.ErrorLogLevel.Error, "Error creating Static Asset: {0}", e); + return null; + } + } + } + + //************************************************************************************************ + /// + /// Extensions to enhance Fusion room, asset and signal creation. + /// + public static class FusionStaticAssetExtensions + { + /// + /// Tries to set a Fusion asset with the make and model of a device. + /// If the provided Device is IMakeModel, will set the corresponding parameters on the fusion static asset. + /// Otherwise, does nothing. + /// + public static void TrySetMakeModel(this FusionStaticAsset asset, Device device) + { + var mm = device as IMakeModel; + if (mm != null) + { + asset.ParamMake.Value = mm.DeviceMake; + asset.ParamModel.Value = mm.DeviceModel; + } + } + + /// + /// Tries to attach the AssetError input on a Fusion asset to a Device's + /// CommunicationMonitor.StatusChange event. Does nothing if the device is not + /// IStatusMonitor + /// + /// + /// + public static void TryLinkAssetErrorToCommunication(this FusionStaticAsset asset, Device device) + { + if (device is ICommunicationMonitor) + { + var monitor = (device as ICommunicationMonitor).CommunicationMonitor; + monitor.StatusChange += (o, a) => + { + // Link connected and error inputs on asset + asset.Connected.InputSig.BoolValue = a.Status == MonitorStatus.IsOk; + asset.AssetError.InputSig.StringValue = a.Status.ToString(); + }; + // set current value + asset.Connected.InputSig.BoolValue = monitor.Status == MonitorStatus.IsOk; + asset.AssetError.InputSig.StringValue = monitor.Status.ToString(); + } + } + } + + public class RoomInformation + { + public RoomInformation() + { + FusionCustomProperties = new List(); + } + + public string ID { get; set; } + public string Name { get; set; } + public string Location { get; set; } + public string Description { get; set; } + public string TimeZone { get; set; } + public string WebcamURL { get; set; } + public string BacklogMsg { get; set; } + public string SubErrorMsg { get; set; } + public string EmailInfo { get; set; } + public List FusionCustomProperties { get; set; } + } + + public class FusionCustomProperty + { + public FusionCustomProperty() + { + } + + public FusionCustomProperty(string id) + { + ID = id; + } + + public string ID { get; set; } + public string CustomFieldName { get; set; } + public string CustomFieldType { get; set; } + public string CustomFieldValue { get; set; } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceRoomFusionRoomJoinMap.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceRoomFusionRoomJoinMap.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceRoomFusionRoomJoinMap.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceRoomFusionRoomJoinMap.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/FusionCustomPropertiesBridge.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/FusionCustomPropertiesBridge.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/FusionCustomPropertiesBridge.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/FusionCustomPropertiesBridge.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/FusionEventHandlers.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/FusionEventHandlers.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/FusionEventHandlers.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/FusionEventHandlers.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/FusionProcessorQueries.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/FusionProcessorQueries.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/FusionProcessorQueries.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/FusionProcessorQueries.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/FusionRviDataClasses.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/FusionRviDataClasses.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/FusionRviDataClasses.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/FusionRviDataClasses.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Gateways/CenCn2Controller.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Gateways/CenCn2Controller.cs similarity index 95% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Gateways/CenCn2Controller.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Gateways/CenCn2Controller.cs index bdd53bde..7134106f 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Gateways/CenCn2Controller.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Gateways/CenCn2Controller.cs @@ -1,12 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -namespace PepperDash_Essentials_Core.Gateways -{ - public class CenCn2Controller - { - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +namespace PepperDash_Essentials_Core.Gateways +{ + public class CenCn2Controller + { + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Gateways/CenRfgwController.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Gateways/CenRfgwController.cs similarity index 97% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Gateways/CenRfgwController.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Gateways/CenRfgwController.cs index 03e8f51d..46078523 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Gateways/CenRfgwController.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Gateways/CenRfgwController.cs @@ -4,192 +4,192 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.Gateways; -using Newtonsoft.Json; -using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.Gateways; +using Newtonsoft.Json; +using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; -using PepperDash.Essentials.Core.Config; - - -namespace PepperDash.Essentials.Core -{ - [Description("Wrapper class for Crestron Infinet-EX Gateways")] - public class CenRfgwController : CrestronGenericBaseDevice, IHasReady - { - public event EventHandler IsReadyEvent; - - public bool IsReady { get; private set; } - - private GatewayBase _gateway; - - public GatewayBase GateWay - { - get { return _gateway; } - } - - /// - /// Constructor for the on-board gateway - /// - /// - /// - /// - public CenRfgwController(string key, string name, GatewayBase gateway) : - base(key, name, gateway) - { - _gateway = gateway; - IsReady = true; - FireIsReadyEvent(IsReady); - } - - public CenRfgwController(string key, Func preActivationFunc, DeviceConfig config) : - base(key, config.Name) - { - IsReady = false; - FireIsReadyEvent(IsReady); - AddPreActivationAction(() => - { - _gateway = preActivationFunc(config); - - IsReady = true; - RegisterCrestronGenericBase(_gateway); - FireIsReadyEvent(IsReady); - - }); - } - - public static GatewayBase GetNewIpRfGateway(DeviceConfig dc) - { - var control = CommFactory.GetControlPropertiesConfig(dc); - var type = dc.Type; - var ipId = control.IpIdInt; - - if (type.Equals("cenrfgwex", StringComparison.InvariantCultureIgnoreCase)) - { - return new CenRfgwEx(ipId, Global.ControlSystem); - } - if (type.Equals("cenerfgwpoe", StringComparison.InvariantCultureIgnoreCase)) - { - return new CenErfgwPoe(ipId, Global.ControlSystem); - } - return null; - } - - private void FireIsReadyEvent(bool data) - { - var handler = IsReadyEvent; - if (handler == null) return; - - handler(this, new IsReadyEventArgs(data)); - - } - - public static GatewayBase GetNewSharedIpRfGateway(DeviceConfig dc) - { - var control = CommFactory.GetControlPropertiesConfig(dc); - var ipId = control.IpIdInt; - - if (dc.Type.Equals("cenrfgwex", StringComparison.InvariantCultureIgnoreCase)) - { - return new CenRfgwExEthernetSharable(ipId, Global.ControlSystem); - } - if (dc.Type.Equals("cenerfgwpoe", StringComparison.InvariantCultureIgnoreCase)) - { - return new CenErfgwPoeEthernetSharable(ipId, Global.ControlSystem); - } - return null; - } - - public static GatewayBase GetCenRfgwCresnetController(DeviceConfig dc) - { - var control = CommFactory.GetControlPropertiesConfig(dc); - var type = dc.Type; - var cresnetId = control.CresnetIdInt; - var branchId = control.ControlPortNumber; - var parentKey = string.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey; - - if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase)) - { - Debug.Console(0, "Device {0} is a valid cresnet master - creating new CenRfgw", parentKey); - if (type.Equals("cenerfgwpoe", StringComparison.InvariantCultureIgnoreCase)) - { - return new CenErfgwPoeCresnet(cresnetId, Global.ControlSystem); - } - if (type.Equals("cenrfgwex", StringComparison.InvariantCultureIgnoreCase)) - { - return new CenRfgwExCresnet(cresnetId, Global.ControlSystem); - } - } - var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as ICresnetBridge; - - if (cresnetBridge != null) - { - Debug.Console(0, "Device {0} is a valid cresnet master - creating new CenRfgw", parentKey); - - if (type.Equals("cenerfgwpoe", StringComparison.InvariantCultureIgnoreCase)) - { - return new CenErfgwPoeCresnet(cresnetId, cresnetBridge.Branches[branchId]); - } - if (type.Equals("cenrfgwex", StringComparison.InvariantCultureIgnoreCase)) - { - return new CenRfgwExCresnet(cresnetId, cresnetBridge.Branches[branchId]); - } - } - Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); - return null; - } - - - - - - - - public enum EExGatewayType - { - Ethernet, - EthernetShared, - Cresnet - } - - - #region Factory - - public class CenRfgwControllerFactory : EssentialsDeviceFactory - { - public CenRfgwControllerFactory() - { - TypeNames = new List {"cenrfgwex", "cenerfgwpoe"}; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - - Debug.Console(1, "Factory Attempting to create new CEN-GWEXER Device"); - - var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); - - EExGatewayType gatewayType = - (EExGatewayType) Enum.Parse(typeof (EExGatewayType), props.GatewayType, true); - - switch (gatewayType) - { - case (EExGatewayType.Ethernet): - return new CenRfgwController(dc.Key, dc.Name, GetNewIpRfGateway(dc)); - case (EExGatewayType.EthernetShared): - return new CenRfgwController(dc.Key, dc.Name, GetNewSharedIpRfGateway(dc)); - case (EExGatewayType.Cresnet): - return new CenRfgwController(dc.Key, GetCenRfgwCresnetController, dc); - } - return null; - } - } - - #endregion - } - - -} - - +using PepperDash.Essentials.Core.Config; + + +namespace PepperDash.Essentials.Core +{ + [Description("Wrapper class for Crestron Infinet-EX Gateways")] + public class CenRfgwController : CrestronGenericBaseDevice, IHasReady + { + public event EventHandler IsReadyEvent; + + public bool IsReady { get; private set; } + + private GatewayBase _gateway; + + public GatewayBase GateWay + { + get { return _gateway; } + } + + /// + /// Constructor for the on-board gateway + /// + /// + /// + /// + public CenRfgwController(string key, string name, GatewayBase gateway) : + base(key, name, gateway) + { + _gateway = gateway; + IsReady = true; + FireIsReadyEvent(IsReady); + } + + public CenRfgwController(string key, Func preActivationFunc, DeviceConfig config) : + base(key, config.Name) + { + IsReady = false; + FireIsReadyEvent(IsReady); + AddPreActivationAction(() => + { + _gateway = preActivationFunc(config); + + IsReady = true; + RegisterCrestronGenericBase(_gateway); + FireIsReadyEvent(IsReady); + + }); + } + + public static GatewayBase GetNewIpRfGateway(DeviceConfig dc) + { + var control = CommFactory.GetControlPropertiesConfig(dc); + var type = dc.Type; + var ipId = control.IpIdInt; + + if (type.Equals("cenrfgwex", StringComparison.InvariantCultureIgnoreCase)) + { + return new CenRfgwEx(ipId, Global.ControlSystem); + } + if (type.Equals("cenerfgwpoe", StringComparison.InvariantCultureIgnoreCase)) + { + return new CenErfgwPoe(ipId, Global.ControlSystem); + } + return null; + } + + private void FireIsReadyEvent(bool data) + { + var handler = IsReadyEvent; + if (handler == null) return; + + handler(this, new IsReadyEventArgs(data)); + + } + + public static GatewayBase GetNewSharedIpRfGateway(DeviceConfig dc) + { + var control = CommFactory.GetControlPropertiesConfig(dc); + var ipId = control.IpIdInt; + + if (dc.Type.Equals("cenrfgwex", StringComparison.InvariantCultureIgnoreCase)) + { + return new CenRfgwExEthernetSharable(ipId, Global.ControlSystem); + } + if (dc.Type.Equals("cenerfgwpoe", StringComparison.InvariantCultureIgnoreCase)) + { + return new CenErfgwPoeEthernetSharable(ipId, Global.ControlSystem); + } + return null; + } + + public static GatewayBase GetCenRfgwCresnetController(DeviceConfig dc) + { + var control = CommFactory.GetControlPropertiesConfig(dc); + var type = dc.Type; + var cresnetId = control.CresnetIdInt; + var branchId = control.ControlPortNumber; + var parentKey = string.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey; + + if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase)) + { + Debug.Console(0, "Device {0} is a valid cresnet master - creating new CenRfgw", parentKey); + if (type.Equals("cenerfgwpoe", StringComparison.InvariantCultureIgnoreCase)) + { + return new CenErfgwPoeCresnet(cresnetId, Global.ControlSystem); + } + if (type.Equals("cenrfgwex", StringComparison.InvariantCultureIgnoreCase)) + { + return new CenRfgwExCresnet(cresnetId, Global.ControlSystem); + } + } + var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as ICresnetBridge; + + if (cresnetBridge != null) + { + Debug.Console(0, "Device {0} is a valid cresnet master - creating new CenRfgw", parentKey); + + if (type.Equals("cenerfgwpoe", StringComparison.InvariantCultureIgnoreCase)) + { + return new CenErfgwPoeCresnet(cresnetId, cresnetBridge.Branches[branchId]); + } + if (type.Equals("cenrfgwex", StringComparison.InvariantCultureIgnoreCase)) + { + return new CenRfgwExCresnet(cresnetId, cresnetBridge.Branches[branchId]); + } + } + Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); + return null; + } + + + + + + + + public enum EExGatewayType + { + Ethernet, + EthernetShared, + Cresnet + } + + + #region Factory + + public class CenRfgwControllerFactory : EssentialsDeviceFactory + { + public CenRfgwControllerFactory() + { + TypeNames = new List {"cenrfgwex", "cenerfgwpoe"}; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + + Debug.Console(1, "Factory Attempting to create new CEN-GWEXER Device"); + + var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); + + EExGatewayType gatewayType = + (EExGatewayType) Enum.Parse(typeof (EExGatewayType), props.GatewayType, true); + + switch (gatewayType) + { + case (EExGatewayType.Ethernet): + return new CenRfgwController(dc.Key, dc.Name, GetNewIpRfGateway(dc)); + case (EExGatewayType.EthernetShared): + return new CenRfgwController(dc.Key, dc.Name, GetNewSharedIpRfGateway(dc)); + case (EExGatewayType.Cresnet): + return new CenRfgwController(dc.Key, GetCenRfgwCresnetController, dc); + } + return null; + } + } + + #endregion + } + + +} + + diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Gateways/EssentialsRfGatewayConfig.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Gateways/EssentialsRfGatewayConfig.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Gateways/EssentialsRfGatewayConfig.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Gateways/EssentialsRfGatewayConfig.cs index e1ae8c11..23ec001d 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Gateways/EssentialsRfGatewayConfig.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Gateways/EssentialsRfGatewayConfig.cs @@ -1,23 +1,23 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using PepperDash.Core; using PepperDash.Essentials.Core.Config; - - -namespace PepperDash.Essentials.Core -{ - public class EssentialsRfGatewayConfig - { - [JsonProperty("control")] - public EssentialsControlPropertiesConfig Control { get; set; } - - [JsonProperty("gatewayType")] - public string GatewayType { get; set; } - - } + + +namespace PepperDash.Essentials.Core +{ + public class EssentialsRfGatewayConfig + { + [JsonProperty("control")] + public EssentialsControlPropertiesConfig Control { get; set; } + + [JsonProperty("gatewayType")] + public string GatewayType { get; set; } + + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/EthernetAdapterInfo.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/EthernetAdapterInfo.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/EthernetAdapterInfo.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/EthernetAdapterInfo.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs similarity index 97% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs index 09529ff8..53bad2b9 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Global.cs @@ -1,281 +1,281 @@ -using System; -using System.Linq; -using System.Text.RegularExpressions; -using System.Globalization; -using Crestron.SimplSharp; -using System.Collections.Generic; -using Crestron.SimplSharp.CrestronIO; -using Crestron.SimplSharp.CrestronDataStore; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DM; - -using PepperDash.Core; -using PepperDash.Essentials.License; - -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Newtonsoft.Json.Schema; - - -namespace PepperDash.Essentials.Core -{ - public static class Global - { - public static CrestronControlSystem ControlSystem { get; set; } - - public static eDevicePlatform Platform { get { return CrestronEnvironment.DevicePlatform; } } - - public static Dictionary EthernetAdapterInfoCollection { get; private set; } - - public static LicenseManager LicenseManager { get; set; } - - public static eCrestronSeries ProcessorSeries { get { return CrestronEnvironment.ProgramCompatibility; } } - - // TODO: consider making this configurable later - public static IFormatProvider Culture = CultureInfo.CreateSpecificCulture("en-US"); - - /// - /// True when the processor type is a DMPS variant - /// - public static bool ControlSystemIsDmpsType - { - get - { - if(ControlSystem.SystemControl != null) - { - if(ControlSystem.SystemControl.SystemControlType > 0) - { - return true; - } - } - return false; - } - } - - /// - /// True when the processor type is a DMPS 4K variant - /// - public static bool ControlSystemIsDmps4kType - { - get - { - if(ControlSystem.SystemControl != null) - { - if(ControlSystem.SystemControl.SystemControlType == eSystemControlType.Dmps34K150CSystemControl || - ControlSystem.SystemControl.SystemControlType == eSystemControlType.Dmps34K200CSystemControl || - ControlSystem.SystemControl.SystemControlType == eSystemControlType.Dmps34K250CSystemControl || - ControlSystem.SystemControl.SystemControlType == eSystemControlType.Dmps34K300CSystemControl || - ControlSystem.SystemControl.SystemControlType == eSystemControlType.Dmps34K350CSystemControl) - { - return true; - } - } - return false; - } - } - - /// - /// True when the processor type is a DMPS 4K 200/300/250/350 variant - /// - public static bool ControlSystemIsDmps4k3xxType - { - get - { - if(ControlSystem.SystemControl != null) - { - if(ControlSystem.SystemControl.SystemControlType == eSystemControlType.Dmps34K200CSystemControl || - ControlSystem.SystemControl.SystemControlType == eSystemControlType.Dmps34K250CSystemControl || - ControlSystem.SystemControl.SystemControlType == eSystemControlType.Dmps34K300CSystemControl || - ControlSystem.SystemControl.SystemControlType == eSystemControlType.Dmps34K350CSystemControl) - { - return true; - } - } - return false; - } - } - - /// - /// The file path prefix to the folder containing configuration files - /// - public static string FilePathPrefix { get; private set; } - - /// - /// The file path prefix to the applciation directory - /// - public static string ApplicationDirectoryPathPrefix - { - get - { - return Crestron.SimplSharp.CrestronIO.Directory.GetApplicationDirectory(); - } - } - - /// - /// Returns the directory separator character based on the running OS - /// - public static char DirectorySeparator - { - get - { - return System.IO.Path.DirectorySeparatorChar; - } - } - - /// - /// Wildcarded config file name for global reference - /// - public const string ConfigFileName = "*configurationFile*.json"; - - /// - /// Sets the file path prefix - /// - /// - public static void SetFilePathPrefix(string prefix) - { - FilePathPrefix = prefix; - } - - static string _AssemblyVersion; - - /// - /// Gets the Assembly Version of Essentials - /// - /// The Assembly Version at Runtime - public static string AssemblyVersion - { - get - { - return _AssemblyVersion; - } - private set - { - _AssemblyVersion = value; - } - } - - /// - /// Sets the Assembly version to the version of the Essentials Library - /// - /// - public static void SetAssemblyVersion(string assemblyVersion) - { - AssemblyVersion = assemblyVersion; - } - - public static bool IsRunningDevelopmentVersion(List developmentVersions, string minimumVersion) - { - if (Regex.Match(AssemblyVersion, @"^(\d*).(\d*).(\d*).*").Groups[1].Value == "0") - { - Debug.Console(2, "Running Local Build. Bypassing Dependency Check."); - return true; - } - - if (developmentVersions == null) - { - Debug.Console(0, - "Development Plugin does not specify a list of versions. Loading plugin may not work as expected. Checking Minumum version"); - return IsRunningMinimumVersionOrHigher(minimumVersion); - } - - Debug.Console(2, "Comparing running version '{0}' to minimum versions '{1}'", AssemblyVersion, developmentVersions); - - var versionMatch = developmentVersions.FirstOrDefault(x => x == AssemblyVersion); - - if (String.IsNullOrEmpty(versionMatch)) - { - Debug.Console(0, "Essentials Build does not match any builds required for plugin load. Bypassing Plugin Load."); - return false; - } - - Debug.Console(2, "Essentials Build {0} matches list of development builds", AssemblyVersion); - return IsRunningMinimumVersionOrHigher(minimumVersion); - - - - } - - /// - /// Checks to see if the running version meets or exceed the minimum specified version. For beta versions (0.xx.yy), will always return true. - /// - /// Minimum specified version in format of xx.yy.zz - /// Returns true if the running version meets or exceeds the minimum specified version - public static bool IsRunningMinimumVersionOrHigher(string minimumVersion) - { - Debug.Console(2, "Comparing running version '{0}' to minimum version '{1}'", AssemblyVersion, minimumVersion); - - if (String.IsNullOrEmpty(minimumVersion)) - { - Debug.Console(0,"Plugin does not specify a minimum version. Loading plugin may not work as expected. Proceeding with loading plugin"); - return true; - } - - var runtimeVersion = Regex.Match(AssemblyVersion, @"^(\d*).(\d*).(\d*).*"); - - var runtimeVersionMajor = Int16.Parse(runtimeVersion.Groups[1].Value); - var runtimeVersionMinor = Int16.Parse(runtimeVersion.Groups[2].Value); - var runtimeVersionBuild = Int16.Parse(runtimeVersion.Groups[3].Value); - - var runtimeVer = new Version(runtimeVersionMajor, runtimeVersionMinor, runtimeVersionBuild); - - Version minimumVer; - try - { - minimumVer = new Version(minimumVersion); - } - catch - { - Debug.Console(2, "unable to parse minimum version {0}. Bypassing plugin load.", minimumVersion); - return false; - } - - - // Check for beta build version - if (runtimeVer.Major != 0) - { - return runtimeVer.CompareTo(minimumVer) >= 0; - } - - Debug.Console(2, "Running Local Build. Bypassing Dependency Check."); - return true; - - /* - var minVersion = Regex.Match(minimumVersion, @"^(\d*).(\d*).(\d*)$"); - - if(!minVersion.Success) - { - - } - - var minVersionMajor = Int16.Parse(minVersion.Groups[1].Value); - var minVersionMinor = Int16.Parse(minVersion.Groups[2].Value); - var minVersionBuild = Int16.Parse(minVersion.Groups[3].Value); - - - - if (minVersionMajor > runtimeVersionMajor) - return false; - - if (minVersionMinor > runtimeVersionMinor) - return false; - - if (minVersionBuild > runtimeVersionBuild) - return false; - - return true; - */ - } - - static Global() - { - // Fire up CrestronDataStoreStatic - var err = CrestronDataStoreStatic.InitCrestronDataStore(); - if (err != CrestronDataStore.CDS_ERROR.CDS_SUCCESS) - { - CrestronConsole.PrintLine("Error starting CrestronDataStoreStatic: {0}", err); - return; - } - } - - } +using System; +using System.Linq; +using System.Text.RegularExpressions; +using System.Globalization; +using Crestron.SimplSharp; +using System.Collections.Generic; +using Crestron.SimplSharp.CrestronIO; +using Crestron.SimplSharp.CrestronDataStore; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DM; + +using PepperDash.Core; +using PepperDash.Essentials.License; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using Newtonsoft.Json.Schema; + + +namespace PepperDash.Essentials.Core +{ + public static class Global + { + public static CrestronControlSystem ControlSystem { get; set; } + + public static eDevicePlatform Platform { get { return CrestronEnvironment.DevicePlatform; } } + + public static Dictionary EthernetAdapterInfoCollection { get; private set; } + + public static LicenseManager LicenseManager { get; set; } + + public static eCrestronSeries ProcessorSeries { get { return CrestronEnvironment.ProgramCompatibility; } } + + // TODO: consider making this configurable later + public static IFormatProvider Culture = CultureInfo.CreateSpecificCulture("en-US"); + + /// + /// True when the processor type is a DMPS variant + /// + public static bool ControlSystemIsDmpsType + { + get + { + if(ControlSystem.SystemControl != null) + { + if(ControlSystem.SystemControl.SystemControlType > 0) + { + return true; + } + } + return false; + } + } + + /// + /// True when the processor type is a DMPS 4K variant + /// + public static bool ControlSystemIsDmps4kType + { + get + { + if(ControlSystem.SystemControl != null) + { + if(ControlSystem.SystemControl.SystemControlType == eSystemControlType.Dmps34K150CSystemControl || + ControlSystem.SystemControl.SystemControlType == eSystemControlType.Dmps34K200CSystemControl || + ControlSystem.SystemControl.SystemControlType == eSystemControlType.Dmps34K250CSystemControl || + ControlSystem.SystemControl.SystemControlType == eSystemControlType.Dmps34K300CSystemControl || + ControlSystem.SystemControl.SystemControlType == eSystemControlType.Dmps34K350CSystemControl) + { + return true; + } + } + return false; + } + } + + /// + /// True when the processor type is a DMPS 4K 200/300/250/350 variant + /// + public static bool ControlSystemIsDmps4k3xxType + { + get + { + if(ControlSystem.SystemControl != null) + { + if(ControlSystem.SystemControl.SystemControlType == eSystemControlType.Dmps34K200CSystemControl || + ControlSystem.SystemControl.SystemControlType == eSystemControlType.Dmps34K250CSystemControl || + ControlSystem.SystemControl.SystemControlType == eSystemControlType.Dmps34K300CSystemControl || + ControlSystem.SystemControl.SystemControlType == eSystemControlType.Dmps34K350CSystemControl) + { + return true; + } + } + return false; + } + } + + /// + /// The file path prefix to the folder containing configuration files + /// + public static string FilePathPrefix { get; private set; } + + /// + /// The file path prefix to the applciation directory + /// + public static string ApplicationDirectoryPathPrefix + { + get + { + return Crestron.SimplSharp.CrestronIO.Directory.GetApplicationDirectory(); + } + } + + /// + /// Returns the directory separator character based on the running OS + /// + public static char DirectorySeparator + { + get + { + return System.IO.Path.DirectorySeparatorChar; + } + } + + /// + /// Wildcarded config file name for global reference + /// + public const string ConfigFileName = "*configurationFile*.json"; + + /// + /// Sets the file path prefix + /// + /// + public static void SetFilePathPrefix(string prefix) + { + FilePathPrefix = prefix; + } + + static string _AssemblyVersion; + + /// + /// Gets the Assembly Version of Essentials + /// + /// The Assembly Version at Runtime + public static string AssemblyVersion + { + get + { + return _AssemblyVersion; + } + private set + { + _AssemblyVersion = value; + } + } + + /// + /// Sets the Assembly version to the version of the Essentials Library + /// + /// + public static void SetAssemblyVersion(string assemblyVersion) + { + AssemblyVersion = assemblyVersion; + } + + public static bool IsRunningDevelopmentVersion(List developmentVersions, string minimumVersion) + { + if (Regex.Match(AssemblyVersion, @"^(\d*).(\d*).(\d*).*").Groups[1].Value == "0") + { + Debug.Console(2, "Running Local Build. Bypassing Dependency Check."); + return true; + } + + if (developmentVersions == null) + { + Debug.Console(0, + "Development Plugin does not specify a list of versions. Loading plugin may not work as expected. Checking Minumum version"); + return IsRunningMinimumVersionOrHigher(minimumVersion); + } + + Debug.Console(2, "Comparing running version '{0}' to minimum versions '{1}'", AssemblyVersion, developmentVersions); + + var versionMatch = developmentVersions.FirstOrDefault(x => x == AssemblyVersion); + + if (String.IsNullOrEmpty(versionMatch)) + { + Debug.Console(0, "Essentials Build does not match any builds required for plugin load. Bypassing Plugin Load."); + return false; + } + + Debug.Console(2, "Essentials Build {0} matches list of development builds", AssemblyVersion); + return IsRunningMinimumVersionOrHigher(minimumVersion); + + + + } + + /// + /// Checks to see if the running version meets or exceed the minimum specified version. For beta versions (0.xx.yy), will always return true. + /// + /// Minimum specified version in format of xx.yy.zz + /// Returns true if the running version meets or exceeds the minimum specified version + public static bool IsRunningMinimumVersionOrHigher(string minimumVersion) + { + Debug.Console(2, "Comparing running version '{0}' to minimum version '{1}'", AssemblyVersion, minimumVersion); + + if (String.IsNullOrEmpty(minimumVersion)) + { + Debug.Console(0,"Plugin does not specify a minimum version. Loading plugin may not work as expected. Proceeding with loading plugin"); + return true; + } + + var runtimeVersion = Regex.Match(AssemblyVersion, @"^(\d*).(\d*).(\d*).*"); + + var runtimeVersionMajor = Int16.Parse(runtimeVersion.Groups[1].Value); + var runtimeVersionMinor = Int16.Parse(runtimeVersion.Groups[2].Value); + var runtimeVersionBuild = Int16.Parse(runtimeVersion.Groups[3].Value); + + var runtimeVer = new Version(runtimeVersionMajor, runtimeVersionMinor, runtimeVersionBuild); + + Version minimumVer; + try + { + minimumVer = new Version(minimumVersion); + } + catch + { + Debug.Console(2, "unable to parse minimum version {0}. Bypassing plugin load.", minimumVersion); + return false; + } + + + // Check for beta build version + if (runtimeVer.Major != 0) + { + return runtimeVer.CompareTo(minimumVer) >= 0; + } + + Debug.Console(2, "Running Local Build. Bypassing Dependency Check."); + return true; + + /* + var minVersion = Regex.Match(minimumVersion, @"^(\d*).(\d*).(\d*)$"); + + if(!minVersion.Success) + { + + } + + var minVersionMajor = Int16.Parse(minVersion.Groups[1].Value); + var minVersionMinor = Int16.Parse(minVersion.Groups[2].Value); + var minVersionBuild = Int16.Parse(minVersion.Groups[3].Value); + + + + if (minVersionMajor > runtimeVersionMajor) + return false; + + if (minVersionMinor > runtimeVersionMinor) + return false; + + if (minVersionBuild > runtimeVersionBuild) + return false; + + return true; + */ + } + + static Global() + { + // Fire up CrestronDataStoreStatic + var err = CrestronDataStoreStatic.InitCrestronDataStore(); + if (err != CrestronDataStore.CDS_ERROR.CDS_SUCCESS) + { + CrestronConsole.PrintLine("Error starting CrestronDataStoreStatic: {0}", err); + return; + } + } + + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/JobTimer.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/JobTimer.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/JobTimer.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/JobTimer.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Scheduler.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Scheduler.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Scheduler.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Scheduler.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/InUseTracking/IInUseTracking.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/InUseTracking/IInUseTracking.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/InUseTracking/IInUseTracking.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/InUseTracking/IInUseTracking.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/InUseTracking/InUseTracking.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/InUseTracking/InUseTracking.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/InUseTracking/InUseTracking.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/InUseTracking/InUseTracking.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Interfaces/ILogStrings.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Interfaces/ILogStrings.cs similarity index 95% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Interfaces/ILogStrings.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Interfaces/ILogStrings.cs index 92557319..4f48e278 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Interfaces/ILogStrings.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Interfaces/ILogStrings.cs @@ -1,17 +1,17 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using PepperDash.Core; - -namespace PepperDash.Essentials.Core.Interfaces -{ - public interface ILogStrings : IKeyed - { - /// - /// Defines a class that is capable of logging a string - /// - void SendToLog(IKeyed device, string logMessage); - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using PepperDash.Core; + +namespace PepperDash.Essentials.Core.Interfaces +{ + public interface ILogStrings : IKeyed + { + /// + /// Defines a class that is capable of logging a string + /// + void SendToLog(IKeyed device, string logMessage); + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Interfaces/ILogStringsWithLevel.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Interfaces/ILogStringsWithLevel.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Interfaces/ILogStringsWithLevel.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Interfaces/ILogStringsWithLevel.cs index c43c4e6c..47c3674e 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Interfaces/ILogStringsWithLevel.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Interfaces/ILogStringsWithLevel.cs @@ -1,18 +1,18 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using PepperDash.Core; - -namespace PepperDash.Essentials.Core.Interfaces -{ - public interface ILogStringsWithLevel : IKeyed - { - /// - /// Defines a class that is capable of logging a string with an int level - /// - void SendToLog(IKeyed device, Debug.ErrorLogLevel level,string logMessage); - } - +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using PepperDash.Core; + +namespace PepperDash.Essentials.Core.Interfaces +{ + public interface ILogStringsWithLevel : IKeyed + { + /// + /// Defines a class that is capable of logging a string with an int level + /// + void SendToLog(IKeyed device, Debug.ErrorLogLevel level,string logMessage); + } + } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs similarity index 97% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs index 12df7f14..74a8fc33 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs @@ -1,641 +1,641 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Text; -using Crestron.SimplSharp.Reflection; -using Crestron.SimplSharp.CrestronIO; -using Crestron.SimplSharp; - -using PepperDash.Core; -using PepperDash.Essentials.Core.Config; - -using Newtonsoft.Json; - -namespace PepperDash.Essentials.Core -{ - public static class JoinMapHelper - { - /// - /// Attempts to get the serialized join map from config - /// - /// - /// - public static string GetSerializedJoinMapForDevice(string joinMapKey) - { - if (string.IsNullOrEmpty(joinMapKey)) - return null; - - var joinMap = ConfigReader.ConfigObject.JoinMaps[joinMapKey]; - - return joinMap.ToString(); - } - - /// - /// Attempts to get the serialized join map from config - /// - /// - /// - public static string GetJoinMapForDevice(string joinMapKey) - { - return GetSerializedJoinMapForDevice(joinMapKey); - } - - /// - /// Attempts to find a custom join map by key and returns it deserialized if found - /// - /// - /// - public static Dictionary TryGetJoinMapAdvancedForDevice(string joinMapKey) - { - try - { - if (string.IsNullOrEmpty(joinMapKey)) - return null; - - if (!ConfigReader.ConfigObject.JoinMaps.ContainsKey(joinMapKey)) - { - Debug.Console(2, "No Join Map found in config with key: '{0}'", joinMapKey); - return null; - } - - Debug.Console(2, "Attempting to load custom join map with key: {0}", joinMapKey); - - var joinMapJToken = ConfigReader.ConfigObject.JoinMaps[joinMapKey]; - - if (joinMapJToken == null) - return null; - - var joinMapData = joinMapJToken.ToObject>(); - - return joinMapData; - } - catch (Exception e) - { - Debug.Console(2, "Error getting join map for key: '{0}'. Error: {1}", joinMapKey, e); - return null; - } - } - - } - - /// - /// Base class for join maps - /// - [Obsolete("This is being deprecated in favor of JoinMapBaseAdvanced")] - public abstract class JoinMapBase - { - /// - /// Modifies all the join numbers by adding the offset. This should never be called twice - /// - /// - public abstract void OffsetJoinNumbers(uint joinStart); - - /// - /// The collection of joins and associated metadata - /// - public Dictionary Joins = new Dictionary(); - - /// - /// Prints the join information to console - /// - public void PrintJoinMapInfo() - { - CrestronConsole.ConsoleCommandResponse("{0}:\n", GetType().Name); - - // Get the joins of each type and print them - CrestronConsole.ConsoleCommandResponse("Digitals:"); - var digitals = Joins.Where(j => (j.Value.JoinType & eJoinType.Digital) == eJoinType.Digital).ToDictionary(j => j.Key, j => j.Value); - CrestronConsole.ConsoleCommandResponse("Found {0} Digital Joins", digitals.Count); - PrintJoinList(GetSortedJoins(digitals)); - - CrestronConsole.ConsoleCommandResponse("Analogs:"); - var analogs = Joins.Where(j => (j.Value.JoinType & eJoinType.Analog) == eJoinType.Analog).ToDictionary(j => j.Key, j => j.Value); - CrestronConsole.ConsoleCommandResponse("Found {0} Analog Joins", analogs.Count); - PrintJoinList(GetSortedJoins(analogs)); - - CrestronConsole.ConsoleCommandResponse("Serials:"); - var serials = Joins.Where(j => (j.Value.JoinType & eJoinType.Serial) == eJoinType.Serial).ToDictionary(j => j.Key, j => j.Value); - CrestronConsole.ConsoleCommandResponse("Found {0} Serial Joins", serials.Count); - PrintJoinList(GetSortedJoins(serials)); - - } - - /// - /// Returns a sorted list by JoinNumber - /// - /// - /// - List> GetSortedJoins(Dictionary joins) - { - var sortedJoins = joins.ToList(); - - sortedJoins.Sort((pair1, pair2) => pair1.Value.JoinNumber.CompareTo(pair2.Value.JoinNumber)); - - return sortedJoins; - } - - void PrintJoinList(List> joins) - { - foreach (var join in joins) - { - CrestronConsole.ConsoleCommandResponse( - @"Join Number: {0} | Label: '{1}' | JoinSpan: '{2}' | Type: '{3}' | Capabilities: '{4}'", - join.Value.JoinNumber, - join.Value.Label, - join.Value.JoinSpan, - join.Value.JoinType.ToString(), - join.Value.JoinCapabilities.ToString()); - } - } - - /// - /// Returns the join number for the join with the specified key - /// - /// - /// - public uint GetJoinForKey(string key) - { - return Joins.ContainsKey(key) ? Joins[key].JoinNumber : 0; - } - - /// - /// Returns the join span for the join with the specified key - /// - /// - /// - public uint GetJoinSpanForKey(string key) - { - return Joins.ContainsKey(key) ? Joins[key].JoinSpan : 0; - } - } - - /// - /// Base class for join maps - /// - public abstract class JoinMapBaseAdvanced - { - protected uint JoinOffset; - - /// - /// The collection of joins and associated metadata - /// - public Dictionary Joins { get; private set; } - - protected JoinMapBaseAdvanced(uint joinStart) - { - Joins = new Dictionary(); - - JoinOffset = joinStart - 1; - } - - protected JoinMapBaseAdvanced(uint joinStart, Type type):this(joinStart) - { - AddJoins(type); - } - - protected void AddJoins(Type type) - { - var fields = - type.GetCType() - .GetFields(BindingFlags.Public | BindingFlags.Instance) - .Where(f => f.IsDefined(typeof (JoinNameAttribute), true)); - - foreach (var field in fields) - { - var childClass = Convert.ChangeType(this, type, null); - - var value = field.GetValue(childClass) as JoinDataComplete; //this here is JoinMapBaseAdvanced, not the child class. JoinMapBaseAdvanced has no fields. - - if (value == null) - { - Debug.Console(0, "Unable to cast base class to {0}", type.Name); - continue; - } - - value.SetJoinOffset(JoinOffset); - - var joinName = value.GetNameAttribute(field); - - if (String.IsNullOrEmpty(joinName)) continue; - - Joins.Add(joinName, value); - } - - - if (Debug.Level > 0) - { - PrintJoinMapInfo(); - } - } - - /// - /// Prints the join information to console - /// - public void PrintJoinMapInfo() - { - var sb = JoinmapStringBuilder(); - - CrestronConsole.ConsoleCommandResponse(sb.ToString()); - } - - private StringBuilder JoinmapStringBuilder() - { - var sb = new StringBuilder(); - - // Get the joins of each type and print them - sb.AppendLine(String.Format("# {0}", GetType().Name)); - sb.AppendLine(); - sb.AppendLine("## Digitals"); - sb.AppendLine(); - // Get the joins of each type and print them - var digitals = - Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Digital) == eJoinType.Digital) - .ToDictionary(j => j.Key, j => j.Value); - var digitalSb = AppendJoinList(GetSortedJoins(digitals)); - digitalSb.AppendLine("## Analogs"); - digitalSb.AppendLine(); - - var analogs = - Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Analog) == eJoinType.Analog) - .ToDictionary(j => j.Key, j => j.Value); - var analogSb = AppendJoinList(GetSortedJoins(analogs)); - analogSb.AppendLine("## Serials"); - analogSb.AppendLine(); - - var serials = - Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Serial) == eJoinType.Serial) - .ToDictionary(j => j.Key, j => j.Value); - var serialSb = AppendJoinList(GetSortedJoins(serials)); - - sb.EnsureCapacity(sb.Length + digitalSb.Length + analogSb.Length + serialSb.Length); - sb.Append(digitalSb).Append(analogSb).Append(serialSb); - return sb; - } - - /// - /// Prints the join information to console - /// - public void MarkdownJoinMapInfo(string deviceKey, string bridgeKey) - { - var pluginType = GetType().Name; - - CrestronConsole.ConsoleCommandResponse("{0}:\n", pluginType); - - - - WriteJoinmapMarkdown(JoinmapStringBuilder(), pluginType, bridgeKey, deviceKey); - - } - - private static void WriteJoinmapMarkdown(StringBuilder stringBuilder, string pluginType, string bridgeKey, string deviceKey) - { - var fileName = String.Format("{0}{1}{2}__{3}__{4}.md", Global.FilePathPrefix, "joinMaps/", pluginType, bridgeKey, deviceKey); - - using (var sw = new StreamWriter(fileName)) - { - sw.WriteLine(stringBuilder.ToString()); - CrestronConsole.ConsoleCommandResponse("Joinmap Readme generated and written to {0}", fileName); - } - - } - - /// - /// Returns a sorted list by JoinNumber - /// - /// - /// - static List> GetSortedJoins(Dictionary joins) - { - var sortedJoins = joins.ToList(); - - sortedJoins.Sort((pair1, pair2) => pair1.Value.JoinNumber.CompareTo(pair2.Value.JoinNumber)); - - return sortedJoins; - } - - - static StringBuilder AppendJoinList(List> joins) - { - var sb = new StringBuilder(); - const string stringFormatter = "| {0} | {1} | {2} | {3} | {4} |"; - const int joinNumberLen = 11; - const int joinSpanLen = 9; - const int typeLen = 19; - const int capabilitiesLen = 12; - var descriptionLen = (from @join in joins select @join.Value into j select j.Metadata.Description.Length).Concat(new[] {11}).Max(); - - //build header - sb.AppendLine(String.Format(stringFormatter, - String.Format("Join Number").PadRight(joinNumberLen, ' '), - String.Format("Join Span").PadRight(joinSpanLen, ' '), - String.Format("Description").PadRight(descriptionLen, ' '), - String.Format("Type").PadRight(typeLen, ' '), - String.Format("Capabilities").PadRight(capabilitiesLen, ' '))); - //build table seperator - sb.AppendLine(String.Format(stringFormatter, - new String('-', joinNumberLen), - new String('-', joinSpanLen), - new String('-', descriptionLen), - new String('-', typeLen), - new String('-', capabilitiesLen))); - - foreach (var join in joins) - { - sb.AppendLine(join.Value.GetMarkdownFormattedData(stringFormatter, descriptionLen)); - } - sb.AppendLine(); - return sb; - } - - /// - /// Attempts to find the matching key for the custom join and if found overwrites the default JoinData with the custom - /// - /// - public void SetCustomJoinData(Dictionary joinData) - { - foreach (var customJoinData in joinData) - { - JoinDataComplete join; - - if (!Joins.TryGetValue(customJoinData.Key, out join)) - { - Debug.Console(2, "No matching key found in join map for: '{0}'", customJoinData.Key); - continue; - } - - if (join != null) - { - join.SetCustomJoinData(customJoinData.Value); - } - } - - PrintJoinMapInfo(); - } - - ///// - ///// Returns the join number for the join with the specified key - ///// - ///// - ///// - //public uint GetJoinForKey(string key) - //{ - // return Joins.ContainsKey(key) ? Joins[key].JoinNumber : 0; - //} - - - ///// - ///// Returns the join span for the join with the specified key - ///// - ///// - ///// - //public uint GetJoinSpanForKey(string key) - //{ - // return Joins.ContainsKey(key) ? Joins[key].JoinSpan : 0; - //} - } - - /// - /// Read = Provides feedback to SIMPL - /// Write = Responds to sig values from SIMPL - /// - [Flags] - public enum eJoinCapabilities - { - None = 0, - ToSIMPL = 1, - FromSIMPL = 2, - ToFromSIMPL = ToSIMPL | FromSIMPL, - ToFusion = 4, - FromFusion = 8, - ToFromFusion = ToFusion | FromFusion, - } - - [Flags] - public enum eJoinType - { - None = 0, - Digital = 1, - Analog = 2, - Serial = 4, - DigitalAnalog = Digital | Analog, - DigitalSerial = Digital | Serial, - AnalogSerial = Analog | Serial, - DigitalAnalogSerial = Digital | Analog | Serial, - } - - /// - /// Metadata describing the join - /// - public class JoinMetadata - { - private string _description; - - /// - /// Join number (based on join offset value) - /// - [JsonProperty("joinNumber")] - [Obsolete] - public uint JoinNumber { get; set; } - /// - /// Join range span. If join indicates the start of a range of joins, this indicated the maximum number of joins in the range - /// - [Obsolete] - [JsonProperty("joinSpan")] - public uint JoinSpan { get; set; } - - /// - /// A label for the join to better describe its usage - /// - [Obsolete("Use Description instead")] - [JsonProperty("label")] - public string Label { get { return _description; } set { _description = value; } } - - /// - /// A description for the join to better describe its usage - /// - [JsonProperty("description")] - public string Description { get { return _description; } set { _description = value; } } - /// - /// Signal type(s) - /// - [JsonProperty("joinType")] - public eJoinType JoinType { get; set; } - /// - /// Indicates whether the join is read and/or write - /// - [JsonProperty("joinCapabilities")] - public eJoinCapabilities JoinCapabilities { get; set; } - /// - /// Indicates a set of valid values (particularly if this translates to an enum - /// - [JsonProperty("validValues")] - public string[] ValidValues { get; set; } - - } - - /// - /// Data describing the join. Can be overridden from configuratino - /// - public class JoinData - { - /// - /// Join number (based on join offset value) - /// - [JsonProperty("joinNumber")] - public uint JoinNumber { get; set; } - /// - /// Join range span. If join indicates the start of a range of joins, this indicated the maximum number of joins in the range - /// - [JsonProperty("joinSpan")] - public uint JoinSpan { get; set; } - /// - /// Fusion Attribute Name (optional) - /// - [JsonProperty("attributeName")] - public string AttributeName { get; set; } - } - - /// - /// A class to aggregate the JoinData and JoinMetadata for a join - /// - public class JoinDataComplete - { - private uint _joinOffset; - - private JoinData _data; - public JoinMetadata Metadata { get; set; } - /// - /// To store some future information as you please - /// - public object UserObject { get; private set; } - - public JoinDataComplete(JoinData data, JoinMetadata metadata) - { - _data = data; - Metadata = metadata; - } - - public string GetMarkdownFormattedData(string stringFormatter, int descriptionLen) - { - - //Fixed Width Headers - var joinNumberLen = String.Format("Join Number").Length; - var joinSpanLen = String.Format("Join Span").Length; - var typeLen = String.Format("AnalogDigitalSerial").Length; - var capabilitiesLen = String.Format("ToFromFusion").Length; - - //Track which one failed, if it did - const string placeholder = "unknown"; - var dataArray = new Dictionary - { - {"joinNumber", placeholder.PadRight(joinNumberLen, ' ')}, - {"joinSpan", placeholder.PadRight(joinSpanLen, ' ')}, - {"description", placeholder.PadRight(descriptionLen, ' ')}, - {"joinType", placeholder.PadRight(typeLen, ' ')}, - {"capabilities", placeholder.PadRight(capabilitiesLen, ' ')} - }; - - - try - { - dataArray["joinNumber"] = String.Format("{0}", JoinNumber.ToString(CultureInfo.InvariantCulture).ReplaceIfNullOrEmpty(placeholder)).PadRight(joinNumberLen, ' '); - dataArray["joinSpan"] = String.Format("{0}", JoinSpan.ToString(CultureInfo.InvariantCulture).ReplaceIfNullOrEmpty(placeholder)).PadRight(joinSpanLen, ' '); - dataArray["description"] = String.Format("{0}", Metadata.Description.ReplaceIfNullOrEmpty(placeholder)).PadRight(descriptionLen, ' '); - dataArray["joinType"] = String.Format("{0}", Metadata.JoinType.ToString().ReplaceIfNullOrEmpty(placeholder)).PadRight(typeLen, ' '); - dataArray["capabilities"] = String.Format("{0}", Metadata.JoinCapabilities.ToString().ReplaceIfNullOrEmpty(placeholder)).PadRight(capabilitiesLen, ' '); - - return String.Format(stringFormatter, - dataArray["joinNumber"], - dataArray["joinSpan"], - dataArray["description"], - dataArray["joinType"], - dataArray["capabilities"]); - - } - catch (Exception e) - { - //Don't Throw - we don't want to kill the system if this falls over - it's not mission critical. Print the error, use placeholder data - var errorKey = string.Empty; - foreach (var item in dataArray) - { - if (item.Value.TrimEnd() == placeholder) continue; - errorKey = item.Key; - break; - } - Debug.Console(0, "Unable to decode join metadata {1}- {0}", e.Message, !String.IsNullOrEmpty(errorKey) ? (' ' + errorKey) : String.Empty); - return String.Format(stringFormatter, - dataArray["joinNumber"], - dataArray["joinSpan"], - dataArray["description"], - dataArray["joinType"], - dataArray["capabilities"]); - } - } - - - /// - /// Sets the join offset value - /// - /// - public void SetJoinOffset(uint joinOffset) - { - _joinOffset = joinOffset; - } - - /// - /// The join number (including the offset) - /// - public uint JoinNumber - { - get { return _data.JoinNumber+ _joinOffset; } - set { _data.JoinNumber = value; } - } - - public uint JoinSpan - { - get { return _data.JoinSpan; } - } - - public string AttributeName - { - get { return _data.AttributeName; } - } - - public void SetCustomJoinData(JoinData customJoinData) - { - _data = customJoinData; - } - - public string GetNameAttribute(MemberInfo memberInfo) - { - var name = string.Empty; - var attribute = (JoinNameAttribute)CAttribute.GetCustomAttribute(memberInfo, typeof(JoinNameAttribute)); - - if (attribute == null) return name; - - name = attribute.Name; - Debug.Console(2, "JoinName Attribute value: {0}", name); - return name; - } - } - - - - [AttributeUsage(AttributeTargets.All)] - public class JoinNameAttribute : CAttribute - { - private string _Name; - - public JoinNameAttribute(string name) - { - Debug.Console(2, "Setting Attribute Name: {0}", name); - _Name = name; - } - - public string Name - { - get { return _Name; } - } - } +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using Crestron.SimplSharp.Reflection; +using Crestron.SimplSharp.CrestronIO; +using Crestron.SimplSharp; + +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +using Newtonsoft.Json; + +namespace PepperDash.Essentials.Core +{ + public static class JoinMapHelper + { + /// + /// Attempts to get the serialized join map from config + /// + /// + /// + public static string GetSerializedJoinMapForDevice(string joinMapKey) + { + if (string.IsNullOrEmpty(joinMapKey)) + return null; + + var joinMap = ConfigReader.ConfigObject.JoinMaps[joinMapKey]; + + return joinMap.ToString(); + } + + /// + /// Attempts to get the serialized join map from config + /// + /// + /// + public static string GetJoinMapForDevice(string joinMapKey) + { + return GetSerializedJoinMapForDevice(joinMapKey); + } + + /// + /// Attempts to find a custom join map by key and returns it deserialized if found + /// + /// + /// + public static Dictionary TryGetJoinMapAdvancedForDevice(string joinMapKey) + { + try + { + if (string.IsNullOrEmpty(joinMapKey)) + return null; + + if (!ConfigReader.ConfigObject.JoinMaps.ContainsKey(joinMapKey)) + { + Debug.Console(2, "No Join Map found in config with key: '{0}'", joinMapKey); + return null; + } + + Debug.Console(2, "Attempting to load custom join map with key: {0}", joinMapKey); + + var joinMapJToken = ConfigReader.ConfigObject.JoinMaps[joinMapKey]; + + if (joinMapJToken == null) + return null; + + var joinMapData = joinMapJToken.ToObject>(); + + return joinMapData; + } + catch (Exception e) + { + Debug.Console(2, "Error getting join map for key: '{0}'. Error: {1}", joinMapKey, e); + return null; + } + } + + } + + /// + /// Base class for join maps + /// + [Obsolete("This is being deprecated in favor of JoinMapBaseAdvanced")] + public abstract class JoinMapBase + { + /// + /// Modifies all the join numbers by adding the offset. This should never be called twice + /// + /// + public abstract void OffsetJoinNumbers(uint joinStart); + + /// + /// The collection of joins and associated metadata + /// + public Dictionary Joins = new Dictionary(); + + /// + /// Prints the join information to console + /// + public void PrintJoinMapInfo() + { + CrestronConsole.ConsoleCommandResponse("{0}:\n", GetType().Name); + + // Get the joins of each type and print them + CrestronConsole.ConsoleCommandResponse("Digitals:"); + var digitals = Joins.Where(j => (j.Value.JoinType & eJoinType.Digital) == eJoinType.Digital).ToDictionary(j => j.Key, j => j.Value); + CrestronConsole.ConsoleCommandResponse("Found {0} Digital Joins", digitals.Count); + PrintJoinList(GetSortedJoins(digitals)); + + CrestronConsole.ConsoleCommandResponse("Analogs:"); + var analogs = Joins.Where(j => (j.Value.JoinType & eJoinType.Analog) == eJoinType.Analog).ToDictionary(j => j.Key, j => j.Value); + CrestronConsole.ConsoleCommandResponse("Found {0} Analog Joins", analogs.Count); + PrintJoinList(GetSortedJoins(analogs)); + + CrestronConsole.ConsoleCommandResponse("Serials:"); + var serials = Joins.Where(j => (j.Value.JoinType & eJoinType.Serial) == eJoinType.Serial).ToDictionary(j => j.Key, j => j.Value); + CrestronConsole.ConsoleCommandResponse("Found {0} Serial Joins", serials.Count); + PrintJoinList(GetSortedJoins(serials)); + + } + + /// + /// Returns a sorted list by JoinNumber + /// + /// + /// + List> GetSortedJoins(Dictionary joins) + { + var sortedJoins = joins.ToList(); + + sortedJoins.Sort((pair1, pair2) => pair1.Value.JoinNumber.CompareTo(pair2.Value.JoinNumber)); + + return sortedJoins; + } + + void PrintJoinList(List> joins) + { + foreach (var join in joins) + { + CrestronConsole.ConsoleCommandResponse( + @"Join Number: {0} | Label: '{1}' | JoinSpan: '{2}' | Type: '{3}' | Capabilities: '{4}'", + join.Value.JoinNumber, + join.Value.Label, + join.Value.JoinSpan, + join.Value.JoinType.ToString(), + join.Value.JoinCapabilities.ToString()); + } + } + + /// + /// Returns the join number for the join with the specified key + /// + /// + /// + public uint GetJoinForKey(string key) + { + return Joins.ContainsKey(key) ? Joins[key].JoinNumber : 0; + } + + /// + /// Returns the join span for the join with the specified key + /// + /// + /// + public uint GetJoinSpanForKey(string key) + { + return Joins.ContainsKey(key) ? Joins[key].JoinSpan : 0; + } + } + + /// + /// Base class for join maps + /// + public abstract class JoinMapBaseAdvanced + { + protected uint JoinOffset; + + /// + /// The collection of joins and associated metadata + /// + public Dictionary Joins { get; private set; } + + protected JoinMapBaseAdvanced(uint joinStart) + { + Joins = new Dictionary(); + + JoinOffset = joinStart - 1; + } + + protected JoinMapBaseAdvanced(uint joinStart, Type type):this(joinStart) + { + AddJoins(type); + } + + protected void AddJoins(Type type) + { + var fields = + type.GetCType() + .GetFields(BindingFlags.Public | BindingFlags.Instance) + .Where(f => f.IsDefined(typeof (JoinNameAttribute), true)); + + foreach (var field in fields) + { + var childClass = Convert.ChangeType(this, type, null); + + var value = field.GetValue(childClass) as JoinDataComplete; //this here is JoinMapBaseAdvanced, not the child class. JoinMapBaseAdvanced has no fields. + + if (value == null) + { + Debug.Console(0, "Unable to cast base class to {0}", type.Name); + continue; + } + + value.SetJoinOffset(JoinOffset); + + var joinName = value.GetNameAttribute(field); + + if (String.IsNullOrEmpty(joinName)) continue; + + Joins.Add(joinName, value); + } + + + if (Debug.Level > 0) + { + PrintJoinMapInfo(); + } + } + + /// + /// Prints the join information to console + /// + public void PrintJoinMapInfo() + { + var sb = JoinmapStringBuilder(); + + CrestronConsole.ConsoleCommandResponse(sb.ToString()); + } + + private StringBuilder JoinmapStringBuilder() + { + var sb = new StringBuilder(); + + // Get the joins of each type and print them + sb.AppendLine(String.Format("# {0}", GetType().Name)); + sb.AppendLine(); + sb.AppendLine("## Digitals"); + sb.AppendLine(); + // Get the joins of each type and print them + var digitals = + Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Digital) == eJoinType.Digital) + .ToDictionary(j => j.Key, j => j.Value); + var digitalSb = AppendJoinList(GetSortedJoins(digitals)); + digitalSb.AppendLine("## Analogs"); + digitalSb.AppendLine(); + + var analogs = + Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Analog) == eJoinType.Analog) + .ToDictionary(j => j.Key, j => j.Value); + var analogSb = AppendJoinList(GetSortedJoins(analogs)); + analogSb.AppendLine("## Serials"); + analogSb.AppendLine(); + + var serials = + Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Serial) == eJoinType.Serial) + .ToDictionary(j => j.Key, j => j.Value); + var serialSb = AppendJoinList(GetSortedJoins(serials)); + + sb.EnsureCapacity(sb.Length + digitalSb.Length + analogSb.Length + serialSb.Length); + sb.Append(digitalSb).Append(analogSb).Append(serialSb); + return sb; + } + + /// + /// Prints the join information to console + /// + public void MarkdownJoinMapInfo(string deviceKey, string bridgeKey) + { + var pluginType = GetType().Name; + + CrestronConsole.ConsoleCommandResponse("{0}:\n", pluginType); + + + + WriteJoinmapMarkdown(JoinmapStringBuilder(), pluginType, bridgeKey, deviceKey); + + } + + private static void WriteJoinmapMarkdown(StringBuilder stringBuilder, string pluginType, string bridgeKey, string deviceKey) + { + var fileName = String.Format("{0}{1}{2}__{3}__{4}.md", Global.FilePathPrefix, "joinMaps/", pluginType, bridgeKey, deviceKey); + + using (var sw = new StreamWriter(fileName)) + { + sw.WriteLine(stringBuilder.ToString()); + CrestronConsole.ConsoleCommandResponse("Joinmap Readme generated and written to {0}", fileName); + } + + } + + /// + /// Returns a sorted list by JoinNumber + /// + /// + /// + static List> GetSortedJoins(Dictionary joins) + { + var sortedJoins = joins.ToList(); + + sortedJoins.Sort((pair1, pair2) => pair1.Value.JoinNumber.CompareTo(pair2.Value.JoinNumber)); + + return sortedJoins; + } + + + static StringBuilder AppendJoinList(List> joins) + { + var sb = new StringBuilder(); + const string stringFormatter = "| {0} | {1} | {2} | {3} | {4} |"; + const int joinNumberLen = 11; + const int joinSpanLen = 9; + const int typeLen = 19; + const int capabilitiesLen = 12; + var descriptionLen = (from @join in joins select @join.Value into j select j.Metadata.Description.Length).Concat(new[] {11}).Max(); + + //build header + sb.AppendLine(String.Format(stringFormatter, + String.Format("Join Number").PadRight(joinNumberLen, ' '), + String.Format("Join Span").PadRight(joinSpanLen, ' '), + String.Format("Description").PadRight(descriptionLen, ' '), + String.Format("Type").PadRight(typeLen, ' '), + String.Format("Capabilities").PadRight(capabilitiesLen, ' '))); + //build table seperator + sb.AppendLine(String.Format(stringFormatter, + new String('-', joinNumberLen), + new String('-', joinSpanLen), + new String('-', descriptionLen), + new String('-', typeLen), + new String('-', capabilitiesLen))); + + foreach (var join in joins) + { + sb.AppendLine(join.Value.GetMarkdownFormattedData(stringFormatter, descriptionLen)); + } + sb.AppendLine(); + return sb; + } + + /// + /// Attempts to find the matching key for the custom join and if found overwrites the default JoinData with the custom + /// + /// + public void SetCustomJoinData(Dictionary joinData) + { + foreach (var customJoinData in joinData) + { + JoinDataComplete join; + + if (!Joins.TryGetValue(customJoinData.Key, out join)) + { + Debug.Console(2, "No matching key found in join map for: '{0}'", customJoinData.Key); + continue; + } + + if (join != null) + { + join.SetCustomJoinData(customJoinData.Value); + } + } + + PrintJoinMapInfo(); + } + + ///// + ///// Returns the join number for the join with the specified key + ///// + ///// + ///// + //public uint GetJoinForKey(string key) + //{ + // return Joins.ContainsKey(key) ? Joins[key].JoinNumber : 0; + //} + + + ///// + ///// Returns the join span for the join with the specified key + ///// + ///// + ///// + //public uint GetJoinSpanForKey(string key) + //{ + // return Joins.ContainsKey(key) ? Joins[key].JoinSpan : 0; + //} + } + + /// + /// Read = Provides feedback to SIMPL + /// Write = Responds to sig values from SIMPL + /// + [Flags] + public enum eJoinCapabilities + { + None = 0, + ToSIMPL = 1, + FromSIMPL = 2, + ToFromSIMPL = ToSIMPL | FromSIMPL, + ToFusion = 4, + FromFusion = 8, + ToFromFusion = ToFusion | FromFusion, + } + + [Flags] + public enum eJoinType + { + None = 0, + Digital = 1, + Analog = 2, + Serial = 4, + DigitalAnalog = Digital | Analog, + DigitalSerial = Digital | Serial, + AnalogSerial = Analog | Serial, + DigitalAnalogSerial = Digital | Analog | Serial, + } + + /// + /// Metadata describing the join + /// + public class JoinMetadata + { + private string _description; + + /// + /// Join number (based on join offset value) + /// + [JsonProperty("joinNumber")] + [Obsolete] + public uint JoinNumber { get; set; } + /// + /// Join range span. If join indicates the start of a range of joins, this indicated the maximum number of joins in the range + /// + [Obsolete] + [JsonProperty("joinSpan")] + public uint JoinSpan { get; set; } + + /// + /// A label for the join to better describe its usage + /// + [Obsolete("Use Description instead")] + [JsonProperty("label")] + public string Label { get { return _description; } set { _description = value; } } + + /// + /// A description for the join to better describe its usage + /// + [JsonProperty("description")] + public string Description { get { return _description; } set { _description = value; } } + /// + /// Signal type(s) + /// + [JsonProperty("joinType")] + public eJoinType JoinType { get; set; } + /// + /// Indicates whether the join is read and/or write + /// + [JsonProperty("joinCapabilities")] + public eJoinCapabilities JoinCapabilities { get; set; } + /// + /// Indicates a set of valid values (particularly if this translates to an enum + /// + [JsonProperty("validValues")] + public string[] ValidValues { get; set; } + + } + + /// + /// Data describing the join. Can be overridden from configuratino + /// + public class JoinData + { + /// + /// Join number (based on join offset value) + /// + [JsonProperty("joinNumber")] + public uint JoinNumber { get; set; } + /// + /// Join range span. If join indicates the start of a range of joins, this indicated the maximum number of joins in the range + /// + [JsonProperty("joinSpan")] + public uint JoinSpan { get; set; } + /// + /// Fusion Attribute Name (optional) + /// + [JsonProperty("attributeName")] + public string AttributeName { get; set; } + } + + /// + /// A class to aggregate the JoinData and JoinMetadata for a join + /// + public class JoinDataComplete + { + private uint _joinOffset; + + private JoinData _data; + public JoinMetadata Metadata { get; set; } + /// + /// To store some future information as you please + /// + public object UserObject { get; private set; } + + public JoinDataComplete(JoinData data, JoinMetadata metadata) + { + _data = data; + Metadata = metadata; + } + + public string GetMarkdownFormattedData(string stringFormatter, int descriptionLen) + { + + //Fixed Width Headers + var joinNumberLen = String.Format("Join Number").Length; + var joinSpanLen = String.Format("Join Span").Length; + var typeLen = String.Format("AnalogDigitalSerial").Length; + var capabilitiesLen = String.Format("ToFromFusion").Length; + + //Track which one failed, if it did + const string placeholder = "unknown"; + var dataArray = new Dictionary + { + {"joinNumber", placeholder.PadRight(joinNumberLen, ' ')}, + {"joinSpan", placeholder.PadRight(joinSpanLen, ' ')}, + {"description", placeholder.PadRight(descriptionLen, ' ')}, + {"joinType", placeholder.PadRight(typeLen, ' ')}, + {"capabilities", placeholder.PadRight(capabilitiesLen, ' ')} + }; + + + try + { + dataArray["joinNumber"] = String.Format("{0}", JoinNumber.ToString(CultureInfo.InvariantCulture).ReplaceIfNullOrEmpty(placeholder)).PadRight(joinNumberLen, ' '); + dataArray["joinSpan"] = String.Format("{0}", JoinSpan.ToString(CultureInfo.InvariantCulture).ReplaceIfNullOrEmpty(placeholder)).PadRight(joinSpanLen, ' '); + dataArray["description"] = String.Format("{0}", Metadata.Description.ReplaceIfNullOrEmpty(placeholder)).PadRight(descriptionLen, ' '); + dataArray["joinType"] = String.Format("{0}", Metadata.JoinType.ToString().ReplaceIfNullOrEmpty(placeholder)).PadRight(typeLen, ' '); + dataArray["capabilities"] = String.Format("{0}", Metadata.JoinCapabilities.ToString().ReplaceIfNullOrEmpty(placeholder)).PadRight(capabilitiesLen, ' '); + + return String.Format(stringFormatter, + dataArray["joinNumber"], + dataArray["joinSpan"], + dataArray["description"], + dataArray["joinType"], + dataArray["capabilities"]); + + } + catch (Exception e) + { + //Don't Throw - we don't want to kill the system if this falls over - it's not mission critical. Print the error, use placeholder data + var errorKey = string.Empty; + foreach (var item in dataArray) + { + if (item.Value.TrimEnd() == placeholder) continue; + errorKey = item.Key; + break; + } + Debug.Console(0, "Unable to decode join metadata {1}- {0}", e.Message, !String.IsNullOrEmpty(errorKey) ? (' ' + errorKey) : String.Empty); + return String.Format(stringFormatter, + dataArray["joinNumber"], + dataArray["joinSpan"], + dataArray["description"], + dataArray["joinType"], + dataArray["capabilities"]); + } + } + + + /// + /// Sets the join offset value + /// + /// + public void SetJoinOffset(uint joinOffset) + { + _joinOffset = joinOffset; + } + + /// + /// The join number (including the offset) + /// + public uint JoinNumber + { + get { return _data.JoinNumber+ _joinOffset; } + set { _data.JoinNumber = value; } + } + + public uint JoinSpan + { + get { return _data.JoinSpan; } + } + + public string AttributeName + { + get { return _data.AttributeName; } + } + + public void SetCustomJoinData(JoinData customJoinData) + { + _data = customJoinData; + } + + public string GetNameAttribute(MemberInfo memberInfo) + { + var name = string.Empty; + var attribute = (JoinNameAttribute)CAttribute.GetCustomAttribute(memberInfo, typeof(JoinNameAttribute)); + + if (attribute == null) return name; + + name = attribute.Name; + Debug.Console(2, "JoinName Attribute value: {0}", name); + return name; + } + } + + + + [AttributeUsage(AttributeTargets.All)] + public class JoinNameAttribute : CAttribute + { + private string _Name; + + public JoinNameAttribute(string name) + { + Debug.Console(2, "Setting Attribute Name: {0}", name); + _Name = name; + } + + public string Name + { + get { return _Name; } + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/License/EssentialsLicenseManager.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/License/EssentialsLicenseManager.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/License/EssentialsLicenseManager.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/License/EssentialsLicenseManager.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Lighting/Lighting Interfaces.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Lighting/Lighting Interfaces.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Lighting/Lighting Interfaces.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Lighting/Lighting Interfaces.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Lighting/LightingBase.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Lighting/LightingBase.cs similarity index 97% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Lighting/LightingBase.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Lighting/LightingBase.cs index 48a4aa76..f0bfdd6a 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Lighting/LightingBase.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Lighting/LightingBase.cs @@ -1,167 +1,167 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.Core.Lighting -{ - public abstract class LightingBase : EssentialsBridgeableDevice, ILightingScenes - { - #region ILightingScenes Members - - public event EventHandler LightingSceneChange; - - public List LightingScenes { get; protected set; } - - public LightingScene CurrentLightingScene { get; protected set; } - - public IntFeedback CurrentLightingSceneFeedback { get; protected set; } - - #endregion - - protected LightingBase(string key, string name) - : base(key, name) - { - LightingScenes = new List(); - - CurrentLightingScene = new LightingScene(); - //CurrentLightingSceneFeedback = new IntFeedback(() => { return int.Parse(this.CurrentLightingScene.ID); }); - } - - public abstract void SelectScene(LightingScene scene); - - public void SimulateSceneSelect(string sceneName) - { - Debug.Console(1, this, "Simulating selection of scene '{0}'", sceneName); - - var scene = LightingScenes.FirstOrDefault(s => s.Name.Equals(sceneName)); - - if (scene != null) - { - CurrentLightingScene = scene; - OnLightingSceneChange(); - } - } - - /// - /// Sets the IsActive property on each scene and fires the LightingSceneChange event - /// - protected void OnLightingSceneChange() - { - foreach (var scene in LightingScenes) - { - if (scene == CurrentLightingScene) - scene.IsActive = true; - - else - scene.IsActive = false; - } - - var handler = LightingSceneChange; - if (handler != null) - { - handler(this, new LightingSceneChangeEventArgs(CurrentLightingScene)); - } - } - - protected GenericLightingJoinMap LinkLightingToApi(LightingBase lightingDevice, BasicTriList trilist, uint joinStart, - string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new GenericLightingJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - return LinkLightingToApi(lightingDevice, trilist, joinMap); - } - - protected GenericLightingJoinMap LinkLightingToApi(LightingBase lightingDevice, BasicTriList trilist, GenericLightingJoinMap joinMap) - { - Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - Debug.Console(0, "Linking to Lighting Type {0}", lightingDevice.GetType().Name.ToString()); - - // GenericLighitng Actions & FeedBack - trilist.SetUShortSigAction(joinMap.SelectScene.JoinNumber, u => lightingDevice.SelectScene(lightingDevice.LightingScenes[u])); - - var sceneIndex = 0; - foreach (var scene in lightingDevice.LightingScenes) - { - var index = sceneIndex; - - trilist.SetSigTrueAction((uint)(joinMap.SelectSceneDirect.JoinNumber + index), () => lightingDevice.SelectScene(lightingDevice.LightingScenes[index])); - scene.IsActiveFeedback.LinkInputSig(trilist.BooleanInput[(uint)(joinMap.SelectSceneDirect.JoinNumber + index)]); - trilist.StringInput[(uint)(joinMap.SelectSceneDirect.JoinNumber + index)].StringValue = scene.Name; - trilist.BooleanInput[(uint)(joinMap.ButtonVisibility.JoinNumber + index)].BoolValue = true; - - sceneIndex++; - } - - trilist.OnlineStatusChange += (sender, args) => - { - if (!args.DeviceOnLine) return; - - sceneIndex = 0; - foreach (var scene in lightingDevice.LightingScenes) - { - var index = sceneIndex; - - trilist.StringInput[(uint) (joinMap.SelectSceneDirect.JoinNumber + index)].StringValue = scene.Name; - trilist.BooleanInput[(uint) (joinMap.ButtonVisibility.JoinNumber + index)].BoolValue = true; - scene.IsActiveFeedback.FireUpdate(); - - sceneIndex++; - } - }; - - return joinMap; - } - } - - public class LightingScene - { - [JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)] - public string Name { get; set; } - [JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)] - public string ID { get; set; } - bool _IsActive; - [JsonProperty("isActive", NullValueHandling = NullValueHandling.Ignore)] - public bool IsActive - { - get - { - return _IsActive; - } - set - { - _IsActive = value; - IsActiveFeedback.FireUpdate(); - } - } - - [JsonIgnore] - public BoolFeedback IsActiveFeedback { get; set; } - - public LightingScene() - { - IsActiveFeedback = new BoolFeedback(new Func(() => IsActive)); - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core.Bridges; + +namespace PepperDash.Essentials.Core.Lighting +{ + public abstract class LightingBase : EssentialsBridgeableDevice, ILightingScenes + { + #region ILightingScenes Members + + public event EventHandler LightingSceneChange; + + public List LightingScenes { get; protected set; } + + public LightingScene CurrentLightingScene { get; protected set; } + + public IntFeedback CurrentLightingSceneFeedback { get; protected set; } + + #endregion + + protected LightingBase(string key, string name) + : base(key, name) + { + LightingScenes = new List(); + + CurrentLightingScene = new LightingScene(); + //CurrentLightingSceneFeedback = new IntFeedback(() => { return int.Parse(this.CurrentLightingScene.ID); }); + } + + public abstract void SelectScene(LightingScene scene); + + public void SimulateSceneSelect(string sceneName) + { + Debug.Console(1, this, "Simulating selection of scene '{0}'", sceneName); + + var scene = LightingScenes.FirstOrDefault(s => s.Name.Equals(sceneName)); + + if (scene != null) + { + CurrentLightingScene = scene; + OnLightingSceneChange(); + } + } + + /// + /// Sets the IsActive property on each scene and fires the LightingSceneChange event + /// + protected void OnLightingSceneChange() + { + foreach (var scene in LightingScenes) + { + if (scene == CurrentLightingScene) + scene.IsActive = true; + + else + scene.IsActive = false; + } + + var handler = LightingSceneChange; + if (handler != null) + { + handler(this, new LightingSceneChangeEventArgs(CurrentLightingScene)); + } + } + + protected GenericLightingJoinMap LinkLightingToApi(LightingBase lightingDevice, BasicTriList trilist, uint joinStart, + string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new GenericLightingJoinMap(joinStart); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + else + { + Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + } + + return LinkLightingToApi(lightingDevice, trilist, joinMap); + } + + protected GenericLightingJoinMap LinkLightingToApi(LightingBase lightingDevice, BasicTriList trilist, GenericLightingJoinMap joinMap) + { + Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + Debug.Console(0, "Linking to Lighting Type {0}", lightingDevice.GetType().Name.ToString()); + + // GenericLighitng Actions & FeedBack + trilist.SetUShortSigAction(joinMap.SelectScene.JoinNumber, u => lightingDevice.SelectScene(lightingDevice.LightingScenes[u])); + + var sceneIndex = 0; + foreach (var scene in lightingDevice.LightingScenes) + { + var index = sceneIndex; + + trilist.SetSigTrueAction((uint)(joinMap.SelectSceneDirect.JoinNumber + index), () => lightingDevice.SelectScene(lightingDevice.LightingScenes[index])); + scene.IsActiveFeedback.LinkInputSig(trilist.BooleanInput[(uint)(joinMap.SelectSceneDirect.JoinNumber + index)]); + trilist.StringInput[(uint)(joinMap.SelectSceneDirect.JoinNumber + index)].StringValue = scene.Name; + trilist.BooleanInput[(uint)(joinMap.ButtonVisibility.JoinNumber + index)].BoolValue = true; + + sceneIndex++; + } + + trilist.OnlineStatusChange += (sender, args) => + { + if (!args.DeviceOnLine) return; + + sceneIndex = 0; + foreach (var scene in lightingDevice.LightingScenes) + { + var index = sceneIndex; + + trilist.StringInput[(uint) (joinMap.SelectSceneDirect.JoinNumber + index)].StringValue = scene.Name; + trilist.BooleanInput[(uint) (joinMap.ButtonVisibility.JoinNumber + index)].BoolValue = true; + scene.IsActiveFeedback.FireUpdate(); + + sceneIndex++; + } + }; + + return joinMap; + } + } + + public class LightingScene + { + [JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)] + public string Name { get; set; } + [JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)] + public string ID { get; set; } + bool _IsActive; + [JsonProperty("isActive", NullValueHandling = NullValueHandling.Ignore)] + public bool IsActive + { + get + { + return _IsActive; + } + set + { + _IsActive = value; + IsActiveFeedback.FireUpdate(); + } + } + + [JsonIgnore] + public BoolFeedback IsActiveFeedback { get; set; } + + public LightingScene() + { + IsActiveFeedback = new BoolFeedback(new Func(() => IsActive)); + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Microphone Privacy/MicrophonePrivacyController.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Microphone Privacy/MicrophonePrivacyController.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Microphone Privacy/MicrophonePrivacyController.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Microphone Privacy/MicrophonePrivacyController.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Microphone Privacy/MicrophonePrivacyControllerConfig.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Microphone Privacy/MicrophonePrivacyControllerConfig.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Microphone Privacy/MicrophonePrivacyControllerConfig.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Microphone Privacy/MicrophonePrivacyControllerConfig.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/CrestronGenericBaseCommunicationMonitor.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/CrestronGenericBaseCommunicationMonitor.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/CrestronGenericBaseCommunicationMonitor.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/CrestronGenericBaseCommunicationMonitor.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/GenericCommunicationMonitor.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/GenericCommunicationMonitor.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/GenericCommunicationMonitor.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/GenericCommunicationMonitor.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/Interfaces.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/Interfaces.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/Interfaces.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/Interfaces.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/StatusMonitorBase.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/StatusMonitorBase.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/StatusMonitorBase.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/StatusMonitorBase.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/StatusMonitorCollection.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/StatusMonitorCollection.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/StatusMonitorCollection.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/StatusMonitorCollection.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/SystemMonitorController.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/SystemMonitorController.cs similarity index 97% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/SystemMonitorController.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/SystemMonitorController.cs index 8a7f379a..a50a85dc 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/SystemMonitorController.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/SystemMonitorController.cs @@ -1,819 +1,819 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.Diagnostics; -using PepperDash.Core; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.Core.Monitoring -{ - /// - /// Wrapper for the static SystemMonitor class to extend functionality and provide external access - /// to SystemMonitor via APIs - /// - public class SystemMonitorController : EssentialsBridgeableDevice - { - private const long UptimePollTime = 300000; - private CTimer _uptimePollTimer; - - private string _uptime; - private string _lastStart; - - public event EventHandler SystemMonitorPropertiesChanged; - - public Dictionary ProgramStatusFeedbackCollection; - public Dictionary EthernetStatusFeedbackCollection; - - public IntFeedback TimeZoneFeedback { get; protected set; } - public StringFeedback TimeZoneTextFeedback { get; protected set; } - - public StringFeedback IoControllerVersionFeedback { get; protected set; } - public StringFeedback SnmpVersionFeedback { get; protected set; } - public StringFeedback BaCnetAppVersionFeedback { get; protected set; } - public StringFeedback ControllerVersionFeedback { get; protected set; } - - //new feedbacks. Issue #50 - public StringFeedback SerialNumberFeedback { get; protected set; } - public StringFeedback ModelFeedback { get; set; } - - public StringFeedback UptimeFeedback { get; set; } - public StringFeedback LastStartFeedback { get; set; } - - public BoolFeedback IsApplianceFeedback { get; protected set; } - private bool _isApplianceFb - { - get { return CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance; } - } - - public BoolFeedback IsServerFeedback { get; protected set; } - private bool _isServerFb - { - get { return CrestronEnvironment.DevicePlatform == eDevicePlatform.Server; } - } - - - public SystemMonitorController(string key) - : base(key) - { - Debug.Console(2, this, "Adding SystemMonitorController."); - - SystemMonitor.ProgramInitialization.ProgramInitializationUnderUserControl = true; - - TimeZoneFeedback = new IntFeedback(() => SystemMonitor.TimeZoneInformation.TimeZoneNumber); - TimeZoneTextFeedback = new StringFeedback(() => SystemMonitor.TimeZoneInformation.TimeZoneName); - - IoControllerVersionFeedback = new StringFeedback(() => SystemMonitor.VersionInformation.IOPVersion); - SnmpVersionFeedback = new StringFeedback(() => SystemMonitor.VersionInformation.SNMPVersion); - BaCnetAppVersionFeedback = new StringFeedback(() => SystemMonitor.VersionInformation.BACNetVersion); - ControllerVersionFeedback = new StringFeedback(() => SystemMonitor.VersionInformation.ControlSystemVersion); - - SerialNumberFeedback = new StringFeedback(() => CrestronEnvironment.SystemInfo.SerialNumber); - ModelFeedback = new StringFeedback(() => InitialParametersClass.ControllerPromptName); - UptimeFeedback = new StringFeedback(() => _uptime); - LastStartFeedback = new StringFeedback(()=> _lastStart); - - IsApplianceFeedback = new BoolFeedback(() => _isApplianceFb); - IsServerFeedback = new BoolFeedback(() => _isServerFb); - - ProgramStatusFeedbackCollection = new Dictionary(); - - foreach (var prog in SystemMonitor.ProgramCollection) - { - var program = new ProgramStatusFeedbacks(prog); - ProgramStatusFeedbackCollection.Add(prog.Number, program); - } - - CreateEthernetStatusFeedbacks(); - UpdateEthernetStatusFeeedbacks(); - - _uptimePollTimer = new CTimer(PollUptime,null,0, UptimePollTime); - - SystemMonitor.ProgramChange += SystemMonitor_ProgramChange; - SystemMonitor.TimeZoneInformation.TimeZoneChange += TimeZoneInformation_TimeZoneChange; - CrestronEnvironment.EthernetEventHandler += CrestronEnvironmentOnEthernetEventHandler; - CrestronEnvironment.ProgramStatusEventHandler += CrestronEnvironmentOnProgramStatusEventHandler; - } - - private void CrestronEnvironmentOnProgramStatusEventHandler(eProgramStatusEventType programEventType) - { - if (programEventType != eProgramStatusEventType.Stopping) return; - - _uptimePollTimer.Stop(); - _uptimePollTimer.Dispose(); - _uptimePollTimer = null; - } - - private void PollUptime(object obj) - { - var consoleResponse = string.Empty; - - CrestronConsole.SendControlSystemCommand("uptime", ref consoleResponse); - - ParseUptime(consoleResponse); - - UptimeFeedback.FireUpdate(); - LastStartFeedback.FireUpdate(); - } - - private void ParseUptime(string response) - { - var splitString = response.Trim().Split('\r', '\n'); - - var lastStartRaw = splitString.FirstOrDefault(o => o.Contains("started")); - var uptimeRaw = splitString.FirstOrDefault(o => o.Contains("running")); - - if (!String.IsNullOrEmpty(lastStartRaw)) - { - var lastStartIndex = lastStartRaw.IndexOf(':'); - _lastStart = lastStartRaw.Substring(lastStartIndex + 1).Trim(); - } - - if (String.IsNullOrEmpty(uptimeRaw)) return; - var forIndex = uptimeRaw.IndexOf("for", StringComparison.Ordinal); - - //4 => "for " to get what's on the right - _uptime = uptimeRaw.Substring(forIndex + 4); - } - - private static void ProcessorReboot() - { - if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Server) return; - - var response = string.Empty; - CrestronConsole.SendControlSystemCommand("reboot", ref response); - } - - private static void ProgramReset(uint index) - { - if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Server) return; - - if (index <= 0 || index > 10) return; - - var cmd = string.Format("progreset -p:{0}", index); - - var response = string.Empty; - CrestronConsole.SendControlSystemCommand(cmd, ref response); - } - - private void CrestronEnvironmentOnEthernetEventHandler(EthernetEventArgs ethernetEventArgs) - { - if (ethernetEventArgs.EthernetEventType != eEthernetEventType.LinkUp) return; - - foreach (var fb in EthernetStatusFeedbackCollection) - { - fb.Value.UpdateEthernetStatus(); - } - } - - private void CreateEthernetStatusFeedbacks() - { - EthernetStatusFeedbackCollection = new Dictionary(); - - Debug.Console(2, "Creating {0} EthernetStatusFeedbacks", InitialParametersClass.NumberOfEthernetInterfaces); - - for (short i = 0; i < InitialParametersClass.NumberOfEthernetInterfaces; i++) - { - Debug.Console(2, "Creating EthernetStatusFeedback for Interface {0}", i); - var ethernetInterface = new EthernetStatusFeedbacks(i); - EthernetStatusFeedbackCollection.Add(i, ethernetInterface); - } - } - - private void UpdateEthernetStatusFeeedbacks() - { - foreach (var iface in EthernetStatusFeedbackCollection) - { - iface.Value.CurrentIpAddressFeedback.FireUpdate(); - iface.Value.CurrentSubnetMaskFeedback.FireUpdate(); - iface.Value.CurrentDefaultGatewayFeedback.FireUpdate(); - iface.Value.StaticIpAddressFeedback.FireUpdate(); - iface.Value.StaticSubnetMaskFeedback.FireUpdate(); - iface.Value.StaticDefaultGatewayFeedback.FireUpdate(); - iface.Value.HostNameFeedback.FireUpdate(); - iface.Value.DnsServerFeedback.FireUpdate(); - iface.Value.DomainFeedback.FireUpdate(); - iface.Value.DhcpStatusFeedback.FireUpdate(); - iface.Value.MacAddressFeedback.FireUpdate(); - } - } - - /// - /// Gets data in separate thread - /// - private void RefreshSystemMonitorData() - { - // this takes a while, launch a new thread - CrestronInvoke.BeginInvoke(UpdateFeedback); - } - - private void UpdateFeedback(object o) - { - TimeZoneFeedback.FireUpdate(); - TimeZoneTextFeedback.FireUpdate(); - IoControllerVersionFeedback.FireUpdate(); - SnmpVersionFeedback.FireUpdate(); - BaCnetAppVersionFeedback.FireUpdate(); - ControllerVersionFeedback.FireUpdate(); - SerialNumberFeedback.FireUpdate(); - ModelFeedback.FireUpdate(); - - IsApplianceFeedback.FireUpdate(); - IsServerFeedback.FireUpdate(); - - OnSystemMonitorPropertiesChanged(); - } - - private void OnSystemMonitorPropertiesChanged() - { - var handler = SystemMonitorPropertiesChanged; - if (handler != null) - { - handler(this, new EventArgs()); - } - } - - public override bool CustomActivate() - { - RefreshSystemMonitorData(); - - return base.CustomActivate(); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new SystemMonitorJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - Debug.Console(2, this, "Linking API starting at join: {0}", joinStart); - - TimeZoneFeedback.LinkInputSig(trilist.UShortInput[joinMap.TimeZone.JoinNumber]); - TimeZoneTextFeedback.LinkInputSig(trilist.StringInput[joinMap.TimeZoneName.JoinNumber]); - - IoControllerVersionFeedback.LinkInputSig(trilist.StringInput[joinMap.IOControllerVersion.JoinNumber]); - SnmpVersionFeedback.LinkInputSig(trilist.StringInput[joinMap.SnmpAppVersion.JoinNumber]); - BaCnetAppVersionFeedback.LinkInputSig(trilist.StringInput[joinMap.BACnetAppVersion.JoinNumber]); - ControllerVersionFeedback.LinkInputSig(trilist.StringInput[joinMap.ControllerVersion.JoinNumber]); - SerialNumberFeedback.LinkInputSig(trilist.StringInput[joinMap.SerialNumber.JoinNumber]); - ModelFeedback.LinkInputSig(trilist.StringInput[joinMap.Model.JoinNumber]); - UptimeFeedback.LinkInputSig(trilist.StringInput[joinMap.Uptime.JoinNumber]); - LastStartFeedback.LinkInputSig(trilist.StringInput[joinMap.LastBoot.JoinNumber]); - - trilist.SetSigHeldAction(joinMap.ProcessorReboot.JoinNumber, 10000, ProcessorReboot); - - IsApplianceFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsAppliance.JoinNumber]); - IsServerFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsServer.JoinNumber]); - - // iterate the program status feedback collection and map all the joins - LinkProgramInfoJoins(this, trilist, joinMap); - - LinkEthernetInfoJoins(this, trilist, joinMap); - } - - private static void LinkEthernetInfoJoins(SystemMonitorController systemMonitorController, BasicTriList trilist, SystemMonitorJoinMap joinMap) - { - uint ethernetSlotJoinStart = 0; - foreach (var fb in systemMonitorController.EthernetStatusFeedbackCollection) - { - fb.Value.CurrentIpAddressFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.CurrentIpAddress.JoinNumber]); - fb.Value.CurrentSubnetMaskFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.CurrentSubnetMask.JoinNumber]); - fb.Value.CurrentDefaultGatewayFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.CurrentDefaultGateway.JoinNumber]); - fb.Value.StaticIpAddressFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.StaticIpAddress.JoinNumber]); - fb.Value.StaticSubnetMaskFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.StaticSubnetMask.JoinNumber]); - fb.Value.StaticDefaultGatewayFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.StaticDefaultGateway.JoinNumber]); - fb.Value.HostNameFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.HostName.JoinNumber]); - fb.Value.MacAddressFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.MacAddress.JoinNumber]); - fb.Value.DomainFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.Domain.JoinNumber]); - fb.Value.DnsServerFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.DnsServer.JoinNumber]); - fb.Value.DhcpStatusFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.DhcpStatus.JoinNumber]); - - ethernetSlotJoinStart += joinMap.EthernetOffsetJoin.JoinNumber; - } - } - - private static void LinkProgramInfoJoins(SystemMonitorController systemMonitorController, BasicTriList trilist, - SystemMonitorJoinMap joinMap) - { - uint programSlotJoinStart = 0; - - foreach (var p in systemMonitorController.ProgramStatusFeedbackCollection) - { - var programNumber = p.Value.Program.Number; - - trilist.SetBoolSigAction(programSlotJoinStart + joinMap.ProgramStart.JoinNumber, - b => SystemMonitor.ProgramCollection[programNumber].OperatingState = eProgramOperatingState.Start); - p.Value.ProgramStartedFeedback.LinkInputSig(trilist.BooleanInput[programSlotJoinStart + joinMap.ProgramStart.JoinNumber]); - - trilist.SetBoolSigAction(programSlotJoinStart + joinMap.ProgramStop.JoinNumber, - b => SystemMonitor.ProgramCollection[programNumber].OperatingState = eProgramOperatingState.Stop); - p.Value.ProgramStoppedFeedback.LinkInputSig(trilist.BooleanInput[programSlotJoinStart + joinMap.ProgramStop.JoinNumber]); - - trilist.SetBoolSigAction(programSlotJoinStart + joinMap.ProgramRegister.JoinNumber, - b => SystemMonitor.ProgramCollection[programNumber].RegistrationState = eProgramRegistrationState.Register); - p.Value.ProgramRegisteredFeedback.LinkInputSig( - trilist.BooleanInput[programSlotJoinStart + joinMap.ProgramRegister.JoinNumber]); - - trilist.SetBoolSigAction(programSlotJoinStart + joinMap.ProgramUnregister.JoinNumber, - b => SystemMonitor.ProgramCollection[programNumber].RegistrationState = eProgramRegistrationState.Unregister); - p.Value.ProgramUnregisteredFeedback.LinkInputSig( - trilist.BooleanInput[programSlotJoinStart + joinMap.ProgramUnregister.JoinNumber]); - - p.Value.ProgramNameFeedback.LinkInputSig(trilist.StringInput[programSlotJoinStart + joinMap.ProgramName.JoinNumber]); - p.Value.ProgramCompileTimeFeedback.LinkInputSig( - trilist.StringInput[programSlotJoinStart + joinMap.ProgramCompiledTime.JoinNumber]); - p.Value.CrestronDataBaseVersionFeedback.LinkInputSig( - trilist.StringInput[programSlotJoinStart + joinMap.ProgramCrestronDatabaseVersion.JoinNumber]); - p.Value.EnvironmentVersionFeedback.LinkInputSig( - trilist.StringInput[programSlotJoinStart + joinMap.ProgramEnvironmentVersion.JoinNumber]); - p.Value.AggregatedProgramInfoFeedback.LinkInputSig( - trilist.StringInput[programSlotJoinStart + joinMap.AggregatedProgramInfo.JoinNumber]); - - trilist.SetSigHeldAction(programSlotJoinStart + joinMap.ProgramReset.JoinNumber, 10000, () => ProgramReset(programNumber)); - - programSlotJoinStart = programSlotJoinStart + joinMap.ProgramOffsetJoin.JoinSpan; - } - } - - //// Sets the time zone - //public void SetTimeZone(int timeZone) - //{ - // SystemMonitor.TimeZoneInformation.TimeZoneNumber = timeZone; - //} - - /// - /// Responds to program change events and triggers the appropriate feedbacks to update - /// - /// - /// - private void SystemMonitor_ProgramChange(Program sender, ProgramEventArgs args) - { - Debug.Console(2, this, "Program Change Detected for slot: {0}", sender.Number); - Debug.Console(2, this, "Event Type: {0}", args.EventType); - - var program = ProgramStatusFeedbackCollection[sender.Number]; - - switch (args.EventType) - { - case eProgramChangeEventType.OperatingState: - program.ProgramStartedFeedback.FireUpdate(); - program.ProgramStoppedFeedback.FireUpdate(); - program.ProgramInfo.OperatingState = args.OperatingState; - if (args.OperatingState == eProgramOperatingState.Start) - program.GetProgramInfo(); - else - { - program.AggregatedProgramInfoFeedback.FireUpdate(); - program.OnProgramInfoChanged(); - } - break; - case eProgramChangeEventType.RegistrationState: - program.ProgramRegisteredFeedback.FireUpdate(); - program.ProgramUnregisteredFeedback.FireUpdate(); - program.ProgramInfo.RegistrationState = args.RegistrationState; - program.GetProgramInfo(); - break; - } - } - - /// - /// Responds to time zone changes and updates the appropriate feedbacks - /// - /// - private void TimeZoneInformation_TimeZoneChange(TimeZoneEventArgs args) - { - Debug.Console(2, this, "Time Zone Change Detected."); - TimeZoneFeedback.FireUpdate(); - TimeZoneTextFeedback.FireUpdate(); - - OnSystemMonitorPropertiesChanged(); - } - - public class EthernetStatusFeedbacks - { - public StringFeedback HostNameFeedback { get; protected set; } - public StringFeedback DnsServerFeedback { get; protected set; } - public StringFeedback DomainFeedback { get; protected set; } - public StringFeedback MacAddressFeedback { get; protected set; } - public StringFeedback DhcpStatusFeedback { get; protected set; } - - public StringFeedback CurrentIpAddressFeedback { get; protected set; } - public StringFeedback CurrentSubnetMaskFeedback { get; protected set; } - public StringFeedback CurrentDefaultGatewayFeedback { get; protected set; } - - public StringFeedback StaticIpAddressFeedback { get; protected set; } - public StringFeedback StaticSubnetMaskFeedback { get; protected set; } - public StringFeedback StaticDefaultGatewayFeedback { get; protected set; } - - public EthernetStatusFeedbacks(short adapterIndex) - { - Debug.Console(2, "Ethernet Information for interface {0}", adapterIndex); - Debug.Console(2, "Adapter Index: {1} Hostname: {0}", CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, adapterIndex), adapterIndex); - Debug.Console(2, "Adapter Index: {1} Current IP Address: {0}", CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, adapterIndex), adapterIndex); - Debug.Console(2, "Adapter Index: {1} Current Subnet Mask: {0}", CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, adapterIndex), adapterIndex); - Debug.Console(2, "Adapter Index: {1} Current Router: {0}", CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_ROUTER, adapterIndex), adapterIndex); - Debug.Console(2, "Adapter Index: {1} Static IP Address: {0}", CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_STATIC_IPADDRESS, adapterIndex), adapterIndex); - Debug.Console(2, "Adapter Index: {1} Static Subnet Mask: {0}", CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_STATIC_IPMASK, adapterIndex), adapterIndex); - Debug.Console(2, "Adapter Index: {1} Static Router: {0}", CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_STATIC_ROUTER, adapterIndex), adapterIndex); - Debug.Console(2, "Adapter Index: {1} DNS Servers: {0}", CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DNS_SERVER, adapterIndex), adapterIndex); - Debug.Console(2, "Adapter Index: {1} DHCP State: {0}", CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_DHCP_STATE, adapterIndex), adapterIndex); - Debug.Console(2, "Adapter Index: {1} Domain Name: {0}", CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DOMAIN_NAME, adapterIndex), adapterIndex); - Debug.Console(2, "Adapter Index: {1} MAC Address: {0}", CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, adapterIndex), adapterIndex); - HostNameFeedback = - new StringFeedback( - () => - CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, adapterIndex)); - - CurrentIpAddressFeedback = - new StringFeedback( - () => - CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, adapterIndex)); - CurrentDefaultGatewayFeedback = - new StringFeedback( - () => - CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_ROUTER, adapterIndex)); - CurrentSubnetMaskFeedback = - new StringFeedback( - () => - CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, adapterIndex)); - StaticIpAddressFeedback = - new StringFeedback( - () => - CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, adapterIndex)); - StaticDefaultGatewayFeedback = - new StringFeedback( - () => - CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_ROUTER, adapterIndex)); - StaticSubnetMaskFeedback = - new StringFeedback( - () => - CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, adapterIndex)); - DomainFeedback = - new StringFeedback( - () => - CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DOMAIN_NAME, adapterIndex)); - DnsServerFeedback = - new StringFeedback( - () => - CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DNS_SERVER, adapterIndex)); - MacAddressFeedback = - new StringFeedback( - () => - CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, adapterIndex)); - - DhcpStatusFeedback = new StringFeedback( - () => - CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_DHCP_STATE, adapterIndex)); - } - - public void UpdateEthernetStatus() - { - HostNameFeedback.FireUpdate(); - CurrentIpAddressFeedback.FireUpdate(); - CurrentSubnetMaskFeedback.FireUpdate(); - CurrentDefaultGatewayFeedback.FireUpdate(); - StaticIpAddressFeedback.FireUpdate(); - StaticSubnetMaskFeedback.FireUpdate(); - StaticDefaultGatewayFeedback.FireUpdate(); - DomainFeedback.FireUpdate(); - DnsServerFeedback.FireUpdate(); - MacAddressFeedback.FireUpdate(); - DhcpStatusFeedback.FireUpdate(); - } - } - - - public class ProgramStatusFeedbacks - { - public event EventHandler ProgramInfoChanged; - - public Program Program; - - public ProgramInfo ProgramInfo { get; set; } - - public BoolFeedback ProgramStartedFeedback; - public BoolFeedback ProgramStoppedFeedback; - public BoolFeedback ProgramRegisteredFeedback; - public BoolFeedback ProgramUnregisteredFeedback; - - public StringFeedback ProgramNameFeedback; - public StringFeedback ProgramCompileTimeFeedback; - public StringFeedback CrestronDataBaseVersionFeedback; - // SIMPL windows version - public StringFeedback EnvironmentVersionFeedback; - public StringFeedback AggregatedProgramInfoFeedback; - - public ProgramStatusFeedbacks(Program program) - { - ProgramInfo = new ProgramInfo(program.Number); - - Program = program; - - ProgramInfo.OperatingState = Program.OperatingState; - ProgramInfo.RegistrationState = Program.RegistrationState; - - ProgramStartedFeedback = new BoolFeedback(() => Program.OperatingState == eProgramOperatingState.Start); - ProgramStartedFeedback.FireUpdate(); - - ProgramStoppedFeedback = new BoolFeedback(() => Program.OperatingState == eProgramOperatingState.Stop); - ProgramStoppedFeedback.FireUpdate(); - - ProgramRegisteredFeedback = - new BoolFeedback(() => Program.RegistrationState == eProgramRegistrationState.Register); - ProgramRegisteredFeedback.FireUpdate(); - - ProgramUnregisteredFeedback = - new BoolFeedback(() => Program.RegistrationState == eProgramRegistrationState.Unregister); - ProgramUnregisteredFeedback.FireUpdate(); - - ProgramNameFeedback = new StringFeedback(() => ProgramInfo.ProgramFile); - CrestronDataBaseVersionFeedback = new StringFeedback(() => ProgramInfo.CrestronDb); - EnvironmentVersionFeedback = new StringFeedback(() => ProgramInfo.Environment); - ProgramCompileTimeFeedback = new StringFeedback(() => ProgramInfo.CompileTime); - AggregatedProgramInfoFeedback = new StringFeedback(() => JsonConvert.SerializeObject(ProgramInfo)); - - GetProgramInfo(); - } - - /// - /// Retrieves information about a running program - /// - public void GetProgramInfo() - { - CrestronInvoke.BeginInvoke(GetProgramInfo); - } - - private void GetProgramInfo(object o) - { - Debug.Console(2, "Attempting to get program info for slot: {0}", Program.Number); - - string response = null; - - if (Program.RegistrationState == eProgramRegistrationState.Unregister || Program.OperatingState == eProgramOperatingState.Stop) - { - Debug.Console(2, "Program {0} not registered. Setting default values for program information.", - Program.Number); - - ProgramInfo = new ProgramInfo(Program.Number) - { - OperatingState = Program.OperatingState, - RegistrationState = Program.RegistrationState - }; - - return; - } - - var success = CrestronConsole.SendControlSystemCommand( - string.Format("progcomments:{0}", Program.Number), ref response); - - if (!success) - { - Debug.Console(2, "Progcomments Attempt Unsuccessful for slot: {0}", Program.Number); - UpdateFeedbacks(); - return; - } - - if (response.ToLower().Contains("bad or incomplete")) - { - Debug.Console(2, - "Program in slot {0} not running. Setting default ProgramInfo for slot: {0}", - Program.Number); - - // Assume no valid program info. Constructing a new object will wipe all properties - ProgramInfo = new ProgramInfo(Program.Number) - { - OperatingState = Program.OperatingState, - RegistrationState = Program.RegistrationState - }; - - UpdateFeedbacks(); - - return; - } - - - // Shared properteis - ProgramInfo.ProgramFile = ParseConsoleData(response, "Program File", ": ", "\n"); - ProgramInfo.CompilerRevision = ParseConsoleData(response, "Compiler Rev", ": ", "\n"); - ProgramInfo.CompileTime = ParseConsoleData(response, "Compiled On", ": ", "\n"); - ProgramInfo.Include4Dat = ParseConsoleData(response, "Include4.dat", ": ", "\n"); - - - if (ProgramInfo.ProgramFile.Contains(".dll")) - { - // SSP Program - ProgramInfo.FriendlyName = ParseConsoleData(response, "Friendly Name", ": ", "\n"); - ProgramInfo.ApplicationName = ParseConsoleData(response, "Application Name", ": ", "\n"); - ProgramInfo.ProgramTool = ParseConsoleData(response, "Program Tool", ": ", "\n"); - ProgramInfo.MinFirmwareVersion = ParseConsoleData(response, "Min Firmware Version", ": ", - "\n"); - ProgramInfo.PlugInVersion = ParseConsoleData(response, "PlugInVersion", ": ", "\n"); - - ProgramInfo.ProgramFile += string.Format(" {0}.{1}.{2}", - ProgramInfo.CompilerRevisionInfo.Major, - ProgramInfo.CompilerRevisionInfo.Minor, - ProgramInfo.CompilerRevisionInfo.Build); - - ProgramInfo.Environment = ProgramInfo.ProgramTool; - } - else if (ProgramInfo.ProgramFile.Contains(".smw")) - { - // SIMPL Windows Program - ProgramInfo.FriendlyName = ParseConsoleData(response, "Friendly Name", ":", "\n"); - ProgramInfo.SystemName = ParseConsoleData(response, "System Name", ": ", "\n"); - ProgramInfo.CrestronDb = ParseConsoleData(response, "CrestronDB", ": ", "\n"); - ProgramInfo.Environment = ParseConsoleData(response, "Source Env", ": ", "\n"); - ProgramInfo.Programmer = ParseConsoleData(response, "Programmer", ": ", "\n"); - } - Debug.Console(2, "Program info for slot {0} successfully updated", Program.Number); - - UpdateFeedbacks(); - } - - private void UpdateFeedbacks() - { - ProgramNameFeedback.FireUpdate(); - ProgramCompileTimeFeedback.FireUpdate(); - CrestronDataBaseVersionFeedback.FireUpdate(); - EnvironmentVersionFeedback.FireUpdate(); - - AggregatedProgramInfoFeedback.FireUpdate(); - - OnProgramInfoChanged(); - } - - public void OnProgramInfoChanged() - { - //Debug.Console(1, "Firing ProgramInfoChanged for slot: {0}", Program.Number); - var handler = ProgramInfoChanged; - if (handler != null) - { - handler(this, new ProgramInfoEventArgs(ProgramInfo)); - } - } - - private string ParseConsoleData(string data, string line, string startString, string endString) - { - var outputData = ""; - - if (data.Length <= 0) return outputData; - - try - { - //Debug.Console(2, "ParseConsoleData Data: {0}, Line {1}, startStirng {2}, endString {3}", data, line, startString, endString); - var linePosition = data.IndexOf(line, StringComparison.Ordinal); - var startPosition = data.IndexOf(startString, linePosition, StringComparison.Ordinal) + - startString.Length; - var endPosition = data.IndexOf(endString, startPosition, StringComparison.Ordinal); - outputData = data.Substring(startPosition, endPosition - startPosition).Trim(); - //Debug.Console(2, "ParseConsoleData Return: {0}", outputData); - } - catch (Exception e) - { - Debug.Console(1, "Error Parsing Console Data:\r{0}", e); - } - - return outputData; - } - } - } - - /// - /// Class for serializing program slot information - /// - public class ProgramInfo - { - // Shared properties - - [JsonProperty("programNumber")] - public uint ProgramNumber { get; private set; } - - [JsonConverter(typeof (StringEnumConverter))] - [JsonProperty("operatingState")] - public eProgramOperatingState OperatingState { get; set; } - - [JsonConverter(typeof (StringEnumConverter))] - [JsonProperty("registrationState")] - public eProgramRegistrationState RegistrationState { get; set; } - - [JsonProperty("programFile")] - public string ProgramFile { get; set; } - - [JsonProperty("friendlyName")] - public string FriendlyName { get; set; } - - [JsonProperty("compilerRevision")] - public string CompilerRevision { get; set; } - - [JsonIgnore] - public Version CompilerRevisionInfo - { - get - { - return new Version(CompilerRevision); - } - } - - [JsonProperty("compileTime")] - public string CompileTime { get; set; } - - [JsonProperty("include4Dat")] - public string Include4Dat { get; set; } - - // SIMPL Windows properties - [JsonProperty("systemName")] - public string SystemName { get; set; } - - [JsonProperty("crestronDb")] - public string CrestronDb { get; set; } - - [JsonProperty("environment")] - public string Environment { get; set; } - - [JsonProperty("programmer")] - public string Programmer { get; set; } - - - // SSP Properties - [JsonProperty("applicationName")] - public string ApplicationName { get; set; } - - [JsonProperty("programTool")] - public string ProgramTool { get; set; } - - [JsonProperty("minFirmwareVersion")] - public string MinFirmwareVersion { get; set; } - - [JsonProperty("plugInVersion")] - public string PlugInVersion { get; set; } - - public ProgramInfo(uint number) - { - ProgramNumber = number; - - ProgramFile = ""; - FriendlyName = ""; - CompilerRevision = ""; - CompileTime = ""; - Include4Dat = ""; - - SystemName = ""; - CrestronDb = ""; - Environment = ""; - Programmer = ""; - - ApplicationName = ""; - ProgramTool = ""; - MinFirmwareVersion = ""; - PlugInVersion = ""; - } - } - - public class ProgramInfoEventArgs : EventArgs - { - public ProgramInfo ProgramInfo; - - public ProgramInfoEventArgs(ProgramInfo progInfo) - { - ProgramInfo = progInfo; - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.Diagnostics; +using PepperDash.Core; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using PepperDash.Essentials.Core.Bridges; + +namespace PepperDash.Essentials.Core.Monitoring +{ + /// + /// Wrapper for the static SystemMonitor class to extend functionality and provide external access + /// to SystemMonitor via APIs + /// + public class SystemMonitorController : EssentialsBridgeableDevice + { + private const long UptimePollTime = 300000; + private CTimer _uptimePollTimer; + + private string _uptime; + private string _lastStart; + + public event EventHandler SystemMonitorPropertiesChanged; + + public Dictionary ProgramStatusFeedbackCollection; + public Dictionary EthernetStatusFeedbackCollection; + + public IntFeedback TimeZoneFeedback { get; protected set; } + public StringFeedback TimeZoneTextFeedback { get; protected set; } + + public StringFeedback IoControllerVersionFeedback { get; protected set; } + public StringFeedback SnmpVersionFeedback { get; protected set; } + public StringFeedback BaCnetAppVersionFeedback { get; protected set; } + public StringFeedback ControllerVersionFeedback { get; protected set; } + + //new feedbacks. Issue #50 + public StringFeedback SerialNumberFeedback { get; protected set; } + public StringFeedback ModelFeedback { get; set; } + + public StringFeedback UptimeFeedback { get; set; } + public StringFeedback LastStartFeedback { get; set; } + + public BoolFeedback IsApplianceFeedback { get; protected set; } + private bool _isApplianceFb + { + get { return CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance; } + } + + public BoolFeedback IsServerFeedback { get; protected set; } + private bool _isServerFb + { + get { return CrestronEnvironment.DevicePlatform == eDevicePlatform.Server; } + } + + + public SystemMonitorController(string key) + : base(key) + { + Debug.Console(2, this, "Adding SystemMonitorController."); + + SystemMonitor.ProgramInitialization.ProgramInitializationUnderUserControl = true; + + TimeZoneFeedback = new IntFeedback(() => SystemMonitor.TimeZoneInformation.TimeZoneNumber); + TimeZoneTextFeedback = new StringFeedback(() => SystemMonitor.TimeZoneInformation.TimeZoneName); + + IoControllerVersionFeedback = new StringFeedback(() => SystemMonitor.VersionInformation.IOPVersion); + SnmpVersionFeedback = new StringFeedback(() => SystemMonitor.VersionInformation.SNMPVersion); + BaCnetAppVersionFeedback = new StringFeedback(() => SystemMonitor.VersionInformation.BACNetVersion); + ControllerVersionFeedback = new StringFeedback(() => SystemMonitor.VersionInformation.ControlSystemVersion); + + SerialNumberFeedback = new StringFeedback(() => CrestronEnvironment.SystemInfo.SerialNumber); + ModelFeedback = new StringFeedback(() => InitialParametersClass.ControllerPromptName); + UptimeFeedback = new StringFeedback(() => _uptime); + LastStartFeedback = new StringFeedback(()=> _lastStart); + + IsApplianceFeedback = new BoolFeedback(() => _isApplianceFb); + IsServerFeedback = new BoolFeedback(() => _isServerFb); + + ProgramStatusFeedbackCollection = new Dictionary(); + + foreach (var prog in SystemMonitor.ProgramCollection) + { + var program = new ProgramStatusFeedbacks(prog); + ProgramStatusFeedbackCollection.Add(prog.Number, program); + } + + CreateEthernetStatusFeedbacks(); + UpdateEthernetStatusFeeedbacks(); + + _uptimePollTimer = new CTimer(PollUptime,null,0, UptimePollTime); + + SystemMonitor.ProgramChange += SystemMonitor_ProgramChange; + SystemMonitor.TimeZoneInformation.TimeZoneChange += TimeZoneInformation_TimeZoneChange; + CrestronEnvironment.EthernetEventHandler += CrestronEnvironmentOnEthernetEventHandler; + CrestronEnvironment.ProgramStatusEventHandler += CrestronEnvironmentOnProgramStatusEventHandler; + } + + private void CrestronEnvironmentOnProgramStatusEventHandler(eProgramStatusEventType programEventType) + { + if (programEventType != eProgramStatusEventType.Stopping) return; + + _uptimePollTimer.Stop(); + _uptimePollTimer.Dispose(); + _uptimePollTimer = null; + } + + private void PollUptime(object obj) + { + var consoleResponse = string.Empty; + + CrestronConsole.SendControlSystemCommand("uptime", ref consoleResponse); + + ParseUptime(consoleResponse); + + UptimeFeedback.FireUpdate(); + LastStartFeedback.FireUpdate(); + } + + private void ParseUptime(string response) + { + var splitString = response.Trim().Split('\r', '\n'); + + var lastStartRaw = splitString.FirstOrDefault(o => o.Contains("started")); + var uptimeRaw = splitString.FirstOrDefault(o => o.Contains("running")); + + if (!String.IsNullOrEmpty(lastStartRaw)) + { + var lastStartIndex = lastStartRaw.IndexOf(':'); + _lastStart = lastStartRaw.Substring(lastStartIndex + 1).Trim(); + } + + if (String.IsNullOrEmpty(uptimeRaw)) return; + var forIndex = uptimeRaw.IndexOf("for", StringComparison.Ordinal); + + //4 => "for " to get what's on the right + _uptime = uptimeRaw.Substring(forIndex + 4); + } + + private static void ProcessorReboot() + { + if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Server) return; + + var response = string.Empty; + CrestronConsole.SendControlSystemCommand("reboot", ref response); + } + + private static void ProgramReset(uint index) + { + if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Server) return; + + if (index <= 0 || index > 10) return; + + var cmd = string.Format("progreset -p:{0}", index); + + var response = string.Empty; + CrestronConsole.SendControlSystemCommand(cmd, ref response); + } + + private void CrestronEnvironmentOnEthernetEventHandler(EthernetEventArgs ethernetEventArgs) + { + if (ethernetEventArgs.EthernetEventType != eEthernetEventType.LinkUp) return; + + foreach (var fb in EthernetStatusFeedbackCollection) + { + fb.Value.UpdateEthernetStatus(); + } + } + + private void CreateEthernetStatusFeedbacks() + { + EthernetStatusFeedbackCollection = new Dictionary(); + + Debug.Console(2, "Creating {0} EthernetStatusFeedbacks", InitialParametersClass.NumberOfEthernetInterfaces); + + for (short i = 0; i < InitialParametersClass.NumberOfEthernetInterfaces; i++) + { + Debug.Console(2, "Creating EthernetStatusFeedback for Interface {0}", i); + var ethernetInterface = new EthernetStatusFeedbacks(i); + EthernetStatusFeedbackCollection.Add(i, ethernetInterface); + } + } + + private void UpdateEthernetStatusFeeedbacks() + { + foreach (var iface in EthernetStatusFeedbackCollection) + { + iface.Value.CurrentIpAddressFeedback.FireUpdate(); + iface.Value.CurrentSubnetMaskFeedback.FireUpdate(); + iface.Value.CurrentDefaultGatewayFeedback.FireUpdate(); + iface.Value.StaticIpAddressFeedback.FireUpdate(); + iface.Value.StaticSubnetMaskFeedback.FireUpdate(); + iface.Value.StaticDefaultGatewayFeedback.FireUpdate(); + iface.Value.HostNameFeedback.FireUpdate(); + iface.Value.DnsServerFeedback.FireUpdate(); + iface.Value.DomainFeedback.FireUpdate(); + iface.Value.DhcpStatusFeedback.FireUpdate(); + iface.Value.MacAddressFeedback.FireUpdate(); + } + } + + /// + /// Gets data in separate thread + /// + private void RefreshSystemMonitorData() + { + // this takes a while, launch a new thread + CrestronInvoke.BeginInvoke(UpdateFeedback); + } + + private void UpdateFeedback(object o) + { + TimeZoneFeedback.FireUpdate(); + TimeZoneTextFeedback.FireUpdate(); + IoControllerVersionFeedback.FireUpdate(); + SnmpVersionFeedback.FireUpdate(); + BaCnetAppVersionFeedback.FireUpdate(); + ControllerVersionFeedback.FireUpdate(); + SerialNumberFeedback.FireUpdate(); + ModelFeedback.FireUpdate(); + + IsApplianceFeedback.FireUpdate(); + IsServerFeedback.FireUpdate(); + + OnSystemMonitorPropertiesChanged(); + } + + private void OnSystemMonitorPropertiesChanged() + { + var handler = SystemMonitorPropertiesChanged; + if (handler != null) + { + handler(this, new EventArgs()); + } + } + + public override bool CustomActivate() + { + RefreshSystemMonitorData(); + + return base.CustomActivate(); + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new SystemMonitorJoinMap(joinStart); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + else + { + Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + } + + Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.Console(2, this, "Linking API starting at join: {0}", joinStart); + + TimeZoneFeedback.LinkInputSig(trilist.UShortInput[joinMap.TimeZone.JoinNumber]); + TimeZoneTextFeedback.LinkInputSig(trilist.StringInput[joinMap.TimeZoneName.JoinNumber]); + + IoControllerVersionFeedback.LinkInputSig(trilist.StringInput[joinMap.IOControllerVersion.JoinNumber]); + SnmpVersionFeedback.LinkInputSig(trilist.StringInput[joinMap.SnmpAppVersion.JoinNumber]); + BaCnetAppVersionFeedback.LinkInputSig(trilist.StringInput[joinMap.BACnetAppVersion.JoinNumber]); + ControllerVersionFeedback.LinkInputSig(trilist.StringInput[joinMap.ControllerVersion.JoinNumber]); + SerialNumberFeedback.LinkInputSig(trilist.StringInput[joinMap.SerialNumber.JoinNumber]); + ModelFeedback.LinkInputSig(trilist.StringInput[joinMap.Model.JoinNumber]); + UptimeFeedback.LinkInputSig(trilist.StringInput[joinMap.Uptime.JoinNumber]); + LastStartFeedback.LinkInputSig(trilist.StringInput[joinMap.LastBoot.JoinNumber]); + + trilist.SetSigHeldAction(joinMap.ProcessorReboot.JoinNumber, 10000, ProcessorReboot); + + IsApplianceFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsAppliance.JoinNumber]); + IsServerFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsServer.JoinNumber]); + + // iterate the program status feedback collection and map all the joins + LinkProgramInfoJoins(this, trilist, joinMap); + + LinkEthernetInfoJoins(this, trilist, joinMap); + } + + private static void LinkEthernetInfoJoins(SystemMonitorController systemMonitorController, BasicTriList trilist, SystemMonitorJoinMap joinMap) + { + uint ethernetSlotJoinStart = 0; + foreach (var fb in systemMonitorController.EthernetStatusFeedbackCollection) + { + fb.Value.CurrentIpAddressFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.CurrentIpAddress.JoinNumber]); + fb.Value.CurrentSubnetMaskFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.CurrentSubnetMask.JoinNumber]); + fb.Value.CurrentDefaultGatewayFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.CurrentDefaultGateway.JoinNumber]); + fb.Value.StaticIpAddressFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.StaticIpAddress.JoinNumber]); + fb.Value.StaticSubnetMaskFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.StaticSubnetMask.JoinNumber]); + fb.Value.StaticDefaultGatewayFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.StaticDefaultGateway.JoinNumber]); + fb.Value.HostNameFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.HostName.JoinNumber]); + fb.Value.MacAddressFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.MacAddress.JoinNumber]); + fb.Value.DomainFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.Domain.JoinNumber]); + fb.Value.DnsServerFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.DnsServer.JoinNumber]); + fb.Value.DhcpStatusFeedback.LinkInputSig(trilist.StringInput[ethernetSlotJoinStart + joinMap.DhcpStatus.JoinNumber]); + + ethernetSlotJoinStart += joinMap.EthernetOffsetJoin.JoinNumber; + } + } + + private static void LinkProgramInfoJoins(SystemMonitorController systemMonitorController, BasicTriList trilist, + SystemMonitorJoinMap joinMap) + { + uint programSlotJoinStart = 0; + + foreach (var p in systemMonitorController.ProgramStatusFeedbackCollection) + { + var programNumber = p.Value.Program.Number; + + trilist.SetBoolSigAction(programSlotJoinStart + joinMap.ProgramStart.JoinNumber, + b => SystemMonitor.ProgramCollection[programNumber].OperatingState = eProgramOperatingState.Start); + p.Value.ProgramStartedFeedback.LinkInputSig(trilist.BooleanInput[programSlotJoinStart + joinMap.ProgramStart.JoinNumber]); + + trilist.SetBoolSigAction(programSlotJoinStart + joinMap.ProgramStop.JoinNumber, + b => SystemMonitor.ProgramCollection[programNumber].OperatingState = eProgramOperatingState.Stop); + p.Value.ProgramStoppedFeedback.LinkInputSig(trilist.BooleanInput[programSlotJoinStart + joinMap.ProgramStop.JoinNumber]); + + trilist.SetBoolSigAction(programSlotJoinStart + joinMap.ProgramRegister.JoinNumber, + b => SystemMonitor.ProgramCollection[programNumber].RegistrationState = eProgramRegistrationState.Register); + p.Value.ProgramRegisteredFeedback.LinkInputSig( + trilist.BooleanInput[programSlotJoinStart + joinMap.ProgramRegister.JoinNumber]); + + trilist.SetBoolSigAction(programSlotJoinStart + joinMap.ProgramUnregister.JoinNumber, + b => SystemMonitor.ProgramCollection[programNumber].RegistrationState = eProgramRegistrationState.Unregister); + p.Value.ProgramUnregisteredFeedback.LinkInputSig( + trilist.BooleanInput[programSlotJoinStart + joinMap.ProgramUnregister.JoinNumber]); + + p.Value.ProgramNameFeedback.LinkInputSig(trilist.StringInput[programSlotJoinStart + joinMap.ProgramName.JoinNumber]); + p.Value.ProgramCompileTimeFeedback.LinkInputSig( + trilist.StringInput[programSlotJoinStart + joinMap.ProgramCompiledTime.JoinNumber]); + p.Value.CrestronDataBaseVersionFeedback.LinkInputSig( + trilist.StringInput[programSlotJoinStart + joinMap.ProgramCrestronDatabaseVersion.JoinNumber]); + p.Value.EnvironmentVersionFeedback.LinkInputSig( + trilist.StringInput[programSlotJoinStart + joinMap.ProgramEnvironmentVersion.JoinNumber]); + p.Value.AggregatedProgramInfoFeedback.LinkInputSig( + trilist.StringInput[programSlotJoinStart + joinMap.AggregatedProgramInfo.JoinNumber]); + + trilist.SetSigHeldAction(programSlotJoinStart + joinMap.ProgramReset.JoinNumber, 10000, () => ProgramReset(programNumber)); + + programSlotJoinStart = programSlotJoinStart + joinMap.ProgramOffsetJoin.JoinSpan; + } + } + + //// Sets the time zone + //public void SetTimeZone(int timeZone) + //{ + // SystemMonitor.TimeZoneInformation.TimeZoneNumber = timeZone; + //} + + /// + /// Responds to program change events and triggers the appropriate feedbacks to update + /// + /// + /// + private void SystemMonitor_ProgramChange(Program sender, ProgramEventArgs args) + { + Debug.Console(2, this, "Program Change Detected for slot: {0}", sender.Number); + Debug.Console(2, this, "Event Type: {0}", args.EventType); + + var program = ProgramStatusFeedbackCollection[sender.Number]; + + switch (args.EventType) + { + case eProgramChangeEventType.OperatingState: + program.ProgramStartedFeedback.FireUpdate(); + program.ProgramStoppedFeedback.FireUpdate(); + program.ProgramInfo.OperatingState = args.OperatingState; + if (args.OperatingState == eProgramOperatingState.Start) + program.GetProgramInfo(); + else + { + program.AggregatedProgramInfoFeedback.FireUpdate(); + program.OnProgramInfoChanged(); + } + break; + case eProgramChangeEventType.RegistrationState: + program.ProgramRegisteredFeedback.FireUpdate(); + program.ProgramUnregisteredFeedback.FireUpdate(); + program.ProgramInfo.RegistrationState = args.RegistrationState; + program.GetProgramInfo(); + break; + } + } + + /// + /// Responds to time zone changes and updates the appropriate feedbacks + /// + /// + private void TimeZoneInformation_TimeZoneChange(TimeZoneEventArgs args) + { + Debug.Console(2, this, "Time Zone Change Detected."); + TimeZoneFeedback.FireUpdate(); + TimeZoneTextFeedback.FireUpdate(); + + OnSystemMonitorPropertiesChanged(); + } + + public class EthernetStatusFeedbacks + { + public StringFeedback HostNameFeedback { get; protected set; } + public StringFeedback DnsServerFeedback { get; protected set; } + public StringFeedback DomainFeedback { get; protected set; } + public StringFeedback MacAddressFeedback { get; protected set; } + public StringFeedback DhcpStatusFeedback { get; protected set; } + + public StringFeedback CurrentIpAddressFeedback { get; protected set; } + public StringFeedback CurrentSubnetMaskFeedback { get; protected set; } + public StringFeedback CurrentDefaultGatewayFeedback { get; protected set; } + + public StringFeedback StaticIpAddressFeedback { get; protected set; } + public StringFeedback StaticSubnetMaskFeedback { get; protected set; } + public StringFeedback StaticDefaultGatewayFeedback { get; protected set; } + + public EthernetStatusFeedbacks(short adapterIndex) + { + Debug.Console(2, "Ethernet Information for interface {0}", adapterIndex); + Debug.Console(2, "Adapter Index: {1} Hostname: {0}", CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, adapterIndex), adapterIndex); + Debug.Console(2, "Adapter Index: {1} Current IP Address: {0}", CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, adapterIndex), adapterIndex); + Debug.Console(2, "Adapter Index: {1} Current Subnet Mask: {0}", CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, adapterIndex), adapterIndex); + Debug.Console(2, "Adapter Index: {1} Current Router: {0}", CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_ROUTER, adapterIndex), adapterIndex); + Debug.Console(2, "Adapter Index: {1} Static IP Address: {0}", CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_STATIC_IPADDRESS, adapterIndex), adapterIndex); + Debug.Console(2, "Adapter Index: {1} Static Subnet Mask: {0}", CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_STATIC_IPMASK, adapterIndex), adapterIndex); + Debug.Console(2, "Adapter Index: {1} Static Router: {0}", CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_STATIC_ROUTER, adapterIndex), adapterIndex); + Debug.Console(2, "Adapter Index: {1} DNS Servers: {0}", CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DNS_SERVER, adapterIndex), adapterIndex); + Debug.Console(2, "Adapter Index: {1} DHCP State: {0}", CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_DHCP_STATE, adapterIndex), adapterIndex); + Debug.Console(2, "Adapter Index: {1} Domain Name: {0}", CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DOMAIN_NAME, adapterIndex), adapterIndex); + Debug.Console(2, "Adapter Index: {1} MAC Address: {0}", CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, adapterIndex), adapterIndex); + HostNameFeedback = + new StringFeedback( + () => + CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, adapterIndex)); + + CurrentIpAddressFeedback = + new StringFeedback( + () => + CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, adapterIndex)); + CurrentDefaultGatewayFeedback = + new StringFeedback( + () => + CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_ROUTER, adapterIndex)); + CurrentSubnetMaskFeedback = + new StringFeedback( + () => + CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, adapterIndex)); + StaticIpAddressFeedback = + new StringFeedback( + () => + CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, adapterIndex)); + StaticDefaultGatewayFeedback = + new StringFeedback( + () => + CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_ROUTER, adapterIndex)); + StaticSubnetMaskFeedback = + new StringFeedback( + () => + CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, adapterIndex)); + DomainFeedback = + new StringFeedback( + () => + CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DOMAIN_NAME, adapterIndex)); + DnsServerFeedback = + new StringFeedback( + () => + CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DNS_SERVER, adapterIndex)); + MacAddressFeedback = + new StringFeedback( + () => + CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, adapterIndex)); + + DhcpStatusFeedback = new StringFeedback( + () => + CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_DHCP_STATE, adapterIndex)); + } + + public void UpdateEthernetStatus() + { + HostNameFeedback.FireUpdate(); + CurrentIpAddressFeedback.FireUpdate(); + CurrentSubnetMaskFeedback.FireUpdate(); + CurrentDefaultGatewayFeedback.FireUpdate(); + StaticIpAddressFeedback.FireUpdate(); + StaticSubnetMaskFeedback.FireUpdate(); + StaticDefaultGatewayFeedback.FireUpdate(); + DomainFeedback.FireUpdate(); + DnsServerFeedback.FireUpdate(); + MacAddressFeedback.FireUpdate(); + DhcpStatusFeedback.FireUpdate(); + } + } + + + public class ProgramStatusFeedbacks + { + public event EventHandler ProgramInfoChanged; + + public Program Program; + + public ProgramInfo ProgramInfo { get; set; } + + public BoolFeedback ProgramStartedFeedback; + public BoolFeedback ProgramStoppedFeedback; + public BoolFeedback ProgramRegisteredFeedback; + public BoolFeedback ProgramUnregisteredFeedback; + + public StringFeedback ProgramNameFeedback; + public StringFeedback ProgramCompileTimeFeedback; + public StringFeedback CrestronDataBaseVersionFeedback; + // SIMPL windows version + public StringFeedback EnvironmentVersionFeedback; + public StringFeedback AggregatedProgramInfoFeedback; + + public ProgramStatusFeedbacks(Program program) + { + ProgramInfo = new ProgramInfo(program.Number); + + Program = program; + + ProgramInfo.OperatingState = Program.OperatingState; + ProgramInfo.RegistrationState = Program.RegistrationState; + + ProgramStartedFeedback = new BoolFeedback(() => Program.OperatingState == eProgramOperatingState.Start); + ProgramStartedFeedback.FireUpdate(); + + ProgramStoppedFeedback = new BoolFeedback(() => Program.OperatingState == eProgramOperatingState.Stop); + ProgramStoppedFeedback.FireUpdate(); + + ProgramRegisteredFeedback = + new BoolFeedback(() => Program.RegistrationState == eProgramRegistrationState.Register); + ProgramRegisteredFeedback.FireUpdate(); + + ProgramUnregisteredFeedback = + new BoolFeedback(() => Program.RegistrationState == eProgramRegistrationState.Unregister); + ProgramUnregisteredFeedback.FireUpdate(); + + ProgramNameFeedback = new StringFeedback(() => ProgramInfo.ProgramFile); + CrestronDataBaseVersionFeedback = new StringFeedback(() => ProgramInfo.CrestronDb); + EnvironmentVersionFeedback = new StringFeedback(() => ProgramInfo.Environment); + ProgramCompileTimeFeedback = new StringFeedback(() => ProgramInfo.CompileTime); + AggregatedProgramInfoFeedback = new StringFeedback(() => JsonConvert.SerializeObject(ProgramInfo)); + + GetProgramInfo(); + } + + /// + /// Retrieves information about a running program + /// + public void GetProgramInfo() + { + CrestronInvoke.BeginInvoke(GetProgramInfo); + } + + private void GetProgramInfo(object o) + { + Debug.Console(2, "Attempting to get program info for slot: {0}", Program.Number); + + string response = null; + + if (Program.RegistrationState == eProgramRegistrationState.Unregister || Program.OperatingState == eProgramOperatingState.Stop) + { + Debug.Console(2, "Program {0} not registered. Setting default values for program information.", + Program.Number); + + ProgramInfo = new ProgramInfo(Program.Number) + { + OperatingState = Program.OperatingState, + RegistrationState = Program.RegistrationState + }; + + return; + } + + var success = CrestronConsole.SendControlSystemCommand( + string.Format("progcomments:{0}", Program.Number), ref response); + + if (!success) + { + Debug.Console(2, "Progcomments Attempt Unsuccessful for slot: {0}", Program.Number); + UpdateFeedbacks(); + return; + } + + if (response.ToLower().Contains("bad or incomplete")) + { + Debug.Console(2, + "Program in slot {0} not running. Setting default ProgramInfo for slot: {0}", + Program.Number); + + // Assume no valid program info. Constructing a new object will wipe all properties + ProgramInfo = new ProgramInfo(Program.Number) + { + OperatingState = Program.OperatingState, + RegistrationState = Program.RegistrationState + }; + + UpdateFeedbacks(); + + return; + } + + + // Shared properteis + ProgramInfo.ProgramFile = ParseConsoleData(response, "Program File", ": ", "\n"); + ProgramInfo.CompilerRevision = ParseConsoleData(response, "Compiler Rev", ": ", "\n"); + ProgramInfo.CompileTime = ParseConsoleData(response, "Compiled On", ": ", "\n"); + ProgramInfo.Include4Dat = ParseConsoleData(response, "Include4.dat", ": ", "\n"); + + + if (ProgramInfo.ProgramFile.Contains(".dll")) + { + // SSP Program + ProgramInfo.FriendlyName = ParseConsoleData(response, "Friendly Name", ": ", "\n"); + ProgramInfo.ApplicationName = ParseConsoleData(response, "Application Name", ": ", "\n"); + ProgramInfo.ProgramTool = ParseConsoleData(response, "Program Tool", ": ", "\n"); + ProgramInfo.MinFirmwareVersion = ParseConsoleData(response, "Min Firmware Version", ": ", + "\n"); + ProgramInfo.PlugInVersion = ParseConsoleData(response, "PlugInVersion", ": ", "\n"); + + ProgramInfo.ProgramFile += string.Format(" {0}.{1}.{2}", + ProgramInfo.CompilerRevisionInfo.Major, + ProgramInfo.CompilerRevisionInfo.Minor, + ProgramInfo.CompilerRevisionInfo.Build); + + ProgramInfo.Environment = ProgramInfo.ProgramTool; + } + else if (ProgramInfo.ProgramFile.Contains(".smw")) + { + // SIMPL Windows Program + ProgramInfo.FriendlyName = ParseConsoleData(response, "Friendly Name", ":", "\n"); + ProgramInfo.SystemName = ParseConsoleData(response, "System Name", ": ", "\n"); + ProgramInfo.CrestronDb = ParseConsoleData(response, "CrestronDB", ": ", "\n"); + ProgramInfo.Environment = ParseConsoleData(response, "Source Env", ": ", "\n"); + ProgramInfo.Programmer = ParseConsoleData(response, "Programmer", ": ", "\n"); + } + Debug.Console(2, "Program info for slot {0} successfully updated", Program.Number); + + UpdateFeedbacks(); + } + + private void UpdateFeedbacks() + { + ProgramNameFeedback.FireUpdate(); + ProgramCompileTimeFeedback.FireUpdate(); + CrestronDataBaseVersionFeedback.FireUpdate(); + EnvironmentVersionFeedback.FireUpdate(); + + AggregatedProgramInfoFeedback.FireUpdate(); + + OnProgramInfoChanged(); + } + + public void OnProgramInfoChanged() + { + //Debug.Console(1, "Firing ProgramInfoChanged for slot: {0}", Program.Number); + var handler = ProgramInfoChanged; + if (handler != null) + { + handler(this, new ProgramInfoEventArgs(ProgramInfo)); + } + } + + private string ParseConsoleData(string data, string line, string startString, string endString) + { + var outputData = ""; + + if (data.Length <= 0) return outputData; + + try + { + //Debug.Console(2, "ParseConsoleData Data: {0}, Line {1}, startStirng {2}, endString {3}", data, line, startString, endString); + var linePosition = data.IndexOf(line, StringComparison.Ordinal); + var startPosition = data.IndexOf(startString, linePosition, StringComparison.Ordinal) + + startString.Length; + var endPosition = data.IndexOf(endString, startPosition, StringComparison.Ordinal); + outputData = data.Substring(startPosition, endPosition - startPosition).Trim(); + //Debug.Console(2, "ParseConsoleData Return: {0}", outputData); + } + catch (Exception e) + { + Debug.Console(1, "Error Parsing Console Data:\r{0}", e); + } + + return outputData; + } + } + } + + /// + /// Class for serializing program slot information + /// + public class ProgramInfo + { + // Shared properties + + [JsonProperty("programNumber")] + public uint ProgramNumber { get; private set; } + + [JsonConverter(typeof (StringEnumConverter))] + [JsonProperty("operatingState")] + public eProgramOperatingState OperatingState { get; set; } + + [JsonConverter(typeof (StringEnumConverter))] + [JsonProperty("registrationState")] + public eProgramRegistrationState RegistrationState { get; set; } + + [JsonProperty("programFile")] + public string ProgramFile { get; set; } + + [JsonProperty("friendlyName")] + public string FriendlyName { get; set; } + + [JsonProperty("compilerRevision")] + public string CompilerRevision { get; set; } + + [JsonIgnore] + public Version CompilerRevisionInfo + { + get + { + return new Version(CompilerRevision); + } + } + + [JsonProperty("compileTime")] + public string CompileTime { get; set; } + + [JsonProperty("include4Dat")] + public string Include4Dat { get; set; } + + // SIMPL Windows properties + [JsonProperty("systemName")] + public string SystemName { get; set; } + + [JsonProperty("crestronDb")] + public string CrestronDb { get; set; } + + [JsonProperty("environment")] + public string Environment { get; set; } + + [JsonProperty("programmer")] + public string Programmer { get; set; } + + + // SSP Properties + [JsonProperty("applicationName")] + public string ApplicationName { get; set; } + + [JsonProperty("programTool")] + public string ProgramTool { get; set; } + + [JsonProperty("minFirmwareVersion")] + public string MinFirmwareVersion { get; set; } + + [JsonProperty("plugInVersion")] + public string PlugInVersion { get; set; } + + public ProgramInfo(uint number) + { + ProgramNumber = number; + + ProgramFile = ""; + FriendlyName = ""; + CompilerRevision = ""; + CompileTime = ""; + Include4Dat = ""; + + SystemName = ""; + CrestronDb = ""; + Environment = ""; + Programmer = ""; + + ApplicationName = ""; + ProgramTool = ""; + MinFirmwareVersion = ""; + PlugInVersion = ""; + } + } + + public class ProgramInfoEventArgs : EventArgs + { + public ProgramInfo ProgramInfo; + + public ProgramInfoEventArgs(ProgramInfo progInfo) + { + ProgramInfo = progInfo; + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/CenOdtOccupancySensorBaseController.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/CenOdtOccupancySensorBaseController.cs similarity index 97% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/CenOdtOccupancySensorBaseController.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/CenOdtOccupancySensorBaseController.cs index eae2f993..8da3fc24 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/CenOdtOccupancySensorBaseController.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/CenOdtOccupancySensorBaseController.cs @@ -1,775 +1,775 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Resources; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.GeneralIO; -using Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.Core -{ - [Description("Wrapper class for CEN-ODT-C-POE")] - [ConfigSnippet("\"properties\": {\"control\": {\"method\": \"cresnet\",\"cresnetId\": \"97\"},\"enablePir\": true,\"enableLedFlash\": true,\"enableRawStates\":true,\"remoteTimeout\": 30,\"internalPhotoSensorMinChange\": 0,\"externalPhotoSensorMinChange\": 0,\"enableUsA\": true,\"enableUsB\": true,\"orWhenVacatedState\": true}")] - public class CenOdtOccupancySensorBaseController : CrestronGenericBridgeableBaseDevice, IOccupancyStatusProvider - { - public CenOdtCPoe OccSensor { get; private set; } - - public GlsOccupancySensorPropertiesConfig PropertiesConfig { get; private set; } - - public BoolFeedback RoomIsOccupiedFeedback { get; private set; } - - public BoolFeedback GraceOccupancyDetectedFeedback { get; private set; } - - public BoolFeedback RawOccupancyFeedback { get; private set; } - - public BoolFeedback PirSensorEnabledFeedback { get; private set; } - - public BoolFeedback LedFlashEnabledFeedback { get; private set; } - - public BoolFeedback ShortTimeoutEnabledFeedback { get; private set; } - - public IntFeedback PirSensitivityInVacantStateFeedback { get; private set; } - - public IntFeedback PirSensitivityInOccupiedStateFeedback { get; private set; } - - public IntFeedback CurrentTimeoutFeedback { get; private set; } - - public IntFeedback RemoteTimeoutFeedback { get; private set; } - - public IntFeedback InternalPhotoSensorValue { get; set; } - - public IntFeedback ExternalPhotoSensorValue { get; set; } - - public BoolFeedback OrWhenVacatedFeedback { get; private set; } - - public BoolFeedback AndWhenVacatedFeedback { get; private set; } - - public BoolFeedback UltrasonicAEnabledFeedback { get; private set; } - - public BoolFeedback UltrasonicBEnabledFeedback { get; private set; } - - public IntFeedback UltrasonicSensitivityInVacantStateFeedback { get; private set; } - - public IntFeedback UltrasonicSensitivityInOccupiedStateFeedback { get; private set; } - - public BoolFeedback RawOccupancyPirFeedback { get; private set; } - - public BoolFeedback RawOccupancyUsFeedback { get; private set; } - - public BoolFeedback IdentityModeFeedback { get; private set; } - - // Debug properties - public bool InTestMode { get; private set; } - - public bool TestRoomIsOccupiedFeedback { get; private set; } - - public Func RoomIsOccupiedFeedbackFunc - { - get - { - return () => InTestMode ? TestRoomIsOccupiedFeedback : OccSensor.OccupancyDetectedFeedback.BoolValue; - } - } - - public CenOdtOccupancySensorBaseController(string key, string name, CenOdtCPoe sensor, GlsOccupancySensorPropertiesConfig config) - : base(key, name, sensor) - { - PropertiesConfig = config; - - OccSensor = sensor; - - RoomIsOccupiedFeedback = new BoolFeedback(RoomIsOccupiedFeedbackFunc); - - PirSensorEnabledFeedback = new BoolFeedback(() => OccSensor.PassiveInfraredSensorEnabledFeedback.BoolValue); - - LedFlashEnabledFeedback = new BoolFeedback(() => OccSensor.LedFlashEnabledFeedback.BoolValue); - - ShortTimeoutEnabledFeedback = new BoolFeedback(() => OccSensor.ShortTimeoutEnabledFeedback.BoolValue); - - PirSensitivityInVacantStateFeedback = new IntFeedback(() => (int)OccSensor.PassiveInfraredSensorSensitivityInVacantStateFeedback); - - PirSensitivityInOccupiedStateFeedback = new IntFeedback(() => (int)OccSensor.PassiveInfraredSensorSensitivityInOccupiedStateFeedback); - - CurrentTimeoutFeedback = new IntFeedback(() => OccSensor.CurrentTimeoutFeedback.UShortValue); - - RemoteTimeoutFeedback = new IntFeedback(() => OccSensor.RemoteTimeout.UShortValue); - - GraceOccupancyDetectedFeedback = new BoolFeedback(() => OccSensor.GraceOccupancyDetectedFeedback.BoolValue); - - RawOccupancyFeedback = new BoolFeedback(() => OccSensor.RawOccupancyDetectedFeedback.BoolValue); - - InternalPhotoSensorValue = new IntFeedback(() => OccSensor.InternalPhotoSensorValueFeedback.UShortValue); - - //ExternalPhotoSensorValue = new IntFeedback(() => OccSensor.ex.UShortValue); - - AndWhenVacatedFeedback = new BoolFeedback(() => OccSensor.AndWhenVacatedFeedback.BoolValue); - - OrWhenVacatedFeedback = new BoolFeedback(() => OccSensor.OrWhenVacatedFeedback.BoolValue); - - UltrasonicAEnabledFeedback = new BoolFeedback(() => OccSensor.UltrasonicSensorSideAEnabledFeedback.BoolValue); - - UltrasonicBEnabledFeedback = new BoolFeedback(() => OccSensor.UltrasonicSensorSideBEnabledFeedback.BoolValue); - - RawOccupancyPirFeedback = new BoolFeedback(() => OccSensor.RawOccupancyDetectedByPassiveInfraredSensorFeedback.BoolValue); - - RawOccupancyUsFeedback = new BoolFeedback(() => OccSensor.RawOccupancyDetectedByUltrasonicSensorFeedback.BoolValue); - - IdentityModeFeedback = new BoolFeedback(()=>OccSensor.IdentityModeOnFeedback.BoolValue); - - UltrasonicSensitivityInVacantStateFeedback = new IntFeedback(() => (int)OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback); - - UltrasonicSensitivityInOccupiedStateFeedback = new IntFeedback(() => (int)OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback); - - OccSensor.BaseEvent += new Crestron.SimplSharpPro.BaseEventHandler(OccSensor_BaseEvent); - - OccSensor.CenOccupancySensorChange += new GenericEventHandler(OccSensor_CenOccupancySensorChange); - - AddPostActivationAction(() => - { - OccSensor.OnlineStatusChange += (o, a) => - { - if (a.DeviceOnLine) - { - ApplySettingsToSensorFromConfig(); - } - }; - - if (OccSensor.IsOnline) - { - ApplySettingsToSensorFromConfig(); - - } - }); - } - - /// - /// Applies any sensor settings defined in config - /// - protected virtual void ApplySettingsToSensorFromConfig() - { - Debug.Console(1, this, "Checking config for settings to apply"); - - if (PropertiesConfig.EnablePir != null) - { - SetPirEnable((bool)PropertiesConfig.EnablePir); - } - - if (PropertiesConfig.EnableLedFlash != null) - { - SetLedFlashEnable((bool)PropertiesConfig.EnableLedFlash); - } - - if (PropertiesConfig.RemoteTimeout != null) - { - SetRemoteTimeout((ushort)PropertiesConfig.RemoteTimeout); - } - - if (PropertiesConfig.ShortTimeoutState != null) - { - SetShortTimeoutState((bool)PropertiesConfig.ShortTimeoutState); - } - - if (PropertiesConfig.EnableRawStates != null) - { - EnableRawStates((bool)PropertiesConfig.EnableRawStates); - } - - if (PropertiesConfig.InternalPhotoSensorMinChange != null) - { - SetInternalPhotoSensorMinChange((ushort)PropertiesConfig.InternalPhotoSensorMinChange); - } - - if (PropertiesConfig.EnableUsA != null) - { - SetUsAEnable((bool)PropertiesConfig.EnableUsA); - } - - if (PropertiesConfig.EnableUsB != null) - { - SetUsBEnable((bool)PropertiesConfig.EnableUsB); - } - - if (PropertiesConfig.OrWhenVacatedState != null) - { - SetOrWhenVacatedState((bool)PropertiesConfig.OrWhenVacatedState); - } - - if (PropertiesConfig.AndWhenVacatedState != null) - { - SetAndWhenVacatedState((bool)PropertiesConfig.AndWhenVacatedState); - } - - // TODO [ ] feature/cenoodtcpoe-sensor-sensitivity-configuration - if (PropertiesConfig.UsSensitivityOccupied != null) - { - SetUsSensitivityOccupied((ushort)PropertiesConfig.UsSensitivityOccupied); - } - - if (PropertiesConfig.UsSensitivityVacant != null) - { - SetUsSensitivityVacant((ushort)PropertiesConfig.UsSensitivityVacant); - } - - if (PropertiesConfig.PirSensitivityOccupied != null) - { - SetPirSensitivityOccupied((ushort)PropertiesConfig.PirSensitivityOccupied); - } - - if (PropertiesConfig.PirSensitivityVacant != null) - { - SetPirSensitivityVacant((ushort)PropertiesConfig.PirSensitivityVacant); - } - } - - /// - /// Catches events for feedbacks on the base class. Any extending wrapper class should call this delegate after it checks for it's own event IDs. - /// - /// - /// - protected virtual void OccSensor_CenOccupancySensorChange(object device, GenericEventArgs args) - { - if (args.EventId == GlsOccupancySensorBase.PirEnabledFeedbackEventId) - PirSensorEnabledFeedback.FireUpdate(); - else if (args.EventId == GlsOccupancySensorBase.LedFlashEnabledFeedbackEventId) - LedFlashEnabledFeedback.FireUpdate(); - else if (args.EventId == GlsOccupancySensorBase.ShortTimeoutEnabledFeedbackEventId) - ShortTimeoutEnabledFeedback.FireUpdate(); - else if (args.EventId == GlsOccupancySensorBase.PirSensitivityInOccupiedStateFeedbackEventId) - PirSensitivityInOccupiedStateFeedback.FireUpdate(); - else if (args.EventId == GlsOccupancySensorBase.PirSensitivityInVacantStateFeedbackEventId) - PirSensitivityInVacantStateFeedback.FireUpdate(); - else if (args.EventId == GlsOccupancySensorBase.RawOccupancyPirFeedbackEventId) - RawOccupancyPirFeedback.FireUpdate(); - else if (args.EventId == GlsOccupancySensorBase.RawOccupancyUsFeedbackEventId) - RawOccupancyUsFeedback.FireUpdate(); - } - - protected virtual void OccSensor_BaseEvent(Crestron.SimplSharpPro.GenericBase device, Crestron.SimplSharpPro.BaseEventArgs args) - { - Debug.Console(2, this, "PoEOccupancySensorChange EventId: {0}", args.EventId); - - if (args.EventId == Crestron.SimplSharpPro.GeneralIO.GlsOccupancySensorBase.RoomOccupiedFeedbackEventId - || args.EventId == Crestron.SimplSharpPro.GeneralIO.GlsOccupancySensorBase.RoomVacantFeedbackEventId) - { - Debug.Console(1, this, "Occupancy State: {0}", OccSensor.OccupancyDetectedFeedback.BoolValue); - RoomIsOccupiedFeedback.FireUpdate(); - } - else if (args.EventId == GlsOccupancySensorBase.TimeoutFeedbackEventId) - CurrentTimeoutFeedback.FireUpdate(); - else if (args.EventId == GlsOccupancySensorBase.TimeoutLocalFeedbackEventId) - RemoteTimeoutFeedback.FireUpdate(); - else if (args.EventId == GlsOccupancySensorBase.GraceOccupancyDetectedFeedbackEventId) - GraceOccupancyDetectedFeedback.FireUpdate(); - else if (args.EventId == GlsOccupancySensorBase.RawOccupancyFeedbackEventId) - RawOccupancyFeedback.FireUpdate(); - else if (args.EventId == GlsOccupancySensorBase.InternalPhotoSensorValueFeedbackEventId) - InternalPhotoSensorValue.FireUpdate(); - else if (args.EventId == GlsOccupancySensorBase.ExternalPhotoSensorValueFeedbackEventId) - ExternalPhotoSensorValue.FireUpdate(); - else if (args.EventId == GlsOccupancySensorBase.AndWhenVacatedFeedbackEventId) - AndWhenVacatedFeedback.FireUpdate(); - else if (args.EventId == GlsOccupancySensorBase.OrWhenVacatedFeedbackEventId) - OrWhenVacatedFeedback.FireUpdate(); - else if (args.EventId == GlsOccupancySensorBase.UsAEnabledFeedbackEventId) - UltrasonicAEnabledFeedback.FireUpdate(); - else if (args.EventId == GlsOccupancySensorBase.UsBEnabledFeedbackEventId) - UltrasonicBEnabledFeedback.FireUpdate(); - else if (args.EventId == GlsOccupancySensorBase.UsSensitivityInOccupiedStateFeedbackEventId) - UltrasonicSensitivityInOccupiedStateFeedback.FireUpdate(); - else if (args.EventId == GlsOccupancySensorBase.UsSensitivityInVacantStateFeedbackEventId) - UltrasonicSensitivityInVacantStateFeedback.FireUpdate(); - } - - public void SetTestMode(bool mode) - { - InTestMode = mode; - - Debug.Console(1, this, "In Mock Mode: '{0}'", InTestMode); - } - - public void SetTestOccupiedState(bool state) - { - if (!InTestMode) - Debug.Console(1, "Mock mode not enabled"); - else - { - TestRoomIsOccupiedFeedback = state; - - RoomIsOccupiedFeedback.FireUpdate(); - } - } - - /// - /// Sets the identity mode on or off - /// - /// - public void SetIdentityMode(bool state) - { - if (state) - OccSensor.IdentityModeOn(); - else - OccSensor.IdentityModeOff(); - - Debug.Console(1, this, "Identity Mode: {0}", OccSensor.IdentityModeOnFeedback.BoolValue ? "On" : "Off"); - } - - /// - /// Enables or disables the PIR sensor - /// - /// - public void SetPirEnable(bool state) - { - if (state) - { - OccSensor.EnablePassiveInfraredSensor(); - } - else - { - OccSensor.DisablePassiveInfraredSensor(); - } - } - - /// - /// Enables or disables the LED Flash - /// - /// - public void SetLedFlashEnable(bool state) - { - if (state) - { - OccSensor.EnableLedFlash(); - } - else - { - OccSensor.DisableLedFlash(); - } - } - - /// - /// Enables or disables short timeout based on state - /// - /// - public void SetShortTimeoutState(bool state) - { - if (state) - { - OccSensor.EnableShortTimeout(); - } - else - { - OccSensor.DisableShortTimeout(); - } - } - - public void IncrementPirSensitivityInOccupiedState(bool pressRelease) - { - if ((int)OccSensor.PassiveInfraredSensorSensitivityInOccupiedStateFeedback != 3) - { - OccSensor.PassiveInfraredSensorSensitivityInOccupiedState = OccSensor.PassiveInfraredSensorSensitivityInOccupiedStateFeedback + 1; - } - } - - public void DecrementPirSensitivityInOccupiedState(bool pressRelease) - { - if ((int)OccSensor.PassiveInfraredSensorSensitivityInOccupiedStateFeedback != 0) - { - OccSensor.PassiveInfraredSensorSensitivityInOccupiedState = OccSensor.PassiveInfraredSensorSensitivityInOccupiedStateFeedback - 1; - } - } - - public void IncrementPirSensitivityInVacantState(bool pressRelease) - { - if ((int)OccSensor.PassiveInfraredSensorSensitivityInVacantStateFeedback != 3) - { - OccSensor.PassiveInfraredSensorSensitivityInVacantState = OccSensor.PassiveInfraredSensorSensitivityInVacantStateFeedback + 1; - } - } - - public void DecrementPirSensitivityInVacantState(bool pressRelease) - { - if ((int)OccSensor.PassiveInfraredSensorSensitivityInVacantStateFeedback != 0) - { - OccSensor.PassiveInfraredSensorSensitivityInVacantState = OccSensor.PassiveInfraredSensorSensitivityInVacantStateFeedback - 1; - } - } - - public void IncrementUsSensitivityInOccupiedState(bool pressRelease) - { - if ((int)OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback < 3) - { - OccSensor.UltrasonicSensorSensitivityInOccupiedState = OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback + 1; - } - else if ((int)OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback > 4) - { - OccSensor.UltrasonicSensorSensitivityInOccupiedState = OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback - 1; - } - else if ((int)OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback == 4) - { - OccSensor.UltrasonicSensorSensitivityInOccupiedState = 0; - } - } - - public void DecrementUsSensitivityInOccupiedState(bool pressRelease) - { - if ((int)OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback > 0 - && (int)OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback < 4) - { - OccSensor.UltrasonicSensorSensitivityInOccupiedState = OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback - 1; - } - else if ((int)OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback > 3 - && (int)OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback < 7) - { - OccSensor.UltrasonicSensorSensitivityInOccupiedState = OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback + 1; - } - } - - public void IncrementUsSensitivityInVacantState(bool pressRelease) - { - if ((int)OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback < 3) - { - OccSensor.UltrasonicSensorSensitivityInVacantState = OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback + 1; - } - else if ((int)OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback > 4) - { - OccSensor.UltrasonicSensorSensitivityInVacantState = OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback - 1; - } - else if ((int)OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback == 4) - { - OccSensor.UltrasonicSensorSensitivityInVacantState = 0; - } - } - - public void DecrementUsSensitivityInVacantState(bool pressRelease) - { - if ((int)OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback > 0 - && (int)OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback < 4) - { - OccSensor.UltrasonicSensorSensitivityInVacantState = OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback - 1; - } - else if ((int)OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback > 3 - && (int)OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback < 7) - { - OccSensor.UltrasonicSensorSensitivityInVacantState = OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback + 1; - } - } - - public void ForceOccupied() - { - OccSensor.ForceOccupied(); - } - - public void ForceVacant() - { - OccSensor.ForceVacant(); - } - - public void EnableRawStates(bool state) - { - if (state) - { - OccSensor.EnableRawStates(); - } - else - OccSensor.DisableRawStates(); - } - - public void SetRemoteTimeout(ushort time) - { - OccSensor.RemoteTimeout.UShortValue = time; - } - - public void SetInternalPhotoSensorMinChange(ushort value) - { - OccSensor.InternalPhotoSensorMinimumChange.UShortValue = value; - } - - /// - /// Sets the OrWhenVacated state - /// - /// - public void SetOrWhenVacatedState(bool state) - { - if (state) - { - OccSensor.OrWhenVacated(); - } - } - - /// - /// Sets the AndWhenVacated state - /// - /// - public void SetAndWhenVacatedState(bool state) - { - if (state) - { - OccSensor.AndWhenVacated(); - } - } - - /// - /// Enables or disables the Ultrasonic A sensor - /// - /// - public void SetUsAEnable(bool state) - { - if (state) - { - OccSensor.EnableUltrasonicSensorSideA(); - } - else - { - OccSensor.DisableUltrasonicSensorSideA(); - } - } - - - /// - /// Enables or disables the Ultrasonic B sensor - /// - /// - public void SetUsBEnable(bool state) - { - if (state) - { - OccSensor.EnableUltrasonicSensorSideB(); - } - else - { - OccSensor.DisableUltrasonicSensorSideB(); - } - } - - /// - /// Sets the US sensor sensitivity for occupied state - /// - /// - public void SetUsSensitivityOccupied(ushort sensitivity) - { - var level = (eSensitivityLevel) sensitivity; - if (level == 0) return; - - OccSensor.UltrasonicSensorSensitivityInOccupiedState = level; - } - - /// - /// Sets the US sensor sensitivity for vacant state - /// - /// - public void SetUsSensitivityVacant(ushort sensitivity) - { - var level = (eSensitivityLevel)sensitivity; - if (level == 0) return; - - OccSensor.UltrasonicSensorSensitivityInVacantState = level; - } - - /// - /// Sets the PIR sensor sensitivity for occupied state - /// - /// - public void SetPirSensitivityOccupied(ushort sensitivity) - { - var level = (eSensitivityLevel)sensitivity; - if (level == 0) return; - - OccSensor.PassiveInfraredSensorSensitivityInOccupiedState = level; - } - - /// - /// Sets the PIR sensor sensitivity for vacant state - /// - /// - public void SetPirSensitivityVacant(ushort sensitivity) - { - var level = (eSensitivityLevel)sensitivity; - if (level == 0) return; - - OccSensor.PassiveInfraredSensorSensitivityInVacantState = level; - } - - /// - /// Method to print current settings to console - /// - public void GetSettings() - { - var dash = new string('*', 50); - CrestronConsole.PrintLine(string.Format("{0}\n", dash)); - - Debug.Console(0, this, "Vacancy Detected: {0}", - OccSensor.VacancyDetectedFeedback.BoolValue); - - Debug.Console(0, Key, "Timeout Current: {0} | Remote: {1}", - OccSensor.CurrentTimeoutFeedback.UShortValue, - OccSensor.RemoteTimeout.UShortValue); - - Debug.Console(0, Key, "Short Timeout Enabled: {0}", - OccSensor.ShortTimeoutEnabledFeedback.BoolValue); - - Debug.Console(0, Key, "PIR Sensor Enabled: {0} | Sensitivity Occupied: {1} | Sensitivity Vacant: {2}", - OccSensor.PassiveInfraredSensorEnabledFeedback.BoolValue, - OccSensor.PassiveInfraredSensorSensitivityInOccupiedStateFeedback, - OccSensor.PassiveInfraredSensorSensitivityInVacantStateFeedback); - - Debug.Console(0, Key, "Ultrasonic Enabled A: {0} | B: {1}", - OccSensor.UltrasonicSensorSideAEnabledFeedback.BoolValue, - OccSensor.UltrasonicSensorSideBEnabledFeedback.BoolValue); - - Debug.Console(0, Key, "Ultrasonic Sensitivity Occupied: {0} | Vacant: {1}", - OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback, - OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback); - - CrestronConsole.PrintLine(string.Format("{0}\n", dash)); - } - - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - LinkOccSensorToApi(this, trilist, joinStart, joinMapKey, bridge); - } - - protected void LinkOccSensorToApi(CenOdtOccupancySensorBaseController occController, - BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - CenOdtOccupancySensorBaseJoinMap joinMap = new CenOdtOccupancySensorBaseJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - Debug.Console(1, occController, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - occController.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.Online.JoinNumber]); - trilist.StringInput[joinMap.Name.JoinNumber].StringValue = occController.Name; - - trilist.OnlineStatusChange += new Crestron.SimplSharpPro.OnlineStatusChangeEventHandler((d, args) => - { - if (args.DeviceOnLine) - { - trilist.StringInput[joinMap.Name.JoinNumber].StringValue = occController.Name; - } - } - ); - - // Occupied status - trilist.SetSigTrueAction(joinMap.ForceOccupied.JoinNumber, new Action(() => occController.ForceOccupied())); - trilist.SetSigTrueAction(joinMap.ForceVacant.JoinNumber, new Action(() => occController.ForceVacant())); - occController.RoomIsOccupiedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RoomOccupiedFeedback.JoinNumber]); - occController.RoomIsOccupiedFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.RoomVacantFeedback.JoinNumber]); - occController.RawOccupancyFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyFeedback.JoinNumber]); - trilist.SetBoolSigAction(joinMap.EnableRawStates.JoinNumber, new Action((b) => occController.EnableRawStates(b))); - - // Timouts - trilist.SetUShortSigAction(joinMap.Timeout.JoinNumber, new Action((u) => occController.SetRemoteTimeout(u))); - occController.CurrentTimeoutFeedback.LinkInputSig(trilist.UShortInput[joinMap.Timeout.JoinNumber]); - occController.RemoteTimeoutFeedback.LinkInputSig(trilist.UShortInput[joinMap.TimeoutLocalFeedback.JoinNumber]); - - // LED Flash - trilist.SetSigTrueAction(joinMap.EnableLedFlash.JoinNumber, new Action(() => occController.SetLedFlashEnable(true))); - trilist.SetSigTrueAction(joinMap.DisableLedFlash.JoinNumber, new Action(() => occController.SetLedFlashEnable(false))); - occController.LedFlashEnabledFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.EnableLedFlash.JoinNumber]); - - // Short Timeout - trilist.SetSigTrueAction(joinMap.EnableShortTimeout.JoinNumber, new Action(() => occController.SetShortTimeoutState(true))); - trilist.SetSigTrueAction(joinMap.DisableShortTimeout.JoinNumber, new Action(() => occController.SetShortTimeoutState(false))); - occController.ShortTimeoutEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableShortTimeout.JoinNumber]); - - // PIR Sensor - trilist.SetSigTrueAction(joinMap.EnablePir.JoinNumber, new Action(() => occController.SetPirEnable(true))); - trilist.SetSigTrueAction(joinMap.DisablePir.JoinNumber, new Action(() => occController.SetPirEnable(false))); - occController.PirSensorEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnablePir.JoinNumber]); - - // PIR Sensitivity in Occupied State - trilist.SetBoolSigAction(joinMap.IncrementPirInOccupiedState.JoinNumber, new Action((b) => occController.IncrementPirSensitivityInOccupiedState(b))); - trilist.SetBoolSigAction(joinMap.DecrementPirInOccupiedState.JoinNumber, new Action((b) => occController.DecrementPirSensitivityInOccupiedState(b))); - occController.PirSensitivityInOccupiedStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.PirSensitivityInOccupiedState.JoinNumber]); - - // PIR Sensitivity in Vacant State - trilist.SetBoolSigAction(joinMap.IncrementPirInVacantState.JoinNumber, new Action((b) => occController.IncrementPirSensitivityInVacantState(b))); - trilist.SetBoolSigAction(joinMap.DecrementPirInVacantState.JoinNumber, new Action((b) => occController.DecrementPirSensitivityInVacantState(b))); - occController.PirSensitivityInVacantStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.PirSensitivityInVacantState.JoinNumber]); - - // OR When Vacated - trilist.SetBoolSigAction(joinMap.OrWhenVacated.JoinNumber, new Action((b) => occController.SetOrWhenVacatedState(b))); - occController.OrWhenVacatedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.OrWhenVacated.JoinNumber]); - - // AND When Vacated - trilist.SetBoolSigAction(joinMap.AndWhenVacated.JoinNumber, new Action((b) => occController.SetAndWhenVacatedState(b))); - occController.AndWhenVacatedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.AndWhenVacated.JoinNumber]); - - // Ultrasonic A Sensor - trilist.SetSigTrueAction(joinMap.EnableUsA.JoinNumber, new Action(() => occController.SetUsAEnable(true))); - trilist.SetSigTrueAction(joinMap.DisableUsA.JoinNumber, new Action(() => occController.SetUsAEnable(false))); - occController.UltrasonicAEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableUsA.JoinNumber]); - - // Ultrasonic B Sensor - trilist.SetSigTrueAction(joinMap.EnableUsB.JoinNumber, new Action(() => occController.SetUsBEnable(true))); - trilist.SetSigTrueAction(joinMap.DisableUsB.JoinNumber, new Action(() => occController.SetUsBEnable(false))); - occController.UltrasonicAEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableUsB.JoinNumber]); - - // US Sensitivity in Occupied State - trilist.SetBoolSigAction(joinMap.IncrementUsInOccupiedState.JoinNumber, new Action((b) => occController.IncrementUsSensitivityInOccupiedState(b))); - trilist.SetBoolSigAction(joinMap.DecrementUsInOccupiedState.JoinNumber, new Action((b) => occController.DecrementUsSensitivityInOccupiedState(b))); - occController.UltrasonicSensitivityInOccupiedStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.UsSensitivityInOccupiedState.JoinNumber]); - - // US Sensitivity in Vacant State - trilist.SetBoolSigAction(joinMap.IncrementUsInVacantState.JoinNumber, new Action((b) => occController.IncrementUsSensitivityInVacantState(b))); - trilist.SetBoolSigAction(joinMap.DecrementUsInVacantState.JoinNumber, new Action((b) => occController.DecrementUsSensitivityInVacantState(b))); - occController.UltrasonicSensitivityInVacantStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.UsSensitivityInVacantState.JoinNumber]); - - //Sensor Raw States - occController.RawOccupancyPirFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyPirFeedback.JoinNumber]); - occController.RawOccupancyUsFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyUsFeedback.JoinNumber]); - - // Identity mode - trilist.SetBoolSigAction(joinMap.IdentityMode.JoinNumber, occController.SetIdentityMode); - occController.IdentityModeFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IdentityModeFeedback.JoinNumber]); - } - - public class CenOdtOccupancySensorBaseControllerFactory : EssentialsDeviceFactory - { - public CenOdtOccupancySensorBaseControllerFactory() - { - TypeNames = new List() { "cenodtcpoe", "cenodtocc" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new GlsOccupancySensorBaseController Device"); - - var typeName = dc.Type.ToLower(); - var key = dc.Key; - var name = dc.Name; - var comm = CommFactory.GetControlPropertiesConfig(dc); - - var props = dc.Properties.ToObject(); - - var occSensor = new CenOdtCPoe(comm.IpIdInt, Global.ControlSystem); - - if (occSensor == null) - { - Debug.Console(0, "ERROR: Unable to create Occupancy Sensor Device. Key: '{0}'", key); - return null; - } - - return new CenOdtOccupancySensorBaseController(key, name, occSensor, props); - } - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Resources; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.GeneralIO; +using Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.Core.Bridges; + +namespace PepperDash.Essentials.Core +{ + [Description("Wrapper class for CEN-ODT-C-POE")] + [ConfigSnippet("\"properties\": {\"control\": {\"method\": \"cresnet\",\"cresnetId\": \"97\"},\"enablePir\": true,\"enableLedFlash\": true,\"enableRawStates\":true,\"remoteTimeout\": 30,\"internalPhotoSensorMinChange\": 0,\"externalPhotoSensorMinChange\": 0,\"enableUsA\": true,\"enableUsB\": true,\"orWhenVacatedState\": true}")] + public class CenOdtOccupancySensorBaseController : CrestronGenericBridgeableBaseDevice, IOccupancyStatusProvider + { + public CenOdtCPoe OccSensor { get; private set; } + + public GlsOccupancySensorPropertiesConfig PropertiesConfig { get; private set; } + + public BoolFeedback RoomIsOccupiedFeedback { get; private set; } + + public BoolFeedback GraceOccupancyDetectedFeedback { get; private set; } + + public BoolFeedback RawOccupancyFeedback { get; private set; } + + public BoolFeedback PirSensorEnabledFeedback { get; private set; } + + public BoolFeedback LedFlashEnabledFeedback { get; private set; } + + public BoolFeedback ShortTimeoutEnabledFeedback { get; private set; } + + public IntFeedback PirSensitivityInVacantStateFeedback { get; private set; } + + public IntFeedback PirSensitivityInOccupiedStateFeedback { get; private set; } + + public IntFeedback CurrentTimeoutFeedback { get; private set; } + + public IntFeedback RemoteTimeoutFeedback { get; private set; } + + public IntFeedback InternalPhotoSensorValue { get; set; } + + public IntFeedback ExternalPhotoSensorValue { get; set; } + + public BoolFeedback OrWhenVacatedFeedback { get; private set; } + + public BoolFeedback AndWhenVacatedFeedback { get; private set; } + + public BoolFeedback UltrasonicAEnabledFeedback { get; private set; } + + public BoolFeedback UltrasonicBEnabledFeedback { get; private set; } + + public IntFeedback UltrasonicSensitivityInVacantStateFeedback { get; private set; } + + public IntFeedback UltrasonicSensitivityInOccupiedStateFeedback { get; private set; } + + public BoolFeedback RawOccupancyPirFeedback { get; private set; } + + public BoolFeedback RawOccupancyUsFeedback { get; private set; } + + public BoolFeedback IdentityModeFeedback { get; private set; } + + // Debug properties + public bool InTestMode { get; private set; } + + public bool TestRoomIsOccupiedFeedback { get; private set; } + + public Func RoomIsOccupiedFeedbackFunc + { + get + { + return () => InTestMode ? TestRoomIsOccupiedFeedback : OccSensor.OccupancyDetectedFeedback.BoolValue; + } + } + + public CenOdtOccupancySensorBaseController(string key, string name, CenOdtCPoe sensor, GlsOccupancySensorPropertiesConfig config) + : base(key, name, sensor) + { + PropertiesConfig = config; + + OccSensor = sensor; + + RoomIsOccupiedFeedback = new BoolFeedback(RoomIsOccupiedFeedbackFunc); + + PirSensorEnabledFeedback = new BoolFeedback(() => OccSensor.PassiveInfraredSensorEnabledFeedback.BoolValue); + + LedFlashEnabledFeedback = new BoolFeedback(() => OccSensor.LedFlashEnabledFeedback.BoolValue); + + ShortTimeoutEnabledFeedback = new BoolFeedback(() => OccSensor.ShortTimeoutEnabledFeedback.BoolValue); + + PirSensitivityInVacantStateFeedback = new IntFeedback(() => (int)OccSensor.PassiveInfraredSensorSensitivityInVacantStateFeedback); + + PirSensitivityInOccupiedStateFeedback = new IntFeedback(() => (int)OccSensor.PassiveInfraredSensorSensitivityInOccupiedStateFeedback); + + CurrentTimeoutFeedback = new IntFeedback(() => OccSensor.CurrentTimeoutFeedback.UShortValue); + + RemoteTimeoutFeedback = new IntFeedback(() => OccSensor.RemoteTimeout.UShortValue); + + GraceOccupancyDetectedFeedback = new BoolFeedback(() => OccSensor.GraceOccupancyDetectedFeedback.BoolValue); + + RawOccupancyFeedback = new BoolFeedback(() => OccSensor.RawOccupancyDetectedFeedback.BoolValue); + + InternalPhotoSensorValue = new IntFeedback(() => OccSensor.InternalPhotoSensorValueFeedback.UShortValue); + + //ExternalPhotoSensorValue = new IntFeedback(() => OccSensor.ex.UShortValue); + + AndWhenVacatedFeedback = new BoolFeedback(() => OccSensor.AndWhenVacatedFeedback.BoolValue); + + OrWhenVacatedFeedback = new BoolFeedback(() => OccSensor.OrWhenVacatedFeedback.BoolValue); + + UltrasonicAEnabledFeedback = new BoolFeedback(() => OccSensor.UltrasonicSensorSideAEnabledFeedback.BoolValue); + + UltrasonicBEnabledFeedback = new BoolFeedback(() => OccSensor.UltrasonicSensorSideBEnabledFeedback.BoolValue); + + RawOccupancyPirFeedback = new BoolFeedback(() => OccSensor.RawOccupancyDetectedByPassiveInfraredSensorFeedback.BoolValue); + + RawOccupancyUsFeedback = new BoolFeedback(() => OccSensor.RawOccupancyDetectedByUltrasonicSensorFeedback.BoolValue); + + IdentityModeFeedback = new BoolFeedback(()=>OccSensor.IdentityModeOnFeedback.BoolValue); + + UltrasonicSensitivityInVacantStateFeedback = new IntFeedback(() => (int)OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback); + + UltrasonicSensitivityInOccupiedStateFeedback = new IntFeedback(() => (int)OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback); + + OccSensor.BaseEvent += new Crestron.SimplSharpPro.BaseEventHandler(OccSensor_BaseEvent); + + OccSensor.CenOccupancySensorChange += new GenericEventHandler(OccSensor_CenOccupancySensorChange); + + AddPostActivationAction(() => + { + OccSensor.OnlineStatusChange += (o, a) => + { + if (a.DeviceOnLine) + { + ApplySettingsToSensorFromConfig(); + } + }; + + if (OccSensor.IsOnline) + { + ApplySettingsToSensorFromConfig(); + + } + }); + } + + /// + /// Applies any sensor settings defined in config + /// + protected virtual void ApplySettingsToSensorFromConfig() + { + Debug.Console(1, this, "Checking config for settings to apply"); + + if (PropertiesConfig.EnablePir != null) + { + SetPirEnable((bool)PropertiesConfig.EnablePir); + } + + if (PropertiesConfig.EnableLedFlash != null) + { + SetLedFlashEnable((bool)PropertiesConfig.EnableLedFlash); + } + + if (PropertiesConfig.RemoteTimeout != null) + { + SetRemoteTimeout((ushort)PropertiesConfig.RemoteTimeout); + } + + if (PropertiesConfig.ShortTimeoutState != null) + { + SetShortTimeoutState((bool)PropertiesConfig.ShortTimeoutState); + } + + if (PropertiesConfig.EnableRawStates != null) + { + EnableRawStates((bool)PropertiesConfig.EnableRawStates); + } + + if (PropertiesConfig.InternalPhotoSensorMinChange != null) + { + SetInternalPhotoSensorMinChange((ushort)PropertiesConfig.InternalPhotoSensorMinChange); + } + + if (PropertiesConfig.EnableUsA != null) + { + SetUsAEnable((bool)PropertiesConfig.EnableUsA); + } + + if (PropertiesConfig.EnableUsB != null) + { + SetUsBEnable((bool)PropertiesConfig.EnableUsB); + } + + if (PropertiesConfig.OrWhenVacatedState != null) + { + SetOrWhenVacatedState((bool)PropertiesConfig.OrWhenVacatedState); + } + + if (PropertiesConfig.AndWhenVacatedState != null) + { + SetAndWhenVacatedState((bool)PropertiesConfig.AndWhenVacatedState); + } + + // TODO [ ] feature/cenoodtcpoe-sensor-sensitivity-configuration + if (PropertiesConfig.UsSensitivityOccupied != null) + { + SetUsSensitivityOccupied((ushort)PropertiesConfig.UsSensitivityOccupied); + } + + if (PropertiesConfig.UsSensitivityVacant != null) + { + SetUsSensitivityVacant((ushort)PropertiesConfig.UsSensitivityVacant); + } + + if (PropertiesConfig.PirSensitivityOccupied != null) + { + SetPirSensitivityOccupied((ushort)PropertiesConfig.PirSensitivityOccupied); + } + + if (PropertiesConfig.PirSensitivityVacant != null) + { + SetPirSensitivityVacant((ushort)PropertiesConfig.PirSensitivityVacant); + } + } + + /// + /// Catches events for feedbacks on the base class. Any extending wrapper class should call this delegate after it checks for it's own event IDs. + /// + /// + /// + protected virtual void OccSensor_CenOccupancySensorChange(object device, GenericEventArgs args) + { + if (args.EventId == GlsOccupancySensorBase.PirEnabledFeedbackEventId) + PirSensorEnabledFeedback.FireUpdate(); + else if (args.EventId == GlsOccupancySensorBase.LedFlashEnabledFeedbackEventId) + LedFlashEnabledFeedback.FireUpdate(); + else if (args.EventId == GlsOccupancySensorBase.ShortTimeoutEnabledFeedbackEventId) + ShortTimeoutEnabledFeedback.FireUpdate(); + else if (args.EventId == GlsOccupancySensorBase.PirSensitivityInOccupiedStateFeedbackEventId) + PirSensitivityInOccupiedStateFeedback.FireUpdate(); + else if (args.EventId == GlsOccupancySensorBase.PirSensitivityInVacantStateFeedbackEventId) + PirSensitivityInVacantStateFeedback.FireUpdate(); + else if (args.EventId == GlsOccupancySensorBase.RawOccupancyPirFeedbackEventId) + RawOccupancyPirFeedback.FireUpdate(); + else if (args.EventId == GlsOccupancySensorBase.RawOccupancyUsFeedbackEventId) + RawOccupancyUsFeedback.FireUpdate(); + } + + protected virtual void OccSensor_BaseEvent(Crestron.SimplSharpPro.GenericBase device, Crestron.SimplSharpPro.BaseEventArgs args) + { + Debug.Console(2, this, "PoEOccupancySensorChange EventId: {0}", args.EventId); + + if (args.EventId == Crestron.SimplSharpPro.GeneralIO.GlsOccupancySensorBase.RoomOccupiedFeedbackEventId + || args.EventId == Crestron.SimplSharpPro.GeneralIO.GlsOccupancySensorBase.RoomVacantFeedbackEventId) + { + Debug.Console(1, this, "Occupancy State: {0}", OccSensor.OccupancyDetectedFeedback.BoolValue); + RoomIsOccupiedFeedback.FireUpdate(); + } + else if (args.EventId == GlsOccupancySensorBase.TimeoutFeedbackEventId) + CurrentTimeoutFeedback.FireUpdate(); + else if (args.EventId == GlsOccupancySensorBase.TimeoutLocalFeedbackEventId) + RemoteTimeoutFeedback.FireUpdate(); + else if (args.EventId == GlsOccupancySensorBase.GraceOccupancyDetectedFeedbackEventId) + GraceOccupancyDetectedFeedback.FireUpdate(); + else if (args.EventId == GlsOccupancySensorBase.RawOccupancyFeedbackEventId) + RawOccupancyFeedback.FireUpdate(); + else if (args.EventId == GlsOccupancySensorBase.InternalPhotoSensorValueFeedbackEventId) + InternalPhotoSensorValue.FireUpdate(); + else if (args.EventId == GlsOccupancySensorBase.ExternalPhotoSensorValueFeedbackEventId) + ExternalPhotoSensorValue.FireUpdate(); + else if (args.EventId == GlsOccupancySensorBase.AndWhenVacatedFeedbackEventId) + AndWhenVacatedFeedback.FireUpdate(); + else if (args.EventId == GlsOccupancySensorBase.OrWhenVacatedFeedbackEventId) + OrWhenVacatedFeedback.FireUpdate(); + else if (args.EventId == GlsOccupancySensorBase.UsAEnabledFeedbackEventId) + UltrasonicAEnabledFeedback.FireUpdate(); + else if (args.EventId == GlsOccupancySensorBase.UsBEnabledFeedbackEventId) + UltrasonicBEnabledFeedback.FireUpdate(); + else if (args.EventId == GlsOccupancySensorBase.UsSensitivityInOccupiedStateFeedbackEventId) + UltrasonicSensitivityInOccupiedStateFeedback.FireUpdate(); + else if (args.EventId == GlsOccupancySensorBase.UsSensitivityInVacantStateFeedbackEventId) + UltrasonicSensitivityInVacantStateFeedback.FireUpdate(); + } + + public void SetTestMode(bool mode) + { + InTestMode = mode; + + Debug.Console(1, this, "In Mock Mode: '{0}'", InTestMode); + } + + public void SetTestOccupiedState(bool state) + { + if (!InTestMode) + Debug.Console(1, "Mock mode not enabled"); + else + { + TestRoomIsOccupiedFeedback = state; + + RoomIsOccupiedFeedback.FireUpdate(); + } + } + + /// + /// Sets the identity mode on or off + /// + /// + public void SetIdentityMode(bool state) + { + if (state) + OccSensor.IdentityModeOn(); + else + OccSensor.IdentityModeOff(); + + Debug.Console(1, this, "Identity Mode: {0}", OccSensor.IdentityModeOnFeedback.BoolValue ? "On" : "Off"); + } + + /// + /// Enables or disables the PIR sensor + /// + /// + public void SetPirEnable(bool state) + { + if (state) + { + OccSensor.EnablePassiveInfraredSensor(); + } + else + { + OccSensor.DisablePassiveInfraredSensor(); + } + } + + /// + /// Enables or disables the LED Flash + /// + /// + public void SetLedFlashEnable(bool state) + { + if (state) + { + OccSensor.EnableLedFlash(); + } + else + { + OccSensor.DisableLedFlash(); + } + } + + /// + /// Enables or disables short timeout based on state + /// + /// + public void SetShortTimeoutState(bool state) + { + if (state) + { + OccSensor.EnableShortTimeout(); + } + else + { + OccSensor.DisableShortTimeout(); + } + } + + public void IncrementPirSensitivityInOccupiedState(bool pressRelease) + { + if ((int)OccSensor.PassiveInfraredSensorSensitivityInOccupiedStateFeedback != 3) + { + OccSensor.PassiveInfraredSensorSensitivityInOccupiedState = OccSensor.PassiveInfraredSensorSensitivityInOccupiedStateFeedback + 1; + } + } + + public void DecrementPirSensitivityInOccupiedState(bool pressRelease) + { + if ((int)OccSensor.PassiveInfraredSensorSensitivityInOccupiedStateFeedback != 0) + { + OccSensor.PassiveInfraredSensorSensitivityInOccupiedState = OccSensor.PassiveInfraredSensorSensitivityInOccupiedStateFeedback - 1; + } + } + + public void IncrementPirSensitivityInVacantState(bool pressRelease) + { + if ((int)OccSensor.PassiveInfraredSensorSensitivityInVacantStateFeedback != 3) + { + OccSensor.PassiveInfraredSensorSensitivityInVacantState = OccSensor.PassiveInfraredSensorSensitivityInVacantStateFeedback + 1; + } + } + + public void DecrementPirSensitivityInVacantState(bool pressRelease) + { + if ((int)OccSensor.PassiveInfraredSensorSensitivityInVacantStateFeedback != 0) + { + OccSensor.PassiveInfraredSensorSensitivityInVacantState = OccSensor.PassiveInfraredSensorSensitivityInVacantStateFeedback - 1; + } + } + + public void IncrementUsSensitivityInOccupiedState(bool pressRelease) + { + if ((int)OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback < 3) + { + OccSensor.UltrasonicSensorSensitivityInOccupiedState = OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback + 1; + } + else if ((int)OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback > 4) + { + OccSensor.UltrasonicSensorSensitivityInOccupiedState = OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback - 1; + } + else if ((int)OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback == 4) + { + OccSensor.UltrasonicSensorSensitivityInOccupiedState = 0; + } + } + + public void DecrementUsSensitivityInOccupiedState(bool pressRelease) + { + if ((int)OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback > 0 + && (int)OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback < 4) + { + OccSensor.UltrasonicSensorSensitivityInOccupiedState = OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback - 1; + } + else if ((int)OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback > 3 + && (int)OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback < 7) + { + OccSensor.UltrasonicSensorSensitivityInOccupiedState = OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback + 1; + } + } + + public void IncrementUsSensitivityInVacantState(bool pressRelease) + { + if ((int)OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback < 3) + { + OccSensor.UltrasonicSensorSensitivityInVacantState = OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback + 1; + } + else if ((int)OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback > 4) + { + OccSensor.UltrasonicSensorSensitivityInVacantState = OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback - 1; + } + else if ((int)OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback == 4) + { + OccSensor.UltrasonicSensorSensitivityInVacantState = 0; + } + } + + public void DecrementUsSensitivityInVacantState(bool pressRelease) + { + if ((int)OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback > 0 + && (int)OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback < 4) + { + OccSensor.UltrasonicSensorSensitivityInVacantState = OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback - 1; + } + else if ((int)OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback > 3 + && (int)OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback < 7) + { + OccSensor.UltrasonicSensorSensitivityInVacantState = OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback + 1; + } + } + + public void ForceOccupied() + { + OccSensor.ForceOccupied(); + } + + public void ForceVacant() + { + OccSensor.ForceVacant(); + } + + public void EnableRawStates(bool state) + { + if (state) + { + OccSensor.EnableRawStates(); + } + else + OccSensor.DisableRawStates(); + } + + public void SetRemoteTimeout(ushort time) + { + OccSensor.RemoteTimeout.UShortValue = time; + } + + public void SetInternalPhotoSensorMinChange(ushort value) + { + OccSensor.InternalPhotoSensorMinimumChange.UShortValue = value; + } + + /// + /// Sets the OrWhenVacated state + /// + /// + public void SetOrWhenVacatedState(bool state) + { + if (state) + { + OccSensor.OrWhenVacated(); + } + } + + /// + /// Sets the AndWhenVacated state + /// + /// + public void SetAndWhenVacatedState(bool state) + { + if (state) + { + OccSensor.AndWhenVacated(); + } + } + + /// + /// Enables or disables the Ultrasonic A sensor + /// + /// + public void SetUsAEnable(bool state) + { + if (state) + { + OccSensor.EnableUltrasonicSensorSideA(); + } + else + { + OccSensor.DisableUltrasonicSensorSideA(); + } + } + + + /// + /// Enables or disables the Ultrasonic B sensor + /// + /// + public void SetUsBEnable(bool state) + { + if (state) + { + OccSensor.EnableUltrasonicSensorSideB(); + } + else + { + OccSensor.DisableUltrasonicSensorSideB(); + } + } + + /// + /// Sets the US sensor sensitivity for occupied state + /// + /// + public void SetUsSensitivityOccupied(ushort sensitivity) + { + var level = (eSensitivityLevel) sensitivity; + if (level == 0) return; + + OccSensor.UltrasonicSensorSensitivityInOccupiedState = level; + } + + /// + /// Sets the US sensor sensitivity for vacant state + /// + /// + public void SetUsSensitivityVacant(ushort sensitivity) + { + var level = (eSensitivityLevel)sensitivity; + if (level == 0) return; + + OccSensor.UltrasonicSensorSensitivityInVacantState = level; + } + + /// + /// Sets the PIR sensor sensitivity for occupied state + /// + /// + public void SetPirSensitivityOccupied(ushort sensitivity) + { + var level = (eSensitivityLevel)sensitivity; + if (level == 0) return; + + OccSensor.PassiveInfraredSensorSensitivityInOccupiedState = level; + } + + /// + /// Sets the PIR sensor sensitivity for vacant state + /// + /// + public void SetPirSensitivityVacant(ushort sensitivity) + { + var level = (eSensitivityLevel)sensitivity; + if (level == 0) return; + + OccSensor.PassiveInfraredSensorSensitivityInVacantState = level; + } + + /// + /// Method to print current settings to console + /// + public void GetSettings() + { + var dash = new string('*', 50); + CrestronConsole.PrintLine(string.Format("{0}\n", dash)); + + Debug.Console(0, this, "Vacancy Detected: {0}", + OccSensor.VacancyDetectedFeedback.BoolValue); + + Debug.Console(0, Key, "Timeout Current: {0} | Remote: {1}", + OccSensor.CurrentTimeoutFeedback.UShortValue, + OccSensor.RemoteTimeout.UShortValue); + + Debug.Console(0, Key, "Short Timeout Enabled: {0}", + OccSensor.ShortTimeoutEnabledFeedback.BoolValue); + + Debug.Console(0, Key, "PIR Sensor Enabled: {0} | Sensitivity Occupied: {1} | Sensitivity Vacant: {2}", + OccSensor.PassiveInfraredSensorEnabledFeedback.BoolValue, + OccSensor.PassiveInfraredSensorSensitivityInOccupiedStateFeedback, + OccSensor.PassiveInfraredSensorSensitivityInVacantStateFeedback); + + Debug.Console(0, Key, "Ultrasonic Enabled A: {0} | B: {1}", + OccSensor.UltrasonicSensorSideAEnabledFeedback.BoolValue, + OccSensor.UltrasonicSensorSideBEnabledFeedback.BoolValue); + + Debug.Console(0, Key, "Ultrasonic Sensitivity Occupied: {0} | Vacant: {1}", + OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback, + OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback); + + CrestronConsole.PrintLine(string.Format("{0}\n", dash)); + } + + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + LinkOccSensorToApi(this, trilist, joinStart, joinMapKey, bridge); + } + + protected void LinkOccSensorToApi(CenOdtOccupancySensorBaseController occController, + BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + CenOdtOccupancySensorBaseJoinMap joinMap = new CenOdtOccupancySensorBaseJoinMap(joinStart); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + else + { + Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + } + + Debug.Console(1, occController, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + occController.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.Online.JoinNumber]); + trilist.StringInput[joinMap.Name.JoinNumber].StringValue = occController.Name; + + trilist.OnlineStatusChange += new Crestron.SimplSharpPro.OnlineStatusChangeEventHandler((d, args) => + { + if (args.DeviceOnLine) + { + trilist.StringInput[joinMap.Name.JoinNumber].StringValue = occController.Name; + } + } + ); + + // Occupied status + trilist.SetSigTrueAction(joinMap.ForceOccupied.JoinNumber, new Action(() => occController.ForceOccupied())); + trilist.SetSigTrueAction(joinMap.ForceVacant.JoinNumber, new Action(() => occController.ForceVacant())); + occController.RoomIsOccupiedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RoomOccupiedFeedback.JoinNumber]); + occController.RoomIsOccupiedFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.RoomVacantFeedback.JoinNumber]); + occController.RawOccupancyFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyFeedback.JoinNumber]); + trilist.SetBoolSigAction(joinMap.EnableRawStates.JoinNumber, new Action((b) => occController.EnableRawStates(b))); + + // Timouts + trilist.SetUShortSigAction(joinMap.Timeout.JoinNumber, new Action((u) => occController.SetRemoteTimeout(u))); + occController.CurrentTimeoutFeedback.LinkInputSig(trilist.UShortInput[joinMap.Timeout.JoinNumber]); + occController.RemoteTimeoutFeedback.LinkInputSig(trilist.UShortInput[joinMap.TimeoutLocalFeedback.JoinNumber]); + + // LED Flash + trilist.SetSigTrueAction(joinMap.EnableLedFlash.JoinNumber, new Action(() => occController.SetLedFlashEnable(true))); + trilist.SetSigTrueAction(joinMap.DisableLedFlash.JoinNumber, new Action(() => occController.SetLedFlashEnable(false))); + occController.LedFlashEnabledFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.EnableLedFlash.JoinNumber]); + + // Short Timeout + trilist.SetSigTrueAction(joinMap.EnableShortTimeout.JoinNumber, new Action(() => occController.SetShortTimeoutState(true))); + trilist.SetSigTrueAction(joinMap.DisableShortTimeout.JoinNumber, new Action(() => occController.SetShortTimeoutState(false))); + occController.ShortTimeoutEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableShortTimeout.JoinNumber]); + + // PIR Sensor + trilist.SetSigTrueAction(joinMap.EnablePir.JoinNumber, new Action(() => occController.SetPirEnable(true))); + trilist.SetSigTrueAction(joinMap.DisablePir.JoinNumber, new Action(() => occController.SetPirEnable(false))); + occController.PirSensorEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnablePir.JoinNumber]); + + // PIR Sensitivity in Occupied State + trilist.SetBoolSigAction(joinMap.IncrementPirInOccupiedState.JoinNumber, new Action((b) => occController.IncrementPirSensitivityInOccupiedState(b))); + trilist.SetBoolSigAction(joinMap.DecrementPirInOccupiedState.JoinNumber, new Action((b) => occController.DecrementPirSensitivityInOccupiedState(b))); + occController.PirSensitivityInOccupiedStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.PirSensitivityInOccupiedState.JoinNumber]); + + // PIR Sensitivity in Vacant State + trilist.SetBoolSigAction(joinMap.IncrementPirInVacantState.JoinNumber, new Action((b) => occController.IncrementPirSensitivityInVacantState(b))); + trilist.SetBoolSigAction(joinMap.DecrementPirInVacantState.JoinNumber, new Action((b) => occController.DecrementPirSensitivityInVacantState(b))); + occController.PirSensitivityInVacantStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.PirSensitivityInVacantState.JoinNumber]); + + // OR When Vacated + trilist.SetBoolSigAction(joinMap.OrWhenVacated.JoinNumber, new Action((b) => occController.SetOrWhenVacatedState(b))); + occController.OrWhenVacatedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.OrWhenVacated.JoinNumber]); + + // AND When Vacated + trilist.SetBoolSigAction(joinMap.AndWhenVacated.JoinNumber, new Action((b) => occController.SetAndWhenVacatedState(b))); + occController.AndWhenVacatedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.AndWhenVacated.JoinNumber]); + + // Ultrasonic A Sensor + trilist.SetSigTrueAction(joinMap.EnableUsA.JoinNumber, new Action(() => occController.SetUsAEnable(true))); + trilist.SetSigTrueAction(joinMap.DisableUsA.JoinNumber, new Action(() => occController.SetUsAEnable(false))); + occController.UltrasonicAEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableUsA.JoinNumber]); + + // Ultrasonic B Sensor + trilist.SetSigTrueAction(joinMap.EnableUsB.JoinNumber, new Action(() => occController.SetUsBEnable(true))); + trilist.SetSigTrueAction(joinMap.DisableUsB.JoinNumber, new Action(() => occController.SetUsBEnable(false))); + occController.UltrasonicAEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableUsB.JoinNumber]); + + // US Sensitivity in Occupied State + trilist.SetBoolSigAction(joinMap.IncrementUsInOccupiedState.JoinNumber, new Action((b) => occController.IncrementUsSensitivityInOccupiedState(b))); + trilist.SetBoolSigAction(joinMap.DecrementUsInOccupiedState.JoinNumber, new Action((b) => occController.DecrementUsSensitivityInOccupiedState(b))); + occController.UltrasonicSensitivityInOccupiedStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.UsSensitivityInOccupiedState.JoinNumber]); + + // US Sensitivity in Vacant State + trilist.SetBoolSigAction(joinMap.IncrementUsInVacantState.JoinNumber, new Action((b) => occController.IncrementUsSensitivityInVacantState(b))); + trilist.SetBoolSigAction(joinMap.DecrementUsInVacantState.JoinNumber, new Action((b) => occController.DecrementUsSensitivityInVacantState(b))); + occController.UltrasonicSensitivityInVacantStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.UsSensitivityInVacantState.JoinNumber]); + + //Sensor Raw States + occController.RawOccupancyPirFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyPirFeedback.JoinNumber]); + occController.RawOccupancyUsFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyUsFeedback.JoinNumber]); + + // Identity mode + trilist.SetBoolSigAction(joinMap.IdentityMode.JoinNumber, occController.SetIdentityMode); + occController.IdentityModeFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IdentityModeFeedback.JoinNumber]); + } + + public class CenOdtOccupancySensorBaseControllerFactory : EssentialsDeviceFactory + { + public CenOdtOccupancySensorBaseControllerFactory() + { + TypeNames = new List() { "cenodtcpoe", "cenodtocc" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new GlsOccupancySensorBaseController Device"); + + var typeName = dc.Type.ToLower(); + var key = dc.Key; + var name = dc.Name; + var comm = CommFactory.GetControlPropertiesConfig(dc); + + var props = dc.Properties.ToObject(); + + var occSensor = new CenOdtCPoe(comm.IpIdInt, Global.ControlSystem); + + if (occSensor == null) + { + Debug.Console(0, "ERROR: Unable to create Occupancy Sensor Device. Key: '{0}'", key); + return null; + } + + return new CenOdtOccupancySensorBaseController(key, name, occSensor, props); + } + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/EssentialsGlsOccupancySensorBaseController.cs.orig b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/EssentialsGlsOccupancySensorBaseController.cs.orig similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/EssentialsGlsOccupancySensorBaseController.cs.orig rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/EssentialsGlsOccupancySensorBaseController.cs.orig diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOccupancySensorBaseController.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOccupancySensorBaseController.cs similarity index 97% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOccupancySensorBaseController.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOccupancySensorBaseController.cs index 53db1716..3d15d5bc 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOccupancySensorBaseController.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOccupancySensorBaseController.cs @@ -1,539 +1,539 @@ -using System; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.GeneralIO; -using Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.Core -{ - [Description("Wrapper class for Single Technology GLS Occupancy Sensors")] - [ConfigSnippet("\"properties\": {\"control\": {\"method\": \"cresnet\",\"cresnetId\": \"97\"},\"enablePir\": true,\"enableLedFlash\": true,\"enableRawStates\":true,\"remoteTimeout\": 30,\"internalPhotoSensorMinChange\": 0,\"externalPhotoSensorMinChange\": 0}")] - public abstract class GlsOccupancySensorBaseController : CrestronGenericBridgeableBaseDevice, IOccupancyStatusProvider - { - public GlsOccupancySensorPropertiesConfig PropertiesConfig { get; private set; } - - protected GlsOccupancySensorBase OccSensor; - - public BoolFeedback RoomIsOccupiedFeedback { get; private set; } - - public BoolFeedback GraceOccupancyDetectedFeedback { get; private set; } - - public BoolFeedback RawOccupancyFeedback { get; private set; } - - public BoolFeedback PirSensorEnabledFeedback { get; private set; } - - public BoolFeedback LedFlashEnabledFeedback { get; private set; } - - public BoolFeedback ShortTimeoutEnabledFeedback { get; private set; } - - public IntFeedback PirSensitivityInVacantStateFeedback { get; private set; } - - public IntFeedback PirSensitivityInOccupiedStateFeedback { get; private set; } - - public IntFeedback CurrentTimeoutFeedback { get; private set; } - - public IntFeedback LocalTimoutFeedback { get; private set; } - - public IntFeedback InternalPhotoSensorValue { get; set; } - - public IntFeedback ExternalPhotoSensorValue { get; set; } - - // Debug properties - public bool InTestMode { get; private set; } - - public bool TestRoomIsOccupiedFeedback { get; private set; } - - public Func RoomIsOccupiedFeedbackFunc - { - get - { - return () => InTestMode ? TestRoomIsOccupiedFeedback : OccSensor.OccupancyDetectedFeedback.BoolValue; - } - } - - protected GlsOccupancySensorBaseController(string key, DeviceConfig config) - : this(key, config.Name, config) - { - } - - protected GlsOccupancySensorBaseController(string key, string name, DeviceConfig config) - : base(key, name) - { - - var props = config.Properties.ToObject(); - - if (props != null) - { - PropertiesConfig = props; - } - else - { - Debug.Console(1, this, "props are null. Unable to deserialize into GlsOccupancySensorPropertiesConfig"); - } - - AddPostActivationAction(() => - { - OccSensor.OnlineStatusChange += (o, a) => - { - if (a.DeviceOnLine) - { - ApplySettingsToSensorFromConfig(); - } - }; - - if (OccSensor.IsOnline) - { - ApplySettingsToSensorFromConfig(); - - } - }); - } - - - /// - /// Applies any sensor settings defined in config - /// - protected virtual void ApplySettingsToSensorFromConfig() - { - Debug.Console(1, this, "Attempting to apply settings to sensor from config"); - - if (PropertiesConfig.EnablePir != null) - { - Debug.Console(1, this, "EnablePir found, attempting to set value from config"); - SetPirEnable((bool)PropertiesConfig.EnablePir); - } - else - { - Debug.Console(1, this, "EnablePir null, no value specified in config"); - } - - if (PropertiesConfig.EnableLedFlash != null) - { - Debug.Console(1, this, "EnableLedFlash found, attempting to set value from config"); - SetLedFlashEnable((bool)PropertiesConfig.EnableLedFlash); - } - - if (PropertiesConfig.RemoteTimeout != null) - { - Debug.Console(1, this, "RemoteTimeout found, attempting to set value from config"); - SetRemoteTimeout((ushort)PropertiesConfig.RemoteTimeout); - } - else - { - Debug.Console(1, this, "RemoteTimeout null, no value specified in config"); - } - - if (PropertiesConfig.ShortTimeoutState != null) - { - SetShortTimeoutState((bool)PropertiesConfig.ShortTimeoutState); - } - - if (PropertiesConfig.EnableRawStates != null) - { - EnableRawStates((bool)PropertiesConfig.EnableRawStates); - } - - if (PropertiesConfig.InternalPhotoSensorMinChange != null) - { - SetInternalPhotoSensorMinChange((ushort)PropertiesConfig.InternalPhotoSensorMinChange); - } - - if (PropertiesConfig.ExternalPhotoSensorMinChange != null) - { - SetExternalPhotoSensorMinChange((ushort)PropertiesConfig.ExternalPhotoSensorMinChange); - } - } - - protected void RegisterGlsOccupancySensorBaseController(GlsOccupancySensorBase occSensor) - { - OccSensor = occSensor; - - RoomIsOccupiedFeedback = new BoolFeedback(RoomIsOccupiedFeedbackFunc); - - PirSensorEnabledFeedback = new BoolFeedback(() => OccSensor.PirEnabledFeedback.BoolValue); - - LedFlashEnabledFeedback = new BoolFeedback(() => OccSensor.LedFlashEnabledFeedback.BoolValue); - - ShortTimeoutEnabledFeedback = new BoolFeedback(() => OccSensor.ShortTimeoutEnabledFeedback.BoolValue); - - PirSensitivityInVacantStateFeedback = - new IntFeedback(() => OccSensor.PirSensitivityInVacantStateFeedback.UShortValue); - - PirSensitivityInOccupiedStateFeedback = - new IntFeedback(() => OccSensor.PirSensitivityInOccupiedStateFeedback.UShortValue); - - CurrentTimeoutFeedback = new IntFeedback(() => OccSensor.CurrentTimeoutFeedback.UShortValue); - - LocalTimoutFeedback = new IntFeedback(() => OccSensor.LocalTimeoutFeedback.UShortValue); - - GraceOccupancyDetectedFeedback = - new BoolFeedback(() => OccSensor.GraceOccupancyDetectedFeedback.BoolValue); - - RawOccupancyFeedback = new BoolFeedback(() => OccSensor.RawOccupancyFeedback.BoolValue); - - InternalPhotoSensorValue = new IntFeedback(() => OccSensor.InternalPhotoSensorValueFeedback.UShortValue); - - ExternalPhotoSensorValue = new IntFeedback(() => OccSensor.ExternalPhotoSensorValueFeedback.UShortValue); - - OccSensor.BaseEvent += OccSensor_BaseEvent; - - OccSensor.GlsOccupancySensorChange += OccSensor_GlsOccupancySensorChange; - } - - - /// - /// Catches events for feedbacks on the base class. Any extending wrapper class should call this delegate after it checks for it's own event IDs. - /// - /// - /// - protected virtual void OccSensor_GlsOccupancySensorChange(GlsOccupancySensorBase device, GlsOccupancySensorChangeEventArgs args) - { - switch (args.EventId) - { - case GlsOccupancySensorBase.PirEnabledFeedbackEventId: - PirSensorEnabledFeedback.FireUpdate(); - break; - case GlsOccupancySensorBase.LedFlashEnabledFeedbackEventId: - LedFlashEnabledFeedback.FireUpdate(); - break; - case GlsOccupancySensorBase.ShortTimeoutEnabledFeedbackEventId: - ShortTimeoutEnabledFeedback.FireUpdate(); - break; - case GlsOccupancySensorBase.PirSensitivityInOccupiedStateFeedbackEventId: - PirSensitivityInOccupiedStateFeedback.FireUpdate(); - break; - case GlsOccupancySensorBase.PirSensitivityInVacantStateFeedbackEventId: - PirSensitivityInVacantStateFeedback.FireUpdate(); - break; - } - } - - protected virtual void OccSensor_BaseEvent(Crestron.SimplSharpPro.GenericBase device, Crestron.SimplSharpPro.BaseEventArgs args) - { - Debug.Console(2, this, "GlsOccupancySensorChange EventId: {0}", args.EventId); - - switch (args.EventId) - { - case GlsOccupancySensorBase.RoomVacantFeedbackEventId: - case GlsOccupancySensorBase.RoomOccupiedFeedbackEventId: - Debug.Console(1, this, "Occupancy State: {0}", OccSensor.OccupancyDetectedFeedback.BoolValue); - RoomIsOccupiedFeedback.FireUpdate(); - break; - case GlsOccupancySensorBase.TimeoutFeedbackEventId: - CurrentTimeoutFeedback.FireUpdate(); - break; - case GlsOccupancySensorBase.TimeoutLocalFeedbackEventId: - LocalTimoutFeedback.FireUpdate(); - break; - case GlsOccupancySensorBase.GraceOccupancyDetectedFeedbackEventId: - GraceOccupancyDetectedFeedback.FireUpdate(); - break; - case GlsOccupancySensorBase.RawOccupancyFeedbackEventId: - RawOccupancyFeedback.FireUpdate(); - break; - case GlsOccupancySensorBase.InternalPhotoSensorValueFeedbackEventId: - InternalPhotoSensorValue.FireUpdate(); - break; - case GlsOccupancySensorBase.ExternalPhotoSensorValueFeedbackEventId: - ExternalPhotoSensorValue.FireUpdate(); - break; - } - } - - public void SetTestMode(bool mode) - { - InTestMode = mode; - - Debug.Console(1, this, "In Mock Mode: '{0}'", InTestMode); - } - - public void SetTestOccupiedState(bool state) - { - if (!InTestMode) - Debug.Console(1, "Mock mode not enabled"); - else - { - TestRoomIsOccupiedFeedback = state; - - RoomIsOccupiedFeedback.FireUpdate(); - } - } - - /// - /// Enables or disables the PIR sensor - /// - /// - public void SetPirEnable(bool state) - { - Debug.Console(1, this, "Setting EnablePir to: {0}", state); - - OccSensor.EnablePir.BoolValue = state; - OccSensor.DisablePir.BoolValue = !state; - } - - /// - /// Enables or disables the LED Flash - /// - /// - public void SetLedFlashEnable(bool state) - { - OccSensor.EnableLedFlash.BoolValue = state; - OccSensor.DisableLedFlash.BoolValue = !state; - } - - /// - /// Enables or disables short timeout based on state - /// - /// - public void SetShortTimeoutState(bool state) - { - OccSensor.EnableShortTimeout.BoolValue = state; - OccSensor.DisableShortTimeout.BoolValue = !state; - } - - public void IncrementPirSensitivityInOccupiedState(bool pressRelease) - { - OccSensor.IncrementPirSensitivityInOccupiedState.BoolValue = pressRelease; - } - - public void DecrementPirSensitivityInOccupiedState(bool pressRelease) - { - OccSensor.DecrementPirSensitivityInOccupiedState.BoolValue = pressRelease; - } - - public void IncrementPirSensitivityInVacantState(bool pressRelease) - { - OccSensor.IncrementPirSensitivityInVacantState.BoolValue = pressRelease; - } - - public void DecrementPirSensitivityInVacantState(bool pressRelease) - { - OccSensor.DecrementPirSensitivityInVacantState.BoolValue = pressRelease; - } - - /// - /// Pulse ForceOccupied on the sensor for .5 seconds - /// - public void ForceOccupied() - { - CrestronInvoke.BeginInvoke((o) => - { - ForceOccupied(true); - CrestronEnvironment.Sleep(500); - ForceOccupied(false); - }); - } - - public void ForceOccupied(bool value) - { - OccSensor.ForceOccupied.BoolValue = value; - } - - /// - /// Pulse ForceVacant on the sensor for .5 seconds - /// - public void ForceVacant() - { - CrestronInvoke.BeginInvoke((o) => - { - ForceVacant(true); - CrestronEnvironment.Sleep(500); - ForceVacant(false); - }); - } - - public void ForceVacant(bool value) - { - OccSensor.ForceVacant.BoolValue = value; - } - - public void EnableRawStates(bool state) - { - OccSensor.EnableRawStates.BoolValue = state; - } - - public void SetRemoteTimeout(ushort time) - { - Debug.Console(1, this, "Setting RemoteTimout to: {0}", time); - - OccSensor.RemoteTimeout.UShortValue = time; - } - - public void SetInternalPhotoSensorMinChange(ushort value) - { - OccSensor.InternalPhotoSensorMinimumChange.UShortValue = value; - } - - public void SetExternalPhotoSensorMinChange(ushort value) - { - OccSensor.ExternalPhotoSensorMinimumChange.UShortValue = value; - } - - /// - /// Method to print current occ settings to console. - /// - public virtual void GetSettings() - { - var dash = new string('*', 50); - CrestronConsole.PrintLine(string.Format("{0}\n", dash)); - - Debug.Console(0, this, "Vacancy Detected: {0}", - OccSensor.VacancyDetectedFeedback.BoolValue); - - Debug.Console(0, this, "Timeout Current: {0} | Local: {1}", - OccSensor.CurrentTimeoutFeedback.UShortValue, - OccSensor.LocalTimeoutFeedback.UShortValue); - - Debug.Console(0, this, "Short Timeout Enabled: {0}", - OccSensor.ShortTimeoutEnabledFeedback.BoolValue); - - Debug.Console(0, this, "PIR Sensor Enabled: {0} | Sensitivity Occupied: {1} | Sensitivity Vacant: {2}", - OccSensor.PirEnabledFeedback.BoolValue, - OccSensor.PirSensitivityInOccupiedStateFeedback.UShortValue, - OccSensor.PirSensitivityInVacantStateFeedback.UShortValue); - - CrestronConsole.PrintLine(string.Format("{0}\n", dash)); - } - - protected void LinkOccSensorToApi(GlsOccupancySensorBaseController occController, BasicTriList trilist, - uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new GlsOccupancySensorBaseJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - Debug.Console(1, occController, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - occController.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - trilist.StringInput[joinMap.Name.JoinNumber].StringValue = occController.Name; - - trilist.OnlineStatusChange += (d, args) => - { - if (args.DeviceOnLine) - { - trilist.StringInput[joinMap.Name.JoinNumber].StringValue = occController.Name; - } - }; - - LinkSingleTechSensorToApi(occController, trilist, joinMap); - - LinkDualTechSensorToApi(occController, trilist, joinMap); - } - - private static void LinkDualTechSensorToApi(GlsOccupancySensorBaseController occController, BasicTriList trilist, - GlsOccupancySensorBaseJoinMap joinMap) - { - var odtOccController = occController as GlsOdtOccupancySensorController; - - if (odtOccController == null) - { - return; - } - // OR When Vacated - trilist.SetBoolSigAction(joinMap.OrWhenVacated.JoinNumber, odtOccController.SetOrWhenVacatedState); - odtOccController.OrWhenVacatedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.OrWhenVacated.JoinNumber]); - - // AND When Vacated - trilist.SetBoolSigAction(joinMap.AndWhenVacated.JoinNumber, odtOccController.SetAndWhenVacatedState); - odtOccController.AndWhenVacatedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.AndWhenVacated.JoinNumber]); - - // Ultrasonic A Sensor - trilist.SetSigTrueAction(joinMap.EnableUsA.JoinNumber, () => odtOccController.SetUsAEnable(true)); - trilist.SetSigTrueAction(joinMap.DisableUsA.JoinNumber, () => odtOccController.SetUsAEnable(false)); - odtOccController.UltrasonicAEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableUsA.JoinNumber]); - - // Ultrasonic B Sensor - trilist.SetSigTrueAction(joinMap.EnableUsB.JoinNumber, () => odtOccController.SetUsBEnable(true)); - trilist.SetSigTrueAction(joinMap.DisableUsB.JoinNumber, () => odtOccController.SetUsBEnable(false)); - odtOccController.UltrasonicBEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableUsB.JoinNumber]); - - // US Sensitivity in Occupied State - trilist.SetBoolSigAction(joinMap.IncrementUsInOccupiedState.JoinNumber, - odtOccController.IncrementUsSensitivityInOccupiedState); - trilist.SetBoolSigAction(joinMap.DecrementUsInOccupiedState.JoinNumber, - odtOccController.DecrementUsSensitivityInOccupiedState); - odtOccController.UltrasonicSensitivityInOccupiedStateFeedback.LinkInputSig( - trilist.UShortInput[joinMap.UsSensitivityInOccupiedState.JoinNumber]); - - // US Sensitivity in Vacant State - trilist.SetBoolSigAction(joinMap.IncrementUsInVacantState.JoinNumber, - odtOccController.IncrementUsSensitivityInVacantState); - trilist.SetBoolSigAction(joinMap.DecrementUsInVacantState.JoinNumber, - odtOccController.DecrementUsSensitivityInVacantState); - odtOccController.UltrasonicSensitivityInVacantStateFeedback.LinkInputSig( - trilist.UShortInput[joinMap.UsSensitivityInVacantState.JoinNumber]); - - //Sensor Raw States - odtOccController.RawOccupancyPirFeedback.LinkInputSig( - trilist.BooleanInput[joinMap.RawOccupancyPirFeedback.JoinNumber]); - odtOccController.RawOccupancyUsFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyUsFeedback.JoinNumber]); - } - - private static void LinkSingleTechSensorToApi(GlsOccupancySensorBaseController occController, BasicTriList trilist, - GlsOccupancySensorBaseJoinMap joinMap) - { -// Occupied status - trilist.SetBoolSigAction(joinMap.ForceOccupied.JoinNumber, occController.ForceOccupied); - trilist.SetBoolSigAction(joinMap.ForceVacant.JoinNumber, occController.ForceVacant); - occController.RoomIsOccupiedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RoomOccupiedFeedback.JoinNumber]); - occController.RoomIsOccupiedFeedback.LinkComplementInputSig( - trilist.BooleanInput[joinMap.RoomVacantFeedback.JoinNumber]); - occController.RawOccupancyFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyFeedback.JoinNumber]); - trilist.SetBoolSigAction(joinMap.EnableRawStates.JoinNumber, occController.EnableRawStates); - - // Timouts - trilist.SetUShortSigAction(joinMap.Timeout.JoinNumber, occController.SetRemoteTimeout); - occController.CurrentTimeoutFeedback.LinkInputSig(trilist.UShortInput[joinMap.Timeout.JoinNumber]); - occController.LocalTimoutFeedback.LinkInputSig(trilist.UShortInput[joinMap.TimeoutLocalFeedback.JoinNumber]); - - // LED Flash - trilist.SetSigTrueAction(joinMap.EnableLedFlash.JoinNumber, () => occController.SetLedFlashEnable(true)); - trilist.SetSigTrueAction(joinMap.DisableLedFlash.JoinNumber, () => occController.SetLedFlashEnable(false)); - occController.LedFlashEnabledFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.EnableLedFlash.JoinNumber]); - - // Short Timeout - trilist.SetSigTrueAction(joinMap.EnableShortTimeout.JoinNumber, () => occController.SetShortTimeoutState(true)); - trilist.SetSigTrueAction(joinMap.DisableShortTimeout.JoinNumber, () => occController.SetShortTimeoutState(false)); - occController.ShortTimeoutEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableShortTimeout.JoinNumber]); - - // PIR Sensor - trilist.SetSigTrueAction(joinMap.EnablePir.JoinNumber, () => occController.SetPirEnable(true)); - trilist.SetSigTrueAction(joinMap.DisablePir.JoinNumber, () => occController.SetPirEnable(false)); - occController.PirSensorEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnablePir.JoinNumber]); - - // PIR Sensitivity in Occupied State - trilist.SetBoolSigAction(joinMap.IncrementPirInOccupiedState.JoinNumber, - occController.IncrementPirSensitivityInOccupiedState); - trilist.SetBoolSigAction(joinMap.DecrementPirInOccupiedState.JoinNumber, - occController.DecrementPirSensitivityInOccupiedState); - occController.PirSensitivityInOccupiedStateFeedback.LinkInputSig( - trilist.UShortInput[joinMap.PirSensitivityInOccupiedState.JoinNumber]); - - // PIR Sensitivity in Vacant State - trilist.SetBoolSigAction(joinMap.IncrementPirInVacantState.JoinNumber, - occController.IncrementPirSensitivityInVacantState); - trilist.SetBoolSigAction(joinMap.DecrementPirInVacantState.JoinNumber, - occController.DecrementPirSensitivityInVacantState); - occController.PirSensitivityInVacantStateFeedback.LinkInputSig( - trilist.UShortInput[joinMap.PirSensitivityInVacantState.JoinNumber]); - } - } - - - +using System; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.GeneralIO; +using Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.Core.Bridges; + +namespace PepperDash.Essentials.Core +{ + [Description("Wrapper class for Single Technology GLS Occupancy Sensors")] + [ConfigSnippet("\"properties\": {\"control\": {\"method\": \"cresnet\",\"cresnetId\": \"97\"},\"enablePir\": true,\"enableLedFlash\": true,\"enableRawStates\":true,\"remoteTimeout\": 30,\"internalPhotoSensorMinChange\": 0,\"externalPhotoSensorMinChange\": 0}")] + public abstract class GlsOccupancySensorBaseController : CrestronGenericBridgeableBaseDevice, IOccupancyStatusProvider + { + public GlsOccupancySensorPropertiesConfig PropertiesConfig { get; private set; } + + protected GlsOccupancySensorBase OccSensor; + + public BoolFeedback RoomIsOccupiedFeedback { get; private set; } + + public BoolFeedback GraceOccupancyDetectedFeedback { get; private set; } + + public BoolFeedback RawOccupancyFeedback { get; private set; } + + public BoolFeedback PirSensorEnabledFeedback { get; private set; } + + public BoolFeedback LedFlashEnabledFeedback { get; private set; } + + public BoolFeedback ShortTimeoutEnabledFeedback { get; private set; } + + public IntFeedback PirSensitivityInVacantStateFeedback { get; private set; } + + public IntFeedback PirSensitivityInOccupiedStateFeedback { get; private set; } + + public IntFeedback CurrentTimeoutFeedback { get; private set; } + + public IntFeedback LocalTimoutFeedback { get; private set; } + + public IntFeedback InternalPhotoSensorValue { get; set; } + + public IntFeedback ExternalPhotoSensorValue { get; set; } + + // Debug properties + public bool InTestMode { get; private set; } + + public bool TestRoomIsOccupiedFeedback { get; private set; } + + public Func RoomIsOccupiedFeedbackFunc + { + get + { + return () => InTestMode ? TestRoomIsOccupiedFeedback : OccSensor.OccupancyDetectedFeedback.BoolValue; + } + } + + protected GlsOccupancySensorBaseController(string key, DeviceConfig config) + : this(key, config.Name, config) + { + } + + protected GlsOccupancySensorBaseController(string key, string name, DeviceConfig config) + : base(key, name) + { + + var props = config.Properties.ToObject(); + + if (props != null) + { + PropertiesConfig = props; + } + else + { + Debug.Console(1, this, "props are null. Unable to deserialize into GlsOccupancySensorPropertiesConfig"); + } + + AddPostActivationAction(() => + { + OccSensor.OnlineStatusChange += (o, a) => + { + if (a.DeviceOnLine) + { + ApplySettingsToSensorFromConfig(); + } + }; + + if (OccSensor.IsOnline) + { + ApplySettingsToSensorFromConfig(); + + } + }); + } + + + /// + /// Applies any sensor settings defined in config + /// + protected virtual void ApplySettingsToSensorFromConfig() + { + Debug.Console(1, this, "Attempting to apply settings to sensor from config"); + + if (PropertiesConfig.EnablePir != null) + { + Debug.Console(1, this, "EnablePir found, attempting to set value from config"); + SetPirEnable((bool)PropertiesConfig.EnablePir); + } + else + { + Debug.Console(1, this, "EnablePir null, no value specified in config"); + } + + if (PropertiesConfig.EnableLedFlash != null) + { + Debug.Console(1, this, "EnableLedFlash found, attempting to set value from config"); + SetLedFlashEnable((bool)PropertiesConfig.EnableLedFlash); + } + + if (PropertiesConfig.RemoteTimeout != null) + { + Debug.Console(1, this, "RemoteTimeout found, attempting to set value from config"); + SetRemoteTimeout((ushort)PropertiesConfig.RemoteTimeout); + } + else + { + Debug.Console(1, this, "RemoteTimeout null, no value specified in config"); + } + + if (PropertiesConfig.ShortTimeoutState != null) + { + SetShortTimeoutState((bool)PropertiesConfig.ShortTimeoutState); + } + + if (PropertiesConfig.EnableRawStates != null) + { + EnableRawStates((bool)PropertiesConfig.EnableRawStates); + } + + if (PropertiesConfig.InternalPhotoSensorMinChange != null) + { + SetInternalPhotoSensorMinChange((ushort)PropertiesConfig.InternalPhotoSensorMinChange); + } + + if (PropertiesConfig.ExternalPhotoSensorMinChange != null) + { + SetExternalPhotoSensorMinChange((ushort)PropertiesConfig.ExternalPhotoSensorMinChange); + } + } + + protected void RegisterGlsOccupancySensorBaseController(GlsOccupancySensorBase occSensor) + { + OccSensor = occSensor; + + RoomIsOccupiedFeedback = new BoolFeedback(RoomIsOccupiedFeedbackFunc); + + PirSensorEnabledFeedback = new BoolFeedback(() => OccSensor.PirEnabledFeedback.BoolValue); + + LedFlashEnabledFeedback = new BoolFeedback(() => OccSensor.LedFlashEnabledFeedback.BoolValue); + + ShortTimeoutEnabledFeedback = new BoolFeedback(() => OccSensor.ShortTimeoutEnabledFeedback.BoolValue); + + PirSensitivityInVacantStateFeedback = + new IntFeedback(() => OccSensor.PirSensitivityInVacantStateFeedback.UShortValue); + + PirSensitivityInOccupiedStateFeedback = + new IntFeedback(() => OccSensor.PirSensitivityInOccupiedStateFeedback.UShortValue); + + CurrentTimeoutFeedback = new IntFeedback(() => OccSensor.CurrentTimeoutFeedback.UShortValue); + + LocalTimoutFeedback = new IntFeedback(() => OccSensor.LocalTimeoutFeedback.UShortValue); + + GraceOccupancyDetectedFeedback = + new BoolFeedback(() => OccSensor.GraceOccupancyDetectedFeedback.BoolValue); + + RawOccupancyFeedback = new BoolFeedback(() => OccSensor.RawOccupancyFeedback.BoolValue); + + InternalPhotoSensorValue = new IntFeedback(() => OccSensor.InternalPhotoSensorValueFeedback.UShortValue); + + ExternalPhotoSensorValue = new IntFeedback(() => OccSensor.ExternalPhotoSensorValueFeedback.UShortValue); + + OccSensor.BaseEvent += OccSensor_BaseEvent; + + OccSensor.GlsOccupancySensorChange += OccSensor_GlsOccupancySensorChange; + } + + + /// + /// Catches events for feedbacks on the base class. Any extending wrapper class should call this delegate after it checks for it's own event IDs. + /// + /// + /// + protected virtual void OccSensor_GlsOccupancySensorChange(GlsOccupancySensorBase device, GlsOccupancySensorChangeEventArgs args) + { + switch (args.EventId) + { + case GlsOccupancySensorBase.PirEnabledFeedbackEventId: + PirSensorEnabledFeedback.FireUpdate(); + break; + case GlsOccupancySensorBase.LedFlashEnabledFeedbackEventId: + LedFlashEnabledFeedback.FireUpdate(); + break; + case GlsOccupancySensorBase.ShortTimeoutEnabledFeedbackEventId: + ShortTimeoutEnabledFeedback.FireUpdate(); + break; + case GlsOccupancySensorBase.PirSensitivityInOccupiedStateFeedbackEventId: + PirSensitivityInOccupiedStateFeedback.FireUpdate(); + break; + case GlsOccupancySensorBase.PirSensitivityInVacantStateFeedbackEventId: + PirSensitivityInVacantStateFeedback.FireUpdate(); + break; + } + } + + protected virtual void OccSensor_BaseEvent(Crestron.SimplSharpPro.GenericBase device, Crestron.SimplSharpPro.BaseEventArgs args) + { + Debug.Console(2, this, "GlsOccupancySensorChange EventId: {0}", args.EventId); + + switch (args.EventId) + { + case GlsOccupancySensorBase.RoomVacantFeedbackEventId: + case GlsOccupancySensorBase.RoomOccupiedFeedbackEventId: + Debug.Console(1, this, "Occupancy State: {0}", OccSensor.OccupancyDetectedFeedback.BoolValue); + RoomIsOccupiedFeedback.FireUpdate(); + break; + case GlsOccupancySensorBase.TimeoutFeedbackEventId: + CurrentTimeoutFeedback.FireUpdate(); + break; + case GlsOccupancySensorBase.TimeoutLocalFeedbackEventId: + LocalTimoutFeedback.FireUpdate(); + break; + case GlsOccupancySensorBase.GraceOccupancyDetectedFeedbackEventId: + GraceOccupancyDetectedFeedback.FireUpdate(); + break; + case GlsOccupancySensorBase.RawOccupancyFeedbackEventId: + RawOccupancyFeedback.FireUpdate(); + break; + case GlsOccupancySensorBase.InternalPhotoSensorValueFeedbackEventId: + InternalPhotoSensorValue.FireUpdate(); + break; + case GlsOccupancySensorBase.ExternalPhotoSensorValueFeedbackEventId: + ExternalPhotoSensorValue.FireUpdate(); + break; + } + } + + public void SetTestMode(bool mode) + { + InTestMode = mode; + + Debug.Console(1, this, "In Mock Mode: '{0}'", InTestMode); + } + + public void SetTestOccupiedState(bool state) + { + if (!InTestMode) + Debug.Console(1, "Mock mode not enabled"); + else + { + TestRoomIsOccupiedFeedback = state; + + RoomIsOccupiedFeedback.FireUpdate(); + } + } + + /// + /// Enables or disables the PIR sensor + /// + /// + public void SetPirEnable(bool state) + { + Debug.Console(1, this, "Setting EnablePir to: {0}", state); + + OccSensor.EnablePir.BoolValue = state; + OccSensor.DisablePir.BoolValue = !state; + } + + /// + /// Enables or disables the LED Flash + /// + /// + public void SetLedFlashEnable(bool state) + { + OccSensor.EnableLedFlash.BoolValue = state; + OccSensor.DisableLedFlash.BoolValue = !state; + } + + /// + /// Enables or disables short timeout based on state + /// + /// + public void SetShortTimeoutState(bool state) + { + OccSensor.EnableShortTimeout.BoolValue = state; + OccSensor.DisableShortTimeout.BoolValue = !state; + } + + public void IncrementPirSensitivityInOccupiedState(bool pressRelease) + { + OccSensor.IncrementPirSensitivityInOccupiedState.BoolValue = pressRelease; + } + + public void DecrementPirSensitivityInOccupiedState(bool pressRelease) + { + OccSensor.DecrementPirSensitivityInOccupiedState.BoolValue = pressRelease; + } + + public void IncrementPirSensitivityInVacantState(bool pressRelease) + { + OccSensor.IncrementPirSensitivityInVacantState.BoolValue = pressRelease; + } + + public void DecrementPirSensitivityInVacantState(bool pressRelease) + { + OccSensor.DecrementPirSensitivityInVacantState.BoolValue = pressRelease; + } + + /// + /// Pulse ForceOccupied on the sensor for .5 seconds + /// + public void ForceOccupied() + { + CrestronInvoke.BeginInvoke((o) => + { + ForceOccupied(true); + CrestronEnvironment.Sleep(500); + ForceOccupied(false); + }); + } + + public void ForceOccupied(bool value) + { + OccSensor.ForceOccupied.BoolValue = value; + } + + /// + /// Pulse ForceVacant on the sensor for .5 seconds + /// + public void ForceVacant() + { + CrestronInvoke.BeginInvoke((o) => + { + ForceVacant(true); + CrestronEnvironment.Sleep(500); + ForceVacant(false); + }); + } + + public void ForceVacant(bool value) + { + OccSensor.ForceVacant.BoolValue = value; + } + + public void EnableRawStates(bool state) + { + OccSensor.EnableRawStates.BoolValue = state; + } + + public void SetRemoteTimeout(ushort time) + { + Debug.Console(1, this, "Setting RemoteTimout to: {0}", time); + + OccSensor.RemoteTimeout.UShortValue = time; + } + + public void SetInternalPhotoSensorMinChange(ushort value) + { + OccSensor.InternalPhotoSensorMinimumChange.UShortValue = value; + } + + public void SetExternalPhotoSensorMinChange(ushort value) + { + OccSensor.ExternalPhotoSensorMinimumChange.UShortValue = value; + } + + /// + /// Method to print current occ settings to console. + /// + public virtual void GetSettings() + { + var dash = new string('*', 50); + CrestronConsole.PrintLine(string.Format("{0}\n", dash)); + + Debug.Console(0, this, "Vacancy Detected: {0}", + OccSensor.VacancyDetectedFeedback.BoolValue); + + Debug.Console(0, this, "Timeout Current: {0} | Local: {1}", + OccSensor.CurrentTimeoutFeedback.UShortValue, + OccSensor.LocalTimeoutFeedback.UShortValue); + + Debug.Console(0, this, "Short Timeout Enabled: {0}", + OccSensor.ShortTimeoutEnabledFeedback.BoolValue); + + Debug.Console(0, this, "PIR Sensor Enabled: {0} | Sensitivity Occupied: {1} | Sensitivity Vacant: {2}", + OccSensor.PirEnabledFeedback.BoolValue, + OccSensor.PirSensitivityInOccupiedStateFeedback.UShortValue, + OccSensor.PirSensitivityInVacantStateFeedback.UShortValue); + + CrestronConsole.PrintLine(string.Format("{0}\n", dash)); + } + + protected void LinkOccSensorToApi(GlsOccupancySensorBaseController occController, BasicTriList trilist, + uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new GlsOccupancySensorBaseJoinMap(joinStart); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + else + { + Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + } + + Debug.Console(1, occController, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + occController.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + trilist.StringInput[joinMap.Name.JoinNumber].StringValue = occController.Name; + + trilist.OnlineStatusChange += (d, args) => + { + if (args.DeviceOnLine) + { + trilist.StringInput[joinMap.Name.JoinNumber].StringValue = occController.Name; + } + }; + + LinkSingleTechSensorToApi(occController, trilist, joinMap); + + LinkDualTechSensorToApi(occController, trilist, joinMap); + } + + private static void LinkDualTechSensorToApi(GlsOccupancySensorBaseController occController, BasicTriList trilist, + GlsOccupancySensorBaseJoinMap joinMap) + { + var odtOccController = occController as GlsOdtOccupancySensorController; + + if (odtOccController == null) + { + return; + } + // OR When Vacated + trilist.SetBoolSigAction(joinMap.OrWhenVacated.JoinNumber, odtOccController.SetOrWhenVacatedState); + odtOccController.OrWhenVacatedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.OrWhenVacated.JoinNumber]); + + // AND When Vacated + trilist.SetBoolSigAction(joinMap.AndWhenVacated.JoinNumber, odtOccController.SetAndWhenVacatedState); + odtOccController.AndWhenVacatedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.AndWhenVacated.JoinNumber]); + + // Ultrasonic A Sensor + trilist.SetSigTrueAction(joinMap.EnableUsA.JoinNumber, () => odtOccController.SetUsAEnable(true)); + trilist.SetSigTrueAction(joinMap.DisableUsA.JoinNumber, () => odtOccController.SetUsAEnable(false)); + odtOccController.UltrasonicAEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableUsA.JoinNumber]); + + // Ultrasonic B Sensor + trilist.SetSigTrueAction(joinMap.EnableUsB.JoinNumber, () => odtOccController.SetUsBEnable(true)); + trilist.SetSigTrueAction(joinMap.DisableUsB.JoinNumber, () => odtOccController.SetUsBEnable(false)); + odtOccController.UltrasonicBEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableUsB.JoinNumber]); + + // US Sensitivity in Occupied State + trilist.SetBoolSigAction(joinMap.IncrementUsInOccupiedState.JoinNumber, + odtOccController.IncrementUsSensitivityInOccupiedState); + trilist.SetBoolSigAction(joinMap.DecrementUsInOccupiedState.JoinNumber, + odtOccController.DecrementUsSensitivityInOccupiedState); + odtOccController.UltrasonicSensitivityInOccupiedStateFeedback.LinkInputSig( + trilist.UShortInput[joinMap.UsSensitivityInOccupiedState.JoinNumber]); + + // US Sensitivity in Vacant State + trilist.SetBoolSigAction(joinMap.IncrementUsInVacantState.JoinNumber, + odtOccController.IncrementUsSensitivityInVacantState); + trilist.SetBoolSigAction(joinMap.DecrementUsInVacantState.JoinNumber, + odtOccController.DecrementUsSensitivityInVacantState); + odtOccController.UltrasonicSensitivityInVacantStateFeedback.LinkInputSig( + trilist.UShortInput[joinMap.UsSensitivityInVacantState.JoinNumber]); + + //Sensor Raw States + odtOccController.RawOccupancyPirFeedback.LinkInputSig( + trilist.BooleanInput[joinMap.RawOccupancyPirFeedback.JoinNumber]); + odtOccController.RawOccupancyUsFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyUsFeedback.JoinNumber]); + } + + private static void LinkSingleTechSensorToApi(GlsOccupancySensorBaseController occController, BasicTriList trilist, + GlsOccupancySensorBaseJoinMap joinMap) + { +// Occupied status + trilist.SetBoolSigAction(joinMap.ForceOccupied.JoinNumber, occController.ForceOccupied); + trilist.SetBoolSigAction(joinMap.ForceVacant.JoinNumber, occController.ForceVacant); + occController.RoomIsOccupiedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RoomOccupiedFeedback.JoinNumber]); + occController.RoomIsOccupiedFeedback.LinkComplementInputSig( + trilist.BooleanInput[joinMap.RoomVacantFeedback.JoinNumber]); + occController.RawOccupancyFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyFeedback.JoinNumber]); + trilist.SetBoolSigAction(joinMap.EnableRawStates.JoinNumber, occController.EnableRawStates); + + // Timouts + trilist.SetUShortSigAction(joinMap.Timeout.JoinNumber, occController.SetRemoteTimeout); + occController.CurrentTimeoutFeedback.LinkInputSig(trilist.UShortInput[joinMap.Timeout.JoinNumber]); + occController.LocalTimoutFeedback.LinkInputSig(trilist.UShortInput[joinMap.TimeoutLocalFeedback.JoinNumber]); + + // LED Flash + trilist.SetSigTrueAction(joinMap.EnableLedFlash.JoinNumber, () => occController.SetLedFlashEnable(true)); + trilist.SetSigTrueAction(joinMap.DisableLedFlash.JoinNumber, () => occController.SetLedFlashEnable(false)); + occController.LedFlashEnabledFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.EnableLedFlash.JoinNumber]); + + // Short Timeout + trilist.SetSigTrueAction(joinMap.EnableShortTimeout.JoinNumber, () => occController.SetShortTimeoutState(true)); + trilist.SetSigTrueAction(joinMap.DisableShortTimeout.JoinNumber, () => occController.SetShortTimeoutState(false)); + occController.ShortTimeoutEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableShortTimeout.JoinNumber]); + + // PIR Sensor + trilist.SetSigTrueAction(joinMap.EnablePir.JoinNumber, () => occController.SetPirEnable(true)); + trilist.SetSigTrueAction(joinMap.DisablePir.JoinNumber, () => occController.SetPirEnable(false)); + occController.PirSensorEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnablePir.JoinNumber]); + + // PIR Sensitivity in Occupied State + trilist.SetBoolSigAction(joinMap.IncrementPirInOccupiedState.JoinNumber, + occController.IncrementPirSensitivityInOccupiedState); + trilist.SetBoolSigAction(joinMap.DecrementPirInOccupiedState.JoinNumber, + occController.DecrementPirSensitivityInOccupiedState); + occController.PirSensitivityInOccupiedStateFeedback.LinkInputSig( + trilist.UShortInput[joinMap.PirSensitivityInOccupiedState.JoinNumber]); + + // PIR Sensitivity in Vacant State + trilist.SetBoolSigAction(joinMap.IncrementPirInVacantState.JoinNumber, + occController.IncrementPirSensitivityInVacantState); + trilist.SetBoolSigAction(joinMap.DecrementPirInVacantState.JoinNumber, + occController.DecrementPirSensitivityInVacantState); + occController.PirSensitivityInVacantStateFeedback.LinkInputSig( + trilist.UShortInput[joinMap.PirSensitivityInVacantState.JoinNumber]); + } + } + + + } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOccupancySensorPropertiesConfig.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOccupancySensorPropertiesConfig.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOccupancySensorPropertiesConfig.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOccupancySensorPropertiesConfig.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOdtOccupancySensorController.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOdtOccupancySensorController.cs similarity index 97% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOdtOccupancySensorController.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOdtOccupancySensorController.cs index d5e18280..dd6b3605 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOdtOccupancySensorController.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOdtOccupancySensorController.cs @@ -1,284 +1,284 @@ -using System; -using System.Collections.Generic; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.GeneralIO; - -using PepperDash.Core; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.Core -{ - [Description("Wrapper class for Dual Technology GLS Occupancy Sensors")] - [ConfigSnippet("\"properties\": {\"control\": {\"method\": \"cresnet\",\"cresnetId\": \"97\"},\"enablePir\": true,\"enableLedFlash\": true,\"enableRawStates\":true,\"remoteTimeout\": 30,\"internalPhotoSensorMinChange\": 0,\"externalPhotoSensorMinChange\": 0,\"enableUsA\": true,\"enableUsB\": true,\"orWhenVacatedState\": true}")] - public class GlsOdtOccupancySensorController : GlsOccupancySensorBaseController - { - private GlsOdtCCn _occSensor; - - public BoolFeedback OrWhenVacatedFeedback { get; private set; } - - public BoolFeedback AndWhenVacatedFeedback { get; private set; } - - public BoolFeedback UltrasonicAEnabledFeedback { get; private set; } - - public BoolFeedback UltrasonicBEnabledFeedback { get; private set; } - - public IntFeedback UltrasonicSensitivityInVacantStateFeedback { get; private set; } - - public IntFeedback UltrasonicSensitivityInOccupiedStateFeedback { get; private set; } - - public BoolFeedback RawOccupancyPirFeedback { get; private set; } - - public BoolFeedback RawOccupancyUsFeedback { get; private set; } - - - public GlsOdtOccupancySensorController(string key, Func preActivationFunc, - DeviceConfig config) - : base(key, config.Name, config) - { - AddPreActivationAction(() => - { - _occSensor = preActivationFunc(config); - - RegisterCrestronGenericBase(_occSensor); - - RegisterGlsOccupancySensorBaseController(_occSensor); - - AndWhenVacatedFeedback = new BoolFeedback(() => _occSensor.AndWhenVacatedFeedback.BoolValue); - - OrWhenVacatedFeedback = new BoolFeedback(() => _occSensor.OrWhenVacatedFeedback.BoolValue); - - UltrasonicAEnabledFeedback = new BoolFeedback(() => _occSensor.UsAEnabledFeedback.BoolValue); - - UltrasonicBEnabledFeedback = new BoolFeedback(() => _occSensor.UsBEnabledFeedback.BoolValue); - - RawOccupancyPirFeedback = new BoolFeedback(() => _occSensor.RawOccupancyPirFeedback.BoolValue); - - RawOccupancyUsFeedback = new BoolFeedback(() => _occSensor.RawOccupancyUsFeedback.BoolValue); - - UltrasonicSensitivityInVacantStateFeedback = new IntFeedback(() => _occSensor.UsSensitivityInVacantStateFeedback.UShortValue); - - UltrasonicSensitivityInOccupiedStateFeedback = new IntFeedback(() => _occSensor.UsSensitivityInOccupiedStateFeedback.UShortValue); - - }); - } - - protected override void ApplySettingsToSensorFromConfig() - { - base.ApplySettingsToSensorFromConfig(); - - if (PropertiesConfig.EnableUsA != null) - { - Debug.Console(1, this, "EnableUsA found, attempting to set value from config"); - SetUsAEnable((bool)PropertiesConfig.EnableUsA); - } - else - { - Debug.Console(1, this, "EnableUsA null, no value specified in config"); - } - - - if (PropertiesConfig.EnableUsB != null) - { - Debug.Console(1, this, "EnableUsB found, attempting to set value from config"); - SetUsBEnable((bool)PropertiesConfig.EnableUsB); - } - else - { - Debug.Console(1, this, "EnablePir null, no value specified in config"); - } - - - if (PropertiesConfig.OrWhenVacatedState != null) - { - SetOrWhenVacatedState((bool)PropertiesConfig.OrWhenVacatedState); - } - - if (PropertiesConfig.AndWhenVacatedState != null) - { - SetAndWhenVacatedState((bool)PropertiesConfig.AndWhenVacatedState); - } - } - - /// - /// Overrides the base class event delegate to fire feedbacks for event IDs that pertain to this extended class. - /// Then calls the base delegate method to ensure any common event IDs are captured. - /// - /// - /// - protected override void OccSensor_GlsOccupancySensorChange(GlsOccupancySensorBase device, GlsOccupancySensorChangeEventArgs args) - { - switch (args.EventId) - { - case GlsOccupancySensorBase.AndWhenVacatedFeedbackEventId: - AndWhenVacatedFeedback.FireUpdate(); - break; - case GlsOccupancySensorBase.OrWhenVacatedFeedbackEventId: - OrWhenVacatedFeedback.FireUpdate(); - break; - case GlsOccupancySensorBase.UsAEnabledFeedbackEventId: - UltrasonicAEnabledFeedback.FireUpdate(); - break; - case GlsOccupancySensorBase.UsBEnabledFeedbackEventId: - UltrasonicBEnabledFeedback.FireUpdate(); - break; - case GlsOccupancySensorBase.UsSensitivityInOccupiedStateFeedbackEventId: - UltrasonicSensitivityInOccupiedStateFeedback.FireUpdate(); - break; - case GlsOccupancySensorBase.UsSensitivityInVacantStateFeedbackEventId: - UltrasonicSensitivityInVacantStateFeedback.FireUpdate(); - break; - } - - base.OccSensor_GlsOccupancySensorChange(device, args); - } - - /// - /// Overrides the base class event delegate to fire feedbacks for event IDs that pertain to this extended class. - /// Then calls the base delegate method to ensure any common event IDs are captured. - /// - /// - /// - protected override void OccSensor_BaseEvent(Crestron.SimplSharpPro.GenericBase device, Crestron.SimplSharpPro.BaseEventArgs args) - { - switch (args.EventId) - { - case GlsOccupancySensorBase.RawOccupancyPirFeedbackEventId: - RawOccupancyPirFeedback.FireUpdate(); - break; - case GlsOccupancySensorBase.RawOccupancyUsFeedbackEventId: - RawOccupancyUsFeedback.FireUpdate(); - break; - } - - base.OccSensor_BaseEvent(device, args); - } - - /// - /// Sets the OrWhenVacated state - /// - /// - public void SetOrWhenVacatedState(bool state) - { - _occSensor.OrWhenVacated.BoolValue = state; - } - - /// - /// Sets the AndWhenVacated state - /// - /// - public void SetAndWhenVacatedState(bool state) - { - _occSensor.AndWhenVacated.BoolValue = state; - } - - /// - /// Enables or disables the Ultrasonic A sensor - /// - /// - public void SetUsAEnable(bool state) - { - _occSensor.EnableUsA.BoolValue = state; - _occSensor.DisableUsA.BoolValue = !state; - } - - - /// - /// Enables or disables the Ultrasonic B sensor - /// - /// - public void SetUsBEnable(bool state) - { - _occSensor.EnableUsB.BoolValue = state; - _occSensor.DisableUsB.BoolValue = !state; - } - - public void IncrementUsSensitivityInOccupiedState(bool pressRelease) - { - _occSensor.IncrementUsSensitivityInOccupiedState.BoolValue = pressRelease; - } - - public void DecrementUsSensitivityInOccupiedState(bool pressRelease) - { - _occSensor.DecrementUsSensitivityInOccupiedState.BoolValue = pressRelease; - } - - public void IncrementUsSensitivityInVacantState(bool pressRelease) - { - _occSensor.IncrementUsSensitivityInVacantState.BoolValue = pressRelease; - } - - public void DecrementUsSensitivityInVacantState(bool pressRelease) - { - _occSensor.DecrementUsSensitivityInVacantState.BoolValue = pressRelease; - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - LinkOccSensorToApi(this, trilist, joinStart, joinMapKey, bridge); - } - - /// - /// Method to print occ sensor settings to console. - /// - public override void GetSettings() - { - base.GetSettings(); - - Debug.Console(0, this, "Ultrasonic Enabled A: {0} | B: {1}", - _occSensor.UsAEnabledFeedback.BoolValue, - _occSensor.UsBEnabledFeedback.BoolValue); - - Debug.Console(0, this, "Ultrasonic Sensitivity Occupied: {0} | Vacant: {1}", - _occSensor.UsSensitivityInOccupiedStateFeedback.UShortValue, - _occSensor.UsSensitivityInVacantStateFeedback.UShortValue); - - var dash = new string('*', 50); - CrestronConsole.PrintLine(string.Format("{0}\n", dash)); - } - - } - - public class GlsOdtOccupancySensorControllerFactory : EssentialsDeviceFactory - { - public GlsOdtOccupancySensorControllerFactory() - { - TypeNames = new List { "glsodtccn" }; - } - - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new GlsOccupancySensorBaseController Device"); - - return new GlsOdtOccupancySensorController(dc.Key, GetGlsOdtCCn, dc); - } - - private static GlsOdtCCn GetGlsOdtCCn(DeviceConfig dc) - { - var control = CommFactory.GetControlPropertiesConfig(dc); - var cresnetId = control.CresnetIdInt; - var branchId = control.ControlPortNumber; - var parentKey = String.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey; - - if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase)) - { - Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOdtCCn", parentKey); - return new GlsOdtCCn(cresnetId, Global.ControlSystem); - } - var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches; - - if (cresnetBridge != null) - { - Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOdtCCn", parentKey); - return new GlsOdtCCn(cresnetId, cresnetBridge.CresnetBranches[branchId]); - } - Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); - return null; - } - } - - - +using System; +using System.Collections.Generic; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.GeneralIO; + +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.Core.Bridges; + +namespace PepperDash.Essentials.Core +{ + [Description("Wrapper class for Dual Technology GLS Occupancy Sensors")] + [ConfigSnippet("\"properties\": {\"control\": {\"method\": \"cresnet\",\"cresnetId\": \"97\"},\"enablePir\": true,\"enableLedFlash\": true,\"enableRawStates\":true,\"remoteTimeout\": 30,\"internalPhotoSensorMinChange\": 0,\"externalPhotoSensorMinChange\": 0,\"enableUsA\": true,\"enableUsB\": true,\"orWhenVacatedState\": true}")] + public class GlsOdtOccupancySensorController : GlsOccupancySensorBaseController + { + private GlsOdtCCn _occSensor; + + public BoolFeedback OrWhenVacatedFeedback { get; private set; } + + public BoolFeedback AndWhenVacatedFeedback { get; private set; } + + public BoolFeedback UltrasonicAEnabledFeedback { get; private set; } + + public BoolFeedback UltrasonicBEnabledFeedback { get; private set; } + + public IntFeedback UltrasonicSensitivityInVacantStateFeedback { get; private set; } + + public IntFeedback UltrasonicSensitivityInOccupiedStateFeedback { get; private set; } + + public BoolFeedback RawOccupancyPirFeedback { get; private set; } + + public BoolFeedback RawOccupancyUsFeedback { get; private set; } + + + public GlsOdtOccupancySensorController(string key, Func preActivationFunc, + DeviceConfig config) + : base(key, config.Name, config) + { + AddPreActivationAction(() => + { + _occSensor = preActivationFunc(config); + + RegisterCrestronGenericBase(_occSensor); + + RegisterGlsOccupancySensorBaseController(_occSensor); + + AndWhenVacatedFeedback = new BoolFeedback(() => _occSensor.AndWhenVacatedFeedback.BoolValue); + + OrWhenVacatedFeedback = new BoolFeedback(() => _occSensor.OrWhenVacatedFeedback.BoolValue); + + UltrasonicAEnabledFeedback = new BoolFeedback(() => _occSensor.UsAEnabledFeedback.BoolValue); + + UltrasonicBEnabledFeedback = new BoolFeedback(() => _occSensor.UsBEnabledFeedback.BoolValue); + + RawOccupancyPirFeedback = new BoolFeedback(() => _occSensor.RawOccupancyPirFeedback.BoolValue); + + RawOccupancyUsFeedback = new BoolFeedback(() => _occSensor.RawOccupancyUsFeedback.BoolValue); + + UltrasonicSensitivityInVacantStateFeedback = new IntFeedback(() => _occSensor.UsSensitivityInVacantStateFeedback.UShortValue); + + UltrasonicSensitivityInOccupiedStateFeedback = new IntFeedback(() => _occSensor.UsSensitivityInOccupiedStateFeedback.UShortValue); + + }); + } + + protected override void ApplySettingsToSensorFromConfig() + { + base.ApplySettingsToSensorFromConfig(); + + if (PropertiesConfig.EnableUsA != null) + { + Debug.Console(1, this, "EnableUsA found, attempting to set value from config"); + SetUsAEnable((bool)PropertiesConfig.EnableUsA); + } + else + { + Debug.Console(1, this, "EnableUsA null, no value specified in config"); + } + + + if (PropertiesConfig.EnableUsB != null) + { + Debug.Console(1, this, "EnableUsB found, attempting to set value from config"); + SetUsBEnable((bool)PropertiesConfig.EnableUsB); + } + else + { + Debug.Console(1, this, "EnablePir null, no value specified in config"); + } + + + if (PropertiesConfig.OrWhenVacatedState != null) + { + SetOrWhenVacatedState((bool)PropertiesConfig.OrWhenVacatedState); + } + + if (PropertiesConfig.AndWhenVacatedState != null) + { + SetAndWhenVacatedState((bool)PropertiesConfig.AndWhenVacatedState); + } + } + + /// + /// Overrides the base class event delegate to fire feedbacks for event IDs that pertain to this extended class. + /// Then calls the base delegate method to ensure any common event IDs are captured. + /// + /// + /// + protected override void OccSensor_GlsOccupancySensorChange(GlsOccupancySensorBase device, GlsOccupancySensorChangeEventArgs args) + { + switch (args.EventId) + { + case GlsOccupancySensorBase.AndWhenVacatedFeedbackEventId: + AndWhenVacatedFeedback.FireUpdate(); + break; + case GlsOccupancySensorBase.OrWhenVacatedFeedbackEventId: + OrWhenVacatedFeedback.FireUpdate(); + break; + case GlsOccupancySensorBase.UsAEnabledFeedbackEventId: + UltrasonicAEnabledFeedback.FireUpdate(); + break; + case GlsOccupancySensorBase.UsBEnabledFeedbackEventId: + UltrasonicBEnabledFeedback.FireUpdate(); + break; + case GlsOccupancySensorBase.UsSensitivityInOccupiedStateFeedbackEventId: + UltrasonicSensitivityInOccupiedStateFeedback.FireUpdate(); + break; + case GlsOccupancySensorBase.UsSensitivityInVacantStateFeedbackEventId: + UltrasonicSensitivityInVacantStateFeedback.FireUpdate(); + break; + } + + base.OccSensor_GlsOccupancySensorChange(device, args); + } + + /// + /// Overrides the base class event delegate to fire feedbacks for event IDs that pertain to this extended class. + /// Then calls the base delegate method to ensure any common event IDs are captured. + /// + /// + /// + protected override void OccSensor_BaseEvent(Crestron.SimplSharpPro.GenericBase device, Crestron.SimplSharpPro.BaseEventArgs args) + { + switch (args.EventId) + { + case GlsOccupancySensorBase.RawOccupancyPirFeedbackEventId: + RawOccupancyPirFeedback.FireUpdate(); + break; + case GlsOccupancySensorBase.RawOccupancyUsFeedbackEventId: + RawOccupancyUsFeedback.FireUpdate(); + break; + } + + base.OccSensor_BaseEvent(device, args); + } + + /// + /// Sets the OrWhenVacated state + /// + /// + public void SetOrWhenVacatedState(bool state) + { + _occSensor.OrWhenVacated.BoolValue = state; + } + + /// + /// Sets the AndWhenVacated state + /// + /// + public void SetAndWhenVacatedState(bool state) + { + _occSensor.AndWhenVacated.BoolValue = state; + } + + /// + /// Enables or disables the Ultrasonic A sensor + /// + /// + public void SetUsAEnable(bool state) + { + _occSensor.EnableUsA.BoolValue = state; + _occSensor.DisableUsA.BoolValue = !state; + } + + + /// + /// Enables or disables the Ultrasonic B sensor + /// + /// + public void SetUsBEnable(bool state) + { + _occSensor.EnableUsB.BoolValue = state; + _occSensor.DisableUsB.BoolValue = !state; + } + + public void IncrementUsSensitivityInOccupiedState(bool pressRelease) + { + _occSensor.IncrementUsSensitivityInOccupiedState.BoolValue = pressRelease; + } + + public void DecrementUsSensitivityInOccupiedState(bool pressRelease) + { + _occSensor.DecrementUsSensitivityInOccupiedState.BoolValue = pressRelease; + } + + public void IncrementUsSensitivityInVacantState(bool pressRelease) + { + _occSensor.IncrementUsSensitivityInVacantState.BoolValue = pressRelease; + } + + public void DecrementUsSensitivityInVacantState(bool pressRelease) + { + _occSensor.DecrementUsSensitivityInVacantState.BoolValue = pressRelease; + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + LinkOccSensorToApi(this, trilist, joinStart, joinMapKey, bridge); + } + + /// + /// Method to print occ sensor settings to console. + /// + public override void GetSettings() + { + base.GetSettings(); + + Debug.Console(0, this, "Ultrasonic Enabled A: {0} | B: {1}", + _occSensor.UsAEnabledFeedback.BoolValue, + _occSensor.UsBEnabledFeedback.BoolValue); + + Debug.Console(0, this, "Ultrasonic Sensitivity Occupied: {0} | Vacant: {1}", + _occSensor.UsSensitivityInOccupiedStateFeedback.UShortValue, + _occSensor.UsSensitivityInVacantStateFeedback.UShortValue); + + var dash = new string('*', 50); + CrestronConsole.PrintLine(string.Format("{0}\n", dash)); + } + + } + + public class GlsOdtOccupancySensorControllerFactory : EssentialsDeviceFactory + { + public GlsOdtOccupancySensorControllerFactory() + { + TypeNames = new List { "glsodtccn" }; + } + + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new GlsOccupancySensorBaseController Device"); + + return new GlsOdtOccupancySensorController(dc.Key, GetGlsOdtCCn, dc); + } + + private static GlsOdtCCn GetGlsOdtCCn(DeviceConfig dc) + { + var control = CommFactory.GetControlPropertiesConfig(dc); + var cresnetId = control.CresnetIdInt; + var branchId = control.ControlPortNumber; + var parentKey = String.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey; + + if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase)) + { + Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOdtCCn", parentKey); + return new GlsOdtCCn(cresnetId, Global.ControlSystem); + } + var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches; + + if (cresnetBridge != null) + { + Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOdtCCn", parentKey); + return new GlsOdtCCn(cresnetId, cresnetBridge.CresnetBranches[branchId]); + } + Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); + return null; + } + } + + + } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOirOccupancySensorController.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOirOccupancySensorController.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOirOccupancySensorController.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOirOccupancySensorController.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/IOccupancyStatusProviderAggregator.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/IOccupancyStatusProviderAggregator.cs similarity index 98% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/IOccupancyStatusProviderAggregator.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/IOccupancyStatusProviderAggregator.cs index 3da9c0dc..dfa4fef1 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/IOccupancyStatusProviderAggregator.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/IOccupancyStatusProviderAggregator.cs @@ -2,12 +2,12 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.GeneralIO; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.GeneralIO; using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; - +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + namespace PepperDash.Essentials.Core { /// @@ -32,41 +32,41 @@ namespace PepperDash.Essentials.Core : base(key, name) { _aggregatedOccupancyStatus = new BoolFeedbackOr(); - } - - public IOccupancyStatusProviderAggregator(string key, string name, OccupancyAggregatorConfig config) - : this(key, name) - { - AddPostActivationAction(() => - { - if (config.DeviceKeys.Count == 0) - { - return; - } - - foreach (var deviceKey in config.DeviceKeys) - { - var device = DeviceManager.GetDeviceForKey(deviceKey); - - if (device == null) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, - "Unable to retrieve Occupancy provider with key {0}", deviceKey); - continue; - } - - var provider = device as IOccupancyStatusProvider; - - if (provider == null) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, - "Device with key {0} does NOT implement IOccupancyStatusProvider. Please check configuration."); - continue; - } - - AddOccupancyStatusProvider(provider); - } - }); + } + + public IOccupancyStatusProviderAggregator(string key, string name, OccupancyAggregatorConfig config) + : this(key, name) + { + AddPostActivationAction(() => + { + if (config.DeviceKeys.Count == 0) + { + return; + } + + foreach (var deviceKey in config.DeviceKeys) + { + var device = DeviceManager.GetDeviceForKey(deviceKey); + + if (device == null) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, + "Unable to retrieve Occupancy provider with key {0}", deviceKey); + continue; + } + + var provider = device as IOccupancyStatusProvider; + + if (provider == null) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, + "Device with key {0} does NOT implement IOccupancyStatusProvider. Please check configuration."); + continue; + } + + AddOccupancyStatusProvider(provider); + } + }); } /// @@ -76,34 +76,34 @@ namespace PepperDash.Essentials.Core public void AddOccupancyStatusProvider(IOccupancyStatusProvider statusProvider) { _aggregatedOccupancyStatus.AddOutputIn(statusProvider.RoomIsOccupiedFeedback); - } - - public void RemoveOccupancyStatusProvider(IOccupancyStatusProvider statusProvider) - { - _aggregatedOccupancyStatus.RemoveOutputIn(statusProvider.RoomIsOccupiedFeedback); - } - - public void ClearOccupancyStatusProviders() - { - _aggregatedOccupancyStatus.ClearOutputs(); } - } - - public class OccupancyAggregatorFactory : EssentialsDeviceFactory - { - public OccupancyAggregatorFactory() - { - TypeNames = new List { "occupancyAggregator", "occAggregate" }; - } - - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new GlsOccupancySensorBaseController Device"); - - var config = dc.Properties.ToObject(); - - return new IOccupancyStatusProviderAggregator(dc.Key, dc.Name, config); - } + + public void RemoveOccupancyStatusProvider(IOccupancyStatusProvider statusProvider) + { + _aggregatedOccupancyStatus.RemoveOutputIn(statusProvider.RoomIsOccupiedFeedback); + } + + public void ClearOccupancyStatusProviders() + { + _aggregatedOccupancyStatus.ClearOutputs(); + } + } + + public class OccupancyAggregatorFactory : EssentialsDeviceFactory + { + public OccupancyAggregatorFactory() + { + TypeNames = new List { "occupancyAggregator", "occAggregate" }; + } + + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new GlsOccupancySensorBaseController Device"); + + var config = dc.Properties.ToObject(); + + return new IOccupancyStatusProviderAggregator(dc.Key, dc.Name, config); + } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/OccupancyAggregatorConfig.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/OccupancyAggregatorConfig.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/OccupancyAggregatorConfig.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/OccupancyAggregatorConfig.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/EssentialsPartitionController.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/EssentialsPartitionController.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/EssentialsPartitionController.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/EssentialsPartitionController.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorController.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorController.cs similarity index 97% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorController.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorController.cs index 73f15cf2..f19d1196 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorController.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorController.cs @@ -1,364 +1,364 @@ -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.GeneralIO; -using Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Bridges.JoinMaps; - -using System; -using System.Collections.Generic; -using PepperDash.Essentials.Core.Config; -using PepperDash_Essentials_Core.PartitionSensor; - -namespace PepperDash.Essentials.Core -{ - [Description("Wrapper class for GLS Cresnet Partition Sensor")] - public class GlsPartitionSensorController : CrestronGenericBridgeableBaseDevice, IPartitionStateProvider - { - - public GlsPartitionSensorPropertiesConfig PropertiesConfig { get; private set; } - - private GlsPartCn _partitionSensor; - - public BoolFeedback EnableFeedback { get; private set; } - public BoolFeedback PartitionPresentFeedback { get; private set; } - public BoolFeedback PartitionNotSensedFeedback { get; private set; } - public IntFeedback SensitivityFeedback { get; private set; } - - public bool InTestMode { get; private set; } - public bool TestEnableFeedback { get; private set; } - public bool TestPartitionSensedFeedback { get; private set; } - public int TestSensitivityFeedback { get; private set; } - - - public GlsPartitionSensorController(string key, Func preActivationFunc, DeviceConfig config) - : base(key, config.Name) - { - - var props = config.Properties.ToObject(); - if (props != null) - { - PropertiesConfig = props; - } - else - { - Debug.Console(1, this, "props are null. Unable to deserialize into GlsPartSensorPropertiesConfig"); - } - - AddPreActivationAction(() => - { - _partitionSensor = preActivationFunc(config); - - RegisterCrestronGenericBase(_partitionSensor); - - EnableFeedback = new BoolFeedback(() => InTestMode ? TestEnableFeedback : _partitionSensor.EnableFeedback.BoolValue); - PartitionPresentFeedback = new BoolFeedback(() => InTestMode ? TestPartitionSensedFeedback : _partitionSensor.PartitionSensedFeedback.BoolValue); - PartitionNotSensedFeedback = new BoolFeedback(() => InTestMode ? !TestPartitionSensedFeedback : _partitionSensor.PartitionNotSensedFeedback.BoolValue); - SensitivityFeedback = new IntFeedback(() => InTestMode ? TestSensitivityFeedback : _partitionSensor.SensitivityFeedback.UShortValue); - - if (_partitionSensor != null) - { - _partitionSensor.BaseEvent += PartitionSensor_BaseEvent; - } - }); - - AddPostActivationAction(() => - { - _partitionSensor.OnlineStatusChange += (o, a) => - { - if (a.DeviceOnLine) - { - ApplySettingsToSensorFromConfig(); - } - }; - - if (_partitionSensor.IsOnline) - { - ApplySettingsToSensorFromConfig(); - } - }); - } - - private void ApplySettingsToSensorFromConfig() - { - if (_partitionSensor.IsOnline == false) return; - - // Default to enable - _partitionSensor.Enable.BoolValue = true; - - Debug.Console(1, this, "Attempting to apply settings to sensor from config"); - - if (PropertiesConfig.Sensitivity != null) - { - Debug.Console(1, this, "Sensitivity found, attempting to set value '{0}' from config", - PropertiesConfig.Sensitivity); - _partitionSensor.Sensitivity.UShortValue = (ushort)PropertiesConfig.Sensitivity; - } - else - { - Debug.Console(1, this, "Sensitivity null, no value specified in config"); - } - - if (PropertiesConfig.Enable != null) - { - Debug.Console(1, this, "Enable found, attempting to set value '{0}' from config", - PropertiesConfig.Enable); - _partitionSensor.Enable.BoolValue = (bool)PropertiesConfig.Enable; - } - else - { - Debug.Console(1, this, "Enable null, no value specified in config"); - } - - } - - private void PartitionSensor_BaseEvent(GenericBase device, BaseEventArgs args) - { - Debug.Console(2, this, "EventId: {0}, Index: {1}", args.EventId, args.Index); - - switch (args.EventId) - { - case (GlsPartCn.EnableFeedbackEventId): - { - EnableFeedback.FireUpdate(); - break; - } - case (GlsPartCn.PartitionSensedFeedbackEventId): - { - Debug.Console(1, this, "Partition Sensed State: {0}", _partitionSensor.PartitionSensedFeedback.BoolValue); - PartitionPresentFeedback.FireUpdate(); - break; - } - case (GlsPartCn.PartitionNotSensedFeedbackEventId): - { - Debug.Console(1, this, "Partition Not Sensed State: {0}", _partitionSensor.PartitionNotSensedFeedback.BoolValue); - PartitionNotSensedFeedback.FireUpdate(); - break; - } - case (GlsPartCn.SensitivityFeedbackEventId): - { - SensitivityFeedback.FireUpdate(); - break; - } - default: - { - Debug.Console(2, this, "Unhandled args.EventId: {0}", args.EventId); - break; - } - } - } - - public void SetTestMode(bool mode) - { - InTestMode = mode; - Debug.Console(1, this, "InTestMode: {0}", InTestMode.ToString()); - } - - public void SetTestEnableState(bool state) - { - if (InTestMode) - { - TestEnableFeedback = state; - - EnableFeedback.FireUpdate(); - - Debug.Console(1, this, "TestEnableFeedback: {0}", TestEnableFeedback.ToString()); - return; - } - - Debug.Console(1, this, "InTestMode: {0}, unable to set enable state: {1}", InTestMode.ToString(), state.ToString()); - } - - public void SetTestPartitionSensedState(bool state) - { - if (InTestMode) - { - TestPartitionSensedFeedback = state; - - PartitionPresentFeedback.FireUpdate(); - PartitionNotSensedFeedback.FireUpdate(); - - Debug.Console(1, this, "TestPartitionSensedFeedback: {0}", TestPartitionSensedFeedback.ToString()); - return; - } - - Debug.Console(1, this, "InTestMode: {0}, unable to set partition state: {1}", InTestMode.ToString(), state.ToString()); - } - - public void SetTestSensitivityValue(int value) - { - if (InTestMode) - { - TestSensitivityFeedback = value; - - SensitivityFeedback.FireUpdate(); - Debug.Console(1, this, "TestSensitivityFeedback: {0}", TestSensitivityFeedback); - return; - } - - Debug.Console(1, this, "InTestMode: {0}, unable to set sensitivity value: {1}", InTestMode.ToString(), value); - } - - public void GetSettings() - { - var dash = new string('*', 50); - CrestronConsole.PrintLine(string.Format("{0}\n", dash)); - - Debug.Console(0, this, "Enabled State: {0}", _partitionSensor.EnableFeedback.BoolValue); - - Debug.Console(0, this, "Partition Sensed State: {0}", _partitionSensor.PartitionSensedFeedback.BoolValue); - Debug.Console(0, this, "Partition Not Sensed State: {0}", _partitionSensor.PartitionNotSensedFeedback.BoolValue); - - Debug.Console(0, this, "Sensitivity Value: {0}", _partitionSensor.SensitivityFeedback.UShortValue); - - CrestronConsole.PrintLine(string.Format("{0}\n", dash)); - } - - public void SetEnableState(bool state) - { - Debug.Console(2, this, "Sensor is {0}, SetEnableState: {1}", _partitionSensor == null ? "null" : "not null", state); - if (_partitionSensor == null) - return; - - _partitionSensor.Enable.BoolValue = state; - } - - public void IncreaseSensitivity() - { - Debug.Console(2, this, "Sensor is {0}, IncreaseSensitivity", _partitionSensor == null ? "null" : "not null"); - if (_partitionSensor == null) - return; - - _partitionSensor.IncreaseSensitivity(); - } - - public void DecreaseSensitivity() - { - Debug.Console(2, this, "Sensor is {0}, DecreaseSensitivity", _partitionSensor == null ? "null" : "not null"); - if (_partitionSensor == null) - return; - - _partitionSensor.DecreaseSensitivity(); - } - - public void SetSensitivity(ushort value) - { - Debug.Console(2, this, "Sensor is {0}, SetSensitivity: {1}", _partitionSensor == null ? "null" : "not null", value); - if (_partitionSensor == null) - return; - - _partitionSensor.Sensitivity.UShortValue = value; - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new GlsPartitionSensorJoinMap(joinStart); - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'type': 'EiscApiAdvanced' to get all join map features for this device"); - } - - Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - Debug.Console(0, this, "Linking to Bridge Type {0}", GetType().Name); - - IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - trilist.StringInput[joinMap.Name.JoinNumber].StringValue = _partitionSensor.Name; - - trilist.SetBoolSigAction(joinMap.Enable.JoinNumber, SetEnableState); - EnableFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Enable.JoinNumber]); - - PartitionPresentFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PartitionSensed.JoinNumber]); - PartitionNotSensedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PartitionNotSensed.JoinNumber]); - - trilist.SetSigTrueAction(joinMap.IncreaseSensitivity.JoinNumber, IncreaseSensitivity); - trilist.SetSigTrueAction(joinMap.DecreaseSensitivity.JoinNumber, DecreaseSensitivity); - - SensitivityFeedback.LinkInputSig(trilist.UShortInput[joinMap.Sensitivity.JoinNumber]); - trilist.SetUShortSigAction(joinMap.Sensitivity.JoinNumber, SetSensitivity); - - FeedbacksFireUpdates(); - - // update when device is online - _partitionSensor.OnlineStatusChange += (o, a) => - { - if (a.DeviceOnLine) - { - FeedbacksFireUpdates(); - } - }; - - // update when trilist is online - trilist.OnlineStatusChange += (o, a) => - { - if (a.DeviceOnLine) - { - trilist.StringInput[joinMap.Name.JoinNumber].StringValue = _partitionSensor.Name; - FeedbacksFireUpdates(); - } - }; - } - - private void FeedbacksFireUpdates() - { - IsOnline.FireUpdate(); - EnableFeedback.FireUpdate(); - PartitionPresentFeedback.FireUpdate(); - PartitionNotSensedFeedback.FireUpdate(); - SensitivityFeedback.FireUpdate(); - } - - #region PreActivation - - private static GlsPartCn GetGlsPartCnDevice(DeviceConfig dc) - { - var control = CommFactory.GetControlPropertiesConfig(dc); - var cresnetId = control.CresnetIdInt; - var branchId = control.ControlPortNumber; - var parentKey = string.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey; - - if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase)) - { - Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsPartCn", parentKey); - return new GlsPartCn(cresnetId, Global.ControlSystem); - } - var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches; - - if (cresnetBridge != null) - { - Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsPartCn", parentKey); - return new GlsPartCn(cresnetId, cresnetBridge.CresnetBranches[branchId]); - } - Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); - return null; - } - #endregion - - - public class GlsPartitionSensorControllerFactory : EssentialsDeviceFactory - { - public GlsPartitionSensorControllerFactory() - { - TypeNames = new List { "glspartcn" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new GlsPartitionSensorController Device"); - - return new GlsPartitionSensorController(dc.Key, GetGlsPartCnDevice, dc); - } - } - - } +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.GeneralIO; +using Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Bridges.JoinMaps; + +using System; +using System.Collections.Generic; +using PepperDash.Essentials.Core.Config; +using PepperDash_Essentials_Core.PartitionSensor; + +namespace PepperDash.Essentials.Core +{ + [Description("Wrapper class for GLS Cresnet Partition Sensor")] + public class GlsPartitionSensorController : CrestronGenericBridgeableBaseDevice, IPartitionStateProvider + { + + public GlsPartitionSensorPropertiesConfig PropertiesConfig { get; private set; } + + private GlsPartCn _partitionSensor; + + public BoolFeedback EnableFeedback { get; private set; } + public BoolFeedback PartitionPresentFeedback { get; private set; } + public BoolFeedback PartitionNotSensedFeedback { get; private set; } + public IntFeedback SensitivityFeedback { get; private set; } + + public bool InTestMode { get; private set; } + public bool TestEnableFeedback { get; private set; } + public bool TestPartitionSensedFeedback { get; private set; } + public int TestSensitivityFeedback { get; private set; } + + + public GlsPartitionSensorController(string key, Func preActivationFunc, DeviceConfig config) + : base(key, config.Name) + { + + var props = config.Properties.ToObject(); + if (props != null) + { + PropertiesConfig = props; + } + else + { + Debug.Console(1, this, "props are null. Unable to deserialize into GlsPartSensorPropertiesConfig"); + } + + AddPreActivationAction(() => + { + _partitionSensor = preActivationFunc(config); + + RegisterCrestronGenericBase(_partitionSensor); + + EnableFeedback = new BoolFeedback(() => InTestMode ? TestEnableFeedback : _partitionSensor.EnableFeedback.BoolValue); + PartitionPresentFeedback = new BoolFeedback(() => InTestMode ? TestPartitionSensedFeedback : _partitionSensor.PartitionSensedFeedback.BoolValue); + PartitionNotSensedFeedback = new BoolFeedback(() => InTestMode ? !TestPartitionSensedFeedback : _partitionSensor.PartitionNotSensedFeedback.BoolValue); + SensitivityFeedback = new IntFeedback(() => InTestMode ? TestSensitivityFeedback : _partitionSensor.SensitivityFeedback.UShortValue); + + if (_partitionSensor != null) + { + _partitionSensor.BaseEvent += PartitionSensor_BaseEvent; + } + }); + + AddPostActivationAction(() => + { + _partitionSensor.OnlineStatusChange += (o, a) => + { + if (a.DeviceOnLine) + { + ApplySettingsToSensorFromConfig(); + } + }; + + if (_partitionSensor.IsOnline) + { + ApplySettingsToSensorFromConfig(); + } + }); + } + + private void ApplySettingsToSensorFromConfig() + { + if (_partitionSensor.IsOnline == false) return; + + // Default to enable + _partitionSensor.Enable.BoolValue = true; + + Debug.Console(1, this, "Attempting to apply settings to sensor from config"); + + if (PropertiesConfig.Sensitivity != null) + { + Debug.Console(1, this, "Sensitivity found, attempting to set value '{0}' from config", + PropertiesConfig.Sensitivity); + _partitionSensor.Sensitivity.UShortValue = (ushort)PropertiesConfig.Sensitivity; + } + else + { + Debug.Console(1, this, "Sensitivity null, no value specified in config"); + } + + if (PropertiesConfig.Enable != null) + { + Debug.Console(1, this, "Enable found, attempting to set value '{0}' from config", + PropertiesConfig.Enable); + _partitionSensor.Enable.BoolValue = (bool)PropertiesConfig.Enable; + } + else + { + Debug.Console(1, this, "Enable null, no value specified in config"); + } + + } + + private void PartitionSensor_BaseEvent(GenericBase device, BaseEventArgs args) + { + Debug.Console(2, this, "EventId: {0}, Index: {1}", args.EventId, args.Index); + + switch (args.EventId) + { + case (GlsPartCn.EnableFeedbackEventId): + { + EnableFeedback.FireUpdate(); + break; + } + case (GlsPartCn.PartitionSensedFeedbackEventId): + { + Debug.Console(1, this, "Partition Sensed State: {0}", _partitionSensor.PartitionSensedFeedback.BoolValue); + PartitionPresentFeedback.FireUpdate(); + break; + } + case (GlsPartCn.PartitionNotSensedFeedbackEventId): + { + Debug.Console(1, this, "Partition Not Sensed State: {0}", _partitionSensor.PartitionNotSensedFeedback.BoolValue); + PartitionNotSensedFeedback.FireUpdate(); + break; + } + case (GlsPartCn.SensitivityFeedbackEventId): + { + SensitivityFeedback.FireUpdate(); + break; + } + default: + { + Debug.Console(2, this, "Unhandled args.EventId: {0}", args.EventId); + break; + } + } + } + + public void SetTestMode(bool mode) + { + InTestMode = mode; + Debug.Console(1, this, "InTestMode: {0}", InTestMode.ToString()); + } + + public void SetTestEnableState(bool state) + { + if (InTestMode) + { + TestEnableFeedback = state; + + EnableFeedback.FireUpdate(); + + Debug.Console(1, this, "TestEnableFeedback: {0}", TestEnableFeedback.ToString()); + return; + } + + Debug.Console(1, this, "InTestMode: {0}, unable to set enable state: {1}", InTestMode.ToString(), state.ToString()); + } + + public void SetTestPartitionSensedState(bool state) + { + if (InTestMode) + { + TestPartitionSensedFeedback = state; + + PartitionPresentFeedback.FireUpdate(); + PartitionNotSensedFeedback.FireUpdate(); + + Debug.Console(1, this, "TestPartitionSensedFeedback: {0}", TestPartitionSensedFeedback.ToString()); + return; + } + + Debug.Console(1, this, "InTestMode: {0}, unable to set partition state: {1}", InTestMode.ToString(), state.ToString()); + } + + public void SetTestSensitivityValue(int value) + { + if (InTestMode) + { + TestSensitivityFeedback = value; + + SensitivityFeedback.FireUpdate(); + Debug.Console(1, this, "TestSensitivityFeedback: {0}", TestSensitivityFeedback); + return; + } + + Debug.Console(1, this, "InTestMode: {0}, unable to set sensitivity value: {1}", InTestMode.ToString(), value); + } + + public void GetSettings() + { + var dash = new string('*', 50); + CrestronConsole.PrintLine(string.Format("{0}\n", dash)); + + Debug.Console(0, this, "Enabled State: {0}", _partitionSensor.EnableFeedback.BoolValue); + + Debug.Console(0, this, "Partition Sensed State: {0}", _partitionSensor.PartitionSensedFeedback.BoolValue); + Debug.Console(0, this, "Partition Not Sensed State: {0}", _partitionSensor.PartitionNotSensedFeedback.BoolValue); + + Debug.Console(0, this, "Sensitivity Value: {0}", _partitionSensor.SensitivityFeedback.UShortValue); + + CrestronConsole.PrintLine(string.Format("{0}\n", dash)); + } + + public void SetEnableState(bool state) + { + Debug.Console(2, this, "Sensor is {0}, SetEnableState: {1}", _partitionSensor == null ? "null" : "not null", state); + if (_partitionSensor == null) + return; + + _partitionSensor.Enable.BoolValue = state; + } + + public void IncreaseSensitivity() + { + Debug.Console(2, this, "Sensor is {0}, IncreaseSensitivity", _partitionSensor == null ? "null" : "not null"); + if (_partitionSensor == null) + return; + + _partitionSensor.IncreaseSensitivity(); + } + + public void DecreaseSensitivity() + { + Debug.Console(2, this, "Sensor is {0}, DecreaseSensitivity", _partitionSensor == null ? "null" : "not null"); + if (_partitionSensor == null) + return; + + _partitionSensor.DecreaseSensitivity(); + } + + public void SetSensitivity(ushort value) + { + Debug.Console(2, this, "Sensor is {0}, SetSensitivity: {1}", _partitionSensor == null ? "null" : "not null", value); + if (_partitionSensor == null) + return; + + _partitionSensor.Sensitivity.UShortValue = value; + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new GlsPartitionSensorJoinMap(joinStart); + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + else + { + Debug.Console(0, this, "Please update config to use 'type': 'EiscApiAdvanced' to get all join map features for this device"); + } + + Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.Console(0, this, "Linking to Bridge Type {0}", GetType().Name); + + IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + trilist.StringInput[joinMap.Name.JoinNumber].StringValue = _partitionSensor.Name; + + trilist.SetBoolSigAction(joinMap.Enable.JoinNumber, SetEnableState); + EnableFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Enable.JoinNumber]); + + PartitionPresentFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PartitionSensed.JoinNumber]); + PartitionNotSensedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PartitionNotSensed.JoinNumber]); + + trilist.SetSigTrueAction(joinMap.IncreaseSensitivity.JoinNumber, IncreaseSensitivity); + trilist.SetSigTrueAction(joinMap.DecreaseSensitivity.JoinNumber, DecreaseSensitivity); + + SensitivityFeedback.LinkInputSig(trilist.UShortInput[joinMap.Sensitivity.JoinNumber]); + trilist.SetUShortSigAction(joinMap.Sensitivity.JoinNumber, SetSensitivity); + + FeedbacksFireUpdates(); + + // update when device is online + _partitionSensor.OnlineStatusChange += (o, a) => + { + if (a.DeviceOnLine) + { + FeedbacksFireUpdates(); + } + }; + + // update when trilist is online + trilist.OnlineStatusChange += (o, a) => + { + if (a.DeviceOnLine) + { + trilist.StringInput[joinMap.Name.JoinNumber].StringValue = _partitionSensor.Name; + FeedbacksFireUpdates(); + } + }; + } + + private void FeedbacksFireUpdates() + { + IsOnline.FireUpdate(); + EnableFeedback.FireUpdate(); + PartitionPresentFeedback.FireUpdate(); + PartitionNotSensedFeedback.FireUpdate(); + SensitivityFeedback.FireUpdate(); + } + + #region PreActivation + + private static GlsPartCn GetGlsPartCnDevice(DeviceConfig dc) + { + var control = CommFactory.GetControlPropertiesConfig(dc); + var cresnetId = control.CresnetIdInt; + var branchId = control.ControlPortNumber; + var parentKey = string.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey; + + if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase)) + { + Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsPartCn", parentKey); + return new GlsPartCn(cresnetId, Global.ControlSystem); + } + var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches; + + if (cresnetBridge != null) + { + Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsPartCn", parentKey); + return new GlsPartCn(cresnetId, cresnetBridge.CresnetBranches[branchId]); + } + Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); + return null; + } + #endregion + + + public class GlsPartitionSensorControllerFactory : EssentialsDeviceFactory + { + public GlsPartitionSensorControllerFactory() + { + TypeNames = new List { "glspartcn" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new GlsPartitionSensorController Device"); + + return new GlsPartitionSensorController(dc.Key, GetGlsPartCnDevice, dc); + } + } + + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorPropertiesConfig.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorPropertiesConfig.cs similarity index 99% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorPropertiesConfig.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorPropertiesConfig.cs index c9f715b5..a90c39d1 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorPropertiesConfig.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorPropertiesConfig.cs @@ -16,9 +16,9 @@ namespace PepperDash_Essentials_Core.PartitionSensor /// The sensitivity range shall be between 1(lowest) to 10 (highest). /// [JsonProperty("sensitivity")] - public ushort? Sensitivity { get; set; } - - [JsonProperty("enable")] - public bool? Enable { get; set; } + public ushort? Sensitivity { get; set; } + + [JsonProperty("enable")] + public bool? Enable { get; set; } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/IPartitionStateProvider.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/IPartitionStateProvider.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/IPartitionStateProvider.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/IPartitionStateProvider.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj similarity index 98% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index 6b7a3ad9..6b94e84f 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -1,433 +1,433 @@ - - - Release - AnyCPU - 9.0.30729 - 2.0 - {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} - Library - Properties - PepperDash_Essentials_Core - PepperDash_Essentials_Core - {0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - WindowsCE - E2BECB1F-8C8C-41ba-B736-9BE7D946A398 - 5.0 - SmartDeviceProject1 - v3.5 - Windows CE - - - - - .allowedReferenceRelatedFileExtensions - true - full - false - bin\ - DEBUG;TRACE; - prompt - 4 - 512 - true - true - off - - - .allowedReferenceRelatedFileExtensions - none - true - bin\ - prompt - 4 - 512 - true - true - off - - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DM.dll - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.EthernetCommunications.dll - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Fusion.dll - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Gateways.dll - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.GeneralIO.dll - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Remotes.dll - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.ThreeSeriesCards.dll - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll - - - - False - ..\..\..\packages\PepperDashCore\lib\net35\PepperDash_Core.dll - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll - False - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCWSHelperInterface.dll - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll - False - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe - False - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpTimerEventInterface.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - rem S# Pro preparation will execute after these operations - + + + Release + AnyCPU + 9.0.30729 + 2.0 + {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} + Library + Properties + PepperDash_Essentials_Core + PepperDash_Essentials_Core + {0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + WindowsCE + E2BECB1F-8C8C-41ba-B736-9BE7D946A398 + 5.0 + SmartDeviceProject1 + v3.5 + Windows CE + + + + + .allowedReferenceRelatedFileExtensions + true + full + false + bin\ + DEBUG;TRACE; + prompt + 4 + 512 + true + true + off + + + .allowedReferenceRelatedFileExtensions + none + true + bin\ + prompt + 4 + 512 + true + true + off + + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DM.dll + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.EthernetCommunications.dll + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Fusion.dll + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Gateways.dll + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.GeneralIO.dll + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Remotes.dll + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.ThreeSeriesCards.dll + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll + + + + False + ..\..\..\packages\PepperDashCore\lib\net35\PepperDash_Core.dll + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll + False + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCWSHelperInterface.dll + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll + False + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe + False + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpTimerEventInterface.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Code + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rem S# Pro preparation will execute after these operations + \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj.DotSettings b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj.DotSettings similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj.DotSettings rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj.DotSettings diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.nuspec b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.nuspec similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.nuspec rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.nuspec diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceFactory.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceFactory.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceFactory.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceFactory.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/DevicePresets.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/DevicePresets.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/DevicePresets.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/DevicePresets.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/DevicePresetsView.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/DevicePresetsView.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/DevicePresetsView.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/DevicePresetsView.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/Interfaces.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/Interfaces.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/Interfaces.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/Interfaces.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/PresetBase.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/PresetBase.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/PresetBase.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/PresetBase.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/PresetChannel.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/PresetChannel.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/PresetChannel.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/PresetChannel.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/PresetsListSubpageReferenceListItem.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/PresetsListSubpageReferenceListItem.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/PresetsListSubpageReferenceListItem.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/PresetsListSubpageReferenceListItem.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Properties/AssemblyInfo.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Properties/AssemblyInfo.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Properties/AssemblyInfo.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Properties/AssemblyInfo.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Properties/ControlSystem.cfg b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Properties/ControlSystem.cfg similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Properties/ControlSystem.cfg rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Properties/ControlSystem.cfg diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Queues/ComsMessage.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Queues/ComsMessage.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Queues/ComsMessage.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Queues/ComsMessage.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Queues/GenericQueue.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Queues/GenericQueue.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Queues/GenericQueue.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Queues/GenericQueue.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Queues/IQueue.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Queues/IQueue.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Queues/IQueue.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Queues/IQueue.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Queues/IQueueMessage.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Queues/IQueueMessage.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Queues/IQueueMessage.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Queues/IQueueMessage.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Queues/ProcessStringMessage.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Queues/ProcessStringMessage.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Queues/ProcessStringMessage.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Queues/ProcessStringMessage.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Queues/StringResponseProcessor.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Queues/StringResponseProcessor.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Queues/StringResponseProcessor.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Queues/StringResponseProcessor.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Ramps and Increments/ActionIncrementer.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Ramps and Increments/ActionIncrementer.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Ramps and Increments/ActionIncrementer.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Ramps and Increments/ActionIncrementer.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Ramps and Increments/NumericalHelpers.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Ramps and Increments/NumericalHelpers.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Ramps and Increments/NumericalHelpers.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Ramps and Increments/NumericalHelpers.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Ramps and Increments/UshortSigIncrementer.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Ramps and Increments/UshortSigIncrementer.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Ramps and Increments/UshortSigIncrementer.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Ramps and Increments/UshortSigIncrementer.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Remotes/ButtonExtensions.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Remotes/ButtonExtensions.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Remotes/ButtonExtensions.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Remotes/ButtonExtensions.cs index 43941260..58cf7d7c 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Remotes/ButtonExtensions.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Remotes/ButtonExtensions.cs @@ -1,47 +1,47 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; - -using PepperDash.Core; - -namespace PepperDash.Essentials.Core -{ - public static class ButtonExtensions - { - public static Button SetButtonAction(this Button button, Action a) - { - button.UserObject = a; - return button; - } - - public static Button SetButtonAction(this CrestronCollection public interface IShadesOpenCloseStop - { - void Open(); + { + void Open(); void Close(); void Stop(); - } - - public interface IShadesOpenClosePreset : IShadesOpenCloseStop - { - void RecallPreset(uint presetNumber); - void SavePreset(uint presetNumber); - string StopOrPresetButtonLabel { get; } - - event EventHandler PresetSaved; + } + + public interface IShadesOpenClosePreset : IShadesOpenCloseStop + { + void RecallPreset(uint presetNumber); + void SavePreset(uint presetNumber); + string StopOrPresetButtonLabel { get; } + + event EventHandler PresetSaved; } /// /// Requirements for a shade that implements press/hold raise/lower functions - /// + /// [Obsolete("Please use IShadesOpenCloseStop instead")] public interface IShadesRaiseLower { @@ -75,8 +75,8 @@ namespace PepperDash.Essentials.Core.Shades /// /// - /// - [Obsolete("Please use IShadesOpenCloseStop instead")] + /// + [Obsolete("Please use IShadesOpenCloseStop instead")] public interface IShadesStop { void Stop(); @@ -84,7 +84,7 @@ namespace PepperDash.Essentials.Core.Shades /// /// Used to implement raise/stop/lower/stop from single button - /// + /// public interface IShadesStopOrMove { void OpenOrStop(); diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Shades/ShadeBase.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Shades/ShadeBase.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Shades/ShadeBase.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Shades/ShadeBase.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Shades/ShadeController.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Shades/ShadeController.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Shades/ShadeController.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Shades/ShadeController.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/SigHelper.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/SigHelper.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/SigHelper.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/SigHelper.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SmartObjectDPad.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SmartObjectDPad.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SmartObjectDPad.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SmartObjectDPad.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SmartObjectDynamicList.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SmartObjectDynamicList.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SmartObjectDynamicList.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SmartObjectDynamicList.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SmartObjectHelperBase.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SmartObjectHelperBase.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SmartObjectHelperBase.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SmartObjectHelperBase.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SmartObjectNumeric.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SmartObjectNumeric.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SmartObjectNumeric.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SmartObjectNumeric.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SubpageReferencList/SourceListSubpageReferenceList.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SubpageReferencList/SourceListSubpageReferenceList.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SubpageReferencList/SourceListSubpageReferenceList.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SubpageReferencList/SourceListSubpageReferenceList.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SubpageReferencList/SubpageReferenceList.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SubpageReferencList/SubpageReferenceList.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SubpageReferencList/SubpageReferenceList.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SubpageReferencList/SubpageReferenceList.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SubpageReferencList/SubpageReferenceListItem.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SubpageReferencList/SubpageReferenceListItem.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SubpageReferencList/SubpageReferenceListItem.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/SmartObjects/SubpageReferencList/SubpageReferenceListItem.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Timers/CountdownTimer.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Timers/CountdownTimer.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Timers/CountdownTimer.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Timers/CountdownTimer.cs index 3678b092..763a4fe1 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Timers/CountdownTimer.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Timers/CountdownTimer.cs @@ -1,148 +1,148 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -using PepperDash.Core; - -namespace PepperDash.Essentials.Core -{ - public class SecondsCountdownTimer: IKeyed - { - public event EventHandler HasStarted; - public event EventHandler HasFinished; - public event EventHandler WasCancelled; - - public string Key { get; private set; } - - public BoolFeedback IsRunningFeedback { get; private set; } - bool _isRunning; - - public IntFeedback PercentFeedback { get; private set; } - public StringFeedback TimeRemainingFeedback { get; private set; } - - public bool CountsDown { get; set; } - - /// - /// The number of seconds to countdown - /// - public int SecondsToCount { get; set; } - - public DateTime StartTime { get; private set; } - public DateTime FinishTime { get; private set; } - - private CTimer _secondTimer; - - /// - /// Constructor - /// - /// - public SecondsCountdownTimer(string key) - { - Key = key; - IsRunningFeedback = new BoolFeedback(() => _isRunning); - - TimeRemainingFeedback = new StringFeedback(() => - { - // Need to handle up and down here. - - var timeSpan = FinishTime - DateTime.Now; - - Debug.Console(2, this, - "timeSpan.Minutes == {0}, timeSpan.Seconds == {1}, timeSpan.TotalSeconds == {2}", - timeSpan.Minutes, timeSpan.Seconds, timeSpan.TotalSeconds); - - if (Math.Floor(timeSpan.TotalSeconds) < 60 && Math.Floor(timeSpan.TotalSeconds) >= 0) //ignore milliseconds - { - return String.Format("{0:00}", timeSpan.Seconds); - } - - return Math.Floor(timeSpan.TotalSeconds) < 0 - ? "00" - : String.Format("{0:00}:{1:00}", timeSpan.Minutes, timeSpan.Seconds); - }); - - PercentFeedback = - new IntFeedback( - () => - (int) - (Math.Floor((FinishTime - DateTime.Now).TotalSeconds)/ - Math.Floor((FinishTime - StartTime).TotalSeconds)*100)); - } - - /// - /// Starts the Timer - /// - public void Start() - { - if (_isRunning) - return; - StartTime = DateTime.Now; - FinishTime = StartTime + TimeSpan.FromSeconds(SecondsToCount); - - if (_secondTimer != null) - _secondTimer.Stop(); - _secondTimer = new CTimer(SecondElapsedTimerCallback, null, 0, 1000); - _isRunning = true; - IsRunningFeedback.FireUpdate(); - - var handler = HasStarted; - if (handler != null) - handler(this, new EventArgs()); - } - - /// - /// Restarts the timer - /// - public void Reset() - { - _isRunning = false; - Start(); - } - - /// - /// Cancels the timer (without triggering it to finish) - /// - public void Cancel() - { - StopHelper(); - - var handler = WasCancelled; - if (handler != null) - handler(this, new EventArgs()); - } - - /// - /// Called upon expiration, or calling this will force timer to finish. - /// - public void Finish() - { - StopHelper(); - - var handler = HasFinished; - if (handler != null) - handler(this, new EventArgs()); - } - - void StopHelper() - { - if (_secondTimer != null) - _secondTimer.Stop(); - _isRunning = false; - IsRunningFeedback.FireUpdate(); - } - - void SecondElapsedTimerCallback(object o) - { - if (DateTime.Now >= FinishTime) - { - Finish(); - return; - } - - PercentFeedback.FireUpdate(); - TimeRemainingFeedback.FireUpdate(); - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + public class SecondsCountdownTimer: IKeyed + { + public event EventHandler HasStarted; + public event EventHandler HasFinished; + public event EventHandler WasCancelled; + + public string Key { get; private set; } + + public BoolFeedback IsRunningFeedback { get; private set; } + bool _isRunning; + + public IntFeedback PercentFeedback { get; private set; } + public StringFeedback TimeRemainingFeedback { get; private set; } + + public bool CountsDown { get; set; } + + /// + /// The number of seconds to countdown + /// + public int SecondsToCount { get; set; } + + public DateTime StartTime { get; private set; } + public DateTime FinishTime { get; private set; } + + private CTimer _secondTimer; + + /// + /// Constructor + /// + /// + public SecondsCountdownTimer(string key) + { + Key = key; + IsRunningFeedback = new BoolFeedback(() => _isRunning); + + TimeRemainingFeedback = new StringFeedback(() => + { + // Need to handle up and down here. + + var timeSpan = FinishTime - DateTime.Now; + + Debug.Console(2, this, + "timeSpan.Minutes == {0}, timeSpan.Seconds == {1}, timeSpan.TotalSeconds == {2}", + timeSpan.Minutes, timeSpan.Seconds, timeSpan.TotalSeconds); + + if (Math.Floor(timeSpan.TotalSeconds) < 60 && Math.Floor(timeSpan.TotalSeconds) >= 0) //ignore milliseconds + { + return String.Format("{0:00}", timeSpan.Seconds); + } + + return Math.Floor(timeSpan.TotalSeconds) < 0 + ? "00" + : String.Format("{0:00}:{1:00}", timeSpan.Minutes, timeSpan.Seconds); + }); + + PercentFeedback = + new IntFeedback( + () => + (int) + (Math.Floor((FinishTime - DateTime.Now).TotalSeconds)/ + Math.Floor((FinishTime - StartTime).TotalSeconds)*100)); + } + + /// + /// Starts the Timer + /// + public void Start() + { + if (_isRunning) + return; + StartTime = DateTime.Now; + FinishTime = StartTime + TimeSpan.FromSeconds(SecondsToCount); + + if (_secondTimer != null) + _secondTimer.Stop(); + _secondTimer = new CTimer(SecondElapsedTimerCallback, null, 0, 1000); + _isRunning = true; + IsRunningFeedback.FireUpdate(); + + var handler = HasStarted; + if (handler != null) + handler(this, new EventArgs()); + } + + /// + /// Restarts the timer + /// + public void Reset() + { + _isRunning = false; + Start(); + } + + /// + /// Cancels the timer (without triggering it to finish) + /// + public void Cancel() + { + StopHelper(); + + var handler = WasCancelled; + if (handler != null) + handler(this, new EventArgs()); + } + + /// + /// Called upon expiration, or calling this will force timer to finish. + /// + public void Finish() + { + StopHelper(); + + var handler = HasFinished; + if (handler != null) + handler(this, new EventArgs()); + } + + void StopHelper() + { + if (_secondTimer != null) + _secondTimer.Stop(); + _isRunning = false; + IsRunningFeedback.FireUpdate(); + } + + void SecondElapsedTimerCallback(object o) + { + if (DateTime.Now >= FinishTime) + { + Finish(); + return; + } + + PercentFeedback.FireUpdate(); + TimeRemainingFeedback.FireUpdate(); + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Timers/RetriggerableTimer.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Timers/RetriggerableTimer.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Timers/RetriggerableTimer.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Timers/RetriggerableTimer.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/CrestronTouchpanelPropertiesConfig.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/CrestronTouchpanelPropertiesConfig.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/CrestronTouchpanelPropertiesConfig.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/CrestronTouchpanelPropertiesConfig.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Interfaces.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Interfaces.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Interfaces.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Interfaces.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Keyboards/HabaneroKeyboardController.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Keyboards/HabaneroKeyboardController.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Keyboards/HabaneroKeyboardController.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Keyboards/HabaneroKeyboardController.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/ModalDialog.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/ModalDialog.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/ModalDialog.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/ModalDialog.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/TriListExtensions.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/TriListExtensions.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/TriListExtensions.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/TriListExtensions.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/TriListBridges/HandlerBridge.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/TriListBridges/HandlerBridge.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/TriListBridges/HandlerBridge.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/TriListBridges/HandlerBridge.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/UI PageManagers/BlurayPageManager.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/UI PageManagers/BlurayPageManager.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/UI PageManagers/BlurayPageManager.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/UI PageManagers/BlurayPageManager.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/UI PageManagers/PageManager.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/UI PageManagers/PageManager.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/UI PageManagers/PageManager.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/UI PageManagers/PageManager.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/UI PageManagers/SetTopBoxThreePanelPageManager.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/UI PageManagers/SetTopBoxThreePanelPageManager.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/UI PageManagers/SetTopBoxThreePanelPageManager.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/UI PageManagers/SetTopBoxThreePanelPageManager.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/UI PageManagers/SetTopBoxTwoPanelPageManager.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/UI PageManagers/SetTopBoxTwoPanelPageManager.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/UI PageManagers/SetTopBoxTwoPanelPageManager.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/UI PageManagers/SetTopBoxTwoPanelPageManager.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/UI PageManagers/SinglePageManager.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/UI PageManagers/SinglePageManager.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/UI PageManagers/SinglePageManager.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/UI PageManagers/SinglePageManager.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/UI/TouchpanelBase.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/UI/TouchpanelBase.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/UI/TouchpanelBase.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/UI/TouchpanelBase.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Utilities/ActionSequence.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Utilities/ActionSequence.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Utilities/ActionSequence.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Utilities/ActionSequence.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/VideoStatus/VideoStatusOutputs.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/VideoStatus/VideoStatusOutputs.cs similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/VideoStatus/VideoStatusOutputs.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/VideoStatus/VideoStatusOutputs.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssemtialsWebApi.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssemtialsWebApi.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssemtialsWebApi.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssemtialsWebApi.cs index dd2ade1a..eb012378 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssemtialsWebApi.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssemtialsWebApi.cs @@ -1,224 +1,224 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Crestron.SimplSharp; -using Crestron.SimplSharp.WebScripting; -using PepperDash.Core; -using PepperDash.Core.Web; -using PepperDash.Essentials.Core.Web.RequestHandlers; - -namespace PepperDash.Essentials.Core.Web -{ - public class EssemtialsWebApi : EssentialsDevice - { - private readonly WebApiServer _server; - - /// - /// http(s)://{ipaddress}/cws/{basePath} - /// http(s)://{ipaddress}/VirtualControl/Rooms/{roomId}/cws/{basePath} - /// - private readonly string _defaultBasePath = CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance - ? string.Format("/app{0:00}/api", InitialParametersClass.ApplicationNumber) - : "/api"; - - private const int DebugTrace = 0; - private const int DebugInfo = 1; - private const int DebugVerbose = 2; - - /// - /// CWS base path - /// - public string BasePath { get; private set; } - - /// - /// Tracks if CWS is registered - /// - public bool IsRegistered - { - get { return _server.IsRegistered; } - } - - /// - /// Constructor - /// - /// - /// - public EssemtialsWebApi(string key, string name) - : this(key, name, null) - { - } - - /// - /// Constructor - /// - /// - /// - /// - public EssemtialsWebApi(string key, string name, EssentialsWebApiPropertiesConfig config) - : base(key, name) - { - Key = key; - - if (config == null) - BasePath = _defaultBasePath; - else - BasePath = string.IsNullOrEmpty(config.BasePath) ? _defaultBasePath : config.BasePath; - - _server = new WebApiServer(Key, Name, BasePath); - } - - /// - /// Custom activate, add routes - /// - /// - public override bool CustomActivate() - { - var routes = new List - { - new HttpCwsRoute("reportversions") - { - Name = "ReportVersions", - RouteHandler = new ReportVersionsRequestHandler() - }, - new HttpCwsRoute("appdebug") - { - Name = "AppDebug", - RouteHandler = new AppDebugRequestHandler() - }, - new HttpCwsRoute("devlist") - { - Name = "DevList", - RouteHandler = new DevListRequestHandler() - }, - new HttpCwsRoute("devprops") - { - Name = "DevProps", - RouteHandler = new DevPropsRequestHandler() - }, - new HttpCwsRoute("devjson") - { - Name = "DevJson", - RouteHandler = new DevJsonRequestHandler() - }, - new HttpCwsRoute("setdevicestreamdebug") - { - Name = "SetDeviceStreamDebug", - RouteHandler = new SetDeviceStreamDebugRequestHandler() - }, - new HttpCwsRoute("disableallstreamdebug") - { - Name = "DisableAllStreamDebug", - RouteHandler = new DisableAllStreamDebugRequestHandler() - }, - new HttpCwsRoute("showconfig") - { - Name = "ShowConfig", - RouteHandler = new ShowConfigRequestHandler() - }, - new HttpCwsRoute("gettypes") - { - Name = "GetTypes", - RouteHandler = new GetTypesRequestHandler() - }, - new HttpCwsRoute("gettypes/{filter}") - { - Name = "GetTypesByFilter", - RouteHandler = new GetTypesByFilterRequestHandler() - }, - new HttpCwsRoute("getjoinmap/{bridgeKey}") - { - Name = "GetJoinMapsForBridgeKey", - RouteHandler = new GetJoinMapForBridgeKeyRequestHandler() - }, - new HttpCwsRoute("getjoinmap/{bridgeKey}/{deviceKey}") - { - Name = "GetJoinMapsForDeviceKey", - RouteHandler = new GetJoinMapForDeviceKeyRequestHandler() - }, - new HttpCwsRoute("feedbacks/{deviceKey}") - { - Name = "GetFeedbacksForDeviceKey", - RouteHandler = new GetFeedbacksForDeviceRequestHandler() - } - }; - - foreach (var route in routes.Where(route => route != null)) - { - var r = route; - _server.AddRoute(r); - } - - return base.CustomActivate(); - } - - /// - /// Initializes the CWS class - /// - public override void Initialize() - { - // If running on an appliance - if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance) - { - /* - WEBSERVER [ON | OFF | TIMEOUT | MAXSESSIONSPERUSER ] - */ - var response = string.Empty; - CrestronConsole.SendControlSystemCommand("webserver", ref response); - if (response.Contains("OFF")) return; - - var is4Series = eCrestronSeries.Series4 == (Global.ProcessorSeries & eCrestronSeries.Series4); - Debug.Console(DebugTrace, Debug.ErrorLogLevel.Notice, "Starting Essentials Web API on {0} Appliance", is4Series ? "4-series" : "3-series"); - - _server.Start(); - - GetPaths(); - - return; - } - - // Automatically start CWS when running on a server (Linux OS, Virtual Control) - Debug.Console(DebugTrace, Debug.ErrorLogLevel.Notice, "Starting Essentials Web API on Virtual Control Server"); - - _server.Start(); - - GetPaths(); - } - - /// - /// Print the available pahts - /// - /// - /// http(s)://{ipaddress}/cws/{basePath} - /// http(s)://{ipaddress}/VirtualControl/Rooms/{roomId}/cws/{basePath} - /// - public void GetPaths() - { - Debug.Console(DebugTrace, this, "{0}", new String('-', 50)); - - var currentIp = CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0); - - var hostname = CrestronEthernetHelper.GetEthernetParameter( - CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, 0); - - var path = CrestronEnvironment.DevicePlatform == eDevicePlatform.Server - ? string.Format("http(s)://{0}/VirtualControl/Rooms/{1}/cws{2}", hostname, InitialParametersClass.RoomId, BasePath) - : string.Format("http(s)://{0}/cws{1}", currentIp, BasePath); - - Debug.Console(DebugTrace, this, "Server:{0}", path); - - var routeCollection = _server.GetRouteCollection(); - if (routeCollection == null) - { - Debug.Console(DebugTrace, this, "Server route collection is null"); - return; - } - Debug.Console(DebugTrace, this, "Configured Routes:"); - foreach (var route in routeCollection) - { - Debug.Console(DebugTrace, this, "{0}: {1}/{2}", route.Name, path, route.Url); - } - Debug.Console(DebugTrace, this, "{0}", new String('-', 50)); - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using Crestron.SimplSharp; +using Crestron.SimplSharp.WebScripting; +using PepperDash.Core; +using PepperDash.Core.Web; +using PepperDash.Essentials.Core.Web.RequestHandlers; + +namespace PepperDash.Essentials.Core.Web +{ + public class EssemtialsWebApi : EssentialsDevice + { + private readonly WebApiServer _server; + + /// + /// http(s)://{ipaddress}/cws/{basePath} + /// http(s)://{ipaddress}/VirtualControl/Rooms/{roomId}/cws/{basePath} + /// + private readonly string _defaultBasePath = CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance + ? string.Format("/app{0:00}/api", InitialParametersClass.ApplicationNumber) + : "/api"; + + private const int DebugTrace = 0; + private const int DebugInfo = 1; + private const int DebugVerbose = 2; + + /// + /// CWS base path + /// + public string BasePath { get; private set; } + + /// + /// Tracks if CWS is registered + /// + public bool IsRegistered + { + get { return _server.IsRegistered; } + } + + /// + /// Constructor + /// + /// + /// + public EssemtialsWebApi(string key, string name) + : this(key, name, null) + { + } + + /// + /// Constructor + /// + /// + /// + /// + public EssemtialsWebApi(string key, string name, EssentialsWebApiPropertiesConfig config) + : base(key, name) + { + Key = key; + + if (config == null) + BasePath = _defaultBasePath; + else + BasePath = string.IsNullOrEmpty(config.BasePath) ? _defaultBasePath : config.BasePath; + + _server = new WebApiServer(Key, Name, BasePath); + } + + /// + /// Custom activate, add routes + /// + /// + public override bool CustomActivate() + { + var routes = new List + { + new HttpCwsRoute("reportversions") + { + Name = "ReportVersions", + RouteHandler = new ReportVersionsRequestHandler() + }, + new HttpCwsRoute("appdebug") + { + Name = "AppDebug", + RouteHandler = new AppDebugRequestHandler() + }, + new HttpCwsRoute("devlist") + { + Name = "DevList", + RouteHandler = new DevListRequestHandler() + }, + new HttpCwsRoute("devprops") + { + Name = "DevProps", + RouteHandler = new DevPropsRequestHandler() + }, + new HttpCwsRoute("devjson") + { + Name = "DevJson", + RouteHandler = new DevJsonRequestHandler() + }, + new HttpCwsRoute("setdevicestreamdebug") + { + Name = "SetDeviceStreamDebug", + RouteHandler = new SetDeviceStreamDebugRequestHandler() + }, + new HttpCwsRoute("disableallstreamdebug") + { + Name = "DisableAllStreamDebug", + RouteHandler = new DisableAllStreamDebugRequestHandler() + }, + new HttpCwsRoute("showconfig") + { + Name = "ShowConfig", + RouteHandler = new ShowConfigRequestHandler() + }, + new HttpCwsRoute("gettypes") + { + Name = "GetTypes", + RouteHandler = new GetTypesRequestHandler() + }, + new HttpCwsRoute("gettypes/{filter}") + { + Name = "GetTypesByFilter", + RouteHandler = new GetTypesByFilterRequestHandler() + }, + new HttpCwsRoute("getjoinmap/{bridgeKey}") + { + Name = "GetJoinMapsForBridgeKey", + RouteHandler = new GetJoinMapForBridgeKeyRequestHandler() + }, + new HttpCwsRoute("getjoinmap/{bridgeKey}/{deviceKey}") + { + Name = "GetJoinMapsForDeviceKey", + RouteHandler = new GetJoinMapForDeviceKeyRequestHandler() + }, + new HttpCwsRoute("feedbacks/{deviceKey}") + { + Name = "GetFeedbacksForDeviceKey", + RouteHandler = new GetFeedbacksForDeviceRequestHandler() + } + }; + + foreach (var route in routes.Where(route => route != null)) + { + var r = route; + _server.AddRoute(r); + } + + return base.CustomActivate(); + } + + /// + /// Initializes the CWS class + /// + public override void Initialize() + { + // If running on an appliance + if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance) + { + /* + WEBSERVER [ON | OFF | TIMEOUT | MAXSESSIONSPERUSER ] + */ + var response = string.Empty; + CrestronConsole.SendControlSystemCommand("webserver", ref response); + if (response.Contains("OFF")) return; + + var is4Series = eCrestronSeries.Series4 == (Global.ProcessorSeries & eCrestronSeries.Series4); + Debug.Console(DebugTrace, Debug.ErrorLogLevel.Notice, "Starting Essentials Web API on {0} Appliance", is4Series ? "4-series" : "3-series"); + + _server.Start(); + + GetPaths(); + + return; + } + + // Automatically start CWS when running on a server (Linux OS, Virtual Control) + Debug.Console(DebugTrace, Debug.ErrorLogLevel.Notice, "Starting Essentials Web API on Virtual Control Server"); + + _server.Start(); + + GetPaths(); + } + + /// + /// Print the available pahts + /// + /// + /// http(s)://{ipaddress}/cws/{basePath} + /// http(s)://{ipaddress}/VirtualControl/Rooms/{roomId}/cws/{basePath} + /// + public void GetPaths() + { + Debug.Console(DebugTrace, this, "{0}", new String('-', 50)); + + var currentIp = CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0); + + var hostname = CrestronEthernetHelper.GetEthernetParameter( + CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, 0); + + var path = CrestronEnvironment.DevicePlatform == eDevicePlatform.Server + ? string.Format("http(s)://{0}/VirtualControl/Rooms/{1}/cws{2}", hostname, InitialParametersClass.RoomId, BasePath) + : string.Format("http(s)://{0}/cws{1}", currentIp, BasePath); + + Debug.Console(DebugTrace, this, "Server:{0}", path); + + var routeCollection = _server.GetRouteCollection(); + if (routeCollection == null) + { + Debug.Console(DebugTrace, this, "Server route collection is null"); + return; + } + Debug.Console(DebugTrace, this, "Configured Routes:"); + foreach (var route in routeCollection) + { + Debug.Console(DebugTrace, this, "{0}: {1}/{2}", route.Name, path, route.Url); + } + Debug.Console(DebugTrace, this, "{0}", new String('-', 50)); + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssentialsWebApiFactory.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssentialsWebApiFactory.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssentialsWebApiFactory.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssentialsWebApiFactory.cs index 51361c2c..3e90808c 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssentialsWebApiFactory.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssentialsWebApiFactory.cs @@ -1,25 +1,25 @@ -using System.Collections.Generic; -using PepperDash.Core; -using PepperDash.Essentials.Core.Config; - -namespace PepperDash.Essentials.Core.Web -{ - public class EssentialsWebApiFactory : EssentialsDeviceFactory - { - public EssentialsWebApiFactory() - { - TypeNames = new List { "EssentialsWebApi" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new Essentials Web API Server"); - - var props = dc.Properties.ToObject(); - if (props != null) return new EssemtialsWebApi(dc.Key, dc.Name, props); - - Debug.Console(1, "Factory failed to create new Essentials Web API Server"); - return null; - } - } +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core.Web +{ + public class EssentialsWebApiFactory : EssentialsDeviceFactory + { + public EssentialsWebApiFactory() + { + TypeNames = new List { "EssentialsWebApi" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Essentials Web API Server"); + + var props = dc.Properties.ToObject(); + if (props != null) return new EssemtialsWebApi(dc.Key, dc.Name, props); + + Debug.Console(1, "Factory failed to create new Essentials Web API Server"); + return null; + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssentialsWebApiHelpers.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssentialsWebApiHelpers.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssentialsWebApiHelpers.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssentialsWebApiHelpers.cs index 4830edb4..89718fcf 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssentialsWebApiHelpers.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssentialsWebApiHelpers.cs @@ -1,87 +1,87 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp.WebScripting; -using PepperDash.Core; - -namespace PepperDash.Essentials.Core.Web -{ - public class EssentialsWebApiHelpers - { - public static string GetRequestBody(HttpCwsRequest request) - { - var bytes = new Byte[request.ContentLength]; - - request.InputStream.Read(bytes, 0, request.ContentLength); - - return Encoding.UTF8.GetString(bytes, 0, bytes.Length); - } - - public static object MapToAssemblyObject(LoadedAssembly assembly) - { - return new - { - Name = assembly.Name, - Version = assembly.Version - }; - } - - public static object MapToDeviceListObject(IKeyed device) - { - return new - { - Key = device.Key, - Name = (device is IKeyName) - ? (device as IKeyName).Name - : "---" - }; - } - - public static object MapJoinToObject(string key, JoinMapBaseAdvanced join) - { - var kp = new KeyValuePair(key, join); - - return MapJoinToObject(kp); - } - - public static object MapJoinToObject(KeyValuePair join) - { - return new - { - DeviceKey = join.Key, - Joins = join.Value.Joins.Select(j => MapJoinDataCompleteToObject(j)) - }; - } - - public static object MapJoinDataCompleteToObject(KeyValuePair joinData) - { - return new - { - Signal = joinData.Key, - Description = joinData.Value.Metadata.Description, - JoinNumber = joinData.Value.JoinNumber, - JoinSpan = joinData.Value.JoinSpan, - JoinType = joinData.Value.Metadata.JoinType.ToString(), - JoinCapabilities = joinData.Value.Metadata.JoinCapabilities.ToString() - }; - } - - public static object MapDeviceTypeToObject(string key, DeviceFactoryWrapper device) - { - var kp = new KeyValuePair(key, device); - - return MapDeviceTypeToObject(kp); - } - - public static object MapDeviceTypeToObject(KeyValuePair device) - { - return new - { - Type = device.Key, - Description = device.Value.Description, - CType = device.Value.CType == null ? "---": device.Value.CType.ToString() - }; - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp.WebScripting; +using PepperDash.Core; + +namespace PepperDash.Essentials.Core.Web +{ + public class EssentialsWebApiHelpers + { + public static string GetRequestBody(HttpCwsRequest request) + { + var bytes = new Byte[request.ContentLength]; + + request.InputStream.Read(bytes, 0, request.ContentLength); + + return Encoding.UTF8.GetString(bytes, 0, bytes.Length); + } + + public static object MapToAssemblyObject(LoadedAssembly assembly) + { + return new + { + Name = assembly.Name, + Version = assembly.Version + }; + } + + public static object MapToDeviceListObject(IKeyed device) + { + return new + { + Key = device.Key, + Name = (device is IKeyName) + ? (device as IKeyName).Name + : "---" + }; + } + + public static object MapJoinToObject(string key, JoinMapBaseAdvanced join) + { + var kp = new KeyValuePair(key, join); + + return MapJoinToObject(kp); + } + + public static object MapJoinToObject(KeyValuePair join) + { + return new + { + DeviceKey = join.Key, + Joins = join.Value.Joins.Select(j => MapJoinDataCompleteToObject(j)) + }; + } + + public static object MapJoinDataCompleteToObject(KeyValuePair joinData) + { + return new + { + Signal = joinData.Key, + Description = joinData.Value.Metadata.Description, + JoinNumber = joinData.Value.JoinNumber, + JoinSpan = joinData.Value.JoinSpan, + JoinType = joinData.Value.Metadata.JoinType.ToString(), + JoinCapabilities = joinData.Value.Metadata.JoinCapabilities.ToString() + }; + } + + public static object MapDeviceTypeToObject(string key, DeviceFactoryWrapper device) + { + var kp = new KeyValuePair(key, device); + + return MapDeviceTypeToObject(kp); + } + + public static object MapDeviceTypeToObject(KeyValuePair device) + { + return new + { + Type = device.Key, + Description = device.Value.Description, + CType = device.Value.CType == null ? "---": device.Value.CType.ToString() + }; + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssentialsWebApiPropertiesConfig.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssentialsWebApiPropertiesConfig.cs similarity index 95% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssentialsWebApiPropertiesConfig.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssentialsWebApiPropertiesConfig.cs index a57e1ce9..7af4c631 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssentialsWebApiPropertiesConfig.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssentialsWebApiPropertiesConfig.cs @@ -1,10 +1,10 @@ -using Newtonsoft.Json; - -namespace PepperDash.Essentials.Core.Web -{ - public class EssentialsWebApiPropertiesConfig - { - [JsonProperty("basePath")] - public string BasePath { get; set; } - } +using Newtonsoft.Json; + +namespace PepperDash.Essentials.Core.Web +{ + public class EssentialsWebApiPropertiesConfig + { + [JsonProperty("basePath")] + public string BasePath { get; set; } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/AppDebugRequestHandler.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/AppDebugRequestHandler.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/AppDebugRequestHandler.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/AppDebugRequestHandler.cs index bbe4bd22..46a0f980 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/AppDebugRequestHandler.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/AppDebugRequestHandler.cs @@ -1,82 +1,82 @@ -using Crestron.SimplSharp.WebScripting; -using Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Core.Web.RequestHandlers; - -namespace PepperDash.Essentials.Core.Web.RequestHandlers -{ - public class AppDebugRequestHandler : WebApiBaseRequestHandler - { - /// - /// Constructor - /// - /// - /// base(true) enables CORS support by default - /// - public AppDebugRequestHandler() - : base(true) - { - } - - /// - /// Handles GET method requests - /// - /// - protected override void HandleGet(HttpCwsContext context) - { - var appDebug = new AppDebug { Level = Debug.Level }; - - var body = JsonConvert.SerializeObject(appDebug, Formatting.Indented); - - context.Response.StatusCode = 200; - context.Response.StatusDescription = "OK"; - context.Response.Write(body, false); - context.Response.End(); - } - - /// - /// Handles POST method requests - /// - /// - protected override void HandlePost(HttpCwsContext context) - { - if (context.Request.ContentLength < 0) - { - context.Response.StatusCode = 400; - context.Response.StatusDescription = "Bad Request"; - context.Response.End(); - - return; - } - - var data = EssentialsWebApiHelpers.GetRequestBody(context.Request); - if (string.IsNullOrEmpty(data)) - { - context.Response.StatusCode = 400; - context.Response.StatusDescription = "Bad Request"; - context.Response.End(); - - return; - } - - var appDebug = new AppDebug(); - var requestBody = JsonConvert.DeserializeAnonymousType(data, appDebug); - - Debug.SetDebugLevel(requestBody.Level); - - appDebug.Level = Debug.Level; - var responseBody = JsonConvert.SerializeObject(appDebug, Formatting.Indented); - - context.Response.StatusCode = 200; - context.Response.StatusDescription = "OK"; - context.Response.Write(responseBody, false); - context.Response.End(); - } - } - - public class AppDebug - { - [JsonProperty("level", NullValueHandling = NullValueHandling.Ignore)] - public int Level { get; set; } - } +using Crestron.SimplSharp.WebScripting; +using Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Core.Web.RequestHandlers; + +namespace PepperDash.Essentials.Core.Web.RequestHandlers +{ + public class AppDebugRequestHandler : WebApiBaseRequestHandler + { + /// + /// Constructor + /// + /// + /// base(true) enables CORS support by default + /// + public AppDebugRequestHandler() + : base(true) + { + } + + /// + /// Handles GET method requests + /// + /// + protected override void HandleGet(HttpCwsContext context) + { + var appDebug = new AppDebug { Level = Debug.Level }; + + var body = JsonConvert.SerializeObject(appDebug, Formatting.Indented); + + context.Response.StatusCode = 200; + context.Response.StatusDescription = "OK"; + context.Response.Write(body, false); + context.Response.End(); + } + + /// + /// Handles POST method requests + /// + /// + protected override void HandlePost(HttpCwsContext context) + { + if (context.Request.ContentLength < 0) + { + context.Response.StatusCode = 400; + context.Response.StatusDescription = "Bad Request"; + context.Response.End(); + + return; + } + + var data = EssentialsWebApiHelpers.GetRequestBody(context.Request); + if (string.IsNullOrEmpty(data)) + { + context.Response.StatusCode = 400; + context.Response.StatusDescription = "Bad Request"; + context.Response.End(); + + return; + } + + var appDebug = new AppDebug(); + var requestBody = JsonConvert.DeserializeAnonymousType(data, appDebug); + + Debug.SetDebugLevel(requestBody.Level); + + appDebug.Level = Debug.Level; + var responseBody = JsonConvert.SerializeObject(appDebug, Formatting.Indented); + + context.Response.StatusCode = 200; + context.Response.StatusDescription = "OK"; + context.Response.Write(responseBody, false); + context.Response.End(); + } + } + + public class AppDebug + { + [JsonProperty("level", NullValueHandling = NullValueHandling.Ignore)] + public int Level { get; set; } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DefaultRequestHandler.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DefaultRequestHandler.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DefaultRequestHandler.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DefaultRequestHandler.cs index 786962f5..3320de7e 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DefaultRequestHandler.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DefaultRequestHandler.cs @@ -1,118 +1,118 @@ -using Crestron.SimplSharp.WebScripting; -using PepperDash.Core.Web.RequestHandlers; - -namespace PepperDash.Essentials.Core.Web.RequestHandlers -{ - public class DefaultRequestHandler : WebApiBaseRequestHandler - { - /// - /// Constructor - /// - /// - /// base(true) enables CORS support by default - /// - public DefaultRequestHandler() - : base(true) - { - } - - /// - /// Handles CONNECT method requests - /// - /// - protected override void HandleConnect(HttpCwsContext context) - { - context.Response.StatusCode = 418; - context.Response.StatusDescription = "I'm a teapot"; - context.Response.End(); - } - - /// - /// Handles DELETE method requests - /// - /// - protected override void HandleDelete(HttpCwsContext context) - { - context.Response.StatusCode = 418; - context.Response.StatusDescription = "I'm a teapot"; - context.Response.End(); - } - - /// - /// Handles GET method requests - /// - /// - protected override void HandleGet(HttpCwsContext context) - { - context.Response.StatusCode = 418; - context.Response.StatusDescription = "I'm a teapot"; - context.Response.End(); - } - - /// - /// Handles HEAD method requests - /// - /// - protected override void HandleHead(HttpCwsContext context) - { - context.Response.StatusCode = 418; - context.Response.StatusDescription = "I'm a teapot"; - context.Response.End(); - } - - /// - /// Handles OPTIONS method requests - /// - /// - protected override void HandleOptions(HttpCwsContext context) - { - context.Response.StatusCode = 418; - context.Response.StatusDescription = "I'm a teapot"; - context.Response.End(); - } - - /// - /// Handles PATCH method requests - /// - /// - protected override void HandlePatch(HttpCwsContext context) - { - context.Response.StatusCode = 418; - context.Response.StatusDescription = "I'm a teapot"; - context.Response.End(); - } - - /// - /// Handles POST method requests - /// - /// - protected override void HandlePost(HttpCwsContext context) - { - context.Response.StatusCode = 418; - context.Response.StatusDescription = "I'm a teapot"; - context.Response.End(); - } - - /// - /// Handles PUT method requests - /// - /// - protected override void HandlePut(HttpCwsContext context) - { - context.Response.StatusCode = 418; - context.Response.StatusDescription = "I'm a teapot"; - context.Response.End(); - } - - /// - /// Handles TRACE method requests - /// - /// - protected override void HandleTrace(HttpCwsContext context) - { - context.Response.StatusCode = 418; - context.Response.StatusDescription = "I'm a teapot"; - context.Response.End(); - } - } +using Crestron.SimplSharp.WebScripting; +using PepperDash.Core.Web.RequestHandlers; + +namespace PepperDash.Essentials.Core.Web.RequestHandlers +{ + public class DefaultRequestHandler : WebApiBaseRequestHandler + { + /// + /// Constructor + /// + /// + /// base(true) enables CORS support by default + /// + public DefaultRequestHandler() + : base(true) + { + } + + /// + /// Handles CONNECT method requests + /// + /// + protected override void HandleConnect(HttpCwsContext context) + { + context.Response.StatusCode = 418; + context.Response.StatusDescription = "I'm a teapot"; + context.Response.End(); + } + + /// + /// Handles DELETE method requests + /// + /// + protected override void HandleDelete(HttpCwsContext context) + { + context.Response.StatusCode = 418; + context.Response.StatusDescription = "I'm a teapot"; + context.Response.End(); + } + + /// + /// Handles GET method requests + /// + /// + protected override void HandleGet(HttpCwsContext context) + { + context.Response.StatusCode = 418; + context.Response.StatusDescription = "I'm a teapot"; + context.Response.End(); + } + + /// + /// Handles HEAD method requests + /// + /// + protected override void HandleHead(HttpCwsContext context) + { + context.Response.StatusCode = 418; + context.Response.StatusDescription = "I'm a teapot"; + context.Response.End(); + } + + /// + /// Handles OPTIONS method requests + /// + /// + protected override void HandleOptions(HttpCwsContext context) + { + context.Response.StatusCode = 418; + context.Response.StatusDescription = "I'm a teapot"; + context.Response.End(); + } + + /// + /// Handles PATCH method requests + /// + /// + protected override void HandlePatch(HttpCwsContext context) + { + context.Response.StatusCode = 418; + context.Response.StatusDescription = "I'm a teapot"; + context.Response.End(); + } + + /// + /// Handles POST method requests + /// + /// + protected override void HandlePost(HttpCwsContext context) + { + context.Response.StatusCode = 418; + context.Response.StatusDescription = "I'm a teapot"; + context.Response.End(); + } + + /// + /// Handles PUT method requests + /// + /// + protected override void HandlePut(HttpCwsContext context) + { + context.Response.StatusCode = 418; + context.Response.StatusDescription = "I'm a teapot"; + context.Response.End(); + } + + /// + /// Handles TRACE method requests + /// + /// + protected override void HandleTrace(HttpCwsContext context) + { + context.Response.StatusCode = 418; + context.Response.StatusDescription = "I'm a teapot"; + context.Response.End(); + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevJsonRequestHandler.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevJsonRequestHandler.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevJsonRequestHandler.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevJsonRequestHandler.cs index 7a9162bd..5c4f33a2 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevJsonRequestHandler.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevJsonRequestHandler.cs @@ -1,66 +1,66 @@ -using System; -using Crestron.SimplSharp.WebScripting; -using PepperDash.Core; -using PepperDash.Core.Web.RequestHandlers; - -namespace PepperDash.Essentials.Core.Web.RequestHandlers -{ - public class DevJsonRequestHandler : WebApiBaseRequestHandler - { - /// - /// Constructor - /// - /// - /// base(true) enables CORS support by default - /// - public DevJsonRequestHandler() - : base(true) - { - } - - /// - /// Handles POST method requests - /// - /// - protected override void HandlePost(HttpCwsContext context) - { - if (context.Request.ContentLength < 0) - { - context.Response.StatusCode = 400; - context.Response.StatusDescription = "Bad Request"; - context.Response.End(); - - return; - } - - var data = EssentialsWebApiHelpers.GetRequestBody(context.Request); - if (string.IsNullOrEmpty(data)) - { - context.Response.StatusCode = 400; - context.Response.StatusDescription = "Bad Request"; - context.Response.End(); - - return; - } - - try - { - DeviceJsonApi.DoDeviceActionWithJson(data); - - context.Response.StatusCode = 200; - context.Response.StatusDescription = "OK"; - context.Response.End(); - } - catch (Exception ex) - { - Debug.Console(1, "Exception Message: {0}", ex.Message); - Debug.Console(2, "Exception Stack Trace: {0}", ex.StackTrace); - if(ex.InnerException != null) Debug.Console(2, "Exception Inner: {0}", ex.InnerException); - - context.Response.StatusCode = 400; - context.Response.StatusDescription = "Bad Request"; - context.Response.End(); - } - } - } +using System; +using Crestron.SimplSharp.WebScripting; +using PepperDash.Core; +using PepperDash.Core.Web.RequestHandlers; + +namespace PepperDash.Essentials.Core.Web.RequestHandlers +{ + public class DevJsonRequestHandler : WebApiBaseRequestHandler + { + /// + /// Constructor + /// + /// + /// base(true) enables CORS support by default + /// + public DevJsonRequestHandler() + : base(true) + { + } + + /// + /// Handles POST method requests + /// + /// + protected override void HandlePost(HttpCwsContext context) + { + if (context.Request.ContentLength < 0) + { + context.Response.StatusCode = 400; + context.Response.StatusDescription = "Bad Request"; + context.Response.End(); + + return; + } + + var data = EssentialsWebApiHelpers.GetRequestBody(context.Request); + if (string.IsNullOrEmpty(data)) + { + context.Response.StatusCode = 400; + context.Response.StatusDescription = "Bad Request"; + context.Response.End(); + + return; + } + + try + { + DeviceJsonApi.DoDeviceActionWithJson(data); + + context.Response.StatusCode = 200; + context.Response.StatusDescription = "OK"; + context.Response.End(); + } + catch (Exception ex) + { + Debug.Console(1, "Exception Message: {0}", ex.Message); + Debug.Console(2, "Exception Stack Trace: {0}", ex.StackTrace); + if(ex.InnerException != null) Debug.Console(2, "Exception Inner: {0}", ex.InnerException); + + context.Response.StatusCode = 400; + context.Response.StatusDescription = "Bad Request"; + context.Response.End(); + } + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevListRequestHandler.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevListRequestHandler.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevListRequestHandler.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevListRequestHandler.cs index cf2a1e78..e9df4347 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevListRequestHandler.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevListRequestHandler.cs @@ -1,51 +1,51 @@ -using System.Linq; -using Crestron.SimplSharp.WebScripting; -using Newtonsoft.Json; -using PepperDash.Core.Web.RequestHandlers; - -namespace PepperDash.Essentials.Core.Web.RequestHandlers -{ - public class DevListRequestHandler : WebApiBaseRequestHandler - { - /// - /// Constructor - /// - /// - /// base(true) enables CORS support by default - /// - public DevListRequestHandler() - : base(true) - { - } - - /// - /// Handles GET method requests - /// - /// - protected override void HandleGet(HttpCwsContext context) - { - var allDevices = DeviceManager.AllDevices; - if (allDevices == null) - { - context.Response.StatusCode = 404; - context.Response.StatusDescription = "Not Found"; - context.Response.End(); - - return; - } - - allDevices.Sort((a, b) => System.String.Compare(a.Key, b.Key, System.StringComparison.Ordinal)); - - var deviceList = allDevices.Select(d => EssentialsWebApiHelpers.MapToDeviceListObject(d)).ToList(); - - var js = JsonConvert.SerializeObject(deviceList, Formatting.Indented); - - context.Response.StatusCode = 200; - context.Response.StatusDescription = "OK"; - context.Response.ContentType = "application/json"; - context.Response.ContentEncoding = System.Text.Encoding.UTF8; - context.Response.Write(js, false); - context.Response.End(); - } - } +using System.Linq; +using Crestron.SimplSharp.WebScripting; +using Newtonsoft.Json; +using PepperDash.Core.Web.RequestHandlers; + +namespace PepperDash.Essentials.Core.Web.RequestHandlers +{ + public class DevListRequestHandler : WebApiBaseRequestHandler + { + /// + /// Constructor + /// + /// + /// base(true) enables CORS support by default + /// + public DevListRequestHandler() + : base(true) + { + } + + /// + /// Handles GET method requests + /// + /// + protected override void HandleGet(HttpCwsContext context) + { + var allDevices = DeviceManager.AllDevices; + if (allDevices == null) + { + context.Response.StatusCode = 404; + context.Response.StatusDescription = "Not Found"; + context.Response.End(); + + return; + } + + allDevices.Sort((a, b) => System.String.Compare(a.Key, b.Key, System.StringComparison.Ordinal)); + + var deviceList = allDevices.Select(d => EssentialsWebApiHelpers.MapToDeviceListObject(d)).ToList(); + + var js = JsonConvert.SerializeObject(deviceList, Formatting.Indented); + + context.Response.StatusCode = 200; + context.Response.StatusDescription = "OK"; + context.Response.ContentType = "application/json"; + context.Response.ContentEncoding = System.Text.Encoding.UTF8; + context.Response.Write(js, false); + context.Response.End(); + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevPropsRequestHandler.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevPropsRequestHandler.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevPropsRequestHandler.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevPropsRequestHandler.cs index be8d154d..25fadbce 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevPropsRequestHandler.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevPropsRequestHandler.cs @@ -1,76 +1,76 @@ -using System.Text; -using Crestron.SimplSharp.WebScripting; -using Newtonsoft.Json; -using PepperDash.Core.Web.RequestHandlers; - -namespace PepperDash.Essentials.Core.Web.RequestHandlers -{ - public class DevPropsRequestHandler : WebApiBaseRequestHandler - { - /// - /// Constructor - /// - /// - /// base(true) enables CORS support by default - /// - public DevPropsRequestHandler() - : base(true) - { - } - - /// - /// Handles POST method requests - /// - /// - protected override void HandlePost(HttpCwsContext context) - { - if (context.Request.ContentLength < 0) - { - context.Response.StatusCode = 400; - context.Response.StatusDescription = "Bad Request"; - context.Response.End(); - - return; - } - - var data = EssentialsWebApiHelpers.GetRequestBody(context.Request); - if (string.IsNullOrEmpty(data)) - { - context.Response.StatusCode = 400; - context.Response.StatusDescription = "Bad Request"; - context.Response.End(); - - return; - } - - var o = new DeviceActionWrapper(); - var body = JsonConvert.DeserializeAnonymousType(data, o); - - if (string.IsNullOrEmpty(body.DeviceKey)) - { - context.Response.StatusCode = 400; - context.Response.StatusDescription = "Bad Request"; - context.Response.End(); - - return; - } - - var deviceProps = DeviceJsonApi.GetProperties(body.DeviceKey); - if (deviceProps == null || deviceProps.ToLower().Contains("no device")) - { - context.Response.StatusCode = 404; - context.Response.StatusDescription = "Not Found"; - context.Response.End(); - - return; - } - - context.Response.StatusCode = 200; - context.Response.StatusDescription = "OK"; - context.Response.ContentType = "application/json"; - context.Response.ContentEncoding = Encoding.UTF8; - context.Response.Write(deviceProps, false); - context.Response.End(); - } - } +using System.Text; +using Crestron.SimplSharp.WebScripting; +using Newtonsoft.Json; +using PepperDash.Core.Web.RequestHandlers; + +namespace PepperDash.Essentials.Core.Web.RequestHandlers +{ + public class DevPropsRequestHandler : WebApiBaseRequestHandler + { + /// + /// Constructor + /// + /// + /// base(true) enables CORS support by default + /// + public DevPropsRequestHandler() + : base(true) + { + } + + /// + /// Handles POST method requests + /// + /// + protected override void HandlePost(HttpCwsContext context) + { + if (context.Request.ContentLength < 0) + { + context.Response.StatusCode = 400; + context.Response.StatusDescription = "Bad Request"; + context.Response.End(); + + return; + } + + var data = EssentialsWebApiHelpers.GetRequestBody(context.Request); + if (string.IsNullOrEmpty(data)) + { + context.Response.StatusCode = 400; + context.Response.StatusDescription = "Bad Request"; + context.Response.End(); + + return; + } + + var o = new DeviceActionWrapper(); + var body = JsonConvert.DeserializeAnonymousType(data, o); + + if (string.IsNullOrEmpty(body.DeviceKey)) + { + context.Response.StatusCode = 400; + context.Response.StatusDescription = "Bad Request"; + context.Response.End(); + + return; + } + + var deviceProps = DeviceJsonApi.GetProperties(body.DeviceKey); + if (deviceProps == null || deviceProps.ToLower().Contains("no device")) + { + context.Response.StatusCode = 404; + context.Response.StatusDescription = "Not Found"; + context.Response.End(); + + return; + } + + context.Response.StatusCode = 200; + context.Response.StatusDescription = "OK"; + context.Response.ContentType = "application/json"; + context.Response.ContentEncoding = Encoding.UTF8; + context.Response.Write(deviceProps, false); + context.Response.End(); + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DisableAllStreamDebugRequestHandler.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DisableAllStreamDebugRequestHandler.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DisableAllStreamDebugRequestHandler.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DisableAllStreamDebugRequestHandler.cs index 2e4546f4..0e682d6c 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DisableAllStreamDebugRequestHandler.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DisableAllStreamDebugRequestHandler.cs @@ -1,32 +1,32 @@ -using Crestron.SimplSharp.WebScripting; -using PepperDash.Core.Web.RequestHandlers; - -namespace PepperDash.Essentials.Core.Web.RequestHandlers -{ - public class DisableAllStreamDebugRequestHandler : WebApiBaseRequestHandler - { - /// - /// Constructor - /// - /// - /// base(true) enables CORS support by default - /// - public DisableAllStreamDebugRequestHandler() - : base(true) - { - } - - /// - /// Handles POST method requests - /// - /// - protected override void HandlePost(HttpCwsContext context) - { - DeviceManager.DisableAllDeviceStreamDebugging(); - - context.Response.StatusCode = 200; - context.Response.StatusDescription = "OK"; - context.Response.End(); - } - } +using Crestron.SimplSharp.WebScripting; +using PepperDash.Core.Web.RequestHandlers; + +namespace PepperDash.Essentials.Core.Web.RequestHandlers +{ + public class DisableAllStreamDebugRequestHandler : WebApiBaseRequestHandler + { + /// + /// Constructor + /// + /// + /// base(true) enables CORS support by default + /// + public DisableAllStreamDebugRequestHandler() + : base(true) + { + } + + /// + /// Handles POST method requests + /// + /// + protected override void HandlePost(HttpCwsContext context) + { + DeviceManager.DisableAllDeviceStreamDebugging(); + + context.Response.StatusCode = 200; + context.Response.StatusDescription = "OK"; + context.Response.End(); + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetFeedbacksForDeviceRequestHandler.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetFeedbacksForDeviceRequestHandler.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetFeedbacksForDeviceRequestHandler.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetFeedbacksForDeviceRequestHandler.cs index 5d76bc73..5dd5495c 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetFeedbacksForDeviceRequestHandler.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetFeedbacksForDeviceRequestHandler.cs @@ -1,102 +1,102 @@ -using System.Linq; -using Crestron.SimplSharp.WebScripting; -using Newtonsoft.Json; -using PepperDash.Core.Web.RequestHandlers; - -namespace PepperDash.Essentials.Core.Web.RequestHandlers -{ - public class GetFeedbacksForDeviceRequestHandler : WebApiBaseRequestHandler - { - /// - /// Constructor - /// - /// - /// base(true) enables CORS support by default - /// - public GetFeedbacksForDeviceRequestHandler() - : base(true) - { - } - - /// - /// Handles GET method requests - /// - /// - protected override void HandleGet(HttpCwsContext context) - { - var routeData = context.Request.RouteData; - if (routeData == null) - { - context.Response.StatusCode = 400; - context.Response.StatusDescription = "Bad Request"; - context.Response.End(); - - return; - } - - object deviceObj; - if (!routeData.Values.TryGetValue("deviceKey", out deviceObj)) - { - context.Response.StatusCode = 400; - context.Response.StatusDescription = "Bad Request"; - context.Response.End(); - - return; - } - - - var device = DeviceManager.GetDeviceForKey(deviceObj.ToString()) as IHasFeedback; - if (device == null) - { - context.Response.StatusCode = 404; - context.Response.StatusDescription = "Not Found"; - context.Response.End(); - - return; - } - - var boolFeedback = - from feedback in device.Feedbacks.OfType() - where !string.IsNullOrEmpty(feedback.Key) - select new - { - FeedbackKey = feedback.Key, - Value = feedback.BoolValue - }; - - var intFeedback = - from feedback in device.Feedbacks.OfType() - where !string.IsNullOrEmpty(feedback.Key) - select new - { - FeedbackKey = feedback.Key, - Value = feedback.IntValue - }; - - var stringFeedback = - from feedback in device.Feedbacks.OfType() - where !string.IsNullOrEmpty(feedback.Key) - select new - { - FeedbackKey = feedback.Key, - Value = feedback.StringValue ?? string.Empty - }; - - var responseObj = new - { - BoolValues = boolFeedback, - IntValues = intFeedback, - SerialValues = stringFeedback - }; - - var js = JsonConvert.SerializeObject(responseObj, Formatting.Indented); - - context.Response.StatusCode = 200; - context.Response.StatusDescription = "OK"; - context.Response.ContentType = "application/json"; - context.Response.ContentEncoding = System.Text.Encoding.UTF8; - context.Response.Write(js, false); - context.Response.End(); - } - } +using System.Linq; +using Crestron.SimplSharp.WebScripting; +using Newtonsoft.Json; +using PepperDash.Core.Web.RequestHandlers; + +namespace PepperDash.Essentials.Core.Web.RequestHandlers +{ + public class GetFeedbacksForDeviceRequestHandler : WebApiBaseRequestHandler + { + /// + /// Constructor + /// + /// + /// base(true) enables CORS support by default + /// + public GetFeedbacksForDeviceRequestHandler() + : base(true) + { + } + + /// + /// Handles GET method requests + /// + /// + protected override void HandleGet(HttpCwsContext context) + { + var routeData = context.Request.RouteData; + if (routeData == null) + { + context.Response.StatusCode = 400; + context.Response.StatusDescription = "Bad Request"; + context.Response.End(); + + return; + } + + object deviceObj; + if (!routeData.Values.TryGetValue("deviceKey", out deviceObj)) + { + context.Response.StatusCode = 400; + context.Response.StatusDescription = "Bad Request"; + context.Response.End(); + + return; + } + + + var device = DeviceManager.GetDeviceForKey(deviceObj.ToString()) as IHasFeedback; + if (device == null) + { + context.Response.StatusCode = 404; + context.Response.StatusDescription = "Not Found"; + context.Response.End(); + + return; + } + + var boolFeedback = + from feedback in device.Feedbacks.OfType() + where !string.IsNullOrEmpty(feedback.Key) + select new + { + FeedbackKey = feedback.Key, + Value = feedback.BoolValue + }; + + var intFeedback = + from feedback in device.Feedbacks.OfType() + where !string.IsNullOrEmpty(feedback.Key) + select new + { + FeedbackKey = feedback.Key, + Value = feedback.IntValue + }; + + var stringFeedback = + from feedback in device.Feedbacks.OfType() + where !string.IsNullOrEmpty(feedback.Key) + select new + { + FeedbackKey = feedback.Key, + Value = feedback.StringValue ?? string.Empty + }; + + var responseObj = new + { + BoolValues = boolFeedback, + IntValues = intFeedback, + SerialValues = stringFeedback + }; + + var js = JsonConvert.SerializeObject(responseObj, Formatting.Indented); + + context.Response.StatusCode = 200; + context.Response.StatusDescription = "OK"; + context.Response.ContentType = "application/json"; + context.Response.ContentEncoding = System.Text.Encoding.UTF8; + context.Response.Write(js, false); + context.Response.End(); + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetJoinMapForBridgeKeyRequestHandler.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetJoinMapForBridgeKeyRequestHandler.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetJoinMapForBridgeKeyRequestHandler.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetJoinMapForBridgeKeyRequestHandler.cs index 7e15fd5e..f2362f4b 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetJoinMapForBridgeKeyRequestHandler.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetJoinMapForBridgeKeyRequestHandler.cs @@ -1,78 +1,78 @@ -using System.Linq; -using Crestron.SimplSharp.WebScripting; -using Newtonsoft.Json; -using PepperDash.Core.Web.RequestHandlers; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.Core.Web.RequestHandlers -{ - public class GetJoinMapForBridgeKeyRequestHandler : WebApiBaseRequestHandler - { - /// - /// Constructor - /// - /// - /// base(true) enables CORS support by default - /// - public GetJoinMapForBridgeKeyRequestHandler() - : base(true) - { - } - - /// - /// Handles GET method requests - /// - /// - protected override void HandleGet(HttpCwsContext context) - { - var routeData = context.Request.RouteData; - if (routeData == null) - { - context.Response.StatusCode = 400; - context.Response.StatusDescription = "Bad Request"; - context.Response.End(); - - return; - } - - object bridgeObj; - if (!routeData.Values.TryGetValue("bridgeKey", out bridgeObj)) - { - context.Response.StatusCode = 400; - context.Response.StatusDescription = "Bad Request"; - context.Response.End(); - - return; - } - - var bridge = DeviceManager.GetDeviceForKey(bridgeObj.ToString()) as EiscApiAdvanced; - if (bridge == null) - { - context.Response.StatusCode = 400; - context.Response.StatusDescription = "Bad Request"; - context.Response.End(); - - return; - } - - var joinMap = bridge.JoinMaps.Select(j => EssentialsWebApiHelpers.MapJoinToObject(j)).ToList(); - if (joinMap == null) - { - context.Response.StatusCode = 404; - context.Response.StatusDescription = "Not Found"; - context.Response.End(); - - return; - } - - var js = JsonConvert.SerializeObject(joinMap, Formatting.Indented); - - context.Response.StatusCode = 200; - context.Response.StatusDescription = "OK"; - context.Response.ContentType = "application/json"; - context.Response.ContentEncoding = System.Text.Encoding.UTF8; - context.Response.Write(js, false); - context.Response.End(); - } - } +using System.Linq; +using Crestron.SimplSharp.WebScripting; +using Newtonsoft.Json; +using PepperDash.Core.Web.RequestHandlers; +using PepperDash.Essentials.Core.Bridges; + +namespace PepperDash.Essentials.Core.Web.RequestHandlers +{ + public class GetJoinMapForBridgeKeyRequestHandler : WebApiBaseRequestHandler + { + /// + /// Constructor + /// + /// + /// base(true) enables CORS support by default + /// + public GetJoinMapForBridgeKeyRequestHandler() + : base(true) + { + } + + /// + /// Handles GET method requests + /// + /// + protected override void HandleGet(HttpCwsContext context) + { + var routeData = context.Request.RouteData; + if (routeData == null) + { + context.Response.StatusCode = 400; + context.Response.StatusDescription = "Bad Request"; + context.Response.End(); + + return; + } + + object bridgeObj; + if (!routeData.Values.TryGetValue("bridgeKey", out bridgeObj)) + { + context.Response.StatusCode = 400; + context.Response.StatusDescription = "Bad Request"; + context.Response.End(); + + return; + } + + var bridge = DeviceManager.GetDeviceForKey(bridgeObj.ToString()) as EiscApiAdvanced; + if (bridge == null) + { + context.Response.StatusCode = 400; + context.Response.StatusDescription = "Bad Request"; + context.Response.End(); + + return; + } + + var joinMap = bridge.JoinMaps.Select(j => EssentialsWebApiHelpers.MapJoinToObject(j)).ToList(); + if (joinMap == null) + { + context.Response.StatusCode = 404; + context.Response.StatusDescription = "Not Found"; + context.Response.End(); + + return; + } + + var js = JsonConvert.SerializeObject(joinMap, Formatting.Indented); + + context.Response.StatusCode = 200; + context.Response.StatusDescription = "OK"; + context.Response.ContentType = "application/json"; + context.Response.ContentEncoding = System.Text.Encoding.UTF8; + context.Response.Write(js, false); + context.Response.End(); + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetJoinMapForDeviceKeyRequestHandler.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetJoinMapForDeviceKeyRequestHandler.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetJoinMapForDeviceKeyRequestHandler.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetJoinMapForDeviceKeyRequestHandler.cs index 77d7f8ea..6c669189 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetJoinMapForDeviceKeyRequestHandler.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetJoinMapForDeviceKeyRequestHandler.cs @@ -1,95 +1,95 @@ -using Crestron.SimplSharp.WebScripting; -using Newtonsoft.Json; -using PepperDash.Core.Web.RequestHandlers; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.Core.Web.RequestHandlers -{ - public class GetJoinMapForDeviceKeyRequestHandler : WebApiBaseRequestHandler - { - /// - /// Constructor - /// - /// - /// base(true) enables CORS support by default - /// - public GetJoinMapForDeviceKeyRequestHandler() - : base(true) - { - } - - /// - /// Handles GET method requests - /// - /// - protected override void HandleGet(HttpCwsContext context) - { - var routeData = context.Request.RouteData; - if (routeData == null) - { - context.Response.StatusCode = 400; - context.Response.StatusDescription = "Bad Request"; - context.Response.End(); - - return; - } - - object bridgeObj; - if (!routeData.Values.TryGetValue("bridgeKey", out bridgeObj)) - { - context.Response.StatusCode = 400; - context.Response.StatusDescription = "Bad Request"; - context.Response.End(); - - return; - } - - object deviceObj; - if (!routeData.Values.TryGetValue("deviceKey", out deviceObj)) - { - context.Response.StatusCode = 400; - context.Response.StatusDescription = "Bad Request"; - context.Response.End(); - - return; - } - - var bridge = DeviceManager.GetDeviceForKey(bridgeObj.ToString()) as EiscApiAdvanced; - if (bridge == null) - { - context.Response.StatusCode = 404; - context.Response.StatusDescription = "Not Found"; - context.Response.End(); - - return; - } - - JoinMapBaseAdvanced deviceJoinMap; - if (!bridge.JoinMaps.TryGetValue(deviceObj.ToString(), out deviceJoinMap)) - { - context.Response.StatusCode = 500; - context.Response.StatusDescription = "Internal Server Error"; - context.Response.End(); - - return; - } - - var joinMap = EssentialsWebApiHelpers.MapJoinToObject(deviceObj.ToString(), deviceJoinMap); - var js = JsonConvert.SerializeObject(joinMap, Formatting.Indented, new JsonSerializerSettings - { - ReferenceLoopHandling = ReferenceLoopHandling.Ignore, - NullValueHandling = NullValueHandling.Ignore, - MissingMemberHandling = MissingMemberHandling.Ignore, - DefaultValueHandling = DefaultValueHandling.Ignore, - TypeNameHandling = TypeNameHandling.None - }); - - context.Response.StatusCode = 200; - context.Response.StatusDescription = "OK"; - context.Response.ContentType = "application/json"; - context.Response.ContentEncoding = System.Text.Encoding.UTF8; - context.Response.Write(js, false); - context.Response.End(); - } - } +using Crestron.SimplSharp.WebScripting; +using Newtonsoft.Json; +using PepperDash.Core.Web.RequestHandlers; +using PepperDash.Essentials.Core.Bridges; + +namespace PepperDash.Essentials.Core.Web.RequestHandlers +{ + public class GetJoinMapForDeviceKeyRequestHandler : WebApiBaseRequestHandler + { + /// + /// Constructor + /// + /// + /// base(true) enables CORS support by default + /// + public GetJoinMapForDeviceKeyRequestHandler() + : base(true) + { + } + + /// + /// Handles GET method requests + /// + /// + protected override void HandleGet(HttpCwsContext context) + { + var routeData = context.Request.RouteData; + if (routeData == null) + { + context.Response.StatusCode = 400; + context.Response.StatusDescription = "Bad Request"; + context.Response.End(); + + return; + } + + object bridgeObj; + if (!routeData.Values.TryGetValue("bridgeKey", out bridgeObj)) + { + context.Response.StatusCode = 400; + context.Response.StatusDescription = "Bad Request"; + context.Response.End(); + + return; + } + + object deviceObj; + if (!routeData.Values.TryGetValue("deviceKey", out deviceObj)) + { + context.Response.StatusCode = 400; + context.Response.StatusDescription = "Bad Request"; + context.Response.End(); + + return; + } + + var bridge = DeviceManager.GetDeviceForKey(bridgeObj.ToString()) as EiscApiAdvanced; + if (bridge == null) + { + context.Response.StatusCode = 404; + context.Response.StatusDescription = "Not Found"; + context.Response.End(); + + return; + } + + JoinMapBaseAdvanced deviceJoinMap; + if (!bridge.JoinMaps.TryGetValue(deviceObj.ToString(), out deviceJoinMap)) + { + context.Response.StatusCode = 500; + context.Response.StatusDescription = "Internal Server Error"; + context.Response.End(); + + return; + } + + var joinMap = EssentialsWebApiHelpers.MapJoinToObject(deviceObj.ToString(), deviceJoinMap); + var js = JsonConvert.SerializeObject(joinMap, Formatting.Indented, new JsonSerializerSettings + { + ReferenceLoopHandling = ReferenceLoopHandling.Ignore, + NullValueHandling = NullValueHandling.Ignore, + MissingMemberHandling = MissingMemberHandling.Ignore, + DefaultValueHandling = DefaultValueHandling.Ignore, + TypeNameHandling = TypeNameHandling.None + }); + + context.Response.StatusCode = 200; + context.Response.StatusDescription = "OK"; + context.Response.ContentType = "application/json"; + context.Response.ContentEncoding = System.Text.Encoding.UTF8; + context.Response.Write(js, false); + context.Response.End(); + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetTypesByFilterRequestHandler.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetTypesByFilterRequestHandler.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetTypesByFilterRequestHandler.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetTypesByFilterRequestHandler.cs index 706793e7..637c533c 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetTypesByFilterRequestHandler.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetTypesByFilterRequestHandler.cs @@ -1,68 +1,68 @@ -using System.Linq; -using Crestron.SimplSharp.WebScripting; -using Newtonsoft.Json; -using PepperDash.Core.Web.RequestHandlers; - -namespace PepperDash.Essentials.Core.Web.RequestHandlers -{ - public class GetTypesByFilterRequestHandler : WebApiBaseRequestHandler - { - /// - /// Constructor - /// - /// - /// base(true) enables CORS support by default - /// - public GetTypesByFilterRequestHandler() - : base(true) - { - } - - /// - /// Handles GET method requests - /// - /// - protected override void HandleGet(HttpCwsContext context) - { - var routeData = context.Request.RouteData; - if (routeData == null) - { - context.Response.StatusCode = 400; - context.Response.StatusDescription = "Bad Request"; - context.Response.End(); - - return; - } - - object filterObj; - if (!routeData.Values.TryGetValue("filter", out filterObj)) - { - context.Response.StatusCode = 400; - context.Response.StatusDescription = "Bad Request"; - context.Response.End(); - - return; - } - - var deviceFactory = DeviceFactory.GetDeviceFactoryDictionary(filterObj.ToString()); - if (deviceFactory == null) - { - context.Response.StatusCode = 404; - context.Response.StatusDescription = "Not Found"; - context.Response.End(); - - return; - } - - var deviceTypes = deviceFactory.Select(t => EssentialsWebApiHelpers.MapDeviceTypeToObject(t)).ToList(); - var js = JsonConvert.SerializeObject(deviceTypes, Formatting.Indented); - - context.Response.StatusCode = 200; - context.Response.StatusDescription = "OK"; - context.Response.ContentType = "application/json"; - context.Response.ContentEncoding = System.Text.Encoding.UTF8; - context.Response.Write(js, false); - context.Response.End(); - } - } +using System.Linq; +using Crestron.SimplSharp.WebScripting; +using Newtonsoft.Json; +using PepperDash.Core.Web.RequestHandlers; + +namespace PepperDash.Essentials.Core.Web.RequestHandlers +{ + public class GetTypesByFilterRequestHandler : WebApiBaseRequestHandler + { + /// + /// Constructor + /// + /// + /// base(true) enables CORS support by default + /// + public GetTypesByFilterRequestHandler() + : base(true) + { + } + + /// + /// Handles GET method requests + /// + /// + protected override void HandleGet(HttpCwsContext context) + { + var routeData = context.Request.RouteData; + if (routeData == null) + { + context.Response.StatusCode = 400; + context.Response.StatusDescription = "Bad Request"; + context.Response.End(); + + return; + } + + object filterObj; + if (!routeData.Values.TryGetValue("filter", out filterObj)) + { + context.Response.StatusCode = 400; + context.Response.StatusDescription = "Bad Request"; + context.Response.End(); + + return; + } + + var deviceFactory = DeviceFactory.GetDeviceFactoryDictionary(filterObj.ToString()); + if (deviceFactory == null) + { + context.Response.StatusCode = 404; + context.Response.StatusDescription = "Not Found"; + context.Response.End(); + + return; + } + + var deviceTypes = deviceFactory.Select(t => EssentialsWebApiHelpers.MapDeviceTypeToObject(t)).ToList(); + var js = JsonConvert.SerializeObject(deviceTypes, Formatting.Indented); + + context.Response.StatusCode = 200; + context.Response.StatusDescription = "OK"; + context.Response.ContentType = "application/json"; + context.Response.ContentEncoding = System.Text.Encoding.UTF8; + context.Response.Write(js, false); + context.Response.End(); + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetTypesRequestHandler.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetTypesRequestHandler.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetTypesRequestHandler.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetTypesRequestHandler.cs index 9d5f1150..564cb00d 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetTypesRequestHandler.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetTypesRequestHandler.cs @@ -1,58 +1,58 @@ -using System.Linq; -using Crestron.SimplSharp.WebScripting; -using Newtonsoft.Json; -using PepperDash.Core.Web.RequestHandlers; - -namespace PepperDash.Essentials.Core.Web.RequestHandlers -{ - public class GetTypesRequestHandler : WebApiBaseRequestHandler - { - /// - /// Constructor - /// - /// - /// base(true) enables CORS support by default - /// - public GetTypesRequestHandler() - : base(true) - { - } - - /// - /// Handles GET method requests - /// - /// - protected override void HandleGet(HttpCwsContext context) - { - var routeData = context.Request.RouteData; - if (routeData == null) - { - context.Response.StatusCode = 400; - context.Response.StatusDescription = "Bad Request"; - context.Response.End(); - - return; - } - - var deviceFactory = DeviceFactory.GetDeviceFactoryDictionary(null); - if (deviceFactory == null) - { - context.Response.StatusCode = 404; - context.Response.StatusDescription = "Not Found"; - context.Response.End(); - - return; - } - - var deviceTypes = deviceFactory.Select(t => EssentialsWebApiHelpers.MapDeviceTypeToObject(t)).ToList(); - var js = JsonConvert.SerializeObject(deviceTypes, Formatting.Indented); - - context.Response.StatusCode = 200; - context.Response.StatusDescription = "OK"; - context.Response.ContentType = "application/json"; - context.Response.ContentEncoding = System.Text.Encoding.UTF8; - context.Response.Write(js, false); - context.Response.End(); - } - } +using System.Linq; +using Crestron.SimplSharp.WebScripting; +using Newtonsoft.Json; +using PepperDash.Core.Web.RequestHandlers; + +namespace PepperDash.Essentials.Core.Web.RequestHandlers +{ + public class GetTypesRequestHandler : WebApiBaseRequestHandler + { + /// + /// Constructor + /// + /// + /// base(true) enables CORS support by default + /// + public GetTypesRequestHandler() + : base(true) + { + } + + /// + /// Handles GET method requests + /// + /// + protected override void HandleGet(HttpCwsContext context) + { + var routeData = context.Request.RouteData; + if (routeData == null) + { + context.Response.StatusCode = 400; + context.Response.StatusDescription = "Bad Request"; + context.Response.End(); + + return; + } + + var deviceFactory = DeviceFactory.GetDeviceFactoryDictionary(null); + if (deviceFactory == null) + { + context.Response.StatusCode = 404; + context.Response.StatusDescription = "Not Found"; + context.Response.End(); + + return; + } + + var deviceTypes = deviceFactory.Select(t => EssentialsWebApiHelpers.MapDeviceTypeToObject(t)).ToList(); + var js = JsonConvert.SerializeObject(deviceTypes, Formatting.Indented); + + context.Response.StatusCode = 200; + context.Response.StatusDescription = "OK"; + context.Response.ContentType = "application/json"; + context.Response.ContentEncoding = System.Text.Encoding.UTF8; + context.Response.Write(js, false); + context.Response.End(); + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/ReportVersionsRequestHandler.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/ReportVersionsRequestHandler.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/ReportVersionsRequestHandler.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/ReportVersionsRequestHandler.cs index e6fb45f1..3447a1eb 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/ReportVersionsRequestHandler.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/ReportVersionsRequestHandler.cs @@ -1,49 +1,49 @@ -using System.Linq; -using Crestron.SimplSharp.WebScripting; -using Newtonsoft.Json; -using PepperDash.Core.Web.RequestHandlers; - -namespace PepperDash.Essentials.Core.Web.RequestHandlers -{ - public class ReportVersionsRequestHandler : WebApiBaseRequestHandler - { - /// - /// Constructor - /// - /// - /// base(true) enables CORS support by default - /// - public ReportVersionsRequestHandler() - : base(true) - { - } - - /// - /// Handles GET method requests - /// - /// - protected override void HandleGet(HttpCwsContext context) - { - var loadAssemblies = PluginLoader.LoadedAssemblies; - if (loadAssemblies == null) - { - context.Response.StatusCode = 500; - context.Response.StatusDescription = "Internal Server Error"; - context.Response.End(); - - return; - } - - var assemblies = loadAssemblies.Select(a => EssentialsWebApiHelpers.MapToAssemblyObject(a)).ToList(); - - var js = JsonConvert.SerializeObject(assemblies, Formatting.Indented); - - context.Response.StatusCode = 200; - context.Response.StatusDescription = "OK"; - context.Response.ContentType = "application/json"; - context.Response.ContentEncoding = System.Text.Encoding.UTF8; - context.Response.Write(js, false); - context.Response.End(); - } - } +using System.Linq; +using Crestron.SimplSharp.WebScripting; +using Newtonsoft.Json; +using PepperDash.Core.Web.RequestHandlers; + +namespace PepperDash.Essentials.Core.Web.RequestHandlers +{ + public class ReportVersionsRequestHandler : WebApiBaseRequestHandler + { + /// + /// Constructor + /// + /// + /// base(true) enables CORS support by default + /// + public ReportVersionsRequestHandler() + : base(true) + { + } + + /// + /// Handles GET method requests + /// + /// + protected override void HandleGet(HttpCwsContext context) + { + var loadAssemblies = PluginLoader.LoadedAssemblies; + if (loadAssemblies == null) + { + context.Response.StatusCode = 500; + context.Response.StatusDescription = "Internal Server Error"; + context.Response.End(); + + return; + } + + var assemblies = loadAssemblies.Select(a => EssentialsWebApiHelpers.MapToAssemblyObject(a)).ToList(); + + var js = JsonConvert.SerializeObject(assemblies, Formatting.Indented); + + context.Response.StatusCode = 200; + context.Response.StatusDescription = "OK"; + context.Response.ContentType = "application/json"; + context.Response.ContentEncoding = System.Text.Encoding.UTF8; + context.Response.Write(js, false); + context.Response.End(); + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/SetDeviceStreamDebugRequestHandler.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/SetDeviceStreamDebugRequestHandler.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/SetDeviceStreamDebugRequestHandler.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/SetDeviceStreamDebugRequestHandler.cs index bb7cc12f..a08fda2b 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/SetDeviceStreamDebugRequestHandler.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/SetDeviceStreamDebugRequestHandler.cs @@ -1,212 +1,212 @@ -using System; -using Crestron.SimplSharp.WebScripting; -using Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Core.Web.RequestHandlers; - -namespace PepperDash.Essentials.Core.Web.RequestHandlers -{ - public class SetDeviceStreamDebugRequestHandler : WebApiBaseRequestHandler - { - /// - /// Handles CONNECT method requests - /// - /// - protected override void HandleConnect(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles DELETE method requests - /// - /// - protected override void HandleDelete(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles GET method requests - /// - /// - protected override void HandleGet(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles HEAD method requests - /// - /// - protected override void HandleHead(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles OPTIONS method requests - /// - /// - protected override void HandleOptions(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PATCH method requests - /// - /// - protected override void HandlePatch(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles POST method requests - /// - /// - protected override void HandlePost(HttpCwsContext context) - { - if (context.Request.ContentLength < 0) - { - context.Response.StatusCode = 400; - context.Response.StatusDescription = "Bad Request"; - context.Response.End(); - - return; - } - - var data = EssentialsWebApiHelpers.GetRequestBody(context.Request); - if (data == null) - { - context.Response.StatusCode = 500; - context.Response.StatusDescription = "Internal Server Error"; - context.Response.End(); - - return; - } - - var config = new SetDeviceStreamDebugConfig(); - var body = JsonConvert.DeserializeAnonymousType(data, config); - if (body == null) - { - context.Response.StatusCode = 500; - context.Response.StatusDescription = "Internal Server Error"; - context.Response.End(); - - return; - } - - if (string.IsNullOrEmpty(body.DeviceKey) || string.IsNullOrEmpty(body.Setting)) - { - context.Response.StatusCode = 400; - context.Response.StatusDescription = "Bad Request"; - context.Response.End(); - - return; - } - - var device = DeviceManager.GetDeviceForKey(body.DeviceKey) as IStreamDebugging; - if (device == null) - { - context.Response.StatusCode = 404; - context.Response.StatusDescription = "Not Found"; - context.Response.End(); - - return; - } - - eStreamDebuggingSetting debugSetting; - try - { - debugSetting = (eStreamDebuggingSetting) Enum.Parse(typeof (eStreamDebuggingSetting), body.Setting, true); - } - catch (Exception ex) - { - context.Response.StatusCode = 500; - context.Response.StatusDescription = "Internal Server Error"; - context.Response.End(); - - return; - } - - try - { - var mins = Convert.ToUInt32(body.Timeout); - if (mins > 0) - { - device.StreamDebugging.SetDebuggingWithSpecificTimeout(debugSetting, mins); - } - else - { - device.StreamDebugging.SetDebuggingWithDefaultTimeout(debugSetting); - } - - context.Response.StatusCode = 200; - context.Response.StatusDescription = "OK"; - context.Response.End(); - } - catch (Exception ex) - { - context.Response.StatusCode = 500; - context.Response.StatusDescription = "Internal Server Error"; - context.Response.End(); - } - } - - /// - /// Handles PUT method requests - /// - /// - protected override void HandlePut(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles TRACE method requests - /// - /// - protected override void HandleTrace(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - } - - - public class SetDeviceStreamDebugConfig - { - [JsonProperty("deviceKey", NullValueHandling = NullValueHandling.Include)] - public string DeviceKey { get; set; } - - [JsonProperty("setting", NullValueHandling = NullValueHandling.Include)] - public string Setting { get; set; } - - [JsonProperty("timeout")] - public int Timeout { get; set; } - - public SetDeviceStreamDebugConfig() - { - DeviceKey = null; - Setting = null; - Timeout = 15; - } - } +using System; +using Crestron.SimplSharp.WebScripting; +using Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Core.Web.RequestHandlers; + +namespace PepperDash.Essentials.Core.Web.RequestHandlers +{ + public class SetDeviceStreamDebugRequestHandler : WebApiBaseRequestHandler + { + /// + /// Handles CONNECT method requests + /// + /// + protected override void HandleConnect(HttpCwsContext context) + { + context.Response.StatusCode = 501; + context.Response.StatusDescription = "Not Implemented"; + context.Response.End(); + } + + /// + /// Handles DELETE method requests + /// + /// + protected override void HandleDelete(HttpCwsContext context) + { + context.Response.StatusCode = 501; + context.Response.StatusDescription = "Not Implemented"; + context.Response.End(); + } + + /// + /// Handles GET method requests + /// + /// + protected override void HandleGet(HttpCwsContext context) + { + context.Response.StatusCode = 501; + context.Response.StatusDescription = "Not Implemented"; + context.Response.End(); + } + + /// + /// Handles HEAD method requests + /// + /// + protected override void HandleHead(HttpCwsContext context) + { + context.Response.StatusCode = 501; + context.Response.StatusDescription = "Not Implemented"; + context.Response.End(); + } + + /// + /// Handles OPTIONS method requests + /// + /// + protected override void HandleOptions(HttpCwsContext context) + { + context.Response.StatusCode = 501; + context.Response.StatusDescription = "Not Implemented"; + context.Response.End(); + } + + /// + /// Handles PATCH method requests + /// + /// + protected override void HandlePatch(HttpCwsContext context) + { + context.Response.StatusCode = 501; + context.Response.StatusDescription = "Not Implemented"; + context.Response.End(); + } + + /// + /// Handles POST method requests + /// + /// + protected override void HandlePost(HttpCwsContext context) + { + if (context.Request.ContentLength < 0) + { + context.Response.StatusCode = 400; + context.Response.StatusDescription = "Bad Request"; + context.Response.End(); + + return; + } + + var data = EssentialsWebApiHelpers.GetRequestBody(context.Request); + if (data == null) + { + context.Response.StatusCode = 500; + context.Response.StatusDescription = "Internal Server Error"; + context.Response.End(); + + return; + } + + var config = new SetDeviceStreamDebugConfig(); + var body = JsonConvert.DeserializeAnonymousType(data, config); + if (body == null) + { + context.Response.StatusCode = 500; + context.Response.StatusDescription = "Internal Server Error"; + context.Response.End(); + + return; + } + + if (string.IsNullOrEmpty(body.DeviceKey) || string.IsNullOrEmpty(body.Setting)) + { + context.Response.StatusCode = 400; + context.Response.StatusDescription = "Bad Request"; + context.Response.End(); + + return; + } + + var device = DeviceManager.GetDeviceForKey(body.DeviceKey) as IStreamDebugging; + if (device == null) + { + context.Response.StatusCode = 404; + context.Response.StatusDescription = "Not Found"; + context.Response.End(); + + return; + } + + eStreamDebuggingSetting debugSetting; + try + { + debugSetting = (eStreamDebuggingSetting) Enum.Parse(typeof (eStreamDebuggingSetting), body.Setting, true); + } + catch (Exception ex) + { + context.Response.StatusCode = 500; + context.Response.StatusDescription = "Internal Server Error"; + context.Response.End(); + + return; + } + + try + { + var mins = Convert.ToUInt32(body.Timeout); + if (mins > 0) + { + device.StreamDebugging.SetDebuggingWithSpecificTimeout(debugSetting, mins); + } + else + { + device.StreamDebugging.SetDebuggingWithDefaultTimeout(debugSetting); + } + + context.Response.StatusCode = 200; + context.Response.StatusDescription = "OK"; + context.Response.End(); + } + catch (Exception ex) + { + context.Response.StatusCode = 500; + context.Response.StatusDescription = "Internal Server Error"; + context.Response.End(); + } + } + + /// + /// Handles PUT method requests + /// + /// + protected override void HandlePut(HttpCwsContext context) + { + context.Response.StatusCode = 501; + context.Response.StatusDescription = "Not Implemented"; + context.Response.End(); + } + + /// + /// Handles TRACE method requests + /// + /// + protected override void HandleTrace(HttpCwsContext context) + { + context.Response.StatusCode = 501; + context.Response.StatusDescription = "Not Implemented"; + context.Response.End(); + } + } + + + public class SetDeviceStreamDebugConfig + { + [JsonProperty("deviceKey", NullValueHandling = NullValueHandling.Include)] + public string DeviceKey { get; set; } + + [JsonProperty("setting", NullValueHandling = NullValueHandling.Include)] + public string Setting { get; set; } + + [JsonProperty("timeout")] + public int Timeout { get; set; } + + public SetDeviceStreamDebugConfig() + { + DeviceKey = null; + Setting = null; + Timeout = 15; + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/ShowConfigRequestHandler.cs b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/ShowConfigRequestHandler.cs similarity index 96% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/ShowConfigRequestHandler.cs rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/ShowConfigRequestHandler.cs index 89da86b3..65af1d06 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/ShowConfigRequestHandler.cs +++ b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/ShowConfigRequestHandler.cs @@ -1,37 +1,37 @@ -using Crestron.SimplSharp.WebScripting; -using Newtonsoft.Json; -using PepperDash.Core.Web.RequestHandlers; -using PepperDash.Essentials.Core.Config; - -namespace PepperDash.Essentials.Core.Web.RequestHandlers -{ - public class ShowConfigRequestHandler : WebApiBaseRequestHandler - { - /// - /// Constructor - /// - /// - /// base(true) enables CORS support by default - /// - public ShowConfigRequestHandler() - : base(true) - { - } - - /// - /// Handles GET method requests - /// - /// - protected override void HandleGet(HttpCwsContext context) - { - var config = JsonConvert.SerializeObject(ConfigReader.ConfigObject, Formatting.Indented); - - context.Response.StatusCode = 200; - context.Response.StatusDescription = "OK"; - context.Response.ContentType = "application/json"; - context.Response.ContentEncoding = System.Text.Encoding.UTF8; - context.Response.Write(config, false); - context.Response.End(); - } - } +using Crestron.SimplSharp.WebScripting; +using Newtonsoft.Json; +using PepperDash.Core.Web.RequestHandlers; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core.Web.RequestHandlers +{ + public class ShowConfigRequestHandler : WebApiBaseRequestHandler + { + /// + /// Constructor + /// + /// + /// base(true) enables CORS support by default + /// + public ShowConfigRequestHandler() + : base(true) + { + } + + /// + /// Handles GET method requests + /// + /// + protected override void HandleGet(HttpCwsContext context) + { + var config = JsonConvert.SerializeObject(ConfigReader.ConfigObject, Formatting.Indented); + + context.Response.StatusCode = 200; + context.Response.StatusDescription = "OK"; + context.Response.ContentType = "application/json"; + context.Response.ContentEncoding = System.Text.Encoding.UTF8; + context.Response.Write(config, false); + context.Response.End(); + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/app.config b/src/essentials-framework/Essentials Core/PepperDashEssentialsBase/app.config similarity index 100% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/app.config rename to src/essentials-framework/Essentials Core/PepperDashEssentialsBase/app.config diff --git a/essentials-framework/Essentials DM/Essentials_DM.sln b/src/essentials-framework/Essentials DM/Essentials_DM.sln similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM.sln rename to src/essentials-framework/Essentials DM/Essentials_DM.sln diff --git a/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs similarity index 97% rename from essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs index 5a1d50ff..061e064d 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs @@ -1,433 +1,433 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.DeviceSupport.Support; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.AirMedia; -using Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Config; - -namespace PepperDash.Essentials.DM.AirMedia -{ - [Description("Wrapper class for an AM-200 or AM-300")] - public class AirMediaController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, IIROutputPorts, IComPorts - { - public Am3x00 AirMedia { get; private set; } - - public DeviceConfig DeviceConfig { get; private set; } - - AirMediaPropertiesConfig PropertiesConfig; - - public RoutingPortCollection InputPorts { get; private set; } - - public RoutingPortCollection OutputPorts { get; private set; } - - - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - public BoolFeedback IsInSessionFeedback { get; private set; } - public IntFeedback ErrorFeedback { get; private set; } - public IntFeedback NumberOfUsersConnectedFeedback { get; set; } - public IntFeedback LoginCodeFeedback { get; set; } - public StringFeedback ConnectionAddressFeedback { get; set; } - public StringFeedback HostnameFeedback { get; set; } - public IntFeedback VideoOutFeedback { get; private set; } - public BoolFeedback HdmiVideoSyncDetectedFeedback { get; private set; } - public StringFeedback SerialNumberFeedback { get; private set; } - public BoolFeedback AutomaticInputRoutingEnabledFeedback { get; private set; } - public BoolFeedback HdmiInHdcpSupportOnFeedback { get; private set; } - public BoolFeedback HdmiInDisabledByHdcpFeedback { get; private set; } - - public AirMediaController(string key, string name, Am3x00 device, DeviceConfig dc, AirMediaPropertiesConfig props) - : base(key, name, device) - { - AirMedia = device; - - DeviceConfig = dc; - - PropertiesConfig = props; - - InputPorts = new RoutingPortCollection(); - OutputPorts = new RoutingPortCollection(); - - InputPorts.Add(new RoutingInputPort(DmPortName.Osd, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.None, new Action(SelectPinPointUxLandingPage), this) - { - FeedbackMatchObject = 0 - }); - - InputPorts.Add(new RoutingInputPort(DmPortName.AirMediaIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Streaming, new Action(SelectAirMedia), this) - { - FeedbackMatchObject = 1 - }); - - InputPorts.Add(new RoutingInputPort(DmPortName.HdmiIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, new Action(SelectHdmiIn), this) - { - FeedbackMatchObject = 2 - }); - - InputPorts.Add(new RoutingInputPort(DmPortName.AirBoardIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.None, new Action(SelectAirboardIn), this) - { - FeedbackMatchObject = 4 - }); - - if (AirMedia is Am300) - { - InputPorts.Add(new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.DmCat, new Action(SelectDmIn), this) - { - FeedbackMatchObject = 3 - }); - } - - OutputPorts.Add(new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, null, this)); - - AirMedia.AirMedia.AirMediaChange += new Crestron.SimplSharpPro.DeviceSupport.GenericEventHandler(AirMedia_AirMediaChange); - - IsInSessionFeedback = new BoolFeedback(() => AirMedia.AirMedia.StatusFeedback.UShortValue == 0); - ErrorFeedback = new IntFeedback(() => AirMedia.AirMedia.ErrorFeedback.UShortValue); - NumberOfUsersConnectedFeedback = new IntFeedback(() => AirMedia.AirMedia.NumberOfUsersConnectedFeedback.UShortValue); - LoginCodeFeedback = new IntFeedback(() => AirMedia.AirMedia.LoginCodeFeedback.UShortValue); - ConnectionAddressFeedback = new StringFeedback(() => AirMedia.AirMedia.ConnectionAddressFeedback.StringValue); - HostnameFeedback = new StringFeedback(() => AirMedia.AirMedia.HostNameFeedback.StringValue); - HdmiInHdcpSupportOnFeedback = new BoolFeedback(() => AirMedia.HdmiIn.HdcpSupportOnFeedback.BoolValue); - HdmiInDisabledByHdcpFeedback = new BoolFeedback(() => AirMedia.HdmiIn.DisabledByHdcpFeedback.BoolValue); - - // TODO: Figure out if we can actually get the TSID/Serial - SerialNumberFeedback = new StringFeedback(() => "unknown"); - - AirMedia.DisplayControl.DisplayControlChange += DisplayControl_DisplayControlChange; - - VideoOutFeedback = new IntFeedback(() => Convert.ToInt16(AirMedia.DisplayControl.VideoOutFeedback)); - AutomaticInputRoutingEnabledFeedback = new BoolFeedback(() => AirMedia.DisplayControl.EnableAutomaticRoutingFeedback.BoolValue); - - // Not all AirMedia versions support HDMI In like the 3200 - if (AirMedia.HdmiIn != null) - { - AirMedia.HdmiIn.StreamChange += HdmiIn_StreamChange; - HdmiVideoSyncDetectedFeedback = new BoolFeedback(() => AirMedia.HdmiIn.SyncDetectedFeedback.BoolValue); - return; - } - - // Return false if the AirMedia device doesn't support HDMI Input - HdmiVideoSyncDetectedFeedback = new BoolFeedback(() => false); - } - - public override bool CustomActivate() - { - if (PropertiesConfig.AutoSwitchingEnabled) - AirMedia.DisplayControl.EnableAutomaticRouting(); - else - AirMedia.DisplayControl.DisableAutomaticRouting(); - - return base.CustomActivate(); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new AirMediaControllerJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - Debug.Console(0, "Linking to Airmedia: {0}", Name); - - trilist.StringInput[joinMap.Name.JoinNumber].StringValue = Name; - - var commMonitor = this as ICommunicationMonitor; - - commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - - IsInSessionFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsInSession.JoinNumber]); - HdmiVideoSyncDetectedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.HdmiVideoSync.JoinNumber]); - - trilist.SetSigTrueAction(joinMap.AutomaticInputRoutingEnabled.JoinNumber, AirMedia.DisplayControl.EnableAutomaticRouting); - trilist.SetSigFalseAction(joinMap.AutomaticInputRoutingEnabled.JoinNumber, AirMedia.DisplayControl.DisableAutomaticRouting); - AutomaticInputRoutingEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.AutomaticInputRoutingEnabled.JoinNumber]); - - trilist.SetUShortSigAction(joinMap.VideoOut.JoinNumber, (u) => SelectVideoOut(u)); - - VideoOutFeedback.LinkInputSig(trilist.UShortInput[joinMap.VideoOut.JoinNumber]); - ErrorFeedback.LinkInputSig(trilist.UShortInput[joinMap.ErrorFB.JoinNumber]); - NumberOfUsersConnectedFeedback.LinkInputSig(trilist.UShortInput[joinMap.NumberOfUsersConnectedFB.JoinNumber]); - - trilist.SetUShortSigAction(joinMap.LoginCode.JoinNumber, (u) => AirMedia.AirMedia.LoginCode.UShortValue = u); - LoginCodeFeedback.LinkInputSig(trilist.UShortInput[joinMap.LoginCode.JoinNumber]); - - ConnectionAddressFeedback.LinkInputSig(trilist.StringInput[joinMap.ConnectionAddressFB.JoinNumber]); - HostnameFeedback.LinkInputSig(trilist.StringInput[joinMap.HostnameFB.JoinNumber]); - SerialNumberFeedback.LinkInputSig(trilist.StringInput[joinMap.SerialNumberFeedback.JoinNumber]); - - trilist.SetSigFalseAction(joinMap.HdmiInHdcpSupportOn.JoinNumber, () => SetHcdpSupport(true)); - HdmiInHdcpSupportOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.HdmiInHdcpSupportOn.JoinNumber]); - trilist.SetSigFalseAction(joinMap.HdmiInHdcpSupportOff.JoinNumber, () => SetHcdpSupport(false)); - HdmiInHdcpSupportOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.HdmiInHdcpSupportOff.JoinNumber]); - - HdmiInDisabledByHdcpFeedback.LinkInputSig(trilist.BooleanInput[joinMap.HdmiInDisabledByHdcp.JoinNumber]); - } - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var handler = NumericSwitchChange; - - if (handler == null) return; - - handler(this, e); - } - - - void AirMedia_AirMediaChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) - { - switch (args.EventId) - { - case AirMediaInputSlot.AirMediaStatusFeedbackEventId: - { - IsInSessionFeedback.FireUpdate(); - break; - } - case AirMediaInputSlot.AirMediaErrorFeedbackEventId: - { - ErrorFeedback.FireUpdate(); - break; - } - case AirMediaInputSlot.AirMediaNumberOfUserConnectedEventId: - { - NumberOfUsersConnectedFeedback.FireUpdate(); - break; - } - case AirMediaInputSlot.AirMediaLoginCodeEventId: - { - LoginCodeFeedback.FireUpdate(); - break; - } - case AirMediaInputSlot.AirMediaConnectionAddressFeedbackEventId: - { - ConnectionAddressFeedback.FireUpdate(); - break; - } - case AirMediaInputSlot.AirMediaHostNameFeedbackEventId: - { - HostnameFeedback.FireUpdate(); - break; - } - } - } - - void DisplayControl_DisplayControlChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) - { - VideoOutFeedback.FireUpdate(); - - var localInputPort = - InputPorts.FirstOrDefault(p => (int) p.FeedbackMatchObject == VideoOutFeedback.UShortValue); - - OnSwitchChange(new RoutingNumericEventArgs(1, VideoOutFeedback.UShortValue, OutputPorts.First(), - localInputPort, eRoutingSignalType.AudioVideo)); - - AutomaticInputRoutingEnabledFeedback.FireUpdate(); - } - - void HdmiIn_StreamChange(Stream stream, Crestron.SimplSharpPro.DeviceSupport.StreamEventArgs args) - { - if (args.EventId == DMInputEventIds.SourceSyncEventId) - HdmiVideoSyncDetectedFeedback.FireUpdate(); - else if (args.EventId == DMInputEventIds.HdcpSupportOnEventId) - { - HdmiInHdcpSupportOnFeedback.FireUpdate(); - } - else if (args.EventId == DMInputEventIds.DisabledByHdcpEventId) - { - HdmiInDisabledByHdcpFeedback.FireUpdate(); - } - } - - /// - /// Sets the VideoOut source ( 0 = PinpointUX, 1 = AirMedia, 2 = HDMI, 3 = DM, 4 = Airboard ) - /// - /// source number - public void SelectVideoOut(uint source) - { - AirMedia.DisplayControl.VideoOut = (AmX00DisplayControl.eAirMediaX00VideoSource)source; - } - - /// - /// Selects the PinPointUXLandingPage input - /// - public void SelectPinPointUxLandingPage() - { - AirMedia.DisplayControl.VideoOut = AmX00DisplayControl.eAirMediaX00VideoSource.PinPointUxLandingPage; - } - - /// - /// Selects the AirMedia input - /// - public void SelectAirMedia() - { - AirMedia.DisplayControl.VideoOut = AmX00DisplayControl.eAirMediaX00VideoSource.AirMedia; - } - - /// - /// Selects the DM input - /// - public void SelectDmIn() - { - AirMedia.DisplayControl.VideoOut = AmX00DisplayControl.eAirMediaX00VideoSource.DM; - } - - /// - /// Selects the HDMI INput - /// - public void SelectHdmiIn() - { - AirMedia.DisplayControl.VideoOut = AmX00DisplayControl.eAirMediaX00VideoSource.HDMI; - } - - public void SelectAirboardIn() - { - AirMedia.DisplayControl.VideoOut = AmX00DisplayControl.eAirMediaX00VideoSource.AirBoard; - } - - public void SetHcdpSupport(bool on) - { - if (on) - AirMedia.HdmiIn.HdcpSupportOn(); - else - AirMedia.HdmiIn.HdcpSupportOff(); - } - - /// - /// Reboots the device - /// - public void RebootDevice() - { - AirMedia.AirMedia.DeviceReboot(); - } - - #region IIROutputPorts Members - - public CrestronCollection IROutputPorts - { - get { return AirMedia.IROutputPorts; } - } - - public int NumberOfIROutputPorts - { - get { return AirMedia.NumberOfIROutputPorts; } - } - - - - #endregion - - - - #region IComPorts Members - - public CrestronCollection ComPorts - { - get { return AirMedia.ComPorts; } - } - - public int NumberOfComPorts - { - get { return AirMedia.NumberOfComPorts; } - } - - #endregion - - - - #region IRoutingNumeric Members - - public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType signalType) - { - if ((signalType & eRoutingSignalType.Video) != eRoutingSignalType.Video) return; - if (!Enum.IsDefined(typeof (AmX00DisplayControl.eAirMediaX00VideoSource), input)) - { - Debug.Console(2, this, "Invalid Video Source Index : {0}", input); - return; - } - AirMedia.DisplayControl.VideoOut = (AmX00DisplayControl.eAirMediaX00VideoSource) input; - } - - #endregion - - #region IRouting Members - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - Debug.Console(2, this, "Input Selector = {0}", inputSelector.ToString()); - var handler = inputSelector as Action; - if (handler == null) return; - handler(); - } - - #endregion - } - - public class AirMediaControllerFactory : EssentialsDeviceFactory - { - public AirMediaControllerFactory() - { - TypeNames = new List() { "am200", "am300", "am3200" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - var type = dc.Type.ToLower(); - - Debug.Console(1, "Factory Attempting to create new AirMedia Device"); - - var props = dc.Properties.ToObject(); - Am3x00 amDevice = null; - switch (type) - { - case "am200" : - { - amDevice = new Am200(props.Control.IpIdInt, Global.ControlSystem); - break; - } - case "am300" : - { - amDevice = new Am300(props.Control.IpIdInt, Global.ControlSystem); - break; - } - case "am3200" : - { - amDevice = new Am3200(props.Control.IpIdInt, Global.ControlSystem); - break; - } - } - - return new AirMediaController(dc.Key, dc.Name, amDevice, dc, props); - - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.DeviceSupport.Support; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.AirMedia; +using Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.DM.AirMedia +{ + [Description("Wrapper class for an AM-200 or AM-300")] + public class AirMediaController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, IIROutputPorts, IComPorts + { + public Am3x00 AirMedia { get; private set; } + + public DeviceConfig DeviceConfig { get; private set; } + + AirMediaPropertiesConfig PropertiesConfig; + + public RoutingPortCollection InputPorts { get; private set; } + + public RoutingPortCollection OutputPorts { get; private set; } + + + //IroutingNumericEvent + public event EventHandler NumericSwitchChange; + + public BoolFeedback IsInSessionFeedback { get; private set; } + public IntFeedback ErrorFeedback { get; private set; } + public IntFeedback NumberOfUsersConnectedFeedback { get; set; } + public IntFeedback LoginCodeFeedback { get; set; } + public StringFeedback ConnectionAddressFeedback { get; set; } + public StringFeedback HostnameFeedback { get; set; } + public IntFeedback VideoOutFeedback { get; private set; } + public BoolFeedback HdmiVideoSyncDetectedFeedback { get; private set; } + public StringFeedback SerialNumberFeedback { get; private set; } + public BoolFeedback AutomaticInputRoutingEnabledFeedback { get; private set; } + public BoolFeedback HdmiInHdcpSupportOnFeedback { get; private set; } + public BoolFeedback HdmiInDisabledByHdcpFeedback { get; private set; } + + public AirMediaController(string key, string name, Am3x00 device, DeviceConfig dc, AirMediaPropertiesConfig props) + : base(key, name, device) + { + AirMedia = device; + + DeviceConfig = dc; + + PropertiesConfig = props; + + InputPorts = new RoutingPortCollection(); + OutputPorts = new RoutingPortCollection(); + + InputPorts.Add(new RoutingInputPort(DmPortName.Osd, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.None, new Action(SelectPinPointUxLandingPage), this) + { + FeedbackMatchObject = 0 + }); + + InputPorts.Add(new RoutingInputPort(DmPortName.AirMediaIn, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.Streaming, new Action(SelectAirMedia), this) + { + FeedbackMatchObject = 1 + }); + + InputPorts.Add(new RoutingInputPort(DmPortName.HdmiIn, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.Hdmi, new Action(SelectHdmiIn), this) + { + FeedbackMatchObject = 2 + }); + + InputPorts.Add(new RoutingInputPort(DmPortName.AirBoardIn, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.None, new Action(SelectAirboardIn), this) + { + FeedbackMatchObject = 4 + }); + + if (AirMedia is Am300) + { + InputPorts.Add(new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.DmCat, new Action(SelectDmIn), this) + { + FeedbackMatchObject = 3 + }); + } + + OutputPorts.Add(new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.Hdmi, null, this)); + + AirMedia.AirMedia.AirMediaChange += new Crestron.SimplSharpPro.DeviceSupport.GenericEventHandler(AirMedia_AirMediaChange); + + IsInSessionFeedback = new BoolFeedback(() => AirMedia.AirMedia.StatusFeedback.UShortValue == 0); + ErrorFeedback = new IntFeedback(() => AirMedia.AirMedia.ErrorFeedback.UShortValue); + NumberOfUsersConnectedFeedback = new IntFeedback(() => AirMedia.AirMedia.NumberOfUsersConnectedFeedback.UShortValue); + LoginCodeFeedback = new IntFeedback(() => AirMedia.AirMedia.LoginCodeFeedback.UShortValue); + ConnectionAddressFeedback = new StringFeedback(() => AirMedia.AirMedia.ConnectionAddressFeedback.StringValue); + HostnameFeedback = new StringFeedback(() => AirMedia.AirMedia.HostNameFeedback.StringValue); + HdmiInHdcpSupportOnFeedback = new BoolFeedback(() => AirMedia.HdmiIn.HdcpSupportOnFeedback.BoolValue); + HdmiInDisabledByHdcpFeedback = new BoolFeedback(() => AirMedia.HdmiIn.DisabledByHdcpFeedback.BoolValue); + + // TODO: Figure out if we can actually get the TSID/Serial + SerialNumberFeedback = new StringFeedback(() => "unknown"); + + AirMedia.DisplayControl.DisplayControlChange += DisplayControl_DisplayControlChange; + + VideoOutFeedback = new IntFeedback(() => Convert.ToInt16(AirMedia.DisplayControl.VideoOutFeedback)); + AutomaticInputRoutingEnabledFeedback = new BoolFeedback(() => AirMedia.DisplayControl.EnableAutomaticRoutingFeedback.BoolValue); + + // Not all AirMedia versions support HDMI In like the 3200 + if (AirMedia.HdmiIn != null) + { + AirMedia.HdmiIn.StreamChange += HdmiIn_StreamChange; + HdmiVideoSyncDetectedFeedback = new BoolFeedback(() => AirMedia.HdmiIn.SyncDetectedFeedback.BoolValue); + return; + } + + // Return false if the AirMedia device doesn't support HDMI Input + HdmiVideoSyncDetectedFeedback = new BoolFeedback(() => false); + } + + public override bool CustomActivate() + { + if (PropertiesConfig.AutoSwitchingEnabled) + AirMedia.DisplayControl.EnableAutomaticRouting(); + else + AirMedia.DisplayControl.DisableAutomaticRouting(); + + return base.CustomActivate(); + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new AirMediaControllerJoinMap(joinStart); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + else + { + Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + } + + Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.Console(0, "Linking to Airmedia: {0}", Name); + + trilist.StringInput[joinMap.Name.JoinNumber].StringValue = Name; + + var commMonitor = this as ICommunicationMonitor; + + commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + + IsInSessionFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsInSession.JoinNumber]); + HdmiVideoSyncDetectedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.HdmiVideoSync.JoinNumber]); + + trilist.SetSigTrueAction(joinMap.AutomaticInputRoutingEnabled.JoinNumber, AirMedia.DisplayControl.EnableAutomaticRouting); + trilist.SetSigFalseAction(joinMap.AutomaticInputRoutingEnabled.JoinNumber, AirMedia.DisplayControl.DisableAutomaticRouting); + AutomaticInputRoutingEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.AutomaticInputRoutingEnabled.JoinNumber]); + + trilist.SetUShortSigAction(joinMap.VideoOut.JoinNumber, (u) => SelectVideoOut(u)); + + VideoOutFeedback.LinkInputSig(trilist.UShortInput[joinMap.VideoOut.JoinNumber]); + ErrorFeedback.LinkInputSig(trilist.UShortInput[joinMap.ErrorFB.JoinNumber]); + NumberOfUsersConnectedFeedback.LinkInputSig(trilist.UShortInput[joinMap.NumberOfUsersConnectedFB.JoinNumber]); + + trilist.SetUShortSigAction(joinMap.LoginCode.JoinNumber, (u) => AirMedia.AirMedia.LoginCode.UShortValue = u); + LoginCodeFeedback.LinkInputSig(trilist.UShortInput[joinMap.LoginCode.JoinNumber]); + + ConnectionAddressFeedback.LinkInputSig(trilist.StringInput[joinMap.ConnectionAddressFB.JoinNumber]); + HostnameFeedback.LinkInputSig(trilist.StringInput[joinMap.HostnameFB.JoinNumber]); + SerialNumberFeedback.LinkInputSig(trilist.StringInput[joinMap.SerialNumberFeedback.JoinNumber]); + + trilist.SetSigFalseAction(joinMap.HdmiInHdcpSupportOn.JoinNumber, () => SetHcdpSupport(true)); + HdmiInHdcpSupportOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.HdmiInHdcpSupportOn.JoinNumber]); + trilist.SetSigFalseAction(joinMap.HdmiInHdcpSupportOff.JoinNumber, () => SetHcdpSupport(false)); + HdmiInHdcpSupportOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.HdmiInHdcpSupportOff.JoinNumber]); + + HdmiInDisabledByHdcpFeedback.LinkInputSig(trilist.BooleanInput[joinMap.HdmiInDisabledByHdcp.JoinNumber]); + } + + /// + /// Raise an event when the status of a switch object changes. + /// + /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType + private void OnSwitchChange(RoutingNumericEventArgs e) + { + var handler = NumericSwitchChange; + + if (handler == null) return; + + handler(this, e); + } + + + void AirMedia_AirMediaChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) + { + switch (args.EventId) + { + case AirMediaInputSlot.AirMediaStatusFeedbackEventId: + { + IsInSessionFeedback.FireUpdate(); + break; + } + case AirMediaInputSlot.AirMediaErrorFeedbackEventId: + { + ErrorFeedback.FireUpdate(); + break; + } + case AirMediaInputSlot.AirMediaNumberOfUserConnectedEventId: + { + NumberOfUsersConnectedFeedback.FireUpdate(); + break; + } + case AirMediaInputSlot.AirMediaLoginCodeEventId: + { + LoginCodeFeedback.FireUpdate(); + break; + } + case AirMediaInputSlot.AirMediaConnectionAddressFeedbackEventId: + { + ConnectionAddressFeedback.FireUpdate(); + break; + } + case AirMediaInputSlot.AirMediaHostNameFeedbackEventId: + { + HostnameFeedback.FireUpdate(); + break; + } + } + } + + void DisplayControl_DisplayControlChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) + { + VideoOutFeedback.FireUpdate(); + + var localInputPort = + InputPorts.FirstOrDefault(p => (int) p.FeedbackMatchObject == VideoOutFeedback.UShortValue); + + OnSwitchChange(new RoutingNumericEventArgs(1, VideoOutFeedback.UShortValue, OutputPorts.First(), + localInputPort, eRoutingSignalType.AudioVideo)); + + AutomaticInputRoutingEnabledFeedback.FireUpdate(); + } + + void HdmiIn_StreamChange(Stream stream, Crestron.SimplSharpPro.DeviceSupport.StreamEventArgs args) + { + if (args.EventId == DMInputEventIds.SourceSyncEventId) + HdmiVideoSyncDetectedFeedback.FireUpdate(); + else if (args.EventId == DMInputEventIds.HdcpSupportOnEventId) + { + HdmiInHdcpSupportOnFeedback.FireUpdate(); + } + else if (args.EventId == DMInputEventIds.DisabledByHdcpEventId) + { + HdmiInDisabledByHdcpFeedback.FireUpdate(); + } + } + + /// + /// Sets the VideoOut source ( 0 = PinpointUX, 1 = AirMedia, 2 = HDMI, 3 = DM, 4 = Airboard ) + /// + /// source number + public void SelectVideoOut(uint source) + { + AirMedia.DisplayControl.VideoOut = (AmX00DisplayControl.eAirMediaX00VideoSource)source; + } + + /// + /// Selects the PinPointUXLandingPage input + /// + public void SelectPinPointUxLandingPage() + { + AirMedia.DisplayControl.VideoOut = AmX00DisplayControl.eAirMediaX00VideoSource.PinPointUxLandingPage; + } + + /// + /// Selects the AirMedia input + /// + public void SelectAirMedia() + { + AirMedia.DisplayControl.VideoOut = AmX00DisplayControl.eAirMediaX00VideoSource.AirMedia; + } + + /// + /// Selects the DM input + /// + public void SelectDmIn() + { + AirMedia.DisplayControl.VideoOut = AmX00DisplayControl.eAirMediaX00VideoSource.DM; + } + + /// + /// Selects the HDMI INput + /// + public void SelectHdmiIn() + { + AirMedia.DisplayControl.VideoOut = AmX00DisplayControl.eAirMediaX00VideoSource.HDMI; + } + + public void SelectAirboardIn() + { + AirMedia.DisplayControl.VideoOut = AmX00DisplayControl.eAirMediaX00VideoSource.AirBoard; + } + + public void SetHcdpSupport(bool on) + { + if (on) + AirMedia.HdmiIn.HdcpSupportOn(); + else + AirMedia.HdmiIn.HdcpSupportOff(); + } + + /// + /// Reboots the device + /// + public void RebootDevice() + { + AirMedia.AirMedia.DeviceReboot(); + } + + #region IIROutputPorts Members + + public CrestronCollection IROutputPorts + { + get { return AirMedia.IROutputPorts; } + } + + public int NumberOfIROutputPorts + { + get { return AirMedia.NumberOfIROutputPorts; } + } + + + + #endregion + + + + #region IComPorts Members + + public CrestronCollection ComPorts + { + get { return AirMedia.ComPorts; } + } + + public int NumberOfComPorts + { + get { return AirMedia.NumberOfComPorts; } + } + + #endregion + + + + #region IRoutingNumeric Members + + public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType signalType) + { + if ((signalType & eRoutingSignalType.Video) != eRoutingSignalType.Video) return; + if (!Enum.IsDefined(typeof (AmX00DisplayControl.eAirMediaX00VideoSource), input)) + { + Debug.Console(2, this, "Invalid Video Source Index : {0}", input); + return; + } + AirMedia.DisplayControl.VideoOut = (AmX00DisplayControl.eAirMediaX00VideoSource) input; + } + + #endregion + + #region IRouting Members + + public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) + { + Debug.Console(2, this, "Input Selector = {0}", inputSelector.ToString()); + var handler = inputSelector as Action; + if (handler == null) return; + handler(); + } + + #endregion + } + + public class AirMediaControllerFactory : EssentialsDeviceFactory + { + public AirMediaControllerFactory() + { + TypeNames = new List() { "am200", "am300", "am3200" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + var type = dc.Type.ToLower(); + + Debug.Console(1, "Factory Attempting to create new AirMedia Device"); + + var props = dc.Properties.ToObject(); + Am3x00 amDevice = null; + switch (type) + { + case "am200" : + { + amDevice = new Am200(props.Control.IpIdInt, Global.ControlSystem); + break; + } + case "am300" : + { + amDevice = new Am300(props.Control.IpIdInt, Global.ControlSystem); + break; + } + case "am3200" : + { + amDevice = new Am3200(props.Control.IpIdInt, Global.ControlSystem); + break; + } + } + + return new AirMediaController(dc.Key, dc.Name, amDevice, dc, props); + + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaPropertiesConfig.cs b/src/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaPropertiesConfig.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaPropertiesConfig.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaPropertiesConfig.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/._DmChassisController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Chassis/._DmChassisController.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Chassis/._DmChassisController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Chassis/._DmChassisController.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/Config/Schema/DmChassisControllerPropertiesConfigSchema.json b/src/essentials-framework/Essentials DM/Essentials_DM/Chassis/Config/Schema/DmChassisControllerPropertiesConfigSchema.json similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Chassis/Config/Schema/DmChassisControllerPropertiesConfigSchema.json rename to src/essentials-framework/Essentials DM/Essentials_DM/Chassis/Config/Schema/DmChassisControllerPropertiesConfigSchema.json diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs similarity index 97% rename from essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs index 3898201d..7db39d6e 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs @@ -1,999 +1,999 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Cards; -using Crestron.SimplSharpPro.DM.Blades; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Receivers; -using Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.DM.Config; - -namespace PepperDash.Essentials.DM -{ - /// - /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions - /// - /// - public class DmBladeChassisController : CrestronGenericBridgeableBaseDevice, IDmSwitchWithEndpointOnlineFeedback, IRoutingNumericWithFeedback - { - private const string NonePortKey = "inputCard0--None"; - - public DMChassisPropertiesConfig PropertiesConfig { get; set; } - - public Switch Chassis { get; private set; } - - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - // Feedbacks for EssentialDM - public Dictionary VideoOutputFeedbacks { get; private set; } - public Dictionary AudioOutputFeedbacks { get; private set; } - public Dictionary VideoInputSyncFeedbacks { get; private set; } - public Dictionary InputEndpointOnlineFeedbacks { get; private set; } - public Dictionary OutputEndpointOnlineFeedbacks { get; private set; } - public Dictionary InputNameFeedbacks { get; private set; } - public Dictionary OutputNameFeedbacks { get; private set; } - public Dictionary OutputVideoRouteNameFeedbacks { get; private set; } - public Dictionary OutputAudioRouteNameFeedbacks { get; private set; } - public Dictionary UsbOutputRoutedToFeebacks { get; private set; } - public Dictionary UsbInputRoutedToFeebacks { get; private set; } - - public IntFeedback SystemIdFeebdack { get; private set; } - public BoolFeedback SystemIdBusyFeedback { get; private set; } - - - public Dictionary InputCardHdcpCapabilityFeedbacks { get; private set; } - - public Dictionary InputCardHdcpCapabilityTypes { get; private set; } - - - // Need a couple Lists of generic Backplane ports - public RoutingPortCollection InputPorts { get; private set; } - public RoutingPortCollection OutputPorts { get; private set; } - - public Dictionary TxDictionary { get; set; } - public Dictionary RxDictionary { get; set; } - - //public Dictionary InputCards { get; private set; } - //public Dictionary OutputCards { get; private set; } - - public Dictionary InputNames { get; set; } - public Dictionary OutputNames { get; set; } - public Dictionary VolumeControls { get; private set; } - - public const int RouteOffTime = 500; - Dictionary RouteOffTimers = new Dictionary(); - - /// - /// Factory method to create a new chassis controller from config data. Limited to 8x8 right now - /// - public static DmBladeChassisController GetDmChassisController(string key, string name, - string type, DMChassisPropertiesConfig properties) - { - try - { - type = type.ToLower(); - uint ipid = properties.Control.IpIdInt; - - BladeSwitch chassis = null; - if (type == "dmmd64x64") { chassis = new DmMd64x64(ipid, Global.ControlSystem); } - else if (type == "dmmd128x128") { chassis = new DmMd128x128(ipid, Global.ControlSystem); } - - - if (chassis == null) - { - return null; - } - - var controller = new DmBladeChassisController(key, name, chassis); - // add the cards and port names - foreach (var kvp in properties.InputSlots) - controller.AddInputBlade(kvp.Value, kvp.Key); - foreach (var kvp in properties.OutputSlots) - { - controller.AddOutputBlade(kvp.Value, kvp.Key); - } - - foreach (var kvp in properties.VolumeControls) - { - // get the card - // check it for an audio-compatible type - // make a something-something that will make it work - // retire to mountain village - var outNum = kvp.Key; - - var card = controller.Chassis.Outputs[outNum].Card; - Audio.Output audio = null; - if (card is DmHdmi4kOutputBladeCard) - audio = (card as DmHdmi4kOutputBladeCard).Hdmi4kOutput.Audio; - if (audio == null) - continue; - // wire up the audio to something here... - controller.AddVolumeControl(outNum, audio); - } - - controller.InputPorts.Add(new RoutingInputPort(NonePortKey, eRoutingSignalType.Video, - eRoutingPortConnectionType.None, null, controller)); - - - controller.InputNames = properties.InputNames; - controller.OutputNames = properties.OutputNames; - controller.PropertiesConfig = properties; - return controller; - } - catch (System.Exception e) - { - Debug.Console(0, "Error creating DM chassis:\r{0}", e); - } - return null; - } - - - /// - /// - /// - /// - /// - /// - public DmBladeChassisController(string key, string name, BladeSwitch chassis) - : base(key, name, chassis) - { - Chassis = chassis; - InputPorts = new RoutingPortCollection(); - OutputPorts = new RoutingPortCollection(); - VolumeControls = new Dictionary(); - TxDictionary = new Dictionary(); - RxDictionary = new Dictionary(); - IsOnline.OutputChange += new EventHandler(IsOnline_OutputChange); - Chassis.DMInputChange += new DMInputEventHandler(Chassis_DMInputChange); - Chassis.DMOutputChange += new DMOutputEventHandler(Chassis_DMOutputChange); - VideoOutputFeedbacks = new Dictionary(); - UsbOutputRoutedToFeebacks = new Dictionary(); - UsbInputRoutedToFeebacks = new Dictionary(); - VideoInputSyncFeedbacks = new Dictionary(); - InputNameFeedbacks = new Dictionary(); - OutputNameFeedbacks = new Dictionary(); - OutputVideoRouteNameFeedbacks = new Dictionary(); - OutputAudioRouteNameFeedbacks = new Dictionary(); - InputEndpointOnlineFeedbacks = new Dictionary(); - OutputEndpointOnlineFeedbacks = new Dictionary(); - - InputCardHdcpCapabilityFeedbacks = new Dictionary(); - InputCardHdcpCapabilityTypes = new Dictionary(); - - for (uint x = 1; x <= Chassis.NumberOfOutputs; x++) - { - var tempX = x; - - if (Chassis.Outputs[tempX] != null) - { - VideoOutputFeedbacks[tempX] = new IntFeedback(() => - { - if (Chassis.Outputs[tempX].VideoOutFeedback != null) { return (ushort)Chassis.Outputs[tempX].VideoOutFeedback.Number; } - else { return 0; }; - }); - - OutputNameFeedbacks[tempX] = new StringFeedback(() => - { - if (Chassis.Outputs[tempX].NameFeedback != null) - { - return Chassis.Outputs[tempX].NameFeedback.StringValue; - } - else - { - return ""; - } - }); - OutputVideoRouteNameFeedbacks[tempX] = new StringFeedback(() => - { - if (Chassis.Outputs[tempX].VideoOutFeedback != null) - { - return Chassis.Outputs[tempX].VideoOutFeedback.NameFeedback.StringValue; - } - else - { - return ""; - } - }); - - OutputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => - { - //if (Chassis.Outputs[tempX].Endpoint != null) - // return Chassis.Outputs[tempX].Endpoint.IsOnline; - //else - return Chassis.Outputs[tempX].EndpointOnlineFeedback; - }); - } - - if (Chassis.Inputs[tempX] != null) - { - UsbInputRoutedToFeebacks[tempX] = new IntFeedback(() => - { - if (Chassis.Inputs[tempX].USBRoutedToFeedback != null) { return (ushort)Chassis.Inputs[tempX].USBRoutedToFeedback.Number; } - else { return 0; }; - }); - VideoInputSyncFeedbacks[tempX] = new BoolFeedback(() => - { - if (Chassis.Inputs[tempX].VideoDetectedFeedback != null) - return Chassis.Inputs[tempX].VideoDetectedFeedback.BoolValue; - else - return false; - }); - InputNameFeedbacks[tempX] = new StringFeedback(() => - { - if (Chassis.Inputs[tempX].NameFeedback != null) - { - return Chassis.Inputs[tempX].NameFeedback.StringValue; - } - else - { - return ""; - } - }); - - InputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => - { - return Chassis.Inputs[tempX].EndpointOnlineFeedback; - }); - - InputCardHdcpCapabilityFeedbacks[tempX] = new IntFeedback(() => - { - var inputCard = Chassis.Inputs[tempX]; - - if (inputCard.Card is DmHdmi4kInputBladeCard) - { - InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.Hdcp2_2Support; - - if ((inputCard.Card as DmHdmi4kInputBladeCard).Hdmi4kInput.HdcpSupportOnFeedback.BoolValue) - return 1; - else - return 0; - } - - if (inputCard.Card is DmC4kInputBladeCard) - { - InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.Hdcp2_2Support; - - if ((inputCard.Card as DmC4kInputBladeCard).DmInput.HdcpCapabilityFeedback.Equals(eHdcpCapabilityType.HdcpSupportOff)) - return 0; - else - return 1; - } - - else - return 0; - }); - } - } - } - - /// - /// - /// - /// - /// - public void AddInputBlade(string type, uint number) - { - Debug.Console(2, this, "Adding input blade '{0}', slot {1}", type, number); - - type = type.ToLower(); - - if (type == "dmb4kihd") - { - var inputBlade = new Dmb4kIHd(number, this.Chassis); - foreach (var item in inputBlade.Inputs) - { - var card = (item.Card as DmHdmi4kInputBladeCard).Hdmi4kInput; - var cecPort = card as ICec; - AddHdmiInBladePorts(item.Number, cecPort); - } - } - - else if (type == "dmb4kihddnt") - { - var inputBlade = new Dmb4kIHd(number, this.Chassis); - foreach (var item in inputBlade.Inputs) - { - var card = (item.Card as DmHdmi4kInputBladeCard).Hdmi4kInput; - var cecPort = card as ICec; - AddHdmiInBladePorts(item.Number, cecPort); - } - } - - else if (type == "dmb4kic") - { - var inputBlade = new Dmb4kIC(number, this.Chassis); - foreach (var item in inputBlade.Inputs) - { - AddDmInBladePorts(item.Number); - } - } - - else if (type == "dmbis") - { - var inputBlade = new DmbIS(number, this.Chassis); - foreach (var item in inputBlade.Inputs) - { - AddDmInMmFiberPorts(item.Number); - } - } - else if (type == "dmbis2") - { - var inputBlade = new DmbIS2(number, this.Chassis); - foreach (var item in inputBlade.Inputs) - { - AddDmInSmFiberPorts(item.Number); - } - } - } - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - - - void AddHdmiInBladePorts(uint number, ICec cecPort) - { - AddInputPortWithDebug(number, "hdmiIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, cecPort); - } - - void AddDmInBladePorts(uint number) - { - AddInputPortWithDebug(number, "dmCIn", eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat); - } - - void AddDmInMmFiberPorts(uint number) - { - AddInputPortWithDebug(number, "dmMmIn", eRoutingSignalType.Video, eRoutingPortConnectionType.DmMmFiber); - } - - void AddDmInSmFiberPorts(uint number) - { - AddInputPortWithDebug(number, "dmSmIn", eRoutingSignalType.Video, eRoutingPortConnectionType.DmSmFiber); - } - - /// - /// - /// - /// - /// - public void AddOutputBlade(string type, uint number) - { - type = type.ToLower(); - - Debug.Console(2, this, "Adding output blade '{0}', slot {1}", type, number); - if (type == "dmb4kohd") - { - var outputBlade = new Dmb4KOHD(number, Chassis); - foreach (var item in outputBlade.Outputs) - { - AddHdmiOutBladePorts(item.Number); - } - } - - else if (type == "dmb4kohddnt") - { - var outputBlade = new Dmb4KOHD(number, Chassis); - foreach (var item in outputBlade.Outputs) - { - AddHdmiOutBladePorts(item.Number); - } - } - - else if (type == "dmb4koc") - { - var outputBlade = new Dmb4KOC(number, Chassis); - foreach (var item in outputBlade.Outputs) - { - AddDmOutBladePorts(item.Number); - } - } - else if (type == "dmb4koc") - { - var outputBlade = new Dmb4KOC(number, Chassis); - foreach (var item in outputBlade.Outputs) - { - AddDmOutBladePorts(item.Number); - } - } - else if (type == "dmbos") - { - var outputBlade = new DmbOS(number, Chassis); - foreach (var item in outputBlade.Outputs) - { - AddDmOutMmFiberBladePorts(item.Number); - } - } - else if (type == "dmbos2") - { - var outputBlade = new DmbOS2(number, Chassis); - foreach (var item in outputBlade.Outputs) - { - AddDmOutSmFiberBladePorts(item.Number); - } - } - } - - void AddHdmiOutBladePorts(uint number) - { - AddOutputPortWithDebug(number, "hdmiOut", eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, Chassis.Outputs[number]); - } - - void AddDmOutBladePorts(uint number) - { - AddOutputPortWithDebug(number, "dmOut", eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, Chassis.Outputs[number]); - } - - void AddDmOutMmFiberBladePorts(uint number) - { - AddOutputPortWithDebug(number, "dmMmOut", eRoutingSignalType.Video, eRoutingPortConnectionType.DmMmFiber, Chassis.Outputs[number]); - } - - void AddDmOutSmFiberBladePorts(uint number) - { - AddOutputPortWithDebug(number, "dmSmOut", eRoutingSignalType.Video, eRoutingPortConnectionType.DmSmFiber, Chassis.Outputs[number]); - } - - - /// - /// Adds InputPort - /// - void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType) - { - AddInputPortWithDebug(cardNum, portName, sigType, portType, null); - } - - /// - /// Adds InputPort and sets Port as ICec object - /// - private void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, - eRoutingPortConnectionType portType, ICec cecPort) - { - var portKey = string.Format("inputCard{0}--{1}", cardNum, portName); - Debug.Console(2, this, "Adding input port '{0}'", portKey); - var inputPort = new RoutingInputPort(portKey, sigType, portType, Chassis.Inputs[cardNum], this) - { - FeedbackMatchObject = Chassis.Inputs[cardNum] - }; - - if (cecPort != null) - inputPort.Port = cecPort; - - InputPorts.Add(inputPort); - } - - - - /*void AddOutputPortWithDebug(string cardName, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, object selector) { - var portKey = string.Format("{0}--{1}", cardName, portName); - Debug.Console(2, this, "Adding output port '{0}'", portKey); - OutputPorts.Add(new RoutingOutputPort(portKey, sigType, portType, selector, this) - { - FeedbackMatchObject = selector - }); - }*/ - - /// - /// Adds OutputPort - /// - void AddOutputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, object selector) - { - try - { - var portKey = string.Format("outputCard{0}--{1}", cardNum, portName); - Debug.Console(2, this, "Adding output port '{0}'", portKey); - var outputPort = new RoutingOutputPort(portKey, sigType, portType, selector, this) - { - FeedbackMatchObject = Chassis.Outputs[cardNum] - }; - OutputPorts.Add(outputPort); - } - catch (Exception ex) - { - Debug.Console(0, this, "Exception : {0}", ex); - } - - } - - - /// - /// - /// - void AddVolumeControl(uint number, Audio.Output audio) - { - VolumeControls.Add(number, new DmCardAudioOutputController(audio)); - } - - //public void SetInputHdcpSupport(uint input, ePdtHdcpSupport hdcpSetting) - //{ - - //} - - - void Chassis_DMInputChange(Switch device, DMInputEventArgs args) - { - - switch (args.EventId) - { - case DMInputEventIds.EndpointOnlineEventId: - { - Debug.Console(2, this, "DM Input EndpointOnlineEventId for input: {0}. State: {1}", args.Number, device.Inputs[args.Number].EndpointOnlineFeedback); - InputEndpointOnlineFeedbacks[args.Number].FireUpdate(); - break; - } - case DMInputEventIds.OnlineFeedbackEventId: - { - Debug.Console(2, this, "DM Input OnlineFeedbackEventId for input: {0}. State: {1}", args.Number, device.Inputs[args.Number].EndpointOnlineFeedback); - InputEndpointOnlineFeedbacks[args.Number].FireUpdate(); - break; - } - case DMInputEventIds.VideoDetectedEventId: - { - Debug.Console(2, this, "DM Input {0} VideoDetectedEventId", args.Number); - VideoInputSyncFeedbacks[args.Number].FireUpdate(); - break; - } - case DMInputEventIds.InputNameEventId: - { - Debug.Console(2, this, "DM Input {0} NameFeedbackEventId", args.Number); - InputNameFeedbacks[args.Number].FireUpdate(); - break; - } - case DMInputEventIds.HdcpCapabilityFeedbackEventId: - { - Debug.Console(2, this, "DM Input {0} HdcpCapabilityFeedbackEventId", args.Number); - InputCardHdcpCapabilityFeedbacks[args.Number].FireUpdate(); - break; - } - default: - { - Debug.Console(2, this, "DMInputChange fired for Input {0} with Unhandled EventId: {1}", args.Number, args.EventId); - break; - } - } - } - - /// - /// - private void Chassis_DMOutputChange(Switch device, DMOutputEventArgs args) - { - var output = args.Number; - - switch (args.EventId) - { - case DMOutputEventIds.VolumeEventId: - { - if (VolumeControls.ContainsKey(output)) - { - VolumeControls[args.Number].VolumeEventFromChassis(); - } - break; - } - case DMOutputEventIds.EndpointOnlineEventId: - { - Debug.Console(2, this, - "Output {0} DMOutputEventIds.EndpointOnlineEventId fired. EndpointOnlineFeedback State: {1}", - args.Number, Chassis.Outputs[output].EndpointOnlineFeedback); - if (Chassis.Outputs[output].Endpoint != null) - Debug.Console(2, this, - "Output {0} DMOutputEventIds.EndpointOnlineEventId fired. Endpoint.IsOnline State: {1}", - args.Number, Chassis.Outputs[output].Endpoint.IsOnline); - - OutputEndpointOnlineFeedbacks[output].FireUpdate(); - break; - } - case DMOutputEventIds.OnlineFeedbackEventId: - { - Debug.Console(2, this, "Output {0} DMInputEventIds.OnlineFeedbackEventId fired. State: {1}", - args.Number, Chassis.Outputs[output].EndpointOnlineFeedback); - OutputEndpointOnlineFeedbacks[output].FireUpdate(); - break; - } - case DMOutputEventIds.VideoOutEventId: - { - - var inputNumber = Chassis.Outputs[output].VideoOutFeedback == null ? 0 : Chassis.Outputs[output].VideoOutFeedback.Number; - - Debug.Console(2, this, "DMSwitchAudioVideo:{0} Routed Input:{1} Output:{2}'", this.Name, - inputNumber, output); - - if (VideoOutputFeedbacks.ContainsKey(output)) - { - var localInputPort = InputPorts.FirstOrDefault(p => (DMInput)p.FeedbackMatchObject == Chassis.Outputs[output].VideoOutFeedback); - var localOutputPort = - OutputPorts.FirstOrDefault(p => (DMOutput)p.FeedbackMatchObject == Chassis.Outputs[output]); - - - VideoOutputFeedbacks[output].FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(output, - inputNumber, - localOutputPort, - localInputPort, - eRoutingSignalType.AudioVideo)); - - } - if (OutputVideoRouteNameFeedbacks.ContainsKey(output)) - { - OutputVideoRouteNameFeedbacks[output].FireUpdate(); - } - break; - } - case DMOutputEventIds.OutputNameEventId: - { - Debug.Console(2, this, "DM Output {0} NameFeedbackEventId", output); - OutputNameFeedbacks[output].FireUpdate(); - break; - } - default: - { - Debug.Console(2, this, "DMOutputChange fired for Output {0} with Unhandled EventId: {1}", - args.Number, args.EventId); - break; - } - } - - } - - - /// - /// - /// - /// - void StartOffTimer(PortNumberType pnt) - { - if (RouteOffTimers.ContainsKey(pnt)) - return; - RouteOffTimers[pnt] = new CTimer(o => ExecuteSwitch(null, pnt.Selector, pnt.Type), RouteOffTime); - } - - - // Send out sigs when coming online - void IsOnline_OutputChange(object sender, EventArgs e) - { - if (IsOnline.BoolValue) - { - Chassis.EnableUSBBreakaway.BoolValue = true; - - if (InputNames != null) - foreach (var kvp in InputNames) - Chassis.Inputs[kvp.Key].Name.StringValue = kvp.Value; - if (OutputNames != null) - foreach (var kvp in OutputNames) - Chassis.Outputs[kvp.Key].Name.StringValue = kvp.Value; - } - } - - #region IRouting Members - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType sigType) - { - Debug.Console(2, this, "Making an awesome DM route from {0} to {1} {2}", inputSelector, outputSelector, sigType); - - var input = inputSelector as DMInput; // Cast can sometimes fail - var output = outputSelector as DMOutput; - - - if (output == null) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Warning, - "Unable to execute switch for inputSelector {0} to outputSelector {1}", inputSelector, - outputSelector); - return; - } - - // Check to see if there's an off timer waiting on this and if so, cancel - var key = new PortNumberType(output, sigType); - - if (input == null) - { - StartOffTimer(key); - } - else - { - if (RouteOffTimers.ContainsKey(key)) - { - Debug.Console(2, this, "{0} cancelling route off due to new source", output); - RouteOffTimers[key].Stop(); - RouteOffTimers.Remove(key); - } - } - - - - /*var inCard = input == 0 ? null : Chassis.Inputs[input]; - var outCard = input == 0 ? null : Chassis.Outputs[output];*/ - - // NOTE THAT BITWISE COMPARISONS - TO CATCH ALL ROUTING TYPES - if ((sigType & eRoutingSignalType.Video) != eRoutingSignalType.Video) return; - Chassis.VideoEnter.BoolValue = true; - output.VideoOut = input; - } - - #endregion - - #region IRoutingNumeric Members - - public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType sigType) - { - var input = inputSelector == 0 ? null : Chassis.Inputs[inputSelector]; - var output = Chassis.Outputs[outputSelector]; - - ExecuteSwitch(input, output, sigType); - } - - #endregion - - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new DmBladeChassisControllerJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - - // Link up outputs - for (uint i = 1; i <= Chassis.NumberOfOutputs; i++) - { - var ioSlot = i; - var ioSlotJoin = ioSlot - 1; - - // Control - trilist.SetUShortSigAction(joinMap.OutputVideo.JoinNumber + ioSlotJoin, o => ExecuteNumericSwitch(o, (ushort)ioSlot, eRoutingSignalType.Video)); - - if (TxDictionary.ContainsKey(ioSlot)) - { - Debug.Console(2, "Creating Tx Feedbacks {0}", ioSlot); - var txKey = TxDictionary[ioSlot]; - var basicTxDevice = DeviceManager.GetDeviceForKey(txKey) as BasicDmTxControllerBase; - - var advancedTxDevice = basicTxDevice as DmTxControllerBase; - - if (Chassis is DmMd128x128 || Chassis is DmMd64x64) - { - InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline.JoinNumber + ioSlotJoin]); - } - else - { - if (advancedTxDevice != null) - { - advancedTxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline.JoinNumber + ioSlotJoin]); - Debug.Console(2, "Linking Tx Online Feedback from Advanced Transmitter at input {0}", ioSlot); - } - else if (InputEndpointOnlineFeedbacks[ioSlot] != null) - { - Debug.Console(2, "Linking Tx Online Feedback from Input Card {0}", ioSlot); - InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline.JoinNumber + ioSlotJoin]); - } - } - - if (basicTxDevice != null && advancedTxDevice == null) - trilist.BooleanInput[joinMap.TxAdvancedIsPresent.JoinNumber + ioSlotJoin].BoolValue = true; - - if (advancedTxDevice != null) - { - advancedTxDevice.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus.JoinNumber + ioSlotJoin]); - } - else - { - Debug.Console(1, "Setting up actions and feedbacks on input card {0}", ioSlot); - VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus.JoinNumber + ioSlotJoin]); - - var inputPort = InputPorts[string.Format("inputCard{0}--hdmiIn", ioSlot)]; - if (inputPort != null) - { - Debug.Console(1, "Port value for input card {0} is set", ioSlot); - var port = inputPort.Port; - - if (port != null) - { - if (port is HdmiInputWithCEC) - { - Debug.Console(1, "Port is HdmiInputWithCec"); - - var hdmiInPortWCec = port as HdmiInputWithCEC; - - if (hdmiInPortWCec.HdcpSupportedLevel != eHdcpSupportedLevel.Unknown) - { - SetHdcpStateAction(true, hdmiInPortWCec, joinMap.HdcpSupportState.JoinNumber + ioSlotJoin, trilist); - } - - InputCardHdcpCapabilityFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportState.JoinNumber + ioSlotJoin]); - - if (InputCardHdcpCapabilityTypes.ContainsKey(ioSlot)) - trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = (ushort)InputCardHdcpCapabilityTypes[ioSlot]; - else - trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = 1; - } - } - } - else - { - inputPort = InputPorts[string.Format("inputCard{0}--dmIn", ioSlot)]; - - if (inputPort != null) - { - var port = inputPort.Port; - - if (port is DMInputPortWithCec) - { - Debug.Console(1, "Port is DMInputPortWithCec"); - - var dmInPortWCec = port as DMInputPortWithCec; - - SetHdcpStateAction(PropertiesConfig.InputSlotSupportsHdcp2[ioSlot], dmInPortWCec, joinMap.HdcpSupportState.JoinNumber + ioSlotJoin, trilist); - - InputCardHdcpCapabilityFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportState.JoinNumber + ioSlotJoin]); - - if (InputCardHdcpCapabilityTypes.ContainsKey(ioSlot)) - trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = (ushort)InputCardHdcpCapabilityTypes[ioSlot]; - else - trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = 1; - } - } - } - } - } - else - { - VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus.JoinNumber + ioSlotJoin]); - - var inputPort = InputPorts[string.Format("inputCard{0}--hdmiIn", ioSlot)]; - if (inputPort != null) - { - var hdmiPort = inputPort.Port as EndpointHdmiInput; - - if (hdmiPort != null) - { - SetHdcpStateAction(true, hdmiPort, joinMap.HdcpSupportState.JoinNumber + ioSlotJoin, trilist); - InputCardHdcpCapabilityFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportState.JoinNumber + ioSlotJoin]); - } - } - } - if (RxDictionary.ContainsKey(ioSlot)) - { - Debug.Console(2, "Creating Rx Feedbacks {0}", ioSlot); - //var rxKey = RxDictionary[ioSlot]; - //var rxDevice = DeviceManager.GetDeviceForKey(rxKey) as DmRmcControllerBase; - //var hdBaseTDevice = DeviceManager.GetDeviceForKey(rxKey) as DmHdBaseTControllerBase; - //if (hdBaseTDevice != null) { - OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline.JoinNumber + ioSlotJoin]); - //} - //else if (rxDevice != null) { - // rxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]); - //} - } - - // Feedback - VideoOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputVideo.JoinNumber + ioSlotJoin]); - - - OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames.JoinNumber + ioSlotJoin]); - InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames.JoinNumber + ioSlotJoin]); - OutputVideoRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentVideoInputNames.JoinNumber + ioSlotJoin]); - } - } - - private void SetHdcpStateAction(bool hdcpTypeSimple, HdmiInputWithCEC port, uint join, BasicTriList trilist) - { - if (hdcpTypeSimple) - { - trilist.SetUShortSigAction(join, - s => - { - if (s == 0) - { - port.HdcpSupportOff(); - } - else if (s > 0) - { - port.HdcpSupportOn(); - } - }); - } - else - { - trilist.SetUShortSigAction(join, - u => - { - port.HdcpReceiveCapability = (eHdcpCapabilityType)u; - }); - } - } - - private void SetHdcpStateAction(bool hdcpTypeSimple, EndpointHdmiInput port, uint join, BasicTriList trilist) - { - if (hdcpTypeSimple) - { - trilist.SetUShortSigAction(join, - s => - { - if (s == 0) - { - port.HdcpSupportOff(); - } - else if (s > 0) - { - port.HdcpSupportOn(); - } - }); - } - else - { - trilist.SetUShortSigAction(join, - u => - { - port.HdcpCapability = (eHdcpCapabilityType)u; - }); - } - } - - private void SetHdcpStateAction(bool supportsHdcp2, DMInputPortWithCec port, uint join, BasicTriList trilist) - { - if (!supportsHdcp2) - { - trilist.SetUShortSigAction(join, - s => - { - if (s == 0) - { - port.HdcpSupportOff(); - } - else if (s > 0) - { - port.HdcpSupportOn(); - } - }); - } - else - { - trilist.SetUShortSigAction(join, - u => - { - port.HdcpReceiveCapability = (eHdcpCapabilityType)u; - }); - } - } - - } - - /* - public struct PortNumberType { - public uint Number { get; private set; } - public eRoutingSignalType Type { get; private set; } - - public PortNumberType(uint number, eRoutingSignalType type) - : this() { - Number = number; - Type = type; - } - }*/ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Cards; +using Crestron.SimplSharpPro.DM.Blades; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Receivers; +using Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.DM.Config; + +namespace PepperDash.Essentials.DM +{ + /// + /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions + /// + /// + public class DmBladeChassisController : CrestronGenericBridgeableBaseDevice, IDmSwitchWithEndpointOnlineFeedback, IRoutingNumericWithFeedback + { + private const string NonePortKey = "inputCard0--None"; + + public DMChassisPropertiesConfig PropertiesConfig { get; set; } + + public Switch Chassis { get; private set; } + + //IroutingNumericEvent + public event EventHandler NumericSwitchChange; + + // Feedbacks for EssentialDM + public Dictionary VideoOutputFeedbacks { get; private set; } + public Dictionary AudioOutputFeedbacks { get; private set; } + public Dictionary VideoInputSyncFeedbacks { get; private set; } + public Dictionary InputEndpointOnlineFeedbacks { get; private set; } + public Dictionary OutputEndpointOnlineFeedbacks { get; private set; } + public Dictionary InputNameFeedbacks { get; private set; } + public Dictionary OutputNameFeedbacks { get; private set; } + public Dictionary OutputVideoRouteNameFeedbacks { get; private set; } + public Dictionary OutputAudioRouteNameFeedbacks { get; private set; } + public Dictionary UsbOutputRoutedToFeebacks { get; private set; } + public Dictionary UsbInputRoutedToFeebacks { get; private set; } + + public IntFeedback SystemIdFeebdack { get; private set; } + public BoolFeedback SystemIdBusyFeedback { get; private set; } + + + public Dictionary InputCardHdcpCapabilityFeedbacks { get; private set; } + + public Dictionary InputCardHdcpCapabilityTypes { get; private set; } + + + // Need a couple Lists of generic Backplane ports + public RoutingPortCollection InputPorts { get; private set; } + public RoutingPortCollection OutputPorts { get; private set; } + + public Dictionary TxDictionary { get; set; } + public Dictionary RxDictionary { get; set; } + + //public Dictionary InputCards { get; private set; } + //public Dictionary OutputCards { get; private set; } + + public Dictionary InputNames { get; set; } + public Dictionary OutputNames { get; set; } + public Dictionary VolumeControls { get; private set; } + + public const int RouteOffTime = 500; + Dictionary RouteOffTimers = new Dictionary(); + + /// + /// Factory method to create a new chassis controller from config data. Limited to 8x8 right now + /// + public static DmBladeChassisController GetDmChassisController(string key, string name, + string type, DMChassisPropertiesConfig properties) + { + try + { + type = type.ToLower(); + uint ipid = properties.Control.IpIdInt; + + BladeSwitch chassis = null; + if (type == "dmmd64x64") { chassis = new DmMd64x64(ipid, Global.ControlSystem); } + else if (type == "dmmd128x128") { chassis = new DmMd128x128(ipid, Global.ControlSystem); } + + + if (chassis == null) + { + return null; + } + + var controller = new DmBladeChassisController(key, name, chassis); + // add the cards and port names + foreach (var kvp in properties.InputSlots) + controller.AddInputBlade(kvp.Value, kvp.Key); + foreach (var kvp in properties.OutputSlots) + { + controller.AddOutputBlade(kvp.Value, kvp.Key); + } + + foreach (var kvp in properties.VolumeControls) + { + // get the card + // check it for an audio-compatible type + // make a something-something that will make it work + // retire to mountain village + var outNum = kvp.Key; + + var card = controller.Chassis.Outputs[outNum].Card; + Audio.Output audio = null; + if (card is DmHdmi4kOutputBladeCard) + audio = (card as DmHdmi4kOutputBladeCard).Hdmi4kOutput.Audio; + if (audio == null) + continue; + // wire up the audio to something here... + controller.AddVolumeControl(outNum, audio); + } + + controller.InputPorts.Add(new RoutingInputPort(NonePortKey, eRoutingSignalType.Video, + eRoutingPortConnectionType.None, null, controller)); + + + controller.InputNames = properties.InputNames; + controller.OutputNames = properties.OutputNames; + controller.PropertiesConfig = properties; + return controller; + } + catch (System.Exception e) + { + Debug.Console(0, "Error creating DM chassis:\r{0}", e); + } + return null; + } + + + /// + /// + /// + /// + /// + /// + public DmBladeChassisController(string key, string name, BladeSwitch chassis) + : base(key, name, chassis) + { + Chassis = chassis; + InputPorts = new RoutingPortCollection(); + OutputPorts = new RoutingPortCollection(); + VolumeControls = new Dictionary(); + TxDictionary = new Dictionary(); + RxDictionary = new Dictionary(); + IsOnline.OutputChange += new EventHandler(IsOnline_OutputChange); + Chassis.DMInputChange += new DMInputEventHandler(Chassis_DMInputChange); + Chassis.DMOutputChange += new DMOutputEventHandler(Chassis_DMOutputChange); + VideoOutputFeedbacks = new Dictionary(); + UsbOutputRoutedToFeebacks = new Dictionary(); + UsbInputRoutedToFeebacks = new Dictionary(); + VideoInputSyncFeedbacks = new Dictionary(); + InputNameFeedbacks = new Dictionary(); + OutputNameFeedbacks = new Dictionary(); + OutputVideoRouteNameFeedbacks = new Dictionary(); + OutputAudioRouteNameFeedbacks = new Dictionary(); + InputEndpointOnlineFeedbacks = new Dictionary(); + OutputEndpointOnlineFeedbacks = new Dictionary(); + + InputCardHdcpCapabilityFeedbacks = new Dictionary(); + InputCardHdcpCapabilityTypes = new Dictionary(); + + for (uint x = 1; x <= Chassis.NumberOfOutputs; x++) + { + var tempX = x; + + if (Chassis.Outputs[tempX] != null) + { + VideoOutputFeedbacks[tempX] = new IntFeedback(() => + { + if (Chassis.Outputs[tempX].VideoOutFeedback != null) { return (ushort)Chassis.Outputs[tempX].VideoOutFeedback.Number; } + else { return 0; }; + }); + + OutputNameFeedbacks[tempX] = new StringFeedback(() => + { + if (Chassis.Outputs[tempX].NameFeedback != null) + { + return Chassis.Outputs[tempX].NameFeedback.StringValue; + } + else + { + return ""; + } + }); + OutputVideoRouteNameFeedbacks[tempX] = new StringFeedback(() => + { + if (Chassis.Outputs[tempX].VideoOutFeedback != null) + { + return Chassis.Outputs[tempX].VideoOutFeedback.NameFeedback.StringValue; + } + else + { + return ""; + } + }); + + OutputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => + { + //if (Chassis.Outputs[tempX].Endpoint != null) + // return Chassis.Outputs[tempX].Endpoint.IsOnline; + //else + return Chassis.Outputs[tempX].EndpointOnlineFeedback; + }); + } + + if (Chassis.Inputs[tempX] != null) + { + UsbInputRoutedToFeebacks[tempX] = new IntFeedback(() => + { + if (Chassis.Inputs[tempX].USBRoutedToFeedback != null) { return (ushort)Chassis.Inputs[tempX].USBRoutedToFeedback.Number; } + else { return 0; }; + }); + VideoInputSyncFeedbacks[tempX] = new BoolFeedback(() => + { + if (Chassis.Inputs[tempX].VideoDetectedFeedback != null) + return Chassis.Inputs[tempX].VideoDetectedFeedback.BoolValue; + else + return false; + }); + InputNameFeedbacks[tempX] = new StringFeedback(() => + { + if (Chassis.Inputs[tempX].NameFeedback != null) + { + return Chassis.Inputs[tempX].NameFeedback.StringValue; + } + else + { + return ""; + } + }); + + InputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => + { + return Chassis.Inputs[tempX].EndpointOnlineFeedback; + }); + + InputCardHdcpCapabilityFeedbacks[tempX] = new IntFeedback(() => + { + var inputCard = Chassis.Inputs[tempX]; + + if (inputCard.Card is DmHdmi4kInputBladeCard) + { + InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.Hdcp2_2Support; + + if ((inputCard.Card as DmHdmi4kInputBladeCard).Hdmi4kInput.HdcpSupportOnFeedback.BoolValue) + return 1; + else + return 0; + } + + if (inputCard.Card is DmC4kInputBladeCard) + { + InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.Hdcp2_2Support; + + if ((inputCard.Card as DmC4kInputBladeCard).DmInput.HdcpCapabilityFeedback.Equals(eHdcpCapabilityType.HdcpSupportOff)) + return 0; + else + return 1; + } + + else + return 0; + }); + } + } + } + + /// + /// + /// + /// + /// + public void AddInputBlade(string type, uint number) + { + Debug.Console(2, this, "Adding input blade '{0}', slot {1}", type, number); + + type = type.ToLower(); + + if (type == "dmb4kihd") + { + var inputBlade = new Dmb4kIHd(number, this.Chassis); + foreach (var item in inputBlade.Inputs) + { + var card = (item.Card as DmHdmi4kInputBladeCard).Hdmi4kInput; + var cecPort = card as ICec; + AddHdmiInBladePorts(item.Number, cecPort); + } + } + + else if (type == "dmb4kihddnt") + { + var inputBlade = new Dmb4kIHd(number, this.Chassis); + foreach (var item in inputBlade.Inputs) + { + var card = (item.Card as DmHdmi4kInputBladeCard).Hdmi4kInput; + var cecPort = card as ICec; + AddHdmiInBladePorts(item.Number, cecPort); + } + } + + else if (type == "dmb4kic") + { + var inputBlade = new Dmb4kIC(number, this.Chassis); + foreach (var item in inputBlade.Inputs) + { + AddDmInBladePorts(item.Number); + } + } + + else if (type == "dmbis") + { + var inputBlade = new DmbIS(number, this.Chassis); + foreach (var item in inputBlade.Inputs) + { + AddDmInMmFiberPorts(item.Number); + } + } + else if (type == "dmbis2") + { + var inputBlade = new DmbIS2(number, this.Chassis); + foreach (var item in inputBlade.Inputs) + { + AddDmInSmFiberPorts(item.Number); + } + } + } + + /// + /// Raise an event when the status of a switch object changes. + /// + /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType + private void OnSwitchChange(RoutingNumericEventArgs e) + { + var newEvent = NumericSwitchChange; + if (newEvent != null) newEvent(this, e); + } + + + void AddHdmiInBladePorts(uint number, ICec cecPort) + { + AddInputPortWithDebug(number, "hdmiIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, cecPort); + } + + void AddDmInBladePorts(uint number) + { + AddInputPortWithDebug(number, "dmCIn", eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat); + } + + void AddDmInMmFiberPorts(uint number) + { + AddInputPortWithDebug(number, "dmMmIn", eRoutingSignalType.Video, eRoutingPortConnectionType.DmMmFiber); + } + + void AddDmInSmFiberPorts(uint number) + { + AddInputPortWithDebug(number, "dmSmIn", eRoutingSignalType.Video, eRoutingPortConnectionType.DmSmFiber); + } + + /// + /// + /// + /// + /// + public void AddOutputBlade(string type, uint number) + { + type = type.ToLower(); + + Debug.Console(2, this, "Adding output blade '{0}', slot {1}", type, number); + if (type == "dmb4kohd") + { + var outputBlade = new Dmb4KOHD(number, Chassis); + foreach (var item in outputBlade.Outputs) + { + AddHdmiOutBladePorts(item.Number); + } + } + + else if (type == "dmb4kohddnt") + { + var outputBlade = new Dmb4KOHD(number, Chassis); + foreach (var item in outputBlade.Outputs) + { + AddHdmiOutBladePorts(item.Number); + } + } + + else if (type == "dmb4koc") + { + var outputBlade = new Dmb4KOC(number, Chassis); + foreach (var item in outputBlade.Outputs) + { + AddDmOutBladePorts(item.Number); + } + } + else if (type == "dmb4koc") + { + var outputBlade = new Dmb4KOC(number, Chassis); + foreach (var item in outputBlade.Outputs) + { + AddDmOutBladePorts(item.Number); + } + } + else if (type == "dmbos") + { + var outputBlade = new DmbOS(number, Chassis); + foreach (var item in outputBlade.Outputs) + { + AddDmOutMmFiberBladePorts(item.Number); + } + } + else if (type == "dmbos2") + { + var outputBlade = new DmbOS2(number, Chassis); + foreach (var item in outputBlade.Outputs) + { + AddDmOutSmFiberBladePorts(item.Number); + } + } + } + + void AddHdmiOutBladePorts(uint number) + { + AddOutputPortWithDebug(number, "hdmiOut", eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, Chassis.Outputs[number]); + } + + void AddDmOutBladePorts(uint number) + { + AddOutputPortWithDebug(number, "dmOut", eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, Chassis.Outputs[number]); + } + + void AddDmOutMmFiberBladePorts(uint number) + { + AddOutputPortWithDebug(number, "dmMmOut", eRoutingSignalType.Video, eRoutingPortConnectionType.DmMmFiber, Chassis.Outputs[number]); + } + + void AddDmOutSmFiberBladePorts(uint number) + { + AddOutputPortWithDebug(number, "dmSmOut", eRoutingSignalType.Video, eRoutingPortConnectionType.DmSmFiber, Chassis.Outputs[number]); + } + + + /// + /// Adds InputPort + /// + void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType) + { + AddInputPortWithDebug(cardNum, portName, sigType, portType, null); + } + + /// + /// Adds InputPort and sets Port as ICec object + /// + private void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, + eRoutingPortConnectionType portType, ICec cecPort) + { + var portKey = string.Format("inputCard{0}--{1}", cardNum, portName); + Debug.Console(2, this, "Adding input port '{0}'", portKey); + var inputPort = new RoutingInputPort(portKey, sigType, portType, Chassis.Inputs[cardNum], this) + { + FeedbackMatchObject = Chassis.Inputs[cardNum] + }; + + if (cecPort != null) + inputPort.Port = cecPort; + + InputPorts.Add(inputPort); + } + + + + /*void AddOutputPortWithDebug(string cardName, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, object selector) { + var portKey = string.Format("{0}--{1}", cardName, portName); + Debug.Console(2, this, "Adding output port '{0}'", portKey); + OutputPorts.Add(new RoutingOutputPort(portKey, sigType, portType, selector, this) + { + FeedbackMatchObject = selector + }); + }*/ + + /// + /// Adds OutputPort + /// + void AddOutputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, object selector) + { + try + { + var portKey = string.Format("outputCard{0}--{1}", cardNum, portName); + Debug.Console(2, this, "Adding output port '{0}'", portKey); + var outputPort = new RoutingOutputPort(portKey, sigType, portType, selector, this) + { + FeedbackMatchObject = Chassis.Outputs[cardNum] + }; + OutputPorts.Add(outputPort); + } + catch (Exception ex) + { + Debug.Console(0, this, "Exception : {0}", ex); + } + + } + + + /// + /// + /// + void AddVolumeControl(uint number, Audio.Output audio) + { + VolumeControls.Add(number, new DmCardAudioOutputController(audio)); + } + + //public void SetInputHdcpSupport(uint input, ePdtHdcpSupport hdcpSetting) + //{ + + //} + + + void Chassis_DMInputChange(Switch device, DMInputEventArgs args) + { + + switch (args.EventId) + { + case DMInputEventIds.EndpointOnlineEventId: + { + Debug.Console(2, this, "DM Input EndpointOnlineEventId for input: {0}. State: {1}", args.Number, device.Inputs[args.Number].EndpointOnlineFeedback); + InputEndpointOnlineFeedbacks[args.Number].FireUpdate(); + break; + } + case DMInputEventIds.OnlineFeedbackEventId: + { + Debug.Console(2, this, "DM Input OnlineFeedbackEventId for input: {0}. State: {1}", args.Number, device.Inputs[args.Number].EndpointOnlineFeedback); + InputEndpointOnlineFeedbacks[args.Number].FireUpdate(); + break; + } + case DMInputEventIds.VideoDetectedEventId: + { + Debug.Console(2, this, "DM Input {0} VideoDetectedEventId", args.Number); + VideoInputSyncFeedbacks[args.Number].FireUpdate(); + break; + } + case DMInputEventIds.InputNameEventId: + { + Debug.Console(2, this, "DM Input {0} NameFeedbackEventId", args.Number); + InputNameFeedbacks[args.Number].FireUpdate(); + break; + } + case DMInputEventIds.HdcpCapabilityFeedbackEventId: + { + Debug.Console(2, this, "DM Input {0} HdcpCapabilityFeedbackEventId", args.Number); + InputCardHdcpCapabilityFeedbacks[args.Number].FireUpdate(); + break; + } + default: + { + Debug.Console(2, this, "DMInputChange fired for Input {0} with Unhandled EventId: {1}", args.Number, args.EventId); + break; + } + } + } + + /// + /// + private void Chassis_DMOutputChange(Switch device, DMOutputEventArgs args) + { + var output = args.Number; + + switch (args.EventId) + { + case DMOutputEventIds.VolumeEventId: + { + if (VolumeControls.ContainsKey(output)) + { + VolumeControls[args.Number].VolumeEventFromChassis(); + } + break; + } + case DMOutputEventIds.EndpointOnlineEventId: + { + Debug.Console(2, this, + "Output {0} DMOutputEventIds.EndpointOnlineEventId fired. EndpointOnlineFeedback State: {1}", + args.Number, Chassis.Outputs[output].EndpointOnlineFeedback); + if (Chassis.Outputs[output].Endpoint != null) + Debug.Console(2, this, + "Output {0} DMOutputEventIds.EndpointOnlineEventId fired. Endpoint.IsOnline State: {1}", + args.Number, Chassis.Outputs[output].Endpoint.IsOnline); + + OutputEndpointOnlineFeedbacks[output].FireUpdate(); + break; + } + case DMOutputEventIds.OnlineFeedbackEventId: + { + Debug.Console(2, this, "Output {0} DMInputEventIds.OnlineFeedbackEventId fired. State: {1}", + args.Number, Chassis.Outputs[output].EndpointOnlineFeedback); + OutputEndpointOnlineFeedbacks[output].FireUpdate(); + break; + } + case DMOutputEventIds.VideoOutEventId: + { + + var inputNumber = Chassis.Outputs[output].VideoOutFeedback == null ? 0 : Chassis.Outputs[output].VideoOutFeedback.Number; + + Debug.Console(2, this, "DMSwitchAudioVideo:{0} Routed Input:{1} Output:{2}'", this.Name, + inputNumber, output); + + if (VideoOutputFeedbacks.ContainsKey(output)) + { + var localInputPort = InputPorts.FirstOrDefault(p => (DMInput)p.FeedbackMatchObject == Chassis.Outputs[output].VideoOutFeedback); + var localOutputPort = + OutputPorts.FirstOrDefault(p => (DMOutput)p.FeedbackMatchObject == Chassis.Outputs[output]); + + + VideoOutputFeedbacks[output].FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(output, + inputNumber, + localOutputPort, + localInputPort, + eRoutingSignalType.AudioVideo)); + + } + if (OutputVideoRouteNameFeedbacks.ContainsKey(output)) + { + OutputVideoRouteNameFeedbacks[output].FireUpdate(); + } + break; + } + case DMOutputEventIds.OutputNameEventId: + { + Debug.Console(2, this, "DM Output {0} NameFeedbackEventId", output); + OutputNameFeedbacks[output].FireUpdate(); + break; + } + default: + { + Debug.Console(2, this, "DMOutputChange fired for Output {0} with Unhandled EventId: {1}", + args.Number, args.EventId); + break; + } + } + + } + + + /// + /// + /// + /// + void StartOffTimer(PortNumberType pnt) + { + if (RouteOffTimers.ContainsKey(pnt)) + return; + RouteOffTimers[pnt] = new CTimer(o => ExecuteSwitch(null, pnt.Selector, pnt.Type), RouteOffTime); + } + + + // Send out sigs when coming online + void IsOnline_OutputChange(object sender, EventArgs e) + { + if (IsOnline.BoolValue) + { + Chassis.EnableUSBBreakaway.BoolValue = true; + + if (InputNames != null) + foreach (var kvp in InputNames) + Chassis.Inputs[kvp.Key].Name.StringValue = kvp.Value; + if (OutputNames != null) + foreach (var kvp in OutputNames) + Chassis.Outputs[kvp.Key].Name.StringValue = kvp.Value; + } + } + + #region IRouting Members + + public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType sigType) + { + Debug.Console(2, this, "Making an awesome DM route from {0} to {1} {2}", inputSelector, outputSelector, sigType); + + var input = inputSelector as DMInput; // Cast can sometimes fail + var output = outputSelector as DMOutput; + + + if (output == null) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Warning, + "Unable to execute switch for inputSelector {0} to outputSelector {1}", inputSelector, + outputSelector); + return; + } + + // Check to see if there's an off timer waiting on this and if so, cancel + var key = new PortNumberType(output, sigType); + + if (input == null) + { + StartOffTimer(key); + } + else + { + if (RouteOffTimers.ContainsKey(key)) + { + Debug.Console(2, this, "{0} cancelling route off due to new source", output); + RouteOffTimers[key].Stop(); + RouteOffTimers.Remove(key); + } + } + + + + /*var inCard = input == 0 ? null : Chassis.Inputs[input]; + var outCard = input == 0 ? null : Chassis.Outputs[output];*/ + + // NOTE THAT BITWISE COMPARISONS - TO CATCH ALL ROUTING TYPES + if ((sigType & eRoutingSignalType.Video) != eRoutingSignalType.Video) return; + Chassis.VideoEnter.BoolValue = true; + output.VideoOut = input; + } + + #endregion + + #region IRoutingNumeric Members + + public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType sigType) + { + var input = inputSelector == 0 ? null : Chassis.Inputs[inputSelector]; + var output = Chassis.Outputs[outputSelector]; + + ExecuteSwitch(input, output, sigType); + } + + #endregion + + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new DmBladeChassisControllerJoinMap(joinStart); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + else + { + Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + } + + Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + + // Link up outputs + for (uint i = 1; i <= Chassis.NumberOfOutputs; i++) + { + var ioSlot = i; + var ioSlotJoin = ioSlot - 1; + + // Control + trilist.SetUShortSigAction(joinMap.OutputVideo.JoinNumber + ioSlotJoin, o => ExecuteNumericSwitch(o, (ushort)ioSlot, eRoutingSignalType.Video)); + + if (TxDictionary.ContainsKey(ioSlot)) + { + Debug.Console(2, "Creating Tx Feedbacks {0}", ioSlot); + var txKey = TxDictionary[ioSlot]; + var basicTxDevice = DeviceManager.GetDeviceForKey(txKey) as BasicDmTxControllerBase; + + var advancedTxDevice = basicTxDevice as DmTxControllerBase; + + if (Chassis is DmMd128x128 || Chassis is DmMd64x64) + { + InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline.JoinNumber + ioSlotJoin]); + } + else + { + if (advancedTxDevice != null) + { + advancedTxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline.JoinNumber + ioSlotJoin]); + Debug.Console(2, "Linking Tx Online Feedback from Advanced Transmitter at input {0}", ioSlot); + } + else if (InputEndpointOnlineFeedbacks[ioSlot] != null) + { + Debug.Console(2, "Linking Tx Online Feedback from Input Card {0}", ioSlot); + InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline.JoinNumber + ioSlotJoin]); + } + } + + if (basicTxDevice != null && advancedTxDevice == null) + trilist.BooleanInput[joinMap.TxAdvancedIsPresent.JoinNumber + ioSlotJoin].BoolValue = true; + + if (advancedTxDevice != null) + { + advancedTxDevice.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus.JoinNumber + ioSlotJoin]); + } + else + { + Debug.Console(1, "Setting up actions and feedbacks on input card {0}", ioSlot); + VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus.JoinNumber + ioSlotJoin]); + + var inputPort = InputPorts[string.Format("inputCard{0}--hdmiIn", ioSlot)]; + if (inputPort != null) + { + Debug.Console(1, "Port value for input card {0} is set", ioSlot); + var port = inputPort.Port; + + if (port != null) + { + if (port is HdmiInputWithCEC) + { + Debug.Console(1, "Port is HdmiInputWithCec"); + + var hdmiInPortWCec = port as HdmiInputWithCEC; + + if (hdmiInPortWCec.HdcpSupportedLevel != eHdcpSupportedLevel.Unknown) + { + SetHdcpStateAction(true, hdmiInPortWCec, joinMap.HdcpSupportState.JoinNumber + ioSlotJoin, trilist); + } + + InputCardHdcpCapabilityFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportState.JoinNumber + ioSlotJoin]); + + if (InputCardHdcpCapabilityTypes.ContainsKey(ioSlot)) + trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = (ushort)InputCardHdcpCapabilityTypes[ioSlot]; + else + trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = 1; + } + } + } + else + { + inputPort = InputPorts[string.Format("inputCard{0}--dmIn", ioSlot)]; + + if (inputPort != null) + { + var port = inputPort.Port; + + if (port is DMInputPortWithCec) + { + Debug.Console(1, "Port is DMInputPortWithCec"); + + var dmInPortWCec = port as DMInputPortWithCec; + + SetHdcpStateAction(PropertiesConfig.InputSlotSupportsHdcp2[ioSlot], dmInPortWCec, joinMap.HdcpSupportState.JoinNumber + ioSlotJoin, trilist); + + InputCardHdcpCapabilityFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportState.JoinNumber + ioSlotJoin]); + + if (InputCardHdcpCapabilityTypes.ContainsKey(ioSlot)) + trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = (ushort)InputCardHdcpCapabilityTypes[ioSlot]; + else + trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = 1; + } + } + } + } + } + else + { + VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus.JoinNumber + ioSlotJoin]); + + var inputPort = InputPorts[string.Format("inputCard{0}--hdmiIn", ioSlot)]; + if (inputPort != null) + { + var hdmiPort = inputPort.Port as EndpointHdmiInput; + + if (hdmiPort != null) + { + SetHdcpStateAction(true, hdmiPort, joinMap.HdcpSupportState.JoinNumber + ioSlotJoin, trilist); + InputCardHdcpCapabilityFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportState.JoinNumber + ioSlotJoin]); + } + } + } + if (RxDictionary.ContainsKey(ioSlot)) + { + Debug.Console(2, "Creating Rx Feedbacks {0}", ioSlot); + //var rxKey = RxDictionary[ioSlot]; + //var rxDevice = DeviceManager.GetDeviceForKey(rxKey) as DmRmcControllerBase; + //var hdBaseTDevice = DeviceManager.GetDeviceForKey(rxKey) as DmHdBaseTControllerBase; + //if (hdBaseTDevice != null) { + OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline.JoinNumber + ioSlotJoin]); + //} + //else if (rxDevice != null) { + // rxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]); + //} + } + + // Feedback + VideoOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputVideo.JoinNumber + ioSlotJoin]); + + + OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames.JoinNumber + ioSlotJoin]); + InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames.JoinNumber + ioSlotJoin]); + OutputVideoRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentVideoInputNames.JoinNumber + ioSlotJoin]); + } + } + + private void SetHdcpStateAction(bool hdcpTypeSimple, HdmiInputWithCEC port, uint join, BasicTriList trilist) + { + if (hdcpTypeSimple) + { + trilist.SetUShortSigAction(join, + s => + { + if (s == 0) + { + port.HdcpSupportOff(); + } + else if (s > 0) + { + port.HdcpSupportOn(); + } + }); + } + else + { + trilist.SetUShortSigAction(join, + u => + { + port.HdcpReceiveCapability = (eHdcpCapabilityType)u; + }); + } + } + + private void SetHdcpStateAction(bool hdcpTypeSimple, EndpointHdmiInput port, uint join, BasicTriList trilist) + { + if (hdcpTypeSimple) + { + trilist.SetUShortSigAction(join, + s => + { + if (s == 0) + { + port.HdcpSupportOff(); + } + else if (s > 0) + { + port.HdcpSupportOn(); + } + }); + } + else + { + trilist.SetUShortSigAction(join, + u => + { + port.HdcpCapability = (eHdcpCapabilityType)u; + }); + } + } + + private void SetHdcpStateAction(bool supportsHdcp2, DMInputPortWithCec port, uint join, BasicTriList trilist) + { + if (!supportsHdcp2) + { + trilist.SetUShortSigAction(join, + s => + { + if (s == 0) + { + port.HdcpSupportOff(); + } + else if (s > 0) + { + port.HdcpSupportOn(); + } + }); + } + else + { + trilist.SetUShortSigAction(join, + u => + { + port.HdcpReceiveCapability = (eHdcpCapabilityType)u; + }); + } + } + + } + + /* + public struct PortNumberType { + public uint Number { get; private set; } + public eRoutingSignalType Type { get; private set; } + + public PortNumberType(uint number, eRoutingSignalType type) + : this() { + Number = number; + Type = type; + } + }*/ } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput.cs.orig b/src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput.cs.orig similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput.cs.orig rename to src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput.cs.orig diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput_BACKUP_14408.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput_BACKUP_14408.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput_BACKUP_14408.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput_BACKUP_14408.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput_BASE_14408.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput_BASE_14408.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput_BASE_14408.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput_BASE_14408.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput_LOCAL_14408.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput_LOCAL_14408.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput_LOCAL_14408.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput_LOCAL_14408.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput_REMOTE_14408.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput_REMOTE_14408.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput_REMOTE_14408.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput_REMOTE_14408.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs similarity index 97% rename from essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs index ca8b3dd8..d956257e 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs @@ -1,2126 +1,2126 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Crestron.SimplSharp; -using Crestron.SimplSharp.Reflection; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Cards; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpProInternal; -using Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.DM.Config; -using PepperDash.Essentials.Core.Config; - -namespace PepperDash.Essentials.DM -{ - /// - /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions - /// - /// - [Description("Wrapper class for all DM-MD chassis variants from 8x8 to 32x32")] - public class DmChassisController : CrestronGenericBridgeableBaseDevice, IDmSwitchWithEndpointOnlineFeedback, IRoutingNumericWithFeedback - { - private const string NonePortKey = "inputCard0--None"; - public DMChassisPropertiesConfig PropertiesConfig { get; set; } - - public Switch Chassis { get; private set; } - - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - // Feedbacks for EssentialDM - public Dictionary VideoOutputFeedbacks { get; private set; } - public Dictionary AudioOutputFeedbacks { get; private set; } - public Dictionary VideoInputSyncFeedbacks { get; private set; } - public Dictionary InputEndpointOnlineFeedbacks { get; private set; } - public Dictionary OutputEndpointOnlineFeedbacks { get; private set; } - public Dictionary InputNameFeedbacks { get; private set; } - public Dictionary OutputNameFeedbacks { get; private set; } - public Dictionary OutputVideoRouteNameFeedbacks { get; private set; } - public Dictionary OutputAudioRouteNameFeedbacks { get; private set; } - public Dictionary UsbOutputRoutedToFeebacks { get; private set; } - public Dictionary UsbInputRoutedToFeebacks { get; private set; } - public Dictionary OutputDisabledByHdcpFeedbacks { get; private set; } - - public IntFeedback SystemIdFeebdack { get; private set; } - public BoolFeedback SystemIdBusyFeedback { get; private set; } - public BoolFeedback EnableAudioBreakawayFeedback { get; private set; } - public BoolFeedback EnableUsbBreakawayFeedback { get; private set; } - - public Dictionary InputCardHdcpStateFeedbacks { get; private set; } - public Dictionary InputStreamCardStateFeedbacks { get; private set; } - public Dictionary OutputStreamCardStateFeedbacks { get; private set; } - - public Dictionary InputCardHdcpCapabilityTypes { get; private set; } - - // Need a couple Lists of generic Backplane ports - public RoutingPortCollection InputPorts { get; private set; } - public RoutingPortCollection OutputPorts { get; private set; } - - public Dictionary TxDictionary { get; set; } - public Dictionary RxDictionary { get; set; } - - //public Dictionary InputCards { get; private set; } - //public Dictionary OutputCards { get; private set; } - - public Dictionary InputNames { get; set; } - public Dictionary OutputNames { get; set; } - public Dictionary VolumeControls { get; private set; } - - public const int RouteOffTime = 500; - Dictionary RouteOffTimers = new Dictionary(); - - /// - /// Text that represents when an output has no source routed to it - /// - public string NoRouteText = ""; - - /// - /// Factory method to create a new chassis controller from config data. Limited to 8x8 right now - /// - public static DmChassisController GetDmChassisController(string key, string name, - string type, DMChassisPropertiesConfig properties) - { - try - { - type = type.ToLower(); - uint ipid = properties.Control.IpIdInt; - - DmMDMnxn chassis = null; - switch (type) { - case "dmmd8x8": - chassis = new DmMd8x8(ipid, Global.ControlSystem); - break; - case "dmmd8x8rps": - chassis = new DmMd8x8rps(ipid, Global.ControlSystem); - break; - case "dmmd8x8cpu3": - chassis = new DmMd8x8Cpu3(ipid, Global.ControlSystem); - break; - case "dmmd8x8cpu3rps": - chassis = new DmMd8x8Cpu3rps(ipid, Global.ControlSystem); - break; - case "dmmd16x16": - chassis = new DmMd16x16(ipid, Global.ControlSystem); - break; - case "dmmd16x16rps": - chassis = new DmMd16x16rps(ipid, Global.ControlSystem); - break; - case "dmmd16x16cpu3": - chassis = new DmMd16x16Cpu3(ipid, Global.ControlSystem); - break; - case "dmmd16x16cpu3rps": - chassis = new DmMd16x16Cpu3rps(ipid, Global.ControlSystem); - break; - case "dmmd32x32": - chassis = new DmMd32x32(ipid, Global.ControlSystem); - break; - case "dmmd32x32rps": - chassis = new DmMd32x32rps(ipid, Global.ControlSystem); - break; - case "dmmd32x32cpu3": - chassis = new DmMd32x32Cpu3(ipid, Global.ControlSystem); - break; - case "dmmd32x32cpu3rps": - chassis = new DmMd32x32Cpu3rps(ipid, Global.ControlSystem); - break; - } - - if (chassis == null) - return null; - - var controller = new DmChassisController(key, name, chassis); - - // - var clearInputPort = new RoutingInputPort(NonePortKey, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.None, null, controller); - - controller.InputPorts.Add(clearInputPort); - - // add the cards and port names - foreach (var kvp in properties.InputSlots) - controller.AddInputCard(kvp.Value, kvp.Key); - - foreach (var kvp in properties.OutputSlots) - controller.AddOutputCard(kvp.Value, kvp.Key); - - foreach (var kvp in properties.VolumeControls) - { - // get the card - // check it for an audio-compatible type - // make a something-something that will make it work - // retire to mountain village - var outNum = kvp.Key; - var card = controller.Chassis.Outputs[outNum].Card; - Audio.Output audio = null; - if (card is DmcHdo) - audio = (card as DmcHdo).Audio; - else if (card is Dmc4kHdo) - audio = (card as Dmc4kHdo).Audio; - if (audio == null) - continue; - - // wire up the audio to something here... - controller.AddVolumeControl(outNum, audio); - } - - controller.InputNames = properties.InputNames; - controller.OutputNames = properties.OutputNames; - - if (!string.IsNullOrEmpty(properties.NoRouteText)) - { - controller.NoRouteText = properties.NoRouteText; - Debug.Console(1, controller, "Setting No Route Text value to: {0}", controller.NoRouteText); - } - else - { - Debug.Console(1, controller, "NoRouteText not specified. Defaulting to blank string.", controller.NoRouteText); - } - - controller.PropertiesConfig = properties; - return controller; - } - catch (Exception e) - { - Debug.Console(0, "Error creating DM chassis:\r{0}", e); - } - - return null; - } - - /// - /// - /// - /// - /// - /// - public DmChassisController(string key, string name, DmMDMnxn chassis) - : base(key, name, chassis) - { - - Chassis = chassis; - InputPorts = new RoutingPortCollection(); - OutputPorts = new RoutingPortCollection(); - VolumeControls = new Dictionary(); - TxDictionary = new Dictionary(); - RxDictionary = new Dictionary(); - IsOnline.OutputChange += new EventHandler(IsOnline_OutputChange); - Chassis.DMInputChange += new DMInputEventHandler(Chassis_DMInputChange); - Chassis.DMSystemChange += new DMSystemEventHandler(Chassis_DMSystemChange); - Chassis.DMOutputChange += new DMOutputEventHandler(Chassis_DMOutputChange); - Chassis.BaseEvent += ChassisOnBaseEvent; - VideoOutputFeedbacks = new Dictionary(); - AudioOutputFeedbacks = new Dictionary(); - UsbOutputRoutedToFeebacks = new Dictionary(); - UsbInputRoutedToFeebacks = new Dictionary(); - OutputDisabledByHdcpFeedbacks = new Dictionary(); - VideoInputSyncFeedbacks = new Dictionary(); - InputNameFeedbacks = new Dictionary(); - OutputNameFeedbacks = new Dictionary(); - OutputVideoRouteNameFeedbacks = new Dictionary(); - OutputAudioRouteNameFeedbacks = new Dictionary(); - InputEndpointOnlineFeedbacks = new Dictionary(); - OutputEndpointOnlineFeedbacks = new Dictionary(); - - SystemIdFeebdack = new IntFeedback(() => { return (Chassis as DmMDMnxn).SystemIdFeedback.UShortValue; }); - SystemIdBusyFeedback = new BoolFeedback(() => { return (Chassis as DmMDMnxn).SystemIdBusy.BoolValue; }); - EnableAudioBreakawayFeedback = - new BoolFeedback(() => (Chassis as DmMDMnxn).EnableAudioBreakawayFeedback.BoolValue); - EnableUsbBreakawayFeedback = - new BoolFeedback(() => (Chassis as DmMDMnxn).EnableUSBBreakawayFeedback.BoolValue); - - InputCardHdcpStateFeedbacks = new Dictionary(); - InputStreamCardStateFeedbacks = new Dictionary(); - OutputStreamCardStateFeedbacks = new Dictionary(); - InputCardHdcpCapabilityTypes = new Dictionary(); - - for (uint x = 1; x <= Chassis.NumberOfOutputs; x++) - { - var tempX = x; - - if (Chassis.Outputs[tempX] != null) - { - VideoOutputFeedbacks[tempX] = new IntFeedback(() => { - if (Chassis.Outputs[tempX].VideoOutFeedback != null) - return (ushort)Chassis.Outputs[tempX].VideoOutFeedback.Number; - - return 0; - }); - AudioOutputFeedbacks[tempX] = new IntFeedback(() => { - if (Chassis.Outputs[tempX].AudioOutFeedback != null) - return (ushort)Chassis.Outputs[tempX].AudioOutFeedback.Number; - - return 0; - }); - UsbOutputRoutedToFeebacks[tempX] = new IntFeedback(() => { - if (Chassis.Outputs[tempX].USBRoutedToFeedback != null) - return (ushort)Chassis.Outputs[tempX].USBRoutedToFeedback.Number; - - return 0; - }); - - OutputNameFeedbacks[tempX] = new StringFeedback(() => { - if (Chassis.Outputs[tempX].NameFeedback != null) - return Chassis.Outputs[tempX].NameFeedback.StringValue; - - return ""; - }); - OutputVideoRouteNameFeedbacks[tempX] = new StringFeedback(() => { - if (Chassis.Outputs[tempX].VideoOutFeedback != null) - return Chassis.Outputs[tempX].VideoOutFeedback.NameFeedback.StringValue; - - return NoRouteText; - }); - OutputAudioRouteNameFeedbacks[tempX] = new StringFeedback(() => { - if (Chassis.Outputs[tempX].AudioOutFeedback != null) - return Chassis.Outputs[tempX].AudioOutFeedback.NameFeedback.StringValue; - - return NoRouteText; - }); - OutputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => Chassis.Outputs[tempX].EndpointOnlineFeedback); - - OutputDisabledByHdcpFeedbacks[tempX] = new BoolFeedback(() => { - var output = Chassis.Outputs[tempX]; - - var hdmiTxOutput = output as Card.HdmiTx; - if (hdmiTxOutput != null) - return hdmiTxOutput.HdmiOutput.DisabledByHdcp.BoolValue; - - var dmHdmiOutput = output as Card.DmHdmiOutput; - if (dmHdmiOutput != null) - return dmHdmiOutput.DisabledByHdcpFeedback.BoolValue; - - var dmsDmOutAdvanced = output as Card.DmsDmOutAdvanced; - if (dmsDmOutAdvanced != null) - return dmsDmOutAdvanced.DisabledByHdcpFeedback.BoolValue; - - var dmps3HdmiAudioOutput = output as Card.Dmps3HdmiAudioOutput; - if (dmps3HdmiAudioOutput != null) - return dmps3HdmiAudioOutput.HdmiOutputPort.DisabledByHdcpFeedback.BoolValue; - - var dmps3HdmiOutput = output as Card.Dmps3HdmiOutput; - if (dmps3HdmiOutput != null) - return dmps3HdmiOutput.HdmiOutputPort.DisabledByHdcpFeedback.BoolValue; - - var dmps3HdmiOutputBackend = output as Card.Dmps3HdmiOutputBackend; - if (dmps3HdmiOutputBackend != null) - return dmps3HdmiOutputBackend.HdmiOutputPort.DisabledByHdcpFeedback.BoolValue; - - // var hdRx4kX10HdmiOutput = output as HdRx4kX10HdmiOutput; - // if (hdRx4kX10HdmiOutput != null) - // return hdRx4kX10HdmiOutput.HdmiOutputPort.DisabledByHdcpFeedback.BoolValue; - - // var hdMdNxMHdmiOutput = output as HdMdNxMHdmiOutput; - // if (hdMdNxMHdmiOutput != null) - // return hdMdNxMHdmiOutput.HdmiOutputPort.DisabledByHdcpFeedback.BoolValue; - - return false; - }); - OutputStreamCardStateFeedbacks[tempX] = new IntFeedback(() => - { - try - { - var outputCard = Chassis.Outputs[tempX]; - - if (outputCard.Card is DmcStroAV) - { - Debug.Console(2, "Found output stream card in slot: {0}.", tempX); - var streamCard = outputCard.Card as DmcStroAV; - if (streamCard.Control.StartFeedback.BoolValue == true) - return 1; - else if (streamCard.Control.StopFeedback.BoolValue == true) - return 2; - else if (streamCard.Control.PauseFeedback.BoolValue == true) - return 3; - else - return 0; - } - return 0; - } - catch (InvalidOperationException iopex) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Warning, "Error adding output stream card in slot: {0}. Error: {1}", tempX, iopex); - return 0; - } - }); - } - - if (Chassis.Inputs[tempX] != null) - { - UsbInputRoutedToFeebacks[tempX] = new IntFeedback(() => { - if (Chassis.Inputs[tempX].USBRoutedToFeedback != null) - return (ushort)Chassis.Inputs[tempX].USBRoutedToFeedback.Number; - - return 0; - }); - VideoInputSyncFeedbacks[tempX] = new BoolFeedback(() => { - if (Chassis.Inputs[tempX].VideoDetectedFeedback != null) - return Chassis.Inputs[tempX].VideoDetectedFeedback.BoolValue; - - return false; - }); - InputNameFeedbacks[tempX] = new StringFeedback(() => { - if (Chassis.Inputs[tempX].NameFeedback != null) - return Chassis.Inputs[tempX].NameFeedback.StringValue; - - return ""; - }); - - InputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => { return Chassis.Inputs[tempX].EndpointOnlineFeedback; }); - - InputCardHdcpStateFeedbacks[tempX] = new IntFeedback(() => { - try - { - var inputCard = Chassis.Inputs[tempX]; - - if (inputCard.Card is DmcHd) - { - InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.HdcpAutoSupport; - - if ((inputCard.Card as DmcHd).HdmiInput.HdcpSupportOnFeedback.BoolValue) - return 1; - return 0; - } - - if (inputCard.Card is DmcHdDsp) - { - InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.HdcpAutoSupport; - - if ((inputCard.Card as DmcHdDsp).HdmiInput.HdcpSupportOnFeedback.BoolValue) - return 1; - return 0; - } - if (inputCard.Card is Dmc4kHdBase) - { - InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.Hdcp2_2Support; - return (int)(inputCard.Card as Dmc4kHdBase).HdmiInput.HdcpReceiveCapability; - } - if (inputCard.Card is Dmc4kHdDspBase) - { - if (PropertiesConfig.InputSlotSupportsHdcp2[tempX]) - { - InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.Hdcp2_2Support; - return (int)(inputCard.Card as Dmc4kHdDspBase).HdmiInput.HdcpReceiveCapability; - } - - InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.HdcpAutoSupport; - if ((inputCard.Card as Dmc4kHdDspBase).HdmiInput.HdcpSupportOnFeedback.BoolValue) - return 1; - return 0; - } - - if (inputCard.Card is Dmc4kCBase) - { - if (PropertiesConfig.InputSlotSupportsHdcp2[tempX]) - { - InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.HdcpAutoSupport; - return (int)(inputCard.Card as Dmc4kCBase).DmInput.HdcpReceiveCapability; - } - - if ((inputCard.Card as Dmc4kCBase).DmInput.HdcpSupportOnFeedback.BoolValue) - return 1; - return 0; - } - if (inputCard.Card is Dmc4kCDspBase) - { - if (PropertiesConfig.InputSlotSupportsHdcp2[tempX]) - { - InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.HdcpAutoSupport; - return (int)(inputCard.Card as Dmc4kCDspBase).DmInput.HdcpReceiveCapability; - } - - if ((inputCard.Card as Dmc4kCDspBase).DmInput.HdcpSupportOnFeedback.BoolValue) - return 1; - - return 0; - } - return 0; - } - catch (InvalidOperationException iopex) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Warning, "The Input Card in slot: {0} supports HDCP 2. Please update the configuration value in the inputCardSupportsHdcp2 object to true. Error: {1}", tempX, iopex); - return 0; - } - }); - InputStreamCardStateFeedbacks[tempX] = new IntFeedback(() => - { - try - { - var inputCard = Chassis.Inputs[tempX]; - - if (inputCard.Card is DmcStr) - { - Debug.Console(2, "Found input stream card in slot: {0}.", tempX); - var streamCard = inputCard.Card as DmcStr; - if (streamCard.Control.StartFeedback.BoolValue == true) - return 1; - else if (streamCard.Control.StopFeedback.BoolValue == true) - return 2; - else if (streamCard.Control.PauseFeedback.BoolValue == true) - return 3; - else - return 0; - } - return 0; - } - catch (InvalidOperationException iopex) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Warning, "Error adding input stream card in slot: {0}. Error: {1}", tempX, iopex); - return 0; - } - }); - } - } - } - - private void ChassisOnBaseEvent(GenericBase device, BaseEventArgs args) - { - - } - - private void RegisterForInputResolutionFeedback(IVideoAttributesBasic input, uint number, RoutingInputPortWithVideoStatuses inputPort) - { - if (input == null) - { - return; - } - - Debug.Console(1, this, "Registering for resolution feedback for input {0} using Routing Port {1}", number, inputPort.Key); - - input.VideoAttributes.AttributeChange += (sender, args) => - { - Debug.Console(1, this, "Input {0} resolution updated", number); - - Debug.Console(1, this, "Updating resolution feedback for input {0}", number); - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - }; - } - - /// - /// - /// - /// - /// - public void AddInputCard(string type, uint number) - { - Debug.Console(2, this, "Adding input card '{0}', slot {1}", type, number); - - type = type.ToLower(); - - switch (type) - { - case "dmchd": - { - var inputCard = new DmcHd(number, Chassis); - AddHdmiInCardPorts(number, inputCard.HdmiInput, inputCard.HdmiInput); - } - break; - case "dmchddsp": - { - var inputCard = new DmcHdDsp(number, Chassis); - AddHdmiInCardPorts(number, inputCard.HdmiInput, inputCard.HdmiInput); - } - break; - case "dmc4khd": - { - var inputCard = new Dmc4kHd(number, Chassis); - AddHdmiInCardPorts(number, inputCard.HdmiInput, inputCard.HdmiInput); - } - break; - case "dmc4khddsp": - { - var inputCard = new Dmc4kHdDsp(number, Chassis); - AddHdmiInCardPorts(number, inputCard.HdmiInput, inputCard.HdmiInput); - } - break; - case "dmc4kzhd": - { - var inputCard = new Dmc4kzHd(number, Chassis); - AddHdmiInCardPorts(number, inputCard.HdmiInput, inputCard.HdmiInput); - break; - } - case "dmc4kzhddsp": - { - var inputCard = new Dmc4kzHdDsp(number, Chassis); - AddHdmiInCardPorts(number, inputCard.HdmiInput, inputCard.HdmiInput); - break; - } - case "dmcc": - { - var inputCard = new DmcC(number, Chassis); - //DmInput doesn't implement ICec...cast was resulting in null anyway - AddDmInCardPorts(number, null, inputCard.DmInput); - } - break; - case "dmccdsp": - { - var inputCard = new DmcCDsp(number, Chassis); - //DmInput doesn't implement ICec...cast was resulting in null anyway - AddDmInCardPorts(number, null, inputCard.DmInput); - break; - } - - case "dmc4kc": - { - var inputCard = new Dmc4kC(number, Chassis); - AddDmInCardPorts(number, inputCard.DmInput,inputCard.DmInput); - break; - } - - case "dmc4kcdsp": - { - var inputCard = new Dmc4kCDsp(number, Chassis); - AddDmInCardPorts(number, inputCard.DmInput,inputCard.DmInput); - break; - } - - case "dmc4kzc": - { - var inputCard = new Dmc4kzC(number, Chassis); - AddDmInCardPorts(number, inputCard.DmInput,inputCard.DmInput); - break; - } - - case "dmc4kzcdsp": - { - var inputCard = new Dmc4kzCDsp(number, Chassis); - AddDmInCardPorts(number, inputCard.DmInput, inputCard.DmInput); - break; - } - - case "dmccat": - { - var inputCard = new DmcCat(number, Chassis); - AddDmInCardPorts(number, null, inputCard.DmInput); - break; - } - case "dmccatdsp": - { - var inputCard = new DmcCatDsp(number, Chassis); - AddDmInCardPorts(number, null, inputCard.DmInput); - break; - } - case "dmcs": - { - var inputCard = new DmcS(number, Chassis); - AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmMmFiber, null, inputCard.DmInput); - AddInCardHdmiAndAudioLoopPorts(number); - break; - } - case "dmcsdsp": - { - var inputCard = new DmcSDsp(number, Chassis); - AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmMmFiber, null, inputCard.DmInput); - AddInCardHdmiAndAudioLoopPorts(number); - break; - } - case "dmcs2": - { - var inputCard = new DmcS2(number, Chassis); - AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmSmFiber, null, inputCard.DmInput); - AddInCardHdmiAndAudioLoopPorts(number); - break; - } - case "dmcs2dsp": - { - var inputCard = new DmcS2Dsp(number, Chassis); - AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmSmFiber, null, inputCard.DmInput); - AddInCardHdmiAndAudioLoopPorts(number); - break; - } - case "dmcsdi": - { - var inputCard = new DmcSdi(number, Chassis); - AddInputPortWithDebug(number, "sdiIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Sdi, null, inputCard.SdiInput); - AddOutputPortWithDebug(string.Format("inputCard{0}", number), "sdiOut", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Sdi, null); - AddInCardHdmiAndAudioLoopPorts(number); - break; - } - case "dmcdvi": - { - var inputCard = new DmcDvi(number, Chassis); - AddInputPortWithDebug(number, "dviIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Dvi, null, inputCard.DviInput); - AddInputPortWithDebug(number, "audioIn", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio); - AddInCardHdmiLoopPort(number); - break; - } - case "dmcvga": - { - var inputCard = new DmcVga(number, Chassis); - AddInputPortWithDebug(number, "vgaIn", eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, null, inputCard.VgaInput); - AddInputPortWithDebug(number, "audioIn", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio); - AddInCardHdmiLoopPort(number); - break; - } - case "dmcvidbnc": - { - var inputCard = new DmcVidBnc(number, Chassis); - AddInputPortWithDebug(number, "componentIn", eRoutingSignalType.Video, eRoutingPortConnectionType.Component, null, inputCard.VideoInput); - AddInputPortWithDebug(number, "audioIn", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio); - AddInCardHdmiLoopPort(number); - break; - } - case "dmcvidrcaa": - { - var inputCard = new DmcVidRcaA(number, Chassis); - AddInputPortWithDebug(number, "componentIn", eRoutingSignalType.Video, eRoutingPortConnectionType.Component, null, inputCard.VideoInput); - AddInputPortWithDebug(number, "audioIn", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio); - AddInCardHdmiLoopPort(number); - break; - } - case "dmcvidrcad": - { - var inputCard = new DmcVidRcaD(number, Chassis); - AddInputPortWithDebug(number, "componentIn", eRoutingSignalType.Video, eRoutingPortConnectionType.Component, null, inputCard.VideoInput); - AddInputPortWithDebug(number, "audioIn", eRoutingSignalType.Audio, eRoutingPortConnectionType.DigitalAudio); - AddInCardHdmiLoopPort(number); - break; - } - case "dmcvid4": - { - var inputCard = new DmcVid4(number, Chassis); - AddInputPortWithDebug(number, "compositeIn1", eRoutingSignalType.Video, eRoutingPortConnectionType.Composite); - AddInputPortWithDebug(number, "compositeIn2", eRoutingSignalType.Video, eRoutingPortConnectionType.Composite); - AddInputPortWithDebug(number, "compositeIn3", eRoutingSignalType.Video, eRoutingPortConnectionType.Composite); - AddInputPortWithDebug(number, "compositeIn4", eRoutingSignalType.Video, eRoutingPortConnectionType.Composite); - AddInCardHdmiLoopPort(number); - break; - } - case "dmcstr": - { - var inputCard = new DmcStr(number, Chassis); - AddInputPortWithDebug(number, "streamIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Streaming, null, inputCard.Source); - AddInCardHdmiAndAudioLoopPorts(number); - break; - } - } - } - - void AddDmInCardPorts(uint number) - { - AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat); - AddInCardHdmiAndAudioLoopPorts(number); - } - - void AddDmInCardPorts(uint number, ICec cecPort) - { - AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, cecPort); - AddInCardHdmiAndAudioLoopPorts(number); - } - - void AddDmInCardPorts(uint number, ICec cecPort, IVideoAttributesBasic videoAttributes) - { - AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, cecPort, videoAttributes); - AddInCardHdmiAndAudioLoopPorts(number); - } - - void AddHdmiInCardPorts(uint number, ICec cecPort) - { - AddInputPortWithDebug(number, "hdmiIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, cecPort); - AddInCardHdmiAndAudioLoopPorts(number); - } - - void AddHdmiInCardPorts(uint number, ICec cecPort, IVideoAttributesBasic videoAttributes) - { - AddInputPortWithDebug(number, "hdmiIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, cecPort, videoAttributes); - AddInCardHdmiAndAudioLoopPorts(number); - } - - void AddInCardHdmiAndAudioLoopPorts(uint number) - { - AddOutputPortWithDebug(string.Format("inputCard{0}", number), "hdmiLoopOut", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null); - AddOutputPortWithDebug(string.Format("inputCard{0}", number), "audioLoopOut", eRoutingSignalType.Audio, eRoutingPortConnectionType.Hdmi, null); - } - - void AddInCardHdmiLoopPort(uint number) - { - AddOutputPortWithDebug(string.Format("inputCard{0}", number), "hdmiLoopOut", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null); - } - - /// - /// - /// - /// - /// - public void AddOutputCard(string type, uint number) - { - type = type.ToLower(); - - Debug.Console(2, this, "Adding output card '{0}', slot {1}", type, number); - switch (type) - { - case "dmc4khdo": - { - var outputCard = new Dmc4kHdoSingle(number, Chassis); - var cecPort1 = outputCard.Card1.HdmiOutput; - var cecPort2 = outputCard.Card2.HdmiOutput; - AddDmcHdoPorts(number, cecPort1, cecPort2); - } - break; - case "dmc4kzhdo": - { - var outputCard = new Dmc4kzHdoSingle(number, Chassis); - var cecPort1 = outputCard.Card1.HdmiOutput; - var cecPort2 = outputCard.Card2.HdmiOutput; - AddDmcHdoPorts(number, cecPort1, cecPort2); - } - break; - case "dmchdo": - { - var outputCard = new DmcHdoSingle(number, Chassis); - var cecPort1 = outputCard.Card1.HdmiOutput; - var cecPort2 = outputCard.Card2.HdmiOutput; - AddDmcHdoPorts(number, cecPort1, cecPort2); - } - break; - case "dmc4kcohd": - { - var outputCard = new Dmc4kCoHdSingle(number, Chassis); - var cecPort1 = outputCard.Card1.HdmiOutput; - AddDmcCoPorts(number, cecPort1); - } - break; - case "dmc4kzcohd": - { - var outputCard = new Dmc4kzCoHdSingle(number, Chassis); - var cecPort1 = outputCard.Card1.HdmiOutput; - AddDmcCoPorts(number, cecPort1); - } - break; - case "dmccohd": - { - var outputCard = new DmcCoHdSingle(number, Chassis); - var cecPort1 = outputCard.Card1.HdmiOutput; - AddDmcCoPorts(number, cecPort1); - } - break; - case "dmccatohd": - { - var outputCard = new DmcCatoHdSingle(number, Chassis); - var cecPort1 = outputCard.Card1.HdmiOutput; - AddDmcCoPorts(number, cecPort1); - } - break; - case "dmcsohd": - { - var outputCard = new DmcSoHdSingle(number, Chassis); - var cecPort1 = outputCard.Card1.HdmiOutput; - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmMmFiber, Chassis.Outputs[2 * (number - 1) + 1]); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "hdmiOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, Chassis.Outputs[2 * (number - 1) + 1], cecPort1); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut2", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmMmFiber, Chassis.Outputs[2 * (number - 1) + 2]); - } - break; - case "dmcs2ohd": - { - var outputCard = new DmcS2oHdSingle(number, Chassis); - var cecPort1 = outputCard.Card1.HdmiOutput; - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmSmFiber, Chassis.Outputs[2 * (number - 1) + 1]); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "hdmiOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, Chassis.Outputs[2 * (number - 1) + 1], cecPort1); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut2", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmSmFiber, Chassis.Outputs[2 * (number - 1) + 2]); - } - break; - case "dmcstro": - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "streamOut", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Streaming, Chassis.Outputs[2 * (number - 1) + 1]); - break; - default: - Debug.Console(1, this, " WARNING: Output card type '{0}' is not available", type); - break; - } - } - - void AddDmcHdoPorts(uint number, ICec cecPort1, ICec cecPort2) - { - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "hdmiOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, Chassis.Outputs[2 * (number - 1) + 1], cecPort1); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "audioOut1", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio, - Chassis.Outputs[2 * (number - 1) + 1]); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "hdmiOut2", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, Chassis.Outputs[2 * (number - 1) + 2], cecPort2); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "audioOut2", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio, - Chassis.Outputs[2 * (number - 1) + 2]); - } - - void AddDmcCoPorts(uint number, ICec cecPort1) - { - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmCat, Chassis.Outputs[2 * (number - 1) + 1]); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "hdmiOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, Chassis.Outputs[2 * (number - 1) + 1], cecPort1); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut2", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmCat, Chassis.Outputs[2 * (number - 1) + 2]); - } - - /// - /// Adds InputPort - /// - void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType) - { - //Cast is necessary here to determine the correct overload - AddInputPortWithDebug(cardNum, portName, sigType, portType, null, null); - } - - private void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, - eRoutingPortConnectionType portType, ICec cecPort) - { - //Cast is necessary here to determine the correct overload - AddInputPortWithDebug(cardNum, portName, sigType, portType, cecPort, null); - } - - /// - /// Adds InputPort and sets Port as ICec object. If videoAttributesBasic is defined, RoutingPort will be RoutingInputPortWithVideoStatuses - /// - void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, ICec cecPort, IVideoAttributesBasic videoAttributesBasic) - { - var portKey = string.Format("inputCard{0}--{1}", cardNum, portName); - Debug.Console(2, this, "Adding input port '{0}'", portKey); - - RoutingInputPort inputPort; - - if (videoAttributesBasic != null) - { - Debug.Console(1, this, "card {0} supports IVideoAttributesBasic", cardNum); - var statusFuncs = new VideoStatusFuncsWrapper - { - VideoResolutionFeedbackFunc = () => - { - var resolution = videoAttributesBasic.VideoAttributes.GetVideoResolutionString(); - Debug.Console(1, this, "Updating resolution for input {0}. New resolution: {1}", cardNum, resolution); - return resolution; - } - }; - inputPort = new RoutingInputPortWithVideoStatuses(portKey, sigType, portType, - Chassis.Inputs[cardNum], this, statusFuncs) - { - FeedbackMatchObject = Chassis.Inputs[cardNum] - }; - - RegisterForInputResolutionFeedback(videoAttributesBasic, cardNum, inputPort as RoutingInputPortWithVideoStatuses); - } - else - { - inputPort = new RoutingInputPort(portKey, sigType, portType, - Chassis.Inputs[cardNum], this) - { - FeedbackMatchObject = Chassis.Inputs[cardNum] - }; - } - - if (cecPort != null) - inputPort.Port = cecPort; - - InputPorts.Add(inputPort); - } - - /// - /// Adds OutputPort - /// - void AddOutputPortWithDebug(string cardName, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, object selector) - { - AddOutputPortWithDebug(cardName, portName, sigType, portType, selector, null); - } - - /// - /// Adds OutputPort and sets Port as ICec object - /// - void AddOutputPortWithDebug(string cardName, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, object selector, ICec cecPort) - { - var portKey = string.Format("{0}--{1}", cardName, portName); - Debug.Console(2, this, "Adding output port '{0}'", portKey); - var outputPort = new RoutingOutputPort(portKey, sigType, portType, selector, this); - - if (portName.IndexOf("Loop", StringComparison.InvariantCultureIgnoreCase) < 0) - { - outputPort.FeedbackMatchObject = selector; - } - if (cecPort != null) - outputPort.Port = cecPort; - - OutputPorts.Add(outputPort); - } - - /// - /// - /// - void AddVolumeControl(uint number, Audio.Output audio) - { - VolumeControls.Add(number, new DmCardAudioOutputController(audio)); - } - - //public void SetInputHdcpSupport(uint input, ePdtHdcpSupport hdcpSetting) - //{ - - //} - - void Chassis_DMSystemChange(Switch device, DMSystemEventArgs args) - { - switch (args.EventId) - { - case DMSystemEventIds.SystemIdEventId: - { - Debug.Console(2, this, "SystemIdEvent Value: {0}", (Chassis as DmMDMnxn).SystemIdFeedback.UShortValue); - SystemIdFeebdack.FireUpdate(); - break; - } - case DMSystemEventIds.SystemIdBusyEventId: - { - Debug.Console(2, this, "SystemIdBusyEvent State: {0}", (Chassis as DmMDMnxn).SystemIdBusy.BoolValue); - SystemIdBusyFeedback.FireUpdate(); - break; - } - case DMSystemEventIds.AudioBreakawayEventId: - { - Debug.Console(2, this, "AudioBreakaway Event: value: {0}", - (Chassis as DmMDMnxn).EnableAudioBreakawayFeedback.BoolValue); - EnableAudioBreakawayFeedback.FireUpdate(); - break; - } - case DMSystemEventIds.USBBreakawayEventId: - { - Debug.Console(2, this, "USBBreakaway Event: value: {0}", - (Chassis as DmMDMnxn).EnableUSBBreakawayFeedback.BoolValue); - EnableUsbBreakawayFeedback.FireUpdate(); - break; - } - } - } - - void Chassis_DMInputChange(Switch device, DMInputEventArgs args) - { - try - { - switch (args.EventId) - { - case DMInputEventIds.EndpointOnlineEventId: - { - Debug.Console(2, this, "DM Input EndpointOnlineEventId for input: {0}. State: {1}", args.Number, device.Inputs[args.Number].EndpointOnlineFeedback); - InputEndpointOnlineFeedbacks[args.Number].FireUpdate(); - break; - } - case DMInputEventIds.OnlineFeedbackEventId: - { - Debug.Console(2, this, "DM Input OnlineFeedbackEventId for input: {0}. State: {1}", args.Number, device.Inputs[args.Number].EndpointOnlineFeedback); - InputEndpointOnlineFeedbacks[args.Number].FireUpdate(); - break; - } - case DMInputEventIds.VideoDetectedEventId: - { - Debug.Console(2, this, "DM Input {0} VideoDetectedEventId", args.Number); - VideoInputSyncFeedbacks[args.Number].FireUpdate(); - break; - } - case DMInputEventIds.InputNameEventId: - { - Debug.Console(2, this, "DM Input {0} NameFeedbackEventId", args.Number); - InputNameFeedbacks[args.Number].FireUpdate(); - break; - } - case DMInputEventIds.UsbRoutedToEventId: - { - Debug.Console(2, this, "DM Input {0} UsbRoutedToEventId", args.Number); - if (UsbInputRoutedToFeebacks[args.Number] != null) - UsbInputRoutedToFeebacks[args.Number].FireUpdate(); - else - Debug.Console(1, this, "No index of {0} found in UsbInputRoutedToFeedbacks"); - break; - } - case DMInputEventIds.HdcpCapabilityFeedbackEventId: - { - Debug.Console(2, this, "DM Input {0} HdcpCapabilityFeedbackEventId", args.Number); - if (InputCardHdcpStateFeedbacks[args.Number] != null) - InputCardHdcpStateFeedbacks[args.Number].FireUpdate(); - else - Debug.Console(1, this, "No index of {0} found in InputCardHdcpCapabilityFeedbacks"); - break; - } - case DMInputEventIds.HdcpSupportOffEventId: - { - Debug.Console(2, this, "DM Input {0} HdcpSupportOffEventId", args.Number); - if (InputCardHdcpStateFeedbacks[args.Number] != null) - InputCardHdcpStateFeedbacks[args.Number].FireUpdate(); - else - Debug.Console(1, this, "No index of {0} found in InputCardHdcpCapabilityFeedbacks"); - break; - } - case DMInputEventIds.HdcpSupportOnEventId: - { - Debug.Console(2, this, "DM Input {0} HdcpSupportOnEventId", args.Number); - if (InputCardHdcpStateFeedbacks[args.Number] != null) - InputCardHdcpStateFeedbacks[args.Number].FireUpdate(); - else - Debug.Console(1, this, "No index of {0} found in InputCardHdcpCapabilityFeedbacks"); - break; - } - case DMInputEventIds.StartEventId: - case DMInputEventIds.StopEventId: - case DMInputEventIds.PauseEventId: - { - Debug.Console(2, this, "DM Input {0} Stream Status EventId", args.Number); - if (InputStreamCardStateFeedbacks[args.Number] != null) - { - InputStreamCardStateFeedbacks[args.Number].FireUpdate(); - } - else - Debug.Console(2, this, "No index of {0} found in InputStreamCardStateFeedbacks"); - break; - } - case DMInputEventIds.HorizontalResolutionFeedbackEventId: - case DMInputEventIds.VerticalResolutionFeedbackEventId: - case DMInputEventIds.FramesPerSecondFeedbackEventId: - case DMInputEventIds.ResolutionEventId: - { - Debug.Console(1, this, "Input {0} resolution updated", args.Number); - var inputPort = - InputPorts.Cast() - .FirstOrDefault((ip) => ip.Key.Contains(String.Format("inputCard{0}", args.Number))); - - if (inputPort != null) - { - Debug.Console(1, this, "Updating resolution feedback for input {0}", args.Number); - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - } - break; - } - default: - { - Debug.Console(2, this, "DMInputChange fired for Input {0} with Unhandled EventId: {1}", args.Number, args.EventId); - break; - } - } - } - catch (Exception ex) - { - Debug.Console(2, this, Debug.ErrorLogLevel.Error, "Error in Chassis_DMInputChange: {0}", ex); - } - } - - /// - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - - /// - /// - void Chassis_DMOutputChange(Switch device, DMOutputEventArgs args) - { - var output = args.Number; - - switch (args.EventId) - { - case DMOutputEventIds.VolumeEventId: - { - if (VolumeControls.ContainsKey(output)) - { - VolumeControls[args.Number].VolumeEventFromChassis(); - } - - break; - } - case DMOutputEventIds.EndpointOnlineEventId: - { - Debug.Console(2, this, "Output {0} DMOutputEventIds.EndpointOnlineEventId fired. State: {1}", args.Number, - Chassis.Outputs[output].EndpointOnlineFeedback); - OutputEndpointOnlineFeedbacks[output].FireUpdate(); - break; - } - case DMOutputEventIds.OnlineFeedbackEventId: - { - Debug.Console(2, this, "Output {0} DMInputEventIds.OnlineFeedbackEventId fired. State: {1}", args.Number, - Chassis.Outputs[output].EndpointOnlineFeedback); - OutputEndpointOnlineFeedbacks[output].FireUpdate(); - break; - } - case DMOutputEventIds.VideoOutEventId: - { - - var inputNumber = Chassis.Outputs[output].VideoOutFeedback == null ? 0 : Chassis. - Outputs[output].VideoOutFeedback.Number; - - Debug.Console(2, this, "DMSwitchVideo:{0} Routed Input:{1} Output:{2}'", Name, inputNumber, output); - - if (VideoOutputFeedbacks.ContainsKey(output)) - { - var localInputPort = InputPorts.FirstOrDefault(p => (DMInput)p.FeedbackMatchObject == Chassis.Outputs[output].VideoOutFeedback); - var localOutputPort = - OutputPorts.FirstOrDefault(p => (DMOutput) p.FeedbackMatchObject == Chassis.Outputs[output]); - - - VideoOutputFeedbacks[output].FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(output, - inputNumber, - localOutputPort, - localInputPort, - eRoutingSignalType.Video)); - } - - if (OutputVideoRouteNameFeedbacks.ContainsKey(output)) - OutputVideoRouteNameFeedbacks[output].FireUpdate(); - - break; - } - case DMOutputEventIds.AudioOutEventId: - { - var inputNumber = Chassis.Outputs[output].AudioOutFeedback == null ? 0 : Chassis. - Outputs[output].AudioOutFeedback.Number; - - Debug.Console(2, this, "DMSwitchAudio:{0} Routed Input:{1} Output:{2}'", Name, inputNumber, output); - - if (AudioOutputFeedbacks.ContainsKey(output)) - { - var localInputPort = InputPorts.FirstOrDefault(p => (DMInput)p.FeedbackMatchObject == Chassis.Outputs[output].AudioOutFeedback); - var localOutputPort = - OutputPorts.FirstOrDefault(p => (DMOutput)p.FeedbackMatchObject == Chassis.Outputs[output]); - - - AudioOutputFeedbacks[output].FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(output, - inputNumber, - localOutputPort, - localInputPort, - eRoutingSignalType.Audio)); - } - - if (OutputAudioRouteNameFeedbacks.ContainsKey(output)) - OutputAudioRouteNameFeedbacks[output].FireUpdate(); - - break; - } - case DMOutputEventIds.OutputNameEventId: - { - Debug.Console(2, this, "DM Output {0} NameFeedbackEventId", output); - OutputNameFeedbacks[output].FireUpdate(); - break; - } - case DMOutputEventIds.UsbRoutedToEventId: - { - Debug.Console(2, this, "DM Output {0} UsbRoutedToEventId", args.Number); - UsbOutputRoutedToFeebacks[args.Number].FireUpdate(); - break; - } - case DMOutputEventIds.DisabledByHdcpEventId: - { - Debug.Console(2, this, "DM Output {0} DisabledByHdcpEventId", args.Number); - OutputDisabledByHdcpFeedbacks[args.Number].FireUpdate(); - break; - } - case DMOutputEventIds.StartEventId: - case DMOutputEventIds.StopEventId: - case DMOutputEventIds.PauseEventId: - { - Debug.Console(2, this, "DM Output {0} Stream Status EventId", args.Number); - if (OutputStreamCardStateFeedbacks[args.Number] != null) - { - OutputStreamCardStateFeedbacks[args.Number].FireUpdate(); - } - else - Debug.Console(2, this, "No index of {0} found in OutputStreamCardStateFeedbacks"); - break; - } - default: - { - Debug.Console(2, this, "DMOutputChange fired for Output {0} with Unhandled EventId: {1}", args.Number, args.EventId); - break; - } - } - } - - /// - /// - /// - /// - void StartOffTimer(PortNumberType pnt) - { - if (RouteOffTimers.ContainsKey(pnt)) - return; - RouteOffTimers[pnt] = new CTimer(o => ExecuteSwitch(null, pnt.Selector, pnt.Type), RouteOffTime); - } - - // Send out sigs when coming online - void IsOnline_OutputChange(object sender, EventArgs e) - { - if (IsOnline.BoolValue) - { - (Chassis as DmMDMnxn).EnableAudioBreakaway.BoolValue = true; - (Chassis as DmMDMnxn).EnableUSBBreakaway.BoolValue = true; - - - EnableAudioBreakawayFeedback.FireUpdate(); - EnableUsbBreakawayFeedback.FireUpdate(); - - if (InputNames != null) - foreach (var kvp in InputNames) - Chassis.Inputs[kvp.Key].Name.StringValue = kvp.Value; - if (OutputNames != null) - foreach (var kvp in OutputNames) - Chassis.Outputs[kvp.Key].Name.StringValue = kvp.Value; - } - } - - #region IRouting Members - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType sigType) - { - Debug.Console(2, this, "Making an awesome DM route from {0} to {1} {2}", inputSelector, outputSelector, sigType); - - var input = inputSelector as DMInput;//Input Selector could be null... - - var output = outputSelector as DMOutput; - - var isUsbInput = (sigType & eRoutingSignalType.UsbInput) == eRoutingSignalType.UsbInput; - var isUsbOutput = (sigType & eRoutingSignalType.UsbOutput) == eRoutingSignalType.UsbOutput; - - if (output == null && !(isUsbOutput || isUsbInput)) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Warning, - "Unable to execute switch for inputSelector {0} to outputSelector {1}", inputSelector, - outputSelector); - return; - } - - // Check to see if there's an off timer waiting on this and if so, cancel - var key = new PortNumberType(output, sigType); - if (input == null) - { - StartOffTimer(key); - } - else - { - if (RouteOffTimers.ContainsKey(key)) - { - Debug.Console(2, this, "{0} cancelling route off due to new source", output); - RouteOffTimers[key].Stop(); - RouteOffTimers.Remove(key); - } - } - - //var inCard = input == 0 ? null : Chassis.Inputs[input]; - //var outCard = input == 0 ? null : Chassis.Outputs[output]; - - // NOTE THAT BITWISE COMPARISONS - TO CATCH ALL ROUTING TYPES - if ((sigType & eRoutingSignalType.Video) == eRoutingSignalType.Video) - { - Chassis.VideoEnter.BoolValue = true; - if (output != null) - { - output.VideoOut = input; //Chassis.Outputs[output].VideoOut = inCard; - } - } - - if ((sigType & eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - { - var dmMdMnxn = Chassis as DmMDMnxn; - if (dmMdMnxn != null) - { - dmMdMnxn.AudioEnter.BoolValue = true; - } - if (output != null) - { - output.AudioOut = input; - } - } - - if ((sigType & eRoutingSignalType.UsbOutput) == eRoutingSignalType.UsbOutput) - - { - Chassis.USBEnter.BoolValue = true; - if (inputSelector == null && output != null) - { - //clearing the route is intended - output.USBRoutedTo = null; - return; - } - - if (inputSelector != null && input == null) - { - //input selector is DMOutput...we're doing a out to out route - var tempInput = inputSelector as DMOutput; - - if (tempInput == null || output == null) - { - return; - } - output.USBRoutedTo = tempInput; - return; - } - - if (input != null & output != null) - { - output.USBRoutedTo = input; - } - } - - if((sigType & eRoutingSignalType.UsbInput) != eRoutingSignalType.UsbInput) - { - return; - } - - Chassis.USBEnter.BoolValue = true; - if (output != null) - { - output.USBRoutedTo = input; - return; - } - var tempOutput = outputSelector as DMInput; - - if (tempOutput == null) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Warning, - "Unable to execute switch for inputSelector {0} to outputSelector {1}", inputSelector, - outputSelector); - return; - } - - tempOutput.USBRoutedTo = input; - } - - #endregion - - #region IRoutingNumeric Members - - public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType sigType) - { - var chassisSize = (uint)Chassis.NumberOfInputs; //need this to determine USB routing values 8x8 -> 1-8 is inputs 1-8, 17-24 is outputs 1-8 - //16x16 1-16 is inputs 1-16, 17-32 is outputs 1-16 - //32x32 1-32 is inputs 1-32, 33-64 is outputs 1-32 - - DMInputOutputBase dmCard; - - //Routing Input to Input or Output to Input - if ((sigType & eRoutingSignalType.UsbInput) == eRoutingSignalType.UsbInput) - { - Debug.Console(2, this, "Executing USB Input switch.\r\n in:{0} output: {1}", inputSelector, outputSelector); - if (outputSelector > chassisSize) - { - uint outputIndex; - - if (chassisSize == 8) - { - outputIndex = (uint) inputSelector - 16; - } - else - { - outputIndex = inputSelector - chassisSize; - } - dmCard = Chassis.Outputs[outputIndex]; - } - else - { - dmCard = Chassis.Inputs[inputSelector]; - } - - ExecuteSwitch(dmCard, Chassis.Inputs[outputSelector], sigType); - return; - } - if ((sigType & eRoutingSignalType.UsbOutput) == eRoutingSignalType.UsbOutput) - { - Debug.Console(2, this, "Executing USB Output switch.\r\n in:{0} output: {1}", inputSelector, outputSelector); - - //routing Output to Output or Input to Output - if (inputSelector > chassisSize) - { - //wanting to route an output to an output. Subtract chassis size and get output, unless it's 8x8 - //need this to determine USB routing values - //8x8 -> 1-8 is inputs 1-8, 17-24 is outputs 1-8 - //16x16 1-16 is inputs 1-16, 17-32 is outputs 1-16 - //32x32 1-32 is inputs 1-32, 33-64 is outputs 1-32 - uint outputIndex; - - if (chassisSize == 8) - { - outputIndex = (uint) inputSelector - 16; - } - else - { - outputIndex = inputSelector - chassisSize; - } - - dmCard = Chassis.Outputs[outputIndex]; - } - else - { - dmCard = Chassis.Inputs[inputSelector]; - } - Chassis.USBEnter.BoolValue = true; - - Debug.Console(2, this, "Routing USB for input {0} to {1}", inputSelector, dmCard); - ExecuteSwitch(dmCard, Chassis.Outputs[outputSelector], sigType); - return; - } - - var inputCard = inputSelector == 0 ? null : Chassis.Inputs[inputSelector]; - var outputCard = Chassis.Outputs[outputSelector]; - - ExecuteSwitch(inputCard, outputCard, sigType); - } - - #endregion - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = GetJoinMap(joinStart, joinMapKey, bridge); - - Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - LinkChassisToApi(trilist, joinMap); - - trilist.StringInput[joinMap.Name.JoinNumber].StringValue = this.Name; - - // Link up inputs & outputs - for (uint i = 1; i <= Chassis.NumberOfOutputs; i++) - { - var ioSlot = i; - var ioSlotJoin = ioSlot - 1; - - LinkRoutingJoinsToApi(trilist, joinMap, ioSlotJoin, ioSlot); - - if (TxDictionary.ContainsKey(ioSlot)) - { - LinkTxToApi(trilist, ioSlot, joinMap, ioSlotJoin); - } - else - { - LinkHdmiInputToApi(trilist, ioSlot, joinMap, ioSlotJoin); - LinkStreamInputToApi(trilist, ioSlot, joinMap, ioSlotJoin); - } - - if (RxDictionary.ContainsKey(ioSlot)) - { - LinkRxToApi(trilist, ioSlot, joinMap, ioSlotJoin); - } - else - LinkStreamOutputToApi(trilist, ioSlot, joinMap, ioSlotJoin); - } - } - - private void LinkHdmiInputToApi(BasicTriList trilist, uint ioSlot, DmChassisControllerJoinMap joinMap, uint ioSlotJoin) - { - VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus.JoinNumber + ioSlotJoin]); - - var inputPort = InputPorts[string.Format("inputCard{0}--hdmiIn", ioSlot)]; - if (inputPort == null) - { - return; - } - - Debug.Console(1, "Port value for input card {0} is set", ioSlot); - var port = inputPort.Port; - - if (port == null) - { - return; - } - if (!(port is HdmiInputWithCEC)) - { - Debug.Console(0, this, "HDMI Input port on card {0} does not support HDCP settings.", ioSlot); - return; - } - - Debug.Console(1, "Port is HdmiInputWithCec"); - - var hdmiInPortWCec = port as HdmiInputWithCEC; - - - SetHdcpStateAction(PropertiesConfig.InputSlotSupportsHdcp2[ioSlot], hdmiInPortWCec, joinMap.HdcpSupportState.JoinNumber + ioSlotJoin, trilist); - - - InputCardHdcpStateFeedbacks[ioSlot].LinkInputSig( - trilist.UShortInput[joinMap.HdcpSupportState.JoinNumber + ioSlotJoin]); - - if (InputCardHdcpCapabilityTypes.ContainsKey(ioSlot)) - { - trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = - (ushort)InputCardHdcpCapabilityTypes[ioSlot]; - } - else - { - trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = 1; - } - - var videoStatus = inputPort as RoutingInputPortWithVideoStatuses; - - if (videoStatus == null) - { - return; - } - - Debug.Console(1, this, "Linking {0} to join {1} for resolution feedback.", videoStatus.Key, joinMap.InputCurrentResolution.JoinNumber + ioSlotJoin); - videoStatus.VideoStatus.VideoResolutionFeedback.LinkInputSig(trilist.StringInput[joinMap.InputCurrentResolution.JoinNumber + ioSlotJoin]); - } - - private void LinkStreamInputToApi(BasicTriList trilist, uint ioSlot, DmChassisControllerJoinMap joinMap, uint ioSlotJoin) - { - var inputPort = InputPorts[string.Format("inputCard{0}--streamIn", ioSlot)]; - if (inputPort == null) - { - return; - } - var streamCard = Chassis.Inputs[ioSlot].Card as DmcStr; - var join = joinMap.InputStreamCardState.JoinNumber + ioSlotJoin; - - Debug.Console(1, "Port value for input card {0} is set as a stream card", ioSlot); - - trilist.SetUShortSigAction(join, s => - { - if (s == 1) - { - Debug.Console(2, this, "Join {0} value {1}: Setting stream state to start", join, s); - streamCard.Control.Start(); - } - else if (s == 2) - { - Debug.Console(2, this, "Join {0} value {1}: Setting stream state to stop", join, s); - streamCard.Control.Stop(); - } - else if (s == 3) - { - Debug.Console(2, this, "Join {0} value {1}: Setting stream state to pause", join, s); - streamCard.Control.Pause(); - } - else - { - Debug.Console(2, this, "Join {0} value {1}: Ignore stream state", join, s); - } - }); - - InputStreamCardStateFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[join]); - - trilist.UShortInput[join].UShortValue = InputStreamCardStateFeedbacks[ioSlot].UShortValue; - - var videoStatus = inputPort as RoutingInputPortWithVideoStatuses; - - if (videoStatus != null) - { - videoStatus.VideoStatus.VideoResolutionFeedback.LinkInputSig(trilist.StringInput[joinMap.InputCurrentResolution.JoinNumber + ioSlotJoin]); - } - } - - private void LinkStreamOutputToApi(BasicTriList trilist, uint ioSlot, DmChassisControllerJoinMap joinMap, uint ioSlotJoin) - { - var outputPort = OutputPorts[string.Format("outputCard{0}--streamOut", ioSlot)]; - if (outputPort == null) - { - return; - } - var streamCard = Chassis.Outputs[ioSlot].Card as DmcStroAV; - var join = joinMap.OutputStreamCardState.JoinNumber + ioSlotJoin; - - Debug.Console(1, "Port value for output card {0} is set as a stream card", ioSlot); - - trilist.SetUShortSigAction(join, s => - { - if (s == 1) - { - Debug.Console(2, this, "Join {0} value {1}: Setting stream state to start", join, s); - streamCard.Control.Start(); - } - else if (s == 2) - { - Debug.Console(2, this, "Join {0} value {1}: Setting stream state to stop", join, s); - streamCard.Control.Stop(); - } - else if (s == 3) - { - Debug.Console(2, this, "Join {0} value {1}: Setting stream state to pause", join, s); - streamCard.Control.Pause(); - } - else - { - Debug.Console(2, this, "Join {0} value {1}: Ignore stream state", join, s); - } - }); - - OutputStreamCardStateFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[join]); - - trilist.UShortInput[join].UShortValue = OutputStreamCardStateFeedbacks[ioSlot].UShortValue; - } - - private void LinkRxToApi(BasicTriList trilist, uint ioSlot, DmChassisControllerJoinMap joinMap, uint ioSlotJoin) - { - Debug.Console(2, "Creating Rx Feedbacks {0}", ioSlot); - var rxKey = RxDictionary[ioSlot]; - var rxDevice = DeviceManager.GetDeviceForKey(rxKey) as DmRmcControllerBase; - var hdBaseTDevice = DeviceManager.GetDeviceForKey(rxKey) as DmHdBaseTControllerBase; - if (Chassis is DmMd8x8Cpu3 || Chassis is DmMd8x8Cpu3rps - || Chassis is DmMd16x16Cpu3 || Chassis is DmMd16x16Cpu3rps - || Chassis is DmMd32x32Cpu3 || Chassis is DmMd32x32Cpu3rps || hdBaseTDevice != null) - { - OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig( - trilist.BooleanInput[joinMap.OutputEndpointOnline.JoinNumber + ioSlotJoin]); - } - else if (rxDevice != null) - { - rxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline.JoinNumber + ioSlotJoin]); - } - } - - private void LinkTxToApi(BasicTriList trilist, uint ioSlot, DmChassisControllerJoinMap joinMap, uint ioSlotJoin) - { - Debug.Console(1, "Setting up actions and feedbacks on input card {0}", ioSlot); - VideoInputSyncFeedbacks[ioSlot].LinkInputSig( - trilist.BooleanInput[joinMap.VideoSyncStatus.JoinNumber + ioSlotJoin]); - - Debug.Console(2, "Creating Tx Feedbacks {0}", ioSlot); - var txKey = TxDictionary[ioSlot]; - var txDevice = DeviceManager.GetDeviceForKey(txKey) as BasicDmTxControllerBase; - - if (txDevice == null) - { - return; - } - - LinkTxOnlineFeedbackToApi(trilist, ioSlot, joinMap, ioSlotJoin, txDevice); - - LinkBasicTxToApi(trilist, joinMap, ioSlot, ioSlotJoin, txDevice); - - LinkAdvancedTxToApi(trilist, joinMap, ioSlot, ioSlotJoin, txDevice); - } - - private void LinkBasicTxToApi(BasicTriList trilist, DmChassisControllerJoinMap joinMap, uint ioSlot, - uint ioSlotJoin, BasicDmTxControllerBase basicTransmitter) - { - var advTx = basicTransmitter as DmTxControllerBase; - - if (advTx != null) - { - return; - } - var inputPort = InputPorts[string.Format("inputCard{0}--dmIn", ioSlot)]; - - if (inputPort == null) - { - return; - } - var port = inputPort.Port; - - if (!(port is DMInputPortWithCec)) - { - Debug.Console(0, this, "DM Input port on card {0} does not support HDCP settings.", ioSlot); - return; - } - Debug.Console(1, "Port is DMInputPortWithCec"); - - var dmInPortWCec = port as DMInputPortWithCec; - - bool supportsHdcp2; - - //added in case the InputSlotSupportsHdcp2 section isn't included in the config, or this slot is left out. - //if the key isn't in the dictionary, supportsHdcp2 will be false - - if(!PropertiesConfig.InputSlotSupportsHdcp2.TryGetValue(ioSlot, out supportsHdcp2)) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Warning, - "Input Slot Supports HDCP2 setting not found for slot {0}. Setting to false. Program may not function as intended.", - ioSlot); - } - - SetHdcpStateAction(supportsHdcp2, dmInPortWCec, - joinMap.HdcpSupportState.JoinNumber + ioSlotJoin, trilist); - - InputCardHdcpStateFeedbacks[ioSlot].LinkInputSig( - trilist.UShortInput[joinMap.HdcpSupportState.JoinNumber + ioSlotJoin]); - - if (InputCardHdcpCapabilityTypes.ContainsKey(ioSlot)) - { - trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = - (ushort) InputCardHdcpCapabilityTypes[ioSlot]; - } - else - { - trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = 1; - } - - var videoStatus = inputPort as RoutingInputPortWithVideoStatuses; - - if (videoStatus == null) - { - return; - } - Debug.Console(1, this, "Linking {0} to join {1} for resolution feedback.", videoStatus.Key, joinMap.InputCurrentResolution.JoinNumber + ioSlotJoin); - videoStatus.VideoStatus.VideoResolutionFeedback.LinkInputSig(trilist.StringInput[joinMap.InputCurrentResolution.JoinNumber + ioSlotJoin]); - } - - private void LinkAdvancedTxToApi(BasicTriList trilist, DmChassisControllerJoinMap joinMap, - uint ioSlot, uint ioSlotJoin, BasicDmTxControllerBase basicTransmitter) - { - var transmitter = basicTransmitter as DmTxControllerBase; - if (transmitter == null) return; - - trilist.BooleanInput[joinMap.TxAdvancedIsPresent.JoinNumber + ioSlotJoin].BoolValue = true; - - transmitter.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig( - trilist.BooleanInput[joinMap.VideoSyncStatus.JoinNumber + ioSlotJoin]); - - var txRoutingInputs = transmitter as IRoutingInputs; - - if (txRoutingInputs == null) return; - - var inputPorts = - txRoutingInputs.InputPorts.Where( - (p) => p.Port is EndpointHdmiInput || p.Port is EndpointDisplayPortInput).ToList(); - - if (inputPorts.Count == 0) - { - Debug.Console(1, this, "No HDCP-capable input ports found on transmitter for slot {0}", ioSlot); - return; - } - - bool supportsHdcp2; - - if (!PropertiesConfig.InputSlotSupportsHdcp2.TryGetValue(ioSlot, out supportsHdcp2)) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Warning, - "Input Slot Supports HDCP2 setting not found for slot {0}. Setting to false. Program may not function as intended.", - ioSlot); - } - - SetHdcpStateAction(supportsHdcp2, inputPorts, joinMap.HdcpSupportState.JoinNumber + ioSlotJoin, trilist); - - if (transmitter.HdcpStateFeedback != null) - { - transmitter.HdcpStateFeedback.LinkInputSig( - trilist.UShortInput[joinMap.HdcpSupportState.JoinNumber + ioSlotJoin]); - } - else - { - Debug.Console(2, this, "Transmitter Hdcp Feedback null. Linking to card's feedback"); - InputCardHdcpStateFeedbacks[ioSlot].LinkInputSig( - trilist.UShortInput[joinMap.HdcpSupportState.JoinNumber + ioSlotJoin]); - } - - trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = - (ushort) transmitter.HdcpSupportCapability; - - - var videoStatus = - InputPorts[string.Format("inputCard{0}--dmIn", ioSlot)] as RoutingInputPortWithVideoStatuses; - - if (videoStatus == null) - { - return; - } - Debug.Console(1, this, "Linking {0} to join {1} for resolution feedback.", videoStatus.Key, - joinMap.InputCurrentResolution.JoinNumber + ioSlotJoin); - videoStatus.VideoStatus.VideoResolutionFeedback.LinkInputSig( - trilist.StringInput[joinMap.InputCurrentResolution.JoinNumber + ioSlotJoin]); - } - - private void LinkTxOnlineFeedbackToApi(BasicTriList trilist, uint ioSlot, DmChassisControllerJoinMap joinMap, - uint ioSlotJoin, BasicDmTxControllerBase txDevice) - { - var advancedTxDevice = txDevice as DmTxControllerBase; - - if ((Chassis is DmMd8x8Cpu3 || Chassis is DmMd8x8Cpu3rps - || Chassis is DmMd16x16Cpu3 || Chassis is DmMd16x16Cpu3rps - || Chassis is DmMd32x32Cpu3 || Chassis is DmMd32x32Cpu3rps) || - advancedTxDevice == null) - { - Debug.Console(2, "Linking Tx Online Feedback from Input Card {0}", ioSlot); - InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig( - trilist.BooleanInput[joinMap.InputEndpointOnline.JoinNumber + ioSlotJoin]); - return; - } - - Debug.Console(2, "Linking Tx Online Feedback from Advanced Transmitter at input {0}", ioSlot); - - advancedTxDevice.IsOnline.LinkInputSig( - trilist.BooleanInput[joinMap.InputEndpointOnline.JoinNumber + ioSlotJoin]); - } - - private void LinkRoutingJoinsToApi(BasicTriList trilist, DmChassisControllerJoinMap joinMap, uint ioSlotJoin, - uint ioSlot) - { - // Routing Control - trilist.SetUShortSigAction(joinMap.OutputVideo.JoinNumber + ioSlotJoin, - o => ExecuteNumericSwitch(o, (ushort) ioSlot, eRoutingSignalType.Video)); - trilist.SetUShortSigAction(joinMap.OutputAudio.JoinNumber + ioSlotJoin, - o => ExecuteNumericSwitch(o, (ushort) ioSlot, eRoutingSignalType.Audio)); - trilist.SetUShortSigAction(joinMap.OutputUsb.JoinNumber + ioSlotJoin, - o => ExecuteNumericSwitch(o, (ushort) ioSlot, eRoutingSignalType.UsbOutput)); - trilist.SetUShortSigAction(joinMap.InputUsb.JoinNumber + ioSlotJoin, - o => ExecuteNumericSwitch(o, (ushort) ioSlot, eRoutingSignalType.UsbInput)); - - //Routing Feedbacks - VideoOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputVideo.JoinNumber + ioSlotJoin]); - AudioOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputAudio.JoinNumber + ioSlotJoin]); - UsbOutputRoutedToFeebacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputUsb.JoinNumber + ioSlotJoin]); - UsbInputRoutedToFeebacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.InputUsb.JoinNumber + ioSlotJoin]); - - OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames.JoinNumber + ioSlotJoin]); - InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames.JoinNumber + ioSlotJoin]); - OutputVideoRouteNameFeedbacks[ioSlot].LinkInputSig( - trilist.StringInput[joinMap.OutputCurrentVideoInputNames.JoinNumber + ioSlotJoin]); - OutputAudioRouteNameFeedbacks[ioSlot].LinkInputSig( - trilist.StringInput[joinMap.OutputCurrentAudioInputNames.JoinNumber + ioSlotJoin]); - - OutputDisabledByHdcpFeedbacks[ioSlot].LinkInputSig( - trilist.BooleanInput[joinMap.OutputDisabledByHdcp.JoinNumber + ioSlotJoin]); - } - - private void LinkChassisToApi(BasicTriList trilist, DmChassisControllerJoinMap joinMap) - { - var chassis = Chassis as DmMDMnxn; - - IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - - trilist.SetUShortSigAction(joinMap.SystemId.JoinNumber, o => - { - if (chassis != null) - { - chassis.SystemId.UShortValue = o; - } - }); - - trilist.SetSigTrueAction(joinMap.SystemId.JoinNumber, () => - { - if (chassis != null) - { - chassis.ApplySystemId(); - } - }); - - SystemIdFeebdack.LinkInputSig(trilist.UShortInput[joinMap.SystemId.JoinNumber]); - SystemIdBusyFeedback.LinkInputSig(trilist.BooleanInput[joinMap.SystemId.JoinNumber]); - - EnableAudioBreakawayFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableAudioBreakaway.JoinNumber]); - EnableUsbBreakawayFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableUsbBreakaway.JoinNumber]); - - trilist.SetString(joinMap.NoRouteName.JoinNumber, NoRouteText); - - trilist.OnlineStatusChange += (o, a) => - { - if (!a.DeviceOnLine) - { - return; - } - - EnableAudioBreakawayFeedback.FireUpdate(); - EnableUsbBreakawayFeedback.FireUpdate(); - SystemIdBusyFeedback.FireUpdate(); - SystemIdFeebdack.FireUpdate(); - - trilist.SetString(joinMap.NoRouteName.JoinNumber, NoRouteText); - }; - } - - private DmChassisControllerJoinMap GetJoinMap(uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new DmChassisControllerJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - { - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - } - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, - "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - return joinMap; - } - - private void SetHdcpStateAction(bool supportsHdcp2, HdmiInputWithCEC port, uint join, BasicTriList trilist) - { - if (!supportsHdcp2) - { - trilist.SetUShortSigAction(join, - s => - { - if (s == 0) - { - Debug.Console(2, this, "Join {0} value {1} Setting HdcpSupport to off", join, s); - port.HdcpSupportOff(); - } - else if (s > 0) - { - Debug.Console(2, this, "Join {0} value {1} Setting HdcpSupport to on", join, s); - port.HdcpSupportOn(); - } - }); - } - else - { - trilist.SetUShortSigAction(join, - u => - { - Debug.Console(2, this, "Join {0} value {1} Setting HdcpReceiveCapability to: {2}", join, u, (eHdcpCapabilityType)u); - port.HdcpReceiveCapability = (eHdcpCapabilityType)u; - }); - } - } - - private void SetHdcpStateAction(bool supportsHdcp2, EndpointHdmiInput port, uint join, BasicTriList trilist) - { - if (!supportsHdcp2) - { - trilist.SetUShortSigAction(join, - s => - { - if (s == 0) - { - Debug.Console(2, this, "Join {0} value {1} Setting HdcpSupport to off", join, s); - port.HdcpSupportOff(); - } - else if (s > 0) - { - Debug.Console(2, this, "Join {0} value {1} Setting HdcpSupport to on", join, s); - port.HdcpSupportOn(); - } - }); - } - else - { - trilist.SetUShortSigAction(join, - u => - { - Debug.Console(2, this, "Join {0} value {1} Setting HdcpReceiveCapability to: {2}", join, u, (eHdcpCapabilityType)u); - port.HdcpCapability = (eHdcpCapabilityType)u; - }); - } - } - - private void SetHdcpStateAction(bool supportsHdcp2, List ports, uint join, - BasicTriList triList) - { - if (!supportsHdcp2) - { - triList.SetUShortSigAction(join, a => - { - foreach (var tempPort in ports.Select(port => port.Port).OfType()) - { - if (a == 0) - { - tempPort.HdcpSupportOff(); - } - else if (a > 0) - { - tempPort.HdcpSupportOn(); - } - } - }); - } - else - { - triList.SetUShortSigAction(join, a => - { - foreach (var tempPort in ports.Select(port => port.Port).OfType()) - { - tempPort.HdcpCapability = (eHdcpCapabilityType) a; - } - }); - } - } - - private void SetHdcpStateAction(bool supportsHdcp2, DMInputPortWithCec port, uint join, BasicTriList trilist) - { - if (!supportsHdcp2) - { - trilist.SetUShortSigAction(join, - s => - { - if (s == 0) - { - port.HdcpSupportOff(); - } - else if (s > 0) - { - port.HdcpSupportOn(); - } - }); - } - else - { - trilist.SetUShortSigAction(join, - u => - { - port.HdcpReceiveCapability = (eHdcpCapabilityType)u; - }); - } - } - } - - public struct PortNumberType - { - public uint Number { get; private set; } - public object Selector { get; private set; } - public eRoutingSignalType Type { get; private set; } - - public PortNumberType(object selector, eRoutingSignalType type) - : this() - { - Selector = selector; - Type = type; - - if (Selector is DMOutput) - { - Number = (selector as DMOutput).Number; - } - else if (Selector is uint) - { - Number = (uint) selector; - } - } - } - - public class DmChassisControllerFactory : EssentialsDeviceFactory - { - public DmChassisControllerFactory() - { - TypeNames = new List() { "dmmd8x8", "dmmd8x8rps", "dmmd8x8cpu3", "dmmd8x8cpu3rps", - "dmmd16x16", "dmmd16x16rps", "dmmd16x16cpu3", "dmmd16x16cpu3rps", - "dmmd32x32", "dmmd32x32rps", "dmmd32x32cpu3", "dmmd32x32cpu3rps", - "dmmd64x64", "dmmd128x128" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - var type = dc.Type.ToLower(); - - Debug.Console(1, "Factory Attempting to create new DmChassisController Device"); - - if (type.StartsWith("dmmd8x") || type.StartsWith("dmmd16x") || type.StartsWith("dmmd32x")) - { - - var props = JsonConvert.DeserializeObject - (dc.Properties.ToString()); - return DmChassisController. - GetDmChassisController(dc.Key, dc.Name, type, props); - } - else if (type.StartsWith("dmmd128x") || type.StartsWith("dmmd64x")) - { - var props = JsonConvert.DeserializeObject - (dc.Properties.ToString()); - return DmBladeChassisController. - GetDmChassisController(dc.Key, dc.Name, type, props); - } - - return null; - } - } - +using System; +using System.Collections.Generic; +using System.Linq; +using Crestron.SimplSharp; +using Crestron.SimplSharp.Reflection; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Cards; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpProInternal; +using Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.DM.Config; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.DM +{ + /// + /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions + /// + /// + [Description("Wrapper class for all DM-MD chassis variants from 8x8 to 32x32")] + public class DmChassisController : CrestronGenericBridgeableBaseDevice, IDmSwitchWithEndpointOnlineFeedback, IRoutingNumericWithFeedback + { + private const string NonePortKey = "inputCard0--None"; + public DMChassisPropertiesConfig PropertiesConfig { get; set; } + + public Switch Chassis { get; private set; } + + //IroutingNumericEvent + public event EventHandler NumericSwitchChange; + + // Feedbacks for EssentialDM + public Dictionary VideoOutputFeedbacks { get; private set; } + public Dictionary AudioOutputFeedbacks { get; private set; } + public Dictionary VideoInputSyncFeedbacks { get; private set; } + public Dictionary InputEndpointOnlineFeedbacks { get; private set; } + public Dictionary OutputEndpointOnlineFeedbacks { get; private set; } + public Dictionary InputNameFeedbacks { get; private set; } + public Dictionary OutputNameFeedbacks { get; private set; } + public Dictionary OutputVideoRouteNameFeedbacks { get; private set; } + public Dictionary OutputAudioRouteNameFeedbacks { get; private set; } + public Dictionary UsbOutputRoutedToFeebacks { get; private set; } + public Dictionary UsbInputRoutedToFeebacks { get; private set; } + public Dictionary OutputDisabledByHdcpFeedbacks { get; private set; } + + public IntFeedback SystemIdFeebdack { get; private set; } + public BoolFeedback SystemIdBusyFeedback { get; private set; } + public BoolFeedback EnableAudioBreakawayFeedback { get; private set; } + public BoolFeedback EnableUsbBreakawayFeedback { get; private set; } + + public Dictionary InputCardHdcpStateFeedbacks { get; private set; } + public Dictionary InputStreamCardStateFeedbacks { get; private set; } + public Dictionary OutputStreamCardStateFeedbacks { get; private set; } + + public Dictionary InputCardHdcpCapabilityTypes { get; private set; } + + // Need a couple Lists of generic Backplane ports + public RoutingPortCollection InputPorts { get; private set; } + public RoutingPortCollection OutputPorts { get; private set; } + + public Dictionary TxDictionary { get; set; } + public Dictionary RxDictionary { get; set; } + + //public Dictionary InputCards { get; private set; } + //public Dictionary OutputCards { get; private set; } + + public Dictionary InputNames { get; set; } + public Dictionary OutputNames { get; set; } + public Dictionary VolumeControls { get; private set; } + + public const int RouteOffTime = 500; + Dictionary RouteOffTimers = new Dictionary(); + + /// + /// Text that represents when an output has no source routed to it + /// + public string NoRouteText = ""; + + /// + /// Factory method to create a new chassis controller from config data. Limited to 8x8 right now + /// + public static DmChassisController GetDmChassisController(string key, string name, + string type, DMChassisPropertiesConfig properties) + { + try + { + type = type.ToLower(); + uint ipid = properties.Control.IpIdInt; + + DmMDMnxn chassis = null; + switch (type) { + case "dmmd8x8": + chassis = new DmMd8x8(ipid, Global.ControlSystem); + break; + case "dmmd8x8rps": + chassis = new DmMd8x8rps(ipid, Global.ControlSystem); + break; + case "dmmd8x8cpu3": + chassis = new DmMd8x8Cpu3(ipid, Global.ControlSystem); + break; + case "dmmd8x8cpu3rps": + chassis = new DmMd8x8Cpu3rps(ipid, Global.ControlSystem); + break; + case "dmmd16x16": + chassis = new DmMd16x16(ipid, Global.ControlSystem); + break; + case "dmmd16x16rps": + chassis = new DmMd16x16rps(ipid, Global.ControlSystem); + break; + case "dmmd16x16cpu3": + chassis = new DmMd16x16Cpu3(ipid, Global.ControlSystem); + break; + case "dmmd16x16cpu3rps": + chassis = new DmMd16x16Cpu3rps(ipid, Global.ControlSystem); + break; + case "dmmd32x32": + chassis = new DmMd32x32(ipid, Global.ControlSystem); + break; + case "dmmd32x32rps": + chassis = new DmMd32x32rps(ipid, Global.ControlSystem); + break; + case "dmmd32x32cpu3": + chassis = new DmMd32x32Cpu3(ipid, Global.ControlSystem); + break; + case "dmmd32x32cpu3rps": + chassis = new DmMd32x32Cpu3rps(ipid, Global.ControlSystem); + break; + } + + if (chassis == null) + return null; + + var controller = new DmChassisController(key, name, chassis); + + // + var clearInputPort = new RoutingInputPort(NonePortKey, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.None, null, controller); + + controller.InputPorts.Add(clearInputPort); + + // add the cards and port names + foreach (var kvp in properties.InputSlots) + controller.AddInputCard(kvp.Value, kvp.Key); + + foreach (var kvp in properties.OutputSlots) + controller.AddOutputCard(kvp.Value, kvp.Key); + + foreach (var kvp in properties.VolumeControls) + { + // get the card + // check it for an audio-compatible type + // make a something-something that will make it work + // retire to mountain village + var outNum = kvp.Key; + var card = controller.Chassis.Outputs[outNum].Card; + Audio.Output audio = null; + if (card is DmcHdo) + audio = (card as DmcHdo).Audio; + else if (card is Dmc4kHdo) + audio = (card as Dmc4kHdo).Audio; + if (audio == null) + continue; + + // wire up the audio to something here... + controller.AddVolumeControl(outNum, audio); + } + + controller.InputNames = properties.InputNames; + controller.OutputNames = properties.OutputNames; + + if (!string.IsNullOrEmpty(properties.NoRouteText)) + { + controller.NoRouteText = properties.NoRouteText; + Debug.Console(1, controller, "Setting No Route Text value to: {0}", controller.NoRouteText); + } + else + { + Debug.Console(1, controller, "NoRouteText not specified. Defaulting to blank string.", controller.NoRouteText); + } + + controller.PropertiesConfig = properties; + return controller; + } + catch (Exception e) + { + Debug.Console(0, "Error creating DM chassis:\r{0}", e); + } + + return null; + } + + /// + /// + /// + /// + /// + /// + public DmChassisController(string key, string name, DmMDMnxn chassis) + : base(key, name, chassis) + { + + Chassis = chassis; + InputPorts = new RoutingPortCollection(); + OutputPorts = new RoutingPortCollection(); + VolumeControls = new Dictionary(); + TxDictionary = new Dictionary(); + RxDictionary = new Dictionary(); + IsOnline.OutputChange += new EventHandler(IsOnline_OutputChange); + Chassis.DMInputChange += new DMInputEventHandler(Chassis_DMInputChange); + Chassis.DMSystemChange += new DMSystemEventHandler(Chassis_DMSystemChange); + Chassis.DMOutputChange += new DMOutputEventHandler(Chassis_DMOutputChange); + Chassis.BaseEvent += ChassisOnBaseEvent; + VideoOutputFeedbacks = new Dictionary(); + AudioOutputFeedbacks = new Dictionary(); + UsbOutputRoutedToFeebacks = new Dictionary(); + UsbInputRoutedToFeebacks = new Dictionary(); + OutputDisabledByHdcpFeedbacks = new Dictionary(); + VideoInputSyncFeedbacks = new Dictionary(); + InputNameFeedbacks = new Dictionary(); + OutputNameFeedbacks = new Dictionary(); + OutputVideoRouteNameFeedbacks = new Dictionary(); + OutputAudioRouteNameFeedbacks = new Dictionary(); + InputEndpointOnlineFeedbacks = new Dictionary(); + OutputEndpointOnlineFeedbacks = new Dictionary(); + + SystemIdFeebdack = new IntFeedback(() => { return (Chassis as DmMDMnxn).SystemIdFeedback.UShortValue; }); + SystemIdBusyFeedback = new BoolFeedback(() => { return (Chassis as DmMDMnxn).SystemIdBusy.BoolValue; }); + EnableAudioBreakawayFeedback = + new BoolFeedback(() => (Chassis as DmMDMnxn).EnableAudioBreakawayFeedback.BoolValue); + EnableUsbBreakawayFeedback = + new BoolFeedback(() => (Chassis as DmMDMnxn).EnableUSBBreakawayFeedback.BoolValue); + + InputCardHdcpStateFeedbacks = new Dictionary(); + InputStreamCardStateFeedbacks = new Dictionary(); + OutputStreamCardStateFeedbacks = new Dictionary(); + InputCardHdcpCapabilityTypes = new Dictionary(); + + for (uint x = 1; x <= Chassis.NumberOfOutputs; x++) + { + var tempX = x; + + if (Chassis.Outputs[tempX] != null) + { + VideoOutputFeedbacks[tempX] = new IntFeedback(() => { + if (Chassis.Outputs[tempX].VideoOutFeedback != null) + return (ushort)Chassis.Outputs[tempX].VideoOutFeedback.Number; + + return 0; + }); + AudioOutputFeedbacks[tempX] = new IntFeedback(() => { + if (Chassis.Outputs[tempX].AudioOutFeedback != null) + return (ushort)Chassis.Outputs[tempX].AudioOutFeedback.Number; + + return 0; + }); + UsbOutputRoutedToFeebacks[tempX] = new IntFeedback(() => { + if (Chassis.Outputs[tempX].USBRoutedToFeedback != null) + return (ushort)Chassis.Outputs[tempX].USBRoutedToFeedback.Number; + + return 0; + }); + + OutputNameFeedbacks[tempX] = new StringFeedback(() => { + if (Chassis.Outputs[tempX].NameFeedback != null) + return Chassis.Outputs[tempX].NameFeedback.StringValue; + + return ""; + }); + OutputVideoRouteNameFeedbacks[tempX] = new StringFeedback(() => { + if (Chassis.Outputs[tempX].VideoOutFeedback != null) + return Chassis.Outputs[tempX].VideoOutFeedback.NameFeedback.StringValue; + + return NoRouteText; + }); + OutputAudioRouteNameFeedbacks[tempX] = new StringFeedback(() => { + if (Chassis.Outputs[tempX].AudioOutFeedback != null) + return Chassis.Outputs[tempX].AudioOutFeedback.NameFeedback.StringValue; + + return NoRouteText; + }); + OutputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => Chassis.Outputs[tempX].EndpointOnlineFeedback); + + OutputDisabledByHdcpFeedbacks[tempX] = new BoolFeedback(() => { + var output = Chassis.Outputs[tempX]; + + var hdmiTxOutput = output as Card.HdmiTx; + if (hdmiTxOutput != null) + return hdmiTxOutput.HdmiOutput.DisabledByHdcp.BoolValue; + + var dmHdmiOutput = output as Card.DmHdmiOutput; + if (dmHdmiOutput != null) + return dmHdmiOutput.DisabledByHdcpFeedback.BoolValue; + + var dmsDmOutAdvanced = output as Card.DmsDmOutAdvanced; + if (dmsDmOutAdvanced != null) + return dmsDmOutAdvanced.DisabledByHdcpFeedback.BoolValue; + + var dmps3HdmiAudioOutput = output as Card.Dmps3HdmiAudioOutput; + if (dmps3HdmiAudioOutput != null) + return dmps3HdmiAudioOutput.HdmiOutputPort.DisabledByHdcpFeedback.BoolValue; + + var dmps3HdmiOutput = output as Card.Dmps3HdmiOutput; + if (dmps3HdmiOutput != null) + return dmps3HdmiOutput.HdmiOutputPort.DisabledByHdcpFeedback.BoolValue; + + var dmps3HdmiOutputBackend = output as Card.Dmps3HdmiOutputBackend; + if (dmps3HdmiOutputBackend != null) + return dmps3HdmiOutputBackend.HdmiOutputPort.DisabledByHdcpFeedback.BoolValue; + + // var hdRx4kX10HdmiOutput = output as HdRx4kX10HdmiOutput; + // if (hdRx4kX10HdmiOutput != null) + // return hdRx4kX10HdmiOutput.HdmiOutputPort.DisabledByHdcpFeedback.BoolValue; + + // var hdMdNxMHdmiOutput = output as HdMdNxMHdmiOutput; + // if (hdMdNxMHdmiOutput != null) + // return hdMdNxMHdmiOutput.HdmiOutputPort.DisabledByHdcpFeedback.BoolValue; + + return false; + }); + OutputStreamCardStateFeedbacks[tempX] = new IntFeedback(() => + { + try + { + var outputCard = Chassis.Outputs[tempX]; + + if (outputCard.Card is DmcStroAV) + { + Debug.Console(2, "Found output stream card in slot: {0}.", tempX); + var streamCard = outputCard.Card as DmcStroAV; + if (streamCard.Control.StartFeedback.BoolValue == true) + return 1; + else if (streamCard.Control.StopFeedback.BoolValue == true) + return 2; + else if (streamCard.Control.PauseFeedback.BoolValue == true) + return 3; + else + return 0; + } + return 0; + } + catch (InvalidOperationException iopex) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Warning, "Error adding output stream card in slot: {0}. Error: {1}", tempX, iopex); + return 0; + } + }); + } + + if (Chassis.Inputs[tempX] != null) + { + UsbInputRoutedToFeebacks[tempX] = new IntFeedback(() => { + if (Chassis.Inputs[tempX].USBRoutedToFeedback != null) + return (ushort)Chassis.Inputs[tempX].USBRoutedToFeedback.Number; + + return 0; + }); + VideoInputSyncFeedbacks[tempX] = new BoolFeedback(() => { + if (Chassis.Inputs[tempX].VideoDetectedFeedback != null) + return Chassis.Inputs[tempX].VideoDetectedFeedback.BoolValue; + + return false; + }); + InputNameFeedbacks[tempX] = new StringFeedback(() => { + if (Chassis.Inputs[tempX].NameFeedback != null) + return Chassis.Inputs[tempX].NameFeedback.StringValue; + + return ""; + }); + + InputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => { return Chassis.Inputs[tempX].EndpointOnlineFeedback; }); + + InputCardHdcpStateFeedbacks[tempX] = new IntFeedback(() => { + try + { + var inputCard = Chassis.Inputs[tempX]; + + if (inputCard.Card is DmcHd) + { + InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.HdcpAutoSupport; + + if ((inputCard.Card as DmcHd).HdmiInput.HdcpSupportOnFeedback.BoolValue) + return 1; + return 0; + } + + if (inputCard.Card is DmcHdDsp) + { + InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.HdcpAutoSupport; + + if ((inputCard.Card as DmcHdDsp).HdmiInput.HdcpSupportOnFeedback.BoolValue) + return 1; + return 0; + } + if (inputCard.Card is Dmc4kHdBase) + { + InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.Hdcp2_2Support; + return (int)(inputCard.Card as Dmc4kHdBase).HdmiInput.HdcpReceiveCapability; + } + if (inputCard.Card is Dmc4kHdDspBase) + { + if (PropertiesConfig.InputSlotSupportsHdcp2[tempX]) + { + InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.Hdcp2_2Support; + return (int)(inputCard.Card as Dmc4kHdDspBase).HdmiInput.HdcpReceiveCapability; + } + + InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.HdcpAutoSupport; + if ((inputCard.Card as Dmc4kHdDspBase).HdmiInput.HdcpSupportOnFeedback.BoolValue) + return 1; + return 0; + } + + if (inputCard.Card is Dmc4kCBase) + { + if (PropertiesConfig.InputSlotSupportsHdcp2[tempX]) + { + InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.HdcpAutoSupport; + return (int)(inputCard.Card as Dmc4kCBase).DmInput.HdcpReceiveCapability; + } + + if ((inputCard.Card as Dmc4kCBase).DmInput.HdcpSupportOnFeedback.BoolValue) + return 1; + return 0; + } + if (inputCard.Card is Dmc4kCDspBase) + { + if (PropertiesConfig.InputSlotSupportsHdcp2[tempX]) + { + InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.HdcpAutoSupport; + return (int)(inputCard.Card as Dmc4kCDspBase).DmInput.HdcpReceiveCapability; + } + + if ((inputCard.Card as Dmc4kCDspBase).DmInput.HdcpSupportOnFeedback.BoolValue) + return 1; + + return 0; + } + return 0; + } + catch (InvalidOperationException iopex) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Warning, "The Input Card in slot: {0} supports HDCP 2. Please update the configuration value in the inputCardSupportsHdcp2 object to true. Error: {1}", tempX, iopex); + return 0; + } + }); + InputStreamCardStateFeedbacks[tempX] = new IntFeedback(() => + { + try + { + var inputCard = Chassis.Inputs[tempX]; + + if (inputCard.Card is DmcStr) + { + Debug.Console(2, "Found input stream card in slot: {0}.", tempX); + var streamCard = inputCard.Card as DmcStr; + if (streamCard.Control.StartFeedback.BoolValue == true) + return 1; + else if (streamCard.Control.StopFeedback.BoolValue == true) + return 2; + else if (streamCard.Control.PauseFeedback.BoolValue == true) + return 3; + else + return 0; + } + return 0; + } + catch (InvalidOperationException iopex) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Warning, "Error adding input stream card in slot: {0}. Error: {1}", tempX, iopex); + return 0; + } + }); + } + } + } + + private void ChassisOnBaseEvent(GenericBase device, BaseEventArgs args) + { + + } + + private void RegisterForInputResolutionFeedback(IVideoAttributesBasic input, uint number, RoutingInputPortWithVideoStatuses inputPort) + { + if (input == null) + { + return; + } + + Debug.Console(1, this, "Registering for resolution feedback for input {0} using Routing Port {1}", number, inputPort.Key); + + input.VideoAttributes.AttributeChange += (sender, args) => + { + Debug.Console(1, this, "Input {0} resolution updated", number); + + Debug.Console(1, this, "Updating resolution feedback for input {0}", number); + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + }; + } + + /// + /// + /// + /// + /// + public void AddInputCard(string type, uint number) + { + Debug.Console(2, this, "Adding input card '{0}', slot {1}", type, number); + + type = type.ToLower(); + + switch (type) + { + case "dmchd": + { + var inputCard = new DmcHd(number, Chassis); + AddHdmiInCardPorts(number, inputCard.HdmiInput, inputCard.HdmiInput); + } + break; + case "dmchddsp": + { + var inputCard = new DmcHdDsp(number, Chassis); + AddHdmiInCardPorts(number, inputCard.HdmiInput, inputCard.HdmiInput); + } + break; + case "dmc4khd": + { + var inputCard = new Dmc4kHd(number, Chassis); + AddHdmiInCardPorts(number, inputCard.HdmiInput, inputCard.HdmiInput); + } + break; + case "dmc4khddsp": + { + var inputCard = new Dmc4kHdDsp(number, Chassis); + AddHdmiInCardPorts(number, inputCard.HdmiInput, inputCard.HdmiInput); + } + break; + case "dmc4kzhd": + { + var inputCard = new Dmc4kzHd(number, Chassis); + AddHdmiInCardPorts(number, inputCard.HdmiInput, inputCard.HdmiInput); + break; + } + case "dmc4kzhddsp": + { + var inputCard = new Dmc4kzHdDsp(number, Chassis); + AddHdmiInCardPorts(number, inputCard.HdmiInput, inputCard.HdmiInput); + break; + } + case "dmcc": + { + var inputCard = new DmcC(number, Chassis); + //DmInput doesn't implement ICec...cast was resulting in null anyway + AddDmInCardPorts(number, null, inputCard.DmInput); + } + break; + case "dmccdsp": + { + var inputCard = new DmcCDsp(number, Chassis); + //DmInput doesn't implement ICec...cast was resulting in null anyway + AddDmInCardPorts(number, null, inputCard.DmInput); + break; + } + + case "dmc4kc": + { + var inputCard = new Dmc4kC(number, Chassis); + AddDmInCardPorts(number, inputCard.DmInput,inputCard.DmInput); + break; + } + + case "dmc4kcdsp": + { + var inputCard = new Dmc4kCDsp(number, Chassis); + AddDmInCardPorts(number, inputCard.DmInput,inputCard.DmInput); + break; + } + + case "dmc4kzc": + { + var inputCard = new Dmc4kzC(number, Chassis); + AddDmInCardPorts(number, inputCard.DmInput,inputCard.DmInput); + break; + } + + case "dmc4kzcdsp": + { + var inputCard = new Dmc4kzCDsp(number, Chassis); + AddDmInCardPorts(number, inputCard.DmInput, inputCard.DmInput); + break; + } + + case "dmccat": + { + var inputCard = new DmcCat(number, Chassis); + AddDmInCardPorts(number, null, inputCard.DmInput); + break; + } + case "dmccatdsp": + { + var inputCard = new DmcCatDsp(number, Chassis); + AddDmInCardPorts(number, null, inputCard.DmInput); + break; + } + case "dmcs": + { + var inputCard = new DmcS(number, Chassis); + AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmMmFiber, null, inputCard.DmInput); + AddInCardHdmiAndAudioLoopPorts(number); + break; + } + case "dmcsdsp": + { + var inputCard = new DmcSDsp(number, Chassis); + AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmMmFiber, null, inputCard.DmInput); + AddInCardHdmiAndAudioLoopPorts(number); + break; + } + case "dmcs2": + { + var inputCard = new DmcS2(number, Chassis); + AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmSmFiber, null, inputCard.DmInput); + AddInCardHdmiAndAudioLoopPorts(number); + break; + } + case "dmcs2dsp": + { + var inputCard = new DmcS2Dsp(number, Chassis); + AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmSmFiber, null, inputCard.DmInput); + AddInCardHdmiAndAudioLoopPorts(number); + break; + } + case "dmcsdi": + { + var inputCard = new DmcSdi(number, Chassis); + AddInputPortWithDebug(number, "sdiIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Sdi, null, inputCard.SdiInput); + AddOutputPortWithDebug(string.Format("inputCard{0}", number), "sdiOut", eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Sdi, null); + AddInCardHdmiAndAudioLoopPorts(number); + break; + } + case "dmcdvi": + { + var inputCard = new DmcDvi(number, Chassis); + AddInputPortWithDebug(number, "dviIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Dvi, null, inputCard.DviInput); + AddInputPortWithDebug(number, "audioIn", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio); + AddInCardHdmiLoopPort(number); + break; + } + case "dmcvga": + { + var inputCard = new DmcVga(number, Chassis); + AddInputPortWithDebug(number, "vgaIn", eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, null, inputCard.VgaInput); + AddInputPortWithDebug(number, "audioIn", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio); + AddInCardHdmiLoopPort(number); + break; + } + case "dmcvidbnc": + { + var inputCard = new DmcVidBnc(number, Chassis); + AddInputPortWithDebug(number, "componentIn", eRoutingSignalType.Video, eRoutingPortConnectionType.Component, null, inputCard.VideoInput); + AddInputPortWithDebug(number, "audioIn", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio); + AddInCardHdmiLoopPort(number); + break; + } + case "dmcvidrcaa": + { + var inputCard = new DmcVidRcaA(number, Chassis); + AddInputPortWithDebug(number, "componentIn", eRoutingSignalType.Video, eRoutingPortConnectionType.Component, null, inputCard.VideoInput); + AddInputPortWithDebug(number, "audioIn", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio); + AddInCardHdmiLoopPort(number); + break; + } + case "dmcvidrcad": + { + var inputCard = new DmcVidRcaD(number, Chassis); + AddInputPortWithDebug(number, "componentIn", eRoutingSignalType.Video, eRoutingPortConnectionType.Component, null, inputCard.VideoInput); + AddInputPortWithDebug(number, "audioIn", eRoutingSignalType.Audio, eRoutingPortConnectionType.DigitalAudio); + AddInCardHdmiLoopPort(number); + break; + } + case "dmcvid4": + { + var inputCard = new DmcVid4(number, Chassis); + AddInputPortWithDebug(number, "compositeIn1", eRoutingSignalType.Video, eRoutingPortConnectionType.Composite); + AddInputPortWithDebug(number, "compositeIn2", eRoutingSignalType.Video, eRoutingPortConnectionType.Composite); + AddInputPortWithDebug(number, "compositeIn3", eRoutingSignalType.Video, eRoutingPortConnectionType.Composite); + AddInputPortWithDebug(number, "compositeIn4", eRoutingSignalType.Video, eRoutingPortConnectionType.Composite); + AddInCardHdmiLoopPort(number); + break; + } + case "dmcstr": + { + var inputCard = new DmcStr(number, Chassis); + AddInputPortWithDebug(number, "streamIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Streaming, null, inputCard.Source); + AddInCardHdmiAndAudioLoopPorts(number); + break; + } + } + } + + void AddDmInCardPorts(uint number) + { + AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat); + AddInCardHdmiAndAudioLoopPorts(number); + } + + void AddDmInCardPorts(uint number, ICec cecPort) + { + AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, cecPort); + AddInCardHdmiAndAudioLoopPorts(number); + } + + void AddDmInCardPorts(uint number, ICec cecPort, IVideoAttributesBasic videoAttributes) + { + AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, cecPort, videoAttributes); + AddInCardHdmiAndAudioLoopPorts(number); + } + + void AddHdmiInCardPorts(uint number, ICec cecPort) + { + AddInputPortWithDebug(number, "hdmiIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, cecPort); + AddInCardHdmiAndAudioLoopPorts(number); + } + + void AddHdmiInCardPorts(uint number, ICec cecPort, IVideoAttributesBasic videoAttributes) + { + AddInputPortWithDebug(number, "hdmiIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, cecPort, videoAttributes); + AddInCardHdmiAndAudioLoopPorts(number); + } + + void AddInCardHdmiAndAudioLoopPorts(uint number) + { + AddOutputPortWithDebug(string.Format("inputCard{0}", number), "hdmiLoopOut", eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, null); + AddOutputPortWithDebug(string.Format("inputCard{0}", number), "audioLoopOut", eRoutingSignalType.Audio, eRoutingPortConnectionType.Hdmi, null); + } + + void AddInCardHdmiLoopPort(uint number) + { + AddOutputPortWithDebug(string.Format("inputCard{0}", number), "hdmiLoopOut", eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, null); + } + + /// + /// + /// + /// + /// + public void AddOutputCard(string type, uint number) + { + type = type.ToLower(); + + Debug.Console(2, this, "Adding output card '{0}', slot {1}", type, number); + switch (type) + { + case "dmc4khdo": + { + var outputCard = new Dmc4kHdoSingle(number, Chassis); + var cecPort1 = outputCard.Card1.HdmiOutput; + var cecPort2 = outputCard.Card2.HdmiOutput; + AddDmcHdoPorts(number, cecPort1, cecPort2); + } + break; + case "dmc4kzhdo": + { + var outputCard = new Dmc4kzHdoSingle(number, Chassis); + var cecPort1 = outputCard.Card1.HdmiOutput; + var cecPort2 = outputCard.Card2.HdmiOutput; + AddDmcHdoPorts(number, cecPort1, cecPort2); + } + break; + case "dmchdo": + { + var outputCard = new DmcHdoSingle(number, Chassis); + var cecPort1 = outputCard.Card1.HdmiOutput; + var cecPort2 = outputCard.Card2.HdmiOutput; + AddDmcHdoPorts(number, cecPort1, cecPort2); + } + break; + case "dmc4kcohd": + { + var outputCard = new Dmc4kCoHdSingle(number, Chassis); + var cecPort1 = outputCard.Card1.HdmiOutput; + AddDmcCoPorts(number, cecPort1); + } + break; + case "dmc4kzcohd": + { + var outputCard = new Dmc4kzCoHdSingle(number, Chassis); + var cecPort1 = outputCard.Card1.HdmiOutput; + AddDmcCoPorts(number, cecPort1); + } + break; + case "dmccohd": + { + var outputCard = new DmcCoHdSingle(number, Chassis); + var cecPort1 = outputCard.Card1.HdmiOutput; + AddDmcCoPorts(number, cecPort1); + } + break; + case "dmccatohd": + { + var outputCard = new DmcCatoHdSingle(number, Chassis); + var cecPort1 = outputCard.Card1.HdmiOutput; + AddDmcCoPorts(number, cecPort1); + } + break; + case "dmcsohd": + { + var outputCard = new DmcSoHdSingle(number, Chassis); + var cecPort1 = outputCard.Card1.HdmiOutput; + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.DmMmFiber, Chassis.Outputs[2 * (number - 1) + 1]); + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "hdmiOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, Chassis.Outputs[2 * (number - 1) + 1], cecPort1); + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut2", eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.DmMmFiber, Chassis.Outputs[2 * (number - 1) + 2]); + } + break; + case "dmcs2ohd": + { + var outputCard = new DmcS2oHdSingle(number, Chassis); + var cecPort1 = outputCard.Card1.HdmiOutput; + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.DmSmFiber, Chassis.Outputs[2 * (number - 1) + 1]); + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "hdmiOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, Chassis.Outputs[2 * (number - 1) + 1], cecPort1); + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut2", eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.DmSmFiber, Chassis.Outputs[2 * (number - 1) + 2]); + } + break; + case "dmcstro": + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "streamOut", eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Streaming, Chassis.Outputs[2 * (number - 1) + 1]); + break; + default: + Debug.Console(1, this, " WARNING: Output card type '{0}' is not available", type); + break; + } + } + + void AddDmcHdoPorts(uint number, ICec cecPort1, ICec cecPort2) + { + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "hdmiOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, Chassis.Outputs[2 * (number - 1) + 1], cecPort1); + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "audioOut1", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio, + Chassis.Outputs[2 * (number - 1) + 1]); + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "hdmiOut2", eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, Chassis.Outputs[2 * (number - 1) + 2], cecPort2); + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "audioOut2", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio, + Chassis.Outputs[2 * (number - 1) + 2]); + } + + void AddDmcCoPorts(uint number, ICec cecPort1) + { + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.DmCat, Chassis.Outputs[2 * (number - 1) + 1]); + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "hdmiOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, Chassis.Outputs[2 * (number - 1) + 1], cecPort1); + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut2", eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.DmCat, Chassis.Outputs[2 * (number - 1) + 2]); + } + + /// + /// Adds InputPort + /// + void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType) + { + //Cast is necessary here to determine the correct overload + AddInputPortWithDebug(cardNum, portName, sigType, portType, null, null); + } + + private void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, + eRoutingPortConnectionType portType, ICec cecPort) + { + //Cast is necessary here to determine the correct overload + AddInputPortWithDebug(cardNum, portName, sigType, portType, cecPort, null); + } + + /// + /// Adds InputPort and sets Port as ICec object. If videoAttributesBasic is defined, RoutingPort will be RoutingInputPortWithVideoStatuses + /// + void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, ICec cecPort, IVideoAttributesBasic videoAttributesBasic) + { + var portKey = string.Format("inputCard{0}--{1}", cardNum, portName); + Debug.Console(2, this, "Adding input port '{0}'", portKey); + + RoutingInputPort inputPort; + + if (videoAttributesBasic != null) + { + Debug.Console(1, this, "card {0} supports IVideoAttributesBasic", cardNum); + var statusFuncs = new VideoStatusFuncsWrapper + { + VideoResolutionFeedbackFunc = () => + { + var resolution = videoAttributesBasic.VideoAttributes.GetVideoResolutionString(); + Debug.Console(1, this, "Updating resolution for input {0}. New resolution: {1}", cardNum, resolution); + return resolution; + } + }; + inputPort = new RoutingInputPortWithVideoStatuses(portKey, sigType, portType, + Chassis.Inputs[cardNum], this, statusFuncs) + { + FeedbackMatchObject = Chassis.Inputs[cardNum] + }; + + RegisterForInputResolutionFeedback(videoAttributesBasic, cardNum, inputPort as RoutingInputPortWithVideoStatuses); + } + else + { + inputPort = new RoutingInputPort(portKey, sigType, portType, + Chassis.Inputs[cardNum], this) + { + FeedbackMatchObject = Chassis.Inputs[cardNum] + }; + } + + if (cecPort != null) + inputPort.Port = cecPort; + + InputPorts.Add(inputPort); + } + + /// + /// Adds OutputPort + /// + void AddOutputPortWithDebug(string cardName, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, object selector) + { + AddOutputPortWithDebug(cardName, portName, sigType, portType, selector, null); + } + + /// + /// Adds OutputPort and sets Port as ICec object + /// + void AddOutputPortWithDebug(string cardName, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, object selector, ICec cecPort) + { + var portKey = string.Format("{0}--{1}", cardName, portName); + Debug.Console(2, this, "Adding output port '{0}'", portKey); + var outputPort = new RoutingOutputPort(portKey, sigType, portType, selector, this); + + if (portName.IndexOf("Loop", StringComparison.InvariantCultureIgnoreCase) < 0) + { + outputPort.FeedbackMatchObject = selector; + } + if (cecPort != null) + outputPort.Port = cecPort; + + OutputPorts.Add(outputPort); + } + + /// + /// + /// + void AddVolumeControl(uint number, Audio.Output audio) + { + VolumeControls.Add(number, new DmCardAudioOutputController(audio)); + } + + //public void SetInputHdcpSupport(uint input, ePdtHdcpSupport hdcpSetting) + //{ + + //} + + void Chassis_DMSystemChange(Switch device, DMSystemEventArgs args) + { + switch (args.EventId) + { + case DMSystemEventIds.SystemIdEventId: + { + Debug.Console(2, this, "SystemIdEvent Value: {0}", (Chassis as DmMDMnxn).SystemIdFeedback.UShortValue); + SystemIdFeebdack.FireUpdate(); + break; + } + case DMSystemEventIds.SystemIdBusyEventId: + { + Debug.Console(2, this, "SystemIdBusyEvent State: {0}", (Chassis as DmMDMnxn).SystemIdBusy.BoolValue); + SystemIdBusyFeedback.FireUpdate(); + break; + } + case DMSystemEventIds.AudioBreakawayEventId: + { + Debug.Console(2, this, "AudioBreakaway Event: value: {0}", + (Chassis as DmMDMnxn).EnableAudioBreakawayFeedback.BoolValue); + EnableAudioBreakawayFeedback.FireUpdate(); + break; + } + case DMSystemEventIds.USBBreakawayEventId: + { + Debug.Console(2, this, "USBBreakaway Event: value: {0}", + (Chassis as DmMDMnxn).EnableUSBBreakawayFeedback.BoolValue); + EnableUsbBreakawayFeedback.FireUpdate(); + break; + } + } + } + + void Chassis_DMInputChange(Switch device, DMInputEventArgs args) + { + try + { + switch (args.EventId) + { + case DMInputEventIds.EndpointOnlineEventId: + { + Debug.Console(2, this, "DM Input EndpointOnlineEventId for input: {0}. State: {1}", args.Number, device.Inputs[args.Number].EndpointOnlineFeedback); + InputEndpointOnlineFeedbacks[args.Number].FireUpdate(); + break; + } + case DMInputEventIds.OnlineFeedbackEventId: + { + Debug.Console(2, this, "DM Input OnlineFeedbackEventId for input: {0}. State: {1}", args.Number, device.Inputs[args.Number].EndpointOnlineFeedback); + InputEndpointOnlineFeedbacks[args.Number].FireUpdate(); + break; + } + case DMInputEventIds.VideoDetectedEventId: + { + Debug.Console(2, this, "DM Input {0} VideoDetectedEventId", args.Number); + VideoInputSyncFeedbacks[args.Number].FireUpdate(); + break; + } + case DMInputEventIds.InputNameEventId: + { + Debug.Console(2, this, "DM Input {0} NameFeedbackEventId", args.Number); + InputNameFeedbacks[args.Number].FireUpdate(); + break; + } + case DMInputEventIds.UsbRoutedToEventId: + { + Debug.Console(2, this, "DM Input {0} UsbRoutedToEventId", args.Number); + if (UsbInputRoutedToFeebacks[args.Number] != null) + UsbInputRoutedToFeebacks[args.Number].FireUpdate(); + else + Debug.Console(1, this, "No index of {0} found in UsbInputRoutedToFeedbacks"); + break; + } + case DMInputEventIds.HdcpCapabilityFeedbackEventId: + { + Debug.Console(2, this, "DM Input {0} HdcpCapabilityFeedbackEventId", args.Number); + if (InputCardHdcpStateFeedbacks[args.Number] != null) + InputCardHdcpStateFeedbacks[args.Number].FireUpdate(); + else + Debug.Console(1, this, "No index of {0} found in InputCardHdcpCapabilityFeedbacks"); + break; + } + case DMInputEventIds.HdcpSupportOffEventId: + { + Debug.Console(2, this, "DM Input {0} HdcpSupportOffEventId", args.Number); + if (InputCardHdcpStateFeedbacks[args.Number] != null) + InputCardHdcpStateFeedbacks[args.Number].FireUpdate(); + else + Debug.Console(1, this, "No index of {0} found in InputCardHdcpCapabilityFeedbacks"); + break; + } + case DMInputEventIds.HdcpSupportOnEventId: + { + Debug.Console(2, this, "DM Input {0} HdcpSupportOnEventId", args.Number); + if (InputCardHdcpStateFeedbacks[args.Number] != null) + InputCardHdcpStateFeedbacks[args.Number].FireUpdate(); + else + Debug.Console(1, this, "No index of {0} found in InputCardHdcpCapabilityFeedbacks"); + break; + } + case DMInputEventIds.StartEventId: + case DMInputEventIds.StopEventId: + case DMInputEventIds.PauseEventId: + { + Debug.Console(2, this, "DM Input {0} Stream Status EventId", args.Number); + if (InputStreamCardStateFeedbacks[args.Number] != null) + { + InputStreamCardStateFeedbacks[args.Number].FireUpdate(); + } + else + Debug.Console(2, this, "No index of {0} found in InputStreamCardStateFeedbacks"); + break; + } + case DMInputEventIds.HorizontalResolutionFeedbackEventId: + case DMInputEventIds.VerticalResolutionFeedbackEventId: + case DMInputEventIds.FramesPerSecondFeedbackEventId: + case DMInputEventIds.ResolutionEventId: + { + Debug.Console(1, this, "Input {0} resolution updated", args.Number); + var inputPort = + InputPorts.Cast() + .FirstOrDefault((ip) => ip.Key.Contains(String.Format("inputCard{0}", args.Number))); + + if (inputPort != null) + { + Debug.Console(1, this, "Updating resolution feedback for input {0}", args.Number); + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + } + break; + } + default: + { + Debug.Console(2, this, "DMInputChange fired for Input {0} with Unhandled EventId: {1}", args.Number, args.EventId); + break; + } + } + } + catch (Exception ex) + { + Debug.Console(2, this, Debug.ErrorLogLevel.Error, "Error in Chassis_DMInputChange: {0}", ex); + } + } + + /// + /// + /// Raise an event when the status of a switch object changes. + /// + /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType + private void OnSwitchChange(RoutingNumericEventArgs e) + { + var newEvent = NumericSwitchChange; + if (newEvent != null) newEvent(this, e); + } + + /// + /// + void Chassis_DMOutputChange(Switch device, DMOutputEventArgs args) + { + var output = args.Number; + + switch (args.EventId) + { + case DMOutputEventIds.VolumeEventId: + { + if (VolumeControls.ContainsKey(output)) + { + VolumeControls[args.Number].VolumeEventFromChassis(); + } + + break; + } + case DMOutputEventIds.EndpointOnlineEventId: + { + Debug.Console(2, this, "Output {0} DMOutputEventIds.EndpointOnlineEventId fired. State: {1}", args.Number, + Chassis.Outputs[output].EndpointOnlineFeedback); + OutputEndpointOnlineFeedbacks[output].FireUpdate(); + break; + } + case DMOutputEventIds.OnlineFeedbackEventId: + { + Debug.Console(2, this, "Output {0} DMInputEventIds.OnlineFeedbackEventId fired. State: {1}", args.Number, + Chassis.Outputs[output].EndpointOnlineFeedback); + OutputEndpointOnlineFeedbacks[output].FireUpdate(); + break; + } + case DMOutputEventIds.VideoOutEventId: + { + + var inputNumber = Chassis.Outputs[output].VideoOutFeedback == null ? 0 : Chassis. + Outputs[output].VideoOutFeedback.Number; + + Debug.Console(2, this, "DMSwitchVideo:{0} Routed Input:{1} Output:{2}'", Name, inputNumber, output); + + if (VideoOutputFeedbacks.ContainsKey(output)) + { + var localInputPort = InputPorts.FirstOrDefault(p => (DMInput)p.FeedbackMatchObject == Chassis.Outputs[output].VideoOutFeedback); + var localOutputPort = + OutputPorts.FirstOrDefault(p => (DMOutput) p.FeedbackMatchObject == Chassis.Outputs[output]); + + + VideoOutputFeedbacks[output].FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(output, + inputNumber, + localOutputPort, + localInputPort, + eRoutingSignalType.Video)); + } + + if (OutputVideoRouteNameFeedbacks.ContainsKey(output)) + OutputVideoRouteNameFeedbacks[output].FireUpdate(); + + break; + } + case DMOutputEventIds.AudioOutEventId: + { + var inputNumber = Chassis.Outputs[output].AudioOutFeedback == null ? 0 : Chassis. + Outputs[output].AudioOutFeedback.Number; + + Debug.Console(2, this, "DMSwitchAudio:{0} Routed Input:{1} Output:{2}'", Name, inputNumber, output); + + if (AudioOutputFeedbacks.ContainsKey(output)) + { + var localInputPort = InputPorts.FirstOrDefault(p => (DMInput)p.FeedbackMatchObject == Chassis.Outputs[output].AudioOutFeedback); + var localOutputPort = + OutputPorts.FirstOrDefault(p => (DMOutput)p.FeedbackMatchObject == Chassis.Outputs[output]); + + + AudioOutputFeedbacks[output].FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(output, + inputNumber, + localOutputPort, + localInputPort, + eRoutingSignalType.Audio)); + } + + if (OutputAudioRouteNameFeedbacks.ContainsKey(output)) + OutputAudioRouteNameFeedbacks[output].FireUpdate(); + + break; + } + case DMOutputEventIds.OutputNameEventId: + { + Debug.Console(2, this, "DM Output {0} NameFeedbackEventId", output); + OutputNameFeedbacks[output].FireUpdate(); + break; + } + case DMOutputEventIds.UsbRoutedToEventId: + { + Debug.Console(2, this, "DM Output {0} UsbRoutedToEventId", args.Number); + UsbOutputRoutedToFeebacks[args.Number].FireUpdate(); + break; + } + case DMOutputEventIds.DisabledByHdcpEventId: + { + Debug.Console(2, this, "DM Output {0} DisabledByHdcpEventId", args.Number); + OutputDisabledByHdcpFeedbacks[args.Number].FireUpdate(); + break; + } + case DMOutputEventIds.StartEventId: + case DMOutputEventIds.StopEventId: + case DMOutputEventIds.PauseEventId: + { + Debug.Console(2, this, "DM Output {0} Stream Status EventId", args.Number); + if (OutputStreamCardStateFeedbacks[args.Number] != null) + { + OutputStreamCardStateFeedbacks[args.Number].FireUpdate(); + } + else + Debug.Console(2, this, "No index of {0} found in OutputStreamCardStateFeedbacks"); + break; + } + default: + { + Debug.Console(2, this, "DMOutputChange fired for Output {0} with Unhandled EventId: {1}", args.Number, args.EventId); + break; + } + } + } + + /// + /// + /// + /// + void StartOffTimer(PortNumberType pnt) + { + if (RouteOffTimers.ContainsKey(pnt)) + return; + RouteOffTimers[pnt] = new CTimer(o => ExecuteSwitch(null, pnt.Selector, pnt.Type), RouteOffTime); + } + + // Send out sigs when coming online + void IsOnline_OutputChange(object sender, EventArgs e) + { + if (IsOnline.BoolValue) + { + (Chassis as DmMDMnxn).EnableAudioBreakaway.BoolValue = true; + (Chassis as DmMDMnxn).EnableUSBBreakaway.BoolValue = true; + + + EnableAudioBreakawayFeedback.FireUpdate(); + EnableUsbBreakawayFeedback.FireUpdate(); + + if (InputNames != null) + foreach (var kvp in InputNames) + Chassis.Inputs[kvp.Key].Name.StringValue = kvp.Value; + if (OutputNames != null) + foreach (var kvp in OutputNames) + Chassis.Outputs[kvp.Key].Name.StringValue = kvp.Value; + } + } + + #region IRouting Members + public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType sigType) + { + Debug.Console(2, this, "Making an awesome DM route from {0} to {1} {2}", inputSelector, outputSelector, sigType); + + var input = inputSelector as DMInput;//Input Selector could be null... + + var output = outputSelector as DMOutput; + + var isUsbInput = (sigType & eRoutingSignalType.UsbInput) == eRoutingSignalType.UsbInput; + var isUsbOutput = (sigType & eRoutingSignalType.UsbOutput) == eRoutingSignalType.UsbOutput; + + if (output == null && !(isUsbOutput || isUsbInput)) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Warning, + "Unable to execute switch for inputSelector {0} to outputSelector {1}", inputSelector, + outputSelector); + return; + } + + // Check to see if there's an off timer waiting on this and if so, cancel + var key = new PortNumberType(output, sigType); + if (input == null) + { + StartOffTimer(key); + } + else + { + if (RouteOffTimers.ContainsKey(key)) + { + Debug.Console(2, this, "{0} cancelling route off due to new source", output); + RouteOffTimers[key].Stop(); + RouteOffTimers.Remove(key); + } + } + + //var inCard = input == 0 ? null : Chassis.Inputs[input]; + //var outCard = input == 0 ? null : Chassis.Outputs[output]; + + // NOTE THAT BITWISE COMPARISONS - TO CATCH ALL ROUTING TYPES + if ((sigType & eRoutingSignalType.Video) == eRoutingSignalType.Video) + { + Chassis.VideoEnter.BoolValue = true; + if (output != null) + { + output.VideoOut = input; //Chassis.Outputs[output].VideoOut = inCard; + } + } + + if ((sigType & eRoutingSignalType.Audio) == eRoutingSignalType.Audio) + { + var dmMdMnxn = Chassis as DmMDMnxn; + if (dmMdMnxn != null) + { + dmMdMnxn.AudioEnter.BoolValue = true; + } + if (output != null) + { + output.AudioOut = input; + } + } + + if ((sigType & eRoutingSignalType.UsbOutput) == eRoutingSignalType.UsbOutput) + + { + Chassis.USBEnter.BoolValue = true; + if (inputSelector == null && output != null) + { + //clearing the route is intended + output.USBRoutedTo = null; + return; + } + + if (inputSelector != null && input == null) + { + //input selector is DMOutput...we're doing a out to out route + var tempInput = inputSelector as DMOutput; + + if (tempInput == null || output == null) + { + return; + } + output.USBRoutedTo = tempInput; + return; + } + + if (input != null & output != null) + { + output.USBRoutedTo = input; + } + } + + if((sigType & eRoutingSignalType.UsbInput) != eRoutingSignalType.UsbInput) + { + return; + } + + Chassis.USBEnter.BoolValue = true; + if (output != null) + { + output.USBRoutedTo = input; + return; + } + var tempOutput = outputSelector as DMInput; + + if (tempOutput == null) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Warning, + "Unable to execute switch for inputSelector {0} to outputSelector {1}", inputSelector, + outputSelector); + return; + } + + tempOutput.USBRoutedTo = input; + } + + #endregion + + #region IRoutingNumeric Members + + public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType sigType) + { + var chassisSize = (uint)Chassis.NumberOfInputs; //need this to determine USB routing values 8x8 -> 1-8 is inputs 1-8, 17-24 is outputs 1-8 + //16x16 1-16 is inputs 1-16, 17-32 is outputs 1-16 + //32x32 1-32 is inputs 1-32, 33-64 is outputs 1-32 + + DMInputOutputBase dmCard; + + //Routing Input to Input or Output to Input + if ((sigType & eRoutingSignalType.UsbInput) == eRoutingSignalType.UsbInput) + { + Debug.Console(2, this, "Executing USB Input switch.\r\n in:{0} output: {1}", inputSelector, outputSelector); + if (outputSelector > chassisSize) + { + uint outputIndex; + + if (chassisSize == 8) + { + outputIndex = (uint) inputSelector - 16; + } + else + { + outputIndex = inputSelector - chassisSize; + } + dmCard = Chassis.Outputs[outputIndex]; + } + else + { + dmCard = Chassis.Inputs[inputSelector]; + } + + ExecuteSwitch(dmCard, Chassis.Inputs[outputSelector], sigType); + return; + } + if ((sigType & eRoutingSignalType.UsbOutput) == eRoutingSignalType.UsbOutput) + { + Debug.Console(2, this, "Executing USB Output switch.\r\n in:{0} output: {1}", inputSelector, outputSelector); + + //routing Output to Output or Input to Output + if (inputSelector > chassisSize) + { + //wanting to route an output to an output. Subtract chassis size and get output, unless it's 8x8 + //need this to determine USB routing values + //8x8 -> 1-8 is inputs 1-8, 17-24 is outputs 1-8 + //16x16 1-16 is inputs 1-16, 17-32 is outputs 1-16 + //32x32 1-32 is inputs 1-32, 33-64 is outputs 1-32 + uint outputIndex; + + if (chassisSize == 8) + { + outputIndex = (uint) inputSelector - 16; + } + else + { + outputIndex = inputSelector - chassisSize; + } + + dmCard = Chassis.Outputs[outputIndex]; + } + else + { + dmCard = Chassis.Inputs[inputSelector]; + } + Chassis.USBEnter.BoolValue = true; + + Debug.Console(2, this, "Routing USB for input {0} to {1}", inputSelector, dmCard); + ExecuteSwitch(dmCard, Chassis.Outputs[outputSelector], sigType); + return; + } + + var inputCard = inputSelector == 0 ? null : Chassis.Inputs[inputSelector]; + var outputCard = Chassis.Outputs[outputSelector]; + + ExecuteSwitch(inputCard, outputCard, sigType); + } + + #endregion + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = GetJoinMap(joinStart, joinMapKey, bridge); + + Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + LinkChassisToApi(trilist, joinMap); + + trilist.StringInput[joinMap.Name.JoinNumber].StringValue = this.Name; + + // Link up inputs & outputs + for (uint i = 1; i <= Chassis.NumberOfOutputs; i++) + { + var ioSlot = i; + var ioSlotJoin = ioSlot - 1; + + LinkRoutingJoinsToApi(trilist, joinMap, ioSlotJoin, ioSlot); + + if (TxDictionary.ContainsKey(ioSlot)) + { + LinkTxToApi(trilist, ioSlot, joinMap, ioSlotJoin); + } + else + { + LinkHdmiInputToApi(trilist, ioSlot, joinMap, ioSlotJoin); + LinkStreamInputToApi(trilist, ioSlot, joinMap, ioSlotJoin); + } + + if (RxDictionary.ContainsKey(ioSlot)) + { + LinkRxToApi(trilist, ioSlot, joinMap, ioSlotJoin); + } + else + LinkStreamOutputToApi(trilist, ioSlot, joinMap, ioSlotJoin); + } + } + + private void LinkHdmiInputToApi(BasicTriList trilist, uint ioSlot, DmChassisControllerJoinMap joinMap, uint ioSlotJoin) + { + VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus.JoinNumber + ioSlotJoin]); + + var inputPort = InputPorts[string.Format("inputCard{0}--hdmiIn", ioSlot)]; + if (inputPort == null) + { + return; + } + + Debug.Console(1, "Port value for input card {0} is set", ioSlot); + var port = inputPort.Port; + + if (port == null) + { + return; + } + if (!(port is HdmiInputWithCEC)) + { + Debug.Console(0, this, "HDMI Input port on card {0} does not support HDCP settings.", ioSlot); + return; + } + + Debug.Console(1, "Port is HdmiInputWithCec"); + + var hdmiInPortWCec = port as HdmiInputWithCEC; + + + SetHdcpStateAction(PropertiesConfig.InputSlotSupportsHdcp2[ioSlot], hdmiInPortWCec, joinMap.HdcpSupportState.JoinNumber + ioSlotJoin, trilist); + + + InputCardHdcpStateFeedbacks[ioSlot].LinkInputSig( + trilist.UShortInput[joinMap.HdcpSupportState.JoinNumber + ioSlotJoin]); + + if (InputCardHdcpCapabilityTypes.ContainsKey(ioSlot)) + { + trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = + (ushort)InputCardHdcpCapabilityTypes[ioSlot]; + } + else + { + trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = 1; + } + + var videoStatus = inputPort as RoutingInputPortWithVideoStatuses; + + if (videoStatus == null) + { + return; + } + + Debug.Console(1, this, "Linking {0} to join {1} for resolution feedback.", videoStatus.Key, joinMap.InputCurrentResolution.JoinNumber + ioSlotJoin); + videoStatus.VideoStatus.VideoResolutionFeedback.LinkInputSig(trilist.StringInput[joinMap.InputCurrentResolution.JoinNumber + ioSlotJoin]); + } + + private void LinkStreamInputToApi(BasicTriList trilist, uint ioSlot, DmChassisControllerJoinMap joinMap, uint ioSlotJoin) + { + var inputPort = InputPorts[string.Format("inputCard{0}--streamIn", ioSlot)]; + if (inputPort == null) + { + return; + } + var streamCard = Chassis.Inputs[ioSlot].Card as DmcStr; + var join = joinMap.InputStreamCardState.JoinNumber + ioSlotJoin; + + Debug.Console(1, "Port value for input card {0} is set as a stream card", ioSlot); + + trilist.SetUShortSigAction(join, s => + { + if (s == 1) + { + Debug.Console(2, this, "Join {0} value {1}: Setting stream state to start", join, s); + streamCard.Control.Start(); + } + else if (s == 2) + { + Debug.Console(2, this, "Join {0} value {1}: Setting stream state to stop", join, s); + streamCard.Control.Stop(); + } + else if (s == 3) + { + Debug.Console(2, this, "Join {0} value {1}: Setting stream state to pause", join, s); + streamCard.Control.Pause(); + } + else + { + Debug.Console(2, this, "Join {0} value {1}: Ignore stream state", join, s); + } + }); + + InputStreamCardStateFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[join]); + + trilist.UShortInput[join].UShortValue = InputStreamCardStateFeedbacks[ioSlot].UShortValue; + + var videoStatus = inputPort as RoutingInputPortWithVideoStatuses; + + if (videoStatus != null) + { + videoStatus.VideoStatus.VideoResolutionFeedback.LinkInputSig(trilist.StringInput[joinMap.InputCurrentResolution.JoinNumber + ioSlotJoin]); + } + } + + private void LinkStreamOutputToApi(BasicTriList trilist, uint ioSlot, DmChassisControllerJoinMap joinMap, uint ioSlotJoin) + { + var outputPort = OutputPorts[string.Format("outputCard{0}--streamOut", ioSlot)]; + if (outputPort == null) + { + return; + } + var streamCard = Chassis.Outputs[ioSlot].Card as DmcStroAV; + var join = joinMap.OutputStreamCardState.JoinNumber + ioSlotJoin; + + Debug.Console(1, "Port value for output card {0} is set as a stream card", ioSlot); + + trilist.SetUShortSigAction(join, s => + { + if (s == 1) + { + Debug.Console(2, this, "Join {0} value {1}: Setting stream state to start", join, s); + streamCard.Control.Start(); + } + else if (s == 2) + { + Debug.Console(2, this, "Join {0} value {1}: Setting stream state to stop", join, s); + streamCard.Control.Stop(); + } + else if (s == 3) + { + Debug.Console(2, this, "Join {0} value {1}: Setting stream state to pause", join, s); + streamCard.Control.Pause(); + } + else + { + Debug.Console(2, this, "Join {0} value {1}: Ignore stream state", join, s); + } + }); + + OutputStreamCardStateFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[join]); + + trilist.UShortInput[join].UShortValue = OutputStreamCardStateFeedbacks[ioSlot].UShortValue; + } + + private void LinkRxToApi(BasicTriList trilist, uint ioSlot, DmChassisControllerJoinMap joinMap, uint ioSlotJoin) + { + Debug.Console(2, "Creating Rx Feedbacks {0}", ioSlot); + var rxKey = RxDictionary[ioSlot]; + var rxDevice = DeviceManager.GetDeviceForKey(rxKey) as DmRmcControllerBase; + var hdBaseTDevice = DeviceManager.GetDeviceForKey(rxKey) as DmHdBaseTControllerBase; + if (Chassis is DmMd8x8Cpu3 || Chassis is DmMd8x8Cpu3rps + || Chassis is DmMd16x16Cpu3 || Chassis is DmMd16x16Cpu3rps + || Chassis is DmMd32x32Cpu3 || Chassis is DmMd32x32Cpu3rps || hdBaseTDevice != null) + { + OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig( + trilist.BooleanInput[joinMap.OutputEndpointOnline.JoinNumber + ioSlotJoin]); + } + else if (rxDevice != null) + { + rxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline.JoinNumber + ioSlotJoin]); + } + } + + private void LinkTxToApi(BasicTriList trilist, uint ioSlot, DmChassisControllerJoinMap joinMap, uint ioSlotJoin) + { + Debug.Console(1, "Setting up actions and feedbacks on input card {0}", ioSlot); + VideoInputSyncFeedbacks[ioSlot].LinkInputSig( + trilist.BooleanInput[joinMap.VideoSyncStatus.JoinNumber + ioSlotJoin]); + + Debug.Console(2, "Creating Tx Feedbacks {0}", ioSlot); + var txKey = TxDictionary[ioSlot]; + var txDevice = DeviceManager.GetDeviceForKey(txKey) as BasicDmTxControllerBase; + + if (txDevice == null) + { + return; + } + + LinkTxOnlineFeedbackToApi(trilist, ioSlot, joinMap, ioSlotJoin, txDevice); + + LinkBasicTxToApi(trilist, joinMap, ioSlot, ioSlotJoin, txDevice); + + LinkAdvancedTxToApi(trilist, joinMap, ioSlot, ioSlotJoin, txDevice); + } + + private void LinkBasicTxToApi(BasicTriList trilist, DmChassisControllerJoinMap joinMap, uint ioSlot, + uint ioSlotJoin, BasicDmTxControllerBase basicTransmitter) + { + var advTx = basicTransmitter as DmTxControllerBase; + + if (advTx != null) + { + return; + } + var inputPort = InputPorts[string.Format("inputCard{0}--dmIn", ioSlot)]; + + if (inputPort == null) + { + return; + } + var port = inputPort.Port; + + if (!(port is DMInputPortWithCec)) + { + Debug.Console(0, this, "DM Input port on card {0} does not support HDCP settings.", ioSlot); + return; + } + Debug.Console(1, "Port is DMInputPortWithCec"); + + var dmInPortWCec = port as DMInputPortWithCec; + + bool supportsHdcp2; + + //added in case the InputSlotSupportsHdcp2 section isn't included in the config, or this slot is left out. + //if the key isn't in the dictionary, supportsHdcp2 will be false + + if(!PropertiesConfig.InputSlotSupportsHdcp2.TryGetValue(ioSlot, out supportsHdcp2)) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Warning, + "Input Slot Supports HDCP2 setting not found for slot {0}. Setting to false. Program may not function as intended.", + ioSlot); + } + + SetHdcpStateAction(supportsHdcp2, dmInPortWCec, + joinMap.HdcpSupportState.JoinNumber + ioSlotJoin, trilist); + + InputCardHdcpStateFeedbacks[ioSlot].LinkInputSig( + trilist.UShortInput[joinMap.HdcpSupportState.JoinNumber + ioSlotJoin]); + + if (InputCardHdcpCapabilityTypes.ContainsKey(ioSlot)) + { + trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = + (ushort) InputCardHdcpCapabilityTypes[ioSlot]; + } + else + { + trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = 1; + } + + var videoStatus = inputPort as RoutingInputPortWithVideoStatuses; + + if (videoStatus == null) + { + return; + } + Debug.Console(1, this, "Linking {0} to join {1} for resolution feedback.", videoStatus.Key, joinMap.InputCurrentResolution.JoinNumber + ioSlotJoin); + videoStatus.VideoStatus.VideoResolutionFeedback.LinkInputSig(trilist.StringInput[joinMap.InputCurrentResolution.JoinNumber + ioSlotJoin]); + } + + private void LinkAdvancedTxToApi(BasicTriList trilist, DmChassisControllerJoinMap joinMap, + uint ioSlot, uint ioSlotJoin, BasicDmTxControllerBase basicTransmitter) + { + var transmitter = basicTransmitter as DmTxControllerBase; + if (transmitter == null) return; + + trilist.BooleanInput[joinMap.TxAdvancedIsPresent.JoinNumber + ioSlotJoin].BoolValue = true; + + transmitter.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig( + trilist.BooleanInput[joinMap.VideoSyncStatus.JoinNumber + ioSlotJoin]); + + var txRoutingInputs = transmitter as IRoutingInputs; + + if (txRoutingInputs == null) return; + + var inputPorts = + txRoutingInputs.InputPorts.Where( + (p) => p.Port is EndpointHdmiInput || p.Port is EndpointDisplayPortInput).ToList(); + + if (inputPorts.Count == 0) + { + Debug.Console(1, this, "No HDCP-capable input ports found on transmitter for slot {0}", ioSlot); + return; + } + + bool supportsHdcp2; + + if (!PropertiesConfig.InputSlotSupportsHdcp2.TryGetValue(ioSlot, out supportsHdcp2)) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Warning, + "Input Slot Supports HDCP2 setting not found for slot {0}. Setting to false. Program may not function as intended.", + ioSlot); + } + + SetHdcpStateAction(supportsHdcp2, inputPorts, joinMap.HdcpSupportState.JoinNumber + ioSlotJoin, trilist); + + if (transmitter.HdcpStateFeedback != null) + { + transmitter.HdcpStateFeedback.LinkInputSig( + trilist.UShortInput[joinMap.HdcpSupportState.JoinNumber + ioSlotJoin]); + } + else + { + Debug.Console(2, this, "Transmitter Hdcp Feedback null. Linking to card's feedback"); + InputCardHdcpStateFeedbacks[ioSlot].LinkInputSig( + trilist.UShortInput[joinMap.HdcpSupportState.JoinNumber + ioSlotJoin]); + } + + trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = + (ushort) transmitter.HdcpSupportCapability; + + + var videoStatus = + InputPorts[string.Format("inputCard{0}--dmIn", ioSlot)] as RoutingInputPortWithVideoStatuses; + + if (videoStatus == null) + { + return; + } + Debug.Console(1, this, "Linking {0} to join {1} for resolution feedback.", videoStatus.Key, + joinMap.InputCurrentResolution.JoinNumber + ioSlotJoin); + videoStatus.VideoStatus.VideoResolutionFeedback.LinkInputSig( + trilist.StringInput[joinMap.InputCurrentResolution.JoinNumber + ioSlotJoin]); + } + + private void LinkTxOnlineFeedbackToApi(BasicTriList trilist, uint ioSlot, DmChassisControllerJoinMap joinMap, + uint ioSlotJoin, BasicDmTxControllerBase txDevice) + { + var advancedTxDevice = txDevice as DmTxControllerBase; + + if ((Chassis is DmMd8x8Cpu3 || Chassis is DmMd8x8Cpu3rps + || Chassis is DmMd16x16Cpu3 || Chassis is DmMd16x16Cpu3rps + || Chassis is DmMd32x32Cpu3 || Chassis is DmMd32x32Cpu3rps) || + advancedTxDevice == null) + { + Debug.Console(2, "Linking Tx Online Feedback from Input Card {0}", ioSlot); + InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig( + trilist.BooleanInput[joinMap.InputEndpointOnline.JoinNumber + ioSlotJoin]); + return; + } + + Debug.Console(2, "Linking Tx Online Feedback from Advanced Transmitter at input {0}", ioSlot); + + advancedTxDevice.IsOnline.LinkInputSig( + trilist.BooleanInput[joinMap.InputEndpointOnline.JoinNumber + ioSlotJoin]); + } + + private void LinkRoutingJoinsToApi(BasicTriList trilist, DmChassisControllerJoinMap joinMap, uint ioSlotJoin, + uint ioSlot) + { + // Routing Control + trilist.SetUShortSigAction(joinMap.OutputVideo.JoinNumber + ioSlotJoin, + o => ExecuteNumericSwitch(o, (ushort) ioSlot, eRoutingSignalType.Video)); + trilist.SetUShortSigAction(joinMap.OutputAudio.JoinNumber + ioSlotJoin, + o => ExecuteNumericSwitch(o, (ushort) ioSlot, eRoutingSignalType.Audio)); + trilist.SetUShortSigAction(joinMap.OutputUsb.JoinNumber + ioSlotJoin, + o => ExecuteNumericSwitch(o, (ushort) ioSlot, eRoutingSignalType.UsbOutput)); + trilist.SetUShortSigAction(joinMap.InputUsb.JoinNumber + ioSlotJoin, + o => ExecuteNumericSwitch(o, (ushort) ioSlot, eRoutingSignalType.UsbInput)); + + //Routing Feedbacks + VideoOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputVideo.JoinNumber + ioSlotJoin]); + AudioOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputAudio.JoinNumber + ioSlotJoin]); + UsbOutputRoutedToFeebacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputUsb.JoinNumber + ioSlotJoin]); + UsbInputRoutedToFeebacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.InputUsb.JoinNumber + ioSlotJoin]); + + OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames.JoinNumber + ioSlotJoin]); + InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames.JoinNumber + ioSlotJoin]); + OutputVideoRouteNameFeedbacks[ioSlot].LinkInputSig( + trilist.StringInput[joinMap.OutputCurrentVideoInputNames.JoinNumber + ioSlotJoin]); + OutputAudioRouteNameFeedbacks[ioSlot].LinkInputSig( + trilist.StringInput[joinMap.OutputCurrentAudioInputNames.JoinNumber + ioSlotJoin]); + + OutputDisabledByHdcpFeedbacks[ioSlot].LinkInputSig( + trilist.BooleanInput[joinMap.OutputDisabledByHdcp.JoinNumber + ioSlotJoin]); + } + + private void LinkChassisToApi(BasicTriList trilist, DmChassisControllerJoinMap joinMap) + { + var chassis = Chassis as DmMDMnxn; + + IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + + trilist.SetUShortSigAction(joinMap.SystemId.JoinNumber, o => + { + if (chassis != null) + { + chassis.SystemId.UShortValue = o; + } + }); + + trilist.SetSigTrueAction(joinMap.SystemId.JoinNumber, () => + { + if (chassis != null) + { + chassis.ApplySystemId(); + } + }); + + SystemIdFeebdack.LinkInputSig(trilist.UShortInput[joinMap.SystemId.JoinNumber]); + SystemIdBusyFeedback.LinkInputSig(trilist.BooleanInput[joinMap.SystemId.JoinNumber]); + + EnableAudioBreakawayFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableAudioBreakaway.JoinNumber]); + EnableUsbBreakawayFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableUsbBreakaway.JoinNumber]); + + trilist.SetString(joinMap.NoRouteName.JoinNumber, NoRouteText); + + trilist.OnlineStatusChange += (o, a) => + { + if (!a.DeviceOnLine) + { + return; + } + + EnableAudioBreakawayFeedback.FireUpdate(); + EnableUsbBreakawayFeedback.FireUpdate(); + SystemIdBusyFeedback.FireUpdate(); + SystemIdFeebdack.FireUpdate(); + + trilist.SetString(joinMap.NoRouteName.JoinNumber, NoRouteText); + }; + } + + private DmChassisControllerJoinMap GetJoinMap(uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new DmChassisControllerJoinMap(joinStart); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + { + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + } + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + else + { + Debug.Console(0, this, + "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + } + return joinMap; + } + + private void SetHdcpStateAction(bool supportsHdcp2, HdmiInputWithCEC port, uint join, BasicTriList trilist) + { + if (!supportsHdcp2) + { + trilist.SetUShortSigAction(join, + s => + { + if (s == 0) + { + Debug.Console(2, this, "Join {0} value {1} Setting HdcpSupport to off", join, s); + port.HdcpSupportOff(); + } + else if (s > 0) + { + Debug.Console(2, this, "Join {0} value {1} Setting HdcpSupport to on", join, s); + port.HdcpSupportOn(); + } + }); + } + else + { + trilist.SetUShortSigAction(join, + u => + { + Debug.Console(2, this, "Join {0} value {1} Setting HdcpReceiveCapability to: {2}", join, u, (eHdcpCapabilityType)u); + port.HdcpReceiveCapability = (eHdcpCapabilityType)u; + }); + } + } + + private void SetHdcpStateAction(bool supportsHdcp2, EndpointHdmiInput port, uint join, BasicTriList trilist) + { + if (!supportsHdcp2) + { + trilist.SetUShortSigAction(join, + s => + { + if (s == 0) + { + Debug.Console(2, this, "Join {0} value {1} Setting HdcpSupport to off", join, s); + port.HdcpSupportOff(); + } + else if (s > 0) + { + Debug.Console(2, this, "Join {0} value {1} Setting HdcpSupport to on", join, s); + port.HdcpSupportOn(); + } + }); + } + else + { + trilist.SetUShortSigAction(join, + u => + { + Debug.Console(2, this, "Join {0} value {1} Setting HdcpReceiveCapability to: {2}", join, u, (eHdcpCapabilityType)u); + port.HdcpCapability = (eHdcpCapabilityType)u; + }); + } + } + + private void SetHdcpStateAction(bool supportsHdcp2, List ports, uint join, + BasicTriList triList) + { + if (!supportsHdcp2) + { + triList.SetUShortSigAction(join, a => + { + foreach (var tempPort in ports.Select(port => port.Port).OfType()) + { + if (a == 0) + { + tempPort.HdcpSupportOff(); + } + else if (a > 0) + { + tempPort.HdcpSupportOn(); + } + } + }); + } + else + { + triList.SetUShortSigAction(join, a => + { + foreach (var tempPort in ports.Select(port => port.Port).OfType()) + { + tempPort.HdcpCapability = (eHdcpCapabilityType) a; + } + }); + } + } + + private void SetHdcpStateAction(bool supportsHdcp2, DMInputPortWithCec port, uint join, BasicTriList trilist) + { + if (!supportsHdcp2) + { + trilist.SetUShortSigAction(join, + s => + { + if (s == 0) + { + port.HdcpSupportOff(); + } + else if (s > 0) + { + port.HdcpSupportOn(); + } + }); + } + else + { + trilist.SetUShortSigAction(join, + u => + { + port.HdcpReceiveCapability = (eHdcpCapabilityType)u; + }); + } + } + } + + public struct PortNumberType + { + public uint Number { get; private set; } + public object Selector { get; private set; } + public eRoutingSignalType Type { get; private set; } + + public PortNumberType(object selector, eRoutingSignalType type) + : this() + { + Selector = selector; + Type = type; + + if (Selector is DMOutput) + { + Number = (selector as DMOutput).Number; + } + else if (Selector is uint) + { + Number = (uint) selector; + } + } + } + + public class DmChassisControllerFactory : EssentialsDeviceFactory + { + public DmChassisControllerFactory() + { + TypeNames = new List() { "dmmd8x8", "dmmd8x8rps", "dmmd8x8cpu3", "dmmd8x8cpu3rps", + "dmmd16x16", "dmmd16x16rps", "dmmd16x16cpu3", "dmmd16x16cpu3rps", + "dmmd32x32", "dmmd32x32rps", "dmmd32x32cpu3", "dmmd32x32cpu3rps", + "dmmd64x64", "dmmd128x128" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + var type = dc.Type.ToLower(); + + Debug.Console(1, "Factory Attempting to create new DmChassisController Device"); + + if (type.StartsWith("dmmd8x") || type.StartsWith("dmmd16x") || type.StartsWith("dmmd32x")) + { + + var props = JsonConvert.DeserializeObject + (dc.Properties.ToString()); + return DmChassisController. + GetDmChassisController(dc.Key, dc.Name, type, props); + } + else if (type.StartsWith("dmmd128x") || type.StartsWith("dmmd64x")) + { + var props = JsonConvert.DeserializeObject + (dc.Properties.ToString()); + return DmBladeChassisController. + GetDmChassisController(dc.Key, dc.Name, type, props); + } + + return null; + } + } + } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsAudioOutputController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsAudioOutputController.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsAudioOutputController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsAudioOutputController.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsDigitalOutputController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsDigitalOutputController.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsDigitalOutputController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsDigitalOutputController.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsInternalVirtualDmTxController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsInternalVirtualDmTxController.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsInternalVirtualDmTxController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsInternalVirtualDmTxController.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsMicrophoneController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsMicrophoneController.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsMicrophoneController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsMicrophoneController.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMd8xNController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMd8xNController.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMd8xNController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMd8xNController.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMdNxM4kEBridgeableController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMdNxM4kEBridgeableController.cs similarity index 97% rename from essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMdNxM4kEBridgeableController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMdNxM4kEBridgeableController.cs index 3d41af3a..6fd85c22 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMdNxM4kEBridgeableController.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMdNxM4kEBridgeableController.cs @@ -1,504 +1,504 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.DM.Config; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Config; - -namespace PepperDash.Essentials.DM.Chassis -{ - [Description("Wrapper class for all HdMdNxM4E switchers")] - public class HdMdNxM4kEBridgeableController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, IHasFeedback - { - private HdMdNxM _Chassis; - private HdMd4x14kE _Chassis4x1; - - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - public Dictionary InputNames { get; set; } - public Dictionary OutputNames { get; set; } - - public RoutingPortCollection InputPorts { get; private set; } - public RoutingPortCollection OutputPorts { get; private set; } - - public FeedbackCollection VideoInputSyncFeedbacks { get; private set; } - public FeedbackCollection VideoOutputRouteFeedbacks { get; private set; } - public FeedbackCollection InputNameFeedbacks { get; private set; } - public FeedbackCollection OutputNameFeedbacks { get; private set; } - public FeedbackCollection OutputRouteNameFeedbacks { get; private set; } - public FeedbackCollection InputHdcpEnableFeedback { get; private set; } - public StringFeedback DeviceNameFeedback { get; private set; } - public BoolFeedback AutoRouteFeedback { get; private set; } - - #region Constructor - - public HdMdNxM4kEBridgeableController(string key, string name, HdMdNxM chassis, - HdMdNxM4kEBridgeablePropertiesConfig props) - : base(key, name, chassis) - { - _Chassis = chassis; - Name = name; - - if (props == null) - { - Debug.Console(1, this, "HdMdNx4keBridgeableController properties are null, failed to build the device"); - return; - } - - - if (props.Inputs != null) - { - foreach (var kvp in props.Inputs) - { - Debug.Console(1, this, "props.Inputs: {0}-{1}", kvp.Key, kvp.Value); - } - InputNames = props.Inputs; - } - if (props.Outputs != null) - { - foreach (var kvp in props.Outputs) - { - Debug.Console(1, this, "props.Outputs: {0}-{1}", kvp.Key, kvp.Value); - } - OutputNames = props.Outputs; - } - - DeviceNameFeedback = new StringFeedback(()=>Name); - - VideoInputSyncFeedbacks = new FeedbackCollection(); - VideoOutputRouteFeedbacks = new FeedbackCollection(); - InputNameFeedbacks = new FeedbackCollection(); - OutputNameFeedbacks = new FeedbackCollection(); - OutputRouteNameFeedbacks = new FeedbackCollection(); - InputHdcpEnableFeedback = new FeedbackCollection(); - - InputPorts = new RoutingPortCollection(); - OutputPorts = new RoutingPortCollection(); - - if (_Chassis.NumberOfInputs == 1) - { - _Chassis4x1 = _Chassis as HdMd4x14kE; - AutoRouteFeedback = new BoolFeedback(() => _Chassis4x1.AutoModeOnFeedback.BoolValue); - } - - for (uint i = 1; i <= _Chassis.NumberOfInputs; i++) - { - var index = i; - var inputName = InputNames[index]; - //_Chassis.Inputs[index].Name.StringValue = inputName; - _Chassis.HdmiInputs[index].Name.StringValue = inputName; - - InputPorts.Add(new RoutingInputPort(inputName, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, _Chassis.HdmiInputs[index], this) - { - FeedbackMatchObject = _Chassis.HdmiInputs[index] - }); - VideoInputSyncFeedbacks.Add(new BoolFeedback(inputName, () => _Chassis.Inputs[index].VideoDetectedFeedback.BoolValue)); - //InputNameFeedbacks.Add(new StringFeedback(inputName, () => _Chassis.Inputs[index].NameFeedback.StringValue)); - InputNameFeedbacks.Add(new StringFeedback(inputName, () => InputNames[index])); - InputHdcpEnableFeedback.Add(new BoolFeedback(inputName, () => _Chassis.HdmiInputs[index].HdmiInputPort.HdcpSupportOnFeedback.BoolValue)); - } - - for (uint i = 1; i <= _Chassis.NumberOfOutputs; i++) - { - var index = i; - var outputName = OutputNames[index]; - //_Chassis.Outputs[index].Name.StringValue = outputName; - //_Chassis.HdmiOutputs[index].Name.StringValue = outputName; - - OutputPorts.Add(new RoutingOutputPort(outputName, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, _Chassis.HdmiOutputs[index], this) - { - FeedbackMatchObject = _Chassis.HdmiOutputs[index] - }); - VideoOutputRouteFeedbacks.Add(new IntFeedback(outputName, () => _Chassis.Outputs[index].VideoOutFeedback == null ? 0 : (int)_Chassis.Outputs[index].VideoOutFeedback.Number)); - OutputNameFeedbacks.Add(new StringFeedback(outputName, () => OutputNames[index])); - OutputRouteNameFeedbacks.Add(new StringFeedback(outputName, () => _Chassis.Outputs[index].VideoOutFeedback.NameFeedback.StringValue)); - } - - _Chassis.DMInputChange += Chassis_DMInputChange; - _Chassis.DMOutputChange += Chassis_DMOutputChange; - - AddPostActivationAction(AddFeedbackCollections); - } - - #endregion - - #region Methods - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - - public void EnableHdcp(uint port) - { - if (port > _Chassis.NumberOfInputs) return; - if (port <= 0) return; - - _Chassis.HdmiInputs[port].HdmiInputPort.HdcpSupportOn(); - InputHdcpEnableFeedback[InputNames[port]].FireUpdate(); - } - - public void DisableHdcp(uint port) - { - if (port > _Chassis.NumberOfInputs) return; - if (port <= 0) return; - - _Chassis.HdmiInputs[port].HdmiInputPort.HdcpSupportOff(); - InputHdcpEnableFeedback[InputNames[port]].FireUpdate(); - } - - public void EnableAutoRoute() - { - if (_Chassis.NumberOfInputs != 1) return; - - if (_Chassis4x1 == null) return; - - _Chassis4x1.AutoModeOn(); - } - - public void DisableAutoRoute() - { - if (_Chassis.NumberOfInputs != 1) return; - - if (_Chassis4x1 == null) return; - - _Chassis4x1.AutoModeOff(); - } - - #region PostActivate - - public void AddFeedbackCollections() - { - AddFeedbackToList(DeviceNameFeedback); - AddCollectionsToList(VideoInputSyncFeedbacks, InputHdcpEnableFeedback); - AddCollectionsToList(VideoOutputRouteFeedbacks); - AddCollectionsToList(InputNameFeedbacks, OutputNameFeedbacks, OutputRouteNameFeedbacks); - } - - #endregion - - #region FeedbackCollection Methods - - //Add arrays of collections - public void AddCollectionsToList(params FeedbackCollection[] newFbs) - { - foreach (FeedbackCollection fbCollection in newFbs) - { - foreach (var item in newFbs) - { - AddCollectionToList(item); - } - } - } - public void AddCollectionsToList(params FeedbackCollection[] newFbs) - { - foreach (FeedbackCollection fbCollection in newFbs) - { - foreach (var item in newFbs) - { - AddCollectionToList(item); - } - } - } - - public void AddCollectionsToList(params FeedbackCollection[] newFbs) - { - foreach (FeedbackCollection fbCollection in newFbs) - { - foreach (var item in newFbs) - { - AddCollectionToList(item); - } - } - } - - //Add Collections - public void AddCollectionToList(FeedbackCollection newFbs) - { - foreach (var f in newFbs) - { - if (f == null) continue; - - AddFeedbackToList(f); - } - } - - public void AddCollectionToList(FeedbackCollection newFbs) - { - foreach (var f in newFbs) - { - if (f == null) continue; - - AddFeedbackToList(f); - } - } - - public void AddCollectionToList(FeedbackCollection newFbs) - { - foreach (var f in newFbs) - { - if (f == null) continue; - - AddFeedbackToList(f); - } - } - - //Add Individual Feedbacks - public void AddFeedbackToList(PepperDash.Essentials.Core.Feedback newFb) - { - if (newFb == null) return; - - if (!Feedbacks.Contains(newFb)) - { - Feedbacks.Add(newFb); - } - } - - #endregion - - #region IRouting Members - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - var input = inputSelector as HdMdNxMHdmiInput; //changed from HdMdNxM4kzEHdmiInput; - var output = outputSelector as HdMdNxMHdmiOutput; - Debug.Console(2, this, "ExecuteSwitch: input={0} output={1}", input, output); - - if (output == null) - { - Debug.Console(0, this, "Unable to make switch. output selector is not HdMdNxMHdmiOutput"); - return; - } - - // Try to make switch only when necessary. The unit appears to toggle when already selected. - var current = output.VideoOut; - if (current != input) - output.VideoOut = input; - } - - #endregion - - #region IRoutingNumeric Members - - public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType signalType) - { - var input = inputSelector == 0 ? null : _Chassis.HdmiInputs[inputSelector]; - var output = _Chassis.HdmiOutputs[outputSelector]; - - Debug.Console(2, this, "ExecuteNumericSwitch: input={0} output={1}", input, output); - - ExecuteSwitch(input, output, signalType); - } - - #endregion - - #endregion - - #region Bridge Linking - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new HdMdNxM4kEControllerJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - DeviceNameFeedback.LinkInputSig(trilist.StringInput[joinMap.Name.JoinNumber]); - - if (_Chassis4x1 != null) - { - trilist.SetSigTrueAction(joinMap.EnableAutoRoute.JoinNumber, () => _Chassis4x1.AutoModeOn()); - trilist.SetSigFalseAction(joinMap.EnableAutoRoute.JoinNumber, () => _Chassis4x1.AutoModeOff()); - AutoRouteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableAutoRoute.JoinNumber]); - } - - for (uint i = 1; i <= _Chassis.NumberOfInputs; i++) - { - var joinIndex = i - 1; - var input = i; - //Digital - VideoInputSyncFeedbacks[InputNames[input]].LinkInputSig(trilist.BooleanInput[joinMap.InputSync.JoinNumber + joinIndex]); - InputHdcpEnableFeedback[InputNames[input]].LinkInputSig(trilist.BooleanInput[joinMap.EnableInputHdcp.JoinNumber + joinIndex]); - InputHdcpEnableFeedback[InputNames[input]].LinkComplementInputSig(trilist.BooleanInput[joinMap.DisableInputHdcp.JoinNumber + joinIndex]); - trilist.SetSigTrueAction(joinMap.EnableInputHdcp.JoinNumber + joinIndex, () => EnableHdcp(input)); - trilist.SetSigTrueAction(joinMap.DisableInputHdcp.JoinNumber + joinIndex, () => DisableHdcp(input)); - - //Serial - InputNameFeedbacks[InputNames[input]].LinkInputSig(trilist.StringInput[joinMap.InputName.JoinNumber + joinIndex]); - } - - for (uint i = 1; i <= _Chassis.NumberOfOutputs; i++) - { - var joinIndex = i - 1; - var output = i; - //Analog - VideoOutputRouteFeedbacks[OutputNames[output]].LinkInputSig(trilist.UShortInput[joinMap.OutputRoute.JoinNumber + joinIndex]); - trilist.SetUShortSigAction(joinMap.OutputRoute.JoinNumber + joinIndex, (a) => ExecuteNumericSwitch(a, (ushort) output, eRoutingSignalType.AudioVideo)); - - //Serial - OutputNameFeedbacks[OutputNames[output]].LinkInputSig(trilist.StringInput[joinMap.OutputName.JoinNumber + joinIndex]); - OutputRouteNameFeedbacks[OutputNames[output]].LinkInputSig(trilist.StringInput[joinMap.OutputRoutedName.JoinNumber + joinIndex]); - } - - _Chassis.OnlineStatusChange += Chassis_OnlineStatusChange; - - trilist.OnlineStatusChange += (d, args) => - { - if (!args.DeviceOnLine) return; - - // feedback updates was moved to the Chassis_OnlineStatusChange - // due to the amount of time it takes for the device to come online - }; - } - - - #endregion - - #region Events - - void Chassis_OnlineStatusChange(Crestron.SimplSharpPro.GenericBase currentDevice, Crestron.SimplSharpPro.OnlineOfflineEventArgs args) - { - IsOnline.FireUpdate(); - - if (!args.DeviceOnLine) return; - - foreach (var feedback in Feedbacks) - { - feedback.FireUpdate(); - } - - if (_Chassis4x1 != null) - AutoRouteFeedback.FireUpdate(); - } - - void Chassis_DMOutputChange(Switch device, DMOutputEventArgs args) - { - if (args.EventId != DMOutputEventIds.VideoOutEventId) return; - - var output = args.Number; - - var inputNumber = _Chassis.HdmiOutputs[output].VideoOutFeedback == null - ? 0 - : _Chassis.HdmiOutputs[output].VideoOutFeedback.Number; - - var outputName = OutputNames[output]; - - var feedback = VideoOutputRouteFeedbacks[outputName]; - - if (feedback == null) - { - return; - } - var inPort = - InputPorts.FirstOrDefault(p => p.FeedbackMatchObject == _Chassis.HdmiOutputs[output].VideoOutFeedback); - var outPort = OutputPorts.FirstOrDefault(p => p.FeedbackMatchObject == _Chassis.HdmiOutputs[output]); - - feedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(output, inputNumber, outPort, inPort, eRoutingSignalType.AudioVideo)); - } - - void Chassis_DMInputChange(Switch device, DMInputEventArgs args) - { - switch (args.EventId) - { - case DMInputEventIds.VideoDetectedEventId: - { - Debug.Console(1, this, "Event ID {0}: Updating VideoInputSyncFeedbacks", args.EventId); - foreach (var item in VideoInputSyncFeedbacks) - { - item.FireUpdate(); - } - break; - } - case DMInputEventIds.InputNameFeedbackEventId: - case DMInputEventIds.InputNameEventId: - case DMInputEventIds.NameFeedbackEventId: - { - Debug.Console(1, this, "Event ID {0}: Updating name feedbacks.", args.EventId); - Debug.Console(1, this, "Input {0} Name {1}", args.Number, - _Chassis.HdmiInputs[args.Number].NameFeedback.StringValue); - foreach (var item in InputNameFeedbacks) - { - item.FireUpdate(); - } - break; - } - default: - { - Debug.Console(1, this, "Unhandled DM Input Event ID {0}", args.EventId); - break; - } - } - } - - #endregion - - #region Factory - - public class HdMdNxM4kEControllerFactory : EssentialsDeviceFactory - { - public HdMdNxM4kEControllerFactory() - { - TypeNames = new List() { "hdmd4x14ke-bridgeable", "hdmd4x24ke", "hdmd6x24ke" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new HD-MD-NxM-4K-E Device"); - - var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); - - var type = dc.Type.ToLower(); - var control = props.Control; - var ipid = control.IpIdInt; - var address = control.TcpSshProperties.Address; - - switch (type) - { - case ("hdmd4x14ke-bridgeable"): - return new HdMdNxM4kEBridgeableController(dc.Key, dc.Name, new HdMd4x14kE(ipid, address, Global.ControlSystem), props); - case ("hdmd4x24ke"): - return new HdMdNxM4kEBridgeableController(dc.Key, dc.Name, new HdMd4x24kE(ipid, address, Global.ControlSystem), props); - case ("hdmd6x24ke"): - return new HdMdNxM4kEBridgeableController(dc.Key, dc.Name, new HdMd6x24kE(ipid, address, Global.ControlSystem), props); - default: - return null; - } - } - } - - #endregion - - - - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.DM.Config; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.DM.Chassis +{ + [Description("Wrapper class for all HdMdNxM4E switchers")] + public class HdMdNxM4kEBridgeableController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, IHasFeedback + { + private HdMdNxM _Chassis; + private HdMd4x14kE _Chassis4x1; + + //IroutingNumericEvent + public event EventHandler NumericSwitchChange; + + public Dictionary InputNames { get; set; } + public Dictionary OutputNames { get; set; } + + public RoutingPortCollection InputPorts { get; private set; } + public RoutingPortCollection OutputPorts { get; private set; } + + public FeedbackCollection VideoInputSyncFeedbacks { get; private set; } + public FeedbackCollection VideoOutputRouteFeedbacks { get; private set; } + public FeedbackCollection InputNameFeedbacks { get; private set; } + public FeedbackCollection OutputNameFeedbacks { get; private set; } + public FeedbackCollection OutputRouteNameFeedbacks { get; private set; } + public FeedbackCollection InputHdcpEnableFeedback { get; private set; } + public StringFeedback DeviceNameFeedback { get; private set; } + public BoolFeedback AutoRouteFeedback { get; private set; } + + #region Constructor + + public HdMdNxM4kEBridgeableController(string key, string name, HdMdNxM chassis, + HdMdNxM4kEBridgeablePropertiesConfig props) + : base(key, name, chassis) + { + _Chassis = chassis; + Name = name; + + if (props == null) + { + Debug.Console(1, this, "HdMdNx4keBridgeableController properties are null, failed to build the device"); + return; + } + + + if (props.Inputs != null) + { + foreach (var kvp in props.Inputs) + { + Debug.Console(1, this, "props.Inputs: {0}-{1}", kvp.Key, kvp.Value); + } + InputNames = props.Inputs; + } + if (props.Outputs != null) + { + foreach (var kvp in props.Outputs) + { + Debug.Console(1, this, "props.Outputs: {0}-{1}", kvp.Key, kvp.Value); + } + OutputNames = props.Outputs; + } + + DeviceNameFeedback = new StringFeedback(()=>Name); + + VideoInputSyncFeedbacks = new FeedbackCollection(); + VideoOutputRouteFeedbacks = new FeedbackCollection(); + InputNameFeedbacks = new FeedbackCollection(); + OutputNameFeedbacks = new FeedbackCollection(); + OutputRouteNameFeedbacks = new FeedbackCollection(); + InputHdcpEnableFeedback = new FeedbackCollection(); + + InputPorts = new RoutingPortCollection(); + OutputPorts = new RoutingPortCollection(); + + if (_Chassis.NumberOfInputs == 1) + { + _Chassis4x1 = _Chassis as HdMd4x14kE; + AutoRouteFeedback = new BoolFeedback(() => _Chassis4x1.AutoModeOnFeedback.BoolValue); + } + + for (uint i = 1; i <= _Chassis.NumberOfInputs; i++) + { + var index = i; + var inputName = InputNames[index]; + //_Chassis.Inputs[index].Name.StringValue = inputName; + _Chassis.HdmiInputs[index].Name.StringValue = inputName; + + InputPorts.Add(new RoutingInputPort(inputName, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.Hdmi, _Chassis.HdmiInputs[index], this) + { + FeedbackMatchObject = _Chassis.HdmiInputs[index] + }); + VideoInputSyncFeedbacks.Add(new BoolFeedback(inputName, () => _Chassis.Inputs[index].VideoDetectedFeedback.BoolValue)); + //InputNameFeedbacks.Add(new StringFeedback(inputName, () => _Chassis.Inputs[index].NameFeedback.StringValue)); + InputNameFeedbacks.Add(new StringFeedback(inputName, () => InputNames[index])); + InputHdcpEnableFeedback.Add(new BoolFeedback(inputName, () => _Chassis.HdmiInputs[index].HdmiInputPort.HdcpSupportOnFeedback.BoolValue)); + } + + for (uint i = 1; i <= _Chassis.NumberOfOutputs; i++) + { + var index = i; + var outputName = OutputNames[index]; + //_Chassis.Outputs[index].Name.StringValue = outputName; + //_Chassis.HdmiOutputs[index].Name.StringValue = outputName; + + OutputPorts.Add(new RoutingOutputPort(outputName, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.Hdmi, _Chassis.HdmiOutputs[index], this) + { + FeedbackMatchObject = _Chassis.HdmiOutputs[index] + }); + VideoOutputRouteFeedbacks.Add(new IntFeedback(outputName, () => _Chassis.Outputs[index].VideoOutFeedback == null ? 0 : (int)_Chassis.Outputs[index].VideoOutFeedback.Number)); + OutputNameFeedbacks.Add(new StringFeedback(outputName, () => OutputNames[index])); + OutputRouteNameFeedbacks.Add(new StringFeedback(outputName, () => _Chassis.Outputs[index].VideoOutFeedback.NameFeedback.StringValue)); + } + + _Chassis.DMInputChange += Chassis_DMInputChange; + _Chassis.DMOutputChange += Chassis_DMOutputChange; + + AddPostActivationAction(AddFeedbackCollections); + } + + #endregion + + #region Methods + + /// + /// Raise an event when the status of a switch object changes. + /// + /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType + private void OnSwitchChange(RoutingNumericEventArgs e) + { + var newEvent = NumericSwitchChange; + if (newEvent != null) newEvent(this, e); + } + + public void EnableHdcp(uint port) + { + if (port > _Chassis.NumberOfInputs) return; + if (port <= 0) return; + + _Chassis.HdmiInputs[port].HdmiInputPort.HdcpSupportOn(); + InputHdcpEnableFeedback[InputNames[port]].FireUpdate(); + } + + public void DisableHdcp(uint port) + { + if (port > _Chassis.NumberOfInputs) return; + if (port <= 0) return; + + _Chassis.HdmiInputs[port].HdmiInputPort.HdcpSupportOff(); + InputHdcpEnableFeedback[InputNames[port]].FireUpdate(); + } + + public void EnableAutoRoute() + { + if (_Chassis.NumberOfInputs != 1) return; + + if (_Chassis4x1 == null) return; + + _Chassis4x1.AutoModeOn(); + } + + public void DisableAutoRoute() + { + if (_Chassis.NumberOfInputs != 1) return; + + if (_Chassis4x1 == null) return; + + _Chassis4x1.AutoModeOff(); + } + + #region PostActivate + + public void AddFeedbackCollections() + { + AddFeedbackToList(DeviceNameFeedback); + AddCollectionsToList(VideoInputSyncFeedbacks, InputHdcpEnableFeedback); + AddCollectionsToList(VideoOutputRouteFeedbacks); + AddCollectionsToList(InputNameFeedbacks, OutputNameFeedbacks, OutputRouteNameFeedbacks); + } + + #endregion + + #region FeedbackCollection Methods + + //Add arrays of collections + public void AddCollectionsToList(params FeedbackCollection[] newFbs) + { + foreach (FeedbackCollection fbCollection in newFbs) + { + foreach (var item in newFbs) + { + AddCollectionToList(item); + } + } + } + public void AddCollectionsToList(params FeedbackCollection[] newFbs) + { + foreach (FeedbackCollection fbCollection in newFbs) + { + foreach (var item in newFbs) + { + AddCollectionToList(item); + } + } + } + + public void AddCollectionsToList(params FeedbackCollection[] newFbs) + { + foreach (FeedbackCollection fbCollection in newFbs) + { + foreach (var item in newFbs) + { + AddCollectionToList(item); + } + } + } + + //Add Collections + public void AddCollectionToList(FeedbackCollection newFbs) + { + foreach (var f in newFbs) + { + if (f == null) continue; + + AddFeedbackToList(f); + } + } + + public void AddCollectionToList(FeedbackCollection newFbs) + { + foreach (var f in newFbs) + { + if (f == null) continue; + + AddFeedbackToList(f); + } + } + + public void AddCollectionToList(FeedbackCollection newFbs) + { + foreach (var f in newFbs) + { + if (f == null) continue; + + AddFeedbackToList(f); + } + } + + //Add Individual Feedbacks + public void AddFeedbackToList(PepperDash.Essentials.Core.Feedback newFb) + { + if (newFb == null) return; + + if (!Feedbacks.Contains(newFb)) + { + Feedbacks.Add(newFb); + } + } + + #endregion + + #region IRouting Members + + public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) + { + var input = inputSelector as HdMdNxMHdmiInput; //changed from HdMdNxM4kzEHdmiInput; + var output = outputSelector as HdMdNxMHdmiOutput; + Debug.Console(2, this, "ExecuteSwitch: input={0} output={1}", input, output); + + if (output == null) + { + Debug.Console(0, this, "Unable to make switch. output selector is not HdMdNxMHdmiOutput"); + return; + } + + // Try to make switch only when necessary. The unit appears to toggle when already selected. + var current = output.VideoOut; + if (current != input) + output.VideoOut = input; + } + + #endregion + + #region IRoutingNumeric Members + + public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType signalType) + { + var input = inputSelector == 0 ? null : _Chassis.HdmiInputs[inputSelector]; + var output = _Chassis.HdmiOutputs[outputSelector]; + + Debug.Console(2, this, "ExecuteNumericSwitch: input={0} output={1}", input, output); + + ExecuteSwitch(input, output, signalType); + } + + #endregion + + #endregion + + #region Bridge Linking + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new HdMdNxM4kEControllerJoinMap(joinStart); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + else + { + Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + } + + IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + DeviceNameFeedback.LinkInputSig(trilist.StringInput[joinMap.Name.JoinNumber]); + + if (_Chassis4x1 != null) + { + trilist.SetSigTrueAction(joinMap.EnableAutoRoute.JoinNumber, () => _Chassis4x1.AutoModeOn()); + trilist.SetSigFalseAction(joinMap.EnableAutoRoute.JoinNumber, () => _Chassis4x1.AutoModeOff()); + AutoRouteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableAutoRoute.JoinNumber]); + } + + for (uint i = 1; i <= _Chassis.NumberOfInputs; i++) + { + var joinIndex = i - 1; + var input = i; + //Digital + VideoInputSyncFeedbacks[InputNames[input]].LinkInputSig(trilist.BooleanInput[joinMap.InputSync.JoinNumber + joinIndex]); + InputHdcpEnableFeedback[InputNames[input]].LinkInputSig(trilist.BooleanInput[joinMap.EnableInputHdcp.JoinNumber + joinIndex]); + InputHdcpEnableFeedback[InputNames[input]].LinkComplementInputSig(trilist.BooleanInput[joinMap.DisableInputHdcp.JoinNumber + joinIndex]); + trilist.SetSigTrueAction(joinMap.EnableInputHdcp.JoinNumber + joinIndex, () => EnableHdcp(input)); + trilist.SetSigTrueAction(joinMap.DisableInputHdcp.JoinNumber + joinIndex, () => DisableHdcp(input)); + + //Serial + InputNameFeedbacks[InputNames[input]].LinkInputSig(trilist.StringInput[joinMap.InputName.JoinNumber + joinIndex]); + } + + for (uint i = 1; i <= _Chassis.NumberOfOutputs; i++) + { + var joinIndex = i - 1; + var output = i; + //Analog + VideoOutputRouteFeedbacks[OutputNames[output]].LinkInputSig(trilist.UShortInput[joinMap.OutputRoute.JoinNumber + joinIndex]); + trilist.SetUShortSigAction(joinMap.OutputRoute.JoinNumber + joinIndex, (a) => ExecuteNumericSwitch(a, (ushort) output, eRoutingSignalType.AudioVideo)); + + //Serial + OutputNameFeedbacks[OutputNames[output]].LinkInputSig(trilist.StringInput[joinMap.OutputName.JoinNumber + joinIndex]); + OutputRouteNameFeedbacks[OutputNames[output]].LinkInputSig(trilist.StringInput[joinMap.OutputRoutedName.JoinNumber + joinIndex]); + } + + _Chassis.OnlineStatusChange += Chassis_OnlineStatusChange; + + trilist.OnlineStatusChange += (d, args) => + { + if (!args.DeviceOnLine) return; + + // feedback updates was moved to the Chassis_OnlineStatusChange + // due to the amount of time it takes for the device to come online + }; + } + + + #endregion + + #region Events + + void Chassis_OnlineStatusChange(Crestron.SimplSharpPro.GenericBase currentDevice, Crestron.SimplSharpPro.OnlineOfflineEventArgs args) + { + IsOnline.FireUpdate(); + + if (!args.DeviceOnLine) return; + + foreach (var feedback in Feedbacks) + { + feedback.FireUpdate(); + } + + if (_Chassis4x1 != null) + AutoRouteFeedback.FireUpdate(); + } + + void Chassis_DMOutputChange(Switch device, DMOutputEventArgs args) + { + if (args.EventId != DMOutputEventIds.VideoOutEventId) return; + + var output = args.Number; + + var inputNumber = _Chassis.HdmiOutputs[output].VideoOutFeedback == null + ? 0 + : _Chassis.HdmiOutputs[output].VideoOutFeedback.Number; + + var outputName = OutputNames[output]; + + var feedback = VideoOutputRouteFeedbacks[outputName]; + + if (feedback == null) + { + return; + } + var inPort = + InputPorts.FirstOrDefault(p => p.FeedbackMatchObject == _Chassis.HdmiOutputs[output].VideoOutFeedback); + var outPort = OutputPorts.FirstOrDefault(p => p.FeedbackMatchObject == _Chassis.HdmiOutputs[output]); + + feedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(output, inputNumber, outPort, inPort, eRoutingSignalType.AudioVideo)); + } + + void Chassis_DMInputChange(Switch device, DMInputEventArgs args) + { + switch (args.EventId) + { + case DMInputEventIds.VideoDetectedEventId: + { + Debug.Console(1, this, "Event ID {0}: Updating VideoInputSyncFeedbacks", args.EventId); + foreach (var item in VideoInputSyncFeedbacks) + { + item.FireUpdate(); + } + break; + } + case DMInputEventIds.InputNameFeedbackEventId: + case DMInputEventIds.InputNameEventId: + case DMInputEventIds.NameFeedbackEventId: + { + Debug.Console(1, this, "Event ID {0}: Updating name feedbacks.", args.EventId); + Debug.Console(1, this, "Input {0} Name {1}", args.Number, + _Chassis.HdmiInputs[args.Number].NameFeedback.StringValue); + foreach (var item in InputNameFeedbacks) + { + item.FireUpdate(); + } + break; + } + default: + { + Debug.Console(1, this, "Unhandled DM Input Event ID {0}", args.EventId); + break; + } + } + } + + #endregion + + #region Factory + + public class HdMdNxM4kEControllerFactory : EssentialsDeviceFactory + { + public HdMdNxM4kEControllerFactory() + { + TypeNames = new List() { "hdmd4x14ke-bridgeable", "hdmd4x24ke", "hdmd6x24ke" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new HD-MD-NxM-4K-E Device"); + + var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); + + var type = dc.Type.ToLower(); + var control = props.Control; + var ipid = control.IpIdInt; + var address = control.TcpSshProperties.Address; + + switch (type) + { + case ("hdmd4x14ke-bridgeable"): + return new HdMdNxM4kEBridgeableController(dc.Key, dc.Name, new HdMd4x14kE(ipid, address, Global.ControlSystem), props); + case ("hdmd4x24ke"): + return new HdMdNxM4kEBridgeableController(dc.Key, dc.Name, new HdMd4x24kE(ipid, address, Global.ControlSystem), props); + case ("hdmd6x24ke"): + return new HdMdNxM4kEBridgeableController(dc.Key, dc.Name, new HdMd6x24kE(ipid, address, Global.ControlSystem), props); + default: + return null; + } + } + } + + #endregion + + + + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMdNxM4kEController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMdNxM4kEController.cs similarity index 97% rename from essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMdNxM4kEController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMdNxM4kEController.cs index b47139e2..60616a06 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMdNxM4kEController.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMdNxM4kEController.cs @@ -1,169 +1,169 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DM; -using Newtonsoft.Json; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.DM.Config; - -namespace PepperDash.Essentials.DM.Chassis -{ - [Obsolete("Please use HdMdNxM4kEBridgeable Controller")] - public class HdMdNxM4kEController : CrestronGenericBaseDevice, IRoutingInputsOutputs, IRouting - { - public HdMdNxM Chassis { get; private set; } - - public RoutingPortCollection InputPorts { get; private set; } - public RoutingPortCollection OutputPorts { get; private set; } - - - /// - /// - /// - /// - /// - /// - public HdMdNxM4kEController(string key, string name, HdMdNxM chassis, - HdMdNxM4kEPropertiesConfig props) - : base(key, name, chassis) - { - Debug.Console(0, this, "Type hdmd4x14ke is obsolete. Please use hdmd4x14ke-bridgeable"); - Chassis = chassis; - - // logical ports - InputPorts = new RoutingPortCollection(); - for (uint i = 1; i <= 4; i++) - { - InputPorts.Add(new RoutingInputPort("hdmiIn" + i, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, i, this)); - } - OutputPorts = new RoutingPortCollection(); - OutputPorts.Add(new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null, this)); - - // physical settings - if (props != null && props.Inputs != null) - { - var inputRegex = new Regex(@"(?\d)", RegexOptions.IgnoreCase); - foreach (var kvp in props.Inputs) - { - // get numnbers from key and convert to int - //var inputNum = Convert.ToUInt32(kvp.Key.Substring(6)); - var inputMatch = inputRegex.Match(kvp.Key); - if (inputMatch == null) continue; - - var inputNum = Convert.ToUInt32(inputMatch.Groups["InputNum"].Value); - - var port = chassis.HdmiInputs[inputNum].HdmiInputPort; - // set hdcp disables - if (kvp.Value.DisableHdcp) - { - Debug.Console(0, this, "Configuration disables HDCP support on {0}", kvp.Key); - port.HdcpSupportOff(); - } - else - port.HdcpSupportOn(); - } - } - } - - public override bool CustomActivate() - { - var result = Chassis.Register(); - if (result != Crestron.SimplSharpPro.eDeviceRegistrationUnRegistrationResponse.Success) - { - Debug.Console(0, this, "Device registration failed: {0}", result); - return false; - } - - return base.CustomActivate(); - } - - - - #region IRouting Members - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - // Try to make switch only when necessary. The unit appears to toggle when already selected. - var current = Chassis.HdmiOutputs[1].VideoOut; - if (current != Chassis.HdmiInputs[(uint)inputSelector]) - Chassis.HdmiOutputs[1].VideoOut = Chassis.HdmiInputs[(uint)inputSelector]; - } - - #endregion - - ///////////////////////////////////////////////////// - - /// - /// - /// - /// - /// - /// - /// - /// - /// /* - /* - public static HdMdNxM4kEController GetController(string key, string name, - string type, HdMdNxM4kEPropertiesConfig properties) - { - try - { - var ipid = properties.Control.IpIdInt; - var address = properties.Control.TcpSshProperties.Address; - - type = type.ToLower(); - if (type == "hdmd4x14ke") - { - Debug.Console(0, @"The 'hdmd4x14ke' device is not an Essentials Bridgeable device. - If an essentials Bridgeable Device is required, use the 'hdmd4x14ke-bridgeable' type"); - - var chassis = new HdMd4x14kE(ipid, address, Global.ControlSystem); - return new HdMdNxM4kEController(key, name, chassis, properties); - } - return null; - } - catch (Exception e) - { - Debug.Console(0, "ERROR Creating device key {0}: \r{1}", key, e); - return null; - } - }*/ - - #region Factory - - public class HdMdNxM4kEFactory : EssentialsDeviceFactory - { - public HdMdNxM4kEFactory() - { - TypeNames = new List() {"hdmd4x14ke"}; - } - - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new HD-MD-NxM-4K-E Device"); - - var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); - - var type = dc.Type.ToLower(); - var control = props.Control; - var ipid = control.IpIdInt; - var address = control.TcpSshProperties.Address; - - return new HdMdNxM4kEController(dc.Key, dc.Name, new HdMd4x14kE(ipid, address, Global.ControlSystem), props); - - } - } - - #endregion - - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DM; +using Newtonsoft.Json; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.DM.Config; + +namespace PepperDash.Essentials.DM.Chassis +{ + [Obsolete("Please use HdMdNxM4kEBridgeable Controller")] + public class HdMdNxM4kEController : CrestronGenericBaseDevice, IRoutingInputsOutputs, IRouting + { + public HdMdNxM Chassis { get; private set; } + + public RoutingPortCollection InputPorts { get; private set; } + public RoutingPortCollection OutputPorts { get; private set; } + + + /// + /// + /// + /// + /// + /// + public HdMdNxM4kEController(string key, string name, HdMdNxM chassis, + HdMdNxM4kEPropertiesConfig props) + : base(key, name, chassis) + { + Debug.Console(0, this, "Type hdmd4x14ke is obsolete. Please use hdmd4x14ke-bridgeable"); + Chassis = chassis; + + // logical ports + InputPorts = new RoutingPortCollection(); + for (uint i = 1; i <= 4; i++) + { + InputPorts.Add(new RoutingInputPort("hdmiIn" + i, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, i, this)); + } + OutputPorts = new RoutingPortCollection(); + OutputPorts.Add(new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, null, this)); + + // physical settings + if (props != null && props.Inputs != null) + { + var inputRegex = new Regex(@"(?\d)", RegexOptions.IgnoreCase); + foreach (var kvp in props.Inputs) + { + // get numnbers from key and convert to int + //var inputNum = Convert.ToUInt32(kvp.Key.Substring(6)); + var inputMatch = inputRegex.Match(kvp.Key); + if (inputMatch == null) continue; + + var inputNum = Convert.ToUInt32(inputMatch.Groups["InputNum"].Value); + + var port = chassis.HdmiInputs[inputNum].HdmiInputPort; + // set hdcp disables + if (kvp.Value.DisableHdcp) + { + Debug.Console(0, this, "Configuration disables HDCP support on {0}", kvp.Key); + port.HdcpSupportOff(); + } + else + port.HdcpSupportOn(); + } + } + } + + public override bool CustomActivate() + { + var result = Chassis.Register(); + if (result != Crestron.SimplSharpPro.eDeviceRegistrationUnRegistrationResponse.Success) + { + Debug.Console(0, this, "Device registration failed: {0}", result); + return false; + } + + return base.CustomActivate(); + } + + + + #region IRouting Members + + public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) + { + // Try to make switch only when necessary. The unit appears to toggle when already selected. + var current = Chassis.HdmiOutputs[1].VideoOut; + if (current != Chassis.HdmiInputs[(uint)inputSelector]) + Chassis.HdmiOutputs[1].VideoOut = Chassis.HdmiInputs[(uint)inputSelector]; + } + + #endregion + + ///////////////////////////////////////////////////// + + /// + /// + /// + /// + /// + /// + /// + /// + /// /* + /* + public static HdMdNxM4kEController GetController(string key, string name, + string type, HdMdNxM4kEPropertiesConfig properties) + { + try + { + var ipid = properties.Control.IpIdInt; + var address = properties.Control.TcpSshProperties.Address; + + type = type.ToLower(); + if (type == "hdmd4x14ke") + { + Debug.Console(0, @"The 'hdmd4x14ke' device is not an Essentials Bridgeable device. + If an essentials Bridgeable Device is required, use the 'hdmd4x14ke-bridgeable' type"); + + var chassis = new HdMd4x14kE(ipid, address, Global.ControlSystem); + return new HdMdNxM4kEController(key, name, chassis, properties); + } + return null; + } + catch (Exception e) + { + Debug.Console(0, "ERROR Creating device key {0}: \r{1}", key, e); + return null; + } + }*/ + + #region Factory + + public class HdMdNxM4kEFactory : EssentialsDeviceFactory + { + public HdMdNxM4kEFactory() + { + TypeNames = new List() {"hdmd4x14ke"}; + } + + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new HD-MD-NxM-4K-E Device"); + + var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); + + var type = dc.Type.ToLower(); + var control = props.Control; + var ipid = control.IpIdInt; + var address = control.TcpSshProperties.Address; + + return new HdMdNxM4kEController(dc.Key, dc.Name, new HdMd4x14kE(ipid, address, Global.ControlSystem), props); + + } + } + + #endregion + + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxAnalogAuxMixerController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxAnalogAuxMixerController.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxAnalogAuxMixerController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxAnalogAuxMixerController.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxOutputAudioController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxOutputAudioController.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxOutputAudioController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxOutputAudioController.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Config/DMChassisConfig.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Config/DMChassisConfig.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Config/DMChassisConfig.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Config/DMChassisConfig.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Config/DeviceFactory.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Config/DeviceFactory.cs similarity index 97% rename from essentials-framework/Essentials DM/Essentials_DM/Config/DeviceFactory.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Config/DeviceFactory.cs index 5c532ac5..605a98e4 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Config/DeviceFactory.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Config/DeviceFactory.cs @@ -1,51 +1,51 @@ -using System; -using System.Linq; -using System.Collections.Generic; -using Crestron.SimplSharp; -using Crestron.SimplSharp.CrestronIO; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.AirMedia; -using Crestron.SimplSharpPro.UI; -using Crestron.SimplSharp.Reflection; - -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.DM.AirMedia; -using PepperDash.Essentials.DM.Endpoints.DGEs; - -namespace PepperDash.Essentials.DM -{ - /// - /// Responsible for loading the type factories for this library - /// - public class DeviceFactory - { - public DeviceFactory() - { - var assy = Assembly.GetExecutingAssembly(); - PluginLoader.SetEssentialsAssembly(assy.GetName().Name, assy); - - var types = assy.GetTypes().Where(ct => typeof(IDeviceFactory).IsAssignableFrom(ct) && !ct.IsInterface && !ct.IsAbstract); - - if (types != null) - { - foreach (var type in types) - { - try - { - var factory = (IDeviceFactory)Crestron.SimplSharp.Reflection.Activator.CreateInstance(type); - factory.LoadTypeFactories(); - } - catch (Exception e) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to load type: '{1}' DeviceFactory: {0}", e, type.Name); - } - } - } - } - } +using System; +using System.Linq; +using System.Collections.Generic; +using Crestron.SimplSharp; +using Crestron.SimplSharp.CrestronIO; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.AirMedia; +using Crestron.SimplSharpPro.UI; +using Crestron.SimplSharp.Reflection; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.DM.AirMedia; +using PepperDash.Essentials.DM.Endpoints.DGEs; + +namespace PepperDash.Essentials.DM +{ + /// + /// Responsible for loading the type factories for this library + /// + public class DeviceFactory + { + public DeviceFactory() + { + var assy = Assembly.GetExecutingAssembly(); + PluginLoader.SetEssentialsAssembly(assy.GetName().Name, assy); + + var types = assy.GetTypes().Where(ct => typeof(IDeviceFactory).IsAssignableFrom(ct) && !ct.IsInterface && !ct.IsAbstract); + + if (types != null) + { + foreach (var type in types) + { + try + { + var factory = (IDeviceFactory)Crestron.SimplSharp.Reflection.Activator.CreateInstance(type); + factory.LoadTypeFactories(); + } + catch (Exception e) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to load type: '{1}' DeviceFactory: {0}", e, type.Name); + } + } + } + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Config/DmRmcConfig.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Config/DmRmcConfig.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Config/DmRmcConfig.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Config/DmRmcConfig.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Config/DmTxConfig.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Config/DmTxConfig.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Config/DmTxConfig.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Config/DmTxConfig.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Config/DmpsRoutingConfig.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Config/DmpsRoutingConfig.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Config/DmpsRoutingConfig.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Config/DmpsRoutingConfig.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Config/HdMdNxM4kEPropertiesConfig.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Config/HdMdNxM4kEPropertiesConfig.cs similarity index 97% rename from essentials-framework/Essentials DM/Essentials_DM/Config/HdMdNxM4kEPropertiesConfig.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Config/HdMdNxM4kEPropertiesConfig.cs index f222694a..2873e2b5 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Config/HdMdNxM4kEPropertiesConfig.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Config/HdMdNxM4kEPropertiesConfig.cs @@ -8,28 +8,28 @@ using Newtonsoft.Json; using PepperDash.Core; namespace PepperDash.Essentials.DM.Config -{ - /// - /// Defines the properties section of HdMdNxM boxes - /// - public class HdMdNxM4kEPropertiesConfig - { - [JsonProperty("control")] - public ControlPropertiesConfig Control { get; set; } - - [JsonProperty("inputs")] - public Dictionary Inputs { get; set; } - } - - public class HdMdNxM4kEBridgeablePropertiesConfig - { - [JsonProperty("control")] - public ControlPropertiesConfig Control { get; set; } - - [JsonProperty("inputs")] - public Dictionary Inputs { get; set; } - - [JsonProperty("outputs")] - public Dictionary Outputs { get; set; } +{ + /// + /// Defines the properties section of HdMdNxM boxes + /// + public class HdMdNxM4kEPropertiesConfig + { + [JsonProperty("control")] + public ControlPropertiesConfig Control { get; set; } + + [JsonProperty("inputs")] + public Dictionary Inputs { get; set; } + } + + public class HdMdNxM4kEBridgeablePropertiesConfig + { + [JsonProperty("control")] + public ControlPropertiesConfig Control { get; set; } + + [JsonProperty("inputs")] + public Dictionary Inputs { get; set; } + + [JsonProperty("outputs")] + public Dictionary Outputs { get; set; } } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Config/InputPropertiesConfig.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Config/InputPropertiesConfig.cs similarity index 95% rename from essentials-framework/Essentials DM/Essentials_DM/Config/InputPropertiesConfig.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Config/InputPropertiesConfig.cs index c95c359f..54fe978e 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Config/InputPropertiesConfig.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Config/InputPropertiesConfig.cs @@ -1,16 +1,16 @@ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -namespace PepperDash.Essentials.DM.Config -{ - public class InputPropertiesConfig - { - public string Name { get; set; } - - public bool DisableHdcp { get; set; } - } + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +namespace PepperDash.Essentials.DM.Config +{ + public class InputPropertiesConfig + { + public string Name { get; set; } + + public bool DisableHdcp { get; set; } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/DmLite/HdMdxxxCEController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/DmLite/HdMdxxxCEController.cs similarity index 99% rename from essentials-framework/Essentials DM/Essentials_DM/DmLite/HdMdxxxCEController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/DmLite/HdMdxxxCEController.cs index 60277c10..c4422a2d 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/DmLite/HdMdxxxCEController.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/DmLite/HdMdxxxCEController.cs @@ -222,53 +222,53 @@ namespace PepperDash.Essentials.DM //public int NumberOfComPorts { get { return 1; } } //#endregion public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { + { var joinMap = new HdMdxxxCEControllerJoinMap(joinStart); var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + else + { + Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); } Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - RemoteEndDetectedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RemoteEndDetected.JoinNumber]); - - trilist.SetSigTrueAction(joinMap.AutoRouteOn.JoinNumber, AutoRouteOn); - AutoRouteOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.AutoRouteOn.JoinNumber]); - trilist.SetSigTrueAction(joinMap.AutoRouteOff.JoinNumber, AutoRouteOff); - AutoRouteOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.AutoRouteOff.JoinNumber]); - - trilist.SetSigTrueAction(joinMap.PriorityRoutingOn.JoinNumber, PriorityRouteOn); - PriorityRoutingOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PriorityRoutingOn.JoinNumber]); - trilist.SetSigTrueAction(joinMap.PriorityRoutingOff.JoinNumber, PriorityRouteOff); - PriorityRoutingOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PriorityRoutingOff.JoinNumber]); - - trilist.SetSigTrueAction(joinMap.InputOnScreenDisplayEnabled.JoinNumber, OnScreenDisplayEnable); - InputOnScreenDisplayEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputOnScreenDisplayEnabled.JoinNumber]); - trilist.SetSigTrueAction(joinMap.AutoRouteOff.JoinNumber, OnScreenDisplayDisable); - InputOnScreenDisplayEnabledFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.InputOnScreenDisplayDisabled.JoinNumber]); - - trilist.SetUShortSigAction(joinMap.VideoSource.JoinNumber, (i) => ExecuteSwitch(i, null, eRoutingSignalType.Video | eRoutingSignalType.Audio)); - VideoSourceFeedback.LinkInputSig(trilist.UShortInput[joinMap.VideoSource.JoinNumber]); - + IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + RemoteEndDetectedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RemoteEndDetected.JoinNumber]); + + trilist.SetSigTrueAction(joinMap.AutoRouteOn.JoinNumber, AutoRouteOn); + AutoRouteOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.AutoRouteOn.JoinNumber]); + trilist.SetSigTrueAction(joinMap.AutoRouteOff.JoinNumber, AutoRouteOff); + AutoRouteOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.AutoRouteOff.JoinNumber]); + + trilist.SetSigTrueAction(joinMap.PriorityRoutingOn.JoinNumber, PriorityRouteOn); + PriorityRoutingOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PriorityRoutingOn.JoinNumber]); + trilist.SetSigTrueAction(joinMap.PriorityRoutingOff.JoinNumber, PriorityRouteOff); + PriorityRoutingOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PriorityRoutingOff.JoinNumber]); + + trilist.SetSigTrueAction(joinMap.InputOnScreenDisplayEnabled.JoinNumber, OnScreenDisplayEnable); + InputOnScreenDisplayEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputOnScreenDisplayEnabled.JoinNumber]); + trilist.SetSigTrueAction(joinMap.AutoRouteOff.JoinNumber, OnScreenDisplayDisable); + InputOnScreenDisplayEnabledFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.InputOnScreenDisplayDisabled.JoinNumber]); + + trilist.SetUShortSigAction(joinMap.VideoSource.JoinNumber, (i) => ExecuteSwitch(i, null, eRoutingSignalType.Video | eRoutingSignalType.Audio)); + VideoSourceFeedback.LinkInputSig(trilist.UShortInput[joinMap.VideoSource.JoinNumber]); + trilist.UShortInput[joinMap.SourceCount.JoinNumber].UShortValue = (ushort)InputPorts.Count; foreach (var input in InputPorts) { - var number = Convert.ToUInt16(input.Selector); - var numberJoin = (UInt16)(number - 1); - SyncDetectedFeedbacks[number].LinkInputSig(trilist.BooleanInput[joinMap.SyncDetected.JoinNumber + numberJoin]); + var number = Convert.ToUInt16(input.Selector); + var numberJoin = (UInt16)(number - 1); + SyncDetectedFeedbacks[number].LinkInputSig(trilist.BooleanInput[joinMap.SyncDetected.JoinNumber + numberJoin]); trilist.StringInput[joinMap.SourceNames.JoinNumber + numberJoin].StringValue = input.Key; } } diff --git a/essentials-framework/Essentials DM/Essentials_DM/DmPortName.cs b/src/essentials-framework/Essentials DM/Essentials_DM/DmPortName.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/DmPortName.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/DmPortName.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/Dge100Controller.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/Dge100Controller.cs similarity index 97% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/Dge100Controller.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/Dge100Controller.cs index 6b0cdf28..8818f790 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/Dge100Controller.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/Dge100Controller.cs @@ -1,13 +1,13 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; +using System.Linq; +using System.Net.Sockets; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.UI; - -using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.UI; + +using Crestron.SimplSharpPro.DM; using Newtonsoft.Json; @@ -15,24 +15,24 @@ using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; -using Crestron.SimplSharpPro.DeviceSupport; -using PepperDash.Essentials.Core.DeviceInfo; -using PepperDash.Essentials.Core.Bridges; - +using Crestron.SimplSharpPro.DeviceSupport; +using PepperDash.Essentials.Core.DeviceInfo; +using PepperDash.Essentials.Core.Bridges; + namespace PepperDash.Essentials.DM.Endpoints.DGEs { [Description("Wrapper class for DGE-100")] - public class Dge100Controller : CrestronGenericBaseDevice, IComPorts, IIROutputPorts, IHasBasicTriListWithSmartObject, ICec, IDeviceInfoProvider, IBridgeAdvanced - { - private const int CtpPort = 41795; - private readonly Dge100 _dge; - - private readonly TsxCcsUcCodec100EthernetReservedSigs _dgeEthernetInfo; - - public BasicTriListWithSmartObject Panel { get { return _dge; } } - - private DeviceConfig _dc; - + public class Dge100Controller : CrestronGenericBaseDevice, IComPorts, IIROutputPorts, IHasBasicTriListWithSmartObject, ICec, IDeviceInfoProvider, IBridgeAdvanced + { + private const int CtpPort = 41795; + private readonly Dge100 _dge; + + private readonly TsxCcsUcCodec100EthernetReservedSigs _dgeEthernetInfo; + + public BasicTriListWithSmartObject Panel { get { return _dge; } } + + private DeviceConfig _dc; + public VideoStatusOutputs VideoStatusFeedbacks { get; private set; } CrestronTouchpanelPropertiesConfig PropertiesConfig; @@ -41,29 +41,29 @@ namespace PepperDash.Essentials.DM.Endpoints.DGEs public Dge100Controller(string key, string name, Dge100 device, DeviceConfig dc, CrestronTouchpanelPropertiesConfig props) :base(key, name, device) { - _dge = device; - _dgeEthernetInfo = _dge.ExtenderEthernetReservedSigs; - //_dgeEthernetInfo.DeviceExtenderSigChange += (extender, args) => UpdateDeviceInfo(); - _dgeEthernetInfo.Use(); - - DeviceInfo = new DeviceInfo(); - + _dge = device; + _dgeEthernetInfo = _dge.ExtenderEthernetReservedSigs; + //_dgeEthernetInfo.DeviceExtenderSigChange += (extender, args) => UpdateDeviceInfo(); + _dgeEthernetInfo.Use(); + + DeviceInfo = new DeviceInfo(); + _dge.OnlineStatusChange += (currentDevice, args) => { if (args.DeviceOnLine) UpdateDeviceInfo(); }; _dc = dc; - PropertiesConfig = props; - - var videoStatusFuncs = new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => _dge.HdmiIn.HdcpSupportOnFeedback.BoolValue, - VideoResolutionFeedbackFunc = () => _dge.HdmiIn.VideoAttributes.GetVideoResolutionString(), - VideoSyncFeedbackFunc = () => _dge.HdmiIn.SyncDetectedFeedback.BoolValue, - }; - - VideoStatusFeedbacks = new VideoStatusOutputs(videoStatusFuncs); - - _dge.HdmiIn.StreamChange += (s,a) => VideoStatusFeedbacks.FireAll(); + PropertiesConfig = props; + + var videoStatusFuncs = new VideoStatusFuncsWrapper + { + HdcpActiveFeedbackFunc = () => _dge.HdmiIn.HdcpSupportOnFeedback.BoolValue, + VideoResolutionFeedbackFunc = () => _dge.HdmiIn.VideoAttributes.GetVideoResolutionString(), + VideoSyncFeedbackFunc = () => _dge.HdmiIn.SyncDetectedFeedback.BoolValue, + }; + + VideoStatusFeedbacks = new VideoStatusOutputs(videoStatusFuncs); + + _dge.HdmiIn.StreamChange += (s,a) => VideoStatusFeedbacks.FireAll(); _dge.HdmiIn.VideoAttributes.AttributeChange += (o, a) => VideoStatusFeedbacks.FireAll(); } @@ -93,174 +93,174 @@ namespace PepperDash.Essentials.DM.Endpoints.DGEs get { return _dge.NumberOfIROutputPorts; } } - #endregion - - #region ICec Members - public Cec StreamCec { get { return _dge.HdmiOut.StreamCec; } } - #endregion - - #region Implementation of IDeviceInfoProvider - - public DeviceInfo DeviceInfo { get; private set; } - - public event DeviceInfoChangeHandler DeviceInfoChanged; - - public void UpdateDeviceInfo() - { - DeviceInfo.IpAddress = _dgeEthernetInfo.IpAddressFeedback.StringValue; - DeviceInfo.MacAddress = _dgeEthernetInfo.MacAddressFeedback.StringValue; - - GetFirmwareAndSerialInfo(); - - OnDeviceInfoChange(); - } - - private void GetFirmwareAndSerialInfo() - { - if (String.IsNullOrEmpty(_dgeEthernetInfo.IpAddressFeedback.StringValue)) - { - Debug.Console(1, this, "IP Address information not yet received. No device is online"); - return; - } - - var tcpClient = new GenericTcpIpClient("", _dgeEthernetInfo.IpAddressFeedback.StringValue, CtpPort, 1024){AutoReconnect = false}; - - var gather = new CommunicationGather(tcpClient, "\r\n\r\n"); - - tcpClient.ConnectionChange += (sender, args) => - { - if (!args.Client.IsConnected) - { - return; - } - - args.Client.SendText("ver\r\n"); - }; - - gather.LineReceived += (sender, args) => - { - try - { - Debug.Console(1, this, "{0}", args.Text); - - if (args.Text.ToLower().Contains("host")) - { - DeviceInfo.HostName = args.Text.Split(':')[1].Trim(); - - Debug.Console(1, this, "hostname: {0}", DeviceInfo.HostName); - tcpClient.Disconnect(); - return; - } - - //ignore console prompt - /*if (args.Text.ToLower().Contains(">")) - { - Debug.Console(1, this, "Ignoring console"); - return; - } - - if (args.Text.ToLower().Contains("dge")) - { - Debug.Console(1, this, "Ignoring DGE"); - return; - }*/ - - if (!args.Text.Contains('[')) - { - return; - } - var splitResponse = args.Text.Split('['); - - foreach (string t in splitResponse) - { - Debug.Console(1, this, "{0}", t); - } - - DeviceInfo.SerialNumber = splitResponse[1].Split(' ')[4].Replace("#", ""); - DeviceInfo.FirmwareVersion = splitResponse[1].Split(' ')[0]; - - Debug.Console(1, this, "Firmware: {0} SerialNumber: {1}", DeviceInfo.FirmwareVersion, - DeviceInfo.SerialNumber); - - tcpClient.SendText("host\r\n"); - } - catch (Exception ex) - { - Debug.Console(0, this, "Exception getting data: {0}", ex.Message); - Debug.Console(0, this, "response: {0}", args.Text); - } - }; - - tcpClient.Connect(); - } - - private void OnDeviceInfoChange() - { - var handler = DeviceInfoChanged; - - if (handler == null) return; - - handler(this, new DeviceInfoEventArgs(DeviceInfo)); - } - - #endregion - - #region IBridgeAdvanced Members - - public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new DgeJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - //Presses - trilist.SetSigTrueAction(joinMap.HdmiInHdcpOn.JoinNumber, () => _dge.HdmiIn.HdcpSupportOn()); - trilist.SetSigTrueAction(joinMap.HdmiInHdcpOff.JoinNumber,() => _dge.HdmiIn.HdcpSupportOff()); - trilist.SetSigTrueAction(joinMap.HdmiInHdcpToggle.JoinNumber, () => { - if(_dge.HdmiIn.HdcpSupportOnFeedback.BoolValue) - { - _dge.HdmiIn.HdcpSupportOff(); - return; - } - - _dge.HdmiIn.HdcpSupportOn(); - }); - - - // Feedbacks - VideoStatusFeedbacks.HdcpActiveFeedback.LinkInputSig(trilist.BooleanInput[joinMap.HdmiInHdcpOn.JoinNumber]); - VideoStatusFeedbacks.HdcpActiveFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.HdmiInHdcpOff.JoinNumber]); - - VideoStatusFeedbacks.VideoResolutionFeedback.LinkInputSig(trilist.StringInput[joinMap.CurrentInputResolution.JoinNumber]); - VideoStatusFeedbacks.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.SyncDetected.JoinNumber]); - - IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - - trilist.OnlineStatusChange += (o, a) => - { - if (!a.DeviceOnLine) return; - - VideoStatusFeedbacks.FireAll(); - }; - } - - - - #endregion + #endregion + + #region ICec Members + public Cec StreamCec { get { return _dge.HdmiOut.StreamCec; } } + #endregion + + #region Implementation of IDeviceInfoProvider + + public DeviceInfo DeviceInfo { get; private set; } + + public event DeviceInfoChangeHandler DeviceInfoChanged; + + public void UpdateDeviceInfo() + { + DeviceInfo.IpAddress = _dgeEthernetInfo.IpAddressFeedback.StringValue; + DeviceInfo.MacAddress = _dgeEthernetInfo.MacAddressFeedback.StringValue; + + GetFirmwareAndSerialInfo(); + + OnDeviceInfoChange(); + } + + private void GetFirmwareAndSerialInfo() + { + if (String.IsNullOrEmpty(_dgeEthernetInfo.IpAddressFeedback.StringValue)) + { + Debug.Console(1, this, "IP Address information not yet received. No device is online"); + return; + } + + var tcpClient = new GenericTcpIpClient("", _dgeEthernetInfo.IpAddressFeedback.StringValue, CtpPort, 1024){AutoReconnect = false}; + + var gather = new CommunicationGather(tcpClient, "\r\n\r\n"); + + tcpClient.ConnectionChange += (sender, args) => + { + if (!args.Client.IsConnected) + { + return; + } + + args.Client.SendText("ver\r\n"); + }; + + gather.LineReceived += (sender, args) => + { + try + { + Debug.Console(1, this, "{0}", args.Text); + + if (args.Text.ToLower().Contains("host")) + { + DeviceInfo.HostName = args.Text.Split(':')[1].Trim(); + + Debug.Console(1, this, "hostname: {0}", DeviceInfo.HostName); + tcpClient.Disconnect(); + return; + } + + //ignore console prompt + /*if (args.Text.ToLower().Contains(">")) + { + Debug.Console(1, this, "Ignoring console"); + return; + } + + if (args.Text.ToLower().Contains("dge")) + { + Debug.Console(1, this, "Ignoring DGE"); + return; + }*/ + + if (!args.Text.Contains('[')) + { + return; + } + var splitResponse = args.Text.Split('['); + + foreach (string t in splitResponse) + { + Debug.Console(1, this, "{0}", t); + } + + DeviceInfo.SerialNumber = splitResponse[1].Split(' ')[4].Replace("#", ""); + DeviceInfo.FirmwareVersion = splitResponse[1].Split(' ')[0]; + + Debug.Console(1, this, "Firmware: {0} SerialNumber: {1}", DeviceInfo.FirmwareVersion, + DeviceInfo.SerialNumber); + + tcpClient.SendText("host\r\n"); + } + catch (Exception ex) + { + Debug.Console(0, this, "Exception getting data: {0}", ex.Message); + Debug.Console(0, this, "response: {0}", args.Text); + } + }; + + tcpClient.Connect(); + } + + private void OnDeviceInfoChange() + { + var handler = DeviceInfoChanged; + + if (handler == null) return; + + handler(this, new DeviceInfoEventArgs(DeviceInfo)); + } + + #endregion + + #region IBridgeAdvanced Members + + public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new DgeJoinMap(joinStart); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + else + { + Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + } + + Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + //Presses + trilist.SetSigTrueAction(joinMap.HdmiInHdcpOn.JoinNumber, () => _dge.HdmiIn.HdcpSupportOn()); + trilist.SetSigTrueAction(joinMap.HdmiInHdcpOff.JoinNumber,() => _dge.HdmiIn.HdcpSupportOff()); + trilist.SetSigTrueAction(joinMap.HdmiInHdcpToggle.JoinNumber, () => { + if(_dge.HdmiIn.HdcpSupportOnFeedback.BoolValue) + { + _dge.HdmiIn.HdcpSupportOff(); + return; + } + + _dge.HdmiIn.HdcpSupportOn(); + }); + + + // Feedbacks + VideoStatusFeedbacks.HdcpActiveFeedback.LinkInputSig(trilist.BooleanInput[joinMap.HdmiInHdcpOn.JoinNumber]); + VideoStatusFeedbacks.HdcpActiveFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.HdmiInHdcpOff.JoinNumber]); + + VideoStatusFeedbacks.VideoResolutionFeedback.LinkInputSig(trilist.StringInput[joinMap.CurrentInputResolution.JoinNumber]); + VideoStatusFeedbacks.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.SyncDetected.JoinNumber]); + + IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + + trilist.OnlineStatusChange += (o, a) => + { + if (!a.DeviceOnLine) return; + + VideoStatusFeedbacks.FireAll(); + }; + } + + + + #endregion } public class Dge100ControllerFactory : EssentialsDeviceFactory diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DgeJoinMap.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DgeJoinMap.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DgeJoinMap.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DgeJoinMap.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DgePropertiesConfig.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DgePropertiesConfig.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DgePropertiesConfig.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DgePropertiesConfig.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DmDge200CController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DmDge200CController.cs similarity index 96% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DmDge200CController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DmDge200CController.cs index d5df7dc6..282f576b 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DmDge200CController.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DmDge200CController.cs @@ -1,94 +1,94 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.UI; - -using Newtonsoft.Json; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; -using Crestron.SimplSharpPro.DeviceSupport; - -using Crestron.SimplSharpPro.DM; - -namespace PepperDash.Essentials.DM.Endpoints.DGEs -{ - /// - /// Wrapper class for DGE-100 and DM-DGE-200-C - /// - [Description("Wrapper class for DM-DGE-200-C")] - public class DmDge200CController : Dge100Controller, IRoutingInputsOutputs - { - private readonly DmDge200C _dge; - - public RoutingInputPort DmIn { get; private set; } - public RoutingOutputPort HdmiOut { get; private set; } - - public RoutingPortCollection InputPorts - { - get; - private set; - } - - public RoutingPortCollection OutputPorts - { - get; - private set; - } - - public DmDge200CController(string key, string name, DmDge200C device, DeviceConfig dc, CrestronTouchpanelPropertiesConfig props) - : base(key, name, device, dc, props) - { - _dge = device; - - DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.DmCat, 0, this); - HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, null, this); - - - InputPorts = new RoutingPortCollection { DmIn }; - OutputPorts = new RoutingPortCollection { HdmiOut }; - - // Set Ports for CEC - HdmiOut.Port = _dge.HdmiOut; ; - - } - } - - public class DmDge200CControllerFactory : EssentialsDeviceFactory - { - public DmDge200CControllerFactory() - { - TypeNames = new List() { "dmdge200c" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - var typeName = dc.Type.ToLower(); - var comm = CommFactory.GetControlPropertiesConfig(dc); - var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); - - Debug.Console(1, "Factory Attempting to create new DgeController Device"); - - DmDge200C dgeDevice = null; - - if (typeName == "dmdge200c") - dgeDevice = new DmDge200C(comm.IpIdInt, Global.ControlSystem); - - if (dgeDevice == null) - { - Debug.Console(1, "Unable to create DGE device"); - return null; - } - - var dgeController = new DmDge200CController(dc.Key, dc.Name, dgeDevice, dc, props); - - return dgeController; - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.UI; + +using Newtonsoft.Json; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; +using Crestron.SimplSharpPro.DeviceSupport; + +using Crestron.SimplSharpPro.DM; + +namespace PepperDash.Essentials.DM.Endpoints.DGEs +{ + /// + /// Wrapper class for DGE-100 and DM-DGE-200-C + /// + [Description("Wrapper class for DM-DGE-200-C")] + public class DmDge200CController : Dge100Controller, IRoutingInputsOutputs + { + private readonly DmDge200C _dge; + + public RoutingInputPort DmIn { get; private set; } + public RoutingOutputPort HdmiOut { get; private set; } + + public RoutingPortCollection InputPorts + { + get; + private set; + } + + public RoutingPortCollection OutputPorts + { + get; + private set; + } + + public DmDge200CController(string key, string name, DmDge200C device, DeviceConfig dc, CrestronTouchpanelPropertiesConfig props) + : base(key, name, device, dc, props) + { + _dge = device; + + DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.DmCat, 0, this); + HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.Hdmi, null, this); + + + InputPorts = new RoutingPortCollection { DmIn }; + OutputPorts = new RoutingPortCollection { HdmiOut }; + + // Set Ports for CEC + HdmiOut.Port = _dge.HdmiOut; ; + + } + } + + public class DmDge200CControllerFactory : EssentialsDeviceFactory + { + public DmDge200CControllerFactory() + { + TypeNames = new List() { "dmdge200c" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + var typeName = dc.Type.ToLower(); + var comm = CommFactory.GetControlPropertiesConfig(dc); + var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); + + Debug.Console(1, "Factory Attempting to create new DgeController Device"); + + DmDge200C dgeDevice = null; + + if (typeName == "dmdge200c") + dgeDevice = new DmDge200C(comm.IpIdInt, Global.ControlSystem); + + if (dgeDevice == null) + { + Debug.Console(1, "Unable to create DGE device"); + return null; + } + + var dgeController = new DmDge200CController(dc.Key, dc.Name, dgeDevice, dc, props); + + return dgeController; + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/EndpointInterfaces.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/EndpointInterfaces.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/EndpointInterfaces.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/EndpointInterfaces.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmHdBaseTEndpointController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmHdBaseTEndpointController.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmHdBaseTEndpointController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmHdBaseTEndpointController.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc100SController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc100SController.cs similarity index 99% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc100SController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc100SController.cs index b67b6584..90f6b3fb 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc100SController.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc100SController.cs @@ -11,7 +11,7 @@ namespace PepperDash.Essentials.DM /// /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions /// - /// + /// [Description("Wrapper Class for DM-RMC-100-S")] public class DmRmc100SController : DmRmcControllerBase, IRoutingInputsOutputs, IIROutputPorts, IComPorts, ICec diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc150SController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc150SController.cs similarity index 97% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc150SController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc150SController.cs index 0753ed4a..39d1fd83 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc150SController.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc150SController.cs @@ -1,99 +1,99 @@ -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints.Receivers; - -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.DM -{ - /// - /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions - /// - /// - [Description("Wrapper Class for DM-RMC-150-S")] - public class DmRmc150SController : DmRmcControllerBase, IRoutingInputsOutputs, - IIROutputPorts, IComPorts, ICec - { - private readonly DmRmc150S _rmc; - - public RoutingInputPort DmIn { get; private set; } - public RoutingOutputPort HdmiOut { get; private set; } - - public RoutingPortCollection InputPorts - { - get; private set; - } - - public RoutingPortCollection OutputPorts - { - get; - private set ; - } - - /// - /// Make a Crestron RMC and put it in here - /// - public DmRmc150SController(string key, string name, DmRmc150S rmc) - : base(key, name, rmc) - { - _rmc = rmc; - DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.DmCat, 0, this); - HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, null, this); - - EdidManufacturerFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Manufacturer.StringValue); - EdidNameFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Name.StringValue); - EdidPreferredTimingFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.PreferredTiming.StringValue); - EdidSerialNumberFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.SerialNumber.StringValue); - - InputPorts = new RoutingPortCollection {DmIn}; - OutputPorts = new RoutingPortCollection {HdmiOut}; - - _rmc.HdmiOutput.ConnectedDevice.DeviceInformationChange += ConnectedDevice_DeviceInformationChange; - - // Set Ports for CEC - HdmiOut.Port = _rmc.HdmiOutput; - } - - void ConnectedDevice_DeviceInformationChange(ConnectedDeviceInformation connectedDevice, ConnectedDeviceEventArgs args) - { - switch (args.EventId) - { - case ConnectedDeviceEventIds.ManufacturerEventId: - EdidManufacturerFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.NameEventId: - EdidNameFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.PreferredTimingEventId: - EdidPreferredTimingFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.SerialNumberEventId: - EdidSerialNumberFeedback.FireUpdate(); - break; - } - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); - } - - #region IIROutputPorts Members - public CrestronCollection IROutputPorts { get { return _rmc.IROutputPorts; } } - public int NumberOfIROutputPorts { get { return _rmc.NumberOfIROutputPorts; } } - #endregion - - #region IComPorts Members - public CrestronCollection ComPorts { get { return _rmc.ComPorts; } } - public int NumberOfComPorts { get { return _rmc.NumberOfComPorts; } } - #endregion - - #region ICec Members - public Cec StreamCec { get { return _rmc.HdmiOutput.StreamCec; } } - #endregion - } +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints.Receivers; + +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; + +namespace PepperDash.Essentials.DM +{ + /// + /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions + /// + /// + [Description("Wrapper Class for DM-RMC-150-S")] + public class DmRmc150SController : DmRmcControllerBase, IRoutingInputsOutputs, + IIROutputPorts, IComPorts, ICec + { + private readonly DmRmc150S _rmc; + + public RoutingInputPort DmIn { get; private set; } + public RoutingOutputPort HdmiOut { get; private set; } + + public RoutingPortCollection InputPorts + { + get; private set; + } + + public RoutingPortCollection OutputPorts + { + get; + private set ; + } + + /// + /// Make a Crestron RMC and put it in here + /// + public DmRmc150SController(string key, string name, DmRmc150S rmc) + : base(key, name, rmc) + { + _rmc = rmc; + DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.DmCat, 0, this); + HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.Hdmi, null, this); + + EdidManufacturerFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Manufacturer.StringValue); + EdidNameFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Name.StringValue); + EdidPreferredTimingFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.PreferredTiming.StringValue); + EdidSerialNumberFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.SerialNumber.StringValue); + + InputPorts = new RoutingPortCollection {DmIn}; + OutputPorts = new RoutingPortCollection {HdmiOut}; + + _rmc.HdmiOutput.ConnectedDevice.DeviceInformationChange += ConnectedDevice_DeviceInformationChange; + + // Set Ports for CEC + HdmiOut.Port = _rmc.HdmiOutput; + } + + void ConnectedDevice_DeviceInformationChange(ConnectedDeviceInformation connectedDevice, ConnectedDeviceEventArgs args) + { + switch (args.EventId) + { + case ConnectedDeviceEventIds.ManufacturerEventId: + EdidManufacturerFeedback.FireUpdate(); + break; + case ConnectedDeviceEventIds.NameEventId: + EdidNameFeedback.FireUpdate(); + break; + case ConnectedDeviceEventIds.PreferredTimingEventId: + EdidPreferredTimingFeedback.FireUpdate(); + break; + case ConnectedDeviceEventIds.SerialNumberEventId: + EdidSerialNumberFeedback.FireUpdate(); + break; + } + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); + } + + #region IIROutputPorts Members + public CrestronCollection IROutputPorts { get { return _rmc.IROutputPorts; } } + public int NumberOfIROutputPorts { get { return _rmc.NumberOfIROutputPorts; } } + #endregion + + #region IComPorts Members + public CrestronCollection ComPorts { get { return _rmc.ComPorts; } } + public int NumberOfComPorts { get { return _rmc.NumberOfComPorts; } } + #endregion + + #region ICec Members + public Cec StreamCec { get { return _rmc.HdmiOutput.StreamCec; } } + #endregion + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200CController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200CController.cs similarity index 97% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200CController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200CController.cs index df39e4ee..e7699e85 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200CController.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200CController.cs @@ -1,111 +1,111 @@ -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Receivers; - -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.DM -{ - /// - /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions - /// - /// - [Description("Wrapper Class for DM-RMC-200-C")] - public class DmRmc200CController : DmRmcControllerBase, IRoutingInputsOutputs, - IIROutputPorts, IComPorts, ICec - { - private readonly DmRmc200C _rmc; - - public RoutingInputPort DmIn { get; private set; } - public RoutingOutputPort HdmiOut { get; private set; } - - public RoutingPortCollection InputPorts - { - get; private set; - } - - public RoutingPortCollection OutputPorts - { - get; private set; - } - - /// - /// Make a Crestron RMC and put it in here - /// - public DmRmc200CController(string key, string name, DmRmc200C rmc) - : base(key, name, rmc) - { - _rmc = rmc; - DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.DmCat, 0, this); - HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, null, this); - - EdidManufacturerFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Manufacturer.StringValue); - EdidNameFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Name.StringValue); - EdidPreferredTimingFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.PreferredTiming.StringValue); - EdidSerialNumberFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.SerialNumber.StringValue); - - VideoOutputResolutionFeedback = new StringFeedback(() => _rmc.HdmiOutput.GetVideoResolutionString()); - - _rmc.HdmiOutput.OutputStreamChange += HdmiOutput_OutputStreamChange; - _rmc.HdmiOutput.ConnectedDevice.DeviceInformationChange += ConnectedDevice_DeviceInformationChange; - - InputPorts = new RoutingPortCollection {DmIn}; - OutputPorts = new RoutingPortCollection {HdmiOut}; - - // Set Ports for CEC - HdmiOut.Port = _rmc.HdmiOutput; - } - - void HdmiOutput_OutputStreamChange(EndpointOutputStream outputStream, EndpointOutputStreamEventArgs args) - { - if (args.EventId == EndpointOutputStreamEventIds.HorizontalResolutionFeedbackEventId || args.EventId == EndpointOutputStreamEventIds.VerticalResolutionFeedbackEventId || - args.EventId == EndpointOutputStreamEventIds.FramesPerSecondFeedbackEventId) - { - VideoOutputResolutionFeedback.FireUpdate(); - } - } - - void ConnectedDevice_DeviceInformationChange(ConnectedDeviceInformation connectedDevice, ConnectedDeviceEventArgs args) - { - switch (args.EventId) - { - case ConnectedDeviceEventIds.ManufacturerEventId: - EdidManufacturerFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.NameEventId: - EdidNameFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.PreferredTimingEventId: - EdidPreferredTimingFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.SerialNumberEventId: - EdidSerialNumberFeedback.FireUpdate(); - break; - } - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); - } - - #region IIROutputPorts Members - public CrestronCollection IROutputPorts { get { return _rmc.IROutputPorts; } } - public int NumberOfIROutputPorts { get { return _rmc.NumberOfIROutputPorts; } } - #endregion - - #region IComPorts Members - public CrestronCollection ComPorts { get { return _rmc.ComPorts; } } - public int NumberOfComPorts { get { return _rmc.NumberOfComPorts; } } - #endregion - - #region ICec Members - public Cec StreamCec { get { return _rmc.HdmiOutput.StreamCec; } } - #endregion - } +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Receivers; + +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; + +namespace PepperDash.Essentials.DM +{ + /// + /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions + /// + /// + [Description("Wrapper Class for DM-RMC-200-C")] + public class DmRmc200CController : DmRmcControllerBase, IRoutingInputsOutputs, + IIROutputPorts, IComPorts, ICec + { + private readonly DmRmc200C _rmc; + + public RoutingInputPort DmIn { get; private set; } + public RoutingOutputPort HdmiOut { get; private set; } + + public RoutingPortCollection InputPorts + { + get; private set; + } + + public RoutingPortCollection OutputPorts + { + get; private set; + } + + /// + /// Make a Crestron RMC and put it in here + /// + public DmRmc200CController(string key, string name, DmRmc200C rmc) + : base(key, name, rmc) + { + _rmc = rmc; + DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.DmCat, 0, this); + HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.Hdmi, null, this); + + EdidManufacturerFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Manufacturer.StringValue); + EdidNameFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Name.StringValue); + EdidPreferredTimingFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.PreferredTiming.StringValue); + EdidSerialNumberFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.SerialNumber.StringValue); + + VideoOutputResolutionFeedback = new StringFeedback(() => _rmc.HdmiOutput.GetVideoResolutionString()); + + _rmc.HdmiOutput.OutputStreamChange += HdmiOutput_OutputStreamChange; + _rmc.HdmiOutput.ConnectedDevice.DeviceInformationChange += ConnectedDevice_DeviceInformationChange; + + InputPorts = new RoutingPortCollection {DmIn}; + OutputPorts = new RoutingPortCollection {HdmiOut}; + + // Set Ports for CEC + HdmiOut.Port = _rmc.HdmiOutput; + } + + void HdmiOutput_OutputStreamChange(EndpointOutputStream outputStream, EndpointOutputStreamEventArgs args) + { + if (args.EventId == EndpointOutputStreamEventIds.HorizontalResolutionFeedbackEventId || args.EventId == EndpointOutputStreamEventIds.VerticalResolutionFeedbackEventId || + args.EventId == EndpointOutputStreamEventIds.FramesPerSecondFeedbackEventId) + { + VideoOutputResolutionFeedback.FireUpdate(); + } + } + + void ConnectedDevice_DeviceInformationChange(ConnectedDeviceInformation connectedDevice, ConnectedDeviceEventArgs args) + { + switch (args.EventId) + { + case ConnectedDeviceEventIds.ManufacturerEventId: + EdidManufacturerFeedback.FireUpdate(); + break; + case ConnectedDeviceEventIds.NameEventId: + EdidNameFeedback.FireUpdate(); + break; + case ConnectedDeviceEventIds.PreferredTimingEventId: + EdidPreferredTimingFeedback.FireUpdate(); + break; + case ConnectedDeviceEventIds.SerialNumberEventId: + EdidSerialNumberFeedback.FireUpdate(); + break; + } + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); + } + + #region IIROutputPorts Members + public CrestronCollection IROutputPorts { get { return _rmc.IROutputPorts; } } + public int NumberOfIROutputPorts { get { return _rmc.NumberOfIROutputPorts; } } + #endregion + + #region IComPorts Members + public CrestronCollection ComPorts { get { return _rmc.ComPorts; } } + public int NumberOfComPorts { get { return _rmc.NumberOfComPorts; } } + #endregion + + #region ICec Members + public Cec StreamCec { get { return _rmc.HdmiOutput.StreamCec; } } + #endregion + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200S2Controller.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200S2Controller.cs similarity index 99% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200S2Controller.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200S2Controller.cs index 6633af15..e329784f 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200S2Controller.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200S2Controller.cs @@ -12,8 +12,8 @@ namespace PepperDash.Essentials.DM /// /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions /// - /// - [Description("Wrapper Class for DM-RMC-200-S2")] + /// + [Description("Wrapper Class for DM-RMC-200-S2")] public class DmRmc200S2Controller : DmRmcControllerBase, IRoutingInputsOutputs, IIROutputPorts, IComPorts, ICec { diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200SController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200SController.cs similarity index 99% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200SController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200SController.cs index 4ccae3e9..86e937c7 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200SController.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200SController.cs @@ -12,8 +12,8 @@ namespace PepperDash.Essentials.DM /// /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions /// - /// - [Description("Wrapper Class for DM-RMC-200-S")] + /// + [Description("Wrapper Class for DM-RMC-200-S")] public class DmRmc200SController : DmRmcControllerBase, IRoutingInputsOutputs, IIROutputPorts, IComPorts, ICec { diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4KScalerCController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4KScalerCController.cs similarity index 97% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4KScalerCController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4KScalerCController.cs index 79debd63..4496e64f 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4KScalerCController.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4KScalerCController.cs @@ -1,261 +1,261 @@ -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Receivers; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash_Essentials_DM; -using System.Collections.Generic; - -namespace PepperDash.Essentials.DM -{ - /// - /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions - /// - /// - [Description("Wrapper Class for DM-RMC-4K-SCALER-C")] - public class DmRmc4kScalerCController : DmRmcControllerBase, IRoutingInputsOutputs, IBasicVolumeWithFeedback, - IIROutputPorts, IComPorts, ICec, IRelayPorts, IHasDmInHdcp, IBasicVideoMuteWithFeedback - { - private readonly DmRmc4kScalerC _rmc; - - public RoutingInputPort DmIn { get; private set; } - public RoutingOutputPort HdmiOut { get; private set; } - public RoutingOutputPort BalancedAudioOut { get; private set; } - - public RoutingPortCollection InputPorts { get; private set; } - - public RoutingPortCollection OutputPorts { get; private set; } - - public EndpointDmInputStreamWithCec DmInput { get; private set; } - - public IntFeedback DmInHdcpStateFeedback { get; private set; } - - - - /// - /// Make a Crestron RMC and put it in here - /// - public DmRmc4kScalerCController(string key, string name, DmRmc4kScalerC rmc) - : base(key, name, rmc) - { - _rmc = rmc; - - DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.DmCat, 0, this); - HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, null, this); - BalancedAudioOut = new RoutingOutputPort(DmPortName.BalancedAudioOut, eRoutingSignalType.Audio, - eRoutingPortConnectionType.LineAudio, null, this); - - MuteFeedback = new BoolFeedback(() => false); - - VolumeLevelFeedback = new IntFeedback("MainVolumeLevelFeedback", () => - rmc.AudioOutput.VolumeFeedback.UShortValue); - - EdidManufacturerFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Manufacturer.StringValue); - EdidNameFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Name.StringValue); - EdidPreferredTimingFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.PreferredTiming.StringValue); - EdidSerialNumberFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.SerialNumber.StringValue); - - InputPorts = new RoutingPortCollection { DmIn }; - OutputPorts = new RoutingPortCollection { HdmiOut, BalancedAudioOut }; - - VideoOutputResolutionFeedback = new StringFeedback(() => _rmc.HdmiOutput.GetVideoResolutionString()); - DmInHdcpStateFeedback = new IntFeedback("DmInHdcpCapability", - () => (int)_rmc.DmInput.HdcpCapabilityFeedback); - - AddToFeedbackList(DmInHdcpStateFeedback); - - VideoMuteIsOn = new BoolFeedback("HdmiOutputVideoMuteIsOn", () => _rmc.HdmiOutput.BlankEnabledFeedback.BoolValue); - - _rmc.HdmiOutput.OutputStreamChange += HdmiOutput_OutputStreamChange; - _rmc.HdmiOutput.ConnectedDevice.DeviceInformationChange += ConnectedDevice_DeviceInformationChange; - - // Set Ports for CEC - HdmiOut.Port = _rmc.HdmiOutput; - } - - void HdmiOutput_OutputStreamChange(EndpointOutputStream outputStream, EndpointOutputStreamEventArgs args) - { - if (args.EventId == EndpointOutputStreamEventIds.HorizontalResolutionFeedbackEventId || args.EventId == EndpointOutputStreamEventIds.VerticalResolutionFeedbackEventId || - args.EventId == EndpointOutputStreamEventIds.FramesPerSecondFeedbackEventId) - { - VideoOutputResolutionFeedback.FireUpdate(); - } - else if (args.EventId == EndpointOutputStreamEventIds.BlankEnabledFeedbackEventId) - { - VideoMuteIsOn.FireUpdate(); - } - } - - void ConnectedDevice_DeviceInformationChange(ConnectedDeviceInformation connectedDevice, ConnectedDeviceEventArgs args) - { - switch (args.EventId) - { - case ConnectedDeviceEventIds.ManufacturerEventId: - EdidManufacturerFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.NameEventId: - EdidNameFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.PreferredTimingEventId: - EdidPreferredTimingFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.SerialNumberEventId: - EdidSerialNumberFeedback.FireUpdate(); - break; - } - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); - } - - #region IIROutputPorts Members - public CrestronCollection IROutputPorts { get { return _rmc.IROutputPorts; } } - public int NumberOfIROutputPorts { get { return _rmc.NumberOfIROutputPorts; } } - #endregion - - #region IComPorts Members - public CrestronCollection ComPorts { get { return _rmc.ComPorts; } } - public int NumberOfComPorts { get { return _rmc.NumberOfComPorts; } } - #endregion - - #region ICec Members - /// - /// Gets the CEC stream directly from the HDMI port. - /// - public Cec StreamCec { get { return _rmc.HdmiOutput.StreamCec; } } - #endregion - - #region IRelayPorts Members - - public int NumberOfRelayPorts - { - get { return _rmc.NumberOfRelayPorts; } - } - - public CrestronCollection RelayPorts - { - get { return _rmc.RelayPorts; } - } - - #endregion - - #region IBasicVolumeWithFeedback Members - - public BoolFeedback MuteFeedback - { - get; - private set; - } - - /// - /// Not implemented - /// - public void MuteOff() - { - Debug.Console(2, this, "DM Endpoint {0} does not have a mute function", Key); - } - - /// - /// Not implemented - /// - public void MuteOn() - { - Debug.Console(2, this, "DM Endpoint {0} does not have a mute function", Key); - } - - public void SetVolume(ushort level) - { - _rmc.AudioOutput.Volume.UShortValue = level; - } - - public IntFeedback VolumeLevelFeedback - { - get; - private set; - } - - #endregion - - #region IBasicVolumeControls Members - - /// - /// Not implemented - /// - public void MuteToggle() - { - Debug.Console(2, this, "DM Endpoint {0} does not have a mute function", Key); - } - - public void VolumeDown(bool pressRelease) - { - if (pressRelease) - SigHelper.RampTimeScaled(_rmc.AudioOutput.Volume, 0, 4000); - else - _rmc.AudioOutput.Volume.StopRamp(); - } - - public void VolumeUp(bool pressRelease) - { - if (pressRelease) - SigHelper.RampTimeScaled(_rmc.AudioOutput.Volume, 65535, 4000); - else - _rmc.AudioOutput.Volume.StopRamp(); - } - - #endregion - - public eHdcpCapabilityType DmInHdcpCapability - { - get { return eHdcpCapabilityType.Hdcp2_2Support; } - } - - public void SetDmInHdcpState(eHdcpCapabilityType hdcpState) - { - if (_rmc == null) return; - _rmc.DmInput.HdcpCapability = hdcpState; - } - - - #region IBasicVideoMuteWithFeedback Members - - public BoolFeedback VideoMuteIsOn - { - get; - private set; - } - - public void VideoMuteOn() - { - Debug.Console(2, this, "Video Mute On"); - _rmc.HdmiOutput.BlankEnabled(); - } - - public void VideoMuteOff() - { - Debug.Console(2, this, "Video Mute Off"); - _rmc.HdmiOutput.BlankDisabled(); - } - - #endregion - - #region IBasicVideoMute Members - - public void VideoMuteToggle() - { - Debug.Console(2, this, "Video Mute Toggle"); - if (_rmc.HdmiOutput.BlankEnabledFeedback.BoolValue == true) - VideoMuteOff(); - else - VideoMuteOn(); - } - - #endregion - } +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Receivers; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash_Essentials_DM; +using System.Collections.Generic; + +namespace PepperDash.Essentials.DM +{ + /// + /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions + /// + /// + [Description("Wrapper Class for DM-RMC-4K-SCALER-C")] + public class DmRmc4kScalerCController : DmRmcControllerBase, IRoutingInputsOutputs, IBasicVolumeWithFeedback, + IIROutputPorts, IComPorts, ICec, IRelayPorts, IHasDmInHdcp, IBasicVideoMuteWithFeedback + { + private readonly DmRmc4kScalerC _rmc; + + public RoutingInputPort DmIn { get; private set; } + public RoutingOutputPort HdmiOut { get; private set; } + public RoutingOutputPort BalancedAudioOut { get; private set; } + + public RoutingPortCollection InputPorts { get; private set; } + + public RoutingPortCollection OutputPorts { get; private set; } + + public EndpointDmInputStreamWithCec DmInput { get; private set; } + + public IntFeedback DmInHdcpStateFeedback { get; private set; } + + + + /// + /// Make a Crestron RMC and put it in here + /// + public DmRmc4kScalerCController(string key, string name, DmRmc4kScalerC rmc) + : base(key, name, rmc) + { + _rmc = rmc; + + DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.DmCat, 0, this); + HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.Hdmi, null, this); + BalancedAudioOut = new RoutingOutputPort(DmPortName.BalancedAudioOut, eRoutingSignalType.Audio, + eRoutingPortConnectionType.LineAudio, null, this); + + MuteFeedback = new BoolFeedback(() => false); + + VolumeLevelFeedback = new IntFeedback("MainVolumeLevelFeedback", () => + rmc.AudioOutput.VolumeFeedback.UShortValue); + + EdidManufacturerFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Manufacturer.StringValue); + EdidNameFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Name.StringValue); + EdidPreferredTimingFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.PreferredTiming.StringValue); + EdidSerialNumberFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.SerialNumber.StringValue); + + InputPorts = new RoutingPortCollection { DmIn }; + OutputPorts = new RoutingPortCollection { HdmiOut, BalancedAudioOut }; + + VideoOutputResolutionFeedback = new StringFeedback(() => _rmc.HdmiOutput.GetVideoResolutionString()); + DmInHdcpStateFeedback = new IntFeedback("DmInHdcpCapability", + () => (int)_rmc.DmInput.HdcpCapabilityFeedback); + + AddToFeedbackList(DmInHdcpStateFeedback); + + VideoMuteIsOn = new BoolFeedback("HdmiOutputVideoMuteIsOn", () => _rmc.HdmiOutput.BlankEnabledFeedback.BoolValue); + + _rmc.HdmiOutput.OutputStreamChange += HdmiOutput_OutputStreamChange; + _rmc.HdmiOutput.ConnectedDevice.DeviceInformationChange += ConnectedDevice_DeviceInformationChange; + + // Set Ports for CEC + HdmiOut.Port = _rmc.HdmiOutput; + } + + void HdmiOutput_OutputStreamChange(EndpointOutputStream outputStream, EndpointOutputStreamEventArgs args) + { + if (args.EventId == EndpointOutputStreamEventIds.HorizontalResolutionFeedbackEventId || args.EventId == EndpointOutputStreamEventIds.VerticalResolutionFeedbackEventId || + args.EventId == EndpointOutputStreamEventIds.FramesPerSecondFeedbackEventId) + { + VideoOutputResolutionFeedback.FireUpdate(); + } + else if (args.EventId == EndpointOutputStreamEventIds.BlankEnabledFeedbackEventId) + { + VideoMuteIsOn.FireUpdate(); + } + } + + void ConnectedDevice_DeviceInformationChange(ConnectedDeviceInformation connectedDevice, ConnectedDeviceEventArgs args) + { + switch (args.EventId) + { + case ConnectedDeviceEventIds.ManufacturerEventId: + EdidManufacturerFeedback.FireUpdate(); + break; + case ConnectedDeviceEventIds.NameEventId: + EdidNameFeedback.FireUpdate(); + break; + case ConnectedDeviceEventIds.PreferredTimingEventId: + EdidPreferredTimingFeedback.FireUpdate(); + break; + case ConnectedDeviceEventIds.SerialNumberEventId: + EdidSerialNumberFeedback.FireUpdate(); + break; + } + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); + } + + #region IIROutputPorts Members + public CrestronCollection IROutputPorts { get { return _rmc.IROutputPorts; } } + public int NumberOfIROutputPorts { get { return _rmc.NumberOfIROutputPorts; } } + #endregion + + #region IComPorts Members + public CrestronCollection ComPorts { get { return _rmc.ComPorts; } } + public int NumberOfComPorts { get { return _rmc.NumberOfComPorts; } } + #endregion + + #region ICec Members + /// + /// Gets the CEC stream directly from the HDMI port. + /// + public Cec StreamCec { get { return _rmc.HdmiOutput.StreamCec; } } + #endregion + + #region IRelayPorts Members + + public int NumberOfRelayPorts + { + get { return _rmc.NumberOfRelayPorts; } + } + + public CrestronCollection RelayPorts + { + get { return _rmc.RelayPorts; } + } + + #endregion + + #region IBasicVolumeWithFeedback Members + + public BoolFeedback MuteFeedback + { + get; + private set; + } + + /// + /// Not implemented + /// + public void MuteOff() + { + Debug.Console(2, this, "DM Endpoint {0} does not have a mute function", Key); + } + + /// + /// Not implemented + /// + public void MuteOn() + { + Debug.Console(2, this, "DM Endpoint {0} does not have a mute function", Key); + } + + public void SetVolume(ushort level) + { + _rmc.AudioOutput.Volume.UShortValue = level; + } + + public IntFeedback VolumeLevelFeedback + { + get; + private set; + } + + #endregion + + #region IBasicVolumeControls Members + + /// + /// Not implemented + /// + public void MuteToggle() + { + Debug.Console(2, this, "DM Endpoint {0} does not have a mute function", Key); + } + + public void VolumeDown(bool pressRelease) + { + if (pressRelease) + SigHelper.RampTimeScaled(_rmc.AudioOutput.Volume, 0, 4000); + else + _rmc.AudioOutput.Volume.StopRamp(); + } + + public void VolumeUp(bool pressRelease) + { + if (pressRelease) + SigHelper.RampTimeScaled(_rmc.AudioOutput.Volume, 65535, 4000); + else + _rmc.AudioOutput.Volume.StopRamp(); + } + + #endregion + + public eHdcpCapabilityType DmInHdcpCapability + { + get { return eHdcpCapabilityType.Hdcp2_2Support; } + } + + public void SetDmInHdcpState(eHdcpCapabilityType hdcpState) + { + if (_rmc == null) return; + _rmc.DmInput.HdcpCapability = hdcpState; + } + + + #region IBasicVideoMuteWithFeedback Members + + public BoolFeedback VideoMuteIsOn + { + get; + private set; + } + + public void VideoMuteOn() + { + Debug.Console(2, this, "Video Mute On"); + _rmc.HdmiOutput.BlankEnabled(); + } + + public void VideoMuteOff() + { + Debug.Console(2, this, "Video Mute Off"); + _rmc.HdmiOutput.BlankDisabled(); + } + + #endregion + + #region IBasicVideoMute Members + + public void VideoMuteToggle() + { + Debug.Console(2, this, "Video Mute Toggle"); + if (_rmc.HdmiOutput.BlankEnabledFeedback.BoolValue == true) + VideoMuteOff(); + else + VideoMuteOn(); + } + + #endregion + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4k100C1GController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4k100C1GController.cs similarity index 98% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4k100C1GController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4k100C1GController.cs index d92d9620..7eef9d13 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4k100C1GController.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4k100C1GController.cs @@ -1,16 +1,16 @@ using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints.Receivers; -using Crestron.SimplSharpPro.DeviceSupport; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core; -using PepperDash.Core; -using Newtonsoft.Json; +using Crestron.SimplSharpPro.DM.Endpoints.Receivers; +using Crestron.SimplSharpPro.DeviceSupport; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core; +using PepperDash.Core; +using Newtonsoft.Json; namespace PepperDash.Essentials.DM -{ - - [Description("Wrapper Class for DM-RMC-4K-100-C-1G")] +{ + + [Description("Wrapper Class for DM-RMC-4K-100-C-1G")] public class DmRmc4k100C1GController : DmHdBaseTControllerBase, IRoutingInputsOutputs, IIROutputPorts, IComPorts, ICec { @@ -32,33 +32,33 @@ namespace PepperDash.Essentials.DM eRoutingPortConnectionType.Hdmi, null, this) {Port = _rmc}; InputPorts = new RoutingPortCollection {DmIn}; - OutputPorts = new RoutingPortCollection {HdmiOut}; - PreventRegistration = true; + OutputPorts = new RoutingPortCollection {HdmiOut}; + PreventRegistration = true; rmc.Register(); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new DmRmcControllerJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - trilist.StringInput[joinMap.Name.JoinNumber].StringValue = this.Name; + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new DmRmcControllerJoinMap(joinStart); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + else + { + Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + } + + Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + trilist.StringInput[joinMap.Name.JoinNumber].StringValue = this.Name; } #region IIROutputPorts Members diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kScalerCDspController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kScalerCDspController.cs similarity index 99% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kScalerCDspController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kScalerCDspController.cs index 99bc35fd..7a172cd3 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kScalerCDspController.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kScalerCDspController.cs @@ -5,16 +5,16 @@ using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Receivers; using PepperDash.Core; using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash_Essentials_DM; - +using PepperDash.Essentials.Core.Bridges; +using PepperDash_Essentials_DM; + namespace PepperDash.Essentials.DM { /// /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions /// - /// - [Description("Wrapper Class for DM-RMC-4K-SCALER-C-DSP")] + /// + [Description("Wrapper Class for DM-RMC-4K-SCALER-C-DSP")] public class DmRmc4kScalerCDspController : DmRmcControllerBase, IRoutingInputsOutputs, IBasicVolumeWithFeedback, IIROutputPorts, IComPorts, ICec, IRelayPorts, IHasDmInHdcp { @@ -26,11 +26,11 @@ namespace PepperDash.Essentials.DM public RoutingPortCollection InputPorts { get; private set; } - public RoutingPortCollection OutputPorts { get; private set; } - - public EndpointDmInputStreamWithCec DmInput { get; private set; } - - public IntFeedback DmInHdcpStateFeedback { get; private set; } + public RoutingPortCollection OutputPorts { get; private set; } + + public EndpointDmInputStreamWithCec DmInput { get; private set; } + + public IntFeedback DmInHdcpStateFeedback { get; private set; } /// @@ -57,12 +57,12 @@ namespace PepperDash.Essentials.DM EdidPreferredTimingFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.PreferredTiming.StringValue); EdidSerialNumberFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.SerialNumber.StringValue); - VideoOutputResolutionFeedback = new StringFeedback(() => _rmc.HdmiOutput.GetVideoResolutionString()); - - DmInHdcpStateFeedback = new IntFeedback("DmInHdcpCapability", - () => (int) _rmc.DmInput.HdcpCapabilityFeedback); - - AddToFeedbackList(DmInHdcpStateFeedback); + VideoOutputResolutionFeedback = new StringFeedback(() => _rmc.HdmiOutput.GetVideoResolutionString()); + + DmInHdcpStateFeedback = new IntFeedback("DmInHdcpCapability", + () => (int) _rmc.DmInput.HdcpCapabilityFeedback); + + AddToFeedbackList(DmInHdcpStateFeedback); InputPorts = new RoutingPortCollection {DmIn}; @@ -202,18 +202,18 @@ namespace PepperDash.Essentials.DM _rmc.AudioOutput.Volume.StopRamp(); } - #endregion - - public eHdcpCapabilityType DmInHdcpCapability - { - get { return eHdcpCapabilityType.Hdcp2_2Support; } - } - - public void SetDmInHdcpState(eHdcpCapabilityType hdcpState) - { - if (_rmc == null) return; - _rmc.DmInput.HdcpCapability = hdcpState; - } + #endregion + + public eHdcpCapabilityType DmInHdcpCapability + { + get { return eHdcpCapabilityType.Hdcp2_2Support; } + } + + public void SetDmInHdcpState(eHdcpCapabilityType hdcpState) + { + if (_rmc == null) return; + _rmc.DmInput.HdcpCapability = hdcpState; + } } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZ100CController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZ100CController.cs similarity index 99% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZ100CController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZ100CController.cs index febcc9dc..3e3f56f9 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZ100CController.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZ100CController.cs @@ -7,8 +7,8 @@ using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.DM -{ - [Description("Wrapper Class for DM-RMC-4K-Z-100-C")] +{ + [Description("Wrapper Class for DM-RMC-4K-Z-100-C")] public class DmRmc4kZ100CController : DmRmcX100CController { private readonly DmRmc4kz100C _rmc; diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZScalerCController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZScalerCController.cs similarity index 97% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZScalerCController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZScalerCController.cs index fd48a904..07b348e5 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZScalerCController.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZScalerCController.cs @@ -1,245 +1,245 @@ -using System; -using System.Linq; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Receivers; - -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Core; -using PepperDash_Essentials_DM; - -namespace PepperDash.Essentials.DM -{ - [Description("Wrapper Class for DM-RMC-4K-Z-SCALER-C")] - public class DmRmc4kZScalerCController : DmRmcControllerBase, IRmcRoutingWithFeedback, - IIROutputPorts, IComPorts, ICec, IRelayPorts, IHasDmInHdcp, IHasHdmiInHdcp - { - private readonly DmRmc4kzScalerC _rmc; - - public RoutingInputPort DmIn { get; private set; } - public RoutingInputPort HdmiIn { get; private set; } - public RoutingOutputPort HdmiOut { get; private set; } - - public IntFeedback DmInHdcpStateFeedback { get; private set; } - public IntFeedback HdmiInHdcpStateFeedback { get; private set; } - - public BoolFeedback HdmiVideoSyncFeedback { get; private set; } - - - - /// - /// The value of the current video source for the HDMI output on the receiver - /// - public IntFeedback AudioVideoSourceNumericFeedback { get; private set; } - - public RoutingPortCollection InputPorts { get; private set; } - - public RoutingPortCollection OutputPorts { get; private set; } - - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - - public DmRmc4kZScalerCController(string key, string name, DmRmc4kzScalerC rmc) - : base(key, name, rmc) - { - _rmc = rmc; - - DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.DmCat, 0, this) - { - FeedbackMatchObject = 1 - }; - HdmiIn = new RoutingInputPort(DmPortName.HdmiIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, 0, this) - { - FeedbackMatchObject = 2 - }; - HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, null, this); - - HdmiInHdcpStateFeedback = new IntFeedback("HdmiInHdcpCapability", - () => (int)_rmc.HdmiIn.HdcpCapabilityFeedback); - DmInHdcpStateFeedback = new IntFeedback("DmInHdcpCapability", - () => (int)_rmc.DmInput.HdcpCapabilityFeedback); - HdmiVideoSyncFeedback = new BoolFeedback("HdmiInVideoSync", - () => _rmc.HdmiIn.SyncDetectedFeedback.BoolValue); - - AddToFeedbackList(HdmiInHdcpStateFeedback, DmInHdcpStateFeedback, HdmiVideoSyncFeedback); - - - EdidManufacturerFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Manufacturer.StringValue); - EdidNameFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Name.StringValue); - EdidPreferredTimingFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.PreferredTiming.StringValue); - EdidSerialNumberFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.SerialNumber.StringValue); - - VideoOutputResolutionFeedback = new StringFeedback(() => _rmc.HdmiOutput.GetVideoResolutionString()); - - InputPorts = new RoutingPortCollection { DmIn, HdmiIn }; - OutputPorts = new RoutingPortCollection { HdmiOut }; - - _rmc.HdmiOutput.OutputStreamChange += HdmiOutput_OutputStreamChange; - _rmc.HdmiOutput.ConnectedDevice.DeviceInformationChange += ConnectedDevice_DeviceInformationChange; - _rmc.HdmiIn.InputStreamChange += InputStreamChangeEvent; - _rmc.DmInput.InputStreamChange += InputStreamChangeEvent; - - _rmc.OnlineStatusChange += _rmc_OnlineStatusChange; - - // Set Ports for CEC - HdmiOut.Port = _rmc.HdmiOutput; - - AudioVideoSourceNumericFeedback = new IntFeedback(() => (ushort)(_rmc.SelectedSourceFeedback)); - } - - void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - switch (args.EventId) - { - case EndpointInputStreamEventIds.HdcpCapabilityFeedbackEventId: - if (inputStream == _rmc.HdmiIn) HdmiInHdcpStateFeedback.FireUpdate(); - if (inputStream == _rmc.DmInput) DmInHdcpStateFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - if (inputStream == _rmc.HdmiIn) HdmiVideoSyncFeedback.FireUpdate(); - break; - } - } - - private void _rmc_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) - { - AudioVideoSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioVideoSourceNumericFeedback.UShortValue, eRoutingSignalType.AudioVideo)); - } - - void HdmiOutput_OutputStreamChange(EndpointOutputStream outputStream, EndpointOutputStreamEventArgs args) - { - if (args.EventId == EndpointOutputStreamEventIds.HorizontalResolutionFeedbackEventId || args.EventId == EndpointOutputStreamEventIds.VerticalResolutionFeedbackEventId || - args.EventId == EndpointOutputStreamEventIds.FramesPerSecondFeedbackEventId) - { - VideoOutputResolutionFeedback.FireUpdate(); - } - - if (args.EventId == EndpointOutputStreamEventIds.SelectedSourceFeedbackEventId) - { - var localInputPort = - InputPorts.FirstOrDefault(p => (int)p.FeedbackMatchObject == AudioVideoSourceNumericFeedback.UShortValue); - - - AudioVideoSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioVideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputPort, eRoutingSignalType.AudioVideo)); - } - } - - void ConnectedDevice_DeviceInformationChange(ConnectedDeviceInformation connectedDevice, ConnectedDeviceEventArgs args) - { - switch (args.EventId) - { - case ConnectedDeviceEventIds.ManufacturerEventId: - EdidManufacturerFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.NameEventId: - EdidNameFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.PreferredTimingEventId: - EdidPreferredTimingFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.SerialNumberEventId: - EdidSerialNumberFeedback.FireUpdate(); - break; - } - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); - } - - #region IIROutputPorts Members - public CrestronCollection IROutputPorts { get { return _rmc.IROutputPorts; } } - public int NumberOfIROutputPorts { get { return _rmc.NumberOfIROutputPorts; } } - #endregion - - #region IComPorts Members - public CrestronCollection ComPorts { get { return _rmc.ComPorts; } } - public int NumberOfComPorts { get { return _rmc.NumberOfComPorts; } } - #endregion - - #region ICec Members - /// - /// Gets the CEC stream directly from the HDMI port. - /// - public Cec StreamCec { get { return _rmc.HdmiOutput.StreamCec; } } - #endregion - - - #region IRmcRouting Members - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - Debug.Console(2, this, "Attempting a route from input {0} to HDMI Output", inputSelector); - - var number = Convert.ToUInt16(inputSelector); - - _rmc.AudioVideoSource = (DmRmc4kzScalerC.eAudioVideoSource)number; - } - - public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType signalType) - { - Debug.Console(2, this, "Attempting a route from input {0} to HDMI Output", inputSelector); - - _rmc.AudioVideoSource = (DmRmc4kzScalerC.eAudioVideoSource)inputSelector; - } - #endregion - - #region Implementation of IRelayPorts - - public CrestronCollection RelayPorts - { - get { return _rmc.RelayPorts; } - } - - public int NumberOfRelayPorts - { - get { return _rmc.NumberOfRelayPorts; } - } - - #endregion - - - public eHdcpCapabilityType DmInHdcpCapability - { - get { return eHdcpCapabilityType.Hdcp2_2Support; } - } - - public void SetDmInHdcpState(eHdcpCapabilityType hdcpState) - { - - if (_rmc == null) return; - _rmc.DmInput.HdcpCapability = hdcpState; - } - - - public eHdcpCapabilityType HdmiInHdcpCapability - { - get { return eHdcpCapabilityType.Hdcp2_2Support; } - } - - public void SetHdmiInHdcpState(eHdcpCapabilityType hdcpState) - { - if (_rmc == null) return; - _rmc.HdmiIn.HdcpCapability = hdcpState; - } - - } +using System; +using System.Linq; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Receivers; + +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Core; +using PepperDash_Essentials_DM; + +namespace PepperDash.Essentials.DM +{ + [Description("Wrapper Class for DM-RMC-4K-Z-SCALER-C")] + public class DmRmc4kZScalerCController : DmRmcControllerBase, IRmcRoutingWithFeedback, + IIROutputPorts, IComPorts, ICec, IRelayPorts, IHasDmInHdcp, IHasHdmiInHdcp + { + private readonly DmRmc4kzScalerC _rmc; + + public RoutingInputPort DmIn { get; private set; } + public RoutingInputPort HdmiIn { get; private set; } + public RoutingOutputPort HdmiOut { get; private set; } + + public IntFeedback DmInHdcpStateFeedback { get; private set; } + public IntFeedback HdmiInHdcpStateFeedback { get; private set; } + + public BoolFeedback HdmiVideoSyncFeedback { get; private set; } + + + + /// + /// The value of the current video source for the HDMI output on the receiver + /// + public IntFeedback AudioVideoSourceNumericFeedback { get; private set; } + + public RoutingPortCollection InputPorts { get; private set; } + + public RoutingPortCollection OutputPorts { get; private set; } + + //IroutingNumericEvent + public event EventHandler NumericSwitchChange; + + /// + /// Raise an event when the status of a switch object changes. + /// + /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType + private void OnSwitchChange(RoutingNumericEventArgs e) + { + var newEvent = NumericSwitchChange; + if (newEvent != null) newEvent(this, e); + } + + public DmRmc4kZScalerCController(string key, string name, DmRmc4kzScalerC rmc) + : base(key, name, rmc) + { + _rmc = rmc; + + DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.DmCat, 0, this) + { + FeedbackMatchObject = 1 + }; + HdmiIn = new RoutingInputPort(DmPortName.HdmiIn, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.Hdmi, 0, this) + { + FeedbackMatchObject = 2 + }; + HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.Hdmi, null, this); + + HdmiInHdcpStateFeedback = new IntFeedback("HdmiInHdcpCapability", + () => (int)_rmc.HdmiIn.HdcpCapabilityFeedback); + DmInHdcpStateFeedback = new IntFeedback("DmInHdcpCapability", + () => (int)_rmc.DmInput.HdcpCapabilityFeedback); + HdmiVideoSyncFeedback = new BoolFeedback("HdmiInVideoSync", + () => _rmc.HdmiIn.SyncDetectedFeedback.BoolValue); + + AddToFeedbackList(HdmiInHdcpStateFeedback, DmInHdcpStateFeedback, HdmiVideoSyncFeedback); + + + EdidManufacturerFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Manufacturer.StringValue); + EdidNameFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Name.StringValue); + EdidPreferredTimingFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.PreferredTiming.StringValue); + EdidSerialNumberFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.SerialNumber.StringValue); + + VideoOutputResolutionFeedback = new StringFeedback(() => _rmc.HdmiOutput.GetVideoResolutionString()); + + InputPorts = new RoutingPortCollection { DmIn, HdmiIn }; + OutputPorts = new RoutingPortCollection { HdmiOut }; + + _rmc.HdmiOutput.OutputStreamChange += HdmiOutput_OutputStreamChange; + _rmc.HdmiOutput.ConnectedDevice.DeviceInformationChange += ConnectedDevice_DeviceInformationChange; + _rmc.HdmiIn.InputStreamChange += InputStreamChangeEvent; + _rmc.DmInput.InputStreamChange += InputStreamChangeEvent; + + _rmc.OnlineStatusChange += _rmc_OnlineStatusChange; + + // Set Ports for CEC + HdmiOut.Port = _rmc.HdmiOutput; + + AudioVideoSourceNumericFeedback = new IntFeedback(() => (ushort)(_rmc.SelectedSourceFeedback)); + } + + void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) + { + switch (args.EventId) + { + case EndpointInputStreamEventIds.HdcpCapabilityFeedbackEventId: + if (inputStream == _rmc.HdmiIn) HdmiInHdcpStateFeedback.FireUpdate(); + if (inputStream == _rmc.DmInput) DmInHdcpStateFeedback.FireUpdate(); + break; + case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: + if (inputStream == _rmc.HdmiIn) HdmiVideoSyncFeedback.FireUpdate(); + break; + } + } + + private void _rmc_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) + { + AudioVideoSourceNumericFeedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(1, AudioVideoSourceNumericFeedback.UShortValue, eRoutingSignalType.AudioVideo)); + } + + void HdmiOutput_OutputStreamChange(EndpointOutputStream outputStream, EndpointOutputStreamEventArgs args) + { + if (args.EventId == EndpointOutputStreamEventIds.HorizontalResolutionFeedbackEventId || args.EventId == EndpointOutputStreamEventIds.VerticalResolutionFeedbackEventId || + args.EventId == EndpointOutputStreamEventIds.FramesPerSecondFeedbackEventId) + { + VideoOutputResolutionFeedback.FireUpdate(); + } + + if (args.EventId == EndpointOutputStreamEventIds.SelectedSourceFeedbackEventId) + { + var localInputPort = + InputPorts.FirstOrDefault(p => (int)p.FeedbackMatchObject == AudioVideoSourceNumericFeedback.UShortValue); + + + AudioVideoSourceNumericFeedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(1, AudioVideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputPort, eRoutingSignalType.AudioVideo)); + } + } + + void ConnectedDevice_DeviceInformationChange(ConnectedDeviceInformation connectedDevice, ConnectedDeviceEventArgs args) + { + switch (args.EventId) + { + case ConnectedDeviceEventIds.ManufacturerEventId: + EdidManufacturerFeedback.FireUpdate(); + break; + case ConnectedDeviceEventIds.NameEventId: + EdidNameFeedback.FireUpdate(); + break; + case ConnectedDeviceEventIds.PreferredTimingEventId: + EdidPreferredTimingFeedback.FireUpdate(); + break; + case ConnectedDeviceEventIds.SerialNumberEventId: + EdidSerialNumberFeedback.FireUpdate(); + break; + } + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); + } + + #region IIROutputPorts Members + public CrestronCollection IROutputPorts { get { return _rmc.IROutputPorts; } } + public int NumberOfIROutputPorts { get { return _rmc.NumberOfIROutputPorts; } } + #endregion + + #region IComPorts Members + public CrestronCollection ComPorts { get { return _rmc.ComPorts; } } + public int NumberOfComPorts { get { return _rmc.NumberOfComPorts; } } + #endregion + + #region ICec Members + /// + /// Gets the CEC stream directly from the HDMI port. + /// + public Cec StreamCec { get { return _rmc.HdmiOutput.StreamCec; } } + #endregion + + + #region IRmcRouting Members + public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) + { + Debug.Console(2, this, "Attempting a route from input {0} to HDMI Output", inputSelector); + + var number = Convert.ToUInt16(inputSelector); + + _rmc.AudioVideoSource = (DmRmc4kzScalerC.eAudioVideoSource)number; + } + + public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType signalType) + { + Debug.Console(2, this, "Attempting a route from input {0} to HDMI Output", inputSelector); + + _rmc.AudioVideoSource = (DmRmc4kzScalerC.eAudioVideoSource)inputSelector; + } + #endregion + + #region Implementation of IRelayPorts + + public CrestronCollection RelayPorts + { + get { return _rmc.RelayPorts; } + } + + public int NumberOfRelayPorts + { + get { return _rmc.NumberOfRelayPorts; } + } + + #endregion + + + public eHdcpCapabilityType DmInHdcpCapability + { + get { return eHdcpCapabilityType.Hdcp2_2Support; } + } + + public void SetDmInHdcpState(eHdcpCapabilityType hdcpState) + { + + if (_rmc == null) return; + _rmc.DmInput.HdcpCapability = hdcpState; + } + + + public eHdcpCapabilityType HdmiInHdcpCapability + { + get { return eHdcpCapabilityType.Hdcp2_2Support; } + } + + public void SetHdmiInHdcpState(eHdcpCapabilityType hdcpState) + { + if (_rmc == null) return; + _rmc.HdmiIn.HdcpCapability = hdcpState; + } + + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs similarity index 99% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs index ee423436..d348a2d2 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs @@ -59,8 +59,8 @@ namespace PepperDash.Essentials.DM else { Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - + } + LinkDmRmcToApi(rmc, trilist, joinMap); } @@ -142,18 +142,18 @@ namespace PepperDash.Essentials.DM trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber].UShortValue = (ushort)hdcpCapability; - trilist.UShortInput[joinMap.HdcpInputPortCount.JoinNumber].UShortValue = (ushort)routing.InputPorts.Count; - - var dmRmcScalerCBasicVideoMuteWithFeedback = rmc as IBasicVideoMuteWithFeedback; - - if (dmRmcScalerCBasicVideoMuteWithFeedback != null) - { - Debug.Console(1, this, "Device is IBasicVideoMuteWithFeedback, linking video mute"); - trilist.SetSigTrueAction(joinMap.VideoMuteToggle.JoinNumber, () => dmRmcScalerCBasicVideoMuteWithFeedback.VideoMuteToggle()); - trilist.SetSigTrueAction(joinMap.VideoMuteOn.JoinNumber, () => dmRmcScalerCBasicVideoMuteWithFeedback.VideoMuteOn()); - trilist.SetSigTrueAction(joinMap.VideoMuteOff.JoinNumber, () => dmRmcScalerCBasicVideoMuteWithFeedback.VideoMuteOff()); - dmRmcScalerCBasicVideoMuteWithFeedback.VideoMuteIsOn.LinkInputSig(trilist.BooleanInput[joinMap.VideoMuteOn.JoinNumber]); - dmRmcScalerCBasicVideoMuteWithFeedback.VideoMuteIsOn.LinkComplementInputSig(trilist.BooleanInput[joinMap.VideoMuteOff.JoinNumber]); + trilist.UShortInput[joinMap.HdcpInputPortCount.JoinNumber].UShortValue = (ushort)routing.InputPorts.Count; + + var dmRmcScalerCBasicVideoMuteWithFeedback = rmc as IBasicVideoMuteWithFeedback; + + if (dmRmcScalerCBasicVideoMuteWithFeedback != null) + { + Debug.Console(1, this, "Device is IBasicVideoMuteWithFeedback, linking video mute"); + trilist.SetSigTrueAction(joinMap.VideoMuteToggle.JoinNumber, () => dmRmcScalerCBasicVideoMuteWithFeedback.VideoMuteToggle()); + trilist.SetSigTrueAction(joinMap.VideoMuteOn.JoinNumber, () => dmRmcScalerCBasicVideoMuteWithFeedback.VideoMuteOn()); + trilist.SetSigTrueAction(joinMap.VideoMuteOff.JoinNumber, () => dmRmcScalerCBasicVideoMuteWithFeedback.VideoMuteOff()); + dmRmcScalerCBasicVideoMuteWithFeedback.VideoMuteIsOn.LinkInputSig(trilist.BooleanInput[joinMap.VideoMuteOn.JoinNumber]); + dmRmcScalerCBasicVideoMuteWithFeedback.VideoMuteIsOn.LinkComplementInputSig(trilist.BooleanInput[joinMap.VideoMuteOff.JoinNumber]); } var routingWithFeedback = routing as IRmcRouting; diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerCController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerCController.cs similarity index 99% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerCController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerCController.cs index d1f2daa1..ec1493d8 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerCController.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerCController.cs @@ -12,8 +12,8 @@ namespace PepperDash.Essentials.DM /// /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions /// - /// - [Description("Wrapper Class for DM-RMC-SCALER-C")] + /// + [Description("Wrapper Class for DM-RMC-SCALER-C")] public class DmRmcScalerCController : DmRmcControllerBase, IRoutingInputsOutputs, IIROutputPorts, IComPorts, ICec { diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerS2Controller.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerS2Controller.cs similarity index 99% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerS2Controller.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerS2Controller.cs index 249a891b..12e4e9d4 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerS2Controller.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerS2Controller.cs @@ -12,8 +12,8 @@ namespace PepperDash.Essentials.DM /// /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions /// - /// - [Description("Wrapper Class for DM-RMC-SCALER-S2")] + /// + [Description("Wrapper Class for DM-RMC-SCALER-S2")] public class DmRmcScalerS2Controller : DmRmcControllerBase, IRoutingInputsOutputs, IIROutputPorts, IComPorts, ICec { diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerSController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerSController.cs similarity index 99% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerSController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerSController.cs index bbf64796..ba509eac 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerSController.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcScalerSController.cs @@ -12,8 +12,8 @@ namespace PepperDash.Essentials.DM /// /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions /// - /// - [Description("Wrapper Class for DM-RMC-SCALER-S")] + /// + [Description("Wrapper Class for DM-RMC-SCALER-S")] public class DmRmcScalerSController : DmRmcControllerBase, IRoutingInputsOutputs, IIROutputPorts, IComPorts, ICec { diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcX100CController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcX100CController.cs similarity index 99% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcX100CController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcX100CController.cs index 920c056f..867069a8 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcX100CController.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcX100CController.cs @@ -11,8 +11,8 @@ namespace PepperDash.Essentials.DM /// /// Builds a controller for basic DM-RMCs (both 4K and non-4K) with Com and IR ports and no control functions /// - /// - [Description("Wrapper Class for DM-RMC-4K-100-C & DM-RMC-100-C")] + /// + [Description("Wrapper Class for DM-RMC-4K-100-C & DM-RMC-100-C")] public class DmRmcX100CController : DmRmcControllerBase, IRoutingInputsOutputs, IIROutputPorts, IComPorts, ICec { diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx200Controller.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx200Controller.cs similarity index 97% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx200Controller.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx200Controller.cs index 10507c4d..0caf6671 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx200Controller.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx200Controller.cs @@ -1,415 +1,415 @@ -using System; -using System.Linq; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.DM -{ - // using eVst = Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType; - - /// - /// Controller class for all DM-TX-201C/S/F transmitters - /// - [Description("Wrapper class for DM-TX-200-C")] - public class DmTx200Controller : DmTxControllerBase, ITxRoutingWithFeedback, IHasFreeRun, IVgaBrightnessContrastControls - { - public DmTx200C2G Tx { get; private set; } - - public RoutingInputPortWithVideoStatuses HdmiInput { get; private set; } - public RoutingInputPortWithVideoStatuses VgaInput { get; private set; } - public RoutingOutputPort DmOutput { get; private set; } - - public override StringFeedback ActiveVideoInputFeedback { get; protected set; } - public IntFeedback VideoSourceNumericFeedback { get; protected set; } - public IntFeedback AudioSourceNumericFeedback { get; protected set; } - public IntFeedback HdmiInHdcpCapabilityFeedback { get; protected set; } //actually state - public BoolFeedback HdmiVideoSyncFeedback { get; protected set; } - public BoolFeedback VgaVideoSyncFeedback { get; protected set; } - - public BoolFeedback FreeRunEnabledFeedback { get; protected set; } - - public IntFeedback VgaBrightnessFeedback { get; protected set; } - public IntFeedback VgaContrastFeedback { get; protected set; } - - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - - - /// - /// Helps get the "real" inputs, including when in Auto - /// - public DmTx200Base.eSourceSelection ActualActiveVideoInput - { - get - { - if (Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Digital || - Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Analog || - Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Disable) - return Tx.VideoSourceFeedback; - if (Tx.HdmiInput.SyncDetectedFeedback.BoolValue) - return DmTx200Base.eSourceSelection.Digital; - - return Tx.VgaInput.SyncDetectedFeedback.BoolValue ? DmTx200Base.eSourceSelection.Analog : DmTx200Base.eSourceSelection.Disable; - } - } - - public RoutingPortCollection InputPorts - { - get - { - return new RoutingPortCollection - { - HdmiInput, - VgaInput, - AnyVideoInput - }; - } - } - - public RoutingPortCollection OutputPorts - { - get - { - return new RoutingPortCollection { DmOutput }; - } - } - - /// - /// - /// - /// - /// - /// - public DmTx200Controller(string key, string name, DmTx200C2G tx, bool preventRegistration) - : base(key, name, tx) - { - Tx = tx; - PreventRegistration = preventRegistration; - - HdmiInput = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, - DmTx200Base.eSourceSelection.Digital, this, - VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInput)) - { - FeedbackMatchObject = DmTx200Base.eSourceSelection.Digital - }; - - VgaInput = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn, - eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, DmTx200Base.eSourceSelection.Analog, this, - VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput)) - { - FeedbackMatchObject = DmTx200Base.eSourceSelection.Analog - }; - - ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", - () => ActualActiveVideoInput.ToString()); - - Tx.HdmiInput.InputStreamChange += InputStreamChangeEvent; - Tx.VgaInput.InputStreamChange += VgaInputOnInputStreamChange; - Tx.BaseEvent += Tx_BaseEvent; - Tx.OnlineStatusChange += Tx_OnlineStatusChange; - - VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); - AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback); - - HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () => tx.HdmiInput.HdcpSupportOnFeedback.BoolValue ? 1 : 0); - - //setting this on the base class so that we can get it easily on the chassis. - HdcpStateFeedback = HdmiInHdcpCapabilityFeedback; - - HdcpSupportCapability = eHdcpCapabilityType.HdcpAutoSupport; - - HdmiVideoSyncFeedback = new BoolFeedback(() => tx.HdmiInput.SyncDetectedFeedback.BoolValue); - - VgaVideoSyncFeedback = new BoolFeedback(() => tx.VgaInput.SyncDetectedFeedback.BoolValue); - - FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled); - - VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue); - VgaContrastFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue); - - tx.VgaInput.VideoControls.ControlChange += VideoControls_ControlChange; - - - var combinedFuncs = new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => - (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital - && tx.HdmiInput.VideoAttributes.HdcpActiveFeedback.BoolValue), - - HdcpStateFeedbackFunc = () => ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital ? tx.HdmiInput.VideoAttributes.HdcpStateFeedback.ToString() : "", - - VideoResolutionFeedbackFunc = () => - { - if (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital) - return tx.HdmiInput.VideoAttributes.GetVideoResolutionString(); - return ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog ? tx.VgaInput.VideoAttributes.GetVideoResolutionString() : ""; - }, - VideoSyncFeedbackFunc = () => - (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital - && tx.HdmiInput.SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog - && tx.VgaInput.SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Auto - && (tx.VgaInput.SyncDetectedFeedback.BoolValue || tx.HdmiInput.SyncDetectedFeedback.BoolValue)) - - }; - - AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); - - DmOutput = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmCat, null, this); - - AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, - AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, - AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, - AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback, HdmiVideoSyncFeedback, - VgaVideoSyncFeedback); - - // Set Ports for CEC - HdmiInput.Port = Tx.HdmiInput; - VgaInput.Port = Tx.VgaInput; - DmOutput.Port = Tx.DmOutput; - } - - private void VgaInputOnInputStreamChange(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - switch (args.EventId) - { - case EndpointInputStreamEventIds.FreeRunFeedbackEventId: - FreeRunEnabledFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - VgaVideoSyncFeedback.FireUpdate(); - break; - } - } - - void VideoControls_ControlChange(object sender, GenericEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case VideoControlsEventIds.BrightnessFeedbackEventId: - VgaBrightnessFeedback.FireUpdate(); - break; - case VideoControlsEventIds.ContrastFeedbackEventId: - VgaContrastFeedback.FireUpdate(); - break; - } - } - - void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) - { - var localVideoInputPort = - InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection) p.Selector == Tx.VideoSourceFeedback); - var localAudioInputPort = - InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection) p.Selector == Tx.AudioSourceFeedback); - - - ActiveVideoInputFeedback.FireUpdate(); - VideoSourceNumericFeedback.FireUpdate(); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); - } - - public override bool CustomActivate() - { - - Tx.HdmiInput.InputStreamChange += (o, a) => FowardInputStreamChange(HdmiInput, a.EventId); - Tx.HdmiInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(HdmiInput, a.EventId); - - Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaInput, a.EventId); - Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(VgaInput, a.EventId); - - // Base does register and sets up comm monitoring. - return base.CustomActivate(); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); - - if (HdmiVideoSyncFeedback != null) - { - HdmiVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); - } - if (VgaVideoSyncFeedback != null) - { - VgaVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); - } - - LinkDmTxToApi(this, trilist, joinMap, bridge); - } - - /// - /// Enables or disables free run - /// - /// - public void SetFreeRunEnabled(bool enable) - { - Tx.VgaInput.FreeRun = enable ? eDmFreeRunSetting.Enabled : eDmFreeRunSetting.Disabled; - } - - /// - /// Sets the VGA brightness level - /// - /// - public void SetVgaBrightness(ushort level) - { - Tx.VgaInput.VideoControls.Brightness.UShortValue = level; - } - - /// - /// Sets the VGA contrast level - /// - /// - public void SetVgaContrast(ushort level) - { - Tx.VgaInput.VideoControls.Contrast.UShortValue = level; - } - - public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) - { - Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); - - switch (input) - { - case 0: - { - ExecuteSwitch(DmTx200Base.eSourceSelection.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(HdmiInput.Selector, null, type); - break; - } - case 2: - { - ExecuteSwitch(VgaInput.Selector, null, type); - break; - } - case 3: - { - ExecuteSwitch(DmTx200Base.eSourceSelection.Disable, null, type); - break; - } - } - } - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) - Tx.VideoSource = (DmTx200Base.eSourceSelection)inputSelector; - if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - Tx.AudioSource = (DmTx200Base.eSourceSelection)inputSelector; - } - - void Tx_BaseEvent(GenericBase device, BaseEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case EndpointTransmitterBase.VideoSourceFeedbackEventId: - var localVideoInputPort = InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.VideoSourceFeedback); - Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); - VideoSourceNumericFeedback.FireUpdate(); - ActiveVideoInputFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - break; - case EndpointTransmitterBase.AudioSourceFeedbackEventId: - var localInputAudioPort = InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.AudioSourceFeedback); - Debug.Console(2, this, " Audio Source: {0}", Tx.AudioSourceFeedback); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); - break; - } - } - - void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - Debug.Console(2, "{0} event {1} stream {2}", Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); - - switch (args.EventId) - { - case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: - HdmiInHdcpCapabilityFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: - HdmiInHdcpCapabilityFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - HdmiVideoSyncFeedback.FireUpdate(); - break; - } - } - - /// - /// Relays the input stream change to the appropriate RoutingInputPort. - /// - void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) - { - return; - } - inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); - } - - /// - /// Relays the VideoAttributes change to a RoutingInputPort - /// - void FireVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds - //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", - // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); - switch (eventId) - { - case VideoAttributeEventIds.HdcpActiveFeedbackEventId: - inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HdcpStateFeedbackEventId: - inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: - case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - } - } - - } +using System; +using System.Linq; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; + +namespace PepperDash.Essentials.DM +{ + // using eVst = Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType; + + /// + /// Controller class for all DM-TX-201C/S/F transmitters + /// + [Description("Wrapper class for DM-TX-200-C")] + public class DmTx200Controller : DmTxControllerBase, ITxRoutingWithFeedback, IHasFreeRun, IVgaBrightnessContrastControls + { + public DmTx200C2G Tx { get; private set; } + + public RoutingInputPortWithVideoStatuses HdmiInput { get; private set; } + public RoutingInputPortWithVideoStatuses VgaInput { get; private set; } + public RoutingOutputPort DmOutput { get; private set; } + + public override StringFeedback ActiveVideoInputFeedback { get; protected set; } + public IntFeedback VideoSourceNumericFeedback { get; protected set; } + public IntFeedback AudioSourceNumericFeedback { get; protected set; } + public IntFeedback HdmiInHdcpCapabilityFeedback { get; protected set; } //actually state + public BoolFeedback HdmiVideoSyncFeedback { get; protected set; } + public BoolFeedback VgaVideoSyncFeedback { get; protected set; } + + public BoolFeedback FreeRunEnabledFeedback { get; protected set; } + + public IntFeedback VgaBrightnessFeedback { get; protected set; } + public IntFeedback VgaContrastFeedback { get; protected set; } + + //IroutingNumericEvent + public event EventHandler NumericSwitchChange; + + /// + /// Raise an event when the status of a switch object changes. + /// + /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType + private void OnSwitchChange(RoutingNumericEventArgs e) + { + var newEvent = NumericSwitchChange; + if (newEvent != null) newEvent(this, e); + } + + + /// + /// Helps get the "real" inputs, including when in Auto + /// + public DmTx200Base.eSourceSelection ActualActiveVideoInput + { + get + { + if (Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Digital || + Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Analog || + Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Disable) + return Tx.VideoSourceFeedback; + if (Tx.HdmiInput.SyncDetectedFeedback.BoolValue) + return DmTx200Base.eSourceSelection.Digital; + + return Tx.VgaInput.SyncDetectedFeedback.BoolValue ? DmTx200Base.eSourceSelection.Analog : DmTx200Base.eSourceSelection.Disable; + } + } + + public RoutingPortCollection InputPorts + { + get + { + return new RoutingPortCollection + { + HdmiInput, + VgaInput, + AnyVideoInput + }; + } + } + + public RoutingPortCollection OutputPorts + { + get + { + return new RoutingPortCollection { DmOutput }; + } + } + + /// + /// + /// + /// + /// + /// + public DmTx200Controller(string key, string name, DmTx200C2G tx, bool preventRegistration) + : base(key, name, tx) + { + Tx = tx; + PreventRegistration = preventRegistration; + + HdmiInput = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, + DmTx200Base.eSourceSelection.Digital, this, + VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInput)) + { + FeedbackMatchObject = DmTx200Base.eSourceSelection.Digital + }; + + VgaInput = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn, + eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, DmTx200Base.eSourceSelection.Analog, this, + VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput)) + { + FeedbackMatchObject = DmTx200Base.eSourceSelection.Analog + }; + + ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", + () => ActualActiveVideoInput.ToString()); + + Tx.HdmiInput.InputStreamChange += InputStreamChangeEvent; + Tx.VgaInput.InputStreamChange += VgaInputOnInputStreamChange; + Tx.BaseEvent += Tx_BaseEvent; + Tx.OnlineStatusChange += Tx_OnlineStatusChange; + + VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); + AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback); + + HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () => tx.HdmiInput.HdcpSupportOnFeedback.BoolValue ? 1 : 0); + + //setting this on the base class so that we can get it easily on the chassis. + HdcpStateFeedback = HdmiInHdcpCapabilityFeedback; + + HdcpSupportCapability = eHdcpCapabilityType.HdcpAutoSupport; + + HdmiVideoSyncFeedback = new BoolFeedback(() => tx.HdmiInput.SyncDetectedFeedback.BoolValue); + + VgaVideoSyncFeedback = new BoolFeedback(() => tx.VgaInput.SyncDetectedFeedback.BoolValue); + + FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled); + + VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue); + VgaContrastFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue); + + tx.VgaInput.VideoControls.ControlChange += VideoControls_ControlChange; + + + var combinedFuncs = new VideoStatusFuncsWrapper + { + HdcpActiveFeedbackFunc = () => + (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital + && tx.HdmiInput.VideoAttributes.HdcpActiveFeedback.BoolValue), + + HdcpStateFeedbackFunc = () => ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital ? tx.HdmiInput.VideoAttributes.HdcpStateFeedback.ToString() : "", + + VideoResolutionFeedbackFunc = () => + { + if (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital) + return tx.HdmiInput.VideoAttributes.GetVideoResolutionString(); + return ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog ? tx.VgaInput.VideoAttributes.GetVideoResolutionString() : ""; + }, + VideoSyncFeedbackFunc = () => + (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital + && tx.HdmiInput.SyncDetectedFeedback.BoolValue) + || (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog + && tx.VgaInput.SyncDetectedFeedback.BoolValue) + || (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Auto + && (tx.VgaInput.SyncDetectedFeedback.BoolValue || tx.HdmiInput.SyncDetectedFeedback.BoolValue)) + + }; + + AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); + + DmOutput = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.DmCat, null, this); + + AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, + AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, + AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, + AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback, HdmiVideoSyncFeedback, + VgaVideoSyncFeedback); + + // Set Ports for CEC + HdmiInput.Port = Tx.HdmiInput; + VgaInput.Port = Tx.VgaInput; + DmOutput.Port = Tx.DmOutput; + } + + private void VgaInputOnInputStreamChange(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) + { + switch (args.EventId) + { + case EndpointInputStreamEventIds.FreeRunFeedbackEventId: + FreeRunEnabledFeedback.FireUpdate(); + break; + case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: + VgaVideoSyncFeedback.FireUpdate(); + break; + } + } + + void VideoControls_ControlChange(object sender, GenericEventArgs args) + { + var id = args.EventId; + Debug.Console(2, this, "EventId {0}", args.EventId); + + switch (id) + { + case VideoControlsEventIds.BrightnessFeedbackEventId: + VgaBrightnessFeedback.FireUpdate(); + break; + case VideoControlsEventIds.ContrastFeedbackEventId: + VgaContrastFeedback.FireUpdate(); + break; + } + } + + void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) + { + var localVideoInputPort = + InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection) p.Selector == Tx.VideoSourceFeedback); + var localAudioInputPort = + InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection) p.Selector == Tx.AudioSourceFeedback); + + + ActiveVideoInputFeedback.FireUpdate(); + VideoSourceNumericFeedback.FireUpdate(); + AudioSourceNumericFeedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); + OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); + } + + public override bool CustomActivate() + { + + Tx.HdmiInput.InputStreamChange += (o, a) => FowardInputStreamChange(HdmiInput, a.EventId); + Tx.HdmiInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(HdmiInput, a.EventId); + + Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaInput, a.EventId); + Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(VgaInput, a.EventId); + + // Base does register and sets up comm monitoring. + return base.CustomActivate(); + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); + + if (HdmiVideoSyncFeedback != null) + { + HdmiVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); + } + if (VgaVideoSyncFeedback != null) + { + VgaVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); + } + + LinkDmTxToApi(this, trilist, joinMap, bridge); + } + + /// + /// Enables or disables free run + /// + /// + public void SetFreeRunEnabled(bool enable) + { + Tx.VgaInput.FreeRun = enable ? eDmFreeRunSetting.Enabled : eDmFreeRunSetting.Disabled; + } + + /// + /// Sets the VGA brightness level + /// + /// + public void SetVgaBrightness(ushort level) + { + Tx.VgaInput.VideoControls.Brightness.UShortValue = level; + } + + /// + /// Sets the VGA contrast level + /// + /// + public void SetVgaContrast(ushort level) + { + Tx.VgaInput.VideoControls.Contrast.UShortValue = level; + } + + public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) + { + Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); + + switch (input) + { + case 0: + { + ExecuteSwitch(DmTx200Base.eSourceSelection.Auto, null, type); + break; + } + case 1: + { + ExecuteSwitch(HdmiInput.Selector, null, type); + break; + } + case 2: + { + ExecuteSwitch(VgaInput.Selector, null, type); + break; + } + case 3: + { + ExecuteSwitch(DmTx200Base.eSourceSelection.Disable, null, type); + break; + } + } + } + + public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) + { + if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) + Tx.VideoSource = (DmTx200Base.eSourceSelection)inputSelector; + if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) + Tx.AudioSource = (DmTx200Base.eSourceSelection)inputSelector; + } + + void Tx_BaseEvent(GenericBase device, BaseEventArgs args) + { + var id = args.EventId; + Debug.Console(2, this, "EventId {0}", args.EventId); + + switch (id) + { + case EndpointTransmitterBase.VideoSourceFeedbackEventId: + var localVideoInputPort = InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.VideoSourceFeedback); + Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); + VideoSourceNumericFeedback.FireUpdate(); + ActiveVideoInputFeedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); + break; + case EndpointTransmitterBase.AudioSourceFeedbackEventId: + var localInputAudioPort = InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.AudioSourceFeedback); + Debug.Console(2, this, " Audio Source: {0}", Tx.AudioSourceFeedback); + AudioSourceNumericFeedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); + break; + } + } + + void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) + { + Debug.Console(2, "{0} event {1} stream {2}", Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); + + switch (args.EventId) + { + case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: + HdmiInHdcpCapabilityFeedback.FireUpdate(); + break; + case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: + HdmiInHdcpCapabilityFeedback.FireUpdate(); + break; + case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: + HdmiVideoSyncFeedback.FireUpdate(); + break; + } + } + + /// + /// Relays the input stream change to the appropriate RoutingInputPort. + /// + void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { + if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) + { + return; + } + inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); + } + + /// + /// Relays the VideoAttributes change to a RoutingInputPort + /// + void FireVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { + //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds + //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", + // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); + switch (eventId) + { + case VideoAttributeEventIds.HdcpActiveFeedbackEventId: + inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HdcpStateFeedbackEventId: + inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: + case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; + } + } + + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx201CController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx201CController.cs similarity index 97% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx201CController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx201CController.cs index ae3dd7fc..2e48f1e2 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx201CController.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx201CController.cs @@ -1,430 +1,430 @@ -using System; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; -using System.Linq; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.DM -{ - /// - /// Controller class for all DM-TX-201C/S/F transmitters - /// - [Description("Wrapper class for DM-TX-201-C")] - public class DmTx201CController : DmTxControllerBase, ITxRoutingWithFeedback, IHasFreeRun, IVgaBrightnessContrastControls - { - public DmTx201C Tx { get; private set; } - - public RoutingInputPortWithVideoStatuses HdmiInput { get; private set; } - public RoutingInputPortWithVideoStatuses VgaInput { get; private set; } - public RoutingOutputPort DmOutput { get; private set; } - public RoutingOutputPort HdmiLoopOut { get; private set; } - - public override StringFeedback ActiveVideoInputFeedback { get; protected set; } - public IntFeedback VideoSourceNumericFeedback { get; protected set; } - public IntFeedback AudioSourceNumericFeedback { get; protected set; } - public IntFeedback HdmiInHdcpCapabilityFeedback { get; protected set; } - public BoolFeedback HdmiVideoSyncFeedback { get; protected set; } - public BoolFeedback VgaVideoSyncFeedback { get; protected set; } - - public BoolFeedback FreeRunEnabledFeedback { get; protected set; } - - public IntFeedback VgaBrightnessFeedback { get; protected set; } - public IntFeedback VgaContrastFeedback { get; protected set; } - - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - - /// - /// Helps get the "real" inputs, including when in Auto - /// - public DmTx200Base.eSourceSelection ActualActiveVideoInput - { - get - { - if (Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Digital || - Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Analog || - Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Disable) - return Tx.VideoSourceFeedback; - else // auto - { - if (Tx.HdmiInput.SyncDetectedFeedback.BoolValue) - return DmTx200Base.eSourceSelection.Digital; - else if (Tx.VgaInput.SyncDetectedFeedback.BoolValue) - return DmTx200Base.eSourceSelection.Analog; - else - return DmTx200Base.eSourceSelection.Disable; - } - } - } - - public RoutingPortCollection InputPorts - { - get - { - return new RoutingPortCollection - { - HdmiInput, - VgaInput, - AnyVideoInput - }; - } - } - - public RoutingPortCollection OutputPorts - { - get - { - return new RoutingPortCollection { DmOutput, HdmiLoopOut }; - } - } - - /// - /// - /// - /// - /// - /// - public DmTx201CController(string key, string name, DmTx201C tx, bool preventRegistration) - : base(key, name, tx) - { - Tx = tx; - PreventRegistration = preventRegistration; - - HdmiInput = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, - DmTx200Base.eSourceSelection.Digital, this, - VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInput)) - { - FeedbackMatchObject = DmTx200Base.eSourceSelection.Digital - }; - - VgaInput = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn, - eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, DmTx200Base.eSourceSelection.Analog, this, - VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput)) - { - FeedbackMatchObject = DmTx200Base.eSourceSelection.Analog - }; - - ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", - () => ActualActiveVideoInput.ToString()); - - Tx.HdmiInput.InputStreamChange += InputStreamChangeEvent; - Tx.VgaInput.InputStreamChange += VgaInputOnInputStreamChange; - Tx.BaseEvent += Tx_BaseEvent; - Tx.OnlineStatusChange += new OnlineStatusChangeEventHandler(Tx_OnlineStatusChange); - - VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); - - AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback); - - HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () => - (tx.HdmiInput.HdcpSupportOnFeedback.BoolValue ? 1 : 0)); - - HdcpStateFeedback = HdmiInHdcpCapabilityFeedback; - - HdmiVideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInput.SyncDetectedFeedback.BoolValue); - - VgaVideoSyncFeedback = new BoolFeedback(() => (bool)tx.VgaInput.SyncDetectedFeedback.BoolValue); - - FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled); - - VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue); - - VgaContrastFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue); - - tx.VgaInput.VideoControls.ControlChange += VideoControls_ControlChange; - - HdcpSupportCapability = eHdcpCapabilityType.HdcpAutoSupport; - - var combinedFuncs = new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => - (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital - && tx.HdmiInput.VideoAttributes.HdcpActiveFeedback.BoolValue), - - HdcpStateFeedbackFunc = () => ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital ? - tx.HdmiInput.VideoAttributes.HdcpStateFeedback.ToString() : "", - - VideoResolutionFeedbackFunc = () => - { - if (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital) - return tx.HdmiInput.VideoAttributes.GetVideoResolutionString(); - return ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog ? - tx.VgaInput.VideoAttributes.GetVideoResolutionString() : ""; - }, - - VideoSyncFeedbackFunc = () => - (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital - && tx.HdmiInput.SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog - && tx.VgaInput.SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Auto - && (tx.VgaInput.SyncDetectedFeedback.BoolValue || tx.HdmiInput.SyncDetectedFeedback.BoolValue)) - - }; - - AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); - - DmOutput = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, null, this); - HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null, this); - - AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, - AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, - AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, - AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback, HdmiVideoSyncFeedback, - VgaVideoSyncFeedback); - - // Set Ports for CEC - HdmiInput.Port = Tx.HdmiInput; - VgaInput.Port = Tx.VgaInput; - HdmiLoopOut.Port = Tx.HdmiOutput; - DmOutput.Port = Tx.DmOutput; - } - - void VideoControls_ControlChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case VideoControlsEventIds.BrightnessFeedbackEventId: - VgaBrightnessFeedback.FireUpdate(); - break; - case VideoControlsEventIds.ContrastFeedbackEventId: - VgaContrastFeedback.FireUpdate(); - break; - } - } - - void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) - { - var localVideoInputPort = - InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.VideoSourceFeedback); - var localAudioInputPort = - InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.AudioSourceFeedback); - - - ActiveVideoInputFeedback.FireUpdate(); - VideoSourceNumericFeedback.FireUpdate(); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); - } - - private void VgaInputOnInputStreamChange(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - switch (args.EventId) - { - case EndpointInputStreamEventIds.FreeRunFeedbackEventId: - FreeRunEnabledFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - VgaVideoSyncFeedback.FireUpdate(); - break; - } - } - - public override bool CustomActivate() - { - Tx.HdmiInput.InputStreamChange += (o, a) => FowardInputStreamChange(HdmiInput, a.EventId); - Tx.HdmiInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(HdmiInput, a.EventId); - - Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaInput, a.EventId); - Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(VgaInput, a.EventId); - - // Base does register and sets up comm monitoring. - return base.CustomActivate(); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); - - if (HdmiVideoSyncFeedback != null) - { - HdmiVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); - } - if (VgaVideoSyncFeedback != null) - { - VgaVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); - } - - LinkDmTxToApi(this, trilist, joinMap, bridge); - } - - /// - /// Enables or disables free run - /// - /// - public void SetFreeRunEnabled(bool enable) - { - Tx.VgaInput.FreeRun = enable ? eDmFreeRunSetting.Enabled : eDmFreeRunSetting.Disabled; - } - - /// - /// Sets the VGA brightness level - /// - /// - public void SetVgaBrightness(ushort level) - { - Tx.VgaInput.VideoControls.Brightness.UShortValue = level; - } - - /// - /// Sets the VGA contrast level - /// - /// - public void SetVgaContrast(ushort level) - { - Tx.VgaInput.VideoControls.Contrast.UShortValue = level; - } - - /// - /// Switches the audio/video source based on the integer value (0-Auto, 1-HDMI, 2-VGA, 3-Disable) - /// - /// - /// - /// - public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) - { - Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); - - switch (input) - { - case 0: - { - ExecuteSwitch(DmTx200Base.eSourceSelection.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(HdmiInput.Selector, null, type); - break; - } - case 2: - { - ExecuteSwitch(VgaInput.Selector, null, type); - break; - } - case 3: - { - ExecuteSwitch(DmTx200Base.eSourceSelection.Disable, null, type); - break; - } - } - } - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - if((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) - Tx.VideoSource = (DmTx200Base.eSourceSelection)inputSelector; - if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - Tx.AudioSource = (DmTx200Base.eSourceSelection)inputSelector; - } - - void Tx_BaseEvent(GenericBase device, BaseEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case EndpointTransmitterBase.VideoSourceFeedbackEventId: - var localVideoInputPort = InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.VideoSourceFeedback); - Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); - VideoSourceNumericFeedback.FireUpdate(); - ActiveVideoInputFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - break; - case EndpointTransmitterBase.AudioSourceFeedbackEventId: - var localInputAudioPort = InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.AudioSourceFeedback); - Debug.Console(2, this, " Audio Source: {0}", Tx.AudioSourceFeedback); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); - break; - } - } - - void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - Debug.Console(2, "{0} event {1} stream {2}", Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); - - switch (args.EventId) - { - case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: - HdmiInHdcpCapabilityFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: - HdmiInHdcpCapabilityFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - HdmiVideoSyncFeedback.FireUpdate(); - break; - } - - } - - /// - /// Relays the input stream change to the appropriate RoutingInputPort. - /// - void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) - { - return; - } - inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); - } - - /// - /// Relays the VideoAttributes change to a RoutingInputPort - /// - void FireVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds - //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", - // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); - switch (eventId) - { - case VideoAttributeEventIds.HdcpActiveFeedbackEventId: - inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HdcpStateFeedbackEventId: - inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: - case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - } - } - - } +using System; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; +using System.Linq; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; + +namespace PepperDash.Essentials.DM +{ + /// + /// Controller class for all DM-TX-201C/S/F transmitters + /// + [Description("Wrapper class for DM-TX-201-C")] + public class DmTx201CController : DmTxControllerBase, ITxRoutingWithFeedback, IHasFreeRun, IVgaBrightnessContrastControls + { + public DmTx201C Tx { get; private set; } + + public RoutingInputPortWithVideoStatuses HdmiInput { get; private set; } + public RoutingInputPortWithVideoStatuses VgaInput { get; private set; } + public RoutingOutputPort DmOutput { get; private set; } + public RoutingOutputPort HdmiLoopOut { get; private set; } + + public override StringFeedback ActiveVideoInputFeedback { get; protected set; } + public IntFeedback VideoSourceNumericFeedback { get; protected set; } + public IntFeedback AudioSourceNumericFeedback { get; protected set; } + public IntFeedback HdmiInHdcpCapabilityFeedback { get; protected set; } + public BoolFeedback HdmiVideoSyncFeedback { get; protected set; } + public BoolFeedback VgaVideoSyncFeedback { get; protected set; } + + public BoolFeedback FreeRunEnabledFeedback { get; protected set; } + + public IntFeedback VgaBrightnessFeedback { get; protected set; } + public IntFeedback VgaContrastFeedback { get; protected set; } + + //IroutingNumericEvent + public event EventHandler NumericSwitchChange; + + /// + /// Raise an event when the status of a switch object changes. + /// + /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType + private void OnSwitchChange(RoutingNumericEventArgs e) + { + var newEvent = NumericSwitchChange; + if (newEvent != null) newEvent(this, e); + } + + /// + /// Helps get the "real" inputs, including when in Auto + /// + public DmTx200Base.eSourceSelection ActualActiveVideoInput + { + get + { + if (Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Digital || + Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Analog || + Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Disable) + return Tx.VideoSourceFeedback; + else // auto + { + if (Tx.HdmiInput.SyncDetectedFeedback.BoolValue) + return DmTx200Base.eSourceSelection.Digital; + else if (Tx.VgaInput.SyncDetectedFeedback.BoolValue) + return DmTx200Base.eSourceSelection.Analog; + else + return DmTx200Base.eSourceSelection.Disable; + } + } + } + + public RoutingPortCollection InputPorts + { + get + { + return new RoutingPortCollection + { + HdmiInput, + VgaInput, + AnyVideoInput + }; + } + } + + public RoutingPortCollection OutputPorts + { + get + { + return new RoutingPortCollection { DmOutput, HdmiLoopOut }; + } + } + + /// + /// + /// + /// + /// + /// + public DmTx201CController(string key, string name, DmTx201C tx, bool preventRegistration) + : base(key, name, tx) + { + Tx = tx; + PreventRegistration = preventRegistration; + + HdmiInput = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, + DmTx200Base.eSourceSelection.Digital, this, + VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInput)) + { + FeedbackMatchObject = DmTx200Base.eSourceSelection.Digital + }; + + VgaInput = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn, + eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, DmTx200Base.eSourceSelection.Analog, this, + VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput)) + { + FeedbackMatchObject = DmTx200Base.eSourceSelection.Analog + }; + + ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", + () => ActualActiveVideoInput.ToString()); + + Tx.HdmiInput.InputStreamChange += InputStreamChangeEvent; + Tx.VgaInput.InputStreamChange += VgaInputOnInputStreamChange; + Tx.BaseEvent += Tx_BaseEvent; + Tx.OnlineStatusChange += new OnlineStatusChangeEventHandler(Tx_OnlineStatusChange); + + VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); + + AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback); + + HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () => + (tx.HdmiInput.HdcpSupportOnFeedback.BoolValue ? 1 : 0)); + + HdcpStateFeedback = HdmiInHdcpCapabilityFeedback; + + HdmiVideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInput.SyncDetectedFeedback.BoolValue); + + VgaVideoSyncFeedback = new BoolFeedback(() => (bool)tx.VgaInput.SyncDetectedFeedback.BoolValue); + + FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled); + + VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue); + + VgaContrastFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue); + + tx.VgaInput.VideoControls.ControlChange += VideoControls_ControlChange; + + HdcpSupportCapability = eHdcpCapabilityType.HdcpAutoSupport; + + var combinedFuncs = new VideoStatusFuncsWrapper + { + HdcpActiveFeedbackFunc = () => + (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital + && tx.HdmiInput.VideoAttributes.HdcpActiveFeedback.BoolValue), + + HdcpStateFeedbackFunc = () => ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital ? + tx.HdmiInput.VideoAttributes.HdcpStateFeedback.ToString() : "", + + VideoResolutionFeedbackFunc = () => + { + if (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital) + return tx.HdmiInput.VideoAttributes.GetVideoResolutionString(); + return ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog ? + tx.VgaInput.VideoAttributes.GetVideoResolutionString() : ""; + }, + + VideoSyncFeedbackFunc = () => + (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital + && tx.HdmiInput.SyncDetectedFeedback.BoolValue) + || (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog + && tx.VgaInput.SyncDetectedFeedback.BoolValue) + || (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Auto + && (tx.VgaInput.SyncDetectedFeedback.BoolValue || tx.HdmiInput.SyncDetectedFeedback.BoolValue)) + + }; + + AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); + + DmOutput = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, null, this); + HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, null, this); + + AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, + AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, + AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, + AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback, HdmiVideoSyncFeedback, + VgaVideoSyncFeedback); + + // Set Ports for CEC + HdmiInput.Port = Tx.HdmiInput; + VgaInput.Port = Tx.VgaInput; + HdmiLoopOut.Port = Tx.HdmiOutput; + DmOutput.Port = Tx.DmOutput; + } + + void VideoControls_ControlChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) + { + var id = args.EventId; + Debug.Console(2, this, "EventId {0}", args.EventId); + + switch (id) + { + case VideoControlsEventIds.BrightnessFeedbackEventId: + VgaBrightnessFeedback.FireUpdate(); + break; + case VideoControlsEventIds.ContrastFeedbackEventId: + VgaContrastFeedback.FireUpdate(); + break; + } + } + + void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) + { + var localVideoInputPort = + InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.VideoSourceFeedback); + var localAudioInputPort = + InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.AudioSourceFeedback); + + + ActiveVideoInputFeedback.FireUpdate(); + VideoSourceNumericFeedback.FireUpdate(); + AudioSourceNumericFeedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); + OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); + } + + private void VgaInputOnInputStreamChange(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) + { + switch (args.EventId) + { + case EndpointInputStreamEventIds.FreeRunFeedbackEventId: + FreeRunEnabledFeedback.FireUpdate(); + break; + case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: + VgaVideoSyncFeedback.FireUpdate(); + break; + } + } + + public override bool CustomActivate() + { + Tx.HdmiInput.InputStreamChange += (o, a) => FowardInputStreamChange(HdmiInput, a.EventId); + Tx.HdmiInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(HdmiInput, a.EventId); + + Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaInput, a.EventId); + Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(VgaInput, a.EventId); + + // Base does register and sets up comm monitoring. + return base.CustomActivate(); + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); + + if (HdmiVideoSyncFeedback != null) + { + HdmiVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); + } + if (VgaVideoSyncFeedback != null) + { + VgaVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); + } + + LinkDmTxToApi(this, trilist, joinMap, bridge); + } + + /// + /// Enables or disables free run + /// + /// + public void SetFreeRunEnabled(bool enable) + { + Tx.VgaInput.FreeRun = enable ? eDmFreeRunSetting.Enabled : eDmFreeRunSetting.Disabled; + } + + /// + /// Sets the VGA brightness level + /// + /// + public void SetVgaBrightness(ushort level) + { + Tx.VgaInput.VideoControls.Brightness.UShortValue = level; + } + + /// + /// Sets the VGA contrast level + /// + /// + public void SetVgaContrast(ushort level) + { + Tx.VgaInput.VideoControls.Contrast.UShortValue = level; + } + + /// + /// Switches the audio/video source based on the integer value (0-Auto, 1-HDMI, 2-VGA, 3-Disable) + /// + /// + /// + /// + public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) + { + Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); + + switch (input) + { + case 0: + { + ExecuteSwitch(DmTx200Base.eSourceSelection.Auto, null, type); + break; + } + case 1: + { + ExecuteSwitch(HdmiInput.Selector, null, type); + break; + } + case 2: + { + ExecuteSwitch(VgaInput.Selector, null, type); + break; + } + case 3: + { + ExecuteSwitch(DmTx200Base.eSourceSelection.Disable, null, type); + break; + } + } + } + + public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) + { + if((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) + Tx.VideoSource = (DmTx200Base.eSourceSelection)inputSelector; + if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) + Tx.AudioSource = (DmTx200Base.eSourceSelection)inputSelector; + } + + void Tx_BaseEvent(GenericBase device, BaseEventArgs args) + { + var id = args.EventId; + Debug.Console(2, this, "EventId {0}", args.EventId); + + switch (id) + { + case EndpointTransmitterBase.VideoSourceFeedbackEventId: + var localVideoInputPort = InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.VideoSourceFeedback); + Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); + VideoSourceNumericFeedback.FireUpdate(); + ActiveVideoInputFeedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); + break; + case EndpointTransmitterBase.AudioSourceFeedbackEventId: + var localInputAudioPort = InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.AudioSourceFeedback); + Debug.Console(2, this, " Audio Source: {0}", Tx.AudioSourceFeedback); + AudioSourceNumericFeedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); + break; + } + } + + void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) + { + Debug.Console(2, "{0} event {1} stream {2}", Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); + + switch (args.EventId) + { + case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: + HdmiInHdcpCapabilityFeedback.FireUpdate(); + break; + case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: + HdmiInHdcpCapabilityFeedback.FireUpdate(); + break; + case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: + HdmiVideoSyncFeedback.FireUpdate(); + break; + } + + } + + /// + /// Relays the input stream change to the appropriate RoutingInputPort. + /// + void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { + if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) + { + return; + } + inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); + } + + /// + /// Relays the VideoAttributes change to a RoutingInputPort + /// + void FireVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { + //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds + //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", + // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); + switch (eventId) + { + case VideoAttributeEventIds.HdcpActiveFeedbackEventId: + inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HdcpStateFeedbackEventId: + inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: + case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; + } + } + + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx201SController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx201SController.cs similarity index 97% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx201SController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx201SController.cs index e42ecb4b..08d43b63 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx201SController.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx201SController.cs @@ -1,432 +1,432 @@ -using System; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; -using System.Linq; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.DM -{ - /// - /// Controller class for all DM-TX-201S/F transmitters - /// - [Description("Wrapper class for DM-TX-201-S/F")] - public class DmTx201SController : DmTxControllerBase, ITxRoutingWithFeedback, IHasFreeRun, IVgaBrightnessContrastControls - { - public DmTx201S Tx { get; private set; } - - public RoutingInputPortWithVideoStatuses HdmiInput { get; private set; } - public RoutingInputPortWithVideoStatuses VgaInput { get; private set; } - public RoutingOutputPort DmOutput { get; private set; } - public RoutingOutputPort HdmiLoopOut { get; private set; } - - public override StringFeedback ActiveVideoInputFeedback { get; protected set; } - public IntFeedback VideoSourceNumericFeedback { get; protected set; } - public IntFeedback AudioSourceNumericFeedback { get; protected set; } - public IntFeedback HdmiInHdcpCapabilityFeedback { get; protected set; } - public BoolFeedback HdmiVideoSyncFeedback { get; protected set; } - public BoolFeedback VgaVideoSyncFeedback { get; protected set; } - - public BoolFeedback FreeRunEnabledFeedback { get; protected set; } - - public IntFeedback VgaBrightnessFeedback { get; protected set; } - public IntFeedback VgaContrastFeedback { get; protected set; } - - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - /// - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); +using System; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; +using System.Linq; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; + +namespace PepperDash.Essentials.DM +{ + /// + /// Controller class for all DM-TX-201S/F transmitters + /// + [Description("Wrapper class for DM-TX-201-S/F")] + public class DmTx201SController : DmTxControllerBase, ITxRoutingWithFeedback, IHasFreeRun, IVgaBrightnessContrastControls + { + public DmTx201S Tx { get; private set; } + + public RoutingInputPortWithVideoStatuses HdmiInput { get; private set; } + public RoutingInputPortWithVideoStatuses VgaInput { get; private set; } + public RoutingOutputPort DmOutput { get; private set; } + public RoutingOutputPort HdmiLoopOut { get; private set; } + + public override StringFeedback ActiveVideoInputFeedback { get; protected set; } + public IntFeedback VideoSourceNumericFeedback { get; protected set; } + public IntFeedback AudioSourceNumericFeedback { get; protected set; } + public IntFeedback HdmiInHdcpCapabilityFeedback { get; protected set; } + public BoolFeedback HdmiVideoSyncFeedback { get; protected set; } + public BoolFeedback VgaVideoSyncFeedback { get; protected set; } + + public BoolFeedback FreeRunEnabledFeedback { get; protected set; } + + public IntFeedback VgaBrightnessFeedback { get; protected set; } + public IntFeedback VgaContrastFeedback { get; protected set; } + + //IroutingNumericEvent + public event EventHandler NumericSwitchChange; + + /// + /// + /// Raise an event when the status of a switch object changes. + /// + /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType + private void OnSwitchChange(RoutingNumericEventArgs e) + { + var newEvent = NumericSwitchChange; + if (newEvent != null) newEvent(this, e); } - - - /// - /// Helps get the "real" inputs, including when in Auto - /// - public DmTx200Base.eSourceSelection ActualActiveVideoInput - { - get - { - if (Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Digital || - Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Analog || - Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Disable) - return Tx.VideoSourceFeedback; - else // auto - { - if (Tx.HdmiInput.SyncDetectedFeedback.BoolValue) - return DmTx200Base.eSourceSelection.Digital; - else if (Tx.VgaInput.SyncDetectedFeedback.BoolValue) - return DmTx200Base.eSourceSelection.Analog; - else - return DmTx200Base.eSourceSelection.Disable; - } - } - } - - public RoutingPortCollection InputPorts - { - get - { + + + /// + /// Helps get the "real" inputs, including when in Auto + /// + public DmTx200Base.eSourceSelection ActualActiveVideoInput + { + get + { + if (Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Digital || + Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Analog || + Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Disable) + return Tx.VideoSourceFeedback; + else // auto + { + if (Tx.HdmiInput.SyncDetectedFeedback.BoolValue) + return DmTx200Base.eSourceSelection.Digital; + else if (Tx.VgaInput.SyncDetectedFeedback.BoolValue) + return DmTx200Base.eSourceSelection.Analog; + else + return DmTx200Base.eSourceSelection.Disable; + } + } + } + + public RoutingPortCollection InputPorts + { + get + { return new RoutingPortCollection { HdmiInput, VgaInput, AnyVideoInput - }; - } - } - - public RoutingPortCollection OutputPorts - { - get - { - return new RoutingPortCollection { DmOutput, HdmiLoopOut }; - } - } - - /// - /// - /// - /// - /// - /// - public DmTx201SController(string key, string name, DmTx201S tx, bool preventRegistration) - : base(key, name, tx) - { - Tx = tx; - PreventRegistration = preventRegistration; - - HdmiInput = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, - DmTx200Base.eSourceSelection.Digital, this, - VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInput)) - { - FeedbackMatchObject = DmTx200Base.eSourceSelection.Digital - }; - - VgaInput = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn, - eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, DmTx200Base.eSourceSelection.Analog, this, - VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput)) - { - FeedbackMatchObject = DmTx200Base.eSourceSelection.Analog + }; + } + } + + public RoutingPortCollection OutputPorts + { + get + { + return new RoutingPortCollection { DmOutput, HdmiLoopOut }; + } + } + + /// + /// + /// + /// + /// + /// + public DmTx201SController(string key, string name, DmTx201S tx, bool preventRegistration) + : base(key, name, tx) + { + Tx = tx; + PreventRegistration = preventRegistration; + + HdmiInput = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, + DmTx200Base.eSourceSelection.Digital, this, + VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInput)) + { + FeedbackMatchObject = DmTx200Base.eSourceSelection.Digital }; - - ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", - () => ActualActiveVideoInput.ToString()); - - Tx.HdmiInput.InputStreamChange += InputStreamChangeEvent; - Tx.VgaInput.InputStreamChange += VgaInputOnInputStreamChange; - Tx.BaseEvent += Tx_BaseEvent; - Tx.OnlineStatusChange += new OnlineStatusChangeEventHandler(Tx_OnlineStatusChange); - - VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); - - AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback); - - HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () => - (tx.HdmiInput.HdcpSupportOnFeedback.BoolValue ? 1 : 0)); - - HdcpStateFeedback = HdmiInHdcpCapabilityFeedback; - - HdmiVideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInput.SyncDetectedFeedback.BoolValue); - - VgaVideoSyncFeedback = new BoolFeedback(() => (bool)tx.VgaInput.SyncDetectedFeedback.BoolValue); - - FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled); - - VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue); - - VgaContrastFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue); - - tx.VgaInput.VideoControls.ControlChange += VideoControls_ControlChange; - - HdcpSupportCapability = eHdcpCapabilityType.HdcpAutoSupport; - - var combinedFuncs = new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => - (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital - && tx.HdmiInput.VideoAttributes.HdcpActiveFeedback.BoolValue), - - HdcpStateFeedbackFunc = () => ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital ? - tx.HdmiInput.VideoAttributes.HdcpStateFeedback.ToString() : "", - - VideoResolutionFeedbackFunc = () => - { - if (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital) - return tx.HdmiInput.VideoAttributes.GetVideoResolutionString(); - return ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog ? - tx.VgaInput.VideoAttributes.GetVideoResolutionString() : ""; - }, - - VideoSyncFeedbackFunc = () => - (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital - && tx.HdmiInput.SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog - && tx.VgaInput.SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Auto - && (tx.VgaInput.SyncDetectedFeedback.BoolValue || tx.HdmiInput.SyncDetectedFeedback.BoolValue)) - - }; - - AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); - - DmOutput = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, null, this); - HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null, this); - - AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, - AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, - AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, - AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback, HdmiVideoSyncFeedback, - VgaVideoSyncFeedback); - - // Set Ports for CEC - HdmiInput.Port = Tx.HdmiInput; - VgaInput.Port = Tx.VgaInput; - HdmiLoopOut.Port = Tx.HdmiOutput; - DmOutput.Port = Tx.DmOutput; - } - - void VideoControls_ControlChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case VideoControlsEventIds.BrightnessFeedbackEventId: - VgaBrightnessFeedback.FireUpdate(); - break; - case VideoControlsEventIds.ContrastFeedbackEventId: - VgaContrastFeedback.FireUpdate(); - break; - } - } - - void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) - { - var localVideoInputPort = - InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.VideoSourceFeedback); - var localAudioInputPort = - InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.AudioSourceFeedback); - - - ActiveVideoInputFeedback.FireUpdate(); - VideoSourceNumericFeedback.FireUpdate(); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); + + VgaInput = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn, + eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, DmTx200Base.eSourceSelection.Analog, this, + VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput)) + { + FeedbackMatchObject = DmTx200Base.eSourceSelection.Analog + }; + + ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", + () => ActualActiveVideoInput.ToString()); + + Tx.HdmiInput.InputStreamChange += InputStreamChangeEvent; + Tx.VgaInput.InputStreamChange += VgaInputOnInputStreamChange; + Tx.BaseEvent += Tx_BaseEvent; + Tx.OnlineStatusChange += new OnlineStatusChangeEventHandler(Tx_OnlineStatusChange); + + VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); + + AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback); + + HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () => + (tx.HdmiInput.HdcpSupportOnFeedback.BoolValue ? 1 : 0)); + + HdcpStateFeedback = HdmiInHdcpCapabilityFeedback; + + HdmiVideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInput.SyncDetectedFeedback.BoolValue); + + VgaVideoSyncFeedback = new BoolFeedback(() => (bool)tx.VgaInput.SyncDetectedFeedback.BoolValue); + + FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled); + + VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue); + + VgaContrastFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue); + + tx.VgaInput.VideoControls.ControlChange += VideoControls_ControlChange; + + HdcpSupportCapability = eHdcpCapabilityType.HdcpAutoSupport; + + var combinedFuncs = new VideoStatusFuncsWrapper + { + HdcpActiveFeedbackFunc = () => + (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital + && tx.HdmiInput.VideoAttributes.HdcpActiveFeedback.BoolValue), + + HdcpStateFeedbackFunc = () => ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital ? + tx.HdmiInput.VideoAttributes.HdcpStateFeedback.ToString() : "", + + VideoResolutionFeedbackFunc = () => + { + if (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital) + return tx.HdmiInput.VideoAttributes.GetVideoResolutionString(); + return ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog ? + tx.VgaInput.VideoAttributes.GetVideoResolutionString() : ""; + }, + + VideoSyncFeedbackFunc = () => + (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital + && tx.HdmiInput.SyncDetectedFeedback.BoolValue) + || (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog + && tx.VgaInput.SyncDetectedFeedback.BoolValue) + || (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Auto + && (tx.VgaInput.SyncDetectedFeedback.BoolValue || tx.HdmiInput.SyncDetectedFeedback.BoolValue)) + + }; + + AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); + + DmOutput = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, null, this); + HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, null, this); + + AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, + AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, + AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, + AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback, HdmiVideoSyncFeedback, + VgaVideoSyncFeedback); + + // Set Ports for CEC + HdmiInput.Port = Tx.HdmiInput; + VgaInput.Port = Tx.VgaInput; + HdmiLoopOut.Port = Tx.HdmiOutput; + DmOutput.Port = Tx.DmOutput; } - - private void VgaInputOnInputStreamChange(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - switch (args.EventId) - { - case EndpointInputStreamEventIds.FreeRunFeedbackEventId: - FreeRunEnabledFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - VgaVideoSyncFeedback.FireUpdate(); - break; - } - } - - public override bool CustomActivate() - { - Tx.HdmiInput.InputStreamChange += (o, a) => FowardInputStreamChange(HdmiInput, a.EventId); - Tx.HdmiInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(HdmiInput, a.EventId); - - Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaInput, a.EventId); - Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(VgaInput, a.EventId); - - // Base does register and sets up comm monitoring. - return base.CustomActivate(); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); - - if (HdmiVideoSyncFeedback != null) - { - HdmiVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); - } - if (VgaVideoSyncFeedback != null) - { - VgaVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); - } - - LinkDmTxToApi(this, trilist, joinMap, bridge); - } - - /// - /// Enables or disables free run - /// - /// - public void SetFreeRunEnabled(bool enable) - { - Tx.VgaInput.FreeRun = enable ? eDmFreeRunSetting.Enabled : eDmFreeRunSetting.Disabled; - } - - /// - /// Sets the VGA brightness level - /// - /// - public void SetVgaBrightness(ushort level) - { - Tx.VgaInput.VideoControls.Brightness.UShortValue = level; - } - - /// - /// Sets the VGA contrast level - /// - /// - public void SetVgaContrast(ushort level) - { - Tx.VgaInput.VideoControls.Contrast.UShortValue = level; - } - - /// - /// Switches the audio/video source based on the integer value (0-Auto, 1-HDMI, 2-VGA, 3-Disable) - /// - /// - /// - /// - public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) - { - Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); - - switch (input) - { - case 0: - { - ExecuteSwitch(DmTx200Base.eSourceSelection.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(HdmiInput.Selector, null, type); - break; - } - case 2: - { - ExecuteSwitch(VgaInput.Selector, null, type); - break; - } - case 3: - { - ExecuteSwitch(DmTx200Base.eSourceSelection.Disable, null, type); - break; - } - } - } - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) - Tx.VideoSource = (DmTx200Base.eSourceSelection)inputSelector; - if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - Tx.AudioSource = (DmTx200Base.eSourceSelection)inputSelector; - } - - void Tx_BaseEvent(GenericBase device, BaseEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case EndpointTransmitterBase.VideoSourceFeedbackEventId: - var localVideoInputPort = InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.VideoSourceFeedback); - Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); - VideoSourceNumericFeedback.FireUpdate(); - ActiveVideoInputFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - break; - case EndpointTransmitterBase.AudioSourceFeedbackEventId: - var localInputAudioPort = InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.AudioSourceFeedback); - Debug.Console(2, this, " Audio Source: {0}", Tx.AudioSourceFeedback); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); - break; - } + + void VideoControls_ControlChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) + { + var id = args.EventId; + Debug.Console(2, this, "EventId {0}", args.EventId); + + switch (id) + { + case VideoControlsEventIds.BrightnessFeedbackEventId: + VgaBrightnessFeedback.FireUpdate(); + break; + case VideoControlsEventIds.ContrastFeedbackEventId: + VgaContrastFeedback.FireUpdate(); + break; + } } - - void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - Debug.Console(2, "{0} event {1} stream {2}", Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); - - switch (args.EventId) - { - case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: - HdmiInHdcpCapabilityFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: - HdmiInHdcpCapabilityFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - HdmiVideoSyncFeedback.FireUpdate(); - break; - } - - } - - /// - /// Relays the input stream change to the appropriate RoutingInputPort. - /// - void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) - { - return; - } - inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); - } - - /// - /// Relays the VideoAttributes change to a RoutingInputPort - /// - void FireVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds - //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", - // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); - switch (eventId) - { - case VideoAttributeEventIds.HdcpActiveFeedbackEventId: - inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HdcpStateFeedbackEventId: - inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: - case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - } - } - - } + + void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) + { + var localVideoInputPort = + InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.VideoSourceFeedback); + var localAudioInputPort = + InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.AudioSourceFeedback); + + + ActiveVideoInputFeedback.FireUpdate(); + VideoSourceNumericFeedback.FireUpdate(); + AudioSourceNumericFeedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); + OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); + } + + private void VgaInputOnInputStreamChange(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) + { + switch (args.EventId) + { + case EndpointInputStreamEventIds.FreeRunFeedbackEventId: + FreeRunEnabledFeedback.FireUpdate(); + break; + case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: + VgaVideoSyncFeedback.FireUpdate(); + break; + } + } + + public override bool CustomActivate() + { + Tx.HdmiInput.InputStreamChange += (o, a) => FowardInputStreamChange(HdmiInput, a.EventId); + Tx.HdmiInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(HdmiInput, a.EventId); + + Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaInput, a.EventId); + Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(VgaInput, a.EventId); + + // Base does register and sets up comm monitoring. + return base.CustomActivate(); + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); + + if (HdmiVideoSyncFeedback != null) + { + HdmiVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); + } + if (VgaVideoSyncFeedback != null) + { + VgaVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); + } + + LinkDmTxToApi(this, trilist, joinMap, bridge); + } + + /// + /// Enables or disables free run + /// + /// + public void SetFreeRunEnabled(bool enable) + { + Tx.VgaInput.FreeRun = enable ? eDmFreeRunSetting.Enabled : eDmFreeRunSetting.Disabled; + } + + /// + /// Sets the VGA brightness level + /// + /// + public void SetVgaBrightness(ushort level) + { + Tx.VgaInput.VideoControls.Brightness.UShortValue = level; + } + + /// + /// Sets the VGA contrast level + /// + /// + public void SetVgaContrast(ushort level) + { + Tx.VgaInput.VideoControls.Contrast.UShortValue = level; + } + + /// + /// Switches the audio/video source based on the integer value (0-Auto, 1-HDMI, 2-VGA, 3-Disable) + /// + /// + /// + /// + public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) + { + Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); + + switch (input) + { + case 0: + { + ExecuteSwitch(DmTx200Base.eSourceSelection.Auto, null, type); + break; + } + case 1: + { + ExecuteSwitch(HdmiInput.Selector, null, type); + break; + } + case 2: + { + ExecuteSwitch(VgaInput.Selector, null, type); + break; + } + case 3: + { + ExecuteSwitch(DmTx200Base.eSourceSelection.Disable, null, type); + break; + } + } + } + + public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) + { + if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) + Tx.VideoSource = (DmTx200Base.eSourceSelection)inputSelector; + if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) + Tx.AudioSource = (DmTx200Base.eSourceSelection)inputSelector; + } + + void Tx_BaseEvent(GenericBase device, BaseEventArgs args) + { + var id = args.EventId; + Debug.Console(2, this, "EventId {0}", args.EventId); + + switch (id) + { + case EndpointTransmitterBase.VideoSourceFeedbackEventId: + var localVideoInputPort = InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.VideoSourceFeedback); + Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); + VideoSourceNumericFeedback.FireUpdate(); + ActiveVideoInputFeedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); + break; + case EndpointTransmitterBase.AudioSourceFeedbackEventId: + var localInputAudioPort = InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.AudioSourceFeedback); + Debug.Console(2, this, " Audio Source: {0}", Tx.AudioSourceFeedback); + AudioSourceNumericFeedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); + break; + } + } + + void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) + { + Debug.Console(2, "{0} event {1} stream {2}", Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); + + switch (args.EventId) + { + case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: + HdmiInHdcpCapabilityFeedback.FireUpdate(); + break; + case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: + HdmiInHdcpCapabilityFeedback.FireUpdate(); + break; + case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: + HdmiVideoSyncFeedback.FireUpdate(); + break; + } + + } + + /// + /// Relays the input stream change to the appropriate RoutingInputPort. + /// + void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { + if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) + { + return; + } + inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); + } + + /// + /// Relays the VideoAttributes change to a RoutingInputPort + /// + void FireVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { + //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds + //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", + // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); + switch (eventId) + { + case VideoAttributeEventIds.HdcpActiveFeedbackEventId: + inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HdcpStateFeedbackEventId: + inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: + case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; + } + } + + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx401CController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx401CController.cs similarity index 97% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx401CController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx401CController.cs index ae4e2c31..a165cd66 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx401CController.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx401CController.cs @@ -1,494 +1,494 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -//using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.DM.Config; - -namespace PepperDash.Essentials.DM -{ - using eVst = DmTx401C.eSourceSelection; - - [Description("Wrapper class for DM-TX-401-C")] - public class DmTx401CController : DmTxControllerBase, ITxRoutingWithFeedback, IIROutputPorts, IComPorts, IHasFreeRun, IVgaBrightnessContrastControls - { - public DmTx401C Tx { get; private set; } - - public RoutingInputPortWithVideoStatuses HdmiIn { get; private set; } - public RoutingInputPortWithVideoStatuses DisplayPortIn { get; private set; } - public RoutingInputPortWithVideoStatuses VgaIn { get; private set; } - public RoutingInputPortWithVideoStatuses CompositeIn { get; private set; } - public RoutingOutputPort DmOut { get; private set; } - - public override StringFeedback ActiveVideoInputFeedback { get; protected set; } - public IntFeedback VideoSourceNumericFeedback { get; protected set; } - public IntFeedback AudioSourceNumericFeedback { get; protected set; } - public IntFeedback HdmiInHdcpCapabilityFeedback { get; protected set; } - public BoolFeedback DisplayPortVideoSyncFeedback { get; protected set; } - public BoolFeedback HdmiVideoSyncFeedback { get; protected set; } - public BoolFeedback VgaVideoSyncFeedback { get; protected set; } - - public BoolFeedback FreeRunEnabledFeedback { get; protected set; } - - public IntFeedback VgaBrightnessFeedback { get; protected set; } - public IntFeedback VgaContrastFeedback { get; protected set; } - - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - - - /// - /// Helps get the "real" inputs, including when in Auto - /// - public BaseDmTx401.eSourceSelection ActualVideoInput - { - get - { - if (Tx.VideoSourceFeedback != BaseDmTx401.eSourceSelection.Auto) - return Tx.VideoSourceFeedback; - else // auto - { - if (Tx.HdmiInput.SyncDetectedFeedback.BoolValue) - return BaseDmTx401.eSourceSelection.HDMI; - else if (Tx.VgaInput.SyncDetectedFeedback.BoolValue) - return BaseDmTx401.eSourceSelection.VGA; - else if (Tx.DisplayPortInput.SyncDetectedFeedback.BoolValue) - return BaseDmTx401.eSourceSelection.DisplayPort; - else if (Tx.CvbsInput.SyncDetectedFeedback.BoolValue) - return BaseDmTx401.eSourceSelection.Composite; - else - return BaseDmTx401.eSourceSelection.Disabled; - } - } - } - - public RoutingPortCollection InputPorts - { - get - { - return new RoutingPortCollection - { - HdmiIn, - DisplayPortIn, - VgaIn, - CompositeIn, - AnyVideoInput - }; - } - } - - public RoutingPortCollection OutputPorts - { - get - { - return new RoutingPortCollection { DmOut }; - } - } - - /// - /// - /// - /// - /// - /// - public DmTx401CController(string key, string name, DmTx401C tx, bool preventRegistration) - : base(key, name, tx) - { - Tx = tx; - PreventRegistration = preventRegistration; - - HdmiIn = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.HDMI, this, - VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInput)) - { - FeedbackMatchObject = eVst.HDMI - }; - DisplayPortIn = new RoutingInputPortWithVideoStatuses(DmPortName.DisplayPortIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.DisplayPort, this, - VideoStatusHelper.GetDisplayPortInputStatusFuncs(tx.DisplayPortInput)) - { - FeedbackMatchObject = eVst.DisplayPort - }; - VgaIn = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn, - eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, eVst.VGA, this, - VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput)) - { - FeedbackMatchObject = eVst.VGA - }; - CompositeIn = new RoutingInputPortWithVideoStatuses(DmPortName.CompositeIn, - eRoutingSignalType.Video, eRoutingPortConnectionType.Composite, eVst.Composite, this, - VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput)) - { - FeedbackMatchObject = eVst.Composite - }; - - Tx.HdmiInput.InputStreamChange += HdmiInputStreamChangeEvent; - Tx.DisplayPortInput.InputStreamChange += DisplayPortInputStreamChangeEvent; - Tx.BaseEvent += Tx_BaseEvent; - Tx.OnlineStatusChange += Tx_OnlineStatusChange; - Tx.VgaInput.InputStreamChange += VgaInputOnInputStreamChange; - tx.VgaInput.VideoControls.ControlChange += VideoControls_ControlChange; - - - ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", - () => ActualVideoInput.ToString()); - - VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); - - AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback); - - HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () => tx.HdmiInput.HdcpSupportOnFeedback.BoolValue ? 1 : 0); - - HdcpStateFeedback = HdmiInHdcpCapabilityFeedback; - - HdcpSupportCapability = eHdcpCapabilityType.HdcpAutoSupport; - - DisplayPortVideoSyncFeedback = new BoolFeedback("DisplayPortVideoSync", () => (bool)tx.DisplayPortInput.SyncDetectedFeedback.BoolValue); - - HdmiVideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInput.SyncDetectedFeedback.BoolValue); - - VgaVideoSyncFeedback = new BoolFeedback(() => (bool)tx.VgaInput.SyncDetectedFeedback.BoolValue); - - FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled); - - VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue); - - VgaContrastFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue); - - - var combinedFuncs = new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => - (ActualVideoInput == eVst.HDMI - && tx.HdmiInput.VideoAttributes.HdcpActiveFeedback.BoolValue) - || (ActualVideoInput == eVst.DisplayPort - && tx.DisplayPortInput.VideoAttributes.HdcpActiveFeedback.BoolValue), - - HdcpStateFeedbackFunc = () => - { - if (ActualVideoInput == eVst.HDMI) - return tx.HdmiInput.VideoAttributes.HdcpStateFeedback.ToString(); - if (ActualVideoInput == eVst.DisplayPort) - return tx.DisplayPortInput.VideoAttributes.HdcpStateFeedback.ToString(); - return ""; - }, - - VideoResolutionFeedbackFunc = () => - { - if (ActualVideoInput == eVst.HDMI) - return tx.HdmiInput.VideoAttributes.GetVideoResolutionString(); - if (ActualVideoInput == eVst.DisplayPort) - return tx.DisplayPortInput.VideoAttributes.GetVideoResolutionString(); - if (ActualVideoInput == eVst.VGA) - return tx.VgaInput.VideoAttributes.GetVideoResolutionString(); - if (ActualVideoInput == eVst.Composite) - return tx.CvbsInput.VideoAttributes.GetVideoResolutionString(); - return ""; - }, - VideoSyncFeedbackFunc = () => - (ActualVideoInput == eVst.HDMI - && tx.HdmiInput.SyncDetectedFeedback.BoolValue) - || (ActualVideoInput == eVst.DisplayPort - && tx.DisplayPortInput.SyncDetectedFeedback.BoolValue) - || (ActualVideoInput == eVst.VGA - && tx.VgaInput.SyncDetectedFeedback.BoolValue) - || (ActualVideoInput == eVst.Composite - && tx.CvbsInput.SyncDetectedFeedback.BoolValue) - }; - - AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); - - DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmCat, null, this); - - AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, - AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, - AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, - AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback, DisplayPortVideoSyncFeedback, - HdmiVideoSyncFeedback, VgaVideoSyncFeedback); - - // Set Ports for CEC - DisplayPortIn.Port = Tx.DisplayPortInput; - HdmiIn.Port = Tx.HdmiInput; - DmOut.Port = Tx.DmOutput; - } - - public override bool CustomActivate() - { - // Link up all of these damned events to the various RoutingPorts via a helper handler - Tx.HdmiInput.InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn, a.EventId); - Tx.HdmiInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn, a.EventId); - - Tx.DisplayPortInput.InputStreamChange += (o, a) => FowardInputStreamChange(DisplayPortIn, a.EventId); - Tx.DisplayPortInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(DisplayPortIn, a.EventId); - - Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaIn, a.EventId); - Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(VgaIn, a.EventId); - - // Base does register and sets up comm monitoring. - return base.CustomActivate(); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); - - if (HdmiVideoSyncFeedback != null) - { - HdmiVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); - } - if (VgaVideoSyncFeedback != null) - { - VgaVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); - } - - LinkDmTxToApi(this, trilist, joinMap, bridge); - } - - public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) - { - Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); - - switch (input) - { - case 0: - { - ExecuteSwitch(eVst.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(DisplayPortIn.Selector, null, type); - break; - } - case 2: - { - ExecuteSwitch(HdmiIn.Selector, null, type); - break; - } - case 3: - { - ExecuteSwitch(VgaIn.Selector, null, type); - break; - } - case 4: - { - ExecuteSwitch(CompositeIn.Selector, null, type); - break; - } - case 5: - { - ExecuteSwitch(eVst.Disabled, null, type); - break; - } - } - - } - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) - Tx.VideoSource = (eVst)inputSelector; - if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - Tx.AudioSource = (eVst)inputSelector; - } - - void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) - { - - var localVideoInputPort = - InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - var localAudioInputPort = - InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.AudioSourceFeedback); - - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); - - } - - void Tx_BaseEvent(GenericBase device, BaseEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case EndpointTransmitterBase.VideoSourceFeedbackEventId: - var localVideoInputPort = InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); - VideoSourceNumericFeedback.FireUpdate(); - ActiveVideoInputFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - break; - case EndpointTransmitterBase.AudioSourceFeedbackEventId: - var localInputAudioPort = InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.AudioSourceFeedback); - Debug.Console(2, this, " Audio Source: {0}", Tx.AudioSourceFeedback); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); - break; - } - } - - void VideoControls_ControlChange(object sender, GenericEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case VideoControlsEventIds.BrightnessFeedbackEventId: - VgaBrightnessFeedback.FireUpdate(); - break; - case VideoControlsEventIds.ContrastFeedbackEventId: - VgaContrastFeedback.FireUpdate(); - break; - } - } - - /// - /// Enables or disables free run - /// - /// - public void SetFreeRunEnabled(bool enable) - { - Tx.VgaInput.FreeRun = enable ? eDmFreeRunSetting.Enabled : eDmFreeRunSetting.Disabled; - } - - /// - /// Sets the VGA brightness level - /// - /// - public void SetVgaBrightness(ushort level) - { - Tx.VgaInput.VideoControls.Brightness.UShortValue = level; - } - - /// - /// Sets the VGA contrast level - /// - /// - public void SetVgaContrast(ushort level) - { - Tx.VgaInput.VideoControls.Contrast.UShortValue = level; - } - - /// - /// Relays the input stream change to the appropriate RoutingInputPort. - /// - void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) - { - return; - } - inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); - } - - /// - /// Relays the VideoAttributes change to a RoutingInputPort - /// - void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds - //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", - // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); - switch (eventId) - { - case VideoAttributeEventIds.HdcpActiveFeedbackEventId: - inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HdcpStateFeedbackEventId: - inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: - case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - } - } - - void HdmiInputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - Debug.Console(2, "{0} event {1} stream {2}", Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); - - switch (args.EventId) - { - case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: - HdmiInHdcpCapabilityFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: - HdmiInHdcpCapabilityFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - HdmiVideoSyncFeedback.FireUpdate(); - break; - } - } - - void DisplayPortInputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - Debug.Console(2, "{0} event {1} stream {2}", Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); - - switch (args.EventId) - { - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - DisplayPortVideoSyncFeedback.FireUpdate(); - break; - } - } - - private void VgaInputOnInputStreamChange(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - switch (args.EventId) - { - case EndpointInputStreamEventIds.FreeRunFeedbackEventId: - FreeRunEnabledFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - VgaVideoSyncFeedback.FireUpdate(); - break; - } - } - - - - #region IIROutputPorts Members - public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } - public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } - #endregion - - #region IComPorts Members - public CrestronCollection ComPorts { get { return Tx.ComPorts; } } - public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } } - #endregion - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +//using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.DM.Config; + +namespace PepperDash.Essentials.DM +{ + using eVst = DmTx401C.eSourceSelection; + + [Description("Wrapper class for DM-TX-401-C")] + public class DmTx401CController : DmTxControllerBase, ITxRoutingWithFeedback, IIROutputPorts, IComPorts, IHasFreeRun, IVgaBrightnessContrastControls + { + public DmTx401C Tx { get; private set; } + + public RoutingInputPortWithVideoStatuses HdmiIn { get; private set; } + public RoutingInputPortWithVideoStatuses DisplayPortIn { get; private set; } + public RoutingInputPortWithVideoStatuses VgaIn { get; private set; } + public RoutingInputPortWithVideoStatuses CompositeIn { get; private set; } + public RoutingOutputPort DmOut { get; private set; } + + public override StringFeedback ActiveVideoInputFeedback { get; protected set; } + public IntFeedback VideoSourceNumericFeedback { get; protected set; } + public IntFeedback AudioSourceNumericFeedback { get; protected set; } + public IntFeedback HdmiInHdcpCapabilityFeedback { get; protected set; } + public BoolFeedback DisplayPortVideoSyncFeedback { get; protected set; } + public BoolFeedback HdmiVideoSyncFeedback { get; protected set; } + public BoolFeedback VgaVideoSyncFeedback { get; protected set; } + + public BoolFeedback FreeRunEnabledFeedback { get; protected set; } + + public IntFeedback VgaBrightnessFeedback { get; protected set; } + public IntFeedback VgaContrastFeedback { get; protected set; } + + //IroutingNumericEvent + public event EventHandler NumericSwitchChange; + + /// + /// Raise an event when the status of a switch object changes. + /// + /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType + private void OnSwitchChange(RoutingNumericEventArgs e) + { + var newEvent = NumericSwitchChange; + if (newEvent != null) newEvent(this, e); + } + + + /// + /// Helps get the "real" inputs, including when in Auto + /// + public BaseDmTx401.eSourceSelection ActualVideoInput + { + get + { + if (Tx.VideoSourceFeedback != BaseDmTx401.eSourceSelection.Auto) + return Tx.VideoSourceFeedback; + else // auto + { + if (Tx.HdmiInput.SyncDetectedFeedback.BoolValue) + return BaseDmTx401.eSourceSelection.HDMI; + else if (Tx.VgaInput.SyncDetectedFeedback.BoolValue) + return BaseDmTx401.eSourceSelection.VGA; + else if (Tx.DisplayPortInput.SyncDetectedFeedback.BoolValue) + return BaseDmTx401.eSourceSelection.DisplayPort; + else if (Tx.CvbsInput.SyncDetectedFeedback.BoolValue) + return BaseDmTx401.eSourceSelection.Composite; + else + return BaseDmTx401.eSourceSelection.Disabled; + } + } + } + + public RoutingPortCollection InputPorts + { + get + { + return new RoutingPortCollection + { + HdmiIn, + DisplayPortIn, + VgaIn, + CompositeIn, + AnyVideoInput + }; + } + } + + public RoutingPortCollection OutputPorts + { + get + { + return new RoutingPortCollection { DmOut }; + } + } + + /// + /// + /// + /// + /// + /// + public DmTx401CController(string key, string name, DmTx401C tx, bool preventRegistration) + : base(key, name, tx) + { + Tx = tx; + PreventRegistration = preventRegistration; + + HdmiIn = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.HDMI, this, + VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInput)) + { + FeedbackMatchObject = eVst.HDMI + }; + DisplayPortIn = new RoutingInputPortWithVideoStatuses(DmPortName.DisplayPortIn, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.DisplayPort, this, + VideoStatusHelper.GetDisplayPortInputStatusFuncs(tx.DisplayPortInput)) + { + FeedbackMatchObject = eVst.DisplayPort + }; + VgaIn = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn, + eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, eVst.VGA, this, + VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput)) + { + FeedbackMatchObject = eVst.VGA + }; + CompositeIn = new RoutingInputPortWithVideoStatuses(DmPortName.CompositeIn, + eRoutingSignalType.Video, eRoutingPortConnectionType.Composite, eVst.Composite, this, + VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput)) + { + FeedbackMatchObject = eVst.Composite + }; + + Tx.HdmiInput.InputStreamChange += HdmiInputStreamChangeEvent; + Tx.DisplayPortInput.InputStreamChange += DisplayPortInputStreamChangeEvent; + Tx.BaseEvent += Tx_BaseEvent; + Tx.OnlineStatusChange += Tx_OnlineStatusChange; + Tx.VgaInput.InputStreamChange += VgaInputOnInputStreamChange; + tx.VgaInput.VideoControls.ControlChange += VideoControls_ControlChange; + + + ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", + () => ActualVideoInput.ToString()); + + VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); + + AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback); + + HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () => tx.HdmiInput.HdcpSupportOnFeedback.BoolValue ? 1 : 0); + + HdcpStateFeedback = HdmiInHdcpCapabilityFeedback; + + HdcpSupportCapability = eHdcpCapabilityType.HdcpAutoSupport; + + DisplayPortVideoSyncFeedback = new BoolFeedback("DisplayPortVideoSync", () => (bool)tx.DisplayPortInput.SyncDetectedFeedback.BoolValue); + + HdmiVideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInput.SyncDetectedFeedback.BoolValue); + + VgaVideoSyncFeedback = new BoolFeedback(() => (bool)tx.VgaInput.SyncDetectedFeedback.BoolValue); + + FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled); + + VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue); + + VgaContrastFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue); + + + var combinedFuncs = new VideoStatusFuncsWrapper + { + HdcpActiveFeedbackFunc = () => + (ActualVideoInput == eVst.HDMI + && tx.HdmiInput.VideoAttributes.HdcpActiveFeedback.BoolValue) + || (ActualVideoInput == eVst.DisplayPort + && tx.DisplayPortInput.VideoAttributes.HdcpActiveFeedback.BoolValue), + + HdcpStateFeedbackFunc = () => + { + if (ActualVideoInput == eVst.HDMI) + return tx.HdmiInput.VideoAttributes.HdcpStateFeedback.ToString(); + if (ActualVideoInput == eVst.DisplayPort) + return tx.DisplayPortInput.VideoAttributes.HdcpStateFeedback.ToString(); + return ""; + }, + + VideoResolutionFeedbackFunc = () => + { + if (ActualVideoInput == eVst.HDMI) + return tx.HdmiInput.VideoAttributes.GetVideoResolutionString(); + if (ActualVideoInput == eVst.DisplayPort) + return tx.DisplayPortInput.VideoAttributes.GetVideoResolutionString(); + if (ActualVideoInput == eVst.VGA) + return tx.VgaInput.VideoAttributes.GetVideoResolutionString(); + if (ActualVideoInput == eVst.Composite) + return tx.CvbsInput.VideoAttributes.GetVideoResolutionString(); + return ""; + }, + VideoSyncFeedbackFunc = () => + (ActualVideoInput == eVst.HDMI + && tx.HdmiInput.SyncDetectedFeedback.BoolValue) + || (ActualVideoInput == eVst.DisplayPort + && tx.DisplayPortInput.SyncDetectedFeedback.BoolValue) + || (ActualVideoInput == eVst.VGA + && tx.VgaInput.SyncDetectedFeedback.BoolValue) + || (ActualVideoInput == eVst.Composite + && tx.CvbsInput.SyncDetectedFeedback.BoolValue) + }; + + AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); + + DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.DmCat, null, this); + + AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, + AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, + AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, + AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback, DisplayPortVideoSyncFeedback, + HdmiVideoSyncFeedback, VgaVideoSyncFeedback); + + // Set Ports for CEC + DisplayPortIn.Port = Tx.DisplayPortInput; + HdmiIn.Port = Tx.HdmiInput; + DmOut.Port = Tx.DmOutput; + } + + public override bool CustomActivate() + { + // Link up all of these damned events to the various RoutingPorts via a helper handler + Tx.HdmiInput.InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn, a.EventId); + Tx.HdmiInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn, a.EventId); + + Tx.DisplayPortInput.InputStreamChange += (o, a) => FowardInputStreamChange(DisplayPortIn, a.EventId); + Tx.DisplayPortInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(DisplayPortIn, a.EventId); + + Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaIn, a.EventId); + Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(VgaIn, a.EventId); + + // Base does register and sets up comm monitoring. + return base.CustomActivate(); + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); + + if (HdmiVideoSyncFeedback != null) + { + HdmiVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); + } + if (VgaVideoSyncFeedback != null) + { + VgaVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); + } + + LinkDmTxToApi(this, trilist, joinMap, bridge); + } + + public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) + { + Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); + + switch (input) + { + case 0: + { + ExecuteSwitch(eVst.Auto, null, type); + break; + } + case 1: + { + ExecuteSwitch(DisplayPortIn.Selector, null, type); + break; + } + case 2: + { + ExecuteSwitch(HdmiIn.Selector, null, type); + break; + } + case 3: + { + ExecuteSwitch(VgaIn.Selector, null, type); + break; + } + case 4: + { + ExecuteSwitch(CompositeIn.Selector, null, type); + break; + } + case 5: + { + ExecuteSwitch(eVst.Disabled, null, type); + break; + } + } + + } + + public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) + { + if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) + Tx.VideoSource = (eVst)inputSelector; + if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) + Tx.AudioSource = (eVst)inputSelector; + } + + void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) + { + + var localVideoInputPort = + InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); + var localAudioInputPort = + InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.AudioSourceFeedback); + + OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); + OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); + + } + + void Tx_BaseEvent(GenericBase device, BaseEventArgs args) + { + var id = args.EventId; + Debug.Console(2, this, "EventId {0}", args.EventId); + + switch (id) + { + case EndpointTransmitterBase.VideoSourceFeedbackEventId: + var localVideoInputPort = InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); + Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); + VideoSourceNumericFeedback.FireUpdate(); + ActiveVideoInputFeedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); + break; + case EndpointTransmitterBase.AudioSourceFeedbackEventId: + var localInputAudioPort = InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.AudioSourceFeedback); + Debug.Console(2, this, " Audio Source: {0}", Tx.AudioSourceFeedback); + AudioSourceNumericFeedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); + break; + } + } + + void VideoControls_ControlChange(object sender, GenericEventArgs args) + { + var id = args.EventId; + Debug.Console(2, this, "EventId {0}", args.EventId); + + switch (id) + { + case VideoControlsEventIds.BrightnessFeedbackEventId: + VgaBrightnessFeedback.FireUpdate(); + break; + case VideoControlsEventIds.ContrastFeedbackEventId: + VgaContrastFeedback.FireUpdate(); + break; + } + } + + /// + /// Enables or disables free run + /// + /// + public void SetFreeRunEnabled(bool enable) + { + Tx.VgaInput.FreeRun = enable ? eDmFreeRunSetting.Enabled : eDmFreeRunSetting.Disabled; + } + + /// + /// Sets the VGA brightness level + /// + /// + public void SetVgaBrightness(ushort level) + { + Tx.VgaInput.VideoControls.Brightness.UShortValue = level; + } + + /// + /// Sets the VGA contrast level + /// + /// + public void SetVgaContrast(ushort level) + { + Tx.VgaInput.VideoControls.Contrast.UShortValue = level; + } + + /// + /// Relays the input stream change to the appropriate RoutingInputPort. + /// + void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { + if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) + { + return; + } + inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); + } + + /// + /// Relays the VideoAttributes change to a RoutingInputPort + /// + void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { + //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds + //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", + // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); + switch (eventId) + { + case VideoAttributeEventIds.HdcpActiveFeedbackEventId: + inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HdcpStateFeedbackEventId: + inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: + case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; + } + } + + void HdmiInputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) + { + Debug.Console(2, "{0} event {1} stream {2}", Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); + + switch (args.EventId) + { + case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: + HdmiInHdcpCapabilityFeedback.FireUpdate(); + break; + case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: + HdmiInHdcpCapabilityFeedback.FireUpdate(); + break; + case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: + HdmiVideoSyncFeedback.FireUpdate(); + break; + } + } + + void DisplayPortInputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) + { + Debug.Console(2, "{0} event {1} stream {2}", Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); + + switch (args.EventId) + { + case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: + DisplayPortVideoSyncFeedback.FireUpdate(); + break; + } + } + + private void VgaInputOnInputStreamChange(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) + { + switch (args.EventId) + { + case EndpointInputStreamEventIds.FreeRunFeedbackEventId: + FreeRunEnabledFeedback.FireUpdate(); + break; + case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: + VgaVideoSyncFeedback.FireUpdate(); + break; + } + } + + + + #region IIROutputPorts Members + public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } + public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } + #endregion + + #region IComPorts Members + public CrestronCollection ComPorts { get { return Tx.ComPorts; } } + public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } } + #endregion + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k100Controller.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k100Controller.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k100Controller.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k100Controller.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k202CController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k202CController.cs similarity index 97% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k202CController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k202CController.cs index 6614bcb4..8d13a80f 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k202CController.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k202CController.cs @@ -1,417 +1,417 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -//using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.DM.Config; - -namespace PepperDash.Essentials.DM -{ - using eVst = Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType; - using eAst = Crestron.SimplSharpPro.DeviceSupport.eX02AudioSourceType; - - [Description("Wrapper class for DM-TX-4K-202-C")] - public class DmTx4k202CController : DmTxControllerBase, ITxRoutingWithFeedback, IHasFeedback, - IIROutputPorts, IComPorts - { - public DmTx4k202C Tx { get; private set; } - - public RoutingInputPortWithVideoStatuses HdmiIn1 { get; private set; } - public RoutingInputPortWithVideoStatuses HdmiIn2 { get; private set; } - public RoutingOutputPort DmOut { get; private set; } - public RoutingOutputPort HdmiLoopOut { get; private set; } - - public override StringFeedback ActiveVideoInputFeedback { get; protected set; } - public IntFeedback VideoSourceNumericFeedback { get; protected set; } - public IntFeedback AudioSourceNumericFeedback { get; protected set; } - public IntFeedback HdmiIn1HdcpCapabilityFeedback { get; protected set; } - public IntFeedback HdmiIn2HdcpCapabilityFeedback { get; protected set; } - public BoolFeedback Hdmi1VideoSyncFeedback { get; protected set; } - public BoolFeedback Hdmi2VideoSyncFeedback { get; protected set; } - - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - - - //public override IntFeedback HdcpSupportAllFeedback { get; protected set; } - //public override ushort HdcpSupportCapability { get; protected set; } - - /// - /// Helps get the "real" inputs, including when in Auto - /// - public Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType ActualActiveVideoInput - { - get - { - if (Tx.VideoSourceFeedback != eVst.Auto) - return Tx.VideoSourceFeedback; - else // auto - { - if (Tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) - return eVst.Hdmi1; - else if (Tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) - return eVst.Hdmi2; - else - return eVst.AllDisabled; - } - } - } - public RoutingPortCollection InputPorts - { - get - { +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +//using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.DM.Config; + +namespace PepperDash.Essentials.DM +{ + using eVst = Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType; + using eAst = Crestron.SimplSharpPro.DeviceSupport.eX02AudioSourceType; + + [Description("Wrapper class for DM-TX-4K-202-C")] + public class DmTx4k202CController : DmTxControllerBase, ITxRoutingWithFeedback, IHasFeedback, + IIROutputPorts, IComPorts + { + public DmTx4k202C Tx { get; private set; } + + public RoutingInputPortWithVideoStatuses HdmiIn1 { get; private set; } + public RoutingInputPortWithVideoStatuses HdmiIn2 { get; private set; } + public RoutingOutputPort DmOut { get; private set; } + public RoutingOutputPort HdmiLoopOut { get; private set; } + + public override StringFeedback ActiveVideoInputFeedback { get; protected set; } + public IntFeedback VideoSourceNumericFeedback { get; protected set; } + public IntFeedback AudioSourceNumericFeedback { get; protected set; } + public IntFeedback HdmiIn1HdcpCapabilityFeedback { get; protected set; } + public IntFeedback HdmiIn2HdcpCapabilityFeedback { get; protected set; } + public BoolFeedback Hdmi1VideoSyncFeedback { get; protected set; } + public BoolFeedback Hdmi2VideoSyncFeedback { get; protected set; } + + //IroutingNumericEvent + public event EventHandler NumericSwitchChange; + + /// + /// Raise an event when the status of a switch object changes. + /// + /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType + private void OnSwitchChange(RoutingNumericEventArgs e) + { + var newEvent = NumericSwitchChange; + if (newEvent != null) newEvent(this, e); + } + + + //public override IntFeedback HdcpSupportAllFeedback { get; protected set; } + //public override ushort HdcpSupportCapability { get; protected set; } + + /// + /// Helps get the "real" inputs, including when in Auto + /// + public Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType ActualActiveVideoInput + { + get + { + if (Tx.VideoSourceFeedback != eVst.Auto) + return Tx.VideoSourceFeedback; + else // auto + { + if (Tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) + return eVst.Hdmi1; + else if (Tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) + return eVst.Hdmi2; + else + return eVst.AllDisabled; + } + } + } + public RoutingPortCollection InputPorts + { + get + { return new RoutingPortCollection { HdmiIn1, HdmiIn2, AnyVideoInput - }; - } - } - public RoutingPortCollection OutputPorts - { - get - { - return new RoutingPortCollection { DmOut, HdmiLoopOut }; - } - } - - public DmTx4k202CController(string key, string name, DmTx4k202C tx, bool preventRegistration) - : base(key, name, tx) - { - Tx = tx; - PreventRegistration = preventRegistration; - - HdmiIn1 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn1, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi1, this, - VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[1])) - { - FeedbackMatchObject = eVst.Hdmi1 - }; - HdmiIn2 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn2, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi2, this, - VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[2])) - { - FeedbackMatchObject = eVst.Hdmi2 - }; - - ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", - () => ActualActiveVideoInput.ToString()); - - - - Tx.HdmiInputs[1].InputStreamChange += InputStreamChangeEvent; - Tx.HdmiInputs[2].InputStreamChange += InputStreamChangeEvent; - - Tx.BaseEvent += Tx_BaseEvent; - - Tx.OnlineStatusChange += Tx_OnlineStatusChange; - - VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); - - AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback); - - HdmiIn1HdcpCapabilityFeedback = new IntFeedback("HdmiIn1HdcpCapability", - () => (int)tx.HdmiInputs[1].HdcpCapabilityFeedback); - - HdmiIn2HdcpCapabilityFeedback = new IntFeedback("HdmiIn2HdcpCapability", - () => (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); - - HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; - - HdcpStateFeedback = new IntFeedback(() => (int)HdcpSupportCapability); - - Hdmi1VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue); - - Hdmi2VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue); - - var combinedFuncs = new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => - (ActualActiveVideoInput == eVst.Hdmi1 - && tx.HdmiInputs[1].VideoAttributes.HdcpActiveFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.Hdmi2 - && tx.HdmiInputs[2].VideoAttributes.HdcpActiveFeedback.BoolValue), - - HdcpStateFeedbackFunc = () => - { - if (ActualActiveVideoInput == eVst.Hdmi1) - return tx.HdmiInputs[1].VideoAttributes.HdcpStateFeedback.ToString(); - if (ActualActiveVideoInput == eVst.Hdmi2) - return tx.HdmiInputs[2].VideoAttributes.HdcpStateFeedback.ToString(); - return ""; - }, - - VideoResolutionFeedbackFunc = () => - { - if (ActualActiveVideoInput == eVst.Hdmi1) - return tx.HdmiInputs[1].VideoAttributes.GetVideoResolutionString(); - if (ActualActiveVideoInput == eVst.Hdmi2) - return tx.HdmiInputs[2].VideoAttributes.GetVideoResolutionString(); - return ""; - }, - VideoSyncFeedbackFunc = () => - (ActualActiveVideoInput == eVst.Hdmi1 - && tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.Hdmi2 - && tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) - - }; - - AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, - combinedFuncs); - - DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmCat, null, this); - HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, - eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null, this); - - - AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, - AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, - AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, - AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiIn1HdcpCapabilityFeedback, - HdmiIn2HdcpCapabilityFeedback, - Hdmi1VideoSyncFeedback, Hdmi2VideoSyncFeedback); - - // Set Ports for CEC - HdmiIn1.Port = Tx.HdmiInputs[1]; - HdmiIn2.Port = Tx.HdmiInputs[2]; - HdmiLoopOut.Port = Tx.HdmiOutput; - DmOut.Port = Tx.DmOutput; - } - - - - public override bool CustomActivate() - { - // Link up all of these damned events to the various RoutingPorts via a helper handler - Tx.HdmiInputs[1].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn1, a.EventId); - Tx.HdmiInputs[1].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn1, a.EventId); - - Tx.HdmiInputs[2].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn2, a.EventId); - Tx.HdmiInputs[2].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn2, a.EventId); - - // Base does register and sets up comm monitoring. - return base.CustomActivate(); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); - - if (Hdmi1VideoSyncFeedback != null) - { - Hdmi1VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); - } - if (Hdmi2VideoSyncFeedback != null) - { - Hdmi2VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); - } - - LinkDmTxToApi(this, trilist, joinMap, bridge); - } - - public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) - { - Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); - - switch (type) - { - case eRoutingSignalType.Video: - switch (input) - { - case 0: - { - ExecuteSwitch(eVst.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(HdmiIn1.Selector, null, type); - break; - } - case 2: - { - ExecuteSwitch(HdmiIn2.Selector, null, type); - break; - } - case 3: - { - ExecuteSwitch(eVst.AllDisabled, null, type); - break; - } - } - break; - case eRoutingSignalType.Audio: - switch (input) - { - case 0: - { - ExecuteSwitch(eAst.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(eAst.Hdmi1, null, type); - break; - } - case 2: - { - ExecuteSwitch(eAst.Hdmi2, null, type); - break; - } - case 3: - { - ExecuteSwitch(eAst.AllDisabled, null, type); - break; - } - } - break; - } - } - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) - Tx.VideoSource = (eVst)inputSelector; - if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - Tx.AudioSource = (eAst)inputSelector; - } - - void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - Debug.Console(2, "{0} event {1} stream {2}", this.Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); - - switch (args.EventId) - { - case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: - case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: - case EndpointInputStreamEventIds.HdcpCapabilityFeedbackEventId: - if (inputStream == Tx.HdmiInputs[1]) HdmiIn1HdcpCapabilityFeedback.FireUpdate(); - if (inputStream == Tx.HdmiInputs[2]) HdmiIn2HdcpCapabilityFeedback.FireUpdate(); - HdcpStateFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - if (inputStream == Tx.HdmiInputs[1]) Hdmi1VideoSyncFeedback.FireUpdate(); - if (inputStream == Tx.HdmiInputs[2]) Hdmi2VideoSyncFeedback.FireUpdate(); - break; - } - } - - void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) - { - var localVideoInputPort = - InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - var localAudioInputPort = - InputPorts.FirstOrDefault(p => (eAst)p.Selector == Tx.AudioSourceFeedback); - - ActiveVideoInputFeedback.FireUpdate(); - VideoSourceNumericFeedback.FireUpdate(); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); - } - - void Tx_BaseEvent(GenericBase device, BaseEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case EndpointTransmitterBase.VideoSourceFeedbackEventId: - var localVideoInputPort = InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); - VideoSourceNumericFeedback.FireUpdate(); - ActiveVideoInputFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - break; - case EndpointTransmitterBase.AudioSourceFeedbackEventId: - var localInputAudioPort = InputPorts.FirstOrDefault(p => (eAst)p.Selector == Tx.AudioSourceFeedback); - Debug.Console(2, this, " Audio Source: {0}", Tx.AudioSourceFeedback); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); - break; - } - } - - /// - /// Relays the input stream change to the appropriate RoutingInputPort. - /// - void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) - { - return; - } - inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); - } - - /// - /// Relays the VideoAttributes change to a RoutingInputPort - /// - void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds - //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", - // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); - switch (eventId) - { - case VideoAttributeEventIds.HdcpActiveFeedbackEventId: - inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HdcpStateFeedbackEventId: - inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: - case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - } - } - - - - - #region IIROutputPorts Members - public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } - public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } - #endregion - - #region IComPorts Members - public CrestronCollection ComPorts { get { return Tx.ComPorts; } } - public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } } - #endregion - } + }; + } + } + public RoutingPortCollection OutputPorts + { + get + { + return new RoutingPortCollection { DmOut, HdmiLoopOut }; + } + } + + public DmTx4k202CController(string key, string name, DmTx4k202C tx, bool preventRegistration) + : base(key, name, tx) + { + Tx = tx; + PreventRegistration = preventRegistration; + + HdmiIn1 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn1, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi1, this, + VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[1])) + { + FeedbackMatchObject = eVst.Hdmi1 + }; + HdmiIn2 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn2, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi2, this, + VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[2])) + { + FeedbackMatchObject = eVst.Hdmi2 + }; + + ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", + () => ActualActiveVideoInput.ToString()); + + + + Tx.HdmiInputs[1].InputStreamChange += InputStreamChangeEvent; + Tx.HdmiInputs[2].InputStreamChange += InputStreamChangeEvent; + + Tx.BaseEvent += Tx_BaseEvent; + + Tx.OnlineStatusChange += Tx_OnlineStatusChange; + + VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); + + AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback); + + HdmiIn1HdcpCapabilityFeedback = new IntFeedback("HdmiIn1HdcpCapability", + () => (int)tx.HdmiInputs[1].HdcpCapabilityFeedback); + + HdmiIn2HdcpCapabilityFeedback = new IntFeedback("HdmiIn2HdcpCapability", + () => (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); + + HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; + + HdcpStateFeedback = new IntFeedback(() => (int)HdcpSupportCapability); + + Hdmi1VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue); + + Hdmi2VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue); + + var combinedFuncs = new VideoStatusFuncsWrapper + { + HdcpActiveFeedbackFunc = () => + (ActualActiveVideoInput == eVst.Hdmi1 + && tx.HdmiInputs[1].VideoAttributes.HdcpActiveFeedback.BoolValue) + || (ActualActiveVideoInput == eVst.Hdmi2 + && tx.HdmiInputs[2].VideoAttributes.HdcpActiveFeedback.BoolValue), + + HdcpStateFeedbackFunc = () => + { + if (ActualActiveVideoInput == eVst.Hdmi1) + return tx.HdmiInputs[1].VideoAttributes.HdcpStateFeedback.ToString(); + if (ActualActiveVideoInput == eVst.Hdmi2) + return tx.HdmiInputs[2].VideoAttributes.HdcpStateFeedback.ToString(); + return ""; + }, + + VideoResolutionFeedbackFunc = () => + { + if (ActualActiveVideoInput == eVst.Hdmi1) + return tx.HdmiInputs[1].VideoAttributes.GetVideoResolutionString(); + if (ActualActiveVideoInput == eVst.Hdmi2) + return tx.HdmiInputs[2].VideoAttributes.GetVideoResolutionString(); + return ""; + }, + VideoSyncFeedbackFunc = () => + (ActualActiveVideoInput == eVst.Hdmi1 + && tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) + || (ActualActiveVideoInput == eVst.Hdmi2 + && tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) + + }; + + AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, + combinedFuncs); + + DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.DmCat, null, this); + HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, + eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, null, this); + + + AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, + AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, + AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, + AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiIn1HdcpCapabilityFeedback, + HdmiIn2HdcpCapabilityFeedback, + Hdmi1VideoSyncFeedback, Hdmi2VideoSyncFeedback); + + // Set Ports for CEC + HdmiIn1.Port = Tx.HdmiInputs[1]; + HdmiIn2.Port = Tx.HdmiInputs[2]; + HdmiLoopOut.Port = Tx.HdmiOutput; + DmOut.Port = Tx.DmOutput; + } + + + + public override bool CustomActivate() + { + // Link up all of these damned events to the various RoutingPorts via a helper handler + Tx.HdmiInputs[1].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn1, a.EventId); + Tx.HdmiInputs[1].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn1, a.EventId); + + Tx.HdmiInputs[2].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn2, a.EventId); + Tx.HdmiInputs[2].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn2, a.EventId); + + // Base does register and sets up comm monitoring. + return base.CustomActivate(); + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); + + if (Hdmi1VideoSyncFeedback != null) + { + Hdmi1VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); + } + if (Hdmi2VideoSyncFeedback != null) + { + Hdmi2VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); + } + + LinkDmTxToApi(this, trilist, joinMap, bridge); + } + + public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) + { + Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); + + switch (type) + { + case eRoutingSignalType.Video: + switch (input) + { + case 0: + { + ExecuteSwitch(eVst.Auto, null, type); + break; + } + case 1: + { + ExecuteSwitch(HdmiIn1.Selector, null, type); + break; + } + case 2: + { + ExecuteSwitch(HdmiIn2.Selector, null, type); + break; + } + case 3: + { + ExecuteSwitch(eVst.AllDisabled, null, type); + break; + } + } + break; + case eRoutingSignalType.Audio: + switch (input) + { + case 0: + { + ExecuteSwitch(eAst.Auto, null, type); + break; + } + case 1: + { + ExecuteSwitch(eAst.Hdmi1, null, type); + break; + } + case 2: + { + ExecuteSwitch(eAst.Hdmi2, null, type); + break; + } + case 3: + { + ExecuteSwitch(eAst.AllDisabled, null, type); + break; + } + } + break; + } + } + + public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) + { + if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) + Tx.VideoSource = (eVst)inputSelector; + if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) + Tx.AudioSource = (eAst)inputSelector; + } + + void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) + { + Debug.Console(2, "{0} event {1} stream {2}", this.Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); + + switch (args.EventId) + { + case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: + case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: + case EndpointInputStreamEventIds.HdcpCapabilityFeedbackEventId: + if (inputStream == Tx.HdmiInputs[1]) HdmiIn1HdcpCapabilityFeedback.FireUpdate(); + if (inputStream == Tx.HdmiInputs[2]) HdmiIn2HdcpCapabilityFeedback.FireUpdate(); + HdcpStateFeedback.FireUpdate(); + break; + case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: + if (inputStream == Tx.HdmiInputs[1]) Hdmi1VideoSyncFeedback.FireUpdate(); + if (inputStream == Tx.HdmiInputs[2]) Hdmi2VideoSyncFeedback.FireUpdate(); + break; + } + } + + void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) + { + var localVideoInputPort = + InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); + var localAudioInputPort = + InputPorts.FirstOrDefault(p => (eAst)p.Selector == Tx.AudioSourceFeedback); + + ActiveVideoInputFeedback.FireUpdate(); + VideoSourceNumericFeedback.FireUpdate(); + AudioSourceNumericFeedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); + OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); + } + + void Tx_BaseEvent(GenericBase device, BaseEventArgs args) + { + var id = args.EventId; + Debug.Console(2, this, "EventId {0}", args.EventId); + + switch (id) + { + case EndpointTransmitterBase.VideoSourceFeedbackEventId: + var localVideoInputPort = InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); + Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); + VideoSourceNumericFeedback.FireUpdate(); + ActiveVideoInputFeedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); + break; + case EndpointTransmitterBase.AudioSourceFeedbackEventId: + var localInputAudioPort = InputPorts.FirstOrDefault(p => (eAst)p.Selector == Tx.AudioSourceFeedback); + Debug.Console(2, this, " Audio Source: {0}", Tx.AudioSourceFeedback); + AudioSourceNumericFeedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); + break; + } + } + + /// + /// Relays the input stream change to the appropriate RoutingInputPort. + /// + void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { + if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) + { + return; + } + inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); + } + + /// + /// Relays the VideoAttributes change to a RoutingInputPort + /// + void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { + //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds + //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", + // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); + switch (eventId) + { + case VideoAttributeEventIds.HdcpActiveFeedbackEventId: + inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HdcpStateFeedbackEventId: + inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: + case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; + } + } + + + + + #region IIROutputPorts Members + public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } + public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } + #endregion + + #region IComPorts Members + public CrestronCollection ComPorts { get { return Tx.ComPorts; } } + public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } } + #endregion + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k302CController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k302CController.cs similarity index 97% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k302CController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k302CController.cs index 0a5532bf..fd3368ae 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k302CController.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k302CController.cs @@ -1,501 +1,501 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -//using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.DM.Config; - -namespace PepperDash.Essentials.DM -{ - using eVst = Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType; - using eAst = Crestron.SimplSharpPro.DeviceSupport.eX02AudioSourceType; - - [Description("Wrapper class for DM-TX-4K-302-C")] - public class DmTx4k302CController : DmTxControllerBase, ITxRoutingWithFeedback, IHasFeedback, - IIROutputPorts, IComPorts, IHasFreeRun, IVgaBrightnessContrastControls - { - public DmTx4k302C Tx { get; private set; } - - public RoutingInputPortWithVideoStatuses HdmiIn1 { get; private set; } - public RoutingInputPortWithVideoStatuses HdmiIn2 { get; private set; } - public RoutingInputPortWithVideoStatuses VgaIn { get; private set; } - public RoutingOutputPort DmOut { get; private set; } - public RoutingOutputPort HdmiLoopOut { get; private set; } - - public override StringFeedback ActiveVideoInputFeedback { get; protected set; } - public IntFeedback VideoSourceNumericFeedback { get; protected set; } - public IntFeedback AudioSourceNumericFeedback { get; protected set; } - public IntFeedback HdmiIn1HdcpCapabilityFeedback { get; protected set; } - public IntFeedback HdmiIn2HdcpCapabilityFeedback { get; protected set; } - public BoolFeedback Hdmi1VideoSyncFeedback { get; protected set; } - public BoolFeedback Hdmi2VideoSyncFeedback { get; protected set; } - public BoolFeedback VgaVideoSyncFeedback { get; protected set; } - - public BoolFeedback FreeRunEnabledFeedback { get; protected set; } - - public IntFeedback VgaBrightnessFeedback { get; protected set; } - public IntFeedback VgaContrastFeedback { get; protected set; } - - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - - - /// - /// Helps get the "real" inputs, including when in Auto - /// - public Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType ActualActiveVideoInput - { - get - { - if (Tx.VideoSourceFeedback != eVst.Auto) - return Tx.VideoSourceFeedback; - else // auto - { - if (Tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) - return eVst.Hdmi1; - else if (Tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) - return eVst.Hdmi2; - else if (Tx.VgaInput.SyncDetectedFeedback.BoolValue) - return eVst.Vga; - else - return eVst.AllDisabled; - } - } - } - public RoutingPortCollection InputPorts - { - get - { - return new RoutingPortCollection - { - HdmiIn1, - HdmiIn2, - VgaIn, - AnyVideoInput - }; - } - } - public RoutingPortCollection OutputPorts - { - get - { - return new RoutingPortCollection { DmOut, HdmiLoopOut }; - } - } - public DmTx4k302CController(string key, string name, DmTx4k302C tx, bool preventRegistration) - : base(key, name, tx) - { - Tx = tx; - PreventRegistration = preventRegistration; - - HdmiIn1 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn1, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi1, this, - VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[1])) - { - FeedbackMatchObject = eVst.Hdmi1 - }; - HdmiIn2 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn2, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi2, this, - VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[2])) - { - FeedbackMatchObject = eVst.Hdmi2 - }; - - VgaIn = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn, - eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, eVst.Vga, this, - VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput)) - { - FeedbackMatchObject = eVst.Vga - }; - - ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", - () => ActualActiveVideoInput.ToString()); - - Tx.HdmiInputs[1].InputStreamChange += InputStreamChangeEvent; - Tx.HdmiInputs[2].InputStreamChange += InputStreamChangeEvent; - Tx.VgaInput.InputStreamChange += VgaInputOnInputStreamChange; - Tx.BaseEvent += Tx_BaseEvent; - - Tx.OnlineStatusChange += Tx_OnlineStatusChange; - - VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); - AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback); - - HdmiIn1HdcpCapabilityFeedback = new IntFeedback("HdmiIn1HdcpCapability", () => (int)tx.HdmiInputs[1].HdcpCapabilityFeedback); - - HdmiIn2HdcpCapabilityFeedback = new IntFeedback("HdmiIn2HdcpCapability", () => (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); - - HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; - - HdcpStateFeedback = new IntFeedback(() => (int)HdcpSupportCapability); - - Hdmi1VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue); - - Hdmi2VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue); - - VgaVideoSyncFeedback = new BoolFeedback(() => (bool)tx.VgaInput.SyncDetectedFeedback.BoolValue); - - FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled); - - VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue); - VgaContrastFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue); - - tx.VgaInput.VideoControls.ControlChange += new Crestron.SimplSharpPro.DeviceSupport.GenericEventHandler(VideoControls_ControlChange); - - - var combinedFuncs = new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => - (ActualActiveVideoInput == eVst.Hdmi1 - && tx.HdmiInputs[1].VideoAttributes.HdcpActiveFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.Hdmi2 - && tx.HdmiInputs[2].VideoAttributes.HdcpActiveFeedback.BoolValue), - - HdcpStateFeedbackFunc = () => - { - if (ActualActiveVideoInput == eVst.Hdmi1) - return tx.HdmiInputs[1].VideoAttributes.HdcpStateFeedback.ToString(); - return ActualActiveVideoInput == eVst.Hdmi2 ? tx.HdmiInputs[2].VideoAttributes.HdcpStateFeedback.ToString() : ""; - }, - - VideoResolutionFeedbackFunc = () => - { - if (ActualActiveVideoInput == eVst.Hdmi1) - return tx.HdmiInputs[1].VideoAttributes.GetVideoResolutionString(); - if (ActualActiveVideoInput == eVst.Hdmi2) - return tx.HdmiInputs[2].VideoAttributes.GetVideoResolutionString(); - return ActualActiveVideoInput == eVst.Vga ? tx.VgaInput.VideoAttributes.GetVideoResolutionString() : ""; - }, - VideoSyncFeedbackFunc = () => - (ActualActiveVideoInput == eVst.Hdmi1 - && tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.Hdmi2 - && tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.Vga - && tx.VgaInput.SyncDetectedFeedback.BoolValue) - - }; - - AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); - - DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmCat, null, this); - HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null, this); - - - AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, - AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, - AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, - AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiIn1HdcpCapabilityFeedback, HdmiIn2HdcpCapabilityFeedback, - Hdmi1VideoSyncFeedback, Hdmi2VideoSyncFeedback, VgaVideoSyncFeedback); - - // Set Ports for CEC - HdmiIn1.Port = Tx.HdmiInputs[1]; - HdmiIn2.Port = Tx.HdmiInputs[2]; - HdmiLoopOut.Port = Tx.HdmiOutput; - DmOut.Port = Tx.DmOutput; - } - - void VgaInputOnInputStreamChange(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - switch (args.EventId) - { - case EndpointInputStreamEventIds.FreeRunFeedbackEventId: - FreeRunEnabledFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - VgaVideoSyncFeedback.FireUpdate(); - break; - } - } - - void VideoControls_ControlChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case VideoControlsEventIds.BrightnessFeedbackEventId: - VgaBrightnessFeedback.FireUpdate(); - break; - case VideoControlsEventIds.ContrastFeedbackEventId: - VgaContrastFeedback.FireUpdate(); - break; - } - } - - - - public override bool CustomActivate() - { - // Link up all of these damned events to the various RoutingPorts via a helper handler - Tx.HdmiInputs[1].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn1, a.EventId); - Tx.HdmiInputs[1].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn1, a.EventId); - - Tx.HdmiInputs[2].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn2, a.EventId); - Tx.HdmiInputs[2].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn2, a.EventId); - - Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaIn, a.EventId); - Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(VgaIn, a.EventId); - - // Base does register and sets up comm monitoring. - return base.CustomActivate(); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); - - if (Hdmi1VideoSyncFeedback != null) - { - Hdmi1VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); - } - if (Hdmi2VideoSyncFeedback != null) - { - Hdmi2VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); - } - if (VgaVideoSyncFeedback != null) - { - VgaVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input3VideoSyncStatus.JoinNumber]); - } - - LinkDmTxToApi(this, trilist, joinMap, bridge); - } - - /// - /// Enables or disables free run - /// - /// - public void SetFreeRunEnabled(bool enable) - { - Tx.VgaInput.FreeRun = enable ? eDmFreeRunSetting.Enabled : eDmFreeRunSetting.Disabled; - } - - /// - /// Sets the VGA brightness level - /// - /// - public void SetVgaBrightness(ushort level) - { - Tx.VgaInput.VideoControls.Brightness.UShortValue = level; - } - - /// - /// Sets the VGA contrast level - /// - /// - public void SetVgaContrast(ushort level) - { - Tx.VgaInput.VideoControls.Contrast.UShortValue = level; - } - - - - public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) - { - Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); - - switch (type) - { - case eRoutingSignalType.Video: - switch (input) - { - case 0: - { - ExecuteSwitch(eVst.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(HdmiIn1.Selector, null, type); - break; - } - case 2: - { - ExecuteSwitch(HdmiIn2.Selector, null, type); - break; - } - case 3: - { - ExecuteSwitch(VgaIn.Selector, null, type); - break; - } - case 4: - { - ExecuteSwitch(eVst.AllDisabled, null, type); - break; - } - } - break; - case eRoutingSignalType.Audio: - switch (input) - { - case 0: - { - ExecuteSwitch(eAst.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(eAst.Hdmi1, null, type); - break; - } - case 2: - { - ExecuteSwitch(eAst.Hdmi2, null, type); - break; - } - case 3: - { - ExecuteSwitch(eAst.AudioIn, null, type); - break; - } - case 4: - { - ExecuteSwitch(eAst.AllDisabled, null, type); - break; - } - } - break; - } - } - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) - Tx.VideoSource = (eVst)inputSelector; - if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - Tx.AudioSource = (eAst)inputSelector; - } - - void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - Debug.Console(2, "{0} event {1} stream {2}", this.Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); - - switch (args.EventId) - { - case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: - case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: - case EndpointInputStreamEventIds.HdcpCapabilityFeedbackEventId: - if (inputStream == Tx.HdmiInputs[1]) HdmiIn1HdcpCapabilityFeedback.FireUpdate(); - if (inputStream == Tx.HdmiInputs[2]) HdmiIn2HdcpCapabilityFeedback.FireUpdate(); - HdcpStateFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - if (inputStream == Tx.HdmiInputs[1]) Hdmi1VideoSyncFeedback.FireUpdate(); - if (inputStream == Tx.HdmiInputs[2]) Hdmi2VideoSyncFeedback.FireUpdate(); - break; - } - } - void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) - { - var localVideoInputPort = - InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - var localAudioInputPort = - InputPorts.FirstOrDefault(p => (eAst)p.Selector == Tx.AudioSourceFeedback); - - ActiveVideoInputFeedback.FireUpdate(); - VideoSourceNumericFeedback.FireUpdate(); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); - } - - void Tx_BaseEvent(GenericBase device, BaseEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case EndpointTransmitterBase.VideoSourceFeedbackEventId: - var localVideoInputPort = InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); - VideoSourceNumericFeedback.FireUpdate(); - ActiveVideoInputFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - break; - case EndpointTransmitterBase.AudioSourceFeedbackEventId: - var localInputAudioPort = InputPorts.FirstOrDefault(p => (eAst)p.Selector == Tx.AudioSourceFeedback); - Debug.Console(2, this, " Audio Source: {0}", Tx.AudioSourceFeedback); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); - break; - } - } - - /// - /// Relays the input stream change to the appropriate RoutingInputPort. - /// - void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) return; - inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); - } - - /// - /// Relays the VideoAttributes change to a RoutingInputPort - /// - void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds - //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", - // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); - switch (eventId) - { - case VideoAttributeEventIds.HdcpActiveFeedbackEventId: - inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HdcpStateFeedbackEventId: - inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: - case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - } - } - - - #region IIROutputPorts Members - public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } - public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } - #endregion - - #region IComPorts Members - public CrestronCollection ComPorts { get { return Tx.ComPorts; } } - public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } } - #endregion - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +//using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.DM.Config; + +namespace PepperDash.Essentials.DM +{ + using eVst = Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType; + using eAst = Crestron.SimplSharpPro.DeviceSupport.eX02AudioSourceType; + + [Description("Wrapper class for DM-TX-4K-302-C")] + public class DmTx4k302CController : DmTxControllerBase, ITxRoutingWithFeedback, IHasFeedback, + IIROutputPorts, IComPorts, IHasFreeRun, IVgaBrightnessContrastControls + { + public DmTx4k302C Tx { get; private set; } + + public RoutingInputPortWithVideoStatuses HdmiIn1 { get; private set; } + public RoutingInputPortWithVideoStatuses HdmiIn2 { get; private set; } + public RoutingInputPortWithVideoStatuses VgaIn { get; private set; } + public RoutingOutputPort DmOut { get; private set; } + public RoutingOutputPort HdmiLoopOut { get; private set; } + + public override StringFeedback ActiveVideoInputFeedback { get; protected set; } + public IntFeedback VideoSourceNumericFeedback { get; protected set; } + public IntFeedback AudioSourceNumericFeedback { get; protected set; } + public IntFeedback HdmiIn1HdcpCapabilityFeedback { get; protected set; } + public IntFeedback HdmiIn2HdcpCapabilityFeedback { get; protected set; } + public BoolFeedback Hdmi1VideoSyncFeedback { get; protected set; } + public BoolFeedback Hdmi2VideoSyncFeedback { get; protected set; } + public BoolFeedback VgaVideoSyncFeedback { get; protected set; } + + public BoolFeedback FreeRunEnabledFeedback { get; protected set; } + + public IntFeedback VgaBrightnessFeedback { get; protected set; } + public IntFeedback VgaContrastFeedback { get; protected set; } + + //IroutingNumericEvent + public event EventHandler NumericSwitchChange; + + /// + /// Raise an event when the status of a switch object changes. + /// + /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType + private void OnSwitchChange(RoutingNumericEventArgs e) + { + var newEvent = NumericSwitchChange; + if (newEvent != null) newEvent(this, e); + } + + + /// + /// Helps get the "real" inputs, including when in Auto + /// + public Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType ActualActiveVideoInput + { + get + { + if (Tx.VideoSourceFeedback != eVst.Auto) + return Tx.VideoSourceFeedback; + else // auto + { + if (Tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) + return eVst.Hdmi1; + else if (Tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) + return eVst.Hdmi2; + else if (Tx.VgaInput.SyncDetectedFeedback.BoolValue) + return eVst.Vga; + else + return eVst.AllDisabled; + } + } + } + public RoutingPortCollection InputPorts + { + get + { + return new RoutingPortCollection + { + HdmiIn1, + HdmiIn2, + VgaIn, + AnyVideoInput + }; + } + } + public RoutingPortCollection OutputPorts + { + get + { + return new RoutingPortCollection { DmOut, HdmiLoopOut }; + } + } + public DmTx4k302CController(string key, string name, DmTx4k302C tx, bool preventRegistration) + : base(key, name, tx) + { + Tx = tx; + PreventRegistration = preventRegistration; + + HdmiIn1 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn1, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi1, this, + VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[1])) + { + FeedbackMatchObject = eVst.Hdmi1 + }; + HdmiIn2 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn2, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi2, this, + VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[2])) + { + FeedbackMatchObject = eVst.Hdmi2 + }; + + VgaIn = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn, + eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, eVst.Vga, this, + VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput)) + { + FeedbackMatchObject = eVst.Vga + }; + + ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", + () => ActualActiveVideoInput.ToString()); + + Tx.HdmiInputs[1].InputStreamChange += InputStreamChangeEvent; + Tx.HdmiInputs[2].InputStreamChange += InputStreamChangeEvent; + Tx.VgaInput.InputStreamChange += VgaInputOnInputStreamChange; + Tx.BaseEvent += Tx_BaseEvent; + + Tx.OnlineStatusChange += Tx_OnlineStatusChange; + + VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); + AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback); + + HdmiIn1HdcpCapabilityFeedback = new IntFeedback("HdmiIn1HdcpCapability", () => (int)tx.HdmiInputs[1].HdcpCapabilityFeedback); + + HdmiIn2HdcpCapabilityFeedback = new IntFeedback("HdmiIn2HdcpCapability", () => (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); + + HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; + + HdcpStateFeedback = new IntFeedback(() => (int)HdcpSupportCapability); + + Hdmi1VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue); + + Hdmi2VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue); + + VgaVideoSyncFeedback = new BoolFeedback(() => (bool)tx.VgaInput.SyncDetectedFeedback.BoolValue); + + FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled); + + VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue); + VgaContrastFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue); + + tx.VgaInput.VideoControls.ControlChange += new Crestron.SimplSharpPro.DeviceSupport.GenericEventHandler(VideoControls_ControlChange); + + + var combinedFuncs = new VideoStatusFuncsWrapper + { + HdcpActiveFeedbackFunc = () => + (ActualActiveVideoInput == eVst.Hdmi1 + && tx.HdmiInputs[1].VideoAttributes.HdcpActiveFeedback.BoolValue) + || (ActualActiveVideoInput == eVst.Hdmi2 + && tx.HdmiInputs[2].VideoAttributes.HdcpActiveFeedback.BoolValue), + + HdcpStateFeedbackFunc = () => + { + if (ActualActiveVideoInput == eVst.Hdmi1) + return tx.HdmiInputs[1].VideoAttributes.HdcpStateFeedback.ToString(); + return ActualActiveVideoInput == eVst.Hdmi2 ? tx.HdmiInputs[2].VideoAttributes.HdcpStateFeedback.ToString() : ""; + }, + + VideoResolutionFeedbackFunc = () => + { + if (ActualActiveVideoInput == eVst.Hdmi1) + return tx.HdmiInputs[1].VideoAttributes.GetVideoResolutionString(); + if (ActualActiveVideoInput == eVst.Hdmi2) + return tx.HdmiInputs[2].VideoAttributes.GetVideoResolutionString(); + return ActualActiveVideoInput == eVst.Vga ? tx.VgaInput.VideoAttributes.GetVideoResolutionString() : ""; + }, + VideoSyncFeedbackFunc = () => + (ActualActiveVideoInput == eVst.Hdmi1 + && tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) + || (ActualActiveVideoInput == eVst.Hdmi2 + && tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) + || (ActualActiveVideoInput == eVst.Vga + && tx.VgaInput.SyncDetectedFeedback.BoolValue) + + }; + + AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); + + DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.DmCat, null, this); + HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, null, this); + + + AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, + AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, + AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, + AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiIn1HdcpCapabilityFeedback, HdmiIn2HdcpCapabilityFeedback, + Hdmi1VideoSyncFeedback, Hdmi2VideoSyncFeedback, VgaVideoSyncFeedback); + + // Set Ports for CEC + HdmiIn1.Port = Tx.HdmiInputs[1]; + HdmiIn2.Port = Tx.HdmiInputs[2]; + HdmiLoopOut.Port = Tx.HdmiOutput; + DmOut.Port = Tx.DmOutput; + } + + void VgaInputOnInputStreamChange(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) + { + switch (args.EventId) + { + case EndpointInputStreamEventIds.FreeRunFeedbackEventId: + FreeRunEnabledFeedback.FireUpdate(); + break; + case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: + VgaVideoSyncFeedback.FireUpdate(); + break; + } + } + + void VideoControls_ControlChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) + { + var id = args.EventId; + Debug.Console(2, this, "EventId {0}", args.EventId); + + switch (id) + { + case VideoControlsEventIds.BrightnessFeedbackEventId: + VgaBrightnessFeedback.FireUpdate(); + break; + case VideoControlsEventIds.ContrastFeedbackEventId: + VgaContrastFeedback.FireUpdate(); + break; + } + } + + + + public override bool CustomActivate() + { + // Link up all of these damned events to the various RoutingPorts via a helper handler + Tx.HdmiInputs[1].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn1, a.EventId); + Tx.HdmiInputs[1].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn1, a.EventId); + + Tx.HdmiInputs[2].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn2, a.EventId); + Tx.HdmiInputs[2].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn2, a.EventId); + + Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaIn, a.EventId); + Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(VgaIn, a.EventId); + + // Base does register and sets up comm monitoring. + return base.CustomActivate(); + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); + + if (Hdmi1VideoSyncFeedback != null) + { + Hdmi1VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); + } + if (Hdmi2VideoSyncFeedback != null) + { + Hdmi2VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); + } + if (VgaVideoSyncFeedback != null) + { + VgaVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input3VideoSyncStatus.JoinNumber]); + } + + LinkDmTxToApi(this, trilist, joinMap, bridge); + } + + /// + /// Enables or disables free run + /// + /// + public void SetFreeRunEnabled(bool enable) + { + Tx.VgaInput.FreeRun = enable ? eDmFreeRunSetting.Enabled : eDmFreeRunSetting.Disabled; + } + + /// + /// Sets the VGA brightness level + /// + /// + public void SetVgaBrightness(ushort level) + { + Tx.VgaInput.VideoControls.Brightness.UShortValue = level; + } + + /// + /// Sets the VGA contrast level + /// + /// + public void SetVgaContrast(ushort level) + { + Tx.VgaInput.VideoControls.Contrast.UShortValue = level; + } + + + + public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) + { + Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); + + switch (type) + { + case eRoutingSignalType.Video: + switch (input) + { + case 0: + { + ExecuteSwitch(eVst.Auto, null, type); + break; + } + case 1: + { + ExecuteSwitch(HdmiIn1.Selector, null, type); + break; + } + case 2: + { + ExecuteSwitch(HdmiIn2.Selector, null, type); + break; + } + case 3: + { + ExecuteSwitch(VgaIn.Selector, null, type); + break; + } + case 4: + { + ExecuteSwitch(eVst.AllDisabled, null, type); + break; + } + } + break; + case eRoutingSignalType.Audio: + switch (input) + { + case 0: + { + ExecuteSwitch(eAst.Auto, null, type); + break; + } + case 1: + { + ExecuteSwitch(eAst.Hdmi1, null, type); + break; + } + case 2: + { + ExecuteSwitch(eAst.Hdmi2, null, type); + break; + } + case 3: + { + ExecuteSwitch(eAst.AudioIn, null, type); + break; + } + case 4: + { + ExecuteSwitch(eAst.AllDisabled, null, type); + break; + } + } + break; + } + } + + public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) + { + if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) + Tx.VideoSource = (eVst)inputSelector; + if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) + Tx.AudioSource = (eAst)inputSelector; + } + + void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) + { + Debug.Console(2, "{0} event {1} stream {2}", this.Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); + + switch (args.EventId) + { + case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: + case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: + case EndpointInputStreamEventIds.HdcpCapabilityFeedbackEventId: + if (inputStream == Tx.HdmiInputs[1]) HdmiIn1HdcpCapabilityFeedback.FireUpdate(); + if (inputStream == Tx.HdmiInputs[2]) HdmiIn2HdcpCapabilityFeedback.FireUpdate(); + HdcpStateFeedback.FireUpdate(); + break; + case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: + if (inputStream == Tx.HdmiInputs[1]) Hdmi1VideoSyncFeedback.FireUpdate(); + if (inputStream == Tx.HdmiInputs[2]) Hdmi2VideoSyncFeedback.FireUpdate(); + break; + } + } + void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) + { + var localVideoInputPort = + InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); + var localAudioInputPort = + InputPorts.FirstOrDefault(p => (eAst)p.Selector == Tx.AudioSourceFeedback); + + ActiveVideoInputFeedback.FireUpdate(); + VideoSourceNumericFeedback.FireUpdate(); + AudioSourceNumericFeedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); + OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); + } + + void Tx_BaseEvent(GenericBase device, BaseEventArgs args) + { + var id = args.EventId; + Debug.Console(2, this, "EventId {0}", args.EventId); + + switch (id) + { + case EndpointTransmitterBase.VideoSourceFeedbackEventId: + var localVideoInputPort = InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); + Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); + VideoSourceNumericFeedback.FireUpdate(); + ActiveVideoInputFeedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); + break; + case EndpointTransmitterBase.AudioSourceFeedbackEventId: + var localInputAudioPort = InputPorts.FirstOrDefault(p => (eAst)p.Selector == Tx.AudioSourceFeedback); + Debug.Console(2, this, " Audio Source: {0}", Tx.AudioSourceFeedback); + AudioSourceNumericFeedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); + break; + } + } + + /// + /// Relays the input stream change to the appropriate RoutingInputPort. + /// + void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { + if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) return; + inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); + } + + /// + /// Relays the VideoAttributes change to a RoutingInputPort + /// + void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { + //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds + //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", + // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); + switch (eventId) + { + case VideoAttributeEventIds.HdcpActiveFeedbackEventId: + inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HdcpStateFeedbackEventId: + inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: + case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; + } + } + + + #region IIROutputPorts Members + public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } + public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } + #endregion + + #region IComPorts Members + public CrestronCollection ComPorts { get { return Tx.ComPorts; } } + public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } } + #endregion + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz100Controller.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz100Controller.cs similarity index 97% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz100Controller.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz100Controller.cs index bb7d9e3d..c0ef7eba 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz100Controller.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz100Controller.cs @@ -1,97 +1,97 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.DM.Config; - -namespace PepperDash.Essentials.DM -{ - // using eVst = Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType; - - /// - /// Controller class for all DM-TX-201C/S/F transmitters - /// - [Description("Wrapper class for DM-TX-4K-Z-100-C")] - public class DmTx4kz100Controller : BasicDmTxControllerBase, IRoutingInputsOutputs, IHasFeedback, - IIROutputPorts, IComPorts, ICec - { - public DmTx4kz100C1G Tx { get; private set; } - - public RoutingInputPort HdmiIn { get; private set; } - public RoutingOutputPort DmOut { get; private set; } - - /// - /// Helps get the "real" inputs, including when in Auto - /// - public eX02VideoSourceType ActualActiveVideoInput - { - get - { - return eX02VideoSourceType.Hdmi1; - } - } - public RoutingPortCollection InputPorts - { - get - { - return new RoutingPortCollection - { - HdmiIn - }; - } - } - public RoutingPortCollection OutputPorts - { - get - { - return new RoutingPortCollection { DmOut }; - } - } - public DmTx4kz100Controller(string key, string name, DmTx4kz100C1G tx) - : base(key, name, tx) - { - Tx = tx; - - HdmiIn = new RoutingInputPort(DmPortName.HdmiIn1, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eX02VideoSourceType.Hdmi1, this); - - DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmCat, null, this); - - // Set Ports for CEC - HdmiIn.Port = Tx; - - PreventRegistration = true; - tx.Register(); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - Debug.Console(1, this, "No properties to link. Skipping device {0}", Name); - } - - #region IIROutputPorts Members - public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } - public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } - #endregion - - #region IComPorts Members - public CrestronCollection ComPorts { get { return Tx.ComPorts; } } - public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } } - #endregion - - #region ICec Members - public Cec StreamCec { get { return Tx.HdmiInput.StreamCec; } } - #endregion - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.DM.Config; + +namespace PepperDash.Essentials.DM +{ + // using eVst = Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType; + + /// + /// Controller class for all DM-TX-201C/S/F transmitters + /// + [Description("Wrapper class for DM-TX-4K-Z-100-C")] + public class DmTx4kz100Controller : BasicDmTxControllerBase, IRoutingInputsOutputs, IHasFeedback, + IIROutputPorts, IComPorts, ICec + { + public DmTx4kz100C1G Tx { get; private set; } + + public RoutingInputPort HdmiIn { get; private set; } + public RoutingOutputPort DmOut { get; private set; } + + /// + /// Helps get the "real" inputs, including when in Auto + /// + public eX02VideoSourceType ActualActiveVideoInput + { + get + { + return eX02VideoSourceType.Hdmi1; + } + } + public RoutingPortCollection InputPorts + { + get + { + return new RoutingPortCollection + { + HdmiIn + }; + } + } + public RoutingPortCollection OutputPorts + { + get + { + return new RoutingPortCollection { DmOut }; + } + } + public DmTx4kz100Controller(string key, string name, DmTx4kz100C1G tx) + : base(key, name, tx) + { + Tx = tx; + + HdmiIn = new RoutingInputPort(DmPortName.HdmiIn1, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eX02VideoSourceType.Hdmi1, this); + + DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.DmCat, null, this); + + // Set Ports for CEC + HdmiIn.Port = Tx; + + PreventRegistration = true; + tx.Register(); + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + Debug.Console(1, this, "No properties to link. Skipping device {0}", Name); + } + + #region IIROutputPorts Members + public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } + public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } + #endregion + + #region IComPorts Members + public CrestronCollection ComPorts { get { return Tx.ComPorts; } } + public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } } + #endregion + + #region ICec Members + public Cec StreamCec { get { return Tx.HdmiInput.StreamCec; } } + #endregion + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz202CController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz202CController.cs similarity index 97% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz202CController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz202CController.cs index b9f521c6..c9a6c7f9 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz202CController.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz202CController.cs @@ -1,406 +1,406 @@ -using Crestron.SimplSharpPro; -using System; -using System.Linq; -//using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.DM -{ - using eVst = eX02VideoSourceType; - using eAst = eX02AudioSourceType; - - public class DmTx4kz202CController : DmTxControllerBase, ITxRoutingWithFeedback, - IIROutputPorts, IComPorts - { - public DmTx4kz202C Tx { get; private set; } - - public RoutingInputPortWithVideoStatuses HdmiIn1 { get; private set; } - public RoutingInputPortWithVideoStatuses HdmiIn2 { get; private set; } - public RoutingOutputPort DmOut { get; private set; } - public RoutingOutputPort HdmiLoopOut { get; private set; } - - public override StringFeedback ActiveVideoInputFeedback { get; protected set; } - public IntFeedback VideoSourceNumericFeedback { get; protected set; } - public IntFeedback AudioSourceNumericFeedback { get; protected set; } - public IntFeedback HdmiIn1HdcpCapabilityFeedback { get; protected set; } - public IntFeedback HdmiIn2HdcpCapabilityFeedback { get; protected set; } - public BoolFeedback Hdmi1VideoSyncFeedback { get; protected set; } - public BoolFeedback Hdmi2VideoSyncFeedback { get; protected set; } - - //public override IntFeedback HdcpSupportAllFeedback { get; protected set; } - //public override ushort HdcpSupportCapability { get; protected set; } - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - - - - /// - /// Helps get the "real" inputs, including when in Auto - /// - public eX02VideoSourceType ActualActiveVideoInput - { - get - { - if (Tx.VideoSourceFeedback != eVst.Auto) - return Tx.VideoSourceFeedback; - - if (Tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) - return eVst.Hdmi1; - - return Tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue ? eVst.Hdmi2 : eVst.AllDisabled; - } - } - public RoutingPortCollection InputPorts - { - get - { - return new RoutingPortCollection - { - HdmiIn1, - HdmiIn2, - AnyVideoInput - }; - } - } - public RoutingPortCollection OutputPorts - { - get - { - return new RoutingPortCollection { DmOut, HdmiLoopOut }; - } - } - public DmTx4kz202CController(string key, string name, DmTx4kz202C tx, bool preventRegistration) - : base(key, name, tx) - { - Tx = tx; - PreventRegistration = preventRegistration; - - HdmiIn1 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn1, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi1, this, - VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[1])) - { - FeedbackMatchObject = eVst.Hdmi1 - }; - HdmiIn2 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn2, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi2, this, - VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[2])) - { - FeedbackMatchObject = eVst.Hdmi2 - }; - - ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", - () => ActualActiveVideoInput.ToString()); - - - - Tx.HdmiInputs[1].InputStreamChange += InputStreamChangeEvent; - Tx.HdmiInputs[2].InputStreamChange += InputStreamChangeEvent; - Tx.BaseEvent += Tx_BaseEvent; - Tx.OnlineStatusChange += Tx_OnlineStatusChange; - - VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); - - //Return VideoSourceFeedback here as DM-TX-4KZ-202-C does not support audio breakaway - AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); - - HdmiIn1HdcpCapabilityFeedback = new IntFeedback("HdmiIn1HdcpCapability", () => (int)tx.HdmiInputs[1].HdcpCapabilityFeedback); - - HdmiIn2HdcpCapabilityFeedback = new IntFeedback("HdmiIn2HdcpCapability", () => (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); - - HdcpStateFeedback = - new IntFeedback( - () => - tx.HdmiInputs[1].HdcpCapabilityFeedback > tx.HdmiInputs[2].HdcpCapabilityFeedback - ? (int)tx.HdmiInputs[1].HdcpCapabilityFeedback - : (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); - - HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; - - Hdmi1VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue); - - Hdmi2VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue); - - var combinedFuncs = new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => - (ActualActiveVideoInput == eVst.Hdmi1 - && tx.HdmiInputs[1].VideoAttributes.HdcpActiveFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.Hdmi2 - && tx.HdmiInputs[2].VideoAttributes.HdcpActiveFeedback.BoolValue), - - HdcpStateFeedbackFunc = () => - { - if (ActualActiveVideoInput == eVst.Hdmi1) - return tx.HdmiInputs[1].VideoAttributes.HdcpStateFeedback.ToString(); - if (ActualActiveVideoInput == eVst.Hdmi2) - return tx.HdmiInputs[2].VideoAttributes.HdcpStateFeedback.ToString(); - return ""; - }, - - VideoResolutionFeedbackFunc = () => - { - if (ActualActiveVideoInput == eVst.Hdmi1) - return tx.HdmiInputs[1].VideoAttributes.GetVideoResolutionString(); - if (ActualActiveVideoInput == eVst.Hdmi2) - return tx.HdmiInputs[2].VideoAttributes.GetVideoResolutionString(); - return ""; - }, - VideoSyncFeedbackFunc = () => - (ActualActiveVideoInput == eVst.Hdmi1 - && tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.Hdmi2 - && tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) - - }; - - AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); - - DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmCat, null, this); - HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null, this); - - - AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, - AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, - AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, - AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiIn1HdcpCapabilityFeedback, HdmiIn2HdcpCapabilityFeedback, - Hdmi1VideoSyncFeedback, Hdmi2VideoSyncFeedback); - - // Set Ports for CEC - HdmiIn1.Port = Tx.HdmiInputs[1]; - HdmiIn2.Port = Tx.HdmiInputs[2]; - HdmiLoopOut.Port = Tx.HdmiOutput; - DmOut.Port = Tx.DmOutput; - } - - - - public override bool CustomActivate() - { - // Link up all of these damned events to the various RoutingPorts via a helper handler - Tx.HdmiInputs[1].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn1, a.EventId); - Tx.HdmiInputs[1].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn1, a.EventId); - - Tx.HdmiInputs[2].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn2, a.EventId); - Tx.HdmiInputs[2].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn2, a.EventId); - - // Base does register and sets up comm monitoring. - return base.CustomActivate(); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); - - if (Hdmi1VideoSyncFeedback != null) - { - Hdmi1VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); - } - if (Hdmi2VideoSyncFeedback != null) - { - Hdmi2VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); - } - - LinkDmTxToApi(this, trilist, joinMap, bridge); - } - - public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) - { - Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); - - switch (type) - { - case eRoutingSignalType.Video: - switch (input) - { - case 0: - { - ExecuteSwitch(eVst.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(HdmiIn1.Selector, null, type); - break; - } - case 2: - { - ExecuteSwitch(HdmiIn2.Selector, null, type); - break; - } - case 3: - { - ExecuteSwitch(eVst.AllDisabled, null, type); - break; - } - } - break; - case eRoutingSignalType.Audio: - switch (input) - { - case 0: - { - ExecuteSwitch(eAst.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(eAst.Hdmi1, null, type); - break; - } - case 2: - { - ExecuteSwitch(eAst.Hdmi2, null, type); - break; - } - case 3: - { - ExecuteSwitch(eAst.AllDisabled, null, type); - break; - } - } - break; - } - } - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - if ((signalType & eRoutingSignalType.Video) == eRoutingSignalType.Video) - Tx.VideoSource = (eVst)inputSelector; - if(((signalType & eRoutingSignalType.Audio) == eRoutingSignalType.Audio)) - Debug.Console(2, this, "Unable to execute audio-only switch for tx {0}", Key); - } - - void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - Debug.Console(2, "{0} event {1} stream {2}", Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); - - switch (args.EventId) - { - case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: - case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: - case EndpointInputStreamEventIds.HdcpCapabilityFeedbackEventId: - if (inputStream == Tx.HdmiInputs[1]) HdmiIn1HdcpCapabilityFeedback.FireUpdate(); - if (inputStream == Tx.HdmiInputs[2]) HdmiIn2HdcpCapabilityFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - if (inputStream == Tx.HdmiInputs[1]) Hdmi1VideoSyncFeedback.FireUpdate(); - if (inputStream == Tx.HdmiInputs[2]) Hdmi2VideoSyncFeedback.FireUpdate(); - break; - } - } - - void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) - { - var localVideoInputPort = - InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - var localAudioInputPort = - InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - - ActiveVideoInputFeedback.FireUpdate(); - VideoSourceNumericFeedback.FireUpdate(); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); - } - - - void Tx_BaseEvent(GenericBase device, BaseEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case EndpointTransmitterBase.VideoSourceFeedbackEventId: - var localVideoInputPort = InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); - VideoSourceNumericFeedback.FireUpdate(); - ActiveVideoInputFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - break; - case EndpointTransmitterBase.AudioSourceFeedbackEventId: - var localInputAudioPort = InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - Debug.Console(2, this, " Audio Source: {0}", Tx.VideoSourceFeedback); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); - break; - } - } - - /// - /// Relays the input stream change to the appropriate RoutingInputPort. - /// - void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) - { - return; - } - inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); - } - - /// - /// Relays the VideoAttributes change to a RoutingInputPort - /// - void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds - //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", - // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); - switch (eventId) - { - case VideoAttributeEventIds.HdcpActiveFeedbackEventId: - inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HdcpStateFeedbackEventId: - inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: - case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - } - } - - - - - #region IIROutputPorts Members - public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } - public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } - #endregion - - #region IComPorts Members - public CrestronCollection ComPorts { get { return Tx.ComPorts; } } - public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } } - #endregion - } +using Crestron.SimplSharpPro; +using System; +using System.Linq; +//using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; + +namespace PepperDash.Essentials.DM +{ + using eVst = eX02VideoSourceType; + using eAst = eX02AudioSourceType; + + public class DmTx4kz202CController : DmTxControllerBase, ITxRoutingWithFeedback, + IIROutputPorts, IComPorts + { + public DmTx4kz202C Tx { get; private set; } + + public RoutingInputPortWithVideoStatuses HdmiIn1 { get; private set; } + public RoutingInputPortWithVideoStatuses HdmiIn2 { get; private set; } + public RoutingOutputPort DmOut { get; private set; } + public RoutingOutputPort HdmiLoopOut { get; private set; } + + public override StringFeedback ActiveVideoInputFeedback { get; protected set; } + public IntFeedback VideoSourceNumericFeedback { get; protected set; } + public IntFeedback AudioSourceNumericFeedback { get; protected set; } + public IntFeedback HdmiIn1HdcpCapabilityFeedback { get; protected set; } + public IntFeedback HdmiIn2HdcpCapabilityFeedback { get; protected set; } + public BoolFeedback Hdmi1VideoSyncFeedback { get; protected set; } + public BoolFeedback Hdmi2VideoSyncFeedback { get; protected set; } + + //public override IntFeedback HdcpSupportAllFeedback { get; protected set; } + //public override ushort HdcpSupportCapability { get; protected set; } + //IroutingNumericEvent + public event EventHandler NumericSwitchChange; + + /// + /// Raise an event when the status of a switch object changes. + /// + /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType + private void OnSwitchChange(RoutingNumericEventArgs e) + { + var newEvent = NumericSwitchChange; + if (newEvent != null) newEvent(this, e); + } + + + + /// + /// Helps get the "real" inputs, including when in Auto + /// + public eX02VideoSourceType ActualActiveVideoInput + { + get + { + if (Tx.VideoSourceFeedback != eVst.Auto) + return Tx.VideoSourceFeedback; + + if (Tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) + return eVst.Hdmi1; + + return Tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue ? eVst.Hdmi2 : eVst.AllDisabled; + } + } + public RoutingPortCollection InputPorts + { + get + { + return new RoutingPortCollection + { + HdmiIn1, + HdmiIn2, + AnyVideoInput + }; + } + } + public RoutingPortCollection OutputPorts + { + get + { + return new RoutingPortCollection { DmOut, HdmiLoopOut }; + } + } + public DmTx4kz202CController(string key, string name, DmTx4kz202C tx, bool preventRegistration) + : base(key, name, tx) + { + Tx = tx; + PreventRegistration = preventRegistration; + + HdmiIn1 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn1, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi1, this, + VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[1])) + { + FeedbackMatchObject = eVst.Hdmi1 + }; + HdmiIn2 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn2, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi2, this, + VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[2])) + { + FeedbackMatchObject = eVst.Hdmi2 + }; + + ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", + () => ActualActiveVideoInput.ToString()); + + + + Tx.HdmiInputs[1].InputStreamChange += InputStreamChangeEvent; + Tx.HdmiInputs[2].InputStreamChange += InputStreamChangeEvent; + Tx.BaseEvent += Tx_BaseEvent; + Tx.OnlineStatusChange += Tx_OnlineStatusChange; + + VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); + + //Return VideoSourceFeedback here as DM-TX-4KZ-202-C does not support audio breakaway + AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); + + HdmiIn1HdcpCapabilityFeedback = new IntFeedback("HdmiIn1HdcpCapability", () => (int)tx.HdmiInputs[1].HdcpCapabilityFeedback); + + HdmiIn2HdcpCapabilityFeedback = new IntFeedback("HdmiIn2HdcpCapability", () => (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); + + HdcpStateFeedback = + new IntFeedback( + () => + tx.HdmiInputs[1].HdcpCapabilityFeedback > tx.HdmiInputs[2].HdcpCapabilityFeedback + ? (int)tx.HdmiInputs[1].HdcpCapabilityFeedback + : (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); + + HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; + + Hdmi1VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue); + + Hdmi2VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue); + + var combinedFuncs = new VideoStatusFuncsWrapper + { + HdcpActiveFeedbackFunc = () => + (ActualActiveVideoInput == eVst.Hdmi1 + && tx.HdmiInputs[1].VideoAttributes.HdcpActiveFeedback.BoolValue) + || (ActualActiveVideoInput == eVst.Hdmi2 + && tx.HdmiInputs[2].VideoAttributes.HdcpActiveFeedback.BoolValue), + + HdcpStateFeedbackFunc = () => + { + if (ActualActiveVideoInput == eVst.Hdmi1) + return tx.HdmiInputs[1].VideoAttributes.HdcpStateFeedback.ToString(); + if (ActualActiveVideoInput == eVst.Hdmi2) + return tx.HdmiInputs[2].VideoAttributes.HdcpStateFeedback.ToString(); + return ""; + }, + + VideoResolutionFeedbackFunc = () => + { + if (ActualActiveVideoInput == eVst.Hdmi1) + return tx.HdmiInputs[1].VideoAttributes.GetVideoResolutionString(); + if (ActualActiveVideoInput == eVst.Hdmi2) + return tx.HdmiInputs[2].VideoAttributes.GetVideoResolutionString(); + return ""; + }, + VideoSyncFeedbackFunc = () => + (ActualActiveVideoInput == eVst.Hdmi1 + && tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) + || (ActualActiveVideoInput == eVst.Hdmi2 + && tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) + + }; + + AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); + + DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.DmCat, null, this); + HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, null, this); + + + AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, + AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, + AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, + AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiIn1HdcpCapabilityFeedback, HdmiIn2HdcpCapabilityFeedback, + Hdmi1VideoSyncFeedback, Hdmi2VideoSyncFeedback); + + // Set Ports for CEC + HdmiIn1.Port = Tx.HdmiInputs[1]; + HdmiIn2.Port = Tx.HdmiInputs[2]; + HdmiLoopOut.Port = Tx.HdmiOutput; + DmOut.Port = Tx.DmOutput; + } + + + + public override bool CustomActivate() + { + // Link up all of these damned events to the various RoutingPorts via a helper handler + Tx.HdmiInputs[1].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn1, a.EventId); + Tx.HdmiInputs[1].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn1, a.EventId); + + Tx.HdmiInputs[2].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn2, a.EventId); + Tx.HdmiInputs[2].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn2, a.EventId); + + // Base does register and sets up comm monitoring. + return base.CustomActivate(); + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); + + if (Hdmi1VideoSyncFeedback != null) + { + Hdmi1VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); + } + if (Hdmi2VideoSyncFeedback != null) + { + Hdmi2VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); + } + + LinkDmTxToApi(this, trilist, joinMap, bridge); + } + + public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) + { + Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); + + switch (type) + { + case eRoutingSignalType.Video: + switch (input) + { + case 0: + { + ExecuteSwitch(eVst.Auto, null, type); + break; + } + case 1: + { + ExecuteSwitch(HdmiIn1.Selector, null, type); + break; + } + case 2: + { + ExecuteSwitch(HdmiIn2.Selector, null, type); + break; + } + case 3: + { + ExecuteSwitch(eVst.AllDisabled, null, type); + break; + } + } + break; + case eRoutingSignalType.Audio: + switch (input) + { + case 0: + { + ExecuteSwitch(eAst.Auto, null, type); + break; + } + case 1: + { + ExecuteSwitch(eAst.Hdmi1, null, type); + break; + } + case 2: + { + ExecuteSwitch(eAst.Hdmi2, null, type); + break; + } + case 3: + { + ExecuteSwitch(eAst.AllDisabled, null, type); + break; + } + } + break; + } + } + + public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) + { + if ((signalType & eRoutingSignalType.Video) == eRoutingSignalType.Video) + Tx.VideoSource = (eVst)inputSelector; + if(((signalType & eRoutingSignalType.Audio) == eRoutingSignalType.Audio)) + Debug.Console(2, this, "Unable to execute audio-only switch for tx {0}", Key); + } + + void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) + { + Debug.Console(2, "{0} event {1} stream {2}", Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); + + switch (args.EventId) + { + case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: + case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: + case EndpointInputStreamEventIds.HdcpCapabilityFeedbackEventId: + if (inputStream == Tx.HdmiInputs[1]) HdmiIn1HdcpCapabilityFeedback.FireUpdate(); + if (inputStream == Tx.HdmiInputs[2]) HdmiIn2HdcpCapabilityFeedback.FireUpdate(); + break; + case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: + if (inputStream == Tx.HdmiInputs[1]) Hdmi1VideoSyncFeedback.FireUpdate(); + if (inputStream == Tx.HdmiInputs[2]) Hdmi2VideoSyncFeedback.FireUpdate(); + break; + } + } + + void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) + { + var localVideoInputPort = + InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); + var localAudioInputPort = + InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); + + ActiveVideoInputFeedback.FireUpdate(); + VideoSourceNumericFeedback.FireUpdate(); + AudioSourceNumericFeedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); + OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); + } + + + void Tx_BaseEvent(GenericBase device, BaseEventArgs args) + { + var id = args.EventId; + Debug.Console(2, this, "EventId {0}", args.EventId); + + switch (id) + { + case EndpointTransmitterBase.VideoSourceFeedbackEventId: + var localVideoInputPort = InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); + Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); + VideoSourceNumericFeedback.FireUpdate(); + ActiveVideoInputFeedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); + break; + case EndpointTransmitterBase.AudioSourceFeedbackEventId: + var localInputAudioPort = InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); + Debug.Console(2, this, " Audio Source: {0}", Tx.VideoSourceFeedback); + AudioSourceNumericFeedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); + break; + } + } + + /// + /// Relays the input stream change to the appropriate RoutingInputPort. + /// + void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { + if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) + { + return; + } + inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); + } + + /// + /// Relays the VideoAttributes change to a RoutingInputPort + /// + void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { + //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds + //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", + // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); + switch (eventId) + { + case VideoAttributeEventIds.HdcpActiveFeedbackEventId: + inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HdcpStateFeedbackEventId: + inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: + case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; + } + } + + + + + #region IIROutputPorts Members + public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } + public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } + #endregion + + #region IComPorts Members + public CrestronCollection ComPorts { get { return Tx.ComPorts; } } + public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } } + #endregion + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs similarity index 98% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs index bd74bf5a..8a212be9 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs @@ -1,446 +1,446 @@ -using Crestron.SimplSharpPro; -using System; -using System.Linq; -//using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.DM -{ - using eVst = eX02VideoSourceType; - using eAst = eX02AudioSourceType; - - - [Description("Wrapper class for DM-TX-4K-Z-302-C")] - public class DmTx4kz302CController : DmTxControllerBase, ITxRoutingWithFeedback, - IIROutputPorts, IComPorts - { - public DmTx4kz302C Tx { get; private set; } - - public RoutingInputPortWithVideoStatuses HdmiIn1 { get; private set; } - public RoutingInputPortWithVideoStatuses HdmiIn2 { get; private set; } - public RoutingInputPortWithVideoStatuses DisplayPortIn { get; private set; } - public RoutingOutputPort DmOut { get; private set; } - public RoutingOutputPort HdmiLoopOut { get; private set; } - - public override StringFeedback ActiveVideoInputFeedback { get; protected set; } - public IntFeedback VideoSourceNumericFeedback { get; protected set; } - public IntFeedback AudioSourceNumericFeedback { get; protected set; } - public IntFeedback HdmiIn1HdcpCapabilityFeedback { get; protected set; } - public IntFeedback HdmiIn2HdcpCapabilityFeedback { get; protected set; } - public IntFeedback DisplayPortInHdcpCapabilityFeedback { get; protected set; } - public BoolFeedback Hdmi1VideoSyncFeedback { get; protected set; } - public BoolFeedback Hdmi2VideoSyncFeedback { get; protected set; } - public BoolFeedback DisplayPortVideoSyncFeedback { get; protected set; } - - //public override IntFeedback HdcpSupportAllFeedback { get; protected set; } - //public override ushort HdcpSupportCapability { get; protected set; } - - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - - /// - /// Helps get the "real" inputs, including when in Auto - /// - public eX02VideoSourceType ActualActiveVideoInput - { - get - { - if (Tx.VideoSourceFeedback != eVst.Auto) - return Tx.VideoSourceFeedback; - if (Tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) - return eVst.Hdmi1; - if (Tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) - return eVst.Hdmi2; - - return Tx.DisplayPortInput.SyncDetectedFeedback.BoolValue ? eVst.Vga : eVst.AllDisabled; - } - } - public RoutingPortCollection InputPorts - { - get - { - return new RoutingPortCollection - { - HdmiIn1, - HdmiIn2, - DisplayPortIn, - AnyVideoInput - }; - } - } - public RoutingPortCollection OutputPorts - { - get - { - return new RoutingPortCollection { DmOut, HdmiLoopOut }; - } - } - public DmTx4kz302CController(string key, string name, DmTx4kz302C tx, bool preventRegistration) - : base(key, name, tx) - { - Tx = tx; - PreventRegistration = preventRegistration; - - HdmiIn1 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn1, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi1, this, - VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[1])) - { - FeedbackMatchObject = eVst.Hdmi1 - }; - HdmiIn2 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn2, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi2, this, - VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[2])) - { - FeedbackMatchObject = eVst.Hdmi2 - }; - DisplayPortIn = new RoutingInputPortWithVideoStatuses(DmPortName.DisplayPortIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DisplayPort, eVst.DisplayPort, this, - VideoStatusHelper.GetDisplayPortInputStatusFuncs(tx.DisplayPortInput)) - { - FeedbackMatchObject = eVst.DisplayPort - }; - ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", - () => ActualActiveVideoInput.ToString()); - - Tx.HdmiInputs[1].InputStreamChange += InputStreamChangeEvent; - Tx.HdmiInputs[2].InputStreamChange += InputStreamChangeEvent; - Tx.DisplayPortInput.InputStreamChange += InputStreamChangeEvent; - Tx.BaseEvent += Tx_BaseEvent; - Tx.OnlineStatusChange += Tx_OnlineStatusChange; - - VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); - AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); - - HdmiIn1HdcpCapabilityFeedback = new IntFeedback("HdmiIn1HdcpCapability", () => (int)tx.HdmiInputs[1].HdcpCapabilityFeedback); - - HdmiIn2HdcpCapabilityFeedback = new IntFeedback("HdmiIn2HdcpCapability", () => (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); - DisplayPortInHdcpCapabilityFeedback = new IntFeedback("DisplayPortInHdcpCapability", - () => (int)tx.DisplayPortInput.HdcpCapabilityFeedback); - - - /* - HdcpStateFeedback = - new IntFeedback( - () => - tx.HdmiInputs[1].HdcpCapabilityFeedback > tx.HdmiInputs[2].HdcpCapabilityFeedback - ? (int)tx.HdmiInputs[1].HdcpCapabilityFeedback - : (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); - */ - - //yeah this is gross - but it's the quickest way to do this... - /* - HdcpStateFeedback = new IntFeedback(() => { - var states = new[] {(int) tx.DisplayPortInput.HdcpCapabilityFeedback, (int) tx.HdmiInputs[1].HdcpCapabilityFeedback, (int) tx.HdmiInputs[2].HdcpCapabilityFeedback}; - - return states.Max(); - }); - */ - - HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; - // I feel like we have had this as a misnomer for so long, that it really needed to be fixed - // All we were doing was reporting the best of the current statuses - not the actual capability of the device. - HdcpStateFeedback = new IntFeedback(() => (int)HdcpSupportCapability); - - Hdmi1VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue); - - Hdmi2VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue); - - DisplayPortVideoSyncFeedback = new BoolFeedback(() => (bool)tx.DisplayPortInput.SyncDetectedFeedback.BoolValue); - - var combinedFuncs = new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => - (ActualActiveVideoInput == eVst.Hdmi1 - && tx.HdmiInputs[1].VideoAttributes.HdcpActiveFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.Hdmi2 - && tx.HdmiInputs[2].VideoAttributes.HdcpActiveFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.DisplayPort - && tx.DisplayPortInput.VideoAttributes.HdcpActiveFeedback.BoolValue), - - HdcpStateFeedbackFunc = () => - { - if (ActualActiveVideoInput == eVst.Hdmi1) - return tx.HdmiInputs[1].VideoAttributes.HdcpStateFeedback.ToString(); - if (ActualActiveVideoInput == eVst.Hdmi2) - return tx.HdmiInputs[2].VideoAttributes.HdcpStateFeedback.ToString(); - return ActualActiveVideoInput == eVst.DisplayPort - ? tx.DisplayPortInput.VideoAttributes.HdcpStateFeedback.ToString() - : ""; - }, - - VideoResolutionFeedbackFunc = () => - { - if (ActualActiveVideoInput == eVst.Hdmi1) - return tx.HdmiInputs[1].VideoAttributes.GetVideoResolutionString(); - if (ActualActiveVideoInput == eVst.Hdmi2) - return tx.HdmiInputs[2].VideoAttributes.GetVideoResolutionString(); - if (ActualActiveVideoInput == eVst.DisplayPort) - return tx.DisplayPortInput.VideoAttributes.GetVideoResolutionString(); - return ActualActiveVideoInput == eVst.Vga ? tx.DisplayPortInput.VideoAttributes.GetVideoResolutionString() : ""; - }, - VideoSyncFeedbackFunc = () => - (ActualActiveVideoInput == eVst.Hdmi1 - && tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.Hdmi2 - && tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.DisplayPort - && tx.DisplayPortInput.SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.Vga - && tx.DisplayPortInput.SyncDetectedFeedback.BoolValue) - - }; - - AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); - - DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmCat, null, this); - HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null, this); - - - AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, - AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, - AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, - AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiIn1HdcpCapabilityFeedback, HdmiIn2HdcpCapabilityFeedback, - Hdmi1VideoSyncFeedback, Hdmi2VideoSyncFeedback, DisplayPortVideoSyncFeedback, DisplayPortInHdcpCapabilityFeedback); - - HdmiIn1.Port = Tx.HdmiInputs[1]; - HdmiIn2.Port = Tx.HdmiInputs[2]; - DisplayPortIn.Port = Tx.DisplayPortInput; - HdmiLoopOut.Port = Tx.HdmiOutput; - DmOut.Port = Tx.DmOutput; - } - - - public override bool CustomActivate() - { - // Link up all of these damned events to the various RoutingPorts via a helper handler - Tx.HdmiInputs[1].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn1, a.EventId); - Tx.HdmiInputs[1].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn1, a.EventId); - - Tx.HdmiInputs[2].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn2, a.EventId); - Tx.HdmiInputs[2].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn2, a.EventId); - - Tx.DisplayPortInput.InputStreamChange += (o, a) => FowardInputStreamChange(DisplayPortIn, a.EventId); - Tx.DisplayPortInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(DisplayPortIn, a.EventId); - - // Base does register and sets up comm monitoring. - return base.CustomActivate(); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); - - if (Hdmi1VideoSyncFeedback != null) - { - Hdmi1VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); - } - if (Hdmi2VideoSyncFeedback != null) - { - Hdmi2VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); - } - if (DisplayPortVideoSyncFeedback != null) - { - DisplayPortVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input3VideoSyncStatus.JoinNumber]); - } - - LinkDmTxToApi(this, trilist, joinMap, bridge); - } - - public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) - { - Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); - - switch (input) - { - case 0: - { - ExecuteSwitch(eVst.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(HdmiIn1.Selector, null, type); - break; - } - case 2: - { - ExecuteSwitch(HdmiIn2.Selector, null, type); - break; - } - case 3: - { - ExecuteSwitch(DisplayPortIn.Selector, null, type); - break; - } - case 4: - { - ExecuteSwitch(eVst.AllDisabled, null, type); - break; - } - default: - { - Debug.Console(2, this, "Unable to execute numeric switch to input {0}", input); - break; - } - - } - - - } - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - try - { - Debug.Console(2, this, "Attempting to switch InputSelector {0}", ((eVst)inputSelector).ToString()); - if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) - Tx.VideoSource = (eVst)inputSelector; - - // NOTE: It's possible that this particular TX model may not like the AudioSource property being set. - // The SIMPL definition only shows a single analog for AudioVideo Source - if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - //it doesn't - Debug.Console(2, this, "Unable to execute audio-only switch for tx {0}", Key); - //Tx.AudioSource = (eAst)inputSelector; - } - catch (Exception e) - { - Debug.Console(2, this, "Exception in ExecuteSwitch: {0}", e); - } - } - - void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - Debug.Console(2, "{0} event {1} stream {2}", Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); - - switch (args.EventId) - { - case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: - case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: - case EndpointInputStreamEventIds.HdcpCapabilityFeedbackEventId: - if (inputStream == Tx.HdmiInputs[1]) HdmiIn1HdcpCapabilityFeedback.FireUpdate(); - if (inputStream == Tx.HdmiInputs[2]) HdmiIn2HdcpCapabilityFeedback.FireUpdate(); - if (inputStream == Tx.DisplayPortInput) DisplayPortInHdcpCapabilityFeedback.FireUpdate(); - - Debug.Console(2, this, "DisplayPortHDCP Mode Trigger = {0}", - DisplayPortInHdcpCapabilityFeedback.IntValue); - - HdcpStateFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - if (inputStream == Tx.HdmiInputs[1]) Hdmi1VideoSyncFeedback.FireUpdate(); - if (inputStream == Tx.HdmiInputs[2]) Hdmi2VideoSyncFeedback.FireUpdate(); - if (inputStream == Tx.DisplayPortInput) DisplayPortVideoSyncFeedback.FireUpdate(); - break; - } - } - - void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) - { - var localVideoInputPort = - InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - var localAudioInputPort = - InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - - ActiveVideoInputFeedback.FireUpdate(); - VideoSourceNumericFeedback.FireUpdate(); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); - } - - - void Tx_BaseEvent(GenericBase device, BaseEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case EndpointTransmitterBase.VideoSourceFeedbackEventId: - var localVideoInputPort = InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); - VideoSourceNumericFeedback.FireUpdate(); - ActiveVideoInputFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - break; - case EndpointTransmitterBase.AudioSourceFeedbackEventId: - var localInputAudioPort = InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - Debug.Console(2, this, " Audio Source: {0}", Tx.VideoSourceFeedback); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); - break; - } - } - - /// - /// Relays the input stream change to the appropriate RoutingInputPort. - /// - void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) return; - inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); - } - - /// - /// Relays the VideoAttributes change to a RoutingInputPort - /// - void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds - //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", - // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); - switch (eventId) - { - case VideoAttributeEventIds.HdcpActiveFeedbackEventId: - inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HdcpStateFeedbackEventId: - inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: - case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - } - } - - #region IIROutputPorts Members - public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } - public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } - #endregion - - #region IComPorts Members - public CrestronCollection ComPorts { get { return Tx.ComPorts; } } - public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } } - #endregion - } +using Crestron.SimplSharpPro; +using System; +using System.Linq; +//using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; + +namespace PepperDash.Essentials.DM +{ + using eVst = eX02VideoSourceType; + using eAst = eX02AudioSourceType; + + + [Description("Wrapper class for DM-TX-4K-Z-302-C")] + public class DmTx4kz302CController : DmTxControllerBase, ITxRoutingWithFeedback, + IIROutputPorts, IComPorts + { + public DmTx4kz302C Tx { get; private set; } + + public RoutingInputPortWithVideoStatuses HdmiIn1 { get; private set; } + public RoutingInputPortWithVideoStatuses HdmiIn2 { get; private set; } + public RoutingInputPortWithVideoStatuses DisplayPortIn { get; private set; } + public RoutingOutputPort DmOut { get; private set; } + public RoutingOutputPort HdmiLoopOut { get; private set; } + + public override StringFeedback ActiveVideoInputFeedback { get; protected set; } + public IntFeedback VideoSourceNumericFeedback { get; protected set; } + public IntFeedback AudioSourceNumericFeedback { get; protected set; } + public IntFeedback HdmiIn1HdcpCapabilityFeedback { get; protected set; } + public IntFeedback HdmiIn2HdcpCapabilityFeedback { get; protected set; } + public IntFeedback DisplayPortInHdcpCapabilityFeedback { get; protected set; } + public BoolFeedback Hdmi1VideoSyncFeedback { get; protected set; } + public BoolFeedback Hdmi2VideoSyncFeedback { get; protected set; } + public BoolFeedback DisplayPortVideoSyncFeedback { get; protected set; } + + //public override IntFeedback HdcpSupportAllFeedback { get; protected set; } + //public override ushort HdcpSupportCapability { get; protected set; } + + //IroutingNumericEvent + public event EventHandler NumericSwitchChange; + + /// + /// Raise an event when the status of a switch object changes. + /// + /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType + private void OnSwitchChange(RoutingNumericEventArgs e) + { + var newEvent = NumericSwitchChange; + if (newEvent != null) newEvent(this, e); + } + + /// + /// Helps get the "real" inputs, including when in Auto + /// + public eX02VideoSourceType ActualActiveVideoInput + { + get + { + if (Tx.VideoSourceFeedback != eVst.Auto) + return Tx.VideoSourceFeedback; + if (Tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) + return eVst.Hdmi1; + if (Tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) + return eVst.Hdmi2; + + return Tx.DisplayPortInput.SyncDetectedFeedback.BoolValue ? eVst.Vga : eVst.AllDisabled; + } + } + public RoutingPortCollection InputPorts + { + get + { + return new RoutingPortCollection + { + HdmiIn1, + HdmiIn2, + DisplayPortIn, + AnyVideoInput + }; + } + } + public RoutingPortCollection OutputPorts + { + get + { + return new RoutingPortCollection { DmOut, HdmiLoopOut }; + } + } + public DmTx4kz302CController(string key, string name, DmTx4kz302C tx, bool preventRegistration) + : base(key, name, tx) + { + Tx = tx; + PreventRegistration = preventRegistration; + + HdmiIn1 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn1, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi1, this, + VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[1])) + { + FeedbackMatchObject = eVst.Hdmi1 + }; + HdmiIn2 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn2, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi2, this, + VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[2])) + { + FeedbackMatchObject = eVst.Hdmi2 + }; + DisplayPortIn = new RoutingInputPortWithVideoStatuses(DmPortName.DisplayPortIn, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DisplayPort, eVst.DisplayPort, this, + VideoStatusHelper.GetDisplayPortInputStatusFuncs(tx.DisplayPortInput)) + { + FeedbackMatchObject = eVst.DisplayPort + }; + ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", + () => ActualActiveVideoInput.ToString()); + + Tx.HdmiInputs[1].InputStreamChange += InputStreamChangeEvent; + Tx.HdmiInputs[2].InputStreamChange += InputStreamChangeEvent; + Tx.DisplayPortInput.InputStreamChange += InputStreamChangeEvent; + Tx.BaseEvent += Tx_BaseEvent; + Tx.OnlineStatusChange += Tx_OnlineStatusChange; + + VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); + AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); + + HdmiIn1HdcpCapabilityFeedback = new IntFeedback("HdmiIn1HdcpCapability", () => (int)tx.HdmiInputs[1].HdcpCapabilityFeedback); + + HdmiIn2HdcpCapabilityFeedback = new IntFeedback("HdmiIn2HdcpCapability", () => (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); + DisplayPortInHdcpCapabilityFeedback = new IntFeedback("DisplayPortInHdcpCapability", + () => (int)tx.DisplayPortInput.HdcpCapabilityFeedback); + + + /* + HdcpStateFeedback = + new IntFeedback( + () => + tx.HdmiInputs[1].HdcpCapabilityFeedback > tx.HdmiInputs[2].HdcpCapabilityFeedback + ? (int)tx.HdmiInputs[1].HdcpCapabilityFeedback + : (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); + */ + + //yeah this is gross - but it's the quickest way to do this... + /* + HdcpStateFeedback = new IntFeedback(() => { + var states = new[] {(int) tx.DisplayPortInput.HdcpCapabilityFeedback, (int) tx.HdmiInputs[1].HdcpCapabilityFeedback, (int) tx.HdmiInputs[2].HdcpCapabilityFeedback}; + + return states.Max(); + }); + */ + + HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; + // I feel like we have had this as a misnomer for so long, that it really needed to be fixed + // All we were doing was reporting the best of the current statuses - not the actual capability of the device. + HdcpStateFeedback = new IntFeedback(() => (int)HdcpSupportCapability); + + Hdmi1VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue); + + Hdmi2VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue); + + DisplayPortVideoSyncFeedback = new BoolFeedback(() => (bool)tx.DisplayPortInput.SyncDetectedFeedback.BoolValue); + + var combinedFuncs = new VideoStatusFuncsWrapper + { + HdcpActiveFeedbackFunc = () => + (ActualActiveVideoInput == eVst.Hdmi1 + && tx.HdmiInputs[1].VideoAttributes.HdcpActiveFeedback.BoolValue) + || (ActualActiveVideoInput == eVst.Hdmi2 + && tx.HdmiInputs[2].VideoAttributes.HdcpActiveFeedback.BoolValue) + || (ActualActiveVideoInput == eVst.DisplayPort + && tx.DisplayPortInput.VideoAttributes.HdcpActiveFeedback.BoolValue), + + HdcpStateFeedbackFunc = () => + { + if (ActualActiveVideoInput == eVst.Hdmi1) + return tx.HdmiInputs[1].VideoAttributes.HdcpStateFeedback.ToString(); + if (ActualActiveVideoInput == eVst.Hdmi2) + return tx.HdmiInputs[2].VideoAttributes.HdcpStateFeedback.ToString(); + return ActualActiveVideoInput == eVst.DisplayPort + ? tx.DisplayPortInput.VideoAttributes.HdcpStateFeedback.ToString() + : ""; + }, + + VideoResolutionFeedbackFunc = () => + { + if (ActualActiveVideoInput == eVst.Hdmi1) + return tx.HdmiInputs[1].VideoAttributes.GetVideoResolutionString(); + if (ActualActiveVideoInput == eVst.Hdmi2) + return tx.HdmiInputs[2].VideoAttributes.GetVideoResolutionString(); + if (ActualActiveVideoInput == eVst.DisplayPort) + return tx.DisplayPortInput.VideoAttributes.GetVideoResolutionString(); + return ActualActiveVideoInput == eVst.Vga ? tx.DisplayPortInput.VideoAttributes.GetVideoResolutionString() : ""; + }, + VideoSyncFeedbackFunc = () => + (ActualActiveVideoInput == eVst.Hdmi1 + && tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) + || (ActualActiveVideoInput == eVst.Hdmi2 + && tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) + || (ActualActiveVideoInput == eVst.DisplayPort + && tx.DisplayPortInput.SyncDetectedFeedback.BoolValue) + || (ActualActiveVideoInput == eVst.Vga + && tx.DisplayPortInput.SyncDetectedFeedback.BoolValue) + + }; + + AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); + + DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.DmCat, null, this); + HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, null, this); + + + AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, + AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, + AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, + AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiIn1HdcpCapabilityFeedback, HdmiIn2HdcpCapabilityFeedback, + Hdmi1VideoSyncFeedback, Hdmi2VideoSyncFeedback, DisplayPortVideoSyncFeedback, DisplayPortInHdcpCapabilityFeedback); + + HdmiIn1.Port = Tx.HdmiInputs[1]; + HdmiIn2.Port = Tx.HdmiInputs[2]; + DisplayPortIn.Port = Tx.DisplayPortInput; + HdmiLoopOut.Port = Tx.HdmiOutput; + DmOut.Port = Tx.DmOutput; + } + + + public override bool CustomActivate() + { + // Link up all of these damned events to the various RoutingPorts via a helper handler + Tx.HdmiInputs[1].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn1, a.EventId); + Tx.HdmiInputs[1].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn1, a.EventId); + + Tx.HdmiInputs[2].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn2, a.EventId); + Tx.HdmiInputs[2].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn2, a.EventId); + + Tx.DisplayPortInput.InputStreamChange += (o, a) => FowardInputStreamChange(DisplayPortIn, a.EventId); + Tx.DisplayPortInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(DisplayPortIn, a.EventId); + + // Base does register and sets up comm monitoring. + return base.CustomActivate(); + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); + + if (Hdmi1VideoSyncFeedback != null) + { + Hdmi1VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); + } + if (Hdmi2VideoSyncFeedback != null) + { + Hdmi2VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); + } + if (DisplayPortVideoSyncFeedback != null) + { + DisplayPortVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input3VideoSyncStatus.JoinNumber]); + } + + LinkDmTxToApi(this, trilist, joinMap, bridge); + } + + public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) + { + Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); + + switch (input) + { + case 0: + { + ExecuteSwitch(eVst.Auto, null, type); + break; + } + case 1: + { + ExecuteSwitch(HdmiIn1.Selector, null, type); + break; + } + case 2: + { + ExecuteSwitch(HdmiIn2.Selector, null, type); + break; + } + case 3: + { + ExecuteSwitch(DisplayPortIn.Selector, null, type); + break; + } + case 4: + { + ExecuteSwitch(eVst.AllDisabled, null, type); + break; + } + default: + { + Debug.Console(2, this, "Unable to execute numeric switch to input {0}", input); + break; + } + + } + + + } + + public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) + { + try + { + Debug.Console(2, this, "Attempting to switch InputSelector {0}", ((eVst)inputSelector).ToString()); + if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) + Tx.VideoSource = (eVst)inputSelector; + + // NOTE: It's possible that this particular TX model may not like the AudioSource property being set. + // The SIMPL definition only shows a single analog for AudioVideo Source + if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) + //it doesn't + Debug.Console(2, this, "Unable to execute audio-only switch for tx {0}", Key); + //Tx.AudioSource = (eAst)inputSelector; + } + catch (Exception e) + { + Debug.Console(2, this, "Exception in ExecuteSwitch: {0}", e); + } + } + + void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) + { + Debug.Console(2, "{0} event {1} stream {2}", Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); + + switch (args.EventId) + { + case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: + case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: + case EndpointInputStreamEventIds.HdcpCapabilityFeedbackEventId: + if (inputStream == Tx.HdmiInputs[1]) HdmiIn1HdcpCapabilityFeedback.FireUpdate(); + if (inputStream == Tx.HdmiInputs[2]) HdmiIn2HdcpCapabilityFeedback.FireUpdate(); + if (inputStream == Tx.DisplayPortInput) DisplayPortInHdcpCapabilityFeedback.FireUpdate(); + + Debug.Console(2, this, "DisplayPortHDCP Mode Trigger = {0}", + DisplayPortInHdcpCapabilityFeedback.IntValue); + + HdcpStateFeedback.FireUpdate(); + break; + case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: + if (inputStream == Tx.HdmiInputs[1]) Hdmi1VideoSyncFeedback.FireUpdate(); + if (inputStream == Tx.HdmiInputs[2]) Hdmi2VideoSyncFeedback.FireUpdate(); + if (inputStream == Tx.DisplayPortInput) DisplayPortVideoSyncFeedback.FireUpdate(); + break; + } + } + + void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) + { + var localVideoInputPort = + InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); + var localAudioInputPort = + InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); + + ActiveVideoInputFeedback.FireUpdate(); + VideoSourceNumericFeedback.FireUpdate(); + AudioSourceNumericFeedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); + OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); + } + + + void Tx_BaseEvent(GenericBase device, BaseEventArgs args) + { + var id = args.EventId; + Debug.Console(2, this, "EventId {0}", args.EventId); + + switch (id) + { + case EndpointTransmitterBase.VideoSourceFeedbackEventId: + var localVideoInputPort = InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); + Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); + VideoSourceNumericFeedback.FireUpdate(); + ActiveVideoInputFeedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); + break; + case EndpointTransmitterBase.AudioSourceFeedbackEventId: + var localInputAudioPort = InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); + Debug.Console(2, this, " Audio Source: {0}", Tx.VideoSourceFeedback); + AudioSourceNumericFeedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); + break; + } + } + + /// + /// Relays the input stream change to the appropriate RoutingInputPort. + /// + void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { + if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) return; + inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); + } + + /// + /// Relays the VideoAttributes change to a RoutingInputPort + /// + void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { + //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds + //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", + // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); + switch (eventId) + { + case VideoAttributeEventIds.HdcpActiveFeedbackEventId: + inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HdcpStateFeedbackEventId: + inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: + case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; + } + } + + #region IIROutputPorts Members + public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } + public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } + #endregion + + #region IComPorts Members + public CrestronCollection ComPorts { get { return Tx.ComPorts; } } + public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } } + #endregion + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/HDBaseTTxController.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/HDBaseTTxController.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/HDBaseTTxController.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/HDBaseTTxController.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/TxInterfaces.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/TxInterfaces.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/TxInterfaces.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/TxInterfaces.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj b/src/essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj rename to src/essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj diff --git a/essentials-framework/Essentials DM/Essentials_DM/Extensions.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Extensions.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Extensions.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Extensions.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/IDmHdmiInputExtensions.cs b/src/essentials-framework/Essentials DM/Essentials_DM/IDmHdmiInputExtensions.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/IDmHdmiInputExtensions.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/IDmHdmiInputExtensions.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/IDmSwitch.cs b/src/essentials-framework/Essentials DM/Essentials_DM/IDmSwitch.cs similarity index 96% rename from essentials-framework/Essentials DM/Essentials_DM/IDmSwitch.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/IDmSwitch.cs index cf3f963e..8f1af55e 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/IDmSwitch.cs +++ b/src/essentials-framework/Essentials DM/Essentials_DM/IDmSwitch.cs @@ -1,32 +1,32 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Cards; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Receivers; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -//using PepperDash.Essentials.DM.Cards; - -using PepperDash.Essentials.DM.Config; - -namespace PepperDash.Essentials.DM { - public interface IDmSwitch - { - Switch Chassis { get; } - - Dictionary TxDictionary { get; } - Dictionary RxDictionary { get; } - } - - public interface IDmSwitchWithEndpointOnlineFeedback : IDmSwitch - { - Dictionary InputEndpointOnlineFeedbacks { get; } - Dictionary OutputEndpointOnlineFeedbacks { get; } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Cards; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Receivers; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +//using PepperDash.Essentials.DM.Cards; + +using PepperDash.Essentials.DM.Config; + +namespace PepperDash.Essentials.DM { + public interface IDmSwitch + { + Switch Chassis { get; } + + Dictionary TxDictionary { get; } + Dictionary RxDictionary { get; } + } + + public interface IDmSwitchWithEndpointOnlineFeedback : IDmSwitch + { + Dictionary InputEndpointOnlineFeedbacks { get; } + Dictionary OutputEndpointOnlineFeedbacks { get; } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj b/src/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj similarity index 98% rename from essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj rename to src/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj index 41136d0d..08070da2 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj +++ b/src/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj @@ -1,177 +1,177 @@ - - - Release - AnyCPU - 9.0.30729 - 2.0 - {9199CE8A-0C9F-4952-8672-3EED798B284F} - Library - Properties - PepperDash_Essentials_DM - PepperDash_Essentials_DM - {0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - WindowsCE - E2BECB1F-8C8C-41ba-B736-9BE7D946A398 - 5.0 - SmartDeviceProject1 - v3.5 - Windows CE - - - - - .allowedReferenceRelatedFileExtensions - true - full - false - bin\ - DEBUG;TRACE; - prompt - 4 - 512 - true - true - off - - - .allowedReferenceRelatedFileExtensions - none - true - bin\ - prompt - 4 - 512 - true - true - off - - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DM.dll - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll - - - - False - ..\..\..\packages\PepperDashCore\lib\net35\PepperDash_Core.dll - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll - False - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll - False - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe - False - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} - PepperDash_Essentials_Core - - - - - - - - - rem S# Pro preparation will execute after these operations - + + + Release + AnyCPU + 9.0.30729 + 2.0 + {9199CE8A-0C9F-4952-8672-3EED798B284F} + Library + Properties + PepperDash_Essentials_DM + PepperDash_Essentials_DM + {0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + WindowsCE + E2BECB1F-8C8C-41ba-B736-9BE7D946A398 + 5.0 + SmartDeviceProject1 + v3.5 + Windows CE + + + + + .allowedReferenceRelatedFileExtensions + true + full + false + bin\ + DEBUG;TRACE; + prompt + 4 + 512 + true + true + off + + + .allowedReferenceRelatedFileExtensions + none + true + bin\ + prompt + 4 + 512 + true + true + off + + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DM.dll + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll + + + + False + ..\..\..\packages\PepperDashCore\lib\net35\PepperDash_Core.dll + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll + False + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll + False + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe + False + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} + PepperDash_Essentials_Core + + + + + + + + + rem S# Pro preparation will execute after these operations + \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Properties/AssemblyInfo.cs b/src/essentials-framework/Essentials DM/Essentials_DM/Properties/AssemblyInfo.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Properties/AssemblyInfo.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/Properties/AssemblyInfo.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Properties/ControlSystem.cfg b/src/essentials-framework/Essentials DM/Essentials_DM/Properties/ControlSystem.cfg similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/Properties/ControlSystem.cfg rename to src/essentials-framework/Essentials DM/Essentials_DM/Properties/ControlSystem.cfg diff --git a/essentials-framework/Essentials DM/Essentials_DM/VideoStatusHelpers.cs b/src/essentials-framework/Essentials DM/Essentials_DM/VideoStatusHelpers.cs similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/VideoStatusHelpers.cs rename to src/essentials-framework/Essentials DM/Essentials_DM/VideoStatusHelpers.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/app.config b/src/essentials-framework/Essentials DM/Essentials_DM/app.config similarity index 100% rename from essentials-framework/Essentials DM/Essentials_DM/app.config rename to src/essentials-framework/Essentials DM/Essentials_DM/app.config diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common.sln b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common.sln similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common.sln rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common.sln diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Audio/GenericAudioOut.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Audio/GenericAudioOut.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Audio/GenericAudioOut.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Audio/GenericAudioOut.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/AudioCodecBase.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/AudioCodecBase.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/AudioCodecBase.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/AudioCodecBase.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/Interfaces/IAudioCodecInfo.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/Interfaces/IAudioCodecInfo.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/Interfaces/IAudioCodecInfo.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/Interfaces/IAudioCodecInfo.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/Interfaces/IHasAudioCodec.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/Interfaces/IHasAudioCodec.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/Interfaces/IHasAudioCodec.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/Interfaces/IHasAudioCodec.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/MockAC/MockAC.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/MockAC/MockAC.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/MockAC/MockAC.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/MockAC/MockAC.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/MockAC/MockAcPropertiesConfig.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/MockAC/MockAcPropertiesConfig.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/MockAC/MockAcPropertiesConfig.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/MockAC/MockAcPropertiesConfig.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraBase.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraBase.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraBase.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraBase.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraControl.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraControl.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraControl.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraControl.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraVisca.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraVisca.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraVisca.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraVisca.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/IHasCameraPresets.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/IHasCameraPresets.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/IHasCameraPresets.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/IHasCameraPresets.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/ClassDiagram1.cd b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/ClassDiagram1.cd similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/ClassDiagram1.cd rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/ClassDiagram1.cd diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/CodecActiveCallItem.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/CodecActiveCallItem.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/CodecActiveCallItem.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/CodecActiveCallItem.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/CodecActiveCallItem.cs.orig b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/CodecActiveCallItem.cs.orig similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/CodecActiveCallItem.cs.orig rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/CodecActiveCallItem.cs.orig diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/IHasCallHold.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/IHasCallHold.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/IHasCallHold.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/IHasCallHold.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/IHasDoNotDisturb.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/IHasDoNotDisturb.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/IHasDoNotDisturb.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/IHasDoNotDisturb.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/IHasExternalSourceSwitching.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/IHasExternalSourceSwitching.cs similarity index 97% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/IHasExternalSourceSwitching.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/IHasExternalSourceSwitching.cs index f8ef33ee..1ea6b09b 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/IHasExternalSourceSwitching.cs +++ b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/IHasExternalSourceSwitching.cs @@ -1,22 +1,22 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Devices.Common.VideoCodec.Cisco; - -namespace PepperDash.Essentials.Devices.Common.Codec -{ - public interface IHasExternalSourceSwitching - { - bool ExternalSourceListEnabled { get; } - string ExternalSourceInputPort { get; } - void AddExternalSource(string connectorId, string key, string name, eExternalSourceType type); - void SetExternalSourceState(string key, eExternalSourceMode mode); - void ClearExternalSources(); - void SetSelectedSource(string key); - Action RunRouteAction { set;} - } - +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Devices.Common.VideoCodec.Cisco; + +namespace PepperDash.Essentials.Devices.Common.Codec +{ + public interface IHasExternalSourceSwitching + { + bool ExternalSourceListEnabled { get; } + string ExternalSourceInputPort { get; } + void AddExternalSource(string connectorId, string key, string name, eExternalSourceType type); + void SetExternalSourceState(string key, eExternalSourceMode mode); + void ClearExternalSources(); + void SetSelectedSource(string key); + Action RunRouteAction { set;} + } + } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/eCodecCallDirection.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/eCodecCallDirection.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/eCodecCallDirection.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/eCodecCallDirection.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/eCodecCallStatus.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/eCodecCallStatus.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/eCodecCallStatus.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/eCodecCallStatus.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/eCodecCallType.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/eCodecCallType.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/eCodecCallType.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/eCodecCallType.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/eMeetingPrivacy.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/eMeetingPrivacy.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/eMeetingPrivacy.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/eMeetingPrivacy.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iCodecAudio.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iCodecAudio.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iCodecAudio.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iCodecAudio.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasCallFavorites.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasCallFavorites.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasCallFavorites.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasCallFavorites.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasCallHistory.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasCallHistory.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasCallHistory.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasCallHistory.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasContentSharing.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasContentSharing.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasContentSharing.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasContentSharing.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasDialer.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasDialer.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasDialer.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasDialer.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasDirectory.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasDirectory.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasDirectory.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasDirectory.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasScheduleAwareness.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasScheduleAwareness.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasScheduleAwareness.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasScheduleAwareness.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDsp.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDsp.cs similarity index 97% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDsp.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDsp.cs index a171b672..f8a102df 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDsp.cs +++ b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDsp.cs @@ -6,391 +6,391 @@ using Crestron.SimplSharp; using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; -using System.Text.RegularExpressions; - - -namespace PepperDash.Essentials.Devices.Common.DSP -{ - - // QUESTIONS: - // - // When subscribing, just use the Instance ID for Custom Name? - - // Verbose on subscriptions? - - // Example subscription feedback responses - // ! "publishToken":"name" "value":-77.0 - // ! "myLevelName" -77 - - public class BiampTesiraForteDsp : DspBase - { - public IBasicCommunication Communication { get; private set; } - public CommunicationGather PortGather { get; private set; } - public StatusMonitorBase CommunicationMonitor { get; private set; } - - public new Dictionary LevelControlPoints { get; private set; } - - public bool isSubscribed; - - private CTimer SubscriptionTimer; - - private CrestronQueue CommandQueue; - - private bool CommandQueueInProgress = false; - - //new public Dictionary DialerControlPoints { get; private set; } - - //new public Dictionary SwitcherControlPoints { get; private set; } - - /// - /// Shows received lines as hex - /// - public bool ShowHexResponse { get; set; } - - public BiampTesiraForteDsp(string key, string name, IBasicCommunication comm, - BiampTesiraFortePropertiesConfig props) : - base(key, name) - { - CommandQueue = new CrestronQueue(100); - - Communication = comm; - var socket = comm as ISocketStatus; - if (socket != null) - { - // This instance uses IP control - - socket.ConnectionChange += new EventHandler(socket_ConnectionChange); - } - else - { - // This instance uses RS-232 control - } - PortGather = new CommunicationGather(Communication, "\x0d\x0a"); - PortGather.LineReceived += this.Port_LineReceived; - if (props.CommunicationMonitorProperties != null) - { - CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, - props.CommunicationMonitorProperties); - } - else - { -//#warning Need to deal with this poll string - CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 120000, 120000, 300000, - "SESSION get aliases\x0d\x0a"); - } - - LevelControlPoints = new Dictionary(); - - foreach (KeyValuePair block in props.LevelControlBlocks) - { - this.LevelControlPoints.Add(block.Key, new TesiraForteLevelControl(block.Key, block.Value, this)); - } - - } - - public override bool CustomActivate() - { - Communication.Connect(); - CommunicationMonitor.StatusChange += - (o, a) => { Debug.Console(2, this, "Communication monitor state: {0}", CommunicationMonitor.Status); }; - CommunicationMonitor.Start(); - - CrestronConsole.AddNewConsoleCommand(SendLine, "send" + Key, "", ConsoleAccessLevelEnum.AccessOperator); - CrestronConsole.AddNewConsoleCommand(s => Communication.Connect(), "con" + Key, "", - ConsoleAccessLevelEnum.AccessOperator); - return true; - } - - private void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e) - { - Debug.Console(2, this, "Socket Status Change: {0}", e.Client.ClientStatus.ToString()); - - if (e.Client.IsConnected) - { - // Tasks on connect - } - else - { - // Cleanup items from this session - - if (SubscriptionTimer != null) - { - SubscriptionTimer.Stop(); - SubscriptionTimer = null; - } - - isSubscribed = false; - CommandQueue.Clear(); - CommandQueueInProgress = false; - } - } - - /// - /// Initiates the subscription process to the DSP - /// - private void SubscribeToAttributes() - { - SendLine("SESSION set verbose true"); - - foreach (KeyValuePair level in LevelControlPoints) - { - level.Value.Subscribe(); - } - - if (!CommandQueueInProgress) - SendNextQueuedCommand(); - - ResetSubscriptionTimer(); - } - - /// - /// Resets or Sets the subscription timer - /// - private void ResetSubscriptionTimer() - { - isSubscribed = true; - - if (SubscriptionTimer != null) - { - SubscriptionTimer = new CTimer(o => SubscribeToAttributes(), 30000); - SubscriptionTimer.Reset(); - - } - } - - /// - /// Handles a response message from the DSP - /// - /// - /// - private void Port_LineReceived(object dev, GenericCommMethodReceiveTextArgs args) - { - try - { - if (args.Text.IndexOf("Welcome to the Tesira Text Protocol Server...") > -1) - { - // Indicates a new TTP session - - SubscribeToAttributes(); - } - else if (args.Text.IndexOf("publishToken") > -1) - { - // response is from a subscribed attribute - - string pattern = "! \"publishToken\":[\"](.*)[\"] \"value\":(.*)"; - - Match match = Regex.Match(args.Text, pattern); - - if (match.Success) - { - - string key; - - string customName; - - string value; - - customName = match.Groups[1].Value; - - // Finds the key (everything before the '~' character - key = customName.Substring(0, customName.IndexOf("~", 0) - 1); - - value = match.Groups[2].Value; - - foreach (KeyValuePair controlPoint in LevelControlPoints) - { - if (customName == controlPoint.Value.LevelCustomName || - customName == controlPoint.Value.MuteCustomName) - { - controlPoint.Value.ParseSubscriptionMessage(customName, value); - return; - } - - } - } - - /// same for dialers - /// same for switchers - - } - else if (args.Text.IndexOf("+OK") > -1) - { - if (args.Text == "+OK" || args.Text.IndexOf("list\":") > -1) - // Check for a simple "+OK" only 'ack' repsonse or a list response and ignore - return; - - // response is not from a subscribed attribute. From a get/set/toggle/increment/decrement command - - if (!CommandQueue.IsEmpty) - { - if (CommandQueue.Peek() is QueuedCommand) - { - // Expected response belongs to a child class - QueuedCommand tempCommand = (QueuedCommand) CommandQueue.TryToDequeue(); - //Debug.Console(1, this, "Command Dequeued. CommandQueue Size: {0}", CommandQueue.Count); - - tempCommand.ControlPoint.ParseGetMessage(tempCommand.AttributeCode, args.Text); - } - else - { - // Expected response belongs to this class - string temp = (string) CommandQueue.TryToDequeue(); - //Debug.Console(1, this, "Command Dequeued. CommandQueue Size: {0}", CommandQueue.Count); - - } - - if (CommandQueue.IsEmpty) - CommandQueueInProgress = false; - else - SendNextQueuedCommand(); - - } - - - } - else if (args.Text.IndexOf("-ERR") > -1) - { - // Error response - - switch (args.Text) - { - case "-ERR ALREADY_SUBSCRIBED": - { - ResetSubscriptionTimer(); - break; - } - default: - { - Debug.Console(0, this, "Error From DSP: '{0}'", args.Text); - break; - } - } - - } - } - catch (Exception e) - { - if (Debug.Level == 2) - Debug.Console(2, this, "Error parsing response: '{0}'\n{1}", args.Text, e); - } - - } - - /// - /// Sends a command to the DSP (with delimiter appended) - /// - /// Command to send - public void SendLine(string s) - { - Communication.SendText(s + "\x0a"); - } - - /// - /// Adds a command from a child module to the queue - /// - /// Command object from child module - public void EnqueueCommand(QueuedCommand commandToEnqueue) - { - CommandQueue.Enqueue(commandToEnqueue); - //Debug.Console(1, this, "Command (QueuedCommand) Enqueued '{0}'. CommandQueue has '{1}' Elements.", commandToEnqueue.Command, CommandQueue.Count); - - if (!CommandQueueInProgress) - SendNextQueuedCommand(); - } - - - /// - /// Adds a raw string command to the queue - /// - /// - public void EnqueueCommand(string command) - { - CommandQueue.Enqueue(command); - //Debug.Console(1, this, "Command (string) Enqueued '{0}'. CommandQueue has '{1}' Elements.", command, CommandQueue.Count); - - if (!CommandQueueInProgress) - SendNextQueuedCommand(); - } - - /// - /// Sends the next queued command to the DSP - /// - private void SendNextQueuedCommand() - { - //Debug.Console(2, this, "Attempting to send next queued command. CommandQueueInProgress: {0} Communication isConnected: {1}", CommandQueueInProgress, Communication.IsConnected); - - //if (CommandQueue.IsEmpty) - // CommandQueueInProgress = false; - - //Debug.Console(1, this, "CommandQueue has {0} Elements:\n", CommandQueue.Count); - - //foreach (object o in CommandQueue) - //{ - // if (o is string) - // Debug.Console(1, this, "{0}", o); - // else if(o is QueuedCommand) - // { - // var item = (QueuedCommand)o; - // Debug.Console(1, this, "{0}", item.Command); - // } - //} - - //Debug.Console(1, this, "End of CommandQueue"); - - if (Communication.IsConnected && !CommandQueue.IsEmpty) - { - CommandQueueInProgress = true; - - if (CommandQueue.Peek() is QueuedCommand) - { - QueuedCommand nextCommand = new QueuedCommand(); - - nextCommand = (QueuedCommand) CommandQueue.Peek(); - - SendLine(nextCommand.Command); - } - else - { - string nextCommand = (string) CommandQueue.Peek(); - - SendLine(nextCommand); - } - } - - } - - /// - /// Sends a command to execute a preset - /// - /// Preset Name - public void RunPreset(string name) - { - SendLine(string.Format("DEVICE recallPreset {0}", name)); - } - - public class QueuedCommand - { - public string Command { get; set; } - public string AttributeCode { get; set; } - public TesiraForteControlPoint ControlPoint { get; set; } - } - } - - public class BiampTesiraForteDspFactory : EssentialsDeviceFactory - { - public BiampTesiraForteDspFactory() - { - TypeNames = new List() {"biamptesira"}; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new BiampTesira Device"); - var comm = CommFactory.CreateCommForDevice(dc); - var props = Newtonsoft.Json.JsonConvert.DeserializeObject( - dc.Properties.ToString()); - return new BiampTesiraForteDsp(dc.Key, dc.Name, comm, props); - } - } - +using System.Text.RegularExpressions; + + +namespace PepperDash.Essentials.Devices.Common.DSP +{ + + // QUESTIONS: + // + // When subscribing, just use the Instance ID for Custom Name? + + // Verbose on subscriptions? + + // Example subscription feedback responses + // ! "publishToken":"name" "value":-77.0 + // ! "myLevelName" -77 + + public class BiampTesiraForteDsp : DspBase + { + public IBasicCommunication Communication { get; private set; } + public CommunicationGather PortGather { get; private set; } + public StatusMonitorBase CommunicationMonitor { get; private set; } + + public new Dictionary LevelControlPoints { get; private set; } + + public bool isSubscribed; + + private CTimer SubscriptionTimer; + + private CrestronQueue CommandQueue; + + private bool CommandQueueInProgress = false; + + //new public Dictionary DialerControlPoints { get; private set; } + + //new public Dictionary SwitcherControlPoints { get; private set; } + + /// + /// Shows received lines as hex + /// + public bool ShowHexResponse { get; set; } + + public BiampTesiraForteDsp(string key, string name, IBasicCommunication comm, + BiampTesiraFortePropertiesConfig props) : + base(key, name) + { + CommandQueue = new CrestronQueue(100); + + Communication = comm; + var socket = comm as ISocketStatus; + if (socket != null) + { + // This instance uses IP control + + socket.ConnectionChange += new EventHandler(socket_ConnectionChange); + } + else + { + // This instance uses RS-232 control + } + PortGather = new CommunicationGather(Communication, "\x0d\x0a"); + PortGather.LineReceived += this.Port_LineReceived; + if (props.CommunicationMonitorProperties != null) + { + CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, + props.CommunicationMonitorProperties); + } + else + { +//#warning Need to deal with this poll string + CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 120000, 120000, 300000, + "SESSION get aliases\x0d\x0a"); + } + + LevelControlPoints = new Dictionary(); + + foreach (KeyValuePair block in props.LevelControlBlocks) + { + this.LevelControlPoints.Add(block.Key, new TesiraForteLevelControl(block.Key, block.Value, this)); + } + + } + + public override bool CustomActivate() + { + Communication.Connect(); + CommunicationMonitor.StatusChange += + (o, a) => { Debug.Console(2, this, "Communication monitor state: {0}", CommunicationMonitor.Status); }; + CommunicationMonitor.Start(); + + CrestronConsole.AddNewConsoleCommand(SendLine, "send" + Key, "", ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(s => Communication.Connect(), "con" + Key, "", + ConsoleAccessLevelEnum.AccessOperator); + return true; + } + + private void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e) + { + Debug.Console(2, this, "Socket Status Change: {0}", e.Client.ClientStatus.ToString()); + + if (e.Client.IsConnected) + { + // Tasks on connect + } + else + { + // Cleanup items from this session + + if (SubscriptionTimer != null) + { + SubscriptionTimer.Stop(); + SubscriptionTimer = null; + } + + isSubscribed = false; + CommandQueue.Clear(); + CommandQueueInProgress = false; + } + } + + /// + /// Initiates the subscription process to the DSP + /// + private void SubscribeToAttributes() + { + SendLine("SESSION set verbose true"); + + foreach (KeyValuePair level in LevelControlPoints) + { + level.Value.Subscribe(); + } + + if (!CommandQueueInProgress) + SendNextQueuedCommand(); + + ResetSubscriptionTimer(); + } + + /// + /// Resets or Sets the subscription timer + /// + private void ResetSubscriptionTimer() + { + isSubscribed = true; + + if (SubscriptionTimer != null) + { + SubscriptionTimer = new CTimer(o => SubscribeToAttributes(), 30000); + SubscriptionTimer.Reset(); + + } + } + + /// + /// Handles a response message from the DSP + /// + /// + /// + private void Port_LineReceived(object dev, GenericCommMethodReceiveTextArgs args) + { + try + { + if (args.Text.IndexOf("Welcome to the Tesira Text Protocol Server...") > -1) + { + // Indicates a new TTP session + + SubscribeToAttributes(); + } + else if (args.Text.IndexOf("publishToken") > -1) + { + // response is from a subscribed attribute + + string pattern = "! \"publishToken\":[\"](.*)[\"] \"value\":(.*)"; + + Match match = Regex.Match(args.Text, pattern); + + if (match.Success) + { + + string key; + + string customName; + + string value; + + customName = match.Groups[1].Value; + + // Finds the key (everything before the '~' character + key = customName.Substring(0, customName.IndexOf("~", 0) - 1); + + value = match.Groups[2].Value; + + foreach (KeyValuePair controlPoint in LevelControlPoints) + { + if (customName == controlPoint.Value.LevelCustomName || + customName == controlPoint.Value.MuteCustomName) + { + controlPoint.Value.ParseSubscriptionMessage(customName, value); + return; + } + + } + } + + /// same for dialers + /// same for switchers + + } + else if (args.Text.IndexOf("+OK") > -1) + { + if (args.Text == "+OK" || args.Text.IndexOf("list\":") > -1) + // Check for a simple "+OK" only 'ack' repsonse or a list response and ignore + return; + + // response is not from a subscribed attribute. From a get/set/toggle/increment/decrement command + + if (!CommandQueue.IsEmpty) + { + if (CommandQueue.Peek() is QueuedCommand) + { + // Expected response belongs to a child class + QueuedCommand tempCommand = (QueuedCommand) CommandQueue.TryToDequeue(); + //Debug.Console(1, this, "Command Dequeued. CommandQueue Size: {0}", CommandQueue.Count); + + tempCommand.ControlPoint.ParseGetMessage(tempCommand.AttributeCode, args.Text); + } + else + { + // Expected response belongs to this class + string temp = (string) CommandQueue.TryToDequeue(); + //Debug.Console(1, this, "Command Dequeued. CommandQueue Size: {0}", CommandQueue.Count); + + } + + if (CommandQueue.IsEmpty) + CommandQueueInProgress = false; + else + SendNextQueuedCommand(); + + } + + + } + else if (args.Text.IndexOf("-ERR") > -1) + { + // Error response + + switch (args.Text) + { + case "-ERR ALREADY_SUBSCRIBED": + { + ResetSubscriptionTimer(); + break; + } + default: + { + Debug.Console(0, this, "Error From DSP: '{0}'", args.Text); + break; + } + } + + } + } + catch (Exception e) + { + if (Debug.Level == 2) + Debug.Console(2, this, "Error parsing response: '{0}'\n{1}", args.Text, e); + } + + } + + /// + /// Sends a command to the DSP (with delimiter appended) + /// + /// Command to send + public void SendLine(string s) + { + Communication.SendText(s + "\x0a"); + } + + /// + /// Adds a command from a child module to the queue + /// + /// Command object from child module + public void EnqueueCommand(QueuedCommand commandToEnqueue) + { + CommandQueue.Enqueue(commandToEnqueue); + //Debug.Console(1, this, "Command (QueuedCommand) Enqueued '{0}'. CommandQueue has '{1}' Elements.", commandToEnqueue.Command, CommandQueue.Count); + + if (!CommandQueueInProgress) + SendNextQueuedCommand(); + } + + + /// + /// Adds a raw string command to the queue + /// + /// + public void EnqueueCommand(string command) + { + CommandQueue.Enqueue(command); + //Debug.Console(1, this, "Command (string) Enqueued '{0}'. CommandQueue has '{1}' Elements.", command, CommandQueue.Count); + + if (!CommandQueueInProgress) + SendNextQueuedCommand(); + } + + /// + /// Sends the next queued command to the DSP + /// + private void SendNextQueuedCommand() + { + //Debug.Console(2, this, "Attempting to send next queued command. CommandQueueInProgress: {0} Communication isConnected: {1}", CommandQueueInProgress, Communication.IsConnected); + + //if (CommandQueue.IsEmpty) + // CommandQueueInProgress = false; + + //Debug.Console(1, this, "CommandQueue has {0} Elements:\n", CommandQueue.Count); + + //foreach (object o in CommandQueue) + //{ + // if (o is string) + // Debug.Console(1, this, "{0}", o); + // else if(o is QueuedCommand) + // { + // var item = (QueuedCommand)o; + // Debug.Console(1, this, "{0}", item.Command); + // } + //} + + //Debug.Console(1, this, "End of CommandQueue"); + + if (Communication.IsConnected && !CommandQueue.IsEmpty) + { + CommandQueueInProgress = true; + + if (CommandQueue.Peek() is QueuedCommand) + { + QueuedCommand nextCommand = new QueuedCommand(); + + nextCommand = (QueuedCommand) CommandQueue.Peek(); + + SendLine(nextCommand.Command); + } + else + { + string nextCommand = (string) CommandQueue.Peek(); + + SendLine(nextCommand); + } + } + + } + + /// + /// Sends a command to execute a preset + /// + /// Preset Name + public void RunPreset(string name) + { + SendLine(string.Format("DEVICE recallPreset {0}", name)); + } + + public class QueuedCommand + { + public string Command { get; set; } + public string AttributeCode { get; set; } + public TesiraForteControlPoint ControlPoint { get; set; } + } + } + + public class BiampTesiraForteDspFactory : EssentialsDeviceFactory + { + public BiampTesiraForteDspFactory() + { + TypeNames = new List() {"biamptesira"}; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new BiampTesira Device"); + var comm = CommFactory.CreateCommForDevice(dc); + var props = Newtonsoft.Json.JsonConvert.DeserializeObject( + dc.Properties.ToString()); + return new BiampTesiraForteDsp(dc.Key, dc.Name, comm, props); + } + } + } diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDspLevel.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDspLevel.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDspLevel.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDspLevel.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraFortePropertiesConfig.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraFortePropertiesConfig.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraFortePropertiesConfig.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraFortePropertiesConfig.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/TesiraForteControlPoint.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/TesiraForteControlPoint.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/TesiraForteControlPoint.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/TesiraForteControlPoint.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/TesiraForteMuteControl.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/TesiraForteMuteControl.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/TesiraForteMuteControl.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/TesiraForteMuteControl.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/DspBase.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/DspBase.cs similarity index 99% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/DspBase.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/DspBase.cs index 0890ca49..7f28ae3d 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/DspBase.cs +++ b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/DspBase.cs @@ -15,19 +15,19 @@ namespace PepperDash.Essentials.Devices.Common.DSP public Dictionary DialerControlPoints { get; private set; } - public Dictionary SwitcherControlPoints { get; private set; } - - public DspBase(string key, string name) : - base(key, name) - { + public Dictionary SwitcherControlPoints { get; private set; } + + public DspBase(string key, string name) : + base(key, name) + { } // in audio call feedback // VOIP - // Phone dialer - + // Phone dialer + } // Fusion diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/PolycomSoundStructure/SoundStructureBasics.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/PolycomSoundStructure/SoundStructureBasics.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/PolycomSoundStructure/SoundStructureBasics.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/PolycomSoundStructure/SoundStructureBasics.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QSC/QscDsp.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QSC/QscDsp.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QSC/QscDsp.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QSC/QscDsp.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QSC/QscDspControlPoint.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QSC/QscDspControlPoint.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QSC/QscDspControlPoint.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QSC/QscDspControlPoint.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QSC/QscDspDialer.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QSC/QscDspDialer.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QSC/QscDspDialer.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QSC/QscDspDialer.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QSC/QscDspLevelControl.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QSC/QscDspLevelControl.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QSC/QscDspLevelControl.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QSC/QscDspLevelControl.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QSC/QscDspPropertiesConfig.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QSC/QscDspPropertiesConfig.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QSC/QscDspPropertiesConfig.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QSC/QscDspPropertiesConfig.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/._QscDspPropertiesConfig.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/._QscDspPropertiesConfig.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/._QscDspPropertiesConfig.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/._QscDspPropertiesConfig.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/QscDsp.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/QscDsp.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/QscDsp.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/QscDsp.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/QscDspControlPoint.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/QscDspControlPoint.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/QscDspControlPoint.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/QscDspControlPoint.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/QscDspDialer.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/QscDspDialer.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/QscDspDialer.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/QscDspDialer.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/QscDspLevelControl.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/QscDspLevelControl.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/QscDspLevelControl.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/QscDspLevelControl.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/QscDspPropertiesConfig.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/QscDspPropertiesConfig.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/QscDspPropertiesConfig.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/QscDsp/QscDspPropertiesConfig.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DiscPlayer/IRDiscPlayerBase.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DiscPlayer/IRDiscPlayerBase.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/DiscPlayer/IRDiscPlayerBase.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/DiscPlayer/IRDiscPlayerBase.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/AvocorVTFDisplay.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/AvocorVTFDisplay.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/AvocorVTFDisplay.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/AvocorVTFDisplay.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/ComTcpDisplayBase.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/ComTcpDisplayBase.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/ComTcpDisplayBase.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/ComTcpDisplayBase.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/InputInterfaces.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/InputInterfaces.cs similarity index 97% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/InputInterfaces.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/InputInterfaces.cs index 95070e1b..ce7113e1 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/InputInterfaces.cs +++ b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/InputInterfaces.cs @@ -1,17 +1,17 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -namespace PepperDash.Essentials.Devices.Displays -{ - public interface IInputHdmi1 { void InputHdmi1(); } - public interface IInputHdmi2 { void InputHdmi2(); } - public interface IInputHdmi3 { void InputHdmi3(); } - public interface IInputHdmi4 { void InputHdmi4(); } - public interface IInputDisplayPort1 { void InputDisplayPort1(); } - public interface IInputDisplayPort2 { void InputDisplayPort2(); } - public interface IInputVga1 { void InputVga1(); } - +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +namespace PepperDash.Essentials.Devices.Displays +{ + public interface IInputHdmi1 { void InputHdmi1(); } + public interface IInputHdmi2 { void InputHdmi2(); } + public interface IInputHdmi3 { void InputHdmi3(); } + public interface IInputHdmi4 { void InputHdmi4(); } + public interface IInputDisplayPort1 { void InputDisplayPort1(); } + public interface IInputDisplayPort2 { void InputDisplayPort2(); } + public interface IInputVga1 { void InputVga1(); } + } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/NECPSXMDisplay.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/NECPSXMDisplay.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/NECPSXMDisplay.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/NECPSXMDisplay.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/NecPaSeriesProjector.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/NecPaSeriesProjector.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/NecPaSeriesProjector.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/NecPaSeriesProjector.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/PanasonicThDisplay.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/PanasonicThDisplay.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/PanasonicThDisplay.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/PanasonicThDisplay.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs similarity index 97% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs index 9fcb7295..80dc23d3 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs +++ b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs @@ -1,663 +1,663 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.CrestronThread; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.Core.Routing; -using Feedback = PepperDash.Essentials.Core.Feedback; - -using Newtonsoft.Json.Linq; - -namespace PepperDash.Essentials.Devices.Displays -{ - /// - /// - /// - public class SamsungMDC : TwoWayDisplayBase, IBasicVolumeWithFeedback, ICommunicationMonitor, IInputDisplayPort1, IInputDisplayPort2, - IInputHdmi1, IInputHdmi2, IInputHdmi3, IInputHdmi4, IBridgeAdvanced - { - public IBasicCommunication Communication { get; private set; } - - - - public StatusMonitorBase CommunicationMonitor { get; private set; } - - public byte ID { get; private set; } - - bool LastCommandSentWasVolume; - - bool _PowerIsOn; - bool _IsWarmingUp; - bool _IsCoolingDown; - ushort _VolumeLevelForSig; - int _LastVolumeSent; - bool _IsMuted; - RoutingInputPort _CurrentInputPort; - byte[] IncomingBuffer = new byte[]{}; - ActionIncrementer VolumeIncrementer; - bool VolumeIsRamping; - public bool IsInStandby { get; private set; } - bool IsPoweringOnIgnorePowerFb; - - protected override Func PowerIsOnFeedbackFunc { get { return () => _PowerIsOn; } } - protected override Func IsCoolingDownFeedbackFunc { get { return () => _IsCoolingDown; } } - protected override Func IsWarmingUpFeedbackFunc { get { return () => _IsWarmingUp; } } - protected override Func CurrentInputFeedbackFunc { get { return () => _CurrentInputPort.Key; } } - - /// - /// Constructor for IBasicCommunication - /// - public SamsungMDC(string key, string name, IBasicCommunication comm, string id) - : base(key, name) - { - Communication = comm; - Communication.BytesReceived += new EventHandler(Communication_BytesReceived); - - ID = id == null ? (byte)0x01 : Convert.ToByte(id, 16); // If id is null, set default value of 0x01, otherwise assign value passed in constructor - Init(); - } - - /// - /// Constructor for TCP - /// - public SamsungMDC(string key, string name, string hostname, int port, string id) - : base(key, name) - { - Communication = new GenericTcpIpClient(key + "-tcp", hostname, port, 5000); - ID = id == null ? (byte)0x01 : Convert.ToByte(id, 16); // If id is null, set default value of 0x01, otherwise assign value passed in constructor - Init(); - } - - /// - /// Constructor for COM - /// - public SamsungMDC(string key, string name, ComPort port, ComPort.ComPortSpec spec, string id) - : base(key, name) - { - Communication = new ComPortController(key + "-com", port, spec); - //Communication.TextReceived += new EventHandler(Communication_TextReceived); - - ID = id == null ? (byte)0x01 : Convert.ToByte(id, 16); // If id is null, set default value of 0x01, otherwise assign value passed in constructor - Init(); - } - - void AddRoutingInputPort(RoutingInputPort port, byte fbMatch) - { - port.FeedbackMatchObject = fbMatch; - InputPorts.Add(port); - } - - void Init() - { - WarmupTime = 10000; - CooldownTime = 8000; - - CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 2000, 120000, 300000, StatusGet, true); - DeviceManager.AddDevice(CommunicationMonitor); - - VolumeIncrementer = new ActionIncrementer(655, 0, 65535, 800, 80, - v => SetVolume((ushort)v), - () => _LastVolumeSent); - - AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.HdmiIn1, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, new Action(InputHdmi1), this), 0x21); - - AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.HdmiIn1PC, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, new Action(InputHdmi1PC), this), 0x22); - - AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.HdmiIn2, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, new Action(InputHdmi2), this), 0x23); - - AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.HdmiIn2PC, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, new Action(InputHdmi2PC), this), 0x24); - - AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.HdmiIn3, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, new Action(InputHdmi3), this), 0x32); - - AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.DisplayPortIn1, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DisplayPort, new Action(InputDisplayPort1), this), 0x25); - - AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.DviIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Dvi, new Action(InputDvi1), this), 0x18); - - AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.CompositeIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Composite, new Action(InputVideo1), this), 0x08); - - AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.RgbIn1, eRoutingSignalType.Video, - eRoutingPortConnectionType.Vga, new Action(InputRgb1), this), 0x14); - - AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.RgbIn2, eRoutingSignalType.Video, - eRoutingPortConnectionType.Rgb, new Action(new Action(InputRgb2)), this), 0x1E); - - VolumeLevelFeedback = new IntFeedback(() => { return _VolumeLevelForSig; }); - MuteFeedback = new BoolFeedback(() => _IsMuted); - - StatusGet(); - } - - /// - /// - /// - /// - public override bool CustomActivate() - { - Communication.Connect(); - CommunicationMonitor.StatusChange += (o, a) => Debug.Console(2, this, "Communication monitor state: {0}", CommunicationMonitor.Status); - CommunicationMonitor.Start(); - return true; - } - - public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - LinkDisplayToApi(this, trilist, joinStart, joinMapKey, bridge); - } - - public override FeedbackCollection Feedbacks - { - get - { - var list = base.Feedbacks; - list.AddRange(new List - { - VolumeLevelFeedback, - MuteFeedback, - CurrentInputFeedback - }); - return list; - } - } - - /// - /// / - /// - /// - void Communication_BytesReceived(object sender, GenericCommMethodReceiveBytesArgs e) - { - try - { - // This is probably not thread-safe buffering - // Append the incoming bytes with whatever is in the buffer - var newBytes = new byte[IncomingBuffer.Length + e.Bytes.Length]; - IncomingBuffer.CopyTo(newBytes, 0); - e.Bytes.CopyTo(newBytes, IncomingBuffer.Length); - - // Need to find AA FF and have - for (int i = 0; i < newBytes.Length; i++) - { - if (newBytes[i] == 0xAA && newBytes[i + 1] == 0xFF) - { - newBytes = newBytes.Skip(i).ToArray(); // Trim off junk if there's "dirt" in the buffer - - // parse it - // If it's at least got the header, then process it, - while (newBytes.Length > 4 && newBytes[0] == 0xAA && newBytes[1] == 0xFF) - { - var msgLen = newBytes[3]; - // if the buffer is shorter than the header (3) + message (msgLen) + checksum (1), - // give and save it for next time - if (newBytes.Length < msgLen + 4) - break; - - // Good length, grab the message - var message = newBytes.Skip(4).Take(msgLen).ToArray(); - - // At this point, the ack/nak is the first byte - if (message[0] == 0x41) - { - switch (message[1]) // type byte - { - case 0x00: // General status - //UpdatePowerFB(message[2], message[5]); // "power" can be misrepresented when the display sleeps - - // Handle the first power on fb when waiting for it. - if (IsPoweringOnIgnorePowerFb && message[2] == 0x01) - IsPoweringOnIgnorePowerFb = false; - // Ignore general-status power off messages when powering up - if (!(IsPoweringOnIgnorePowerFb && message[2] == 0x00)) - UpdatePowerFB(message[2]); - UpdateVolumeFB(message[3]); - UpdateMuteFb(message[4]); - UpdateInputFb(message[5]); - break; - - case 0x11: - UpdatePowerFB(message[2]); - break; - - case 0x12: - UpdateVolumeFB(message[2]); - break; - - case 0x13: - UpdateMuteFb(message[2]); - break; - - case 0x14: - UpdateInputFb(message[2]); - break; - - default: - break; - } - } - // Skip over what we've used and save the rest for next time - newBytes = newBytes.Skip(5 + msgLen).ToArray(); - } - - break; // parsing will mean we can stop looking for header in loop - } - } - - // Save whatever partial message is here - IncomingBuffer = newBytes; - } - catch (Exception err) - { - Debug.Console(2, this, "Error parsing feedback: {0}", err); - } - } - - /// - /// - /// - void UpdatePowerFB(byte powerByte) - { - var newVal = powerByte == 1; - if (newVal != _PowerIsOn) - { - _PowerIsOn = newVal; - Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Feedback Power State: {0}", _PowerIsOn); - PowerIsOnFeedback.FireUpdate(); - } - } - - /// - /// Updates power status from general updates where source is included. - /// Compensates for errant standby / power off hiccups by ignoring - /// power off states with input < 0x10 - /// - void UpdatePowerFB(byte powerByte, byte inputByte) - { - // This should reject errant power feedbacks when switching away from input on standby. - if (powerByte == 0x01 && inputByte < 0x10) - IsInStandby = true; - if (powerByte == 0x00 && IsInStandby) // Ignore power off if coming from standby - glitch - { - IsInStandby = false; - return; - } - - UpdatePowerFB(powerByte); - } - - /// - /// - /// - void UpdateVolumeFB(byte b) - { - var newVol = (ushort)NumericalHelpers.Scale((double)b, 0, 100, 0, 65535); - if (!VolumeIsRamping) - _LastVolumeSent = newVol; - if (newVol != _VolumeLevelForSig) - { - _VolumeLevelForSig = newVol; - VolumeLevelFeedback.FireUpdate(); - } - } - - /// - /// - /// - void UpdateMuteFb(byte b) - { - var newMute = b == 1; - if (newMute != _IsMuted) - { - _IsMuted = newMute; - MuteFeedback.FireUpdate(); - } - } - - - - - /// - /// - /// - void UpdateInputFb(byte b) - { - var newInput = InputPorts.FirstOrDefault(i => i.FeedbackMatchObject.Equals(b)); - if (newInput != null && newInput != _CurrentInputPort) - { - _CurrentInputPort = newInput; - CurrentInputFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(null, _CurrentInputPort, eRoutingSignalType.AudioVideo)); - } - } - - /// - /// Formats an outgoing message. Replaces third byte with ID and replaces last byte with checksum - /// - /// - void SendBytes(byte[] b) - { - if (LastCommandSentWasVolume) // If the last command sent was volume - if (b[1] != 0x12) // Check if this command is volume, and if not, delay this command - CrestronEnvironment.Sleep(100); - - b[2] = ID; - // append checksum by adding all bytes, except last which should be 00 - int checksum = 0; - for (var i = 1; i < b.Length - 1; i++) // add 2nd through 2nd-to-last bytes - { - checksum += b[i]; - } - checksum = checksum & 0x000000FF; // mask off MSBs - b[b.Length - 1] = (byte)checksum; - - if (b[1] == 0x12) - LastCommandSentWasVolume = true; - else - LastCommandSentWasVolume = false; - - Communication.SendBytes(b); - } - - - /// - /// - /// - public void StatusGet() - { - SendBytes(new byte[] { 0xAA, 0x00, 0x00, 0x00, 0x00 }); - } - - /// - /// - /// - public override void PowerOn() - { - Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Powering On Display"); - - IsPoweringOnIgnorePowerFb = true; - //Send(PowerOnCmd); - SendBytes(new byte[] { 0xAA, 0x11, 0x00, 0x01, 0x01, 0x00 }); - if (!PowerIsOnFeedback.BoolValue && !_IsWarmingUp && !_IsCoolingDown) - { - _IsWarmingUp = true; - IsWarmingUpFeedback.FireUpdate(); - // Fake power-up cycle - WarmupTimer = new CTimer(o => - { - _IsWarmingUp = false; - _PowerIsOn = true; - IsWarmingUpFeedback.FireUpdate(); - PowerIsOnFeedback.FireUpdate(); - }, WarmupTime); - } - } - - /// - /// - /// - public override void PowerOff() - { - Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Powering Off Display"); - - IsPoweringOnIgnorePowerFb = false; - // If a display has unreliable-power off feedback, just override this and - // remove this check. - if (!_IsWarmingUp && !_IsCoolingDown) // PowerIsOnFeedback.BoolValue && - { - //Send(PowerOffCmd); - SendBytes(new byte[] { 0xAA, 0x11, 0x00, 0x01, 0x00, 0x00 }); - _IsCoolingDown = true; - _PowerIsOn = false; - PowerIsOnFeedback.FireUpdate(); - IsCoolingDownFeedback.FireUpdate(); - // Fake cool-down cycle - CooldownTimer = new CTimer(o => - { - _IsCoolingDown = false; - IsCoolingDownFeedback.FireUpdate(); - }, CooldownTime); - } - } - - public override void PowerToggle() - { - if (PowerIsOnFeedback.BoolValue && !IsWarmingUpFeedback.BoolValue) - PowerOff(); - else if (!PowerIsOnFeedback.BoolValue && !IsCoolingDownFeedback.BoolValue) - PowerOn(); - } - - public void PowerGet() - { - SendBytes(new byte[] { 0xAA, 0x11, 0x00, 0x00, 0x00 }); - } - - public void InputHdmi1() - { - SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x01, 0x21, 0x00 }); - } - - public void InputHdmi1PC() - { - SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x01, 0x22, 0x00 }); - } - - public void InputHdmi2() - { - SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x01, 0x23, 0x00 }); - } - - public void InputHdmi2PC() - { - SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x01, 0x24, 0x00 }); - } - - public void InputHdmi3() - { - SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x01, 0x32, 0x00 }); - } - - public void InputHdmi4() - { - SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x01, 0x34, 0x00 }); - } - - public void InputDisplayPort1() - { - SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x01, 0x25, 0x00 }); - } - - public void InputDisplayPort2() - { - SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x01, 0x26, 0x00 }); - } - - public void InputDvi1() - { - SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x01, 0x18, 0x00 }); - } - - public void InputVideo1() - { - SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x01, 0x08, 0x00 }); - } - - public void InputRgb1() - { - SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x01, 0x14, 0x00 }); - } - - public void InputRgb2() - { - SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x01, 0x1E, 0x00 }); - } - - public void InputGet() - { - SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x00, 0x00 }); - } - - - /// - /// Executes a switch, turning on display if necessary. - /// - /// - public override void ExecuteSwitch(object selector) - { - //if (!(selector is Action)) - // Debug.Console(1, this, "WARNING: ExecuteSwitch cannot handle type {0}", selector.GetType()); - - if (_PowerIsOn) - (selector as Action)(); - else // if power is off, wait until we get on FB to send it. - { - // One-time event handler to wait for power on before executing switch - EventHandler handler = null; // necessary to allow reference inside lambda to handler - handler = (o, a) => - { - if (!_IsWarmingUp) // Done warming - { - IsWarmingUpFeedback.OutputChange -= handler; - (selector as Action)(); - } - }; - IsWarmingUpFeedback.OutputChange += handler; // attach and wait for on FB - PowerOn(); - } - } - - /// - /// Scales the level to the range of the display and sends the command - /// - /// - public void SetVolume(ushort level) - { - _LastVolumeSent = level; - var scaled = (int)NumericalHelpers.Scale(level, 0, 65535, 0, 100); - // The inputs to Scale ensure that byte won't overflow - SendBytes(new byte[] { 0xAA, 0x12, 0x00, 0x01, Convert.ToByte(scaled), 0x00 }); - } - - #region IBasicVolumeWithFeedback Members - - public IntFeedback VolumeLevelFeedback { get; private set; } - - public BoolFeedback MuteFeedback { get; private set; } - - /// - /// - /// - public void MuteOff() - { - SendBytes(new byte[] { 0xAA, 0x13, 0x00, 0x01, 0x00, 0x00 }); - } - - /// - /// - /// - public void MuteOn() - { - SendBytes(new byte[] { 0xAA, 0x13, 0x00, 0x01, 0x01, 0x00 }); - } - - /// - /// - /// - public void MuteGet() - { - SendBytes(new byte[] { 0xAA, 0x13, 0x00, 0x00, 0x00 }); - } - - #endregion - - #region IBasicVolumeControls Members - - /// - /// - /// - public void MuteToggle() - { - if (_IsMuted) - MuteOff(); - else - MuteOn(); - } - - /// - /// - /// - /// - public void VolumeDown(bool pressRelease) - { - if (pressRelease) - { - VolumeIncrementer.StartDown(); - VolumeIsRamping = true; - } - else - { - VolumeIsRamping = false; - VolumeIncrementer.Stop(); - } - } - - /// - /// - /// - /// - public void VolumeUp(bool pressRelease) - { - if (pressRelease) - { - VolumeIncrementer.StartUp(); - VolumeIsRamping = true; - } - else - { - VolumeIsRamping = false; - VolumeIncrementer.Stop(); - } - } - - /// - /// - /// - public void VolumeGet() - { - SendBytes(new byte[] { 0xAA, 0x12, 0x00, 0x00, 0x00 }); - } - - #endregion - } - - public class SamsungMDCFactory : EssentialsDeviceFactory - { - public SamsungMDCFactory() - { - TypeNames = new List() { "samsungmdc" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); - var comm = CommFactory.CreateCommForDevice(dc); - if (comm != null) - return new SamsungMDC(dc.Key, dc.Name, comm, dc.Properties["id"].Value()); - else - return null; - } - } - +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.CrestronThread; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.Core.Routing; +using Feedback = PepperDash.Essentials.Core.Feedback; + +using Newtonsoft.Json.Linq; + +namespace PepperDash.Essentials.Devices.Displays +{ + /// + /// + /// + public class SamsungMDC : TwoWayDisplayBase, IBasicVolumeWithFeedback, ICommunicationMonitor, IInputDisplayPort1, IInputDisplayPort2, + IInputHdmi1, IInputHdmi2, IInputHdmi3, IInputHdmi4, IBridgeAdvanced + { + public IBasicCommunication Communication { get; private set; } + + + + public StatusMonitorBase CommunicationMonitor { get; private set; } + + public byte ID { get; private set; } + + bool LastCommandSentWasVolume; + + bool _PowerIsOn; + bool _IsWarmingUp; + bool _IsCoolingDown; + ushort _VolumeLevelForSig; + int _LastVolumeSent; + bool _IsMuted; + RoutingInputPort _CurrentInputPort; + byte[] IncomingBuffer = new byte[]{}; + ActionIncrementer VolumeIncrementer; + bool VolumeIsRamping; + public bool IsInStandby { get; private set; } + bool IsPoweringOnIgnorePowerFb; + + protected override Func PowerIsOnFeedbackFunc { get { return () => _PowerIsOn; } } + protected override Func IsCoolingDownFeedbackFunc { get { return () => _IsCoolingDown; } } + protected override Func IsWarmingUpFeedbackFunc { get { return () => _IsWarmingUp; } } + protected override Func CurrentInputFeedbackFunc { get { return () => _CurrentInputPort.Key; } } + + /// + /// Constructor for IBasicCommunication + /// + public SamsungMDC(string key, string name, IBasicCommunication comm, string id) + : base(key, name) + { + Communication = comm; + Communication.BytesReceived += new EventHandler(Communication_BytesReceived); + + ID = id == null ? (byte)0x01 : Convert.ToByte(id, 16); // If id is null, set default value of 0x01, otherwise assign value passed in constructor + Init(); + } + + /// + /// Constructor for TCP + /// + public SamsungMDC(string key, string name, string hostname, int port, string id) + : base(key, name) + { + Communication = new GenericTcpIpClient(key + "-tcp", hostname, port, 5000); + ID = id == null ? (byte)0x01 : Convert.ToByte(id, 16); // If id is null, set default value of 0x01, otherwise assign value passed in constructor + Init(); + } + + /// + /// Constructor for COM + /// + public SamsungMDC(string key, string name, ComPort port, ComPort.ComPortSpec spec, string id) + : base(key, name) + { + Communication = new ComPortController(key + "-com", port, spec); + //Communication.TextReceived += new EventHandler(Communication_TextReceived); + + ID = id == null ? (byte)0x01 : Convert.ToByte(id, 16); // If id is null, set default value of 0x01, otherwise assign value passed in constructor + Init(); + } + + void AddRoutingInputPort(RoutingInputPort port, byte fbMatch) + { + port.FeedbackMatchObject = fbMatch; + InputPorts.Add(port); + } + + void Init() + { + WarmupTime = 10000; + CooldownTime = 8000; + + CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 2000, 120000, 300000, StatusGet, true); + DeviceManager.AddDevice(CommunicationMonitor); + + VolumeIncrementer = new ActionIncrementer(655, 0, 65535, 800, 80, + v => SetVolume((ushort)v), + () => _LastVolumeSent); + + AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.HdmiIn1, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, new Action(InputHdmi1), this), 0x21); + + AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.HdmiIn1PC, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, new Action(InputHdmi1PC), this), 0x22); + + AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.HdmiIn2, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, new Action(InputHdmi2), this), 0x23); + + AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.HdmiIn2PC, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, new Action(InputHdmi2PC), this), 0x24); + + AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.HdmiIn3, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, new Action(InputHdmi3), this), 0x32); + + AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.DisplayPortIn1, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.DisplayPort, new Action(InputDisplayPort1), this), 0x25); + + AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.DviIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Dvi, new Action(InputDvi1), this), 0x18); + + AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.CompositeIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Composite, new Action(InputVideo1), this), 0x08); + + AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.RgbIn1, eRoutingSignalType.Video, + eRoutingPortConnectionType.Vga, new Action(InputRgb1), this), 0x14); + + AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.RgbIn2, eRoutingSignalType.Video, + eRoutingPortConnectionType.Rgb, new Action(new Action(InputRgb2)), this), 0x1E); + + VolumeLevelFeedback = new IntFeedback(() => { return _VolumeLevelForSig; }); + MuteFeedback = new BoolFeedback(() => _IsMuted); + + StatusGet(); + } + + /// + /// + /// + /// + public override bool CustomActivate() + { + Communication.Connect(); + CommunicationMonitor.StatusChange += (o, a) => Debug.Console(2, this, "Communication monitor state: {0}", CommunicationMonitor.Status); + CommunicationMonitor.Start(); + return true; + } + + public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + LinkDisplayToApi(this, trilist, joinStart, joinMapKey, bridge); + } + + public override FeedbackCollection Feedbacks + { + get + { + var list = base.Feedbacks; + list.AddRange(new List + { + VolumeLevelFeedback, + MuteFeedback, + CurrentInputFeedback + }); + return list; + } + } + + /// + /// / + /// + /// + void Communication_BytesReceived(object sender, GenericCommMethodReceiveBytesArgs e) + { + try + { + // This is probably not thread-safe buffering + // Append the incoming bytes with whatever is in the buffer + var newBytes = new byte[IncomingBuffer.Length + e.Bytes.Length]; + IncomingBuffer.CopyTo(newBytes, 0); + e.Bytes.CopyTo(newBytes, IncomingBuffer.Length); + + // Need to find AA FF and have + for (int i = 0; i < newBytes.Length; i++) + { + if (newBytes[i] == 0xAA && newBytes[i + 1] == 0xFF) + { + newBytes = newBytes.Skip(i).ToArray(); // Trim off junk if there's "dirt" in the buffer + + // parse it + // If it's at least got the header, then process it, + while (newBytes.Length > 4 && newBytes[0] == 0xAA && newBytes[1] == 0xFF) + { + var msgLen = newBytes[3]; + // if the buffer is shorter than the header (3) + message (msgLen) + checksum (1), + // give and save it for next time + if (newBytes.Length < msgLen + 4) + break; + + // Good length, grab the message + var message = newBytes.Skip(4).Take(msgLen).ToArray(); + + // At this point, the ack/nak is the first byte + if (message[0] == 0x41) + { + switch (message[1]) // type byte + { + case 0x00: // General status + //UpdatePowerFB(message[2], message[5]); // "power" can be misrepresented when the display sleeps + + // Handle the first power on fb when waiting for it. + if (IsPoweringOnIgnorePowerFb && message[2] == 0x01) + IsPoweringOnIgnorePowerFb = false; + // Ignore general-status power off messages when powering up + if (!(IsPoweringOnIgnorePowerFb && message[2] == 0x00)) + UpdatePowerFB(message[2]); + UpdateVolumeFB(message[3]); + UpdateMuteFb(message[4]); + UpdateInputFb(message[5]); + break; + + case 0x11: + UpdatePowerFB(message[2]); + break; + + case 0x12: + UpdateVolumeFB(message[2]); + break; + + case 0x13: + UpdateMuteFb(message[2]); + break; + + case 0x14: + UpdateInputFb(message[2]); + break; + + default: + break; + } + } + // Skip over what we've used and save the rest for next time + newBytes = newBytes.Skip(5 + msgLen).ToArray(); + } + + break; // parsing will mean we can stop looking for header in loop + } + } + + // Save whatever partial message is here + IncomingBuffer = newBytes; + } + catch (Exception err) + { + Debug.Console(2, this, "Error parsing feedback: {0}", err); + } + } + + /// + /// + /// + void UpdatePowerFB(byte powerByte) + { + var newVal = powerByte == 1; + if (newVal != _PowerIsOn) + { + _PowerIsOn = newVal; + Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Feedback Power State: {0}", _PowerIsOn); + PowerIsOnFeedback.FireUpdate(); + } + } + + /// + /// Updates power status from general updates where source is included. + /// Compensates for errant standby / power off hiccups by ignoring + /// power off states with input < 0x10 + /// + void UpdatePowerFB(byte powerByte, byte inputByte) + { + // This should reject errant power feedbacks when switching away from input on standby. + if (powerByte == 0x01 && inputByte < 0x10) + IsInStandby = true; + if (powerByte == 0x00 && IsInStandby) // Ignore power off if coming from standby - glitch + { + IsInStandby = false; + return; + } + + UpdatePowerFB(powerByte); + } + + /// + /// + /// + void UpdateVolumeFB(byte b) + { + var newVol = (ushort)NumericalHelpers.Scale((double)b, 0, 100, 0, 65535); + if (!VolumeIsRamping) + _LastVolumeSent = newVol; + if (newVol != _VolumeLevelForSig) + { + _VolumeLevelForSig = newVol; + VolumeLevelFeedback.FireUpdate(); + } + } + + /// + /// + /// + void UpdateMuteFb(byte b) + { + var newMute = b == 1; + if (newMute != _IsMuted) + { + _IsMuted = newMute; + MuteFeedback.FireUpdate(); + } + } + + + + + /// + /// + /// + void UpdateInputFb(byte b) + { + var newInput = InputPorts.FirstOrDefault(i => i.FeedbackMatchObject.Equals(b)); + if (newInput != null && newInput != _CurrentInputPort) + { + _CurrentInputPort = newInput; + CurrentInputFeedback.FireUpdate(); + OnSwitchChange(new RoutingNumericEventArgs(null, _CurrentInputPort, eRoutingSignalType.AudioVideo)); + } + } + + /// + /// Formats an outgoing message. Replaces third byte with ID and replaces last byte with checksum + /// + /// + void SendBytes(byte[] b) + { + if (LastCommandSentWasVolume) // If the last command sent was volume + if (b[1] != 0x12) // Check if this command is volume, and if not, delay this command + CrestronEnvironment.Sleep(100); + + b[2] = ID; + // append checksum by adding all bytes, except last which should be 00 + int checksum = 0; + for (var i = 1; i < b.Length - 1; i++) // add 2nd through 2nd-to-last bytes + { + checksum += b[i]; + } + checksum = checksum & 0x000000FF; // mask off MSBs + b[b.Length - 1] = (byte)checksum; + + if (b[1] == 0x12) + LastCommandSentWasVolume = true; + else + LastCommandSentWasVolume = false; + + Communication.SendBytes(b); + } + + + /// + /// + /// + public void StatusGet() + { + SendBytes(new byte[] { 0xAA, 0x00, 0x00, 0x00, 0x00 }); + } + + /// + /// + /// + public override void PowerOn() + { + Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Powering On Display"); + + IsPoweringOnIgnorePowerFb = true; + //Send(PowerOnCmd); + SendBytes(new byte[] { 0xAA, 0x11, 0x00, 0x01, 0x01, 0x00 }); + if (!PowerIsOnFeedback.BoolValue && !_IsWarmingUp && !_IsCoolingDown) + { + _IsWarmingUp = true; + IsWarmingUpFeedback.FireUpdate(); + // Fake power-up cycle + WarmupTimer = new CTimer(o => + { + _IsWarmingUp = false; + _PowerIsOn = true; + IsWarmingUpFeedback.FireUpdate(); + PowerIsOnFeedback.FireUpdate(); + }, WarmupTime); + } + } + + /// + /// + /// + public override void PowerOff() + { + Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Powering Off Display"); + + IsPoweringOnIgnorePowerFb = false; + // If a display has unreliable-power off feedback, just override this and + // remove this check. + if (!_IsWarmingUp && !_IsCoolingDown) // PowerIsOnFeedback.BoolValue && + { + //Send(PowerOffCmd); + SendBytes(new byte[] { 0xAA, 0x11, 0x00, 0x01, 0x00, 0x00 }); + _IsCoolingDown = true; + _PowerIsOn = false; + PowerIsOnFeedback.FireUpdate(); + IsCoolingDownFeedback.FireUpdate(); + // Fake cool-down cycle + CooldownTimer = new CTimer(o => + { + _IsCoolingDown = false; + IsCoolingDownFeedback.FireUpdate(); + }, CooldownTime); + } + } + + public override void PowerToggle() + { + if (PowerIsOnFeedback.BoolValue && !IsWarmingUpFeedback.BoolValue) + PowerOff(); + else if (!PowerIsOnFeedback.BoolValue && !IsCoolingDownFeedback.BoolValue) + PowerOn(); + } + + public void PowerGet() + { + SendBytes(new byte[] { 0xAA, 0x11, 0x00, 0x00, 0x00 }); + } + + public void InputHdmi1() + { + SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x01, 0x21, 0x00 }); + } + + public void InputHdmi1PC() + { + SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x01, 0x22, 0x00 }); + } + + public void InputHdmi2() + { + SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x01, 0x23, 0x00 }); + } + + public void InputHdmi2PC() + { + SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x01, 0x24, 0x00 }); + } + + public void InputHdmi3() + { + SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x01, 0x32, 0x00 }); + } + + public void InputHdmi4() + { + SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x01, 0x34, 0x00 }); + } + + public void InputDisplayPort1() + { + SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x01, 0x25, 0x00 }); + } + + public void InputDisplayPort2() + { + SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x01, 0x26, 0x00 }); + } + + public void InputDvi1() + { + SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x01, 0x18, 0x00 }); + } + + public void InputVideo1() + { + SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x01, 0x08, 0x00 }); + } + + public void InputRgb1() + { + SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x01, 0x14, 0x00 }); + } + + public void InputRgb2() + { + SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x01, 0x1E, 0x00 }); + } + + public void InputGet() + { + SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x00, 0x00 }); + } + + + /// + /// Executes a switch, turning on display if necessary. + /// + /// + public override void ExecuteSwitch(object selector) + { + //if (!(selector is Action)) + // Debug.Console(1, this, "WARNING: ExecuteSwitch cannot handle type {0}", selector.GetType()); + + if (_PowerIsOn) + (selector as Action)(); + else // if power is off, wait until we get on FB to send it. + { + // One-time event handler to wait for power on before executing switch + EventHandler handler = null; // necessary to allow reference inside lambda to handler + handler = (o, a) => + { + if (!_IsWarmingUp) // Done warming + { + IsWarmingUpFeedback.OutputChange -= handler; + (selector as Action)(); + } + }; + IsWarmingUpFeedback.OutputChange += handler; // attach and wait for on FB + PowerOn(); + } + } + + /// + /// Scales the level to the range of the display and sends the command + /// + /// + public void SetVolume(ushort level) + { + _LastVolumeSent = level; + var scaled = (int)NumericalHelpers.Scale(level, 0, 65535, 0, 100); + // The inputs to Scale ensure that byte won't overflow + SendBytes(new byte[] { 0xAA, 0x12, 0x00, 0x01, Convert.ToByte(scaled), 0x00 }); + } + + #region IBasicVolumeWithFeedback Members + + public IntFeedback VolumeLevelFeedback { get; private set; } + + public BoolFeedback MuteFeedback { get; private set; } + + /// + /// + /// + public void MuteOff() + { + SendBytes(new byte[] { 0xAA, 0x13, 0x00, 0x01, 0x00, 0x00 }); + } + + /// + /// + /// + public void MuteOn() + { + SendBytes(new byte[] { 0xAA, 0x13, 0x00, 0x01, 0x01, 0x00 }); + } + + /// + /// + /// + public void MuteGet() + { + SendBytes(new byte[] { 0xAA, 0x13, 0x00, 0x00, 0x00 }); + } + + #endregion + + #region IBasicVolumeControls Members + + /// + /// + /// + public void MuteToggle() + { + if (_IsMuted) + MuteOff(); + else + MuteOn(); + } + + /// + /// + /// + /// + public void VolumeDown(bool pressRelease) + { + if (pressRelease) + { + VolumeIncrementer.StartDown(); + VolumeIsRamping = true; + } + else + { + VolumeIsRamping = false; + VolumeIncrementer.Stop(); + } + } + + /// + /// + /// + /// + public void VolumeUp(bool pressRelease) + { + if (pressRelease) + { + VolumeIncrementer.StartUp(); + VolumeIsRamping = true; + } + else + { + VolumeIsRamping = false; + VolumeIncrementer.Stop(); + } + } + + /// + /// + /// + public void VolumeGet() + { + SendBytes(new byte[] { 0xAA, 0x12, 0x00, 0x00, 0x00 }); + } + + #endregion + } + + public class SamsungMDCFactory : EssentialsDeviceFactory + { + public SamsungMDCFactory() + { + TypeNames = new List() { "samsungmdc" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); + var comm = CommFactory.CreateCommForDevice(dc); + if (comm != null) + return new SamsungMDC(dc.Key, dc.Name, comm, dc.Properties["id"].Value()); + else + return null; + } + } + } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Crestron Lighting/Din8sw8.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Crestron Lighting/Din8sw8.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Crestron Lighting/Din8sw8.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Crestron Lighting/Din8sw8.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Lutron/LutronQuantum.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Lutron/LutronQuantum.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Lutron/LutronQuantum.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Lutron/LutronQuantum.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Somfy/RelayControlledShade.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Somfy/RelayControlledShade.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Somfy/RelayControlledShade.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Somfy/RelayControlledShade.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj similarity index 98% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj index 845b61ef..7c03eb19 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj +++ b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj @@ -1,210 +1,210 @@ - - - Release - AnyCPU - 9.0.30729 - 2.0 - {892B761C-E479-44CE-BD74-243E9214AF13} - Library - Properties - PepperDash.Essentials.Devices.Common - Essentials Devices Common - {0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - WindowsCE - E2BECB1F-8C8C-41ba-B736-9BE7D946A398 - 5.0 - SmartDeviceProject1 - v3.5 - Windows CE - - - - - .allowedReferenceRelatedFileExtensions - true - full - false - bin\ - DEBUG;TRACE; - prompt - 4 - 512 - true - true - off - - - .allowedReferenceRelatedFileExtensions - none - true - bin\ - prompt - 4 - 512 - true - true - off - - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Gateways.dll - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.GeneralIO.dll - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Lighting.dll - - - - False - ..\..\..\packages\PepperDashCore\lib\net35\PepperDash_Core.dll - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll - False - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll - False - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe - False - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} - PepperDash_Essentials_Core - - - - - - - - - rem S# Pro preparation will execute after these operations - + + + Release + AnyCPU + 9.0.30729 + 2.0 + {892B761C-E479-44CE-BD74-243E9214AF13} + Library + Properties + PepperDash.Essentials.Devices.Common + Essentials Devices Common + {0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + WindowsCE + E2BECB1F-8C8C-41ba-B736-9BE7D946A398 + 5.0 + SmartDeviceProject1 + v3.5 + Windows CE + + + + + .allowedReferenceRelatedFileExtensions + true + full + false + bin\ + DEBUG;TRACE; + prompt + 4 + 512 + true + true + off + + + .allowedReferenceRelatedFileExtensions + none + true + bin\ + prompt + 4 + 512 + true + true + off + + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Gateways.dll + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.GeneralIO.dll + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Lighting.dll + + + + False + ..\..\..\packages\PepperDashCore\lib\net35\PepperDash_Core.dll + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll + False + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll + False + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe + False + + + False + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} + PepperDash_Essentials_Core + + + + + + + + + rem S# Pro preparation will execute after these operations + \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Generic/GenericSource.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Generic/GenericSource.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Generic/GenericSource.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Generic/GenericSource.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/AnalogWay/AnalogWayLiveCorePropertiesConfig.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/AnalogWay/AnalogWayLiveCorePropertiesConfig.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/AnalogWay/AnalogWayLiveCorePropertiesConfig.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/AnalogWay/AnalogWayLiveCorePropertiesConfig.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/AnalogWay/AnalongWayLiveCore.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/AnalogWay/AnalongWayLiveCore.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/AnalogWay/AnalongWayLiveCore.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/AnalogWay/AnalongWayLiveCore.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/TVOne/TVOneCorio.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/TVOne/TVOneCorio.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/TVOne/TVOneCorio.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/TVOne/TVOneCorio.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/TVOne/TVOneCorioPropertiesConfig.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/TVOne/TVOneCorioPropertiesConfig.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/TVOne/TVOneCorioPropertiesConfig.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/TVOne/TVOneCorioPropertiesConfig.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/TVOneCorio.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/TVOneCorio.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/TVOneCorio.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/TVOneCorio.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/TVOneCorioPropertiesConfig.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/TVOneCorioPropertiesConfig.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/TVOneCorioPropertiesConfig.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/TVOneCorioPropertiesConfig.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Power Controllers/DigitalLoggerPropertiesConfig.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Power Controllers/DigitalLoggerPropertiesConfig.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Power Controllers/DigitalLoggerPropertiesConfig.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Power Controllers/DigitalLoggerPropertiesConfig.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Power Controllers/Digitallogger.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Power Controllers/Digitallogger.cs similarity index 99% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Power Controllers/Digitallogger.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Power Controllers/Digitallogger.cs index ee33b5e6..6c844c29 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Power Controllers/Digitallogger.cs +++ b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Power Controllers/Digitallogger.cs @@ -11,13 +11,13 @@ using Crestron.SimplSharp.Net.Http; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.Core.Config; using PepperDash.Essentials; namespace PepperDash.Essentials.Devices.Common -{ +{ [Obsolete("This Device will be moved to a plugin in a future update")] public class DigitalLogger : EssentialsBridgeableDevice { diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Properties/AssemblyInfo.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Properties/AssemblyInfo.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Properties/AssemblyInfo.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Properties/AssemblyInfo.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Properties/ControlSystem.cfg b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Properties/ControlSystem.cfg similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Properties/ControlSystem.cfg rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Properties/ControlSystem.cfg diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/SetTopBox/IRSetTopBoxBase.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/SetTopBox/IRSetTopBoxBase.cs similarity index 97% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/SetTopBox/IRSetTopBoxBase.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/SetTopBox/IRSetTopBoxBase.cs index db72d8eb..e18e8e19 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/SetTopBox/IRSetTopBoxBase.cs +++ b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/SetTopBox/IRSetTopBoxBase.cs @@ -1,518 +1,518 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.Core.Presets; -using PepperDash.Essentials.Core.Routing; -using PepperDash.Essentials.Core.DeviceTypeInterfaces; - -namespace PepperDash.Essentials.Devices.Common -{ - [Description("Wrapper class for an IR Set Top Box")] - public class IRSetTopBoxBase : EssentialsBridgeableDevice, ISetTopBoxControls, IRoutingOutputs, IUsageTracking, IHasPowerControl, ITvPresetsProvider - { - public IrOutputPortController IrPort { get; private set; } - - public uint DisplayUiType { get { return DisplayUiConstants.TypeDirecTv; } } - public ushort IrPulseTime { get; set; } - - public bool HasPresets { get; set; } - public bool HasDvr { get; set; } - public bool HasDpad { get; set; } - public bool HasNumeric { get; set; } - - public DevicePresetsModel TvPresets { get; private set; } - - public IRSetTopBoxBase(string key, string name, IrOutputPortController portCont, - SetTopBoxPropertiesConfig props) - : base(key, name) - { - IrPort = portCont; - IrPulseTime = 200; - - if (props.IrPulseTime > 0) - { - IrPulseTime = (ushort)props.IrPulseTime; - } - - DeviceManager.AddDevice(portCont); - - HasPresets = props.HasPresets; - HasDvr = props.HasDvr; - HasDpad = props.HasDpad; - HasNumeric = props.HasNumeric; - - HasKeypadAccessoryButton1 = true; - KeypadAccessoryButton1Command = "Dash"; - KeypadAccessoryButton1Label = "-"; - - HasKeypadAccessoryButton2 = true; - KeypadAccessoryButton2Command = "KEYPAD_ENTER"; - KeypadAccessoryButton2Label = "Enter"; - - AnyVideoOut = new RoutingOutputPort(RoutingPortNames.AnyVideoOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null, this); - AnyAudioOut = new RoutingOutputPort(RoutingPortNames.AnyAudioOut, eRoutingSignalType.Audio, - eRoutingPortConnectionType.DigitalAudio, null, this); - OutputPorts = new RoutingPortCollection { AnyVideoOut, AnyAudioOut }; - } - - public void LoadPresets(string filePath) - { - TvPresets = new DevicePresetsModel(Key + "-presets", this, filePath); - DeviceManager.AddDevice(TvPresets); - } - - - #region ISetTopBoxControls Members - - public void DvrList(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_DVR, pressRelease); - } - - public void Replay(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_REPLAY, pressRelease); - } - - #endregion - - #region IDPad Members - - public void Up(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_UP_ARROW, pressRelease); - } - - public void Down(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_DN_ARROW, pressRelease); - } - - public void Left(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_LEFT_ARROW, pressRelease); - } - - public void Right(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_RIGHT_ARROW, pressRelease); - } - - public void Select(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_ENTER, pressRelease); - } - - public void Menu(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_MENU, pressRelease); - } - - public void Exit(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_EXIT, pressRelease); - } - - #endregion - - #region INumericKeypad Members - - public void Digit0(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_0, pressRelease); - } - - public void Digit1(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_1, pressRelease); - } - - public void Digit2(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_2, pressRelease); - } - - public void Digit3(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_3, pressRelease); - } - - public void Digit4(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_4, pressRelease); - } - - public void Digit5(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_5, pressRelease); - } - - public void Digit6(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_6, pressRelease); - } - - public void Digit7(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_7, pressRelease); - } - - public void Digit8(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_8, pressRelease); - } - - public void Digit9(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_9, pressRelease); - } - - /// - /// Defaults to true - /// - public bool HasKeypadAccessoryButton1 { get; set; } - - /// - /// Defaults to "-" - /// - public string KeypadAccessoryButton1Label { get; set; } - - - /// - /// Defaults to "Dash" - /// - public string KeypadAccessoryButton1Command { get; set; } - - public void KeypadAccessoryButton1(bool pressRelease) - { - IrPort.PressRelease(KeypadAccessoryButton1Command, pressRelease); - } - - /// - /// Defaults to true - /// - public bool HasKeypadAccessoryButton2 { get; set; } - - /// - /// Defaults to "Enter" - /// - public string KeypadAccessoryButton2Label { get; set; } - - - /// - /// Defaults to "Enter" - /// - public string KeypadAccessoryButton2Command { get; set; } - - public void KeypadAccessoryButton2(bool pressRelease) - { - IrPort.PressRelease(KeypadAccessoryButton2Command, pressRelease); - } - - #endregion - - #region ISetTopBoxNumericKeypad Members - - /// - /// Corresponds to "dash" IR command - /// - public void Dash(bool pressRelease) - { - IrPort.PressRelease("dash", pressRelease); - } - - /// - /// Corresponds to "numericEnter" IR command - /// - public void KeypadEnter(bool pressRelease) - { - IrPort.PressRelease("numericEnter", pressRelease); - } - - #endregion - - #region IChannelFunctions Members - - public void ChannelUp(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_CH_PLUS, pressRelease); - } - - public void ChannelDown(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_CH_MINUS, pressRelease); - } - - public void LastChannel(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_LAST, pressRelease); - } - - public void Guide(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_GUIDE, pressRelease); - } - - public void Info(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_INFO, pressRelease); - } - - #endregion - - #region IColorFunctions Members - - public void Red(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_RED, pressRelease); - } - - public void Green(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_GREEN, pressRelease); - } - - public void Yellow(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_YELLOW, pressRelease); - } - - public void Blue(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_BLUE, pressRelease); - } - - #endregion - - #region IRoutingOutputs Members - - public RoutingOutputPort AnyVideoOut { get; private set; } - public RoutingOutputPort AnyAudioOut { get; private set; } - public RoutingPortCollection OutputPorts { get; private set; } - - #endregion - - #region ITransport Members - - public void ChapMinus(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_REPLAY, pressRelease); - } - - public void ChapPlus(bool pressRelease) - { - } - - public void FFwd(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_FSCAN, pressRelease); - } - - public void Pause(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_RSCAN, pressRelease); - } - - public void Play(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_PLAY, pressRelease); - } - - public void Record(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_RECORD, pressRelease); - } - - public void Rewind(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_RSCAN, pressRelease); - } - - public void Stop(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_STOP, pressRelease); - } - - #endregion - - #region IUsageTracking Members - - public UsageTracking UsageTracker { get; set; } - - #endregion - - #region IPower Members - - public void PowerOn() - { - IrPort.Pulse(IROutputStandardCommands.IROut_POWER_ON, IrPulseTime); - } - - public void PowerOff() - { - IrPort.Pulse(IROutputStandardCommands.IROut_POWER_OFF, IrPulseTime); - } - - public void PowerToggle() - { - IrPort.Pulse(IROutputStandardCommands.IROut_POWER, IrPulseTime); - } - - #endregion - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new SetTopBoxControllerJoinMap(joinStart); - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - Debug.Console(0, "Linking to SetTopBox: {0}", Name); - - trilist.OnlineStatusChange += new OnlineStatusChangeEventHandler((o, a) => - { - if (a.DeviceOnLine) - { - trilist.StringInput[joinMap.Name.JoinNumber].StringValue = Name; - } - }); - - - var stbBase = this as ISetTopBoxControls; - if (stbBase != null) - { - trilist.BooleanInput[joinMap.HasDpad.JoinNumber].BoolValue = stbBase.HasDpad; - trilist.BooleanInput[joinMap.HasNumeric.JoinNumber].BoolValue = stbBase.HasNumeric; - trilist.BooleanInput[joinMap.HasDvr.JoinNumber].BoolValue = stbBase.HasDvr; - trilist.BooleanInput[joinMap.HasPresets.JoinNumber].BoolValue = stbBase.HasPresets; - - trilist.SetBoolSigAction(joinMap.DvrList.JoinNumber, stbBase.DvrList); - trilist.SetBoolSigAction(joinMap.Replay.JoinNumber, stbBase.Replay); - - trilist.SetStringSigAction(joinMap.LoadPresets.JoinNumber, stbBase.LoadPresets); - } - - var stbPower = this as IHasPowerControl; - if (stbPower != null) - { - trilist.SetSigTrueAction(joinMap.PowerOn.JoinNumber, stbPower.PowerOn); - trilist.SetSigTrueAction(joinMap.PowerOff.JoinNumber, stbPower.PowerOff); - trilist.SetSigTrueAction(joinMap.PowerToggle.JoinNumber, stbPower.PowerToggle); - } - - var stbDPad = this as IDPad; - if (stbDPad != null) - { - trilist.SetBoolSigAction(joinMap.Up.JoinNumber, stbDPad.Up); - trilist.SetBoolSigAction(joinMap.Down.JoinNumber, stbDPad.Down); - trilist.SetBoolSigAction(joinMap.Left.JoinNumber, stbDPad.Left); - trilist.SetBoolSigAction(joinMap.Right.JoinNumber, stbDPad.Right); - trilist.SetBoolSigAction(joinMap.Select.JoinNumber, stbDPad.Select); - trilist.SetBoolSigAction(joinMap.Menu.JoinNumber, stbDPad.Menu); - trilist.SetBoolSigAction(joinMap.Exit.JoinNumber, stbDPad.Exit); - } - - var stbChannel = this as IChannel; - if (stbChannel != null) - { - trilist.SetBoolSigAction(joinMap.ChannelUp.JoinNumber, stbChannel.ChannelUp); - trilist.SetBoolSigAction(joinMap.ChannelDown.JoinNumber, stbChannel.ChannelDown); - trilist.SetBoolSigAction(joinMap.LastChannel.JoinNumber, stbChannel.LastChannel); - trilist.SetBoolSigAction(joinMap.Guide.JoinNumber, stbChannel.Guide); - trilist.SetBoolSigAction(joinMap.Info.JoinNumber, stbChannel.Info); - trilist.SetBoolSigAction(joinMap.Exit.JoinNumber, stbChannel.Exit); - } - - var stbColor = this as IColor; - if (stbColor != null) - { - trilist.SetBoolSigAction(joinMap.Red.JoinNumber, stbColor.Red); - trilist.SetBoolSigAction(joinMap.Green.JoinNumber, stbColor.Green); - trilist.SetBoolSigAction(joinMap.Yellow.JoinNumber, stbColor.Yellow); - trilist.SetBoolSigAction(joinMap.Blue.JoinNumber, stbColor.Blue); - } - - var stbKeypad = this as ISetTopBoxNumericKeypad; - if (stbKeypad != null) - { - trilist.StringInput[joinMap.KeypadAccessoryButton1Label.JoinNumber].StringValue = stbKeypad.KeypadAccessoryButton1Label; - trilist.StringInput[joinMap.KeypadAccessoryButton2Label.JoinNumber].StringValue = stbKeypad.KeypadAccessoryButton2Label; - - trilist.BooleanInput[joinMap.HasKeypadAccessoryButton1.JoinNumber].BoolValue = stbKeypad.HasKeypadAccessoryButton1; - trilist.BooleanInput[joinMap.HasKeypadAccessoryButton2.JoinNumber].BoolValue = stbKeypad.HasKeypadAccessoryButton2; - - trilist.SetBoolSigAction(joinMap.Digit0.JoinNumber, stbKeypad.Digit0); - trilist.SetBoolSigAction(joinMap.Digit1.JoinNumber, stbKeypad.Digit1); - trilist.SetBoolSigAction(joinMap.Digit2.JoinNumber, stbKeypad.Digit2); - trilist.SetBoolSigAction(joinMap.Digit3.JoinNumber, stbKeypad.Digit3); - trilist.SetBoolSigAction(joinMap.Digit4.JoinNumber, stbKeypad.Digit4); - trilist.SetBoolSigAction(joinMap.Digit5.JoinNumber, stbKeypad.Digit5); - trilist.SetBoolSigAction(joinMap.Digit6.JoinNumber, stbKeypad.Digit6); - trilist.SetBoolSigAction(joinMap.Digit7.JoinNumber, stbKeypad.Digit7); - trilist.SetBoolSigAction(joinMap.Digit8.JoinNumber, stbKeypad.Digit8); - trilist.SetBoolSigAction(joinMap.Digit9.JoinNumber, stbKeypad.Digit9); - trilist.SetBoolSigAction(joinMap.KeypadAccessoryButton1Press.JoinNumber, stbKeypad.KeypadAccessoryButton1); - trilist.SetBoolSigAction(joinMap.KeypadAccessoryButton2Press.JoinNumber, stbKeypad.KeypadAccessoryButton1); - trilist.SetBoolSigAction(joinMap.Dash.JoinNumber, stbKeypad.Dash); - trilist.SetBoolSigAction(joinMap.KeypadEnter.JoinNumber, stbKeypad.KeypadEnter); - } - - var stbTransport = this as ITransport; - if (stbTransport != null) - { - trilist.SetBoolSigAction(joinMap.Play.JoinNumber, stbTransport.Play); - trilist.SetBoolSigAction(joinMap.Pause.JoinNumber, stbTransport.Pause); - trilist.SetBoolSigAction(joinMap.Rewind.JoinNumber, stbTransport.Rewind); - trilist.SetBoolSigAction(joinMap.FFwd.JoinNumber, stbTransport.FFwd); - trilist.SetBoolSigAction(joinMap.ChapMinus.JoinNumber, stbTransport.ChapMinus); - trilist.SetBoolSigAction(joinMap.ChapPlus.JoinNumber, stbTransport.ChapPlus); - trilist.SetBoolSigAction(joinMap.Stop.JoinNumber, stbTransport.Stop); - trilist.SetBoolSigAction(joinMap.Record.JoinNumber, stbTransport.Record); - } - } - } - - public class IRSetTopBoxBaseFactory : EssentialsDeviceFactory - { - public IRSetTopBoxBaseFactory() - { - TypeNames = new List() { "settopbox" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new SetTopBox Device"); - var irCont = IRPortHelper.GetIrOutputPortController(dc); - var config = dc.Properties.ToObject(); - var stb = new IRSetTopBoxBase(dc.Key, dc.Name, irCont, config); - - var listName = dc.Properties.Value("presetsList"); - if (listName != null) - stb.LoadPresets(listName); - return stb; - - } - } - +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.Core.Presets; +using PepperDash.Essentials.Core.Routing; +using PepperDash.Essentials.Core.DeviceTypeInterfaces; + +namespace PepperDash.Essentials.Devices.Common +{ + [Description("Wrapper class for an IR Set Top Box")] + public class IRSetTopBoxBase : EssentialsBridgeableDevice, ISetTopBoxControls, IRoutingOutputs, IUsageTracking, IHasPowerControl, ITvPresetsProvider + { + public IrOutputPortController IrPort { get; private set; } + + public uint DisplayUiType { get { return DisplayUiConstants.TypeDirecTv; } } + public ushort IrPulseTime { get; set; } + + public bool HasPresets { get; set; } + public bool HasDvr { get; set; } + public bool HasDpad { get; set; } + public bool HasNumeric { get; set; } + + public DevicePresetsModel TvPresets { get; private set; } + + public IRSetTopBoxBase(string key, string name, IrOutputPortController portCont, + SetTopBoxPropertiesConfig props) + : base(key, name) + { + IrPort = portCont; + IrPulseTime = 200; + + if (props.IrPulseTime > 0) + { + IrPulseTime = (ushort)props.IrPulseTime; + } + + DeviceManager.AddDevice(portCont); + + HasPresets = props.HasPresets; + HasDvr = props.HasDvr; + HasDpad = props.HasDpad; + HasNumeric = props.HasNumeric; + + HasKeypadAccessoryButton1 = true; + KeypadAccessoryButton1Command = "Dash"; + KeypadAccessoryButton1Label = "-"; + + HasKeypadAccessoryButton2 = true; + KeypadAccessoryButton2Command = "KEYPAD_ENTER"; + KeypadAccessoryButton2Label = "Enter"; + + AnyVideoOut = new RoutingOutputPort(RoutingPortNames.AnyVideoOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, null, this); + AnyAudioOut = new RoutingOutputPort(RoutingPortNames.AnyAudioOut, eRoutingSignalType.Audio, + eRoutingPortConnectionType.DigitalAudio, null, this); + OutputPorts = new RoutingPortCollection { AnyVideoOut, AnyAudioOut }; + } + + public void LoadPresets(string filePath) + { + TvPresets = new DevicePresetsModel(Key + "-presets", this, filePath); + DeviceManager.AddDevice(TvPresets); + } + + + #region ISetTopBoxControls Members + + public void DvrList(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_DVR, pressRelease); + } + + public void Replay(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_REPLAY, pressRelease); + } + + #endregion + + #region IDPad Members + + public void Up(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_UP_ARROW, pressRelease); + } + + public void Down(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_DN_ARROW, pressRelease); + } + + public void Left(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_LEFT_ARROW, pressRelease); + } + + public void Right(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_RIGHT_ARROW, pressRelease); + } + + public void Select(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_ENTER, pressRelease); + } + + public void Menu(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_MENU, pressRelease); + } + + public void Exit(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_EXIT, pressRelease); + } + + #endregion + + #region INumericKeypad Members + + public void Digit0(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_0, pressRelease); + } + + public void Digit1(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_1, pressRelease); + } + + public void Digit2(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_2, pressRelease); + } + + public void Digit3(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_3, pressRelease); + } + + public void Digit4(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_4, pressRelease); + } + + public void Digit5(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_5, pressRelease); + } + + public void Digit6(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_6, pressRelease); + } + + public void Digit7(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_7, pressRelease); + } + + public void Digit8(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_8, pressRelease); + } + + public void Digit9(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_9, pressRelease); + } + + /// + /// Defaults to true + /// + public bool HasKeypadAccessoryButton1 { get; set; } + + /// + /// Defaults to "-" + /// + public string KeypadAccessoryButton1Label { get; set; } + + + /// + /// Defaults to "Dash" + /// + public string KeypadAccessoryButton1Command { get; set; } + + public void KeypadAccessoryButton1(bool pressRelease) + { + IrPort.PressRelease(KeypadAccessoryButton1Command, pressRelease); + } + + /// + /// Defaults to true + /// + public bool HasKeypadAccessoryButton2 { get; set; } + + /// + /// Defaults to "Enter" + /// + public string KeypadAccessoryButton2Label { get; set; } + + + /// + /// Defaults to "Enter" + /// + public string KeypadAccessoryButton2Command { get; set; } + + public void KeypadAccessoryButton2(bool pressRelease) + { + IrPort.PressRelease(KeypadAccessoryButton2Command, pressRelease); + } + + #endregion + + #region ISetTopBoxNumericKeypad Members + + /// + /// Corresponds to "dash" IR command + /// + public void Dash(bool pressRelease) + { + IrPort.PressRelease("dash", pressRelease); + } + + /// + /// Corresponds to "numericEnter" IR command + /// + public void KeypadEnter(bool pressRelease) + { + IrPort.PressRelease("numericEnter", pressRelease); + } + + #endregion + + #region IChannelFunctions Members + + public void ChannelUp(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_CH_PLUS, pressRelease); + } + + public void ChannelDown(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_CH_MINUS, pressRelease); + } + + public void LastChannel(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_LAST, pressRelease); + } + + public void Guide(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_GUIDE, pressRelease); + } + + public void Info(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_INFO, pressRelease); + } + + #endregion + + #region IColorFunctions Members + + public void Red(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_RED, pressRelease); + } + + public void Green(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_GREEN, pressRelease); + } + + public void Yellow(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_YELLOW, pressRelease); + } + + public void Blue(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_BLUE, pressRelease); + } + + #endregion + + #region IRoutingOutputs Members + + public RoutingOutputPort AnyVideoOut { get; private set; } + public RoutingOutputPort AnyAudioOut { get; private set; } + public RoutingPortCollection OutputPorts { get; private set; } + + #endregion + + #region ITransport Members + + public void ChapMinus(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_REPLAY, pressRelease); + } + + public void ChapPlus(bool pressRelease) + { + } + + public void FFwd(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_FSCAN, pressRelease); + } + + public void Pause(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_RSCAN, pressRelease); + } + + public void Play(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_PLAY, pressRelease); + } + + public void Record(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_RECORD, pressRelease); + } + + public void Rewind(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_RSCAN, pressRelease); + } + + public void Stop(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_STOP, pressRelease); + } + + #endregion + + #region IUsageTracking Members + + public UsageTracking UsageTracker { get; set; } + + #endregion + + #region IPower Members + + public void PowerOn() + { + IrPort.Pulse(IROutputStandardCommands.IROut_POWER_ON, IrPulseTime); + } + + public void PowerOff() + { + IrPort.Pulse(IROutputStandardCommands.IROut_POWER_OFF, IrPulseTime); + } + + public void PowerToggle() + { + IrPort.Pulse(IROutputStandardCommands.IROut_POWER, IrPulseTime); + } + + #endregion + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new SetTopBoxControllerJoinMap(joinStart); + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + else + { + Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + } + + Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.Console(0, "Linking to SetTopBox: {0}", Name); + + trilist.OnlineStatusChange += new OnlineStatusChangeEventHandler((o, a) => + { + if (a.DeviceOnLine) + { + trilist.StringInput[joinMap.Name.JoinNumber].StringValue = Name; + } + }); + + + var stbBase = this as ISetTopBoxControls; + if (stbBase != null) + { + trilist.BooleanInput[joinMap.HasDpad.JoinNumber].BoolValue = stbBase.HasDpad; + trilist.BooleanInput[joinMap.HasNumeric.JoinNumber].BoolValue = stbBase.HasNumeric; + trilist.BooleanInput[joinMap.HasDvr.JoinNumber].BoolValue = stbBase.HasDvr; + trilist.BooleanInput[joinMap.HasPresets.JoinNumber].BoolValue = stbBase.HasPresets; + + trilist.SetBoolSigAction(joinMap.DvrList.JoinNumber, stbBase.DvrList); + trilist.SetBoolSigAction(joinMap.Replay.JoinNumber, stbBase.Replay); + + trilist.SetStringSigAction(joinMap.LoadPresets.JoinNumber, stbBase.LoadPresets); + } + + var stbPower = this as IHasPowerControl; + if (stbPower != null) + { + trilist.SetSigTrueAction(joinMap.PowerOn.JoinNumber, stbPower.PowerOn); + trilist.SetSigTrueAction(joinMap.PowerOff.JoinNumber, stbPower.PowerOff); + trilist.SetSigTrueAction(joinMap.PowerToggle.JoinNumber, stbPower.PowerToggle); + } + + var stbDPad = this as IDPad; + if (stbDPad != null) + { + trilist.SetBoolSigAction(joinMap.Up.JoinNumber, stbDPad.Up); + trilist.SetBoolSigAction(joinMap.Down.JoinNumber, stbDPad.Down); + trilist.SetBoolSigAction(joinMap.Left.JoinNumber, stbDPad.Left); + trilist.SetBoolSigAction(joinMap.Right.JoinNumber, stbDPad.Right); + trilist.SetBoolSigAction(joinMap.Select.JoinNumber, stbDPad.Select); + trilist.SetBoolSigAction(joinMap.Menu.JoinNumber, stbDPad.Menu); + trilist.SetBoolSigAction(joinMap.Exit.JoinNumber, stbDPad.Exit); + } + + var stbChannel = this as IChannel; + if (stbChannel != null) + { + trilist.SetBoolSigAction(joinMap.ChannelUp.JoinNumber, stbChannel.ChannelUp); + trilist.SetBoolSigAction(joinMap.ChannelDown.JoinNumber, stbChannel.ChannelDown); + trilist.SetBoolSigAction(joinMap.LastChannel.JoinNumber, stbChannel.LastChannel); + trilist.SetBoolSigAction(joinMap.Guide.JoinNumber, stbChannel.Guide); + trilist.SetBoolSigAction(joinMap.Info.JoinNumber, stbChannel.Info); + trilist.SetBoolSigAction(joinMap.Exit.JoinNumber, stbChannel.Exit); + } + + var stbColor = this as IColor; + if (stbColor != null) + { + trilist.SetBoolSigAction(joinMap.Red.JoinNumber, stbColor.Red); + trilist.SetBoolSigAction(joinMap.Green.JoinNumber, stbColor.Green); + trilist.SetBoolSigAction(joinMap.Yellow.JoinNumber, stbColor.Yellow); + trilist.SetBoolSigAction(joinMap.Blue.JoinNumber, stbColor.Blue); + } + + var stbKeypad = this as ISetTopBoxNumericKeypad; + if (stbKeypad != null) + { + trilist.StringInput[joinMap.KeypadAccessoryButton1Label.JoinNumber].StringValue = stbKeypad.KeypadAccessoryButton1Label; + trilist.StringInput[joinMap.KeypadAccessoryButton2Label.JoinNumber].StringValue = stbKeypad.KeypadAccessoryButton2Label; + + trilist.BooleanInput[joinMap.HasKeypadAccessoryButton1.JoinNumber].BoolValue = stbKeypad.HasKeypadAccessoryButton1; + trilist.BooleanInput[joinMap.HasKeypadAccessoryButton2.JoinNumber].BoolValue = stbKeypad.HasKeypadAccessoryButton2; + + trilist.SetBoolSigAction(joinMap.Digit0.JoinNumber, stbKeypad.Digit0); + trilist.SetBoolSigAction(joinMap.Digit1.JoinNumber, stbKeypad.Digit1); + trilist.SetBoolSigAction(joinMap.Digit2.JoinNumber, stbKeypad.Digit2); + trilist.SetBoolSigAction(joinMap.Digit3.JoinNumber, stbKeypad.Digit3); + trilist.SetBoolSigAction(joinMap.Digit4.JoinNumber, stbKeypad.Digit4); + trilist.SetBoolSigAction(joinMap.Digit5.JoinNumber, stbKeypad.Digit5); + trilist.SetBoolSigAction(joinMap.Digit6.JoinNumber, stbKeypad.Digit6); + trilist.SetBoolSigAction(joinMap.Digit7.JoinNumber, stbKeypad.Digit7); + trilist.SetBoolSigAction(joinMap.Digit8.JoinNumber, stbKeypad.Digit8); + trilist.SetBoolSigAction(joinMap.Digit9.JoinNumber, stbKeypad.Digit9); + trilist.SetBoolSigAction(joinMap.KeypadAccessoryButton1Press.JoinNumber, stbKeypad.KeypadAccessoryButton1); + trilist.SetBoolSigAction(joinMap.KeypadAccessoryButton2Press.JoinNumber, stbKeypad.KeypadAccessoryButton1); + trilist.SetBoolSigAction(joinMap.Dash.JoinNumber, stbKeypad.Dash); + trilist.SetBoolSigAction(joinMap.KeypadEnter.JoinNumber, stbKeypad.KeypadEnter); + } + + var stbTransport = this as ITransport; + if (stbTransport != null) + { + trilist.SetBoolSigAction(joinMap.Play.JoinNumber, stbTransport.Play); + trilist.SetBoolSigAction(joinMap.Pause.JoinNumber, stbTransport.Pause); + trilist.SetBoolSigAction(joinMap.Rewind.JoinNumber, stbTransport.Rewind); + trilist.SetBoolSigAction(joinMap.FFwd.JoinNumber, stbTransport.FFwd); + trilist.SetBoolSigAction(joinMap.ChapMinus.JoinNumber, stbTransport.ChapMinus); + trilist.SetBoolSigAction(joinMap.ChapPlus.JoinNumber, stbTransport.ChapPlus); + trilist.SetBoolSigAction(joinMap.Stop.JoinNumber, stbTransport.Stop); + trilist.SetBoolSigAction(joinMap.Record.JoinNumber, stbTransport.Record); + } + } + } + + public class IRSetTopBoxBaseFactory : EssentialsDeviceFactory + { + public IRSetTopBoxBaseFactory() + { + TypeNames = new List() { "settopbox" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new SetTopBox Device"); + var irCont = IRPortHelper.GetIrOutputPortController(dc); + var config = dc.Properties.ToObject(); + var stb = new IRSetTopBoxBase(dc.Key, dc.Name, irCont, config); + + var listName = dc.Properties.Value("presetsList"); + if (listName != null) + stb.LoadPresets(listName); + return stb; + + } + } + } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/SetTopBox/SetTopBoxPropertiesConfig.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/SetTopBox/SetTopBoxPropertiesConfig.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/SetTopBox/SetTopBoxPropertiesConfig.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/SetTopBox/SetTopBoxPropertiesConfig.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/SoftCodec/BlueJeansPc.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/SoftCodec/BlueJeansPc.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/SoftCodec/BlueJeansPc.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/SoftCodec/BlueJeansPc.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs similarity index 96% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs index 07df3602..a700cd16 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs +++ b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs @@ -1,218 +1,218 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharp.Reflection; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Routing; - -namespace PepperDash.Essentials.Devices.Common -{ - [Description("Wrapper class for an IR-Controlled AppleTV")] - public class AppleTV : EssentialsBridgeableDevice, IDPad, ITransport, IUiDisplayInfo, IRoutingOutputs - { - public IrOutputPortController IrPort { get; private set; } - public const string StandardDriverName = "Apple_AppleTV_4th_Gen_Essentials.ir"; - public uint DisplayUiType { get { return DisplayUiConstants.TypeAppleTv; } } - - public AppleTV(string key, string name, IrOutputPortController portCont) - : base(key, name) - { - IrPort = portCont; - DeviceManager.AddDevice(portCont); - - HdmiOut = new RoutingOutputPort(RoutingPortNames.HdmiOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null, this); - AnyAudioOut = new RoutingOutputPort(RoutingPortNames.AnyAudioOut, eRoutingSignalType.Audio, - eRoutingPortConnectionType.DigitalAudio, null, this); - OutputPorts = new RoutingPortCollection { HdmiOut, AnyAudioOut }; - - PrintExpectedIrCommands(); - } - - public void PrintExpectedIrCommands() - { - var cmds = typeof (AppleTvIrCommands).GetCType().GetFields(BindingFlags.Public | BindingFlags.Static); - - foreach (var value in cmds.Select(cmd => cmd.GetValue(null)).OfType()) - { - Debug.Console(2, this, "Expected IR Function Name: {0}", value); - } - } - - #region IDPad Members - - public void Up(bool pressRelease) - { - IrPort.PressRelease(AppleTvIrCommands.Up, pressRelease); - } - - public void Down(bool pressRelease) - { - IrPort.PressRelease(AppleTvIrCommands.Down, pressRelease); - } - - public void Left(bool pressRelease) - { - IrPort.PressRelease(AppleTvIrCommands.Left, pressRelease); - } - - public void Right(bool pressRelease) - { - IrPort.PressRelease(AppleTvIrCommands.Right, pressRelease); - } - - public void Select(bool pressRelease) - { - IrPort.PressRelease(AppleTvIrCommands.Enter, pressRelease); - } - - public void Menu(bool pressRelease) - { - IrPort.PressRelease(AppleTvIrCommands.Menu, pressRelease); - } - - public void Exit(bool pressRelease) - { - - } - - #endregion - - #region ITransport Members - - public void Play(bool pressRelease) - { - IrPort.PressRelease(AppleTvIrCommands.PlayPause, pressRelease); - } - - public void Pause(bool pressRelease) - { - IrPort.PressRelease(AppleTvIrCommands.PlayPause, pressRelease); - } - - /// - /// Not implemented - /// - /// - public void Rewind(bool pressRelease) - { - } - - /// - /// Not implemented - /// - /// - public void FFwd(bool pressRelease) - { - } - - /// - /// Not implemented - /// - /// - public void ChapMinus(bool pressRelease) - { - } - - /// - /// Not implemented - /// - /// - public void ChapPlus(bool pressRelease) - { - } - - /// - /// Not implemented - /// - /// - public void Stop(bool pressRelease) - { - } - - /// - /// Not implemented - /// - /// - public void Record(bool pressRelease) - { - } - - #endregion - - #region IRoutingOutputs Members - - public RoutingOutputPort HdmiOut { get; private set; } - public RoutingOutputPort AnyAudioOut { get; private set; } - public RoutingPortCollection OutputPorts { get; private set; } - - #endregion - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new AppleTvJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - Debug.Console(0, "Linking to Bridge Type {0}", GetType().Name); - - trilist.SetBoolSigAction(joinMap.UpArrow.JoinNumber, Up); - trilist.SetBoolSigAction(joinMap.DnArrow.JoinNumber, Down); - trilist.SetBoolSigAction(joinMap.LeftArrow.JoinNumber, Left); - trilist.SetBoolSigAction(joinMap.RightArrow.JoinNumber, Right); - trilist.SetBoolSigAction(joinMap.Select.JoinNumber, Select); - trilist.SetBoolSigAction(joinMap.Menu.JoinNumber, Menu); - trilist.SetBoolSigAction(joinMap.PlayPause.JoinNumber, Play); - } - } - - public class AppleTVFactory : EssentialsDeviceFactory - { - public AppleTVFactory() - { - TypeNames = new List() { "appletv" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new AppleTV Device"); - var irCont = IRPortHelper.GetIrOutputPortController(dc); - return new AppleTV(dc.Key, dc.Name, irCont); - } - } - - public static class AppleTvIrCommands - { - - public static string Up = "+"; - public static string Down = "-"; - public static string Left = IROutputStandardCommands.IROut_TRACK_MINUS; - public static string Right = IROutputStandardCommands.IROut_TRACK_PLUS; - public static string Enter = IROutputStandardCommands.IROut_ENTER; - public static string PlayPause = "PLAY/PAUSE"; - public static string Rewind = "REWIND"; - public static string Menu = "Menu"; - public static string FastForward = "FASTFORWARD"; - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharp.Reflection; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Routing; + +namespace PepperDash.Essentials.Devices.Common +{ + [Description("Wrapper class for an IR-Controlled AppleTV")] + public class AppleTV : EssentialsBridgeableDevice, IDPad, ITransport, IUiDisplayInfo, IRoutingOutputs + { + public IrOutputPortController IrPort { get; private set; } + public const string StandardDriverName = "Apple_AppleTV_4th_Gen_Essentials.ir"; + public uint DisplayUiType { get { return DisplayUiConstants.TypeAppleTv; } } + + public AppleTV(string key, string name, IrOutputPortController portCont) + : base(key, name) + { + IrPort = portCont; + DeviceManager.AddDevice(portCont); + + HdmiOut = new RoutingOutputPort(RoutingPortNames.HdmiOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, null, this); + AnyAudioOut = new RoutingOutputPort(RoutingPortNames.AnyAudioOut, eRoutingSignalType.Audio, + eRoutingPortConnectionType.DigitalAudio, null, this); + OutputPorts = new RoutingPortCollection { HdmiOut, AnyAudioOut }; + + PrintExpectedIrCommands(); + } + + public void PrintExpectedIrCommands() + { + var cmds = typeof (AppleTvIrCommands).GetCType().GetFields(BindingFlags.Public | BindingFlags.Static); + + foreach (var value in cmds.Select(cmd => cmd.GetValue(null)).OfType()) + { + Debug.Console(2, this, "Expected IR Function Name: {0}", value); + } + } + + #region IDPad Members + + public void Up(bool pressRelease) + { + IrPort.PressRelease(AppleTvIrCommands.Up, pressRelease); + } + + public void Down(bool pressRelease) + { + IrPort.PressRelease(AppleTvIrCommands.Down, pressRelease); + } + + public void Left(bool pressRelease) + { + IrPort.PressRelease(AppleTvIrCommands.Left, pressRelease); + } + + public void Right(bool pressRelease) + { + IrPort.PressRelease(AppleTvIrCommands.Right, pressRelease); + } + + public void Select(bool pressRelease) + { + IrPort.PressRelease(AppleTvIrCommands.Enter, pressRelease); + } + + public void Menu(bool pressRelease) + { + IrPort.PressRelease(AppleTvIrCommands.Menu, pressRelease); + } + + public void Exit(bool pressRelease) + { + + } + + #endregion + + #region ITransport Members + + public void Play(bool pressRelease) + { + IrPort.PressRelease(AppleTvIrCommands.PlayPause, pressRelease); + } + + public void Pause(bool pressRelease) + { + IrPort.PressRelease(AppleTvIrCommands.PlayPause, pressRelease); + } + + /// + /// Not implemented + /// + /// + public void Rewind(bool pressRelease) + { + } + + /// + /// Not implemented + /// + /// + public void FFwd(bool pressRelease) + { + } + + /// + /// Not implemented + /// + /// + public void ChapMinus(bool pressRelease) + { + } + + /// + /// Not implemented + /// + /// + public void ChapPlus(bool pressRelease) + { + } + + /// + /// Not implemented + /// + /// + public void Stop(bool pressRelease) + { + } + + /// + /// Not implemented + /// + /// + public void Record(bool pressRelease) + { + } + + #endregion + + #region IRoutingOutputs Members + + public RoutingOutputPort HdmiOut { get; private set; } + public RoutingOutputPort AnyAudioOut { get; private set; } + public RoutingPortCollection OutputPorts { get; private set; } + + #endregion + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new AppleTvJoinMap(joinStart); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + else + { + Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + } + + Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.Console(0, "Linking to Bridge Type {0}", GetType().Name); + + trilist.SetBoolSigAction(joinMap.UpArrow.JoinNumber, Up); + trilist.SetBoolSigAction(joinMap.DnArrow.JoinNumber, Down); + trilist.SetBoolSigAction(joinMap.LeftArrow.JoinNumber, Left); + trilist.SetBoolSigAction(joinMap.RightArrow.JoinNumber, Right); + trilist.SetBoolSigAction(joinMap.Select.JoinNumber, Select); + trilist.SetBoolSigAction(joinMap.Menu.JoinNumber, Menu); + trilist.SetBoolSigAction(joinMap.PlayPause.JoinNumber, Play); + } + } + + public class AppleTVFactory : EssentialsDeviceFactory + { + public AppleTVFactory() + { + TypeNames = new List() { "appletv" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new AppleTV Device"); + var irCont = IRPortHelper.GetIrOutputPortController(dc); + return new AppleTV(dc.Key, dc.Name, irCont); + } + } + + public static class AppleTvIrCommands + { + + public static string Up = "+"; + public static string Down = "-"; + public static string Left = IROutputStandardCommands.IROut_TRACK_MINUS; + public static string Right = IROutputStandardCommands.IROut_TRACK_PLUS; + public static string Enter = IROutputStandardCommands.IROut_ENTER; + public static string PlayPause = "PLAY/PAUSE"; + public static string Rewind = "REWIND"; + public static string Menu = "Menu"; + public static string FastForward = "FASTFORWARD"; + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/Roku.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/Roku.cs similarity index 99% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/Roku.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/Roku.cs index de848406..4e053b78 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/Roku.cs +++ b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/Roku.cs @@ -12,7 +12,7 @@ using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Routing; namespace PepperDash.Essentials.Devices.Common -{ +{ [Description("Wrapper class for an IR-Controlled Roku")] public class Roku2 : EssentialsDevice, IDPad, ITransport, IUiDisplayInfo, IRoutingOutputs { diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/BookingsDataClasses.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/BookingsDataClasses.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/BookingsDataClasses.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/BookingsDataClasses.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CallHistoryDataClasses.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CallHistoryDataClasses.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CallHistoryDataClasses.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CallHistoryDataClasses.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCamera.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCamera.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCamera.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCamera.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCodec.cs.orig b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCodec.cs.orig similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCodec.cs.orig rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCodec.cs.orig diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCodecJoinMap.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCodecJoinMap.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCodecJoinMap.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCodecJoinMap.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs.orig b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs.orig similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs.orig rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs.orig diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodecPropertiesConfig.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodecPropertiesConfig.cs similarity index 96% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodecPropertiesConfig.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodecPropertiesConfig.cs index 7f36b0bf..c254a5ae 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodecPropertiesConfig.cs +++ b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodecPropertiesConfig.cs @@ -1,89 +1,89 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -using PepperDash.Core; -using PepperDash.Essentials.Core; - -using Newtonsoft.Json; - -namespace PepperDash.Essentials.Devices.Common.Codec -{ - public class CiscoSparkCodecPropertiesConfig - { - [JsonProperty("communicationMonitorProperties")] - public CommunicationMonitorConfig CommunicationMonitorProperties { get; set; } - - [JsonProperty("favorites")] - public List Favorites { get; set; } - - /// - /// Valid values: "Local" or "Corporate" - /// - [JsonProperty("phonebookMode")] - public string PhonebookMode { get; set; } - - [JsonProperty("showSelfViewByDefault")] - public bool ShowSelfViewByDefault { get; set; } - - [JsonProperty("sharing")] - public SharingProperties Sharing { get; set; } - - /// - /// Enables external source switching capability - /// - [JsonProperty("externalSourceListEnabled")] - public bool ExternalSourceListEnabled { get; set; } - - /// - /// The name of the routing input port on the codec to which the external switch is connected - /// - [JsonProperty("externalSourceInputPort")] - public string ExternalSourceInputPort { get; set; } - - /// - /// Optionsal property to set the limit of any phonebook queries for directory or searching - /// - [JsonProperty("phonebookResultsLimit")] - public uint PhonebookResultsLimit { get; set; } - - [JsonProperty("UiBranding")] - public BrandingLogoProperties UiBranding { get; set; } - - [JsonProperty("cameraInfo")] - public List CameraInfo { get; set; } - - - public CiscoSparkCodecPropertiesConfig() - { - CameraInfo = new List(); - } - } - - public class SharingProperties - { - [JsonProperty("autoShareContentWhileInCall")] - public bool AutoShareContentWhileInCall { get; set; } - } - - public class BrandingLogoProperties - { - [JsonProperty("enable")] - public bool Enable { get; set; } - - [JsonProperty("brandingUrl")] - public string BrandingUrl { get; set; } - } - - /// - /// Describes configuration information for the near end cameras - /// - public class CameraInfo - { - public int CameraNumber { get; set; } - public string Name { get; set; } - public int SourceId { get; set; } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using PepperDash.Core; +using PepperDash.Essentials.Core; + +using Newtonsoft.Json; + +namespace PepperDash.Essentials.Devices.Common.Codec +{ + public class CiscoSparkCodecPropertiesConfig + { + [JsonProperty("communicationMonitorProperties")] + public CommunicationMonitorConfig CommunicationMonitorProperties { get; set; } + + [JsonProperty("favorites")] + public List Favorites { get; set; } + + /// + /// Valid values: "Local" or "Corporate" + /// + [JsonProperty("phonebookMode")] + public string PhonebookMode { get; set; } + + [JsonProperty("showSelfViewByDefault")] + public bool ShowSelfViewByDefault { get; set; } + + [JsonProperty("sharing")] + public SharingProperties Sharing { get; set; } + + /// + /// Enables external source switching capability + /// + [JsonProperty("externalSourceListEnabled")] + public bool ExternalSourceListEnabled { get; set; } + + /// + /// The name of the routing input port on the codec to which the external switch is connected + /// + [JsonProperty("externalSourceInputPort")] + public string ExternalSourceInputPort { get; set; } + + /// + /// Optionsal property to set the limit of any phonebook queries for directory or searching + /// + [JsonProperty("phonebookResultsLimit")] + public uint PhonebookResultsLimit { get; set; } + + [JsonProperty("UiBranding")] + public BrandingLogoProperties UiBranding { get; set; } + + [JsonProperty("cameraInfo")] + public List CameraInfo { get; set; } + + + public CiscoSparkCodecPropertiesConfig() + { + CameraInfo = new List(); + } + } + + public class SharingProperties + { + [JsonProperty("autoShareContentWhileInCall")] + public bool AutoShareContentWhileInCall { get; set; } + } + + public class BrandingLogoProperties + { + [JsonProperty("enable")] + public bool Enable { get; set; } + + [JsonProperty("brandingUrl")] + public string BrandingUrl { get; set; } + } + + /// + /// Describes configuration information for the near end cameras + /// + public class CameraInfo + { + public int CameraNumber { get; set; } + public string Name { get; set; } + public int SourceId { get; set; } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/HttpApiServer.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/HttpApiServer.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/HttpApiServer.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/HttpApiServer.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/PhonebookDataClasses.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/PhonebookDataClasses.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/PhonebookDataClasses.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/PhonebookDataClasses.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/RoomPresets.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/RoomPresets.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/RoomPresets.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/RoomPresets.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xConfiguration.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xConfiguration.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xConfiguration.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xConfiguration.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xEvent.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xEvent.cs similarity index 96% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xEvent.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xEvent.cs index 171e7bd0..a797103c 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xEvent.cs +++ b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xEvent.cs @@ -1,166 +1,166 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco -{ - /// - /// This class exists to capture serialized data sent back by a Cisco codec in JSON output mode - /// - public class CiscoCodecEvents - { - public class CauseValue - { - public string id { get; set; } - public string Value { get; set; } - } - - public class CauseType - { - public string id { get; set; } - public string Value { get; set; } - } - - public class CauseString - { - public string id { get; set; } - public string Value { get; set; } - } - - public class OrigCallDirection - { - public string id { get; set; } - public string Value { get; set; } - } - - public class RemoteURI - { - public string id { get; set; } - public string Value { get; set; } - } - - public class DisplayName - { - public string id { get; set; } - public string Value { get; set; } - } - - public class CallId - { - public string id { get; set; } - public string Value { get; set; } - } - - public class CauseCode - { - public string id { get; set; } - public string Value { get; set; } - } - - public class CauseOrigin - { - public string id { get; set; } - public string Value { get; set; } - } - - public class Protocol - { - public string id { get; set; } - public string Value { get; set; } - } - - public class Duration - { - public string id { get; set; } - public string Value { get; set; } - } - - public class CallType - { - public string id { get; set; } - public string Value { get; set; } - } - - public class CallRate - { - public string id { get; set; } - public string Value { get; set; } - } - - public class Encryption - { - public string id { get; set; } - public string Value { get; set; } - } - - public class RequestedURI - { - public string id { get; set; } - public string Value { get; set; } - } - - public class PeopleCountAverage - { - public string id { get; set; } - public string Value { get; set; } - } - - public class CallDisconnect - { - public string id { get; set; } - public CauseValue CauseValue { get; set; } - public CauseType CauseType { get; set; } - public CauseString CauseString { get; set; } - public OrigCallDirection OrigCallDirection { get; set; } - public RemoteURI RemoteURI { get; set; } - public DisplayName DisplayName { get; set; } - public CallId CallId { get; set; } - public CauseCode CauseCode { get; set; } - public CauseOrigin CauseOrigin { get; set; } - public Protocol Protocol { get; set; } - public Duration Duration { get; set; } - public CallType CallType { get; set; } - public CallRate CallRate { get; set; } - public Encryption Encryption { get; set; } - public RequestedURI RequestedURI { get; set; } - public PeopleCountAverage PeopleCountAverage { get; set; } - } - public class UserInterface - { - public string id { get; set; } - public Presentation Presentation { get; set; } - } - public class Presentation - { - public string id { get; set; } - public ExternalSource ExternalSource { get; set; } - } - public class ExternalSource - { - public string id { get; set; } - public Selected Selected { get; set; } - } - public class Selected - { - public string id { get; set; } - public SourceIdentifier SourceIdentifier { get; set; } - } - public class SourceIdentifier - { - public string id { get; set; } - public string Value { get; set; } - } - public class Event - { - public CallDisconnect CallDisconnect { get; set; } - public UserInterface UserInterface { get; set; } - } - - public class RootObject - { - public Event Event { get; set; } - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco +{ + /// + /// This class exists to capture serialized data sent back by a Cisco codec in JSON output mode + /// + public class CiscoCodecEvents + { + public class CauseValue + { + public string id { get; set; } + public string Value { get; set; } + } + + public class CauseType + { + public string id { get; set; } + public string Value { get; set; } + } + + public class CauseString + { + public string id { get; set; } + public string Value { get; set; } + } + + public class OrigCallDirection + { + public string id { get; set; } + public string Value { get; set; } + } + + public class RemoteURI + { + public string id { get; set; } + public string Value { get; set; } + } + + public class DisplayName + { + public string id { get; set; } + public string Value { get; set; } + } + + public class CallId + { + public string id { get; set; } + public string Value { get; set; } + } + + public class CauseCode + { + public string id { get; set; } + public string Value { get; set; } + } + + public class CauseOrigin + { + public string id { get; set; } + public string Value { get; set; } + } + + public class Protocol + { + public string id { get; set; } + public string Value { get; set; } + } + + public class Duration + { + public string id { get; set; } + public string Value { get; set; } + } + + public class CallType + { + public string id { get; set; } + public string Value { get; set; } + } + + public class CallRate + { + public string id { get; set; } + public string Value { get; set; } + } + + public class Encryption + { + public string id { get; set; } + public string Value { get; set; } + } + + public class RequestedURI + { + public string id { get; set; } + public string Value { get; set; } + } + + public class PeopleCountAverage + { + public string id { get; set; } + public string Value { get; set; } + } + + public class CallDisconnect + { + public string id { get; set; } + public CauseValue CauseValue { get; set; } + public CauseType CauseType { get; set; } + public CauseString CauseString { get; set; } + public OrigCallDirection OrigCallDirection { get; set; } + public RemoteURI RemoteURI { get; set; } + public DisplayName DisplayName { get; set; } + public CallId CallId { get; set; } + public CauseCode CauseCode { get; set; } + public CauseOrigin CauseOrigin { get; set; } + public Protocol Protocol { get; set; } + public Duration Duration { get; set; } + public CallType CallType { get; set; } + public CallRate CallRate { get; set; } + public Encryption Encryption { get; set; } + public RequestedURI RequestedURI { get; set; } + public PeopleCountAverage PeopleCountAverage { get; set; } + } + public class UserInterface + { + public string id { get; set; } + public Presentation Presentation { get; set; } + } + public class Presentation + { + public string id { get; set; } + public ExternalSource ExternalSource { get; set; } + } + public class ExternalSource + { + public string id { get; set; } + public Selected Selected { get; set; } + } + public class Selected + { + public string id { get; set; } + public SourceIdentifier SourceIdentifier { get; set; } + } + public class SourceIdentifier + { + public string id { get; set; } + public string Value { get; set; } + } + public class Event + { + public CallDisconnect CallDisconnect { get; set; } + public UserInterface UserInterface { get; set; } + } + + public class RootObject + { + public Event Event { get; set; } + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xStatus.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xStatus.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xStatus.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xStatus.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xStatusSparkPlus.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xStatusSparkPlus.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xStatusSparkPlus.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xStatusSparkPlus.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CodecActiveCallItem.cs.orig b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CodecActiveCallItem.cs.orig similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CodecActiveCallItem.cs.orig rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CodecActiveCallItem.cs.orig diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ConvertiblePreset.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ConvertiblePreset.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ConvertiblePreset.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ConvertiblePreset.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasCodecLayouts.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasCodecLayouts.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasCodecLayouts.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasCodecLayouts.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasCodecSelfview.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasCodecSelfview.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasCodecSelfview.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasCodecSelfview.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasMeetingInfo.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasMeetingInfo.cs similarity index 99% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasMeetingInfo.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasMeetingInfo.cs index 4d27535a..c29a6ae7 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasMeetingInfo.cs +++ b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasMeetingInfo.cs @@ -43,8 +43,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces [JsonProperty("isLocked", NullValueHandling = NullValueHandling.Ignore)] public Boolean IsLocked { get; private set; } [JsonProperty("isRecording", NullValueHandling = NullValueHandling.Ignore)] - public Boolean IsRecording { get; private set; } - [JsonProperty("canRecord", NullValueHandling = NullValueHandling.Ignore)] + public Boolean IsRecording { get; private set; } + [JsonProperty("canRecord", NullValueHandling = NullValueHandling.Ignore)] public Boolean CanRecord { get; private set; } @@ -59,7 +59,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces IsSharingMeeting = isSharingMeeting; WaitingForHost = waitingForHost; IsLocked = isLocked; - IsRecording = isRecording; + IsRecording = isRecording; CanRecord = CanRecord; } } diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasMeetingLock.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasMeetingLock.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasMeetingLock.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasMeetingLock.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasMeetingRecording.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasMeetingRecording.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasMeetingRecording.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasMeetingRecording.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasParticipants.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasParticipants.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasParticipants.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasParticipants.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasPresentationOnlyMeeting.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasPresentationOnlyMeeting.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasPresentationOnlyMeeting.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasPresentationOnlyMeeting.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasSelfviewPosition.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasSelfviewPosition.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasSelfviewPosition.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasSelfviewPosition.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasSelfviewSize.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasSelfviewSize.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasSelfviewSize.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasSelfviewSize.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasStandbyMode.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasStandbyMode.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasStandbyMode.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasStandbyMode.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasStartMeeting.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasStartMeeting.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasStartMeeting.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasStartMeeting.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasVideoCodec.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasVideoCodec.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasVideoCodec.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IHasVideoCodec.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IJoinCalls.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IJoinCalls.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IJoinCalls.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/IJoinCalls.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/iVideoCodecInfo.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/iVideoCodecInfo.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/iVideoCodecInfo.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/Interfaces/iVideoCodecInfo.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockCodecDirectory.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockCodecDirectory.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockCodecDirectory.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockCodecDirectory.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVC.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVC.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVC.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVC.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVC.cs.orig b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVC.cs.orig similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVC.cs.orig rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVC.cs.orig diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVCCamera.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVCCamera.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVCCamera.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVCCamera.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVcPropertiesConfig.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVcPropertiesConfig.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVcPropertiesConfig.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVcPropertiesConfig.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/VideoCodecBase.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/VideoCodecBase.cs similarity index 97% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/VideoCodecBase.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/VideoCodecBase.cs index 1a842bc5..0b1450bb 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/VideoCodecBase.cs +++ b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/VideoCodecBase.cs @@ -1,2031 +1,2031 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp.CrestronIO; -using Crestron.SimplSharp.Reflection; -using Crestron.SimplSharp.Ssh; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharp; -using PepperDash.Core; -using PepperDash.Core.Intersystem; -using PepperDash.Core.Intersystem.Tokens; -using PepperDash.Core.WebApi.Presets; -using Crestron.SimplSharp.Reflection; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.Core.Devices; -using PepperDash.Essentials.Core.DeviceTypeInterfaces; -using PepperDash.Essentials.Core.Routing; -using PepperDash.Essentials.Devices.Common.Cameras; -using PepperDash.Essentials.Devices.Common.Codec; -using PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces; -using PepperDash.Essentials.Core.Bridges.JoinMaps; -using Feedback = PepperDash.Essentials.Core.Feedback; - -namespace PepperDash.Essentials.Devices.Common.VideoCodec -{ - public abstract class VideoCodecBase : ReconfigurableDevice, IRoutingInputsOutputs, - IUsageTracking, IHasDialer, IHasContentSharing, ICodecAudio, iVideoCodecInfo, IBridgeAdvanced, IHasStandbyMode - { - private const int XSigEncoding = 28591; - protected const int MaxParticipants = 50; - private readonly byte[] _clearBytes = XSigHelpers.ClearOutputs(); - - private IHasDirectory _directoryCodec; - private BasicTriList _directoryTrilist; - private VideoCodecControllerJoinMap _directoryJoinmap; - - protected string _timeFormatSpecifier; - protected string _dateFormatSpecifier; - - - protected VideoCodecBase(DeviceConfig config) - : base(config) - { - - StandbyIsOnFeedback = new BoolFeedback(StandbyIsOnFeedbackFunc); - PrivacyModeIsOnFeedback = new BoolFeedback(PrivacyModeIsOnFeedbackFunc); - VolumeLevelFeedback = new IntFeedback(VolumeLevelFeedbackFunc); - MuteFeedback = new BoolFeedback(MuteFeedbackFunc); - SharingSourceFeedback = new StringFeedback(SharingSourceFeedbackFunc); - SharingContentIsOnFeedback = new BoolFeedback(SharingContentIsOnFeedbackFunc); - - // TODO [ ] hotfix/videocodecbase-max-meeting-xsig-set - MeetingsToDisplayFeedback = new IntFeedback(() => MeetingsToDisplay); - - InputPorts = new RoutingPortCollection(); - OutputPorts = new RoutingPortCollection(); - - ActiveCalls = new List(); - } - - public IBasicCommunication Communication { get; protected set; } - - /// - /// An internal pseudo-source that is routable and connected to the osd input - /// - public DummyRoutingInputsDevice OsdSource { get; protected set; } - - public BoolFeedback StandbyIsOnFeedback { get; private set; } - - protected abstract Func PrivacyModeIsOnFeedbackFunc { get; } - protected abstract Func VolumeLevelFeedbackFunc { get; } - protected abstract Func MuteFeedbackFunc { get; } - protected abstract Func StandbyIsOnFeedbackFunc { get; } - - public List ActiveCalls { get; set; } - - public bool ShowSelfViewByDefault { get; protected set; } - - public bool SupportsCameraOff { get; protected set; } - public bool SupportsCameraAutoMode { get; protected set; } - - public bool IsReady { get; protected set; } - - public virtual List Feedbacks - { - get - { - return new List - { - PrivacyModeIsOnFeedback, - SharingSourceFeedback - }; - } - } - - protected abstract Func SharingSourceFeedbackFunc { get; } - protected abstract Func SharingContentIsOnFeedbackFunc { get; } - - #region ICodecAudio Members - - public abstract void PrivacyModeOn(); - public abstract void PrivacyModeOff(); - public abstract void PrivacyModeToggle(); - public BoolFeedback PrivacyModeIsOnFeedback { get; private set; } - - - public BoolFeedback MuteFeedback { get; private set; } - - public abstract void MuteOff(); - - public abstract void MuteOn(); - - public abstract void SetVolume(ushort level); - - public IntFeedback VolumeLevelFeedback { get; private set; } - - public abstract void MuteToggle(); - - public abstract void VolumeDown(bool pressRelease); - - - public abstract void VolumeUp(bool pressRelease); - - #endregion - - #region IHasContentSharing Members - - public abstract void StartSharing(); - public abstract void StopSharing(); - - public bool AutoShareContentWhileInCall { get; protected set; } - - public StringFeedback SharingSourceFeedback { get; private set; } - public BoolFeedback SharingContentIsOnFeedback { get; private set; } - - #endregion - - #region IHasDialer Members - - /// - /// Fires when the status of any active, dialing, or incoming call changes or is new - /// - public event EventHandler CallStatusChange; - - /// - /// Returns true when any call is not in state Unknown, Disconnecting, Disconnected - /// - public bool IsInCall - { - get - { - var value = ActiveCalls != null && ActiveCalls.Any(c => c.IsActiveCall); - return value; - } - } - - public abstract void Dial(string number); - public abstract void EndCall(CodecActiveCallItem call); - public abstract void EndAllCalls(); - public abstract void AcceptCall(CodecActiveCallItem call); - public abstract void RejectCall(CodecActiveCallItem call); - public abstract void SendDtmf(string s); - public virtual void SendDtmf(string s, CodecActiveCallItem call) { } - - #endregion - - #region IRoutingInputsOutputs Members - - public RoutingPortCollection InputPorts { get; private set; } - - public RoutingPortCollection OutputPorts { get; private set; } - - #endregion - - #region IUsageTracking Members - - /// - /// This object can be added by outside users of this class to provide usage tracking - /// for various services - /// - public UsageTracking UsageTracker { get; set; } - - #endregion - - #region iVideoCodecInfo Members - - public VideoCodecInfo CodecInfo { get; protected set; } - - #endregion - - public event EventHandler IsReadyChange; - public abstract void Dial(Meeting meeting); - - public virtual void Dial(IInvitableContact contact) - { - } - - public abstract void ExecuteSwitch(object selector); - - /// - /// Helper method to fire CallStatusChange event with old and new status - /// - protected void SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus newStatus, CodecActiveCallItem call) - { - call.Status = newStatus; - - OnCallStatusChange(call); - } - - /// - /// - /// - /// - /// - /// - protected virtual void OnCallStatusChange(CodecActiveCallItem item) - { - var handler = CallStatusChange; - if (handler != null) - { - handler(this, new CodecCallStatusItemChangeEventArgs(item)); - } - - PrivacyModeIsOnFeedback.FireUpdate(); - - if (AutoShareContentWhileInCall) - { - StartSharing(); - } - - if (UsageTracker != null) - { - if (IsInCall && !UsageTracker.UsageTrackingStarted) - { - UsageTracker.StartDeviceUsage(); - } - else if (UsageTracker.UsageTrackingStarted && !IsInCall) - { - UsageTracker.EndDeviceUsage(); - } - } - } - - /// - /// Sets IsReady property and fires the event. Used for dependent classes to sync up their data. - /// - protected void SetIsReady() - { - CrestronInvoke.BeginInvoke((o) => - { - try - { - IsReady = true; - var h = IsReadyChange; - if (h != null) - { - h(this, new EventArgs()); - } - } - catch (Exception e) - { - Debug.Console(2, this, "Error in SetIsReady() : {0}", e); - } - }); - } - - // **** DEBUGGING THINGS **** - /// - /// - /// - public virtual void ListCalls() - { - Debug.Console(1, this, "Active Calls:"); - - var sb = new StringBuilder(); - foreach (var c in ActiveCalls) - { - sb.AppendFormat("id: {0} number: {1} -- name: {2} status: {3} onHold: {4}\r\n", c.Id, c.Number, c.Name, c.Status, c.IsOnHold); - } - Debug.Console(1, this, "\n{0}\n", sb.ToString()); - } - - public abstract void StandbyActivate(); - - public abstract void StandbyDeactivate(); - - #region Implementation of IBridgeAdvanced - - public abstract void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge); - - /// - /// Use this method when using a plain VideoCodecControllerJoinMap - /// - /// - /// - /// - /// - /// - protected void LinkVideoCodecToApi(VideoCodecBase codec, BasicTriList trilist, uint joinStart, string joinMapKey, - EiscApiAdvanced bridge) - { - var joinMap = new VideoCodecControllerJoinMap(joinStart); - - var customJoins = JoinMapHelper.TryGetJoinMapAdvancedForDevice(joinMapKey); - - if (customJoins != null) - { - joinMap.SetCustomJoinData(customJoins); - } - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - - LinkVideoCodecToApi(codec, trilist, joinMap); - - trilist.OnlineStatusChange += (device, args) => - { - if (!args.DeviceOnLine) return; - }; - } - - /// - /// Use this method when you need to pass in a join map that extends VideoCodecControllerJoinMap - /// - /// - /// - /// - protected void LinkVideoCodecToApi(VideoCodecBase codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) - { - Debug.Console(1, this, "Linking to Trilist {0}", trilist.ID.ToString("X")); - - LinkVideoCodecDtmfToApi(trilist, joinMap); - - LinkVideoCodecCallControlsToApi(trilist, joinMap); - - LinkVideoCodecContentSharingToApi(trilist, joinMap); - - LinkVideoCodecPrivacyToApi(trilist, joinMap); - - LinkVideoCodecVolumeToApi(trilist, joinMap); - - LinkVideoCodecInfoToApi(trilist, joinMap); - - // Register for this event to link any functions that require the codec to be ready first - codec.IsReadyChange += (o, a) => - { - if (codec is IHasCodecCameras) - { - LinkVideoCodecCameraToApi(codec as IHasCodecCameras, trilist, joinMap); - } - }; - - if (codec is ICommunicationMonitor) - { - LinkVideoCodecCommMonitorToApi(codec as ICommunicationMonitor, trilist, joinMap); - } - - - if (codec is IHasCodecSelfView) - { - LinkVideoCodecSelfviewToApi(codec as IHasCodecSelfView, trilist, joinMap); - } - - if (codec is IHasCameraAutoMode) - { - trilist.SetBool(joinMap.CameraSupportsAutoMode.JoinNumber, SupportsCameraAutoMode); - LinkVideoCodecCameraModeToApi(codec as IHasCameraAutoMode, trilist, joinMap); - } - - if (codec is IHasCameraOff) - { - trilist.SetBool(joinMap.CameraSupportsOffMode.JoinNumber, SupportsCameraOff); - LinkVideoCodecCameraOffToApi(codec as IHasCameraOff, trilist, joinMap); - } - - if (codec is IHasCodecLayouts) - { - LinkVideoCodecCameraLayoutsToApi(codec as IHasCodecLayouts, trilist, joinMap); - } - - - if (codec is IHasSelfviewPosition) - { - LinkVideoCodecSelfviewPositionToApi(codec as IHasSelfviewPosition, trilist, joinMap); - } - - if (codec is IHasDirectory) - { - LinkVideoCodecDirectoryToApi(codec as IHasDirectory, trilist, joinMap); - } - - if (codec is IHasScheduleAwareness) - { - LinkVideoCodecScheduleToApi(codec as IHasScheduleAwareness, trilist, joinMap); - } - - if (codec is IHasParticipants) - { - LinkVideoCodecParticipantsToApi(codec as IHasParticipants, trilist, joinMap); - } - - if (codec is IHasFarEndContentStatus) - { - (codec as IHasFarEndContentStatus).ReceivingContent.LinkInputSig(trilist.BooleanInput[joinMap.RecievingContent.JoinNumber]); - } - - if (codec is IHasPhoneDialing) - { - LinkVideoCodecPhoneToApi(codec as IHasPhoneDialing, trilist, joinMap); - } - - if (codec is IHasCallHistory) - { - LinkVideoCodecCallHistoryToApi(codec as IHasCallHistory, trilist, joinMap); - } - - trilist.OnlineStatusChange += (device, args) => - { - if (!args.DeviceOnLine) return; - - if (codec is IHasDirectory) - { - (codec as IHasDirectory).SetCurrentDirectoryToRoot(); - } - - if (codec is IHasScheduleAwareness) - { - (codec as IHasScheduleAwareness).GetSchedule(); - } - - if (codec is IHasParticipants) - { - UpdateParticipantsXSig((codec as IHasParticipants).Participants.CurrentParticipants); - } - - if (codec is IHasCameraAutoMode) - { - trilist.SetBool(joinMap.CameraSupportsAutoMode.JoinNumber, SupportsCameraAutoMode); - - (codec as IHasCameraAutoMode).CameraAutoModeIsOnFeedback.FireUpdate(); - } - - if (codec is IHasCodecSelfView) - { - (codec as IHasCodecSelfView).SelfviewIsOnFeedback.FireUpdate(); - } - - if (codec is IHasCameraAutoMode) - { - (codec as IHasCameraAutoMode).CameraAutoModeIsOnFeedback.FireUpdate(); - } - - if (codec is IHasCameraOff) - { - (codec as IHasCameraOff).CameraIsOffFeedback.FireUpdate(); - } - - if (codec is IHasPhoneDialing) - { - (codec as IHasPhoneDialing).PhoneOffHookFeedback.FireUpdate(); - } - - if (codec is IHasCallHistory) - { - UpdateCallHistory((codec as IHasCallHistory), trilist, joinMap); - } - - SharingContentIsOnFeedback.FireUpdate(); - }; - } - - private void LinkVideoCodecInfoToApi(BasicTriList trilist, VideoCodecControllerJoinMap joinMap) - { - trilist.SetBool(joinMap.MultiSiteOptionIsEnabled.JoinNumber, this.CodecInfo.MultiSiteOptionIsEnabled); - trilist.SetBool(joinMap.AutoAnswerEnabled.JoinNumber, this.CodecInfo.AutoAnswerEnabled); - trilist.SetString(joinMap.DeviceIpAddresss.JoinNumber, this.CodecInfo.IpAddress); - trilist.SetString(joinMap.SipPhoneNumber.JoinNumber, this.CodecInfo.SipPhoneNumber); - trilist.SetString(joinMap.E164Alias.JoinNumber, this.CodecInfo.E164Alias); - trilist.SetString(joinMap.H323Id.JoinNumber, this.CodecInfo.H323Id); - trilist.SetString(joinMap.SipUri.JoinNumber, this.CodecInfo.SipUri); - - trilist.OnlineStatusChange += (o, a) => - { - if (a.DeviceOnLine) - { - trilist.SetBool(joinMap.MultiSiteOptionIsEnabled.JoinNumber, this.CodecInfo.MultiSiteOptionIsEnabled); - trilist.SetBool(joinMap.AutoAnswerEnabled.JoinNumber, this.CodecInfo.AutoAnswerEnabled); - trilist.SetString(joinMap.DeviceIpAddresss.JoinNumber, this.CodecInfo.IpAddress); - trilist.SetString(joinMap.SipPhoneNumber.JoinNumber, this.CodecInfo.SipPhoneNumber); - trilist.SetString(joinMap.E164Alias.JoinNumber, this.CodecInfo.E164Alias); - trilist.SetString(joinMap.H323Id.JoinNumber, this.CodecInfo.H323Id); - trilist.SetString(joinMap.SipUri.JoinNumber, this.CodecInfo.SipUri); - } - }; - } - - private void LinkVideoCodecPhoneToApi(IHasPhoneDialing codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) - { - codec.PhoneOffHookFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PhoneHookState.JoinNumber]); - - trilist.SetSigFalseAction(joinMap.DialPhone.JoinNumber, - () => codec.DialPhoneCall(trilist.StringOutput[joinMap.PhoneDialString.JoinNumber].StringValue)); - - trilist.SetSigFalseAction(joinMap.HangUpPhone.JoinNumber, codec.EndPhoneCall); - } - - private void LinkVideoCodecSelfviewPositionToApi(IHasSelfviewPosition codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) - { - trilist.SetSigFalseAction(joinMap.SelfviewPosition.JoinNumber, codec.SelfviewPipPositionToggle); - - codec.SelfviewPipPositionFeedback.LinkInputSig(trilist.StringInput[joinMap.SelfviewPositionFb.JoinNumber]); - } - - private void LinkVideoCodecCameraOffToApi(IHasCameraOff codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) - { - trilist.SetSigFalseAction(joinMap.CameraModeOff.JoinNumber, codec.CameraOff); - - codec.CameraIsOffFeedback.OutputChange += (o, a) => - { - if (a.BoolValue) - { - trilist.SetBool(joinMap.CameraModeOff.JoinNumber, true); - trilist.SetBool(joinMap.CameraModeManual.JoinNumber, false); - trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, false); - return; - } - - trilist.SetBool(joinMap.CameraModeOff.JoinNumber, false); - - var autoCodec = codec as IHasCameraAutoMode; - - if (autoCodec == null) return; - - trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, autoCodec.CameraAutoModeIsOnFeedback.BoolValue); - trilist.SetBool(joinMap.CameraModeManual.JoinNumber, !autoCodec.CameraAutoModeIsOnFeedback.BoolValue); - }; - - if (codec.CameraIsOffFeedback.BoolValue) - { - trilist.SetBool(joinMap.CameraModeOff.JoinNumber, true); - trilist.SetBool(joinMap.CameraModeManual.JoinNumber, false); - trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, false); - return; - } - - trilist.SetBool(joinMap.CameraModeOff.JoinNumber, false); - - var autoModeCodec = codec as IHasCameraAutoMode; - - if (autoModeCodec == null) return; - - trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, autoModeCodec.CameraAutoModeIsOnFeedback.BoolValue); - trilist.SetBool(joinMap.CameraModeManual.JoinNumber, !autoModeCodec.CameraAutoModeIsOnFeedback.BoolValue); - } - - private void LinkVideoCodecVolumeToApi(BasicTriList trilist, VideoCodecControllerJoinMap joinMap) - { - MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMuteOn.JoinNumber]); - MuteFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.VolumeMuteOff.JoinNumber]); - - trilist.SetSigFalseAction(joinMap.VolumeMuteOn.JoinNumber, MuteOn); - trilist.SetSigFalseAction(joinMap.VolumeMuteOff.JoinNumber, MuteOff); - trilist.SetSigFalseAction(joinMap.VolumeMuteToggle.JoinNumber, MuteToggle); - - VolumeLevelFeedback.LinkInputSig(trilist.UShortInput[joinMap.VolumeLevel.JoinNumber]); - - trilist.SetBoolSigAction(joinMap.VolumeUp.JoinNumber, VolumeUp); - trilist.SetBoolSigAction(joinMap.VolumeDown.JoinNumber, VolumeDown); - - trilist.SetUShortSigAction(joinMap.VolumeLevel.JoinNumber, SetVolume); - - } - - private void LinkVideoCodecPrivacyToApi(BasicTriList trilist, VideoCodecControllerJoinMap joinMap) - { - PrivacyModeIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.MicMuteOn.JoinNumber]); - PrivacyModeIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.MicMuteOff.JoinNumber]); - - trilist.SetSigFalseAction(joinMap.MicMuteOn.JoinNumber, PrivacyModeOn); - trilist.SetSigFalseAction(joinMap.MicMuteOff.JoinNumber, PrivacyModeOff); - trilist.SetSigFalseAction(joinMap.MicMuteToggle.JoinNumber, PrivacyModeToggle); - } - - private void LinkVideoCodecCommMonitorToApi(ICommunicationMonitor codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) - { - codec.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - } - - private void LinkVideoCodecParticipantsToApi(IHasParticipants codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) - { - // make sure to update the values when the EISC comes online - trilist.OnlineStatusChange += (sender, args) => - { - if (sender.IsOnline) - { - UpdateParticipantsXSig(codec, trilist, joinMap); - } - }; - - // set actions and update the values when the list changes - codec.Participants.ParticipantsListHasChanged += (sender, args) => - { - SetParticipantActions(trilist, joinMap, codec.Participants.CurrentParticipants); - - UpdateParticipantsXSig(codec, trilist, joinMap); - }; - - trilist.OnlineStatusChange += (device, args) => - { - if (!args.DeviceOnLine) return; - - // TODO [ ] Issue #868 - trilist.SetString(joinMap.CurrentParticipants.JoinNumber, "\xFC"); - UpdateParticipantsXSig(codec, trilist, joinMap); - }; - } - - private void UpdateParticipantsXSig(IHasParticipants codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) - { - string participantsXSig; - - if (codec.Participants.CurrentParticipants.Count == 0) - { - participantsXSig = Encoding.GetEncoding(XSigEncoding).GetString(_clearBytes, 0, _clearBytes.Length); - trilist.SetString(joinMap.CurrentParticipants.JoinNumber, participantsXSig); - trilist.SetUshort(joinMap.ParticipantCount.JoinNumber, (ushort)codec.Participants.CurrentParticipants.Count); - return; - } - - participantsXSig = UpdateParticipantsXSig(codec.Participants.CurrentParticipants); - - trilist.SetString(joinMap.CurrentParticipants.JoinNumber, participantsXSig); - - trilist.SetUshort(joinMap.ParticipantCount.JoinNumber, (ushort)codec.Participants.CurrentParticipants.Count); - } - - /// - /// Sets the actions for each participant in the list - /// - private void SetParticipantActions(BasicTriList trilist, VideoCodecControllerJoinMap joinMap, List currentParticipants) - { - uint index = 0; // track the index of the participant in the - - foreach (var participant in currentParticipants) - { - var p = participant; - if (index > MaxParticipants) break; - - var audioMuteCodec = this as IHasParticipantAudioMute; - if (audioMuteCodec != null) - { - trilist.SetSigFalseAction(joinMap.ParticipantAudioMuteToggleStart.JoinNumber + index, - () => audioMuteCodec.ToggleAudioForParticipant(p.UserId)); - - trilist.SetSigFalseAction(joinMap.ParticipantVideoMuteToggleStart.JoinNumber + index, - () => audioMuteCodec.ToggleVideoForParticipant(p.UserId)); - } - - var pinCodec = this as IHasParticipantPinUnpin; - if (pinCodec != null) - { - trilist.SetSigFalseAction(joinMap.ParticipantPinToggleStart.JoinNumber + index, - () => pinCodec.ToggleParticipantPinState(p.UserId, pinCodec.ScreenIndexToPinUserTo)); - } - - index++; - } - - // Clear out any previously set actions - while (index < MaxParticipants) - { - trilist.ClearBoolSigAction(joinMap.ParticipantAudioMuteToggleStart.JoinNumber + index); - trilist.ClearBoolSigAction(joinMap.ParticipantVideoMuteToggleStart.JoinNumber + index); - trilist.ClearBoolSigAction(joinMap.ParticipantPinToggleStart.JoinNumber + index); - - index++; - } - } - - private string UpdateParticipantsXSig(List currentParticipants) - { - const int maxParticipants = MaxParticipants; - const int maxDigitals = 7; - const int maxStrings = 1; - const int maxAnalogs = 1; - const int offset = maxDigitals + maxStrings + maxAnalogs; // 9 - var digitalIndex = (maxStrings + maxAnalogs) * maxParticipants; // 100 - var stringIndex = 0; - var analogIndex = stringIndex + maxParticipants; - var meetingIndex = 0; - - var tokenArray = new XSigToken[maxParticipants * offset]; - - foreach (var participant in currentParticipants) - { - if (meetingIndex >= maxParticipants * offset) break; - - // Debug.Console(2, this, - //@"Updating Participant on xsig: - //Name: {0} (s{9}) - //AudioMute: {1} (d{10}) - //VideoMute: {2} (d{11}) - //CanMuteVideo: {3} (d{12}) - //CanUMuteVideo: {4} (d{13}) - //IsHost: {5} (d{14}) - //HandIsRaised: {6} (d{15}) - //IsPinned: {7} (d{16}) - //ScreenIndexIsPinnedTo: {8} (a{17}) - //", - // participant.Name, - // participant.AudioMuteFb, - // participant.VideoMuteFb, - // participant.CanMuteVideo, - // participant.CanUnmuteVideo, - // participant.IsHost, - // participant.HandIsRaisedFb, - // participant.IsPinnedFb, - // participant.ScreenIndexIsPinnedToFb, - // stringIndex + 1, - // digitalIndex + 1, - // digitalIndex + 2, - // digitalIndex + 3, - // digitalIndex + 4, - // digitalIndex + 5, - // digitalIndex + 6, - // digitalIndex + 7, - // analogIndex + 1 - // ); - - - //digitals - tokenArray[digitalIndex] = new XSigDigitalToken(digitalIndex + 1, participant.AudioMuteFb); - tokenArray[digitalIndex + 1] = new XSigDigitalToken(digitalIndex + 2, participant.VideoMuteFb); - tokenArray[digitalIndex + 2] = new XSigDigitalToken(digitalIndex + 3, participant.CanMuteVideo); - tokenArray[digitalIndex + 3] = new XSigDigitalToken(digitalIndex + 4, participant.CanUnmuteVideo); - tokenArray[digitalIndex + 4] = new XSigDigitalToken(digitalIndex + 5, participant.IsHost); - tokenArray[digitalIndex + 5] = new XSigDigitalToken(digitalIndex + 6, participant.HandIsRaisedFb); - tokenArray[digitalIndex + 6] = new XSigDigitalToken(digitalIndex + 7, participant.IsPinnedFb); - - Debug.Console(2, this, "Index: {0} byte value: {1}", digitalIndex + 7, ComTextHelper.GetEscapedText(tokenArray[digitalIndex + 6].GetBytes())); - - //serials - tokenArray[stringIndex] = new XSigSerialToken(stringIndex + 1, participant.Name); - - //analogs - tokenArray[analogIndex] = new XSigAnalogToken(analogIndex + 1, (ushort)participant.ScreenIndexIsPinnedToFb); - - digitalIndex += maxDigitals; - meetingIndex += offset; - stringIndex += maxStrings; - analogIndex += maxAnalogs; - } - - while (meetingIndex < maxParticipants * offset) - { - //digitals - tokenArray[digitalIndex] = new XSigDigitalToken(digitalIndex + 1, false); - tokenArray[digitalIndex + 1] = new XSigDigitalToken(digitalIndex + 2, false); - tokenArray[digitalIndex + 2] = new XSigDigitalToken(digitalIndex + 3, false); - tokenArray[digitalIndex + 3] = new XSigDigitalToken(digitalIndex + 4, false); - tokenArray[digitalIndex + 4] = new XSigDigitalToken(digitalIndex + 5, false); - tokenArray[digitalIndex + 5] = new XSigDigitalToken(digitalIndex + 6, false); - tokenArray[digitalIndex + 6] = new XSigDigitalToken(digitalIndex + 7, false); - - //serials - tokenArray[stringIndex] = new XSigSerialToken(stringIndex + 1, String.Empty); - - //analogs - tokenArray[analogIndex] = new XSigAnalogToken(analogIndex + 1, 0); - - digitalIndex += maxDigitals; - meetingIndex += offset; - stringIndex += maxStrings; - analogIndex += maxAnalogs; - } - - var returnString = GetXSigString(tokenArray); - - //Debug.Console(2, this, "{0}", ComTextHelper.GetEscapedText(Encoding.GetEncoding(28591).GetBytes(returnString))); - - - return returnString; - } - - private void LinkVideoCodecContentSharingToApi(BasicTriList trilist, VideoCodecControllerJoinMap joinMap) - { - SharingContentIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.SourceShareStart.JoinNumber]); - SharingContentIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.SourceShareEnd.JoinNumber]); - - SharingSourceFeedback.LinkInputSig(trilist.StringInput[joinMap.CurrentSource.JoinNumber]); - - trilist.SetSigFalseAction(joinMap.SourceShareStart.JoinNumber, StartSharing); - trilist.SetSigFalseAction(joinMap.SourceShareEnd.JoinNumber, StopSharing); - - trilist.SetBoolSigAction(joinMap.SourceShareAutoStart.JoinNumber, b => AutoShareContentWhileInCall = b); - } - - private List _currentMeetings = new List(); - - private void LinkVideoCodecScheduleToApi(IHasScheduleAwareness codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) - { - trilist.SetSigFalseAction(joinMap.UpdateMeetings.JoinNumber, codec.GetSchedule); - - trilist.SetUShortSigAction(joinMap.MinutesBeforeMeetingStart.JoinNumber, (i) => - { - codec.CodecSchedule.MeetingWarningMinutes = i; - }); - - - for (uint i = 0; i < joinMap.DialMeetingStart.JoinSpan; i++) - { - Debug.Console(1, this, "Setting action to Dial Meeting {0} to digital join {1}", i + 1, joinMap.DialMeetingStart.JoinNumber + i); - var joinNumber = joinMap.DialMeetingStart.JoinNumber + i; - var mtg = i + 1; - var index = (int)i; - - trilist.SetSigFalseAction(joinNumber, () => - { - Debug.Console(1, this, "Meeting {0} Selected (EISC dig-o{1}) > _currentMeetings[{2}].Id: {3}, Title: {4}", - mtg, joinMap.DialMeetingStart.JoinNumber + i, index, _currentMeetings[index].Id, _currentMeetings[index].Title); - if (_currentMeetings[index] != null) - Dial(_currentMeetings[index]); - }); - } - - codec.CodecSchedule.MeetingsListHasChanged += (sender, args) => UpdateMeetingsList(codec, trilist, joinMap); - codec.CodecSchedule.MeetingEventChange += (sender, args) => - { - if (args.ChangeType == eMeetingEventChangeType.MeetingStartWarning) - { - UpdateMeetingsList(codec, trilist, joinMap); - } - }; - - trilist.SetUShortSigAction(joinMap.MeetingsToDisplay.JoinNumber, m => MeetingsToDisplay = m); - MeetingsToDisplayFeedback.LinkInputSig(trilist.UShortInput[joinMap.MeetingsToDisplay.JoinNumber]); - - trilist.OnlineStatusChange += (device, args) => - { - if (!args.DeviceOnLine) return; - - // TODO [ ] Issue #868 - trilist.SetString(joinMap.Schedule.JoinNumber, "\xFC"); - UpdateMeetingsList(codec, trilist, joinMap); - // TODO [ ] hotfix/videocodecbase-max-meeting-xsig-set - MeetingsToDisplayFeedback.LinkInputSig(trilist.UShortInput[joinMap.MeetingsToDisplay.JoinNumber]); - }; - } - - private void UpdateMeetingsList(IHasScheduleAwareness codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) - { - var currentTime = DateTime.Now; - - _currentMeetings = codec.CodecSchedule.Meetings.Where(m => m.StartTime >= currentTime || m.EndTime >= currentTime).ToList(); - - if (_currentMeetings.Count == 0) - { - var emptyXSigByteArray = XSigHelpers.ClearOutputs(); - var emptyXSigString = Encoding.GetEncoding(XSigEncoding) - .GetString(emptyXSigByteArray, 0, emptyXSigByteArray.Length); - - trilist.SetString(joinMap.Schedule.JoinNumber, emptyXSigString); - return; - } - - var meetingsData = UpdateMeetingsListXSig(_currentMeetings); - trilist.SetString(joinMap.Schedule.JoinNumber, meetingsData); - trilist.SetUshort(joinMap.MeetingCount.JoinNumber, (ushort)_currentMeetings.Count); - - trilist.OnlineStatusChange += (device, args) => - { - if (!args.DeviceOnLine) return; - - // TODO [ ] Issue #868 - trilist.SetString(joinMap.Schedule.JoinNumber, "\xFC"); - UpdateMeetingsListXSig(_currentMeetings); - }; - } - - - // TODO [ ] hotfix/videocodecbase-max-meeting-xsig-set - private int _meetingsToDisplay = 3; - // TODO [ ] hotfix/videocodecbase-max-meeting-xsig-set - protected int MeetingsToDisplay - { - get { return _meetingsToDisplay; } - set { - _meetingsToDisplay = (ushort) (value == 0 ? 3 : value); - MeetingsToDisplayFeedback.FireUpdate(); - } - } - - // TODO [ ] hotfix/videocodecbase-max-meeting-xsig-set - public IntFeedback MeetingsToDisplayFeedback { get; set; } - - private string UpdateMeetingsListXSig(List meetings) - { - // TODO [ ] hotfix/videocodecbase-max-meeting-xsig-set - //const int _meetingsToDisplay = 3; - const int maxDigitals = 2; - const int maxStrings = 7; - const int offset = maxDigitals + maxStrings; - var digitalIndex = maxStrings * _meetingsToDisplay; //15 - var stringIndex = 0; - var meetingIndex = 0; - - var tokenArray = new XSigToken[_meetingsToDisplay * offset]; - /* - * Digitals - * IsJoinable - 1 - * IsDialable - 2 - * - * Serials - * Organizer - 1 - * Title - 2 - * Start Date - 3 - * Start Time - 4 - * End Date - 5 - * End Time - 6 - * Id - 7 - */ - - - foreach (var meeting in meetings) - { - var currentTime = DateTime.Now; - - if (meeting.StartTime < currentTime && meeting.EndTime < currentTime) continue; - - if (meetingIndex >= _meetingsToDisplay * offset) - { - Debug.Console(2, this, "Max Meetings reached"); - break; - } - - //digitals - tokenArray[digitalIndex] = new XSigDigitalToken(digitalIndex + 1, meeting.Joinable); - tokenArray[digitalIndex + 1] = new XSigDigitalToken(digitalIndex + 2, meeting.Dialable); - - //serials - tokenArray[stringIndex] = new XSigSerialToken(stringIndex + 1, meeting.Organizer); - tokenArray[stringIndex + 1] = new XSigSerialToken(stringIndex + 2, meeting.Title); - tokenArray[stringIndex + 2] = new XSigSerialToken(stringIndex + 3, meeting.StartTime.ToString(_dateFormatSpecifier.NullIfEmpty() ?? "d", Global.Culture)); - tokenArray[stringIndex + 3] = new XSigSerialToken(stringIndex + 4, meeting.StartTime.ToString(_timeFormatSpecifier.NullIfEmpty() ?? "t", Global.Culture)); - tokenArray[stringIndex + 4] = new XSigSerialToken(stringIndex + 5, meeting.EndTime.ToString(_dateFormatSpecifier.NullIfEmpty() ?? "d", Global.Culture)); - tokenArray[stringIndex + 5] = new XSigSerialToken(stringIndex + 6, meeting.EndTime.ToString(_timeFormatSpecifier.NullIfEmpty() ?? "t", Global.Culture)); - tokenArray[stringIndex + 6] = new XSigSerialToken(stringIndex + 7, meeting.Id); - - digitalIndex += maxDigitals; - meetingIndex += offset; - stringIndex += maxStrings; - } - - while (meetingIndex < _meetingsToDisplay * offset) - { - Debug.Console(2, this, "Clearing unused data. Meeting Index: {0} MaxMeetings * Offset: {1}", - meetingIndex, _meetingsToDisplay * offset); - - //digitals - tokenArray[digitalIndex] = new XSigDigitalToken(digitalIndex + 1, false); - tokenArray[digitalIndex + 1] = new XSigDigitalToken(digitalIndex + 2, false); - - //serials - tokenArray[stringIndex] = new XSigSerialToken(stringIndex + 1, String.Empty); - tokenArray[stringIndex + 1] = new XSigSerialToken(stringIndex + 2, String.Empty); - tokenArray[stringIndex + 2] = new XSigSerialToken(stringIndex + 3, String.Empty); - tokenArray[stringIndex + 3] = new XSigSerialToken(stringIndex + 4, String.Empty); - tokenArray[stringIndex + 4] = new XSigSerialToken(stringIndex + 5, String.Empty); - tokenArray[stringIndex + 5] = new XSigSerialToken(stringIndex + 6, String.Empty); - tokenArray[stringIndex + 6] = new XSigSerialToken(stringIndex + 7, String.Empty); - - digitalIndex += maxDigitals; - meetingIndex += offset; - stringIndex += maxStrings; - } - - return GetXSigString(tokenArray); - } - - - private void LinkVideoCodecDirectoryToApi(IHasDirectory codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) - { - codec.CurrentDirectoryResultIsNotDirectoryRoot.LinkComplementInputSig( - trilist.BooleanInput[joinMap.DirectoryIsRoot.JoinNumber]); - - trilist.SetStringSigAction(joinMap.DirectorySearchString.JoinNumber, codec.SearchDirectory); - - trilist.SetUShortSigAction(joinMap.DirectorySelectRow.JoinNumber, (i) => SelectDirectoryEntry(codec, i, trilist, joinMap)); - - //Special Change for protected directory clear - - trilist.SetBoolSigAction(joinMap.DirectoryClearSelected.JoinNumber, (b) => SelectDirectoryEntry(codec, 0, trilist, joinMap)); - - // Report feedback for number of contact methods for selected contact - - trilist.SetSigFalseAction(joinMap.DirectoryRoot.JoinNumber, codec.SetCurrentDirectoryToRoot); - - trilist.SetSigFalseAction(joinMap.DirectoryFolderBack.JoinNumber, codec.GetDirectoryParentFolderContents); - - if (codec.DirectoryRoot != null) - { - var contactsCount = codec.DirectoryRoot.CurrentDirectoryResults.Where(c => c.ParentFolderId.Equals("root")).ToList().Count; - trilist.SetUshort(joinMap.DirectoryRowCount.JoinNumber, (ushort)contactsCount); - Debug.Console(2, this, ">>> contactsCount: {0}", contactsCount); - - var clearBytes = XSigHelpers.ClearOutputs(); - - trilist.SetString(joinMap.DirectoryEntries.JoinNumber, - Encoding.GetEncoding(XSigEncoding).GetString(clearBytes, 0, clearBytes.Length)); - var directoryXSig = UpdateDirectoryXSig(codec.DirectoryRoot, - codec.CurrentDirectoryResultIsNotDirectoryRoot.BoolValue == false); - - Debug.Console(2, this, "Directory XSig Length: {0}", directoryXSig.Length); - - trilist.SetString(joinMap.DirectoryEntries.JoinNumber, directoryXSig); - } - - codec.DirectoryResultReturned += (sender, args) => - { - var isRoot = codec.CurrentDirectoryResultIsNotDirectoryRoot.BoolValue == false; - var argsCount = isRoot - ? args.Directory.CurrentDirectoryResults.Where(a => a.ParentFolderId.Equals("root")).ToList().Count - : args.Directory.CurrentDirectoryResults.Count; - - trilist.SetUshort(joinMap.DirectoryRowCount.JoinNumber, (ushort)argsCount); - Debug.Console(2, this, ">>> argsCount: {0}", argsCount); - - var clearBytes = XSigHelpers.ClearOutputs(); - - trilist.SetString(joinMap.DirectoryEntries.JoinNumber, - Encoding.GetEncoding(XSigEncoding).GetString(clearBytes, 0, clearBytes.Length)); - var directoryXSig = UpdateDirectoryXSig(args.Directory, - codec.CurrentDirectoryResultIsNotDirectoryRoot.BoolValue == false); - Debug.Console(2, this, "Directory XSig Length: {0}", directoryXSig.Length); - - trilist.SetString(joinMap.DirectoryEntries.JoinNumber, directoryXSig); - }; - - trilist.OnlineStatusChange += (device, args) => - { - if (!args.DeviceOnLine) return; - - var clearBytes = XSigHelpers.ClearOutputs(); - trilist.SetString(joinMap.DirectoryEntries.JoinNumber, - Encoding.GetEncoding(XSigEncoding).GetString(clearBytes, 0, clearBytes.Length)); - var directoryXSig = UpdateDirectoryXSig(codec.DirectoryRoot, codec.CurrentDirectoryResultIsNotDirectoryRoot.BoolValue == false); - trilist.SetString(joinMap.DirectoryEntries.JoinNumber, directoryXSig); - }; - } - - private void SelectDirectoryEntry(IHasDirectory codec, ushort i, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) - { - if (i > codec.CurrentDirectoryResult.CurrentDirectoryResults.Count) return; - _selectedDirectoryItem = i == 0 ? null : codec.CurrentDirectoryResult.CurrentDirectoryResults[i - 1]; - trilist.SetUshort(joinMap.DirectorySelectRowFeedback.JoinNumber, i); - - if (_selectedDirectoryItem == null) trilist.SetBool(joinMap.DirectoryEntryIsContact.JoinNumber, false); - - - if (_selectedDirectoryItem is DirectoryFolder) - { - codec.GetDirectoryFolderContents(_selectedDirectoryItem.FolderId); - trilist.SetUshort(joinMap.SelectedContactMethodCount.JoinNumber, 0); - trilist.SetString(joinMap.DirectorySelectedFolderName.JoinNumber, _selectedDirectoryItem.Name); - trilist.SetString(joinMap.DirectoryEntrySelectedName.JoinNumber, string.Empty); - trilist.ClearUShortSigAction(joinMap.SelectContactMethod.JoinNumber); - trilist.ClearBoolSigAction(joinMap.DirectoryDialSelectedLine.JoinNumber); - trilist.ClearBoolSigAction(joinMap.DirectoryDialSelectedContactMethod.JoinNumber); - trilist.SetBool(joinMap.DirectoryEntryIsContact.JoinNumber, false); - return; - } - - // not a folder. Clear this value - trilist.SetString(joinMap.DirectorySelectedFolderName.JoinNumber, string.Empty); - - var selectedContact = _selectedDirectoryItem as DirectoryContact; - - if (selectedContact != null && selectedContact.ContactMethods.Count >= 1) - { - trilist.SetBool(joinMap.DirectoryEntryIsContact.JoinNumber, true); - } - - trilist.SetString(joinMap.DirectoryEntrySelectedName.JoinNumber, - selectedContact != null ? selectedContact.Name : string.Empty); - - // Allow auto dial of selected line. Always dials first contact method - if (!trilist.GetBool(joinMap.DirectoryDisableAutoDialSelectedLine.JoinNumber)) - { - var invitableEntry = _selectedDirectoryItem as IInvitableContact; - - if (invitableEntry != null) - { - Dial(invitableEntry); - return; - } - - var entryToDial = _selectedDirectoryItem as DirectoryContact; - - trilist.SetString(joinMap.DirectoryEntrySelectedNumber.JoinNumber, - selectedContact != null ? selectedContact.ContactMethods[0].Number : string.Empty); - - if (entryToDial == null) return; - - Dial(entryToDial.ContactMethods[0].Number); - } - else - { - // If auto dial is disabled... - var entryToDial = _selectedDirectoryItem as DirectoryContact; - - if (entryToDial == null) - { - // Clear out values and actions from last selected item - trilist.SetUshort(joinMap.SelectedContactMethodCount.JoinNumber, 0); - trilist.SetString(joinMap.DirectoryEntrySelectedName.JoinNumber, string.Empty); - trilist.ClearUShortSigAction(joinMap.SelectContactMethod.JoinNumber); - trilist.ClearBoolSigAction(joinMap.DirectoryDialSelectedLine.JoinNumber); - trilist.ClearBoolSigAction(joinMap.DirectoryDialSelectedContactMethod.JoinNumber); - return; - } - - trilist.SetUshort(joinMap.SelectedContactMethodCount.JoinNumber, (ushort)entryToDial.ContactMethods.Count); - - // Update the action to dial the selected contact method - trilist.SetUShortSigAction(joinMap.SelectContactMethod.JoinNumber, (u) => - { - if (u < 1 || u > entryToDial.ContactMethods.Count) return; - - trilist.SetSigFalseAction(joinMap.DirectoryDialSelectedContactMethod.JoinNumber, () => Dial(entryToDial.ContactMethods[u - 1].Number)); - }); - - // Sets DirectoryDialSelectedLine join action to dial first contact method - trilist.SetSigFalseAction(joinMap.DirectoryDialSelectedLine.JoinNumber, () => Dial(entryToDial.ContactMethods[0].Number)); - - var clearBytes = XSigHelpers.ClearOutputs(); - - trilist.SetString(joinMap.ContactMethods.JoinNumber, - Encoding.GetEncoding(XSigEncoding).GetString(clearBytes, 0, clearBytes.Length)); - var contactMethodsXSig = UpdateContactMethodsXSig(entryToDial); - - trilist.SetString(joinMap.ContactMethods.JoinNumber, contactMethodsXSig); - } - } - - /// - /// Generates the XSig data representing the available contact methods for the selected DirectoryContact - /// - /// - /// - private string UpdateContactMethodsXSig(DirectoryContact contact) - { - const int maxMethods = 10; - const int maxStrings = 3; - const int offset = maxStrings; - var stringIndex = 0; - var arrayIndex = 0; - // Create a new token array and set the size to the number of methods times the total number of signals - var tokenArray = new XSigToken[maxMethods * offset]; - - Debug.Console(2, this, "Creating XSIG token array with size {0}", maxMethods * offset); - - // TODO: Add code to generate XSig data - foreach (var method in contact.ContactMethods) - { - if (arrayIndex >= maxMethods * offset) - break; - - //serials - tokenArray[arrayIndex + 1] = new XSigSerialToken(stringIndex + 1, method.Number); - tokenArray[arrayIndex + 2] = new XSigSerialToken(stringIndex + 2, method.ContactMethodId.ToString()); - tokenArray[arrayIndex + 3] = new XSigSerialToken(stringIndex + 3, method.Device.ToString()); - - arrayIndex += offset; - stringIndex += maxStrings; - } - - while (arrayIndex < maxMethods) - { - tokenArray[arrayIndex + 1] = new XSigSerialToken(stringIndex + 1, String.Empty); - tokenArray[arrayIndex + 2] = new XSigSerialToken(stringIndex + 2, String.Empty); - tokenArray[arrayIndex + 3] = new XSigSerialToken(stringIndex + 3, String.Empty); - - arrayIndex += offset; - stringIndex += maxStrings; - } - - return GetXSigString(tokenArray); - } - - private string UpdateDirectoryXSig(CodecDirectory directory, bool isRoot) - { - var xSigMaxIndex = 1023; - var tokenArray = new XSigToken[directory.CurrentDirectoryResults.Count > xSigMaxIndex - ? xSigMaxIndex - : directory.CurrentDirectoryResults.Count]; - - Debug.Console(2, this, "IsRoot: {0}, Directory Count: {1}, TokenArray.Length: {2}", isRoot, directory.CurrentDirectoryResults.Count, tokenArray.Length); - - var contacts = directory.CurrentDirectoryResults.Count > xSigMaxIndex - ? directory.CurrentDirectoryResults.Take(xSigMaxIndex) - : directory.CurrentDirectoryResults; - - var contactsToDisplay = isRoot - ? contacts.Where(c => c.ParentFolderId == "root") - : contacts.Where(c => c.ParentFolderId != "root"); - - var counterIndex = 1; - foreach (var entry in contactsToDisplay) - { - var arrayIndex = counterIndex - 1; - var entryIndex = counterIndex; - - Debug.Console(2, this, "Entry{2:0000} Name: {0}, Folder ID: {1}, Type: {3}, ParentFolderId: {4}", - entry.Name, entry.FolderId, entryIndex, entry.GetType().GetCType().FullName, entry.ParentFolderId); - - if (entry is DirectoryFolder) - { - tokenArray[arrayIndex] = new XSigSerialToken(entryIndex, String.Format("[+] {0}", entry.Name)); - - counterIndex++; - - continue; - } - - tokenArray[arrayIndex] = new XSigSerialToken(entryIndex, entry.Name); - - counterIndex++; - } - - return GetXSigString(tokenArray); - } - - private void LinkVideoCodecCallControlsToApi(BasicTriList trilist, VideoCodecControllerJoinMap joinMap) - { - trilist.SetSigFalseAction(joinMap.ManualDial.JoinNumber, - () => Dial(trilist.StringOutput[joinMap.CurrentDialString.JoinNumber].StringValue)); - - //End All calls - trilist.SetSigFalseAction(joinMap.EndAllCalls.JoinNumber, EndAllCalls); - - //End a specific call, specified by index. Maximum 8 calls supported - for (int i = 0; i < joinMap.EndCallStart.JoinSpan; i++) - { - var callIndex = i; - - trilist.SetSigFalseAction((uint)(joinMap.EndCallStart.JoinNumber + i), () => - { - - if (callIndex < 0 || callIndex >= ActiveCalls.Count) - { - Debug.Console(2, this, "Cannot end call. No call found at index: {0}", callIndex); - return; - } - - var call = ActiveCalls[callIndex]; - if (call != null) - { - EndCall(call); - } - else - { - Debug.Console(0, this, "[End Call] Unable to find call at index '{0}'", i); - } - }); - } - - trilist.SetBool(joinMap.HookState.JoinNumber, IsInCall); - - CallStatusChange += (sender, args) => - { - trilist.SetBool(joinMap.HookState.JoinNumber, IsInCall); - - Debug.Console(1, this, "Call Direction: {0}", args.CallItem.Direction); - Debug.Console(1, this, "Call is incoming: {0}", args.CallItem.Direction == eCodecCallDirection.Incoming); - trilist.SetBool(joinMap.IncomingCall.JoinNumber, args.CallItem.Direction == eCodecCallDirection.Incoming && args.CallItem.Status == eCodecCallStatus.Ringing); - - if (args.CallItem.Direction == eCodecCallDirection.Incoming) - { - trilist.SetSigFalseAction(joinMap.IncomingAnswer.JoinNumber, () => AcceptCall(args.CallItem)); - trilist.SetSigFalseAction(joinMap.IncomingReject.JoinNumber, () => RejectCall(args.CallItem)); - trilist.SetString(joinMap.IncomingCallName.JoinNumber, args.CallItem.Name); - trilist.SetString(joinMap.IncomingCallNumber.JoinNumber, args.CallItem.Number); - } - else - { - trilist.SetString(joinMap.IncomingCallName.JoinNumber, string.Empty); - trilist.SetString(joinMap.IncomingCallNumber.JoinNumber, string.Empty); - } - - - trilist.SetString(joinMap.CurrentCallData.JoinNumber, UpdateCallStatusXSig()); - - trilist.SetUshort(joinMap.ConnectedCallCount.JoinNumber, (ushort)ActiveCalls.Count); - }; - - var joinCodec = this as IJoinCalls; - if (joinCodec != null) - { - trilist.SetSigFalseAction(joinMap.JoinAllCalls.JoinNumber, () => joinCodec.JoinAllCalls()); - - for (int i = 0; i < joinMap.JoinCallStart.JoinSpan; i++) - { - trilist.SetSigFalseAction((uint)(joinMap.JoinCallStart.JoinNumber + i), () => - { - var call = ActiveCalls[i]; - if (call != null) - { - joinCodec.JoinCall(call); - } - else - { - Debug.Console(0, this, "[Join Call] Unable to find call at index '{0}'", i); - } - }); - } - } - - var holdCodec = this as IHasCallHold; - if (holdCodec != null) - { - trilist.SetSigFalseAction(joinMap.HoldAllCalls.JoinNumber, () => - { - foreach (var call in ActiveCalls) - { - holdCodec.HoldCall(call); - } - }); - - for (int i = 0; i < joinMap.HoldCallsStart.JoinSpan; i++) - { - var index = i; - - trilist.SetSigFalseAction((uint)(joinMap.HoldCallsStart.JoinNumber + index), () => - { - if (index < 0 || index >= ActiveCalls.Count) return; - - var call = ActiveCalls[index]; - if (call != null) - { - holdCodec.HoldCall(call); - } - else - { - Debug.Console(0, this, "[Hold Call] Unable to find call at index '{0}'", i); - } - }); - - trilist.SetSigFalseAction((uint)(joinMap.ResumeCallsStart.JoinNumber + index), () => - { - if (index < 0 || index >= ActiveCalls.Count) return; - - var call = ActiveCalls[index]; - if (call != null) - { - holdCodec.ResumeCall(call); - } - else - { - Debug.Console(0, this, "[Resume Call] Unable to find call at index '{0}'", i); - } - }); - } - } - - - - trilist.OnlineStatusChange += (device, args) => - { - if (!args.DeviceOnLine) return; - - // TODO [ ] #983 - Debug.Console(0, this, "LinkVideoCodecCallControlsToApi: device is {0}, IsInCall {1}", args.DeviceOnLine ? "online" : "offline", IsInCall); - trilist.SetBool(joinMap.HookState.JoinNumber, IsInCall); - trilist.SetString(joinMap.CurrentCallData.JoinNumber, "\xFC"); - trilist.SetString(joinMap.CurrentCallData.JoinNumber, UpdateCallStatusXSig()); - }; - } - - private string UpdateCallStatusXSig() - { - const int maxCalls = 8; - const int maxStrings = 6; - const int maxDigitals = 2; - const int offset = maxStrings + maxDigitals; - var stringIndex = 0; - var digitalIndex = maxStrings * maxCalls; - var arrayIndex = 0; - - var tokenArray = new XSigToken[maxCalls * offset]; //set array size for number of calls * pieces of info - - foreach (var call in ActiveCalls) - { - if (arrayIndex >= maxCalls * offset) - break; - //digitals - tokenArray[digitalIndex] = new XSigDigitalToken(digitalIndex + 1, call.IsActiveCall); - tokenArray[digitalIndex + 1] = new XSigDigitalToken(digitalIndex + 2, call.IsOnHold); - - //serials - tokenArray[stringIndex] = new XSigSerialToken(stringIndex + 1, call.Name ?? String.Empty); - tokenArray[stringIndex + 1] = new XSigSerialToken(stringIndex + 2, call.Number ?? String.Empty); - tokenArray[stringIndex + 2] = new XSigSerialToken(stringIndex + 3, call.Direction.ToString()); - tokenArray[stringIndex + 3] = new XSigSerialToken(stringIndex + 4, call.Type.ToString()); - tokenArray[stringIndex + 4] = new XSigSerialToken(stringIndex + 5, call.Status.ToString()); - if(call.Duration != null) - { - // May need to verify correct string format here - var dur = string.Format("{0:c}", call.Duration); - tokenArray[arrayIndex + 6] = new XSigSerialToken(stringIndex + 6, dur); - } - - arrayIndex += offset; - stringIndex += maxStrings; - digitalIndex += maxDigitals; - } - while (arrayIndex < maxCalls * offset) - { - //digitals - tokenArray[digitalIndex] = new XSigDigitalToken(digitalIndex + 1, false); - tokenArray[digitalIndex + 1] = new XSigDigitalToken(digitalIndex + 2, false); - - - //serials - tokenArray[stringIndex] = new XSigSerialToken(stringIndex + 1, String.Empty); - tokenArray[stringIndex + 1] = new XSigSerialToken(stringIndex + 2, String.Empty); - tokenArray[stringIndex + 2] = new XSigSerialToken(stringIndex + 3, String.Empty); - tokenArray[stringIndex + 3] = new XSigSerialToken(stringIndex + 4, String.Empty); - tokenArray[stringIndex + 4] = new XSigSerialToken(stringIndex + 5, String.Empty); - tokenArray[stringIndex + 5] = new XSigSerialToken(stringIndex + 6, String.Empty); - - arrayIndex += offset; - stringIndex += maxStrings; - digitalIndex += maxDigitals; - } - - return GetXSigString(tokenArray); - } - - private void LinkVideoCodecDtmfToApi(BasicTriList trilist, VideoCodecControllerJoinMap joinMap) - { - trilist.SetSigFalseAction(joinMap.Dtmf0.JoinNumber, () => SendDtmfAction("0", trilist, joinMap)); - trilist.SetSigFalseAction(joinMap.Dtmf1.JoinNumber, () => SendDtmfAction("1", trilist, joinMap)); - trilist.SetSigFalseAction(joinMap.Dtmf2.JoinNumber, () => SendDtmfAction("2", trilist, joinMap)); - trilist.SetSigFalseAction(joinMap.Dtmf3.JoinNumber, () => SendDtmfAction("3", trilist, joinMap)); - trilist.SetSigFalseAction(joinMap.Dtmf4.JoinNumber, () => SendDtmfAction("4", trilist, joinMap)); - trilist.SetSigFalseAction(joinMap.Dtmf5.JoinNumber, () => SendDtmfAction("5", trilist, joinMap)); - trilist.SetSigFalseAction(joinMap.Dtmf6.JoinNumber, () => SendDtmfAction("6", trilist, joinMap)); - trilist.SetSigFalseAction(joinMap.Dtmf7.JoinNumber, () => SendDtmfAction("7", trilist, joinMap)); - trilist.SetSigFalseAction(joinMap.Dtmf8.JoinNumber, () => SendDtmfAction("8", trilist, joinMap)); - trilist.SetSigFalseAction(joinMap.Dtmf9.JoinNumber, () => SendDtmfAction("9", trilist, joinMap)); - trilist.SetSigFalseAction(joinMap.DtmfStar.JoinNumber, () => SendDtmfAction("*", trilist, joinMap)); - trilist.SetSigFalseAction(joinMap.DtmfPound.JoinNumber, () => SendDtmfAction("#", trilist, joinMap)); - } - - /// - /// Sends the specified string as a DTMF command. - /// Reads the value of the SendDtmfToSpecificCallInstance digital join and SelectCall analog join to determine - /// Whther to send to a specific call index or to the last connected call - /// - /// - /// - /// - private void SendDtmfAction(string s, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) - { - if (!trilist.GetBool(joinMap.SendDtmfToSpecificCallIndex.JoinNumber)) - { - SendDtmf(s); - } - else - { - var callIndex = trilist.GetUshort(joinMap.SelectCall.JoinNumber); - if (callIndex > 0 && callIndex <= 8) - { - var call = ActiveCalls[callIndex - 1]; - if (call != null && call.IsActiveCall) - { - SendDtmf(s, call); - } - else - { - Debug.Console(0, this, "Warning: No call found at index {0} or call is not active.", callIndex); - } - } - else - { - Debug.Console(0, this, "Warning: Invalid call index specified. Please use a value of 1-8."); - } - } - } - - private void LinkVideoCodecCameraLayoutsToApi(IHasCodecLayouts codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) - { - trilist.SetSigFalseAction(joinMap.CameraLayout.JoinNumber, codec.LocalLayoutToggle); - - codec.LocalLayoutFeedback.LinkInputSig(trilist.StringInput[joinMap.CurrentLayoutStringFb.JoinNumber]); - } - - private void LinkVideoCodecCameraModeToApi(IHasCameraAutoMode codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) - { - trilist.SetSigFalseAction(joinMap.CameraModeAuto.JoinNumber, codec.CameraAutoModeOn); - trilist.SetSigFalseAction(joinMap.CameraModeManual.JoinNumber, codec.CameraAutoModeOff); - - codec.CameraAutoModeIsOnFeedback.OutputChange += (o, a) => - { - var offCodec = codec as IHasCameraOff; - - if (offCodec != null) - { - if (offCodec.CameraIsOffFeedback.BoolValue) - { - trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, false); - trilist.SetBool(joinMap.CameraModeManual.JoinNumber, false); - trilist.SetBool(joinMap.CameraModeOff.JoinNumber, true); - return; - } - - trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, a.BoolValue); - trilist.SetBool(joinMap.CameraModeManual.JoinNumber, !a.BoolValue); - trilist.SetBool(joinMap.CameraModeOff.JoinNumber, false); - return; - } - - trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, a.BoolValue); - trilist.SetBool(joinMap.CameraModeManual.JoinNumber, !a.BoolValue); - trilist.SetBool(joinMap.CameraModeOff.JoinNumber, false); - }; - - var offModeCodec = codec as IHasCameraOff; - - if (offModeCodec != null) - { - if (offModeCodec.CameraIsOffFeedback.BoolValue) - { - trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, false); - trilist.SetBool(joinMap.CameraModeManual.JoinNumber, false); - trilist.SetBool(joinMap.CameraModeOff.JoinNumber, true); - return; - } - - trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, codec.CameraAutoModeIsOnFeedback.BoolValue); - trilist.SetBool(joinMap.CameraModeManual.JoinNumber, !codec.CameraAutoModeIsOnFeedback.BoolValue); - trilist.SetBool(joinMap.CameraModeOff.JoinNumber, false); - return; - } - - trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, codec.CameraAutoModeIsOnFeedback.BoolValue); - trilist.SetBool(joinMap.CameraModeManual.JoinNumber, !codec.CameraAutoModeIsOnFeedback.BoolValue); - trilist.SetBool(joinMap.CameraModeOff.JoinNumber, false); - } - - private void LinkVideoCodecSelfviewToApi(IHasCodecSelfView codec, BasicTriList trilist, - VideoCodecControllerJoinMap joinMap) - { - trilist.SetSigFalseAction(joinMap.CameraSelfView.JoinNumber, codec.SelfViewModeToggle); - - codec.SelfviewIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.CameraSelfView.JoinNumber]); - } - - private void LinkVideoCodecCameraToApi(IHasCodecCameras codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) - { - //Camera PTZ - trilist.SetBoolSigAction(joinMap.CameraTiltUp.JoinNumber, (b) => - { - if (codec.SelectedCamera == null) return; - var camera = codec.SelectedCamera as IHasCameraPtzControl; - - if (camera == null) return; - - if (b) camera.TiltUp(); - else camera.TiltStop(); - }); - - trilist.SetBoolSigAction(joinMap.CameraTiltDown.JoinNumber, (b) => - { - if (codec.SelectedCamera == null) return; - var camera = codec.SelectedCamera as IHasCameraPtzControl; - - if (camera == null) return; - - if (b) camera.TiltDown(); - else camera.TiltStop(); - }); - trilist.SetBoolSigAction(joinMap.CameraPanLeft.JoinNumber, (b) => - { - if (codec.SelectedCamera == null) return; - var camera = codec.SelectedCamera as IHasCameraPtzControl; - - if (camera == null) return; - - if (b) camera.PanLeft(); - else camera.PanStop(); - }); - trilist.SetBoolSigAction(joinMap.CameraPanRight.JoinNumber, (b) => - { - if (codec.SelectedCamera == null) return; - var camera = codec.SelectedCamera as IHasCameraPtzControl; - - if (camera == null) return; - - if (b) camera.PanRight(); - else camera.PanStop(); - }); - - trilist.SetBoolSigAction(joinMap.CameraZoomIn.JoinNumber, (b) => - { - if (codec.SelectedCamera == null) return; - var camera = codec.SelectedCamera as IHasCameraPtzControl; - - if (camera == null) return; - - if (b) camera.ZoomIn(); - else camera.ZoomStop(); - }); - - trilist.SetBoolSigAction(joinMap.CameraZoomOut.JoinNumber, (b) => - { - if (codec.SelectedCamera == null) return; - var camera = codec.SelectedCamera as IHasCameraPtzControl; - - if (camera == null) return; - - if (b) camera.ZoomOut(); - else camera.ZoomStop(); - }); - - - trilist.SetBoolSigAction(joinMap.CameraFocusNear.JoinNumber, (b) => - { - if (codec.SelectedCamera == null) return; - var camera = codec.SelectedCamera as IHasCameraFocusControl; - - if (camera == null) return; - - if (b) camera.FocusNear(); - else camera.FocusStop(); - }); - - trilist.SetBoolSigAction(joinMap.CameraFocusFar.JoinNumber, (b) => - { - if (codec.SelectedCamera == null) return; - var camera = codec.SelectedCamera as IHasCameraFocusControl; - - if (camera == null) return; - - if (b) camera.FocusFar(); - else camera.FocusStop(); - }); - - trilist.SetSigFalseAction(joinMap.CameraFocusAuto.JoinNumber, () => - { - if (codec.SelectedCamera == null) return; - var camera = codec.SelectedCamera as IHasCameraFocusControl; - - if (camera == null) return; - - camera.TriggerAutoFocus(); - }); - - // Camera count - trilist.SetUshort(joinMap.CameraCount.JoinNumber, (ushort)codec.Cameras.Count); - - // Camera names - for (uint i = 0; i < joinMap.CameraNamesFb.JoinSpan; i++) - { - //Check the count first - if (i < codec.Cameras.Count && codec.Cameras[(int)i] != null) - { - trilist.SetString(joinMap.CameraNamesFb.JoinNumber + i, codec.Cameras[(int)i].Name); - } - else - { - trilist.SetString(joinMap.CameraNamesFb.JoinNumber + i, ""); - } - } - - //Camera Select - trilist.SetUShortSigAction(joinMap.CameraNumberSelect.JoinNumber, (i) => - { - if (i > 0 && i <= codec.Cameras.Count) - { - codec.SelectCamera(codec.Cameras[i - 1].Key); - } - else - { - Debug.Console(0, this, "Unable to select. No camera found at index {0}", i); - } - }); - - // Set initial selected camera feedback - if (codec.SelectedCamera != null) - { - trilist.SetUshort(joinMap.CameraNumberSelect.JoinNumber, (ushort)codec.Cameras.FindIndex((c) => c.Key == codec.SelectedCamera.Key)); - } - - codec.CameraSelected += (sender, args) => - { - var i = (ushort)codec.Cameras.FindIndex((c) => c.Key == args.SelectedCamera.Key); - - trilist.SetUshort(joinMap.CameraNumberSelect.JoinNumber, (ushort)(i + 1)); - - if (codec is IHasCodecRoomPresets) - { - return; - } - - if (!(args.SelectedCamera is IHasCameraPresets)) - { - return; - } - - var cam = args.SelectedCamera as IHasCameraPresets; - SetCameraPresetNames(cam.Presets); - - (args.SelectedCamera as IHasCameraPresets).PresetsListHasChanged += (o, eventArgs) => SetCameraPresetNames(cam.Presets); - - trilist.SetUShortSigAction(joinMap.CameraPresetSelect.JoinNumber, - (a) => - { - cam.PresetSelect(a); - trilist.SetUshort(joinMap.CameraPresetSelect.JoinNumber, a); - }); - - trilist.SetSigFalseAction(joinMap.CameraPresetSave.JoinNumber, - () => - { - cam.PresetStore(trilist.UShortOutput[joinMap.CameraPresetSelect.JoinNumber].UShortValue, - String.Empty); - trilist.PulseBool(joinMap.CameraPresetSave.JoinNumber, 3000); - }); - }; - - if (!(codec is IHasCodecRoomPresets)) return; - - var presetCodec = codec as IHasCodecRoomPresets; - - presetCodec.CodecRoomPresetsListHasChanged += - (sender, args) => SetCameraPresetNames(presetCodec.NearEndPresets); - - //Camera Presets - trilist.SetUShortSigAction(joinMap.CameraPresetSelect.JoinNumber, (i) => - { - presetCodec.CodecRoomPresetSelect(i); - }); - - - // Far End Presets - trilist.SetUShortSigAction(joinMap.FarEndPresetSelect.JoinNumber, (i) => - { - presetCodec.SelectFarEndPreset(i); - }); - - - trilist.SetSigFalseAction(joinMap.CameraPresetSave.JoinNumber, - () => - { - presetCodec.CodecRoomPresetStore( - trilist.UShortOutput[joinMap.CameraPresetSelect.JoinNumber].UShortValue, String.Empty); - trilist.PulseBool(joinMap.CameraPresetSave.JoinNumber, 3000); - }); - - trilist.OnlineStatusChange += (device, args) => - { - if (!args.DeviceOnLine) return; - - // TODO [ ] Issue #868 - trilist.SetString(joinMap.CameraPresetNames.JoinNumber, "\xFC"); - SetCameraPresetNames(presetCodec.NearEndPresets); - }; - } - - // Following fields only used for Bridging - private int _selectedRecentCallItemIndex; - private CodecCallHistory.CallHistoryEntry _selectedRecentCallItem; - private DirectoryItem _selectedDirectoryItem; - - private void LinkVideoCodecCallHistoryToApi(IHasCallHistory codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) - { - codec.CallHistory.RecentCallsListHasChanged += (o, a) => - { - UpdateCallHistory(codec, trilist, joinMap); - }; - - // Selected item action and feedback - trilist.SetUShortSigAction(joinMap.SelectRecentCallItem.JoinNumber, (u) => - { - if (u == 0 || u > codec.CallHistory.RecentCalls.Count) - { - Debug.Console(2, this, "Recent Call History index out of range"); - return; - } - - _selectedRecentCallItemIndex = (int)(u - 1); - trilist.SetUshort(joinMap.SelectRecentCallItem.JoinNumber, u); - - var _selectedRecentCallItem = codec.CallHistory.RecentCalls[_selectedRecentCallItemIndex]; - - if (_selectedRecentCallItem != null) - { - trilist.SetString(joinMap.SelectedRecentCallName.JoinNumber, _selectedRecentCallItem.Name); - trilist.SetString(joinMap.SelectedRecentCallNumber.JoinNumber, _selectedRecentCallItem.Number); - trilist.SetSigFalseAction(joinMap.RemoveSelectedRecentCallItem.JoinNumber, () => codec.RemoveCallHistoryEntry(_selectedRecentCallItem)); - trilist.SetSigFalseAction(joinMap.DialSelectedRecentCallItem.JoinNumber, () => this.Dial(_selectedRecentCallItem.Number)); - } - else - { - trilist.SetString(joinMap.SelectedRecentCallName.JoinNumber, string.Empty); - trilist.SetString(joinMap.SelectedRecentCallNumber.JoinNumber, string.Empty); - trilist.ClearBoolSigAction(joinMap.RemoveSelectedRecentCallItem.JoinNumber); - trilist.ClearBoolSigAction(joinMap.DialSelectedRecentCallItem.JoinNumber); - } - }); - } - - - - private void UpdateCallHistory(IHasCallHistory codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) - { - // Clear out selected item - _selectedRecentCallItemIndex = 0; - _selectedRecentCallItem = null; - trilist.SetUshort(joinMap.SelectRecentCallItem.JoinNumber, 0); - trilist.SetString(joinMap.SelectedRecentCallName.JoinNumber, string.Empty); - trilist.SetString(joinMap.SelectedRecentCallNumber.JoinNumber, string.Empty); - trilist.ClearBoolSigAction(joinMap.RemoveSelectedRecentCallItem.JoinNumber); - // - - trilist.SetUshort(joinMap.RecentCallCount.JoinNumber, (ushort)codec.CallHistory.RecentCalls.Count); - - // Update the call history joins - var maxItems = joinMap.RecentCallNamesStart.JoinSpan; - - // Create history - uint index = 0; - for (uint i = 0; i < maxItems && i < codec.CallHistory.RecentCalls.Count; i++) - { - trilist.SetString(joinMap.RecentCallNamesStart.JoinNumber + i, codec.CallHistory.RecentCalls[(int)i].Name); - trilist.SetString(joinMap.RecentCallTimesStart.JoinNumber + i, codec.CallHistory.RecentCalls[(int)i].StartTime.ToShortTimeString()); - trilist.SetUshort(joinMap.RecentCallOccurrenceType.JoinNumber + i, (ushort)codec.CallHistory.RecentCalls[(int)i].OccurrenceType); - //i++; - index = i; - } - - //foreach(var item in codec.CallHistory.RecentCalls) - //{ - // trilist.SetString(joinMap.RecentCallNamesStart.JoinNumber + i, item.Name); - // trilist.SetString(joinMap.RecentCallTimesStart.JoinNumber + i, item.StartTime.ToShortTimeString()); - // trilist.SetUshort(joinMap.RecentCallOccurrenceType.JoinNumber + i, (ushort)item.OccurrenceType); - // i++; - //} - - // Clears existing items - for (uint j = index; j < maxItems; j++) - { - trilist.SetString(joinMap.RecentCallNamesStart.JoinNumber + j, string.Empty); - trilist.SetString(joinMap.RecentCallTimesStart.JoinNumber + j, string.Empty); - trilist.SetUshort(joinMap.RecentCallOccurrenceType.JoinNumber + j, 0); - } - } - - private string SetCameraPresetNames(IEnumerable presets) - { - return SetCameraPresetNames(presets.Select(p => p.Description).ToList()); - } - - private string SetCameraPresetNames(IEnumerable presets) - { - return SetCameraPresetNames(presets.Select(p => p.Description).ToList()); - } - - private string SetCameraPresetNames(ICollection presets) - { - var i = 1; //start index for xsig; - - var tokenArray = new XSigToken[presets.Count]; - - foreach (var preset in presets) - { - var cameraPreset = new XSigSerialToken(i, preset); - tokenArray[i - 1] = cameraPreset; - i++; - } - - return GetXSigString(tokenArray); - } - - private string GetXSigString(XSigToken[] tokenArray) - { - string returnString; - using (var s = new MemoryStream()) - { - using (var tw = new XSigTokenStreamWriter(s, true)) - { - tw.WriteXSigData(tokenArray); - } - - var xSig = s.ToArray(); - - returnString = Encoding.GetEncoding(XSigEncoding).GetString(xSig, 0, xSig.Length); - } - - return returnString; - } - - #endregion - } - - - /// - /// Used to track the status of syncronizing the phonebook values when connecting to a codec or refreshing the phonebook info - /// - public class CodecPhonebookSyncState : IKeyed - { - private bool _InitialSyncComplete; - - public CodecPhonebookSyncState(string key) - { - Key = key; - - CodecDisconnected(); - } - - public bool InitialSyncComplete - { - get { return _InitialSyncComplete; } - private set - { - if (value == true) - { - var handler = InitialSyncCompleted; - if (handler != null) - { - handler(this, new EventArgs()); - } - } - _InitialSyncComplete = value; - } - } - - public bool InitialPhonebookFoldersWasReceived { get; private set; } - - public bool NumberOfContactsWasReceived { get; private set; } - - public bool PhonebookRootEntriesWasRecieved { get; private set; } - - public bool PhonebookHasFolders { get; private set; } - - public int NumberOfContacts { get; private set; } - - #region IKeyed Members - - public string Key { get; private set; } - - #endregion - - public event EventHandler InitialSyncCompleted; - - public void InitialPhonebookFoldersReceived() - { - InitialPhonebookFoldersWasReceived = true; - - CheckSyncStatus(); - } - - public void PhonebookRootEntriesReceived() - { - PhonebookRootEntriesWasRecieved = true; - - CheckSyncStatus(); - } - - public void SetPhonebookHasFolders(bool value) - { - PhonebookHasFolders = value; - - Debug.Console(1, this, "Phonebook has folders: {0}", PhonebookHasFolders); - } - - public void SetNumberOfContacts(int contacts) - { - NumberOfContacts = contacts; - NumberOfContactsWasReceived = true; - - Debug.Console(1, this, "Phonebook contains {0} contacts.", NumberOfContacts); - - CheckSyncStatus(); - } - - public void CodecDisconnected() - { - InitialPhonebookFoldersWasReceived = false; - PhonebookHasFolders = false; - NumberOfContacts = 0; - NumberOfContactsWasReceived = false; - } - - private void CheckSyncStatus() - { - if (InitialPhonebookFoldersWasReceived && NumberOfContactsWasReceived && PhonebookRootEntriesWasRecieved) - { - InitialSyncComplete = true; - Debug.Console(1, this, "Initial Phonebook Sync Complete!"); - } - else - { - InitialSyncComplete = false; - } - } - } - /// - /// Represents a codec command that might need to have a friendly label applied for UI feedback purposes - /// - public class CodecCommandWithLabel - { - public string Command { get; private set; } - public string Label { get; private set; } - - public CodecCommandWithLabel(string command, string label) - { - Command = command; - Label = label; - } - } - - - +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp.CrestronIO; +using Crestron.SimplSharp.Reflection; +using Crestron.SimplSharp.Ssh; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharp; +using PepperDash.Core; +using PepperDash.Core.Intersystem; +using PepperDash.Core.Intersystem.Tokens; +using PepperDash.Core.WebApi.Presets; +using Crestron.SimplSharp.Reflection; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.Core.Devices; +using PepperDash.Essentials.Core.DeviceTypeInterfaces; +using PepperDash.Essentials.Core.Routing; +using PepperDash.Essentials.Devices.Common.Cameras; +using PepperDash.Essentials.Devices.Common.Codec; +using PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces; +using PepperDash.Essentials.Core.Bridges.JoinMaps; +using Feedback = PepperDash.Essentials.Core.Feedback; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec +{ + public abstract class VideoCodecBase : ReconfigurableDevice, IRoutingInputsOutputs, + IUsageTracking, IHasDialer, IHasContentSharing, ICodecAudio, iVideoCodecInfo, IBridgeAdvanced, IHasStandbyMode + { + private const int XSigEncoding = 28591; + protected const int MaxParticipants = 50; + private readonly byte[] _clearBytes = XSigHelpers.ClearOutputs(); + + private IHasDirectory _directoryCodec; + private BasicTriList _directoryTrilist; + private VideoCodecControllerJoinMap _directoryJoinmap; + + protected string _timeFormatSpecifier; + protected string _dateFormatSpecifier; + + + protected VideoCodecBase(DeviceConfig config) + : base(config) + { + + StandbyIsOnFeedback = new BoolFeedback(StandbyIsOnFeedbackFunc); + PrivacyModeIsOnFeedback = new BoolFeedback(PrivacyModeIsOnFeedbackFunc); + VolumeLevelFeedback = new IntFeedback(VolumeLevelFeedbackFunc); + MuteFeedback = new BoolFeedback(MuteFeedbackFunc); + SharingSourceFeedback = new StringFeedback(SharingSourceFeedbackFunc); + SharingContentIsOnFeedback = new BoolFeedback(SharingContentIsOnFeedbackFunc); + + // TODO [ ] hotfix/videocodecbase-max-meeting-xsig-set + MeetingsToDisplayFeedback = new IntFeedback(() => MeetingsToDisplay); + + InputPorts = new RoutingPortCollection(); + OutputPorts = new RoutingPortCollection(); + + ActiveCalls = new List(); + } + + public IBasicCommunication Communication { get; protected set; } + + /// + /// An internal pseudo-source that is routable and connected to the osd input + /// + public DummyRoutingInputsDevice OsdSource { get; protected set; } + + public BoolFeedback StandbyIsOnFeedback { get; private set; } + + protected abstract Func PrivacyModeIsOnFeedbackFunc { get; } + protected abstract Func VolumeLevelFeedbackFunc { get; } + protected abstract Func MuteFeedbackFunc { get; } + protected abstract Func StandbyIsOnFeedbackFunc { get; } + + public List ActiveCalls { get; set; } + + public bool ShowSelfViewByDefault { get; protected set; } + + public bool SupportsCameraOff { get; protected set; } + public bool SupportsCameraAutoMode { get; protected set; } + + public bool IsReady { get; protected set; } + + public virtual List Feedbacks + { + get + { + return new List + { + PrivacyModeIsOnFeedback, + SharingSourceFeedback + }; + } + } + + protected abstract Func SharingSourceFeedbackFunc { get; } + protected abstract Func SharingContentIsOnFeedbackFunc { get; } + + #region ICodecAudio Members + + public abstract void PrivacyModeOn(); + public abstract void PrivacyModeOff(); + public abstract void PrivacyModeToggle(); + public BoolFeedback PrivacyModeIsOnFeedback { get; private set; } + + + public BoolFeedback MuteFeedback { get; private set; } + + public abstract void MuteOff(); + + public abstract void MuteOn(); + + public abstract void SetVolume(ushort level); + + public IntFeedback VolumeLevelFeedback { get; private set; } + + public abstract void MuteToggle(); + + public abstract void VolumeDown(bool pressRelease); + + + public abstract void VolumeUp(bool pressRelease); + + #endregion + + #region IHasContentSharing Members + + public abstract void StartSharing(); + public abstract void StopSharing(); + + public bool AutoShareContentWhileInCall { get; protected set; } + + public StringFeedback SharingSourceFeedback { get; private set; } + public BoolFeedback SharingContentIsOnFeedback { get; private set; } + + #endregion + + #region IHasDialer Members + + /// + /// Fires when the status of any active, dialing, or incoming call changes or is new + /// + public event EventHandler CallStatusChange; + + /// + /// Returns true when any call is not in state Unknown, Disconnecting, Disconnected + /// + public bool IsInCall + { + get + { + var value = ActiveCalls != null && ActiveCalls.Any(c => c.IsActiveCall); + return value; + } + } + + public abstract void Dial(string number); + public abstract void EndCall(CodecActiveCallItem call); + public abstract void EndAllCalls(); + public abstract void AcceptCall(CodecActiveCallItem call); + public abstract void RejectCall(CodecActiveCallItem call); + public abstract void SendDtmf(string s); + public virtual void SendDtmf(string s, CodecActiveCallItem call) { } + + #endregion + + #region IRoutingInputsOutputs Members + + public RoutingPortCollection InputPorts { get; private set; } + + public RoutingPortCollection OutputPorts { get; private set; } + + #endregion + + #region IUsageTracking Members + + /// + /// This object can be added by outside users of this class to provide usage tracking + /// for various services + /// + public UsageTracking UsageTracker { get; set; } + + #endregion + + #region iVideoCodecInfo Members + + public VideoCodecInfo CodecInfo { get; protected set; } + + #endregion + + public event EventHandler IsReadyChange; + public abstract void Dial(Meeting meeting); + + public virtual void Dial(IInvitableContact contact) + { + } + + public abstract void ExecuteSwitch(object selector); + + /// + /// Helper method to fire CallStatusChange event with old and new status + /// + protected void SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus newStatus, CodecActiveCallItem call) + { + call.Status = newStatus; + + OnCallStatusChange(call); + } + + /// + /// + /// + /// + /// + /// + protected virtual void OnCallStatusChange(CodecActiveCallItem item) + { + var handler = CallStatusChange; + if (handler != null) + { + handler(this, new CodecCallStatusItemChangeEventArgs(item)); + } + + PrivacyModeIsOnFeedback.FireUpdate(); + + if (AutoShareContentWhileInCall) + { + StartSharing(); + } + + if (UsageTracker != null) + { + if (IsInCall && !UsageTracker.UsageTrackingStarted) + { + UsageTracker.StartDeviceUsage(); + } + else if (UsageTracker.UsageTrackingStarted && !IsInCall) + { + UsageTracker.EndDeviceUsage(); + } + } + } + + /// + /// Sets IsReady property and fires the event. Used for dependent classes to sync up their data. + /// + protected void SetIsReady() + { + CrestronInvoke.BeginInvoke((o) => + { + try + { + IsReady = true; + var h = IsReadyChange; + if (h != null) + { + h(this, new EventArgs()); + } + } + catch (Exception e) + { + Debug.Console(2, this, "Error in SetIsReady() : {0}", e); + } + }); + } + + // **** DEBUGGING THINGS **** + /// + /// + /// + public virtual void ListCalls() + { + Debug.Console(1, this, "Active Calls:"); + + var sb = new StringBuilder(); + foreach (var c in ActiveCalls) + { + sb.AppendFormat("id: {0} number: {1} -- name: {2} status: {3} onHold: {4}\r\n", c.Id, c.Number, c.Name, c.Status, c.IsOnHold); + } + Debug.Console(1, this, "\n{0}\n", sb.ToString()); + } + + public abstract void StandbyActivate(); + + public abstract void StandbyDeactivate(); + + #region Implementation of IBridgeAdvanced + + public abstract void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge); + + /// + /// Use this method when using a plain VideoCodecControllerJoinMap + /// + /// + /// + /// + /// + /// + protected void LinkVideoCodecToApi(VideoCodecBase codec, BasicTriList trilist, uint joinStart, string joinMapKey, + EiscApiAdvanced bridge) + { + var joinMap = new VideoCodecControllerJoinMap(joinStart); + + var customJoins = JoinMapHelper.TryGetJoinMapAdvancedForDevice(joinMapKey); + + if (customJoins != null) + { + joinMap.SetCustomJoinData(customJoins); + } + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + + LinkVideoCodecToApi(codec, trilist, joinMap); + + trilist.OnlineStatusChange += (device, args) => + { + if (!args.DeviceOnLine) return; + }; + } + + /// + /// Use this method when you need to pass in a join map that extends VideoCodecControllerJoinMap + /// + /// + /// + /// + protected void LinkVideoCodecToApi(VideoCodecBase codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) + { + Debug.Console(1, this, "Linking to Trilist {0}", trilist.ID.ToString("X")); + + LinkVideoCodecDtmfToApi(trilist, joinMap); + + LinkVideoCodecCallControlsToApi(trilist, joinMap); + + LinkVideoCodecContentSharingToApi(trilist, joinMap); + + LinkVideoCodecPrivacyToApi(trilist, joinMap); + + LinkVideoCodecVolumeToApi(trilist, joinMap); + + LinkVideoCodecInfoToApi(trilist, joinMap); + + // Register for this event to link any functions that require the codec to be ready first + codec.IsReadyChange += (o, a) => + { + if (codec is IHasCodecCameras) + { + LinkVideoCodecCameraToApi(codec as IHasCodecCameras, trilist, joinMap); + } + }; + + if (codec is ICommunicationMonitor) + { + LinkVideoCodecCommMonitorToApi(codec as ICommunicationMonitor, trilist, joinMap); + } + + + if (codec is IHasCodecSelfView) + { + LinkVideoCodecSelfviewToApi(codec as IHasCodecSelfView, trilist, joinMap); + } + + if (codec is IHasCameraAutoMode) + { + trilist.SetBool(joinMap.CameraSupportsAutoMode.JoinNumber, SupportsCameraAutoMode); + LinkVideoCodecCameraModeToApi(codec as IHasCameraAutoMode, trilist, joinMap); + } + + if (codec is IHasCameraOff) + { + trilist.SetBool(joinMap.CameraSupportsOffMode.JoinNumber, SupportsCameraOff); + LinkVideoCodecCameraOffToApi(codec as IHasCameraOff, trilist, joinMap); + } + + if (codec is IHasCodecLayouts) + { + LinkVideoCodecCameraLayoutsToApi(codec as IHasCodecLayouts, trilist, joinMap); + } + + + if (codec is IHasSelfviewPosition) + { + LinkVideoCodecSelfviewPositionToApi(codec as IHasSelfviewPosition, trilist, joinMap); + } + + if (codec is IHasDirectory) + { + LinkVideoCodecDirectoryToApi(codec as IHasDirectory, trilist, joinMap); + } + + if (codec is IHasScheduleAwareness) + { + LinkVideoCodecScheduleToApi(codec as IHasScheduleAwareness, trilist, joinMap); + } + + if (codec is IHasParticipants) + { + LinkVideoCodecParticipantsToApi(codec as IHasParticipants, trilist, joinMap); + } + + if (codec is IHasFarEndContentStatus) + { + (codec as IHasFarEndContentStatus).ReceivingContent.LinkInputSig(trilist.BooleanInput[joinMap.RecievingContent.JoinNumber]); + } + + if (codec is IHasPhoneDialing) + { + LinkVideoCodecPhoneToApi(codec as IHasPhoneDialing, trilist, joinMap); + } + + if (codec is IHasCallHistory) + { + LinkVideoCodecCallHistoryToApi(codec as IHasCallHistory, trilist, joinMap); + } + + trilist.OnlineStatusChange += (device, args) => + { + if (!args.DeviceOnLine) return; + + if (codec is IHasDirectory) + { + (codec as IHasDirectory).SetCurrentDirectoryToRoot(); + } + + if (codec is IHasScheduleAwareness) + { + (codec as IHasScheduleAwareness).GetSchedule(); + } + + if (codec is IHasParticipants) + { + UpdateParticipantsXSig((codec as IHasParticipants).Participants.CurrentParticipants); + } + + if (codec is IHasCameraAutoMode) + { + trilist.SetBool(joinMap.CameraSupportsAutoMode.JoinNumber, SupportsCameraAutoMode); + + (codec as IHasCameraAutoMode).CameraAutoModeIsOnFeedback.FireUpdate(); + } + + if (codec is IHasCodecSelfView) + { + (codec as IHasCodecSelfView).SelfviewIsOnFeedback.FireUpdate(); + } + + if (codec is IHasCameraAutoMode) + { + (codec as IHasCameraAutoMode).CameraAutoModeIsOnFeedback.FireUpdate(); + } + + if (codec is IHasCameraOff) + { + (codec as IHasCameraOff).CameraIsOffFeedback.FireUpdate(); + } + + if (codec is IHasPhoneDialing) + { + (codec as IHasPhoneDialing).PhoneOffHookFeedback.FireUpdate(); + } + + if (codec is IHasCallHistory) + { + UpdateCallHistory((codec as IHasCallHistory), trilist, joinMap); + } + + SharingContentIsOnFeedback.FireUpdate(); + }; + } + + private void LinkVideoCodecInfoToApi(BasicTriList trilist, VideoCodecControllerJoinMap joinMap) + { + trilist.SetBool(joinMap.MultiSiteOptionIsEnabled.JoinNumber, this.CodecInfo.MultiSiteOptionIsEnabled); + trilist.SetBool(joinMap.AutoAnswerEnabled.JoinNumber, this.CodecInfo.AutoAnswerEnabled); + trilist.SetString(joinMap.DeviceIpAddresss.JoinNumber, this.CodecInfo.IpAddress); + trilist.SetString(joinMap.SipPhoneNumber.JoinNumber, this.CodecInfo.SipPhoneNumber); + trilist.SetString(joinMap.E164Alias.JoinNumber, this.CodecInfo.E164Alias); + trilist.SetString(joinMap.H323Id.JoinNumber, this.CodecInfo.H323Id); + trilist.SetString(joinMap.SipUri.JoinNumber, this.CodecInfo.SipUri); + + trilist.OnlineStatusChange += (o, a) => + { + if (a.DeviceOnLine) + { + trilist.SetBool(joinMap.MultiSiteOptionIsEnabled.JoinNumber, this.CodecInfo.MultiSiteOptionIsEnabled); + trilist.SetBool(joinMap.AutoAnswerEnabled.JoinNumber, this.CodecInfo.AutoAnswerEnabled); + trilist.SetString(joinMap.DeviceIpAddresss.JoinNumber, this.CodecInfo.IpAddress); + trilist.SetString(joinMap.SipPhoneNumber.JoinNumber, this.CodecInfo.SipPhoneNumber); + trilist.SetString(joinMap.E164Alias.JoinNumber, this.CodecInfo.E164Alias); + trilist.SetString(joinMap.H323Id.JoinNumber, this.CodecInfo.H323Id); + trilist.SetString(joinMap.SipUri.JoinNumber, this.CodecInfo.SipUri); + } + }; + } + + private void LinkVideoCodecPhoneToApi(IHasPhoneDialing codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) + { + codec.PhoneOffHookFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PhoneHookState.JoinNumber]); + + trilist.SetSigFalseAction(joinMap.DialPhone.JoinNumber, + () => codec.DialPhoneCall(trilist.StringOutput[joinMap.PhoneDialString.JoinNumber].StringValue)); + + trilist.SetSigFalseAction(joinMap.HangUpPhone.JoinNumber, codec.EndPhoneCall); + } + + private void LinkVideoCodecSelfviewPositionToApi(IHasSelfviewPosition codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) + { + trilist.SetSigFalseAction(joinMap.SelfviewPosition.JoinNumber, codec.SelfviewPipPositionToggle); + + codec.SelfviewPipPositionFeedback.LinkInputSig(trilist.StringInput[joinMap.SelfviewPositionFb.JoinNumber]); + } + + private void LinkVideoCodecCameraOffToApi(IHasCameraOff codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) + { + trilist.SetSigFalseAction(joinMap.CameraModeOff.JoinNumber, codec.CameraOff); + + codec.CameraIsOffFeedback.OutputChange += (o, a) => + { + if (a.BoolValue) + { + trilist.SetBool(joinMap.CameraModeOff.JoinNumber, true); + trilist.SetBool(joinMap.CameraModeManual.JoinNumber, false); + trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, false); + return; + } + + trilist.SetBool(joinMap.CameraModeOff.JoinNumber, false); + + var autoCodec = codec as IHasCameraAutoMode; + + if (autoCodec == null) return; + + trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, autoCodec.CameraAutoModeIsOnFeedback.BoolValue); + trilist.SetBool(joinMap.CameraModeManual.JoinNumber, !autoCodec.CameraAutoModeIsOnFeedback.BoolValue); + }; + + if (codec.CameraIsOffFeedback.BoolValue) + { + trilist.SetBool(joinMap.CameraModeOff.JoinNumber, true); + trilist.SetBool(joinMap.CameraModeManual.JoinNumber, false); + trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, false); + return; + } + + trilist.SetBool(joinMap.CameraModeOff.JoinNumber, false); + + var autoModeCodec = codec as IHasCameraAutoMode; + + if (autoModeCodec == null) return; + + trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, autoModeCodec.CameraAutoModeIsOnFeedback.BoolValue); + trilist.SetBool(joinMap.CameraModeManual.JoinNumber, !autoModeCodec.CameraAutoModeIsOnFeedback.BoolValue); + } + + private void LinkVideoCodecVolumeToApi(BasicTriList trilist, VideoCodecControllerJoinMap joinMap) + { + MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMuteOn.JoinNumber]); + MuteFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.VolumeMuteOff.JoinNumber]); + + trilist.SetSigFalseAction(joinMap.VolumeMuteOn.JoinNumber, MuteOn); + trilist.SetSigFalseAction(joinMap.VolumeMuteOff.JoinNumber, MuteOff); + trilist.SetSigFalseAction(joinMap.VolumeMuteToggle.JoinNumber, MuteToggle); + + VolumeLevelFeedback.LinkInputSig(trilist.UShortInput[joinMap.VolumeLevel.JoinNumber]); + + trilist.SetBoolSigAction(joinMap.VolumeUp.JoinNumber, VolumeUp); + trilist.SetBoolSigAction(joinMap.VolumeDown.JoinNumber, VolumeDown); + + trilist.SetUShortSigAction(joinMap.VolumeLevel.JoinNumber, SetVolume); + + } + + private void LinkVideoCodecPrivacyToApi(BasicTriList trilist, VideoCodecControllerJoinMap joinMap) + { + PrivacyModeIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.MicMuteOn.JoinNumber]); + PrivacyModeIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.MicMuteOff.JoinNumber]); + + trilist.SetSigFalseAction(joinMap.MicMuteOn.JoinNumber, PrivacyModeOn); + trilist.SetSigFalseAction(joinMap.MicMuteOff.JoinNumber, PrivacyModeOff); + trilist.SetSigFalseAction(joinMap.MicMuteToggle.JoinNumber, PrivacyModeToggle); + } + + private void LinkVideoCodecCommMonitorToApi(ICommunicationMonitor codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) + { + codec.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + } + + private void LinkVideoCodecParticipantsToApi(IHasParticipants codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) + { + // make sure to update the values when the EISC comes online + trilist.OnlineStatusChange += (sender, args) => + { + if (sender.IsOnline) + { + UpdateParticipantsXSig(codec, trilist, joinMap); + } + }; + + // set actions and update the values when the list changes + codec.Participants.ParticipantsListHasChanged += (sender, args) => + { + SetParticipantActions(trilist, joinMap, codec.Participants.CurrentParticipants); + + UpdateParticipantsXSig(codec, trilist, joinMap); + }; + + trilist.OnlineStatusChange += (device, args) => + { + if (!args.DeviceOnLine) return; + + // TODO [ ] Issue #868 + trilist.SetString(joinMap.CurrentParticipants.JoinNumber, "\xFC"); + UpdateParticipantsXSig(codec, trilist, joinMap); + }; + } + + private void UpdateParticipantsXSig(IHasParticipants codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) + { + string participantsXSig; + + if (codec.Participants.CurrentParticipants.Count == 0) + { + participantsXSig = Encoding.GetEncoding(XSigEncoding).GetString(_clearBytes, 0, _clearBytes.Length); + trilist.SetString(joinMap.CurrentParticipants.JoinNumber, participantsXSig); + trilist.SetUshort(joinMap.ParticipantCount.JoinNumber, (ushort)codec.Participants.CurrentParticipants.Count); + return; + } + + participantsXSig = UpdateParticipantsXSig(codec.Participants.CurrentParticipants); + + trilist.SetString(joinMap.CurrentParticipants.JoinNumber, participantsXSig); + + trilist.SetUshort(joinMap.ParticipantCount.JoinNumber, (ushort)codec.Participants.CurrentParticipants.Count); + } + + /// + /// Sets the actions for each participant in the list + /// + private void SetParticipantActions(BasicTriList trilist, VideoCodecControllerJoinMap joinMap, List currentParticipants) + { + uint index = 0; // track the index of the participant in the + + foreach (var participant in currentParticipants) + { + var p = participant; + if (index > MaxParticipants) break; + + var audioMuteCodec = this as IHasParticipantAudioMute; + if (audioMuteCodec != null) + { + trilist.SetSigFalseAction(joinMap.ParticipantAudioMuteToggleStart.JoinNumber + index, + () => audioMuteCodec.ToggleAudioForParticipant(p.UserId)); + + trilist.SetSigFalseAction(joinMap.ParticipantVideoMuteToggleStart.JoinNumber + index, + () => audioMuteCodec.ToggleVideoForParticipant(p.UserId)); + } + + var pinCodec = this as IHasParticipantPinUnpin; + if (pinCodec != null) + { + trilist.SetSigFalseAction(joinMap.ParticipantPinToggleStart.JoinNumber + index, + () => pinCodec.ToggleParticipantPinState(p.UserId, pinCodec.ScreenIndexToPinUserTo)); + } + + index++; + } + + // Clear out any previously set actions + while (index < MaxParticipants) + { + trilist.ClearBoolSigAction(joinMap.ParticipantAudioMuteToggleStart.JoinNumber + index); + trilist.ClearBoolSigAction(joinMap.ParticipantVideoMuteToggleStart.JoinNumber + index); + trilist.ClearBoolSigAction(joinMap.ParticipantPinToggleStart.JoinNumber + index); + + index++; + } + } + + private string UpdateParticipantsXSig(List currentParticipants) + { + const int maxParticipants = MaxParticipants; + const int maxDigitals = 7; + const int maxStrings = 1; + const int maxAnalogs = 1; + const int offset = maxDigitals + maxStrings + maxAnalogs; // 9 + var digitalIndex = (maxStrings + maxAnalogs) * maxParticipants; // 100 + var stringIndex = 0; + var analogIndex = stringIndex + maxParticipants; + var meetingIndex = 0; + + var tokenArray = new XSigToken[maxParticipants * offset]; + + foreach (var participant in currentParticipants) + { + if (meetingIndex >= maxParticipants * offset) break; + + // Debug.Console(2, this, + //@"Updating Participant on xsig: + //Name: {0} (s{9}) + //AudioMute: {1} (d{10}) + //VideoMute: {2} (d{11}) + //CanMuteVideo: {3} (d{12}) + //CanUMuteVideo: {4} (d{13}) + //IsHost: {5} (d{14}) + //HandIsRaised: {6} (d{15}) + //IsPinned: {7} (d{16}) + //ScreenIndexIsPinnedTo: {8} (a{17}) + //", + // participant.Name, + // participant.AudioMuteFb, + // participant.VideoMuteFb, + // participant.CanMuteVideo, + // participant.CanUnmuteVideo, + // participant.IsHost, + // participant.HandIsRaisedFb, + // participant.IsPinnedFb, + // participant.ScreenIndexIsPinnedToFb, + // stringIndex + 1, + // digitalIndex + 1, + // digitalIndex + 2, + // digitalIndex + 3, + // digitalIndex + 4, + // digitalIndex + 5, + // digitalIndex + 6, + // digitalIndex + 7, + // analogIndex + 1 + // ); + + + //digitals + tokenArray[digitalIndex] = new XSigDigitalToken(digitalIndex + 1, participant.AudioMuteFb); + tokenArray[digitalIndex + 1] = new XSigDigitalToken(digitalIndex + 2, participant.VideoMuteFb); + tokenArray[digitalIndex + 2] = new XSigDigitalToken(digitalIndex + 3, participant.CanMuteVideo); + tokenArray[digitalIndex + 3] = new XSigDigitalToken(digitalIndex + 4, participant.CanUnmuteVideo); + tokenArray[digitalIndex + 4] = new XSigDigitalToken(digitalIndex + 5, participant.IsHost); + tokenArray[digitalIndex + 5] = new XSigDigitalToken(digitalIndex + 6, participant.HandIsRaisedFb); + tokenArray[digitalIndex + 6] = new XSigDigitalToken(digitalIndex + 7, participant.IsPinnedFb); + + Debug.Console(2, this, "Index: {0} byte value: {1}", digitalIndex + 7, ComTextHelper.GetEscapedText(tokenArray[digitalIndex + 6].GetBytes())); + + //serials + tokenArray[stringIndex] = new XSigSerialToken(stringIndex + 1, participant.Name); + + //analogs + tokenArray[analogIndex] = new XSigAnalogToken(analogIndex + 1, (ushort)participant.ScreenIndexIsPinnedToFb); + + digitalIndex += maxDigitals; + meetingIndex += offset; + stringIndex += maxStrings; + analogIndex += maxAnalogs; + } + + while (meetingIndex < maxParticipants * offset) + { + //digitals + tokenArray[digitalIndex] = new XSigDigitalToken(digitalIndex + 1, false); + tokenArray[digitalIndex + 1] = new XSigDigitalToken(digitalIndex + 2, false); + tokenArray[digitalIndex + 2] = new XSigDigitalToken(digitalIndex + 3, false); + tokenArray[digitalIndex + 3] = new XSigDigitalToken(digitalIndex + 4, false); + tokenArray[digitalIndex + 4] = new XSigDigitalToken(digitalIndex + 5, false); + tokenArray[digitalIndex + 5] = new XSigDigitalToken(digitalIndex + 6, false); + tokenArray[digitalIndex + 6] = new XSigDigitalToken(digitalIndex + 7, false); + + //serials + tokenArray[stringIndex] = new XSigSerialToken(stringIndex + 1, String.Empty); + + //analogs + tokenArray[analogIndex] = new XSigAnalogToken(analogIndex + 1, 0); + + digitalIndex += maxDigitals; + meetingIndex += offset; + stringIndex += maxStrings; + analogIndex += maxAnalogs; + } + + var returnString = GetXSigString(tokenArray); + + //Debug.Console(2, this, "{0}", ComTextHelper.GetEscapedText(Encoding.GetEncoding(28591).GetBytes(returnString))); + + + return returnString; + } + + private void LinkVideoCodecContentSharingToApi(BasicTriList trilist, VideoCodecControllerJoinMap joinMap) + { + SharingContentIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.SourceShareStart.JoinNumber]); + SharingContentIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.SourceShareEnd.JoinNumber]); + + SharingSourceFeedback.LinkInputSig(trilist.StringInput[joinMap.CurrentSource.JoinNumber]); + + trilist.SetSigFalseAction(joinMap.SourceShareStart.JoinNumber, StartSharing); + trilist.SetSigFalseAction(joinMap.SourceShareEnd.JoinNumber, StopSharing); + + trilist.SetBoolSigAction(joinMap.SourceShareAutoStart.JoinNumber, b => AutoShareContentWhileInCall = b); + } + + private List _currentMeetings = new List(); + + private void LinkVideoCodecScheduleToApi(IHasScheduleAwareness codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) + { + trilist.SetSigFalseAction(joinMap.UpdateMeetings.JoinNumber, codec.GetSchedule); + + trilist.SetUShortSigAction(joinMap.MinutesBeforeMeetingStart.JoinNumber, (i) => + { + codec.CodecSchedule.MeetingWarningMinutes = i; + }); + + + for (uint i = 0; i < joinMap.DialMeetingStart.JoinSpan; i++) + { + Debug.Console(1, this, "Setting action to Dial Meeting {0} to digital join {1}", i + 1, joinMap.DialMeetingStart.JoinNumber + i); + var joinNumber = joinMap.DialMeetingStart.JoinNumber + i; + var mtg = i + 1; + var index = (int)i; + + trilist.SetSigFalseAction(joinNumber, () => + { + Debug.Console(1, this, "Meeting {0} Selected (EISC dig-o{1}) > _currentMeetings[{2}].Id: {3}, Title: {4}", + mtg, joinMap.DialMeetingStart.JoinNumber + i, index, _currentMeetings[index].Id, _currentMeetings[index].Title); + if (_currentMeetings[index] != null) + Dial(_currentMeetings[index]); + }); + } + + codec.CodecSchedule.MeetingsListHasChanged += (sender, args) => UpdateMeetingsList(codec, trilist, joinMap); + codec.CodecSchedule.MeetingEventChange += (sender, args) => + { + if (args.ChangeType == eMeetingEventChangeType.MeetingStartWarning) + { + UpdateMeetingsList(codec, trilist, joinMap); + } + }; + + trilist.SetUShortSigAction(joinMap.MeetingsToDisplay.JoinNumber, m => MeetingsToDisplay = m); + MeetingsToDisplayFeedback.LinkInputSig(trilist.UShortInput[joinMap.MeetingsToDisplay.JoinNumber]); + + trilist.OnlineStatusChange += (device, args) => + { + if (!args.DeviceOnLine) return; + + // TODO [ ] Issue #868 + trilist.SetString(joinMap.Schedule.JoinNumber, "\xFC"); + UpdateMeetingsList(codec, trilist, joinMap); + // TODO [ ] hotfix/videocodecbase-max-meeting-xsig-set + MeetingsToDisplayFeedback.LinkInputSig(trilist.UShortInput[joinMap.MeetingsToDisplay.JoinNumber]); + }; + } + + private void UpdateMeetingsList(IHasScheduleAwareness codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) + { + var currentTime = DateTime.Now; + + _currentMeetings = codec.CodecSchedule.Meetings.Where(m => m.StartTime >= currentTime || m.EndTime >= currentTime).ToList(); + + if (_currentMeetings.Count == 0) + { + var emptyXSigByteArray = XSigHelpers.ClearOutputs(); + var emptyXSigString = Encoding.GetEncoding(XSigEncoding) + .GetString(emptyXSigByteArray, 0, emptyXSigByteArray.Length); + + trilist.SetString(joinMap.Schedule.JoinNumber, emptyXSigString); + return; + } + + var meetingsData = UpdateMeetingsListXSig(_currentMeetings); + trilist.SetString(joinMap.Schedule.JoinNumber, meetingsData); + trilist.SetUshort(joinMap.MeetingCount.JoinNumber, (ushort)_currentMeetings.Count); + + trilist.OnlineStatusChange += (device, args) => + { + if (!args.DeviceOnLine) return; + + // TODO [ ] Issue #868 + trilist.SetString(joinMap.Schedule.JoinNumber, "\xFC"); + UpdateMeetingsListXSig(_currentMeetings); + }; + } + + + // TODO [ ] hotfix/videocodecbase-max-meeting-xsig-set + private int _meetingsToDisplay = 3; + // TODO [ ] hotfix/videocodecbase-max-meeting-xsig-set + protected int MeetingsToDisplay + { + get { return _meetingsToDisplay; } + set { + _meetingsToDisplay = (ushort) (value == 0 ? 3 : value); + MeetingsToDisplayFeedback.FireUpdate(); + } + } + + // TODO [ ] hotfix/videocodecbase-max-meeting-xsig-set + public IntFeedback MeetingsToDisplayFeedback { get; set; } + + private string UpdateMeetingsListXSig(List meetings) + { + // TODO [ ] hotfix/videocodecbase-max-meeting-xsig-set + //const int _meetingsToDisplay = 3; + const int maxDigitals = 2; + const int maxStrings = 7; + const int offset = maxDigitals + maxStrings; + var digitalIndex = maxStrings * _meetingsToDisplay; //15 + var stringIndex = 0; + var meetingIndex = 0; + + var tokenArray = new XSigToken[_meetingsToDisplay * offset]; + /* + * Digitals + * IsJoinable - 1 + * IsDialable - 2 + * + * Serials + * Organizer - 1 + * Title - 2 + * Start Date - 3 + * Start Time - 4 + * End Date - 5 + * End Time - 6 + * Id - 7 + */ + + + foreach (var meeting in meetings) + { + var currentTime = DateTime.Now; + + if (meeting.StartTime < currentTime && meeting.EndTime < currentTime) continue; + + if (meetingIndex >= _meetingsToDisplay * offset) + { + Debug.Console(2, this, "Max Meetings reached"); + break; + } + + //digitals + tokenArray[digitalIndex] = new XSigDigitalToken(digitalIndex + 1, meeting.Joinable); + tokenArray[digitalIndex + 1] = new XSigDigitalToken(digitalIndex + 2, meeting.Dialable); + + //serials + tokenArray[stringIndex] = new XSigSerialToken(stringIndex + 1, meeting.Organizer); + tokenArray[stringIndex + 1] = new XSigSerialToken(stringIndex + 2, meeting.Title); + tokenArray[stringIndex + 2] = new XSigSerialToken(stringIndex + 3, meeting.StartTime.ToString(_dateFormatSpecifier.NullIfEmpty() ?? "d", Global.Culture)); + tokenArray[stringIndex + 3] = new XSigSerialToken(stringIndex + 4, meeting.StartTime.ToString(_timeFormatSpecifier.NullIfEmpty() ?? "t", Global.Culture)); + tokenArray[stringIndex + 4] = new XSigSerialToken(stringIndex + 5, meeting.EndTime.ToString(_dateFormatSpecifier.NullIfEmpty() ?? "d", Global.Culture)); + tokenArray[stringIndex + 5] = new XSigSerialToken(stringIndex + 6, meeting.EndTime.ToString(_timeFormatSpecifier.NullIfEmpty() ?? "t", Global.Culture)); + tokenArray[stringIndex + 6] = new XSigSerialToken(stringIndex + 7, meeting.Id); + + digitalIndex += maxDigitals; + meetingIndex += offset; + stringIndex += maxStrings; + } + + while (meetingIndex < _meetingsToDisplay * offset) + { + Debug.Console(2, this, "Clearing unused data. Meeting Index: {0} MaxMeetings * Offset: {1}", + meetingIndex, _meetingsToDisplay * offset); + + //digitals + tokenArray[digitalIndex] = new XSigDigitalToken(digitalIndex + 1, false); + tokenArray[digitalIndex + 1] = new XSigDigitalToken(digitalIndex + 2, false); + + //serials + tokenArray[stringIndex] = new XSigSerialToken(stringIndex + 1, String.Empty); + tokenArray[stringIndex + 1] = new XSigSerialToken(stringIndex + 2, String.Empty); + tokenArray[stringIndex + 2] = new XSigSerialToken(stringIndex + 3, String.Empty); + tokenArray[stringIndex + 3] = new XSigSerialToken(stringIndex + 4, String.Empty); + tokenArray[stringIndex + 4] = new XSigSerialToken(stringIndex + 5, String.Empty); + tokenArray[stringIndex + 5] = new XSigSerialToken(stringIndex + 6, String.Empty); + tokenArray[stringIndex + 6] = new XSigSerialToken(stringIndex + 7, String.Empty); + + digitalIndex += maxDigitals; + meetingIndex += offset; + stringIndex += maxStrings; + } + + return GetXSigString(tokenArray); + } + + + private void LinkVideoCodecDirectoryToApi(IHasDirectory codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) + { + codec.CurrentDirectoryResultIsNotDirectoryRoot.LinkComplementInputSig( + trilist.BooleanInput[joinMap.DirectoryIsRoot.JoinNumber]); + + trilist.SetStringSigAction(joinMap.DirectorySearchString.JoinNumber, codec.SearchDirectory); + + trilist.SetUShortSigAction(joinMap.DirectorySelectRow.JoinNumber, (i) => SelectDirectoryEntry(codec, i, trilist, joinMap)); + + //Special Change for protected directory clear + + trilist.SetBoolSigAction(joinMap.DirectoryClearSelected.JoinNumber, (b) => SelectDirectoryEntry(codec, 0, trilist, joinMap)); + + // Report feedback for number of contact methods for selected contact + + trilist.SetSigFalseAction(joinMap.DirectoryRoot.JoinNumber, codec.SetCurrentDirectoryToRoot); + + trilist.SetSigFalseAction(joinMap.DirectoryFolderBack.JoinNumber, codec.GetDirectoryParentFolderContents); + + if (codec.DirectoryRoot != null) + { + var contactsCount = codec.DirectoryRoot.CurrentDirectoryResults.Where(c => c.ParentFolderId.Equals("root")).ToList().Count; + trilist.SetUshort(joinMap.DirectoryRowCount.JoinNumber, (ushort)contactsCount); + Debug.Console(2, this, ">>> contactsCount: {0}", contactsCount); + + var clearBytes = XSigHelpers.ClearOutputs(); + + trilist.SetString(joinMap.DirectoryEntries.JoinNumber, + Encoding.GetEncoding(XSigEncoding).GetString(clearBytes, 0, clearBytes.Length)); + var directoryXSig = UpdateDirectoryXSig(codec.DirectoryRoot, + codec.CurrentDirectoryResultIsNotDirectoryRoot.BoolValue == false); + + Debug.Console(2, this, "Directory XSig Length: {0}", directoryXSig.Length); + + trilist.SetString(joinMap.DirectoryEntries.JoinNumber, directoryXSig); + } + + codec.DirectoryResultReturned += (sender, args) => + { + var isRoot = codec.CurrentDirectoryResultIsNotDirectoryRoot.BoolValue == false; + var argsCount = isRoot + ? args.Directory.CurrentDirectoryResults.Where(a => a.ParentFolderId.Equals("root")).ToList().Count + : args.Directory.CurrentDirectoryResults.Count; + + trilist.SetUshort(joinMap.DirectoryRowCount.JoinNumber, (ushort)argsCount); + Debug.Console(2, this, ">>> argsCount: {0}", argsCount); + + var clearBytes = XSigHelpers.ClearOutputs(); + + trilist.SetString(joinMap.DirectoryEntries.JoinNumber, + Encoding.GetEncoding(XSigEncoding).GetString(clearBytes, 0, clearBytes.Length)); + var directoryXSig = UpdateDirectoryXSig(args.Directory, + codec.CurrentDirectoryResultIsNotDirectoryRoot.BoolValue == false); + Debug.Console(2, this, "Directory XSig Length: {0}", directoryXSig.Length); + + trilist.SetString(joinMap.DirectoryEntries.JoinNumber, directoryXSig); + }; + + trilist.OnlineStatusChange += (device, args) => + { + if (!args.DeviceOnLine) return; + + var clearBytes = XSigHelpers.ClearOutputs(); + trilist.SetString(joinMap.DirectoryEntries.JoinNumber, + Encoding.GetEncoding(XSigEncoding).GetString(clearBytes, 0, clearBytes.Length)); + var directoryXSig = UpdateDirectoryXSig(codec.DirectoryRoot, codec.CurrentDirectoryResultIsNotDirectoryRoot.BoolValue == false); + trilist.SetString(joinMap.DirectoryEntries.JoinNumber, directoryXSig); + }; + } + + private void SelectDirectoryEntry(IHasDirectory codec, ushort i, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) + { + if (i > codec.CurrentDirectoryResult.CurrentDirectoryResults.Count) return; + _selectedDirectoryItem = i == 0 ? null : codec.CurrentDirectoryResult.CurrentDirectoryResults[i - 1]; + trilist.SetUshort(joinMap.DirectorySelectRowFeedback.JoinNumber, i); + + if (_selectedDirectoryItem == null) trilist.SetBool(joinMap.DirectoryEntryIsContact.JoinNumber, false); + + + if (_selectedDirectoryItem is DirectoryFolder) + { + codec.GetDirectoryFolderContents(_selectedDirectoryItem.FolderId); + trilist.SetUshort(joinMap.SelectedContactMethodCount.JoinNumber, 0); + trilist.SetString(joinMap.DirectorySelectedFolderName.JoinNumber, _selectedDirectoryItem.Name); + trilist.SetString(joinMap.DirectoryEntrySelectedName.JoinNumber, string.Empty); + trilist.ClearUShortSigAction(joinMap.SelectContactMethod.JoinNumber); + trilist.ClearBoolSigAction(joinMap.DirectoryDialSelectedLine.JoinNumber); + trilist.ClearBoolSigAction(joinMap.DirectoryDialSelectedContactMethod.JoinNumber); + trilist.SetBool(joinMap.DirectoryEntryIsContact.JoinNumber, false); + return; + } + + // not a folder. Clear this value + trilist.SetString(joinMap.DirectorySelectedFolderName.JoinNumber, string.Empty); + + var selectedContact = _selectedDirectoryItem as DirectoryContact; + + if (selectedContact != null && selectedContact.ContactMethods.Count >= 1) + { + trilist.SetBool(joinMap.DirectoryEntryIsContact.JoinNumber, true); + } + + trilist.SetString(joinMap.DirectoryEntrySelectedName.JoinNumber, + selectedContact != null ? selectedContact.Name : string.Empty); + + // Allow auto dial of selected line. Always dials first contact method + if (!trilist.GetBool(joinMap.DirectoryDisableAutoDialSelectedLine.JoinNumber)) + { + var invitableEntry = _selectedDirectoryItem as IInvitableContact; + + if (invitableEntry != null) + { + Dial(invitableEntry); + return; + } + + var entryToDial = _selectedDirectoryItem as DirectoryContact; + + trilist.SetString(joinMap.DirectoryEntrySelectedNumber.JoinNumber, + selectedContact != null ? selectedContact.ContactMethods[0].Number : string.Empty); + + if (entryToDial == null) return; + + Dial(entryToDial.ContactMethods[0].Number); + } + else + { + // If auto dial is disabled... + var entryToDial = _selectedDirectoryItem as DirectoryContact; + + if (entryToDial == null) + { + // Clear out values and actions from last selected item + trilist.SetUshort(joinMap.SelectedContactMethodCount.JoinNumber, 0); + trilist.SetString(joinMap.DirectoryEntrySelectedName.JoinNumber, string.Empty); + trilist.ClearUShortSigAction(joinMap.SelectContactMethod.JoinNumber); + trilist.ClearBoolSigAction(joinMap.DirectoryDialSelectedLine.JoinNumber); + trilist.ClearBoolSigAction(joinMap.DirectoryDialSelectedContactMethod.JoinNumber); + return; + } + + trilist.SetUshort(joinMap.SelectedContactMethodCount.JoinNumber, (ushort)entryToDial.ContactMethods.Count); + + // Update the action to dial the selected contact method + trilist.SetUShortSigAction(joinMap.SelectContactMethod.JoinNumber, (u) => + { + if (u < 1 || u > entryToDial.ContactMethods.Count) return; + + trilist.SetSigFalseAction(joinMap.DirectoryDialSelectedContactMethod.JoinNumber, () => Dial(entryToDial.ContactMethods[u - 1].Number)); + }); + + // Sets DirectoryDialSelectedLine join action to dial first contact method + trilist.SetSigFalseAction(joinMap.DirectoryDialSelectedLine.JoinNumber, () => Dial(entryToDial.ContactMethods[0].Number)); + + var clearBytes = XSigHelpers.ClearOutputs(); + + trilist.SetString(joinMap.ContactMethods.JoinNumber, + Encoding.GetEncoding(XSigEncoding).GetString(clearBytes, 0, clearBytes.Length)); + var contactMethodsXSig = UpdateContactMethodsXSig(entryToDial); + + trilist.SetString(joinMap.ContactMethods.JoinNumber, contactMethodsXSig); + } + } + + /// + /// Generates the XSig data representing the available contact methods for the selected DirectoryContact + /// + /// + /// + private string UpdateContactMethodsXSig(DirectoryContact contact) + { + const int maxMethods = 10; + const int maxStrings = 3; + const int offset = maxStrings; + var stringIndex = 0; + var arrayIndex = 0; + // Create a new token array and set the size to the number of methods times the total number of signals + var tokenArray = new XSigToken[maxMethods * offset]; + + Debug.Console(2, this, "Creating XSIG token array with size {0}", maxMethods * offset); + + // TODO: Add code to generate XSig data + foreach (var method in contact.ContactMethods) + { + if (arrayIndex >= maxMethods * offset) + break; + + //serials + tokenArray[arrayIndex + 1] = new XSigSerialToken(stringIndex + 1, method.Number); + tokenArray[arrayIndex + 2] = new XSigSerialToken(stringIndex + 2, method.ContactMethodId.ToString()); + tokenArray[arrayIndex + 3] = new XSigSerialToken(stringIndex + 3, method.Device.ToString()); + + arrayIndex += offset; + stringIndex += maxStrings; + } + + while (arrayIndex < maxMethods) + { + tokenArray[arrayIndex + 1] = new XSigSerialToken(stringIndex + 1, String.Empty); + tokenArray[arrayIndex + 2] = new XSigSerialToken(stringIndex + 2, String.Empty); + tokenArray[arrayIndex + 3] = new XSigSerialToken(stringIndex + 3, String.Empty); + + arrayIndex += offset; + stringIndex += maxStrings; + } + + return GetXSigString(tokenArray); + } + + private string UpdateDirectoryXSig(CodecDirectory directory, bool isRoot) + { + var xSigMaxIndex = 1023; + var tokenArray = new XSigToken[directory.CurrentDirectoryResults.Count > xSigMaxIndex + ? xSigMaxIndex + : directory.CurrentDirectoryResults.Count]; + + Debug.Console(2, this, "IsRoot: {0}, Directory Count: {1}, TokenArray.Length: {2}", isRoot, directory.CurrentDirectoryResults.Count, tokenArray.Length); + + var contacts = directory.CurrentDirectoryResults.Count > xSigMaxIndex + ? directory.CurrentDirectoryResults.Take(xSigMaxIndex) + : directory.CurrentDirectoryResults; + + var contactsToDisplay = isRoot + ? contacts.Where(c => c.ParentFolderId == "root") + : contacts.Where(c => c.ParentFolderId != "root"); + + var counterIndex = 1; + foreach (var entry in contactsToDisplay) + { + var arrayIndex = counterIndex - 1; + var entryIndex = counterIndex; + + Debug.Console(2, this, "Entry{2:0000} Name: {0}, Folder ID: {1}, Type: {3}, ParentFolderId: {4}", + entry.Name, entry.FolderId, entryIndex, entry.GetType().GetCType().FullName, entry.ParentFolderId); + + if (entry is DirectoryFolder) + { + tokenArray[arrayIndex] = new XSigSerialToken(entryIndex, String.Format("[+] {0}", entry.Name)); + + counterIndex++; + + continue; + } + + tokenArray[arrayIndex] = new XSigSerialToken(entryIndex, entry.Name); + + counterIndex++; + } + + return GetXSigString(tokenArray); + } + + private void LinkVideoCodecCallControlsToApi(BasicTriList trilist, VideoCodecControllerJoinMap joinMap) + { + trilist.SetSigFalseAction(joinMap.ManualDial.JoinNumber, + () => Dial(trilist.StringOutput[joinMap.CurrentDialString.JoinNumber].StringValue)); + + //End All calls + trilist.SetSigFalseAction(joinMap.EndAllCalls.JoinNumber, EndAllCalls); + + //End a specific call, specified by index. Maximum 8 calls supported + for (int i = 0; i < joinMap.EndCallStart.JoinSpan; i++) + { + var callIndex = i; + + trilist.SetSigFalseAction((uint)(joinMap.EndCallStart.JoinNumber + i), () => + { + + if (callIndex < 0 || callIndex >= ActiveCalls.Count) + { + Debug.Console(2, this, "Cannot end call. No call found at index: {0}", callIndex); + return; + } + + var call = ActiveCalls[callIndex]; + if (call != null) + { + EndCall(call); + } + else + { + Debug.Console(0, this, "[End Call] Unable to find call at index '{0}'", i); + } + }); + } + + trilist.SetBool(joinMap.HookState.JoinNumber, IsInCall); + + CallStatusChange += (sender, args) => + { + trilist.SetBool(joinMap.HookState.JoinNumber, IsInCall); + + Debug.Console(1, this, "Call Direction: {0}", args.CallItem.Direction); + Debug.Console(1, this, "Call is incoming: {0}", args.CallItem.Direction == eCodecCallDirection.Incoming); + trilist.SetBool(joinMap.IncomingCall.JoinNumber, args.CallItem.Direction == eCodecCallDirection.Incoming && args.CallItem.Status == eCodecCallStatus.Ringing); + + if (args.CallItem.Direction == eCodecCallDirection.Incoming) + { + trilist.SetSigFalseAction(joinMap.IncomingAnswer.JoinNumber, () => AcceptCall(args.CallItem)); + trilist.SetSigFalseAction(joinMap.IncomingReject.JoinNumber, () => RejectCall(args.CallItem)); + trilist.SetString(joinMap.IncomingCallName.JoinNumber, args.CallItem.Name); + trilist.SetString(joinMap.IncomingCallNumber.JoinNumber, args.CallItem.Number); + } + else + { + trilist.SetString(joinMap.IncomingCallName.JoinNumber, string.Empty); + trilist.SetString(joinMap.IncomingCallNumber.JoinNumber, string.Empty); + } + + + trilist.SetString(joinMap.CurrentCallData.JoinNumber, UpdateCallStatusXSig()); + + trilist.SetUshort(joinMap.ConnectedCallCount.JoinNumber, (ushort)ActiveCalls.Count); + }; + + var joinCodec = this as IJoinCalls; + if (joinCodec != null) + { + trilist.SetSigFalseAction(joinMap.JoinAllCalls.JoinNumber, () => joinCodec.JoinAllCalls()); + + for (int i = 0; i < joinMap.JoinCallStart.JoinSpan; i++) + { + trilist.SetSigFalseAction((uint)(joinMap.JoinCallStart.JoinNumber + i), () => + { + var call = ActiveCalls[i]; + if (call != null) + { + joinCodec.JoinCall(call); + } + else + { + Debug.Console(0, this, "[Join Call] Unable to find call at index '{0}'", i); + } + }); + } + } + + var holdCodec = this as IHasCallHold; + if (holdCodec != null) + { + trilist.SetSigFalseAction(joinMap.HoldAllCalls.JoinNumber, () => + { + foreach (var call in ActiveCalls) + { + holdCodec.HoldCall(call); + } + }); + + for (int i = 0; i < joinMap.HoldCallsStart.JoinSpan; i++) + { + var index = i; + + trilist.SetSigFalseAction((uint)(joinMap.HoldCallsStart.JoinNumber + index), () => + { + if (index < 0 || index >= ActiveCalls.Count) return; + + var call = ActiveCalls[index]; + if (call != null) + { + holdCodec.HoldCall(call); + } + else + { + Debug.Console(0, this, "[Hold Call] Unable to find call at index '{0}'", i); + } + }); + + trilist.SetSigFalseAction((uint)(joinMap.ResumeCallsStart.JoinNumber + index), () => + { + if (index < 0 || index >= ActiveCalls.Count) return; + + var call = ActiveCalls[index]; + if (call != null) + { + holdCodec.ResumeCall(call); + } + else + { + Debug.Console(0, this, "[Resume Call] Unable to find call at index '{0}'", i); + } + }); + } + } + + + + trilist.OnlineStatusChange += (device, args) => + { + if (!args.DeviceOnLine) return; + + // TODO [ ] #983 + Debug.Console(0, this, "LinkVideoCodecCallControlsToApi: device is {0}, IsInCall {1}", args.DeviceOnLine ? "online" : "offline", IsInCall); + trilist.SetBool(joinMap.HookState.JoinNumber, IsInCall); + trilist.SetString(joinMap.CurrentCallData.JoinNumber, "\xFC"); + trilist.SetString(joinMap.CurrentCallData.JoinNumber, UpdateCallStatusXSig()); + }; + } + + private string UpdateCallStatusXSig() + { + const int maxCalls = 8; + const int maxStrings = 6; + const int maxDigitals = 2; + const int offset = maxStrings + maxDigitals; + var stringIndex = 0; + var digitalIndex = maxStrings * maxCalls; + var arrayIndex = 0; + + var tokenArray = new XSigToken[maxCalls * offset]; //set array size for number of calls * pieces of info + + foreach (var call in ActiveCalls) + { + if (arrayIndex >= maxCalls * offset) + break; + //digitals + tokenArray[digitalIndex] = new XSigDigitalToken(digitalIndex + 1, call.IsActiveCall); + tokenArray[digitalIndex + 1] = new XSigDigitalToken(digitalIndex + 2, call.IsOnHold); + + //serials + tokenArray[stringIndex] = new XSigSerialToken(stringIndex + 1, call.Name ?? String.Empty); + tokenArray[stringIndex + 1] = new XSigSerialToken(stringIndex + 2, call.Number ?? String.Empty); + tokenArray[stringIndex + 2] = new XSigSerialToken(stringIndex + 3, call.Direction.ToString()); + tokenArray[stringIndex + 3] = new XSigSerialToken(stringIndex + 4, call.Type.ToString()); + tokenArray[stringIndex + 4] = new XSigSerialToken(stringIndex + 5, call.Status.ToString()); + if(call.Duration != null) + { + // May need to verify correct string format here + var dur = string.Format("{0:c}", call.Duration); + tokenArray[arrayIndex + 6] = new XSigSerialToken(stringIndex + 6, dur); + } + + arrayIndex += offset; + stringIndex += maxStrings; + digitalIndex += maxDigitals; + } + while (arrayIndex < maxCalls * offset) + { + //digitals + tokenArray[digitalIndex] = new XSigDigitalToken(digitalIndex + 1, false); + tokenArray[digitalIndex + 1] = new XSigDigitalToken(digitalIndex + 2, false); + + + //serials + tokenArray[stringIndex] = new XSigSerialToken(stringIndex + 1, String.Empty); + tokenArray[stringIndex + 1] = new XSigSerialToken(stringIndex + 2, String.Empty); + tokenArray[stringIndex + 2] = new XSigSerialToken(stringIndex + 3, String.Empty); + tokenArray[stringIndex + 3] = new XSigSerialToken(stringIndex + 4, String.Empty); + tokenArray[stringIndex + 4] = new XSigSerialToken(stringIndex + 5, String.Empty); + tokenArray[stringIndex + 5] = new XSigSerialToken(stringIndex + 6, String.Empty); + + arrayIndex += offset; + stringIndex += maxStrings; + digitalIndex += maxDigitals; + } + + return GetXSigString(tokenArray); + } + + private void LinkVideoCodecDtmfToApi(BasicTriList trilist, VideoCodecControllerJoinMap joinMap) + { + trilist.SetSigFalseAction(joinMap.Dtmf0.JoinNumber, () => SendDtmfAction("0", trilist, joinMap)); + trilist.SetSigFalseAction(joinMap.Dtmf1.JoinNumber, () => SendDtmfAction("1", trilist, joinMap)); + trilist.SetSigFalseAction(joinMap.Dtmf2.JoinNumber, () => SendDtmfAction("2", trilist, joinMap)); + trilist.SetSigFalseAction(joinMap.Dtmf3.JoinNumber, () => SendDtmfAction("3", trilist, joinMap)); + trilist.SetSigFalseAction(joinMap.Dtmf4.JoinNumber, () => SendDtmfAction("4", trilist, joinMap)); + trilist.SetSigFalseAction(joinMap.Dtmf5.JoinNumber, () => SendDtmfAction("5", trilist, joinMap)); + trilist.SetSigFalseAction(joinMap.Dtmf6.JoinNumber, () => SendDtmfAction("6", trilist, joinMap)); + trilist.SetSigFalseAction(joinMap.Dtmf7.JoinNumber, () => SendDtmfAction("7", trilist, joinMap)); + trilist.SetSigFalseAction(joinMap.Dtmf8.JoinNumber, () => SendDtmfAction("8", trilist, joinMap)); + trilist.SetSigFalseAction(joinMap.Dtmf9.JoinNumber, () => SendDtmfAction("9", trilist, joinMap)); + trilist.SetSigFalseAction(joinMap.DtmfStar.JoinNumber, () => SendDtmfAction("*", trilist, joinMap)); + trilist.SetSigFalseAction(joinMap.DtmfPound.JoinNumber, () => SendDtmfAction("#", trilist, joinMap)); + } + + /// + /// Sends the specified string as a DTMF command. + /// Reads the value of the SendDtmfToSpecificCallInstance digital join and SelectCall analog join to determine + /// Whther to send to a specific call index or to the last connected call + /// + /// + /// + /// + private void SendDtmfAction(string s, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) + { + if (!trilist.GetBool(joinMap.SendDtmfToSpecificCallIndex.JoinNumber)) + { + SendDtmf(s); + } + else + { + var callIndex = trilist.GetUshort(joinMap.SelectCall.JoinNumber); + if (callIndex > 0 && callIndex <= 8) + { + var call = ActiveCalls[callIndex - 1]; + if (call != null && call.IsActiveCall) + { + SendDtmf(s, call); + } + else + { + Debug.Console(0, this, "Warning: No call found at index {0} or call is not active.", callIndex); + } + } + else + { + Debug.Console(0, this, "Warning: Invalid call index specified. Please use a value of 1-8."); + } + } + } + + private void LinkVideoCodecCameraLayoutsToApi(IHasCodecLayouts codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) + { + trilist.SetSigFalseAction(joinMap.CameraLayout.JoinNumber, codec.LocalLayoutToggle); + + codec.LocalLayoutFeedback.LinkInputSig(trilist.StringInput[joinMap.CurrentLayoutStringFb.JoinNumber]); + } + + private void LinkVideoCodecCameraModeToApi(IHasCameraAutoMode codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) + { + trilist.SetSigFalseAction(joinMap.CameraModeAuto.JoinNumber, codec.CameraAutoModeOn); + trilist.SetSigFalseAction(joinMap.CameraModeManual.JoinNumber, codec.CameraAutoModeOff); + + codec.CameraAutoModeIsOnFeedback.OutputChange += (o, a) => + { + var offCodec = codec as IHasCameraOff; + + if (offCodec != null) + { + if (offCodec.CameraIsOffFeedback.BoolValue) + { + trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, false); + trilist.SetBool(joinMap.CameraModeManual.JoinNumber, false); + trilist.SetBool(joinMap.CameraModeOff.JoinNumber, true); + return; + } + + trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, a.BoolValue); + trilist.SetBool(joinMap.CameraModeManual.JoinNumber, !a.BoolValue); + trilist.SetBool(joinMap.CameraModeOff.JoinNumber, false); + return; + } + + trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, a.BoolValue); + trilist.SetBool(joinMap.CameraModeManual.JoinNumber, !a.BoolValue); + trilist.SetBool(joinMap.CameraModeOff.JoinNumber, false); + }; + + var offModeCodec = codec as IHasCameraOff; + + if (offModeCodec != null) + { + if (offModeCodec.CameraIsOffFeedback.BoolValue) + { + trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, false); + trilist.SetBool(joinMap.CameraModeManual.JoinNumber, false); + trilist.SetBool(joinMap.CameraModeOff.JoinNumber, true); + return; + } + + trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, codec.CameraAutoModeIsOnFeedback.BoolValue); + trilist.SetBool(joinMap.CameraModeManual.JoinNumber, !codec.CameraAutoModeIsOnFeedback.BoolValue); + trilist.SetBool(joinMap.CameraModeOff.JoinNumber, false); + return; + } + + trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, codec.CameraAutoModeIsOnFeedback.BoolValue); + trilist.SetBool(joinMap.CameraModeManual.JoinNumber, !codec.CameraAutoModeIsOnFeedback.BoolValue); + trilist.SetBool(joinMap.CameraModeOff.JoinNumber, false); + } + + private void LinkVideoCodecSelfviewToApi(IHasCodecSelfView codec, BasicTriList trilist, + VideoCodecControllerJoinMap joinMap) + { + trilist.SetSigFalseAction(joinMap.CameraSelfView.JoinNumber, codec.SelfViewModeToggle); + + codec.SelfviewIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.CameraSelfView.JoinNumber]); + } + + private void LinkVideoCodecCameraToApi(IHasCodecCameras codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) + { + //Camera PTZ + trilist.SetBoolSigAction(joinMap.CameraTiltUp.JoinNumber, (b) => + { + if (codec.SelectedCamera == null) return; + var camera = codec.SelectedCamera as IHasCameraPtzControl; + + if (camera == null) return; + + if (b) camera.TiltUp(); + else camera.TiltStop(); + }); + + trilist.SetBoolSigAction(joinMap.CameraTiltDown.JoinNumber, (b) => + { + if (codec.SelectedCamera == null) return; + var camera = codec.SelectedCamera as IHasCameraPtzControl; + + if (camera == null) return; + + if (b) camera.TiltDown(); + else camera.TiltStop(); + }); + trilist.SetBoolSigAction(joinMap.CameraPanLeft.JoinNumber, (b) => + { + if (codec.SelectedCamera == null) return; + var camera = codec.SelectedCamera as IHasCameraPtzControl; + + if (camera == null) return; + + if (b) camera.PanLeft(); + else camera.PanStop(); + }); + trilist.SetBoolSigAction(joinMap.CameraPanRight.JoinNumber, (b) => + { + if (codec.SelectedCamera == null) return; + var camera = codec.SelectedCamera as IHasCameraPtzControl; + + if (camera == null) return; + + if (b) camera.PanRight(); + else camera.PanStop(); + }); + + trilist.SetBoolSigAction(joinMap.CameraZoomIn.JoinNumber, (b) => + { + if (codec.SelectedCamera == null) return; + var camera = codec.SelectedCamera as IHasCameraPtzControl; + + if (camera == null) return; + + if (b) camera.ZoomIn(); + else camera.ZoomStop(); + }); + + trilist.SetBoolSigAction(joinMap.CameraZoomOut.JoinNumber, (b) => + { + if (codec.SelectedCamera == null) return; + var camera = codec.SelectedCamera as IHasCameraPtzControl; + + if (camera == null) return; + + if (b) camera.ZoomOut(); + else camera.ZoomStop(); + }); + + + trilist.SetBoolSigAction(joinMap.CameraFocusNear.JoinNumber, (b) => + { + if (codec.SelectedCamera == null) return; + var camera = codec.SelectedCamera as IHasCameraFocusControl; + + if (camera == null) return; + + if (b) camera.FocusNear(); + else camera.FocusStop(); + }); + + trilist.SetBoolSigAction(joinMap.CameraFocusFar.JoinNumber, (b) => + { + if (codec.SelectedCamera == null) return; + var camera = codec.SelectedCamera as IHasCameraFocusControl; + + if (camera == null) return; + + if (b) camera.FocusFar(); + else camera.FocusStop(); + }); + + trilist.SetSigFalseAction(joinMap.CameraFocusAuto.JoinNumber, () => + { + if (codec.SelectedCamera == null) return; + var camera = codec.SelectedCamera as IHasCameraFocusControl; + + if (camera == null) return; + + camera.TriggerAutoFocus(); + }); + + // Camera count + trilist.SetUshort(joinMap.CameraCount.JoinNumber, (ushort)codec.Cameras.Count); + + // Camera names + for (uint i = 0; i < joinMap.CameraNamesFb.JoinSpan; i++) + { + //Check the count first + if (i < codec.Cameras.Count && codec.Cameras[(int)i] != null) + { + trilist.SetString(joinMap.CameraNamesFb.JoinNumber + i, codec.Cameras[(int)i].Name); + } + else + { + trilist.SetString(joinMap.CameraNamesFb.JoinNumber + i, ""); + } + } + + //Camera Select + trilist.SetUShortSigAction(joinMap.CameraNumberSelect.JoinNumber, (i) => + { + if (i > 0 && i <= codec.Cameras.Count) + { + codec.SelectCamera(codec.Cameras[i - 1].Key); + } + else + { + Debug.Console(0, this, "Unable to select. No camera found at index {0}", i); + } + }); + + // Set initial selected camera feedback + if (codec.SelectedCamera != null) + { + trilist.SetUshort(joinMap.CameraNumberSelect.JoinNumber, (ushort)codec.Cameras.FindIndex((c) => c.Key == codec.SelectedCamera.Key)); + } + + codec.CameraSelected += (sender, args) => + { + var i = (ushort)codec.Cameras.FindIndex((c) => c.Key == args.SelectedCamera.Key); + + trilist.SetUshort(joinMap.CameraNumberSelect.JoinNumber, (ushort)(i + 1)); + + if (codec is IHasCodecRoomPresets) + { + return; + } + + if (!(args.SelectedCamera is IHasCameraPresets)) + { + return; + } + + var cam = args.SelectedCamera as IHasCameraPresets; + SetCameraPresetNames(cam.Presets); + + (args.SelectedCamera as IHasCameraPresets).PresetsListHasChanged += (o, eventArgs) => SetCameraPresetNames(cam.Presets); + + trilist.SetUShortSigAction(joinMap.CameraPresetSelect.JoinNumber, + (a) => + { + cam.PresetSelect(a); + trilist.SetUshort(joinMap.CameraPresetSelect.JoinNumber, a); + }); + + trilist.SetSigFalseAction(joinMap.CameraPresetSave.JoinNumber, + () => + { + cam.PresetStore(trilist.UShortOutput[joinMap.CameraPresetSelect.JoinNumber].UShortValue, + String.Empty); + trilist.PulseBool(joinMap.CameraPresetSave.JoinNumber, 3000); + }); + }; + + if (!(codec is IHasCodecRoomPresets)) return; + + var presetCodec = codec as IHasCodecRoomPresets; + + presetCodec.CodecRoomPresetsListHasChanged += + (sender, args) => SetCameraPresetNames(presetCodec.NearEndPresets); + + //Camera Presets + trilist.SetUShortSigAction(joinMap.CameraPresetSelect.JoinNumber, (i) => + { + presetCodec.CodecRoomPresetSelect(i); + }); + + + // Far End Presets + trilist.SetUShortSigAction(joinMap.FarEndPresetSelect.JoinNumber, (i) => + { + presetCodec.SelectFarEndPreset(i); + }); + + + trilist.SetSigFalseAction(joinMap.CameraPresetSave.JoinNumber, + () => + { + presetCodec.CodecRoomPresetStore( + trilist.UShortOutput[joinMap.CameraPresetSelect.JoinNumber].UShortValue, String.Empty); + trilist.PulseBool(joinMap.CameraPresetSave.JoinNumber, 3000); + }); + + trilist.OnlineStatusChange += (device, args) => + { + if (!args.DeviceOnLine) return; + + // TODO [ ] Issue #868 + trilist.SetString(joinMap.CameraPresetNames.JoinNumber, "\xFC"); + SetCameraPresetNames(presetCodec.NearEndPresets); + }; + } + + // Following fields only used for Bridging + private int _selectedRecentCallItemIndex; + private CodecCallHistory.CallHistoryEntry _selectedRecentCallItem; + private DirectoryItem _selectedDirectoryItem; + + private void LinkVideoCodecCallHistoryToApi(IHasCallHistory codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) + { + codec.CallHistory.RecentCallsListHasChanged += (o, a) => + { + UpdateCallHistory(codec, trilist, joinMap); + }; + + // Selected item action and feedback + trilist.SetUShortSigAction(joinMap.SelectRecentCallItem.JoinNumber, (u) => + { + if (u == 0 || u > codec.CallHistory.RecentCalls.Count) + { + Debug.Console(2, this, "Recent Call History index out of range"); + return; + } + + _selectedRecentCallItemIndex = (int)(u - 1); + trilist.SetUshort(joinMap.SelectRecentCallItem.JoinNumber, u); + + var _selectedRecentCallItem = codec.CallHistory.RecentCalls[_selectedRecentCallItemIndex]; + + if (_selectedRecentCallItem != null) + { + trilist.SetString(joinMap.SelectedRecentCallName.JoinNumber, _selectedRecentCallItem.Name); + trilist.SetString(joinMap.SelectedRecentCallNumber.JoinNumber, _selectedRecentCallItem.Number); + trilist.SetSigFalseAction(joinMap.RemoveSelectedRecentCallItem.JoinNumber, () => codec.RemoveCallHistoryEntry(_selectedRecentCallItem)); + trilist.SetSigFalseAction(joinMap.DialSelectedRecentCallItem.JoinNumber, () => this.Dial(_selectedRecentCallItem.Number)); + } + else + { + trilist.SetString(joinMap.SelectedRecentCallName.JoinNumber, string.Empty); + trilist.SetString(joinMap.SelectedRecentCallNumber.JoinNumber, string.Empty); + trilist.ClearBoolSigAction(joinMap.RemoveSelectedRecentCallItem.JoinNumber); + trilist.ClearBoolSigAction(joinMap.DialSelectedRecentCallItem.JoinNumber); + } + }); + } + + + + private void UpdateCallHistory(IHasCallHistory codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) + { + // Clear out selected item + _selectedRecentCallItemIndex = 0; + _selectedRecentCallItem = null; + trilist.SetUshort(joinMap.SelectRecentCallItem.JoinNumber, 0); + trilist.SetString(joinMap.SelectedRecentCallName.JoinNumber, string.Empty); + trilist.SetString(joinMap.SelectedRecentCallNumber.JoinNumber, string.Empty); + trilist.ClearBoolSigAction(joinMap.RemoveSelectedRecentCallItem.JoinNumber); + // + + trilist.SetUshort(joinMap.RecentCallCount.JoinNumber, (ushort)codec.CallHistory.RecentCalls.Count); + + // Update the call history joins + var maxItems = joinMap.RecentCallNamesStart.JoinSpan; + + // Create history + uint index = 0; + for (uint i = 0; i < maxItems && i < codec.CallHistory.RecentCalls.Count; i++) + { + trilist.SetString(joinMap.RecentCallNamesStart.JoinNumber + i, codec.CallHistory.RecentCalls[(int)i].Name); + trilist.SetString(joinMap.RecentCallTimesStart.JoinNumber + i, codec.CallHistory.RecentCalls[(int)i].StartTime.ToShortTimeString()); + trilist.SetUshort(joinMap.RecentCallOccurrenceType.JoinNumber + i, (ushort)codec.CallHistory.RecentCalls[(int)i].OccurrenceType); + //i++; + index = i; + } + + //foreach(var item in codec.CallHistory.RecentCalls) + //{ + // trilist.SetString(joinMap.RecentCallNamesStart.JoinNumber + i, item.Name); + // trilist.SetString(joinMap.RecentCallTimesStart.JoinNumber + i, item.StartTime.ToShortTimeString()); + // trilist.SetUshort(joinMap.RecentCallOccurrenceType.JoinNumber + i, (ushort)item.OccurrenceType); + // i++; + //} + + // Clears existing items + for (uint j = index; j < maxItems; j++) + { + trilist.SetString(joinMap.RecentCallNamesStart.JoinNumber + j, string.Empty); + trilist.SetString(joinMap.RecentCallTimesStart.JoinNumber + j, string.Empty); + trilist.SetUshort(joinMap.RecentCallOccurrenceType.JoinNumber + j, 0); + } + } + + private string SetCameraPresetNames(IEnumerable presets) + { + return SetCameraPresetNames(presets.Select(p => p.Description).ToList()); + } + + private string SetCameraPresetNames(IEnumerable presets) + { + return SetCameraPresetNames(presets.Select(p => p.Description).ToList()); + } + + private string SetCameraPresetNames(ICollection presets) + { + var i = 1; //start index for xsig; + + var tokenArray = new XSigToken[presets.Count]; + + foreach (var preset in presets) + { + var cameraPreset = new XSigSerialToken(i, preset); + tokenArray[i - 1] = cameraPreset; + i++; + } + + return GetXSigString(tokenArray); + } + + private string GetXSigString(XSigToken[] tokenArray) + { + string returnString; + using (var s = new MemoryStream()) + { + using (var tw = new XSigTokenStreamWriter(s, true)) + { + tw.WriteXSigData(tokenArray); + } + + var xSig = s.ToArray(); + + returnString = Encoding.GetEncoding(XSigEncoding).GetString(xSig, 0, xSig.Length); + } + + return returnString; + } + + #endregion + } + + + /// + /// Used to track the status of syncronizing the phonebook values when connecting to a codec or refreshing the phonebook info + /// + public class CodecPhonebookSyncState : IKeyed + { + private bool _InitialSyncComplete; + + public CodecPhonebookSyncState(string key) + { + Key = key; + + CodecDisconnected(); + } + + public bool InitialSyncComplete + { + get { return _InitialSyncComplete; } + private set + { + if (value == true) + { + var handler = InitialSyncCompleted; + if (handler != null) + { + handler(this, new EventArgs()); + } + } + _InitialSyncComplete = value; + } + } + + public bool InitialPhonebookFoldersWasReceived { get; private set; } + + public bool NumberOfContactsWasReceived { get; private set; } + + public bool PhonebookRootEntriesWasRecieved { get; private set; } + + public bool PhonebookHasFolders { get; private set; } + + public int NumberOfContacts { get; private set; } + + #region IKeyed Members + + public string Key { get; private set; } + + #endregion + + public event EventHandler InitialSyncCompleted; + + public void InitialPhonebookFoldersReceived() + { + InitialPhonebookFoldersWasReceived = true; + + CheckSyncStatus(); + } + + public void PhonebookRootEntriesReceived() + { + PhonebookRootEntriesWasRecieved = true; + + CheckSyncStatus(); + } + + public void SetPhonebookHasFolders(bool value) + { + PhonebookHasFolders = value; + + Debug.Console(1, this, "Phonebook has folders: {0}", PhonebookHasFolders); + } + + public void SetNumberOfContacts(int contacts) + { + NumberOfContacts = contacts; + NumberOfContactsWasReceived = true; + + Debug.Console(1, this, "Phonebook contains {0} contacts.", NumberOfContacts); + + CheckSyncStatus(); + } + + public void CodecDisconnected() + { + InitialPhonebookFoldersWasReceived = false; + PhonebookHasFolders = false; + NumberOfContacts = 0; + NumberOfContactsWasReceived = false; + } + + private void CheckSyncStatus() + { + if (InitialPhonebookFoldersWasReceived && NumberOfContactsWasReceived && PhonebookRootEntriesWasRecieved) + { + InitialSyncComplete = true; + Debug.Console(1, this, "Initial Phonebook Sync Complete!"); + } + else + { + InitialSyncComplete = false; + } + } + } + /// + /// Represents a codec command that might need to have a friendly label applied for UI feedback purposes + /// + public class CodecCommandWithLabel + { + public string Command { get; private set; } + public string Label { get; private set; } + + public CodecCommandWithLabel(string command, string label) + { + Command = command; + Label = label; + } + } + + + } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/VideoCodecBase.cs.orig b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/VideoCodecBase.cs.orig similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/VideoCodecBase.cs.orig rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/VideoCodecBase.cs.orig diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/IZoomWirelessShareInstructions.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/IZoomWirelessShareInstructions.cs similarity index 96% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/IZoomWirelessShareInstructions.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/IZoomWirelessShareInstructions.cs index 58690d3b..465e2d2b 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/IZoomWirelessShareInstructions.cs +++ b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/IZoomWirelessShareInstructions.cs @@ -1,28 +1,28 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using PepperDash.Essentials.Core; - -using PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom; - -namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom -{ - public class ShareInfoEventArgs : EventArgs - { - public zStatus.Sharing SharingStatus { get; private set; } - - public ShareInfoEventArgs(zStatus.Sharing status) - { - SharingStatus = status; - } - } - - public interface IZoomWirelessShareInstructions - { - event EventHandler ShareInfoChanged; - - zStatus.Sharing SharingState { get; } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using PepperDash.Essentials.Core; + +using PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom +{ + public class ShareInfoEventArgs : EventArgs + { + public zStatus.Sharing SharingStatus { get; private set; } + + public ShareInfoEventArgs(zStatus.Sharing status) + { + SharingStatus = status; + } + } + + public interface IZoomWirelessShareInstructions + { + event EventHandler ShareInfoChanged; + + zStatus.Sharing SharingState { get; } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ResponseObjects.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ResponseObjects.cs similarity index 96% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ResponseObjects.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ResponseObjects.cs index 09069146..ed359bd3 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ResponseObjects.cs +++ b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ResponseObjects.cs @@ -1,1820 +1,1820 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.ComponentModel; -using System.Runtime.CompilerServices; -using Crestron.SimplSharp; - -using PepperDash.Core; -using PepperDash.Essentials.Devices.Common.Codec; - -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces; - -namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom -{ - public enum eZoomRoomResponseType - { - zEvent, - zStatus, - zConfiguration, - zCommand - } - - public abstract class NotifiableObject : INotifyPropertyChanged - { - #region INotifyPropertyChanged Members - - public event PropertyChangedEventHandler PropertyChanged; - - protected void NotifyPropertyChanged(string propertyName) - { - var handler = PropertyChanged; - if (handler != null) - { - handler(this, new PropertyChangedEventArgs(propertyName)); - } - else - { - Debug.Console(2, "PropertyChanged event is NULL"); - } - } - - #endregion - } - - /// - /// Used to track the current status of a ZoomRoom - /// - public class ZoomRoomStatus - { - public zStatus.Login Login { get; set; } - public zStatus.SystemUnit SystemUnit { get; set; } - public zStatus.Phonebook Phonebook { get; set; } - public zStatus.Call Call { get; set; } - public zStatus.Capabilities Capabilities { get; set; } - public zStatus.Sharing Sharing { get; set; } - public zStatus.NumberOfScreens NumberOfScreens { get; set; } - public zStatus.Layout Layout { get; set; } - public zStatus.Video Video { get; set; } - public zStatus.CameraShare CameraShare { get; set; } - public List AudioInputs { get; set; } - public List AudioOuputs { get; set; } - public List Cameras { get; set; } - public zEvent.PhoneCallStatus PhoneCall { get; set; } - public zEvent.NeedWaitForHost NeedWaitForHost { get; set; } - - public ZoomRoomStatus() - { - Login = new zStatus.Login(); - SystemUnit = new zStatus.SystemUnit(); - Phonebook = new zStatus.Phonebook(); - Call = new zStatus.Call(); - Capabilities = new zStatus.Capabilities(); - Sharing = new zStatus.Sharing(); - NumberOfScreens = new zStatus.NumberOfScreens(); - Layout = new zStatus.Layout(); - Video = new zStatus.Video(); - CameraShare = new zStatus.CameraShare(); - AudioInputs = new List(); - AudioOuputs = new List(); - Cameras = new List(); - PhoneCall = new zEvent.PhoneCallStatus(); - NeedWaitForHost = new zEvent.NeedWaitForHost(); - } - } - - /// - /// Used to track the current configuration of a ZoomRoom - /// - public class ZoomRoomConfiguration - { - public zConfiguration.Call Call { get; set; } - public zConfiguration.Audio Audio { get; set; } - public zConfiguration.Video Video { get; set; } - public zConfiguration.Client Client { get; set; } - public zConfiguration.Camera Camera { get; set; } - - public ZoomRoomConfiguration() - { - Call = new zConfiguration.Call(); - Audio = new zConfiguration.Audio(); - Video = new zConfiguration.Video(); - Client = new zConfiguration.Client(); - Camera = new zConfiguration.Camera(); - } - } - - /// - /// Represents a response from a ZoomRoom system - /// - public class Response - { - public Status Status { get; set; } - public bool Sync { get; set; } - [JsonProperty("topKey")] - public string TopKey { get; set; } - [JsonProperty("type")] - public string Type { get; set; } - - public Response() - { - Status = new Status(); - } - } - - public class Status - { - [JsonProperty("message")] - public string Message { get; set; } - [JsonProperty("state")] - public string State { get; set; } - } - - - /// - /// zStatus class stucture - /// - public class zStatus - { - public class Login - { - [JsonProperty("ZAAPI Release")] - public string ZAAPIRelease { get; set; } - [JsonProperty("Zoom Room Release")] - public string ZoomRoomRelease { get; set; } - } - - public class SystemUnit - { - [JsonProperty("email")] - public string Email { get; set; } - [JsonProperty("login_type")] - public string LoginType { get; set; } - [JsonProperty("meeting_number")] - public string MeetingNumber { get; set; } - [JsonProperty("platform")] - public string Platform { get; set; } - [JsonProperty("room_info")] - public RoomInfo RoomInfo { get; set; } - [JsonProperty("room_version")] - public string RoomVersion { get; set; } - - public SystemUnit() - { - RoomInfo = new RoomInfo(); - } - } - - public class RoomInfo - { - [JsonProperty("account_email")] - public string AccountEmail { get; set; } - [JsonProperty("display_version")] - public string DisplayVersion { get; set; } - [JsonProperty("is_auto_answer_enabled")] - public bool AutoAnswerIsEnabled { get; set; } - [JsonProperty("is_auto_answer_selected")] - public bool AutoAnswerIsSelected { get; set; } - [JsonProperty("room_name")] - public string RoomName { get; set; } - } - - public class CloudPbxInfo - { - [JsonProperty("company_number")] - public string CompanyNumber { get; set; } - [JsonProperty("extension")] - public string Extension { get; set; } - [JsonProperty("isValid")] - public bool IsValid { get; set; } - } - - public enum ePresence - { - PRESENCE_OFFLINE, - PRESENCE_ONLINE, - PRESENCE_AWAY, - PRESENCE_BUSY, - PRESENCE_DND - } - - public class Contact - { - [JsonProperty("avatarURL")] - public string AvatarURL { get; set; } - [JsonProperty("cloud_pbx_info")] - public CloudPbxInfo CloudPbxInfo { get; set; } - [JsonProperty("email")] - public string Email { get; set; } - [JsonProperty("firstName")] - public string FirstName { get; set; } - [JsonProperty("index")] - public int Index { get; set; } - [JsonProperty("isLegacy")] - public bool IsLegacy { get; set; } - [JsonProperty("isZoomRoom")] - public bool IsZoomRoom { get; set; } - [JsonProperty("jid")] - public string Jid { get; set; } - [JsonProperty("lastName")] - public string LastName { get; set; } - [JsonProperty("onDesktop")] - public bool OnDesktop { get; set; } - [JsonProperty("onMobile")] - public bool OnMobile { get; set; } - [JsonProperty("phoneNumber")] - public string PhoneNumber { get; set; } - [JsonProperty("presence")] - public ePresence Presence { get; set; } - [JsonProperty("presence_status")] - public int PresenceStatus { get; set; } - [JsonProperty("screenName")] - public string ScreenName { get; set; } - [JsonProperty("sip_phone_number")] - public string SipPhoneNumber { get; set; } - - - public Contact() - { - CloudPbxInfo = new CloudPbxInfo(); - } - } - - public class Phonebook - { - [JsonProperty("Contacts")] - public List Contacts { get; set; } - - public Phonebook() - { - Contacts = new List(); - } - - /// - /// Converts from zStatus.Contact types to generic directory items - /// - /// - public static CodecDirectory ConvertZoomContactsToGeneric(List zoomContacts) - { - var directory = new CodecDirectory(); - - var folders = new List(); - - var roomFolder = new DirectoryFolder(); - - var contactFolder = new DirectoryFolder(); - - var contacts = new List(); - - // Check if there are any zoom rooms - var zoomRooms = zoomContacts.FindAll(c => c.IsZoomRoom); - - if (zoomRooms.Count > 0) - { - // If so, setup a rooms and contacts folder and add them. - - directory.ResultsFolderId = "root"; - - roomFolder.Name = "Rooms"; - roomFolder.ParentFolderId = "root"; - roomFolder.FolderId = "rooms"; - - contactFolder.Name = "Contacts"; - contactFolder.ParentFolderId = "root"; - contactFolder.FolderId = "contacts"; - - folders.Add(roomFolder); - folders.Add(contactFolder); - - directory.AddFoldersToDirectory(folders); - } - - try - { - if (zoomContacts.Count == 0) - { - return directory; - } - - foreach (Contact c in zoomContacts) - { - var contact = new InvitableDirectoryContact { Name = c.ScreenName, ContactId = c.Jid }; - - contact.ContactMethods.Add(new ContactMethod() - { - Number = c.Jid, - Device = eContactMethodDevice.Video, - CallType = eContactMethodCallType.Video, - ContactMethodId = c.Jid - }); - - if (folders.Count > 0) - { - contact.ParentFolderId = c.IsZoomRoom - ? roomFolder.FolderId // "rooms" - : contactFolder.FolderId; // "contacts" - } - - contacts.Add(contact); - } - - directory.AddContactsToDirectory(contacts); - } - catch (Exception e) - { - Debug.Console(1, "Error converting Zoom Phonebook results to generic: {0}", e); - } - - return directory; - } - } - - public enum eCallStatus - { - UNKNOWN, - NOT_IN_MEETING, - CONNECTING_MEETING, - IN_MEETING, - LOGGED_OUT - } - - public class ClosedCaption - { - public bool Available { get; set; } - } - - public class Call : NotifiableObject - { - private eCallStatus _status; - private List _participants; - - public bool IsInCall; - - public eCallStatus Status - { - get - { - return _status; - } - set - { - if (value != _status) - { - _status = value; - IsInCall = _status == eCallStatus.IN_MEETING || _status == eCallStatus.CONNECTING_MEETING; - NotifyPropertyChanged("Status"); - } - } - } - public ClosedCaption ClosedCaption { get; set; } - public List Participants - { - get - { - return _participants; - } - set - { - _participants = value; - NotifyPropertyChanged("Participants"); - } - } - public zEvent.SharingState Sharing { get; set; } - - public CallRecordInfo CallRecordInfo { get; set; } - - private zCommand.InfoResult _info; - - public zCommand.InfoResult Info - { - get - { - return _info; - } - set - { - _info = value; - NotifyPropertyChanged("Info"); - } - } - - public Call() - { - ClosedCaption = new ClosedCaption(); - Participants = new List(); - Sharing = new zEvent.SharingState(); - CallRecordInfo = new CallRecordInfo(); - Info = new zCommand.InfoResult(); - } - } - - public class Capabilities - { - public bool aec_Setting_Stored_In_ZR { get; set; } - public bool can_Dtmf_For_Invite_By_Phone { get; set; } - public bool can_Mute_On_Entry { get; set; } - public bool can_Ringing_In_Pstn_Call { get; set; } - public bool can_Switch_To_Specific_Camera { get; set; } - public bool is_Airhost_Disabled { get; set; } - public bool pstn_Call_In_Local_resentation { get; set; } - public bool support_Claim_Host { get; set; } - public bool support_Out_Room_Display { get; set; } - public bool support_Pin_And_Spotlight { get; set; } - public bool supports_Audio_Checkup { get; set; } - public bool supports_CheckIn { get; set; } - public bool supports_Cloud_PBX { get; set; } - public bool supports_Encrypted_Connection { get; set; } - public bool supports_Expel_User_Permanently { get; set; } - public bool supports_H323_DTMF { get; set; } - public bool supports_Hdmi_Cec_Control { get; set; } - public bool supports_Highly_Reverberant_Room { get; set; } - public bool supports_Loading_Contacts_Dynamically { get; set; } - public bool supports_Loading_Participants_Dynamically { get; set; } - public bool supports_Mic_Record_Test { get; set; } - public bool supports_Multi_Share { get; set; } - public bool supports_ShareCamera { get; set; } - public bool supports_Share_For_Floating_And_Content_Only { get; set; } - public bool supports_Sip_Call_out { get; set; } - public bool supports_Software_Audio_Processing { get; set; } - public bool supports_Web_Settings_Push { get; set; } - } - - public enum eDisplayState - { - None, - Laptop, - IOS, - } - - public class Sharing : NotifiableObject - { - private eDisplayState _dispState; - private string _password; - private bool _isAirHostClientConnected; - private bool _isSharingBlackMagic; - private bool _isDirectPresentationConnected; - private bool _isBlackMagicConnected; - - - public string directPresentationPairingCode { get; set; } - /// - /// Laptop client sharing key - /// - public string directPresentationSharingKey { get; set; } - public eDisplayState dispState - { - get - { - return _dispState; - } - set - { - if (value != _dispState) - { - _dispState = value; - NotifyPropertyChanged("dispState"); - } - } - } - - public bool isAirHostClientConnected - { - get { return _isAirHostClientConnected; } - set - { - if (value != _isAirHostClientConnected) - { - _isAirHostClientConnected = value; - NotifyPropertyChanged("isAirHostClientConnected"); - } - } - } - - public bool isBlackMagicConnected - { - get { return _isBlackMagicConnected; } - set - { - if (value != _isBlackMagicConnected) - { - _isBlackMagicConnected = value; - NotifyPropertyChanged("isBlackMagicConnected"); - } - } - } - public bool isBlackMagicDataAvailable { get; set; } - - public bool isDirectPresentationConnected - { - get { return _isDirectPresentationConnected; } - set - { - if (value != _isDirectPresentationConnected) - { - _isDirectPresentationConnected = value; - NotifyPropertyChanged("isDirectPresentationConnected"); - } - } - } - - public bool isSharingBlackMagic - { - get { return _isSharingBlackMagic; } - set - { - if (value != _isSharingBlackMagic) - { - _isSharingBlackMagic = value; - NotifyPropertyChanged("isSharingBlackMagic"); - } - } - } - - /// - /// IOS Airplay code - /// - public string password - { - get - { - return _password; - } - set - { - if (value != _password) - { - _password = value; - NotifyPropertyChanged("password"); - } - } - } - public string serverName { get; set; } - public string wifiName { get; set; } - } - - public class NumberOfScreens : NotifiableObject - { - private int _numOfScreens; - - [JsonProperty("NumberOfCECScreens")] - public int NumOfCECScreens { get; set; } - [JsonProperty("NumberOfScreens")] - public int NumOfScreens - { - get - { - return _numOfScreens; - } - set - { - if (value != _numOfScreens) - { - _numOfScreens = value; - NotifyPropertyChanged("NumberOfScreens"); - } - } - } - } - - /// - /// AudioInputLine/AudioOutputLine/VideoCameraLine list item - /// - public class AudioVideoInputOutputLineItem - { - public string Alias { get; set; } - public string Name { get; set; } - public bool Selected { get; set; } - public bool combinedDevice { get; set; } - public string id { get; set; } - public bool manuallySelected { get; set; } - public int numberOfCombinedDevices { get; set; } - public int ptzComId { get; set; } - } - - public class Video - { - public bool Optimizable { get; set; } - } - - public class CameraShare : NotifiableObject - { - private bool _canControlCamera; - private bool _isSharing; - - [JsonProperty("can_Control_Camera")] - public bool CanControlCamera - { - get - { - return _canControlCamera; - } - set - { - if (value != _canControlCamera) - { - _canControlCamera = value; - NotifyPropertyChanged("CanControlCamera"); - } - } - } - public string id { get; set; } - public bool is_Mirrored { get; set; } - [JsonProperty("is_Sharing")] - public bool IsSharing - { - get - { - return _isSharing; - } - set - { - if (value != _isSharing) - { - _isSharing = value; - NotifyPropertyChanged("IsSharing"); - } - } - } - public int pan_Tilt_Speed { get; set; } - - } - - public class Layout : NotifiableObject - { - // backer variables - private bool _can_Switch_Speaker_View; - private bool _can_Switch_Wall_View; - private bool _can_Switch_Strip_View; - private bool _can_Switch_Share_On_All_Screens; - private bool _can_Switch_Floating_Share_Content; - private bool _is_In_First_Page; - private bool _is_In_Last_Page; - private string _video_type; - - - public bool can_Adjust_Floating_Video { get; set; } - - - public bool can_Switch_Floating_Share_Content - { - get - { - return _can_Switch_Floating_Share_Content; - } - set - { - if (value != _can_Switch_Floating_Share_Content) - { - _can_Switch_Floating_Share_Content = value; - NotifyPropertyChanged("can_Switch_Floating_Share_Content"); - } - } - } - - - /// - /// [on/off] // Set to On if it is possible to invoke zConfiguration Call Layout Style: ShareAll, to switch to the ShareAll mode, where the content sharing is shown full screen on all monitors. - /// - [JsonProperty("can_Switch_Share_On_All_Screens")] - public bool can_Switch_Share_On_All_Screens - { - get - { - return _can_Switch_Share_On_All_Screens; - } - set - { - if (value != _can_Switch_Share_On_All_Screens) - { - _can_Switch_Share_On_All_Screens = value; - NotifyPropertyChanged("can_Switch_Share_On_All_Screens"); - } - } - } - - /// - /// [on/off] // Set to On if it is possible to switch to Speaker view by invoking zConfiguration Call Layout Style: Speaker. The active speaker is shown full screen, and other video streams, like self-view, are shown in thumbnails. - /// - [JsonProperty("can_Switch_Speaker_View")] - public bool can_Switch_Speaker_View - { - get - { - return _can_Switch_Speaker_View; - } - set - { - if (value != _can_Switch_Speaker_View) - { - _can_Switch_Speaker_View = value; - NotifyPropertyChanged("can_Switch_Speaker_View"); - } - } - } - - /// - /// [on/off] On if it is possible to invoke zConfiguration Call Layout Style: Gallery, to switch to the Gallery mode, showing video participants in tiled windows: The Zoom Room shows up to a 5x5 array of tiled windows per page. - /// - [JsonProperty("can_Switch_Wall_View")] - public bool can_Switch_Wall_View - { - get - { - return _can_Switch_Wall_View; - } - set - { - if (value != _can_Switch_Wall_View) - { - _can_Switch_Wall_View = value; - NotifyPropertyChanged("can_Switch_Wall_View"); - } - } - } - - [JsonProperty("can_Switch_Strip_View")] - public bool can_Switch_Strip_View - { - get - { - return _can_Switch_Strip_View; - } - set - { - if (value != _can_Switch_Strip_View) - { - _can_Switch_Strip_View = value; - NotifyPropertyChanged("can_Switch_Strip_View"); - } - } - } - - [JsonProperty("is_In_First_Page")] - public bool is_In_First_Page - { - get - { - return _is_In_First_Page; - } - set - { - if (value != _is_In_First_Page) - { - _is_In_First_Page = value; - NotifyPropertyChanged("is_In_First_Page"); - } - } - } - - [JsonProperty("is_In_Last_Page")] - public bool is_In_Last_Page - { - get - { - return _is_In_Last_Page; - } - set - { - if (value != _is_In_Last_Page) - { - _is_In_Last_Page = value; - NotifyPropertyChanged("is_In_Last_Page"); - } - } - } - - public bool is_supported { get; set; } - public int video_Count_In_Current_Page { get; set; } - - /// - /// [Gallery | Strip] Indicates which mode applies: Strip or Gallery. - /// - [JsonProperty("video_type")] - public string video_type - { - get - { - return _video_type; - } - set - { - if (value != _video_type) - { - _video_type = value; - NotifyPropertyChanged("video_type"); - } - } - } - } - - public class CallRecordInfo : NotifiableObject - { - private bool _meetingIsBeingRecorded; - private bool _canRecord; - private bool _emailRequired; - - public bool amIRecording { get; set; } - - public bool canRecord - { - get - { - return _canRecord; - } - set - { - if (value != _canRecord) - { - _canRecord = value; - NotifyPropertyChanged("canRecord"); - } - } - } - - public bool emailRequired - { - get - { - return _emailRequired; - } - set - { - if (value != _emailRequired) - { - _emailRequired = value; - NotifyPropertyChanged("emailRequired"); - } - } - } - - public bool meetingIsBeingRecorded - { - get - { - return _meetingIsBeingRecorded; - } - set - { - //Debug.Console(2, "************************************setting value of meetingIsBeingRecorded to: {0}", value); - if (value != _meetingIsBeingRecorded) - { - _meetingIsBeingRecorded = value; - //Debug.Console(2, "********************************set value of meetingIsBeingRecorded to: {0}", _meetingIsBeingRecorded); - NotifyPropertyChanged("meetingIsBeingRecorded"); - } - } - } - - /// - /// Indicates if recording is allowed (when meeting capable and and email is not required to be entered by the user) - /// - public bool AllowRecord - { - get - { - return canRecord && !emailRequired; - } - } - - public CallRecordInfo() - { - Debug.Console(2, Debug.ErrorLogLevel.Notice, "********************************************* CallRecordInfo() ******************************************"); - } - } - } - - /// - /// zEvent Class Structure - /// - public class zEvent - { - public class StartLocalPresentMeeting - { - public bool Success { get; set; } - } - public class NeedWaitForHost - { - public bool Wait { get; set; } - } - - public class IncomingCallIndication - { - public string callerJID { get; set; } - public string calleeJID { get; set; } - public string meetingID { get; set; } - public string password { get; set; } - public string meetingOption { get; set; } - public long MeetingNumber { get; set; } - public string callerName { get; set; } - public string avatarURL { get; set; } - public int lifeTime { get; set; } - public bool accepted { get; set; } - } - - public class CallConnectError - { - public int error_code { get; set; } - public string error_message { get; set; } - } - - public class CallDisconnect - { - public bool Successful - { - get - { - return success == "on"; - } - } - - public string success { get; set; } - } - - public class Layout - { - public bool Sharethumb { get; set; } - } - - public class Call - { - public Layout Layout { get; set; } - } - - public class Client - { - public Call Call { get; set; } - } - - public enum eSharingState - { - None, - Connecting, - Sending, - Receiving, - Send_Receiving - } - - public class SharingState : NotifiableObject - { - private bool _paused; - private eSharingState _state; - - public bool IsSharing { get; private set; } - - [JsonProperty("paused")] - public bool Paused - { - get - { - return _paused; - } - set - { - if (value != _paused) - { - _paused = value; - NotifyPropertyChanged("Paused"); - } - } - } - [JsonProperty("state")] - public eSharingState State - { - get - { - return _state; - } - set - { - if (value != _state) - { - _state = value; - IsSharing = _state == eSharingState.Sending; - NotifyPropertyChanged("State"); - } - } - } - } - - public class PinStatusOfScreenNotification - { - - - [JsonProperty("can_be_pinned")] - public bool CanBePinned { get; set; } - [JsonProperty("can_pin_share")] - public bool CanPinShare { get; set; } - [JsonProperty("pinned_share_source_id")] - public int PinnedShareSourceId { get; set; } - [JsonProperty("pinned_user_id")] - public int PinnedUserId { get; set; } - [JsonProperty("screen_index")] - public int ScreenIndex { get; set; } - [JsonProperty("screen_layout")] - public int ScreenLayout { get; set; } - [JsonProperty("share_source_type")] - public int ShareSourceType { get; set; } - [JsonProperty("why_cannot_pin_share")] - public string WhyCannotPinShare { get; set; } - } - - public class PhoneCallStatus : NotifiableObject - { - private bool _isIncomingCall; - private string _peerDisplayName; - private string _peerNumber; - - private bool _offHook; - - public string CallId { get; set; } - public bool IsIncomingCall - { - get { return _isIncomingCall; } - set - { - if (value == _isIncomingCall) return; - - _isIncomingCall = value; - NotifyPropertyChanged("IsIncomingCall"); - } - } - - public string PeerDisplayName - { - get { return _peerDisplayName; } - set - { - if (value == _peerDisplayName) return; - _peerDisplayName = value; - NotifyPropertyChanged("PeerDisplayName"); - } - } - - public string PeerNumber - { - get { return _peerNumber; } - set - { - if (value == _peerNumber) return; - - _peerNumber = value; - NotifyPropertyChanged("PeerNumber"); - } - } - - public string PeerUri { get; set; } - - private ePhoneCallStatus _status; - public ePhoneCallStatus Status - { - get { return _status; } - set - { - _status = value; - OffHook = _status == ePhoneCallStatus.PhoneCallStatus_Accepted || - _status == ePhoneCallStatus.PhoneCallStatus_InCall || - _status == ePhoneCallStatus.PhoneCallStatus_Init || - _status == ePhoneCallStatus.PhoneCallStatus_Ringing; - } - } - - public bool OffHook - { - get { return _offHook; } - set - { - if (value == _offHook) return; - - _offHook = value; - NotifyPropertyChanged("OffHook"); - } - } - } - - public enum ePhoneCallStatus - { - PhoneCallStatus_Ringing, - PhoneCallStatus_Terminated, - PhoneCallStatus_Accepted, - PhoneCallStatus_InCall, - PhoneCallStatus_Init, - } - - public class MeetingNeedsPassword - { - [JsonProperty("needsPassword")] - public bool NeedsPassword { get; set; } - - [JsonProperty("wrongAndRetry")] - public bool WrongAndRetry { get; set; } - } - } - - /// - /// zConfiguration class structure - /// - public class zConfiguration - { - public class Sharing - { - [JsonProperty("optimize_video_sharing")] - public bool OptimizeVideoSharing { get; set; } - } - - public class Camera : NotifiableObject - { - private bool _mute; - - public bool Mute - { - get { return _mute; } - set - { - Debug.Console(1, "Camera Mute response received: {0}", value); - - if (value == _mute) return; - - _mute = value; - NotifyPropertyChanged("Mute"); - } - } - } - - public class Microphone : NotifiableObject - { - private bool _mute; - - public bool Mute - { - get - { - return _mute; - } - set - { - if (value != _mute) - { - _mute = value; - NotifyPropertyChanged("Mute"); - } - } - } - } - - [Flags] - public enum eLayoutStyle - { - None = 0, - Gallery = 1, - Speaker = 2, - Strip = 4, - ShareAll = 8, - } - - public enum eLayoutSize - { - Off, - Size1, - Size2, - Size3, - Strip - } - - public enum eLayoutPosition - { - Center, - Up, - Right, - UpRight, - Down, - DownRight, - Left, - UpLeft, - DownLeft - } - - public class Layout : NotifiableObject - { - private bool _shareThumb; - private eLayoutStyle _style; - private eLayoutSize _size; - private eLayoutPosition _position; - - public bool ShareThumb - { - get { return _shareThumb; } - set - { - if (value != _shareThumb) - { - _shareThumb = value; - NotifyPropertyChanged("ShareThumb"); - } - } - } - - public eLayoutStyle Style - { - get { return _style; } - set - { - if (value != _style) - { - _style = value; - NotifyPropertyChanged("Style"); - } - } - } - - public eLayoutSize Size - { - get { return _size; } - set - { - if (value != _size) - { - _size = value; - NotifyPropertyChanged("Size"); - } - } - } - - public eLayoutPosition Position - { - get { return _position; } - set - { - if (value != _position) - { - _position = value; - NotifyPropertyChanged("Position"); - } - } - } - } - - public class Lock : NotifiableObject - { - private bool _enable; - - public bool Enable - { - get - { - return _enable; - } - set - { - if (value != _enable) - { - _enable = value; - NotifyPropertyChanged("Enable"); - } - } - } - } - - public class ClosedCaption - { - public bool Visible { get; set; } - public int FontSize { get; set; } - } - - public class MuteUserOnEntry - { - public bool Enable { get; set; } - } - - public class Call - { - public Sharing Sharing { get; set; } - public Camera Camera { get; set; } - public Microphone Microphone { get; set; } - public Layout Layout { get; set; } - public Lock Lock { get; set; } - public MuteUserOnEntry MuteUserOnEntry { get; set; } - public ClosedCaption ClosedCaption { get; set; } - - - public Call() - { - Sharing = new Sharing(); - Camera = new Camera(); - Microphone = new Microphone(); - Layout = new Layout(); - Lock = new Lock(); - MuteUserOnEntry = new MuteUserOnEntry(); - ClosedCaption = new ClosedCaption(); - } - } - - public class Audio - { - public Input Input { get; set; } - public Output Output { get; set; } - - public Audio() - { - Input = new Input(); - Output = new Output(); - } - } - - public class Input : Output - { - [JsonProperty("reduce_reverb")] - public bool ReduceReverb { get; set; } - } - - public class Output : NotifiableObject - { - private int _volume; - - [JsonProperty("volume")] - public int Volume - { - get - { - return _volume; - } - set - { - if (value != _volume) - { - _volume = value; - NotifyPropertyChanged("Volume"); - } - } - } - [JsonProperty("selectedId")] - public string SelectedId { get; set; } - [JsonProperty("is_sap_disabled")] - public bool IsSapDisabled { get; set; } - } - - public class Video : NotifiableObject - { - private bool _hideConfSelfVideo; - - [JsonProperty("hide_conf_self_video")] - public bool HideConfSelfVideo - { - get - { - return _hideConfSelfVideo; - } - set - { - //if (value != _hideConfSelfVideo) - //{ - _hideConfSelfVideo = value; - NotifyPropertyChanged("HideConfSelfVideo"); - //} - } - } - - public VideoCamera Camera { get; set; } - - public Video() - { - Camera = new VideoCamera(); - } - } - - public class VideoCamera : NotifiableObject - { - private string _selectedId; - - [JsonProperty("selectedId")] - public string SelectedId - { - get - { - return _selectedId; - } - set - { - if (value != _selectedId) - { - _selectedId = value; - NotifyPropertyChanged("SelectedId"); - } - } - - } - public bool Mirror { get; set; } - } - - public class Client - { - public string appVersion { get; set; } - public string deviceSystem { get; set; } - - // This doesn't belong here, but there's a bug in the object structure of Zoom Room 5.6.3 that puts it here - public zConfiguration.Call Call { get; set; } - - public Client() - { - Call = new zConfiguration.Call(); - } - } - - } - - /// - /// zCommand class structure - /// - public class zCommand - { - public class BookingsListResult - { - [JsonProperty("accessRole")] - public string AccessRole { get; set; } - [JsonProperty("calendarChangeKey")] - public string CalendarChangeKey { get; set; } - [JsonProperty("calendarID")] - public string CalendarId { get; set; } - [JsonProperty("checkIn")] - public bool CheckIn { get; set; } - [JsonProperty("creatorEmail")] - public string CreatorEmail { get; set; } - [JsonProperty("creatorName")] - public string CreatorName { get; set; } - [JsonProperty("endTime")] - public DateTime EndTime { get; set; } - [JsonProperty("hostName")] - public string HostName { get; set; } - [JsonProperty("isInstantMeeting")] - public bool IsInstantMeeting { get; set; } - [JsonProperty("isPrivate")] - public bool IsPrivate { get; set; } - [JsonProperty("location")] - public string Location { get; set; } - [JsonProperty("meetingName")] - public string MeetingName { get; set; } - [JsonProperty("meetingNumber")] - public string MeetingNumber { get; set; } - [JsonProperty("scheduledFrom")] - public string ScheduledFrom { get; set; } - [JsonProperty("startTime")] - public DateTime StartTime { get; set; } - [JsonProperty("third_party")] - public ThirdParty ThirdParty { get; set; } - } - - public static List GetGenericMeetingsFromBookingResult(List bookings, - int minutesBeforeMeetingStart) - { - var rv = GetGenericMeetingsFromBookingResult(bookings); - - foreach (var meeting in rv) - { - meeting.MinutesBeforeMeeting = minutesBeforeMeetingStart; - } - - return rv; - } - /// - /// Extracts the necessary meeting values from the Zoom bookings response and converts them to the generic class - /// - /// - /// - public static List GetGenericMeetingsFromBookingResult(List bookings) - { - var meetings = new List(); - - if (Debug.Level > 0) - { - Debug.Console(1, "Meetings List:\n"); - } - - foreach (var b in bookings) - { - var meeting = new Meeting(); - - if (b.MeetingNumber != null) - meeting.Id = b.MeetingNumber; - if (b.CreatorName != null) - meeting.Organizer = b.CreatorName; - if (b.MeetingName != null) - meeting.Title = b.MeetingName; - //if (b.Agenda != null) - // meeting.Agenda = b.Agenda.Value; - if (b.StartTime != null) - meeting.StartTime = b.StartTime; - if (b.EndTime != null) - meeting.EndTime = b.EndTime; - - meeting.Privacy = b.IsPrivate ? eMeetingPrivacy.Private : eMeetingPrivacy.Public; - - meeting.Dialable = meeting.Id != "0"; - - // No meeting.Calls data exists for Zoom Rooms. Leaving out for now. - var now = DateTime.Now; - if (meeting.StartTime < now && meeting.EndTime < now) - { - Debug.Console(1, "Skipping meeting {0}. Meeting is in the past.", meeting.Title); - continue; - } - - meetings.Add(meeting); - - if (Debug.Level > 0) - { - Debug.Console(1, "Title: {0}, ID: {1}, Organizer: {2}", meeting.Title, meeting.Id, meeting.Organizer); - Debug.Console(1, " Start Time: {0}, End Time: {1}, Duration: {2}", meeting.StartTime, meeting.EndTime, meeting.Duration); - Debug.Console(1, " Joinable: {0}\n", meeting.Joinable); - } - } - - meetings.OrderBy(m => m.StartTime); - - return meetings; - } - - public class HandStatus - { - // example return of the "hand_status" object - // !!!! Note the properties contain ': ' within the property name !!! - //"hand_status": { - // "is_raise_hand: ": false, - // "is_valid: ": "on", - // "time_stamp: ": "11825083" - //}, - [JsonProperty("is_raise_hand: ")] - public bool IsRaiseHand { get; set; } - [JsonProperty("is_valid: ")] - public string IsValid { get; set; } - [JsonProperty("time_stamp: ")] - public string TimeStamp { get; set; } - /// - /// Retuns a boolean value if the participant hand state is raised and is valid (both need to be true) - /// - public bool HandIsRaisedAndValid - { - get { return IsValid != null && IsValid == "on" && IsRaiseHand; } - } - } - public class ListParticipant - { - [JsonProperty("audio_status state")] - public string AudioStatusState { get; set; } - [JsonProperty("audio_status type")] - public string AudioStatusType { get; set; } - [JsonProperty("avatar_url")] - public string AvatarUrl { get; set; } - [JsonProperty("camera_status am_i_controlling")] - public bool CameraStatusAmIControlling { get; set; } - [JsonProperty("camera_status can_i_request_control")] - public bool CameraStatusCanIRequestConrol { get; set; } - [JsonProperty("camera_status can_move_camera")] - public bool CameraStatusCanMoveCamera { get; set; } - [JsonProperty("camera_status can_switch_camera")] - public bool CameraStatusCanSwitchCamera { get; set; } - [JsonProperty("camera_status can_zoom_camera")] - public bool CameraStatusCanZoomCamera { get; set; } - [JsonProperty("can_edit_closed_caption")] - public bool CanEditClosedCaption { get; set; } - [JsonProperty("can_record")] - public bool CanRecord { get; set; } - [JsonProperty("event")] - public string Event { get; set; } - [JsonProperty("hand_status")] - public HandStatus HandStatus { get; set; } - [JsonProperty("isCohost")] - public bool IsCohost { get; set; } - [JsonProperty("is_client_support_closed_caption")] - public bool IsClientSupportClosedCaption { get; set; } - [JsonProperty("is_client_support_coHost")] - public bool IsClientSupportCoHost { get; set; } - [JsonProperty("is_host")] - public bool IsHost { get; set; } - [JsonProperty("is_myself")] - public bool IsMyself { get; set; } - [JsonProperty("is_recording")] - public bool IsRecording { get; set; } - [JsonProperty("is_video_can_mute_byHost")] - public bool IsVideoCanMuteByHost { get; set; } - [JsonProperty("is_video_can_unmute_byHost")] - public bool IsVideoCanUnmuteByHost { get; set; } - [JsonProperty("local_recording_disabled")] - public bool LocalRecordingDisabled { get; set; } - [JsonProperty("user_id")] - public int UserId { get; set; } - [JsonProperty("user_name")] - public string UserName { get; set; } - [JsonProperty("user_type")] - public string UserType { get; set; } - [JsonProperty("video_status has_source")] - public bool VideoStatusHasSource { get; set; } - [JsonProperty("video_status is_receiving")] - public bool VideoStatusIsReceiving { get; set; } - [JsonProperty("video_status is_sending")] - public bool VideoStatusIsSending { get; set; } - - public ListParticipant() - { - HandStatus = new HandStatus(); - } - - /// - /// Converts ZoomRoom pariticpant list response to an Essentials participant list - /// - /// - /// - public static List GetGenericParticipantListFromParticipantsResult( - List participants) - { - if (participants.Count == 0) - { - return new List(); - } - //return participants.Select(p => new Participant - // { - // UserId = p.UserId, - // Name = p.UserName, - // IsHost = p.IsHost, - // CanMuteVideo = p.IsVideoCanMuteByHost, - // CanUnmuteVideo = p.IsVideoCanUnmuteByHost, - // AudioMuteFb = p.AudioStatusState == "AUDIO_MUTED", - // VideoMuteFb = p.VideoStatusIsSending, - // HandIsRaisedFb = p.HandStatus.HandIsRaisedAndValid, - // }).ToList(); - - var sortedParticipants = SortParticipantListByHandStatus(participants); - return sortedParticipants.Select(p => new Participant - { - UserId = p.UserId, - Name = p.UserName, - IsHost = p.IsHost, - IsMyself = p.IsMyself, - CanMuteVideo = p.IsVideoCanMuteByHost, - CanUnmuteVideo = p.IsVideoCanUnmuteByHost, - AudioMuteFb = p.AudioStatusState == "AUDIO_MUTED", - VideoMuteFb = !p.VideoStatusIsSending, - HandIsRaisedFb = p.HandStatus.HandIsRaisedAndValid, - }).ToList(); - } - - /// - /// Will sort by hand-raise status and then alphabetically - /// - /// Zoom Room response list of participants - /// List - public static List SortParticipantListByHandStatus(List participants) - { - if (participants == null) - { - //Debug.Console(1, "SortParticiapntListByHandStatu(participants == null)"); - return null; - } - - // debug testing - //foreach (ListParticipant participant in participants) - //{ - // Debug.Console(1, "{0} | IsValid: {1} | IsRaiseHand: {2} | HandIsRaisedAndValid: {3}", - // participant.UserName, participant.HandStatus.IsValid, participant.HandStatus.IsRaiseHand.ToString(), participant.HandStatus.HandIsRaisedAndValid.ToString()); - //} - - List handRaisedParticipantsList = participants.Where(p => p.HandStatus.HandIsRaisedAndValid).ToList(); - - if (handRaisedParticipantsList != null) - { - IOrderedEnumerable orderByDescending = handRaisedParticipantsList.OrderByDescending(p => p.HandStatus.TimeStamp); - - //foreach (var participant in handRaisedParticipantsList) - // Debug.Console(1, "handRaisedParticipantList: {0} | {1}", participant.UserName, participant.UserId); - } - - List allOtherParticipantsList = participants.Where(p => !p.HandStatus.HandIsRaisedAndValid).ToList(); - - if (allOtherParticipantsList != null) - { - allOtherParticipantsList.OrderBy(p => p.UserName); - - //foreach (var participant in allOtherParticipantsList) - // Debug.Console(1, "allOtherParticipantsList: {0} | {1}", participant.UserName, participant.UserId); - } - - // merge the lists - List sortedList = handRaisedParticipantsList.Union(allOtherParticipantsList).ToList(); - - // return the sorted list - return sortedList; - } - - } - - public class CallinCountryList - { - public int code { get; set; } - public string display_number { get; set; } - public string id { get; set; } - public string name { get; set; } - public string number { get; set; } - } - - public class CalloutCountryList - { - public int code { get; set; } - public string display_number { get; set; } - public string id { get; set; } - public string name { get; set; } - public string number { get; set; } - } - - public class TollFreeCallinList - { - public int code { get; set; } - public string display_number { get; set; } - public string id { get; set; } - public string name { get; set; } - public string number { get; set; } - } - - public class Info - { - public List callin_country_list { get; set; } - public List callout_country_list { get; set; } - public List toll_free_callin_list { get; set; } - } - - public class ThirdParty - { - public string h323_address { get; set; } - public string meeting_number { get; set; } - public string service_provider { get; set; } - public string sip_address { get; set; } - } - - public class MeetingListItem - { - public string accessRole { get; set; } - public string calendarChangeKey { get; set; } - public string calendarID { get; set; } - public bool checkIn { get; set; } - public string creatorEmail { get; set; } - public string creatorName { get; set; } - public string endTime { get; set; } - public string hostName { get; set; } - public bool isInstantMeeting { get; set; } - public bool isPrivate { get; set; } - public string location { get; set; } - public string meetingName { get; set; } - public string meetingNumber { get; set; } - public string scheduledFrom { get; set; } - public string startTime { get; set; } - public ThirdParty third_party { get; set; } - - public MeetingListItem() - { - third_party = new ThirdParty(); - } - } - - public class InfoResult - { - public Info Info { get; set; } - public bool am_i_original_host { get; set; } - public string default_callin_country { get; set; } - public string dialIn { get; set; } - public string international_url { get; set; } - public string invite_email_content { get; set; } - public string invite_email_subject { get; set; } - public bool is_callin_country_list_available { get; set; } - public bool is_calling_room_system_enabled { get; set; } - public bool is_toll_free_callin_list_available { get; set; } - public bool is_view_only { get; set; } - public bool is_waiting_room { get; set; } - public bool is_webinar { get; set; } - public string meeting_id { get; set; } - public MeetingListItem meeting_list_item { get; set; } - public string meeting_password { get; set; } - public string meeting_type { get; set; } - public int my_userid { get; set; } - public int participant_id { get; set; } - public string real_meeting_id { get; set; } - public string schedule_option { get; set; } - public string schedule_option2 { get; set; } - public string support_callout_type { get; set; } - public string toll_free_number { get; set; } - public string user_type { get; set; } - - public InfoResult() - { - Info = new Info(); - meeting_list_item = new MeetingListItem(); - } - } - - public class Phonebook - { - public List Contacts { get; set; } - public int Limit { get; set; } - public int Offset { get; set; } - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using Crestron.SimplSharp; + +using PepperDash.Core; +using PepperDash.Essentials.Devices.Common.Codec; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom +{ + public enum eZoomRoomResponseType + { + zEvent, + zStatus, + zConfiguration, + zCommand + } + + public abstract class NotifiableObject : INotifyPropertyChanged + { + #region INotifyPropertyChanged Members + + public event PropertyChangedEventHandler PropertyChanged; + + protected void NotifyPropertyChanged(string propertyName) + { + var handler = PropertyChanged; + if (handler != null) + { + handler(this, new PropertyChangedEventArgs(propertyName)); + } + else + { + Debug.Console(2, "PropertyChanged event is NULL"); + } + } + + #endregion + } + + /// + /// Used to track the current status of a ZoomRoom + /// + public class ZoomRoomStatus + { + public zStatus.Login Login { get; set; } + public zStatus.SystemUnit SystemUnit { get; set; } + public zStatus.Phonebook Phonebook { get; set; } + public zStatus.Call Call { get; set; } + public zStatus.Capabilities Capabilities { get; set; } + public zStatus.Sharing Sharing { get; set; } + public zStatus.NumberOfScreens NumberOfScreens { get; set; } + public zStatus.Layout Layout { get; set; } + public zStatus.Video Video { get; set; } + public zStatus.CameraShare CameraShare { get; set; } + public List AudioInputs { get; set; } + public List AudioOuputs { get; set; } + public List Cameras { get; set; } + public zEvent.PhoneCallStatus PhoneCall { get; set; } + public zEvent.NeedWaitForHost NeedWaitForHost { get; set; } + + public ZoomRoomStatus() + { + Login = new zStatus.Login(); + SystemUnit = new zStatus.SystemUnit(); + Phonebook = new zStatus.Phonebook(); + Call = new zStatus.Call(); + Capabilities = new zStatus.Capabilities(); + Sharing = new zStatus.Sharing(); + NumberOfScreens = new zStatus.NumberOfScreens(); + Layout = new zStatus.Layout(); + Video = new zStatus.Video(); + CameraShare = new zStatus.CameraShare(); + AudioInputs = new List(); + AudioOuputs = new List(); + Cameras = new List(); + PhoneCall = new zEvent.PhoneCallStatus(); + NeedWaitForHost = new zEvent.NeedWaitForHost(); + } + } + + /// + /// Used to track the current configuration of a ZoomRoom + /// + public class ZoomRoomConfiguration + { + public zConfiguration.Call Call { get; set; } + public zConfiguration.Audio Audio { get; set; } + public zConfiguration.Video Video { get; set; } + public zConfiguration.Client Client { get; set; } + public zConfiguration.Camera Camera { get; set; } + + public ZoomRoomConfiguration() + { + Call = new zConfiguration.Call(); + Audio = new zConfiguration.Audio(); + Video = new zConfiguration.Video(); + Client = new zConfiguration.Client(); + Camera = new zConfiguration.Camera(); + } + } + + /// + /// Represents a response from a ZoomRoom system + /// + public class Response + { + public Status Status { get; set; } + public bool Sync { get; set; } + [JsonProperty("topKey")] + public string TopKey { get; set; } + [JsonProperty("type")] + public string Type { get; set; } + + public Response() + { + Status = new Status(); + } + } + + public class Status + { + [JsonProperty("message")] + public string Message { get; set; } + [JsonProperty("state")] + public string State { get; set; } + } + + + /// + /// zStatus class stucture + /// + public class zStatus + { + public class Login + { + [JsonProperty("ZAAPI Release")] + public string ZAAPIRelease { get; set; } + [JsonProperty("Zoom Room Release")] + public string ZoomRoomRelease { get; set; } + } + + public class SystemUnit + { + [JsonProperty("email")] + public string Email { get; set; } + [JsonProperty("login_type")] + public string LoginType { get; set; } + [JsonProperty("meeting_number")] + public string MeetingNumber { get; set; } + [JsonProperty("platform")] + public string Platform { get; set; } + [JsonProperty("room_info")] + public RoomInfo RoomInfo { get; set; } + [JsonProperty("room_version")] + public string RoomVersion { get; set; } + + public SystemUnit() + { + RoomInfo = new RoomInfo(); + } + } + + public class RoomInfo + { + [JsonProperty("account_email")] + public string AccountEmail { get; set; } + [JsonProperty("display_version")] + public string DisplayVersion { get; set; } + [JsonProperty("is_auto_answer_enabled")] + public bool AutoAnswerIsEnabled { get; set; } + [JsonProperty("is_auto_answer_selected")] + public bool AutoAnswerIsSelected { get; set; } + [JsonProperty("room_name")] + public string RoomName { get; set; } + } + + public class CloudPbxInfo + { + [JsonProperty("company_number")] + public string CompanyNumber { get; set; } + [JsonProperty("extension")] + public string Extension { get; set; } + [JsonProperty("isValid")] + public bool IsValid { get; set; } + } + + public enum ePresence + { + PRESENCE_OFFLINE, + PRESENCE_ONLINE, + PRESENCE_AWAY, + PRESENCE_BUSY, + PRESENCE_DND + } + + public class Contact + { + [JsonProperty("avatarURL")] + public string AvatarURL { get; set; } + [JsonProperty("cloud_pbx_info")] + public CloudPbxInfo CloudPbxInfo { get; set; } + [JsonProperty("email")] + public string Email { get; set; } + [JsonProperty("firstName")] + public string FirstName { get; set; } + [JsonProperty("index")] + public int Index { get; set; } + [JsonProperty("isLegacy")] + public bool IsLegacy { get; set; } + [JsonProperty("isZoomRoom")] + public bool IsZoomRoom { get; set; } + [JsonProperty("jid")] + public string Jid { get; set; } + [JsonProperty("lastName")] + public string LastName { get; set; } + [JsonProperty("onDesktop")] + public bool OnDesktop { get; set; } + [JsonProperty("onMobile")] + public bool OnMobile { get; set; } + [JsonProperty("phoneNumber")] + public string PhoneNumber { get; set; } + [JsonProperty("presence")] + public ePresence Presence { get; set; } + [JsonProperty("presence_status")] + public int PresenceStatus { get; set; } + [JsonProperty("screenName")] + public string ScreenName { get; set; } + [JsonProperty("sip_phone_number")] + public string SipPhoneNumber { get; set; } + + + public Contact() + { + CloudPbxInfo = new CloudPbxInfo(); + } + } + + public class Phonebook + { + [JsonProperty("Contacts")] + public List Contacts { get; set; } + + public Phonebook() + { + Contacts = new List(); + } + + /// + /// Converts from zStatus.Contact types to generic directory items + /// + /// + public static CodecDirectory ConvertZoomContactsToGeneric(List zoomContacts) + { + var directory = new CodecDirectory(); + + var folders = new List(); + + var roomFolder = new DirectoryFolder(); + + var contactFolder = new DirectoryFolder(); + + var contacts = new List(); + + // Check if there are any zoom rooms + var zoomRooms = zoomContacts.FindAll(c => c.IsZoomRoom); + + if (zoomRooms.Count > 0) + { + // If so, setup a rooms and contacts folder and add them. + + directory.ResultsFolderId = "root"; + + roomFolder.Name = "Rooms"; + roomFolder.ParentFolderId = "root"; + roomFolder.FolderId = "rooms"; + + contactFolder.Name = "Contacts"; + contactFolder.ParentFolderId = "root"; + contactFolder.FolderId = "contacts"; + + folders.Add(roomFolder); + folders.Add(contactFolder); + + directory.AddFoldersToDirectory(folders); + } + + try + { + if (zoomContacts.Count == 0) + { + return directory; + } + + foreach (Contact c in zoomContacts) + { + var contact = new InvitableDirectoryContact { Name = c.ScreenName, ContactId = c.Jid }; + + contact.ContactMethods.Add(new ContactMethod() + { + Number = c.Jid, + Device = eContactMethodDevice.Video, + CallType = eContactMethodCallType.Video, + ContactMethodId = c.Jid + }); + + if (folders.Count > 0) + { + contact.ParentFolderId = c.IsZoomRoom + ? roomFolder.FolderId // "rooms" + : contactFolder.FolderId; // "contacts" + } + + contacts.Add(contact); + } + + directory.AddContactsToDirectory(contacts); + } + catch (Exception e) + { + Debug.Console(1, "Error converting Zoom Phonebook results to generic: {0}", e); + } + + return directory; + } + } + + public enum eCallStatus + { + UNKNOWN, + NOT_IN_MEETING, + CONNECTING_MEETING, + IN_MEETING, + LOGGED_OUT + } + + public class ClosedCaption + { + public bool Available { get; set; } + } + + public class Call : NotifiableObject + { + private eCallStatus _status; + private List _participants; + + public bool IsInCall; + + public eCallStatus Status + { + get + { + return _status; + } + set + { + if (value != _status) + { + _status = value; + IsInCall = _status == eCallStatus.IN_MEETING || _status == eCallStatus.CONNECTING_MEETING; + NotifyPropertyChanged("Status"); + } + } + } + public ClosedCaption ClosedCaption { get; set; } + public List Participants + { + get + { + return _participants; + } + set + { + _participants = value; + NotifyPropertyChanged("Participants"); + } + } + public zEvent.SharingState Sharing { get; set; } + + public CallRecordInfo CallRecordInfo { get; set; } + + private zCommand.InfoResult _info; + + public zCommand.InfoResult Info + { + get + { + return _info; + } + set + { + _info = value; + NotifyPropertyChanged("Info"); + } + } + + public Call() + { + ClosedCaption = new ClosedCaption(); + Participants = new List(); + Sharing = new zEvent.SharingState(); + CallRecordInfo = new CallRecordInfo(); + Info = new zCommand.InfoResult(); + } + } + + public class Capabilities + { + public bool aec_Setting_Stored_In_ZR { get; set; } + public bool can_Dtmf_For_Invite_By_Phone { get; set; } + public bool can_Mute_On_Entry { get; set; } + public bool can_Ringing_In_Pstn_Call { get; set; } + public bool can_Switch_To_Specific_Camera { get; set; } + public bool is_Airhost_Disabled { get; set; } + public bool pstn_Call_In_Local_resentation { get; set; } + public bool support_Claim_Host { get; set; } + public bool support_Out_Room_Display { get; set; } + public bool support_Pin_And_Spotlight { get; set; } + public bool supports_Audio_Checkup { get; set; } + public bool supports_CheckIn { get; set; } + public bool supports_Cloud_PBX { get; set; } + public bool supports_Encrypted_Connection { get; set; } + public bool supports_Expel_User_Permanently { get; set; } + public bool supports_H323_DTMF { get; set; } + public bool supports_Hdmi_Cec_Control { get; set; } + public bool supports_Highly_Reverberant_Room { get; set; } + public bool supports_Loading_Contacts_Dynamically { get; set; } + public bool supports_Loading_Participants_Dynamically { get; set; } + public bool supports_Mic_Record_Test { get; set; } + public bool supports_Multi_Share { get; set; } + public bool supports_ShareCamera { get; set; } + public bool supports_Share_For_Floating_And_Content_Only { get; set; } + public bool supports_Sip_Call_out { get; set; } + public bool supports_Software_Audio_Processing { get; set; } + public bool supports_Web_Settings_Push { get; set; } + } + + public enum eDisplayState + { + None, + Laptop, + IOS, + } + + public class Sharing : NotifiableObject + { + private eDisplayState _dispState; + private string _password; + private bool _isAirHostClientConnected; + private bool _isSharingBlackMagic; + private bool _isDirectPresentationConnected; + private bool _isBlackMagicConnected; + + + public string directPresentationPairingCode { get; set; } + /// + /// Laptop client sharing key + /// + public string directPresentationSharingKey { get; set; } + public eDisplayState dispState + { + get + { + return _dispState; + } + set + { + if (value != _dispState) + { + _dispState = value; + NotifyPropertyChanged("dispState"); + } + } + } + + public bool isAirHostClientConnected + { + get { return _isAirHostClientConnected; } + set + { + if (value != _isAirHostClientConnected) + { + _isAirHostClientConnected = value; + NotifyPropertyChanged("isAirHostClientConnected"); + } + } + } + + public bool isBlackMagicConnected + { + get { return _isBlackMagicConnected; } + set + { + if (value != _isBlackMagicConnected) + { + _isBlackMagicConnected = value; + NotifyPropertyChanged("isBlackMagicConnected"); + } + } + } + public bool isBlackMagicDataAvailable { get; set; } + + public bool isDirectPresentationConnected + { + get { return _isDirectPresentationConnected; } + set + { + if (value != _isDirectPresentationConnected) + { + _isDirectPresentationConnected = value; + NotifyPropertyChanged("isDirectPresentationConnected"); + } + } + } + + public bool isSharingBlackMagic + { + get { return _isSharingBlackMagic; } + set + { + if (value != _isSharingBlackMagic) + { + _isSharingBlackMagic = value; + NotifyPropertyChanged("isSharingBlackMagic"); + } + } + } + + /// + /// IOS Airplay code + /// + public string password + { + get + { + return _password; + } + set + { + if (value != _password) + { + _password = value; + NotifyPropertyChanged("password"); + } + } + } + public string serverName { get; set; } + public string wifiName { get; set; } + } + + public class NumberOfScreens : NotifiableObject + { + private int _numOfScreens; + + [JsonProperty("NumberOfCECScreens")] + public int NumOfCECScreens { get; set; } + [JsonProperty("NumberOfScreens")] + public int NumOfScreens + { + get + { + return _numOfScreens; + } + set + { + if (value != _numOfScreens) + { + _numOfScreens = value; + NotifyPropertyChanged("NumberOfScreens"); + } + } + } + } + + /// + /// AudioInputLine/AudioOutputLine/VideoCameraLine list item + /// + public class AudioVideoInputOutputLineItem + { + public string Alias { get; set; } + public string Name { get; set; } + public bool Selected { get; set; } + public bool combinedDevice { get; set; } + public string id { get; set; } + public bool manuallySelected { get; set; } + public int numberOfCombinedDevices { get; set; } + public int ptzComId { get; set; } + } + + public class Video + { + public bool Optimizable { get; set; } + } + + public class CameraShare : NotifiableObject + { + private bool _canControlCamera; + private bool _isSharing; + + [JsonProperty("can_Control_Camera")] + public bool CanControlCamera + { + get + { + return _canControlCamera; + } + set + { + if (value != _canControlCamera) + { + _canControlCamera = value; + NotifyPropertyChanged("CanControlCamera"); + } + } + } + public string id { get; set; } + public bool is_Mirrored { get; set; } + [JsonProperty("is_Sharing")] + public bool IsSharing + { + get + { + return _isSharing; + } + set + { + if (value != _isSharing) + { + _isSharing = value; + NotifyPropertyChanged("IsSharing"); + } + } + } + public int pan_Tilt_Speed { get; set; } + + } + + public class Layout : NotifiableObject + { + // backer variables + private bool _can_Switch_Speaker_View; + private bool _can_Switch_Wall_View; + private bool _can_Switch_Strip_View; + private bool _can_Switch_Share_On_All_Screens; + private bool _can_Switch_Floating_Share_Content; + private bool _is_In_First_Page; + private bool _is_In_Last_Page; + private string _video_type; + + + public bool can_Adjust_Floating_Video { get; set; } + + + public bool can_Switch_Floating_Share_Content + { + get + { + return _can_Switch_Floating_Share_Content; + } + set + { + if (value != _can_Switch_Floating_Share_Content) + { + _can_Switch_Floating_Share_Content = value; + NotifyPropertyChanged("can_Switch_Floating_Share_Content"); + } + } + } + + + /// + /// [on/off] // Set to On if it is possible to invoke zConfiguration Call Layout Style: ShareAll, to switch to the ShareAll mode, where the content sharing is shown full screen on all monitors. + /// + [JsonProperty("can_Switch_Share_On_All_Screens")] + public bool can_Switch_Share_On_All_Screens + { + get + { + return _can_Switch_Share_On_All_Screens; + } + set + { + if (value != _can_Switch_Share_On_All_Screens) + { + _can_Switch_Share_On_All_Screens = value; + NotifyPropertyChanged("can_Switch_Share_On_All_Screens"); + } + } + } + + /// + /// [on/off] // Set to On if it is possible to switch to Speaker view by invoking zConfiguration Call Layout Style: Speaker. The active speaker is shown full screen, and other video streams, like self-view, are shown in thumbnails. + /// + [JsonProperty("can_Switch_Speaker_View")] + public bool can_Switch_Speaker_View + { + get + { + return _can_Switch_Speaker_View; + } + set + { + if (value != _can_Switch_Speaker_View) + { + _can_Switch_Speaker_View = value; + NotifyPropertyChanged("can_Switch_Speaker_View"); + } + } + } + + /// + /// [on/off] On if it is possible to invoke zConfiguration Call Layout Style: Gallery, to switch to the Gallery mode, showing video participants in tiled windows: The Zoom Room shows up to a 5x5 array of tiled windows per page. + /// + [JsonProperty("can_Switch_Wall_View")] + public bool can_Switch_Wall_View + { + get + { + return _can_Switch_Wall_View; + } + set + { + if (value != _can_Switch_Wall_View) + { + _can_Switch_Wall_View = value; + NotifyPropertyChanged("can_Switch_Wall_View"); + } + } + } + + [JsonProperty("can_Switch_Strip_View")] + public bool can_Switch_Strip_View + { + get + { + return _can_Switch_Strip_View; + } + set + { + if (value != _can_Switch_Strip_View) + { + _can_Switch_Strip_View = value; + NotifyPropertyChanged("can_Switch_Strip_View"); + } + } + } + + [JsonProperty("is_In_First_Page")] + public bool is_In_First_Page + { + get + { + return _is_In_First_Page; + } + set + { + if (value != _is_In_First_Page) + { + _is_In_First_Page = value; + NotifyPropertyChanged("is_In_First_Page"); + } + } + } + + [JsonProperty("is_In_Last_Page")] + public bool is_In_Last_Page + { + get + { + return _is_In_Last_Page; + } + set + { + if (value != _is_In_Last_Page) + { + _is_In_Last_Page = value; + NotifyPropertyChanged("is_In_Last_Page"); + } + } + } + + public bool is_supported { get; set; } + public int video_Count_In_Current_Page { get; set; } + + /// + /// [Gallery | Strip] Indicates which mode applies: Strip or Gallery. + /// + [JsonProperty("video_type")] + public string video_type + { + get + { + return _video_type; + } + set + { + if (value != _video_type) + { + _video_type = value; + NotifyPropertyChanged("video_type"); + } + } + } + } + + public class CallRecordInfo : NotifiableObject + { + private bool _meetingIsBeingRecorded; + private bool _canRecord; + private bool _emailRequired; + + public bool amIRecording { get; set; } + + public bool canRecord + { + get + { + return _canRecord; + } + set + { + if (value != _canRecord) + { + _canRecord = value; + NotifyPropertyChanged("canRecord"); + } + } + } + + public bool emailRequired + { + get + { + return _emailRequired; + } + set + { + if (value != _emailRequired) + { + _emailRequired = value; + NotifyPropertyChanged("emailRequired"); + } + } + } + + public bool meetingIsBeingRecorded + { + get + { + return _meetingIsBeingRecorded; + } + set + { + //Debug.Console(2, "************************************setting value of meetingIsBeingRecorded to: {0}", value); + if (value != _meetingIsBeingRecorded) + { + _meetingIsBeingRecorded = value; + //Debug.Console(2, "********************************set value of meetingIsBeingRecorded to: {0}", _meetingIsBeingRecorded); + NotifyPropertyChanged("meetingIsBeingRecorded"); + } + } + } + + /// + /// Indicates if recording is allowed (when meeting capable and and email is not required to be entered by the user) + /// + public bool AllowRecord + { + get + { + return canRecord && !emailRequired; + } + } + + public CallRecordInfo() + { + Debug.Console(2, Debug.ErrorLogLevel.Notice, "********************************************* CallRecordInfo() ******************************************"); + } + } + } + + /// + /// zEvent Class Structure + /// + public class zEvent + { + public class StartLocalPresentMeeting + { + public bool Success { get; set; } + } + public class NeedWaitForHost + { + public bool Wait { get; set; } + } + + public class IncomingCallIndication + { + public string callerJID { get; set; } + public string calleeJID { get; set; } + public string meetingID { get; set; } + public string password { get; set; } + public string meetingOption { get; set; } + public long MeetingNumber { get; set; } + public string callerName { get; set; } + public string avatarURL { get; set; } + public int lifeTime { get; set; } + public bool accepted { get; set; } + } + + public class CallConnectError + { + public int error_code { get; set; } + public string error_message { get; set; } + } + + public class CallDisconnect + { + public bool Successful + { + get + { + return success == "on"; + } + } + + public string success { get; set; } + } + + public class Layout + { + public bool Sharethumb { get; set; } + } + + public class Call + { + public Layout Layout { get; set; } + } + + public class Client + { + public Call Call { get; set; } + } + + public enum eSharingState + { + None, + Connecting, + Sending, + Receiving, + Send_Receiving + } + + public class SharingState : NotifiableObject + { + private bool _paused; + private eSharingState _state; + + public bool IsSharing { get; private set; } + + [JsonProperty("paused")] + public bool Paused + { + get + { + return _paused; + } + set + { + if (value != _paused) + { + _paused = value; + NotifyPropertyChanged("Paused"); + } + } + } + [JsonProperty("state")] + public eSharingState State + { + get + { + return _state; + } + set + { + if (value != _state) + { + _state = value; + IsSharing = _state == eSharingState.Sending; + NotifyPropertyChanged("State"); + } + } + } + } + + public class PinStatusOfScreenNotification + { + + + [JsonProperty("can_be_pinned")] + public bool CanBePinned { get; set; } + [JsonProperty("can_pin_share")] + public bool CanPinShare { get; set; } + [JsonProperty("pinned_share_source_id")] + public int PinnedShareSourceId { get; set; } + [JsonProperty("pinned_user_id")] + public int PinnedUserId { get; set; } + [JsonProperty("screen_index")] + public int ScreenIndex { get; set; } + [JsonProperty("screen_layout")] + public int ScreenLayout { get; set; } + [JsonProperty("share_source_type")] + public int ShareSourceType { get; set; } + [JsonProperty("why_cannot_pin_share")] + public string WhyCannotPinShare { get; set; } + } + + public class PhoneCallStatus : NotifiableObject + { + private bool _isIncomingCall; + private string _peerDisplayName; + private string _peerNumber; + + private bool _offHook; + + public string CallId { get; set; } + public bool IsIncomingCall + { + get { return _isIncomingCall; } + set + { + if (value == _isIncomingCall) return; + + _isIncomingCall = value; + NotifyPropertyChanged("IsIncomingCall"); + } + } + + public string PeerDisplayName + { + get { return _peerDisplayName; } + set + { + if (value == _peerDisplayName) return; + _peerDisplayName = value; + NotifyPropertyChanged("PeerDisplayName"); + } + } + + public string PeerNumber + { + get { return _peerNumber; } + set + { + if (value == _peerNumber) return; + + _peerNumber = value; + NotifyPropertyChanged("PeerNumber"); + } + } + + public string PeerUri { get; set; } + + private ePhoneCallStatus _status; + public ePhoneCallStatus Status + { + get { return _status; } + set + { + _status = value; + OffHook = _status == ePhoneCallStatus.PhoneCallStatus_Accepted || + _status == ePhoneCallStatus.PhoneCallStatus_InCall || + _status == ePhoneCallStatus.PhoneCallStatus_Init || + _status == ePhoneCallStatus.PhoneCallStatus_Ringing; + } + } + + public bool OffHook + { + get { return _offHook; } + set + { + if (value == _offHook) return; + + _offHook = value; + NotifyPropertyChanged("OffHook"); + } + } + } + + public enum ePhoneCallStatus + { + PhoneCallStatus_Ringing, + PhoneCallStatus_Terminated, + PhoneCallStatus_Accepted, + PhoneCallStatus_InCall, + PhoneCallStatus_Init, + } + + public class MeetingNeedsPassword + { + [JsonProperty("needsPassword")] + public bool NeedsPassword { get; set; } + + [JsonProperty("wrongAndRetry")] + public bool WrongAndRetry { get; set; } + } + } + + /// + /// zConfiguration class structure + /// + public class zConfiguration + { + public class Sharing + { + [JsonProperty("optimize_video_sharing")] + public bool OptimizeVideoSharing { get; set; } + } + + public class Camera : NotifiableObject + { + private bool _mute; + + public bool Mute + { + get { return _mute; } + set + { + Debug.Console(1, "Camera Mute response received: {0}", value); + + if (value == _mute) return; + + _mute = value; + NotifyPropertyChanged("Mute"); + } + } + } + + public class Microphone : NotifiableObject + { + private bool _mute; + + public bool Mute + { + get + { + return _mute; + } + set + { + if (value != _mute) + { + _mute = value; + NotifyPropertyChanged("Mute"); + } + } + } + } + + [Flags] + public enum eLayoutStyle + { + None = 0, + Gallery = 1, + Speaker = 2, + Strip = 4, + ShareAll = 8, + } + + public enum eLayoutSize + { + Off, + Size1, + Size2, + Size3, + Strip + } + + public enum eLayoutPosition + { + Center, + Up, + Right, + UpRight, + Down, + DownRight, + Left, + UpLeft, + DownLeft + } + + public class Layout : NotifiableObject + { + private bool _shareThumb; + private eLayoutStyle _style; + private eLayoutSize _size; + private eLayoutPosition _position; + + public bool ShareThumb + { + get { return _shareThumb; } + set + { + if (value != _shareThumb) + { + _shareThumb = value; + NotifyPropertyChanged("ShareThumb"); + } + } + } + + public eLayoutStyle Style + { + get { return _style; } + set + { + if (value != _style) + { + _style = value; + NotifyPropertyChanged("Style"); + } + } + } + + public eLayoutSize Size + { + get { return _size; } + set + { + if (value != _size) + { + _size = value; + NotifyPropertyChanged("Size"); + } + } + } + + public eLayoutPosition Position + { + get { return _position; } + set + { + if (value != _position) + { + _position = value; + NotifyPropertyChanged("Position"); + } + } + } + } + + public class Lock : NotifiableObject + { + private bool _enable; + + public bool Enable + { + get + { + return _enable; + } + set + { + if (value != _enable) + { + _enable = value; + NotifyPropertyChanged("Enable"); + } + } + } + } + + public class ClosedCaption + { + public bool Visible { get; set; } + public int FontSize { get; set; } + } + + public class MuteUserOnEntry + { + public bool Enable { get; set; } + } + + public class Call + { + public Sharing Sharing { get; set; } + public Camera Camera { get; set; } + public Microphone Microphone { get; set; } + public Layout Layout { get; set; } + public Lock Lock { get; set; } + public MuteUserOnEntry MuteUserOnEntry { get; set; } + public ClosedCaption ClosedCaption { get; set; } + + + public Call() + { + Sharing = new Sharing(); + Camera = new Camera(); + Microphone = new Microphone(); + Layout = new Layout(); + Lock = new Lock(); + MuteUserOnEntry = new MuteUserOnEntry(); + ClosedCaption = new ClosedCaption(); + } + } + + public class Audio + { + public Input Input { get; set; } + public Output Output { get; set; } + + public Audio() + { + Input = new Input(); + Output = new Output(); + } + } + + public class Input : Output + { + [JsonProperty("reduce_reverb")] + public bool ReduceReverb { get; set; } + } + + public class Output : NotifiableObject + { + private int _volume; + + [JsonProperty("volume")] + public int Volume + { + get + { + return _volume; + } + set + { + if (value != _volume) + { + _volume = value; + NotifyPropertyChanged("Volume"); + } + } + } + [JsonProperty("selectedId")] + public string SelectedId { get; set; } + [JsonProperty("is_sap_disabled")] + public bool IsSapDisabled { get; set; } + } + + public class Video : NotifiableObject + { + private bool _hideConfSelfVideo; + + [JsonProperty("hide_conf_self_video")] + public bool HideConfSelfVideo + { + get + { + return _hideConfSelfVideo; + } + set + { + //if (value != _hideConfSelfVideo) + //{ + _hideConfSelfVideo = value; + NotifyPropertyChanged("HideConfSelfVideo"); + //} + } + } + + public VideoCamera Camera { get; set; } + + public Video() + { + Camera = new VideoCamera(); + } + } + + public class VideoCamera : NotifiableObject + { + private string _selectedId; + + [JsonProperty("selectedId")] + public string SelectedId + { + get + { + return _selectedId; + } + set + { + if (value != _selectedId) + { + _selectedId = value; + NotifyPropertyChanged("SelectedId"); + } + } + + } + public bool Mirror { get; set; } + } + + public class Client + { + public string appVersion { get; set; } + public string deviceSystem { get; set; } + + // This doesn't belong here, but there's a bug in the object structure of Zoom Room 5.6.3 that puts it here + public zConfiguration.Call Call { get; set; } + + public Client() + { + Call = new zConfiguration.Call(); + } + } + + } + + /// + /// zCommand class structure + /// + public class zCommand + { + public class BookingsListResult + { + [JsonProperty("accessRole")] + public string AccessRole { get; set; } + [JsonProperty("calendarChangeKey")] + public string CalendarChangeKey { get; set; } + [JsonProperty("calendarID")] + public string CalendarId { get; set; } + [JsonProperty("checkIn")] + public bool CheckIn { get; set; } + [JsonProperty("creatorEmail")] + public string CreatorEmail { get; set; } + [JsonProperty("creatorName")] + public string CreatorName { get; set; } + [JsonProperty("endTime")] + public DateTime EndTime { get; set; } + [JsonProperty("hostName")] + public string HostName { get; set; } + [JsonProperty("isInstantMeeting")] + public bool IsInstantMeeting { get; set; } + [JsonProperty("isPrivate")] + public bool IsPrivate { get; set; } + [JsonProperty("location")] + public string Location { get; set; } + [JsonProperty("meetingName")] + public string MeetingName { get; set; } + [JsonProperty("meetingNumber")] + public string MeetingNumber { get; set; } + [JsonProperty("scheduledFrom")] + public string ScheduledFrom { get; set; } + [JsonProperty("startTime")] + public DateTime StartTime { get; set; } + [JsonProperty("third_party")] + public ThirdParty ThirdParty { get; set; } + } + + public static List GetGenericMeetingsFromBookingResult(List bookings, + int minutesBeforeMeetingStart) + { + var rv = GetGenericMeetingsFromBookingResult(bookings); + + foreach (var meeting in rv) + { + meeting.MinutesBeforeMeeting = minutesBeforeMeetingStart; + } + + return rv; + } + /// + /// Extracts the necessary meeting values from the Zoom bookings response and converts them to the generic class + /// + /// + /// + public static List GetGenericMeetingsFromBookingResult(List bookings) + { + var meetings = new List(); + + if (Debug.Level > 0) + { + Debug.Console(1, "Meetings List:\n"); + } + + foreach (var b in bookings) + { + var meeting = new Meeting(); + + if (b.MeetingNumber != null) + meeting.Id = b.MeetingNumber; + if (b.CreatorName != null) + meeting.Organizer = b.CreatorName; + if (b.MeetingName != null) + meeting.Title = b.MeetingName; + //if (b.Agenda != null) + // meeting.Agenda = b.Agenda.Value; + if (b.StartTime != null) + meeting.StartTime = b.StartTime; + if (b.EndTime != null) + meeting.EndTime = b.EndTime; + + meeting.Privacy = b.IsPrivate ? eMeetingPrivacy.Private : eMeetingPrivacy.Public; + + meeting.Dialable = meeting.Id != "0"; + + // No meeting.Calls data exists for Zoom Rooms. Leaving out for now. + var now = DateTime.Now; + if (meeting.StartTime < now && meeting.EndTime < now) + { + Debug.Console(1, "Skipping meeting {0}. Meeting is in the past.", meeting.Title); + continue; + } + + meetings.Add(meeting); + + if (Debug.Level > 0) + { + Debug.Console(1, "Title: {0}, ID: {1}, Organizer: {2}", meeting.Title, meeting.Id, meeting.Organizer); + Debug.Console(1, " Start Time: {0}, End Time: {1}, Duration: {2}", meeting.StartTime, meeting.EndTime, meeting.Duration); + Debug.Console(1, " Joinable: {0}\n", meeting.Joinable); + } + } + + meetings.OrderBy(m => m.StartTime); + + return meetings; + } + + public class HandStatus + { + // example return of the "hand_status" object + // !!!! Note the properties contain ': ' within the property name !!! + //"hand_status": { + // "is_raise_hand: ": false, + // "is_valid: ": "on", + // "time_stamp: ": "11825083" + //}, + [JsonProperty("is_raise_hand: ")] + public bool IsRaiseHand { get; set; } + [JsonProperty("is_valid: ")] + public string IsValid { get; set; } + [JsonProperty("time_stamp: ")] + public string TimeStamp { get; set; } + /// + /// Retuns a boolean value if the participant hand state is raised and is valid (both need to be true) + /// + public bool HandIsRaisedAndValid + { + get { return IsValid != null && IsValid == "on" && IsRaiseHand; } + } + } + public class ListParticipant + { + [JsonProperty("audio_status state")] + public string AudioStatusState { get; set; } + [JsonProperty("audio_status type")] + public string AudioStatusType { get; set; } + [JsonProperty("avatar_url")] + public string AvatarUrl { get; set; } + [JsonProperty("camera_status am_i_controlling")] + public bool CameraStatusAmIControlling { get; set; } + [JsonProperty("camera_status can_i_request_control")] + public bool CameraStatusCanIRequestConrol { get; set; } + [JsonProperty("camera_status can_move_camera")] + public bool CameraStatusCanMoveCamera { get; set; } + [JsonProperty("camera_status can_switch_camera")] + public bool CameraStatusCanSwitchCamera { get; set; } + [JsonProperty("camera_status can_zoom_camera")] + public bool CameraStatusCanZoomCamera { get; set; } + [JsonProperty("can_edit_closed_caption")] + public bool CanEditClosedCaption { get; set; } + [JsonProperty("can_record")] + public bool CanRecord { get; set; } + [JsonProperty("event")] + public string Event { get; set; } + [JsonProperty("hand_status")] + public HandStatus HandStatus { get; set; } + [JsonProperty("isCohost")] + public bool IsCohost { get; set; } + [JsonProperty("is_client_support_closed_caption")] + public bool IsClientSupportClosedCaption { get; set; } + [JsonProperty("is_client_support_coHost")] + public bool IsClientSupportCoHost { get; set; } + [JsonProperty("is_host")] + public bool IsHost { get; set; } + [JsonProperty("is_myself")] + public bool IsMyself { get; set; } + [JsonProperty("is_recording")] + public bool IsRecording { get; set; } + [JsonProperty("is_video_can_mute_byHost")] + public bool IsVideoCanMuteByHost { get; set; } + [JsonProperty("is_video_can_unmute_byHost")] + public bool IsVideoCanUnmuteByHost { get; set; } + [JsonProperty("local_recording_disabled")] + public bool LocalRecordingDisabled { get; set; } + [JsonProperty("user_id")] + public int UserId { get; set; } + [JsonProperty("user_name")] + public string UserName { get; set; } + [JsonProperty("user_type")] + public string UserType { get; set; } + [JsonProperty("video_status has_source")] + public bool VideoStatusHasSource { get; set; } + [JsonProperty("video_status is_receiving")] + public bool VideoStatusIsReceiving { get; set; } + [JsonProperty("video_status is_sending")] + public bool VideoStatusIsSending { get; set; } + + public ListParticipant() + { + HandStatus = new HandStatus(); + } + + /// + /// Converts ZoomRoom pariticpant list response to an Essentials participant list + /// + /// + /// + public static List GetGenericParticipantListFromParticipantsResult( + List participants) + { + if (participants.Count == 0) + { + return new List(); + } + //return participants.Select(p => new Participant + // { + // UserId = p.UserId, + // Name = p.UserName, + // IsHost = p.IsHost, + // CanMuteVideo = p.IsVideoCanMuteByHost, + // CanUnmuteVideo = p.IsVideoCanUnmuteByHost, + // AudioMuteFb = p.AudioStatusState == "AUDIO_MUTED", + // VideoMuteFb = p.VideoStatusIsSending, + // HandIsRaisedFb = p.HandStatus.HandIsRaisedAndValid, + // }).ToList(); + + var sortedParticipants = SortParticipantListByHandStatus(participants); + return sortedParticipants.Select(p => new Participant + { + UserId = p.UserId, + Name = p.UserName, + IsHost = p.IsHost, + IsMyself = p.IsMyself, + CanMuteVideo = p.IsVideoCanMuteByHost, + CanUnmuteVideo = p.IsVideoCanUnmuteByHost, + AudioMuteFb = p.AudioStatusState == "AUDIO_MUTED", + VideoMuteFb = !p.VideoStatusIsSending, + HandIsRaisedFb = p.HandStatus.HandIsRaisedAndValid, + }).ToList(); + } + + /// + /// Will sort by hand-raise status and then alphabetically + /// + /// Zoom Room response list of participants + /// List + public static List SortParticipantListByHandStatus(List participants) + { + if (participants == null) + { + //Debug.Console(1, "SortParticiapntListByHandStatu(participants == null)"); + return null; + } + + // debug testing + //foreach (ListParticipant participant in participants) + //{ + // Debug.Console(1, "{0} | IsValid: {1} | IsRaiseHand: {2} | HandIsRaisedAndValid: {3}", + // participant.UserName, participant.HandStatus.IsValid, participant.HandStatus.IsRaiseHand.ToString(), participant.HandStatus.HandIsRaisedAndValid.ToString()); + //} + + List handRaisedParticipantsList = participants.Where(p => p.HandStatus.HandIsRaisedAndValid).ToList(); + + if (handRaisedParticipantsList != null) + { + IOrderedEnumerable orderByDescending = handRaisedParticipantsList.OrderByDescending(p => p.HandStatus.TimeStamp); + + //foreach (var participant in handRaisedParticipantsList) + // Debug.Console(1, "handRaisedParticipantList: {0} | {1}", participant.UserName, participant.UserId); + } + + List allOtherParticipantsList = participants.Where(p => !p.HandStatus.HandIsRaisedAndValid).ToList(); + + if (allOtherParticipantsList != null) + { + allOtherParticipantsList.OrderBy(p => p.UserName); + + //foreach (var participant in allOtherParticipantsList) + // Debug.Console(1, "allOtherParticipantsList: {0} | {1}", participant.UserName, participant.UserId); + } + + // merge the lists + List sortedList = handRaisedParticipantsList.Union(allOtherParticipantsList).ToList(); + + // return the sorted list + return sortedList; + } + + } + + public class CallinCountryList + { + public int code { get; set; } + public string display_number { get; set; } + public string id { get; set; } + public string name { get; set; } + public string number { get; set; } + } + + public class CalloutCountryList + { + public int code { get; set; } + public string display_number { get; set; } + public string id { get; set; } + public string name { get; set; } + public string number { get; set; } + } + + public class TollFreeCallinList + { + public int code { get; set; } + public string display_number { get; set; } + public string id { get; set; } + public string name { get; set; } + public string number { get; set; } + } + + public class Info + { + public List callin_country_list { get; set; } + public List callout_country_list { get; set; } + public List toll_free_callin_list { get; set; } + } + + public class ThirdParty + { + public string h323_address { get; set; } + public string meeting_number { get; set; } + public string service_provider { get; set; } + public string sip_address { get; set; } + } + + public class MeetingListItem + { + public string accessRole { get; set; } + public string calendarChangeKey { get; set; } + public string calendarID { get; set; } + public bool checkIn { get; set; } + public string creatorEmail { get; set; } + public string creatorName { get; set; } + public string endTime { get; set; } + public string hostName { get; set; } + public bool isInstantMeeting { get; set; } + public bool isPrivate { get; set; } + public string location { get; set; } + public string meetingName { get; set; } + public string meetingNumber { get; set; } + public string scheduledFrom { get; set; } + public string startTime { get; set; } + public ThirdParty third_party { get; set; } + + public MeetingListItem() + { + third_party = new ThirdParty(); + } + } + + public class InfoResult + { + public Info Info { get; set; } + public bool am_i_original_host { get; set; } + public string default_callin_country { get; set; } + public string dialIn { get; set; } + public string international_url { get; set; } + public string invite_email_content { get; set; } + public string invite_email_subject { get; set; } + public bool is_callin_country_list_available { get; set; } + public bool is_calling_room_system_enabled { get; set; } + public bool is_toll_free_callin_list_available { get; set; } + public bool is_view_only { get; set; } + public bool is_waiting_room { get; set; } + public bool is_webinar { get; set; } + public string meeting_id { get; set; } + public MeetingListItem meeting_list_item { get; set; } + public string meeting_password { get; set; } + public string meeting_type { get; set; } + public int my_userid { get; set; } + public int participant_id { get; set; } + public string real_meeting_id { get; set; } + public string schedule_option { get; set; } + public string schedule_option2 { get; set; } + public string support_callout_type { get; set; } + public string toll_free_number { get; set; } + public string user_type { get; set; } + + public InfoResult() + { + Info = new Info(); + meeting_list_item = new MeetingListItem(); + } + } + + public class Phonebook + { + public List Contacts { get; set; } + public int Limit { get; set; } + public int Offset { get; set; } + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoom.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoom.cs similarity index 96% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoom.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoom.cs index 1a70b2af..d342c9bf 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoom.cs +++ b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoom.cs @@ -1,3941 +1,3941 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.CrestronThread; -using Crestron.SimplSharpPro.DeviceSupport; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.Core.DeviceTypeInterfaces; -using PepperDash.Essentials.Core.Routing; -using PepperDash.Essentials.Core.Queues; -using PepperDash.Essentials.Devices.Common.Cameras; -using PepperDash.Essentials.Devices.Common.Codec; -using PepperDash.Essentials.Devices.Common.VideoCodec.Cisco; -using PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces; - -namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom -{ - public class ZoomRoom : VideoCodecBase, IHasCodecSelfView, IHasDirectoryHistoryStack, ICommunicationMonitor, - IRouting, - IHasScheduleAwareness, IHasCodecCameras, IHasParticipants, IHasCameraOff, IHasCameraMuteWithUnmuteReqeust, IHasCameraAutoMode, - IHasFarEndContentStatus, IHasSelfviewPosition, IHasPhoneDialing, IHasZoomRoomLayouts, IHasParticipantPinUnpin, - IHasParticipantAudioMute, IHasSelfviewSize, IPasswordPrompt, IHasStartMeeting, IHasMeetingInfo, IHasPresentationOnlyMeeting, - IHasMeetingLock, IHasMeetingRecordingWithPrompt, IZoomWirelessShareInstructions - { - public event EventHandler VideoUnmuteRequested; - - private const long MeetingRefreshTimer = 60000; - public uint DefaultMeetingDurationMin { get; private set; } - - /// - /// CR LF CR LF Delimits an echoed response to a command - /// - private const string EchoDelimiter = "\x0D\x0A\x0D\x0A"; - - private const string SendDelimiter = "\x0D"; - - /// - /// CR LF } CR LF Delimits a JSON response - /// - private const string JsonDelimiter = "\x0D\x0A\x7D\x0D\x0A"; - - private string[] Delimiters = new string[] { EchoDelimiter, JsonDelimiter, "OK\x0D\x0A", "end\x0D\x0A" }; - private readonly GenericQueue _receiveQueue; - - private readonly ZoomRoomSyncState _syncState; - public bool CommDebuggingIsOn; - private CodecDirectory _currentDirectoryResult; - private uint _jsonCurlyBraceCounter; - private bool _jsonFeedbackMessageIsIncoming; - private StringBuilder _jsonMessage; - private int _previousVolumeLevel; - private CameraBase _selectedCamera; - private string _lastDialedMeetingNumber; - - private CTimer contactsDebounceTimer; - - - private readonly ZoomRoomPropertiesConfig _props; - - private bool _meetingPasswordRequired; - - private bool _waitingForUserToAcceptOrRejectIncomingCall; - - public void Poll(string pollString) - { - if(_meetingPasswordRequired || _waitingForUserToAcceptOrRejectIncomingCall) return; - - SendText(string.Format("{0}{1}", pollString, SendDelimiter)); - } - - public ZoomRoom(DeviceConfig config, IBasicCommunication comm) - : base(config) - { - DefaultMeetingDurationMin = 30; - - _props = JsonConvert.DeserializeObject(config.Properties.ToString()); - - _receiveQueue = new GenericQueue(Key + "-rxQueue", Thread.eThreadPriority.MediumPriority, 2048); - - Communication = comm; - - if (_props.CommunicationMonitorProperties != null) - { - CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, _props.CommunicationMonitorProperties.PollInterval, _props.CommunicationMonitorProperties.TimeToWarning, _props.CommunicationMonitorProperties.TimeToError, - () => Poll(_props.CommunicationMonitorProperties.PollString)); - } - else - { - CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 30000, 120000, 300000, () => Poll("zStatus SystemUnit")); - } - - DeviceManager.AddDevice(CommunicationMonitor); - - Status = new ZoomRoomStatus(); - - Configuration = new ZoomRoomConfiguration(); - - CodecInfo = new ZoomRoomInfo(Status, Configuration); - - _syncState = new ZoomRoomSyncState(Key + "--Sync", this); - - _syncState.InitialSyncCompleted += SyncState_InitialSyncCompleted; - - _syncState.FirstJsonResponseReceived += (o, a) => SetUpSyncQueries(); - - PhonebookSyncState = new CodecPhonebookSyncState(Key + "--PhonebookSync"); - - PhonebookSyncState.InitialSyncCompleted += (o, a) => ResubscribeForAddedContacts(); - - PortGather = new CommunicationGather(Communication, Delimiters) {IncludeDelimiter = true}; - PortGather.LineReceived += Port_LineReceived; - - CodecOsdIn = new RoutingInputPort(RoutingPortNames.CodecOsd, - eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, new Action(StopSharing), this); - - Output1 = new RoutingOutputPort(RoutingPortNames.HdmiOut1, - eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null, this); - - Output2 = new RoutingOutputPort(RoutingPortNames.HdmiOut2, - eRoutingSignalType.Video, - eRoutingPortConnectionType.DisplayPort, null, this); - - Output3 = new RoutingOutputPort(RoutingPortNames.HdmiOut3, - eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null, this); - - SelfviewIsOnFeedback = new BoolFeedback(SelfViewIsOnFeedbackFunc); - - CameraIsOffFeedback = new BoolFeedback(CameraIsOffFeedbackFunc); - - CameraIsMutedFeedback = CameraIsOffFeedback; - - CameraAutoModeIsOnFeedback = new BoolFeedback(CameraAutoModeIsOnFeedbackFunc); - - CodecSchedule = new CodecScheduleAwareness(MeetingRefreshTimer); - - if (_props.MinutesBeforeMeetingStart > 0) - { - CodecSchedule.MeetingWarningMinutes = _props.MinutesBeforeMeetingStart; - } - - ReceivingContent = new BoolFeedback(FarEndIsSharingContentFeedbackFunc); - - SelfviewPipPositionFeedback = new StringFeedback(SelfviewPipPositionFeedbackFunc); - - // TODO: #714 [ ] SelfviewPipSizeFeedback - SelfviewPipSizeFeedback = new StringFeedback(SelfviewPipSizeFeedbackFunc); - - SetUpFeedbackActions(); - - Cameras = new List(); - - SetUpDirectory(); - - Participants = new CodecParticipants(); - - SupportsCameraOff = true; // Always allow turning off the camera for zoom calls? - SupportsCameraAutoMode = _props.SupportsCameraAutoMode; - - PhoneOffHookFeedback = new BoolFeedback(PhoneOffHookFeedbackFunc); - CallerIdNameFeedback = new StringFeedback(CallerIdNameFeedbackFunc); - CallerIdNumberFeedback = new StringFeedback(CallerIdNumberFeedbackFunc); - - LocalLayoutFeedback = new StringFeedback(LocalLayoutFeedbackFunc); - - LayoutViewIsOnFirstPageFeedback = new BoolFeedback(LayoutViewIsOnFirstPageFeedbackFunc); - LayoutViewIsOnLastPageFeedback = new BoolFeedback(LayoutViewIsOnLastPageFeedbackFunc); - CanSwapContentWithThumbnailFeedback = new BoolFeedback(CanSwapContentWithThumbnailFeedbackFunc); - ContentSwappedWithThumbnailFeedback = new BoolFeedback(ContentSwappedWithThumbnailFeedbackFunc); - - NumberOfScreensFeedback = new IntFeedback(NumberOfScreensFeedbackFunc); - - MeetingIsLockedFeedback = new BoolFeedback(() => Configuration.Call.Lock.Enable ); - - MeetingIsRecordingFeedback = new BoolFeedback(() => Status.Call.CallRecordInfo.meetingIsBeingRecorded ); - - RecordConsentPromptIsVisible = new BoolFeedback(() => _recordConsentPromptIsVisible); - - SetUpRouting(); - } - - public CommunicationGather PortGather { get; private set; } - - public ZoomRoomStatus Status { get; private set; } - - public ZoomRoomConfiguration Configuration { get; private set; } - - //CTimer LoginMessageReceivedTimer; - //CTimer RetryConnectionTimer; - - /// - /// Gets and returns the scaled volume of the codec - /// - protected override Func VolumeLevelFeedbackFunc - { - get - { - return () => - { - var scaledVol = CrestronEnvironment.ScaleWithLimits(Configuration.Audio.Output.Volume, 100, 0, 65535, 0); - - if (Configuration.Audio.Output.Volume != 0) - { - Debug.Console(2, this, "Storing previous volume level as: {0}, scaled: {1}", Configuration.Audio.Output.Volume, - scaledVol); - _previousVolumeLevel = scaledVol; // Store the previous level for recall - } - - return scaledVol; - }; - } - } - - protected override Func PrivacyModeIsOnFeedbackFunc - { - get - { - return () => - { - //Debug.Console(2, this, "PrivacyModeIsOnFeedbackFunc. IsInCall: {0} muteState: {1}", IsInCall, Configuration.Call.Microphone.Mute); - if (IsInCall) - { - //Debug.Console(2, this, "reporting muteState: ", Configuration.Call.Microphone.Mute); - return Configuration.Call.Microphone.Mute; - } - else - { - //Debug.Console(2, this, "muteState: true", IsInCall); - return false; - } - }; - } - } - - protected override Func StandbyIsOnFeedbackFunc - { - get { return () => false; } - } - - protected override Func SharingSourceFeedbackFunc - { - get - { - return () => - { - if (Status.Sharing.isAirHostClientConnected) - return "Airplay"; - else if (Status.Sharing.isDirectPresentationConnected || Status.Sharing.isBlackMagicConnected) - return "Laptop"; - else return "None"; - - }; - } - } - - protected override Func SharingContentIsOnFeedbackFunc - { - get { return () => Status.Sharing.isAirHostClientConnected || Status.Sharing.isDirectPresentationConnected || Status.Sharing.isSharingBlackMagic; } - } - - protected Func FarEndIsSharingContentFeedbackFunc - { - get { return () => Status.Call.Sharing.State == zEvent.eSharingState.Receiving; } - } - - protected override Func MuteFeedbackFunc - { - get { return () => Configuration.Audio.Output.Volume == 0; } - } - - //protected Func RoomIsOccupiedFeedbackFunc - //{ - // get - // { - // return () => false; - // } - //} - - //protected Func PeopleCountFeedbackFunc - //{ - // get - // { - // return () => 0; - // } - //} - - protected Func SelfViewIsOnFeedbackFunc - { - get { return () => !Configuration.Video.HideConfSelfVideo; } - } - - protected Func CameraIsOffFeedbackFunc - { - get { return () => Configuration.Call.Camera.Mute; } - } - - protected Func CameraAutoModeIsOnFeedbackFunc - { - get { return () => false; } - } - - protected Func SelfviewPipPositionFeedbackFunc - { - get - { - return - () => - _currentSelfviewPipPosition != null - ? _currentSelfviewPipPosition.Command ?? "Unknown" - : "Unknown"; - } - } - - // TODO: #714 [ ] SelfviewPipSizeFeedbackFunc - protected Func SelfviewPipSizeFeedbackFunc - { - get - { - return - () => - _currentSelfviewPipSize != null - ? _currentSelfviewPipSize.Command ?? "Unknown" - : "Unknown"; - } - } - - protected Func LocalLayoutIsProminentFeedbackFunc - { - get { return () => false; } - } - - - public RoutingInputPort CodecOsdIn { get; private set; } - public RoutingOutputPort Output1 { get; private set; } - public RoutingOutputPort Output2 { get; private set; } - public RoutingOutputPort Output3 { get; private set; } - - #region ICommunicationMonitor Members - - public StatusMonitorBase CommunicationMonitor { get; private set; } - - #endregion - - #region IHasCodecCameras Members - - public event EventHandler CameraSelected; - - public List Cameras { get; private set; } - - public CameraBase SelectedCamera - { - get { return _selectedCamera; } - private set - { - _selectedCamera = value; - SelectedCameraFeedback.FireUpdate(); - ControllingFarEndCameraFeedback.FireUpdate(); - - var handler = CameraSelected; - if (handler != null) - { - handler(this, new CameraSelectedEventArgs(_selectedCamera)); - } - } - } - - - public StringFeedback SelectedCameraFeedback { get; private set; } - - public void SelectCamera(string key) - { - if (CameraIsMutedFeedback.BoolValue) - { - CameraMuteOff(); - } - - SendText(string.Format("zConfiguration Video Camera selectedId: {0}", key)); - } - - public CameraBase FarEndCamera { get; private set; } - - public BoolFeedback ControllingFarEndCameraFeedback { get; private set; } - - #endregion - - #region IHasCodecSelfView Members - - public BoolFeedback SelfviewIsOnFeedback { get; private set; } - - public void GetSelfViewMode() - { - SendText("zConfiguration Video hide_conf_self_video"); - } - - public void SelfViewModeOn() - { - SendText("zConfiguration Video hide_conf_self_video: off"); - } - - public void SelfViewModeOff() - { - SendText("zConfiguration Video hide_conf_self_video: on"); - } - - public void SelfViewModeToggle() - { - if (SelfviewIsOnFeedback.BoolValue) - { - SelfViewModeOff(); - } - else - { - SelfViewModeOn(); - } - } - - #endregion - - #region IHasDirectoryHistoryStack Members - - public event EventHandler DirectoryResultReturned; - public CodecDirectory DirectoryRoot { get; private set; } - - public CodecDirectory CurrentDirectoryResult - { - get { return _currentDirectoryResult; } - private set - { - _currentDirectoryResult = value; - - Debug.Console(2, this, "CurrentDirectoryResult Updated. ResultsFolderId: {0} Contact Count: {1}", - _currentDirectoryResult.ResultsFolderId, _currentDirectoryResult.CurrentDirectoryResults.Count); - - OnDirectoryResultReturned(_currentDirectoryResult); - } - } - - public CodecPhonebookSyncState PhonebookSyncState { get; private set; } - - public void SearchDirectory(string searchString) - { - var directoryResults = new CodecDirectory(); - - directoryResults.AddContactsToDirectory( - DirectoryRoot.CurrentDirectoryResults.FindAll( - c => c.Name.IndexOf(searchString, 0, StringComparison.OrdinalIgnoreCase) > -1)); - - DirectoryBrowseHistoryStack.Clear(); - CurrentDirectoryResult = directoryResults; - } - - public void GetDirectoryFolderContents(string folderId) - { - var directoryResults = new CodecDirectory {ResultsFolderId = folderId}; - - directoryResults.AddContactsToDirectory( - DirectoryRoot.CurrentDirectoryResults.FindAll(c => c.ParentFolderId.Equals(folderId))); - - DirectoryBrowseHistoryStack.Push(_currentDirectoryResult); - - CurrentDirectoryResult = directoryResults; - } - - public void SetCurrentDirectoryToRoot() - { - DirectoryBrowseHistoryStack.Clear(); - - CurrentDirectoryResult = DirectoryRoot; - } - - public void GetDirectoryParentFolderContents() - { - if (DirectoryBrowseHistoryStack.Count == 0) - { - return; - } - - var currentDirectory = DirectoryBrowseHistoryStack.Pop(); - - CurrentDirectoryResult = currentDirectory; - } - - public BoolFeedback CurrentDirectoryResultIsNotDirectoryRoot { get; private set; } - - public List DirectoryBrowseHistory { get; private set; } - - public Stack DirectoryBrowseHistoryStack { get; private set; } - - #endregion - - #region IHasScheduleAwareness Members - - public CodecScheduleAwareness CodecSchedule { get; private set; } - - public void GetSchedule() - { - GetBookings(); - } - - #endregion - - #region IRouting Members - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - ExecuteSwitch(inputSelector); - } - - #endregion - - private void SyncState_InitialSyncCompleted(object sender, EventArgs e) - { - SetIsReady(); - } - - /// - /// Handles subscriptions to Status.Call and sub objects. Needs to be called whenever Status.Call is constructed - /// - private void SetUpCallFeedbackActions() - { - Status.Sharing.PropertyChanged -= HandleSharingStateUpdate; - Status.Sharing.PropertyChanged += HandleSharingStateUpdate; - - Status.Call.Sharing.PropertyChanged -= HandleSharingStateUpdate; - Status.Call.Sharing.PropertyChanged += HandleSharingStateUpdate; - - Status.Call.PropertyChanged -= HandleCallStateUpdate; - Status.Call.PropertyChanged += HandleCallStateUpdate; - - Status.Call.CallRecordInfo.PropertyChanged -= HandleCallRecordInfoStateUpdate; - Status.Call.CallRecordInfo.PropertyChanged += HandleCallRecordInfoStateUpdate; - } - - private void HandleCallRecordInfoStateUpdate(object sender, PropertyChangedEventArgs a) - { - if (a.PropertyName == "meetingIsBeingRecorded" || a.PropertyName == "emailRequired" || a.PropertyName == "canRecord") - { - MeetingIsRecordingFeedback.FireUpdate(); - - var meetingInfo = new MeetingInfo(MeetingInfo.Id, - MeetingInfo.Name, - MeetingInfo.Host, - MeetingInfo.Password, - GetSharingStatus(), - GetIsHostMyself(), - MeetingInfo.IsSharingMeeting, - MeetingInfo.WaitingForHost, - MeetingIsLockedFeedback.BoolValue, - MeetingIsRecordingFeedback.BoolValue, Status.Call.CallRecordInfo.AllowRecord); - MeetingInfo = meetingInfo; - } - } - - private void HandleCallStateUpdate(object sender, PropertyChangedEventArgs a) - { - switch (a.PropertyName) - { - case "Info": - { - Debug.Console(1, this, "Updating Call Status"); - UpdateCallStatus(); - break; - } - - case "Status": - { - UpdateCallStatus(); - break; - } - } - } - - private void HandleSharingStateUpdate(object sender, PropertyChangedEventArgs a) - { - //if (a.PropertyName != "State") - //{ - // return; - //} - - SharingContentIsOnFeedback.FireUpdate(); - ReceivingContent.FireUpdate(); - try - { - - // Update the share status of the meeting info - if (MeetingInfo == null) - { - MeetingInfo = new MeetingInfo("", "", "", "", GetSharingStatus(), GetIsHostMyself(), true, false, MeetingIsLockedFeedback.BoolValue, MeetingIsRecordingFeedback.BoolValue, Status.Call.CallRecordInfo.AllowRecord); - return; - } - - var meetingInfo = new MeetingInfo(MeetingInfo.Id, MeetingInfo.Name, Participants.Host != null ? Participants.Host.Name : "None", - MeetingInfo.Password, GetSharingStatus(), GetIsHostMyself(), MeetingInfo.IsSharingMeeting, MeetingInfo.WaitingForHost, MeetingIsLockedFeedback.BoolValue, MeetingIsRecordingFeedback.BoolValue, Status.Call.CallRecordInfo.AllowRecord); - MeetingInfo = meetingInfo; - } - catch (Exception e) - { - Debug.Console(1, this, "Error processing state property update. {0}", e.Message); - Debug.Console(2, this, e.StackTrace); - MeetingInfo = new MeetingInfo("", "", "", "", "None", false, false, false, MeetingIsLockedFeedback.BoolValue, MeetingIsRecordingFeedback.BoolValue, false); - } - } - - /// - /// Subscribes to the PropertyChanged events on the state objects and fires the corresponding feedbacks. - /// - private void SetUpFeedbackActions() - { - // Set these up initially. - SetUpCallFeedbackActions(); - - Configuration.Audio.Output.PropertyChanged += (o, a) => - { - if (a.PropertyName == "Volume") - { - VolumeLevelFeedback.FireUpdate(); - MuteFeedback.FireUpdate(); - } - }; - - Configuration.Call.Microphone.PropertyChanged += (o, a) => - { - if (a.PropertyName == "Mute") - { - PrivacyModeIsOnFeedback.FireUpdate(); - } - }; - - Configuration.Video.PropertyChanged += (o, a) => - { - if (a.PropertyName == "HideConfSelfVideo") - { - SelfviewIsOnFeedback.FireUpdate(); - } - }; - Configuration.Video.Camera.PropertyChanged += (o, a) => - { - if (a.PropertyName == "SelectedId") - { - if (Cameras == null) - { - return; - } - - var camera = Cameras.FirstOrDefault(c => c.Key.IndexOf(Configuration.Video.Camera.SelectedId, StringComparison.OrdinalIgnoreCase) > -1); - if (camera != null) - { - Debug.Console(1, this, "Camera selected with key: '{0}'", camera.Key); - - SelectedCamera = camera; - - if (CameraIsMutedFeedback.BoolValue) - { - CameraMuteOff(); - } - } - else - { - Debug.Console(1, this, "No camera found with key: '{0}'", Configuration.Video.Camera.SelectedId); - } - } - }; - - Configuration.Call.Camera.PropertyChanged += (o, a) => - { - Debug.Console(1, this, "Configuration.Call.Camera.PropertyChanged: {0}", a.PropertyName); - - if (a.PropertyName != "Mute") return; - - CameraIsOffFeedback.FireUpdate(); - CameraAutoModeIsOnFeedback.FireUpdate(); - }; - - Configuration.Call.Layout.PropertyChanged += (o, a) => - { - switch (a.PropertyName) - { - case "Position": - { - ComputeSelfviewPipPositionStatus(); - - SelfviewPipPositionFeedback.FireUpdate(); - - break; - } - case "ShareThumb": - { - ContentSwappedWithThumbnailFeedback.FireUpdate(); - OnLayoutInfoChanged(); - break; - } - case "Style": - { - LocalLayoutFeedback.FireUpdate(); - OnLayoutInfoChanged(); - break; - } - case "Size": - { - // TODO: #714 [ ] SetupFeedbackActions >> Size - ComputeSelfviewPipSizeStatus(); - - SelfviewPipSizeFeedback.FireUpdate(); - - break; - } - } - }; - - Configuration.Call.Lock.PropertyChanged += (o, a) => - { - if (a.PropertyName == "Enable") - { - MeetingIsLockedFeedback.FireUpdate(); - MeetingInfo = new MeetingInfo - ( - MeetingInfo.Id, - MeetingInfo.Name, - MeetingInfo.Host, - MeetingInfo.Password, - GetSharingStatus(), - MeetingInfo.IsHost, - MeetingInfo.IsSharingMeeting, - MeetingInfo.WaitingForHost, - MeetingIsLockedFeedback.BoolValue, - MeetingIsRecordingFeedback.BoolValue, Status.Call.CallRecordInfo.AllowRecord - ); - } - }; - - // This is to deal with incorrect object structure coming back from the Zoom Room on v 5.6.3 - Configuration.Client.Call.Layout.PropertyChanged += (o, a) => - { - switch (a.PropertyName) - { - case "Position": - { - ComputeSelfviewPipPositionStatus(); - - SelfviewPipPositionFeedback.FireUpdate(); - - break; - } - case "ShareThumb": - { - ContentSwappedWithThumbnailFeedback.FireUpdate(); - OnLayoutInfoChanged(); - break; - } - case "Style": - { - LocalLayoutFeedback.FireUpdate(); - OnLayoutInfoChanged(); - break; - } - } - }; - - - Status.Sharing.PropertyChanged += (o, a) => - { - OnShareInfoChanged(Status.Sharing); - SharingSourceFeedback.FireUpdate(); - switch (a.PropertyName) - { - case "password": - break; - case "isSharingBlackMagic": - { - Debug.Console(2, this, "Updating sharing status: {0}", a.PropertyName); - - SharingContentIsOnFeedback.FireUpdate(); - if (MeetingInfo == null) - { - //Ignoring for now, as the CallInfo return will create the appropriate value - return; - } - // Update the share status of the meeting info - var meetingInfo = new MeetingInfo(MeetingInfo.Id, - MeetingInfo.Name, - MeetingInfo.Host, - MeetingInfo.Password, - GetSharingStatus(), - GetIsHostMyself(), - MeetingInfo.IsSharingMeeting, - MeetingInfo.WaitingForHost, - MeetingIsLockedFeedback.BoolValue, - MeetingIsRecordingFeedback.BoolValue, Status.Call.CallRecordInfo.AllowRecord); - MeetingInfo = meetingInfo; - break; - } - } - }; - - Status.PhoneCall.PropertyChanged += (o, a) => - { - switch (a.PropertyName) - { - case "IsIncomingCall": - Debug.Console(1, this, "Incoming Phone Call: {0}", Status.PhoneCall.IsIncomingCall); - break; - case "PeerDisplayName": - Debug.Console(1, this, "Peer Display Name: {0}", Status.PhoneCall.PeerDisplayName); - CallerIdNameFeedback.FireUpdate(); - break; - case "PeerNumber": - Debug.Console(1, this, "Peer Number: {0}", Status.PhoneCall.PeerNumber); - CallerIdNumberFeedback.FireUpdate(); - break; - case "OffHook": - Debug.Console(1, this, "Phone is OffHook: {0}", Status.PhoneCall.OffHook); - PhoneOffHookFeedback.FireUpdate(); - break; - } - }; - - Status.Layout.PropertyChanged += (o, a) => - { - Debug.Console(1, this, "Status.Layout.PropertyChanged a.PropertyName: {0}", a.PropertyName); - switch (a.PropertyName.ToLower()) - { - case "can_Switch_speaker_view": - case "can_switch_wall_view": - case "can_switch_strip_view": - case "video_type": - case "can_switch_share_on_all_screens": - { - ComputeAvailableLayouts(); - break; - } - case "is_in_first_page": - { - LayoutViewIsOnFirstPageFeedback.FireUpdate(); - break; - } - case "is_in_last_page": - { - LayoutViewIsOnLastPageFeedback.FireUpdate(); - break; - } - case "can_switch_floating_share_content": - { - CanSwapContentWithThumbnailFeedback.FireUpdate(); - break; - } - } - OnLayoutInfoChanged(); - }; - - Status.NumberOfScreens.PropertyChanged += (o, a) => - { - switch (a.PropertyName) - { - case "NumberOfScreens": - { - NumberOfScreensFeedback.FireUpdate(); - break; - } - } - }; - } - - private void SetUpDirectory() - { - DirectoryRoot = new CodecDirectory() {ResultsFolderId = "root"}; - - CurrentDirectoryResultIsNotDirectoryRoot = new BoolFeedback(() => CurrentDirectoryResult.ResultsFolderId != "root"); - - CurrentDirectoryResult = DirectoryRoot; - - DirectoryBrowseHistory = new List(); - DirectoryBrowseHistoryStack = new Stack(); - } - - private void SetUpRouting() - { - // Set up input ports - CreateOsdSource(); - InputPorts.Add(CodecOsdIn); - - // Set up output ports - OutputPorts.Add(Output1); - OutputPorts.Add(Output2); - } - - /// - /// Creates the fake OSD source, and connects it's AudioVideo output to the CodecOsdIn input - /// to enable routing - /// - private void CreateOsdSource() - { - OsdSource = new DummyRoutingInputsDevice(Key + "[osd]"); - DeviceManager.AddDevice(OsdSource); - var tl = new TieLine(OsdSource.AudioVideoOutputPort, CodecOsdIn); - TieLineCollection.Default.Add(tl); - - //foreach(var input in Status.Video. - } - - /// - /// Starts the HTTP feedback server and syncronizes state of codec - /// - /// - public override bool CustomActivate() - { - CrestronConsole.AddNewConsoleCommand(SetCommDebug, "SetCodecCommDebug", "0 for Off, 1 for on", - ConsoleAccessLevelEnum.AccessOperator); - if (!_props.DisablePhonebookAutoDownload) - { - CrestronConsole.AddNewConsoleCommand(s => SendText("zCommand Phonebook List Offset: 0 Limit: 10000"), - "GetZoomRoomContacts", "Triggers a refresh of the codec phonebook", - ConsoleAccessLevelEnum.AccessOperator); - } - - CrestronConsole.AddNewConsoleCommand(s => GetBookings(), "GetZoomRoomBookings", - "Triggers a refresh of the booking data for today", ConsoleAccessLevelEnum.AccessOperator); - - - - return base.CustomActivate(); - } - - #region Overrides of Device - - public override void Initialize() - { - var socket = Communication as ISocketStatus; - if (socket != null) - { - socket.ConnectionChange += socket_ConnectionChange; - } - - CommDebuggingIsOn = false; - - Communication.Connect(); - - CommunicationMonitor.Start(); - } - - #endregion - - public void SetCommDebug(string s) - { - if (s == "1") - { - CommDebuggingIsOn = true; - Debug.Console(1, this, "Comm Debug Enabled."); - } - else - { - CommDebuggingIsOn = false; - Debug.Console(1, this, "Comm Debug Disabled."); - } - } - - private void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e) - { - Debug.Console(1, this, "Socket status change {0}", e.Client.ClientStatus); - if (e.Client.IsConnected) - { - } - else - { - _syncState.CodecDisconnected(); - PhonebookSyncState.CodecDisconnected(); - } - } - - public void SendText(string command) - { - if (_meetingPasswordRequired) - { - Debug.Console(2, this, "Blocking commands to ZoomRoom while waiting for user to enter meeting password"); - return; - } - - if (_waitingForUserToAcceptOrRejectIncomingCall) - { - Debug.Console(2, this, "Blocking commands to ZoomRoom while waiting for user to accept or reject incoming call"); - return; - } - - if (CommDebuggingIsOn) - { - Debug.Console(1, this, "Sending: '{0}'", command); - } - - Communication.SendText(command + SendDelimiter); - } - - /// - /// Gathers responses and enqueues them. - /// - /// - /// - private void Port_LineReceived(object dev, GenericCommMethodReceiveTextArgs args) - { - //Debug.Console(0, this, "Port_LineReceived"); - - if (args.Delimiter != JsonDelimiter) - { -// Debug.Console(0, this, -//@"Non JSON response: -//Delimiter: {0} -//{1}", ComTextHelper.GetDebugText(args.Delimiter), args.Text); - ProcessNonJsonResponse(args.Text); - return; - } - else - { -// Debug.Console(0, this, -//@"JSON response: -//Delimiter: {0} -//{1}", ComTextHelper.GetDebugText(args.Delimiter), args.Text); - _receiveQueue.Enqueue(new ProcessStringMessage(args.Text, DeserializeResponse)); - //_receiveQueue.Enqueue(new ProcessStringMessage(args.Text, ProcessMessage)); - } - } - - /// - /// Queues the initial queries to be sent upon connection - /// - private void SetUpSyncQueries() - { - // zStatus - _syncState.AddQueryToQueue("zStatus Call Status"); - _syncState.AddQueryToQueue("zStatus Audio Input Line"); - _syncState.AddQueryToQueue("zStatus Audio Output Line"); - _syncState.AddQueryToQueue("zStatus Video Camera Line"); - _syncState.AddQueryToQueue("zStatus Video Optimizable"); - _syncState.AddQueryToQueue("zStatus Capabilities"); - _syncState.AddQueryToQueue("zStatus Sharing"); - _syncState.AddQueryToQueue("zStatus CameraShare"); - _syncState.AddQueryToQueue("zStatus Call Layout"); - _syncState.AddQueryToQueue("zStatus Call ClosedCaption Available"); - _syncState.AddQueryToQueue("zStatus NumberOfScreens"); - - // zConfiguration - - _syncState.AddQueryToQueue("zConfiguration Call Sharing optimize_video_sharing"); - _syncState.AddQueryToQueue("zConfiguration Call Microphone Mute"); - _syncState.AddQueryToQueue("zConfiguration Call Camera Mute"); - _syncState.AddQueryToQueue("zConfiguration Audio Input SelectedId"); - _syncState.AddQueryToQueue("zConfiguration Audio Input is_sap_disabled"); - _syncState.AddQueryToQueue("zConfiguration Audio Input reduce_reverb"); - _syncState.AddQueryToQueue("zConfiguration Audio Input volume"); - _syncState.AddQueryToQueue("zConfiguration Audio Output selectedId"); - _syncState.AddQueryToQueue("zConfiguration Audio Output volume"); - _syncState.AddQueryToQueue("zConfiguration Video hide_conf_self_video"); - _syncState.AddQueryToQueue("zConfiguration Video Camera selectedId"); - _syncState.AddQueryToQueue("zConfiguration Video Camera Mirror"); - _syncState.AddQueryToQueue("zConfiguration Client appVersion"); - _syncState.AddQueryToQueue("zConfiguration Client deviceSystem"); - _syncState.AddQueryToQueue("zConfiguration Call Layout ShareThumb"); - _syncState.AddQueryToQueue("zConfiguration Call Layout Style"); - _syncState.AddQueryToQueue("zConfiguration Call Layout Size"); - _syncState.AddQueryToQueue("zConfiguration Call Layout Position"); - _syncState.AddQueryToQueue("zConfiguration Call Lock Enable"); - _syncState.AddQueryToQueue("zConfiguration Call MuteUserOnEntry Enable"); - _syncState.AddQueryToQueue("zConfiguration Call ClosedCaption FontSize "); - _syncState.AddQueryToQueue("zConfiguration Call ClosedCaption Visible"); - - // zCommand - - if (!_props.DisablePhonebookAutoDownload) - { - _syncState.AddQueryToQueue("zCommand Phonebook List Offset: 0 Limit: 10000"); - } - - _syncState.AddQueryToQueue("zCommand Bookings List"); - _syncState.AddQueryToQueue("zCommand Call ListParticipants"); - _syncState.AddQueryToQueue("zCommand Call Info"); - - - _syncState.StartSync(); - } - - private void SetupSession() - { - // disable echo of commands - SendText("echo off"); - // switch to json format - // set feedback exclusions - // Currently the feedback exclusions don't work when using the API in JSON response mode - // But leave these here in case the API gets updated in the future - // These may work as of 5.9.4 - - // In 5.9.4 we're getting sent an AddedContact message for every contact in the phonebook on connect, which is redunant and way too much data - // We want to exclude these messages right away until after we've retrieved the entire phonebook and then we can re-enable them - SendText("zFeedback Register Op: ex Path: /Event/Phonebook/AddedContact"); - - SendText("zFeedback Register Op: ex Path: /Event/InfoResult/Info/callin_country_list"); - SendText("zFeedback Register Op: ex Path: /Event/InfoResult/Info/callout_country_list"); - SendText("zFeedback Register Op: ex Path: /Event/InfoResult/Info/toll_free_callinLlist"); - - SendText("zStatus SystemUnit"); - } - - /// - /// Removes the feedback exclusion for added contacts - /// - private void ResubscribeForAddedContacts() - { - SendText("zFeedback Register Op: in Path: /Event/Phonebook/AddedContact"); - } - - /// - /// Processes non-JSON responses as their are received - /// - /// - private void ProcessNonJsonResponse(string response) - { - if (response.Contains("client_loop: send disconnect: Broken pipe")) - { - Debug.Console(1, this, Debug.ErrorLogLevel.Error, - "Zoom Room Controller or App connected. Essentials will NOT control the Zoom Room until it is disconnected."); - - return; - } - - if (!_syncState.InitialSyncComplete) - { - if(response.ToLower().Contains("*r login successful")) - { - _syncState.LoginResponseReceived(); - - SendText("format json"); - - SetupSession(); - } - - //switch (response.Trim().ToLower()) // remove the whitespace - //{ - // case "*r login successful": - // { - // _syncState.LoginMessageReceived(); - - // //// Fire up a thread to send the intial commands. - // //CrestronInvoke.BeginInvoke(o => - // //{ - // // disable echo of commands - // SendText("echo off"); - // // switch to json format - // SendText("format json"); - // // set feedback exclusions - // // Currently the feedback exclusions don't work when using the API in JSON response mode - // // But leave these here in case the API gets updated in the future - // // These may work as of 5.9.4 - // if (_props.DisablePhonebookAutoDownload) - // { - // SendText("zFeedback Register Op: ex Path: /Event/Phonebook/AddedContact"); - // } - // SendText("zFeedback Register Op: ex Path: /Event/InfoResult/Info/callin_country_list"); - // SendText("zFeedback Register Op: ex Path: /Event/InfoResult/Info/callout_country_list"); - // SendText("zFeedback Register Op: ex Path: /Event/InfoResult/Info/toll_free_callinLlist"); - - // //}); - - // break; - // } - //} - } - } - - /// - /// Processes messages as they are dequeued - /// - /// - private void ProcessMessage(string message) - { - // Counts the curly braces - if (message.Contains("client_loop: send disconnect: Broken pipe")) - { - Debug.Console(1, this, Debug.ErrorLogLevel.Error, - "Zoom Room Controller or App connected. Essentials will NOT control the Zoom Room until it is disconnected."); - - return; - } - - if (message.Contains('{')) - { - _jsonCurlyBraceCounter++; - } - - if (message.Contains('}')) - { - _jsonCurlyBraceCounter--; - } - - //Debug.Console(2, this, "JSON Curly Brace Count: {0}", _jsonCurlyBraceCounter); - - if (!_jsonFeedbackMessageIsIncoming && message.Trim('\x20') == "{" + EchoDelimiter) - // Check for the beginning of a new JSON message - { - _jsonFeedbackMessageIsIncoming = true; - _jsonCurlyBraceCounter = 1; // reset the counter for each new message - - _jsonMessage = new StringBuilder(); - - _jsonMessage.Append(message); - - if (CommDebuggingIsOn) - { - Debug.Console(2, this, "Incoming JSON message..."); - } - - return; - } - if (_jsonFeedbackMessageIsIncoming && message.Trim('\x20') == "}" + EchoDelimiter) - // Check for the end of a JSON message - { - _jsonMessage.Append(message); - - if (_jsonCurlyBraceCounter == 0) - { - _jsonFeedbackMessageIsIncoming = false; - - if (CommDebuggingIsOn) - { - Debug.Console(2, this, "Complete JSON Received:\n{0}", _jsonMessage.ToString()); - } - - // Forward the complete message to be deserialized - DeserializeResponse(_jsonMessage.ToString()); - } - - //JsonMessage = new StringBuilder(); - return; - } - - // NOTE: This must happen after the above conditions have been checked - // Append subsequent partial JSON fragments to the string builder - if (_jsonFeedbackMessageIsIncoming) - { - _jsonMessage.Append(message); - - //Debug.Console(1, this, "Building JSON:\n{0}", JsonMessage.ToString()); - return; - } - - if (CommDebuggingIsOn) - { - Debug.Console(1, this, "Non-JSON response: '{0}'", message); - } - - _jsonCurlyBraceCounter = 0; // reset on non-JSON response - - if (!_syncState.InitialSyncComplete) - { - switch (message.Trim().ToLower()) // remove the whitespace - { - case "*r login successful": - { - _syncState.LoginResponseReceived(); - - - // Fire up a thread to send the intial commands. - CrestronInvoke.BeginInvoke(o => - { - // Currently the feedback exclusions don't work when using the API in JSON response mode - // But leave these here in case the API gets updated in the future - - - Thread.Sleep(100); - // disable echo of commands - SendText("echo off"); - Thread.Sleep(100); - // set feedback exclusions - SendText("zFeedback Register Op: ex Path: /Event/InfoResult/Info/callin_country_list"); - Thread.Sleep(100); - SendText("zFeedback Register Op: ex Path: /Event/InfoResult/Info/callout_country_list"); - Thread.Sleep(100); - SendText("zFeedback Register Op: ex Path: /Event/InfoResult/Info/toll_free_callinLlist"); - Thread.Sleep(100); - - if (_props.DisablePhonebookAutoDownload) - { - SendText("zFeedback Register Op: ex Path: /Event/Phonebook/AddedContact"); - } - // switch to json format - SendText("format json"); - }); - - break; - } - } - } - } - - /// - /// Deserializes a JSON formatted response - /// - /// - private void DeserializeResponse(string response) - { - try - { - var trimmedResponse = response.Trim(); - - if (trimmedResponse.Length <= 0) - { - return; - } - - var message = JObject.Parse(trimmedResponse); - - if (!_syncState.FirstJsonResponseWasReceived) - { - _syncState.ReceivedFirstJsonResponse(); - } - - var eType = - (eZoomRoomResponseType) - Enum.Parse(typeof (eZoomRoomResponseType), message["type"].Value(), true); - - var topKey = message["topKey"].Value(); - - var responseObj = message[topKey]; - - Debug.Console(1, this, "{0} Response Received. topKey: '{1}'\n{2}", eType, topKey, responseObj.ToString().Replace("\n", CrestronEnvironment.NewLine)); - - switch (eType) - { - case eZoomRoomResponseType.zConfiguration: - { - switch (topKey.ToLower()) - { - case "call": - { - JsonConvert.PopulateObject(responseObj.ToString(), Configuration.Call); - - break; - } - case "audio": - { - JsonConvert.PopulateObject(responseObj.ToString(), Configuration.Audio); - - break; - } - case "video": - { - JsonConvert.PopulateObject(responseObj.ToString(), Configuration.Video); - - break; - } - case "client": - { - JsonConvert.PopulateObject(responseObj.ToString(), Configuration.Client); - - break; - } - default: - { - break; - } - } - break; - } - case eZoomRoomResponseType.zCommand: - { - switch (topKey.ToLower()) - { - case "inforesult": - { - JsonConvert.PopulateObject(responseObj.ToString(), Status.Call.Info); - break; - } - case "phonebooklistresult": - { - // This result will always be the complete contents of the directory and never - // A subset of the results via a search - - // Clear out any existing data - Status.Phonebook = new zStatus.Phonebook(); - - JsonConvert.PopulateObject(responseObj.ToString(), Status.Phonebook); - - UpdateDirectory(); - - break; - } - case "listparticipantsresult": - { - Debug.Console(1, this, "JTokenType: {0}", responseObj.Type); - - switch (responseObj.Type) - { - case JTokenType.Array: - Status.Call.Participants = - JsonConvert.DeserializeObject>( - responseObj.ToString()); - break; - case JTokenType.Object: - { - // this is a single participant event notification - - var participant = - JsonConvert.DeserializeObject( - responseObj.ToString()); - - if (participant != null) - { - Debug.Console(1, this, - "[DeserializeResponse] zCommands.listparticipantresult - participant.event: {0} **********************************", - participant.Event); - Debug.Console(1, this, - "[DeserializeResponse] zCommands.listparticipantresult - participant.event: {0} - UserId: {1} Name: {2} IsHost: {3}", - participant.Event, participant.UserId, participant.UserName, participant.IsHost); - - switch (participant.Event) - { - case "ZRCUserChangedEventUserInfoUpdated": - case "ZRCUserChangedEventLeftMeeting": - { - var existingParticipant = - Status.Call.Participants.FirstOrDefault( - p => p.UserId.Equals(participant.UserId)); - - if (existingParticipant != null) - { - switch (participant.Event) - { - case "ZRCUserChangedEventLeftMeeting": - Status.Call.Participants.Remove(existingParticipant); - break; - case "ZRCUserChangedEventUserInfoUpdated": - JsonConvert.PopulateObject(responseObj.ToString(), - existingParticipant); - break; - } - } - } - break; - case "ZRCUserChangedEventJoinedMeeting": - { - var existingParticipant = - Status.Call.Participants.FirstOrDefault(p => p.UserId.Equals(participant.UserId)); - - if (existingParticipant != null) - { - Debug.Console(1, this, - "[DeserializeResponse] zCommands.listparticipantresult - participant.event: {0} ...updating matching UserId participant with UserId: {1} UserName: {2}", - participant.Event, participant.UserId, participant.UserName); - - JsonConvert.PopulateObject(responseObj.ToString(), existingParticipant); - } - else - { - Debug.Console(1, this, - "[DeserializeResponse] zCommands.listparticipantresult - participant.event: {0} ...adding participant with UserId: {1} UserName: {2}", - participant.Event, participant.UserId, participant.UserName); - - Status.Call.Participants.Add(participant); - } - - break; - } - } - - Debug.Console(1, this, - "[DeserializeResponse] zCommands.listparticipantresult - participant.event: {0} ***********************************", - participant.Event); - } - } - break; - } - - var participants = - zCommand.ListParticipant.GetGenericParticipantListFromParticipantsResult( - Status.Call.Participants); - - Participants.CurrentParticipants = participants; - - // Update the share status of the meeting info - var meetingInfo = new MeetingInfo( - MeetingInfo.Id, - MeetingInfo.Name, - Participants.Host.Name, - MeetingInfo.Password, - GetSharingStatus(), - GetIsHostMyself(), - MeetingInfo.IsSharingMeeting, - MeetingInfo.WaitingForHost, - MeetingIsLockedFeedback.BoolValue, - MeetingIsRecordingFeedback.BoolValue, - Status.Call.CallRecordInfo.AllowRecord - ); - MeetingInfo = meetingInfo; - - PrintCurrentCallParticipants(); - - break; - } - default: - { - break; - } - } - break; - } - case eZoomRoomResponseType.zEvent: - { - switch (topKey.ToLower()) - { - case "phonebook": - { - zStatus.Contact contact = new zStatus.Contact(); - - if (responseObj["Updated Contact"] != null) - { - contact = responseObj["Updated Contact"].ToObject(); - } - else if (responseObj["Added Contact"] != null) - { - contact = responseObj["Added Contact"].ToObject(); - } - - var existingContactIndex = Status.Phonebook.Contacts.FindIndex(c => c.Jid.Equals(contact.Jid)); - - if (existingContactIndex > 0) - { - Status.Phonebook.Contacts[existingContactIndex] = contact; - } - else - { - Status.Phonebook.Contacts.Add(contact); - } - - if(contactsDebounceTimer == null) - { - contactsDebounceTimer = new CTimer(o => UpdateDirectory(), 2000); - } - else - { - contactsDebounceTimer.Reset(); - } - - break; - } - case "bookingslistresult": - { - if (!_syncState.InitialSyncComplete) - { - _syncState.LastQueryResponseReceived(); - } - - var codecBookings = JsonConvert.DeserializeObject>( - responseObj.ToString()); - - if (codecBookings != null && codecBookings.Count > 0) - { - CodecSchedule.Meetings = zCommand.GetGenericMeetingsFromBookingResult( - codecBookings, CodecSchedule.MeetingWarningMinutes); - } - else - { - //need to clear the list if it's empty - CodecSchedule.Meetings = new List(); - } - - break; - } - case "bookings updated": - { - GetBookings(); - - break; - } - case "sharingstate": - { - JsonConvert.PopulateObject(responseObj.ToString(), Status.Call.Sharing); - - SetDefaultLayout(); - - break; - } - case "incomingcallindication": - { - var incomingCall = - JsonConvert.DeserializeObject(responseObj.ToString()); - - if (incomingCall != null) - { - var newCall = new CodecActiveCallItem - { - Direction = eCodecCallDirection.Incoming, - Status = eCodecCallStatus.Ringing, - Type = eCodecCallType.Video, - Name = incomingCall.callerName, - Id = incomingCall.callerJID - }; - - _waitingForUserToAcceptOrRejectIncomingCall = true; - - ActiveCalls.Add(newCall); - - OnCallStatusChange(newCall); - } - - break; - } - case "treatedincomingcallindication": - { - var incomingCall = - JsonConvert.DeserializeObject(responseObj.ToString()); - - if (incomingCall != null) - { - var existingCall = - ActiveCalls.FirstOrDefault(c => c.Id.Equals(incomingCall.callerJID)); - - if (existingCall != null) - { - existingCall.Status = !incomingCall.accepted - ? eCodecCallStatus.Disconnected - : eCodecCallStatus.Connecting; - - OnCallStatusChange(existingCall); - } - - _waitingForUserToAcceptOrRejectIncomingCall = false; - - UpdateCallStatus(); - } - - break; - } - case "calldisconnect": - { - var disconnectEvent = - JsonConvert.DeserializeObject(responseObj.ToString()); - - Debug.Console(1, this, - "[DeserializeResponse] zEvent.calldisconnect ********************************************"); - Debug.Console(1, this, "[DeserializeResponse] zEvent.calldisconnect - disconnectEvent.Successful: {0}", - disconnectEvent.Successful); - - if (disconnectEvent.Successful) - { - if (ActiveCalls.Count > 0) - { - var activeCall = ActiveCalls.FirstOrDefault(c => c.IsActiveCall); - - if (activeCall != null) - { - Debug.Console(1, this, - "[DeserializeResponse] zEvent.calldisconnect - ActiveCalls.Count: {0} activeCall.Id: {1}, activeCall.Number: {2} activeCall.Name: {3}, activeCall.IsActive: {4}", - ActiveCalls.Count, activeCall.Id, activeCall.Number, activeCall.Name, activeCall.IsActiveCall); - activeCall.Status = eCodecCallStatus.Disconnected; - - OnCallStatusChange(activeCall); - } - } - } - - Debug.Console(1, this, - "[DeserializeResponse] zEvent.calldisconnect ********************************************"); - - UpdateCallStatus(); - break; - } - case "callconnecterror": - { - UpdateCallStatus(); - break; - } - case "videounmuterequest": - { - var handler = VideoUnmuteRequested; - - if (handler != null) - { - handler(this, null); - } - - break; - } - case "meetingneedspassword": - { - var meetingNeedsPassword = - responseObj.ToObject(); - - if (meetingNeedsPassword.NeedsPassword) - { - var prompt = "Password required to join this meeting. Please enter the meeting password."; - - OnPasswordRequired(meetingNeedsPassword.WrongAndRetry, false, false, prompt); - } - else - { - OnPasswordRequired(false, false, true, ""); - } - - break; - } - case "needwaitforhost": - { - Status.NeedWaitForHost = JsonConvert.DeserializeObject(responseObj.ToString()); - - Debug.Console(1, this, "WaitingForHost: {0}", Status.NeedWaitForHost.Wait); - - if (Status.NeedWaitForHost.Wait) - { - if (MeetingInfo == null) - { - MeetingInfo = new MeetingInfo("Waiting For Host", "Waiting For Host", "Waiting For Host", "", - GetSharingStatus(), false, false, true, MeetingIsLockedFeedback.BoolValue, MeetingIsRecordingFeedback.BoolValue, Status.Call.CallRecordInfo.AllowRecord); - - UpdateCallStatus(); - break; - } - - MeetingInfo = new MeetingInfo("Waiting For Host", "Waiting For Host", "Waiting For Host", "", - GetSharingStatus(), false, false, true, MeetingIsLockedFeedback.BoolValue, MeetingIsRecordingFeedback.BoolValue, Status.Call.CallRecordInfo.AllowRecord); - - UpdateCallStatus(); - - break; - } - - if (MeetingInfo == null) - { - MeetingInfo = new MeetingInfo("Waiting For Host", "Waiting For Host", "Waiting For Host", "", - GetSharingStatus(), false, false, false, MeetingIsLockedFeedback.BoolValue, MeetingIsRecordingFeedback.BoolValue, Status.Call.CallRecordInfo.AllowRecord); - break; - } - - MeetingInfo = new MeetingInfo(MeetingInfo.Id, MeetingInfo.Name, MeetingInfo.Host, MeetingInfo.Password, - GetSharingStatus(), GetIsHostMyself(), false, false, MeetingIsLockedFeedback.BoolValue, MeetingIsRecordingFeedback.BoolValue, Status.Call.CallRecordInfo.AllowRecord); - - break; - } - case "openvideofailforhoststop": - { - // TODO: notify user that host has disabled unmuting video - break; - } - case "updatecallrecordinfo": - { - JsonConvert.PopulateObject(responseObj.ToString(), Status.Call.CallRecordInfo); - - break; - } - case "recordingconsent": - { - _recordConsentPromptIsVisible = responseObj["isShow"].Value(); - RecordConsentPromptIsVisible.FireUpdate(); - break; - } - case "phonecallstatus": - { - JsonConvert.PopulateObject(responseObj.ToString(), Status.PhoneCall); - break; - } - case "pinstatusofscreennotification": - { - var status = responseObj.ToObject(); - - Debug.Console(1, this, "Pin Status notification for UserId: {0}, ScreenIndex: {1}", status.PinnedUserId, - status.ScreenIndex); - - Participant alreadyPinnedParticipant = null; - - // Check for a participant already pinned to the same screen index. - if (status.PinnedUserId > 0) - { - alreadyPinnedParticipant = - Participants.CurrentParticipants.FirstOrDefault(p => p.ScreenIndexIsPinnedToFb.Equals(status.ScreenIndex)); - - // Make sure that the already pinned participant isn't the same ID as for this message. If true, clear the pinned fb. - if (alreadyPinnedParticipant != null && alreadyPinnedParticipant.UserId != status.PinnedUserId) - { - Debug.Console(1, this, "Participant: {0} with id: {1} already pinned to screenIndex {2}. Clearing pinned fb.", - alreadyPinnedParticipant.Name, alreadyPinnedParticipant.UserId, - alreadyPinnedParticipant.ScreenIndexIsPinnedToFb); - alreadyPinnedParticipant.IsPinnedFb = false; - alreadyPinnedParticipant.ScreenIndexIsPinnedToFb = -1; - } - } - - var participant = Participants.CurrentParticipants.FirstOrDefault(p => p.UserId.Equals(status.PinnedUserId)); - - if (participant != null) - { - participant.IsPinnedFb = true; - participant.ScreenIndexIsPinnedToFb = status.ScreenIndex; - } - else - { - participant = - Participants.CurrentParticipants.FirstOrDefault(p => p.ScreenIndexIsPinnedToFb.Equals(status.ScreenIndex)); - - if (participant == null && alreadyPinnedParticipant == null) - { - Debug.Console(1, this, "no matching participant found by pinned_user_id: {0} or screen_index: {1}", - status.PinnedUserId, status.ScreenIndex); - return; - } - else if (participant != null) - { - Debug.Console(2, this, "Unpinning {0} with id: {1} from screen index: {2}", participant.Name, - participant.UserId, status.ScreenIndex); - participant.IsPinnedFb = false; - participant.ScreenIndexIsPinnedToFb = -1; - } - } - - // fire the event as we've modified the participants list - Participants.OnParticipantsChanged(); - - break; - } - case "startlocalpresentmeeting": - { - var result = JsonConvert.DeserializeObject(responseObj.ToString()); - - if (result.Success) - { - MeetingInfo = new MeetingInfo("", "", "", "", GetSharingStatus(), true, true, MeetingInfo.WaitingForHost, MeetingIsLockedFeedback.BoolValue, MeetingIsRecordingFeedback.BoolValue, Status.Call.CallRecordInfo.AllowRecord); - break; - } - - break; - } - default: - { - break; - } - } - break; - } - case eZoomRoomResponseType.zStatus: - { - switch (topKey.ToLower()) - { - case "login": - { - _syncState.LoginResponseReceived(); - - SetupSession(); - - JsonConvert.PopulateObject(responseObj.ToString(), Status.Login); - - break; - } - case "systemunit": - { - - JsonConvert.PopulateObject(responseObj.ToString(), Status.SystemUnit); - - break; - } - case "call": - { - JsonConvert.PopulateObject(responseObj.ToString(), Status.Call); - - Debug.Console(1, this, - "[DeserializeResponse] zStatus.call - Status.Call.Info.meeting_id: {0} Status.Call.Info.meeting_list_item.meetingName: {1}", - Status.Call.Info.meeting_id, Status.Call.Info.meeting_list_item.meetingName); - foreach (var participant in Status.Call.Participants) - { - Debug.Console(1, this, - "[DeserializeResponse] zStatus.call - Status.Call.Participants participant.UserId: {0} participant.UserName: {1}", - participant.UserId, participant.UserName); - } - - UpdateCallStatus(); - - break; - } - case "capabilities": - { - JsonConvert.PopulateObject(responseObj.ToString(), Status.Capabilities); - break; - } - case "sharing": - { - JsonConvert.PopulateObject(responseObj.ToString(), Status.Sharing); - - break; - } - case "numberofscreens": - { - JsonConvert.PopulateObject(responseObj.ToString(), Status.NumberOfScreens); - break; - } - case "video": - { - JsonConvert.PopulateObject(responseObj.ToString(), Status.Video); - break; - } - case "camerashare": - { - JsonConvert.PopulateObject(responseObj.ToString(), Status.CameraShare); - break; - } - case "layout": - { - JsonConvert.PopulateObject(responseObj.ToString(), Status.Layout); - break; - } - case "audio input line": - { - JsonConvert.PopulateObject(responseObj.ToString(), Status.AudioInputs); - break; - } - case "audio output line": - { - JsonConvert.PopulateObject(responseObj.ToString(), Status.AudioOuputs); - break; - } - case "video camera line": - { - Status.Cameras.Clear(); - - JsonConvert.PopulateObject(responseObj.ToString(), Status.Cameras); - - if (!_syncState.CamerasHaveBeenSetUp) - { - SetUpCameras(); - } - - break; - } - default: - { - break; - } - } - - break; - } - default: - { - Debug.Console(1, "Unknown Response Type:"); - break; - } - } - } - catch (Exception ex) - { - Debug.Console(1, this, "Error Deserializing feedback: {0}", ex.Message); - Debug.Console(2, this, "{0}", ex); - - if (ex.InnerException != null) - { - Debug.Console(1, this,"Error Deserializing feedback inner exception: {0}", ex.InnerException.Message); - Debug.Console(2, this, "{0}", ex.InnerException.StackTrace); - } - } - } - - private void SetDefaultLayout() - { - if (!_props.AutoDefaultLayouts) return; - - if ( - (Status.Call.Sharing.State == zEvent.eSharingState.Receiving || - Status.Call.Sharing.State == zEvent.eSharingState.Sending)) - { - SendText(String.Format("zconfiguration call layout style: {0}", - _props.DefaultSharingLayout)); - } - else - { - if (_props.DefaultCallLayout == (_props.DefaultCallLayout & AvailableLayouts)) - { - SendText(String.Format("zconfiguration call layout style: {0}", - _props.DefaultCallLayout)); - } - else - Debug.Console(0, this, "Unable to set default Layout. {0} not currently an available layout based on meeting state", _props.DefaultCallLayout); - } - } - - /// - /// Retrieves the current call participants list - /// - public void GetCurrentCallParticipants() - { - SendText("zCommand Call ListParticipants"); - } - - /// - /// Prints the current call particiapnts list - /// - public void PrintCurrentCallParticipants() - { - if (Debug.Level <= 0) return; - - Debug.Console(1, this, "*************************** Call Participants **************************"); - foreach (var participant in Participants.CurrentParticipants) - { - Debug.Console(1, this, "UserId: {3} Name: {0} Audio: {1} IsHost: {2}", - participant.Name, participant.AudioMuteFb, participant.IsHost, participant.UserId); - } - Debug.Console(1, this, "************************************************************************"); - } - - /// - /// Retrieves bookings list - /// - private void GetBookings() - { - if (_meetingPasswordRequired || _waitingForUserToAcceptOrRejectIncomingCall) return; - - SendText("zCommand Bookings List"); - } - - - /// - /// Updates the current call status - /// - private void UpdateCallStatus() - { - Debug.Console(1, this, - "[UpdateCallStatus] Current Call Status: {0} Active Call Count: {1} Need Wait For Host: {2}", - Status.Call != null ? Status.Call.Status.ToString() : "no call", ActiveCalls.Count, Status.NeedWaitForHost.Wait); - - if (Status.Call != null) - { - var callStatus = Status.Call.Status; - - // If not crrently in a meeting, intialize the call object - if (callStatus != zStatus.eCallStatus.IN_MEETING && callStatus != zStatus.eCallStatus.CONNECTING_MEETING) - { - Status.Call = new zStatus.Call {Status = callStatus}; - // Resubscribe to all property change events after Status.Call is reconstructed - SetUpCallFeedbackActions(); - - OnCallStatusChange(new CodecActiveCallItem() {Status = eCodecCallStatus.Disconnected}); - } - - if (ActiveCalls.Count == 0) - { - if (callStatus == zStatus.eCallStatus.CONNECTING_MEETING || - callStatus == zStatus.eCallStatus.IN_MEETING) - { - var newStatus = eCodecCallStatus.Unknown; - - switch (callStatus) - { - case zStatus.eCallStatus.CONNECTING_MEETING: - newStatus = eCodecCallStatus.Connecting; - break; - case zStatus.eCallStatus.IN_MEETING: - newStatus = eCodecCallStatus.Connected; - break; - } - - if (!string.IsNullOrEmpty(Status.Call.Info.meeting_id)) - { - var newCall = new CodecActiveCallItem - { - Name = Status.Call.Info.meeting_list_item.meetingName, - Number = Status.Call.Info.meeting_list_item.meetingNumber, - Id = Status.Call.Info.meeting_id, - Status = newStatus, - Type = eCodecCallType.Video, - }; - - if (!String.IsNullOrEmpty(_lastDialedMeetingNumber)) - { - _lastDialedMeetingNumber = String.Empty; - } - ActiveCalls.Add(newCall); - - OnCallStatusChange(newCall); - } else if (String.IsNullOrEmpty(Status.Call.Info.meeting_id) && Status.NeedWaitForHost.Wait) - { - var newCall = new CodecActiveCallItem - { - Name = "Waiting For Host", - Number = "Waiting For Host", - Id = "Waiting For Host", - Status = newStatus, - Type = eCodecCallType.Video, - }; - - if (!String.IsNullOrEmpty(_lastDialedMeetingNumber)) - { - _lastDialedMeetingNumber = String.Empty; - } - - ActiveCalls.Add(newCall); - - OnCallStatusChange(newCall); - } - } - } - else - { - var existingCall = ActiveCalls.FirstOrDefault(c => !c.Status.Equals(eCodecCallStatus.Ringing)); - - switch (callStatus) - { - case zStatus.eCallStatus.IN_MEETING: - if (Status.NeedWaitForHost.Wait) - { - Status.NeedWaitForHost.Wait = false; - } - existingCall.Status = eCodecCallStatus.Connected; - break; - case zStatus.eCallStatus.NOT_IN_MEETING: - if (Status.NeedWaitForHost.Wait) - { - Status.NeedWaitForHost.Wait = false; - } - existingCall.Status = eCodecCallStatus.Disconnected; - break; - } - - Debug.Console(1, this, "[UpdateCallStatus] ELSE ActiveCalls.Count == {1} - Current Call Status: {0}", - Status.Call != null ? Status.Call.Status.ToString() : "no call", ActiveCalls.Count); - - - OnCallStatusChange(existingCall); - } - } - - Debug.Console(1, this, "[UpdateCallStatus] Active Calls ------------------------------"); - - // Clean up any disconnected calls left in the list - for (int i = 0; i < ActiveCalls.Count; i++) - { - var call = ActiveCalls[i]; - - Debug.Console(1, this, - @"ID: {1} - Number: {5} - Name: {0} - IsActive: {2} - Status: {3} - Direction: {4} - IsActiveCall: {6}", call.Name, call.Id, call.IsActiveCall, call.Status, call.Direction, call.Number, - call.IsActiveCall); - - if (!call.IsActiveCall) - { - Debug.Console(1, this, "[UpdateCallStatus] Removing Inactive call.Id: {1} call.Name: {0}", call.Name, call.Id); - ActiveCalls.Remove(call); - } - } - Debug.Console(1, this, "[UpdateCallStatus] Active Calls ------------------------------"); - - //clear participants list after call cleanup - var emptyList = new List(); - Participants.CurrentParticipants = emptyList; - if (ActiveCalls.Count > 0) GetCurrentCallParticipants(); - } - - protected override void OnCallStatusChange(CodecActiveCallItem item) - { - if (item.Status == eCodecCallStatus.Connected) - { - - var host = ""; - - if (Participants.Host != null) - host = Participants.Host.Name; - - MeetingInfo = new MeetingInfo( - Status.Call.Info.meeting_id, - Status.Call.Info.meeting_list_item.meetingName, - host, - Status.Call.Info.meeting_password, - GetSharingStatus(), - GetIsHostMyself(), - !String.Equals(Status.Call.Info.meeting_type,"NORMAL"), - false, - MeetingIsLockedFeedback.BoolValue, - MeetingIsRecordingFeedback.BoolValue, Status.Call.CallRecordInfo.AllowRecord - ); - - SetDefaultLayout(); - } - - else if (item.Status == eCodecCallStatus.Disconnected) - { - MeetingInfo = new MeetingInfo( - string.Empty, - string.Empty, - string.Empty, - string.Empty, - string.Empty, - false, - false, - false, - false, - false, Status.Call.CallRecordInfo.AllowRecord - ); - } - - _meetingPasswordRequired = false; - base.OnCallStatusChange(item); - - Debug.Console(1, this, "[OnCallStatusChange] Current Call Status: {0}", - Status.Call != null ? Status.Call.Status.ToString() : "no call"); - } - - private string GetSharingStatus() - { - string sharingState = "None"; - - try - { - if (Status.Call.Sharing.State == zEvent.eSharingState.Receiving) - { - sharingState = "Receiving Content"; - } - if (Status.Sharing.isAirHostClientConnected) - { - sharingState = "Sharing AirPlay"; - } - if (Status.Sharing.isDirectPresentationConnected) - { - sharingState = "Sharing Laptop"; - } - if (Status.Sharing.isSharingBlackMagic) - { - sharingState = "Sharing HDMI Source"; - } - - return sharingState; - } - catch (Exception e) - { - Debug.Console(1, this, "Exception getting sharing status: {0}", e.Message); - Debug.Console(2, this, "{0}", e.StackTrace); - return sharingState; - } - } - - private void UpdateDirectory() - { - Debug.Console(2, this, "Updating directory"); - var directoryResults = zStatus.Phonebook.ConvertZoomContactsToGeneric(Status.Phonebook.Contacts); - - if (!PhonebookSyncState.InitialSyncComplete) - { - PhonebookSyncState.InitialPhonebookFoldersReceived(); - PhonebookSyncState.PhonebookRootEntriesReceived(); - PhonebookSyncState.SetPhonebookHasFolders(true); - PhonebookSyncState.SetNumberOfContacts(Status.Phonebook.Contacts.Count); - } - - directoryResults.ResultsFolderId = "root"; - - DirectoryRoot = directoryResults; - - CurrentDirectoryResult = directoryResults; - - // - if (contactsDebounceTimer != null) - { - ClearContactDebounceTimer(); - } - } - - private void ClearContactDebounceTimer() - { - Debug.Console(2, this, "Clearing Timer"); - if (!contactsDebounceTimer.Disposed && contactsDebounceTimer != null) - { - contactsDebounceTimer.Dispose(); - contactsDebounceTimer = null; - } - } - - /// - /// Will return true if the host is myself (this zoom room) - /// - /// - private bool GetIsHostMyself() - { - try - { - if (Participants.CurrentParticipants.Count == 0) - { - Debug.Console(2, this, "No current participants"); - return false; - } - - var host = Participants.Host; - - if(host == null) - { - Debug.Console(2, this, "Host is currently null"); - return false; - } - Debug.Console(2, this, "Host is: '{0}' IsMyself?: {1}", host.Name, host.IsMyself); - return host.IsMyself; - } - catch (Exception e) - { - Debug.Console(1, "Exception getting isHost: {0}", e.Message); - Debug.Console(2, "{0}", e.StackTrace); - return false; - } - } - - /// - /// Starts sharing HDMI source - /// - public override void StartSharing() - { - SendText("zCommand Call Sharing HDMI Start"); - } - - /// - /// Stops sharing the current presentation - /// - public override void StopSharing() - { - if (Status.Sharing.isSharingBlackMagic) - { - SendText("zCommand Call Sharing HDMI Stop"); - } - else - { - SendText("zCommand Call Sharing Disconnect"); - } - } - - public override void PrivacyModeOn() - { - SendText("zConfiguration Call Microphone Mute: on"); - } - - public override void PrivacyModeOff() - { - SendText("zConfiguration Call Microphone Mute: off"); - } - - public override void PrivacyModeToggle() - { - if (PrivacyModeIsOnFeedback.BoolValue) - { - PrivacyModeOff(); - } - else - { - PrivacyModeOn(); - } - } - - public override void MuteOff() - { - Debug.Console(2, this, "Unmuting to previous level: {0}", _previousVolumeLevel); - SetVolume((ushort) _previousVolumeLevel); - } - - public override void MuteOn() - { - SetVolume(0); - } - - public override void MuteToggle() - { - if (MuteFeedback.BoolValue) - { - MuteOff(); - } - else - { - MuteOn(); - } - } - - - /// - /// Increments the voluem - /// - /// - public override void VolumeUp(bool pressRelease) - { - // TODO: Implment volume decrement that calls SetVolume() - } - - /// - /// Decrements the volume - /// - /// - public override void VolumeDown(bool pressRelease) - { - // TODO: Implment volume decrement that calls SetVolume() - } - - /// - /// Scales the level and sets the codec to the specified level within its range - /// - /// level from slider (0-65535 range) - public override void SetVolume(ushort level) - { - var scaledLevel = CrestronEnvironment.ScaleWithLimits(level, 65535, 0, 100, 0); - SendText(string.Format("zConfiguration Audio Output volume: {0}", scaledLevel)); - } - - /// - /// Recalls the default volume on the codec - /// - public void VolumeSetToDefault() - { - } - - /// - /// - /// - public override void StandbyActivate() - { - // No corresponding function on device - } - - /// - /// - /// - public override void StandbyDeactivate() - { - // No corresponding function on device - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new ZoomRoomJoinMap(joinStart); - - var customJoins = JoinMapHelper.TryGetJoinMapAdvancedForDevice(joinMapKey); - - if (customJoins != null) - { - joinMap.SetCustomJoinData(customJoins); - } - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - - LinkVideoCodecToApi(this, trilist, joinMap); - - LinkZoomRoomToApi(trilist, joinMap); - } - - /// - /// Links all the specific Zoom functionality to the API bridge - /// - /// - /// - public void LinkZoomRoomToApi(BasicTriList trilist, ZoomRoomJoinMap joinMap) - { - var meetingInfoCodec = this as IHasMeetingInfo; - if (meetingInfoCodec != null) - { - if (meetingInfoCodec.MeetingInfo != null) - { - trilist.SetBool(joinMap.MeetingCanRecord.JoinNumber, meetingInfoCodec.MeetingInfo.CanRecord); - } - - meetingInfoCodec.MeetingInfoChanged += (o, a) => - { - trilist.SetBool(joinMap.MeetingCanRecord.JoinNumber, a.Info.CanRecord); - }; - } - - var recordingCodec = this as IHasMeetingRecordingWithPrompt; - if (recordingCodec != null) - { - trilist.SetSigFalseAction(joinMap.StartRecording.JoinNumber, () => recordingCodec.StartRecording()); - trilist.SetSigFalseAction(joinMap.StopRecording.JoinNumber, () => recordingCodec.StopRecording()); - - recordingCodec.MeetingIsRecordingFeedback.LinkInputSig(trilist.BooleanInput[joinMap.StartRecording.JoinNumber]); - recordingCodec.MeetingIsRecordingFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.StopRecording.JoinNumber]); - - trilist.SetSigFalseAction(joinMap.RecordingPromptAgree.JoinNumber, () => recordingCodec.RecordingPromptAcknowledgement(true)); - trilist.SetSigFalseAction(joinMap.RecordingPromptDisagree.JoinNumber, () => recordingCodec.RecordingPromptAcknowledgement(false)); - - recordingCodec.RecordConsentPromptIsVisible.LinkInputSig(trilist.BooleanInput[joinMap.RecordConsentPromptIsVisible.JoinNumber]); - } - - var layoutsCodec = this as IHasZoomRoomLayouts; - if (layoutsCodec != null) - { - layoutsCodec.LayoutInfoChanged += (o, a) => - { - trilist.SetBool(joinMap.LayoutGalleryIsAvailable.JoinNumber, - zConfiguration.eLayoutStyle.Gallery == (a.AvailableLayouts & zConfiguration.eLayoutStyle.Gallery)); - - trilist.SetBool(joinMap.LayoutSpeakerIsAvailable.JoinNumber, - zConfiguration.eLayoutStyle.Speaker == (a.AvailableLayouts & zConfiguration.eLayoutStyle.Speaker)); - - - - trilist.SetBool(joinMap.LayoutStripIsAvailable.JoinNumber, zConfiguration.eLayoutStyle.Strip - == - (a.AvailableLayouts & zConfiguration.eLayoutStyle.Strip)); - trilist.SetBool(joinMap.LayoutShareAllIsAvailable.JoinNumber, zConfiguration.eLayoutStyle.ShareAll - == - (a.AvailableLayouts & - zConfiguration.eLayoutStyle.ShareAll)); - - // pass the names used to set the layout through the bridge - trilist.SetString(joinMap.LayoutGalleryIsAvailable.JoinNumber, zConfiguration.eLayoutStyle.Gallery.ToString()); - trilist.SetString(joinMap.LayoutSpeakerIsAvailable.JoinNumber, zConfiguration.eLayoutStyle.Speaker.ToString()); - trilist.SetString(joinMap.LayoutStripIsAvailable.JoinNumber, zConfiguration.eLayoutStyle.Strip.ToString()); - trilist.SetString(joinMap.LayoutShareAllIsAvailable.JoinNumber, zConfiguration.eLayoutStyle.ShareAll.ToString()); - }; - - trilist.SetSigFalseAction(joinMap.SwapContentWithThumbnail.JoinNumber, () => layoutsCodec.SwapContentWithThumbnail()); - - layoutsCodec.CanSwapContentWithThumbnailFeedback.LinkInputSig( - trilist.BooleanInput[joinMap.CanSwapContentWithThumbnail.JoinNumber]); - layoutsCodec.ContentSwappedWithThumbnailFeedback.LinkInputSig( - trilist.BooleanInput[joinMap.SwapContentWithThumbnail.JoinNumber]); - - layoutsCodec.LayoutViewIsOnFirstPageFeedback.LinkInputSig( - trilist.BooleanInput[joinMap.LayoutIsOnFirstPage.JoinNumber]); - layoutsCodec.LayoutViewIsOnLastPageFeedback.LinkInputSig(trilist.BooleanInput[joinMap.LayoutIsOnLastPage.JoinNumber]); - trilist.SetSigFalseAction(joinMap.LayoutTurnToNextPage.JoinNumber, () => layoutsCodec.LayoutTurnNextPage()); - trilist.SetSigFalseAction(joinMap.LayoutTurnToPreviousPage.JoinNumber, () => layoutsCodec.LayoutTurnPreviousPage()); - trilist.SetSigFalseAction(joinMap.GetAvailableLayouts.JoinNumber, () => layoutsCodec.GetAvailableLayouts()); - - trilist.SetStringSigAction(joinMap.GetSetCurrentLayout.JoinNumber, (s) => - { - try - { - var style = (zConfiguration.eLayoutStyle) Enum.Parse(typeof (zConfiguration.eLayoutStyle), s, true); - SetLayout(style); - } - catch (Exception e) - { - Debug.Console(1, this, "Unable to parse '{0}' to zConfiguration.eLayoutStyle: {1}", s, e); - } - }); - - layoutsCodec.LocalLayoutFeedback.LinkInputSig(trilist.StringInput[joinMap.GetSetCurrentLayout.JoinNumber]); - } - - var pinCodec = this as IHasParticipantPinUnpin; - if (pinCodec != null) - { - pinCodec.NumberOfScreensFeedback.LinkInputSig(trilist.UShortInput[joinMap.NumberOfScreens.JoinNumber]); - - // Set the value of the local property to be used when pinning a participant - trilist.SetUShortSigAction(joinMap.ScreenIndexToPinUserTo.JoinNumber, (u) => ScreenIndexToPinUserTo = u); - } - - var layoutSizeCodec = this as IHasSelfviewSize; - if (layoutSizeCodec != null) - { - trilist.SetSigFalseAction(joinMap.GetSetSelfviewPipSize.JoinNumber, layoutSizeCodec.SelfviewPipSizeToggle); - trilist.SetStringSigAction(joinMap.GetSetSelfviewPipSize.JoinNumber, (s) => - { - try - { - var size = (zConfiguration.eLayoutSize) Enum.Parse(typeof (zConfiguration.eLayoutSize), s, true); - var cmd = SelfviewPipSizes.FirstOrDefault(c => c.Command.Equals(size.ToString())); - SelfviewPipSizeSet(cmd); - } - catch (Exception e) - { - Debug.Console(1, this, "Unable to parse '{0}' to zConfiguration.eLayoutSize: {1}", s, e); - } - }); - - layoutSizeCodec.SelfviewPipSizeFeedback.LinkInputSig(trilist.StringInput[joinMap.GetSetSelfviewPipSize.JoinNumber]); - } - - MeetingInfoChanged += (device, args) => - { - trilist.SetString(joinMap.MeetingInfoId.JoinNumber, args.Info.Id); - trilist.SetString(joinMap.MeetingInfoHost.JoinNumber, args.Info.Host); - trilist.SetString(joinMap.MeetingInfoPassword.JoinNumber, args.Info.Password); - trilist.SetBool(joinMap.IsHost.JoinNumber, args.Info.IsHost); - trilist.SetBool(joinMap.ShareOnlyMeeting.JoinNumber, args.Info.IsSharingMeeting); - trilist.SetBool(joinMap.WaitingForHost.JoinNumber, args.Info.WaitingForHost); - //trilist.SetString(joinMap.CurrentSource.JoinNumber, args.Info.ShareStatus); - }; - - trilist.SetSigFalseAction(joinMap.StartMeetingNow.JoinNumber, () => StartMeeting(0)); - trilist.SetSigFalseAction(joinMap.ShareOnlyMeeting.JoinNumber, StartSharingOnlyMeeting); - trilist.SetSigFalseAction(joinMap.StartNormalMeetingFromSharingOnlyMeeting.JoinNumber, StartNormalMeetingFromSharingOnlyMeeting); - - trilist.SetStringSigAction(joinMap.SubmitPassword.JoinNumber, SubmitPassword); - - // Subscribe to call status to clear ShowPasswordPrompt when in meeting - this.CallStatusChange += (o, a) => - { - if (a.CallItem.Status == eCodecCallStatus.Connected || a.CallItem.Status == eCodecCallStatus.Disconnected) - { - trilist.SetBool(joinMap.MeetingPasswordRequired.JoinNumber, false); - } - - }; - - trilist.SetSigFalseAction(joinMap.CancelJoinAttempt.JoinNumber, () => { - trilist.SetBool(joinMap.MeetingPasswordRequired.JoinNumber, false); - EndAllCalls(); - }); - - PasswordRequired += (devices, args) => - { - Debug.Console(2, this, "***********************************PaswordRequired. Message: {0} Cancelled: {1} Last Incorrect: {2} Failed: {3}", args.Message, args.LoginAttemptCancelled, args.LastAttemptWasIncorrect, args.LoginAttemptFailed); - - if (args.LoginAttemptCancelled) - { - trilist.SetBool(joinMap.MeetingPasswordRequired.JoinNumber, false); - return; - } - - if (!string.IsNullOrEmpty(args.Message)) - { - trilist.SetString(joinMap.PasswordPromptMessage.JoinNumber, args.Message); - } - - if (args.LoginAttemptFailed) - { - // login attempt failed - return; - } - - trilist.SetBool(joinMap.PasswordIncorrect.JoinNumber, args.LastAttemptWasIncorrect); - trilist.SetBool(joinMap.MeetingPasswordRequired.JoinNumber, true); - }; - - trilist.OnlineStatusChange += (device, args) => - { - if (!args.DeviceOnLine) return; - - ComputeAvailableLayouts(); - layoutsCodec.LocalLayoutFeedback.FireUpdate(); - layoutsCodec.CanSwapContentWithThumbnailFeedback.FireUpdate(); - layoutsCodec.ContentSwappedWithThumbnailFeedback.FireUpdate(); - layoutsCodec.LayoutViewIsOnFirstPageFeedback.FireUpdate(); - layoutsCodec.LayoutViewIsOnLastPageFeedback.FireUpdate(); - pinCodec.NumberOfScreensFeedback.FireUpdate(); - layoutSizeCodec.SelfviewPipSizeFeedback.FireUpdate(); - }; - - var wirelessInfoCodec = this as IZoomWirelessShareInstructions; - if (wirelessInfoCodec != null) - { - if (Status != null && Status.Sharing != null) - { - SetSharingStateJoins(Status.Sharing, trilist, joinMap); - } - - wirelessInfoCodec.ShareInfoChanged += (o, a) => - { - SetSharingStateJoins(a.SharingStatus, trilist, joinMap); - }; - } - } - - void SetSharingStateJoins(zStatus.Sharing state, BasicTriList trilist, ZoomRoomJoinMap joinMap) - { - trilist.SetBool(joinMap.IsSharingAirplay.JoinNumber, state.isAirHostClientConnected); - trilist.SetBool(joinMap.IsSharingHdmi.JoinNumber, state.isBlackMagicConnected || state.isDirectPresentationConnected); - - trilist.SetString(joinMap.DisplayState.JoinNumber, state.dispState.ToString()); - trilist.SetString(joinMap.AirplayShareCode.JoinNumber, state.password); - trilist.SetString(joinMap.LaptopShareKey.JoinNumber, state.directPresentationSharingKey); - trilist.SetString(joinMap.WifiName.JoinNumber, state.wifiName); - trilist.SetString(joinMap.ServerName.JoinNumber, state.serverName); - } - - public override void ExecuteSwitch(object selector) - { - var action = selector as Action; - if (action == null) - { - return; - } - - action(); - } - - public void AcceptCall() - { - _waitingForUserToAcceptOrRejectIncomingCall = false; - - var incomingCall = - ActiveCalls.FirstOrDefault( - c => c.Status.Equals(eCodecCallStatus.Ringing) && c.Direction.Equals(eCodecCallDirection.Incoming)); - - AcceptCall(incomingCall); - } - - public override void AcceptCall(CodecActiveCallItem call) - { - _waitingForUserToAcceptOrRejectIncomingCall = false; - - SendText(string.Format("zCommand Call Accept callerJID: {0}", call.Id)); - - call.Status = eCodecCallStatus.Connected; - - OnCallStatusChange(call); - - UpdateCallStatus(); - } - - public void RejectCall() - { - _waitingForUserToAcceptOrRejectIncomingCall = false; - - var incomingCall = - ActiveCalls.FirstOrDefault( - c => c.Status.Equals(eCodecCallStatus.Ringing) && c.Direction.Equals(eCodecCallDirection.Incoming)); - - RejectCall(incomingCall); - } - - public override void RejectCall(CodecActiveCallItem call) - { - _waitingForUserToAcceptOrRejectIncomingCall = false; - - SendText(string.Format("zCommand Call Reject callerJID: {0}", call.Id)); - - call.Status = eCodecCallStatus.Disconnected; - - OnCallStatusChange(call); - - UpdateCallStatus(); - } - - public override void Dial(Meeting meeting) - { - Debug.Console(1, this, "Dialing meeting.Id: {0} Title: {1}", meeting.Id, meeting.Title); - _lastDialedMeetingNumber = meeting.Id; - SendText(string.Format("zCommand Dial Start meetingNumber: {0}", meeting.Id)); - } - - public override void Dial(string number) - { - Debug.Console(2, this, "Dialing number: {0}", number); - _lastDialedMeetingNumber = number; - SendText(string.Format("zCommand Dial Join meetingNumber: {0}", number)); - } - - /// - /// Dials a meeting with a password - /// - /// - /// - public void Dial(string number, string password) - { - Debug.Console(2, this, "Dialing meeting number: {0} with password: {1}", number, password); - SendText(string.Format("zCommand Dial Join meetingNumber: {0} password: {1}", number, password)); - } - - /// - /// Invites a contact to either a new meeting (if not already in a meeting) or the current meeting. - /// Currently only invites a single user - /// - /// - public override void Dial(IInvitableContact contact) - { - var ic = contact as InvitableDirectoryContact; - - if (ic != null) - { - Debug.Console(1, this, "Attempting to Dial (Invite): {0}", ic.Name); - - if (!IsInCall) - { - SendText(string.Format("zCommand Invite Duration: {0} user: {1}", DefaultMeetingDurationMin, - ic.ContactId)); - } - else - { - SendText(string.Format("zCommand Call invite user: {0}", ic.ContactId)); - } - } - } - - /// - /// Invites contacts to a new meeting for a specified duration - /// - /// - /// - public void InviteContactsToNewMeeting(List contacts, uint duration) - { - if(duration == 0) - { - duration = DefaultMeetingDurationMin; - } - - StringBuilder message = new StringBuilder(); - - // Add the prefix - message.Append(string.Format("zCommand Invite Duration: {0}", duration)); - - // Add each invitee - foreach (var contact in contacts) - { - var invitee = string.Format(" user: {0}", contact.ContactId); - - message.Append(invitee); - } - - SendText(message.ToString()); - } - - /// - /// Invites contacts to an existing meeting - /// - /// - public void InviteContactsToExistingMeeting(List contacts) - { - StringBuilder message = new StringBuilder(); - - // Add the prefix - message.Append(string.Format("zCommand Call Invite")); - - // Add each invitee - foreach (var contact in contacts) - { - var invitee = string.Format(" user: {0}", contact.ContactId); - - message.Append(invitee); - } - - SendText(message.ToString()); - } - - - /// - /// Starts a PMI Meeting for the specified duration (or default meeting duration if 0 is specified) - /// - /// duration of meeting - public void StartMeeting(uint duration) - { - uint dur = DefaultMeetingDurationMin; - - if (duration > 0) - dur = duration; - - SendText(string.Format("zCommand Dial StartPmi Duration: {0}", dur)); - } - - public void LeaveMeeting() - { - _meetingPasswordRequired = false; - _waitingForUserToAcceptOrRejectIncomingCall = false; - - SendText("zCommand Call Leave"); - } - - public override void EndCall(CodecActiveCallItem call) - { - _meetingPasswordRequired = false; - _waitingForUserToAcceptOrRejectIncomingCall = false; - - SendText("zCommand Call Disconnect"); - } - - public override void EndAllCalls() - { - _meetingPasswordRequired = false; - _waitingForUserToAcceptOrRejectIncomingCall = false; - - SendText("zCommand Call Disconnect"); - } - - public override void SendDtmf(string s) - { - SendDtmfToPhone(s); - } - - /// - /// Call when directory results are updated - /// - /// - private void OnDirectoryResultReturned(CodecDirectory result) - { - try - { - Debug.Console(2, this, "OnDirectoryResultReturned. Result has {0} contacts", result.Contacts.Count); - - CurrentDirectoryResultIsNotDirectoryRoot.FireUpdate(); - - var directoryResult = result; - var directoryIsRoot = CurrentDirectoryResultIsNotDirectoryRoot.BoolValue == false; - - // If result is Root, create a copy and filter out contacts whose parent folder is not root - //if (!CurrentDirectoryResultIsNotDirectoryRoot.BoolValue) - //{ - // Debug.Console(2, this, "Filtering DirectoryRoot to remove contacts for display"); - - // directoryResult.ResultsFolderId = result.ResultsFolderId; - // directoryResult.AddFoldersToDirectory(result.Folders); - // directoryResult.AddContactsToDirectory( - // result.Contacts.Where((c) => c.ParentFolderId == result.ResultsFolderId).ToList()); - //} - //else - //{ - // directoryResult = result; - //} - - Debug.Console(2, this, "Updating directoryResult. IsOnRoot: {0} Contact Count: {1}", - directoryIsRoot, directoryResult.Contacts.Count); - - // This will return the latest results to all UIs. Multiple indendent UI Directory browsing will require a different methodology - var handler = DirectoryResultReturned; - if (handler != null) - { - handler(this, new DirectoryEventArgs - { - Directory = directoryResult, - DirectoryIsOnRoot = directoryIsRoot - }); - } - - - } - catch (Exception e) - { - Debug.Console(2, this, "Error: {0}", e); - } - - //PrintDirectory(result); - } - - /// - /// Builds the cameras List by using the Zoom Room zStatus.Cameras data. Could later be modified to build from config data - /// - private void SetUpCameras() - { - SelectedCameraFeedback = new StringFeedback(() => Configuration.Video.Camera.SelectedId); - - ControllingFarEndCameraFeedback = new BoolFeedback(() => SelectedCamera is IAmFarEndCamera); - - foreach (var cam in Status.Cameras) - { - // Known Issue: - // Crestron UC engine systems seem to report an item in the cameras list that represnts the USB bridge device. - // If we know the name and it's reliably consistent, we could ignore it here... - - if (cam.Name.IndexOf("HD-CONV-USB") > -1) - { - // Skip this as it's the Crestron USB box, not a real camera - continue; - } - - var existingCam = Cameras.FirstOrDefault((c) => c.Key.Equals(cam.id)); - - if (existingCam == null) - { - var camera = new ZoomRoomCamera(cam.id, cam.Name, this); - - Cameras.Add(camera); - - if (cam.Selected) - { - SelectedCamera = camera; - } - } - } - - if (IsInCall) - { - UpdateFarEndCameras(); - } - - _syncState.CamerasSetUp(); - } - - /// - /// Dynamically creates far end cameras for call participants who have far end control enabled. - /// - private void UpdateFarEndCameras() - { - // TODO: set up far end cameras for the current call - } - - #region Implementation of IHasParticipants - - public CodecParticipants Participants { get; private set; } - - public void RemoveParticipant(int userId) - { - SendText(string.Format("zCommand Call Expel Id: {0}", userId)); - } - - public void SetParticipantAsHost(int userId) - { - SendText(string.Format("zCommand Call HostChange Id: {0}", userId)); - } - - public void AdmitParticipantFromWaitingRoom(int userId) - { - SendText(string.Format("zCommand Call Admit Participant Id: {0}", userId)); - } - - #endregion - - #region IHasParticipantAudioMute Members - - public void MuteAudioForAllParticipants() - { - SendText(string.Format("zCommand Call MuteAll Mute: on")); - } - - public void MuteAudioForParticipant(int userId) - { - SendText(string.Format("zCommand Call MuteParticipant Mute: on Id: {0}", userId)); - } - - public void UnmuteAudioForParticipant(int userId) - { - SendText(string.Format("zCommand Call MuteParticipant Mute: off Id: {0}", userId)); - } - - public void ToggleAudioForParticipant(int userId) - { - var user = Participants.CurrentParticipants.FirstOrDefault(p => p.UserId.Equals(userId)); - - if (user == null) - { - Debug.Console(2, this, "Unable to find user with id: {0}", userId); - return; - } - - if (user.AudioMuteFb) - { - UnmuteAudioForParticipant(userId); - } - else - { - MuteAudioForParticipant(userId); - } - } - - #endregion - - #region IHasParticipantVideoMute Members - - public void MuteVideoForParticipant(int userId) - { - SendText(string.Format("zCommand Call MuteParticipantVideo Mute: on Id: {0}", userId)); - } - - public void UnmuteVideoForParticipant(int userId) - { - SendText(string.Format("zCommand Call MuteParticipantVideo Mute: off Id: {0}", userId)); - } - - public void ToggleVideoForParticipant(int userId) - { - var user = Participants.CurrentParticipants.FirstOrDefault(p => p.UserId.Equals(userId)); - - if (user == null) - { - Debug.Console(2, this, "Unable to find user with id: {0}", userId); - return; - } - - if (user.VideoMuteFb) - { - UnmuteVideoForParticipant(userId); - } - else - { - MuteVideoForParticipant(userId); - } - } - - #endregion - - #region IHasParticipantPinUnpin Members - - private Func NumberOfScreensFeedbackFunc - { - get { return () => Status.NumberOfScreens.NumOfScreens; } - } - - public IntFeedback NumberOfScreensFeedback { get; private set; } - - public int ScreenIndexToPinUserTo { get; private set; } - - public void PinParticipant(int userId, int screenIndex) - { - SendText(string.Format("zCommand Call Pin Id: {0} Enable: on Screen: {1}", userId, screenIndex)); - } - - public void UnPinParticipant(int userId) - { - SendText(string.Format("zCommand Call Pin Id: {0} Enable: off", userId)); - } - - public void ToggleParticipantPinState(int userId, int screenIndex) - { - var user = Participants.CurrentParticipants.FirstOrDefault(p => p.UserId.Equals(userId)); - - if (user == null) - { - Debug.Console(2, this, "Unable to find user with id: {0}", userId); - return; - } - - if (user.IsPinnedFb) - { - UnPinParticipant(userId); - } - else - { - PinParticipant(userId, screenIndex); - } - } - - #endregion - - #region Implementation of IHasCameraOff - - public BoolFeedback CameraIsOffFeedback { get; private set; } - - public void CameraOff() - { - CameraMuteOn(); - } - - #endregion - - public BoolFeedback CameraIsMutedFeedback { get; private set; } - - public void CameraMuteOn() - { - SendText("zConfiguration Call Camera Mute: On"); - } - - public void CameraMuteOff() - { - SendText("zConfiguration Call Camera Mute: Off"); - } - - public void CameraMuteToggle() - { - if (CameraIsMutedFeedback.BoolValue) - CameraMuteOff(); - else - CameraMuteOn(); - } - - #region Implementation of IHasCameraAutoMode - - //Zoom doesn't support camera auto modes. Setting this to just unmute video - public void CameraAutoModeOn() - { - CameraMuteOff(); - throw new NotImplementedException("Zoom Room Doesn't support camera auto mode"); - } - - //Zoom doesn't support camera auto modes. Setting this to just unmute video - public void CameraAutoModeOff() - { - SendText("zConfiguration Call Camera Mute: Off"); - } - - public void CameraAutoModeToggle() - { - throw new NotImplementedException("Zoom Room doesn't support camera auto mode"); - } - - public BoolFeedback CameraAutoModeIsOnFeedback { get; private set; } - - #endregion - - #region Implementation of IHasFarEndContentStatus - - public BoolFeedback ReceivingContent { get; private set; } - - #endregion - - #region Implementation of IHasSelfviewPosition - - private CodecCommandWithLabel _currentSelfviewPipPosition; - - public StringFeedback SelfviewPipPositionFeedback { get; private set; } - - public void SelfviewPipPositionSet(CodecCommandWithLabel position) - { - SendText(String.Format("zConfiguration Call Layout Position: {0}", position.Command)); - } - - public void SelfviewPipPositionToggle() - { - if (_currentSelfviewPipPosition != null) - { - var nextPipPositionIndex = SelfviewPipPositions.IndexOf(_currentSelfviewPipPosition) + 1; - - if (nextPipPositionIndex >= SelfviewPipPositions.Count) - // Check if we need to loop back to the first item in the list - nextPipPositionIndex = 0; - - SelfviewPipPositionSet(SelfviewPipPositions[nextPipPositionIndex]); - } - } - - public List SelfviewPipPositions = new List() - { - new CodecCommandWithLabel("UpLeft", "Center Left"), - new CodecCommandWithLabel("UpRight", "Center Right"), - new CodecCommandWithLabel("DownRight", "Lower Right"), - new CodecCommandWithLabel("DownLeft", "Lower Left") - }; - - private void ComputeSelfviewPipPositionStatus() - { - _currentSelfviewPipPosition = - SelfviewPipPositions.FirstOrDefault( - p => p.Command.ToLower().Equals(Configuration.Call.Layout.Position.ToString().ToLower())); - } - - #endregion - - // TODO: #714 [ ] Implementation of IHasSelfviewPipSize - - #region Implementation of IHasSelfviewPipSize - - private CodecCommandWithLabel _currentSelfviewPipSize; - - public StringFeedback SelfviewPipSizeFeedback { get; private set; } - - public void SelfviewPipSizeSet(CodecCommandWithLabel size) - { - SendText(String.Format("zConfiguration Call Layout Size: {0}", size.Command)); - } - - public void SelfviewPipSizeToggle() - { - if (_currentSelfviewPipSize != null) - { - var nextPipSizeIndex = SelfviewPipSizes.IndexOf(_currentSelfviewPipSize) + 1; - - if (nextPipSizeIndex >= SelfviewPipSizes.Count) - // Check if we need to loop back to the first item in the list - nextPipSizeIndex = 0; - - SelfviewPipSizeSet(SelfviewPipSizes[nextPipSizeIndex]); - } - } - - public List SelfviewPipSizes = new List() - { - new CodecCommandWithLabel("Off", "Off"), - new CodecCommandWithLabel("Size1", "Size 1"), - new CodecCommandWithLabel("Size2", "Size 2"), - new CodecCommandWithLabel("Size3", "Size 3"), - new CodecCommandWithLabel("Strip", "Strip") - }; - - private void ComputeSelfviewPipSizeStatus() - { - _currentSelfviewPipSize = - SelfviewPipSizes.FirstOrDefault( - p => p.Command.ToLower().Equals(Configuration.Call.Layout.Size.ToString().ToLower())); - } - - #endregion - - #region Implementation of IHasPhoneDialing - - private Func PhoneOffHookFeedbackFunc - { - get { return () => Status.PhoneCall.OffHook; } - } - - private Func CallerIdNameFeedbackFunc - { - get { return () => Status.PhoneCall.PeerDisplayName; } - } - - private Func CallerIdNumberFeedbackFunc - { - get { return () => Status.PhoneCall.PeerNumber; } - } - - public BoolFeedback PhoneOffHookFeedback { get; private set; } - public StringFeedback CallerIdNameFeedback { get; private set; } - public StringFeedback CallerIdNumberFeedback { get; private set; } - - public void DialPhoneCall(string number) - { - SendText(String.Format("zCommand Dial PhoneCallOut Number: {0}", number)); - } - - public void EndPhoneCall() - { - SendText(String.Format("zCommand Dial PhoneHangUp CallId: {0}", Status.PhoneCall.CallId)); - } - - public void SendDtmfToPhone(string digit) - { - SendText(String.Format("zCommand SendSipDTMF CallId: {0} Key: {1}", Status.PhoneCall.CallId, digit)); - } - - #endregion - - #region IHasZoomRoomLayouts Members - - public event EventHandler LayoutInfoChanged; - - private Func LayoutViewIsOnFirstPageFeedbackFunc - { - get { return () => Status.Layout.is_In_First_Page; } - } - - private Func LayoutViewIsOnLastPageFeedbackFunc - { - get { return () => Status.Layout.is_In_Last_Page; } - } - - private Func CanSwapContentWithThumbnailFeedbackFunc - { - get { return () => Status.Layout.can_Switch_Floating_Share_Content; } - } - - private Func ContentSwappedWithThumbnailFeedbackFunc - { - get { return () => Configuration.Call.Layout.ShareThumb; } - } - - public BoolFeedback LayoutViewIsOnFirstPageFeedback { get; private set; } - - public BoolFeedback LayoutViewIsOnLastPageFeedback { get; private set; } - - public BoolFeedback CanSwapContentWithThumbnailFeedback { get; private set; } - - public BoolFeedback ContentSwappedWithThumbnailFeedback { get; private set; } - - - public zConfiguration.eLayoutStyle LastSelectedLayout { get; private set; } - - public zConfiguration.eLayoutStyle AvailableLayouts { get; private set; } - - /// - /// Reads individual properties to determine if which layouts are avalailable - /// - private void ComputeAvailableLayouts() - { - Debug.Console(1, this, "Computing available layouts..."); - zConfiguration.eLayoutStyle availableLayouts = zConfiguration.eLayoutStyle.None; - if (Status.Layout.can_Switch_Wall_View) - { - availableLayouts |= zConfiguration.eLayoutStyle.Gallery; - } - - if (Status.Layout.can_Switch_Speaker_View) - { - availableLayouts |= zConfiguration.eLayoutStyle.Speaker; - } - - if (Status.Layout.can_Switch_Share_On_All_Screens) - { - availableLayouts |= zConfiguration.eLayoutStyle.ShareAll; - } - - // There is no property that directly reports if strip mode is valid, but API stipulates - // that strip mode is available if the number of screens is 1 - if (Status.NumberOfScreens.NumOfScreens == 1 || Status.Layout.can_Switch_Strip_View || Status.Layout.video_type.ToLower() == "strip") - { - availableLayouts |= zConfiguration.eLayoutStyle.Strip; - } - - Debug.Console(1, this, "availablelayouts: {0}", availableLayouts); - - AvailableLayouts = availableLayouts; - } - - private void OnLayoutInfoChanged() - { - var handler = LayoutInfoChanged; - if (handler != null) - { - - var currentLayout = zConfiguration.eLayoutStyle.None; - - currentLayout = (zConfiguration.eLayoutStyle)Enum.Parse(typeof(zConfiguration.eLayoutStyle), string.IsNullOrEmpty(LocalLayoutFeedback.StringValue) ? "None" : LocalLayoutFeedback.StringValue, true); - - handler(this, new LayoutInfoChangedEventArgs() - { - AvailableLayouts = AvailableLayouts, - CurrentSelectedLayout = currentLayout, - LayoutViewIsOnFirstPage = LayoutViewIsOnFirstPageFeedback.BoolValue, - LayoutViewIsOnLastPage = LayoutViewIsOnLastPageFeedback.BoolValue, - CanSwapContentWithThumbnail = CanSwapContentWithThumbnailFeedback.BoolValue, - ContentSwappedWithThumbnail = ContentSwappedWithThumbnailFeedback.BoolValue, - }); - } - } - - public void GetAvailableLayouts() - { - SendText("zStatus Call Layout"); - } - - public void SetLayout(zConfiguration.eLayoutStyle layoutStyle) - { - LastSelectedLayout = layoutStyle; - SendText(String.Format("zConfiguration Call Layout Style: {0}", layoutStyle.ToString())); - } - - public void SwapContentWithThumbnail() - { - if (CanSwapContentWithThumbnailFeedback.BoolValue) - { - var oppositeValue = ContentSwappedWithThumbnailFeedback.BoolValue ? "on" : "off"; - // Get the value based on the opposite of the current state - // TODO: #697 [*] Need to verify the ternary above and make sure that the correct on/off value is being send based on the true/false value of the feedback - // to toggle the state - SendText(String.Format("zConfiguration Call Layout ShareThumb: {0}", oppositeValue)); - } - } - - public void LayoutTurnNextPage() - { - SendText("zCommand Call Layout TurnPage Forward: On"); - } - - public void LayoutTurnPreviousPage() - { - SendText("zCommand Call Layout TurnPage Forward: Off"); - } - - #endregion - - #region IHasCodecLayouts Members - - private Func LocalLayoutFeedbackFunc - { - get - { - return () => - { - if (Configuration.Call.Layout.Style != zConfiguration.eLayoutStyle.None) - return Configuration.Call.Layout.Style.ToString(); - else - return Configuration.Client.Call.Layout.Style.ToString(); - }; - } - } - - public StringFeedback LocalLayoutFeedback { get; private set; } - - public void LocalLayoutToggle() - { - var currentLayout = LocalLayoutFeedback.StringValue; - - var eCurrentLayout = (int) Enum.Parse(typeof (zConfiguration.eLayoutStyle), currentLayout, true); - - var nextLayout = GetNextLayout(eCurrentLayout); - - if (nextLayout != zConfiguration.eLayoutStyle.None) - { - SetLayout(nextLayout); - } - } - - /// - /// Tries to get the next available layout - /// - /// - /// - private zConfiguration.eLayoutStyle GetNextLayout(int currentLayout) - { - if (AvailableLayouts == zConfiguration.eLayoutStyle.None) - { - return zConfiguration.eLayoutStyle.None; - } - - zConfiguration.eLayoutStyle nextLayout; - - if (((zConfiguration.eLayoutStyle) currentLayout & zConfiguration.eLayoutStyle.ShareAll) == - zConfiguration.eLayoutStyle.ShareAll) - { - nextLayout = zConfiguration.eLayoutStyle.Gallery; - } - else - { - nextLayout = (zConfiguration.eLayoutStyle) (currentLayout << 1); - } - - if ((AvailableLayouts & nextLayout) == nextLayout) - { - return nextLayout; - } - else - { - return GetNextLayout((int) nextLayout); - } - } - - public void LocalLayoutToggleSingleProminent() - { - throw new NotImplementedException(); - } - - public void MinMaxLayoutToggle() - { - throw new NotImplementedException(); - } - - #endregion - - #region IPasswordPrompt Members - - public event EventHandler PasswordRequired; - - public void SubmitPassword(string password) - { - _meetingPasswordRequired = false; - Debug.Console(2, this, "Password Submitted: {0}", password); - Dial(_lastDialedMeetingNumber, password); - } - - void OnPasswordRequired(bool lastAttemptIncorrect, bool loginFailed, bool loginCancelled, string message) - { - _meetingPasswordRequired = !loginFailed || !loginCancelled; - - var handler = PasswordRequired; - if (handler != null) - { - Debug.Console(2, this, "Meeting Password Required: {0}", _meetingPasswordRequired); - - handler(this, new PasswordPromptEventArgs(lastAttemptIncorrect, loginFailed, loginCancelled, message)); - } - } - - #endregion - - #region IHasMeetingInfo Members - - public event EventHandler MeetingInfoChanged; - - private MeetingInfo _meetingInfo; - - public MeetingInfo MeetingInfo - { - get { return _meetingInfo; } - private set - { - if (value != _meetingInfo) - { - _meetingInfo = value; - - var handler = MeetingInfoChanged; - if (handler != null) - { - handler(this, new MeetingInfoEventArgs(_meetingInfo)); - } - } - } - } - - #endregion - - #region Implementation of IHasPresentationOnlyMeeting - - public void StartSharingOnlyMeeting() - { - StartSharingOnlyMeeting(eSharingMeetingMode.None, 30, String.Empty); - } - - public void StartSharingOnlyMeeting(eSharingMeetingMode displayMode) - { - StartSharingOnlyMeeting(displayMode, DefaultMeetingDurationMin, String.Empty); - } - - public void StartSharingOnlyMeeting(eSharingMeetingMode displayMode, uint duration) - { - StartSharingOnlyMeeting(displayMode, duration, String.Empty); - } - - public void StartSharingOnlyMeeting(eSharingMeetingMode displayMode, uint duration, string password) - { - SendText(String.Format("zCommand Dial Sharing Duration: {0} DisplayState: {1} Password: {2}", duration, displayMode, password)); - } - - public void StartNormalMeetingFromSharingOnlyMeeting() - { - Debug.Console(2, this, "Converting Sharing Meeting to Normal Meeting"); - SendText("zCommand call sharing ToNormal"); - } - - #endregion - - #region IHasMeetingLock Members - - public BoolFeedback MeetingIsLockedFeedback { get; private set; } - - public void LockMeeting() - { - SendText(string.Format("zConfiguration Call Lock Enable: on")); - } - - public void UnLockMeeting() - { - SendText(string.Format("zConfiguration Call Lock Enable: off")); - } - - public void ToggleMeetingLock() - { - if (MeetingIsLockedFeedback.BoolValue) - { - UnLockMeeting(); - } - else - { - LockMeeting(); - } - } - - #endregion - - #region IHasMeetingRecordingWithPrompt Members - - public BoolFeedback MeetingIsRecordingFeedback { get; private set; } - - bool _recordConsentPromptIsVisible; - - public BoolFeedback RecordConsentPromptIsVisible { get; private set; } - - public void RecordingPromptAcknowledgement(bool agree) - { - var command = string.Format("zCommand Agree Recording: {0}", agree ? "on" : "off"); - //Debug.Console(2, this, "Sending agree: {0} {1}", agree, command); - SendText(command); - } - - public void StartRecording() - { - SendText(string.Format("zCommand Call Record Enable: on")); - } - - public void StopRecording() - { - SendText(string.Format("zCommand Call Record Enable: off")); - } - - public void ToggleRecording() - { - if (MeetingIsRecordingFeedback.BoolValue) - { - StopRecording(); - } - else - { - StartRecording(); - } - } - - #endregion - - #region IZoomWirelessShareInstructions Members - - public event EventHandler ShareInfoChanged; - - public zStatus.Sharing SharingState - { - get - { - return Status.Sharing; - } - } - - void OnShareInfoChanged(zStatus.Sharing status) - { - Debug.Console(2, this, -@"ShareInfoChanged: -isSharingHDMI: {0} -isSharingAirplay: {1} -AirplayPassword: {2} -OSD Display State: {3} -", -status.isSharingBlackMagic, -status.isAirHostClientConnected, -status.password, -status.dispState); - - var handler = ShareInfoChanged; - if (handler != null) - { - handler(this, new ShareInfoEventArgs(status)); - } - } - - #endregion - } - - /// - /// Zoom Room specific info object - /// - public class ZoomRoomInfo : VideoCodecInfo - { - public ZoomRoomInfo(ZoomRoomStatus status, ZoomRoomConfiguration configuration) - { - Status = status; - Configuration = configuration; - } - - [JsonIgnore] - public ZoomRoomStatus Status { get; private set; } - [JsonIgnore] - public ZoomRoomConfiguration Configuration { get; private set; } - - public override bool AutoAnswerEnabled - { - get { return Status.SystemUnit.RoomInfo.AutoAnswerIsEnabled; } - } - - public override string E164Alias - { - get - { - if (!string.IsNullOrEmpty(Status.SystemUnit.MeetingNumber)) - { - return Status.SystemUnit.MeetingNumber; - } - return string.Empty; - } - } - - public override string H323Id - { - get - { - if (!string.IsNullOrEmpty(Status.Call.Info.meeting_list_item.third_party.h323_address)) - { - return Status.Call.Info.meeting_list_item.third_party.h323_address; - } - return string.Empty; - } - } - - public override string IpAddress - { - get - { - if (!string.IsNullOrEmpty(Status.SystemUnit.RoomInfo.AccountEmail)) - { - return Status.SystemUnit.RoomInfo.AccountEmail; - } - return string.Empty; - } - } - - public override bool MultiSiteOptionIsEnabled - { - get { return true; } - } - - public override string SipPhoneNumber - { - get - { - if (!string.IsNullOrEmpty(Status.Call.Info.dialIn)) - { - return Status.Call.Info.dialIn; - } - return string.Empty; - } - } - - public override string SipUri - { - get - { - if (!string.IsNullOrEmpty(Status.Call.Info.meeting_list_item.third_party.sip_address)) - { - return Status.Call.Info.meeting_list_item.third_party.sip_address; - } - return string.Empty; - } - } - } - - /// - /// Tracks the initial sycnronization state when establishing a new connection - /// - public class ZoomRoomSyncState : IKeyed - { - private readonly ZoomRoom _parent; - private readonly CrestronQueue _syncQueries; - private bool _initialSyncComplete; - - public ZoomRoomSyncState(string key, ZoomRoom parent) - { - _parent = parent; - Key = key; - _syncQueries = new CrestronQueue(50); - CodecDisconnected(); - } - - public bool InitialSyncComplete - { - get { return _initialSyncComplete; } - private set - { - if (value) - { - var handler = InitialSyncCompleted; - if (handler != null) - { - handler(this, new EventArgs()); - } - } - _initialSyncComplete = value; - } - } - - public bool LoginResponseWasReceived { get; private set; } - - public bool FirstJsonResponseWasReceived { get; private set; } - - public bool InitialQueryMessagesWereSent { get; private set; } - - public bool LastQueryResponseWasReceived { get; private set; } - - public bool CamerasHaveBeenSetUp { get; private set; } - - #region IKeyed Members - - public string Key { get; private set; } - - #endregion - - public event EventHandler InitialSyncCompleted; - - public event EventHandler FirstJsonResponseReceived; - - public void StartSync() - { - DequeueQueries(); - } - - private void DequeueQueries() - { - while (!_syncQueries.IsEmpty) - { - var query = _syncQueries.Dequeue(); - - _parent.SendText(query); - } - - InitialQueryMessagesSent(); - } - - public void AddQueryToQueue(string query) - { - _syncQueries.Enqueue(query); - } - - public void LoginResponseReceived() - { - LoginResponseWasReceived = true; - Debug.Console(1, this, "Login Rsponse Received."); - CheckSyncStatus(); - } - - public void ReceivedFirstJsonResponse() - { - FirstJsonResponseWasReceived = true; - Debug.Console(1, this, "First JSON Response Received."); - - var handler = FirstJsonResponseReceived; - if (handler != null) - { - handler(this, null); - } - CheckSyncStatus(); - } - - public void InitialQueryMessagesSent() - { - InitialQueryMessagesWereSent = true; - Debug.Console(1, this, "Query Messages Sent."); - CheckSyncStatus(); - } - - public void LastQueryResponseReceived() - { - LastQueryResponseWasReceived = true; - Debug.Console(1, this, "Last Query Response Received."); - CheckSyncStatus(); - } - - public void CamerasSetUp() - { - CamerasHaveBeenSetUp = true; - Debug.Console(1, this, "Cameras Set Up."); - CheckSyncStatus(); - } - - public void CodecDisconnected() - { - _syncQueries.Clear(); - LoginResponseWasReceived = false; - FirstJsonResponseWasReceived = false; - InitialQueryMessagesWereSent = false; - LastQueryResponseWasReceived = false; - CamerasHaveBeenSetUp = false; - InitialSyncComplete = false; - } - - private void CheckSyncStatus() - { - if (LoginResponseWasReceived && FirstJsonResponseWasReceived && InitialQueryMessagesWereSent && LastQueryResponseWasReceived && - CamerasHaveBeenSetUp) - { - InitialSyncComplete = true; - Debug.Console(1, this, "Initial Codec Sync Complete!"); - } - else - { - InitialSyncComplete = false; - } - } - } - - public class ZoomRoomFactory : EssentialsDeviceFactory - { - public ZoomRoomFactory() - { - TypeNames = new List {"zoomroom"}; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new ZoomRoom Device"); - var comm = CommFactory.CreateCommForDevice(dc); - return new ZoomRoom(dc, comm); - } - } +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.CrestronThread; +using Crestron.SimplSharpPro.DeviceSupport; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.Core.DeviceTypeInterfaces; +using PepperDash.Essentials.Core.Routing; +using PepperDash.Essentials.Core.Queues; +using PepperDash.Essentials.Devices.Common.Cameras; +using PepperDash.Essentials.Devices.Common.Codec; +using PepperDash.Essentials.Devices.Common.VideoCodec.Cisco; +using PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom +{ + public class ZoomRoom : VideoCodecBase, IHasCodecSelfView, IHasDirectoryHistoryStack, ICommunicationMonitor, + IRouting, + IHasScheduleAwareness, IHasCodecCameras, IHasParticipants, IHasCameraOff, IHasCameraMuteWithUnmuteReqeust, IHasCameraAutoMode, + IHasFarEndContentStatus, IHasSelfviewPosition, IHasPhoneDialing, IHasZoomRoomLayouts, IHasParticipantPinUnpin, + IHasParticipantAudioMute, IHasSelfviewSize, IPasswordPrompt, IHasStartMeeting, IHasMeetingInfo, IHasPresentationOnlyMeeting, + IHasMeetingLock, IHasMeetingRecordingWithPrompt, IZoomWirelessShareInstructions + { + public event EventHandler VideoUnmuteRequested; + + private const long MeetingRefreshTimer = 60000; + public uint DefaultMeetingDurationMin { get; private set; } + + /// + /// CR LF CR LF Delimits an echoed response to a command + /// + private const string EchoDelimiter = "\x0D\x0A\x0D\x0A"; + + private const string SendDelimiter = "\x0D"; + + /// + /// CR LF } CR LF Delimits a JSON response + /// + private const string JsonDelimiter = "\x0D\x0A\x7D\x0D\x0A"; + + private string[] Delimiters = new string[] { EchoDelimiter, JsonDelimiter, "OK\x0D\x0A", "end\x0D\x0A" }; + private readonly GenericQueue _receiveQueue; + + private readonly ZoomRoomSyncState _syncState; + public bool CommDebuggingIsOn; + private CodecDirectory _currentDirectoryResult; + private uint _jsonCurlyBraceCounter; + private bool _jsonFeedbackMessageIsIncoming; + private StringBuilder _jsonMessage; + private int _previousVolumeLevel; + private CameraBase _selectedCamera; + private string _lastDialedMeetingNumber; + + private CTimer contactsDebounceTimer; + + + private readonly ZoomRoomPropertiesConfig _props; + + private bool _meetingPasswordRequired; + + private bool _waitingForUserToAcceptOrRejectIncomingCall; + + public void Poll(string pollString) + { + if(_meetingPasswordRequired || _waitingForUserToAcceptOrRejectIncomingCall) return; + + SendText(string.Format("{0}{1}", pollString, SendDelimiter)); + } + + public ZoomRoom(DeviceConfig config, IBasicCommunication comm) + : base(config) + { + DefaultMeetingDurationMin = 30; + + _props = JsonConvert.DeserializeObject(config.Properties.ToString()); + + _receiveQueue = new GenericQueue(Key + "-rxQueue", Thread.eThreadPriority.MediumPriority, 2048); + + Communication = comm; + + if (_props.CommunicationMonitorProperties != null) + { + CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, _props.CommunicationMonitorProperties.PollInterval, _props.CommunicationMonitorProperties.TimeToWarning, _props.CommunicationMonitorProperties.TimeToError, + () => Poll(_props.CommunicationMonitorProperties.PollString)); + } + else + { + CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 30000, 120000, 300000, () => Poll("zStatus SystemUnit")); + } + + DeviceManager.AddDevice(CommunicationMonitor); + + Status = new ZoomRoomStatus(); + + Configuration = new ZoomRoomConfiguration(); + + CodecInfo = new ZoomRoomInfo(Status, Configuration); + + _syncState = new ZoomRoomSyncState(Key + "--Sync", this); + + _syncState.InitialSyncCompleted += SyncState_InitialSyncCompleted; + + _syncState.FirstJsonResponseReceived += (o, a) => SetUpSyncQueries(); + + PhonebookSyncState = new CodecPhonebookSyncState(Key + "--PhonebookSync"); + + PhonebookSyncState.InitialSyncCompleted += (o, a) => ResubscribeForAddedContacts(); + + PortGather = new CommunicationGather(Communication, Delimiters) {IncludeDelimiter = true}; + PortGather.LineReceived += Port_LineReceived; + + CodecOsdIn = new RoutingInputPort(RoutingPortNames.CodecOsd, + eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, new Action(StopSharing), this); + + Output1 = new RoutingOutputPort(RoutingPortNames.HdmiOut1, + eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, null, this); + + Output2 = new RoutingOutputPort(RoutingPortNames.HdmiOut2, + eRoutingSignalType.Video, + eRoutingPortConnectionType.DisplayPort, null, this); + + Output3 = new RoutingOutputPort(RoutingPortNames.HdmiOut3, + eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, null, this); + + SelfviewIsOnFeedback = new BoolFeedback(SelfViewIsOnFeedbackFunc); + + CameraIsOffFeedback = new BoolFeedback(CameraIsOffFeedbackFunc); + + CameraIsMutedFeedback = CameraIsOffFeedback; + + CameraAutoModeIsOnFeedback = new BoolFeedback(CameraAutoModeIsOnFeedbackFunc); + + CodecSchedule = new CodecScheduleAwareness(MeetingRefreshTimer); + + if (_props.MinutesBeforeMeetingStart > 0) + { + CodecSchedule.MeetingWarningMinutes = _props.MinutesBeforeMeetingStart; + } + + ReceivingContent = new BoolFeedback(FarEndIsSharingContentFeedbackFunc); + + SelfviewPipPositionFeedback = new StringFeedback(SelfviewPipPositionFeedbackFunc); + + // TODO: #714 [ ] SelfviewPipSizeFeedback + SelfviewPipSizeFeedback = new StringFeedback(SelfviewPipSizeFeedbackFunc); + + SetUpFeedbackActions(); + + Cameras = new List(); + + SetUpDirectory(); + + Participants = new CodecParticipants(); + + SupportsCameraOff = true; // Always allow turning off the camera for zoom calls? + SupportsCameraAutoMode = _props.SupportsCameraAutoMode; + + PhoneOffHookFeedback = new BoolFeedback(PhoneOffHookFeedbackFunc); + CallerIdNameFeedback = new StringFeedback(CallerIdNameFeedbackFunc); + CallerIdNumberFeedback = new StringFeedback(CallerIdNumberFeedbackFunc); + + LocalLayoutFeedback = new StringFeedback(LocalLayoutFeedbackFunc); + + LayoutViewIsOnFirstPageFeedback = new BoolFeedback(LayoutViewIsOnFirstPageFeedbackFunc); + LayoutViewIsOnLastPageFeedback = new BoolFeedback(LayoutViewIsOnLastPageFeedbackFunc); + CanSwapContentWithThumbnailFeedback = new BoolFeedback(CanSwapContentWithThumbnailFeedbackFunc); + ContentSwappedWithThumbnailFeedback = new BoolFeedback(ContentSwappedWithThumbnailFeedbackFunc); + + NumberOfScreensFeedback = new IntFeedback(NumberOfScreensFeedbackFunc); + + MeetingIsLockedFeedback = new BoolFeedback(() => Configuration.Call.Lock.Enable ); + + MeetingIsRecordingFeedback = new BoolFeedback(() => Status.Call.CallRecordInfo.meetingIsBeingRecorded ); + + RecordConsentPromptIsVisible = new BoolFeedback(() => _recordConsentPromptIsVisible); + + SetUpRouting(); + } + + public CommunicationGather PortGather { get; private set; } + + public ZoomRoomStatus Status { get; private set; } + + public ZoomRoomConfiguration Configuration { get; private set; } + + //CTimer LoginMessageReceivedTimer; + //CTimer RetryConnectionTimer; + + /// + /// Gets and returns the scaled volume of the codec + /// + protected override Func VolumeLevelFeedbackFunc + { + get + { + return () => + { + var scaledVol = CrestronEnvironment.ScaleWithLimits(Configuration.Audio.Output.Volume, 100, 0, 65535, 0); + + if (Configuration.Audio.Output.Volume != 0) + { + Debug.Console(2, this, "Storing previous volume level as: {0}, scaled: {1}", Configuration.Audio.Output.Volume, + scaledVol); + _previousVolumeLevel = scaledVol; // Store the previous level for recall + } + + return scaledVol; + }; + } + } + + protected override Func PrivacyModeIsOnFeedbackFunc + { + get + { + return () => + { + //Debug.Console(2, this, "PrivacyModeIsOnFeedbackFunc. IsInCall: {0} muteState: {1}", IsInCall, Configuration.Call.Microphone.Mute); + if (IsInCall) + { + //Debug.Console(2, this, "reporting muteState: ", Configuration.Call.Microphone.Mute); + return Configuration.Call.Microphone.Mute; + } + else + { + //Debug.Console(2, this, "muteState: true", IsInCall); + return false; + } + }; + } + } + + protected override Func StandbyIsOnFeedbackFunc + { + get { return () => false; } + } + + protected override Func SharingSourceFeedbackFunc + { + get + { + return () => + { + if (Status.Sharing.isAirHostClientConnected) + return "Airplay"; + else if (Status.Sharing.isDirectPresentationConnected || Status.Sharing.isBlackMagicConnected) + return "Laptop"; + else return "None"; + + }; + } + } + + protected override Func SharingContentIsOnFeedbackFunc + { + get { return () => Status.Sharing.isAirHostClientConnected || Status.Sharing.isDirectPresentationConnected || Status.Sharing.isSharingBlackMagic; } + } + + protected Func FarEndIsSharingContentFeedbackFunc + { + get { return () => Status.Call.Sharing.State == zEvent.eSharingState.Receiving; } + } + + protected override Func MuteFeedbackFunc + { + get { return () => Configuration.Audio.Output.Volume == 0; } + } + + //protected Func RoomIsOccupiedFeedbackFunc + //{ + // get + // { + // return () => false; + // } + //} + + //protected Func PeopleCountFeedbackFunc + //{ + // get + // { + // return () => 0; + // } + //} + + protected Func SelfViewIsOnFeedbackFunc + { + get { return () => !Configuration.Video.HideConfSelfVideo; } + } + + protected Func CameraIsOffFeedbackFunc + { + get { return () => Configuration.Call.Camera.Mute; } + } + + protected Func CameraAutoModeIsOnFeedbackFunc + { + get { return () => false; } + } + + protected Func SelfviewPipPositionFeedbackFunc + { + get + { + return + () => + _currentSelfviewPipPosition != null + ? _currentSelfviewPipPosition.Command ?? "Unknown" + : "Unknown"; + } + } + + // TODO: #714 [ ] SelfviewPipSizeFeedbackFunc + protected Func SelfviewPipSizeFeedbackFunc + { + get + { + return + () => + _currentSelfviewPipSize != null + ? _currentSelfviewPipSize.Command ?? "Unknown" + : "Unknown"; + } + } + + protected Func LocalLayoutIsProminentFeedbackFunc + { + get { return () => false; } + } + + + public RoutingInputPort CodecOsdIn { get; private set; } + public RoutingOutputPort Output1 { get; private set; } + public RoutingOutputPort Output2 { get; private set; } + public RoutingOutputPort Output3 { get; private set; } + + #region ICommunicationMonitor Members + + public StatusMonitorBase CommunicationMonitor { get; private set; } + + #endregion + + #region IHasCodecCameras Members + + public event EventHandler CameraSelected; + + public List Cameras { get; private set; } + + public CameraBase SelectedCamera + { + get { return _selectedCamera; } + private set + { + _selectedCamera = value; + SelectedCameraFeedback.FireUpdate(); + ControllingFarEndCameraFeedback.FireUpdate(); + + var handler = CameraSelected; + if (handler != null) + { + handler(this, new CameraSelectedEventArgs(_selectedCamera)); + } + } + } + + + public StringFeedback SelectedCameraFeedback { get; private set; } + + public void SelectCamera(string key) + { + if (CameraIsMutedFeedback.BoolValue) + { + CameraMuteOff(); + } + + SendText(string.Format("zConfiguration Video Camera selectedId: {0}", key)); + } + + public CameraBase FarEndCamera { get; private set; } + + public BoolFeedback ControllingFarEndCameraFeedback { get; private set; } + + #endregion + + #region IHasCodecSelfView Members + + public BoolFeedback SelfviewIsOnFeedback { get; private set; } + + public void GetSelfViewMode() + { + SendText("zConfiguration Video hide_conf_self_video"); + } + + public void SelfViewModeOn() + { + SendText("zConfiguration Video hide_conf_self_video: off"); + } + + public void SelfViewModeOff() + { + SendText("zConfiguration Video hide_conf_self_video: on"); + } + + public void SelfViewModeToggle() + { + if (SelfviewIsOnFeedback.BoolValue) + { + SelfViewModeOff(); + } + else + { + SelfViewModeOn(); + } + } + + #endregion + + #region IHasDirectoryHistoryStack Members + + public event EventHandler DirectoryResultReturned; + public CodecDirectory DirectoryRoot { get; private set; } + + public CodecDirectory CurrentDirectoryResult + { + get { return _currentDirectoryResult; } + private set + { + _currentDirectoryResult = value; + + Debug.Console(2, this, "CurrentDirectoryResult Updated. ResultsFolderId: {0} Contact Count: {1}", + _currentDirectoryResult.ResultsFolderId, _currentDirectoryResult.CurrentDirectoryResults.Count); + + OnDirectoryResultReturned(_currentDirectoryResult); + } + } + + public CodecPhonebookSyncState PhonebookSyncState { get; private set; } + + public void SearchDirectory(string searchString) + { + var directoryResults = new CodecDirectory(); + + directoryResults.AddContactsToDirectory( + DirectoryRoot.CurrentDirectoryResults.FindAll( + c => c.Name.IndexOf(searchString, 0, StringComparison.OrdinalIgnoreCase) > -1)); + + DirectoryBrowseHistoryStack.Clear(); + CurrentDirectoryResult = directoryResults; + } + + public void GetDirectoryFolderContents(string folderId) + { + var directoryResults = new CodecDirectory {ResultsFolderId = folderId}; + + directoryResults.AddContactsToDirectory( + DirectoryRoot.CurrentDirectoryResults.FindAll(c => c.ParentFolderId.Equals(folderId))); + + DirectoryBrowseHistoryStack.Push(_currentDirectoryResult); + + CurrentDirectoryResult = directoryResults; + } + + public void SetCurrentDirectoryToRoot() + { + DirectoryBrowseHistoryStack.Clear(); + + CurrentDirectoryResult = DirectoryRoot; + } + + public void GetDirectoryParentFolderContents() + { + if (DirectoryBrowseHistoryStack.Count == 0) + { + return; + } + + var currentDirectory = DirectoryBrowseHistoryStack.Pop(); + + CurrentDirectoryResult = currentDirectory; + } + + public BoolFeedback CurrentDirectoryResultIsNotDirectoryRoot { get; private set; } + + public List DirectoryBrowseHistory { get; private set; } + + public Stack DirectoryBrowseHistoryStack { get; private set; } + + #endregion + + #region IHasScheduleAwareness Members + + public CodecScheduleAwareness CodecSchedule { get; private set; } + + public void GetSchedule() + { + GetBookings(); + } + + #endregion + + #region IRouting Members + + public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) + { + ExecuteSwitch(inputSelector); + } + + #endregion + + private void SyncState_InitialSyncCompleted(object sender, EventArgs e) + { + SetIsReady(); + } + + /// + /// Handles subscriptions to Status.Call and sub objects. Needs to be called whenever Status.Call is constructed + /// + private void SetUpCallFeedbackActions() + { + Status.Sharing.PropertyChanged -= HandleSharingStateUpdate; + Status.Sharing.PropertyChanged += HandleSharingStateUpdate; + + Status.Call.Sharing.PropertyChanged -= HandleSharingStateUpdate; + Status.Call.Sharing.PropertyChanged += HandleSharingStateUpdate; + + Status.Call.PropertyChanged -= HandleCallStateUpdate; + Status.Call.PropertyChanged += HandleCallStateUpdate; + + Status.Call.CallRecordInfo.PropertyChanged -= HandleCallRecordInfoStateUpdate; + Status.Call.CallRecordInfo.PropertyChanged += HandleCallRecordInfoStateUpdate; + } + + private void HandleCallRecordInfoStateUpdate(object sender, PropertyChangedEventArgs a) + { + if (a.PropertyName == "meetingIsBeingRecorded" || a.PropertyName == "emailRequired" || a.PropertyName == "canRecord") + { + MeetingIsRecordingFeedback.FireUpdate(); + + var meetingInfo = new MeetingInfo(MeetingInfo.Id, + MeetingInfo.Name, + MeetingInfo.Host, + MeetingInfo.Password, + GetSharingStatus(), + GetIsHostMyself(), + MeetingInfo.IsSharingMeeting, + MeetingInfo.WaitingForHost, + MeetingIsLockedFeedback.BoolValue, + MeetingIsRecordingFeedback.BoolValue, Status.Call.CallRecordInfo.AllowRecord); + MeetingInfo = meetingInfo; + } + } + + private void HandleCallStateUpdate(object sender, PropertyChangedEventArgs a) + { + switch (a.PropertyName) + { + case "Info": + { + Debug.Console(1, this, "Updating Call Status"); + UpdateCallStatus(); + break; + } + + case "Status": + { + UpdateCallStatus(); + break; + } + } + } + + private void HandleSharingStateUpdate(object sender, PropertyChangedEventArgs a) + { + //if (a.PropertyName != "State") + //{ + // return; + //} + + SharingContentIsOnFeedback.FireUpdate(); + ReceivingContent.FireUpdate(); + try + { + + // Update the share status of the meeting info + if (MeetingInfo == null) + { + MeetingInfo = new MeetingInfo("", "", "", "", GetSharingStatus(), GetIsHostMyself(), true, false, MeetingIsLockedFeedback.BoolValue, MeetingIsRecordingFeedback.BoolValue, Status.Call.CallRecordInfo.AllowRecord); + return; + } + + var meetingInfo = new MeetingInfo(MeetingInfo.Id, MeetingInfo.Name, Participants.Host != null ? Participants.Host.Name : "None", + MeetingInfo.Password, GetSharingStatus(), GetIsHostMyself(), MeetingInfo.IsSharingMeeting, MeetingInfo.WaitingForHost, MeetingIsLockedFeedback.BoolValue, MeetingIsRecordingFeedback.BoolValue, Status.Call.CallRecordInfo.AllowRecord); + MeetingInfo = meetingInfo; + } + catch (Exception e) + { + Debug.Console(1, this, "Error processing state property update. {0}", e.Message); + Debug.Console(2, this, e.StackTrace); + MeetingInfo = new MeetingInfo("", "", "", "", "None", false, false, false, MeetingIsLockedFeedback.BoolValue, MeetingIsRecordingFeedback.BoolValue, false); + } + } + + /// + /// Subscribes to the PropertyChanged events on the state objects and fires the corresponding feedbacks. + /// + private void SetUpFeedbackActions() + { + // Set these up initially. + SetUpCallFeedbackActions(); + + Configuration.Audio.Output.PropertyChanged += (o, a) => + { + if (a.PropertyName == "Volume") + { + VolumeLevelFeedback.FireUpdate(); + MuteFeedback.FireUpdate(); + } + }; + + Configuration.Call.Microphone.PropertyChanged += (o, a) => + { + if (a.PropertyName == "Mute") + { + PrivacyModeIsOnFeedback.FireUpdate(); + } + }; + + Configuration.Video.PropertyChanged += (o, a) => + { + if (a.PropertyName == "HideConfSelfVideo") + { + SelfviewIsOnFeedback.FireUpdate(); + } + }; + Configuration.Video.Camera.PropertyChanged += (o, a) => + { + if (a.PropertyName == "SelectedId") + { + if (Cameras == null) + { + return; + } + + var camera = Cameras.FirstOrDefault(c => c.Key.IndexOf(Configuration.Video.Camera.SelectedId, StringComparison.OrdinalIgnoreCase) > -1); + if (camera != null) + { + Debug.Console(1, this, "Camera selected with key: '{0}'", camera.Key); + + SelectedCamera = camera; + + if (CameraIsMutedFeedback.BoolValue) + { + CameraMuteOff(); + } + } + else + { + Debug.Console(1, this, "No camera found with key: '{0}'", Configuration.Video.Camera.SelectedId); + } + } + }; + + Configuration.Call.Camera.PropertyChanged += (o, a) => + { + Debug.Console(1, this, "Configuration.Call.Camera.PropertyChanged: {0}", a.PropertyName); + + if (a.PropertyName != "Mute") return; + + CameraIsOffFeedback.FireUpdate(); + CameraAutoModeIsOnFeedback.FireUpdate(); + }; + + Configuration.Call.Layout.PropertyChanged += (o, a) => + { + switch (a.PropertyName) + { + case "Position": + { + ComputeSelfviewPipPositionStatus(); + + SelfviewPipPositionFeedback.FireUpdate(); + + break; + } + case "ShareThumb": + { + ContentSwappedWithThumbnailFeedback.FireUpdate(); + OnLayoutInfoChanged(); + break; + } + case "Style": + { + LocalLayoutFeedback.FireUpdate(); + OnLayoutInfoChanged(); + break; + } + case "Size": + { + // TODO: #714 [ ] SetupFeedbackActions >> Size + ComputeSelfviewPipSizeStatus(); + + SelfviewPipSizeFeedback.FireUpdate(); + + break; + } + } + }; + + Configuration.Call.Lock.PropertyChanged += (o, a) => + { + if (a.PropertyName == "Enable") + { + MeetingIsLockedFeedback.FireUpdate(); + MeetingInfo = new MeetingInfo + ( + MeetingInfo.Id, + MeetingInfo.Name, + MeetingInfo.Host, + MeetingInfo.Password, + GetSharingStatus(), + MeetingInfo.IsHost, + MeetingInfo.IsSharingMeeting, + MeetingInfo.WaitingForHost, + MeetingIsLockedFeedback.BoolValue, + MeetingIsRecordingFeedback.BoolValue, Status.Call.CallRecordInfo.AllowRecord + ); + } + }; + + // This is to deal with incorrect object structure coming back from the Zoom Room on v 5.6.3 + Configuration.Client.Call.Layout.PropertyChanged += (o, a) => + { + switch (a.PropertyName) + { + case "Position": + { + ComputeSelfviewPipPositionStatus(); + + SelfviewPipPositionFeedback.FireUpdate(); + + break; + } + case "ShareThumb": + { + ContentSwappedWithThumbnailFeedback.FireUpdate(); + OnLayoutInfoChanged(); + break; + } + case "Style": + { + LocalLayoutFeedback.FireUpdate(); + OnLayoutInfoChanged(); + break; + } + } + }; + + + Status.Sharing.PropertyChanged += (o, a) => + { + OnShareInfoChanged(Status.Sharing); + SharingSourceFeedback.FireUpdate(); + switch (a.PropertyName) + { + case "password": + break; + case "isSharingBlackMagic": + { + Debug.Console(2, this, "Updating sharing status: {0}", a.PropertyName); + + SharingContentIsOnFeedback.FireUpdate(); + if (MeetingInfo == null) + { + //Ignoring for now, as the CallInfo return will create the appropriate value + return; + } + // Update the share status of the meeting info + var meetingInfo = new MeetingInfo(MeetingInfo.Id, + MeetingInfo.Name, + MeetingInfo.Host, + MeetingInfo.Password, + GetSharingStatus(), + GetIsHostMyself(), + MeetingInfo.IsSharingMeeting, + MeetingInfo.WaitingForHost, + MeetingIsLockedFeedback.BoolValue, + MeetingIsRecordingFeedback.BoolValue, Status.Call.CallRecordInfo.AllowRecord); + MeetingInfo = meetingInfo; + break; + } + } + }; + + Status.PhoneCall.PropertyChanged += (o, a) => + { + switch (a.PropertyName) + { + case "IsIncomingCall": + Debug.Console(1, this, "Incoming Phone Call: {0}", Status.PhoneCall.IsIncomingCall); + break; + case "PeerDisplayName": + Debug.Console(1, this, "Peer Display Name: {0}", Status.PhoneCall.PeerDisplayName); + CallerIdNameFeedback.FireUpdate(); + break; + case "PeerNumber": + Debug.Console(1, this, "Peer Number: {0}", Status.PhoneCall.PeerNumber); + CallerIdNumberFeedback.FireUpdate(); + break; + case "OffHook": + Debug.Console(1, this, "Phone is OffHook: {0}", Status.PhoneCall.OffHook); + PhoneOffHookFeedback.FireUpdate(); + break; + } + }; + + Status.Layout.PropertyChanged += (o, a) => + { + Debug.Console(1, this, "Status.Layout.PropertyChanged a.PropertyName: {0}", a.PropertyName); + switch (a.PropertyName.ToLower()) + { + case "can_Switch_speaker_view": + case "can_switch_wall_view": + case "can_switch_strip_view": + case "video_type": + case "can_switch_share_on_all_screens": + { + ComputeAvailableLayouts(); + break; + } + case "is_in_first_page": + { + LayoutViewIsOnFirstPageFeedback.FireUpdate(); + break; + } + case "is_in_last_page": + { + LayoutViewIsOnLastPageFeedback.FireUpdate(); + break; + } + case "can_switch_floating_share_content": + { + CanSwapContentWithThumbnailFeedback.FireUpdate(); + break; + } + } + OnLayoutInfoChanged(); + }; + + Status.NumberOfScreens.PropertyChanged += (o, a) => + { + switch (a.PropertyName) + { + case "NumberOfScreens": + { + NumberOfScreensFeedback.FireUpdate(); + break; + } + } + }; + } + + private void SetUpDirectory() + { + DirectoryRoot = new CodecDirectory() {ResultsFolderId = "root"}; + + CurrentDirectoryResultIsNotDirectoryRoot = new BoolFeedback(() => CurrentDirectoryResult.ResultsFolderId != "root"); + + CurrentDirectoryResult = DirectoryRoot; + + DirectoryBrowseHistory = new List(); + DirectoryBrowseHistoryStack = new Stack(); + } + + private void SetUpRouting() + { + // Set up input ports + CreateOsdSource(); + InputPorts.Add(CodecOsdIn); + + // Set up output ports + OutputPorts.Add(Output1); + OutputPorts.Add(Output2); + } + + /// + /// Creates the fake OSD source, and connects it's AudioVideo output to the CodecOsdIn input + /// to enable routing + /// + private void CreateOsdSource() + { + OsdSource = new DummyRoutingInputsDevice(Key + "[osd]"); + DeviceManager.AddDevice(OsdSource); + var tl = new TieLine(OsdSource.AudioVideoOutputPort, CodecOsdIn); + TieLineCollection.Default.Add(tl); + + //foreach(var input in Status.Video. + } + + /// + /// Starts the HTTP feedback server and syncronizes state of codec + /// + /// + public override bool CustomActivate() + { + CrestronConsole.AddNewConsoleCommand(SetCommDebug, "SetCodecCommDebug", "0 for Off, 1 for on", + ConsoleAccessLevelEnum.AccessOperator); + if (!_props.DisablePhonebookAutoDownload) + { + CrestronConsole.AddNewConsoleCommand(s => SendText("zCommand Phonebook List Offset: 0 Limit: 10000"), + "GetZoomRoomContacts", "Triggers a refresh of the codec phonebook", + ConsoleAccessLevelEnum.AccessOperator); + } + + CrestronConsole.AddNewConsoleCommand(s => GetBookings(), "GetZoomRoomBookings", + "Triggers a refresh of the booking data for today", ConsoleAccessLevelEnum.AccessOperator); + + + + return base.CustomActivate(); + } + + #region Overrides of Device + + public override void Initialize() + { + var socket = Communication as ISocketStatus; + if (socket != null) + { + socket.ConnectionChange += socket_ConnectionChange; + } + + CommDebuggingIsOn = false; + + Communication.Connect(); + + CommunicationMonitor.Start(); + } + + #endregion + + public void SetCommDebug(string s) + { + if (s == "1") + { + CommDebuggingIsOn = true; + Debug.Console(1, this, "Comm Debug Enabled."); + } + else + { + CommDebuggingIsOn = false; + Debug.Console(1, this, "Comm Debug Disabled."); + } + } + + private void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e) + { + Debug.Console(1, this, "Socket status change {0}", e.Client.ClientStatus); + if (e.Client.IsConnected) + { + } + else + { + _syncState.CodecDisconnected(); + PhonebookSyncState.CodecDisconnected(); + } + } + + public void SendText(string command) + { + if (_meetingPasswordRequired) + { + Debug.Console(2, this, "Blocking commands to ZoomRoom while waiting for user to enter meeting password"); + return; + } + + if (_waitingForUserToAcceptOrRejectIncomingCall) + { + Debug.Console(2, this, "Blocking commands to ZoomRoom while waiting for user to accept or reject incoming call"); + return; + } + + if (CommDebuggingIsOn) + { + Debug.Console(1, this, "Sending: '{0}'", command); + } + + Communication.SendText(command + SendDelimiter); + } + + /// + /// Gathers responses and enqueues them. + /// + /// + /// + private void Port_LineReceived(object dev, GenericCommMethodReceiveTextArgs args) + { + //Debug.Console(0, this, "Port_LineReceived"); + + if (args.Delimiter != JsonDelimiter) + { +// Debug.Console(0, this, +//@"Non JSON response: +//Delimiter: {0} +//{1}", ComTextHelper.GetDebugText(args.Delimiter), args.Text); + ProcessNonJsonResponse(args.Text); + return; + } + else + { +// Debug.Console(0, this, +//@"JSON response: +//Delimiter: {0} +//{1}", ComTextHelper.GetDebugText(args.Delimiter), args.Text); + _receiveQueue.Enqueue(new ProcessStringMessage(args.Text, DeserializeResponse)); + //_receiveQueue.Enqueue(new ProcessStringMessage(args.Text, ProcessMessage)); + } + } + + /// + /// Queues the initial queries to be sent upon connection + /// + private void SetUpSyncQueries() + { + // zStatus + _syncState.AddQueryToQueue("zStatus Call Status"); + _syncState.AddQueryToQueue("zStatus Audio Input Line"); + _syncState.AddQueryToQueue("zStatus Audio Output Line"); + _syncState.AddQueryToQueue("zStatus Video Camera Line"); + _syncState.AddQueryToQueue("zStatus Video Optimizable"); + _syncState.AddQueryToQueue("zStatus Capabilities"); + _syncState.AddQueryToQueue("zStatus Sharing"); + _syncState.AddQueryToQueue("zStatus CameraShare"); + _syncState.AddQueryToQueue("zStatus Call Layout"); + _syncState.AddQueryToQueue("zStatus Call ClosedCaption Available"); + _syncState.AddQueryToQueue("zStatus NumberOfScreens"); + + // zConfiguration + + _syncState.AddQueryToQueue("zConfiguration Call Sharing optimize_video_sharing"); + _syncState.AddQueryToQueue("zConfiguration Call Microphone Mute"); + _syncState.AddQueryToQueue("zConfiguration Call Camera Mute"); + _syncState.AddQueryToQueue("zConfiguration Audio Input SelectedId"); + _syncState.AddQueryToQueue("zConfiguration Audio Input is_sap_disabled"); + _syncState.AddQueryToQueue("zConfiguration Audio Input reduce_reverb"); + _syncState.AddQueryToQueue("zConfiguration Audio Input volume"); + _syncState.AddQueryToQueue("zConfiguration Audio Output selectedId"); + _syncState.AddQueryToQueue("zConfiguration Audio Output volume"); + _syncState.AddQueryToQueue("zConfiguration Video hide_conf_self_video"); + _syncState.AddQueryToQueue("zConfiguration Video Camera selectedId"); + _syncState.AddQueryToQueue("zConfiguration Video Camera Mirror"); + _syncState.AddQueryToQueue("zConfiguration Client appVersion"); + _syncState.AddQueryToQueue("zConfiguration Client deviceSystem"); + _syncState.AddQueryToQueue("zConfiguration Call Layout ShareThumb"); + _syncState.AddQueryToQueue("zConfiguration Call Layout Style"); + _syncState.AddQueryToQueue("zConfiguration Call Layout Size"); + _syncState.AddQueryToQueue("zConfiguration Call Layout Position"); + _syncState.AddQueryToQueue("zConfiguration Call Lock Enable"); + _syncState.AddQueryToQueue("zConfiguration Call MuteUserOnEntry Enable"); + _syncState.AddQueryToQueue("zConfiguration Call ClosedCaption FontSize "); + _syncState.AddQueryToQueue("zConfiguration Call ClosedCaption Visible"); + + // zCommand + + if (!_props.DisablePhonebookAutoDownload) + { + _syncState.AddQueryToQueue("zCommand Phonebook List Offset: 0 Limit: 10000"); + } + + _syncState.AddQueryToQueue("zCommand Bookings List"); + _syncState.AddQueryToQueue("zCommand Call ListParticipants"); + _syncState.AddQueryToQueue("zCommand Call Info"); + + + _syncState.StartSync(); + } + + private void SetupSession() + { + // disable echo of commands + SendText("echo off"); + // switch to json format + // set feedback exclusions + // Currently the feedback exclusions don't work when using the API in JSON response mode + // But leave these here in case the API gets updated in the future + // These may work as of 5.9.4 + + // In 5.9.4 we're getting sent an AddedContact message for every contact in the phonebook on connect, which is redunant and way too much data + // We want to exclude these messages right away until after we've retrieved the entire phonebook and then we can re-enable them + SendText("zFeedback Register Op: ex Path: /Event/Phonebook/AddedContact"); + + SendText("zFeedback Register Op: ex Path: /Event/InfoResult/Info/callin_country_list"); + SendText("zFeedback Register Op: ex Path: /Event/InfoResult/Info/callout_country_list"); + SendText("zFeedback Register Op: ex Path: /Event/InfoResult/Info/toll_free_callinLlist"); + + SendText("zStatus SystemUnit"); + } + + /// + /// Removes the feedback exclusion for added contacts + /// + private void ResubscribeForAddedContacts() + { + SendText("zFeedback Register Op: in Path: /Event/Phonebook/AddedContact"); + } + + /// + /// Processes non-JSON responses as their are received + /// + /// + private void ProcessNonJsonResponse(string response) + { + if (response.Contains("client_loop: send disconnect: Broken pipe")) + { + Debug.Console(1, this, Debug.ErrorLogLevel.Error, + "Zoom Room Controller or App connected. Essentials will NOT control the Zoom Room until it is disconnected."); + + return; + } + + if (!_syncState.InitialSyncComplete) + { + if(response.ToLower().Contains("*r login successful")) + { + _syncState.LoginResponseReceived(); + + SendText("format json"); + + SetupSession(); + } + + //switch (response.Trim().ToLower()) // remove the whitespace + //{ + // case "*r login successful": + // { + // _syncState.LoginMessageReceived(); + + // //// Fire up a thread to send the intial commands. + // //CrestronInvoke.BeginInvoke(o => + // //{ + // // disable echo of commands + // SendText("echo off"); + // // switch to json format + // SendText("format json"); + // // set feedback exclusions + // // Currently the feedback exclusions don't work when using the API in JSON response mode + // // But leave these here in case the API gets updated in the future + // // These may work as of 5.9.4 + // if (_props.DisablePhonebookAutoDownload) + // { + // SendText("zFeedback Register Op: ex Path: /Event/Phonebook/AddedContact"); + // } + // SendText("zFeedback Register Op: ex Path: /Event/InfoResult/Info/callin_country_list"); + // SendText("zFeedback Register Op: ex Path: /Event/InfoResult/Info/callout_country_list"); + // SendText("zFeedback Register Op: ex Path: /Event/InfoResult/Info/toll_free_callinLlist"); + + // //}); + + // break; + // } + //} + } + } + + /// + /// Processes messages as they are dequeued + /// + /// + private void ProcessMessage(string message) + { + // Counts the curly braces + if (message.Contains("client_loop: send disconnect: Broken pipe")) + { + Debug.Console(1, this, Debug.ErrorLogLevel.Error, + "Zoom Room Controller or App connected. Essentials will NOT control the Zoom Room until it is disconnected."); + + return; + } + + if (message.Contains('{')) + { + _jsonCurlyBraceCounter++; + } + + if (message.Contains('}')) + { + _jsonCurlyBraceCounter--; + } + + //Debug.Console(2, this, "JSON Curly Brace Count: {0}", _jsonCurlyBraceCounter); + + if (!_jsonFeedbackMessageIsIncoming && message.Trim('\x20') == "{" + EchoDelimiter) + // Check for the beginning of a new JSON message + { + _jsonFeedbackMessageIsIncoming = true; + _jsonCurlyBraceCounter = 1; // reset the counter for each new message + + _jsonMessage = new StringBuilder(); + + _jsonMessage.Append(message); + + if (CommDebuggingIsOn) + { + Debug.Console(2, this, "Incoming JSON message..."); + } + + return; + } + if (_jsonFeedbackMessageIsIncoming && message.Trim('\x20') == "}" + EchoDelimiter) + // Check for the end of a JSON message + { + _jsonMessage.Append(message); + + if (_jsonCurlyBraceCounter == 0) + { + _jsonFeedbackMessageIsIncoming = false; + + if (CommDebuggingIsOn) + { + Debug.Console(2, this, "Complete JSON Received:\n{0}", _jsonMessage.ToString()); + } + + // Forward the complete message to be deserialized + DeserializeResponse(_jsonMessage.ToString()); + } + + //JsonMessage = new StringBuilder(); + return; + } + + // NOTE: This must happen after the above conditions have been checked + // Append subsequent partial JSON fragments to the string builder + if (_jsonFeedbackMessageIsIncoming) + { + _jsonMessage.Append(message); + + //Debug.Console(1, this, "Building JSON:\n{0}", JsonMessage.ToString()); + return; + } + + if (CommDebuggingIsOn) + { + Debug.Console(1, this, "Non-JSON response: '{0}'", message); + } + + _jsonCurlyBraceCounter = 0; // reset on non-JSON response + + if (!_syncState.InitialSyncComplete) + { + switch (message.Trim().ToLower()) // remove the whitespace + { + case "*r login successful": + { + _syncState.LoginResponseReceived(); + + + // Fire up a thread to send the intial commands. + CrestronInvoke.BeginInvoke(o => + { + // Currently the feedback exclusions don't work when using the API in JSON response mode + // But leave these here in case the API gets updated in the future + + + Thread.Sleep(100); + // disable echo of commands + SendText("echo off"); + Thread.Sleep(100); + // set feedback exclusions + SendText("zFeedback Register Op: ex Path: /Event/InfoResult/Info/callin_country_list"); + Thread.Sleep(100); + SendText("zFeedback Register Op: ex Path: /Event/InfoResult/Info/callout_country_list"); + Thread.Sleep(100); + SendText("zFeedback Register Op: ex Path: /Event/InfoResult/Info/toll_free_callinLlist"); + Thread.Sleep(100); + + if (_props.DisablePhonebookAutoDownload) + { + SendText("zFeedback Register Op: ex Path: /Event/Phonebook/AddedContact"); + } + // switch to json format + SendText("format json"); + }); + + break; + } + } + } + } + + /// + /// Deserializes a JSON formatted response + /// + /// + private void DeserializeResponse(string response) + { + try + { + var trimmedResponse = response.Trim(); + + if (trimmedResponse.Length <= 0) + { + return; + } + + var message = JObject.Parse(trimmedResponse); + + if (!_syncState.FirstJsonResponseWasReceived) + { + _syncState.ReceivedFirstJsonResponse(); + } + + var eType = + (eZoomRoomResponseType) + Enum.Parse(typeof (eZoomRoomResponseType), message["type"].Value(), true); + + var topKey = message["topKey"].Value(); + + var responseObj = message[topKey]; + + Debug.Console(1, this, "{0} Response Received. topKey: '{1}'\n{2}", eType, topKey, responseObj.ToString().Replace("\n", CrestronEnvironment.NewLine)); + + switch (eType) + { + case eZoomRoomResponseType.zConfiguration: + { + switch (topKey.ToLower()) + { + case "call": + { + JsonConvert.PopulateObject(responseObj.ToString(), Configuration.Call); + + break; + } + case "audio": + { + JsonConvert.PopulateObject(responseObj.ToString(), Configuration.Audio); + + break; + } + case "video": + { + JsonConvert.PopulateObject(responseObj.ToString(), Configuration.Video); + + break; + } + case "client": + { + JsonConvert.PopulateObject(responseObj.ToString(), Configuration.Client); + + break; + } + default: + { + break; + } + } + break; + } + case eZoomRoomResponseType.zCommand: + { + switch (topKey.ToLower()) + { + case "inforesult": + { + JsonConvert.PopulateObject(responseObj.ToString(), Status.Call.Info); + break; + } + case "phonebooklistresult": + { + // This result will always be the complete contents of the directory and never + // A subset of the results via a search + + // Clear out any existing data + Status.Phonebook = new zStatus.Phonebook(); + + JsonConvert.PopulateObject(responseObj.ToString(), Status.Phonebook); + + UpdateDirectory(); + + break; + } + case "listparticipantsresult": + { + Debug.Console(1, this, "JTokenType: {0}", responseObj.Type); + + switch (responseObj.Type) + { + case JTokenType.Array: + Status.Call.Participants = + JsonConvert.DeserializeObject>( + responseObj.ToString()); + break; + case JTokenType.Object: + { + // this is a single participant event notification + + var participant = + JsonConvert.DeserializeObject( + responseObj.ToString()); + + if (participant != null) + { + Debug.Console(1, this, + "[DeserializeResponse] zCommands.listparticipantresult - participant.event: {0} **********************************", + participant.Event); + Debug.Console(1, this, + "[DeserializeResponse] zCommands.listparticipantresult - participant.event: {0} - UserId: {1} Name: {2} IsHost: {3}", + participant.Event, participant.UserId, participant.UserName, participant.IsHost); + + switch (participant.Event) + { + case "ZRCUserChangedEventUserInfoUpdated": + case "ZRCUserChangedEventLeftMeeting": + { + var existingParticipant = + Status.Call.Participants.FirstOrDefault( + p => p.UserId.Equals(participant.UserId)); + + if (existingParticipant != null) + { + switch (participant.Event) + { + case "ZRCUserChangedEventLeftMeeting": + Status.Call.Participants.Remove(existingParticipant); + break; + case "ZRCUserChangedEventUserInfoUpdated": + JsonConvert.PopulateObject(responseObj.ToString(), + existingParticipant); + break; + } + } + } + break; + case "ZRCUserChangedEventJoinedMeeting": + { + var existingParticipant = + Status.Call.Participants.FirstOrDefault(p => p.UserId.Equals(participant.UserId)); + + if (existingParticipant != null) + { + Debug.Console(1, this, + "[DeserializeResponse] zCommands.listparticipantresult - participant.event: {0} ...updating matching UserId participant with UserId: {1} UserName: {2}", + participant.Event, participant.UserId, participant.UserName); + + JsonConvert.PopulateObject(responseObj.ToString(), existingParticipant); + } + else + { + Debug.Console(1, this, + "[DeserializeResponse] zCommands.listparticipantresult - participant.event: {0} ...adding participant with UserId: {1} UserName: {2}", + participant.Event, participant.UserId, participant.UserName); + + Status.Call.Participants.Add(participant); + } + + break; + } + } + + Debug.Console(1, this, + "[DeserializeResponse] zCommands.listparticipantresult - participant.event: {0} ***********************************", + participant.Event); + } + } + break; + } + + var participants = + zCommand.ListParticipant.GetGenericParticipantListFromParticipantsResult( + Status.Call.Participants); + + Participants.CurrentParticipants = participants; + + // Update the share status of the meeting info + var meetingInfo = new MeetingInfo( + MeetingInfo.Id, + MeetingInfo.Name, + Participants.Host.Name, + MeetingInfo.Password, + GetSharingStatus(), + GetIsHostMyself(), + MeetingInfo.IsSharingMeeting, + MeetingInfo.WaitingForHost, + MeetingIsLockedFeedback.BoolValue, + MeetingIsRecordingFeedback.BoolValue, + Status.Call.CallRecordInfo.AllowRecord + ); + MeetingInfo = meetingInfo; + + PrintCurrentCallParticipants(); + + break; + } + default: + { + break; + } + } + break; + } + case eZoomRoomResponseType.zEvent: + { + switch (topKey.ToLower()) + { + case "phonebook": + { + zStatus.Contact contact = new zStatus.Contact(); + + if (responseObj["Updated Contact"] != null) + { + contact = responseObj["Updated Contact"].ToObject(); + } + else if (responseObj["Added Contact"] != null) + { + contact = responseObj["Added Contact"].ToObject(); + } + + var existingContactIndex = Status.Phonebook.Contacts.FindIndex(c => c.Jid.Equals(contact.Jid)); + + if (existingContactIndex > 0) + { + Status.Phonebook.Contacts[existingContactIndex] = contact; + } + else + { + Status.Phonebook.Contacts.Add(contact); + } + + if(contactsDebounceTimer == null) + { + contactsDebounceTimer = new CTimer(o => UpdateDirectory(), 2000); + } + else + { + contactsDebounceTimer.Reset(); + } + + break; + } + case "bookingslistresult": + { + if (!_syncState.InitialSyncComplete) + { + _syncState.LastQueryResponseReceived(); + } + + var codecBookings = JsonConvert.DeserializeObject>( + responseObj.ToString()); + + if (codecBookings != null && codecBookings.Count > 0) + { + CodecSchedule.Meetings = zCommand.GetGenericMeetingsFromBookingResult( + codecBookings, CodecSchedule.MeetingWarningMinutes); + } + else + { + //need to clear the list if it's empty + CodecSchedule.Meetings = new List(); + } + + break; + } + case "bookings updated": + { + GetBookings(); + + break; + } + case "sharingstate": + { + JsonConvert.PopulateObject(responseObj.ToString(), Status.Call.Sharing); + + SetDefaultLayout(); + + break; + } + case "incomingcallindication": + { + var incomingCall = + JsonConvert.DeserializeObject(responseObj.ToString()); + + if (incomingCall != null) + { + var newCall = new CodecActiveCallItem + { + Direction = eCodecCallDirection.Incoming, + Status = eCodecCallStatus.Ringing, + Type = eCodecCallType.Video, + Name = incomingCall.callerName, + Id = incomingCall.callerJID + }; + + _waitingForUserToAcceptOrRejectIncomingCall = true; + + ActiveCalls.Add(newCall); + + OnCallStatusChange(newCall); + } + + break; + } + case "treatedincomingcallindication": + { + var incomingCall = + JsonConvert.DeserializeObject(responseObj.ToString()); + + if (incomingCall != null) + { + var existingCall = + ActiveCalls.FirstOrDefault(c => c.Id.Equals(incomingCall.callerJID)); + + if (existingCall != null) + { + existingCall.Status = !incomingCall.accepted + ? eCodecCallStatus.Disconnected + : eCodecCallStatus.Connecting; + + OnCallStatusChange(existingCall); + } + + _waitingForUserToAcceptOrRejectIncomingCall = false; + + UpdateCallStatus(); + } + + break; + } + case "calldisconnect": + { + var disconnectEvent = + JsonConvert.DeserializeObject(responseObj.ToString()); + + Debug.Console(1, this, + "[DeserializeResponse] zEvent.calldisconnect ********************************************"); + Debug.Console(1, this, "[DeserializeResponse] zEvent.calldisconnect - disconnectEvent.Successful: {0}", + disconnectEvent.Successful); + + if (disconnectEvent.Successful) + { + if (ActiveCalls.Count > 0) + { + var activeCall = ActiveCalls.FirstOrDefault(c => c.IsActiveCall); + + if (activeCall != null) + { + Debug.Console(1, this, + "[DeserializeResponse] zEvent.calldisconnect - ActiveCalls.Count: {0} activeCall.Id: {1}, activeCall.Number: {2} activeCall.Name: {3}, activeCall.IsActive: {4}", + ActiveCalls.Count, activeCall.Id, activeCall.Number, activeCall.Name, activeCall.IsActiveCall); + activeCall.Status = eCodecCallStatus.Disconnected; + + OnCallStatusChange(activeCall); + } + } + } + + Debug.Console(1, this, + "[DeserializeResponse] zEvent.calldisconnect ********************************************"); + + UpdateCallStatus(); + break; + } + case "callconnecterror": + { + UpdateCallStatus(); + break; + } + case "videounmuterequest": + { + var handler = VideoUnmuteRequested; + + if (handler != null) + { + handler(this, null); + } + + break; + } + case "meetingneedspassword": + { + var meetingNeedsPassword = + responseObj.ToObject(); + + if (meetingNeedsPassword.NeedsPassword) + { + var prompt = "Password required to join this meeting. Please enter the meeting password."; + + OnPasswordRequired(meetingNeedsPassword.WrongAndRetry, false, false, prompt); + } + else + { + OnPasswordRequired(false, false, true, ""); + } + + break; + } + case "needwaitforhost": + { + Status.NeedWaitForHost = JsonConvert.DeserializeObject(responseObj.ToString()); + + Debug.Console(1, this, "WaitingForHost: {0}", Status.NeedWaitForHost.Wait); + + if (Status.NeedWaitForHost.Wait) + { + if (MeetingInfo == null) + { + MeetingInfo = new MeetingInfo("Waiting For Host", "Waiting For Host", "Waiting For Host", "", + GetSharingStatus(), false, false, true, MeetingIsLockedFeedback.BoolValue, MeetingIsRecordingFeedback.BoolValue, Status.Call.CallRecordInfo.AllowRecord); + + UpdateCallStatus(); + break; + } + + MeetingInfo = new MeetingInfo("Waiting For Host", "Waiting For Host", "Waiting For Host", "", + GetSharingStatus(), false, false, true, MeetingIsLockedFeedback.BoolValue, MeetingIsRecordingFeedback.BoolValue, Status.Call.CallRecordInfo.AllowRecord); + + UpdateCallStatus(); + + break; + } + + if (MeetingInfo == null) + { + MeetingInfo = new MeetingInfo("Waiting For Host", "Waiting For Host", "Waiting For Host", "", + GetSharingStatus(), false, false, false, MeetingIsLockedFeedback.BoolValue, MeetingIsRecordingFeedback.BoolValue, Status.Call.CallRecordInfo.AllowRecord); + break; + } + + MeetingInfo = new MeetingInfo(MeetingInfo.Id, MeetingInfo.Name, MeetingInfo.Host, MeetingInfo.Password, + GetSharingStatus(), GetIsHostMyself(), false, false, MeetingIsLockedFeedback.BoolValue, MeetingIsRecordingFeedback.BoolValue, Status.Call.CallRecordInfo.AllowRecord); + + break; + } + case "openvideofailforhoststop": + { + // TODO: notify user that host has disabled unmuting video + break; + } + case "updatecallrecordinfo": + { + JsonConvert.PopulateObject(responseObj.ToString(), Status.Call.CallRecordInfo); + + break; + } + case "recordingconsent": + { + _recordConsentPromptIsVisible = responseObj["isShow"].Value(); + RecordConsentPromptIsVisible.FireUpdate(); + break; + } + case "phonecallstatus": + { + JsonConvert.PopulateObject(responseObj.ToString(), Status.PhoneCall); + break; + } + case "pinstatusofscreennotification": + { + var status = responseObj.ToObject(); + + Debug.Console(1, this, "Pin Status notification for UserId: {0}, ScreenIndex: {1}", status.PinnedUserId, + status.ScreenIndex); + + Participant alreadyPinnedParticipant = null; + + // Check for a participant already pinned to the same screen index. + if (status.PinnedUserId > 0) + { + alreadyPinnedParticipant = + Participants.CurrentParticipants.FirstOrDefault(p => p.ScreenIndexIsPinnedToFb.Equals(status.ScreenIndex)); + + // Make sure that the already pinned participant isn't the same ID as for this message. If true, clear the pinned fb. + if (alreadyPinnedParticipant != null && alreadyPinnedParticipant.UserId != status.PinnedUserId) + { + Debug.Console(1, this, "Participant: {0} with id: {1} already pinned to screenIndex {2}. Clearing pinned fb.", + alreadyPinnedParticipant.Name, alreadyPinnedParticipant.UserId, + alreadyPinnedParticipant.ScreenIndexIsPinnedToFb); + alreadyPinnedParticipant.IsPinnedFb = false; + alreadyPinnedParticipant.ScreenIndexIsPinnedToFb = -1; + } + } + + var participant = Participants.CurrentParticipants.FirstOrDefault(p => p.UserId.Equals(status.PinnedUserId)); + + if (participant != null) + { + participant.IsPinnedFb = true; + participant.ScreenIndexIsPinnedToFb = status.ScreenIndex; + } + else + { + participant = + Participants.CurrentParticipants.FirstOrDefault(p => p.ScreenIndexIsPinnedToFb.Equals(status.ScreenIndex)); + + if (participant == null && alreadyPinnedParticipant == null) + { + Debug.Console(1, this, "no matching participant found by pinned_user_id: {0} or screen_index: {1}", + status.PinnedUserId, status.ScreenIndex); + return; + } + else if (participant != null) + { + Debug.Console(2, this, "Unpinning {0} with id: {1} from screen index: {2}", participant.Name, + participant.UserId, status.ScreenIndex); + participant.IsPinnedFb = false; + participant.ScreenIndexIsPinnedToFb = -1; + } + } + + // fire the event as we've modified the participants list + Participants.OnParticipantsChanged(); + + break; + } + case "startlocalpresentmeeting": + { + var result = JsonConvert.DeserializeObject(responseObj.ToString()); + + if (result.Success) + { + MeetingInfo = new MeetingInfo("", "", "", "", GetSharingStatus(), true, true, MeetingInfo.WaitingForHost, MeetingIsLockedFeedback.BoolValue, MeetingIsRecordingFeedback.BoolValue, Status.Call.CallRecordInfo.AllowRecord); + break; + } + + break; + } + default: + { + break; + } + } + break; + } + case eZoomRoomResponseType.zStatus: + { + switch (topKey.ToLower()) + { + case "login": + { + _syncState.LoginResponseReceived(); + + SetupSession(); + + JsonConvert.PopulateObject(responseObj.ToString(), Status.Login); + + break; + } + case "systemunit": + { + + JsonConvert.PopulateObject(responseObj.ToString(), Status.SystemUnit); + + break; + } + case "call": + { + JsonConvert.PopulateObject(responseObj.ToString(), Status.Call); + + Debug.Console(1, this, + "[DeserializeResponse] zStatus.call - Status.Call.Info.meeting_id: {0} Status.Call.Info.meeting_list_item.meetingName: {1}", + Status.Call.Info.meeting_id, Status.Call.Info.meeting_list_item.meetingName); + foreach (var participant in Status.Call.Participants) + { + Debug.Console(1, this, + "[DeserializeResponse] zStatus.call - Status.Call.Participants participant.UserId: {0} participant.UserName: {1}", + participant.UserId, participant.UserName); + } + + UpdateCallStatus(); + + break; + } + case "capabilities": + { + JsonConvert.PopulateObject(responseObj.ToString(), Status.Capabilities); + break; + } + case "sharing": + { + JsonConvert.PopulateObject(responseObj.ToString(), Status.Sharing); + + break; + } + case "numberofscreens": + { + JsonConvert.PopulateObject(responseObj.ToString(), Status.NumberOfScreens); + break; + } + case "video": + { + JsonConvert.PopulateObject(responseObj.ToString(), Status.Video); + break; + } + case "camerashare": + { + JsonConvert.PopulateObject(responseObj.ToString(), Status.CameraShare); + break; + } + case "layout": + { + JsonConvert.PopulateObject(responseObj.ToString(), Status.Layout); + break; + } + case "audio input line": + { + JsonConvert.PopulateObject(responseObj.ToString(), Status.AudioInputs); + break; + } + case "audio output line": + { + JsonConvert.PopulateObject(responseObj.ToString(), Status.AudioOuputs); + break; + } + case "video camera line": + { + Status.Cameras.Clear(); + + JsonConvert.PopulateObject(responseObj.ToString(), Status.Cameras); + + if (!_syncState.CamerasHaveBeenSetUp) + { + SetUpCameras(); + } + + break; + } + default: + { + break; + } + } + + break; + } + default: + { + Debug.Console(1, "Unknown Response Type:"); + break; + } + } + } + catch (Exception ex) + { + Debug.Console(1, this, "Error Deserializing feedback: {0}", ex.Message); + Debug.Console(2, this, "{0}", ex); + + if (ex.InnerException != null) + { + Debug.Console(1, this,"Error Deserializing feedback inner exception: {0}", ex.InnerException.Message); + Debug.Console(2, this, "{0}", ex.InnerException.StackTrace); + } + } + } + + private void SetDefaultLayout() + { + if (!_props.AutoDefaultLayouts) return; + + if ( + (Status.Call.Sharing.State == zEvent.eSharingState.Receiving || + Status.Call.Sharing.State == zEvent.eSharingState.Sending)) + { + SendText(String.Format("zconfiguration call layout style: {0}", + _props.DefaultSharingLayout)); + } + else + { + if (_props.DefaultCallLayout == (_props.DefaultCallLayout & AvailableLayouts)) + { + SendText(String.Format("zconfiguration call layout style: {0}", + _props.DefaultCallLayout)); + } + else + Debug.Console(0, this, "Unable to set default Layout. {0} not currently an available layout based on meeting state", _props.DefaultCallLayout); + } + } + + /// + /// Retrieves the current call participants list + /// + public void GetCurrentCallParticipants() + { + SendText("zCommand Call ListParticipants"); + } + + /// + /// Prints the current call particiapnts list + /// + public void PrintCurrentCallParticipants() + { + if (Debug.Level <= 0) return; + + Debug.Console(1, this, "*************************** Call Participants **************************"); + foreach (var participant in Participants.CurrentParticipants) + { + Debug.Console(1, this, "UserId: {3} Name: {0} Audio: {1} IsHost: {2}", + participant.Name, participant.AudioMuteFb, participant.IsHost, participant.UserId); + } + Debug.Console(1, this, "************************************************************************"); + } + + /// + /// Retrieves bookings list + /// + private void GetBookings() + { + if (_meetingPasswordRequired || _waitingForUserToAcceptOrRejectIncomingCall) return; + + SendText("zCommand Bookings List"); + } + + + /// + /// Updates the current call status + /// + private void UpdateCallStatus() + { + Debug.Console(1, this, + "[UpdateCallStatus] Current Call Status: {0} Active Call Count: {1} Need Wait For Host: {2}", + Status.Call != null ? Status.Call.Status.ToString() : "no call", ActiveCalls.Count, Status.NeedWaitForHost.Wait); + + if (Status.Call != null) + { + var callStatus = Status.Call.Status; + + // If not crrently in a meeting, intialize the call object + if (callStatus != zStatus.eCallStatus.IN_MEETING && callStatus != zStatus.eCallStatus.CONNECTING_MEETING) + { + Status.Call = new zStatus.Call {Status = callStatus}; + // Resubscribe to all property change events after Status.Call is reconstructed + SetUpCallFeedbackActions(); + + OnCallStatusChange(new CodecActiveCallItem() {Status = eCodecCallStatus.Disconnected}); + } + + if (ActiveCalls.Count == 0) + { + if (callStatus == zStatus.eCallStatus.CONNECTING_MEETING || + callStatus == zStatus.eCallStatus.IN_MEETING) + { + var newStatus = eCodecCallStatus.Unknown; + + switch (callStatus) + { + case zStatus.eCallStatus.CONNECTING_MEETING: + newStatus = eCodecCallStatus.Connecting; + break; + case zStatus.eCallStatus.IN_MEETING: + newStatus = eCodecCallStatus.Connected; + break; + } + + if (!string.IsNullOrEmpty(Status.Call.Info.meeting_id)) + { + var newCall = new CodecActiveCallItem + { + Name = Status.Call.Info.meeting_list_item.meetingName, + Number = Status.Call.Info.meeting_list_item.meetingNumber, + Id = Status.Call.Info.meeting_id, + Status = newStatus, + Type = eCodecCallType.Video, + }; + + if (!String.IsNullOrEmpty(_lastDialedMeetingNumber)) + { + _lastDialedMeetingNumber = String.Empty; + } + ActiveCalls.Add(newCall); + + OnCallStatusChange(newCall); + } else if (String.IsNullOrEmpty(Status.Call.Info.meeting_id) && Status.NeedWaitForHost.Wait) + { + var newCall = new CodecActiveCallItem + { + Name = "Waiting For Host", + Number = "Waiting For Host", + Id = "Waiting For Host", + Status = newStatus, + Type = eCodecCallType.Video, + }; + + if (!String.IsNullOrEmpty(_lastDialedMeetingNumber)) + { + _lastDialedMeetingNumber = String.Empty; + } + + ActiveCalls.Add(newCall); + + OnCallStatusChange(newCall); + } + } + } + else + { + var existingCall = ActiveCalls.FirstOrDefault(c => !c.Status.Equals(eCodecCallStatus.Ringing)); + + switch (callStatus) + { + case zStatus.eCallStatus.IN_MEETING: + if (Status.NeedWaitForHost.Wait) + { + Status.NeedWaitForHost.Wait = false; + } + existingCall.Status = eCodecCallStatus.Connected; + break; + case zStatus.eCallStatus.NOT_IN_MEETING: + if (Status.NeedWaitForHost.Wait) + { + Status.NeedWaitForHost.Wait = false; + } + existingCall.Status = eCodecCallStatus.Disconnected; + break; + } + + Debug.Console(1, this, "[UpdateCallStatus] ELSE ActiveCalls.Count == {1} - Current Call Status: {0}", + Status.Call != null ? Status.Call.Status.ToString() : "no call", ActiveCalls.Count); + + + OnCallStatusChange(existingCall); + } + } + + Debug.Console(1, this, "[UpdateCallStatus] Active Calls ------------------------------"); + + // Clean up any disconnected calls left in the list + for (int i = 0; i < ActiveCalls.Count; i++) + { + var call = ActiveCalls[i]; + + Debug.Console(1, this, + @"ID: {1} + Number: {5} + Name: {0} + IsActive: {2} + Status: {3} + Direction: {4} + IsActiveCall: {6}", call.Name, call.Id, call.IsActiveCall, call.Status, call.Direction, call.Number, + call.IsActiveCall); + + if (!call.IsActiveCall) + { + Debug.Console(1, this, "[UpdateCallStatus] Removing Inactive call.Id: {1} call.Name: {0}", call.Name, call.Id); + ActiveCalls.Remove(call); + } + } + Debug.Console(1, this, "[UpdateCallStatus] Active Calls ------------------------------"); + + //clear participants list after call cleanup + var emptyList = new List(); + Participants.CurrentParticipants = emptyList; + if (ActiveCalls.Count > 0) GetCurrentCallParticipants(); + } + + protected override void OnCallStatusChange(CodecActiveCallItem item) + { + if (item.Status == eCodecCallStatus.Connected) + { + + var host = ""; + + if (Participants.Host != null) + host = Participants.Host.Name; + + MeetingInfo = new MeetingInfo( + Status.Call.Info.meeting_id, + Status.Call.Info.meeting_list_item.meetingName, + host, + Status.Call.Info.meeting_password, + GetSharingStatus(), + GetIsHostMyself(), + !String.Equals(Status.Call.Info.meeting_type,"NORMAL"), + false, + MeetingIsLockedFeedback.BoolValue, + MeetingIsRecordingFeedback.BoolValue, Status.Call.CallRecordInfo.AllowRecord + ); + + SetDefaultLayout(); + } + + else if (item.Status == eCodecCallStatus.Disconnected) + { + MeetingInfo = new MeetingInfo( + string.Empty, + string.Empty, + string.Empty, + string.Empty, + string.Empty, + false, + false, + false, + false, + false, Status.Call.CallRecordInfo.AllowRecord + ); + } + + _meetingPasswordRequired = false; + base.OnCallStatusChange(item); + + Debug.Console(1, this, "[OnCallStatusChange] Current Call Status: {0}", + Status.Call != null ? Status.Call.Status.ToString() : "no call"); + } + + private string GetSharingStatus() + { + string sharingState = "None"; + + try + { + if (Status.Call.Sharing.State == zEvent.eSharingState.Receiving) + { + sharingState = "Receiving Content"; + } + if (Status.Sharing.isAirHostClientConnected) + { + sharingState = "Sharing AirPlay"; + } + if (Status.Sharing.isDirectPresentationConnected) + { + sharingState = "Sharing Laptop"; + } + if (Status.Sharing.isSharingBlackMagic) + { + sharingState = "Sharing HDMI Source"; + } + + return sharingState; + } + catch (Exception e) + { + Debug.Console(1, this, "Exception getting sharing status: {0}", e.Message); + Debug.Console(2, this, "{0}", e.StackTrace); + return sharingState; + } + } + + private void UpdateDirectory() + { + Debug.Console(2, this, "Updating directory"); + var directoryResults = zStatus.Phonebook.ConvertZoomContactsToGeneric(Status.Phonebook.Contacts); + + if (!PhonebookSyncState.InitialSyncComplete) + { + PhonebookSyncState.InitialPhonebookFoldersReceived(); + PhonebookSyncState.PhonebookRootEntriesReceived(); + PhonebookSyncState.SetPhonebookHasFolders(true); + PhonebookSyncState.SetNumberOfContacts(Status.Phonebook.Contacts.Count); + } + + directoryResults.ResultsFolderId = "root"; + + DirectoryRoot = directoryResults; + + CurrentDirectoryResult = directoryResults; + + // + if (contactsDebounceTimer != null) + { + ClearContactDebounceTimer(); + } + } + + private void ClearContactDebounceTimer() + { + Debug.Console(2, this, "Clearing Timer"); + if (!contactsDebounceTimer.Disposed && contactsDebounceTimer != null) + { + contactsDebounceTimer.Dispose(); + contactsDebounceTimer = null; + } + } + + /// + /// Will return true if the host is myself (this zoom room) + /// + /// + private bool GetIsHostMyself() + { + try + { + if (Participants.CurrentParticipants.Count == 0) + { + Debug.Console(2, this, "No current participants"); + return false; + } + + var host = Participants.Host; + + if(host == null) + { + Debug.Console(2, this, "Host is currently null"); + return false; + } + Debug.Console(2, this, "Host is: '{0}' IsMyself?: {1}", host.Name, host.IsMyself); + return host.IsMyself; + } + catch (Exception e) + { + Debug.Console(1, "Exception getting isHost: {0}", e.Message); + Debug.Console(2, "{0}", e.StackTrace); + return false; + } + } + + /// + /// Starts sharing HDMI source + /// + public override void StartSharing() + { + SendText("zCommand Call Sharing HDMI Start"); + } + + /// + /// Stops sharing the current presentation + /// + public override void StopSharing() + { + if (Status.Sharing.isSharingBlackMagic) + { + SendText("zCommand Call Sharing HDMI Stop"); + } + else + { + SendText("zCommand Call Sharing Disconnect"); + } + } + + public override void PrivacyModeOn() + { + SendText("zConfiguration Call Microphone Mute: on"); + } + + public override void PrivacyModeOff() + { + SendText("zConfiguration Call Microphone Mute: off"); + } + + public override void PrivacyModeToggle() + { + if (PrivacyModeIsOnFeedback.BoolValue) + { + PrivacyModeOff(); + } + else + { + PrivacyModeOn(); + } + } + + public override void MuteOff() + { + Debug.Console(2, this, "Unmuting to previous level: {0}", _previousVolumeLevel); + SetVolume((ushort) _previousVolumeLevel); + } + + public override void MuteOn() + { + SetVolume(0); + } + + public override void MuteToggle() + { + if (MuteFeedback.BoolValue) + { + MuteOff(); + } + else + { + MuteOn(); + } + } + + + /// + /// Increments the voluem + /// + /// + public override void VolumeUp(bool pressRelease) + { + // TODO: Implment volume decrement that calls SetVolume() + } + + /// + /// Decrements the volume + /// + /// + public override void VolumeDown(bool pressRelease) + { + // TODO: Implment volume decrement that calls SetVolume() + } + + /// + /// Scales the level and sets the codec to the specified level within its range + /// + /// level from slider (0-65535 range) + public override void SetVolume(ushort level) + { + var scaledLevel = CrestronEnvironment.ScaleWithLimits(level, 65535, 0, 100, 0); + SendText(string.Format("zConfiguration Audio Output volume: {0}", scaledLevel)); + } + + /// + /// Recalls the default volume on the codec + /// + public void VolumeSetToDefault() + { + } + + /// + /// + /// + public override void StandbyActivate() + { + // No corresponding function on device + } + + /// + /// + /// + public override void StandbyDeactivate() + { + // No corresponding function on device + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new ZoomRoomJoinMap(joinStart); + + var customJoins = JoinMapHelper.TryGetJoinMapAdvancedForDevice(joinMapKey); + + if (customJoins != null) + { + joinMap.SetCustomJoinData(customJoins); + } + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + + LinkVideoCodecToApi(this, trilist, joinMap); + + LinkZoomRoomToApi(trilist, joinMap); + } + + /// + /// Links all the specific Zoom functionality to the API bridge + /// + /// + /// + public void LinkZoomRoomToApi(BasicTriList trilist, ZoomRoomJoinMap joinMap) + { + var meetingInfoCodec = this as IHasMeetingInfo; + if (meetingInfoCodec != null) + { + if (meetingInfoCodec.MeetingInfo != null) + { + trilist.SetBool(joinMap.MeetingCanRecord.JoinNumber, meetingInfoCodec.MeetingInfo.CanRecord); + } + + meetingInfoCodec.MeetingInfoChanged += (o, a) => + { + trilist.SetBool(joinMap.MeetingCanRecord.JoinNumber, a.Info.CanRecord); + }; + } + + var recordingCodec = this as IHasMeetingRecordingWithPrompt; + if (recordingCodec != null) + { + trilist.SetSigFalseAction(joinMap.StartRecording.JoinNumber, () => recordingCodec.StartRecording()); + trilist.SetSigFalseAction(joinMap.StopRecording.JoinNumber, () => recordingCodec.StopRecording()); + + recordingCodec.MeetingIsRecordingFeedback.LinkInputSig(trilist.BooleanInput[joinMap.StartRecording.JoinNumber]); + recordingCodec.MeetingIsRecordingFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.StopRecording.JoinNumber]); + + trilist.SetSigFalseAction(joinMap.RecordingPromptAgree.JoinNumber, () => recordingCodec.RecordingPromptAcknowledgement(true)); + trilist.SetSigFalseAction(joinMap.RecordingPromptDisagree.JoinNumber, () => recordingCodec.RecordingPromptAcknowledgement(false)); + + recordingCodec.RecordConsentPromptIsVisible.LinkInputSig(trilist.BooleanInput[joinMap.RecordConsentPromptIsVisible.JoinNumber]); + } + + var layoutsCodec = this as IHasZoomRoomLayouts; + if (layoutsCodec != null) + { + layoutsCodec.LayoutInfoChanged += (o, a) => + { + trilist.SetBool(joinMap.LayoutGalleryIsAvailable.JoinNumber, + zConfiguration.eLayoutStyle.Gallery == (a.AvailableLayouts & zConfiguration.eLayoutStyle.Gallery)); + + trilist.SetBool(joinMap.LayoutSpeakerIsAvailable.JoinNumber, + zConfiguration.eLayoutStyle.Speaker == (a.AvailableLayouts & zConfiguration.eLayoutStyle.Speaker)); + + + + trilist.SetBool(joinMap.LayoutStripIsAvailable.JoinNumber, zConfiguration.eLayoutStyle.Strip + == + (a.AvailableLayouts & zConfiguration.eLayoutStyle.Strip)); + trilist.SetBool(joinMap.LayoutShareAllIsAvailable.JoinNumber, zConfiguration.eLayoutStyle.ShareAll + == + (a.AvailableLayouts & + zConfiguration.eLayoutStyle.ShareAll)); + + // pass the names used to set the layout through the bridge + trilist.SetString(joinMap.LayoutGalleryIsAvailable.JoinNumber, zConfiguration.eLayoutStyle.Gallery.ToString()); + trilist.SetString(joinMap.LayoutSpeakerIsAvailable.JoinNumber, zConfiguration.eLayoutStyle.Speaker.ToString()); + trilist.SetString(joinMap.LayoutStripIsAvailable.JoinNumber, zConfiguration.eLayoutStyle.Strip.ToString()); + trilist.SetString(joinMap.LayoutShareAllIsAvailable.JoinNumber, zConfiguration.eLayoutStyle.ShareAll.ToString()); + }; + + trilist.SetSigFalseAction(joinMap.SwapContentWithThumbnail.JoinNumber, () => layoutsCodec.SwapContentWithThumbnail()); + + layoutsCodec.CanSwapContentWithThumbnailFeedback.LinkInputSig( + trilist.BooleanInput[joinMap.CanSwapContentWithThumbnail.JoinNumber]); + layoutsCodec.ContentSwappedWithThumbnailFeedback.LinkInputSig( + trilist.BooleanInput[joinMap.SwapContentWithThumbnail.JoinNumber]); + + layoutsCodec.LayoutViewIsOnFirstPageFeedback.LinkInputSig( + trilist.BooleanInput[joinMap.LayoutIsOnFirstPage.JoinNumber]); + layoutsCodec.LayoutViewIsOnLastPageFeedback.LinkInputSig(trilist.BooleanInput[joinMap.LayoutIsOnLastPage.JoinNumber]); + trilist.SetSigFalseAction(joinMap.LayoutTurnToNextPage.JoinNumber, () => layoutsCodec.LayoutTurnNextPage()); + trilist.SetSigFalseAction(joinMap.LayoutTurnToPreviousPage.JoinNumber, () => layoutsCodec.LayoutTurnPreviousPage()); + trilist.SetSigFalseAction(joinMap.GetAvailableLayouts.JoinNumber, () => layoutsCodec.GetAvailableLayouts()); + + trilist.SetStringSigAction(joinMap.GetSetCurrentLayout.JoinNumber, (s) => + { + try + { + var style = (zConfiguration.eLayoutStyle) Enum.Parse(typeof (zConfiguration.eLayoutStyle), s, true); + SetLayout(style); + } + catch (Exception e) + { + Debug.Console(1, this, "Unable to parse '{0}' to zConfiguration.eLayoutStyle: {1}", s, e); + } + }); + + layoutsCodec.LocalLayoutFeedback.LinkInputSig(trilist.StringInput[joinMap.GetSetCurrentLayout.JoinNumber]); + } + + var pinCodec = this as IHasParticipantPinUnpin; + if (pinCodec != null) + { + pinCodec.NumberOfScreensFeedback.LinkInputSig(trilist.UShortInput[joinMap.NumberOfScreens.JoinNumber]); + + // Set the value of the local property to be used when pinning a participant + trilist.SetUShortSigAction(joinMap.ScreenIndexToPinUserTo.JoinNumber, (u) => ScreenIndexToPinUserTo = u); + } + + var layoutSizeCodec = this as IHasSelfviewSize; + if (layoutSizeCodec != null) + { + trilist.SetSigFalseAction(joinMap.GetSetSelfviewPipSize.JoinNumber, layoutSizeCodec.SelfviewPipSizeToggle); + trilist.SetStringSigAction(joinMap.GetSetSelfviewPipSize.JoinNumber, (s) => + { + try + { + var size = (zConfiguration.eLayoutSize) Enum.Parse(typeof (zConfiguration.eLayoutSize), s, true); + var cmd = SelfviewPipSizes.FirstOrDefault(c => c.Command.Equals(size.ToString())); + SelfviewPipSizeSet(cmd); + } + catch (Exception e) + { + Debug.Console(1, this, "Unable to parse '{0}' to zConfiguration.eLayoutSize: {1}", s, e); + } + }); + + layoutSizeCodec.SelfviewPipSizeFeedback.LinkInputSig(trilist.StringInput[joinMap.GetSetSelfviewPipSize.JoinNumber]); + } + + MeetingInfoChanged += (device, args) => + { + trilist.SetString(joinMap.MeetingInfoId.JoinNumber, args.Info.Id); + trilist.SetString(joinMap.MeetingInfoHost.JoinNumber, args.Info.Host); + trilist.SetString(joinMap.MeetingInfoPassword.JoinNumber, args.Info.Password); + trilist.SetBool(joinMap.IsHost.JoinNumber, args.Info.IsHost); + trilist.SetBool(joinMap.ShareOnlyMeeting.JoinNumber, args.Info.IsSharingMeeting); + trilist.SetBool(joinMap.WaitingForHost.JoinNumber, args.Info.WaitingForHost); + //trilist.SetString(joinMap.CurrentSource.JoinNumber, args.Info.ShareStatus); + }; + + trilist.SetSigFalseAction(joinMap.StartMeetingNow.JoinNumber, () => StartMeeting(0)); + trilist.SetSigFalseAction(joinMap.ShareOnlyMeeting.JoinNumber, StartSharingOnlyMeeting); + trilist.SetSigFalseAction(joinMap.StartNormalMeetingFromSharingOnlyMeeting.JoinNumber, StartNormalMeetingFromSharingOnlyMeeting); + + trilist.SetStringSigAction(joinMap.SubmitPassword.JoinNumber, SubmitPassword); + + // Subscribe to call status to clear ShowPasswordPrompt when in meeting + this.CallStatusChange += (o, a) => + { + if (a.CallItem.Status == eCodecCallStatus.Connected || a.CallItem.Status == eCodecCallStatus.Disconnected) + { + trilist.SetBool(joinMap.MeetingPasswordRequired.JoinNumber, false); + } + + }; + + trilist.SetSigFalseAction(joinMap.CancelJoinAttempt.JoinNumber, () => { + trilist.SetBool(joinMap.MeetingPasswordRequired.JoinNumber, false); + EndAllCalls(); + }); + + PasswordRequired += (devices, args) => + { + Debug.Console(2, this, "***********************************PaswordRequired. Message: {0} Cancelled: {1} Last Incorrect: {2} Failed: {3}", args.Message, args.LoginAttemptCancelled, args.LastAttemptWasIncorrect, args.LoginAttemptFailed); + + if (args.LoginAttemptCancelled) + { + trilist.SetBool(joinMap.MeetingPasswordRequired.JoinNumber, false); + return; + } + + if (!string.IsNullOrEmpty(args.Message)) + { + trilist.SetString(joinMap.PasswordPromptMessage.JoinNumber, args.Message); + } + + if (args.LoginAttemptFailed) + { + // login attempt failed + return; + } + + trilist.SetBool(joinMap.PasswordIncorrect.JoinNumber, args.LastAttemptWasIncorrect); + trilist.SetBool(joinMap.MeetingPasswordRequired.JoinNumber, true); + }; + + trilist.OnlineStatusChange += (device, args) => + { + if (!args.DeviceOnLine) return; + + ComputeAvailableLayouts(); + layoutsCodec.LocalLayoutFeedback.FireUpdate(); + layoutsCodec.CanSwapContentWithThumbnailFeedback.FireUpdate(); + layoutsCodec.ContentSwappedWithThumbnailFeedback.FireUpdate(); + layoutsCodec.LayoutViewIsOnFirstPageFeedback.FireUpdate(); + layoutsCodec.LayoutViewIsOnLastPageFeedback.FireUpdate(); + pinCodec.NumberOfScreensFeedback.FireUpdate(); + layoutSizeCodec.SelfviewPipSizeFeedback.FireUpdate(); + }; + + var wirelessInfoCodec = this as IZoomWirelessShareInstructions; + if (wirelessInfoCodec != null) + { + if (Status != null && Status.Sharing != null) + { + SetSharingStateJoins(Status.Sharing, trilist, joinMap); + } + + wirelessInfoCodec.ShareInfoChanged += (o, a) => + { + SetSharingStateJoins(a.SharingStatus, trilist, joinMap); + }; + } + } + + void SetSharingStateJoins(zStatus.Sharing state, BasicTriList trilist, ZoomRoomJoinMap joinMap) + { + trilist.SetBool(joinMap.IsSharingAirplay.JoinNumber, state.isAirHostClientConnected); + trilist.SetBool(joinMap.IsSharingHdmi.JoinNumber, state.isBlackMagicConnected || state.isDirectPresentationConnected); + + trilist.SetString(joinMap.DisplayState.JoinNumber, state.dispState.ToString()); + trilist.SetString(joinMap.AirplayShareCode.JoinNumber, state.password); + trilist.SetString(joinMap.LaptopShareKey.JoinNumber, state.directPresentationSharingKey); + trilist.SetString(joinMap.WifiName.JoinNumber, state.wifiName); + trilist.SetString(joinMap.ServerName.JoinNumber, state.serverName); + } + + public override void ExecuteSwitch(object selector) + { + var action = selector as Action; + if (action == null) + { + return; + } + + action(); + } + + public void AcceptCall() + { + _waitingForUserToAcceptOrRejectIncomingCall = false; + + var incomingCall = + ActiveCalls.FirstOrDefault( + c => c.Status.Equals(eCodecCallStatus.Ringing) && c.Direction.Equals(eCodecCallDirection.Incoming)); + + AcceptCall(incomingCall); + } + + public override void AcceptCall(CodecActiveCallItem call) + { + _waitingForUserToAcceptOrRejectIncomingCall = false; + + SendText(string.Format("zCommand Call Accept callerJID: {0}", call.Id)); + + call.Status = eCodecCallStatus.Connected; + + OnCallStatusChange(call); + + UpdateCallStatus(); + } + + public void RejectCall() + { + _waitingForUserToAcceptOrRejectIncomingCall = false; + + var incomingCall = + ActiveCalls.FirstOrDefault( + c => c.Status.Equals(eCodecCallStatus.Ringing) && c.Direction.Equals(eCodecCallDirection.Incoming)); + + RejectCall(incomingCall); + } + + public override void RejectCall(CodecActiveCallItem call) + { + _waitingForUserToAcceptOrRejectIncomingCall = false; + + SendText(string.Format("zCommand Call Reject callerJID: {0}", call.Id)); + + call.Status = eCodecCallStatus.Disconnected; + + OnCallStatusChange(call); + + UpdateCallStatus(); + } + + public override void Dial(Meeting meeting) + { + Debug.Console(1, this, "Dialing meeting.Id: {0} Title: {1}", meeting.Id, meeting.Title); + _lastDialedMeetingNumber = meeting.Id; + SendText(string.Format("zCommand Dial Start meetingNumber: {0}", meeting.Id)); + } + + public override void Dial(string number) + { + Debug.Console(2, this, "Dialing number: {0}", number); + _lastDialedMeetingNumber = number; + SendText(string.Format("zCommand Dial Join meetingNumber: {0}", number)); + } + + /// + /// Dials a meeting with a password + /// + /// + /// + public void Dial(string number, string password) + { + Debug.Console(2, this, "Dialing meeting number: {0} with password: {1}", number, password); + SendText(string.Format("zCommand Dial Join meetingNumber: {0} password: {1}", number, password)); + } + + /// + /// Invites a contact to either a new meeting (if not already in a meeting) or the current meeting. + /// Currently only invites a single user + /// + /// + public override void Dial(IInvitableContact contact) + { + var ic = contact as InvitableDirectoryContact; + + if (ic != null) + { + Debug.Console(1, this, "Attempting to Dial (Invite): {0}", ic.Name); + + if (!IsInCall) + { + SendText(string.Format("zCommand Invite Duration: {0} user: {1}", DefaultMeetingDurationMin, + ic.ContactId)); + } + else + { + SendText(string.Format("zCommand Call invite user: {0}", ic.ContactId)); + } + } + } + + /// + /// Invites contacts to a new meeting for a specified duration + /// + /// + /// + public void InviteContactsToNewMeeting(List contacts, uint duration) + { + if(duration == 0) + { + duration = DefaultMeetingDurationMin; + } + + StringBuilder message = new StringBuilder(); + + // Add the prefix + message.Append(string.Format("zCommand Invite Duration: {0}", duration)); + + // Add each invitee + foreach (var contact in contacts) + { + var invitee = string.Format(" user: {0}", contact.ContactId); + + message.Append(invitee); + } + + SendText(message.ToString()); + } + + /// + /// Invites contacts to an existing meeting + /// + /// + public void InviteContactsToExistingMeeting(List contacts) + { + StringBuilder message = new StringBuilder(); + + // Add the prefix + message.Append(string.Format("zCommand Call Invite")); + + // Add each invitee + foreach (var contact in contacts) + { + var invitee = string.Format(" user: {0}", contact.ContactId); + + message.Append(invitee); + } + + SendText(message.ToString()); + } + + + /// + /// Starts a PMI Meeting for the specified duration (or default meeting duration if 0 is specified) + /// + /// duration of meeting + public void StartMeeting(uint duration) + { + uint dur = DefaultMeetingDurationMin; + + if (duration > 0) + dur = duration; + + SendText(string.Format("zCommand Dial StartPmi Duration: {0}", dur)); + } + + public void LeaveMeeting() + { + _meetingPasswordRequired = false; + _waitingForUserToAcceptOrRejectIncomingCall = false; + + SendText("zCommand Call Leave"); + } + + public override void EndCall(CodecActiveCallItem call) + { + _meetingPasswordRequired = false; + _waitingForUserToAcceptOrRejectIncomingCall = false; + + SendText("zCommand Call Disconnect"); + } + + public override void EndAllCalls() + { + _meetingPasswordRequired = false; + _waitingForUserToAcceptOrRejectIncomingCall = false; + + SendText("zCommand Call Disconnect"); + } + + public override void SendDtmf(string s) + { + SendDtmfToPhone(s); + } + + /// + /// Call when directory results are updated + /// + /// + private void OnDirectoryResultReturned(CodecDirectory result) + { + try + { + Debug.Console(2, this, "OnDirectoryResultReturned. Result has {0} contacts", result.Contacts.Count); + + CurrentDirectoryResultIsNotDirectoryRoot.FireUpdate(); + + var directoryResult = result; + var directoryIsRoot = CurrentDirectoryResultIsNotDirectoryRoot.BoolValue == false; + + // If result is Root, create a copy and filter out contacts whose parent folder is not root + //if (!CurrentDirectoryResultIsNotDirectoryRoot.BoolValue) + //{ + // Debug.Console(2, this, "Filtering DirectoryRoot to remove contacts for display"); + + // directoryResult.ResultsFolderId = result.ResultsFolderId; + // directoryResult.AddFoldersToDirectory(result.Folders); + // directoryResult.AddContactsToDirectory( + // result.Contacts.Where((c) => c.ParentFolderId == result.ResultsFolderId).ToList()); + //} + //else + //{ + // directoryResult = result; + //} + + Debug.Console(2, this, "Updating directoryResult. IsOnRoot: {0} Contact Count: {1}", + directoryIsRoot, directoryResult.Contacts.Count); + + // This will return the latest results to all UIs. Multiple indendent UI Directory browsing will require a different methodology + var handler = DirectoryResultReturned; + if (handler != null) + { + handler(this, new DirectoryEventArgs + { + Directory = directoryResult, + DirectoryIsOnRoot = directoryIsRoot + }); + } + + + } + catch (Exception e) + { + Debug.Console(2, this, "Error: {0}", e); + } + + //PrintDirectory(result); + } + + /// + /// Builds the cameras List by using the Zoom Room zStatus.Cameras data. Could later be modified to build from config data + /// + private void SetUpCameras() + { + SelectedCameraFeedback = new StringFeedback(() => Configuration.Video.Camera.SelectedId); + + ControllingFarEndCameraFeedback = new BoolFeedback(() => SelectedCamera is IAmFarEndCamera); + + foreach (var cam in Status.Cameras) + { + // Known Issue: + // Crestron UC engine systems seem to report an item in the cameras list that represnts the USB bridge device. + // If we know the name and it's reliably consistent, we could ignore it here... + + if (cam.Name.IndexOf("HD-CONV-USB") > -1) + { + // Skip this as it's the Crestron USB box, not a real camera + continue; + } + + var existingCam = Cameras.FirstOrDefault((c) => c.Key.Equals(cam.id)); + + if (existingCam == null) + { + var camera = new ZoomRoomCamera(cam.id, cam.Name, this); + + Cameras.Add(camera); + + if (cam.Selected) + { + SelectedCamera = camera; + } + } + } + + if (IsInCall) + { + UpdateFarEndCameras(); + } + + _syncState.CamerasSetUp(); + } + + /// + /// Dynamically creates far end cameras for call participants who have far end control enabled. + /// + private void UpdateFarEndCameras() + { + // TODO: set up far end cameras for the current call + } + + #region Implementation of IHasParticipants + + public CodecParticipants Participants { get; private set; } + + public void RemoveParticipant(int userId) + { + SendText(string.Format("zCommand Call Expel Id: {0}", userId)); + } + + public void SetParticipantAsHost(int userId) + { + SendText(string.Format("zCommand Call HostChange Id: {0}", userId)); + } + + public void AdmitParticipantFromWaitingRoom(int userId) + { + SendText(string.Format("zCommand Call Admit Participant Id: {0}", userId)); + } + + #endregion + + #region IHasParticipantAudioMute Members + + public void MuteAudioForAllParticipants() + { + SendText(string.Format("zCommand Call MuteAll Mute: on")); + } + + public void MuteAudioForParticipant(int userId) + { + SendText(string.Format("zCommand Call MuteParticipant Mute: on Id: {0}", userId)); + } + + public void UnmuteAudioForParticipant(int userId) + { + SendText(string.Format("zCommand Call MuteParticipant Mute: off Id: {0}", userId)); + } + + public void ToggleAudioForParticipant(int userId) + { + var user = Participants.CurrentParticipants.FirstOrDefault(p => p.UserId.Equals(userId)); + + if (user == null) + { + Debug.Console(2, this, "Unable to find user with id: {0}", userId); + return; + } + + if (user.AudioMuteFb) + { + UnmuteAudioForParticipant(userId); + } + else + { + MuteAudioForParticipant(userId); + } + } + + #endregion + + #region IHasParticipantVideoMute Members + + public void MuteVideoForParticipant(int userId) + { + SendText(string.Format("zCommand Call MuteParticipantVideo Mute: on Id: {0}", userId)); + } + + public void UnmuteVideoForParticipant(int userId) + { + SendText(string.Format("zCommand Call MuteParticipantVideo Mute: off Id: {0}", userId)); + } + + public void ToggleVideoForParticipant(int userId) + { + var user = Participants.CurrentParticipants.FirstOrDefault(p => p.UserId.Equals(userId)); + + if (user == null) + { + Debug.Console(2, this, "Unable to find user with id: {0}", userId); + return; + } + + if (user.VideoMuteFb) + { + UnmuteVideoForParticipant(userId); + } + else + { + MuteVideoForParticipant(userId); + } + } + + #endregion + + #region IHasParticipantPinUnpin Members + + private Func NumberOfScreensFeedbackFunc + { + get { return () => Status.NumberOfScreens.NumOfScreens; } + } + + public IntFeedback NumberOfScreensFeedback { get; private set; } + + public int ScreenIndexToPinUserTo { get; private set; } + + public void PinParticipant(int userId, int screenIndex) + { + SendText(string.Format("zCommand Call Pin Id: {0} Enable: on Screen: {1}", userId, screenIndex)); + } + + public void UnPinParticipant(int userId) + { + SendText(string.Format("zCommand Call Pin Id: {0} Enable: off", userId)); + } + + public void ToggleParticipantPinState(int userId, int screenIndex) + { + var user = Participants.CurrentParticipants.FirstOrDefault(p => p.UserId.Equals(userId)); + + if (user == null) + { + Debug.Console(2, this, "Unable to find user with id: {0}", userId); + return; + } + + if (user.IsPinnedFb) + { + UnPinParticipant(userId); + } + else + { + PinParticipant(userId, screenIndex); + } + } + + #endregion + + #region Implementation of IHasCameraOff + + public BoolFeedback CameraIsOffFeedback { get; private set; } + + public void CameraOff() + { + CameraMuteOn(); + } + + #endregion + + public BoolFeedback CameraIsMutedFeedback { get; private set; } + + public void CameraMuteOn() + { + SendText("zConfiguration Call Camera Mute: On"); + } + + public void CameraMuteOff() + { + SendText("zConfiguration Call Camera Mute: Off"); + } + + public void CameraMuteToggle() + { + if (CameraIsMutedFeedback.BoolValue) + CameraMuteOff(); + else + CameraMuteOn(); + } + + #region Implementation of IHasCameraAutoMode + + //Zoom doesn't support camera auto modes. Setting this to just unmute video + public void CameraAutoModeOn() + { + CameraMuteOff(); + throw new NotImplementedException("Zoom Room Doesn't support camera auto mode"); + } + + //Zoom doesn't support camera auto modes. Setting this to just unmute video + public void CameraAutoModeOff() + { + SendText("zConfiguration Call Camera Mute: Off"); + } + + public void CameraAutoModeToggle() + { + throw new NotImplementedException("Zoom Room doesn't support camera auto mode"); + } + + public BoolFeedback CameraAutoModeIsOnFeedback { get; private set; } + + #endregion + + #region Implementation of IHasFarEndContentStatus + + public BoolFeedback ReceivingContent { get; private set; } + + #endregion + + #region Implementation of IHasSelfviewPosition + + private CodecCommandWithLabel _currentSelfviewPipPosition; + + public StringFeedback SelfviewPipPositionFeedback { get; private set; } + + public void SelfviewPipPositionSet(CodecCommandWithLabel position) + { + SendText(String.Format("zConfiguration Call Layout Position: {0}", position.Command)); + } + + public void SelfviewPipPositionToggle() + { + if (_currentSelfviewPipPosition != null) + { + var nextPipPositionIndex = SelfviewPipPositions.IndexOf(_currentSelfviewPipPosition) + 1; + + if (nextPipPositionIndex >= SelfviewPipPositions.Count) + // Check if we need to loop back to the first item in the list + nextPipPositionIndex = 0; + + SelfviewPipPositionSet(SelfviewPipPositions[nextPipPositionIndex]); + } + } + + public List SelfviewPipPositions = new List() + { + new CodecCommandWithLabel("UpLeft", "Center Left"), + new CodecCommandWithLabel("UpRight", "Center Right"), + new CodecCommandWithLabel("DownRight", "Lower Right"), + new CodecCommandWithLabel("DownLeft", "Lower Left") + }; + + private void ComputeSelfviewPipPositionStatus() + { + _currentSelfviewPipPosition = + SelfviewPipPositions.FirstOrDefault( + p => p.Command.ToLower().Equals(Configuration.Call.Layout.Position.ToString().ToLower())); + } + + #endregion + + // TODO: #714 [ ] Implementation of IHasSelfviewPipSize + + #region Implementation of IHasSelfviewPipSize + + private CodecCommandWithLabel _currentSelfviewPipSize; + + public StringFeedback SelfviewPipSizeFeedback { get; private set; } + + public void SelfviewPipSizeSet(CodecCommandWithLabel size) + { + SendText(String.Format("zConfiguration Call Layout Size: {0}", size.Command)); + } + + public void SelfviewPipSizeToggle() + { + if (_currentSelfviewPipSize != null) + { + var nextPipSizeIndex = SelfviewPipSizes.IndexOf(_currentSelfviewPipSize) + 1; + + if (nextPipSizeIndex >= SelfviewPipSizes.Count) + // Check if we need to loop back to the first item in the list + nextPipSizeIndex = 0; + + SelfviewPipSizeSet(SelfviewPipSizes[nextPipSizeIndex]); + } + } + + public List SelfviewPipSizes = new List() + { + new CodecCommandWithLabel("Off", "Off"), + new CodecCommandWithLabel("Size1", "Size 1"), + new CodecCommandWithLabel("Size2", "Size 2"), + new CodecCommandWithLabel("Size3", "Size 3"), + new CodecCommandWithLabel("Strip", "Strip") + }; + + private void ComputeSelfviewPipSizeStatus() + { + _currentSelfviewPipSize = + SelfviewPipSizes.FirstOrDefault( + p => p.Command.ToLower().Equals(Configuration.Call.Layout.Size.ToString().ToLower())); + } + + #endregion + + #region Implementation of IHasPhoneDialing + + private Func PhoneOffHookFeedbackFunc + { + get { return () => Status.PhoneCall.OffHook; } + } + + private Func CallerIdNameFeedbackFunc + { + get { return () => Status.PhoneCall.PeerDisplayName; } + } + + private Func CallerIdNumberFeedbackFunc + { + get { return () => Status.PhoneCall.PeerNumber; } + } + + public BoolFeedback PhoneOffHookFeedback { get; private set; } + public StringFeedback CallerIdNameFeedback { get; private set; } + public StringFeedback CallerIdNumberFeedback { get; private set; } + + public void DialPhoneCall(string number) + { + SendText(String.Format("zCommand Dial PhoneCallOut Number: {0}", number)); + } + + public void EndPhoneCall() + { + SendText(String.Format("zCommand Dial PhoneHangUp CallId: {0}", Status.PhoneCall.CallId)); + } + + public void SendDtmfToPhone(string digit) + { + SendText(String.Format("zCommand SendSipDTMF CallId: {0} Key: {1}", Status.PhoneCall.CallId, digit)); + } + + #endregion + + #region IHasZoomRoomLayouts Members + + public event EventHandler LayoutInfoChanged; + + private Func LayoutViewIsOnFirstPageFeedbackFunc + { + get { return () => Status.Layout.is_In_First_Page; } + } + + private Func LayoutViewIsOnLastPageFeedbackFunc + { + get { return () => Status.Layout.is_In_Last_Page; } + } + + private Func CanSwapContentWithThumbnailFeedbackFunc + { + get { return () => Status.Layout.can_Switch_Floating_Share_Content; } + } + + private Func ContentSwappedWithThumbnailFeedbackFunc + { + get { return () => Configuration.Call.Layout.ShareThumb; } + } + + public BoolFeedback LayoutViewIsOnFirstPageFeedback { get; private set; } + + public BoolFeedback LayoutViewIsOnLastPageFeedback { get; private set; } + + public BoolFeedback CanSwapContentWithThumbnailFeedback { get; private set; } + + public BoolFeedback ContentSwappedWithThumbnailFeedback { get; private set; } + + + public zConfiguration.eLayoutStyle LastSelectedLayout { get; private set; } + + public zConfiguration.eLayoutStyle AvailableLayouts { get; private set; } + + /// + /// Reads individual properties to determine if which layouts are avalailable + /// + private void ComputeAvailableLayouts() + { + Debug.Console(1, this, "Computing available layouts..."); + zConfiguration.eLayoutStyle availableLayouts = zConfiguration.eLayoutStyle.None; + if (Status.Layout.can_Switch_Wall_View) + { + availableLayouts |= zConfiguration.eLayoutStyle.Gallery; + } + + if (Status.Layout.can_Switch_Speaker_View) + { + availableLayouts |= zConfiguration.eLayoutStyle.Speaker; + } + + if (Status.Layout.can_Switch_Share_On_All_Screens) + { + availableLayouts |= zConfiguration.eLayoutStyle.ShareAll; + } + + // There is no property that directly reports if strip mode is valid, but API stipulates + // that strip mode is available if the number of screens is 1 + if (Status.NumberOfScreens.NumOfScreens == 1 || Status.Layout.can_Switch_Strip_View || Status.Layout.video_type.ToLower() == "strip") + { + availableLayouts |= zConfiguration.eLayoutStyle.Strip; + } + + Debug.Console(1, this, "availablelayouts: {0}", availableLayouts); + + AvailableLayouts = availableLayouts; + } + + private void OnLayoutInfoChanged() + { + var handler = LayoutInfoChanged; + if (handler != null) + { + + var currentLayout = zConfiguration.eLayoutStyle.None; + + currentLayout = (zConfiguration.eLayoutStyle)Enum.Parse(typeof(zConfiguration.eLayoutStyle), string.IsNullOrEmpty(LocalLayoutFeedback.StringValue) ? "None" : LocalLayoutFeedback.StringValue, true); + + handler(this, new LayoutInfoChangedEventArgs() + { + AvailableLayouts = AvailableLayouts, + CurrentSelectedLayout = currentLayout, + LayoutViewIsOnFirstPage = LayoutViewIsOnFirstPageFeedback.BoolValue, + LayoutViewIsOnLastPage = LayoutViewIsOnLastPageFeedback.BoolValue, + CanSwapContentWithThumbnail = CanSwapContentWithThumbnailFeedback.BoolValue, + ContentSwappedWithThumbnail = ContentSwappedWithThumbnailFeedback.BoolValue, + }); + } + } + + public void GetAvailableLayouts() + { + SendText("zStatus Call Layout"); + } + + public void SetLayout(zConfiguration.eLayoutStyle layoutStyle) + { + LastSelectedLayout = layoutStyle; + SendText(String.Format("zConfiguration Call Layout Style: {0}", layoutStyle.ToString())); + } + + public void SwapContentWithThumbnail() + { + if (CanSwapContentWithThumbnailFeedback.BoolValue) + { + var oppositeValue = ContentSwappedWithThumbnailFeedback.BoolValue ? "on" : "off"; + // Get the value based on the opposite of the current state + // TODO: #697 [*] Need to verify the ternary above and make sure that the correct on/off value is being send based on the true/false value of the feedback + // to toggle the state + SendText(String.Format("zConfiguration Call Layout ShareThumb: {0}", oppositeValue)); + } + } + + public void LayoutTurnNextPage() + { + SendText("zCommand Call Layout TurnPage Forward: On"); + } + + public void LayoutTurnPreviousPage() + { + SendText("zCommand Call Layout TurnPage Forward: Off"); + } + + #endregion + + #region IHasCodecLayouts Members + + private Func LocalLayoutFeedbackFunc + { + get + { + return () => + { + if (Configuration.Call.Layout.Style != zConfiguration.eLayoutStyle.None) + return Configuration.Call.Layout.Style.ToString(); + else + return Configuration.Client.Call.Layout.Style.ToString(); + }; + } + } + + public StringFeedback LocalLayoutFeedback { get; private set; } + + public void LocalLayoutToggle() + { + var currentLayout = LocalLayoutFeedback.StringValue; + + var eCurrentLayout = (int) Enum.Parse(typeof (zConfiguration.eLayoutStyle), currentLayout, true); + + var nextLayout = GetNextLayout(eCurrentLayout); + + if (nextLayout != zConfiguration.eLayoutStyle.None) + { + SetLayout(nextLayout); + } + } + + /// + /// Tries to get the next available layout + /// + /// + /// + private zConfiguration.eLayoutStyle GetNextLayout(int currentLayout) + { + if (AvailableLayouts == zConfiguration.eLayoutStyle.None) + { + return zConfiguration.eLayoutStyle.None; + } + + zConfiguration.eLayoutStyle nextLayout; + + if (((zConfiguration.eLayoutStyle) currentLayout & zConfiguration.eLayoutStyle.ShareAll) == + zConfiguration.eLayoutStyle.ShareAll) + { + nextLayout = zConfiguration.eLayoutStyle.Gallery; + } + else + { + nextLayout = (zConfiguration.eLayoutStyle) (currentLayout << 1); + } + + if ((AvailableLayouts & nextLayout) == nextLayout) + { + return nextLayout; + } + else + { + return GetNextLayout((int) nextLayout); + } + } + + public void LocalLayoutToggleSingleProminent() + { + throw new NotImplementedException(); + } + + public void MinMaxLayoutToggle() + { + throw new NotImplementedException(); + } + + #endregion + + #region IPasswordPrompt Members + + public event EventHandler PasswordRequired; + + public void SubmitPassword(string password) + { + _meetingPasswordRequired = false; + Debug.Console(2, this, "Password Submitted: {0}", password); + Dial(_lastDialedMeetingNumber, password); + } + + void OnPasswordRequired(bool lastAttemptIncorrect, bool loginFailed, bool loginCancelled, string message) + { + _meetingPasswordRequired = !loginFailed || !loginCancelled; + + var handler = PasswordRequired; + if (handler != null) + { + Debug.Console(2, this, "Meeting Password Required: {0}", _meetingPasswordRequired); + + handler(this, new PasswordPromptEventArgs(lastAttemptIncorrect, loginFailed, loginCancelled, message)); + } + } + + #endregion + + #region IHasMeetingInfo Members + + public event EventHandler MeetingInfoChanged; + + private MeetingInfo _meetingInfo; + + public MeetingInfo MeetingInfo + { + get { return _meetingInfo; } + private set + { + if (value != _meetingInfo) + { + _meetingInfo = value; + + var handler = MeetingInfoChanged; + if (handler != null) + { + handler(this, new MeetingInfoEventArgs(_meetingInfo)); + } + } + } + } + + #endregion + + #region Implementation of IHasPresentationOnlyMeeting + + public void StartSharingOnlyMeeting() + { + StartSharingOnlyMeeting(eSharingMeetingMode.None, 30, String.Empty); + } + + public void StartSharingOnlyMeeting(eSharingMeetingMode displayMode) + { + StartSharingOnlyMeeting(displayMode, DefaultMeetingDurationMin, String.Empty); + } + + public void StartSharingOnlyMeeting(eSharingMeetingMode displayMode, uint duration) + { + StartSharingOnlyMeeting(displayMode, duration, String.Empty); + } + + public void StartSharingOnlyMeeting(eSharingMeetingMode displayMode, uint duration, string password) + { + SendText(String.Format("zCommand Dial Sharing Duration: {0} DisplayState: {1} Password: {2}", duration, displayMode, password)); + } + + public void StartNormalMeetingFromSharingOnlyMeeting() + { + Debug.Console(2, this, "Converting Sharing Meeting to Normal Meeting"); + SendText("zCommand call sharing ToNormal"); + } + + #endregion + + #region IHasMeetingLock Members + + public BoolFeedback MeetingIsLockedFeedback { get; private set; } + + public void LockMeeting() + { + SendText(string.Format("zConfiguration Call Lock Enable: on")); + } + + public void UnLockMeeting() + { + SendText(string.Format("zConfiguration Call Lock Enable: off")); + } + + public void ToggleMeetingLock() + { + if (MeetingIsLockedFeedback.BoolValue) + { + UnLockMeeting(); + } + else + { + LockMeeting(); + } + } + + #endregion + + #region IHasMeetingRecordingWithPrompt Members + + public BoolFeedback MeetingIsRecordingFeedback { get; private set; } + + bool _recordConsentPromptIsVisible; + + public BoolFeedback RecordConsentPromptIsVisible { get; private set; } + + public void RecordingPromptAcknowledgement(bool agree) + { + var command = string.Format("zCommand Agree Recording: {0}", agree ? "on" : "off"); + //Debug.Console(2, this, "Sending agree: {0} {1}", agree, command); + SendText(command); + } + + public void StartRecording() + { + SendText(string.Format("zCommand Call Record Enable: on")); + } + + public void StopRecording() + { + SendText(string.Format("zCommand Call Record Enable: off")); + } + + public void ToggleRecording() + { + if (MeetingIsRecordingFeedback.BoolValue) + { + StopRecording(); + } + else + { + StartRecording(); + } + } + + #endregion + + #region IZoomWirelessShareInstructions Members + + public event EventHandler ShareInfoChanged; + + public zStatus.Sharing SharingState + { + get + { + return Status.Sharing; + } + } + + void OnShareInfoChanged(zStatus.Sharing status) + { + Debug.Console(2, this, +@"ShareInfoChanged: +isSharingHDMI: {0} +isSharingAirplay: {1} +AirplayPassword: {2} +OSD Display State: {3} +", +status.isSharingBlackMagic, +status.isAirHostClientConnected, +status.password, +status.dispState); + + var handler = ShareInfoChanged; + if (handler != null) + { + handler(this, new ShareInfoEventArgs(status)); + } + } + + #endregion + } + + /// + /// Zoom Room specific info object + /// + public class ZoomRoomInfo : VideoCodecInfo + { + public ZoomRoomInfo(ZoomRoomStatus status, ZoomRoomConfiguration configuration) + { + Status = status; + Configuration = configuration; + } + + [JsonIgnore] + public ZoomRoomStatus Status { get; private set; } + [JsonIgnore] + public ZoomRoomConfiguration Configuration { get; private set; } + + public override bool AutoAnswerEnabled + { + get { return Status.SystemUnit.RoomInfo.AutoAnswerIsEnabled; } + } + + public override string E164Alias + { + get + { + if (!string.IsNullOrEmpty(Status.SystemUnit.MeetingNumber)) + { + return Status.SystemUnit.MeetingNumber; + } + return string.Empty; + } + } + + public override string H323Id + { + get + { + if (!string.IsNullOrEmpty(Status.Call.Info.meeting_list_item.third_party.h323_address)) + { + return Status.Call.Info.meeting_list_item.third_party.h323_address; + } + return string.Empty; + } + } + + public override string IpAddress + { + get + { + if (!string.IsNullOrEmpty(Status.SystemUnit.RoomInfo.AccountEmail)) + { + return Status.SystemUnit.RoomInfo.AccountEmail; + } + return string.Empty; + } + } + + public override bool MultiSiteOptionIsEnabled + { + get { return true; } + } + + public override string SipPhoneNumber + { + get + { + if (!string.IsNullOrEmpty(Status.Call.Info.dialIn)) + { + return Status.Call.Info.dialIn; + } + return string.Empty; + } + } + + public override string SipUri + { + get + { + if (!string.IsNullOrEmpty(Status.Call.Info.meeting_list_item.third_party.sip_address)) + { + return Status.Call.Info.meeting_list_item.third_party.sip_address; + } + return string.Empty; + } + } + } + + /// + /// Tracks the initial sycnronization state when establishing a new connection + /// + public class ZoomRoomSyncState : IKeyed + { + private readonly ZoomRoom _parent; + private readonly CrestronQueue _syncQueries; + private bool _initialSyncComplete; + + public ZoomRoomSyncState(string key, ZoomRoom parent) + { + _parent = parent; + Key = key; + _syncQueries = new CrestronQueue(50); + CodecDisconnected(); + } + + public bool InitialSyncComplete + { + get { return _initialSyncComplete; } + private set + { + if (value) + { + var handler = InitialSyncCompleted; + if (handler != null) + { + handler(this, new EventArgs()); + } + } + _initialSyncComplete = value; + } + } + + public bool LoginResponseWasReceived { get; private set; } + + public bool FirstJsonResponseWasReceived { get; private set; } + + public bool InitialQueryMessagesWereSent { get; private set; } + + public bool LastQueryResponseWasReceived { get; private set; } + + public bool CamerasHaveBeenSetUp { get; private set; } + + #region IKeyed Members + + public string Key { get; private set; } + + #endregion + + public event EventHandler InitialSyncCompleted; + + public event EventHandler FirstJsonResponseReceived; + + public void StartSync() + { + DequeueQueries(); + } + + private void DequeueQueries() + { + while (!_syncQueries.IsEmpty) + { + var query = _syncQueries.Dequeue(); + + _parent.SendText(query); + } + + InitialQueryMessagesSent(); + } + + public void AddQueryToQueue(string query) + { + _syncQueries.Enqueue(query); + } + + public void LoginResponseReceived() + { + LoginResponseWasReceived = true; + Debug.Console(1, this, "Login Rsponse Received."); + CheckSyncStatus(); + } + + public void ReceivedFirstJsonResponse() + { + FirstJsonResponseWasReceived = true; + Debug.Console(1, this, "First JSON Response Received."); + + var handler = FirstJsonResponseReceived; + if (handler != null) + { + handler(this, null); + } + CheckSyncStatus(); + } + + public void InitialQueryMessagesSent() + { + InitialQueryMessagesWereSent = true; + Debug.Console(1, this, "Query Messages Sent."); + CheckSyncStatus(); + } + + public void LastQueryResponseReceived() + { + LastQueryResponseWasReceived = true; + Debug.Console(1, this, "Last Query Response Received."); + CheckSyncStatus(); + } + + public void CamerasSetUp() + { + CamerasHaveBeenSetUp = true; + Debug.Console(1, this, "Cameras Set Up."); + CheckSyncStatus(); + } + + public void CodecDisconnected() + { + _syncQueries.Clear(); + LoginResponseWasReceived = false; + FirstJsonResponseWasReceived = false; + InitialQueryMessagesWereSent = false; + LastQueryResponseWasReceived = false; + CamerasHaveBeenSetUp = false; + InitialSyncComplete = false; + } + + private void CheckSyncStatus() + { + if (LoginResponseWasReceived && FirstJsonResponseWasReceived && InitialQueryMessagesWereSent && LastQueryResponseWasReceived && + CamerasHaveBeenSetUp) + { + InitialSyncComplete = true; + Debug.Console(1, this, "Initial Codec Sync Complete!"); + } + else + { + InitialSyncComplete = false; + } + } + } + + public class ZoomRoomFactory : EssentialsDeviceFactory + { + public ZoomRoomFactory() + { + TypeNames = new List {"zoomroom"}; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new ZoomRoom Device"); + var comm = CommFactory.CreateCommForDevice(dc); + return new ZoomRoom(dc, comm); + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomCamera.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomCamera.cs similarity index 100% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomCamera.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomCamera.cs diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomJoinMap.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomJoinMap.cs similarity index 96% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomJoinMap.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomJoinMap.cs index 878f88d5..bb6bf90f 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomJoinMap.cs +++ b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomJoinMap.cs @@ -1,706 +1,706 @@ -using System; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges.JoinMaps; - -namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom -{ - public class ZoomRoomJoinMap : VideoCodecControllerJoinMap - { - #region Digital - - [JoinName("CancelJoinAttempt")] - public JoinDataComplete CancelJoinAttempt = new JoinDataComplete( - new JoinData - { - JoinNumber = 5, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Pulse to hide the password prompt", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("MeetingPasswordRequired")] - public JoinDataComplete MeetingPasswordRequired = new JoinDataComplete( - new JoinData - { - JoinNumber = 6, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "FB Indicates to show the password prompt", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("PasswordIncorrect")] - public JoinDataComplete PasswordIncorrect = new JoinDataComplete( - new JoinData - { - JoinNumber = 7, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "FB Indicates the password entered is incorrect", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("PasswordLoginFailed")] - public JoinDataComplete PasswordLoginFailed = new JoinDataComplete( - new JoinData - { - JoinNumber = 8, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "FB Indicates the password entered is incorrect", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("WaitingForHost")] - public JoinDataComplete WaitingForHost = new JoinDataComplete( - new JoinData - { - JoinNumber = 9, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "FB Indicates system is waiting for host", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("IsHost")] - public JoinDataComplete IsHost = new JoinDataComplete( - new JoinData - { - JoinNumber = 10, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "FB Indicates system is the host", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("StartMeetingNow")] - public JoinDataComplete StartMeetingNow = new JoinDataComplete( - new JoinData - { - JoinNumber = 25, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Pulse to start an ad-hoc meeting with the default duration", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("ShareOnlyMeeting")] - public JoinDataComplete ShareOnlyMeeting = new JoinDataComplete( - new JoinData - { - JoinNumber = 26, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Triggers a share only meeting, feedback indicates the current meeting is share only", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("StartNormalMeetingFromSharingOnlyMeeting")] - public JoinDataComplete StartNormalMeetingFromSharingOnlyMeeting = new JoinDataComplete( - new JoinData - { - JoinNumber = 27, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Starts a normal meeting from a share only meeting", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CanSwapContentWithThumbnail")] - public JoinDataComplete CanSwapContentWithThumbnail = new JoinDataComplete( - new JoinData - { - JoinNumber = 206, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "FB Indicates if content can be swapped with thumbnail", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("SwapContentWithThumbnail")] - public JoinDataComplete SwapContentWithThumbnail = new JoinDataComplete( - new JoinData - { - JoinNumber = 206, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Pulse to swap content with thumbnail. FB reports current state", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("GetAvailableLayouts")] - public JoinDataComplete GetAvailableLayouts = new JoinDataComplete( - new JoinData - { - JoinNumber = 215, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Gets the available layouts. Will update the LayoutXXXXXIsAvailbale signals.", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("LayoutIsOnFirstPage")] - public JoinDataComplete LayoutIsOnFirstPage = new JoinDataComplete( - new JoinData - { - JoinNumber = 216, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Indicates if layout is on first page", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("LayoutIsOnLastPage")] - public JoinDataComplete LayoutIsOnLastPage = new JoinDataComplete( - new JoinData - { - JoinNumber = 217, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Indicates if layout is on first page", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("LayoutTurnToNextPage")] - public JoinDataComplete LayoutTurnToNextPage = new JoinDataComplete( - new JoinData - { - JoinNumber = 216, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Turns layout view to next page", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("LayoutTurnToPreviousPage")] - public JoinDataComplete LayoutTurnToPreviousPage = new JoinDataComplete( - new JoinData - { - JoinNumber = 217, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Turns layout view to previous page", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("LayoutGalleryIsAvailable")] - public JoinDataComplete LayoutGalleryIsAvailable = new JoinDataComplete( - new JoinData - { - JoinNumber = 221, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "FB Indicates if layout 'Gallery' is available", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.DigitalSerial - }); - - [JoinName("LayoutSpeakerIsAvailable")] - public JoinDataComplete LayoutSpeakerIsAvailable = new JoinDataComplete( - new JoinData - { - JoinNumber = 222, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "FB Indicates if layout 'Speaker' is available", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.DigitalSerial - }); - - [JoinName("LayoutStripIsAvailable")] - public JoinDataComplete LayoutStripIsAvailable = new JoinDataComplete( - new JoinData - { - JoinNumber = 223, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "FB Indicates if layout 'Strip' is available", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.DigitalSerial - }); - - [JoinName("LayoutShareAllIsAvailable")] - public JoinDataComplete LayoutShareAllIsAvailable = new JoinDataComplete( - new JoinData - { - JoinNumber = 224, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "FB Indicates if layout 'ShareAll' is available", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.DigitalSerial - }); - - // TODO: #714 [ ] JoinMap >> SelfivewPipSizeToggle - [JoinName("SelfviewPipSizeToggle")] - public JoinDataComplete SelfviewPipSizeToggle = new JoinDataComplete( - new JoinData - { - JoinNumber = 231, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Toggles the selfview pip size, (aka layout size)", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("StartRecording")] - public JoinDataComplete StartRecording = new JoinDataComplete( - new JoinData - { - JoinNumber = 241, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Pulse to start the Meeting Recording. FB high if meeting is currently recording", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("StopRecording")] - public JoinDataComplete StopRecording = new JoinDataComplete( - new JoinData - { - JoinNumber = 242, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Pulse to stop the Meeting Recording. FB high if meeting is currently NOT recording", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("RecordConsentPromptIsVisible")] - public JoinDataComplete RecordConsentPromptIsVisible = new JoinDataComplete( - new JoinData - { - JoinNumber = 243, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "When high, indicates that the recording consent prompt is visible on the ZoomRoom UI", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("RecordingPromptAgree")] - public JoinDataComplete RecordingPromptAgree = new JoinDataComplete( - new JoinData - { - JoinNumber = 244, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Pulse to agree to consent for meeting recording", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("RecordingPromptDisagree")] - public JoinDataComplete RecordingPromptDisagree = new JoinDataComplete( - new JoinData - { - JoinNumber = 245, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Pulse to disagree to consent for meeting recording", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("MeetingCanRecord")] - public JoinDataComplete MeetingCanRecord = new JoinDataComplete( - new JoinData - { - JoinNumber = 246, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "When high, indicated that the current meeting can be recorded", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - - #region Sharing Status - - [JoinName("IsSharingAirplay")] - public JoinDataComplete IsSharingAirplay = new JoinDataComplete( - new JoinData - { - JoinNumber = 250, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Indicates an Airplay source is sharing", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("IsSharingHdmi")] - public JoinDataComplete IsSharingHdmi = new JoinDataComplete( - new JoinData - { - JoinNumber = 251, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Indicates an HDMI source is sharing", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - - - #endregion - //[JoinName("ParticipantAudioMuteToggleStart")] - //public JoinDataComplete ParticipantAudioMuteToggleStart = new JoinDataComplete( - // new JoinData - // { - // JoinNumber = 500, - // JoinSpan = 100 - // }, - // new JoinMetadata - // { - // Description = "Toggles the participant's audio mute status", - // JoinCapabilities = eJoinCapabilities.ToSIMPL, - // JoinType = eJoinType.Digital - // }); - - //[JoinName("ParticipantVideoMuteToggleStart")] - //public JoinDataComplete ParticipantVideoMuteToggleStart = new JoinDataComplete( - // new JoinData - // { - // JoinNumber = 800, - // JoinSpan = 100 - // }, - // new JoinMetadata - // { - // Description = "Toggles the participant's video mute status", - // JoinCapabilities = eJoinCapabilities.ToSIMPL, - // JoinType = eJoinType.Digital - // }); - - //[JoinName("ParticipantPinToggleStart")] - //public JoinDataComplete ParticipantPinToggleStart = new JoinDataComplete( - // new JoinData - // { - // JoinNumber = 1100, - // JoinSpan = 100 - // }, - // new JoinMetadata - // { - // Description = "Toggles the participant's pin status", - // JoinCapabilities = eJoinCapabilities.ToSIMPL, - // JoinType = eJoinType.Digital - // }); - - #endregion - - - #region Analog - - [JoinName("NumberOfScreens")] - public JoinDataComplete NumberOfScreens = new JoinDataComplete( - new JoinData - { - JoinNumber = 11, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Reports the number of screens connected", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Analog - }); - - [JoinName("ScreenIndexToPinUserTo")] - public JoinDataComplete ScreenIndexToPinUserTo = new JoinDataComplete( - new JoinData - { - JoinNumber = 11, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Specifies the screen index a participant should be pinned to", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Analog - }); - - #endregion - - - #region Serials - - // TODO [ ] Issue #868 - [JoinName("SubmitPassword")] - public JoinDataComplete SubmitPassword = new JoinDataComplete( - new JoinData - { - JoinNumber = 6, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Submit password text", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Serial - }); - - // TODO [ ] Issue #868 - [JoinName("PasswordPromptMessage")] - public JoinDataComplete PasswordPromptMessage = new JoinDataComplete( - new JoinData - { - JoinNumber = 6, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Password prompt message", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - // TODO [ ] Issue #868 - [JoinName("MeetingInfoId")] - public JoinDataComplete MeetingInfoId = new JoinDataComplete( - new JoinData - { - JoinNumber = 11, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Meeting info ID text feedback", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - // TODO [ ] Issue #868 - [JoinName("MeetingInfoHostt")] - public JoinDataComplete MeetingInfoHost = new JoinDataComplete( - new JoinData - { - JoinNumber = 12, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Meeting info Host text feedback", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - // TODO [ ] Issue #868 - [JoinName("MeetingInfoPassword")] - public JoinDataComplete MeetingInfoPassword = new JoinDataComplete( - new JoinData - { - JoinNumber = 13, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Meeting info Password text feedback", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("GetSetCurrentLayout")] - public JoinDataComplete GetSetCurrentLayout = new JoinDataComplete( - new JoinData - { - JoinNumber = 215, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Sets and reports the current layout. Use the LayoutXXXXIsAvailable signals to determine valid layouts", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Serial - }); - - // TODO: #714 [ ] JoinMap >> GetSetSelfviewPipSize - [JoinName("GetSetSelfviewPipSize")] - public JoinDataComplete GetSetSelfviewPipSize = new JoinDataComplete( - new JoinData - { - JoinNumber = 230, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Sets and reports the selfview pip size, (aka layout size).", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.DigitalSerial - }); - - [JoinName("DisplayState")] - public JoinDataComplete DisplayState = new JoinDataComplete( - new JoinData - { - JoinNumber = 250, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Reports the instructions the ZoomRoom is displaying on the monitor. ", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("AirplayShareCode")] - public JoinDataComplete AirplayShareCode = new JoinDataComplete( - new JoinData - { - JoinNumber = 251, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Reports the current code for Airplay Sharing.", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("LaptopShareKey")] - public JoinDataComplete LaptopShareKey = new JoinDataComplete( - new JoinData - { - JoinNumber = 252, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "The alpha-only sharing key that users type into a laptop client to share with the Zoom Room.", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("LaptopSharePairingCode")] - public JoinDataComplete LaptopSharePairingCode = new JoinDataComplete( - new JoinData - { - JoinNumber = 253, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "This is the paring code that is broadcast via an ultrasonic signal from the ZRC. It is different than the user-supplied paring code. The ZRC uses a Zoom-proprietary method of advertizing the ultrasonic pairing code, so it\'s not possible to advertize it using commonly available libraries.", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("WifiName")] - public JoinDataComplete WifiName = new JoinDataComplete( - new JoinData - { - JoinNumber = 254, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Reports the Wifi SSID used by the ZoomRoom.", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - [JoinName("ServerName")] - public JoinDataComplete ServerName = new JoinDataComplete( - new JoinData - { - JoinNumber = 255, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Reports the namne of the the ZoomRoom.", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - - - #endregion - - public ZoomRoomJoinMap(uint joinStart) - : base(joinStart, typeof(ZoomRoomJoinMap)) - { - } - - public ZoomRoomJoinMap(uint joinStart, Type type) - : base(joinStart, type) - { - } - } +using System; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges.JoinMaps; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom +{ + public class ZoomRoomJoinMap : VideoCodecControllerJoinMap + { + #region Digital + + [JoinName("CancelJoinAttempt")] + public JoinDataComplete CancelJoinAttempt = new JoinDataComplete( + new JoinData + { + JoinNumber = 5, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Pulse to hide the password prompt", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("MeetingPasswordRequired")] + public JoinDataComplete MeetingPasswordRequired = new JoinDataComplete( + new JoinData + { + JoinNumber = 6, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "FB Indicates to show the password prompt", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("PasswordIncorrect")] + public JoinDataComplete PasswordIncorrect = new JoinDataComplete( + new JoinData + { + JoinNumber = 7, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "FB Indicates the password entered is incorrect", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("PasswordLoginFailed")] + public JoinDataComplete PasswordLoginFailed = new JoinDataComplete( + new JoinData + { + JoinNumber = 8, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "FB Indicates the password entered is incorrect", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("WaitingForHost")] + public JoinDataComplete WaitingForHost = new JoinDataComplete( + new JoinData + { + JoinNumber = 9, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "FB Indicates system is waiting for host", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("IsHost")] + public JoinDataComplete IsHost = new JoinDataComplete( + new JoinData + { + JoinNumber = 10, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "FB Indicates system is the host", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("StartMeetingNow")] + public JoinDataComplete StartMeetingNow = new JoinDataComplete( + new JoinData + { + JoinNumber = 25, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Pulse to start an ad-hoc meeting with the default duration", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("ShareOnlyMeeting")] + public JoinDataComplete ShareOnlyMeeting = new JoinDataComplete( + new JoinData + { + JoinNumber = 26, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Triggers a share only meeting, feedback indicates the current meeting is share only", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("StartNormalMeetingFromSharingOnlyMeeting")] + public JoinDataComplete StartNormalMeetingFromSharingOnlyMeeting = new JoinDataComplete( + new JoinData + { + JoinNumber = 27, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Starts a normal meeting from a share only meeting", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CanSwapContentWithThumbnail")] + public JoinDataComplete CanSwapContentWithThumbnail = new JoinDataComplete( + new JoinData + { + JoinNumber = 206, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "FB Indicates if content can be swapped with thumbnail", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("SwapContentWithThumbnail")] + public JoinDataComplete SwapContentWithThumbnail = new JoinDataComplete( + new JoinData + { + JoinNumber = 206, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Pulse to swap content with thumbnail. FB reports current state", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("GetAvailableLayouts")] + public JoinDataComplete GetAvailableLayouts = new JoinDataComplete( + new JoinData + { + JoinNumber = 215, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Gets the available layouts. Will update the LayoutXXXXXIsAvailbale signals.", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("LayoutIsOnFirstPage")] + public JoinDataComplete LayoutIsOnFirstPage = new JoinDataComplete( + new JoinData + { + JoinNumber = 216, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Indicates if layout is on first page", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("LayoutIsOnLastPage")] + public JoinDataComplete LayoutIsOnLastPage = new JoinDataComplete( + new JoinData + { + JoinNumber = 217, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Indicates if layout is on first page", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("LayoutTurnToNextPage")] + public JoinDataComplete LayoutTurnToNextPage = new JoinDataComplete( + new JoinData + { + JoinNumber = 216, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Turns layout view to next page", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("LayoutTurnToPreviousPage")] + public JoinDataComplete LayoutTurnToPreviousPage = new JoinDataComplete( + new JoinData + { + JoinNumber = 217, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Turns layout view to previous page", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("LayoutGalleryIsAvailable")] + public JoinDataComplete LayoutGalleryIsAvailable = new JoinDataComplete( + new JoinData + { + JoinNumber = 221, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "FB Indicates if layout 'Gallery' is available", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.DigitalSerial + }); + + [JoinName("LayoutSpeakerIsAvailable")] + public JoinDataComplete LayoutSpeakerIsAvailable = new JoinDataComplete( + new JoinData + { + JoinNumber = 222, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "FB Indicates if layout 'Speaker' is available", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.DigitalSerial + }); + + [JoinName("LayoutStripIsAvailable")] + public JoinDataComplete LayoutStripIsAvailable = new JoinDataComplete( + new JoinData + { + JoinNumber = 223, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "FB Indicates if layout 'Strip' is available", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.DigitalSerial + }); + + [JoinName("LayoutShareAllIsAvailable")] + public JoinDataComplete LayoutShareAllIsAvailable = new JoinDataComplete( + new JoinData + { + JoinNumber = 224, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "FB Indicates if layout 'ShareAll' is available", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.DigitalSerial + }); + + // TODO: #714 [ ] JoinMap >> SelfivewPipSizeToggle + [JoinName("SelfviewPipSizeToggle")] + public JoinDataComplete SelfviewPipSizeToggle = new JoinDataComplete( + new JoinData + { + JoinNumber = 231, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Toggles the selfview pip size, (aka layout size)", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("StartRecording")] + public JoinDataComplete StartRecording = new JoinDataComplete( + new JoinData + { + JoinNumber = 241, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Pulse to start the Meeting Recording. FB high if meeting is currently recording", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("StopRecording")] + public JoinDataComplete StopRecording = new JoinDataComplete( + new JoinData + { + JoinNumber = 242, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Pulse to stop the Meeting Recording. FB high if meeting is currently NOT recording", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("RecordConsentPromptIsVisible")] + public JoinDataComplete RecordConsentPromptIsVisible = new JoinDataComplete( + new JoinData + { + JoinNumber = 243, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "When high, indicates that the recording consent prompt is visible on the ZoomRoom UI", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("RecordingPromptAgree")] + public JoinDataComplete RecordingPromptAgree = new JoinDataComplete( + new JoinData + { + JoinNumber = 244, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Pulse to agree to consent for meeting recording", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("RecordingPromptDisagree")] + public JoinDataComplete RecordingPromptDisagree = new JoinDataComplete( + new JoinData + { + JoinNumber = 245, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Pulse to disagree to consent for meeting recording", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("MeetingCanRecord")] + public JoinDataComplete MeetingCanRecord = new JoinDataComplete( + new JoinData + { + JoinNumber = 246, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "When high, indicated that the current meeting can be recorded", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + + #region Sharing Status + + [JoinName("IsSharingAirplay")] + public JoinDataComplete IsSharingAirplay = new JoinDataComplete( + new JoinData + { + JoinNumber = 250, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Indicates an Airplay source is sharing", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("IsSharingHdmi")] + public JoinDataComplete IsSharingHdmi = new JoinDataComplete( + new JoinData + { + JoinNumber = 251, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Indicates an HDMI source is sharing", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + + + #endregion + //[JoinName("ParticipantAudioMuteToggleStart")] + //public JoinDataComplete ParticipantAudioMuteToggleStart = new JoinDataComplete( + // new JoinData + // { + // JoinNumber = 500, + // JoinSpan = 100 + // }, + // new JoinMetadata + // { + // Description = "Toggles the participant's audio mute status", + // JoinCapabilities = eJoinCapabilities.ToSIMPL, + // JoinType = eJoinType.Digital + // }); + + //[JoinName("ParticipantVideoMuteToggleStart")] + //public JoinDataComplete ParticipantVideoMuteToggleStart = new JoinDataComplete( + // new JoinData + // { + // JoinNumber = 800, + // JoinSpan = 100 + // }, + // new JoinMetadata + // { + // Description = "Toggles the participant's video mute status", + // JoinCapabilities = eJoinCapabilities.ToSIMPL, + // JoinType = eJoinType.Digital + // }); + + //[JoinName("ParticipantPinToggleStart")] + //public JoinDataComplete ParticipantPinToggleStart = new JoinDataComplete( + // new JoinData + // { + // JoinNumber = 1100, + // JoinSpan = 100 + // }, + // new JoinMetadata + // { + // Description = "Toggles the participant's pin status", + // JoinCapabilities = eJoinCapabilities.ToSIMPL, + // JoinType = eJoinType.Digital + // }); + + #endregion + + + #region Analog + + [JoinName("NumberOfScreens")] + public JoinDataComplete NumberOfScreens = new JoinDataComplete( + new JoinData + { + JoinNumber = 11, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Reports the number of screens connected", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Analog + }); + + [JoinName("ScreenIndexToPinUserTo")] + public JoinDataComplete ScreenIndexToPinUserTo = new JoinDataComplete( + new JoinData + { + JoinNumber = 11, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Specifies the screen index a participant should be pinned to", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Analog + }); + + #endregion + + + #region Serials + + // TODO [ ] Issue #868 + [JoinName("SubmitPassword")] + public JoinDataComplete SubmitPassword = new JoinDataComplete( + new JoinData + { + JoinNumber = 6, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Submit password text", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Serial + }); + + // TODO [ ] Issue #868 + [JoinName("PasswordPromptMessage")] + public JoinDataComplete PasswordPromptMessage = new JoinDataComplete( + new JoinData + { + JoinNumber = 6, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Password prompt message", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + // TODO [ ] Issue #868 + [JoinName("MeetingInfoId")] + public JoinDataComplete MeetingInfoId = new JoinDataComplete( + new JoinData + { + JoinNumber = 11, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Meeting info ID text feedback", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + // TODO [ ] Issue #868 + [JoinName("MeetingInfoHostt")] + public JoinDataComplete MeetingInfoHost = new JoinDataComplete( + new JoinData + { + JoinNumber = 12, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Meeting info Host text feedback", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + // TODO [ ] Issue #868 + [JoinName("MeetingInfoPassword")] + public JoinDataComplete MeetingInfoPassword = new JoinDataComplete( + new JoinData + { + JoinNumber = 13, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Meeting info Password text feedback", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("GetSetCurrentLayout")] + public JoinDataComplete GetSetCurrentLayout = new JoinDataComplete( + new JoinData + { + JoinNumber = 215, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Sets and reports the current layout. Use the LayoutXXXXIsAvailable signals to determine valid layouts", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Serial + }); + + // TODO: #714 [ ] JoinMap >> GetSetSelfviewPipSize + [JoinName("GetSetSelfviewPipSize")] + public JoinDataComplete GetSetSelfviewPipSize = new JoinDataComplete( + new JoinData + { + JoinNumber = 230, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Sets and reports the selfview pip size, (aka layout size).", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.DigitalSerial + }); + + [JoinName("DisplayState")] + public JoinDataComplete DisplayState = new JoinDataComplete( + new JoinData + { + JoinNumber = 250, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Reports the instructions the ZoomRoom is displaying on the monitor. ", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("AirplayShareCode")] + public JoinDataComplete AirplayShareCode = new JoinDataComplete( + new JoinData + { + JoinNumber = 251, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Reports the current code for Airplay Sharing.", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("LaptopShareKey")] + public JoinDataComplete LaptopShareKey = new JoinDataComplete( + new JoinData + { + JoinNumber = 252, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "The alpha-only sharing key that users type into a laptop client to share with the Zoom Room.", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("LaptopSharePairingCode")] + public JoinDataComplete LaptopSharePairingCode = new JoinDataComplete( + new JoinData + { + JoinNumber = 253, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "This is the paring code that is broadcast via an ultrasonic signal from the ZRC. It is different than the user-supplied paring code. The ZRC uses a Zoom-proprietary method of advertizing the ultrasonic pairing code, so it\'s not possible to advertize it using commonly available libraries.", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("WifiName")] + public JoinDataComplete WifiName = new JoinDataComplete( + new JoinData + { + JoinNumber = 254, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Reports the Wifi SSID used by the ZoomRoom.", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + [JoinName("ServerName")] + public JoinDataComplete ServerName = new JoinDataComplete( + new JoinData + { + JoinNumber = 255, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Reports the namne of the the ZoomRoom.", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + + + #endregion + + public ZoomRoomJoinMap(uint joinStart) + : base(joinStart, typeof(ZoomRoomJoinMap)) + { + } + + public ZoomRoomJoinMap(uint joinStart, Type type) + : base(joinStart, type) + { + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomPropertiesConfig.cs b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomPropertiesConfig.cs similarity index 98% rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomPropertiesConfig.cs rename to src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomPropertiesConfig.cs index 771cfe11..1026d9a4 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomPropertiesConfig.cs +++ b/src/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoomPropertiesConfig.cs @@ -2,43 +2,43 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using Crestron.SimplSharp; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; +using Crestron.SimplSharp; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; using PepperDash.Core; using PepperDash.Essentials.Core; namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom { public class ZoomRoomPropertiesConfig - { + { [JsonProperty("communicationMonitorProperties")] - public CommunicationMonitorConfig CommunicationMonitorProperties { get; set; } - + public CommunicationMonitorConfig CommunicationMonitorProperties { get; set; } + [JsonProperty("disablePhonebookAutoDownload")] - public bool DisablePhonebookAutoDownload { get; set; } - + public bool DisablePhonebookAutoDownload { get; set; } + [JsonProperty("supportsCameraAutoMode")] - public bool SupportsCameraAutoMode { get; set; } - + public bool SupportsCameraAutoMode { get; set; } + [JsonProperty("supportsCameraOff")] public bool SupportsCameraOff { get; set; } - //if true, the layouts will be set automatically when sharing starts/ends or a call is joined - [JsonProperty("autoDefaultLayouts")] + //if true, the layouts will be set automatically when sharing starts/ends or a call is joined + [JsonProperty("autoDefaultLayouts")] public bool AutoDefaultLayouts { get; set; } - /* This layout will be selected when Sharing starts (either from Far end or locally)*/ - [JsonProperty("defaultSharingLayout")] - [JsonConverter(typeof(StringEnumConverter))] + /* This layout will be selected when Sharing starts (either from Far end or locally)*/ + [JsonProperty("defaultSharingLayout")] + [JsonConverter(typeof(StringEnumConverter))] public zConfiguration.eLayoutStyle DefaultSharingLayout { get; set; } - //This layout will be selected when a call is connected and no content is being shared - [JsonProperty("defaultCallLayout")] - [JsonConverter(typeof(StringEnumConverter))] - public zConfiguration.eLayoutStyle DefaultCallLayout { get; set; } - - [JsonProperty("minutesBeforeMeetingStart")] + //This layout will be selected when a call is connected and no content is being shared + [JsonProperty("defaultCallLayout")] + [JsonConverter(typeof(StringEnumConverter))] + public zConfiguration.eLayoutStyle DefaultCallLayout { get; set; } + + [JsonProperty("minutesBeforeMeetingStart")] public int MinutesBeforeMeetingStart { get; set; } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Framework.sln b/src/essentials-framework/Essentials Framework.sln similarity index 100% rename from essentials-framework/Essentials Framework.sln rename to src/essentials-framework/Essentials Framework.sln diff --git a/essentials-framework/Essentials/PepperDashEssentials/Bridges/Bridges.BridgeFactory.cs b/src/essentials-framework/Essentials/PepperDashEssentials/Bridges/Bridges.BridgeFactory.cs similarity index 100% rename from essentials-framework/Essentials/PepperDashEssentials/Bridges/Bridges.BridgeFactory.cs rename to src/essentials-framework/Essentials/PepperDashEssentials/Bridges/Bridges.BridgeFactory.cs diff --git a/essentials-framework/Essentials/PepperDashEssentials/Bridges/EssentialComms.cs b/src/essentials-framework/Essentials/PepperDashEssentials/Bridges/EssentialComms.cs similarity index 100% rename from essentials-framework/Essentials/PepperDashEssentials/Bridges/EssentialComms.cs rename to src/essentials-framework/Essentials/PepperDashEssentials/Bridges/EssentialComms.cs diff --git a/essentials-framework/Essentials/PepperDashEssentials/Bridges/EssentialDM.cs b/src/essentials-framework/Essentials/PepperDashEssentials/Bridges/EssentialDM.cs similarity index 100% rename from essentials-framework/Essentials/PepperDashEssentials/Bridges/EssentialDM.cs rename to src/essentials-framework/Essentials/PepperDashEssentials/Bridges/EssentialDM.cs diff --git a/essentials-framework/Essentials/PepperDashEssentials/Configuration Original/Factories/DmFactory.cs b/src/essentials-framework/Essentials/PepperDashEssentials/Configuration Original/Factories/DmFactory.cs similarity index 100% rename from essentials-framework/Essentials/PepperDashEssentials/Configuration Original/Factories/DmFactory.cs rename to src/essentials-framework/Essentials/PepperDashEssentials/Configuration Original/Factories/DmFactory.cs diff --git a/essentials-framework/Essentials/PepperDashEssentials/ControlSystem.cs b/src/essentials-framework/Essentials/PepperDashEssentials/ControlSystem.cs similarity index 100% rename from essentials-framework/Essentials/PepperDashEssentials/ControlSystem.cs rename to src/essentials-framework/Essentials/PepperDashEssentials/ControlSystem.cs diff --git a/essentials-framework/Essentials/PepperDashEssentials/PepperDashEssentials.csproj b/src/essentials-framework/Essentials/PepperDashEssentials/PepperDashEssentials.csproj similarity index 100% rename from essentials-framework/Essentials/PepperDashEssentials/PepperDashEssentials.csproj rename to src/essentials-framework/Essentials/PepperDashEssentials/PepperDashEssentials.csproj diff --git a/essentials-framework/Essentials/PepperDashEssentials/UIDrivers/DualDisplayRouting REMOVE.cs b/src/essentials-framework/Essentials/PepperDashEssentials/UIDrivers/DualDisplayRouting REMOVE.cs similarity index 100% rename from essentials-framework/Essentials/PepperDashEssentials/UIDrivers/DualDisplayRouting REMOVE.cs rename to src/essentials-framework/Essentials/PepperDashEssentials/UIDrivers/DualDisplayRouting REMOVE.cs