Moved ProtocolCore, SlotConfig and PortConfig to common\hardware\interfaces

This commit is contained in:
Thomas Wiedebusch
2023-04-26 13:16:32 +02:00
parent dc16f86930
commit cb72bc0352
46 changed files with 94 additions and 144 deletions
@@ -0,0 +1,63 @@
using System;
using System.IO.Ports;
namespace Xylem.Common.Hardware.Interfaces.Ports.PortCore
{
/// <summary>
/// Collection of port settings
/// </summary>
public struct PortConfig
{
private String _portName;
/// <summary>
/// Assigns a port name and creates the serial port object
/// Port name e.g. "COM2"
/// </summary>
public String PortName
{
get =>
//if the serial port object does not exists
GetSerialPort() == null ? "NA" : _portName;
set
{
if (value == null) return;
_portName = value;
//create a serial port object
if (GetSerialPort() == null)
{
SetSerialPort(new SerialPort(value));
}
else
{
GetSerialPort().PortName = value;
}
}
}
/// <summary>
/// setup of port type from name (referenced as "Type" in config file)
/// </summary>
public String Type { get; set; }
private SerialPort _serialPort;
/// <summary>
/// using dotNets <see cref="GetSerialPort()"/> for connection
/// </summary>
public SerialPort GetSerialPort()
{
return _serialPort;
}
/// <summary>
/// using dotNets <see cref="GetSerialPort()"/> for connection
/// </summary>
private void SetSerialPort(SerialPort value)
{
_serialPort = value;
}
}
}
@@ -94,7 +94,10 @@
<Compile Include="EventArguments\ListBytePortDataEventArgs.cs" />
<Compile Include="EventArguments\StringPortDataEventArgs.cs" />
<Compile Include="IPort.cs" />
<Compile Include="PortConfig.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SlotConfig.cs" />
<Compile Include="SlotType.cs" />
<Compile Include="TransmitPortSettings.cs" />
</ItemGroup>
<ItemGroup>
@@ -107,6 +110,7 @@
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\ServiceFwUpdate\packages\Newtonsoft.Json.12.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
@@ -0,0 +1,30 @@
using System;
namespace Xylem.Common.Hardware.Interfaces.Ports.PortCore
{
/// <summary>
/// Container for port configuration
/// </summary>
public class SlotConfig
{
/// <summary>
/// Slot number
/// </summary>
public Int32 Slot { get; set; }
/// <summary>
/// Request port settings
/// </summary>
public PortConfig Request { get; set; }
/// <summary>
/// Streaming port settings
/// </summary>
public PortConfig Streaming { get; set; }
/// <summary>
/// Streaming port settings
/// </summary>
public SlotType Type { get; set; }
}
}
@@ -0,0 +1,17 @@
namespace Xylem.Common.Hardware.Interfaces.Ports.PortCore
{
/// <summary>
/// Definition of type for slot
/// </summary>
public enum SlotType
{
/// <summary>
/// Cordonel used as DUT with two serial ports
/// </summary>
DutMeter,
/// <summary>
/// Cordonel used as temperature meter with one serial port streaming the temperature
/// </summary>
TemperatureMeter,
}
}