Photomechanics API
ModbusListener Class Reference
Inheritance diagram for ModbusListener:
[legend]

Public Member Functions

 ModbusListener (IModbusMaster modbusMaster, ILogger logger)
 
override String ToString ()
 
void AddRegistersToObserve (IEnumerable< IObservableRegister > registerDescriptors)
 Add registers which will be periodically read from slave. More...
 
async Task WriteRegistersAsync (params(IObservableRegister register, UInt16 newValue)[] registers)
 Write new values to the given registers. More...
 
Task WaitInitialRegistersUpdate ()
 Wait for registers to be updated. Used if needed to ensure registers update before other actions. More...
 
- Public Member Functions inherited from AsyncDisposableExtendedBase
async ValueTask DisposeAsync ()
 
void AddRegistersToObserve (IEnumerable< IObservableRegister > registerDescriptors)
 Add registers which will be periodically read from slave. More...
 
Task WriteRegistersAsync (params(IObservableRegister register, UInt16 newValue)[] registers)
 Write new values to the given registers. More...
 
Task WaitInitialRegistersUpdate ()
 Wait for registers to be updated. Used if needed to ensure registers update before other actions. More...
 

Protected Member Functions

override ValueTask DisposeAsyncCore ()
 Derived type disposal logic. More...
 
- Protected Member Functions inherited from AsyncDisposableExtendedBase
 AsyncDisposableExtendedBase (ILogger logger)
 Base constructor for device api. More...
 
abstract ValueTask DisposeAsyncCore ()
 Derived type disposal logic. More...
 
void UpdateLoggerContext ()
 Unfortunately Serilog ForContext method does not store provided object as property value, calling its ToString method immediately instead. In some cases, we want to use information like device name/id as log context but it is only available when derived type is fully constructed and maybe some other initialization took place. For such cases, derived type can use this method to update Logger context value.
 

Properties

Byte SlaveAddress [get]
 SlaveID. More...
 
IModbusMaster ModbusMaster [get]
 Modbus master. More...
 
- Properties inherited from AsyncDisposableExtendedBase
ILogger Logger [get]
 Logger associated with this instance. This way extension methods can use logging without requiring it as parameter. More...
 
Boolean IsDisposed [get]
 Determines whether the object is being disposed or already disposed and no longer functional. More...
 
virtual IAsyncDisposableExtended Owner [get]
 Type and ToString values of this object will appear when logging begin/end of DisposeAsync. This object will also be used as Disposed sender, essentially allowing seamlessly using AsyncDisposableExtendedBase logic even when directly inheriting from it is not possible. Usually it simply returns "this" value, but AsyncDisposableExtendedImpl overrides it to return its owner instance for the aforementioned reason.
 
- Properties inherited from IAsyncDisposableExtended
Boolean IsDisposed [get]
 Determines whether the object is being disposed or already disposed and no longer functional. More...
 
ILogger Logger [get]
 Logger associated with this instance. This way extension methods can use logging without requiring it as parameter. More...
 
- Properties inherited from IModbusListener
IModbusMaster ModbusMaster [get]
 Modbus master. More...
 
Byte SlaveAddress [get]
 SlaveID. More...
 

Additional Inherited Members

- Events inherited from AsyncDisposableExtendedBase
AsyncTypedEventHandler< IAsyncDisposableExtended >? Disposed
 
- Events inherited from IAsyncDisposableExtended
AsyncTypedEventHandler< IAsyncDisposableExtendedDisposed
 Occurs when object is disposed. It should be invoked at the end of IAsyncDisposable.DisposeAsync implementation in a Fire-and-Forget fashion (non-blocking).
 

Member Function Documentation

◆ AddRegistersToObserve()

void ModbusListener.AddRegistersToObserve ( IEnumerable< IObservableRegister registerDescriptors)

Add registers which will be periodically read from slave.

Implements IModbusListener.

◆ WriteRegistersAsync()

async Task ModbusListener.WriteRegistersAsync ( params(IObservableRegister register, UInt16 newValue)[]  registers)

Write new values to the given registers.

Attempts to write multiple registers at once if addresses are sequentional. Used by modbus commands.

Implements IModbusListener.

◆ WaitInitialRegistersUpdate()

Task ModbusListener.WaitInitialRegistersUpdate ( )

Wait for registers to be updated. Used if needed to ensure registers update before other actions.

Implements IModbusListener.

◆ DisposeAsyncCore()

override ValueTask ModbusListener.DisposeAsyncCore ( )
protectedvirtual

Derived type disposal logic.

Implements AsyncDisposableExtendedBase.

Property Documentation

◆ SlaveAddress

Byte ModbusListener.SlaveAddress
get

SlaveID.

Implements IModbusListener.

◆ ModbusMaster

IModbusMaster ModbusListener.ModbusMaster
get

Modbus master.

Implements IModbusListener.