using Hylasoft.Opc.Common;
using Hylasoft.Opc.Da;
using Hylasoft.Opc.Ua;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Modbus.Net.Opc
{
///
/// Opc Client Extend interface, Unified for DA and UA
///
public interface IClientExtend : IDisposable
{
///
/// Unified Root Node
///
Node RootNodeBase { get; }
///
/// Connect the client to the Opc Server
///
void Connect();
///
/// Read a tag
///
/// The type of tag to read
///
/// The fully-qualified identifier of the tag. You can specify a subfolder by using a comma delimited name.
/// E.g: the tag `foo.bar` reads the tag `bar` on the folder `foo`
///
/// The value retrieved from the Opc
ReadEvent Read(string tag);
///
/// Write a value on the specified Opc tag
///
/// The type of tag to write on
///
/// The fully-qualified identifier of the tag. You can specify a subfolder by using a comma delimited name.
/// E.g: the tag `foo.bar` writes on the tag `bar` on the folder `foo`
///
///
void Write(string tag, T item);
///
/// Read a tag asynchronusly
///
Task> ReadAsync(string tag);
///
/// Write a value on the specified Opc tag asynchronously
///
Task WriteAsync(string tag, T item);
///
/// Finds a node on the Opc Server asynchronously
///
Task FindNodeAsync(string tag);
///
/// Explore a folder on the Opc Server asynchronously
///
Task> ExploreFolderAsync(string tag);
}
///
/// UaClient Extend
///
public class MyDaClient : DaClient, IClientExtend
{
///
/// UaClient Extend
///
/// Url address of Opc UA server
public MyDaClient(Uri serverUrl) : base(serverUrl)
{
}
///
/// Unified root node
///
public Node RootNodeBase => RootNode;
}
///
/// DaClient Extend
///
public class MyUaClient : UaClient, IClientExtend
{
///
/// DaClient Extend
///
public MyUaClient(Uri serverUrl) : base(serverUrl)
{
}
///
/// Unified root node
///
public Node RootNodeBase => RootNode;
}
///
/// Param input of OpcConnector
///
public class OpcParamIn
{
///
/// Is the action read (not is write)
///
public bool IsRead { get; set; }
///
/// Tag of a node
///
public string[] Tag { get; set; }
///
/// Tag splitter of a node
///
public char Split { get; set; }
///
/// The value set to node(only available when IsRead is false
///
public object SetValue { get; set; }
}
///
/// Param output of OpcConnector
///
public class OpcParamOut
{
///
/// Is the action success
///
public bool Success { get; set; }
///
/// Action return values
///
public byte[] Value { get; set; }
}
}