Initial commit
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
namespace RobotNet10.Script.IO;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for CC-Link IE connection operations.
|
||||
/// </summary>
|
||||
public interface ICcLinkIeConnection : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the IP address of the CC-Link IE device.
|
||||
/// </summary>
|
||||
string IpAddress { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the station number.
|
||||
/// </summary>
|
||||
int StationNumber { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the connection is currently connected.
|
||||
/// </summary>
|
||||
bool IsConnected { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Connects to the CC-Link IE device.
|
||||
/// </summary>
|
||||
Task ConnectAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Disconnects from the CC-Link IE device.
|
||||
/// </summary>
|
||||
Task DisconnectAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Reads data from the CC-Link IE device.
|
||||
/// </summary>
|
||||
/// <param name="address">The memory address.</param>
|
||||
/// <param name="length">The number of words to read.</param>
|
||||
/// <returns>The read data as ushort array.</returns>
|
||||
Task<ushort[]> ReadAsync(int address, int length);
|
||||
|
||||
/// <summary>
|
||||
/// Writes data to the CC-Link IE device.
|
||||
/// </summary>
|
||||
/// <param name="address">The memory address.</param>
|
||||
/// <param name="data">The data to write.</param>
|
||||
Task WriteAsync(int address, ushort[] data);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
namespace RobotNet10.Script.IO;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for HTTP connection operations.
|
||||
/// </summary>
|
||||
public interface IHttpConnection : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the base URL of the HTTP connection.
|
||||
/// </summary>
|
||||
string BaseUrl { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the connection is currently connected.
|
||||
/// </summary>
|
||||
bool IsConnected { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Connects to the HTTP endpoint.
|
||||
/// </summary>
|
||||
Task ConnectAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Disconnects from the HTTP endpoint.
|
||||
/// </summary>
|
||||
Task DisconnectAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Sends a GET request to the specified path.
|
||||
/// </summary>
|
||||
/// <param name="path">The path relative to BaseUrl.</param>
|
||||
/// <param name="headers">Optional headers to include in the request.</param>
|
||||
/// <returns>The response content as string.</returns>
|
||||
Task<string> GetAsync(string path, Dictionary<string, string>? headers = null);
|
||||
|
||||
/// <summary>
|
||||
/// Sends a POST request to the specified path.
|
||||
/// </summary>
|
||||
/// <param name="path">The path relative to BaseUrl.</param>
|
||||
/// <param name="content">The content to send.</param>
|
||||
/// <param name="contentType">The content type (default: application/json).</param>
|
||||
/// <param name="headers">Optional headers to include in the request.</param>
|
||||
/// <returns>The response content as string.</returns>
|
||||
Task<string> PostAsync(string path, string content, string contentType = "application/json", Dictionary<string, string>? headers = null);
|
||||
|
||||
/// <summary>
|
||||
/// Sends a PUT request to the specified path.
|
||||
/// </summary>
|
||||
/// <param name="path">The path relative to BaseUrl.</param>
|
||||
/// <param name="content">The content to send.</param>
|
||||
/// <param name="contentType">The content type (default: application/json).</param>
|
||||
/// <param name="headers">Optional headers to include in the request.</param>
|
||||
/// <returns>The response content as string.</returns>
|
||||
Task<string> PutAsync(string path, string content, string contentType = "application/json", Dictionary<string, string>? headers = null);
|
||||
|
||||
/// <summary>
|
||||
/// Sends a DELETE request to the specified path.
|
||||
/// </summary>
|
||||
/// <param name="path">The path relative to BaseUrl.</param>
|
||||
/// <param name="headers">Optional headers to include in the request.</param>
|
||||
/// <returns>The response content as string.</returns>
|
||||
Task<string> DeleteAsync(string path, Dictionary<string, string>? headers = null);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
namespace RobotNet10.Script.IO;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for ModbusTCP connection operations.
|
||||
/// </summary>
|
||||
public interface IModbusTcpConnection : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the IP address of the ModbusTCP server.
|
||||
/// </summary>
|
||||
string IpAddress { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the port of the ModbusTCP server.
|
||||
/// </summary>
|
||||
int Port { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the slave ID (unit identifier).
|
||||
/// </summary>
|
||||
byte SlaveId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the connection is currently connected.
|
||||
/// </summary>
|
||||
bool IsConnected { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Connects to the ModbusTCP server.
|
||||
/// </summary>
|
||||
Task ConnectAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Disconnects from the ModbusTCP server.
|
||||
/// </summary>
|
||||
Task DisconnectAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Reads holding registers.
|
||||
/// </summary>
|
||||
/// <param name="startAddress">The starting address.</param>
|
||||
/// <param name="numberOfPoints">The number of registers to read.</param>
|
||||
/// <returns>Array of register values.</returns>
|
||||
Task<ushort[]> ReadHoldingRegistersAsync(ushort startAddress, ushort numberOfPoints);
|
||||
|
||||
/// <summary>
|
||||
/// Reads input registers.
|
||||
/// </summary>
|
||||
/// <param name="startAddress">The starting address.</param>
|
||||
/// <param name="numberOfPoints">The number of registers to read.</param>
|
||||
/// <returns>Array of register values.</returns>
|
||||
Task<ushort[]> ReadInputRegistersAsync(ushort startAddress, ushort numberOfPoints);
|
||||
|
||||
/// <summary>
|
||||
/// Reads coils.
|
||||
/// </summary>
|
||||
/// <param name="startAddress">The starting address.</param>
|
||||
/// <param name="numberOfPoints">The number of coils to read.</param>
|
||||
/// <returns>Array of coil values.</returns>
|
||||
Task<bool[]> ReadCoilsAsync(ushort startAddress, ushort numberOfPoints);
|
||||
|
||||
/// <summary>
|
||||
/// Reads discrete inputs.
|
||||
/// </summary>
|
||||
/// <param name="startAddress">The starting address.</param>
|
||||
/// <param name="numberOfPoints">The number of inputs to read.</param>
|
||||
/// <returns>Array of input values.</returns>
|
||||
Task<bool[]> ReadDiscreteInputsAsync(ushort startAddress, ushort numberOfPoints);
|
||||
|
||||
/// <summary>
|
||||
/// Writes a single coil.
|
||||
/// </summary>
|
||||
/// <param name="coilAddress">The coil address.</param>
|
||||
/// <param name="value">The value to write.</param>
|
||||
Task WriteSingleCoilAsync(ushort coilAddress, bool value);
|
||||
|
||||
/// <summary>
|
||||
/// Writes multiple coils.
|
||||
/// </summary>
|
||||
/// <param name="startAddress">The starting address.</param>
|
||||
/// <param name="values">The values to write.</param>
|
||||
Task WriteMultipleCoilsAsync(ushort startAddress, bool[] values);
|
||||
|
||||
/// <summary>
|
||||
/// Writes a single holding register.
|
||||
/// </summary>
|
||||
/// <param name="registerAddress">The register address.</param>
|
||||
/// <param name="value">The value to write.</param>
|
||||
Task WriteSingleRegisterAsync(ushort registerAddress, ushort value);
|
||||
|
||||
/// <summary>
|
||||
/// Writes multiple holding registers.
|
||||
/// </summary>
|
||||
/// <param name="startAddress">The starting address.</param>
|
||||
/// <param name="values">The values to write.</param>
|
||||
Task WriteMultipleRegistersAsync(ushort startAddress, ushort[] values);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
namespace RobotNet10.Script.IO;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for OPC UA connection operations.
|
||||
/// </summary>
|
||||
public interface IOpcUaConnection : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the endpoint URL of the OPC UA server.
|
||||
/// </summary>
|
||||
string EndpointUrl { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the connection is currently connected.
|
||||
/// </summary>
|
||||
bool IsConnected { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Connects to the OPC UA server.
|
||||
/// </summary>
|
||||
Task ConnectAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Connects to the OPC UA server with username and password.
|
||||
/// </summary>
|
||||
/// <param name="username">The username.</param>
|
||||
/// <param name="password">The password.</param>
|
||||
Task ConnectAsync(string username, string password);
|
||||
|
||||
/// <summary>
|
||||
/// Disconnects from the OPC UA server.
|
||||
/// </summary>
|
||||
Task DisconnectAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Reads a node value by node ID.
|
||||
/// </summary>
|
||||
/// <param name="nodeId">The node ID string (e.g., "ns=2;s=MyVariable").</param>
|
||||
/// <returns>The read value as object.</returns>
|
||||
Task<object?> ReadNodeAsync(string nodeId);
|
||||
|
||||
/// <summary>
|
||||
/// Reads multiple node values by node IDs.
|
||||
/// </summary>
|
||||
/// <param name="nodeIds">Array of node ID strings.</param>
|
||||
/// <returns>Dictionary of node ID to value.</returns>
|
||||
Task<Dictionary<string, object?>> ReadNodesAsync(string[] nodeIds);
|
||||
|
||||
/// <summary>
|
||||
/// Writes a value to a node by node ID.
|
||||
/// </summary>
|
||||
/// <param name="nodeId">The node ID string.</param>
|
||||
/// <param name="value">The value to write.</param>
|
||||
Task WriteNodeAsync(string nodeId, object value);
|
||||
|
||||
/// <summary>
|
||||
/// Writes multiple values to nodes.
|
||||
/// </summary>
|
||||
/// <param name="values">Dictionary of node ID to value.</param>
|
||||
Task WriteNodesAsync(Dictionary<string, object> values);
|
||||
|
||||
/// <summary>
|
||||
/// Browses the node tree starting from the specified node.
|
||||
/// </summary>
|
||||
/// <param name="nodeId">The starting node ID (null for root).</param>
|
||||
/// <returns>Array of child node IDs.</returns>
|
||||
Task<string[]> BrowseNodesAsync(string? nodeId = null);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
namespace RobotNet10.Script.IO;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for ProfiNet connection operations.
|
||||
/// </summary>
|
||||
public interface IProfiNetConnection : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the IP address of the ProfiNet device.
|
||||
/// </summary>
|
||||
string IpAddress { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the slot number.
|
||||
/// </summary>
|
||||
int Slot { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the subslot number.
|
||||
/// </summary>
|
||||
int Subslot { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the connection is currently connected.
|
||||
/// </summary>
|
||||
bool IsConnected { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Connects to the ProfiNet device.
|
||||
/// </summary>
|
||||
Task ConnectAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Disconnects from the ProfiNet device.
|
||||
/// </summary>
|
||||
Task DisconnectAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Reads data from the ProfiNet device.
|
||||
/// </summary>
|
||||
/// <param name="index">The index to read from.</param>
|
||||
/// <param name="length">The number of bytes to read.</param>
|
||||
/// <returns>The read data as byte array.</returns>
|
||||
Task<byte[]> ReadAsync(int index, int length);
|
||||
|
||||
/// <summary>
|
||||
/// Writes data to the ProfiNet device.
|
||||
/// </summary>
|
||||
/// <param name="index">The index to write to.</param>
|
||||
/// <param name="data">The data to write.</param>
|
||||
Task WriteAsync(int index, byte[] data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user