Example #1
0
        /// <summary>
        /// Enables the PIT.
        /// </summary>
        public override void Enable()
        {
            if (!enabled)
            {
                //Ignore the process state for timer interrupts. Timer interrupts occur so frequently
                //  that to continually switch state would be massively inefficient. Also, switching
                //  state isn't necessary for the handlers queued in the timer.
                DeviceManager.AddDevice(this);
                enabled = true;

                T0RateGen = true;
                T0Reload  = _T0Reload;

                Interrupts.Interrupts.EnableIRQ(0);
            }
        }
Example #2
0
        void Init()
        {
            WarmupTime   = 10000;
            CooldownTime = 8000;

            CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 2000, 120000, 300000, StatusGet);
            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();
        }
Example #3
0
        private void btnAddDevice_Click(object sender, EventArgs e)
        {
            try
            {
                if (DeviceManager.Devices.Count >= 8)
                {
                    return;
                }

                string devName = txtDeviceName.Text;
                if (string.IsNullOrEmpty(devName))
                {
                    return;
                }

                if (!DeviceManager.CanAdd(devName))
                {
                    MessageBox.Show("Urządzenie o podanej nazwie już istnieje",
                                    "Niepoprawna nazwa",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    return;
                }

                DeviceType     type = (DeviceType)ddDeviceType.SelectedIndex;
                eCalendarColor color;
                int            slot = Convert.ToInt32(ddDeviceSlot.Text);

                if (DeviceManager.HasColor(type))
                {
                    color = CalendarUtils.CalendarColorFromString(cddDeviceColor.SelectedItem.ToString());
                }
                else
                {
                    color = DeviceManager.GetDefaultColor(type);
                }

                DeviceManager.AddDevice(devName, type, slot, color);
                devName += getSlotFormat(slot);
                TimelineAddNewRow(devName, color);
                txtDeviceName.Text = "";
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
        /// <summary>
        /// Initializes this attribute based on config values and generates subscriptions commands and adds commands to the parent's queue.
        /// </summary>
        public void Initialize(string key, string label, bool hasMute, bool hasLevel)
        {
            Key = string.Format("{0}--{1}", Parent.Key, key);

            DeviceManager.AddDevice(this);

            Debug.Console(2, this, "Adding LevelControl '{0}'", Key);

            this.IsSubscribed = false;

            MuteFeedback = new BoolFeedback(() => _IsMuted);

            VolumeLevelFeedback = new IntFeedback(() => _VolumeLevel);

            HasMute  = hasMute;
            HasLevel = hasLevel;
        }
Example #5
0
        void LinkSystemMonitorToAppServer()
        {
            var sysMon = DeviceManager.GetDeviceForKey("systemMonitor") as PepperDash.Essentials.Core.Monitoring.SystemMonitorController;

            var appServer = DeviceManager.GetDeviceForKey("appServer") as MobileControlSystemController;


            if (sysMon != null && appServer != null)
            {
                var key       = sysMon.Key + "-" + appServer.Key;
                var messenger = new PepperDash.Essentials.AppServer.Messengers.SystemMonitorMessenger
                                    (key, sysMon, "/device/systemMonitor");

                messenger.RegisterWithAppServer(appServer);

                DeviceManager.AddDevice(messenger);
            }
        }
Example #6
0
        public void LoadDevices()
        {
            IDeviceReader deviceReader = Container.Resolve <IDeviceReader>();

            DeviceManager   deviceManager = Container.Resolve <DeviceManager>();
            DeviceModelList deviceModels  = deviceReader.ReadDevices();

            List <IStreamDeckRefHandle> deckRefHandles = StreamDeck.EnumerateDevices().ToList();
            //TODO Add support for multuple devices
            var deviceModel = deviceModels.First();

            foreach (IStreamDeckRefHandle streamDeckRefHandle in deckRefHandles)
            {
                deviceModel.Info.HardwareId = streamDeckRefHandle.DevicePath;
                IStreamDeckBoard board = streamDeckRefHandle.Open();
                deviceManager.AddDevice(board, deviceModel);
            }
        }
Example #7
0
        /// <summary>
        /// Reads all rooms from config and adds them to DeviceManager
        /// </summary>
        public void LoadRooms()
        {
            if (ConfigReader.ConfigObject.Rooms == null)
            {
                Debug.Console(0, "WARNING: Configuration contains no rooms");
                return;
            }

            foreach (var roomConfig in ConfigReader.ConfigObject.Rooms)
            {
                var room = roomConfig.GetRoomObject();
                if (room != null)
                {
                    if (room is EssentialsHuddleSpaceRoom)
                    {
                        DeviceManager.AddDevice(room);

                        Debug.Console(1, "Room is EssentialsHuddleSpaceRoom, attempting to add to DeviceManager with Fusion");
                        DeviceManager.AddDevice(new EssentialsHuddleSpaceFusionSystemControllerBase((EssentialsHuddleSpaceRoom)room, 0xf1));

                        // Cotija bridge
                        var bridge = new CotijaEssentialsHuddleSpaceRoomBridge(room as EssentialsHuddleSpaceRoom);
                        AddBridgePostActivationHelper(bridge);                         // Lets things happen later when all devices are present
                        DeviceManager.AddDevice(bridge);
                    }
                    else if (room is EssentialsHuddleVtc1Room)
                    {
                        DeviceManager.AddDevice(room);

                        Debug.Console(1, "Room is EssentialsHuddleVtc1Room, attempting to add to DeviceManager with Fusion");
                        DeviceManager.AddDevice(new EssentialsHuddleVtc1FusionController((EssentialsHuddleVtc1Room)room, 0xf1));
                    }
                    else
                    {
                        Debug.Console(1, "Room is NOT EssentialsHuddleSpaceRoom, attempting to add to DeviceManager w/o Fusion");
                        DeviceManager.AddDevice(room);
                    }
                }
                else
                {
                    Debug.Console(0, "WARNING: Cannot create room from config, key '{0}'", roomConfig.Key);
                }
            }
        }
Example #8
0
            public override void OnReceive(Context context, Intent intent)
            {
                var device = intent.GetParcelableExtra(UsbManager.ExtraDevice) as UsbDevice;

                if (device == null)
                {
                    return;
                }

                var id   = new UsbSerialDeviceID(device.VendorId, device.ProductId);
                var info = DeviceManager.FindDeviceInfo(id, device.DeviceClass, DeviceManager.AllowAnonymousCdcAcmDevices);

                if (info == null)
                {
                    return;
                }

                var action = intent.Action;

                if (action == UsbManager.ActionUsbDeviceAttached)
                {
                    if (!UsbManager.HasPermission(device))
                    {
                        var permissionIntent = PendingIntent.GetBroadcast(context, 0, new Intent(ActionUsbPermission), 0);
                        UsbManager.RequestPermission(device, permissionIntent);
                    }
                    else
                    {
                        DeviceManager.AddDevice(UsbManager, device);
                    }
                }
                else if (action == UsbManager.ActionUsbDeviceDetached)
                {
                    DeviceManager.RemoveDevice(device);
                }
                else if (action == ActionUsbPermission)
                {
                    if (UsbManager.HasPermission(device))
                    {
                        DeviceManager.AddDevice(UsbManager, device);
                    }
                }
            }
Example #9
0
        void Init()
        {
            WarmupTime   = 10000;
            CooldownTime = 8000;

            CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 30000, 120000, 300000, StatusGet);
            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), InputHdmi1Value);

            AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.HdmiIn2, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                                     eRoutingPortConnectionType.Hdmi, new Action(InputHdmi2), this), InputHdmi2Value);

            AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.HdmiIn3, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                                     eRoutingPortConnectionType.Hdmi, new Action(InputHdmi3), this), InputHdmi3Value);

            AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.HdmiIn4, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                                     eRoutingPortConnectionType.Hdmi, new Action(InputHdmi4), this), InputHdmi4Value);

            AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.HdmiIn5, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                                     eRoutingPortConnectionType.Hdmi, new Action(InputHdmi5), this), InputHdmi5Value);

            AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.DisplayPortIn1, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                                     eRoutingPortConnectionType.DisplayPort, new Action(InputDisplayPort1), this), InputDisplayPort1Value);

            AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.VgaIn, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                                     eRoutingPortConnectionType.Dvi, new Action(InputVga1), this), InputVga1Value);

            AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.IpcOps, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                                     eRoutingPortConnectionType.Composite, new Action(InputIpcOps), this), InputIpcOpsValue);

            AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.MediaPlayer, eRoutingSignalType.Video,
                                                     eRoutingPortConnectionType.Vga, new Action(InputMediaPlayer), this), InputMediaPlayerValue);

            VolumeLevelFeedback = new IntFeedback(() => { return(_VolumeLevelForSig); });
            MuteFeedback        = new BoolFeedback(() => _IsMuted);
        }
Example #10
0
        public ClearOneDSPVolumeControl(string key, ClearOneLevelControlBlockConfig config, ClearOneDSPDevice parent)
        {
            _config = config;
            _parent = parent;
            Key     = string.Format("{0}--{1}", _parent.Key, key);
            Name    = config.Label;

            DeviceManager.AddDevice(this);

            Debug.Console(2, this, "Adding LevelControl '{0}':{1}", Key, Name);

            _muteCmd = String.Format("{0}{1} {2} {3} {4}", _config.DeviceType.ToChar(), _config.DeviceId, @"MUTE", _config.Channel, _config.Group.ToChar());
            _gainCmd = String.Format("{0}{1} {2} {3} {4}", _config.DeviceType.ToChar(), _config.DeviceId, @"GAIN", _config.Channel, _config.Group.ToChar());

            _muteCmdFeedbackKey = "OK> #" + _muteCmd + ' ';
            _gainCmdFeedbackKey = "OK> #" + _gainCmd + ' ';

            MuteFeedback        = new BoolFeedback(() => _isMuted);
            VolumeLevelFeedback = new IntFeedback(() => _volumeLevel);
        }
Example #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="key"></param>
        /// <param name="name"></param>
        /// <param name="ipId"></param>
        public MobileControlDdvc01RoomBridge(string key, string name, uint ipId)
            : base(key, name)
        {
            try
            {
                EISC = new ThreeSeriesTcpIpEthernetIntersystemCommunications(ipId, "127.0.0.2", Global.ControlSystem);
                var reg = EISC.Register();
                if (reg != Crestron.SimplSharpPro.eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    Debug.Console(0, this, "Cannot connect EISC at IPID {0}: \r{1}", ipId, reg);
                }

                SourceBridge = new MobileControlDdvc01DeviceBridge(key + "-sourceBridge", "DDVC01 source bridge", EISC);
                DeviceManager.AddDevice(SourceBridge);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public void GetDeviceByApplicationNumberTest()
        {
            // arrange
            const int    applicationNumber = 1;
            const string name         = "Dell Vostro";
            const string type         = "Notebook";
            DateTime     registerDate = new DateTime(2016, 3, 15);
            const bool   state        = false;

            Device device = new Device(applicationNumber, name, type, registerDate, state);

            DeviceManager deviceManager = new DeviceManager();

            deviceManager.AddDevice(device);

            // act
            Device obtainedDevice = deviceManager.GetDeviceByApplicationNumber(applicationNumber);

            // assert
            Assert.AreEqual(device, obtainedDevice);
        }
        public void AddDeviceTest()
        {
            // arrange
            const int    applicationNumber = 1;
            const string name         = "Dell Vostro";
            const string type         = "Notebook";
            DateTime     registerDate = new DateTime(2016, 3, 15);
            const bool   state        = false;

            Device device = new Device(applicationNumber, name, type, registerDate, state);

            DeviceManager deviceManager = new DeviceManager();

            // act
            deviceManager.AddDevice(device);

            // assert
            Device addedDevice = deviceManager.devices.Last();

            Assert.AreEqual(device, addedDevice);
        }
Example #14
0
        void SetupCameras()
        {
            Cameras = new List <CameraBase>();

            var internalCamera = new MockVCCamera(Key + "-camera1", "Near End", this);

            Cameras.Add(internalCamera);

            var farEndCamera = new MockFarEndVCCamera(Key + "-cameraFar", "Far End", this);

            Cameras.Add(farEndCamera);

            SelectedCameraFeedback = new StringFeedback(() => SelectedCamera.Key);

            ControllingFarEndCameraFeedback = new BoolFeedback(() => SelectedCamera is IAmFarEndCamera);

            CameraAutoModeIsOnFeedback = new BoolFeedback(() => _CameraAutoModeIsOn);

            CameraAutoModeIsOnFeedback.FireUpdate();

            DeviceManager.AddDevice(internalCamera);
            DeviceManager.AddDevice(farEndCamera);

            NearEndPresets = new List <CodecRoomPreset>(15); // Fix the capacity to emulate Cisco

            NearEndPresets = PropertiesConfig.Presets;

            FarEndRoomPresets = new List <CodecRoomPreset>(15); // Fix the capacity to emulate Cisco

            // Add the far end presets
            for (int i = 1; i <= FarEndRoomPresets.Capacity; i++)
            {
                var label = string.Format("Far End Preset {0}", i);
                FarEndRoomPresets.Add(new CodecRoomPreset(i, label, true, false));
            }

            SelectedCamera = internalCamera;;  // call the method to select the camera and ensure the feedbacks get updated.
        }
Example #15
0
        public CameraVisca(string key, string name, IBasicCommunication comm, CameraPropertiesConfig props) :
            base(key, name)
        {
            Presets = props.Presets;

            OutputPorts.Add(new RoutingOutputPort("videoOut", eRoutingSignalType.Video, eRoutingPortConnectionType.None, null, this, true));

            // Default to all capabilties
            Capabilities = eCameraCapabilities.Pan | eCameraCapabilities.Tilt | eCameraCapabilities.Zoom | eCameraCapabilities.Focus;

            Communication = comm;
            var socket = comm as ISocketStatus;

            if (socket != null)
            {
                // This instance uses IP control
                socket.ConnectionChange += new EventHandler <GenericSocketStatusChageEventArgs>(socket_ConnectionChange);
            }
            else
            {
                // This instance uses RS-232 control
            }
            PortGather = new CommunicationGather(Communication, "\xFF");


            Communication.BytesReceived += new EventHandler <GenericCommMethodReceiveBytesArgs>(Communication_BytesReceived);
            PowerIsOnFeedback            = new BoolFeedback(() => { return(PowerIsOn); });

            if (props.CommunicationMonitorProperties != null)
            {
                CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, props.CommunicationMonitorProperties);
            }
            else
            {
                CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 20000, 120000, 300000, "\x81\x09\x04\x00\xFF");
            }
            DeviceManager.AddDevice(CommunicationMonitor);
        }
Example #16
0
        public IRBlurayBase(string key, string name, IrOutputPortController portCont)
            : base(key, name)
        {
            IrPort = portCont;
            DeviceManager.AddDevice(portCont);

            HasKeypadAccessoryButton1     = true;
            KeypadAccessoryButton1Command = "Clear";
            KeypadAccessoryButton1Label   = "Clear";

            HasKeypadAccessoryButton2     = true;
            KeypadAccessoryButton2Command = "NumericEnter";
            KeypadAccessoryButton2Label   = "Enter";

            PowerIsOnFeedback = new BoolFeedback(() => _PowerIsOn);

            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 <RoutingOutputPort> {
                HdmiOut, AnyAudioOut
            };
        }
Example #17
0
        private void CreateDspObjects()
        {
            Debug.Console(2, "Creating DSP Objects");

            var props = JsonConvert.DeserializeObject <TesiraDspPropertiesConfig>(_dc.Properties.ToString());

            if (props == null)
            {
                return;
            }

            Debug.Console(2, this, "Props Exists");
            Debug.Console(2, this, "Here's the props string\n {0}", _dc.Properties.ToString());

            Faders.Clear();
            Presets.Clear();
            Dialers.Clear();
            States.Clear();
            Switchers.Clear();
            ControlPointList.Clear();
            Meters.Clear();
            RoomCombiners.Clear();

            if (props.FaderControlBlocks != null)
            {
                Debug.Console(2, this, "levelControlBlocks is not null - There are {0} of them", props.FaderControlBlocks.Count());
                foreach (var block in props.FaderControlBlocks)
                {
                    var key = block.Key;
                    Debug.Console(2, this, "LevelControlBlock Key - {0}", key);
                    var value = block.Value;

                    Faders.Add(key, new TesiraDspFaderControl(key, value, this));
                    Debug.Console(2, this, "Added LevelControlPoint {0} LevelTag: {1} MuteTag: {2}", key, value.LevelInstanceTag, value.MuteInstanceTag);
                    if (block.Value.Enabled)
                    {
                        //Add ControlPoint to the list for the watchdog
                        ControlPointList.Add(Faders[key]);
                    }
                }
            }

            if (props.SwitcherControlBlocks != null)
            {
                Debug.Console(2, this, "switcherControlBlocks is not null - There are {0} of them", props.FaderControlBlocks.Count());
                foreach (var block in props.SwitcherControlBlocks)
                {
                    var key = block.Key;
                    Debug.Console(2, this, "SwitcherControlBlock Key - {0}", key);
                    var value = block.Value;

                    Switchers.Add(key, new TesiraDspSwitcher(key, value, this));
                    Debug.Console(2, this, "Added TesiraSwitcher {0} InstanceTag {1}", key, value.SwitcherInstanceTag);

                    if (block.Value.Enabled)
                    {
                        //Add ControlPoint to the list for the watchdog

                        ControlPointList.Add(Switchers[key]);
                    }
                }
            }

            if (props.DialerControlBlocks != null)
            {
                Debug.Console(2, this, "DialerControlBlocks is not null - There are {0} of them", props.DialerControlBlocks.Count());
                foreach (var block in props.DialerControlBlocks)
                {
                    var key = block.Key;
                    Debug.Console(2, this, "LevelControlBlock Key - {0}", key);
                    var value = block.Value;
                    Dialers.Add(key, new TesiraDspDialer(key, value, this));
                    Debug.Console(2, this, "Added DspDialer {0} ControlStatusTag: {1} DialerTag: {2}", key, value.ControlStatusInstanceTag, value.DialerInstanceTag);

                    if (block.Value.Enabled)
                    {
                        ControlPointList.Add(Dialers[key]);
                    }
                }
            }

            if (props.StateControlBlocks != null)
            {
                Debug.Console(2, this, "stateControlBlocks is not null - There are {0} of them", props.StateControlBlocks.Count());
                foreach (var block in props.StateControlBlocks)
                {
                    var key   = block.Key;
                    var value = block.Value;
                    States.Add(key, new TesiraDspStateControl(key, value, this));
                    Debug.Console(2, this, "Added DspState {0} InstanceTag: {1}", key, value.StateInstanceTag);

                    if (block.Value.Enabled)
                    {
                        ControlPointList.Add(States[key]);
                    }
                }
            }

            if (props.Presets != null)
            {
                foreach (var preset in props.Presets)
                {
                    var value = preset.Value;
                    var key   = preset.Key;
                    Presets.Add(key, value);
                    Debug.Console(2, this, "Added Preset {0} {1}", value.Label, value.PresetName);
                }
            }

            if (props.MeterControlBlocks != null)
            {
                foreach (var meter in props.MeterControlBlocks)
                {
                    var key   = meter.Key;
                    var value = meter.Value;
                    Meters.Add(key, new TesiraDspMeter(key, value, this));
                    Debug.Console(2, this, "Adding Meter {0} InstanceTag: {1}", key, value.MeterInstanceTag);

                    if (value.Enabled)
                    {
                        ControlPointList.Add(Meters[key]);
                    }
                }
            }

            if (props.CrosspointStateControlBlocks != null)
            {
                foreach (var mixer in props.CrosspointStateControlBlocks)
                {
                    var key   = mixer.Key;
                    var value = mixer.Value;
                    CrosspointStates.Add(key, new TesiraDspCrosspointState(key, value, this));
                    Debug.Console(2, this, "Adding Mixer {0} InstanceTag: {1}", key, value.MatrixInstanceTag);

                    if (value.Enabled)
                    {
                        ControlPointList.Add(CrosspointStates[key]);
                    }
                }
            }
            if (props.RoomCombinerControlBlocks == null)
            {
                return;
            }
            foreach (var roomCombiner in props.RoomCombinerControlBlocks)
            {
                var key   = roomCombiner.Key;
                var value = roomCombiner.Value;
                RoomCombiners.Add(key, new TesiraDspRoomCombiner(key, value, this));
                Debug.Console(2, this, "Adding Mixer {0} InstanceTag: {1}", key, value.RoomCombinerInstanceTag);

                if (value.Enabled)
                {
                    ControlPointList.Add(RoomCombiners[key]);
                }
            }

            //Keep me at the end of this method!
            DeviceManager.AddDevice(new TesiraDspDeviceInfo(String.Format("{0}--DeviceInfo", Key), String.Format("{0}--DeviceInfo", Name, Presets), this, Presets));
        }
Example #18
0
        /// <summary>
        /// Consturctor for base Tesira DSP Device
        /// </summary>
        /// <param name="key">Tesira DSP Device Key</param>
        /// <param name="name">Tesira DSP Device Friendly Name</param>
        /// <param name="comm">Device Communication Object</param>
        /// <param name="dc">Full device configuration object</param>
        public TesiraDsp(string key, string name, IBasicCommunication comm, DeviceConfig dc)
            : base(key, name)
        {
            _dc = dc;

            Debug.Console(0, this, "Made it to device constructor");

            _commandQueue = new CrestronQueue(100);
            Communication = comm;
            var socket = comm as ISocketStatus;

            if (socket != null)
            {
                // This instance uses IP control
                socket.ConnectionChange += new EventHandler <GenericSocketStatusChageEventArgs>(socket_ConnectionChange);
                _isSerialComm            = false;
            }
            else
            {
                // This instance uses RS-232 control
                _isSerialComm = true;
            }
            PortGather = new CommunicationGather(Communication, "\x0D\x0A");
            PortGather.LineReceived += Port_LineReceived;

            CommandPassthruFeedback = new StringFeedback(() => DeviceRx);

            CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 20000, 120000, 300000, () => SendLine("SESSION set verbose false"));

            // Custom monitoring, will check the heartbeat tracker count every 20s and reset. Heartbeat sbould be coming in every 20s if subscriptions are valid
            DeviceManager.AddDevice(CommunicationMonitor);

            ControlPointList = new List <ISubscribedComponent>();

            //Initialize Dictionaries
            Feedbacks        = new FeedbackCollection <Feedback>();
            Faders           = new Dictionary <string, TesiraDspFaderControl>();
            Presets          = new Dictionary <string, TesiraDspPresets>();
            Dialers          = new Dictionary <string, TesiraDspDialer>();
            Switchers        = new Dictionary <string, TesiraDspSwitcher>();
            States           = new Dictionary <string, TesiraDspStateControl>();
            Meters           = new Dictionary <string, TesiraDspMeter>();
            CrosspointStates = new Dictionary <string, TesiraDspCrosspointState>();
            RoomCombiners    = new Dictionary <string, TesiraDspRoomCombiner>();


            CommunicationMonitor.StatusChange += CommunicationMonitor_StatusChange;
            CrestronConsole.AddNewConsoleCommand(SendLine, "send" + Key, "", ConsoleAccessLevelEnum.AccessOperator);
            CrestronConsole.AddNewConsoleCommand(s => Communication.Connect(), "con" + Key, "", ConsoleAccessLevelEnum.AccessOperator);

            Feedbacks.Add(CommunicationMonitor.IsOnlineFeedback);
            Feedbacks.Add(CommandPassthruFeedback);

            //Start CommnicationMonitor in PostActivation phase
            AddPostActivationAction(() =>
            {
                Communication.Connect();
                if (_isSerialComm)
                {
                    CommunicationMonitor.Start();
                }
            });

            CreateDspObjects();
        }
Example #19
0
        private void Initialize(TesiraFaderControlBlockConfig config)
        {
            if (config.Enabled)
            {
                DeviceManager.AddDevice(this);
            }

            _type = config.IsMic ? ePdtLevelTypes.Microphone : ePdtLevelTypes.Speaker;

            Debug.Console(2, this, "Adding LevelControl '{0}'", Key);

            IsSubscribed = false;

            HasMute                     = config.HasMute;
            HasLevel                    = config.HasLevel;
            UseAbsoluteValue            = config.UseAbsoluteValue;
            Enabled                     = config.Enabled;
            Permissions                 = config.Permissions;
            IncrementAmount             = config.IncrementAmount;
            AutomaticUnmuteOnVolumeUp   = config.UnmuteOnVolChange;
            _volumeUpRepeatTimer        = new CTimer(VolumeUpRepeat, Timeout.Infinite);
            _volumeDownRepeatTimer      = new CTimer(VolumeDownRepeat, Timeout.Infinite);
            _volumeUpRepeatDelayTimer   = new CTimer(VolumeUpRepeatDelay, Timeout.Infinite);
            _volumeDownRepeatDelayTimer = new CTimer(VolumeDownRepeatDelay, Timeout.Infinite);



            if (HasMute && HasLevel)
            {
                ControlType = 0;
                Debug.Console(2, this, "{0} has BOTH Mute and Level", Key);
            }
            else if (!HasMute && HasLevel)
            {
                ControlType = 1;
                Debug.Console(2, this, "{0} has Level ONLY", Key);
            }

            else if (HasMute && !HasLevel)
            {
                Debug.Console(2, this, "{0} has MUTE ONLY", Key);
                ControlType = 2;
            }

            MuteFeedback    = new BoolFeedback(Key + "-MuteFeedback", () => IsMuted);
            VisibleFeedback = new BoolFeedback(Key + "-VisibleFeedback", () => Enabled);

            VolumeLevelFeedback = new IntFeedback(Key + "-LevelFeedback", () => VolumeLevel);
            TypeFeedback        = new IntFeedback(Key + "-TypeFeedback", () => (ushort)_type);
            ControlTypeFeedback = new IntFeedback(Key + "-ControlTypeFeedback", () => ControlType);
            PermissionsFeedback = new IntFeedback(Key + "-PermissionsFeedback", () => Permissions);

            Feedbacks.Add(MuteFeedback);
            Feedbacks.Add(VolumeLevelFeedback);
            Feedbacks.Add(NameFeedback);
            Feedbacks.Add(VisibleFeedback);
            Feedbacks.Add(TypeFeedback);
            Feedbacks.Add(ControlTypeFeedback);
            Feedbacks.Add(PermissionsFeedback);

            Parent.Feedbacks.AddRange(Feedbacks);
        }
        /// <summary>
        /// CameraVisca Plugin device constructor using IBasicCommunication
        /// </summary>
        /// <param name="key"></param>
        /// <param name="name"></param>
        /// <param name="config"></param>
        /// <param name="comms"></param>
        public CameraVisca(string key, string name, CameraViscaConfig config, IBasicCommunication comm)
            : base(key, name)
        {
            Debug.Console(0, this, "Constructing new {0} instance", name);

            _config = config;
            Enabled = _config.Enabled;

            _visca = new ViscaProtocolProcessor(comm.SendBytes, new Action <byte, string, object[]>((l, f, o) =>
            {
                Debug.Console(l, this, f, o);
            }));

            _camera             = new ViscaCamera((ViscaCameraId)_config.Id, null, _visca);
            _camera.PollEnabled = Enabled;

            Capabilities = eCameraCapabilities.Pan | eCameraCapabilities.Tilt | eCameraCapabilities.Zoom | eCameraCapabilities.Focus;
            ControlMode  = eCameraControlMode.Auto;

            ConnectFeedback       = new BoolFeedback(() => Connect);
            OnlineFeedback        = new BoolFeedback(() => _commsMonitor.IsOnline);
            StatusFeedback        = new IntFeedback(() => (int)_commsMonitor.Status);
            PowerIsOnFeedback     = new BoolFeedback(() => _camera.Power);
            CameraIsOffFeedback   = new BoolFeedback(() => !_camera.Power);
            CameraIsMutedFeedback = new BoolFeedback(() => _camera.Mute);

            _camera.PowerChanged += (o, e) => { PowerIsOnFeedback.FireUpdate(); CameraIsOffFeedback.FireUpdate(); };
            _camera.MuteChanged  += (o, e) => { CameraIsMutedFeedback.FireUpdate(); };

            _cameraPollCommands = new Dictionary <string, Action>()
            {
                { "AE", _camera.AEPoll },
                { "Aperture", _camera.AperturePoll },
                { "BackLight", _camera.BackLightPoll },
                { "BGain", _camera.BGainPoll },
                { "ExpComp", _camera.ExpCompPoll },
                { "FocusAuto", _camera.FocusAutoPoll },
                { "FocusPosition", _camera.FocusPositionPoll },
                { "Gain", _camera.GainPoll },
                { "Iris", _camera.IrisPoll },
                { "Mute", _camera.MutePoll },
                { "PTZPosition", _camera.PanTiltPositionPoll },
                { "Power", _camera.PowerPoll },
                { "RGain", _camera.RGainPoll },
                { "Shutter", _camera.ShutterPoll },
                { "Title", _camera.TitlePoll },
                { "WB", _camera.WBModePoll },
                { "WD", _camera.WideDynamicModePoll },
                { "ZoomPosition", _camera.ZoomPositionPoll },
            };

            _comms = comm;

            // TODO: For VISCA camera current library implementation only
            // serial is supported, so socket code is not needed
            var socket = _comms as ISocketStatus;

            if (socket != null)
            {
                socket.ConnectionChange += socket_ConnectionChange;
                if (Enabled)
                {
                    Connect = true;
                }
            }

            if (_config.CommunicationMonitorProperties != null)
            {
                if (!String.IsNullOrEmpty(_config.CommunicationMonitorProperties.PollString))
                {
                    foreach (var poll in _config.CommunicationMonitorProperties.PollString.Split(','))
                    {
                        if (_cameraPollCommands.ContainsKey(poll.Trim()))
                        {
                            _poll.Add(_cameraPollCommands[poll.Trim()]);
                        }
                    }
                }

                _commsMonitor = new GenericCommunicationMonitor(this, _comms,
                                                                _config.CommunicationMonitorProperties.PollInterval,
                                                                _config.CommunicationMonitorProperties.TimeToWarning,
                                                                _config.CommunicationMonitorProperties.TimeToError,
                                                                () => _poll.ForEach((pollAction) => pollAction())
                                                                );
            }
            else
            {
                // We do not have CommunicationMonitorProperties and therefore
                // no Poll string defined, using ALL poll functions
                _poll.AddRange(_cameraPollCommands.Values);
                _commsMonitor = new GenericCommunicationMonitor(this, _comms, 10000, 20000, 30000, () => _poll.ForEach((pollAction) => pollAction()));
            }

            _commsMonitor.Client.BytesReceived += (s, e) => _visca.ProcessIncomingData(e.Bytes);
            DeviceManager.AddDevice(CommunicationMonitor);

            // Handle Increase PTZ move speed
            #region PTZ Speed Increase

            // if FastSpeedHoldTimeMs defined in config, enable SpeedIncrease behaivor
            if (_config.FastSpeedHoldTimeMs > 0)
            {
                _ptzSpeedIncreaseBehaivor = true;

                if (_config.PanSpeedSlow > 0)
                {
                    _camera.PanSpeed = _config.PanSpeedSlow;
                }

                if (_config.TiltSpeedSlow > 0)
                {
                    _camera.TiltSpeed = _config.TiltSpeedSlow;
                }

                _ptzPanNormalSpeed  = _camera.PanSpeed;
                _ptzTiltNormalSpeed = _camera.TiltSpeed;

                _ptzSpeedIncreaseAction = ptzCommand =>
                {
                    // Kill Speed Increase Timer as we already in fast pace
                    ptzSpeedChangeTimerDispose();
                    // if Fast speeds not defined, use Max values
                    _camera.PanSpeed  = (_config.PanSpeedFast > 0) ? _config.PanSpeedFast : Visca.ViscaDefaults.PanSpeedLimits.High;
                    _camera.TiltSpeed = (_config.TiltSpeedFast > 0) ? _config.PanSpeedFast : Visca.ViscaDefaults.TiltSpeedLimits.High;
                    // we passed current ptz command to action, so we repeat it with increased speed
                    (ptzCommand as Action).Invoke();
                };
            }

            #endregion PTZ Speed Increase
        }
Example #21
0
    public void Handle(HttpListenerContext context)
    {
        HttpListenerResponse response = context.Response;

        // Check if we need to ask the user for registration
        Result result;

        if (context.Request.QueryString["ask"] != null && context.Request.QueryString["ask"].ToLower() == "true")
        {
            result = Result.AskUser;
        }
        else
        {
            result = Result.DoNothing;
        }

        // Create device object
        string name = context.Request.QueryString["name"];
        string id   = context.Request.QueryString["id"];
        string gcm  = context.Request.QueryString["gcm"];

        // Create response
        string message = "{\"Version\":\"2.0.1\",";

        // Register device if it's not ready
        Device possibleDevice = _deviceManager.FindDeviceByID(id);

        if (_deviceManager.AuthenticationEnabled)
        {
            if (possibleDevice == null)
            {
                message += "\"Status\":\"WAITING\"}";
            }
            else
            {
                result = Result.DoNothing;
                if (possibleDevice.Allowed == true)
                {
                    message += "\"Status\":\"ALLOWED\"}";
                }
                else
                {
                    message += "\"Status\":\"DENIED\"}";
                }
            }
        }
        else
        {
            message += "\"Status\":\"ALLOWED\"}";
            if (possibleDevice == null)
            {
                result = Result.SaveDevice;
            }
            else
            {
                result = Result.DoNothing;
            }
        }

        // Fill in response body
        byte[] messageBytes = Encoding.Default.GetBytes(message);
        response.OutputStream.Write(messageBytes, 0, messageBytes.Length);
        response.ContentType = "application/json";
        response.StatusCode  = (int)HttpStatusCode.OK;

        // Send the HTTP response to the client
        response.Close();

        // Decide what to do with this device
        switch (result)
        {
        case Result.AskUser: AskForRegistration(name, id, gcm); break;

        case Result.SaveDevice: _deviceManager.AddDevice(new Device(name, id, gcm, true)); _deviceManager.SaveData(); break;
        }
    }
Example #22
0
        /// <summary>
        /// Initialises a particular drive on the ATA bus.
        /// </summary>
        /// <param name="ctrlId">The controller ID of the device.</param>
        /// <param name="busPos">The bus position of the device.</param>
        public static void InitDrive(ATA.ControllerID ctrlId, ATA.BusPosition busPos)
        {
            //Get the IO ports for the correct bus
            ATAIOPorts theIO = ctrlId == ATA.ControllerID.Primary ? ATAIO1 : ATAIO2;

            //Create / init the device on the bus
            try
            {
                PATABase ThePATABase = new PATABase(theIO, ctrlId, busPos);
                //If the device was detected as present:
                if (ThePATABase.DriveType != PATABase.SpecLevel.Null)
                {
                    //If the device was actually a PATA device:
                    if (ThePATABase.DriveType == PATABase.SpecLevel.PATA)
                    {
                        //Add it to the list of devices.
                        try
                        {
                            DeviceManager.AddDevice(new PATA(ThePATABase));
                        }
                        catch
                        {
                            ExceptionMethods.Throw(new FOS_System.Exception("Error initialising PATA device."));
                        }
                    }
                    else if (ThePATABase.DriveType == PATABase.SpecLevel.PATAPI)
                    {
                        // Add a PATAPI device
                        try
                        {
                            DeviceManager.AddDevice(new PATAPI(ThePATABase));
                        }
                        catch
                        {
                            ExceptionMethods.Throw(new FOS_System.Exception("Error initialising PATAPI device."));
                        }
                    }
                    //TODO: Remove the SATA/SATAPI initialisation from here. It should be done
                    //  in the ATAManager.Init method.
                    else if (ThePATABase.DriveType == PATABase.SpecLevel.SATA)
                    {
                        // Add a SATA device
                        try
                        {
                            DeviceManager.AddDevice(new SATA());
                        }
                        catch
                        {
                            ExceptionMethods.Throw(new FOS_System.Exception("Error initialising SATA device."));
                        }
                    }
                    else if (ThePATABase.DriveType == PATABase.SpecLevel.SATAPI)
                    {
                        // Add a SATAPI device
                        try
                        {
                            DeviceManager.AddDevice(new SATAPI());
                        }
                        catch
                        {
                            ExceptionMethods.Throw(new FOS_System.Exception("Error initialising SATAPI device."));
                        }
                    }
                }
            }
            catch
            {
                ExceptionMethods.Throw(new FOS_System.Exception((FOS_System.String) "Error initialising PATA Base device. Controller ID: " +
                                                                (ctrlId == ATA.ControllerID.Primary ? "Primary" : "Secondary") + " , Position: " +
                                                                (busPos == ATA.BusPosition.Master ? "Master" : "Slave")));
            }
        }
Example #23
0
        /// <summary>
        /// Reads all devices from config and adds them to DeviceManager
        /// </summary>
        public void LoadDevices()
        {
            // Build the processor wrapper class

            DeviceManager.AddDevice(new PepperDash.Essentials.Core.Devices.CrestronProcessor("processor"));



            // Add global System Monitor device
            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")
                    {
                        if (devConf.Type.ToLower() != Global.ControlSystem.ControllerPrompt.ToLower())
                        {
                            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 <DM.Config.DmpsRoutingPropertiesConfig>(devConf.Properties.ToString());

                            if (propertiesConfig == null)
                            {
                                propertiesConfig = new DM.Config.DmpsRoutingPropertiesConfig();
                            }

                            var dmpsRoutingController = DmpsRoutingController.GetDmpsRoutingController("processor-avRouting", this.ControllerPrompt, propertiesConfig);

                            DeviceManager.AddDevice(dmpsRoutingController);
                        }
                        else
                        {
                            Debug.Console(2, "************Processor is not DMPS type***************");
                        }

                        continue;
                    }

                    // Try local factories first
                    var newDev = DeviceFactory.GetDevice(devConf);

                    if (newDev == null)
                    {
                        newDev = BridgeFactory.GetDevice(devConf);
                    }

                    // Then associated library factories
                    if (newDev == null)
                    {
                        newDev = PepperDash.Essentials.Core.DeviceFactory.GetDevice(devConf);
                    }
                    if (newDev == null)
                    {
                        newDev = PepperDash.Essentials.Devices.Common.DeviceFactory.GetDevice(devConf);
                    }
                    if (newDev == null)
                    {
                        newDev = PepperDash.Essentials.DM.DeviceFactory.GetDevice(devConf);
                    }
                    if (newDev == null)
                    {
                        newDev = PepperDash.Essentials.Devices.Displays.DisplayDeviceFactory.GetDevice(devConf);
                    }

                    //if (newDev == null) // might want to consider the ability to override an essentials "type"
                    //{
                    //    // iterate plugin factories
                    //    foreach (var f in FactoryObjects)
                    //    {
                    //        var cresFactory = f as IGetCrestronDevice;
                    //        if (cresFactory != null)
                    //        {
                    //            newDev = cresFactory.GetDevice(devConf, this);
                    //        }
                    //    }
                    //}

                    if (newDev != null)
                    {
                        DeviceManager.AddDevice(newDev);
                    }
                    else
                    {
                        Debug.Console(0, Debug.ErrorLogLevel.Notice, "ERROR: Cannot load unknown device type '{0}', key '{1}'.", devConf.Type, devConf.Key);
                    }
                }
                catch (Exception e)
                {
                    Debug.Console(0, Debug.ErrorLogLevel.Notice, "ERROR: Creating device {0}. Skipping device. \r{1}", devConf.Key, e);
                }
            }
            Debug.Console(0, Debug.ErrorLogLevel.Notice, "All Devices Loaded.");
        }
Example #24
0
        private void btnRead_Click(object sender, EventArgs e)
        {
            try
            {
                string json = null;
                if (OFFLINE)
                {
                    json = rx;
                }
                else
                {
                    if (link.Connect())
                    {
                        Console.WriteLine("Read config");
                        link.Send("TER_READ");
                        json = link.Receive();
                        link.Close();
                    }
                }
                Console.WriteLine("offline read");
                var data = JObject.Parse(json);
                Console.WriteLine(data);
                var devices = data["Devices"].ToObject <Dictionary <string, JObject> >();
                var config  = data["Config"];
                DeviceManager.Clear();
                TimelineClear();

                List <Event> temp = new List <Event>();
                foreach (var entry in devices)
                {
                    string         devName = entry.Key;
                    DeviceType     devType = (DeviceType)Enum.Parse(typeof(DeviceType), (string)entry.Value["Type"]);
                    RGB            rgb     = entry.Value["Color"].ToObject <RGB>();
                    eCalendarColor color   = CalendarUtils.ConvertColor(rgb);
                    int            slot    = (int)entry.Value["Slot"];
                    List <Event>   events  = new List <Event>();
                    foreach (var evData in entry.Value["Events"])
                    {
                        Event ev = evData.ToObject <Event>();
                        events.Add(ev);
                    }

                    DeviceManager.AddDevice(devName, devType, slot, color);
                    devName += getSlotFormat(slot);
                    TimelineAddNewRow(devName, color);
                    FillTimeline(events, devName);
                }

                ///////////////////////////////////////////////////////
                minTempLimit = (int)config["Limits"]["Min"];
                maxTempLimit = (int)config["Limits"]["Max"];

                List <LimitTempView> _views = new List <LimitTempView>();
                foreach (var limit in config["Limits"]["Events"])
                {
                    LimitTempModel model = limit.ToObject <LimitTempModel>();
                    _views.Add(new LimitTempView(model));
                }

                // Create views for Limit Temp window
                List <string>         names  = DeviceManager.GetNames();
                List <LimitTempModel> models = (views == null) ?
                                               LimitTempModel.Create(names) :
                                               LimitTempModel.Create(names, views.ConvertAll(view => view.Model));
                views = LimitTempView.Create(models);

                // Update those views with received data
                foreach (var _view in _views)
                {
                    foreach (var view in views)
                    {
                        if (view.Model.Name == _view.Model.Name)
                        {
                            view.Model = _view.Model;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Example #25
0
        public static IKeyed GetUiDevice(DeviceConfig config)
        {
            var comm = CommFactory.GetControlPropertiesConfig(config);

            var typeName = config.Type.ToLower();

            EssentialsTouchpanelController panelController = null;

            var props = JsonConvert.DeserializeObject <CrestronTouchpanelPropertiesConfig>(config.Properties.ToString());

            if (typeName.Contains("dge"))
            {
                Dge100 dgeDevice = null;
                if (typeName == "dge100")
                {
                    dgeDevice = new Dge100(comm.IpIdInt, Global.ControlSystem);
                }
                else 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 DgeController(config.Key + "-comPorts", config.Name, dgeDevice, config, props);

                DeviceManager.AddDevice(dgeController);

                panelController = new EssentialsTouchpanelController(config.Key, config.Name, dgeController.DigitalGraphicsEngine,
                                                                     props.ProjectName, props.SgdFile);
            }
            else
            {
                panelController = new EssentialsTouchpanelController(config.Key, config.Name, config.Type, props, comm.IpIdInt);
            }

            panelController.AddPostActivationAction(() =>
            {
                var mainDriver = new EssentialsPanelMainInterfaceDriver(panelController.Panel, props);
                // Then the sub drivers

                // spin up different room drivers depending on room type
                var room = DeviceManager.GetDeviceForKey(props.DefaultRoomKey);
                if (room is EssentialsHuddleSpaceRoom)
                {
                    // Header Driver
                    Debug.Console(0, panelController, "Adding header driver");
                    mainDriver.HeaderDriver = new EssentialsHeaderDriver(mainDriver, props);

                    // AV Driver
                    Debug.Console(0, panelController, "Adding huddle space AV driver");
                    var avDriver            = new EssentialsHuddlePanelAvFunctionsDriver(mainDriver, props);
                    avDriver.DefaultRoomKey = props.DefaultRoomKey;
                    mainDriver.AvDriver     = avDriver;
                    avDriver.CurrentRoom    = room as EssentialsHuddleSpaceRoom;

                    // Environment Driver
                    if (avDriver.CurrentRoom.PropertiesConfig.Environment != null && avDriver.CurrentRoom.PropertiesConfig.Environment.DeviceKeys.Count > 0)
                    {
                        Debug.Console(0, panelController, "Adding environment driver");
                        mainDriver.EnvironmentDriver = new EssentialsEnvironmentDriver(mainDriver, props);

                        mainDriver.EnvironmentDriver.GetDevicesFromConfig(avDriver.CurrentRoom.PropertiesConfig.Environment);
                    }

                    mainDriver.HeaderDriver.SetupHeaderButtons(avDriver, avDriver.CurrentRoom);

                    panelController.LoadAndShowDriver(mainDriver);      // This is a little convoluted.

                    if (panelController.Panel is TswFt5ButtonSystem)
                    {
                        var tsw = panelController.Panel as TswFt5ButtonSystem;
                        // Wire up hard keys
                        tsw.Power.UserObject = new Action <bool>(b => { if (!b)
                                                                        {
                                                                            avDriver.PowerButtonPressed();
                                                                        }
                                                                 });
                        //tsw.Home.UserObject = new Action<bool>(b => { if (!b) HomePressed(); });
                        if (mainDriver.EnvironmentDriver != null)
                        {
                            tsw.Lights.UserObject = new Action <bool>(b =>
                            {
                                if (!b)
                                {
                                    //mainDriver.AvDriver.PopupInterlock.ShowInterlockedWithToggle(mainDriver.EnvironmentDriver.BackgroundSubpageJoin);
                                    mainDriver.EnvironmentDriver.Toggle();
                                }
                            });
                        }
                        tsw.Up.UserObject   = new Action <bool>(avDriver.VolumeUpPress);
                        tsw.Down.UserObject = new Action <bool>(avDriver.VolumeDownPress);
                    }
                }
                //else if (room is EssentialsPresentationRoom)
                //{
                //    Debug.Console(0, panelController, "Adding presentation room driver");
                //    var avDriver = new EssentialsPresentationPanelAvFunctionsDriver(mainDriver, props);
                //    avDriver.CurrentRoom = room as EssentialsPresentationRoom;
                //    avDriver.DefaultRoomKey = props.DefaultRoomKey;
                //    mainDriver.AvDriver = avDriver ;
                //    mainDriver.HeaderDriver = new EssentialsHeaderDriver(mainDriver, props);
                //    panelController.LoadAndShowDriver(mainDriver);

                //    if (panelController.Panel is TswFt5ButtonSystem)
                //    {
                //        var tsw = panelController.Panel as TswFt5ButtonSystem;
                //        // Wire up hard keys
                //        tsw.Power.UserObject = new Action<bool>(b => { if (!b) avDriver.PowerButtonPressed(); });
                //        //tsw.Home.UserObject = new Action<bool>(b => { if (!b) HomePressed(); });
                //        tsw.Up.UserObject = new Action<bool>(avDriver.VolumeUpPress);
                //        tsw.Down.UserObject = new Action<bool>(avDriver.VolumeDownPress);
                //    }
                //}
                else if (room is EssentialsHuddleVtc1Room)
                {
                    Debug.Console(0, panelController, "Adding huddle space VTC AV driver");

                    // Header Driver
                    mainDriver.HeaderDriver = new EssentialsHeaderDriver(mainDriver, props);

                    // AV Driver
                    var avDriver = new EssentialsHuddleVtc1PanelAvFunctionsDriver(mainDriver, props);

                    var codecDriver = new PepperDash.Essentials.UIDrivers.VC.EssentialsVideoCodecUiDriver(panelController.Panel, avDriver,
                                                                                                          (room as EssentialsHuddleVtc1Room).VideoCodec, mainDriver.HeaderDriver);
                    avDriver.SetVideoCodecDriver(codecDriver);
                    avDriver.DefaultRoomKey = props.DefaultRoomKey;
                    mainDriver.AvDriver     = avDriver;
                    avDriver.CurrentRoom    = room as EssentialsHuddleVtc1Room;

                    // Environment Driver
                    if (avDriver.CurrentRoom.PropertiesConfig.Environment != null && avDriver.CurrentRoom.PropertiesConfig.Environment.DeviceKeys.Count > 0)
                    {
                        Debug.Console(0, panelController, "Adding environment driver");
                        mainDriver.EnvironmentDriver = new EssentialsEnvironmentDriver(mainDriver, props);

                        mainDriver.EnvironmentDriver.GetDevicesFromConfig(avDriver.CurrentRoom.PropertiesConfig.Environment);
                    }

                    mainDriver.HeaderDriver.SetupHeaderButtons(avDriver, avDriver.CurrentRoom);

                    panelController.LoadAndShowDriver(mainDriver);      // This is a little convoluted.

                    if (panelController.Panel is TswFt5ButtonSystem)
                    {
                        var tsw = panelController.Panel as TswFt5ButtonSystem;
                        // Wire up hard keys
                        tsw.Power.UserObject = new Action <bool>(b => { if (!b)
                                                                        {
                                                                            avDriver.EndMeetingPress();
                                                                        }
                                                                 });
                        //tsw.Home.UserObject = new Action<bool>(b => { if (!b) HomePressed(); });
                        if (mainDriver.EnvironmentDriver != null)
                        {
                            tsw.Lights.UserObject = new Action <bool>(b =>
                            {
                                if (!b)
                                {
                                    //mainDriver.AvDriver.PopupInterlock.ShowInterlockedWithToggle(mainDriver.EnvironmentDriver.BackgroundSubpageJoin);
                                    mainDriver.EnvironmentDriver.Toggle();
                                }
                            });
                        }
                        tsw.Up.UserObject   = new Action <bool>(avDriver.VolumeUpPress);
                        tsw.Down.UserObject = new Action <bool>(avDriver.VolumeDownPress);
                    }
                }
                else
                {
                    Debug.Console(0, panelController, "ERROR: Cannot load AvFunctionsDriver for room '{0}'", props.DefaultRoomKey);
                }
            });

            return(panelController);
        }
Example #26
0
        /// <summary>
        /// Reads all devices from config and adds them to DeviceManager
        /// </summary>
        public void LoadDevices()
        {
            // Build the processor wrapper class
            DeviceManager.AddDevice(new PepperDash.Essentials.Core.Devices.CrestronProcessor("processor"));

            // Add global System Monitor device
            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")
                    {
                        if (devConf.Type.ToLower() != Global.ControlSystem.ControllerPrompt.ToLower())
                        {
                            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 <DM.Config.DmpsRoutingPropertiesConfig>(devConf.Properties.ToString());

                            if (propertiesConfig == null)
                            {
                                propertiesConfig = new DM.Config.DmpsRoutingPropertiesConfig();
                            }

                            var dmpsRoutingController = DmpsRoutingController.GetDmpsRoutingController("processor-avRouting", this.ControllerPrompt, propertiesConfig);

                            DeviceManager.AddDevice(dmpsRoutingController);
                        }
                        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)
                            {
                                var buttons      = butToken.ToObject <Dictionary <string, Essentials.Core.Touchpanels.KeypadButton> >();
                                var tpController = new Essentials.Core.Touchpanels.Mpc3TouchpanelController(devConf.Key, devConf.Name, Global.ControlSystem, buttons);
                                DeviceManager.AddDevice(tpController);
                            }
                            else
                            {
                                Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: Unable to deserialize buttons collection for device: {0}", devConf.Key);
                            }
                        }
                        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)
                    //    newDev = PepperDash.Essentials.Devices.Displays.DisplayDeviceFactory.GetDevice(devConf);
                    //

                    if (newDev != null)
                    {
                        DeviceManager.AddDevice(newDev);
                    }
                    else
                    {
                        Debug.Console(0, Debug.ErrorLogLevel.Notice, "ERROR: Cannot load unknown device type '{0}', key '{1}'.", devConf.Type, devConf.Key);
                    }
                }
                catch (Exception e)
                {
                    Debug.Console(0, Debug.ErrorLogLevel.Notice, "ERROR: Creating device {0}. Skipping device. \r{1}", devConf.Key, e);
                }
            }
            Debug.Console(0, Debug.ErrorLogLevel.Notice, "All Devices Loaded.");
        }
Example #27
0
        /// <summary>
        /// Builds the appropriate ports and calls the appropriate add port method
        /// </summary>
        /// <param name="number"></param>
        /// <param name="outputCard"></param>
        public void AddOutputCard(uint number, DMOutput outputCard)
        {
            if (outputCard is Card.Dmps3HdmiOutput)
            {
                var hdmiOutputCard = outputCard as Card.Dmps3HdmiOutput;

                var cecPort = hdmiOutputCard.HdmiOutputPort;

                AddHdmiOutputPort(number, cecPort);

                return;
            }
            else if (outputCard is Card.Dmps3DmOutput)
            {
                var dmOutputCard = outputCard as Card.Dmps3DmOutput;

                var cecPort = dmOutputCard.DmOutputPort;

                AddDmOutputPort(number);
                return;
            }
            else if (outputCard is Card.Dmps3ProgramOutput)
            {
                AddAudioOnlyOutputPort(number, "Program");

                var programOutput = new DmpsAudioOutputController(string.Format("processor-programAudioOutput"), "Program Audio Output", outputCard as Card.Dmps3OutputBase);

                DeviceManager.AddDevice(programOutput);

                return;
            }
            else if (outputCard is Card.Dmps3AuxOutput)
            {
                if (outputCard.CardInputOutputType == eCardInputOutputType.Dmps3Aux1Output)
                {
                    AddAudioOnlyOutputPort(number, "Aux1");

                    var aux1Output = new DmpsAudioOutputController(string.Format("processor-aux1AudioOutput"), "Program Audio Output", outputCard as Card.Dmps3OutputBase);

                    DeviceManager.AddDevice(aux1Output);
                }
                else if (outputCard.CardInputOutputType == eCardInputOutputType.Dmps3Aux2Output)
                {
                    AddAudioOnlyOutputPort(number, "Aux2");

                    var aux2Output = new DmpsAudioOutputController(string.Format("processor-aux2AudioOutput"), "Program Audio Output", outputCard as Card.Dmps3OutputBase);

                    DeviceManager.AddDevice(aux2Output);
                }
                return;
            }
            else if (outputCard is Card.Dmps3CodecOutput)
            {
                if (number == (uint)CrestronControlSystem.eDmps300cOutputs.Codec1 ||
                    number == (uint)CrestronControlSystem.eDmps3200cOutputs.Codec1 ||
                    number == (uint)CrestronControlSystem.eDmps3300cAecOutputs.Codec1 ||
                    number == (uint)CrestronControlSystem.eDmps34K250COutputs.Codec1 ||
                    number == (uint)CrestronControlSystem.eDmps34K350COutputs.Codec1)
                {
                    AddAudioOnlyOutputPort(number, CrestronControlSystem.eDmps300cOutputs.Codec1.ToString());
                }
                else if (number == (uint)CrestronControlSystem.eDmps300cOutputs.Codec2 ||
                         number == (uint)CrestronControlSystem.eDmps3200cOutputs.Codec2 ||
                         number == (uint)CrestronControlSystem.eDmps3300cAecOutputs.Codec2 ||
                         number == (uint)CrestronControlSystem.eDmps34K250COutputs.Codec2 ||
                         number == (uint)CrestronControlSystem.eDmps34K350COutputs.Codec2)
                {
                    AddAudioOnlyOutputPort(number, CrestronControlSystem.eDmps300cOutputs.Codec2.ToString());
                }
                return;
            }
            else if (outputCard is Card.Dmps3DialerOutput)
            {
                AddAudioOnlyOutputPort(number, "Dialer");
                return;
            }
            else if (outputCard is Card.Dmps3DigitalMixOutput)
            {
                if (number == (uint)CrestronControlSystem.eDmps34K250COutputs.Mix1 ||
                    number == (uint)CrestronControlSystem.eDmps34K300COutputs.Mix1 ||
                    number == (uint)CrestronControlSystem.eDmps34K350COutputs.Mix1)
                {
                    AddAudioOnlyOutputPort(number, CrestronControlSystem.eDmps34K250COutputs.Mix1.ToString());
                }
                if (number == (uint)CrestronControlSystem.eDmps34K250COutputs.Mix2 ||
                    number == (uint)CrestronControlSystem.eDmps34K300COutputs.Mix2 ||
                    number == (uint)CrestronControlSystem.eDmps34K350COutputs.Mix2)
                {
                    AddAudioOnlyOutputPort(number, CrestronControlSystem.eDmps34K250COutputs.Mix2.ToString());
                }
                return;
            }
            else if (outputCard is Card.Dmps3AecOutput)
            {
                AddAudioOnlyOutputPort(number, "Aec");
                return;
            }
            else
            {
                Debug.Console(1, this, "Output Card is of a type not currently handled:", outputCard.CardInputOutputType.ToString());
            }
        }
Example #28
0
 public void LoadPresets(string filePath)
 {
     PresetsModel = new DevicePresetsModel(Key + "-presets", this, filePath);
     DeviceManager.AddDevice(PresetsModel);
 }