3using System.Threading.Tasks;
17 private readonly SemaphoreSlim synchObj =
new SemaphoreSlim(1);
54 public override Task
FromXml(XmlElement Definition)
56 this.host =
XML.
Attribute(Definition,
"host",
"localhost");
59 return base.FromXml(Definition);
96 return Task.CompletedTask;
119 if (!(this.sniffer is
null))
121 if (this.sniffer is IDisposable Disposable)
122 Disposable.Dispose();
143 await this.synchObj.WaitAsync();
151 this.synchObj.Release();
Abstract base class for ModBus actors.
Represents a simulated ModBus client
ModBusClient(ISimulationNode Parent, Model Model, int InstanceIndex, string InstanceId)
Represents a simulated ModBus client
override Task< Actor > CreateInstanceAsync(int InstanceIndex, string InstanceId)
Creates an instance of the actor.
void Unlock()
Unlocks the client.
override Task InitializeInstance()
Initializes an instance of an actor.
override async Task FinalizeInstance()
Finalizes an instance of an actor.
ModBusClient(ISimulationNode Parent, Model Model)
Represents a simulated ModBus client
override ISimulationNode Create(ISimulationNode Parent, Model Model)
Creates a new instance of the node.
ModbusTcpClient Client
ModBus TCP client reference.
override async Task StartInstance()
Starts an instance of an actor.
async Task Lock()
Locks the client for use by one caller.
override string LocalName
override Task FromXml(XmlElement Definition)
Sets properties and attributes of class in accordance with XML definition.
Root node of a simulation model
ISniffer GetSniffer(string Actor)
Gets a sniffer, if sniffer output is desired.
Abstract base class for actors
string InstanceId
ID of actor instance.
int InstanceIndex
Actor instance index.
Helps with common XML-related tasks.
static string Attribute(XmlElement E, string Name)
Gets the value of an XML attribute.
static async Task< ModbusTcpClient > Connect(string Host, int Port, params ISniffer[] Sniffers)
Connects to an Modbus TCP/IP Gateway
const int DefaultPort
Default Modbus port (502)
void Dispose()
IDisposable.Dispose
Basic interface for simulator nodes. Implementing this interface allows classes with default contruct...
ISimulationNode Parent
Parent node in the simulation model.
Interface for sniffers. Sniffers can be added to ICommunicationLayer classes to eavesdrop on communic...
BinaryPresentationMethod
How binary data is to be presented.