refactor: rearrange and add solution for 4-series

This commit is contained in:
Andrew Welker 2023-02-07 15:45:01 -07:00
parent 7a9f76ee12
commit 0d515e5f0a
649 changed files with 45907 additions and 105752 deletions

View file

@ -0,0 +1,119 @@
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.Routing;
namespace PepperDash.Essentials.Devices.Common
{
/// <summary>
/// Represents and audio endpoint
/// </summary>
public class GenericAudioOut : EssentialsDevice, IRoutingSinkNoSwitching
{
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 RoutingInputPort AnyAudioIn { get; private set; }
public GenericAudioOut(string key, string name)
: base(key, name)
{
AnyAudioIn = new RoutingInputPort(RoutingPortNames.AnyAudioIn, eRoutingSignalType.Audio,
eRoutingPortConnectionType.LineAudio, null, this);
}
#region IRoutingInputs Members
public RoutingPortCollection<RoutingInputPort> InputPorts
{
get { return new RoutingPortCollection<RoutingInputPort> { AnyAudioIn }; }
}
#endregion
}
/// <summary>
/// Allows a zone-device's audio control to be attached to the endpoint, for easy routing and
/// control switching. Will also set the zone name on attached devices, like SWAMP or other
/// hardware with names built in.
/// </summary>
public class GenericAudioOutWithVolume : GenericAudioOut, IHasVolumeDevice
{
public string VolumeDeviceKey { get; private set; }
public uint VolumeZone { get; private set; }
public IBasicVolumeControls VolumeDevice
{
get
{
var dev = DeviceManager.GetDeviceForKey(VolumeDeviceKey);
if (dev is IAudioZones)
return (dev as IAudioZones).Zone[VolumeZone];
else return dev as IBasicVolumeControls;
}
}
/// <summary>
/// Constructor - adds the name to the attached audio device, if appropriate.
/// </summary>
/// <param name="key"></param>
/// <param name="name"></param>
/// <param name="audioDevice"></param>
/// <param name="zone"></param>
public GenericAudioOutWithVolume(string key, string name, string audioDevice, uint zone)
: base(key, name)
{
VolumeDeviceKey = audioDevice;
VolumeZone = zone;
}
}
public class GenericAudioOutWithVolumeFactory : EssentialsDeviceFactory<GenericAudioOutWithVolume>
{
public GenericAudioOutWithVolumeFactory()
{
TypeNames = new List<string>() { "genericaudiooutwithvolume" };
}
public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
Debug.Console(1, "Factory Attempting to create new GenericAudioOutWithVolumeFactory Device");
var zone = dc.Properties.Value<uint>("zone");
return new GenericAudioOutWithVolume(dc.Key, dc.Name,
dc.Properties.Value<string>("volumeDeviceKey"), zone);
}
}
}

View file

@ -0,0 +1,104 @@
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.Devices.Common.Codec;
namespace PepperDash.Essentials.Devices.Common.AudioCodec
{
public abstract class AudioCodecBase : EssentialsDevice, IHasDialer, IUsageTracking, IAudioCodecInfo
{
public event EventHandler<CodecCallStatusItemChangeEventArgs> CallStatusChange;
public AudioCodecInfo CodecInfo { get; protected set; }
#region IUsageTracking Members
/// <summary>
/// This object can be added by outside users of this class to provide usage tracking
/// for various services
/// </summary>
public UsageTracking UsageTracker { get; set; }
#endregion
/// <summary>
/// Returns true when any call is not in state Unknown, Disconnecting, Disconnected
/// </summary>
public bool IsInCall
{
get
{
bool value;
if (ActiveCalls != null)
value = ActiveCalls.Any(c => c.IsActiveCall);
else
value = false;
return value;
}
}
// In most cases only a single call can be active
public List<CodecActiveCallItem> ActiveCalls { get; set; }
public AudioCodecBase(string key, string name)
: base(key, name)
{
ActiveCalls = new List<CodecActiveCallItem>();
}
/// <summary>
/// Helper method to fire CallStatusChange event with old and new status
/// </summary>
protected void SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus newStatus, CodecActiveCallItem call)
{
call.Status = newStatus;
OnCallStatusChange(call);
}
/// <summary>
///
/// </summary>
/// <param name="previousStatus"></param>
/// <param name="newStatus"></param>
/// <param name="item"></param>
protected void OnCallStatusChange(CodecActiveCallItem item)
{
var handler = CallStatusChange;
if (handler != null)
handler(this, new CodecCallStatusItemChangeEventArgs(item));
if (UsageTracker != null)
{
if (IsInCall && !UsageTracker.UsageTrackingStarted)
UsageTracker.StartDeviceUsage();
else if (UsageTracker.UsageTrackingStarted && !IsInCall)
UsageTracker.EndDeviceUsage();
}
}
#region IHasDialer Members
public abstract void Dial(string number);
public abstract void EndCall(CodecActiveCallItem activeCall);
public abstract void EndAllCalls();
public abstract void AcceptCall(CodecActiveCallItem item);
public abstract void RejectCall(CodecActiveCallItem item);
public abstract void SendDtmf(string digit);
#endregion
}
}

View file

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Devices.Common.AudioCodec
{
/// <summary>
/// Implements a common set of data about a codec
/// </summary>
public interface IAudioCodecInfo
{
AudioCodecInfo CodecInfo { get; }
}
/// <summary>
/// Stores general information about a codec
/// </summary>
public abstract class AudioCodecInfo
{
public abstract string PhoneNumber { get; set; }
}
}

View file

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Devices.Common.AudioCodec
{
/// <summary>
/// For rooms that have audio codec
/// </summary>
public interface IHasAudioCodec:IHasInCallFeedback
{
AudioCodecBase AudioCodec { get; }
///// <summary>
///// Make this more specific
///// </summary>
//List<PepperDash.Essentials.Devices.Common.Codec.CodecActiveCallItem> ActiveCalls { get; }
}
}

View file

@ -0,0 +1,131 @@
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.Devices.Common.Codec;
namespace PepperDash.Essentials.Devices.Common.AudioCodec
{
public class MockAC : AudioCodecBase
{
public MockAC(string key, string name, MockAcPropertiesConfig props)
: base(key, name)
{
CodecInfo = new MockAudioCodecInfo();
CodecInfo.PhoneNumber = props.PhoneNumber;
}
public override void Dial(string number)
{
if (!IsInCall)
{
Debug.Console(1, this, "Dial: {0}", number);
var call = new CodecActiveCallItem()
{
Name = "Mock Outgoing Call",
Number = number,
Type = eCodecCallType.Audio,
Status = eCodecCallStatus.Connected,
Direction = eCodecCallDirection.Outgoing,
Id = "mockAudioCall-1"
};
ActiveCalls.Add(call);
OnCallStatusChange(call);
}
else
{
Debug.Console(1, this, "Already in call. Cannot dial new call.");
}
}
public override void EndCall(CodecActiveCallItem call)
{
Debug.Console(1, this, "EndCall");
ActiveCalls.Remove(call);
SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Disconnected, call);
}
public override void EndAllCalls()
{
Debug.Console(1, this, "EndAllCalls");
for (int i = ActiveCalls.Count - 1; i >= 0; i--)
{
var call = ActiveCalls[i];
ActiveCalls.Remove(call);
SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Disconnected, call);
}
}
public override void AcceptCall(CodecActiveCallItem call)
{
Debug.Console(1, this, "AcceptCall");
SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Connecting, call);
}
public override void RejectCall(CodecActiveCallItem call)
{
Debug.Console(1, this, "RejectCall");
ActiveCalls.Remove(call);
SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Disconnected, call);
}
public override void SendDtmf(string s)
{
Debug.Console(1, this, "BEEP BOOP SendDTMF: {0}", s);
}
/// <summary>
///
/// </summary>
/// <param name="url"></param>
public void TestIncomingAudioCall(string number)
{
Debug.Console(1, this, "TestIncomingAudioCall from {0}", number);
var call = new CodecActiveCallItem() { Name = number, Id = number, Number = number, Type = eCodecCallType.Audio, Direction = eCodecCallDirection.Incoming };
ActiveCalls.Add(call);
SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Ringing, call);
}
}
public class MockAudioCodecInfo : AudioCodecInfo
{
string _phoneNumber;
public override string PhoneNumber
{
get
{
return _phoneNumber;
}
set
{
_phoneNumber = value;
}
}
}
public class MockACFactory : EssentialsDeviceFactory<MockAC>
{
public MockACFactory()
{
TypeNames = new List<string>() { "mockac" };
}
public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
Debug.Console(1, "Factory Attempting to create new MockAc Device");
var props = Newtonsoft.Json.JsonConvert.DeserializeObject<AudioCodec.MockAcPropertiesConfig>(dc.Properties.ToString());
return new AudioCodec.MockAC(dc.Key, dc.Name, props);
}
}
}

View file

@ -0,0 +1,18 @@
extern alias Full;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Full.Newtonsoft.Json;
namespace PepperDash.Essentials.Devices.Common.AudioCodec
{
public class MockAcPropertiesConfig
{
[JsonProperty("phoneNumber")]
public string PhoneNumber { get; set; }
}
}

View file

@ -0,0 +1,297 @@
extern alias Full;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Crestron.SimplSharp;
using Crestron.SimplSharp.Reflection;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Devices;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.Bridges;
using PepperDash.Essentials.Core.Presets;
using PepperDash.Essentials.Devices.Common.Codec;
using Full.Newtonsoft.Json;
namespace PepperDash.Essentials.Devices.Common.Cameras
{
public enum eCameraCapabilities
{
None = 0,
Pan = 1,
Tilt = 2,
Zoom = 4,
Focus = 8
}
public abstract class CameraBase : ReconfigurableDevice, IRoutingOutputs
{
[JsonProperty("controlMode", NullValueHandling = NullValueHandling.Ignore)]
public eCameraControlMode ControlMode { get; protected set; }
#region IRoutingOutputs Members
public RoutingPortCollection<RoutingOutputPort> OutputPorts { get; protected set; }
#endregion
[JsonProperty("canPan", NullValueHandling = NullValueHandling.Ignore)]
public bool CanPan
{
get
{
return (Capabilities & eCameraCapabilities.Pan) == eCameraCapabilities.Pan;
}
}
[JsonProperty("canTilt", NullValueHandling = NullValueHandling.Ignore)]
public bool CanTilt
{
get
{
return (Capabilities & eCameraCapabilities.Tilt) == eCameraCapabilities.Tilt;
}
}
[JsonProperty("canZoom", NullValueHandling = NullValueHandling.Ignore)]
public bool CanZoom
{
get
{
return (Capabilities & eCameraCapabilities.Zoom) == eCameraCapabilities.Zoom;
}
}
[JsonProperty("canFocus", NullValueHandling = NullValueHandling.Ignore)]
public bool CanFocus
{
get
{
return (Capabilities & eCameraCapabilities.Focus) == eCameraCapabilities.Focus;
}
}
// A bitmasked value to indicate the movement capabilites of this camera
protected eCameraCapabilities Capabilities { get; set; }
protected CameraBase(DeviceConfig config) : base(config)
{
OutputPorts = new RoutingPortCollection<RoutingOutputPort>();
ControlMode = eCameraControlMode.Manual;
}
protected CameraBase(string key, string name) :
this (new DeviceConfig{Name = name, Key = key})
{
}
protected void LinkCameraToApi(CameraBase cameraDevice, BasicTriList trilist, uint joinStart, string joinMapKey,
EiscApiAdvanced bridge)
{
CameraControllerJoinMap joinMap = new CameraControllerJoinMap(joinStart);
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.");
}
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();
}
});
}
var powerCamera = cameraDevice as IHasPowerControl;
if (powerCamera != null)
{
trilist.SetSigTrueAction(joinMap.PowerOn.JoinNumber, () => powerCamera.PowerOn());
trilist.SetSigTrueAction(joinMap.PowerOff.JoinNumber, () => powerCamera.PowerOff());
var powerFbCamera = powerCamera as IHasPowerControlWithFeedback;
if (powerFbCamera != null)
{
powerFbCamera.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn.JoinNumber]);
powerFbCamera.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<EventArgs>((o, a) =>
{
SendCameraPresetNamesToApi(presetsCamera, joinMap, trilist);
});
SendCameraPresetNamesToApi(presetsCamera, joinMap, trilist);
for (int i = 0; i < joinMap.NumberOfPresets.JoinSpan; 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);
});
}
trilist.OnlineStatusChange += (sender, args) =>
{
if (!args.DeviceOnLine)
{ return; }
SendCameraPresetNamesToApi(presetsCamera, joinMap, trilist);
};
}
}
private void SendCameraPresetNamesToApi(IHasCameraPresets presetsCamera, CameraControllerJoinMap joinMap, BasicTriList trilist)
{
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);
}
}
}
public class CameraPreset : PresetBase
{
public CameraPreset(int id, string description, bool isDefined, bool isDefinable)
: base(id, description, isDefined, isDefinable)
{
}
}
public class CameraPropertiesConfig
{
public CommunicationMonitorConfig CommunicationMonitorProperties { get; set; }
public ControlPropertiesConfig Control { get; set; }
[JsonProperty("supportsAutoMode")]
public bool SupportsAutoMode { get; set; }
[JsonProperty("supportsOffMode")]
public bool SupportsOffMode { get; set; }
[JsonProperty("presets")]
public List<CameraPreset> Presets { get; set; }
}
}

View file

@ -0,0 +1,166 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Devices.Common.Cameras
{
public enum eCameraControlMode
{
Manual = 0,
Off,
Auto
}
public interface IHasCameras
{
event EventHandler<CameraSelectedEventArgs> CameraSelected;
List<CameraBase> Cameras { get; }
CameraBase SelectedCamera { get; }
StringFeedback SelectedCameraFeedback { get; }
void SelectCamera(string key);
}
/// <summary>
/// Aggregates far end cameras with near end cameras
/// </summary>
public interface IHasCodecCameras : IHasCameras, IHasFarEndCameraControl
{
}
/// <summary>
/// To be implmented on codecs that can disable their camera(s) to blank the near end video
/// </summary>
public interface IHasCameraOff
{
BoolFeedback CameraIsOffFeedback { get; }
void CameraOff();
}
/// <summary>
/// Describes the ability to mute and unmute camera video
/// </summary>
public interface IHasCameraMute
{
BoolFeedback CameraIsMutedFeedback { get; }
void CameraMuteOn();
void CameraMuteOff();
void CameraMuteToggle();
}
public interface IHasCameraMuteWithUnmuteReqeust : IHasCameraMute
{
event EventHandler VideoUnmuteRequested;
}
public class CameraSelectedEventArgs : EventArgs
{
public CameraBase SelectedCamera { get; private set; }
public CameraSelectedEventArgs(CameraBase camera)
{
SelectedCamera = camera;
}
}
public interface IHasFarEndCameraControl
{
CameraBase FarEndCamera { get; }
BoolFeedback ControllingFarEndCameraFeedback { get; }
}
/// <summary>
/// Used to decorate a camera as a far end
/// </summary>
public interface IAmFarEndCamera
{
}
public interface IHasCameraControls
{
}
/// <summary>
/// Aggregates the pan, tilt and zoom interfaces
/// </summary>
public interface IHasCameraPtzControl : IHasCameraPanControl, IHasCameraTiltControl, IHasCameraZoomControl
{
/// <summary>
/// Resets the camera position
/// </summary>
void PositionHome();
}
/// <summary>
/// Interface for camera pan control
/// </summary>
public interface IHasCameraPanControl : IHasCameraControls
{
void PanLeft();
void PanRight();
void PanStop();
}
/// <summary>
/// Interface for camera tilt control
/// </summary>
public interface IHasCameraTiltControl : IHasCameraControls
{
void TiltDown();
void TiltUp();
void TiltStop();
}
/// <summary>
/// Interface for camera zoom control
/// </summary>
public interface IHasCameraZoomControl : IHasCameraControls
{
void ZoomIn();
void ZoomOut();
void ZoomStop();
}
/// <summary>
/// Interface for camera focus control
/// </summary>
public interface IHasCameraFocusControl : IHasCameraControls
{
void FocusNear();
void FocusFar();
void FocusStop();
void TriggerAutoFocus();
}
public interface IHasAutoFocusMode
{
void SetFocusModeAuto();
void SetFocusModeManual();
void ToggleFocusMode();
}
public interface IHasCameraAutoMode : IHasCameraControls
{
void CameraAutoModeOn();
void CameraAutoModeOff();
void CameraAutoModeToggle();
BoolFeedback CameraAutoModeIsOnFeedback { get; }
}
}

View file

@ -0,0 +1,697 @@
extern alias Full;
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.Core.Bridges;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Devices.Common.Codec;
using System.Text.RegularExpressions;
using Crestron.SimplSharp.Reflection;
using Full.Newtonsoft.Json;
namespace PepperDash.Essentials.Devices.Common.Cameras
{
public class CameraVisca : CameraBase, IHasCameraPtzControl, ICommunicationMonitor, IHasCameraPresets, IHasPowerControlWithFeedback, IBridgeAdvanced, IHasCameraFocusControl, IHasAutoFocusMode
{
CameraViscaPropertiesConfig PropertiesConfig;
public IBasicCommunication Communication { get; private set; }
public StatusMonitorBase CommunicationMonitor { get; private set; }
/// <summary>
/// Used to store the actions to parse inquiry responses as the inquiries are sent
/// </summary>
private CrestronQueue<Action<byte[]>> InquiryResponseQueue;
/// <summary>
/// Camera ID (Default 1)
/// </summary>
public byte ID = 0x01;
public byte ResponseID;
public byte PanSpeedSlow = 0x10;
public byte TiltSpeedSlow = 0x10;
public byte PanSpeedFast = 0x13;
public byte TiltSpeedFast = 0x13;
private bool IsMoving;
private bool IsZooming;
bool _powerIsOn;
public bool PowerIsOn
{
get
{
return _powerIsOn;
}
private set
{
if (value != _powerIsOn)
{
_powerIsOn = value;
PowerIsOnFeedback.FireUpdate();
CameraIsOffFeedback.FireUpdate();
}
}
}
const byte ZoomInCmd = 0x02;
const byte ZoomOutCmd = 0x03;
const byte ZoomStopCmd = 0x00;
/// <summary>
/// Used to determine when to move the camera at a faster speed if a direction is held
/// </summary>
CTimer SpeedTimer;
// TODO: Implment speed timer for PTZ controls
long FastSpeedHoldTimeMs = 2000;
byte[] IncomingBuffer = new byte[] { };
public BoolFeedback PowerIsOnFeedback { get; private set; }
public CameraVisca(string key, string name, IBasicCommunication comm, CameraViscaPropertiesConfig props) :
base(key, name)
{
InquiryResponseQueue = new CrestronQueue<Action<byte[]>>(15);
Presets = props.Presets;
PropertiesConfig = props;
ID = (byte)(props.Id + 0x80);
ResponseID = (byte)((props.Id * 0x10) + 0x80);
SetupCameraSpeeds();
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
}
Communication.BytesReceived += new EventHandler<GenericCommMethodReceiveBytesArgs>(Communication_BytesReceived);
PowerIsOnFeedback = new BoolFeedback(() => { return PowerIsOn; });
CameraIsOffFeedback = 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);
}
/// <summary>
/// Sets up camera speed values based on config
/// </summary>
void SetupCameraSpeeds()
{
if (PropertiesConfig.FastSpeedHoldTimeMs > 0)
{
FastSpeedHoldTimeMs = PropertiesConfig.FastSpeedHoldTimeMs;
}
if (PropertiesConfig.PanSpeedSlow > 0)
{
PanSpeedSlow = (byte)PropertiesConfig.PanSpeedSlow;
}
if (PropertiesConfig.PanSpeedFast > 0)
{
PanSpeedFast = (byte)PropertiesConfig.PanSpeedFast;
}
if (PropertiesConfig.TiltSpeedSlow > 0)
{
TiltSpeedSlow = (byte)PropertiesConfig.TiltSpeedSlow;
}
if (PropertiesConfig.TiltSpeedFast > 0)
{
TiltSpeedFast = (byte)PropertiesConfig.TiltSpeedFast;
}
}
public override bool CustomActivate()
{
Communication.Connect();
CommunicationMonitor.StatusChange += (o, a) => { Debug.Console(2, this, "Communication monitor state: {0}", CommunicationMonitor.Status); };
CommunicationMonitor.Start();
CrestronConsole.AddNewConsoleCommand(s => Communication.Connect(), "con" + Key, "", ConsoleAccessLevelEnum.AccessOperator);
return true;
}
public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{
LinkCameraToApi(this, trilist, joinStart, joinMapKey, bridge);
}
void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e)
{
Debug.Console(2, this, "Socket Status Change: {0}", e.Client.ClientStatus.ToString());
if (e.Client.IsConnected)
{
}
else
{
}
}
void SendBytes(byte[] b)
{
if (Debug.Level == 2) // This check is here to prevent following string format from building unnecessarily on level 0 or 1
Debug.Console(2, this, "Sending:{0}", ComTextHelper.GetEscapedText(b));
Communication.SendBytes(b);
}
void Communication_BytesReceived(object sender, GenericCommMethodReceiveBytesArgs e)
{
var newBytes = new byte[IncomingBuffer.Length + e.Bytes.Length];
try
{
// This is probably not thread-safe buffering
// Append the incoming bytes with whatever is in the buffer
IncomingBuffer.CopyTo(newBytes, 0);
e.Bytes.CopyTo(newBytes, IncomingBuffer.Length);
if (Debug.Level == 2) // This check is here to prevent following string format from building unnecessarily on level 0 or 1
Debug.Console(2, this, "Received:{0}", ComTextHelper.GetEscapedText(newBytes));
byte[] message = new byte[] { };
// Search for the delimiter 0xFF character
for (int i = 0; i < newBytes.Length; i++)
{
if (newBytes[i] == 0xFF)
{
// i will be the index of the delmiter character
message = newBytes.Take(i).ToArray();
// Skip over what we just took and save the rest for next time
newBytes = newBytes.Skip(i).ToArray();
}
}
if (message.Length > 0)
{
// Check for matching ID
if (message[0] != ResponseID)
{
return;
}
switch (message[1])
{
case 0x40:
{
// ACK received
Debug.Console(2, this, "ACK Received");
break;
}
case 0x50:
{
if (message[2] == 0xFF)
{
// Completion received
Debug.Console(2, this, "Completion Received");
}
else
{
// Inquiry response received. Dequeue the next response handler and invoke it
if (InquiryResponseQueue.Count > 0)
{
var inquiryAction = InquiryResponseQueue.Dequeue();
inquiryAction.Invoke(message.Skip(2).ToArray());
}
else
{
Debug.Console(2, this, "Response Queue is empty. Nothing to dequeue.");
}
}
break;
}
case 0x60:
{
// Error message
switch (message[2])
{
case 0x01:
{
// Message Length Error
Debug.Console(2, this, "Error from device: Message Length Error");
break;
}
case 0x02:
{
// Syntax Error
Debug.Console(2, this, "Error from device: Syntax Error");
break;
}
case 0x03:
{
// Command Buffer Full
Debug.Console(2, this, "Error from device: Command Buffer Full");
break;
}
case 0x04:
{
// Command Cancelled
Debug.Console(2, this, "Error from device: Command Cancelled");
break;
}
case 0x05:
{
// No Socket
Debug.Console(2, this, "Error from device: No Socket");
break;
}
case 0x41:
{
// Command not executable
Debug.Console(2, this, "Error from device: Command not executable");
break;
}
}
break;
}
}
if (message == new byte[] { ResponseID, 0x50, 0x02, 0xFF })
{
PowerIsOn = true;
}
else if (message == new byte[] { ResponseID, 0x50, 0x03, 0xFF })
{
PowerIsOn = false;
}
}
}
catch (Exception err)
{
Debug.Console(2, this, "Error parsing feedback: {0}", err);
}
finally
{
// Save whatever partial message is here
IncomingBuffer = newBytes;
}
}
/// <summary>
/// Sends a pan/tilt command. If the command is not for fastSpeed then it starts a timer to initiate fast speed.
/// </summary>
/// <param name="cmd"></param>
/// <param name="fastSpeed"></param>
private void SendPanTiltCommand (byte[] cmd, bool fastSpeedEnabled)
{
SendBytes(GetPanTiltCommand(cmd, fastSpeedEnabled));
if (!fastSpeedEnabled)
{
if (SpeedTimer != null)
{
StopSpeedTimer();
}
// Start the timer to send fast speed if still moving after FastSpeedHoldTime elapses
SpeedTimer = new CTimer((o) => SendPanTiltCommand(GetPanTiltCommand(cmd, true), true), FastSpeedHoldTimeMs);
}
}
private void StopSpeedTimer()
{
if (SpeedTimer != null)
{
SpeedTimer.Stop();
SpeedTimer.Dispose();
SpeedTimer = null;
}
}
/// <summary>
/// Generates the pan/tilt command with either slow or fast speed
/// </summary>
/// <param name="cmd"></param>
/// <param name="fastSpeed"></param>
/// <returns></returns>
private byte[] GetPanTiltCommand(byte[] cmd, bool fastSpeed)
{
byte panSpeed;
byte tiltSpeed;
if (!fastSpeed)
{
panSpeed = PanSpeedSlow;
tiltSpeed = TiltSpeedSlow;
}
else
{
panSpeed = PanSpeedFast;
tiltSpeed = TiltSpeedFast;
}
var temp = new byte[] { ID, 0x01, 0x06, 0x01, panSpeed, tiltSpeed };
int length = temp.Length + cmd.Length + 1;
byte[] sum = new byte[length];
temp.CopyTo(sum, 0);
cmd.CopyTo(sum, temp.Length);
sum[length - 1] = 0xFF;
return sum;
}
void SendPowerQuery()
{
SendBytes(new byte[] { ID, 0x09, 0x04, 0x00, 0xFF });
InquiryResponseQueue.Enqueue(HandlePowerResponse);
}
public void PowerOn()
{
SendBytes(new byte[] { ID, 0x01, 0x04, 0x00, 0x02, 0xFF });
SendPowerQuery();
}
void HandlePowerResponse(byte[] response)
{
switch (response[0])
{
case 0x02:
{
PowerIsOn = true;
break;
}
case 0x03:
{
PowerIsOn = false;
break;
}
}
}
public void PowerOff()
{
SendBytes(new byte[] {ID, 0x01, 0x04, 0x00, 0x03, 0xFF});
SendPowerQuery();
}
public void PowerToggle()
{
if (PowerIsOnFeedback.BoolValue)
PowerOff();
else
PowerOn();
}
public void PanLeft()
{
SendPanTiltCommand(new byte[] {0x01, 0x03}, false);
IsMoving = true;
}
public void PanRight()
{
SendPanTiltCommand(new byte[] { 0x02, 0x03 }, false);
IsMoving = true;
}
public void PanStop()
{
Stop();
}
public void TiltDown()
{
SendPanTiltCommand(new byte[] { 0x03, 0x02 }, false);
IsMoving = true;
}
public void TiltUp()
{
SendPanTiltCommand(new byte[] { 0x03, 0x01 }, false);
IsMoving = true;
}
public void TiltStop()
{
Stop();
}
private void SendZoomCommand (byte cmd)
{
SendBytes(new byte[] {ID, 0x01, 0x04, 0x07, cmd, 0xFF} );
}
public void ZoomIn()
{
SendZoomCommand(ZoomInCmd);
IsZooming = true;
}
public void ZoomOut()
{
SendZoomCommand(ZoomOutCmd);
IsZooming = true;
}
public void ZoomStop()
{
Stop();
}
public void Stop()
{
if (IsZooming)
{
SendZoomCommand(ZoomStopCmd);
IsZooming = false;
}
else
{
StopSpeedTimer();
SendPanTiltCommand(new byte[] { 0x03, 0x03 }, false);
IsMoving = false;
}
}
public void PositionHome()
{
SendBytes(new byte[] { ID, 0x01, 0x06, 0x02, PanSpeedFast, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF });
SendBytes(new byte[] { ID, 0x01, 0x04, 0x47, 0x00, 0x00, 0x00, 0x00, 0xFF });
}
public void RecallPreset(int presetNumber)
{
SendBytes(new byte[] {ID, 0x01, 0x04, 0x3F, 0x02, (byte)presetNumber, 0xFF} );
}
public void SavePreset(int presetNumber)
{
SendBytes(new byte[] { ID, 0x01, 0x04, 0x3F, 0x01, (byte)presetNumber, 0xFF });
}
#region IHasCameraPresets Members
public event EventHandler<EventArgs> PresetsListHasChanged;
protected void OnPresetsListHasChanged()
{
var handler = PresetsListHasChanged;
if (handler == null)
return;
handler.Invoke(this, EventArgs.Empty);
}
public List<CameraPreset> Presets { get; private set; }
public void PresetSelect(int preset)
{
RecallPreset(preset);
}
public void PresetStore(int preset, string description)
{
SavePreset(preset);
}
#endregion
#region IHasCameraFocusControl Members
public void FocusNear()
{
SendBytes(new byte[] { ID, 0x01, 0x04, 0x08, 0x03, 0xFF });
}
public void FocusFar()
{
SendBytes(new byte[] { ID, 0x01, 0x04, 0x08, 0x02, 0xFF });
}
public void FocusStop()
{
SendBytes(new byte[] { ID, 0x01, 0x04, 0x08, 0x00, 0xFF });
}
public void TriggerAutoFocus()
{
SendBytes(new byte[] { ID, 0x01, 0x04, 0x18, 0x01, 0xFF });
SendAutoFocusQuery();
}
#endregion
#region IHasAutoFocus Members
public void SetFocusModeAuto()
{
SendBytes(new byte[] { ID, 0x01, 0x04, 0x38, 0x02, 0xFF });
SendAutoFocusQuery();
}
public void SetFocusModeManual()
{
SendBytes(new byte[] { ID, 0x01, 0x04, 0x38, 0x03, 0xFF });
SendAutoFocusQuery();
}
public void ToggleFocusMode()
{
SendBytes(new byte[] { ID, 0x01, 0x04, 0x38, 0x10, 0xFF });
SendAutoFocusQuery();
}
#endregion
void SendAutoFocusQuery()
{
SendBytes(new byte[] { ID, 0x09, 0x04, 0x38, 0xFF });
InquiryResponseQueue.Enqueue(HandleAutoFocusResponse);
}
void HandleAutoFocusResponse(byte[] response)
{
switch (response[0])
{
case 0x02:
{
// Auto Mode
PowerIsOn = true;
break;
}
case 0x03:
{
// Manual Mode
PowerIsOn = false;
break;
}
}
}
#region IHasCameraOff Members
public BoolFeedback CameraIsOffFeedback { get; private set; }
public void CameraOff()
{
PowerOff();
}
#endregion
}
public class CameraViscaFactory : EssentialsDeviceFactory<CameraVisca>
{
public CameraViscaFactory()
{
TypeNames = new List<string>() { "cameravisca" };
}
public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
Debug.Console(1, "Factory Attempting to create new CameraVisca Device");
var comm = CommFactory.CreateCommForDevice(dc);
var props = Newtonsoft.Json.JsonConvert.DeserializeObject<Cameras.CameraViscaPropertiesConfig>(
dc.Properties.ToString());
return new Cameras.CameraVisca(dc.Key, dc.Name, comm, props);
}
}
public class CameraViscaPropertiesConfig : CameraPropertiesConfig
{
/// <summary>
/// Control ID of the camera (1-7)
/// </summary>
[JsonProperty("id")]
public uint Id { get; set; }
/// <summary>
/// Slow Pan speed (0-18)
/// </summary>
[JsonProperty("panSpeedSlow")]
public uint PanSpeedSlow { get; set; }
/// <summary>
/// Fast Pan speed (0-18)
/// </summary>
[JsonProperty("panSpeedFast")]
public uint PanSpeedFast { get; set; }
/// <summary>
/// Slow tilt speed (0-18)
/// </summary>
[JsonProperty("tiltSpeedSlow")]
public uint TiltSpeedSlow { get; set; }
/// <summary>
/// Fast tilt speed (0-18)
/// </summary>
[JsonProperty("tiltSpeedFast")]
public uint TiltSpeedFast { get; set; }
/// <summary>
/// Time a button must be held before fast speed is engaged (Milliseconds)
/// </summary>
[JsonProperty("fastSpeedHoldTimeMs")]
public uint FastSpeedHoldTimeMs { get; set; }
}
}

View file

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Devices.Common.Cameras
{
/// <summary>
/// Describes a camera with preset functionality
/// </summary>
public interface IHasCameraPresets
{
event EventHandler<EventArgs> PresetsListHasChanged;
List<CameraPreset> Presets { get; }
void PresetSelect(int preset);
void PresetStore(int preset, string description);
}
}

View file

@ -0,0 +1,75 @@
extern alias Full;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Full.Newtonsoft.Json;
using Full.Newtonsoft.Json.Converters;
namespace PepperDash.Essentials.Devices.Common.Codec
{
public class CodecActiveCallItem
{
[JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)]
public string Name { get; set; }
[JsonProperty("number", NullValueHandling = NullValueHandling.Ignore)]
public string Number { get; set; }
[JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(StringEnumConverter))]
public eCodecCallType Type { get; set; }
[JsonProperty("status", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(StringEnumConverter))]
public eCodecCallStatus Status { get; set; }
[JsonProperty("direction", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(StringEnumConverter))]
public eCodecCallDirection Direction { get; set; }
[JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)]
public string Id { get; set; }
[JsonProperty("isOnHold", NullValueHandling = NullValueHandling.Ignore)]
public bool IsOnHold { get; set; }
[JsonProperty("duration", NullValueHandling = NullValueHandling.Ignore)]
public TimeSpan Duration { get; set; }
//public object CallMetaData { get; set; }
/// <summary>
/// Returns true when this call is any status other than
/// Unknown, Disconnected, Disconnecting
/// </summary>
[JsonProperty("isActiveCall", NullValueHandling = NullValueHandling.Ignore)]
public bool IsActiveCall
{
get
{
return !(Status == eCodecCallStatus.Disconnected
|| Status == eCodecCallStatus.Disconnecting
|| Status == eCodecCallStatus.Idle
|| Status == eCodecCallStatus.Unknown);
}
}
}
/// <summary>
///
/// </summary>
public class CodecCallStatusItemChangeEventArgs : EventArgs
{
public CodecActiveCallItem CallItem { get; private set; }
public CodecCallStatusItemChangeEventArgs(CodecActiveCallItem item)
{
CallItem = item;
}
}
}

View file

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Devices.Common.Codec
{
public interface IHasCallHold
{
/// <summary>
/// Put the specified call on hold
/// </summary>
/// <param name="activeCall"></param>
void HoldCall(CodecActiveCallItem activeCall);
/// <summary>
/// Resume the specified call
/// </summary>
/// <param name="activeCall"></param>
void ResumeCall(CodecActiveCallItem activeCall);
}
}

View file

@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Devices.Common.Codec
{
/// <summary>
/// Describes a device that has Do Not Disturb mode capability
/// </summary>
public interface IHasDoNotDisturbMode
{
/// <summary>
/// Indictes whether Do Not Disturb mode is on (Activated)
/// </summary>
BoolFeedback DoNotDisturbModeIsOnFeedback { get; }
/// <summary>
/// Activates Do Not Disturb mode
/// </summary>
void ActivateDoNotDisturbMode();
/// <summary>
/// Deactivates Do Not Disturb mode
/// </summary>
void DeactivateDoNotDisturbMode();
/// <summary>
/// Toggles Do Not Disturb mode
/// </summary>
void ToggleDoNotDisturbMode();
}
public interface IHasDoNotDisturbModeWithTimeout : IHasDoNotDisturbMode
{
/// <summary>
/// Activates Do Not Disturb mode with a timeout
/// </summary>
/// <param name="timeout"></param>
void ActivateDoNotDisturbMode(int timeout);
}
}

View file

@ -0,0 +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<string, string> RunRouteAction { set;}
}
}

View file

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Devices.Common.Codec
{
public enum eCodecCallDirection
{
Unknown = 0, Incoming, Outgoing
}
public class CodecCallDirection
{
/// <summary>
/// Takes the Cisco call type and converts to the matching enum
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static eCodecCallDirection ConvertToDirectionEnum(string s)
{
switch (s.ToLower())
{
case "incoming":
{
return eCodecCallDirection.Incoming;
}
case "outgoing":
{
return eCodecCallDirection.Outgoing;
}
default:
return eCodecCallDirection.Unknown;
}
}
}
}

View file

@ -0,0 +1,89 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Devices.Common.Codec
{
public enum eCodecCallStatus
{
Unknown = 0,
Connected,
Connecting,
Dialing,
Disconnected,
Disconnecting,
EarlyMedia,
Idle,
OnHold,
Ringing,
Preserved,
RemotePreserved,
}
public class CodecCallStatus
{
/// <summary>
/// Takes the Cisco call type and converts to the matching enum
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static eCodecCallStatus ConvertToStatusEnum(string s)
{
switch (s)
{
case "Connected":
{
return eCodecCallStatus.Connected;
}
case "Connecting":
{
return eCodecCallStatus.Connecting;
}
case "Dialling":
{
return eCodecCallStatus.Dialing;
}
case "Disconnected":
{
return eCodecCallStatus.Disconnected;
}
case "Disconnecting":
{
return eCodecCallStatus.Disconnecting;
}
case "EarlyMedia":
{
return eCodecCallStatus.EarlyMedia;
}
case "Idle":
{
return eCodecCallStatus.Idle;
}
case "OnHold":
{
return eCodecCallStatus.OnHold;
}
case "Ringing":
{
return eCodecCallStatus.Ringing;
}
case "Preserved":
{
return eCodecCallStatus.Preserved;
}
case "RemotePreserved":
{
return eCodecCallStatus.RemotePreserved;
}
default:
return eCodecCallStatus.Unknown;
}
}
}
}

View file

@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Devices.Common.Codec
{
public enum eCodecCallType
{
Unknown = 0,
Audio,
Video,
AudioCanEscalate,
ForwardAllCall
}
public class CodecCallType
{
/// <summary>
/// Takes the Cisco call type and converts to the matching enum
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static eCodecCallType ConvertToTypeEnum(string s)
{
switch (s)
{
case "Audio":
{
return eCodecCallType.Audio;
}
case "Video":
{
return eCodecCallType.Video;
}
case "AudioCanEscalate":
{
return eCodecCallType.AudioCanEscalate;
}
case "ForwardAllCall":
{
return eCodecCallType.ForwardAllCall;
}
default:
return eCodecCallType.Unknown;
}
}
}
}

View file

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Devices.Common.Codec
{
public enum eMeetingPrivacy
{
Unknown = 0,
Public,
Private
}
public class CodecCallPrivacy
{
/// <summary>
/// Takes the Cisco privacy type and converts to the matching enum
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static eMeetingPrivacy ConvertToDirectionEnum(string s)
{
switch (s.ToLower())
{
case "public":
{
return eMeetingPrivacy.Public;
}
case "private":
{
return eMeetingPrivacy.Private;
}
default:
return eMeetingPrivacy.Unknown;
}
}
}
}

View file

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Devices.Common.Codec
{
/// <summary>
/// Defines minimum volume controls for a codec device with dialing capabilities
/// </summary>
public interface ICodecAudio : IBasicVolumeWithFeedback, IPrivacy
{
}
}

View file

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Devices.Common.Codec
{
public interface IHasCallFavorites
{
CodecCallFavorites CallFavorites { get; }
}
/// <summary>
/// Represents favorites entries for a codec device
/// </summary>
public class CodecCallFavorites
{
public List<CodecActiveCallItem> Favorites { get; set; }
public CodecCallFavorites()
{
Favorites = new List<CodecActiveCallItem>();
}
}
}

View file

@ -0,0 +1,143 @@
extern alias Full;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
using PepperDash.Essentials.Devices.Common.Codec;
using PepperDash.Essentials.Devices.Common.VideoCodec;
using Full.Newtonsoft.Json;
using Full.Newtonsoft.Json.Converters;
namespace PepperDash.Essentials.Devices.Common.Codec
{
public interface IHasCallHistory
{
CodecCallHistory CallHistory { get; }
void RemoveCallHistoryEntry(CodecCallHistory.CallHistoryEntry entry);
}
public enum eCodecOccurrenceType
{
Unknown = 0,
Placed = 1,
Received = 2,
NoAnswer = 3,
}
/// <summary>
/// Represents the recent call history for a codec device
/// </summary>
public class CodecCallHistory
{
public event EventHandler<EventArgs> RecentCallsListHasChanged;
public List<CallHistoryEntry> RecentCalls { get; private set; }
/// <summary>
/// Item that gets added to the list when there are no recent calls in history
/// </summary>
CallHistoryEntry ListEmptyEntry;
public CodecCallHistory()
{
ListEmptyEntry = new CallHistoryEntry() { Name = "No Recent Calls" };
RecentCalls = new List<CallHistoryEntry>();
RecentCalls.Add(ListEmptyEntry);
}
void OnRecentCallsListChange()
{
var handler = RecentCallsListHasChanged;
if (handler != null)
{
handler(this, new EventArgs());
}
}
public void RemoveEntry(CallHistoryEntry entry)
{
RecentCalls.Remove(entry);
OnRecentCallsListChange();
}
/// <summary>
/// Generic call history entry, not device specific
/// </summary>
public class CallHistoryEntry : CodecActiveCallItem
{
[JsonConverter(typeof(IsoDateTimeConverter))]
[JsonProperty("startTime")]
public DateTime StartTime { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
[JsonProperty("occurrenceType")]
public eCodecOccurrenceType OccurrenceType { get; set; }
[JsonProperty("occurrenceHistoryId")]
public string OccurrenceHistoryId { get; set; }
}
/// <summary>
/// Converts a list of call history entries returned by a Cisco codec to the generic list type
/// </summary>
/// <param name="entries"></param>
/// <returns></returns>
public void ConvertCiscoCallHistoryToGeneric(List<CiscoCallHistory.Entry> entries)
{
var genericEntries = new List<CallHistoryEntry>();
foreach (CiscoCallHistory.Entry entry in entries)
{
genericEntries.Add(new CallHistoryEntry()
{
Name = entry.DisplayName.Value,
Number = entry.CallbackNumber.Value,
StartTime = entry.LastOccurrenceStartTime.Value,
OccurrenceHistoryId = entry.LastOccurrenceHistoryId.Value,
OccurrenceType = ConvertToOccurenceTypeEnum(entry.OccurrenceType.Value)
});
}
// Check if list is empty and if so, add an item to display No Recent Calls
if(genericEntries.Count == 0)
genericEntries.Add(ListEmptyEntry);
RecentCalls = genericEntries;
OnRecentCallsListChange();
}
/// <summary>
/// Takes the Cisco occurence type and converts it to the matching enum
/// </summary>
/// <param name="s"></para
public eCodecOccurrenceType ConvertToOccurenceTypeEnum(string s)
{
switch (s)
{
case "Placed":
{
return eCodecOccurrenceType.Placed;
}
case "Received":
{
return eCodecOccurrenceType.Received;
}
case "NoAnswer":
{
return eCodecOccurrenceType.NoAnswer;
}
default:
return eCodecOccurrenceType.Unknown;
}
}
}
}

View file

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Devices.Common.Codec
{
public interface IHasContentSharing
{
BoolFeedback SharingContentIsOnFeedback { get; }
StringFeedback SharingSourceFeedback { get; }
bool AutoShareContentWhileInCall { get; }
void StartSharing();
void StopSharing();
}
}

View file

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Devices.Common.Codec
{
/// <summary>
/// Requirements for a device that has dialing capabilities
/// </summary>
public interface IHasDialer
{
// Add requirements for Dialer functionality
event EventHandler<CodecCallStatusItemChangeEventArgs> CallStatusChange;
void Dial(string number);
void EndCall(CodecActiveCallItem activeCall);
void EndAllCalls();
void AcceptCall(CodecActiveCallItem item);
void RejectCall(CodecActiveCallItem item);
void SendDtmf(string digit);
bool IsInCall { get; }
}
}

View file

@ -0,0 +1,280 @@
extern alias Full;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Full.Newtonsoft.Json;
using Full.Newtonsoft.Json.Converters;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Devices.Common.VideoCodec;
namespace PepperDash.Essentials.Devices.Common.Codec
{
/// <summary>
/// Defines the API for codecs with a directory
/// </summary>
public interface IHasDirectory
{
event EventHandler<DirectoryEventArgs> DirectoryResultReturned;
CodecDirectory DirectoryRoot { get; }
CodecDirectory CurrentDirectoryResult { get; }
CodecPhonebookSyncState PhonebookSyncState { get; }
void SearchDirectory(string searchString);
void GetDirectoryFolderContents(string folderId);
void SetCurrentDirectoryToRoot();
void GetDirectoryParentFolderContents();
BoolFeedback CurrentDirectoryResultIsNotDirectoryRoot { get; }
/// <summary>
/// Tracks the directory browse history when browsing beyond the root directory
/// </summary>
[Obsolete("Please use the Stack-based history instead")]
List<CodecDirectory> DirectoryBrowseHistory { get; }
}
public interface IHasDirectoryHistoryStack : IHasDirectory
{
Stack<CodecDirectory> DirectoryBrowseHistoryStack { get; }
}
/// <summary>
///
/// </summary>
public class DirectoryEventArgs : EventArgs
{
public CodecDirectory Directory { get; set; }
public bool DirectoryIsOnRoot { get; set; }
}
/// <summary>
/// Represents a codec directory
/// </summary>
public class CodecDirectory
{
/// <summary>
/// Represents the contents of the directory
/// We don't want to serialize this for messages to MobileControl. MC can combine Contacts and Folders to get the same data
/// </summary>
[JsonIgnore]
public List<DirectoryItem> CurrentDirectoryResults { get; private set; }
[JsonProperty("contacts")]
public List<DirectoryItem> Contacts
{
get
{
return CurrentDirectoryResults.OfType<DirectoryContact>().Cast<DirectoryItem>().ToList();
}
}
[JsonProperty("folders")]
public List<DirectoryItem> Folders
{
get
{
return CurrentDirectoryResults.OfType<DirectoryFolder>().Cast<DirectoryItem>().ToList();
}
}
/// <summary>
/// Used to store the ID of the current folder for CurrentDirectoryResults
/// </summary>
[JsonProperty("resultsFolderId")]
public string ResultsFolderId { get; set; }
public CodecDirectory()
{
CurrentDirectoryResults = new List<DirectoryItem>();
}
/// <summary>
/// Adds folders to the directory
/// </summary>
/// <param name="folders"></param>
public void AddFoldersToDirectory(List<DirectoryItem> folders)
{
if(folders != null)
CurrentDirectoryResults.AddRange(folders);
SortDirectory();
}
/// <summary>
/// Adds contacts to the directory
/// </summary>
/// <param name="contacts"></param>
public void AddContactsToDirectory(List<DirectoryItem> contacts)
{
if(contacts != null)
CurrentDirectoryResults.AddRange(contacts);
SortDirectory();
}
/// <summary>
/// Filters the CurrentDirectoryResults by the predicate
/// </summary>
/// <param name="predicate"></param>
public void FilterContacts(Func<DirectoryItem, bool> predicate)
{
CurrentDirectoryResults = CurrentDirectoryResults.Where(predicate).ToList();
}
/// <summary>
/// Sorts the DirectoryResults list to display all folders alphabetically, then all contacts alphabetically
/// </summary>
private void SortDirectory()
{
var sortedFolders = new List<DirectoryItem>();
sortedFolders.AddRange(CurrentDirectoryResults.Where(f => f is DirectoryFolder));
sortedFolders.OrderBy(f => f.Name);
var sortedContacts = new List<DirectoryItem>();
sortedContacts.AddRange(CurrentDirectoryResults.Where(c => c is DirectoryContact));
sortedFolders.OrderBy(c => c.Name);
CurrentDirectoryResults.Clear();
CurrentDirectoryResults.AddRange(sortedFolders);
CurrentDirectoryResults.AddRange(sortedContacts);
}
}
/// <summary>
/// Used to decorate a contact to indicate it can be invided to a meeting
/// </summary>
public interface IInvitableContact
{
bool IsInvitableContact { get; }
}
public class InvitableDirectoryContact : DirectoryContact, IInvitableContact
{
[JsonProperty("isInvitableContact")]
public bool IsInvitableContact
{
get
{
return this is IInvitableContact;
}
}
}
/// <summary>
/// Represents an item in the directory
/// </summary>
public class DirectoryItem : ICloneable
{
public object Clone()
{
return this.MemberwiseClone();
}
[JsonProperty("folderId")]
public string FolderId { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("parentFolderId")]
public string ParentFolderId { get; set; }
}
/// <summary>
/// Represents a folder type DirectoryItem
/// </summary>
public class DirectoryFolder : DirectoryItem
{
[JsonProperty("contacts")]
public List<DirectoryContact> Contacts { get; set; }
public DirectoryFolder()
{
Contacts = new List<DirectoryContact>();
}
}
/// <summary>
/// Represents a contact type DirectoryItem
/// </summary>
public class DirectoryContact : DirectoryItem
{
[JsonProperty("contactId")]
public string ContactId { get; set; }
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("contactMethods")]
public List<ContactMethod> ContactMethods { get; set; }
public DirectoryContact()
{
ContactMethods = new List<ContactMethod>();
}
}
/// <summary>
/// Represents a method of contact for a contact
/// </summary>
public class ContactMethod
{
[JsonProperty("contactMethodId")]
public string ContactMethodId { get; set; }
[JsonProperty("number")]
public string Number { get; set; }
[JsonProperty("device")]
[JsonConverter(typeof(StringEnumConverter))]
public eContactMethodDevice Device { get; set; }
[JsonProperty("callType")]
[JsonConverter(typeof(StringEnumConverter))]
public eContactMethodCallType CallType { get; set; }
}
/// <summary>
///
/// </summary>
public enum eContactMethodDevice
{
Unknown = 0,
Mobile,
Other,
Telephone,
Video
}
/// <summary>
///
/// </summary>
public enum eContactMethodCallType
{
Unknown = 0,
Audio,
Video
}
}

View file

@ -0,0 +1,277 @@
extern alias Full;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
using Full.Newtonsoft.Json;
namespace PepperDash.Essentials.Devices.Common.Codec
{
[Flags]
public enum eMeetingEventChangeType
{
Unknown = 0,
MeetingStartWarning = 1,
MeetingStart = 2,
MeetingEndWarning = 4,
MeetingEnd = 8
}
public interface IHasScheduleAwareness
{
CodecScheduleAwareness CodecSchedule { get; }
void GetSchedule();
}
public class CodecScheduleAwareness
{
List<Meeting> _meetings;
public event EventHandler<MeetingEventArgs> MeetingEventChange;
public event EventHandler<EventArgs> MeetingsListHasChanged;
private int _meetingWarningMinutes = 5;
private Meeting _previousChangedMeeting;
private eMeetingEventChangeType _previousChangeType = eMeetingEventChangeType.Unknown;
public int MeetingWarningMinutes
{
get { return _meetingWarningMinutes; }
set { _meetingWarningMinutes = value; }
}
/// <summary>
/// Setter triggers MeetingsListHasChanged event
/// </summary>
public List<Meeting> Meetings
{
get
{
return _meetings;
}
set
{
_meetings = value;
var handler = MeetingsListHasChanged;
if (handler != null)
{
handler(this, new EventArgs());
}
}
}
private CTimer _scheduleChecker;
public CodecScheduleAwareness()
{
Meetings = new List<Meeting>();
_scheduleChecker = new CTimer(CheckSchedule, null, 1000, 1000);
}
public CodecScheduleAwareness(long pollTime)
{
Meetings = new List<Meeting>();
_scheduleChecker = new CTimer(CheckSchedule, null, pollTime, pollTime);
}
/// <summary>
/// Helper method to fire MeetingEventChange. Should only fire once for each changeType on each meeting
/// </summary>
/// <param name="changeType"></param>
/// <param name="meeting"></param>
private void OnMeetingChange(eMeetingEventChangeType changeType, Meeting meeting)
{
Debug.Console(2, "*****************OnMeetingChange. id: {0} changeType: {1}**********************", meeting.Id, changeType);
if (changeType != (changeType & meeting.NotifiedChangeTypes))
{
// Add this change type to the NotifiedChangeTypes
meeting.NotifiedChangeTypes |= changeType;
var handler = MeetingEventChange;
if (handler != null)
{
handler(this, new MeetingEventArgs() { ChangeType = changeType, Meeting = meeting });
}
}
else
{
Debug.Console(2, "Meeting: {0} already notified of changeType: {1}", meeting.Id, changeType);
}
}
/// <summary>
/// Checks the schedule to see if any MeetingEventChange updates should be fired
/// </summary>
/// <param name="o"></param>
private void CheckSchedule(object o)
{
// Iterate the meeting list and check if any meeting need to do anything
const double meetingTimeEpsilon = 0.05;
foreach (var m in Meetings)
{
var changeType = eMeetingEventChangeType.Unknown;
if (eMeetingEventChangeType.MeetingStartWarning != (m.NotifiedChangeTypes & eMeetingEventChangeType.MeetingStartWarning) && m.TimeToMeetingStart.TotalMinutes <= m.MeetingWarningMinutes.TotalMinutes && m.TimeToMeetingStart.Seconds > 0) // Meeting is about to start
{
Debug.Console(2, "********************* MeetingStartWarning. TotalMinutes: {0} Seconds: {1}", m.TimeToMeetingStart.TotalMinutes, m.TimeToMeetingStart.Seconds);
changeType = eMeetingEventChangeType.MeetingStartWarning;
}
else if (eMeetingEventChangeType.MeetingStart != (m.NotifiedChangeTypes & eMeetingEventChangeType.MeetingStart) && Math.Abs(m.TimeToMeetingStart.TotalMinutes) < meetingTimeEpsilon) // Meeting Start
{
Debug.Console(2, "********************* MeetingStart");
changeType = eMeetingEventChangeType.MeetingStart;
}
else if (eMeetingEventChangeType.MeetingEndWarning != (m.NotifiedChangeTypes & eMeetingEventChangeType.MeetingEndWarning) && m.TimeToMeetingEnd.TotalMinutes <= m.MeetingWarningMinutes.TotalMinutes && m.TimeToMeetingEnd.Seconds > 0) // Meeting is about to end
{
Debug.Console(2, "********************* MeetingEndWarning. TotalMinutes: {0} Seconds: {1}", m.TimeToMeetingEnd.TotalMinutes, m.TimeToMeetingEnd.Seconds);
changeType = eMeetingEventChangeType.MeetingEndWarning;
}
else if (eMeetingEventChangeType.MeetingEnd != (m.NotifiedChangeTypes & eMeetingEventChangeType.MeetingEnd) && Math.Abs(m.TimeToMeetingEnd.TotalMinutes) < meetingTimeEpsilon) // Meeting has ended
{
Debug.Console(2, "********************* MeetingEnd");
changeType = eMeetingEventChangeType.MeetingEnd;
}
if (changeType != eMeetingEventChangeType.Unknown)
{
OnMeetingChange(changeType, m);
}
}
}
}
/// <summary>
/// Generic class to represent a meeting (Cisco or Polycom OBTP or Fusion)
/// </summary>
public class Meeting
{
[JsonProperty("minutesBeforeMeeting")]
public int MinutesBeforeMeeting;
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("organizer")]
public string Organizer { get; set; }
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("agenda")]
public string Agenda { get; set; }
[JsonProperty("meetingWarningMinutes")]
public TimeSpan MeetingWarningMinutes
{
get { return TimeSpan.FromMinutes(MinutesBeforeMeeting); }
}
[JsonProperty("timeToMeetingStart")]
public TimeSpan TimeToMeetingStart
{
get
{
return StartTime - DateTime.Now;
}
}
[JsonProperty("timeToMeetingEnd")]
public TimeSpan TimeToMeetingEnd
{
get
{
return EndTime - DateTime.Now;
}
}
[JsonProperty("startTime")]
public DateTime StartTime { get; set; }
[JsonProperty("endTime")]
public DateTime EndTime { get; set; }
[JsonProperty("duration")]
public TimeSpan Duration
{
get
{
return EndTime - StartTime;
}
}
[JsonProperty("privacy")]
public eMeetingPrivacy Privacy { get; set; }
[JsonProperty("joinable")]
public bool Joinable
{
get
{
var joinable = StartTime.AddMinutes(-MinutesBeforeMeeting) <= DateTime.Now
&& DateTime.Now <= EndTime.AddSeconds(-_joinableCooldownSeconds);
//Debug.Console(2, "Meeting Id: {0} joinable: {1}", Id, joinable);
return joinable;
}
}
//public string ConferenceNumberToDial { get; set; }
[JsonProperty("conferencePassword")]
public string ConferencePassword { get; set; }
[JsonProperty("isOneButtonToPushMeeting")]
public bool IsOneButtonToPushMeeting { get; set; }
[JsonProperty("calls")]
public List<Call> Calls { get; private set; }
/// <summary>
/// Tracks the change types that have already been notified for
/// </summary>
[JsonIgnore]
public eMeetingEventChangeType NotifiedChangeTypes { get; set; }
[JsonIgnore] private readonly int _joinableCooldownSeconds;
public Meeting()
{
Calls = new List<Call>();
_joinableCooldownSeconds = 300;
}
public Meeting(int joinableCooldownSeconds)
{
Calls = new List<Call>();
_joinableCooldownSeconds = joinableCooldownSeconds;
}
#region Overrides of Object
public override string ToString()
{
return String.Format("{0}:{1}: {2}-{3}", Title, Agenda, StartTime, EndTime);
}
#endregion
}
public class Call
{
public string Number { get; set; }
public string Protocol { get; set; }
public string CallRate { get; set; }
public string CallType { get; set; }
}
public class MeetingEventArgs : EventArgs
{
public eMeetingEventChangeType ChangeType { get; set; }
public Meeting Meeting { get; set; }
}
}

View file

@ -0,0 +1,396 @@
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 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<string, TesiraForteLevelControl> LevelControlPoints { get; private set; }
public bool isSubscribed;
private CTimer SubscriptionTimer;
private CrestronQueue CommandQueue;
private bool CommandQueueInProgress = false;
//new public Dictionary<string, DspControlPoint> DialerControlPoints { get; private set; }
//new public Dictionary<string, DspControlPoint> SwitcherControlPoints { get; private set; }
/// <summary>
/// Shows received lines as hex
/// </summary>
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<GenericSocketStatusChageEventArgs>(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<string, TesiraForteLevelControl>();
foreach (KeyValuePair<string, BiampTesiraForteLevelControlBlockConfig> 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;
}
}
/// <summary>
/// Initiates the subscription process to the DSP
/// </summary>
private void SubscribeToAttributes()
{
SendLine("SESSION set verbose true");
foreach (KeyValuePair<string, TesiraForteLevelControl> level in LevelControlPoints)
{
level.Value.Subscribe();
}
if (!CommandQueueInProgress)
SendNextQueuedCommand();
ResetSubscriptionTimer();
}
/// <summary>
/// Resets or Sets the subscription timer
/// </summary>
private void ResetSubscriptionTimer()
{
isSubscribed = true;
if (SubscriptionTimer != null)
{
SubscriptionTimer = new CTimer(o => SubscribeToAttributes(), 30000);
SubscriptionTimer.Reset();
}
}
/// <summary>
/// Handles a response message from the DSP
/// </summary>
/// <param name="dev"></param>
/// <param name="args"></param>
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<string, TesiraForteLevelControl> 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);
}
}
/// <summary>
/// Sends a command to the DSP (with delimiter appended)
/// </summary>
/// <param name="s">Command to send</param>
public void SendLine(string s)
{
Communication.SendText(s + "\x0a");
}
/// <summary>
/// Adds a command from a child module to the queue
/// </summary>
/// <param name="command">Command object from child module</param>
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();
}
/// <summary>
/// Adds a raw string command to the queue
/// </summary>
/// <param name="command"></param>
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();
}
/// <summary>
/// Sends the next queued command to the DSP
/// </summary>
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);
}
}
}
/// <summary>
/// Sends a command to execute a preset
/// </summary>
/// <param name="name">Preset Name</param>
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<BiampTesiraForteDsp>
{
public BiampTesiraForteDspFactory()
{
TypeNames = new List<string>() {"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<BiampTesiraFortePropertiesConfig>(
dc.Properties.ToString());
return new BiampTesiraForteDsp(dc.Key, dc.Name, comm, props);
}
}
}

View file

@ -0,0 +1,379 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using System.Text.RegularExpressions;
namespace PepperDash.Essentials.Devices.Common.DSP
{
public interface IBiampTesiraDspLevelControl : IBasicVolumeWithFeedback
{
/// <summary>
/// In BiAmp: Instance Tag, QSC: Named Control, Polycom:
/// </summary>
string ControlPointTag { get; }
int Index1 { get; }
int Index2 { get; }
bool HasMute { get; }
bool HasLevel { get; }
bool AutomaticUnmuteOnVolumeUp { get; }
}
public class TesiraForteLevelControl : TesiraForteControlPoint, IBiampTesiraDspLevelControl, IKeyed
{
bool _IsMuted;
ushort _VolumeLevel;
public BoolFeedback MuteFeedback { get; private set; }
public IntFeedback VolumeLevelFeedback { get; private set; }
public bool Enabled { get; set; }
public string ControlPointTag { get { return base.InstanceTag; } }
/// <summary>
/// Used for to identify level subscription values
/// </summary>
public string LevelCustomName { get; private set; }
/// <summary>
/// Used for to identify mute subscription values
/// </summary>
public string MuteCustomName { get; private set; }
/// <summary>
/// Minimum fader level
/// </summary>
double MinLevel;
/// <summary>
/// Maximum fader level
/// </summary>
double MaxLevel;
/// <summary>
/// Checks if a valid subscription string has been recieved for all subscriptions
/// </summary>
public bool IsSubsribed
{
get
{
bool isSubscribed = false;
if (HasMute && MuteIsSubscribed)
isSubscribed = true;
if (HasLevel && LevelIsSubscribed)
isSubscribed = true;
return isSubscribed;
}
}
public bool AutomaticUnmuteOnVolumeUp { get; private set; }
public bool HasMute { get; private set; }
public bool HasLevel { get; private set; }
bool MuteIsSubscribed;
bool LevelIsSubscribed;
//public TesiraForteLevelControl(string label, string id, int index1, int index2, bool hasMute, bool hasLevel, BiampTesiraForteDsp parent)
// : base(id, index1, index2, parent)
//{
// Initialize(label, hasMute, hasLevel);
//}
public TesiraForteLevelControl(string key, BiampTesiraForteLevelControlBlockConfig config, BiampTesiraForteDsp parent)
: base(config.InstanceTag, config.Index1, config.Index2, parent)
{
Initialize(key, config.Label, config.HasMute, config.HasLevel);
}
/// <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;
}
public void Subscribe()
{
// Do subscriptions and blah blah
// Subscribe to mute
if (this.HasMute)
{
MuteCustomName = string.Format("{0}~mute{1}", this.InstanceTag, this.Index1);
SendSubscriptionCommand(MuteCustomName, "mute", 500);
}
// Subscribe to level
if (this.HasLevel)
{
LevelCustomName = string.Format("{0}~level{1}", this.InstanceTag, this.Index1);
SendSubscriptionCommand(LevelCustomName, "level", 250);
SendFullCommand("get", "minLevel", null);
SendFullCommand("get", "maxLevel", null);
}
}
/// <summary>
/// Parses the response from the DspBase
/// </summary>
/// <param name="customName"></param>
/// <param name="value"></param>
public void ParseSubscriptionMessage(string customName, string value)
{
// Check for valid subscription response
if (this.HasMute && customName == MuteCustomName)
{
//if (value.IndexOf("+OK") > -1)
//{
// int pointer = value.IndexOf(" +OK");
// MuteIsSubscribed = true;
// // Removes the +OK
// value = value.Substring(0, value.Length - (value.Length - (pointer - 1)));
//}
if (value.IndexOf("true") > -1)
{
_IsMuted = true;
MuteIsSubscribed = true;
}
else if (value.IndexOf("false") > -1)
{
_IsMuted = false;
MuteIsSubscribed = true;
}
MuteFeedback.FireUpdate();
}
else if (this.HasLevel && customName == LevelCustomName)
{
//if (value.IndexOf("+OK") > -1)
//{
// int pointer = value.IndexOf(" +OK");
// LevelIsSubscribed = true;
//}
var _value = Double.Parse(value);
_VolumeLevel = (ushort)Scale(_value, MinLevel, MaxLevel, 0, 65535);
LevelIsSubscribed = true;
VolumeLevelFeedback.FireUpdate();
}
}
/// <summary>
/// Parses a non subscription response
/// </summary>
/// <param name="attributeCode">The attribute code of the command</param>
/// <param name="message">The message to parse</param>
public override void ParseGetMessage(string attributeCode, string message)
{
try
{
// Parse an "+OK" message
string pattern = @"\+OK ""value"":(.*)";
Match match = Regex.Match(message, pattern);
if (match.Success)
{
string value = match.Groups[1].Value;
Debug.Console(1, this, "Response: '{0}' Value: '{1}'", attributeCode, value);
if (message.IndexOf("\"value\":") > -1)
{
switch (attributeCode)
{
case "minLevel":
{
MinLevel = Double.Parse(value);
Debug.Console(1, this, "MinLevel is '{0}'", MinLevel);
break;
}
case "maxLevel":
{
MaxLevel = Double.Parse(value);
Debug.Console(1, this, "MaxLevel is '{0}'", MaxLevel);
break;
}
default:
{
Debug.Console(2, "Response does not match expected attribute codes: '{0}'", message);
break;
}
}
}
}
}
catch (Exception e)
{
Debug.Console(2, "Unable to parse message: '{0}'\n{1}", message, e);
}
}
/// <summary>
/// Turns the mute off
/// </summary>
public void MuteOff()
{
SendFullCommand("set", "mute", "false");
}
/// <summary>
/// Turns the mute on
/// </summary>
public void MuteOn()
{
SendFullCommand("set", "mute", "true");
}
/// <summary>
/// Sets the volume to a specified level
/// </summary>
/// <param name="level"></param>
public void SetVolume(ushort level)
{
Debug.Console(1, this, "volume: {0}", level);
// Unmute volume if new level is higher than existing
if (level > _VolumeLevel && AutomaticUnmuteOnVolumeUp)
if(_IsMuted)
MuteOff();
double volumeLevel = Scale(level, 0, 65535, MinLevel, MaxLevel);
SendFullCommand("set", "level", string.Format("{0:0.000000}", volumeLevel));
}
/// <summary>
/// Toggles mute status
/// </summary>
public void MuteToggle()
{
SendFullCommand("toggle", "mute", "");
}
/// <summary>
/// Decrements volume level
/// </summary>
/// <param name="pressRelease"></param>
public void VolumeDown(bool pressRelease)
{
SendFullCommand("decrement", "level", "");
}
/// <summary>
/// Increments volume level
/// </summary>
/// <param name="pressRelease"></param>
public void VolumeUp(bool pressRelease)
{
SendFullCommand("increment", "level", "");
if (AutomaticUnmuteOnVolumeUp)
if (!_IsMuted)
MuteOff();
}
///// <summary>
///// Scales the input from the input range to the output range
///// </summary>
///// <param name="input"></param>
///// <param name="inMin"></param>
///// <param name="inMax"></param>
///// <param name="outMin"></param>
///// <param name="outMax"></param>
///// <returns></returns>
//int Scale(int input, int inMin, int inMax, int outMin, int outMax)
//{
// Debug.Console(1, this, "Scaling (int) input '{0}' with min '{1}'/max '{2}' to output range min '{3}'/max '{4}'", input, inMin, inMax, outMin, outMax);
// int inputRange = inMax - inMin;
// int outputRange = outMax - outMin;
// var output = (((input-inMin) * outputRange) / inputRange ) - outMin;
// Debug.Console(1, this, "Scaled output '{0}'", output);
// return output;
//}
/// <summary>
/// Scales the input from the input range to the output range
/// </summary>
/// <param name="input"></param>
/// <param name="inMin"></param>
/// <param name="inMax"></param>
/// <param name="outMin"></param>
/// <param name="outMax"></param>
/// <returns></returns>
double Scale(double input, double inMin, double inMax, double outMin, double outMax)
{
Debug.Console(1, this, "Scaling (double) input '{0}' with min '{1}'/max '{2}' to output range min '{3}'/max '{4}'",input ,inMin ,inMax ,outMin, outMax);
double inputRange = inMax - inMin;
if (inputRange <= 0)
{
throw new ArithmeticException(string.Format("Invalid Input Range '{0}' for Scaling. Min '{1}' Max '{2}'.", inputRange, inMin, inMax));
}
double outputRange = outMax - outMin;
var output = (((input - inMin) * outputRange) / inputRange) + outMin;
Debug.Console(1, this, "Scaled output '{0}'", output);
return output;
}
}
}

View file

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Devices.Common.DSP
{
/// <summary>
///
/// </summary>
public class BiampTesiraFortePropertiesConfig
{
public CommunicationMonitorConfig CommunicationMonitorProperties { get; set; }
public ControlPropertiesConfig Control { get; set; }
/// <summary>
/// These are key-value pairs, string id, string type.
/// Valid types are level and mute.
/// Need to include the index values somehow
/// </summary>
public Dictionary<string, BiampTesiraForteLevelControlBlockConfig> LevelControlBlocks { get; set; }
// public Dictionary<string, BiampTesiraForteDialerControlBlockConfig> DialerControlBlocks {get; set;}
}
public class BiampTesiraForteLevelControlBlockConfig
{
public bool Enabled { get; set; }
public string Label { get; set; }
public string InstanceTag { get; set; }
public int Index1 { get; set; }
public int Index2 { get; set; }
public bool HasMute { get; set; }
public bool HasLevel { get; set; }
}
}

View file

@ -0,0 +1,115 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Devices.Common.DSP
{
public abstract class TesiraForteControlPoint : DspControlPoint
{
public string Key { get; protected set; }
public string InstanceTag { get; set; }
public int Index1 { get; private set; }
public int Index2 { get; private set; }
public BiampTesiraForteDsp Parent { get; private set; }
public bool IsSubscribed { get; protected set; }
protected TesiraForteControlPoint(string id, int index1, int index2, BiampTesiraForteDsp parent)
{
InstanceTag = id;
Index1 = index1;
Index2 = index2;
Parent = parent;
}
virtual public void Initialize()
{
}
/// <summary>
/// Sends a command to the DSP
/// </summary>
/// <param name="command">command</param>
/// <param name="attribute">attribute code</param>
/// <param name="value">value (use "" if not applicable)</param>
public virtual void SendFullCommand(string command, string attributeCode, string value)
{
// Command Format: InstanceTag get/set/toggle/increment/decrement/subscribe/unsubscribe attributeCode [index] [value]
// Ex: "RoomLevel set level 1.00"
string cmd;
if (attributeCode == "level" || attributeCode == "mute" || attributeCode == "minLevel" || attributeCode == "maxLevel" || attributeCode == "label" || attributeCode == "rampInterval" || attributeCode == "rampStep")
{
//Command requires Index
if (String.IsNullOrEmpty(value))
{
// format command without value
cmd = string.Format("{0} {1} {2} {3}", InstanceTag, command, attributeCode, Index1);
}
else
{
// format commadn with value
cmd = string.Format("{0} {1} {2} {3} {4}", InstanceTag, command, attributeCode, Index1, value);
}
}
else
{
//Command does not require Index
if (String.IsNullOrEmpty(value))
{
cmd = string.Format("{0} {1} {2} {3}", InstanceTag, command, attributeCode, value);
}
else
{
cmd = string.Format("{0} {1} {2}", InstanceTag, command, attributeCode);
}
}
if (command == "get")
{
// This command will generate a return value response so it needs to be queued
Parent.EnqueueCommand(new BiampTesiraForteDsp.QueuedCommand{ Command = cmd, AttributeCode = attributeCode, ControlPoint = this });
}
else
{
// This command will generate a simple "+OK" response and doesn't need to be queued
Parent.SendLine(cmd);
}
}
virtual public void ParseGetMessage(string attributeCode, string message)
{
}
public virtual void SendSubscriptionCommand(string customName, string attributeCode, int responseRate)
{
// Subscription string format: InstanceTag subscribe attributeCode Index1 customName responseRate
// Ex: "RoomLevel subscribe level 1 MyRoomLevel 500"
string cmd;
if (responseRate > 0)
{
cmd = string.Format("{0} subscribe {1} {2} {3} {4}", InstanceTag, attributeCode, Index1, customName, responseRate);
}
else
{
cmd = string.Format("{0} subscribe {1} {2} {3}", InstanceTag, attributeCode, Index1, customName);
}
Parent.SendLine(cmd);
}
}
}

View file

@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Devices.Common.DSP
{
//QUESTIONS:
//When subscribing, just use the Instance ID for Custom Name?
//Verbose on subscriptions?
//! "publishToken":"name" "value":-77.0
//! "myLevelName" -77
//public class TesiraForteMuteControl : IDspLevelControl
//{
// BiampTesiraForteDsp Parent;
// bool _IsMuted;
// ushort _VolumeLevel;
// public TesiraForteMuteControl(string id, BiampTesiraForteDsp parent)
// : base(id)
// {
// Parent = parent;
// }
// public void Initialize()
// {
// }
// protected override Func<bool> MuteFeedbackFunc
// {
// get { return () => _IsMuted; }
// }
// protected override Func<int> VolumeLevelFeedbackFunc
// {
// get { return () => _VolumeLevel; }
// }
// public override void MuteOff()
// {
// throw new NotImplementedException();
// }
// public override void MuteOn()
// {
// throw new NotImplementedException();
// }
// public override void SetVolume(ushort level)
// {
// throw new NotImplementedException();
// }
// public override void MuteToggle()
// {
// }
// public override void VolumeDown(bool pressRelease)
// {
// throw new NotImplementedException();
// }
// public override void VolumeUp(bool pressRelease)
// {
// throw new NotImplementedException();
// }
//}
}

View file

@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Essentials.Devices.Common.Codec;
using PepperDash.Core;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Devices.Common.DSP
{
public abstract class DspBase : EssentialsDevice
{
public Dictionary<string, DspControlPoint> LevelControlPoints { get; private set; }
public Dictionary<string, DspControlPoint> DialerControlPoints { get; private set; }
public Dictionary<string, DspControlPoint> SwitcherControlPoints { get; private set; }
public DspBase(string key, string name) :
base(key, name)
{
}
// in audio call feedback
// VOIP
// Phone dialer
}
// Fusion
// Privacy state
// Online state
// level/mutes ?
// AC Log call stats
// Typical presets:
// call default preset to restore levels and mutes
public abstract class DspControlPoint
{
string Key { get; set; }
}
public class DspDialerBase
{
}
// Main program
// VTC
// ATC
// Mics, unusual
}

View file

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Devices.Common.DSP
{
public class SoundStructureBasics
{
// public Dictionary<string, IBiampTesiraDspLevelControl> Levels { get; private set; }
}
}

View file

@ -0,0 +1,455 @@
extern alias Full;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using Full.Newtonsoft.Json;
using Full.Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Routing;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.Bridges;
namespace PepperDash.Essentials.Devices.Common
{
public class IRBlurayBase : EssentialsBridgeableDevice, IDiscPlayerControls, IUiDisplayInfo, IRoutingOutputs, IUsageTracking
{
public IrOutputPortController IrPort { get; private set; }
public uint DisplayUiType { get { return DisplayUiConstants.TypeBluray; } }
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 };
}
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{
var joinMap = new IRBlurayBaseJoinMap(joinStart);
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<IRBlurayBaseJoinMap>(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 powerDev = this as IHasPowerControl;
if (powerDev != null)
{
trilist.SetSigTrueAction(joinMap.PowerOn.JoinNumber, powerDev.PowerOn);
trilist.SetSigTrueAction(joinMap.PowerOff.JoinNumber, powerDev.PowerOff);
trilist.SetSigTrueAction(joinMap.PowerToggle.JoinNumber, powerDev.PowerToggle);
}
var dpadDev = this as IDPad;
if (dpadDev != null)
{
trilist.SetBoolSigAction(joinMap.Up.JoinNumber, dpadDev.Up);
trilist.SetBoolSigAction(joinMap.Down.JoinNumber, dpadDev.Down);
trilist.SetBoolSigAction(joinMap.Left.JoinNumber, dpadDev.Left);
trilist.SetBoolSigAction(joinMap.Right.JoinNumber, dpadDev.Right);
trilist.SetBoolSigAction(joinMap.Select.JoinNumber, dpadDev.Select);
trilist.SetBoolSigAction(joinMap.Menu.JoinNumber, dpadDev.Menu);
trilist.SetBoolSigAction(joinMap.Exit.JoinNumber, dpadDev.Exit);
}
var channelDev = this as IChannel;
if (channelDev != null)
{
trilist.SetBoolSigAction(joinMap.ChannelUp.JoinNumber, channelDev.ChannelUp);
trilist.SetBoolSigAction(joinMap.ChannelDown.JoinNumber, channelDev.ChannelDown);
trilist.SetBoolSigAction(joinMap.LastChannel.JoinNumber, channelDev.LastChannel);
trilist.SetBoolSigAction(joinMap.Guide.JoinNumber, channelDev.Guide);
trilist.SetBoolSigAction(joinMap.Info.JoinNumber, channelDev.Info);
trilist.SetBoolSigAction(joinMap.Exit.JoinNumber, channelDev.Exit);
}
var colorDev = this as IColor;
if (colorDev != null)
{
trilist.SetBoolSigAction(joinMap.Red.JoinNumber, colorDev.Red);
trilist.SetBoolSigAction(joinMap.Green.JoinNumber, colorDev.Green);
trilist.SetBoolSigAction(joinMap.Yellow.JoinNumber, colorDev.Yellow);
trilist.SetBoolSigAction(joinMap.Blue.JoinNumber, colorDev.Blue);
}
var keypadDev = this as ISetTopBoxNumericKeypad;
if (keypadDev != null)
{
trilist.StringInput[joinMap.KeypadAccessoryButton1Label.JoinNumber].StringValue = keypadDev.KeypadAccessoryButton1Label;
trilist.StringInput[joinMap.KeypadAccessoryButton2Label.JoinNumber].StringValue = keypadDev.KeypadAccessoryButton2Label;
trilist.BooleanInput[joinMap.HasKeypadAccessoryButton1.JoinNumber].BoolValue = keypadDev.HasKeypadAccessoryButton1;
trilist.BooleanInput[joinMap.HasKeypadAccessoryButton2.JoinNumber].BoolValue = keypadDev.HasKeypadAccessoryButton2;
trilist.SetBoolSigAction(joinMap.Digit0.JoinNumber, keypadDev.Digit0);
trilist.SetBoolSigAction(joinMap.Digit1.JoinNumber, keypadDev.Digit1);
trilist.SetBoolSigAction(joinMap.Digit2.JoinNumber, keypadDev.Digit2);
trilist.SetBoolSigAction(joinMap.Digit3.JoinNumber, keypadDev.Digit3);
trilist.SetBoolSigAction(joinMap.Digit4.JoinNumber, keypadDev.Digit4);
trilist.SetBoolSigAction(joinMap.Digit5.JoinNumber, keypadDev.Digit5);
trilist.SetBoolSigAction(joinMap.Digit6.JoinNumber, keypadDev.Digit6);
trilist.SetBoolSigAction(joinMap.Digit7.JoinNumber, keypadDev.Digit7);
trilist.SetBoolSigAction(joinMap.Digit8.JoinNumber, keypadDev.Digit8);
trilist.SetBoolSigAction(joinMap.Digit9.JoinNumber, keypadDev.Digit9);
trilist.SetBoolSigAction(joinMap.KeypadAccessoryButton1Press.JoinNumber, keypadDev.KeypadAccessoryButton1);
trilist.SetBoolSigAction(joinMap.KeypadAccessoryButton2Press.JoinNumber, keypadDev.KeypadAccessoryButton1);
trilist.SetBoolSigAction(joinMap.KeypadEnter.JoinNumber, keypadDev.KeypadEnter);
}
var transportDev = this as ITransport;
if (transportDev != null)
{
trilist.SetBoolSigAction(joinMap.Play.JoinNumber, transportDev.Play);
trilist.SetBoolSigAction(joinMap.Pause.JoinNumber, transportDev.Pause);
trilist.SetBoolSigAction(joinMap.Rewind.JoinNumber, transportDev.Rewind);
trilist.SetBoolSigAction(joinMap.FFwd.JoinNumber, transportDev.FFwd);
trilist.SetBoolSigAction(joinMap.ChapMinus.JoinNumber, transportDev.ChapMinus);
trilist.SetBoolSigAction(joinMap.ChapPlus.JoinNumber, transportDev.ChapPlus);
trilist.SetBoolSigAction(joinMap.Stop.JoinNumber, transportDev.Stop);
trilist.SetBoolSigAction(joinMap.Record.JoinNumber, transportDev.Record);
}
}
#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);
}
/// <summary>
/// Defaults to true
/// </summary>
public bool HasKeypadAccessoryButton1 { get; set; }
/// <summary>
/// Defaults to "-"
/// </summary>
public string KeypadAccessoryButton1Label { get; set; }
/// <summary>
/// Defaults to "Dash"
/// </summary>
public string KeypadAccessoryButton1Command { get; set; }
public void KeypadAccessoryButton1(bool pressRelease)
{
IrPort.PressRelease(KeypadAccessoryButton1Command, pressRelease);
}
/// <summary>
/// Defaults to true
/// </summary>
public bool HasKeypadAccessoryButton2 { get; set; }
/// <summary>
/// Defaults to "Enter"
/// </summary>
public string KeypadAccessoryButton2Label { get; set; }
/// <summary>
/// Defaults to "Enter"
/// </summary>
public string KeypadAccessoryButton2Command { get; set; }
public void KeypadAccessoryButton2(bool pressRelease)
{
IrPort.PressRelease(KeypadAccessoryButton2Command, 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 HdmiOut { get; private set; }
public RoutingOutputPort AnyAudioOut { get; private set; }
public RoutingPortCollection<RoutingOutputPort> OutputPorts { get; private set; }
#endregion
#region IPower Members
public void PowerOn()
{
IrPort.Pulse(IROutputStandardCommands.IROut_POWER_ON, 200);
_PowerIsOn = true;
}
public void PowerOff()
{
IrPort.Pulse(IROutputStandardCommands.IROut_POWER_OFF, 200);
_PowerIsOn = false;
}
public void PowerToggle()
{
IrPort.Pulse(IROutputStandardCommands.IROut_POWER, 200);
_PowerIsOn = false;
}
public BoolFeedback PowerIsOnFeedback { get; set; }
bool _PowerIsOn;
#endregion
#region ITransport Members
public void Play(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_PLAY, pressRelease);
}
public void Pause(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_PAUSE, pressRelease);
}
public void Rewind(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_RSCAN, pressRelease);
}
public void FFwd(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_FSCAN, pressRelease);
}
public void ChapMinus(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_TRACK_MINUS, pressRelease);
}
public void ChapPlus(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_TRACK_PLUS, pressRelease);
}
public void Stop(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_STOP, pressRelease);
}
public void Record(bool pressRelease)
{
}
#endregion
#region IUsageTracking Members
public UsageTracking UsageTracker { get; set; }
#endregion
}
public class IRBlurayBaseFactory : EssentialsDeviceFactory<IRBlurayBase>
{
public IRBlurayBaseFactory()
{
TypeNames = new List<string>() { "discplayer", "bluray" };
}
public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
Debug.Console(1, "Factory Attempting to create new IRBlurayPlayer Device");
if (dc.Properties["control"]["method"].Value<string>() == "ir")
{
var irCont = IRPortHelper.GetIrOutputPortController(dc);
return new IRBlurayBase(dc.Key, dc.Name, irCont);
}
else if (dc.Properties["control"]["method"].Value<string>() == "com")
{
Debug.Console(0, "[{0}] COM Device type not implemented YET!", dc.Key);
}
return null;
}
}
}

View file

@ -0,0 +1,749 @@
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;
namespace PepperDash.Essentials.Devices.Displays
{
/// <summary>
///
/// </summary>
public class AvocorDisplay : TwoWayDisplayBase, IBasicVolumeWithFeedback, ICommunicationMonitor, IInputDisplayPort1,
IInputHdmi1, IInputHdmi2, IInputHdmi3, IInputHdmi4, IInputVga1, IBridgeAdvanced
{
public IBasicCommunication Communication { get; private set; }
public CommunicationGather PortGather { get; private set; }
public StatusMonitorBase CommunicationMonitor { get; private set; }
public byte ID { get; private set; }
/// <summary>
/// 0x08
/// </summary>
const byte InputVga1Value = 0x00;
/// <summary>
/// 0x09
/// </summary>
const byte InputHdmi1Value = 0x09;
/// <summary>
/// 0x0a
/// </summary>
const byte InputHdmi2Value = 0x0a;
/// <summary>
/// 0x0b
/// </summary>
const byte InputHdmi3Value = 0x0b;
/// <summary>
/// 0x0c
/// </summary>
const byte InputHdmi4Value = 0x0c;
/// <summary>
/// 0c0d
/// </summary>
const byte InputDisplayPort1Value = 0x0d;
/// <summary>
/// 0x0e
/// </summary>
const byte InputIpcOpsValue = 0x0e;
/// <summary>
/// 0x11
/// </summary>
const byte InputHdmi5Value = 0x11;
/// <summary>
/// 0x12
/// </summary>
const byte InputMediaPlayerValue = 0x12;
bool _PowerIsOn;
bool _IsWarmingUp;
bool _IsCoolingDown;
ushort _VolumeLevelForSig;
int _LastVolumeSent;
ushort _PreMuteVolumeLevel;
bool _IsMuted;
RoutingInputPort _CurrentInputPort;
ActionIncrementer VolumeIncrementer;
bool VolumeIsRamping;
public bool IsInStandby { get; private set; }
protected override Func<bool> PowerIsOnFeedbackFunc { get { return () => _PowerIsOn; } }
protected override Func<bool> IsCoolingDownFeedbackFunc { get { return () => _IsCoolingDown; } }
protected override Func<bool> IsWarmingUpFeedbackFunc { get { return () => _IsWarmingUp; } }
protected override Func<string> CurrentInputFeedbackFunc { get { return () => _CurrentInputPort.Key; } }
/// <summary>
/// Constructor for IBasicCommunication
/// </summary>
public AvocorDisplay(string key, string name, IBasicCommunication comm, string id)
: base(key, name)
{
Communication = comm;
//Communication.BytesReceived += new EventHandler<GenericCommMethodReceiveBytesArgs>(Communication_BytesReceived);
PortGather = new CommunicationGather(Communication, '\x08');
PortGather.IncludeDelimiter = true;
PortGather.LineReceived += new EventHandler<GenericCommMethodReceiveTextArgs>(PortGather_LineReceived);
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();
}
/// <summary>
/// Constructor for TCP
/// </summary>
public AvocorDisplay(string key, string name, string hostname, int port, string id)
: base(key, name)
{
Communication = new GenericTcpIpClient(key + "-tcp", hostname, port, 5000);
PortGather = new CommunicationGather(Communication, '\x0d');
PortGather.IncludeDelimiter = true;
PortGather.LineReceived += new EventHandler<GenericCommMethodReceiveTextArgs>(PortGather_LineReceived);
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();
}
/// <summary>
/// Constructor for COM
/// </summary>
public AvocorDisplay(string key, string name, ComPort port, ComPort.ComPortSpec spec, string id)
: base(key, name)
{
Communication = new ComPortController(key + "-com", port, spec);
PortGather = new CommunicationGather(Communication, '\x0d');
PortGather.IncludeDelimiter = true;
PortGather.LineReceived += new EventHandler<GenericCommMethodReceiveTextArgs>(PortGather_LineReceived);
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, 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);
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public override bool CustomActivate()
{
Communication.Connect();
var socket = Communication as ISocketStatus;
if (socket != null)
{
socket.ConnectionChange += new EventHandler<GenericSocketStatusChageEventArgs>(socket_ConnectionChange);
}
CommunicationMonitor.StatusChange += (o, a) => { Debug.Console(2, this, "Communication monitor state: {0}", CommunicationMonitor.Status); };
CommunicationMonitor.Start();
StatusGet();
return true;
}
public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{
LinkDisplayToApi(this, trilist, joinStart, joinMapKey, bridge);
}
void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e)
{
if (e.Client.IsConnected)
StatusGet();
}
public override FeedbackCollection<Feedback> Feedbacks
{
get
{
var list = base.Feedbacks;
list.AddRange(new List<Feedback>
{
VolumeLevelFeedback,
MuteFeedback,
CurrentInputFeedback
});
return list;
}
}
///// <summary>
///// /
///// </summary>
///// <param name="sender"></param>
//void Communication_BytesReceived(object sender, GenericCommMethodReceiveBytesArgs e)
//{
// // 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);
// if (Debug.Level == 2) // This check is here to prevent following string format from building unnecessarily on level 0 or 1
// Debug.Console(2, this, "Received:{0}", ComTextHelper.GetEscapedText(newBytes));
// // 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
// UpdateInputFb(message[5]);
// 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;
//}
void PortGather_LineReceived(object sender, GenericCommMethodReceiveTextArgs e)
{
Debug.Console(1, this, "Receivied: '{0}'", ComTextHelper.GetEscapedText(e.Text));
if (e.Text.IndexOf("\x50\x4F\x57") > -1)
{
// Power Status Response
var value = e.Text.ToCharArray();
switch (value[6])
{
case '\x00':
{
_PowerIsOn = false;
break;
}
case '\x01':
{
_PowerIsOn = true;
break;
}
}
PowerIsOnFeedback.FireUpdate();
Debug.Console(1, this, "PowerIsOn State: {0}", PowerIsOnFeedback.BoolValue);
}
else if (e.Text.IndexOf("\x4D\x49\x4E") > -1)
{
var value = e.Text.ToCharArray();
var b = value[6];
var newInput = InputPorts.FirstOrDefault(i => i.FeedbackMatchObject.Equals(b));
if (newInput != null && newInput != _CurrentInputPort)
{
_CurrentInputPort = newInput;
CurrentInputFeedback.FireUpdate();
Debug.Console(1, this, "Current Input: {0}", CurrentInputFeedback.StringValue);
}
}
else if (e.Text.IndexOf("\x56\x4F\x4C") > -1)
{
// Volume Status Response
var value = e.Text.ToCharArray();
var b = value[6];
var newVol = (ushort)NumericalHelpers.Scale((double)b, 0, 100, 0, 65535);
if (!VolumeIsRamping)
_LastVolumeSent = newVol;
if (newVol != _VolumeLevelForSig)
{
_VolumeLevelForSig = newVol;
VolumeLevelFeedback.FireUpdate();
if (_VolumeLevelForSig > 0)
_IsMuted = false;
else
_IsMuted = true;
MuteFeedback.FireUpdate();
Debug.Console(1, this, "Volume Level: {0}", VolumeLevelFeedback.IntValue);
}
}
}
/// <summary>
///
/// </summary>
void UpdatePowerFB(byte powerByte)
{
var newVal = powerByte == 1;
if (newVal != _PowerIsOn)
{
_PowerIsOn = newVal;
PowerIsOnFeedback.FireUpdate();
}
}
/// <summary>
/// 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
/// </summary>
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);
}
/// <summary>
///
/// </summary>
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();
}
}
/// <summary>
///
/// </summary>
void UpdateMuteFb(byte b)
{
var newMute = b == 1;
if (newMute != _IsMuted)
{
_IsMuted = newMute;
MuteFeedback.FireUpdate();
}
}
/// <summary>
///
/// </summary>
void UpdateInputFb(byte b)
{
var newInput = InputPorts.FirstOrDefault(i => i.FeedbackMatchObject.Equals(b));
if (newInput != null && newInput != _CurrentInputPort)
{
_CurrentInputPort = newInput;
CurrentInputFeedback.FireUpdate();
}
}
/// <summary>
/// Formats an outgoing message. Replaces third byte with ID and replaces last byte with checksum
/// </summary>
/// <param name="b"></param>
void SendBytes(byte[] b)
{
b[1] = ID;
var command = b.ToString();
Debug.Console(1, this, "Sending: '{0}'",ComTextHelper.GetEscapedText(b));
Communication.SendBytes(b);
}
/// <summary>
///
/// </summary>
public void StatusGet()
{
PowerGet();
CrestronEnvironment.Sleep(100);
InputGet();
CrestronEnvironment.Sleep(100);
VolumeGet();
}
/// <summary>
///
/// </summary>
public override void PowerOn()
{
//Send(PowerOnCmd);
SendBytes(new byte[] { 0x07, ID, 0x02, 0x50, 0x4F, 0x57, 0x01, 0x08, 0x0d });
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);
}
}
/// <summary>
///
/// </summary>
public override void PowerOff()
{
// 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[] { 0x07, ID, 0x02, 0x50, 0x4F, 0x57, 0x00, 0x08, 0x0d });
_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[] { 0x07, ID, 0x01, 0x50, 0x4F, 0x57, 0x08, 0x0d });
}
public void InputHdmi1()
{
SendBytes(new byte[] { 0x07, ID, 0x02, 0x4D, 0x49, 0x4E, InputHdmi1Value, 0x08, 0x0d });
}
public void InputHdmi2()
{
SendBytes(new byte[] { 0x07, ID, 0x02, 0x4D, 0x49, 0x4E, InputHdmi2Value, 0x08, 0x0d });
}
public void InputHdmi3()
{
SendBytes(new byte[] { 0x07, ID, 0x02, 0x4D, 0x49, 0x4E, InputHdmi3Value, 0x08, 0x0d });
}
public void InputHdmi4()
{
SendBytes(new byte[] { 0x07, ID, 0x02, 0x4D, 0x49, 0x4E, InputHdmi4Value, 0x08, 0x0d });
}
public void InputHdmi5()
{
SendBytes(new byte[] { 0x07, ID, 0x02, 0x4D, 0x49, 0x4E, InputHdmi5Value, 0x08, 0x0d });
}
public void InputDisplayPort1()
{
SendBytes(new byte[] { 0x07, ID, 0x02, 0x4D, 0x49, 0x4E, InputDisplayPort1Value, 0x08, 0x0d });
}
public void InputVga1()
{
SendBytes(new byte[] { 0x07, ID, 0x02, 0x4D, 0x49, 0x4E, InputVga1Value, 0x08, 0x0d });
}
public void InputIpcOps()
{
SendBytes(new byte[] { 0x07, ID, 0x02, 0x4D, 0x49, 0x4E, InputIpcOpsValue, 0x08, 0x0d });
}
public void InputMediaPlayer()
{
SendBytes(new byte[] { 0x07, ID, 0x02, 0x4D, 0x49, 0x4E, InputMediaPlayerValue, 0x08, 0x0d });
}
public void InputGet()
{
SendBytes(new byte[] { 0x07, ID, 0x01, 0x4D, 0x49, 0x4E, 0x08, 0x0d });
}
public void VolumeGet()
{
SendBytes(new byte[] { 0x07, ID, 0x01, 0x56, 0x4F, 0x4C, 0x08, 0x0d });
}
/// <summary>
/// Executes a switch, turning on display if necessary.
/// </summary>
/// <param name="selector"></param>
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<FeedbackEventArgs> 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();
}
}
/// <summary>
/// Scales the level to the range of the display and sends the command
/// </summary>
/// <param name="level"></param>
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[] { 0x07, ID, 0x02, 0x56, 0x4F, 0x4C, Convert.ToByte(scaled), 0x08, 0x0d });
}
#region IBasicVolumeWithFeedback Members
public IntFeedback VolumeLevelFeedback { get; private set; }
public BoolFeedback MuteFeedback { get; private set; }
/// <summary>
///
/// </summary>
public void MuteOff()
{
SetVolume(_PreMuteVolumeLevel);
}
/// <summary>
///
/// </summary>
public void MuteOn()
{
_PreMuteVolumeLevel = _VolumeLevelForSig;
SetVolume(0);
}
///// <summary>
/////
///// </summary>
//public void MuteGet()
//{
// SendBytes(new byte[] { 0x07, ID, 0x01, });
//}
#endregion
#region IBasicVolumeControls Members
/// <summary>
///
/// </summary>
public void MuteToggle()
{
if (_IsMuted)
MuteOff();
else
MuteOn();
}
/// <summary>
///
/// </summary>
/// <param name="pressRelease"></param>
public void VolumeDown(bool pressRelease)
{
if (pressRelease)
{
VolumeIncrementer.StartDown();
VolumeIsRamping = true;
}
else
{
VolumeIsRamping = false;
VolumeIncrementer.Stop();
}
}
/// <summary>
///
/// </summary>
/// <param name="pressRelease"></param>
public void VolumeUp(bool pressRelease)
{
if (pressRelease)
{
VolumeIncrementer.StartUp();
VolumeIsRamping = true;
}
else
{
VolumeIsRamping = false;
VolumeIncrementer.Stop();
}
}
#endregion
}
public class AvocorDisplayFactory : EssentialsDeviceFactory<AvocorDisplay>
{
public AvocorDisplayFactory()
{
TypeNames = new List<string>() { "avocorvtf" };
}
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 AvocorDisplay(dc.Key, dc.Name, comm, null);
else
return null;
}
}
}

View file

@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using PepperDash.Core;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Devices.Displays
{
[Obsolete("Please use TwoWayDisplayBase instead")]
public abstract class ComTcpDisplayBase : TwoWayDisplayBase
{
///// <summary>
///// Sets the communication method for this - swaps out event handlers and output handlers
///// </summary>
//public IBasicCommunication CommunicationMethod
//{
// get { return _CommunicationMethod; }
// set
// {
// if (_CommunicationMethod != null)
// _CommunicationMethod.BytesReceived -= this.CommunicationMethod_BytesReceived;
// // Outputs???
// _CommunicationMethod = value;
// if (_CommunicationMethod != null)
// _CommunicationMethod.BytesReceived += this.CommunicationMethod_BytesReceived;
// // Outputs?
// }
//}
//IBasicCommunication _CommunicationMethod;
public ComTcpDisplayBase(string key, string name)
: base(key, name)
{
}
//protected abstract void CommunicationMethod_BytesReceived(object sender, GenericCommMethodReceiveBytesArgs args);
}
}

View file

@ -0,0 +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(); }
}

View file

@ -0,0 +1,387 @@
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;
using Feedback = PepperDash.Essentials.Core.Feedback;
namespace PepperDash.Essentials.Devices.Displays
{
/// <summary>
///
/// </summary>
public class NecPSXMDisplay : TwoWayDisplayBase, IBasicVolumeWithFeedback, ICommunicationMonitor, IBridgeAdvanced
{
public IBasicCommunication Communication { get; private set; }
public CommunicationGather PortGather { get; private set; }
public StatusMonitorBase CommunicationMonitor { get; private set; }
#region Command constants
public const string InputGetCmd = "\x01\x30\x41\x30\x43\x30\x36\x02\x30\x30\x36\x30\x03\x03\x0D";
public const string Hdmi1Cmd = "\x01\x30\x41\x30\x45\x30\x41\x02\x30\x30\x36\x30\x30\x30\x31\x31\x03\x72\x0d";
public const string Hdmi2Cmd = "\x01\x30\x41\x30\x45\x30\x41\x02\x30\x30\x36\x30\x30\x30\x31\x32\x03\x71\x0D";
public const string Hdmi3Cmd = "\x01\x30\x41\x30\x45\x30\x41\x02\x30\x30\x36\x30\x30\x30\x38\x32\x03\x78\x0D";
public const string Hdmi4Cmd = "\x01\x30\x41\x30\x45\x30\x41\x02\x30\x30\x36\x30\x30\x30\x38\x33\x03\x79\x0D";
public const string Dp1Cmd = "\x01\x30\x41\x30\x45\x30\x41\x02\x30\x30\x36\x30\x30\x30\x30\x46\x03\x04\x0D";
public const string Dp2Cmd = "\x01\x30\x41\x30\x45\x30\x41\x02\x30\x30\x36\x30\x30\x30\x31\x30\x03\x73\x0D";
public const string Dvi1Cmd = "\x01\x30\x41\x30\x45\x30\x41\x02\x30\x30\x36\x30\x30\x30\x30\x33\x03\x71\x0d";
public const string Video1Cmd = "\x01\x30\x41\x30\x45\x30\x41\x02\x30\x30\x36\x30\x30\x30\x30\x35\x03\x77\x0D";
public const string VgaCmd = "\x01\x30\x41\x30\x45\x30\x41\x02\x30\x30\x36\x30\x30\x30\x30\x31\x03\x73\x0D";
public const string RgbCmd = "\x01\x30\x41\x30\x45\x30\x41\x02\x30\x30\x36\x30\x30\x30\x30\x32\x03\x70\x0D";
public const string PowerOnCmd = "\x01\x30\x41\x30\x41\x30\x43\x02\x43\x32\x30\x33\x44\x36\x30\x30\x30\x31\x03\x73\x0D";
public const string PowerOffCmd = "\x01\x30\x41\x30\x41\x30\x43\x02\x43\x32\x30\x33\x44\x36\x30\x30\x30\x34\x03\x76\x0D";
public const string PowerToggleIrCmd = "\x01\x30\x41\x30\x41\x30\x43\x02\x43\x32\x31\x30\x30\x30\x30\x33\x30\x33\x03\x02\x0D";
public const string MuteOffCmd = "\x01\x30\x41\x30\x45\x30\x41\x02\x30\x30\x38\x44\x30\x30\x30\x30\x03\x08\x0D";
public const string MuteOnCmd = "\x01\x30\x41\x30\x45\x30\x41\x02\x30\x30\x38\x44\x30\x30\x30\x31\x03\x09\x0D";
public const string MuteToggleIrCmd = "\x01\x30\x41\x30\x41\x30\x43\x02\x43\x32\x31\x30\x30\x30\x31\x42\x30\x33\x03\x72\x0D";
public const string MuteGetCmd = "\x01\x30\x41\x30\x43\x30\x36\x02\x30\x30\x38\x44\x03\x79\x0D";
public const string VolumeGetCmd = "\x01\x30\x41\x30\x43\x30\x36\x02\x30\x30\x36\x32\x03\x01\x0D";
public const string VolumeLevelPartialCmd = "\x01\x30\x41\x30\x45\x30\x41\x02\x30\x30\x36\x32"; //\x46\x46\x46\x46\x03\xNN\x0D
public const string VolumeUpCmd = "\x01\x30\x41\x30\x45\x30\x41\x02\x31\x30\x41\x44\x30\x30\x30\x31\x03\x71\x0D";
public const string VolumeDownCmd = "\x01\x30\x41\x30\x45\x30\x41\x02\x31\x30\x41\x44\x30\x30\x30\x32\x03\x72\x0D";
public const string MenuIrCmd = "\x01\x30\x41\x30\x41\x30\x43\x02\x43\x32\x31\x30\x30\x30\x32\x30\x30\x33\x03\x03\x0D";
public const string UpIrCmd = "\x01\x30\x41\x30\x41\x30\x43\x02\x43\x32\x31\x30\x30\x30\x31\x35\x30\x33\x03\x05\x0D";
public const string DownIrCmd = "\x01\x30\x41\x30\x41\x30\x43\x02\x43\x32\x31\x30\x30\x30\x31\x34\x30\x33\x03\x04\x0D";
public const string LeftIrCmd = "\x01\x30\x41\x30\x41\x30\x43\x02\x43\x32\x31\x30\x30\x30\x32\x31\x30\x33\x03\x02\x0D";
public const string RightIrCmd = "\x01\x30\x41\x30\x41\x30\x43\x02\x43\x32\x31\x30\x30\x30\x32\x32\x30\x33\x03\x01\x0D";
public const string SelectIrCmd = "\x01\x30\x41\x30\x41\x30\x43\x02\x43\x32\x31\x30\x30\x30\x32\x33\x30\x33\x03\x00\x0D";
public const string ExitIrCmd = "\x01\x30\x41\x30\x41\x30\x43\x02\x43\x32\x31\x30\x30\x30\x31\x46\x30\x33\x03\x76\x0D";
#endregion
bool _PowerIsOn;
bool _IsWarmingUp;
bool _IsCoolingDown;
ushort _VolumeLevel;
bool _IsMuted;
protected override Func<bool> PowerIsOnFeedbackFunc { get { return () => _PowerIsOn; } }
protected override Func<bool> IsCoolingDownFeedbackFunc { get { return () => _IsCoolingDown; } }
protected override Func<bool> IsWarmingUpFeedbackFunc { get { return () => _IsWarmingUp; } }
protected override Func<string> CurrentInputFeedbackFunc { get { return () => "Not Implemented"; } }
/// <summary>
/// Constructor for IBasicCommunication
/// </summary>
public NecPSXMDisplay(string key, string name, IBasicCommunication comm)
: base(key, name)
{
Communication = comm;
Init();
}
/// <summary>
/// Constructor for TCP
/// </summary>
public NecPSXMDisplay(string key, string name, string hostname, int port)
: base(key, name)
{
Communication = new GenericTcpIpClient(key + "-tcp", hostname, port, 5000);
Init();
}
/// <summary>
/// Constructor for COM
/// </summary>
public NecPSXMDisplay(string key, string name, ComPort port, ComPort.ComPortSpec spec)
: base(key, name)
{
Communication = new ComPortController(key + "-com", port, spec);
Init();
}
void Init()
{
PortGather = new CommunicationGather(Communication, '\x0d');
PortGather.LineReceived += this.Port_LineReceived;
CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 30000, 120000, 300000, "xx\x0d");
InputPorts.Add(new RoutingInputPort(RoutingPortNames.HdmiIn1, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.Hdmi, new Action(InputHdmi1), this));
InputPorts.Add(new RoutingInputPort(RoutingPortNames.HdmiIn2, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.Hdmi, new Action(InputHdmi2), this));
InputPorts.Add(new RoutingInputPort(RoutingPortNames.HdmiIn3, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.Hdmi, new Action(InputHdmi3), this));
InputPorts.Add(new RoutingInputPort(RoutingPortNames.HdmiIn4, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.Hdmi, new Action(InputHdmi4), this));
InputPorts.Add(new RoutingInputPort(RoutingPortNames.DisplayPortIn1, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.DisplayPort, new Action(InputDisplayPort1), this));
InputPorts.Add(new RoutingInputPort(RoutingPortNames.DisplayPortIn2, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.DisplayPort, new Action(InputDisplayPort2), this));
InputPorts.Add(new RoutingInputPort(RoutingPortNames.DviIn, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.Dvi, new Action(InputDvi1), this));
InputPorts.Add(new RoutingInputPort(RoutingPortNames.CompositeIn, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.Composite, new Action(InputVideo1), this));
InputPorts.Add(new RoutingInputPort(RoutingPortNames.VgaIn, eRoutingSignalType.Video,
eRoutingPortConnectionType.Vga, new Action(InputVga), this));
InputPorts.Add(new RoutingInputPort(RoutingPortNames.RgbIn, eRoutingSignalType.Video,
eRoutingPortConnectionType.Rgb, new Action(new Action(InputRgb)), this));
VolumeLevelFeedback = new IntFeedback(() => { return _VolumeLevel; });
MuteFeedback = new BoolFeedback(() => _IsMuted);
// new BoolCueActionPair(CommonBoolCue.Menu, b => { if(b) Send(MenuIrCmd); }),
// new BoolCueActionPair(CommonBoolCue.Up, b => { if(b) Send(UpIrCmd); }),
// new BoolCueActionPair(CommonBoolCue.Down, b => { if(b) Send(DownIrCmd); }),
// new BoolCueActionPair(CommonBoolCue.Left, b => { if(b) Send(LeftIrCmd); }),
// new BoolCueActionPair(CommonBoolCue.Right, b => { if(b) Send(RightIrCmd); }),
// new BoolCueActionPair(CommonBoolCue.Select, b => { if(b) Send(SelectIrCmd); }),
// new BoolCueActionPair(CommonBoolCue.Exit, b => { if(b) Send(ExitIrCmd); }),
//};
}
~NecPSXMDisplay()
{
PortGather = null;
}
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<Feedback> Feedbacks
{
get
{
var list = base.Feedbacks;
list.AddRange(new List<Feedback>
{
});
return list;
}
}
void Port_LineReceived(object dev, GenericCommMethodReceiveTextArgs args)
{
if (Debug.Level == 2)
Debug.Console(2, this, "Received: '{0}'", ComTextHelper.GetEscapedText(args.Text));
if (args.Text=="DO SOMETHING HERE EVENTUALLY")
{
_IsMuted = true;
MuteFeedback.FireUpdate();
}
}
void AppendChecksumAndSend(string s)
{
int x = 0;
for (int i = 1; i < s.Length; i++)
x = x ^ s[i];
string send = s + (char)x + '\x0d';
Send(send);
}
void Send(string s)
{
if (Debug.Level == 2)
Debug.Console(2, this, "Send: '{0}'", ComTextHelper.GetEscapedText(s));
Communication.SendText(s);
}
public override void PowerOn()
{
Send(PowerOnCmd);
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()
{
// If a display has unreliable-power off feedback, just override this and
// remove this check.
if (PowerIsOnFeedback.BoolValue && !_IsWarmingUp && !_IsCoolingDown)
{
Send(PowerOffCmd);
_IsCoolingDown = true;
_PowerIsOn = false;
PowerIsOnFeedback.FireUpdate();
IsCoolingDownFeedback.FireUpdate();
// Fake cool-down cycle
CooldownTimer = new CTimer(o =>
{
Debug.Console(2, this, "Cooldown timer ending");
_IsCoolingDown = false;
IsCoolingDownFeedback.FireUpdate();
}, CooldownTime);
}
}
public override void PowerToggle()
{
if (PowerIsOnFeedback.BoolValue && !IsWarmingUpFeedback.BoolValue)
PowerOff();
else if (!PowerIsOnFeedback.BoolValue && !IsCoolingDownFeedback.BoolValue)
PowerOn();
}
public void InputHdmi1()
{
Send(Hdmi1Cmd);
}
public void InputHdmi2()
{
Send(Hdmi2Cmd);
}
public void InputHdmi3()
{
Send(Hdmi3Cmd);
}
public void InputHdmi4()
{
Send(Hdmi4Cmd);
}
public void InputDisplayPort1()
{
Send(Dp1Cmd);
}
public void InputDisplayPort2()
{
Send(Dp2Cmd);
}
public void InputDvi1()
{
Send(Dvi1Cmd);
}
public void InputVideo1()
{
Send(Video1Cmd);
}
public void InputVga()
{
Send(VgaCmd);
}
public void InputRgb()
{
Send(RgbCmd);
}
public override void ExecuteSwitch(object selector)
{
if (selector is Action)
(selector as Action).Invoke();
else
Debug.Console(1, this, "WARNING: ExecuteSwitch cannot handle type {0}", selector.GetType());
//Send((string)selector);
}
public void SetVolume(ushort level)
{
var levelString = string.Format("{0}{1:X4}\x03", VolumeLevelPartialCmd, level);
AppendChecksumAndSend(levelString);
//Debug.Console(2, this, "Volume:{0}", ComTextHelper.GetEscapedText(levelString));
_VolumeLevel = level;
VolumeLevelFeedback.FireUpdate();
}
#region IBasicVolumeWithFeedback Members
public IntFeedback VolumeLevelFeedback { get; private set; }
public BoolFeedback MuteFeedback { get; private set; }
public void MuteOff()
{
Send(MuteOffCmd);
}
public void MuteOn()
{
Send(MuteOnCmd);
}
/*
public void IBasicVolumeWithFeedback.SetVolume(ushort level)
{
SetVolume(level);
}
*/
#endregion
#region IBasicVolumeControls Members
public void MuteToggle()
{
Send(MuteToggleIrCmd);
}
public void VolumeDown(bool pressRelease)
{
//throw new NotImplementedException();
//#warning need incrementer for these
SetVolume(_VolumeLevel++);
}
public void VolumeUp(bool pressRelease)
{
//throw new NotImplementedException();
SetVolume(_VolumeLevel--);
}
#endregion
}
public class NecPSXMDisplayFactory : EssentialsDeviceFactory<NecPSXMDisplay>
{
public NecPSXMDisplayFactory()
{
TypeNames = new List<string>() { "necmpsx" };
}
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 NecPSXMDisplay(dc.Key, dc.Name, comm);
else
return null;
}
}
}

View file

@ -0,0 +1,232 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Essentials.Core;
using PepperDash.Core;
using PepperDash.Essentials.Core.Bridges;
namespace PepperDash.Essentials.Devices.Displays
{
//public class NecPaSeriesProjector : TwoWayDisplayBase, IBridgeAdvanced
//{
// public readonly IntFeedback Lamp1RemainingPercent;
// int _Lamp1RemainingPercent;
// public readonly IntFeedback Lamp2RemainingPercent;
// int _Lamp2RemainingPercent;
// RoutingInputPort _CurrentInputPort;
// protected override Func<string> CurrentInputFeedbackFunc { get { return () => _CurrentInputPort.Key; } }
// protected override Func<bool> PowerIsOnFeedbackFunc
// {
// get { return () => _PowerIsOn; }
// }
// bool _PowerIsOn;
// protected override Func<bool> IsCoolingDownFeedbackFunc
// {
// get { return () => false; }
// }
// protected override Func<bool> IsWarmingUpFeedbackFunc
// {
// get { return () => false; }
// }
// public override void PowerToggle()
// {
// throw new NotImplementedException();
// }
// public override void ExecuteSwitch(object selector)
// {
// throw new NotImplementedException();
// }
// Dictionary<string, string> InputMap;
// /// <summary>
// /// Constructor
// /// </summary>
// public NecPaSeriesProjector(string key, string name)
// : base(key, name)
// {
// Lamp1RemainingPercent = new IntFeedback("Lamp1RemainingPercent", () => _Lamp1RemainingPercent);
// Lamp2RemainingPercent = new IntFeedback("Lamp2RemainingPercent", () => _Lamp2RemainingPercent);
// InputMap = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
// {
// { "computer1", "\x02\x03\x00\x00\x02\x01\x01\x09" },
// { "computer2", "\x02\x03\x00\x00\x02\x01\x02\x0a" },
// { "computer3", "\x02\x03\x00\x00\x02\x01\x03\x0b" },
// { "hdmi", "\x02\x03\x00\x00\x02\x01\x1a\x22" },
// { "dp", "\x02\x03\x00\x00\x02\x01\x1b\x23" },
// { "video", "\x02\x03\x00\x00\x02\x01\x06\x0e" },
// { "viewer", "\x02\x03\x00\x00\x02\x01\x1f\x27" },
// { "network", "\x02\x03\x00\x00\x02\x01\x20\x28" },
// };
// }
// void IsConnected_OutputChange(object sender, EventArgs e)
// {
// }
// public void SetEnable(bool state)
// {
// var tcp = CommunicationMethod as GenericTcpIpClient;
// if (tcp != null)
// {
// tcp.Connect();
// }
// }
// public override void PowerOn()
// {
// SendText("\x02\x00\x00\x00\x00\x02");
// }
// public override void PowerOff()
// {
// SendText("\x02\x01\x00\x00\x00\x03");
// }
// public void PictureMuteOn()
// {
// SendText("\x02\x10\x00\x00\x00\x12");
// }
// public void PictureMuteOff()
// {
// SendText("\x02\x11\x00\x00\x00\x13");
// }
// public void GetRunningStatus()
// {
// SendText("\x00\x85\x00\x00\x01\x01\x87");
// }
// public void GetLampRemaining(int lampNum)
// {
// if (!_PowerIsOn) return;
// var bytes = new byte[]{0x03,0x96,0x00,0x00,0x02,0x00,0x04};
// if (lampNum == 2)
// bytes[5] = 0x01;
// SendBytes(AppendChecksum(bytes));
// }
// public void SelectInput(string inputKey)
// {
// if (InputMap.ContainsKey(inputKey))
// SendText(InputMap[inputKey]);
// }
// void SendText(string text)
// {
// if (CommunicationMethod != null)
// CommunicationMethod.SendText(text);
// }
// void SendBytes(byte[] bytes)
// {
// if (CommunicationMethod != null)
// CommunicationMethod.SendBytes(bytes);
// }
// byte[] AppendChecksum(byte[] bytes)
// {
// byte sum = unchecked((byte)bytes.Sum(x => (int)x));
// var retVal = new byte[bytes.Length + 1];
// bytes.CopyTo(retVal, 0);
// retVal[retVal.Length - 1] = sum;
// return retVal;
// }
// protected override void CommunicationMethod_BytesReceived(object sender, GenericCommMethodReceiveBytesArgs args)
// {
// var bytes = args.Bytes;
// ParseBytes(args.Bytes);
// }
// void ParseBytes(byte[] bytes)
// {
// if (bytes[0] == 0x22)
// {
// // Power on
// if (bytes[1] == 0x00)
// {
// _PowerIsOn = true;
// PowerIsOnFeedback.FireUpdate();
// }
// // Power off
// else if (bytes[1] == 0x01)
// {
// _PowerIsOn = false;
// PowerIsOnFeedback.FireUpdate();
// }
// }
// // Running Status
// else if (bytes[0] == 0x20 && bytes[1] == 0x85 && bytes[4] == 0x10)
// {
// var operationStates = new Dictionary<int, string>
// {
// { 0x00, "Standby" },
// { 0x04, "Power On" },
// { 0x05, "Cooling" },
// { 0x06, "Standby (error)" },
// { 0x0f, "Standby (power saving" },
// { 0x10, "Network Standby" },
// { 0xff, "Not supported" }
// };
// var newPowerIsOn = bytes[7] == 0x01;
// if (newPowerIsOn != _PowerIsOn)
// {
// _PowerIsOn = newPowerIsOn;
// PowerIsOnFeedback.FireUpdate();
// }
// Debug.Console(2, this, "PowerIsOn={0}\rCooling={1}\rPowering on/off={2}\rStatus={3}",
// _PowerIsOn,
// bytes[8] == 0x01,
// bytes[9] == 0x01,
// operationStates[bytes[10]]);
// }
// // Lamp remaining
// else if (bytes[0] == 0x23 && bytes[1] == 0x96 && bytes[4] == 0x06 && bytes[6] == 0x04)
// {
// var newValue = bytes[7];
// if (bytes[5] == 0x00)
// {
// if (newValue != _Lamp1RemainingPercent)
// {
// _Lamp1RemainingPercent = newValue;
// Lamp1RemainingPercent.FireUpdate();
// }
// }
// else
// {
// if (newValue != _Lamp2RemainingPercent)
// {
// _Lamp2RemainingPercent = newValue;
// Lamp2RemainingPercent.FireUpdate();
// }
// }
// Debug.Console(0, this, "Lamp {0}, {1}% remaining", (bytes[5] + 1), bytes[7]);
// }
// }
// public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
// {
// LinkDisplayToApi(this, trilist, joinStart, joinMapKey, bridge);
// }
//}
}

View file

@ -0,0 +1,367 @@
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;
using Feedback = PepperDash.Essentials.Core.Feedback;
namespace PepperDash.Essentials.Devices.Displays
{
/// <summary>
///
/// </summary>
public class PanasonicThDisplay : TwoWayDisplayBase, IBasicVolumeWithFeedback, ICommunicationMonitor, IBridgeAdvanced
{
public IBasicCommunication Communication { get; private set; }
public CommunicationGather PortGather { get; private set; }
public StatusMonitorBase CommunicationMonitor { get; private set; }
#region Command constants
public const string InputGetCmd = "\x02QMI\x03";
public const string Hdmi1Cmd = "\x02IMS:HM1\x03";
public const string Hdmi2Cmd = "\x02IMS:HM2\x03";
public const string Hdmi3Cmd = "";
public const string Hdmi4Cmd = "";
public const string Dp1Cmd = "";
public const string Dp2Cmd = "";
public const string Dvi1Cmd = "\x02IMS:DV1";
public const string Video1Cmd = "";
public const string VgaCmd = "";
public const string RgbCmd = "";
public const string PowerOnCmd = "\x02PON\x03";
public const string PowerOffCmd = "\x02POF\x03";
public const string PowerToggleIrCmd = "";
public const string MuteOffCmd = "\x02AMT:0\x03";
public const string MuteOnCmd = "\x02AMT:1\x03";
public const string MuteToggleIrCmd = "\x02AMT\x03";
public const string MuteGetCmd = "\x02QAM\x03";
public const string VolumeGetCmd = "\x02QAV\x03";
public const string VolumeLevelPartialCmd = "\x02AVL:"; //
public const string VolumeUpCmd = "\x02AUU\x03";
public const string VolumeDownCmd = "\x02AUD\x03";
public const string MenuIrCmd = "";
public const string UpIrCmd = "";
public const string DownIrCmd = "";
public const string LeftIrCmd = "";
public const string RightIrCmd = "";
public const string SelectIrCmd = "";
public const string ExitIrCmd = "";
#endregion
bool _PowerIsOn;
bool _IsWarmingUp;
bool _IsCoolingDown;
ushort _VolumeLevel;
bool _IsMuted;
protected override Func<bool> PowerIsOnFeedbackFunc { get { return () => _PowerIsOn; } }
protected override Func<bool> IsCoolingDownFeedbackFunc { get { return () => _IsCoolingDown; } }
protected override Func<bool> IsWarmingUpFeedbackFunc { get { return () => _IsWarmingUp; } }
protected override Func<string> CurrentInputFeedbackFunc { get { return () => "Not Implemented"; } }
/// <summary>
/// Constructor for IBasicCommunication
/// </summary>
public PanasonicThDisplay(string key, string name, IBasicCommunication comm)
: base(key, name)
{
Communication = comm;
Init();
}
/// <summary>
/// Constructor for TCP
/// </summary>
public PanasonicThDisplay(string key, string name, string hostname, int port)
: base(key, name)
{
Communication = new GenericTcpIpClient(key + "-tcp", hostname, port, 5000);
Init();
}
/// <summary>
/// Constructor for COM
/// </summary>
public PanasonicThDisplay(string key, string name, ComPort port, ComPort.ComPortSpec spec)
: base(key, name)
{
Communication = new ComPortController(key + "-com", port, spec);
Init();
}
void Init()
{
PortGather = new CommunicationGather(Communication, '\x0d');
PortGather.LineReceived += this.Port_LineReceived;
CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 30000, 120000, 300000, "\x02QPW\x03"); // Query Power
InputPorts.Add(new RoutingInputPort(RoutingPortNames.HdmiIn1, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.Hdmi, new Action(InputHdmi1), this));
InputPorts.Add(new RoutingInputPort(RoutingPortNames.HdmiIn2, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.Hdmi, new Action(InputHdmi2), this));
InputPorts.Add(new RoutingInputPort(RoutingPortNames.DviIn, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.Dvi, new Action(InputDvi1), this));
InputPorts.Add(new RoutingInputPort(RoutingPortNames.CompositeIn, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.Composite, new Action(InputVideo1), this));
InputPorts.Add(new RoutingInputPort(RoutingPortNames.VgaIn, eRoutingSignalType.Video,
eRoutingPortConnectionType.Vga, new Action(InputVga), this));
VolumeLevelFeedback = new IntFeedback(() => { return _VolumeLevel; });
MuteFeedback = new BoolFeedback(() => _IsMuted);
// new BoolCueActionPair(CommonBoolCue.Menu, b => { if(b) Send(MenuIrCmd); }),
// new BoolCueActionPair(CommonBoolCue.Up, b => { if(b) Send(UpIrCmd); }),
// new BoolCueActionPair(CommonBoolCue.Down, b => { if(b) Send(DownIrCmd); }),
// new BoolCueActionPair(CommonBoolCue.Left, b => { if(b) Send(LeftIrCmd); }),
// new BoolCueActionPair(CommonBoolCue.Right, b => { if(b) Send(RightIrCmd); }),
// new BoolCueActionPair(CommonBoolCue.Select, b => { if(b) Send(SelectIrCmd); }),
// new BoolCueActionPair(CommonBoolCue.Exit, b => { if(b) Send(ExitIrCmd); }),
//};
}
~PanasonicThDisplay()
{
PortGather = null;
}
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<Feedback> Feedbacks
{
get
{
var list = base.Feedbacks;
list.AddRange(new List<Feedback>
{
});
return list;
}
}
void Port_LineReceived(object dev, GenericCommMethodReceiveTextArgs args)
{
if (Debug.Level == 2)
Debug.Console(2, this, "Received: '{0}'", ComTextHelper.GetEscapedText(args.Text));
if (args.Text=="DO SOMETHING HERE EVENTUALLY")
{
_IsMuted = true;
MuteFeedback.FireUpdate();
}
}
void Send(string s)
{
if (Debug.Level == 2)
Debug.Console(2, this, "Send: '{0}'", ComTextHelper.GetEscapedText(s));
Communication.SendText(s);
}
public override void PowerOn()
{
Send(PowerOnCmd);
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()
{
// If a display has unreliable-power off feedback, just override this and
// remove this check.
if (PowerIsOnFeedback.BoolValue && !_IsWarmingUp && !_IsCoolingDown)
{
Send(PowerOffCmd);
_IsCoolingDown = true;
_PowerIsOn = false;
PowerIsOnFeedback.FireUpdate();
IsCoolingDownFeedback.FireUpdate();
// Fake cool-down cycle
CooldownTimer = new CTimer(o =>
{
Debug.Console(2, this, "Cooldown timer ending");
_IsCoolingDown = false;
IsCoolingDownFeedback.FireUpdate();
}, CooldownTime);
}
}
public override void PowerToggle()
{
if (PowerIsOnFeedback.BoolValue && !IsWarmingUpFeedback.BoolValue)
PowerOff();
else if (!PowerIsOnFeedback.BoolValue && !IsCoolingDownFeedback.BoolValue)
PowerOn();
}
public void InputHdmi1()
{
Send(Hdmi1Cmd);
}
public void InputHdmi2()
{
Send(Hdmi2Cmd);
}
public void InputHdmi3()
{
Send(Hdmi3Cmd);
}
public void InputHdmi4()
{
Send(Hdmi4Cmd);
}
public void InputDisplayPort1()
{
Send(Dp1Cmd);
}
public void InputDisplayPort2()
{
Send(Dp2Cmd);
}
public void InputDvi1()
{
Send(Dvi1Cmd);
}
public void InputVideo1()
{
Send(Video1Cmd);
}
public void InputVga()
{
Send(VgaCmd);
}
public void InputRgb()
{
Send(RgbCmd);
}
public override void ExecuteSwitch(object selector)
{
if (selector is Action)
(selector as Action).Invoke();
else
Debug.Console(1, this, "WARNING: ExecuteSwitch cannot handle type {0}", selector.GetType());
//Send((string)selector);
}
public void SetVolume(ushort level)
{
var levelString = string.Format("{0}{1:X3}\x03", VolumeLevelPartialCmd, level);
//Debug.Console(2, this, "Volume:{0}", ComTextHelper.GetEscapedText(levelString));
_VolumeLevel = level;
VolumeLevelFeedback.FireUpdate();
}
#region IBasicVolumeWithFeedback Members
public IntFeedback VolumeLevelFeedback { get; private set; }
public BoolFeedback MuteFeedback { get; private set; }
public void MuteOff()
{
Send(MuteOffCmd);
}
public void MuteOn()
{
Send(MuteOnCmd);
}
/*
void IBasicVolumeWithFeedback.SetVolume(ushort level)
{
SetVolume(level);
}
*/
#endregion
#region IBasicVolumeControls Members
public void MuteToggle()
{
Send(MuteToggleIrCmd);
}
public void VolumeDown(bool pressRelease)
{
//throw new NotImplementedException();
//#warning need incrementer for these
SetVolume(_VolumeLevel++);
}
public void VolumeUp(bool pressRelease)
{
//throw new NotImplementedException();
SetVolume(_VolumeLevel--);
}
#endregion
}
public class PanasonicThDisplayFactory : EssentialsDeviceFactory<PanasonicThDisplay>
{
public PanasonicThDisplayFactory()
{
TypeNames = new List<string>() { "panasonicthef" };
}
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 PanasonicThDisplay(dc.Key, dc.Name, comm);
else
return null;
}
}
}

View file

@ -0,0 +1,665 @@
extern alias Full;
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 Full.Newtonsoft.Json.Linq;
namespace PepperDash.Essentials.Devices.Displays
{
/// <summary>
///
/// </summary>
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<bool> PowerIsOnFeedbackFunc { get { return () => _PowerIsOn; } }
protected override Func<bool> IsCoolingDownFeedbackFunc { get { return () => _IsCoolingDown; } }
protected override Func<bool> IsWarmingUpFeedbackFunc { get { return () => _IsWarmingUp; } }
protected override Func<string> CurrentInputFeedbackFunc { get { return () => _CurrentInputPort.Key; } }
/// <summary>
/// Constructor for IBasicCommunication
/// </summary>
public SamsungMDC(string key, string name, IBasicCommunication comm, string id)
: base(key, name)
{
Communication = comm;
Communication.BytesReceived += new EventHandler<GenericCommMethodReceiveBytesArgs>(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();
}
/// <summary>
/// Constructor for TCP
/// </summary>
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();
}
/// <summary>
/// Constructor for COM
/// </summary>
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<GenericCommMethodReceiveTextArgs>(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();
}
/// <summary>
///
/// </summary>
/// <returns></returns>
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<Feedback> Feedbacks
{
get
{
var list = base.Feedbacks;
list.AddRange(new List<Feedback>
{
VolumeLevelFeedback,
MuteFeedback,
CurrentInputFeedback
});
return list;
}
}
/// <summary>
/// /
/// </summary>
/// <param name="sender"></param>
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);
}
}
/// <summary>
///
/// </summary>
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();
}
}
/// <summary>
/// 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
/// </summary>
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);
}
/// <summary>
///
/// </summary>
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();
}
}
/// <summary>
///
/// </summary>
void UpdateMuteFb(byte b)
{
var newMute = b == 1;
if (newMute != _IsMuted)
{
_IsMuted = newMute;
MuteFeedback.FireUpdate();
}
}
/// <summary>
///
/// </summary>
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));
}
}
/// <summary>
/// Formats an outgoing message. Replaces third byte with ID and replaces last byte with checksum
/// </summary>
/// <param name="b"></param>
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);
}
/// <summary>
///
/// </summary>
public void StatusGet()
{
SendBytes(new byte[] { 0xAA, 0x00, 0x00, 0x00, 0x00 });
}
/// <summary>
///
/// </summary>
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);
}
}
/// <summary>
///
/// </summary>
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 });
}
/// <summary>
/// Executes a switch, turning on display if necessary.
/// </summary>
/// <param name="selector"></param>
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<FeedbackEventArgs> 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();
}
}
/// <summary>
/// Scales the level to the range of the display and sends the command
/// </summary>
/// <param name="level"></param>
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; }
/// <summary>
///
/// </summary>
public void MuteOff()
{
SendBytes(new byte[] { 0xAA, 0x13, 0x00, 0x01, 0x00, 0x00 });
}
/// <summary>
///
/// </summary>
public void MuteOn()
{
SendBytes(new byte[] { 0xAA, 0x13, 0x00, 0x01, 0x01, 0x00 });
}
/// <summary>
///
/// </summary>
public void MuteGet()
{
SendBytes(new byte[] { 0xAA, 0x13, 0x00, 0x00, 0x00 });
}
#endregion
#region IBasicVolumeControls Members
/// <summary>
///
/// </summary>
public void MuteToggle()
{
if (_IsMuted)
MuteOff();
else
MuteOn();
}
/// <summary>
///
/// </summary>
/// <param name="pressRelease"></param>
public void VolumeDown(bool pressRelease)
{
if (pressRelease)
{
VolumeIncrementer.StartDown();
VolumeIsRamping = true;
}
else
{
VolumeIsRamping = false;
VolumeIncrementer.Stop();
}
}
/// <summary>
///
/// </summary>
/// <param name="pressRelease"></param>
public void VolumeUp(bool pressRelease)
{
if (pressRelease)
{
VolumeIncrementer.StartUp();
VolumeIsRamping = true;
}
else
{
VolumeIsRamping = false;
VolumeIncrementer.Stop();
}
}
/// <summary>
///
/// </summary>
public void VolumeGet()
{
SendBytes(new byte[] { 0xAA, 0x12, 0x00, 0x00, 0x00 });
}
#endregion
}
public class SamsungMDCFactory : EssentialsDeviceFactory<SamsungMDC>
{
public SamsungMDCFactory()
{
TypeNames = new List<string>() { "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<string>());
else
return null;
}
}
}

View file

@ -0,0 +1,106 @@
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.Lighting;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.CrestronIO;
namespace PepperDash.Essentials.Devices.Common.Environment.Lighting
{
public class Din8sw8Controller : EssentialsDevice, ISwitchedOutputCollection
{
// Need to figure out some sort of interface to make these switched outputs behave like processor relays so they can be used interchangably
public Din8Sw8 SwitchModule { get; private set; }
/// <summary>
/// Collection of generic switched outputs
/// </summary>
public Dictionary<uint, ISwitchedOutput> SwitchedOutputs { get; private set; }
public Din8sw8Controller(string key, uint cresnetId)
: base(key)
{
SwitchedOutputs = new Dictionary<uint, ISwitchedOutput>();
SwitchModule = new Din8Sw8(cresnetId, Global.ControlSystem);
if (SwitchModule.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
{
Debug.Console(2, this, "Error registering Din8sw8. Reason: {0}", SwitchModule.RegistrationFailureReason);
}
PopulateDictionary();
}
public override bool CustomActivate()
{
return base.CustomActivate();
}
/// <summary>
/// Populates the generic collection with the loads from the Crestron collection
/// </summary>
void PopulateDictionary()
{
foreach (var item in SwitchModule.SwitchedLoads)
{
SwitchedOutputs.Add(item.Number, new Din8sw8Output(item));
}
}
}
/// <summary>
/// Wrapper class to
/// </summary>
public class Din8sw8Output : ISwitchedOutput
{
SwitchedLoadWithOverrideParameter SwitchedOutput;
public BoolFeedback OutputIsOnFeedback { get; protected set; }
public Din8sw8Output(SwitchedLoadWithOverrideParameter switchedOutput)
{
SwitchedOutput = switchedOutput;
OutputIsOnFeedback = new BoolFeedback(new Func<bool>(() => SwitchedOutput.IsOn));
}
public void On()
{
SwitchedOutput.FullOn();
}
public void Off()
{
SwitchedOutput.FullOff();
}
}
public class Din8sw8ControllerFactory : EssentialsDeviceFactory<Din8sw8Controller>
{
public Din8sw8ControllerFactory()
{
TypeNames = new List<string>() { "din8sw8" };
}
public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
Debug.Console(1, "Factory Attempting to create new Din8sw8Controller Device");
var comm = CommFactory.GetControlPropertiesConfig(dc);
return new Din8sw8Controller(dc.Key, comm.CresnetIdInt);
}
}
}

View file

@ -0,0 +1,286 @@
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.Core.Config;
using PepperDash.Essentials.Core.Bridges;
using PepperDash.Essentials.Core.Lighting;
using LightingBase = PepperDash.Essentials.Core.Lighting.LightingBase;
namespace PepperDash.Essentials.Devices.Common.Environment.Lutron
{
public class LutronQuantumArea : LightingBase, ILightingMasterRaiseLower, ICommunicationMonitor
{
public IBasicCommunication Communication { get; private set; }
public CommunicationGather PortGather { get; private set; }
public StatusMonitorBase CommunicationMonitor { get; private set; }
CTimer SubscribeAfterLogin;
public string IntegrationId;
string Username;
string Password;
const string Delimiter = "\x0d\x0a";
const string Set = "#";
const string Get = "?";
public LutronQuantumArea(string key, string name, IBasicCommunication comm, LutronQuantumPropertiesConfig props)
: base(key, name)
{
Communication = comm;
IntegrationId = props.IntegrationId;
if (props.Control.Method != eControlMethod.Com)
{
Username = props.Control.TcpSshProperties.Username;
Password = props.Control.TcpSshProperties.Password;
}
LightingScenes = props.Scenes;
var socket = comm as ISocketStatus;
if (socket != null)
{
// IP Control
socket.ConnectionChange += new EventHandler<GenericSocketStatusChageEventArgs>(socket_ConnectionChange);
}
else
{
// RS-232 Control
}
Communication.TextReceived += new EventHandler<GenericCommMethodReceiveTextArgs>(Communication_TextReceived);
PortGather = new CommunicationGather(Communication, Delimiter);
PortGather.LineReceived += new EventHandler<GenericCommMethodReceiveTextArgs>(PortGather_LineReceived);
if (props.CommunicationMonitorProperties != null)
{
CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, props.CommunicationMonitorProperties);
}
else
{
CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 120000, 120000, 300000, "?ETHERNET,0\x0d\x0a");
}
}
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 override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{
var joinMap = LinkLightingToApi(this, trilist, joinStart, joinMapKey, bridge);
CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]);
trilist.SetStringSigAction(joinMap.IntegrationIdSet.JoinNumber , s => IntegrationId = s);
}
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
}
}
/// <summary>
/// Checks for responses that do not contain the delimiter
/// </summary>
/// <param name="sender"></param>
/// <param name="args"></param>
void Communication_TextReceived(object sender, GenericCommMethodReceiveTextArgs args)
{
Debug.Console(2, this, "Text Received: '{0}'", args.Text);
if (args.Text.Contains("login:"))
{
// Login
SendLine(Username);
}
else if (args.Text.Contains("password:"))
{
// Login
SendLine(Password);
SubscribeAfterLogin = new CTimer(x => SubscribeToFeedback(), null, 5000);
}
else if (args.Text.Contains("Access Granted"))
{
if (SubscribeAfterLogin != null)
{
SubscribeAfterLogin.Stop();
}
SubscribeToFeedback();
}
}
/// <summary>
/// Handles all responses that contain the delimiter
/// </summary>
/// <param name="sender"></param>
/// <param name="args"></param>
void PortGather_LineReceived(object sender, GenericCommMethodReceiveTextArgs args)
{
Debug.Console(2, this, "Line Received: '{0}'", args.Text);
try
{
if (args.Text.Contains("~AREA"))
{
var response = args.Text.Split(',');
var integrationId = response[1];
if (integrationId != IntegrationId)
{
Debug.Console(2, this, "Response is not for correct Integration ID");
return;
}
else
{
var action = Int32.Parse(response[2]);
switch (action)
{
case (int)eAction.Scene:
{
var scene = response[3];
CurrentLightingScene = LightingScenes.FirstOrDefault(s => s.ID.Equals(scene));
OnLightingSceneChange();
break;
}
default:
break;
}
}
}
}
catch (Exception e)
{
Debug.Console(2, this, "Error parsing response:\n{0}", e);
}
}
/// <summary>
/// Subscribes to feedback
/// </summary>
public void SubscribeToFeedback()
{
Debug.Console(1, "Sending Monitoring Subscriptions");
SendLine("#MONITORING,6,1");
SendLine("#MONITORING,8,1");
SendLine("#MONITORING,5,2");
}
/// <summary>
/// Recalls the specified scene
/// </summary>
/// <param name="scene"></param>
///
public override void SelectScene(LightingScene scene)
{
Debug.Console(1, this, "Selecting Scene: '{0}'", scene.Name);
SendLine(string.Format("{0}AREA,{1},{2},{3}", Set, IntegrationId, (int)eAction.Scene, scene.ID));
}
/// <summary>
/// Begins raising the lights in the area
/// </summary>
public void MasterRaise()
{
SendLine(string.Format("{0}AREA,{1},{2}", Set, IntegrationId, (int)eAction.Raise));
}
/// <summary>
/// Begins lowering the lights in the area
/// </summary>
public void MasterLower()
{
SendLine(string.Format("{0}AREA,{1},{2}", Set, IntegrationId, (int)eAction.Lower));
}
/// <summary>
/// Stops the current raise/lower action
/// </summary>
public void MasterRaiseLowerStop()
{
SendLine(string.Format("{0}AREA,{1},{2}", Set, IntegrationId, (int)eAction.Stop));
}
/// <summary>
/// Appends the delimiter and sends the string
/// </summary>
/// <param name="s"></param>
public void SendLine(string s)
{
Communication.SendText(s + Delimiter);
}
}
public enum eAction : int
{
SetLevel = 1,
Raise = 2,
Lower = 3,
Stop = 4,
Scene = 6,
DaylightMode = 7,
OccupancyState = 8,
OccupancyMode = 9,
OccupiedLevelOrScene = 12,
UnoccupiedLevelOrScene = 13,
HyperionShaddowSensorOverrideState = 26,
HyperionBrightnessSensorOverrideStatue = 27
}
public class LutronQuantumPropertiesConfig
{
public CommunicationMonitorConfig CommunicationMonitorProperties { get; set; }
public ControlPropertiesConfig Control { get; set; }
public string IntegrationId { get; set; }
public List<LightingScene> Scenes { get; set; }
// Moved to use existing properties in Control object
// public string Username { get; set; }
// public string Password { get; set; }
}
public class LutronQuantumAreaFactory : EssentialsDeviceFactory<LutronQuantumArea>
{
public LutronQuantumAreaFactory()
{
TypeNames = new List<string>() { "lutronqs" };
}
public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
Debug.Console(1, "Factory Attempting to create new LutronQuantumArea Device");
var comm = CommFactory.CreateCommForDevice(dc);
var props = Newtonsoft.Json.JsonConvert.DeserializeObject<Environment.Lutron.LutronQuantumPropertiesConfig>(dc.Properties.ToString());
return new LutronQuantumArea(dc.Key, dc.Name, comm, props);
}
}
}

View file

@ -0,0 +1,131 @@
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.CrestronIO;
using PepperDash.Essentials.Core.Shades;
namespace PepperDash.Essentials.Devices.Common.Environment.Somfy
{
/// <summary>
/// Controls a single shade using three relays
/// </summary>
public class RelayControlledShade : ShadeBase, IShadesOpenCloseStop
{
RelayControlledShadeConfigProperties Config;
ISwitchedOutput OpenRelay;
ISwitchedOutput StopOrPresetRelay;
ISwitchedOutput CloseRelay;
int RelayPulseTime;
public string StopOrPresetButtonLabel { get; set; }
public RelayControlledShade(string key, string name, RelayControlledShadeConfigProperties config)
: base(key, name)
{
Config = config;
RelayPulseTime = Config.RelayPulseTime;
StopOrPresetButtonLabel = Config.StopOrPresetLabel;
}
public override bool CustomActivate()
{
//Create ISwitchedOutput objects based on props
OpenRelay = GetSwitchedOutputFromDevice(Config.Relays.Open);
StopOrPresetRelay = GetSwitchedOutputFromDevice(Config.Relays.StopOrPreset);
CloseRelay = GetSwitchedOutputFromDevice(Config.Relays.Close);
return base.CustomActivate();
}
public override void Open()
{
Debug.Console(1, this, "Opening Shade: '{0}'", this.Name);
PulseOutput(OpenRelay, RelayPulseTime);
}
public override void Stop()
{
Debug.Console(1, this, "Stopping Shade: '{0}'", this.Name);
PulseOutput(StopOrPresetRelay, RelayPulseTime);
}
public override void Close()
{
Debug.Console(1, this, "Closing Shade: '{0}'", this.Name);
PulseOutput(CloseRelay, RelayPulseTime);
}
void PulseOutput(ISwitchedOutput output, int pulseTime)
{
output.On();
CTimer pulseTimer = new CTimer(new CTimerCallbackFunction((o) => output.Off()), pulseTime);
}
/// <summary>
/// Attempts to get the port on teh specified device from config
/// </summary>
/// <param name="relayConfig"></param>
/// <returns></returns>
ISwitchedOutput GetSwitchedOutputFromDevice(IOPortConfig relayConfig)
{
var portDevice = DeviceManager.GetDeviceForKey(relayConfig.PortDeviceKey);
if (portDevice != null)
{
return (portDevice as ISwitchedOutputCollection).SwitchedOutputs[relayConfig.PortNumber];
}
else
{
Debug.Console(1, this, "Error: Unable to get relay on port '{0}' from device with key '{1}'", relayConfig.PortNumber, relayConfig.PortDeviceKey);
return null;
}
}
}
public class RelayControlledShadeConfigProperties
{
public int RelayPulseTime { get; set; }
public ShadeRelaysConfig Relays { get; set; }
public string StopOrPresetLabel { get; set; }
public class ShadeRelaysConfig
{
public IOPortConfig Open { get; set; }
public IOPortConfig StopOrPreset { get; set; }
public IOPortConfig Close { get; set; }
}
}
public class RelayControlledShadeFactory : EssentialsDeviceFactory<RelayControlledShade>
{
public RelayControlledShadeFactory()
{
TypeNames = new List<string>() { "relaycontrolledshade" };
}
public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
Debug.Console(1, "Factory Attempting to create new Generic Comm Device");
var props = Newtonsoft.Json.JsonConvert.DeserializeObject<Environment.Somfy.RelayControlledShadeConfigProperties>(dc.Properties.ToString());
return new Environment.Somfy.RelayControlledShade(dc.Key, dc.Name, props);
}
}
}

View file

@ -0,0 +1,53 @@
extern alias Full;
using System;
using System.Linq;
using System.Collections.Generic;
using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.GeneralIO;
using Crestron.SimplSharp.Reflection;
using Full.Newtonsoft.Json;
using Full.Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.CrestronIO;
using PepperDash.Essentials.Devices.Common;
using PepperDash.Essentials.Devices.Common.DSP;
using PepperDash.Essentials.Devices.Common.VideoCodec;
using PepperDash.Essentials.Devices.Common.Environment;
namespace PepperDash.Essentials.Devices.Common
{
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);
}
}
}
}
}
}

View file

@ -0,0 +1,58 @@
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.Routing;
namespace PepperDash.Essentials.Devices.Common
{
public class GenericSource : EssentialsDevice, IUiDisplayInfo, IRoutingOutputs, IUsageTracking
{
public uint DisplayUiType { get { return DisplayUiConstants.TypeNoControls; } }
public GenericSource(string key, string name)
: base(key, name)
{
AnyOut = new RoutingOutputPort(RoutingPortNames.AnyOut, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.Hdmi, null, this);
OutputPorts = new RoutingPortCollection<RoutingOutputPort> { AnyOut };
}
#region IRoutingOutputs Members
public RoutingOutputPort AnyOut { get; private set; }
public RoutingPortCollection<RoutingOutputPort> OutputPorts { get; private set; }
#endregion
#region IUsageTracking Members
public UsageTracking UsageTracker { get; set; }
#endregion
}
public class GenericSourceFactory : EssentialsDeviceFactory<GenericSource>
{
public GenericSourceFactory()
{
TypeNames = new List<string>() { "genericsource" };
}
public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
Debug.Console(1, "Factory Attempting to create new Generic Source Device");
return new GenericSource(dc.Key, dc.Name);
}
}
}

View file

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Devices.Common
{
/// <summary>
///
/// </summary>
public class AnalogWayLiveCorePropertiesConfig
{
public CommunicationMonitorConfig CommunicationMonitorProperties { get; set; }
public ControlPropertiesConfig Control { get; set; }
public string userName { get; set; }
public string password { get; set; }
}
}

View file

@ -0,0 +1,252 @@
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 System.Text.RegularExpressions;
namespace PepperDash.Essentials.Devices.Common
{
public class AnalogWayLiveCore : EssentialsDevice
{
public IBasicCommunication Communication { get; private set; }
public CommunicationGather PortGather { get; private set; }
public StatusMonitorBase CommunicationMonitor { get; private set; }
public string userName;
public string password;
private bool OnlineStatus;
public BoolFeedback OnlineFeedback;
private ushort CurrentPreset;
public IntFeedback PresetFeedback;
// new public Dictionary<string, QscDspLevelControl> LevelControlPoints { get; private set; }
// public List<QscDspPresets> PresetList = new List<QscDspPresets>();
public bool isSubscribed;
private CTimer SubscriptionTimer;
CrestronQueue CommandQueue;
bool CommandQueueInProgress = false;
//new public Dictionary<string, DspControlPoint> DialerControlPoints { get; private set; }
//new public Dictionary<string, DspControlPoint> SwitcherControlPoints { get; private set; }
/// <summary>
/// Shows received lines as hex
/// </summary>
public bool ShowHexResponse { get; set; }
public AnalogWayLiveCore(string key, string name, IBasicCommunication comm, AnalogWayLiveCorePropertiesConfig props) :
base(key, name)
{
this.userName = props.userName;
this.password = props.password;
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);
}
else
{
// This instance uses RS-232 control
}
PortGather = new CommunicationGather(Communication, "\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, "System.Status\x0A\x0D");
}
}
public override bool CustomActivate()
{
Communication.Connect();
CommunicationMonitor.StatusChange += (o, a) => { Debug.Console(2, this, "Communication monitor state: {0}", CommunicationMonitor.Status); };
CommunicationMonitor.Start();
OnlineFeedback = new BoolFeedback(() => { return OnlineStatus; });
PresetFeedback = new IntFeedback(() => { return CurrentPreset; });
CrestronConsole.AddNewConsoleCommand(SendLine, "send" + Key, "", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s => Communication.Connect(), "con" + Key, "", ConsoleAccessLevelEnum.AccessOperator);
return true;
}
void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e)
{
Debug.Console(2, this, "Socket Status Change: {0}", e.Client.ClientStatus.ToString());
if (e.Client.IsConnected)
{
OnlineStatus = true;
OnlineFeedback.FireUpdate();
}
else
{
OnlineStatus = false;
OnlineFeedback.FireUpdate();
if (SubscriptionTimer != null)
{
SubscriptionTimer.Stop();
SubscriptionTimer = null;
}
isSubscribed = false;
CommandQueue.Clear();
CommandQueueInProgress = false;
}
}
/// <summary>
/// Initiates the subscription process to the DSP
/// </summary>
/// <summary>
/// Handles a response message from the DSP
/// </summary>
/// <param name="dev"></param>
/// <param name="args"></param>
void Port_LineReceived(object dev, GenericCommMethodReceiveTextArgs args)
{
try
{
if (args.Text.IndexOf("login") > -1)
{
SendLine(string.Format("Login({0},{1})", this.userName, this.password));
}
else if (args.Text.IndexOf("!Done Preset.Take =") > -1)
{
string presetNumberParse = args.Text.Remove(0, args.Text.IndexOf("=") + 2);
Debug.Console(1, this, "Preset Parse: {0}", presetNumberParse);
CurrentPreset = ushort.Parse(presetNumberParse);
PresetFeedback.FireUpdate();
}
}
catch (Exception e)
{
if (Debug.Level == 2)
Debug.Console(2, this, "Error parsing response: '{0}'\n{1}", args.Text, e);
}
}
/// <summary>
/// Sends a command to the DSP (with delimiter appended)
/// </summary>
/// <param name="s">Command to send</param>
public void SendLine(string s)
{
Communication.SendText(s + "\x0d\x0a");
}
/// <summary>
/// Adds a command from a child module to the queue
/// </summary>
/// <param name="command">Command object from child module</param>
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();
}
/// <summary>
/// Adds a raw string command to the queue
/// </summary>
/// <param name="command"></param>
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();
}
/// <summary>
/// Sends the next queued command to the DSP
/// </summary>
void SendNextQueuedCommand()
{
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);
}
}
}
public void CallPreset(ushort presetNumber)
{
SendLine(string.Format("Preset.Take = {0}", presetNumber));
// SendLine("cgp 1");
}
public class QueuedCommand
{
public string Command { get; set; }
public string AttributeCode { get; set; }
// public QscDspControlPoint ControlPoint { get; set; }
}
}
public class AnalogWayLiveCoreFactory : EssentialsDeviceFactory<AnalogWayLiveCore>
{
public AnalogWayLiveCoreFactory()
{
TypeNames = new List<string>() { "analogwaylivecore" };
}
public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
Debug.Console(1, "Factory Attempting to create new AnalogWayLiveCore Device");
var comm = CommFactory.CreateCommForDevice(dc);
var props = Newtonsoft.Json.JsonConvert.DeserializeObject<AnalogWayLiveCorePropertiesConfig>(
dc.Properties.ToString());
return new AnalogWayLiveCore(dc.Key, dc.Name, comm, props);
}
}
}

View file

@ -0,0 +1,241 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using System.Text.RegularExpressions;
namespace PepperDash.Essentials.Devices.Common
{
public class TVOneCorio : Device
{
public IBasicCommunication Communication { get; private set; }
public CommunicationGather PortGather { get; private set; }
public StatusMonitorBase CommunicationMonitor { get; private set; }
public string userName;
public string password;
private bool OnlineStatus;
public BoolFeedback OnlineFeedback;
private ushort CurrentPreset;
public IntFeedback PresetFeedback;
// new public Dictionary<string, QscDspLevelControl> LevelControlPoints { get; private set; }
// public List<QscDspPresets> PresetList = new List<QscDspPresets>();
public bool isSubscribed;
private CTimer SubscriptionTimer;
CrestronQueue CommandQueue;
bool CommandQueueInProgress = false;
//new public Dictionary<string, DspControlPoint> DialerControlPoints { get; private set; }
//new public Dictionary<string, DspControlPoint> SwitcherControlPoints { get; private set; }
/// <summary>
/// Shows received lines as hex
/// </summary>
public bool ShowHexResponse { get; set; }
public TVOneCorio(string key, string name, IBasicCommunication comm, TVOneCorioPropertiesConfig props) :
base(key, name)
{
this.userName = props.userName;
this.password = props.password;
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);
}
else
{
// This instance uses RS-232 control
}
PortGather = new CommunicationGather(Communication, "\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, "System.Status\x0A\x0D");
}
}
public override bool CustomActivate()
{
Communication.Connect();
CommunicationMonitor.StatusChange += (o, a) => { Debug.Console(2, this, "Communication monitor state: {0}", CommunicationMonitor.Status); };
CommunicationMonitor.Start();
OnlineFeedback = new BoolFeedback(() => { return OnlineStatus; });
PresetFeedback = new IntFeedback(() => { return CurrentPreset; });
CrestronConsole.AddNewConsoleCommand(SendLine, "send" + Key, "", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s => Communication.Connect(), "con" + Key, "", ConsoleAccessLevelEnum.AccessOperator);
return true;
}
void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e)
{
Debug.Console(2, this, "Socket Status Change: {0}", e.Client.ClientStatus.ToString());
if (e.Client.IsConnected)
{
OnlineStatus = true;
OnlineFeedback.FireUpdate();
}
else
{
OnlineStatus = false;
OnlineFeedback.FireUpdate();
if (SubscriptionTimer != null)
{
SubscriptionTimer.Stop();
SubscriptionTimer = null;
}
isSubscribed = false;
CommandQueue.Clear();
CommandQueueInProgress = false;
}
}
/// <summary>
/// Initiates the subscription process to the DSP
/// </summary>
/// <summary>
/// Handles a response message from the DSP
/// </summary>
/// <param name="dev"></param>
/// <param name="args"></param>
void Port_LineReceived(object dev, GenericCommMethodReceiveTextArgs args)
{
Debug.Console(2, this, "TVOneCurio RX: '{0}'", args.Text);
try
{
if (args.Text.IndexOf("login") > -1)
{
SendLine(string.Format("Login({0},{1})", this.userName, this.password));
}
else if (args.Text.IndexOf("!Done Preset.Take =") > -1)
{
string presetNumberParse = args.Text.Remove(0, args.Text.IndexOf("=") + 2);
Debug.Console(1, this, "Preset Parse: {0}", presetNumberParse);
CurrentPreset = ushort.Parse(presetNumberParse);
PresetFeedback.FireUpdate();
}
}
catch (Exception e)
{
if (Debug.Level == 2)
Debug.Console(2, this, "Error parsing response: '{0}'\n{1}", args.Text, e);
}
}
/// <summary>
/// Sends a command to the DSP (with delimiter appended)
/// </summary>
/// <param name="s">Command to send</param>
public void SendLine(string s)
{
Debug.Console(1, this, "TVOne Cusio TX: '{0}'", s);
Communication.SendText(s + "\x0d\x0a");
}
/// <summary>
/// Adds a command from a child module to the queue
/// </summary>
/// <param name="command">Command object from child module</param>
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();
}
/// <summary>
/// Adds a raw string command to the queue
/// </summary>
/// <param name="command"></param>
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();
}
/// <summary>
/// Sends the next queued command to the DSP
/// </summary>
void SendNextQueuedCommand()
{
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);
}
}
}
public void CallPreset(ushort presetNumber)
{
SendLine(string.Format("Preset.Take = {0}", presetNumber));
// SendLine("cgp 1");
}
public class QueuedCommand
{
public string Command { get; set; }
public string AttributeCode { get; set; }
// public QscDspControlPoint ControlPoint { get; set; }
}
}
}

View file

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Devices.Common
{
/// <summary>
///
/// </summary>
public class TVOneCorioPropertiesConfig
{
public CommunicationMonitorConfig CommunicationMonitorProperties { get; set; }
public ControlPropertiesConfig Control { get; set; }
public string userName { get; set; }
public string password { get; set; }
}
}

View file

@ -0,0 +1,41 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<OutputPath>bin\$(Configuration)\</OutputPath>
<AssemblyName>PepperDash.Essentials.Devices.Common</AssemblyName>
<RootNamespace>PepperDash.Essentials.Devices.Common</RootNamespace>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Title>PepperDash Essentials Devices Common</Title>
<Authors>PepperDash Technologies</Authors>
<Company>PepperDash Technologies</Company>
<Product>PepperDash Essentials</Product>
<Copyright>Copyright © 2023</Copyright>
<RepositoryUrl>https://github.com/PepperDash/Essentials</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>Crestron; 4series</PackageTags>
<PackageOutputPath>../../output</PackageOutputPath>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
</PropertyGroup>
<ItemGroup>
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PepperDash.Essentials.Core\PepperDash.Essentials.Core.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.19.36" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2">
<Aliases>Full</Aliases>
</PackageReference>
<PackageReference Include="PepperDashCore" Version="2.0.0-beta-318" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Devices.Common
{
/// <summary>
///
/// </summary>
public class DigitalLoggerPropertiesConfig
{
public CommunicationMonitorConfig CommunicationMonitorProperties { get; set; }
public ControlPropertiesConfig Control { get; set; }
public string userName { get; set; }
public string password { get; set; }
public string address { get; set; }
}
}

View file

@ -0,0 +1,356 @@
extern alias Full;
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 System.Text.RegularExpressions;
using Crestron.SimplSharp.Net.Http;
using Full.Newtonsoft.Json;
using Full.Newtonsoft.Json.Linq;
using PepperDash.Essentials.Core.Bridges;
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
{
public IBasicCommunication Communication { get; private set; }
public CommunicationGather PortGather { get; private set; }
public StatusMonitorBase CommunicationMonitor { get; private set; }
private HttpClient WebClient;
public string userName;
public string password;
public string address;
private bool OnlineStatus;
public BoolFeedback OnlineFeedback;
//private ushort CurrentPreset;
public IntFeedback PresetFeedback;
public Dictionary<uint, DigitalLoggerCircuit> CircuitStatus;
public uint CircuitCount;
public Dictionary<uint, StringFeedback> CircuitNameFeedbacks { get; private set; }
public Dictionary<uint, BoolFeedback> CircuitIsCritical{ get; private set; }
public Dictionary<uint, BoolFeedback> CircuitState { get; private set; }
// new public Dictionary<string, QscDspLevelControl> LevelControlPoints { get; private set; }
// public List<QscDspPresets> PresetList = new List<QscDspPresets>();
public bool isSubscribed;
private CTimer SubscriptionTimer;
CrestronQueue CommandQueue;
bool CommandQueueInProgress = false;
//new public Dictionary<string, DspControlPoint> DialerControlPoints { get; private set; }
//new public Dictionary<string, DspControlPoint> SwitcherControlPoints { get; private set; }
/// <summary>
/// Shows received lines as hex
/// </summary>
public bool ShowHexResponse { get; set; }
public DigitalLogger(string key, string name, DigitalLoggerPropertiesConfig props) :
base(key, name)
{
CircuitCount = 8;
this.userName = props.userName;
this.password = props.password;
CommandQueue = new CrestronQueue(100);
WebClient = new HttpClient();
WebClient.UserName = this.userName;
WebClient.Password = this.password;
this.address = props.address;
WebClient.HostAddress = props.address;
}
public override bool CustomActivate()
{
/*
Communication.Connect();
CommunicationMonitor.StatusChange += (o, a) => { Debug.Console(2, this, "Communication monitor state: {0}", CommunicationMonitor.Status); };
CommunicationMonitor.Start();
*/
OnlineFeedback = new BoolFeedback(() => { return OnlineStatus; });
CircuitStatus = new Dictionary<uint, DigitalLoggerCircuit>();
CircuitNameFeedbacks = new Dictionary<uint, StringFeedback>();
CircuitIsCritical = new Dictionary<uint, BoolFeedback>();
CircuitState = new Dictionary<uint, BoolFeedback>();
for (uint i = 0; i < CircuitCount; i++)
{
uint circuit = i;
CircuitStatus[circuit] = new DigitalLoggerCircuit();
CircuitNameFeedbacks[circuit] = new StringFeedback(() => {
if (CircuitStatus[circuit].name != null)
{
return CircuitStatus[circuit].name;
}
else
{
return "";
}
});
CircuitIsCritical[circuit] = new BoolFeedback(() =>
{
if (CircuitStatus.ContainsKey(circuit))
{
return CircuitStatus[circuit].critical;
}
else
{
return false;
}
});
CircuitState[circuit] = new BoolFeedback(() =>
{
if (CircuitStatus.ContainsKey(circuit))
{
return CircuitStatus[circuit].state;
}
else
{
return false;
}
});
PollCircuit(circuit);
}
CrestronConsole.AddNewConsoleCommand(SendLine, "send" + Key, "", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s => Communication.Connect(), "con" + Key, "", ConsoleAccessLevelEnum.AccessOperator);
return true;
}
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{
var joinMap = new DigitalLoggerJoinMap();
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<DigitalLoggerJoinMap>(joinMapSerialized);
joinMap.OffsetJoinNumbers(joinStart);
Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
for (uint i = 1; i <= CircuitCount; i++)
{
var circuit = i;
CircuitNameFeedbacks[circuit - 1].LinkInputSig(trilist.StringInput[joinMap.CircuitNames + circuit]);
CircuitIsCritical[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitIsCritical + circuit]);
CircuitState[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitState + circuit]);
trilist.SetSigTrueAction(joinMap.CircuitCycle + circuit, () => CycleCircuit(circuit - 1));
trilist.SetSigTrueAction(joinMap.CircuitOnCmd + circuit, () => TurnOnCircuit(circuit - 1));
trilist.SetSigTrueAction(joinMap.CircuitOffCmd + circuit, () => TurnOffCircuit(circuit - 1));
}
}
void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e)
{
Debug.Console(2, this, "Socket Status Change: {0}", e.Client.ClientStatus.ToString());
if (e.Client.IsConnected)
{
OnlineStatus = true;
OnlineFeedback.FireUpdate();
}
else
{
OnlineStatus = false;
OnlineFeedback.FireUpdate();
if (SubscriptionTimer != null)
{
SubscriptionTimer.Stop();
SubscriptionTimer = null;
}
isSubscribed = false;
CommandQueue.Clear();
CommandQueueInProgress = false;
}
}
public void PollCircuit(uint circuit)
{
try
{
string PollCircuitResponse = SendRequest(String.Format("/restapi/relay/outlets/{0}/", circuit));
CircuitStatus[circuit] = JsonConvert.DeserializeObject<DigitalLoggerCircuit>(PollCircuitResponse);
DigitalLoggerCircuit temp = CircuitStatus[circuit];
Debug.Console(2, this, "DigitalLogger Circuit {0} Name: {1} State:{2}'", circuit, CircuitStatus[circuit].name, CircuitStatus[circuit].state);
CircuitNameFeedbacks[circuit].FireUpdate();
CircuitState[circuit].FireUpdate();
CircuitIsCritical[circuit].FireUpdate();
}
catch (Exception e)
{
Debug.Console(0, this, "PollCircuit {0}", e);
}
}
void Port_LineReceived(string response, HTTP_CALLBACK_ERROR error)
{
}
public string SendRequest(string s)
{
HttpClientRequest request = new HttpClientRequest();
string url = string.Format("http://{0}{1}", this.address, s);
request.Url = new UrlParser(url);
HttpClientResponse response = WebClient.Dispatch(request);
return response.ContentString;
}
/// <summary>
/// Sends a command to the DSP (with delimiter appended)
/// </summary>
/// <param name="s">Command to send</param>
///
public void SendLine(string s)
{
HttpClientRequest request = new HttpClientRequest();
string url = string.Format("http://{0}{1}", this.address, s);
request.Url = new UrlParser(url);
HttpClientResponse response = WebClient.Dispatch(request);
}
public void CycleCircuit(uint circuit)
{
SendLine(String.Format("/outlet?{0}=CCL", circuit));
//PollCircuit(circuit);
}
public void TurnOnCircuit(uint circuit)
{
SendLine(String.Format("/outlet?{0}=ON", circuit));
//PollCircuit(circuit);
}
public void TurnOffCircuit(uint circuit)
{
SendLine(String.Format("/outlet?{0}=Off", circuit));
//PollCircuit(circuit);
}
/// <summary>
/// Adds a command from a child module to the queue
/// </summary>
/// <param name="command">Command object from child module</param>
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();
}
/// <summary>
/// Adds a raw string command to the queue
/// </summary>
/// <param name="command"></param>
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();
}
/// <summary>
/// Sends the next queued command to the DSP
/// </summary>
void SendNextQueuedCommand()
{
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);
}
}
}
public void CallPreset(ushort presetNumber)
{
SendLine(string.Format("Preset.Take = {0}", presetNumber));
// SendLine("cgp 1");
}
public class QueuedCommand
{
public string Command { get; set; }
public string AttributeCode { get; set; }
// public QscDspControlPoint ControlPoint { get; set; }
}
public class DigitalLoggerCircuit
{
public string name;
public bool locked;
public bool critical;
public bool transient_state;
public bool physical_state;
//public int cycle_delay;
public bool state;
}
}
public class DigitalLoggerFactory : EssentialsDeviceFactory<DigitalLogger>
{
public DigitalLoggerFactory()
{
TypeNames = new List<string>() { "digitallogger" };
}
public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
Debug.Console(1, "Factory Attempting to create new DigitalLogger Device");
var props = JsonConvert.DeserializeObject<DigitalLoggerPropertiesConfig>(
dc.Properties.ToString());
return new DigitalLogger(dc.Key, dc.Name, props);
}
}
}

View file

@ -0,0 +1,520 @@
extern alias Full;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using Full.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<RoutingOutputPort> { 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);
}
/// <summary>
/// Defaults to true
/// </summary>
public bool HasKeypadAccessoryButton1 { get; set; }
/// <summary>
/// Defaults to "-"
/// </summary>
public string KeypadAccessoryButton1Label { get; set; }
/// <summary>
/// Defaults to "Dash"
/// </summary>
public string KeypadAccessoryButton1Command { get; set; }
public void KeypadAccessoryButton1(bool pressRelease)
{
IrPort.PressRelease(KeypadAccessoryButton1Command, pressRelease);
}
/// <summary>
/// Defaults to true
/// </summary>
public bool HasKeypadAccessoryButton2 { get; set; }
/// <summary>
/// Defaults to "Enter"
/// </summary>
public string KeypadAccessoryButton2Label { get; set; }
/// <summary>
/// Defaults to "Enter"
/// </summary>
public string KeypadAccessoryButton2Command { get; set; }
public void KeypadAccessoryButton2(bool pressRelease)
{
IrPort.PressRelease(KeypadAccessoryButton2Command, pressRelease);
}
#endregion
#region ISetTopBoxNumericKeypad Members
/// <summary>
/// Corresponds to "dash" IR command
/// </summary>
public void Dash(bool pressRelease)
{
IrPort.PressRelease("dash", pressRelease);
}
/// <summary>
/// Corresponds to "numericEnter" IR command
/// </summary>
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<RoutingOutputPort> 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<SetTopBoxControllerJoinMap>(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<IRSetTopBoxBase>
{
public IRSetTopBoxBaseFactory()
{
TypeNames = new List<string>() { "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<SetTopBoxPropertiesConfig>();
var stb = new IRSetTopBoxBase(dc.Key, dc.Name, irCont, config);
var listName = dc.Properties.Value<string>("presetsList");
if (listName != null)
stb.LoadPresets(listName);
return stb;
}
}
}

View file

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
namespace PepperDash.Essentials.Devices.Common
{
public class SetTopBoxPropertiesConfig : PepperDash.Essentials.Core.Config.SourceDevicePropertiesConfigBase
{
public bool HasPresets { get; set; }
public bool HasDvr { get; set; }
public bool HasDpad { get; set; }
public bool HasNumeric { get; set; }
public int IrPulseTime { get; set; }
public ControlPropertiesConfig Control { get; set; }
}
}

View file

@ -0,0 +1,179 @@
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.Routing;
using PepperDash.Essentials.Core.Devices;
using PepperDash.Essentials.Core.Config;
namespace PepperDash.Essentials.Devices.Common.SoftCodec
{
public class BlueJeansPc : InRoomPc, IRoutingInputs, IRunRouteAction, IRoutingSinkNoSwitching
{
public RoutingInputPort AnyVideoIn { get; private set; }
#region IRoutingInputs Members
public RoutingPortCollection<RoutingInputPort> InputPorts { get; private set; }
#endregion
public BlueJeansPc(string key, string name)
: base(key, name)
{
InputPorts = new RoutingPortCollection<RoutingInputPort>();
InputPorts.Add(AnyVideoIn = new RoutingInputPort(RoutingPortNames.AnyVideoIn, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.None, 0, this));
}
#region IRunRouteAction Members
public void RunRouteAction(string routeKey, string sourceListKey)
{
RunRouteAction(routeKey, sourceListKey, null);
}
public void RunRouteAction(string routeKey, string sourceListKey, Action successCallback)
{
CrestronInvoke.BeginInvoke(o =>
{
Debug.Console(1, this, "Run route action '{0}' on SourceList: {1}", routeKey, sourceListKey);
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];
foreach (var route in item.RouteList)
{
DoRoute(route);
}
// store the name and UI info for routes
if (item.SourceKey == "none")
{
CurrentSourceInfoKey = routeKey;
CurrentSourceInfo = null;
}
else if (item.SourceKey != null)
{
CurrentSourceInfoKey = routeKey;
CurrentSourceInfo = item;
}
// report back when done
if (successCallback != null)
successCallback();
});
}
#endregion
/// <summary>
///
/// </summary>
/// <param name="route"></param>
/// <returns></returns>
bool DoRoute(SourceRouteListItem route)
{
IRoutingSinkNoSwitching dest = null;
dest = DeviceManager.GetDeviceForKey(route.DestinationKey) as IRoutingSinkNoSwitching;
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;
}
#region IHasCurrentSourceInfoChange Members
public string CurrentSourceInfoKey { get; set; }
/// <summary>
/// The SourceListItem last run - containing names and icons
/// </summary>
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 event SourceInfoChangeHandler CurrentSourceChange;
#endregion
}
public class BlueJeansPcFactory : EssentialsDeviceFactory<BlueJeansPc>
{
public BlueJeansPcFactory()
{
TypeNames = new List<string>() { "bluejeanspc" };
}
public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
Debug.Console(1, "Factory Attempting to create new BlueJeansPc Device");
return new SoftCodec.BlueJeansPc(dc.Key, dc.Name);
}
}
}

View file

@ -0,0 +1,220 @@
extern alias Full;
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 Full.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<RoutingOutputPort> { 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<string>())
{
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);
}
/// <summary>
/// Not implemented
/// </summary>
/// <param name="pressRelease"></param>
public void Rewind(bool pressRelease)
{
}
/// <summary>
/// Not implemented
/// </summary>
/// <param name="pressRelease"></param>
public void FFwd(bool pressRelease)
{
}
/// <summary>
/// Not implemented
/// </summary>
/// <param name="pressRelease"></param>
public void ChapMinus(bool pressRelease)
{
}
/// <summary>
/// Not implemented
/// </summary>
/// <param name="pressRelease"></param>
public void ChapPlus(bool pressRelease)
{
}
/// <summary>
/// Not implemented
/// </summary>
/// <param name="pressRelease"></param>
public void Stop(bool pressRelease)
{
}
/// <summary>
/// Not implemented
/// </summary>
/// <param name="pressRelease"></param>
public void Record(bool pressRelease)
{
}
#endregion
#region IRoutingOutputs Members
public RoutingOutputPort HdmiOut { get; private set; }
public RoutingOutputPort AnyAudioOut { get; private set; }
public RoutingPortCollection<RoutingOutputPort> 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<AppleTvJoinMap>(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<AppleTV>
{
public AppleTVFactory()
{
TypeNames = new List<string>() { "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";
}
}

View file

@ -0,0 +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 PepperDash.Core;
using PepperDash.Essentials.Core;
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
{
[Api]
public IrOutputPortController IrPort { get; private set; }
public const string StandardDriverName = "Roku XD_S.ir";
[Api]
public uint DisplayUiType { get { return DisplayUiConstants.TypeRoku; } }
public Roku2(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);
OutputPorts = new RoutingPortCollection<RoutingOutputPort> { HdmiOut };
}
#region IDPad Members
[Api]
public void Up(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_UP_ARROW, pressRelease);
}
[Api]
public void Down(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_DN_ARROW, pressRelease);
}
[Api]
public void Left(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_LEFT_ARROW, pressRelease);
}
[Api]
public void Right(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_RIGHT_ARROW, pressRelease);
}
[Api]
public void Select(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_ENTER, pressRelease);
}
[Api]
public void Menu(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_MENU, pressRelease);
}
[Api]
public void Exit(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_EXIT, pressRelease);
}
#endregion
#region ITransport Members
[Api]
public void Play(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_PLAY, pressRelease);
}
[Api]
public void Pause(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_PAUSE, pressRelease);
}
[Api]
public void Rewind(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_RSCAN, pressRelease);
}
[Api]
public void FFwd(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_FSCAN, pressRelease);
}
/// <summary>
/// Not implemented
/// </summary>
/// <param name="pressRelease"></param>
public void ChapMinus(bool pressRelease)
{
}
/// <summary>
/// Not implemented
/// </summary>
/// <param name="pressRelease"></param>
public void ChapPlus(bool pressRelease)
{
}
/// <summary>
/// Not implemented
/// </summary>
/// <param name="pressRelease"></param>
public void Stop(bool pressRelease)
{
}
/// <summary>
/// Not implemented
/// </summary>
/// <param name="pressRelease"></param>
public void Record(bool pressRelease)
{
}
#endregion
#region IRoutingOutputs Members
public RoutingOutputPort HdmiOut { get; private set; }
public RoutingPortCollection<RoutingOutputPort> OutputPorts { get; private set; }
#endregion
}
public class Roku2Factory : EssentialsDeviceFactory<Roku2>
{
public Roku2Factory()
{
TypeNames = new List<string>() { "roku" };
}
public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
Debug.Console(1, "Factory Attempting to create new Roku Device");
var irCont = IRPortHelper.GetIrOutputPortController(dc);
return new Roku2(dc.Key, dc.Name, irCont);
}
}
}

View file

@ -0,0 +1,446 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
using PepperDash.Essentials.Devices.Common.Codec;
namespace PepperDash.Essentials.Devices.Common.VideoCodec
{
public class CiscoCodecBookings
{
public class TotalRows
{
public string Value { get; set; }
}
public class ResultInfo
{
public TotalRows TotalRows { get; set; }
}
public class LastUpdated
{
string _value;
public DateTime Value {
get
{
DateTime _valueDateTime;
try
{
_valueDateTime = DateTime.Parse(_value);
return _valueDateTime;
}
catch
{
return new DateTime();
}
}
set
{
_value = value.ToString();
}
}
}
public class Id
{
public string Value { get; set; }
}
public class Title
{
public string Value { get; set; }
}
public class Agenda
{
public string Value { get; set; }
}
public class Privacy
{
public string Value { get; set; }
}
public class FirstName
{
public string Value { get; set; }
}
public class LastName
{
public string Value { get; set; }
}
public class Email
{
public string Value { get; set; }
}
public class Id2
{
public string Value { get; set; }
}
public class Organizer
{
public FirstName FirstName { get; set; }
public LastName LastName { get; set; }
public Email Email { get; set; }
public Id2 Id { get; set; }
public Organizer()
{
FirstName = new FirstName();
LastName = new LastName();
Email = new Email();
}
}
public class StartTime
{
public DateTime Value { get; set; }
}
public class StartTimeBuffer
{
public string Value { get; set; }
}
public class EndTime
{
public DateTime Value { get; set; }
}
public class EndTimeBuffer
{
public string Value { get; set; }
}
public class Time
{
public StartTime StartTime { get; set; }
public StartTimeBuffer StartTimeBuffer { get; set; }
public EndTime EndTime { get; set; }
public EndTimeBuffer EndTimeBuffer { get; set; }
public Time()
{
StartTime = new StartTime();
EndTime = new EndTime();
}
}
public class MaximumMeetingExtension
{
public string Value { get; set; }
}
public class MeetingExtensionAvailability
{
public string Value { get; set; }
}
public class BookingStatus
{
public string Value { get; set; }
}
public class BookingStatusMessage
{
public string Value { get; set; }
}
public class Enabled
{
public string Value { get; set; }
}
public class Url
{
public string Value { get; set; }
}
public class MeetingNumber
{
public string Value { get; set; }
}
public class Password
{
public string Value { get; set; }
}
public class HostKey
{
public string Value { get; set; }
}
public class DialInNumbers
{
}
public class Webex
{
public Enabled Enabled { get; set; }
public Url Url { get; set; }
public MeetingNumber MeetingNumber { get; set; }
public Password Password { get; set; }
public HostKey HostKey { get; set; }
public DialInNumbers DialInNumbers { get; set; }
}
public class Encryption
{
public string Value { get; set; }
}
public class Role
{
public string Value { get; set; }
}
public class Recording
{
public string Value { get; set; }
}
public class Number
{
public string Value { get; set; }
}
public class Protocol
{
public string Value { get; set; }
}
public class CallRate
{
public string Value { get; set; }
}
public class CallType
{
public string Value { get; set; }
}
public class Call
{
public string id { get; set; }
public Number Number { get; set; }
public Protocol Protocol { get; set; }
public CallRate CallRate { get; set; }
public CallType CallType { get; set; }
}
public class Calls
{
public List<Call> Call {get; set;}
}
public class ConnectMode
{
public string Value { get; set; }
}
public class DialInfo
{
public Calls Calls { get; set; }
public ConnectMode ConnectMode { get; set; }
public DialInfo()
{
Calls = new Calls();
ConnectMode = new ConnectMode();
}
}
public class Booking
{
public string id { get; set; }
public Id Id { get; set; }
public Title Title { get; set; }
public Agenda Agenda { get; set; }
public Privacy Privacy { get; set; }
public Organizer Organizer { get; set; }
public Time Time { get; set; }
public MaximumMeetingExtension MaximumMeetingExtension { get; set; }
public MeetingExtensionAvailability MeetingExtensionAvailability { get; set; }
public BookingStatus BookingStatus { get; set; }
public BookingStatusMessage BookingStatusMessage { get; set; }
public Webex Webex { get; set; }
public Encryption Encryption { get; set; }
public Role Role { get; set; }
public Recording Recording { get; set; }
public DialInfo DialInfo { get; set; }
public Booking()
{
Time = new Time();
Id = new Id();
Organizer = new Organizer();
Title = new Title();
Agenda = new Agenda();
Privacy = new Privacy();
DialInfo = new DialInfo();
}
}
public class BookingsListResult
{
public string status { get; set; }
public ResultInfo ResultInfo { get; set; }
//public LastUpdated LastUpdated { get; set; }
public List<Booking> Booking { get; set; }
}
public class CommandResponse
{
public BookingsListResult BookingsListResult { get; set; }
}
public class RootObject
{
public CommandResponse CommandResponse { get; set; }
}
/// <summary>
/// Extracts the necessary meeting values from the Cisco bookings response ans converts them to the generic class
/// </summary>
/// <param name="bookings"></param>
/// <returns></returns>
public static List<Meeting> GetGenericMeetingsFromBookingResult(List<Booking> bookings)
{
var meetings = new List<Meeting>();
if (Debug.Level > 0)
{
Debug.Console(1, "Meetings List:\n");
}
foreach(Booking b in bookings)
{
var meeting = new Meeting();
if(b.Id != null)
meeting.Id = b.Id.Value;
if(b.Organizer != null)
meeting.Organizer = string.Format("{0}, {1}", b.Organizer.LastName.Value, b.Organizer.FirstName.Value);
if(b.Title != null)
meeting.Title = b.Title.Value;
if(b.Agenda != null)
meeting.Agenda = b.Agenda.Value;
if(b.Time != null)
{
meeting.StartTime = b.Time.StartTime.Value;
meeting.EndTime = b.Time.EndTime.Value;
}
if(b.Privacy != null)
meeting.Privacy = CodecCallPrivacy.ConvertToDirectionEnum(b.Privacy.Value);
//#warning Update this ConnectMode conversion after testing onsite. Expected value is "OBTP", but in PD NYC Test scenarios, "Manual" is being returned for OBTP meetings
if (b.DialInfo.ConnectMode != null)
if (b.DialInfo.ConnectMode.Value.ToLower() == "obtp" || b.DialInfo.ConnectMode.Value.ToLower() == "manual")
meeting.IsOneButtonToPushMeeting = true;
if (b.DialInfo.Calls.Call != null)
{
foreach (Call c in b.DialInfo.Calls.Call)
{
meeting.Calls.Add(new PepperDash.Essentials.Devices.Common.Codec.Call()
{
Number = c.Number.Value,
Protocol = c.Protocol.Value,
CallRate = c.CallRate.Value,
CallType = c.CallType.Value
});
}
}
meetings.Add(meeting);
if(Debug.Level > 0)
{
Debug.Console(1, "Title: {0}, ID: {1}, Organizer: {2}, Agenda: {3}", meeting.Title, meeting.Id, meeting.Organizer, meeting.Agenda);
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 static List<Meeting> GetGenericMeetingsFromBookingResult(List<Booking> bookings, int joinableCooldownSeconds)
{
var meetings = new List<Meeting>();
if (Debug.Level > 0)
{
Debug.Console(1, "Meetings List:\n");
}
foreach (Booking b in bookings)
{
var meeting = new Meeting(joinableCooldownSeconds);
if (b.Id != null)
meeting.Id = b.Id.Value;
if (b.Organizer != null)
meeting.Organizer = string.Format("{0}, {1}", b.Organizer.LastName.Value, b.Organizer.FirstName.Value);
if (b.Title != null)
meeting.Title = b.Title.Value;
if (b.Agenda != null)
meeting.Agenda = b.Agenda.Value;
if (b.Time != null)
{
meeting.StartTime = b.Time.StartTime.Value;
meeting.EndTime = b.Time.EndTime.Value;
}
if (b.Privacy != null)
meeting.Privacy = CodecCallPrivacy.ConvertToDirectionEnum(b.Privacy.Value);
//#warning Update this ConnectMode conversion after testing onsite. Expected value is "OBTP", but in PD NYC Test scenarios, "Manual" is being returned for OBTP meetings
if (b.DialInfo.ConnectMode != null)
if (b.DialInfo.ConnectMode.Value.ToLower() == "obtp" || b.DialInfo.ConnectMode.Value.ToLower() == "manual")
meeting.IsOneButtonToPushMeeting = true;
if (b.DialInfo.Calls.Call != null)
{
foreach (Call c in b.DialInfo.Calls.Call)
{
meeting.Calls.Add(new PepperDash.Essentials.Devices.Common.Codec.Call()
{
Number = c.Number.Value,
Protocol = c.Protocol.Value,
CallRate = c.CallRate.Value,
CallType = c.CallType.Value
});
}
}
meetings.Add(meeting);
if (Debug.Level > 0)
{
Debug.Console(1, "Title: {0}, ID: {1}, Organizer: {2}, Agenda: {3}", meeting.Title, meeting.Id, meeting.Organizer, meeting.Agenda);
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;
}
}
}

View file

@ -0,0 +1,97 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Devices.Common.VideoCodec
{
public class CiscoCallHistory
{
public class CallbackNumber
{
public string Value { get; set; }
}
public class DisplayName
{
public string Value { get; set; }
}
public class LastOccurrenceStartTime
{
public DateTime Value { get; set; }
}
public class LastOccurrenceDaysAgo
{
public string Value { get; set; }
}
public class LastOccurrenceHistoryId
{
public string Value { get; set; }
}
public class OccurrenceType
{
public string Value { get; set; }
}
public class IsAcknowledged
{
public string Value { get; set; }
}
public class OccurrenceCount
{
public string Value { get; set; }
}
public class Entry
{
public string id { get; set; }
public CallbackNumber CallbackNumber { get; set; }
public DisplayName DisplayName { get; set; }
public LastOccurrenceStartTime LastOccurrenceStartTime { get; set; }
public LastOccurrenceDaysAgo LastOccurrenceDaysAgo { get; set; }
public LastOccurrenceHistoryId LastOccurrenceHistoryId { get; set; }
public OccurrenceType OccurrenceType { get; set; }
public IsAcknowledged IsAcknowledged { get; set; }
public OccurrenceCount OccurrenceCount { get; set; }
}
public class Offset
{
public string Value { get; set; }
}
public class Limit
{
public string Value { get; set; }
}
public class ResultInfo
{
public Offset Offset { get; set; }
public Limit Limit { get; set; }
}
public class CallHistoryRecentsResult
{
public string status { get; set; }
public List<Entry> Entry { get; set; }
public ResultInfo ResultInfo { get; set; }
}
public class CommandResponse
{
public CallHistoryRecentsResult CallHistoryRecentsResult { get; set; }
}
public class RootObject
{
public CommandResponse CommandResponse { get; set; }
}
}
}

View file

@ -0,0 +1,323 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Essentials.Core.Bridges;
using PepperDash.Essentials.Devices.Common.Cameras;
namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
{
public class CiscoFarEndCamera : CameraBase, IHasCameraPtzControl, IAmFarEndCamera, IBridgeAdvanced
{
protected CiscoSparkCodec ParentCodec { get; private set; }
protected string CallId {
get
{
return (ParentCodec as CiscoSparkCodec).GetCallId();
}
}
public CiscoFarEndCamera(string key, string name, CiscoSparkCodec codec)
: base(key, name)
{
Capabilities = eCameraCapabilities.Pan | eCameraCapabilities.Tilt | eCameraCapabilities.Zoom;
ParentCodec = codec;
}
#region IHasCameraPtzControl Members
public void PositionHome()
{
// Not supported on far end camera
}
#endregion
#region IHasCameraPanControl Members
public void PanLeft()
{
ParentCodec.EnqueueCommand(string.Format("xCommand Call FarEndControl Camera Move Value: Left CallId: {0}", CallId));
}
public void PanRight()
{
ParentCodec.EnqueueCommand(string.Format("xCommand Call FarEndControl Camera Move Value: Right CallId: {0}", CallId));
}
public void PanStop()
{
Stop();
}
#endregion
#region IHasCameraTiltControl Members
public void TiltDown()
{
ParentCodec.EnqueueCommand(string.Format("xCommand Call FarEndControl Camera Move Value: Down CallId: {0}", CallId));
}
public void TiltUp()
{
ParentCodec.EnqueueCommand(string.Format("xCommand Call FarEndControl Camera Move Value: Up CallId: {0}", CallId));
}
public void TiltStop()
{
Stop();
}
#endregion
#region IHasCameraZoomControl Members
public void ZoomIn()
{
ParentCodec.EnqueueCommand(string.Format("xCommand Call FarEndControl Camera Move Value: ZoomIn CallId: {0}", CallId));
}
public void ZoomOut()
{
ParentCodec.EnqueueCommand(string.Format("xCommand Call FarEndControl Camera Move Value: ZoomOut CallId: {0}", CallId));
}
public void ZoomStop()
{
Stop();
}
#endregion
void Stop()
{
ParentCodec.EnqueueCommand(string.Format("xCommand Call FarEndControl Camera Stop CallId: {0}", CallId));
}
public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{
LinkCameraToApi(this, trilist, joinStart, joinMapKey, bridge);
}
}
public class CiscoSparkCamera : CameraBase, IHasCameraPtzControl, IHasCameraFocusControl, IBridgeAdvanced
{
/// <summary>
/// The codec this camera belongs to
/// </summary>
protected CiscoSparkCodec ParentCodec { get; private set; }
/// <summary>
/// The ID of the camera on the codec
/// </summary>
public uint CameraId { get; private set; }
/// <summary>
/// Valid range 1-15
/// </summary>
protected uint PanSpeed { get; private set; }
/// <summary>
/// Valid range 1-15
/// </summary>
protected uint TiltSpeed { get; private set; }
/// <summary>
/// Valid range 1-15
/// </summary>
protected uint ZoomSpeed { get; private set; }
private bool isPanning;
private bool isTilting;
private bool isZooming;
private bool isFocusing;
private bool isMoving
{
get
{
return isPanning || isTilting || isZooming || isFocusing;
}
}
public CiscoSparkCamera(string key, string name, CiscoSparkCodec codec, uint id)
: base(key, name)
{
// Default to all capabilties
Capabilities = eCameraCapabilities.Pan | eCameraCapabilities.Tilt | eCameraCapabilities.Zoom | eCameraCapabilities.Focus;
ParentCodec = codec;
CameraId = id;
// Set default speeds
PanSpeed = 7;
TiltSpeed = 7;
ZoomSpeed = 7;
}
// Takes a string from the camera capabilities value and converts from "ptzf" to enum bitmask
public void SetCapabilites(string capabilites)
{
var c = capabilites.ToLower();
if (c.Contains("p"))
Capabilities = Capabilities | eCameraCapabilities.Pan;
if (c.Contains("t"))
Capabilities = Capabilities | eCameraCapabilities.Tilt;
if (c.Contains("z"))
Capabilities = Capabilities | eCameraCapabilities.Zoom;
if (c.Contains("f"))
Capabilities = Capabilities | eCameraCapabilities.Focus;
}
#region IHasCameraPtzControl Members
public void PositionHome()
{
// Not supported on Internal Spark Camera
}
#endregion
#region IHasCameraPanControl Members
public void PanLeft()
{
if (!isMoving)
{
ParentCodec.EnqueueCommand(string.Format("xCommand Camera Ramp CameraId: {0} Pan: Left PanSpeed: {1}", CameraId, PanSpeed));
isPanning = true;
}
}
public void PanRight()
{
if (!isMoving)
{
ParentCodec.EnqueueCommand(string.Format("xCommand Camera Ramp CameraId: {0} Pan: Right PanSpeed: {1}", CameraId, PanSpeed));
isPanning = true;
}
}
public void PanStop()
{
ParentCodec.EnqueueCommand(string.Format("xCommand Camera Ramp CameraId: {0} Pan: Stop", CameraId));
isPanning = false;
}
#endregion
#region IHasCameraTiltControl Members
public void TiltDown()
{
if (!isMoving)
{
ParentCodec.EnqueueCommand(string.Format("xCommand Camera Ramp CameraId: {0} Tilt: Down TiltSpeed: {1}", CameraId, TiltSpeed));
isTilting = true;
}
}
public void TiltUp()
{
if (!isMoving)
{
ParentCodec.EnqueueCommand(string.Format("xCommand Camera Ramp CameraId: {0} Tilt: Up TiltSpeed: {1}", CameraId, TiltSpeed));
isTilting = true;
}
}
public void TiltStop()
{
ParentCodec.EnqueueCommand(string.Format("xCommand Camera Ramp CameraId: {0} Tilt: Stop", CameraId));
isTilting = false;
}
#endregion
#region IHasCameraZoomControl Members
public void ZoomIn()
{
if (!isMoving)
{
ParentCodec.EnqueueCommand(string.Format("xCommand Camera Ramp CameraId: {0} Zoom: In ZoomSpeed: {1}", CameraId, ZoomSpeed));
isZooming = true;
}
}
public void ZoomOut()
{
if (!isMoving)
{
ParentCodec.EnqueueCommand(string.Format("xCommand Camera Ramp CameraId: {0} Zoom: Out ZoomSpeed: {1}", CameraId, ZoomSpeed));
isZooming = true;
}
}
public void ZoomStop()
{
ParentCodec.EnqueueCommand(string.Format("xCommand Camera Ramp CameraId: {0} Zoom: Stop", CameraId));
isZooming = false;
}
#endregion
#region IHasCameraFocusControl Members
public void FocusNear()
{
if (!isMoving)
{
ParentCodec.EnqueueCommand(string.Format("xCommand Camera Ramp CameraId: {0} Focus: Near", CameraId));
isFocusing = true;
}
}
public void FocusFar()
{
if (!isMoving)
{
ParentCodec.EnqueueCommand(string.Format("xCommand Camera Ramp CameraId: {0} Focus: Far", CameraId));
isFocusing = true;
}
}
public void FocusStop()
{
ParentCodec.EnqueueCommand(string.Format("xCommand Camera Ramp CameraId: {0} Focus: Stop", CameraId));
isFocusing = false;
}
public void TriggerAutoFocus()
{
ParentCodec.EnqueueCommand(string.Format("xCommand Camera TriggerAutofocus CameraId: {0}", CameraId));
}
#endregion
public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{
LinkCameraToApi(this, trilist, joinStart, joinMapKey, bridge);
}
}
}

View file

@ -0,0 +1,205 @@
using System;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Bridges.JoinMaps;
namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
{
public class CiscoCodecJoinMap : VideoCodecControllerJoinMap
{
#region Digital
[JoinName("PresentationLocalOnly")]
public JoinDataComplete PresentationLocalOnly = new JoinDataComplete(
new JoinData
{
JoinNumber = 205,
JoinSpan = 1
},
new JoinMetadata
{
Description = "Presentation Local Only Feedback",
JoinCapabilities = eJoinCapabilities.ToSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("PresentationLocalRemote")]
public JoinDataComplete PresentationLocalRemote = new JoinDataComplete(
new JoinData
{
JoinNumber = 206,
JoinSpan = 1
},
new JoinMetadata
{
Description = "Presentation Local and Remote Feedback",
JoinCapabilities = eJoinCapabilities.ToSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("ActivateDoNotDisturbMode")]
public JoinDataComplete ActivateDoNotDisturbMode = new JoinDataComplete(
new JoinData
{
JoinNumber = 241,
JoinSpan = 1
},
new JoinMetadata
{
Description = "Activates Do Not Disturb Mode. FB High if active.",
JoinCapabilities = eJoinCapabilities.ToFromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("DeactivateDoNotDisturbMode")]
public JoinDataComplete DeactivateDoNotDisturbMode = new JoinDataComplete(
new JoinData
{
JoinNumber = 242,
JoinSpan = 1
},
new JoinMetadata
{
Description = "Deactivates Do Not Disturb Mode. FB High if deactivated.",
JoinCapabilities = eJoinCapabilities.ToFromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("ToggleDoNotDisturbMode")]
public JoinDataComplete ToggleDoNotDisturbMode = new JoinDataComplete(
new JoinData
{
JoinNumber = 243,
JoinSpan = 1
},
new JoinMetadata
{
Description = "Toggles Do Not Disturb Mode.",
JoinCapabilities = eJoinCapabilities.ToSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("ActivateStandby")]
public JoinDataComplete ActivateStandby = new JoinDataComplete(
new JoinData
{
JoinNumber = 246,
JoinSpan = 1
},
new JoinMetadata
{
Description = "Activates Standby Mode. FB High if active.",
JoinCapabilities = eJoinCapabilities.ToFromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("DeactivateStandby")]
public JoinDataComplete DeactivateStandby = new JoinDataComplete(
new JoinData
{
JoinNumber = 247,
JoinSpan = 1
},
new JoinMetadata
{
Description = "Deactivates Standby Mode. FB High if deactivated.",
JoinCapabilities = eJoinCapabilities.ToFromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("ActivateHalfWakeMode")]
public JoinDataComplete ActivateHalfWakeMode = new JoinDataComplete(
new JoinData
{
JoinNumber = 248,
JoinSpan = 1
},
new JoinMetadata
{
Description = "Activates Half Wake Mode. FB High if active.",
JoinCapabilities = eJoinCapabilities.ToFromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("EnteringStandbyMode")]
public JoinDataComplete EnteringStandbyMode = new JoinDataComplete(
new JoinData
{
JoinNumber = 249,
JoinSpan = 1
},
new JoinMetadata
{
Description = "High to indicate that the codec is entering standby mode",
JoinCapabilities = eJoinCapabilities.ToSIMPL,
JoinType = eJoinType.Digital
});
#endregion
#region Analog
[JoinName("RingtoneVolume")]
public JoinDataComplete RingtoneVolume = new JoinDataComplete(
new JoinData
{
JoinNumber = 21,
JoinSpan = 1
},
new JoinMetadata
{
Description = "Ringtone volume set/FB. Valid values are 0 - 100 in increments of 5 (5, 10, 15, 20, etc.)",
JoinCapabilities = eJoinCapabilities.ToFromSIMPL,
JoinType = eJoinType.Analog
});
[JoinName("PresentationSource")]
public JoinDataComplete PresentationSource = new JoinDataComplete(
new JoinData
{
JoinNumber = 201,
JoinSpan = 1
},
new JoinMetadata
{
Description = "Presentation set/FB. Valid values are 0 - 6 depending on the codec model.",
JoinCapabilities = eJoinCapabilities.ToFromSIMPL,
JoinType = eJoinType.Analog
});
#endregion
#region Serials
[JoinName("CommandToDevice")]
public JoinDataComplete CommandToDevice = new JoinDataComplete(
new JoinData
{
JoinNumber = 5,
JoinSpan = 1
},
new JoinMetadata
{
Description = "Sends a serial command to the device. Do not include the delimiter, it will be added automatically.",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Serial
});
#endregion
public CiscoCodecJoinMap(uint joinStart)
: base(joinStart, typeof(CiscoCodecJoinMap))
{
}
public CiscoCodecJoinMap(uint joinStart, Type type)
: base(joinStart, type)
{
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,91 @@
extern alias Full;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using Full.Newtonsoft.Json;
namespace PepperDash.Essentials.Devices.Common.Codec
{
public class CiscoSparkCodecPropertiesConfig
{
[JsonProperty("communicationMonitorProperties")]
public CommunicationMonitorConfig CommunicationMonitorProperties { get; set; }
[JsonProperty("favorites")]
public List<CodecActiveCallItem> Favorites { get; set; }
/// <summary>
/// Valid values: "Local" or "Corporate"
/// </summary>
[JsonProperty("phonebookMode")]
public string PhonebookMode { get; set; }
[JsonProperty("showSelfViewByDefault")]
public bool ShowSelfViewByDefault { get; set; }
[JsonProperty("sharing")]
public SharingProperties Sharing { get; set; }
/// <summary>
/// Enables external source switching capability
/// </summary>
[JsonProperty("externalSourceListEnabled")]
public bool ExternalSourceListEnabled { get; set; }
/// <summary>
/// The name of the routing input port on the codec to which the external switch is connected
/// </summary>
[JsonProperty("externalSourceInputPort")]
public string ExternalSourceInputPort { get; set; }
/// <summary>
/// Optionsal property to set the limit of any phonebook queries for directory or searching
/// </summary>
[JsonProperty("phonebookResultsLimit")]
public uint PhonebookResultsLimit { get; set; }
[JsonProperty("UiBranding")]
public BrandingLogoProperties UiBranding { get; set; }
[JsonProperty("cameraInfo")]
public List<CameraInfo> CameraInfo { get; set; }
public CiscoSparkCodecPropertiesConfig()
{
CameraInfo = new List<CameraInfo>();
}
}
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; }
}
/// <summary>
/// Describes configuration information for the near end cameras
/// </summary>
public class CameraInfo
{
public int CameraNumber { get; set; }
public string Name { get; set; }
public int SourceId { get; set; }
}
}

View file

@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharp.Net.Http;
using PepperDash.Core;
namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
{
public class HttpApiServer
{
public static Dictionary<string, string> ExtensionContentTypes;
public event EventHandler<OnHttpRequestArgs> ApiRequest;
public Crestron.SimplSharp.Net.Http.HttpServer HttpServer { get; private set; }
public string HtmlRoot { get; set; }
/// <summary>
/// SIMPL+ can only execute the default constructor. If you have variables that require initialization, please
/// use an Initialize method
/// </summary>
public HttpApiServer()
{
ExtensionContentTypes = new Dictionary<string, string>
{
{ ".css", "text/css" },
{ ".htm", "text/html" },
{ ".html", "text/html" },
{ ".jpg", "image/jpeg" },
{ ".jpeg", "image/jpeg" },
{ ".js", "application/javascript" },
{ ".json", "application/json" },
{ ".xml", "text/xml" },
{ ".map", "application/x-navimap" },
{ ".pdf", "application.pdf" },
{ ".png", "image/png" },
{ ".txt", "text/plain" },
};
HtmlRoot = @"\HTML";
}
public void Start(int port)
{
// TEMP - this should be inserted by configuring class
HttpServer = new Crestron.SimplSharp.Net.Http.HttpServer();
HttpServer.ServerName = "Cisco API Server";
HttpServer.KeepAlive = true;
HttpServer.Port = port;
HttpServer.OnHttpRequest += Server_Request;
HttpServer.Open();
CrestronEnvironment.ProgramStatusEventHandler += (a) =>
{
if (a == eProgramStatusEventType.Stopping)
{
HttpServer.Close();
Debug.Console(1, "Shutting down HTTP Server on port {0}", HttpServer.Port);
}
};
}
void Server_Request(object sender, OnHttpRequestArgs args)
{
if (args.Request.Header.RequestType == "OPTIONS")
{
Debug.Console(2, "Asking for OPTIONS");
args.Response.Header.SetHeaderValue("Access-Control-Allow-Origin", "*");
args.Response.Header.SetHeaderValue("Access-Control-Allow-Methods", "GET, POST, PATCH, PUT, DELETE, OPTIONS");
return;
}
string path = Uri.UnescapeDataString(args.Request.Path);
var host = args.Request.DataConnection.RemoteEndPointAddress;
//string authToken;
Debug.Console(2, "HTTP Request: {2}: Path='{0}' ?'{1}'", path, args.Request.QueryString, host);
// ----------------------------------- ADD AUTH HERE
if (path.StartsWith("/cisco/api"))
{
var handler = ApiRequest;
if (ApiRequest != null)
ApiRequest(this, args);
}
}
public static string GetContentType(string extension)
{
string type;
if (ExtensionContentTypes.ContainsKey(extension))
type = ExtensionContentTypes[extension];
else
type = "text/plain";
return type;
}
}
}

View file

@ -0,0 +1,397 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
using PepperDash.Essentials.Devices.Common.Codec;
namespace PepperDash.Essentials.Devices.Common.VideoCodec
{
public class CiscoCodecPhonebook
{
public class Offset
{
public string Value { get; set; }
}
public class Limit
{
public string Value { get; set; }
}
public class TotalRows
{
public string Value { get; set; }
}
public class ResultInfo
{
public Offset Offset { get; set; }
public Limit Limit { get; set; }
public TotalRows TotalRows { get; set; }
}
public class LocalId
{
public string Value { get; set; }
}
public class FolderId
{
public string Value { get; set; }
}
public class ParentFolderId
{
public string Value { get; set; }
}
public class Name
{
public string Value { get; set; }
}
public class Folder
{
public string id { get; set; }
public LocalId LocalId { get; set; }
public FolderId FolderId { get; set; }
public Name Name { get; set; }
public ParentFolderId ParentFolderId { get; set; }
}
public class Name2
{
public string Value { get; set; }
}
public class ContactId
{
public string Value { get; set; }
}
public class FolderId2
{
public string Value { get; set; }
}
public class Title
{
public string Value { get; set; }
}
public class ContactMethodId
{
public string Value { get; set; }
}
public class Number
{
public string Value { get; set; }
}
public class Device
{
public string Value { get; set; }
}
public class CallType
{
public string Value { get; set; }
}
public class ContactMethod
{
public string id { get; set; }
public ContactMethodId ContactMethodId { get; set; }
public Number Number { get; set; }
public Device Device { get; set; }
public CallType CallType { get; set; }
public ContactMethod()
{
ContactMethodId = new ContactMethodId();
Number = new Number();
Device = new Device();
CallType = new CallType();
}
}
public class Contact
{
public string id { get; set; }
public Name2 Name { get; set; }
public ContactId ContactId { get; set; }
public FolderId2 FolderId { get; set; }
public Title Title { get; set; }
public List<ContactMethod> ContactMethod { get; set; }
public Contact()
{
Name = new Name2();
ContactId = new ContactId();
FolderId = new FolderId2();
Title = new Title();
ContactMethod = new List<ContactMethod>();
}
}
public class PhonebookSearchResult
{
public string status { get; set; }
public ResultInfo ResultInfo { get; set; }
public List<Folder> Folder { get; set; }
public List<Contact> Contact { get; set; }
public PhonebookSearchResult()
{
Folder = new List<Folder>();
Contact = new List<Contact>();
ResultInfo = new ResultInfo();
}
}
public class CommandResponse
{
public PhonebookSearchResult PhonebookSearchResult { get; set; }
}
public class RootObject
{
public CommandResponse CommandResponse { get; set; }
}
/// <summary>
/// Extracts the folders with no ParentFolder and returns them sorted alphabetically
/// </summary>
/// <param name="result"></param>
/// <returns></returns>
public static List<DirectoryItem> GetRootFoldersFromSearchResult(PhonebookSearchResult result)
{
var rootFolders = new List<DirectoryItem>();
if (result.Folder.Count == 0)
{
return null;
}
else if (result.Folder.Count > 0)
{
if (Debug.Level > 0)
Debug.Console(1, "Phonebook Folders:\n");
foreach (Folder f in result.Folder)
{
var folder = new DirectoryFolder();
folder.Name = f.Name.Value;
folder.FolderId = f.FolderId.Value;
if (f.ParentFolderId == null)
rootFolders.Add(folder);
if (Debug.Level > 0)
Debug.Console(1, "+ {0}", folder.Name);
}
}
rootFolders.OrderBy(f => f.Name);
return rootFolders;
}
/// <summary>
/// Extracts the contacts with no FolderId and returns them sorted alphabetically
/// </summary>
/// <param name="result"></param>
/// <returns></returns>
public static List<DirectoryItem> GetRootContactsFromSearchResult(PhonebookSearchResult result)
{
var rootContacts = new List<DirectoryItem>();
if (result.Contact.Count == 0)
{
return null;
}
else if (result.Contact.Count > 0)
{
if (Debug.Level > 0)
Debug.Console(1, "Root Contacts:\n");
foreach (Contact c in result.Contact)
{
var contact = new DirectoryContact();
if (string.IsNullOrEmpty(c.FolderId.Value))
{
contact.Name = c.Name.Value;
contact.ContactId = c.ContactId.Value;
if(!string.IsNullOrEmpty(c.Title.Value))
contact.Title = c.Title.Value;
if (Debug.Level > 0)
Debug.Console(1, "{0}\nContact Methods:", contact.Name);
foreach (ContactMethod m in c.ContactMethod)
{
var tempContactMethod = new PepperDash.Essentials.Devices.Common.Codec.ContactMethod();
eContactMethodCallType callType = eContactMethodCallType.Unknown;
if (!string.IsNullOrEmpty(m.CallType.Value))
{
if (!string.IsNullOrEmpty(m.CallType.Value))
{
if (m.CallType.Value.ToLower() == "audio")
callType = eContactMethodCallType.Audio;
else if (m.CallType.Value.ToLower() == "video")
callType = eContactMethodCallType.Video;
tempContactMethod.CallType = callType;
}
}
eContactMethodDevice device = eContactMethodDevice.Unknown;
if (!string.IsNullOrEmpty(m.Device.Value))
{
if (m.Device.Value.ToLower() == "mobile")
device = eContactMethodDevice.Mobile;
else if (m.Device.Value.ToLower() == "telephone")
device = eContactMethodDevice.Telephone;
else if (m.Device.Value.ToLower() == "video")
device = eContactMethodDevice.Video;
else if (m.Device.Value.ToLower() == "other")
device = eContactMethodDevice.Other;
tempContactMethod.Device = device;
}
if (Debug.Level > 0)
Debug.Console(1, "Number: {0}", m.Number.Value);
tempContactMethod.Number = m.Number.Value;
tempContactMethod.ContactMethodId = m.ContactMethodId.Value;
contact.ContactMethods.Add(tempContactMethod);
}
rootContacts.Add(contact);
}
}
}
rootContacts.OrderBy(f => f.Name);
return rootContacts;
}
/// <summary>
/// Converts data returned from a cisco codec to the generic Directory format.
/// </summary>
/// <param name="result"></param>
/// <param name="resultFolder"></param>
/// <returns></returns>
public static CodecDirectory ConvertCiscoPhonebookToGeneric(PhonebookSearchResult result)
{
var directory = new Codec.CodecDirectory();
var folders = new List<Codec.DirectoryItem>();
var contacts = new List<Codec.DirectoryItem>();
try
{
if (result.Folder.Count > 0)
{
foreach (Folder f in result.Folder)
{
var folder = new DirectoryFolder();
folder.Name = f.Name.Value;
folder.FolderId = f.FolderId.Value;
if (f.ParentFolderId != null)
{
folder.ParentFolderId = f.ParentFolderId.Value;
}
folders.Add(folder);
}
folders.OrderBy(f => f.Name);
directory.AddFoldersToDirectory(folders);
}
if (result.Contact.Count > 0)
{
foreach (Contact c in result.Contact)
{
var contact = new DirectoryContact();
contact.Name = c.Name.Value;
contact.ContactId = c.ContactId.Value;
if (!string.IsNullOrEmpty(c.Title.Value))
contact.Title = c.Title.Value;
if (c.FolderId != null)
{
contact.FolderId = c.FolderId.Value;
}
foreach (ContactMethod m in c.ContactMethod)
{
eContactMethodCallType callType = eContactMethodCallType.Unknown;
if (!string.IsNullOrEmpty(m.CallType.Value))
{
if (m.CallType.Value.ToLower() == "audio")
callType = eContactMethodCallType.Audio;
else if (m.CallType.Value.ToLower() == "video")
callType = eContactMethodCallType.Video;
}
eContactMethodDevice device = eContactMethodDevice.Unknown;
if (!string.IsNullOrEmpty(m.Device.Value))
{
if (m.Device.Value.ToLower() == "mobile")
device = eContactMethodDevice.Mobile;
else if (m.Device.Value.ToLower() == "telephone")
device = eContactMethodDevice.Telephone;
else if (m.Device.Value.ToLower() == "video")
device = eContactMethodDevice.Video;
else if (m.Device.Value.ToLower() == "other")
device = eContactMethodDevice.Other;
}
contact.ContactMethods.Add(new PepperDash.Essentials.Devices.Common.Codec.ContactMethod()
{
Number = m.Number.Value,
ContactMethodId = m.ContactMethodId.Value,
CallType = callType,
Device = device
});
}
contacts.Add(contact);
}
contacts.OrderBy(c => c.Name);
directory.AddContactsToDirectory(contacts);
}
}
catch (Exception e)
{
Debug.Console(1, "Error converting Cisco Phonebook results to generic: {0}", e);
}
return directory;
}
}
}

View file

@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core.Presets;
namespace PepperDash.Essentials.Devices.Common.VideoCodec
{
/// <summary>
/// Interface for camera presets
/// </summary>
public interface IHasCodecRoomPresets
{
event EventHandler<EventArgs> CodecRoomPresetsListHasChanged;
List<CodecRoomPreset> NearEndPresets { get; }
List<CodecRoomPreset> FarEndRoomPresets { get; }
void CodecRoomPresetSelect(int preset);
void CodecRoomPresetStore(int preset, string description);
void SelectFarEndPreset(int preset);
}
public static class RoomPresets
{
/// <summary>
/// Converts non-generic RoomPresets to generic CameraPresets
/// </summary>
/// <param name="presets"></param>
/// <returns></returns>
public static List<TDestination> GetGenericPresets<TSource, TDestination>(this List<TSource> presets) where TSource : ConvertiblePreset where TDestination : PresetBase
{
return
presets.Select(preset => preset.ConvertCodecPreset())
.Where(newPreset => newPreset != null)
.Cast<TDestination>()
.ToList();
}
}
/// <summary>
/// Represents a room preset on a video codec. Typically stores camera position(s) and video routing. Can be recalled by Far End if enabled.
/// </summary>
public class CodecRoomPreset : PresetBase
{
public CodecRoomPreset(int id, string description, bool def, bool isDef)
: base(id, description, def, isDef)
{
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,166 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
{
/// <summary>
/// This class exists to capture serialized data sent back by a Cisco codec in JSON output mode
/// </summary>
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; }
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,9 @@
using PepperDash.Essentials.Core.Presets;
namespace PepperDash.Essentials.Devices.Common.VideoCodec
{
public abstract class ConvertiblePreset
{
public abstract PresetBase ConvertCodecPreset();
}
}

View file

@ -0,0 +1,66 @@
extern alias Full;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Essentials.Core;
using Full.Newtonsoft.Json;
namespace PepperDash.Essentials.Devices.Common.VideoCodec
{
/// <summary>
/// Defines the required elements for layout control
/// </summary>
public interface IHasCodecLayouts
{
StringFeedback LocalLayoutFeedback { get; }
void LocalLayoutToggle();
void LocalLayoutToggleSingleProminent();
void MinMaxLayoutToggle();
}
/// <summary>
/// Defines the requirements for Zoom Room layout control
/// </summary>
public interface IHasZoomRoomLayouts : IHasCodecLayouts
{
event EventHandler<LayoutInfoChangedEventArgs> LayoutInfoChanged;
BoolFeedback LayoutViewIsOnFirstPageFeedback { get; } // TODO: #697 [*] Consider modifying to report button visibility in func
BoolFeedback LayoutViewIsOnLastPageFeedback { get; } // TODO: #697 [*] Consider modifying to report button visibility in func
BoolFeedback CanSwapContentWithThumbnailFeedback { get; }
BoolFeedback ContentSwappedWithThumbnailFeedback { get; }
ZoomRoom.zConfiguration.eLayoutStyle LastSelectedLayout { get; }
ZoomRoom.zConfiguration.eLayoutStyle AvailableLayouts { get; }
void GetAvailableLayouts(); // Mot sure this is necessary if we're already subscribed to zStatus Call Layout
void SetLayout(ZoomRoom.zConfiguration.eLayoutStyle layoutStyle);
void SwapContentWithThumbnail();
void LayoutTurnNextPage();
void LayoutTurnPreviousPage();
}
public class LayoutInfoChangedEventArgs : EventArgs
{
[JsonProperty("availableLayouts", NullValueHandling = NullValueHandling.Ignore)]
public ZoomRoom.zConfiguration.eLayoutStyle AvailableLayouts { get; set; }
[JsonProperty("currentSelectedLayout", NullValueHandling = NullValueHandling.Ignore)]
public ZoomRoom.zConfiguration.eLayoutStyle CurrentSelectedLayout { get; set; }
[JsonProperty("canSwapContentWithThumbnail", NullValueHandling = NullValueHandling.Ignore)]
public bool CanSwapContentWithThumbnail { get; set; }
[JsonProperty("contentSwappedWithThumbnail", NullValueHandling = NullValueHandling.Ignore)]
public bool ContentSwappedWithThumbnail { get; set; }
[JsonProperty("layoutViewIsOnFirstPage", NullValueHandling = NullValueHandling.Ignore)]
public bool LayoutViewIsOnFirstPage { get; set; }
[JsonProperty("layoutViewIsOnLastPage", NullValueHandling = NullValueHandling.Ignore)]
public bool LayoutViewIsOnLastPage { get; set; }
}
}

View file

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Devices.Common.VideoCodec
{
/// <summary>
/// Defines the requred elements for selfview control
/// </summary>
public interface IHasCodecSelfView
{
BoolFeedback SelfviewIsOnFeedback { get; }
bool ShowSelfViewByDefault { get; }
void SelfViewModeOn();
void SelfViewModeOff();
void SelfViewModeToggle();
}
}

View file

@ -0,0 +1,79 @@
extern alias Full;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Full.Newtonsoft.Json;
namespace PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces
{
/// <summary>
/// Describes a device that provides meeting information (like a ZoomRoom)
/// </summary>
public interface IHasMeetingInfo
{
event EventHandler<MeetingInfoEventArgs> MeetingInfoChanged;
MeetingInfo MeetingInfo { get; }
}
/// <summary>
/// Represents the information about a meeting in progress
/// Currently used for Zoom meetings
/// </summary>
public class MeetingInfo
{
[JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)]
public string Id { get; private set; }
[JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)]
public string Name { get; private set; }
[JsonProperty("host", NullValueHandling = NullValueHandling.Ignore)]
public string Host { get; private set; }
[JsonProperty("password", NullValueHandling = NullValueHandling.Ignore)]
public string Password { get; private set; }
[JsonProperty("shareStatus", NullValueHandling = NullValueHandling.Ignore)]
public string ShareStatus { get; private set; }
[JsonProperty("isHost", NullValueHandling = NullValueHandling.Ignore)]
public Boolean IsHost { get; private set; }
[JsonProperty("isSharingMeeting", NullValueHandling = NullValueHandling.Ignore)]
public Boolean IsSharingMeeting { get; private set; }
[JsonProperty("waitingForHost", NullValueHandling = NullValueHandling.Ignore)]
public Boolean WaitingForHost { get; private set; }
[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 CanRecord { get; private set; }
public MeetingInfo(string id, string name, string host, string password, string shareStatus, bool isHost, bool isSharingMeeting, bool waitingForHost, bool isLocked, bool isRecording, bool canRecord)
{
Id = id;
Name = name;
Host = host;
Password = password;
ShareStatus = shareStatus;
IsHost = isHost;
IsSharingMeeting = isSharingMeeting;
WaitingForHost = waitingForHost;
IsLocked = isLocked;
IsRecording = isRecording;
CanRecord = CanRecord;
}
}
public class MeetingInfoEventArgs : EventArgs
{
public MeetingInfo Info { get; private set; }
public MeetingInfoEventArgs(MeetingInfo info)
{
Info = info;
}
}
}

View file

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces
{
public interface IHasMeetingLock
{
BoolFeedback MeetingIsLockedFeedback { get; }
void LockMeeting();
void UnLockMeeting();
void ToggleMeetingLock();
}
}

View file

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces
{
public interface IHasMeetingRecording
{
BoolFeedback MeetingIsRecordingFeedback { get; }
void StartRecording();
void StopRecording();
void ToggleRecording();
}
public interface IHasMeetingRecordingWithPrompt : IHasMeetingRecording
{
BoolFeedback RecordConsentPromptIsVisible { get; }
/// <summary>
/// Used to agree or disagree to the meeting being recorded when prompted
/// </summary>
/// <param name="agree"></param>
void RecordingPromptAcknowledgement(bool agree);
}
}

View file

@ -0,0 +1,135 @@
using System;
using System.Linq;
using System.Collections.Generic;
using PepperDash.Core;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces
{
/// <summary>
/// Describes a device that has call participants
/// </summary>
public interface IHasParticipants
{
CodecParticipants Participants { get; }
/// <summary>
/// Removes the participant from the meeting
/// </summary>
/// <param name="participant"></param>
void RemoveParticipant(int userId);
/// <summary>
/// Sets the participant as the new host
/// </summary>
/// <param name="participant"></param>
void SetParticipantAsHost(int userId);
/// <summary>
/// Admits a participant from the waiting room
/// </summary>
/// <param name="userId"></param>
void AdmitParticipantFromWaitingRoom(int userId);
}
/// <summary>
/// Describes the ability to mute and unmute a participant's video in a meeting
/// </summary>
public interface IHasParticipantVideoMute : IHasParticipants
{
void MuteVideoForParticipant(int userId);
void UnmuteVideoForParticipant(int userId);
void ToggleVideoForParticipant(int userId);
}
/// <summary>
/// Describes the ability to mute and unmute a participant's audio in a meeting
/// </summary>
public interface IHasParticipantAudioMute : IHasParticipantVideoMute
{
/// <summary>
/// Mute audio of all participants
/// </summary>
void MuteAudioForAllParticipants();
void MuteAudioForParticipant(int userId);
void UnmuteAudioForParticipant(int userId);
void ToggleAudioForParticipant(int userId);
}
/// <summary>
/// Describes the ability to pin and unpin a participant in a meeting
/// </summary>
public interface IHasParticipantPinUnpin : IHasParticipants
{
IntFeedback NumberOfScreensFeedback { get; }
int ScreenIndexToPinUserTo { get; }
void PinParticipant(int userId, int screenIndex);
void UnPinParticipant(int userId);
void ToggleParticipantPinState(int userId, int screenIndex);
}
public class CodecParticipants
{
private List<Participant> _currentParticipants;
public List<Participant> CurrentParticipants
{
get { return _currentParticipants; }
set
{
_currentParticipants = value;
OnParticipantsChanged();
}
}
public Participant Host
{
get
{
return _currentParticipants.FirstOrDefault(p => p.IsHost);
}
}
public event EventHandler<EventArgs> ParticipantsListHasChanged;
public CodecParticipants()
{
_currentParticipants = new List<Participant>();
}
public void OnParticipantsChanged()
{
var handler = ParticipantsListHasChanged;
if (handler == null) return;
handler(this, new EventArgs());
}
}
/// <summary>
/// Represents a call participant
/// </summary>
public class Participant
{
public int UserId { get; set; }
public bool IsHost { get; set; }
public bool IsMyself { get; set; }
public string Name { get; set; }
public bool CanMuteVideo { get; set; }
public bool CanUnmuteVideo { get; set; }
public bool VideoMuteFb { get; set; }
public bool AudioMuteFb { get; set; }
public bool HandIsRaisedFb { get; set; }
public bool IsPinnedFb { get; set; }
public int ScreenIndexIsPinnedToFb { get; set; }
public Participant()
{
// Initialize to -1 (no screen)
ScreenIndexIsPinnedToFb = -1;
}
}
}

View file

@ -0,0 +1,18 @@
namespace PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces
{
public interface IHasPresentationOnlyMeeting
{
void StartSharingOnlyMeeting();
void StartSharingOnlyMeeting(eSharingMeetingMode displayMode);
void StartSharingOnlyMeeting(eSharingMeetingMode displayMode, uint duration);
void StartSharingOnlyMeeting(eSharingMeetingMode displayMode, uint duration, string password);
void StartNormalMeetingFromSharingOnlyMeeting();
}
public enum eSharingMeetingMode
{
None,
Laptop,
Ios,
}
}

View file

@ -0,0 +1,14 @@
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Devices.Common.VideoCodec;
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
{
public interface IHasSelfviewPosition
{
StringFeedback SelfviewPipPositionFeedback { get; }
void SelfviewPipPositionSet(CodecCommandWithLabel position);
void SelfviewPipPositionToggle();
}
}

View file

@ -0,0 +1,13 @@
using PepperDash.Essentials.Devices.Common.VideoCodec;
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
{
public interface IHasSelfviewSize
{
StringFeedback SelfviewPipSizeFeedback { get; }
void SelfviewPipSizeSet(CodecCommandWithLabel size);
void SelfviewPipSizeToggle();
}
}

View file

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Devices.Common.VideoCodec
{
/// <summary>
/// Describes a device that has Standby Mode capability
/// </summary>
public interface IHasStandbyMode
{
BoolFeedback StandbyIsOnFeedback { get; }
void StandbyActivate();
void StandbyDeactivate();
}
/// <summary>
/// Describes a device that has Half Waek Mode capability
/// </summary>
public interface IHasHalfWakeMode : IHasStandbyMode
{
BoolFeedback HalfWakeModeIsOnFeedback { get; }
BoolFeedback EnteringStandbyModeFeedback { get; }
void HalfwakeActivate();
}
}

View file

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces
{
/// <summary>
/// Describes the ability to start an ad-hoc meeting
/// </summary>
public interface IHasStartMeeting
{
/// <summary>
/// The default meeting duration in minutes
/// </summary>
uint DefaultMeetingDurationMin { get; }
/// <summary>
/// Start an ad-hoc meeting for the specified duration
/// </summary>
/// <param name="duration"></param>
void StartMeeting(uint duration);
/// <summary>
/// Leaves a meeting without ending it
/// </summary>
void LeaveMeeting();
}
}

View file

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Devices.Common.VideoCodec
{
/// <summary>
/// For rooms that have video codec
/// </summary>
public interface IHasVideoCodec:IHasInCallFeedback,IPrivacy
{
VideoCodecBase VideoCodec { get; }
///// <summary>
///// Make this more specific
///// </summary>
//List<PepperDash.Essentials.Devices.Common.Codec.CodecActiveCallItem> ActiveCalls { get; }
/// <summary>
/// States: 0 for on hook, 1 for video, 2 for audio, 3 for telekenesis
/// </summary>
IntFeedback CallTypeFeedback { get; }
/// <summary>
/// When something in the room is sharing with the far end or through other means
/// </summary>
BoolFeedback IsSharingFeedback { get; }
}
}

View file

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Essentials.Devices.Common.Codec;
namespace PepperDash.Essentials.Devices.Common.VideoCodec
{
public interface IJoinCalls
{
void JoinCall(CodecActiveCallItem activeCall);
void JoinAllCalls();
}
}

View file

@ -0,0 +1,41 @@
extern alias Full;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Full.Newtonsoft.Json;
namespace PepperDash.Essentials.Devices.Common.Codec
{
/// <summary>
/// Implements a common set of data about a codec
/// </summary>
public interface iVideoCodecInfo
{
VideoCodecInfo CodecInfo { get; }
}
/// <summary>
/// Stores general information about a codec
/// </summary>
public abstract class VideoCodecInfo
{
[JsonProperty("multiSiteOptionIsEnabled", NullValueHandling = NullValueHandling.Ignore)]
public abstract bool MultiSiteOptionIsEnabled { get; }
[JsonProperty("ipAddress", NullValueHandling = NullValueHandling.Ignore)]
public abstract string IpAddress { get; }
[JsonProperty("sipPhoneNumber", NullValueHandling = NullValueHandling.Ignore)]
public abstract string SipPhoneNumber { get; }
[JsonProperty("e164Alias", NullValueHandling = NullValueHandling.Ignore)]
public abstract string E164Alias { get; }
[JsonProperty("h323Id", NullValueHandling = NullValueHandling.Ignore)]
public abstract string H323Id { get; }
[JsonProperty("sipUri", NullValueHandling = NullValueHandling.Ignore)]
public abstract string SipUri { get; }
[JsonProperty("autoAnswerEnabled", NullValueHandling = NullValueHandling.Ignore)]
public abstract bool AutoAnswerEnabled { get; }
}
}

View file

@ -0,0 +1,419 @@
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.Devices.Common.Codec;
namespace PepperDash.Essentials.Devices.Common.VideoCodec
{
public static class MockVideoCodecDirectory
{
public enum eFolderId
{
UnitedStates,
Canada,
NewYork,
Boston,
SanFrancisco,
Denver,
Austin,
Calgary
}
/// <summary>
/// Aggregates the directory items for all directories into a single directory for searching purposes
/// </summary>
public static CodecDirectory CompleteDirectory
{
get
{
var completeDirectory = new CodecDirectory();
completeDirectory.AddContactsToDirectory(DirectoryRoot.CurrentDirectoryResults);
completeDirectory.AddContactsToDirectory(UnitedStatesFolderContents.CurrentDirectoryResults);
completeDirectory.AddContactsToDirectory(CanadaFolderContents.CurrentDirectoryResults);
completeDirectory.AddContactsToDirectory(NewYorkFolderContents.CurrentDirectoryResults);
completeDirectory.AddContactsToDirectory(BostonFolderContents.CurrentDirectoryResults);
completeDirectory.AddContactsToDirectory(DenverFolderContents.CurrentDirectoryResults);
completeDirectory.AddContactsToDirectory(AustinFolderContents.CurrentDirectoryResults);
completeDirectory.AddContactsToDirectory(CalgaryFolderContents.CurrentDirectoryResults);
return completeDirectory;
}
}
public static CodecDirectory DirectoryRoot
{
get
{
var directory = new CodecDirectory();
directory.AddFoldersToDirectory
(
new List<DirectoryItem>()
{
new DirectoryFolder()
{
FolderId = eFolderId.UnitedStates.ToString(),
Name = "United States",
ParentFolderId = "",
Contacts = null
},
new DirectoryFolder()
{
FolderId = eFolderId.Canada.ToString(),
Name = "Canada",
ParentFolderId = "",
Contacts = null
}
}
);
directory.AddContactsToDirectory
(
new List<DirectoryItem>()
{
new DirectoryContact()
{
Name = "Corporate Bridge",
ContactMethods = new List<ContactMethod>()
{
new ContactMethod()
{
ContactMethodId = "c_1",
Number = "site.corp.com",
Device = eContactMethodDevice.Video,
CallType = eContactMethodCallType.Video
}
}
}
}
);
return directory;
}
}
public static CodecDirectory UnitedStatesFolderContents
{
get
{
var directory = new CodecDirectory();
directory.ResultsFolderId = eFolderId.UnitedStates.ToString();
directory.AddFoldersToDirectory
(
new List<DirectoryItem>()
{
new DirectoryFolder()
{
FolderId = eFolderId.NewYork.ToString(),
Name = "New York",
ParentFolderId = eFolderId.UnitedStates.ToString(),
Contacts = null
},
new DirectoryFolder()
{
FolderId = eFolderId.Boston.ToString(),
Name = "Boston",
ParentFolderId = eFolderId.UnitedStates.ToString(),
Contacts = null
},
new DirectoryFolder()
{
FolderId = eFolderId.SanFrancisco.ToString(),
Name = "San Francisco",
ParentFolderId = eFolderId.UnitedStates.ToString(),
Contacts = null
},
new DirectoryFolder()
{
FolderId = eFolderId.Denver.ToString(),
Name = "Denver",
ParentFolderId = eFolderId.UnitedStates.ToString(),
Contacts = null
},
new DirectoryFolder()
{
FolderId = eFolderId.Austin.ToString(),
Name = "Austin",
ParentFolderId = eFolderId.UnitedStates.ToString(),
Contacts = null
}
}
);
return directory;
}
}
public static CodecDirectory NewYorkFolderContents
{
get
{
var directory = new CodecDirectory();
directory.ResultsFolderId = eFolderId.NewYork.ToString();
directory.AddContactsToDirectory
(
new List<DirectoryItem>()
{
new DirectoryContact()
{
ContactId = "nyc_1",
Name = "Meeting Room",
Title = @"",
ContactMethods = new List<ContactMethod>()
{
new ContactMethod()
{
ContactMethodId = "cid_1",
Number = "nycmeetingroom.pepperdash.com",
Device = eContactMethodDevice.Video,
CallType = eContactMethodCallType.Video
}
}
},
new DirectoryContact()
{
ContactId = "nyc_2",
Name = "Sumanth Rayancha",
Title = @"CTO",
ContactMethods = new List<ContactMethod>()
{
new ContactMethod()
{
ContactMethodId = "cid_1",
Number = "srayancha.pepperdash.com",
Device = eContactMethodDevice.Video,
CallType = eContactMethodCallType.Video
}
}
},
new DirectoryContact()
{
ContactId = "nyc_3",
Name = "Justin Gordon",
Title = @"Software Developer",
ContactMethods = new List<ContactMethod>()
{
new ContactMethod()
{
ContactMethodId = "cid_1",
Number = "jgordon.pepperdash.com",
Device = eContactMethodDevice.Video,
CallType = eContactMethodCallType.Video
}
}
}
}
);
return directory;
}
}
public static CodecDirectory BostonFolderContents
{
get
{
var directory = new CodecDirectory();
directory.ResultsFolderId = eFolderId.Boston.ToString();
directory.AddContactsToDirectory
(
new List<DirectoryItem>()
{
new DirectoryContact()
{
ContactId = "bos_1",
Name = "Board Room",
Title = @"",
ContactMethods = new List<ContactMethod>()
{
new ContactMethod()
{
ContactMethodId = "cid_1",
Number = "bosboardroom.pepperdash.com",
Device = eContactMethodDevice.Video,
CallType = eContactMethodCallType.Video
}
}
}
}
);
return directory;
}
}
public static CodecDirectory SanFranciscoFolderContents
{
get
{
var directory = new CodecDirectory();
directory.ResultsFolderId = eFolderId.SanFrancisco.ToString();
directory.AddContactsToDirectory
(
new List<DirectoryItem>()
{
new DirectoryContact()
{
ContactId = "sfo_1",
Name = "David Huselid",
Title = @"Cive President, COO",
ContactMethods = new List<ContactMethod>()
{
new ContactMethod()
{
ContactMethodId = "cid_1",
Number = "dhuselid.pepperdash.com",
Device = eContactMethodDevice.Video,
CallType = eContactMethodCallType.Video
}
}
}
}
);
return directory;
}
}
public static CodecDirectory DenverFolderContents
{
get
{
var directory = new CodecDirectory();
directory.ResultsFolderId = eFolderId.Denver.ToString();
directory.AddContactsToDirectory
(
new List<DirectoryItem>()
{
new DirectoryContact()
{
ContactId = "den_1",
Name = "Heath Volmer",
Title = @"Software Developer",
ContactMethods = new List<ContactMethod>()
{
new ContactMethod()
{
ContactMethodId = "cid_1",
Number = "hvolmer.pepperdash.com",
Device = eContactMethodDevice.Video,
CallType = eContactMethodCallType.Video
}
}
}
}
);
return directory;
}
}
public static CodecDirectory AustinFolderContents
{
get
{
var directory = new CodecDirectory();
directory.ResultsFolderId = eFolderId.Austin.ToString();
directory.AddContactsToDirectory
(
new List<DirectoryItem>()
{
new DirectoryContact()
{
ContactId = "atx_1",
Name = "Vincent Longano",
Title = @"Product Development Manager",
ContactMethods = new List<ContactMethod>()
{
new ContactMethod()
{
ContactMethodId = "cid_1",
Number = "vlongano.pepperdash.com",
Device = eContactMethodDevice.Video,
CallType = eContactMethodCallType.Video
}
}
}
}
);
return directory;
}
}
public static CodecDirectory CanadaFolderContents
{
get
{
var directory = new CodecDirectory();
directory.ResultsFolderId = eFolderId.Canada.ToString();
directory.AddFoldersToDirectory
(
new List<DirectoryItem>()
{
new DirectoryFolder()
{
FolderId = eFolderId.Calgary.ToString(),
Name = "Calgary",
ParentFolderId = eFolderId.Canada.ToString(),
Contacts = null
}
}
);
return directory;
}
}
public static CodecDirectory CalgaryFolderContents
{
get
{
var directory = new CodecDirectory();
directory.ResultsFolderId = eFolderId.Calgary.ToString();
directory.AddContactsToDirectory
(
new List<DirectoryItem>()
{
new DirectoryContact()
{
ContactId = "cdn_1",
Name = "Neil Dorin",
Title = @"Software Developer /SC",
ContactMethods = new List<ContactMethod>()
{
new ContactMethod()
{
ContactMethodId = "cid_1",
Number = "ndorin@pepperdash.com",
Device = eContactMethodDevice.Video,
CallType = eContactMethodCallType.Video
}
}
}
}
);
return directory;
}
}
}
}

View file

@ -0,0 +1,849 @@
extern alias Full;
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.Core.Bridges;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.Routing;
using PepperDash.Essentials.Devices.Common.Codec;
using PepperDash.Essentials.Devices.Common.Cameras;
using Full.Newtonsoft.Json;
using Full.Newtonsoft.Json.Linq;
namespace PepperDash.Essentials.Devices.Common.VideoCodec
{
public class MockVC : VideoCodecBase, IRoutingSource, IHasCallHistory, IHasScheduleAwareness, IHasCallFavorites, IHasDirectory, IHasCodecCameras, IHasCameraAutoMode, IHasCodecRoomPresets
{
public MockVcPropertiesConfig PropertiesConfig;
public RoutingInputPort CodecOsdIn { get; private set; }
public RoutingInputPort HdmiIn1 { get; private set; }
public RoutingInputPort HdmiIn2 { get; private set; }
public RoutingOutputPort HdmiOut { get; private set; }
public CodecCallFavorites CallFavorites { get; private set; }
/// <summary>
///
/// </summary>
public MockVC(DeviceConfig config)
: base(config)
{
PropertiesConfig = JsonConvert.DeserializeObject<VideoCodec.MockVcPropertiesConfig>(config.Properties.ToString());
CodecInfo = new MockCodecInfo();
// Get favoritesw
if (PropertiesConfig.Favorites != null)
{
CallFavorites = new CodecCallFavorites();
CallFavorites.Favorites = PropertiesConfig.Favorites;
}
DirectoryBrowseHistory = new List<CodecDirectory>();
// Debug helpers
MuteFeedback.OutputChange += (o, a) => Debug.Console(1, this, "Mute={0}", _IsMuted);
PrivacyModeIsOnFeedback.OutputChange += (o, a) => Debug.Console(1, this, "Privacy={0}", _PrivacyModeIsOn);
SharingSourceFeedback.OutputChange += (o, a) => Debug.Console(1, this, "SharingSource={0}", _SharingSource);
VolumeLevelFeedback.OutputChange += (o, a) => Debug.Console(1, this, "Volume={0}", _VolumeLevel);
CurrentDirectoryResultIsNotDirectoryRoot = new BoolFeedback(() => DirectoryBrowseHistory.Count > 0);
CurrentDirectoryResultIsNotDirectoryRoot.FireUpdate();
CodecOsdIn = new RoutingInputPort(RoutingPortNames.CodecOsd, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, 0, this);
InputPorts.Add(CodecOsdIn);
HdmiIn1 = new RoutingInputPort(RoutingPortNames.HdmiIn1, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, 1, this);
InputPorts.Add(HdmiIn1);
HdmiIn2 = new RoutingInputPort(RoutingPortNames.HdmiIn2, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, 2, this);
InputPorts.Add(HdmiIn2);
HdmiOut = new RoutingOutputPort(RoutingPortNames.HdmiOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, null, this);
OutputPorts.Add(HdmiOut);
CallHistory = new CodecCallHistory();
for (int i = 0; i < 10; i++)
{
var call = new CodecCallHistory.CallHistoryEntry();
call.Name = "Call " + i;
call.Number = i + "@call.com";
CallHistory.RecentCalls.Add(call);
}
// eventually fire history event here
SetupCameras();
CreateOsdSource();
SetIsReady();
}
protected override Func<bool> MuteFeedbackFunc
{
get { return () => _IsMuted; }
}
bool _IsMuted;
protected override Func<bool> PrivacyModeIsOnFeedbackFunc
{
get { return () => _PrivacyModeIsOn; }
}
bool _PrivacyModeIsOn;
protected override Func<string> SharingSourceFeedbackFunc
{
get { return () => _SharingSource; }
}
string _SharingSource;
protected override Func<bool> SharingContentIsOnFeedbackFunc
{
get { return () => _SharingIsOn; }
}
bool _SharingIsOn;
protected override Func<int> VolumeLevelFeedbackFunc
{
get { return () => _VolumeLevel; }
}
int _VolumeLevel;
protected override Func<bool> StandbyIsOnFeedbackFunc
{
get { return () => _StandbyIsOn; }
}
bool _StandbyIsOn;
/// <summary>
/// Creates the fake OSD source, and connects it's AudioVideo output to the CodecOsdIn input
/// to enable routing
/// </summary>
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.
}
/// <summary>
/// Dials, yo!
/// </summary>
public override void Dial(string number)
{
Debug.Console(1, this, "Dial: {0}", number);
var call = new CodecActiveCallItem() { Name = number, Number = number, Id = number, Status = eCodecCallStatus.Dialing, Direction = eCodecCallDirection.Outgoing, Type = eCodecCallType.Video };
ActiveCalls.Add(call);
OnCallStatusChange(call);
//ActiveCallCountFeedback.FireUpdate();
// Simulate 2-second ring, then connecting, then connected
new CTimer(o =>
{
call.Type = eCodecCallType.Video;
SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Connecting, call);
new CTimer(oo => SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Connected, call), 1000);
}, 2000);
}
public override void Dial(Meeting meeting)
{
Debug.Console(1, this, "Dial Meeting: {0}", meeting.Id);
var call = new CodecActiveCallItem() { Name = meeting.Title, Number = meeting.Id, Id = meeting.Id, Status = eCodecCallStatus.Dialing, Direction = eCodecCallDirection.Outgoing, Type = eCodecCallType.Video };
ActiveCalls.Add(call);
OnCallStatusChange(call);
//ActiveCallCountFeedback.FireUpdate();
// Simulate 2-second ring, then connecting, then connected
new CTimer(o =>
{
call.Type = eCodecCallType.Video;
SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Connecting, call);
new CTimer(oo => SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Connected, call), 1000);
}, 2000);
}
/// <summary>
///
/// </summary>
public override void EndCall(CodecActiveCallItem call)
{
Debug.Console(1, this, "EndCall");
ActiveCalls.Remove(call);
SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Disconnected, call);
//ActiveCallCountFeedback.FireUpdate();
}
/// <summary>
///
/// </summary>
public override void EndAllCalls()
{
Debug.Console(1, this, "EndAllCalls");
for(int i = ActiveCalls.Count - 1; i >= 0; i--)
{
var call = ActiveCalls[i];
ActiveCalls.Remove(call);
SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Disconnected, call);
}
//ActiveCallCountFeedback.FireUpdate();
}
/// <summary>
/// For a call from the test methods below
/// </summary>
public override void AcceptCall(CodecActiveCallItem call)
{
Debug.Console(1, this, "AcceptCall");
SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Connecting, call);
new CTimer(o => SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Connected, call), 1000);
// should already be in active list
}
/// <summary>
/// For a call from the test methods below
/// </summary>
public override void RejectCall(CodecActiveCallItem call)
{
Debug.Console(1, this, "RejectCall");
ActiveCalls.Remove(call);
SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Disconnected, call);
//ActiveCallCountFeedback.FireUpdate();
}
/// <summary>
/// Makes horrible tones go out on the wire!
/// </summary>
/// <param name="s"></param>
public override void SendDtmf(string s)
{
Debug.Console(1, this, "SendDTMF: {0}", s);
}
/// <summary>
///
/// </summary>
public override void StartSharing()
{
_SharingIsOn = true;
SharingContentIsOnFeedback.FireUpdate();
}
/// <summary>
///
/// </summary>
public override void StopSharing()
{
_SharingIsOn = false;
SharingContentIsOnFeedback.FireUpdate();
}
public override void StandbyActivate()
{
_StandbyIsOn = true;
}
public override void StandbyDeactivate()
{
_StandbyIsOn = false;
}
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{
throw new NotImplementedException();
}
/// <summary>
/// Called by routing to make it happen
/// </summary>
/// <param name="selector"></param>
public override void ExecuteSwitch(object selector)
{
Debug.Console(1, this, "ExecuteSwitch: {0}", selector);
_SharingSource = selector.ToString();
}
/// <summary>
///
/// </summary>
public override void MuteOff()
{
_IsMuted = false;
MuteFeedback.FireUpdate();
}
/// <summary>
///
/// </summary>
public override void MuteOn()
{
_IsMuted = true;
MuteFeedback.FireUpdate();
}
/// <summary>
///
/// </summary>
public override void MuteToggle()
{
_IsMuted = !_IsMuted;
MuteFeedback.FireUpdate();
}
/// <summary>
///
/// </summary>
/// <param name="level"></param>
public override void SetVolume(ushort level)
{
_VolumeLevel = level;
VolumeLevelFeedback.FireUpdate();
}
/// <summary>
///
/// </summary>
/// <param name="pressRelease"></param>
public override void VolumeDown(bool pressRelease)
{
}
/// <summary>
///
/// </summary>
/// <param name="pressRelease"></param>
public override void VolumeUp(bool pressRelease)
{
}
/// <summary>
///
/// </summary>
public override void PrivacyModeOn()
{
Debug.Console(1, this, "PrivacyMuteOn");
if (_PrivacyModeIsOn)
return;
_PrivacyModeIsOn = true;
PrivacyModeIsOnFeedback.FireUpdate();
}
/// <summary>
///
/// </summary>
public override void PrivacyModeOff()
{
Debug.Console(1, this, "PrivacyMuteOff");
if (!_PrivacyModeIsOn)
return;
_PrivacyModeIsOn = false;
PrivacyModeIsOnFeedback.FireUpdate();
}
/// <summary>
///
/// </summary>
public override void PrivacyModeToggle()
{
_PrivacyModeIsOn = !_PrivacyModeIsOn;
Debug.Console(1, this, "PrivacyMuteToggle: {0}", _PrivacyModeIsOn);
PrivacyModeIsOnFeedback.FireUpdate();
}
//********************************************************
// SIMULATION METHODS
/// <summary>
///
/// </summary>
/// <param name="url"></param>
public void TestIncomingVideoCall(string url)
{
Debug.Console(1, this, "TestIncomingVideoCall from {0}", url);
var call = new CodecActiveCallItem() { Name = url, Id = url, Number = url, Type= eCodecCallType.Video, Direction = eCodecCallDirection.Incoming };
ActiveCalls.Add(call);
SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Ringing, call);
//OnCallStatusChange(eCodecCallStatus.Unknown, eCodecCallStatus.Ringing, call);
}
/// <summary>
///
/// </summary>
/// <param name="url"></param>
public void TestIncomingAudioCall(string url)
{
Debug.Console(1, this, "TestIncomingAudioCall from {0}", url);
var call = new CodecActiveCallItem() { Name = url, Id = url, Number = url, Type = eCodecCallType.Audio, Direction = eCodecCallDirection.Incoming };
ActiveCalls.Add(call);
SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Ringing, call);
//OnCallStatusChange(eCodecCallStatus.Unknown, eCodecCallStatus.Ringing, call);
}
/// <summary>
///
/// </summary>
public void TestFarEndHangup()
{
Debug.Console(1, this, "TestFarEndHangup");
}
#region IHasCallHistory Members
public CodecCallHistory CallHistory { get; private set; }
public void RemoveCallHistoryEntry(CodecCallHistory.CallHistoryEntry entry)
{
}
#endregion
#region IHasScheduleAwareness Members
public void GetSchedule()
{
}
public CodecScheduleAwareness CodecSchedule
{
get {
// if the last meeting has past, generate a new list
if (_CodecSchedule == null || _CodecSchedule.Meetings.Count == 0
|| _CodecSchedule.Meetings[_CodecSchedule.Meetings.Count - 1].StartTime < DateTime.Now)
{
_CodecSchedule = new CodecScheduleAwareness(1000);
for (int i = 0; i < 5; i++)
{
var m = new Meeting();
m.MinutesBeforeMeeting = 5;
m.Id = i.ToString();
m.Organizer = "Employee " + 1;
m.StartTime = DateTime.Now.AddMinutes(5).AddHours(i);
m.EndTime = DateTime.Now.AddHours(i).AddMinutes(50);
m.Title = "Meeting " + i;
m.Calls.Add(new Call() { Number = i + "meeting@fake.com"});
_CodecSchedule.Meetings.Add(m);
}
}
return _CodecSchedule;
}
}
CodecScheduleAwareness _CodecSchedule;
#endregion
#region IHasDirectory Members
public event EventHandler<DirectoryEventArgs> DirectoryResultReturned;
public CodecDirectory DirectoryRoot
{
get
{
return MockVideoCodecDirectory.DirectoryRoot;
}
}
public CodecDirectory CurrentDirectoryResult
{
get
{
if (DirectoryBrowseHistory.Count > 0)
return DirectoryBrowseHistory[DirectoryBrowseHistory.Count - 1];
else
return DirectoryRoot;
}
}
public CodecPhonebookSyncState PhonebookSyncState
{
get
{
var syncState = new CodecPhonebookSyncState(Key + "PhonebookSync");
syncState.InitialPhonebookFoldersReceived();
syncState.PhonebookRootEntriesReceived();
syncState.SetPhonebookHasFolders(true);
syncState.SetNumberOfContacts(0); // just need to call this method for the sync to complete
return syncState;
}
}
public void SearchDirectory(string searchString)
{
var searchResults = new CodecDirectory();
searchResults.ResultsFolderId = "searchResult";
// Search mock directory for contacts that contain the search string, ignoring case
List<DirectoryItem> matches = MockVideoCodecDirectory.CompleteDirectory.CurrentDirectoryResults.FindAll(
s => s is DirectoryContact && s.Name.ToLower().Contains(searchString.ToLower()));
if (matches != null)
{
searchResults.AddContactsToDirectory(matches);
DirectoryBrowseHistory.Add(searchResults);
}
OnDirectoryResultReturned(searchResults);
}
public void GetDirectoryFolderContents(string folderId)
{
var folderDirectory = new CodecDirectory();
if (folderId == MockVideoCodecDirectory.eFolderId.UnitedStates.ToString())
folderDirectory = MockVideoCodecDirectory.UnitedStatesFolderContents;
else if (folderId == MockVideoCodecDirectory.eFolderId.Canada.ToString())
folderDirectory = MockVideoCodecDirectory.CanadaFolderContents;
else if (folderId == MockVideoCodecDirectory.eFolderId.NewYork.ToString())
folderDirectory = MockVideoCodecDirectory.NewYorkFolderContents;
else if (folderId == MockVideoCodecDirectory.eFolderId.Boston.ToString())
folderDirectory = MockVideoCodecDirectory.BostonFolderContents;
else if (folderId == MockVideoCodecDirectory.eFolderId.SanFrancisco.ToString())
folderDirectory = MockVideoCodecDirectory.SanFranciscoFolderContents;
else if (folderId == MockVideoCodecDirectory.eFolderId.Denver.ToString())
folderDirectory = MockVideoCodecDirectory.DenverFolderContents;
else if (folderId == MockVideoCodecDirectory.eFolderId.Austin.ToString())
folderDirectory = MockVideoCodecDirectory.AustinFolderContents;
else if (folderId == MockVideoCodecDirectory.eFolderId.Calgary.ToString())
folderDirectory = MockVideoCodecDirectory.CalgaryFolderContents;
DirectoryBrowseHistory.Add(folderDirectory);
OnDirectoryResultReturned(folderDirectory);
}
public void SetCurrentDirectoryToRoot()
{
DirectoryBrowseHistory.Clear();
OnDirectoryResultReturned(DirectoryRoot);
}
public void GetDirectoryParentFolderContents()
{
var currentDirectory = new CodecDirectory();
if (DirectoryBrowseHistory.Count > 0)
{
var lastItemIndex = DirectoryBrowseHistory.Count - 1;
var parentDirectoryContents = DirectoryBrowseHistory[lastItemIndex];
DirectoryBrowseHistory.Remove(DirectoryBrowseHistory[lastItemIndex]);
currentDirectory = parentDirectoryContents;
}
else
{
currentDirectory = DirectoryRoot;
}
OnDirectoryResultReturned(currentDirectory);
}
public BoolFeedback CurrentDirectoryResultIsNotDirectoryRoot { get; private set; }
public List<CodecDirectory> DirectoryBrowseHistory { get; private set; }
public void OnDirectoryResultReturned(CodecDirectory result)
{
CurrentDirectoryResultIsNotDirectoryRoot.FireUpdate();
var handler = DirectoryResultReturned;
if (handler != null)
{
handler(this, new DirectoryEventArgs()
{
Directory = result,
DirectoryIsOnRoot = !CurrentDirectoryResultIsNotDirectoryRoot.BoolValue
});
}
}
#endregion
void SetupCameras()
{
SupportsCameraAutoMode = true;
SupportsCameraOff = false;
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);
SupportsCameraAutoMode = true;
CameraAutoModeIsOnFeedback.FireUpdate();
DeviceManager.AddDevice(internalCamera);
DeviceManager.AddDevice(farEndCamera);
NearEndPresets = new List<CodecRoomPreset>(15); // Fix the capacity to emulate Cisco
if (PropertiesConfig.Presets != null && PropertiesConfig.Presets.Count > 0)
{
NearEndPresets = PropertiesConfig.Presets;
}
else
{
for (int i = 1; i <= NearEndPresets.Capacity; i++)
{
var label = string.Format("Near End Preset {0}", i);
NearEndPresets.Add(new CodecRoomPreset(i, label, true, false));
}
}
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.
}
#region IHasCameras Members
public event EventHandler<CameraSelectedEventArgs> CameraSelected;
public List<CameraBase> Cameras { get; private set; }
private CameraBase _selectedCamera;
/// <summary>
/// Returns the selected camera
/// </summary>
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)
{
var camera = Cameras.FirstOrDefault(c => c.Key.ToLower().IndexOf(key.ToLower()) > -1);
if (camera != null)
{
Debug.Console(2, this, "Selected Camera with key: '{0}'", camera.Key);
SelectedCamera = camera;
}
else
Debug.Console(2, this, "Unable to select camera with key: '{0}'", key);
}
#endregion
#region IHasFarEndCameraControl Members
public CameraBase FarEndCamera { get; private set; }
public BoolFeedback ControllingFarEndCameraFeedback { get; private set; }
#endregion
#region IHasCameraAutoMode Members
private bool _CameraAutoModeIsOn;
public void CameraAutoModeOn()
{
_CameraAutoModeIsOn = true;
CameraAutoModeIsOnFeedback.FireUpdate();
}
public void CameraAutoModeOff()
{
_CameraAutoModeIsOn = false;
CameraAutoModeIsOnFeedback.FireUpdate();
}
public void CameraAutoModeToggle()
{
if(_CameraAutoModeIsOn)
_CameraAutoModeIsOn = false;
else
_CameraAutoModeIsOn = true;
CameraAutoModeIsOnFeedback.FireUpdate();
}
public BoolFeedback CameraAutoModeIsOnFeedback {get; private set;}
#endregion
#region IHasCameraPresets Members
public event EventHandler<EventArgs> CodecRoomPresetsListHasChanged;
public List<CodecRoomPreset> NearEndPresets { get; private set; }
public List<CodecRoomPreset> FarEndRoomPresets { get; private set; }
public void CodecRoomPresetSelect(int preset)
{
if (SelectedCamera is IAmFarEndCamera)
{
Debug.Console(1, this, "Selecting Far End Preset: {0}", preset);
}
else
{
Debug.Console(1, this, "Selecting Near End Preset: {0}", preset);
}
}
public void CodecRoomPresetStore(int preset, string description)
{
var editPreset = NearEndPresets.FirstOrDefault(p => p.ID.Equals(preset));
if (editPreset != null)
{
editPreset.Defined = true;
editPreset.Description = description;
}
else
NearEndPresets.Add(new CodecRoomPreset(preset, description, true, true));
var handler = CodecRoomPresetsListHasChanged;
if (handler != null)
{
handler(this, new EventArgs());
}
// Update the config
SetConfig(Config);
}
public void SelectFarEndPreset(int i)
{
Debug.Console(1, this, "Selecting Far End Preset: {0}", i);
}
#endregion
protected override void CustomSetConfig(DeviceConfig config)
{
PropertiesConfig.Presets = NearEndPresets;
Config.Properties = JToken.FromObject(PropertiesConfig);
ConfigWriter.UpdateDeviceConfig(config);
}
}
/// <summary>
/// Implementation for the mock VC
/// </summary>
public class MockCodecInfo : VideoCodecInfo
{
public override bool MultiSiteOptionIsEnabled
{
get { return true; }
}
public override string E164Alias
{
get { return "someE164alias"; }
}
public override string H323Id
{
get { return "someH323Id"; }
}
public override string IpAddress
{
get { return "xxx.xxx.xxx.xxx"; }
}
public override string SipPhoneNumber
{
get { return "333-444-5555"; }
}
public override string SipUri
{
get { return "mock@someurl.com"; }
}
public override bool AutoAnswerEnabled
{
get { return _AutoAnswerEnabled; }
}
bool _AutoAnswerEnabled;
public void SetAutoAnswer(bool value)
{
_AutoAnswerEnabled = value;
}
}
public class MockVCFactory : EssentialsDeviceFactory<MockVC>
{
public MockVCFactory()
{
TypeNames = new List<string>() { "mockvc" };
}
public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
Debug.Console(1, "Factory Attempting to create new MockVC Device");
return new VideoCodec.MockVC(dc);
}
}
}

View file

@ -0,0 +1,206 @@
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.Bridges;
using PepperDash.Essentials.Devices.Common.VideoCodec;
namespace PepperDash.Essentials.Devices.Common.Cameras
{
public class MockVCCamera : CameraBase, IHasCameraPtzControl, IHasCameraFocusControl, IBridgeAdvanced
{
protected VideoCodecBase ParentCodec { get; private set; }
public MockVCCamera(string key, string name, VideoCodecBase codec)
: base(key, name)
{
Capabilities = eCameraCapabilities.Pan | eCameraCapabilities.Tilt | eCameraCapabilities.Zoom | eCameraCapabilities.Focus;
ParentCodec = codec;
}
#region IHasCameraPtzControl Members
public void PositionHome()
{
Debug.Console(1, this, "Resetting to home position");
}
#endregion
#region IHasCameraPanControl Members
public void PanLeft()
{
Debug.Console(1, this, "Panning Left");
}
public void PanRight()
{
Debug.Console(1, this, "Panning Right");
}
public void PanStop()
{
Debug.Console(1, this, "Stopping Pan");
}
#endregion
#region IHasCameraTiltControl Members
public void TiltDown()
{
Debug.Console(1, this, "Tilting Down");
}
public void TiltUp()
{
Debug.Console(1, this, "Tilting Up");
}
public void TiltStop()
{
Debug.Console(1, this, "Stopping Tilt");
}
#endregion
#region IHasCameraZoomControl Members
public void ZoomIn()
{
Debug.Console(1, this, "Zooming In");
}
public void ZoomOut()
{
Debug.Console(1, this, "Zooming Out");
}
public void ZoomStop()
{
Debug.Console(1, this, "Stopping Zoom");
}
#endregion
#region IHasCameraFocusControl Members
public void FocusNear()
{
Debug.Console(1, this, "Focusing Near");
}
public void FocusFar()
{
Debug.Console(1, this, "Focusing Far");
}
public void FocusStop()
{
Debug.Console(1, this, "Stopping Focus");
}
public void TriggerAutoFocus()
{
Debug.Console(1, this, "AutoFocus Triggered");
}
#endregion
public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{
LinkCameraToApi(this, trilist, joinStart, joinMapKey, bridge);
}
}
public class MockFarEndVCCamera : CameraBase, IHasCameraPtzControl, IAmFarEndCamera, IBridgeAdvanced
{
protected VideoCodecBase ParentCodec { get; private set; }
public MockFarEndVCCamera(string key, string name, VideoCodecBase codec)
: base(key, name)
{
Capabilities = eCameraCapabilities.Pan | eCameraCapabilities.Tilt | eCameraCapabilities.Zoom;
ParentCodec = codec;
}
#region IHasCameraPtzControl Members
public void PositionHome()
{
Debug.Console(1, this, "Resetting to home position");
}
#endregion
#region IHasCameraPanControl Members
public void PanLeft()
{
Debug.Console(1, this, "Panning Left");
}
public void PanRight()
{
Debug.Console(1, this, "Panning Right");
}
public void PanStop()
{
Debug.Console(1, this, "Stopping Pan");
}
#endregion
#region IHasCameraTiltControl Members
public void TiltDown()
{
Debug.Console(1, this, "Tilting Down");
}
public void TiltUp()
{
Debug.Console(1, this, "Tilting Up");
}
public void TiltStop()
{
Debug.Console(1, this, "Stopping Tilt");
}
#endregion
#region IHasCameraZoomControl Members
public void ZoomIn()
{
Debug.Console(1, this, "Zooming In");
}
public void ZoomOut()
{
Debug.Console(1, this, "Zooming Out");
}
public void ZoomStop()
{
Debug.Console(1, this, "Stopping Zoom");
}
#endregion
public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{
LinkCameraToApi(this, trilist, joinStart, joinMapKey, bridge);
}
}
}

View file

@ -0,0 +1,30 @@
extern alias Full;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Full.Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Devices.Common.Codec;
namespace PepperDash.Essentials.Devices.Common.VideoCodec
{
public class MockVcPropertiesConfig
{
[JsonProperty("favorites")]
public List<CodecActiveCallItem> Favorites { get; set; }
[JsonProperty("presets")]
public List<CodecRoomPreset> Presets { get; set; }
public MockVcPropertiesConfig()
{
Favorites = new List<CodecActiveCallItem>();
Presets = new List<CodecRoomPreset>();
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +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<ShareInfoEventArgs> ShareInfoChanged;
zStatus.Sharing SharingState { get; }
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,231 @@
extern alias Full;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Essentials.Core.Bridges;
using PepperDash.Essentials.Devices.Common.Cameras;
using Full.Newtonsoft.Json;
namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom
{
public enum eZoomRoomCameraState
{
Start,
Continue,
Stop,
RequestRemote,
GiveupRemote,
RequestedByFarEnd
}
public enum eZoomRoomCameraAction
{
Left,
Right,
Up,
Down,
In,
Out
}
public class ZoomRoomCamera : CameraBase, IHasCameraPtzControl, IBridgeAdvanced
{
protected ZoomRoom ParentCodec { get; private set; }
[JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)]
public int? Id = 0; // ID of near end selected camara is always 0
private int ContinueTime = 10; // number of milliseconds between issuing continue commands
private CTimer ContinueTimer;
eZoomRoomCameraAction LastAction;
private bool isPanning;
private bool isTilting;
private bool isZooming;
//private bool isFocusing;
private bool isMoving
{
get
{
return isPanning || isTilting || isZooming;
}
}
public ZoomRoomCamera(string key, string name, ZoomRoom codec)
: base(key, name)
{
ParentCodec = codec;
Capabilities = eCameraCapabilities.Pan | eCameraCapabilities.Tilt | eCameraCapabilities.Zoom;
}
/// <summary>
/// Builds the command and triggers the parent ZoomRoom to send it
/// </summary>
/// <param name="state"></param>
/// <param name="action"></param>
void SendCommand(eZoomRoomCameraState state, eZoomRoomCameraAction action)
{
LastAction = action;
ParentCodec.SendText(string.Format("zCommand Call CameraControl Id: {0} State: {1} Action: {2}", Id, state, action));
}
void StartContinueTimer()
{
if (ContinueTimer == null)
ContinueTimer = new CTimer((o) => SendContinueAction(LastAction), null, ContinueTime, ContinueTime);
}
void SendContinueAction(eZoomRoomCameraAction action)
{
SendCommand(eZoomRoomCameraState.Continue, action);
}
void StopContinueTimer()
{
if (ContinueTimer == null)
{
return;
}
ContinueTimer.Stop();
ContinueTimer.Dispose();
ContinueTimer = null;
}
#region IHasCameraPtzControl Members
public void PositionHome()
{
throw new NotImplementedException();
}
#endregion
#region IHasCameraPanControl Members
public void PanLeft()
{
if (isMoving)
{
return;
}
SendCommand(eZoomRoomCameraState.Start, eZoomRoomCameraAction.Left);
StartContinueTimer();
isPanning = true;
}
public void PanRight()
{
if (isMoving)
{
return;
}
SendCommand(eZoomRoomCameraState.Start, eZoomRoomCameraAction.Right);
StartContinueTimer();
isPanning = true;
}
public void PanStop()
{
StopContinueTimer();
SendCommand(eZoomRoomCameraState.Stop, LastAction);
isPanning = false;
}
#endregion
#region IHasCameraTiltControl Members
public void TiltDown()
{
if (!isMoving)
{
SendCommand(eZoomRoomCameraState.Start, eZoomRoomCameraAction.Down);
StartContinueTimer();
isTilting = true;
}
}
public void TiltUp()
{
if (!isMoving)
{
SendCommand(eZoomRoomCameraState.Start, eZoomRoomCameraAction.Up);
StartContinueTimer();
isTilting = true;
}
}
public void TiltStop()
{
StopContinueTimer();
SendCommand(eZoomRoomCameraState.Stop, LastAction);
isTilting = false;
}
#endregion
#region IHasCameraZoomControl Members
public void ZoomIn()
{
if (!isMoving)
{
SendCommand(eZoomRoomCameraState.Start, eZoomRoomCameraAction.In);
StartContinueTimer();
isZooming = true;
}
}
public void ZoomOut()
{
if (!isMoving)
{
SendCommand(eZoomRoomCameraState.Start, eZoomRoomCameraAction.Out);
StartContinueTimer();
isZooming = true;
}
}
public void ZoomStop()
{
StopContinueTimer();
SendCommand(eZoomRoomCameraState.Stop, LastAction);
isZooming = false;
}
#endregion
public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{
LinkCameraToApi(this, trilist, joinStart, joinMapKey, bridge);
}
}
public class ZoomRoomFarEndCamera : ZoomRoomCamera, IAmFarEndCamera
{
public ZoomRoomFarEndCamera(string key, string name, ZoomRoom codec, int id)
: base(key, name, codec)
{
Id = id;
}
}
}

View file

@ -0,0 +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. <None | Laptop | IOS>",
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)
{
}
}
}

View file

@ -0,0 +1,46 @@
extern alias Full;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Full.Newtonsoft.Json;
using Full.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; }
[JsonProperty("disablePhonebookAutoDownload")]
public bool DisablePhonebookAutoDownload { get; set; }
[JsonProperty("supportsCameraAutoMode")]
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")]
public bool AutoDefaultLayouts { get; set; }
/* 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")]
public int MinutesBeforeMeetingStart { get; set; }
}
}