mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-14 04:04:58 +00:00
Added properties and feedbacks debugging; Working on buffering socket on Sammy
This commit is contained in:
@@ -22,13 +22,6 @@ namespace PepperDash.Essentials.Devices.Displays
|
||||
var properties = dc.Properties;
|
||||
|
||||
var typeName = dc.Type.ToLower();
|
||||
//if (typeName == "dmmd8x8")
|
||||
//{
|
||||
// var props = JsonConvert.DeserializeObject
|
||||
// <PepperDash.Essentials.DM.Config.DMChassisPropertiesConfig>(properties.ToString());
|
||||
// return PepperDash.Essentials.DM.DmChassisController.
|
||||
// GetDmChassisController(key, name, type, props);
|
||||
//}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace PepperDash.Essentials.Devices.Displays
|
||||
ushort _VolumeLevel;
|
||||
bool _IsMuted;
|
||||
RoutingInputPort _CurrentInputPort;
|
||||
byte[] IncomingBuffer = new byte[]{};
|
||||
//CTimer StatusTimer;
|
||||
|
||||
protected override Func<bool> PowerIsOnFeedbackFunc { get { return () => _PowerIsOn; } }
|
||||
@@ -85,6 +86,7 @@ namespace PepperDash.Essentials.Devices.Displays
|
||||
{
|
||||
WarmupTime = 10000;
|
||||
CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 30000, 120000, 300000, StatusGet);
|
||||
DeviceManager.AddDevice(CommunicationMonitor);
|
||||
|
||||
AddRoutingInputPort(new RoutingInputPort(RoutingPortNames.HdmiIn1, eRoutingSignalType.AudioVideo,
|
||||
eRoutingPortConnectionType.Hdmi, new Action(InputHdmi1), this), 0x21);
|
||||
@@ -151,45 +153,75 @@ namespace PepperDash.Essentials.Devices.Displays
|
||||
/// <param name="e"></param>
|
||||
void Communication_BytesReceived(object sender, GenericCommMethodReceiveBytesArgs e)
|
||||
{
|
||||
var b = e.Bytes;
|
||||
Debug.Console(0, this, "Parsing: {0}", ComTextHelper.GetEscapedText(b));
|
||||
if (b[0] == 0xAA && b[1] == 0xFF)
|
||||
Debug.Console(2, this, "Socket in: {0}", ComTextHelper.GetEscapedText(e.Bytes));
|
||||
// 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);
|
||||
Debug.Console(2, this, "Buffer+new: {0}", ComTextHelper.GetEscapedText(newBytes));
|
||||
|
||||
ADD A while HERE TOMORROW.
|
||||
// If it's at least got the header, then process it,
|
||||
if (newBytes.Length > 4 && newBytes[0] == 0xAA && newBytes[1] == 0xFF)
|
||||
{
|
||||
if (b[4] == 0x41)
|
||||
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)
|
||||
{
|
||||
var typeByte = b[5];
|
||||
switch (typeByte)
|
||||
IncomingBuffer = newBytes;
|
||||
return;
|
||||
}
|
||||
|
||||
// Good length, grab the message
|
||||
var message = newBytes.Skip(4).Take(msgLen).ToArray();
|
||||
Debug.Console(0, this, "Parsing: {0}", ComTextHelper.GetEscapedText(message));
|
||||
|
||||
// At this point, the ack/nak is the first byte
|
||||
if (message[0] == 0x41)
|
||||
{
|
||||
switch (message[1]) // type byte
|
||||
{
|
||||
case 0x00: // General status
|
||||
UpdatePowerFB(b[6]);
|
||||
UpdateVolumeFB(b[7]);
|
||||
UpdateMuteFb(b[8]);
|
||||
UpdateInputFb(b[9]);
|
||||
UpdatePowerFB(message[2]);
|
||||
UpdateVolumeFB(message[3]);
|
||||
UpdateMuteFb(message[4]);
|
||||
UpdateInputFb(message[5]);
|
||||
break;
|
||||
|
||||
case 0x11:
|
||||
UpdatePowerFB(b[6]);
|
||||
UpdatePowerFB(message[2]);
|
||||
break;
|
||||
|
||||
case 0x12:
|
||||
UpdateVolumeFB(b[6]);
|
||||
UpdateVolumeFB(message[2]);
|
||||
break;
|
||||
|
||||
|
||||
case 0x13:
|
||||
UpdateMuteFb(b[6]);
|
||||
UpdateMuteFb(message[2]);
|
||||
break;
|
||||
|
||||
case 0x14:
|
||||
UpdateInputFb(b[6]);
|
||||
UpdateInputFb(message[2]);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Skip over what we've used and save the rest for next time
|
||||
IncomingBuffer = newBytes.Skip(5 + msgLen).ToArray();
|
||||
}
|
||||
// there's not even a full header in the event. Save it for next time.
|
||||
else
|
||||
IncomingBuffer = newBytes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="b"></param>
|
||||
void UpdatePowerFB(byte b)
|
||||
{
|
||||
var newVal = b == 1;
|
||||
@@ -201,6 +233,10 @@ namespace PepperDash.Essentials.Devices.Displays
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="b"></param>
|
||||
void UpdateVolumeFB(byte b)
|
||||
{
|
||||
var newVol = (ushort)Scale((double)b, 0, 100, 0, 65535);
|
||||
|
||||
@@ -105,6 +105,7 @@
|
||||
<Compile Include="DSP\BiampTesira\BiampTesiraFortePropertiesConfig.cs" />
|
||||
<Compile Include="DSP\PolycomSoundStructure\SoundStructureBasics.cs" />
|
||||
<Compile Include="Factory\DeviceFactory.cs" />
|
||||
<Compile Include="Generic\GenericSource.cs" />
|
||||
<Compile Include="PC\InRoomPc.cs" />
|
||||
<Compile Include="PC\Laptop.cs" />
|
||||
<Compile Include="SetTopBox\SetTopBoxPropertiesConfig.cs" />
|
||||
|
||||
Binary file not shown.
@@ -36,7 +36,6 @@ namespace PepperDash.Essentials.Devices.Common
|
||||
|
||||
var irCont = IRPortHelper.GetIrOutputPortController(dc);
|
||||
return new AppleTV(key, name, irCont);
|
||||
|
||||
}
|
||||
|
||||
else if (typeName == "basicirdisplay")
|
||||
@@ -46,6 +45,14 @@ namespace PepperDash.Essentials.Devices.Common
|
||||
return new BasicIrDisplay(key, name, ir.Port, ir.FileName);
|
||||
}
|
||||
|
||||
else if (typeName == "biamptesira")
|
||||
{
|
||||
var comm = CommFactory.CreateCommForDevice(dc);
|
||||
var props = JsonConvert.DeserializeObject<BiampTesiraFortePropertiesConfig>(
|
||||
properties.ToString());
|
||||
return new BiampTesiraForteDsp(key, name, comm, props);
|
||||
}
|
||||
|
||||
else if (typeName == "cenrfgwex")
|
||||
{
|
||||
return CenRfgwController.GetNewExGatewayController(key, name,
|
||||
@@ -58,6 +65,19 @@ namespace PepperDash.Essentials.Devices.Common
|
||||
properties.Value<string>("id"), properties.Value<string>("gatewayType"));
|
||||
}
|
||||
|
||||
else if (groupName == "discplayer") // (typeName == "irbluray")
|
||||
{
|
||||
if (properties["control"]["method"].Value<string>() == "ir")
|
||||
{
|
||||
var irCont = IRPortHelper.GetIrOutputPortController(dc);
|
||||
return new IRBlurayBase(key, name, irCont);
|
||||
}
|
||||
else if (properties["control"]["method"].Value<string>() == "com")
|
||||
{
|
||||
Debug.Console(0, "[{0}] COM Device type not implemented YET!", key);
|
||||
}
|
||||
}
|
||||
|
||||
else if (typeName == "genericaudiooutwithvolume")
|
||||
{
|
||||
var zone = dc.Properties.Value<uint>("zone");
|
||||
@@ -65,63 +85,39 @@ namespace PepperDash.Essentials.Devices.Common
|
||||
dc.Properties.Value<string>("volumeDeviceKey"), zone);
|
||||
}
|
||||
|
||||
else if (groupName == "discplayer") // (typeName == "irbluray")
|
||||
{
|
||||
if (properties["control"]["method"].Value<string>() == "ir")
|
||||
{
|
||||
var irCont = IRPortHelper.GetIrOutputPortController(dc);
|
||||
return new IRBlurayBase(key, name, irCont);
|
||||
else if (groupName == "genericsource")
|
||||
{
|
||||
return new GenericSource(key, name);
|
||||
}
|
||||
|
||||
//var ir = IRPortHelper.GetIrPort(properties);
|
||||
//if (ir != null)
|
||||
// return new IRBlurayBase(key, name, ir.Port, ir.FileName);
|
||||
}
|
||||
else if (properties["control"]["method"].Value<string>() == "com")
|
||||
{
|
||||
Debug.Console(0, "[{0}] COM Device type not implemented YET!", key);
|
||||
}
|
||||
}
|
||||
else if (typeName == "inroompc")
|
||||
{
|
||||
return new InRoomPc(key, name);
|
||||
}
|
||||
|
||||
else if (groupName == "settopbox") //(typeName == "irstbbase")
|
||||
{
|
||||
var irCont = IRPortHelper.GetIrOutputPortController(dc);
|
||||
else if (typeName == "laptop")
|
||||
{
|
||||
return new Laptop(key, name);
|
||||
}
|
||||
|
||||
else if (groupName == "settopbox") //(typeName == "irstbbase")
|
||||
{
|
||||
var irCont = IRPortHelper.GetIrOutputPortController(dc);
|
||||
var config = dc.Properties.ToObject<SetTopBoxPropertiesConfig>();
|
||||
var stb = new IRSetTopBoxBase(key, name, irCont, config);
|
||||
var stb = new IRSetTopBoxBase(key, name, irCont, config);
|
||||
|
||||
//stb.HasDvr = properties.Value<bool>("hasDvr");
|
||||
var listName = properties.Value<string>("presetsList");
|
||||
if (listName != null)
|
||||
stb.LoadPresets(listName);
|
||||
return stb;
|
||||
}
|
||||
//stb.HasDvr = properties.Value<bool>("hasDvr");
|
||||
var listName = properties.Value<string>("presetsList");
|
||||
if (listName != null)
|
||||
stb.LoadPresets(listName);
|
||||
return stb;
|
||||
}
|
||||
|
||||
else if (typeName == "laptop")
|
||||
{
|
||||
return new Laptop(key, name);
|
||||
}
|
||||
|
||||
else if (typeName == "inroompc")
|
||||
{
|
||||
return new InRoomPc(key, name);
|
||||
}
|
||||
|
||||
else if (typeName == "roku")
|
||||
{
|
||||
var irCont = IRPortHelper.GetIrOutputPortController(dc);
|
||||
return new Roku2(key, name, irCont);
|
||||
|
||||
//var ir = IRPortHelper.GetIrPort(properties);
|
||||
//if (ir != null)
|
||||
// return new Roku2(key, name, ir.Port, ir.FileName);
|
||||
}
|
||||
|
||||
else if (typeName == "biamptesira")
|
||||
{
|
||||
var comm = CommFactory.CreateCommForDevice(dc);
|
||||
var props = JsonConvert.DeserializeObject<BiampTesiraFortePropertiesConfig>(
|
||||
properties.ToString());
|
||||
return new BiampTesiraForteDsp(key, name, comm, props);
|
||||
}
|
||||
else if (typeName == "roku")
|
||||
{
|
||||
var irCont = IRPortHelper.GetIrOutputPortController(dc);
|
||||
return new Roku2(key, name, irCont);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
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.Routing;
|
||||
|
||||
namespace PepperDash.Essentials.Devices.Common
|
||||
{
|
||||
public class GenericSource : Device, IUiDisplayInfo, IRoutingOutputs
|
||||
{
|
||||
|
||||
public uint DisplayUiType { get { return DisplayUiConstants.TypeNoControls; } }
|
||||
|
||||
public GenericSource(string key, string name)
|
||||
: base(key, name)
|
||||
{
|
||||
|
||||
AnyOut = new RoutingOutputPort(RoutingPortNames.AnyOut, eRoutingSignalType.AudioVideo,
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user