Compare commits

...

6 Commits

Author SHA1 Message Date
Andrew Welker
5f69c9eafe Merge 4a9b1514e3 into 7019b62610 2021-03-12 22:54:24 +00:00
Andrew Welker
7019b62610 Merge pull request #647 from PepperDash/feature/cecportcontroller-with-streamdebugging
Update CecPortController class to implement IBasicCommunicationWithStreamDebugging
2021-03-11 10:43:41 -07:00
Evan
a583fdb72a Update StreamDebugging on receive for both CECPortController and ComPortController 2021-03-11 12:25:46 -05:00
Andrew Welker
33bf98303d Merge branch 'development' into feature/cecportcontroller-with-streamdebugging 2021-03-11 09:06:52 -07:00
Neil Dorin
b2f3aa9cfa Merge pull request #644 from PepperDash/release/1.8.0
Release/1.8.0
2021-03-10 16:07:55 -07:00
Evan
29b77f5629 Update CecPortController class to implement IBasicCommunicationWithStreamDebuggingB 2021-03-10 17:28:32 -05:00
2 changed files with 23 additions and 7 deletions

View File

@@ -11,8 +11,10 @@ using PepperDash.Core;
namespace PepperDash.Essentials.Core
{
public class CecPortController : Device, IBasicCommunication
public class CecPortController : Device, IBasicCommunicationWithStreamDebugging
{
public CommunicationStreamDebugging StreamDebugging { get; private set; }
public event EventHandler<GenericCommMethodReceiveBytesArgs> BytesReceived;
public event EventHandler<GenericCommMethodReceiveTextArgs> TextReceived;
@@ -23,6 +25,8 @@ namespace PepperDash.Essentials.Core
public CecPortController(string key, Func<EssentialsControlPropertiesConfig, ICec> postActivationFunc,
EssentialsControlPropertiesConfig config):base(key)
{
StreamDebugging = new CommunicationStreamDebugging(key);
AddPostActivationAction(() =>
{
Port = postActivationFunc(config);
@@ -50,15 +54,21 @@ namespace PepperDash.Essentials.Core
void OnDataReceived(string s)
{
var bytesHandler = BytesReceived;
var bytesHandler = BytesReceived;
if (bytesHandler != null)
{
var bytes = Encoding.GetEncoding(28591).GetBytes(s);
if (StreamDebugging.RxStreamDebuggingIsEnabled)
Debug.Console(0, this, "Received: '{0}'", ComTextHelper.GetEscapedText(bytes));
bytesHandler(this, new GenericCommMethodReceiveBytesArgs(bytes));
}
var textHandler = TextReceived;
if (textHandler != null)
textHandler(this, new GenericCommMethodReceiveTextArgs(s));
if (textHandler != null)
{
if (StreamDebugging.RxStreamDebuggingIsEnabled)
Debug.Console(0, this, "Received: '{0}'", s);
textHandler(this, new GenericCommMethodReceiveTextArgs(s));
}
}
#region IBasicCommunication Members
@@ -67,6 +77,8 @@ namespace PepperDash.Essentials.Core
{
if (Port == null)
return;
if (StreamDebugging.TxStreamDebuggingIsEnabled)
Debug.Console(0, this, "Sending {0} characters of text: '{1}'", text.Length, text);
Port.StreamCec.Send.StringValue = text;
}
@@ -75,6 +87,8 @@ namespace PepperDash.Essentials.Core
if (Port == null)
return;
var text = Encoding.GetEncoding(28591).GetString(bytes, 0, bytes.Length);
if (StreamDebugging.TxStreamDebuggingIsEnabled)
Debug.Console(0, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes));
Port.StreamCec.Send.StringValue = text;
}

View File

@@ -92,18 +92,20 @@ namespace PepperDash.Essentials.Core
void OnDataReceived(string s)
{
var bytesHandler = BytesReceived;
if (bytesHandler != null)
{
var bytes = Encoding.GetEncoding(28591).GetBytes(s);
if (StreamDebugging.RxStreamDebuggingIsEnabled)
Debug.Console(0, this, "Received: '{0}'", ComTextHelper.GetEscapedText(bytes));
bytesHandler(this, new GenericCommMethodReceiveBytesArgs(bytes));
}
var textHandler = TextReceived;
if (textHandler != null)
{
if (StreamDebugging.RxStreamDebuggingIsEnabled)
Debug.Console(0, this, "Recevied: '{0}'", s);
if (StreamDebugging.RxStreamDebuggingIsEnabled)
Debug.Console(0, this, "Received: '{0}'", s);
textHandler(this, new GenericCommMethodReceiveTextArgs(s));
}
}