Skip to content

Commit

Permalink
delete agentgenerator
Browse files Browse the repository at this point in the history
  • Loading branch information
gc87 committed Jun 10, 2015
1 parent 5703e99 commit af1a27a
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 70 deletions.
40 changes: 0 additions & 40 deletions Windup.SerialTalker/AgentGenerator.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Windup.SerialTalker/Analyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Windup.SerialTalker
{
public enum ChangeFlag
enum ChangeFlag
{
Succeed,
Failed
Expand Down
26 changes: 0 additions & 26 deletions Windup.SerialTalker/SerialList.cs

This file was deleted.

60 changes: 59 additions & 1 deletion Windup.SerialTalker/Talker.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Linq;
using System.IO.Ports;
using System.Collections.Generic;

namespace Windup.SerialTalker
Expand All @@ -21,7 +23,7 @@ public Talker(string portName, int baudRate, LineBreak lineBreak)

public Talker(SPSetting setting, LineBreak lineBreak)
{
var sa = AgentGenerator.CreateAgent (setting);
var sa = CreateAgent(setting);
CreateAnalyzer (sa, lineBreak);
}

Expand Down Expand Up @@ -49,6 +51,62 @@ void OnDataListReady(object o, DataListReadyEventArgs e)
{
byteListProc (e.Bytes);
}

/// <summary>
/// Creates the agent.
/// </summary>
/// <returns>The agent.</returns>
/// <param name="setting">Setting.</param>
SerialAgent CreateAgent(SPSetting setting)
{
var sa = new SerialAgent() {
AgentPortName = setting.PortName,
AgentBaudRate = setting.BaudRate,
AgentParity = setting.Parity,
AgentDataBits = setting.DataBits,
AgentStopBits = setting.StopBits
};
return sa;
}

/// <summary>
/// Creates the agents.
/// </summary>
/// <returns>The agents.</returns>
/// <param name="settings">Settings.</param>
IEnumerable<SerialAgent> CreateAgents(IEnumerable<SPSetting> settings)
{
var list = new List<SerialAgent>();
foreach (var sa in settings.Select(setting => new SerialAgent(
portName: setting.PortName,
baudRate: setting.BaudRate,
parity: setting.Parity,
dataBits: setting.DataBits,
stopBits: setting.StopBits
))) {
list.Add(sa);
}
return list;
}

/// <summary>
/// Gets the serial ports.
/// </summary>
/// <returns>The serial ports.</returns>
public string[] GetSerialPorts()
{
string[] allSerial = null;
try
{
allSerial = SerialPort.GetPortNames();
}
catch /*(Exception e)*/
{
//throw new Exception(e.Message);
return null;
}
return allSerial;
}
}
}

2 changes: 0 additions & 2 deletions Windup.SerialTalker/Windup.SerialTalker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,11 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AgentGenerator.cs" />
<Compile Include="Analyzer.cs" />
<Compile Include="EventArgs\DataListReadyEventArgs.cs" />
<Compile Include="EventArgs\DataRxEventArgs.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SerialAgent.cs" />
<Compile Include="SerialList.cs" />
<Compile Include="Talker.cs" />
<Compile Include="LineBreak.cs" />
<Compile Include="SPSetting.cs" />
Expand Down

0 comments on commit af1a27a

Please sign in to comment.