mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-02-16 21:24:43 +00:00
Multiple character gather on CommunicationGather
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
@@ -41,6 +42,8 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
char Delimiter;
|
char Delimiter;
|
||||||
|
|
||||||
|
string StringDelimiter;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fires up a gather, given a IBasicCommunicaion port and char for de
|
/// Fires up a gather, given a IBasicCommunicaion port and char for de
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -53,6 +56,18 @@ namespace PepperDash.Core
|
|||||||
port.TextReceived += new EventHandler<GenericCommMethodReceiveTextArgs>(Port_TextReceived);
|
port.TextReceived += new EventHandler<GenericCommMethodReceiveTextArgs>(Port_TextReceived);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="port"></param>
|
||||||
|
/// <param name="delimiter"></param>
|
||||||
|
public CommunicationGather(IBasicCommunication port, string delimiter)
|
||||||
|
{
|
||||||
|
Port = port;
|
||||||
|
StringDelimiter = delimiter;
|
||||||
|
port.TextReceived += TextReceivedStringDelimiter;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handler for raw data coming from port
|
/// Handler for raw data coming from port
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -73,6 +88,31 @@ namespace PepperDash.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="args"></param>
|
||||||
|
void TextReceivedStringDelimiter(object sender, GenericCommMethodReceiveTextArgs args)
|
||||||
|
{
|
||||||
|
var handler = LineReceived;
|
||||||
|
if (handler != null)
|
||||||
|
{
|
||||||
|
// Receive buffer should either be empty or not contain the delimiter
|
||||||
|
// If the line does not have a delimiter, append the
|
||||||
|
|
||||||
|
ReceiveBuffer.Append(args.Text);
|
||||||
|
var str = ReceiveBuffer.ToString();
|
||||||
|
var lines = Regex.Split(str, StringDelimiter);
|
||||||
|
if (lines.Length > 1)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < lines.Length - 1; i++)
|
||||||
|
handler(this, new GenericCommMethodReceiveTextArgs(lines[i]));
|
||||||
|
ReceiveBuffer = new StringBuilder(lines[lines.Length - 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deconstructor. Disconnects from port TextReceived events.
|
/// Deconstructor. Disconnects from port TextReceived events.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -85,7 +85,7 @@
|
|||||||
<Programmer />
|
<Programmer />
|
||||||
<ArchiveFilename>C:\Users\hvolm\Desktop\working\pepperdash-simplsharp-core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.clz</ArchiveFilename>
|
<ArchiveFilename>C:\Users\hvolm\Desktop\working\pepperdash-simplsharp-core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.clz</ArchiveFilename>
|
||||||
<MinFirmwareVersion>1.007.0017</MinFirmwareVersion>
|
<MinFirmwareVersion>1.007.0017</MinFirmwareVersion>
|
||||||
<CompiledOn>9/12/2016 2:06:04 PM</CompiledOn>
|
<CompiledOn>9/20/2016 2:09:33 PM</CompiledOn>
|
||||||
<AdditionalInfo />
|
<AdditionalInfo />
|
||||||
<EmbedSourceArchive>False</EmbedSourceArchive>
|
<EmbedSourceArchive>False</EmbedSourceArchive>
|
||||||
<CopyTo />
|
<CopyTo />
|
||||||
|
|||||||
Binary file not shown.
@@ -10,7 +10,7 @@
|
|||||||
<ArchiveName />
|
<ArchiveName />
|
||||||
</RequiredInfo>
|
</RequiredInfo>
|
||||||
<OptionalInfo>
|
<OptionalInfo>
|
||||||
<CompiledOn>9/12/2016 2:06:04 PM</CompiledOn>
|
<CompiledOn>9/20/2016 2:09:33 PM</CompiledOn>
|
||||||
<CompilerRev>1.0.0.23581</CompilerRev>
|
<CompilerRev>1.0.0.23686</CompilerRev>
|
||||||
</OptionalInfo>
|
</OptionalInfo>
|
||||||
</ProgramInfo>
|
</ProgramInfo>
|
||||||
Binary file not shown.
@@ -1,4 +1,4 @@
|
|||||||
MainAssembly=PepperDash_Core.dll:841414db99de3a39f802c9ba80e23ad1
|
MainAssembly=PepperDash_Core.dll:d21b9348a9ff127c20006e8d8b9a166c
|
||||||
MainAssemblyMinFirmwareVersion=1.007.0017
|
MainAssemblyMinFirmwareVersion=1.007.0017
|
||||||
ü
|
ü
|
||||||
DependencySource=Newtonsoft.Json.Compact.dll:ea996aa2ec65aa1878e7c9d09e37a896
|
DependencySource=Newtonsoft.Json.Compact.dll:ea996aa2ec65aa1878e7c9d09e37a896
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user