Photomechanics API
LegacyMftMessagesTransport Class Reference

Represents physical turn table messages transport. Provides methods for send and receive messages. More...

Inheritance diagram for LegacyMftMessagesTransport:
[legend]

Public Member Functions

 LegacyMftMessagesTransport (IDataTransport dataTransport, ILogger logger)
 
override String ToString ()
 
async ValueTask SendCommand (String command)
 Send given command string. Command begin and end inserted automatically;
 
void StartListening ()
 Start listening for messages.
 
- Public Member Functions inherited from AsyncDisposableExtendedBase
async ValueTask DisposeAsync ()
 

Static Public Attributes

const Char CommandBegin = '#'
 PC-to-turntable command begin character.
 
const Char CommandEnd = '.'
 PC-to-turntable command end character.
 

Protected Member Functions

override async ValueTask DisposeAsyncCore ()
 Derived type disposal logic. More...
 
void RaiseMessageReceived (String message)
 Raise MessageReceived.
 
- 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

String ConnectionInfo [get]
 ITurntableApi.ConnectionInfo.
 
Boolean ShouldFilterOutFirstBytes [get, set]
 Determines whether to ignore whatever got sent from serial port after connection until nothing is received for FirstBytesTimeout.
 
TimeSpan FirstBytesTimeout = TimeSpan.FromMilliseconds(500) [get, set]
 Amount of time that serial port must remain "silent" before starting reading messages.
 
TimeSpan MessageFinishTimeout = TimeSpan.FromMilliseconds(500) [get, set]
 Max amount of time after first message character until receiving newline. Arduino crane is known for sending something like "àààààààààààààààààààààààààààààààààààààà..." without newline at 57600 baud rate. Without this timeout API will be stuck in message reading loop. Update: turns out, some older arduino turntables may not send anything at this baud rate, fixed in devices manager.
 
TaskCompletionSource< Boolean > FilterOutFirstBytesTaskCompletionSource [get]
 Use this to await first bytes filtering before starting actual communication.
 
- 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...
 

Events

TypedEventHandler< LegacyMftMessagesTransport, String > MessageReceived
 Occurs when message is received.
 
- 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).
 

Detailed Description

Represents physical turn table messages transport. Provides methods for send and receive messages.

This base class can be inherited in order to implement custom communication channel (for instance, if needed to control turntable that is connected to remote PC). The messages transport is then used by higher-level API's.

Member Function Documentation

◆ DisposeAsyncCore()

override async ValueTask LegacyMftMessagesTransport.DisposeAsyncCore ( )
protectedvirtual

Derived type disposal logic.

Implements AsyncDisposableExtendedBase.