Class Connector
Abstract base class provides implementation contract for the PLC connector and basic common underlying logic.
Implements priority-based access control and configurable batch operations for efficient communication.
Inherited Members
Namespace: AXSharp.Connector
Assembly: AXSharp.Connector.dll
Syntax
public abstract class Connector : RootTwinObject, ITwinObject, ITwinElement, INotifyPropertyChanged
Constructors
| Edit this page View SourceConnector()
Creates new instance of Connector class
Declaration
protected Connector()
Connector(object[])
Creates an instance of Connector class
Declaration
protected Connector(object[] parameters)
Parameters
| Type | Name | Description |
|---|---|---|
| object[] | parameters | Connection parameters |
Examples
var connector = new IConnector();
Properties
| Edit this page View SourceBatchSettings
Gets or sets the batch operation settings for different priority levels. Each priority level can have its own chunk size and inter-chunk delay settings.
Declaration
public Dictionary<eAccessPriority, (int? chunkSize, int? interChunkDelay)> BatchSettings { get; }
Property Value
| Type | Description |
|---|---|
| Dictionary<eAccessPriority, (int? chunkSize, int? interChunkDelay)> |
Remarks
The dictionary maps each priority level to a tuple containing:
- chunkSize: Maximum number of items to process in a single batch (null uses default)
- interChunkDelay: Delay in milliseconds between chunks (null uses default)
ConcurrentRequestDelay
Gets delay between concurrent requests. It is applied when ConcurrentRequestMaxCount is reached.
Declaration
public int ConcurrentRequestDelay { get; protected set; }
Property Value
| Type | Description |
|---|---|
| int |
ConcurrentRequestMaxCount
Gets maximal count of concurrent requests.
Maximum number of simultaneous requests is 4.
Note
The property will be capped to this value if higher value is assigned.
Important
When setting this value take into account that other devices may communicate with your target system.
Declaration
public int ConcurrentRequestMaxCount { get; protected set; }
Property Value
| Type | Description |
|---|---|
| int |
ConnectorAdapter
Gets adapter for onliners.
Declaration
public ConnectorAdapter ConnectorAdapter { get; }
Property Value
| Type | Description |
|---|---|
| ConnectorAdapter |
CyclicRwDuration
Gets the last duration of Read/Write cycle in milliseconds.
Declaration
public long CyclicRwDuration { get; }
Property Value
| Type | Description |
|---|---|
| long |
ErrorCount
Gets or sets error counter of the adapter.
Declaration
public int ErrorCount { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
ExceptionBehaviour
Gets or sets how the connector should handle communication exceptions.
Declaration
public CommExceptionBehaviour ExceptionBehaviour { get; set; }
Property Value
| Type | Description |
|---|---|
| CommExceptionBehaviour |
IdentityProvider
Gets object identity provider.
Declaration
public TwinIdentityProvider IdentityProvider { get; }
Property Value
| Type | Description |
|---|---|
| TwinIdentityProvider |
IsRwLoopSuspended
Gets or set whether RW loop is suspended.
Declaration
public bool IsRwLoopSuspended { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Logger
Provides logging capability for this connector.
Declaration
public ILogger Logger { get; }
Property Value
| Type | Description |
|---|---|
| ILogger |
MonitorConnector
Gets or sets value indicating whether the performance of the monitor should be active.
Declaration
public bool MonitorConnector { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
OnlineTags
Gets online value items tags attached to this connector.
Declaration
public IEnumerable<ITwinPrimitive> OnlineTags { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<ITwinPrimitive> |
ReadWriteCycleDelay
Gets or sets delay between Read/Write cycles.
Declaration
public int ReadWriteCycleDelay { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
RwCycleCount
Gets the number of Read Write cycles from the start of the connector.
Declaration
public long RwCycleCount { get; protected set; }
Property Value
| Type | Description |
|---|---|
| long |
StartUpTime
Get the connector's startup timestamp.
Declaration
public DateTime StartUpTime { get; protected set; }
Property Value
| Type | Description |
|---|---|
| DateTime |
SubscriptionMode
Gets or sets subscription mode for reading data from the controller.
Declaration
public ReadSubscriptionMode SubscriptionMode { get; set; }
Property Value
| Type | Description |
|---|---|
| ReadSubscriptionMode |
TargetPlatformMoniker
Target platform moniker.
Declaration
public abstract string TargetPlatformMoniker { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
| Edit this page View SourceBuildAndStart()
Builds and starts this connector.
Declaration
public abstract Connector BuildAndStart()
Returns
| Type | Description |
|---|---|
| Connector |
ClearPeriodicReadSet()
Declaration
protected void ClearPeriodicReadSet()
CreateHumanReadable(string, string)
Return humanized path combining parent's and member's names.
Declaration
public static string CreateHumanReadable(string parent, string member)
Parameters
| Type | Name | Description |
|---|---|---|
| string | parent | Parent's name. |
| string | member | Members name. |
Returns
| Type | Description |
|---|---|
| string | Combine symbol of parent and member. |
CreateSymbol(string, string)
Return symbol path combining parent's and member's symbol.
Declaration
public static string CreateSymbol(string parent, string member)
Parameters
| Type | Name | Description |
|---|---|---|
| string | parent | Parent's path. |
| string | member | Members name. |
Returns
| Type | Description |
|---|---|
| string | Combine symbol of parent and member. |
CyclicRead()
Reads online variables required to be read.
Declaration
protected Task CyclicRead()
Returns
| Type | Description |
|---|---|
| Task |
CyclicWrite()
Writes modified online variables.
Declaration
protected Task CyclicWrite()
Returns
| Type | Description |
|---|---|
| Task |
ReadBatchAsync(IEnumerable<ITwinPrimitive>, eAccessPriority, int, int)
Reads a batch of primitives asynchronously with specified priority and batch settings.
Declaration
public abstract Task ReadBatchAsync(IEnumerable<ITwinPrimitive> primitives, eAccessPriority priority = eAccessPriority.Normal, int chunkSize = 250, int interChunkDelay = 250)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<ITwinPrimitive> | primitives | Collection of primitives to read. |
| eAccessPriority | priority | Access priority level that determines batch processing parameters. |
| int | chunkSize | Override for the number of items to process in each chunk. |
| int | interChunkDelay | Override for the delay between chunks in milliseconds. |
Returns
| Type | Description |
|---|---|
| Task | A task representing the asynchronous read operation. |
Remarks
The actual batch processing parameters (chunk size and delay) may be determined by the priority level rather than the provided parameters, depending on the connector implementation.
ReloadConnector()
Forces the connector to reload symbols.
Declaration
public abstract void ReloadConnector()
SetCulture(CultureInfo)
Sets the culture for this connector.
Declaration
public static void SetCulture(CultureInfo culture)
Parameters
| Type | Name | Description |
|---|---|---|
| CultureInfo | culture | Desired culture |
SetField<T>(ref T, T, string)
Sets properties backing field value and notifies over INotifyPropertyChanged interface.
Declaration
protected bool SetField<T>(ref T field, T value, string propertyName)
Parameters
| Type | Name | Description |
|---|---|---|
| T | field | Field. |
| T | value | Value to be set. |
| string | propertyName | Property name. |
Returns
| Type | Description |
|---|---|
| bool |
Type Parameters
| Name | Description |
|---|---|
| T | Type of backing field. |
SetLoggerConfiguration(ILogger)
Sets logger for this connector.
![NOTE] The default logger is implemented. Default implementation will log into console and in simple text file.
Declaration
public void SetLoggerConfiguration(ILogger logger)
Parameters
| Type | Name | Description |
|---|---|---|
| ILogger | logger | Logger |
StartReadWriteOps()
Starts cyclical read write operation on this connector.
Declaration
protected void StartReadWriteOps()
StartSubscriptionPolling(int, int, int)
Start polling queue of subscribed items.
Declaration
public void StartSubscriptionPolling(int pollingInterval = 100, int chunkSize = 250, int interChunkDelay = 250)
Parameters
| Type | Name | Description |
|---|---|---|
| int | pollingInterval | |
| int | chunkSize | |
| int | interChunkDelay |
WriteBatchAsync(IEnumerable<ITwinPrimitive>, eAccessPriority, int, int)
Writes a batch of primitives asynchronously with specified priority and batch settings.
Declaration
public abstract Task WriteBatchAsync(IEnumerable<ITwinPrimitive> primitives, eAccessPriority priority = eAccessPriority.Normal, int chunkSize = 250, int interChunkDelay = 250)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<ITwinPrimitive> | primitives | Collection of primitives to write. |
| eAccessPriority | priority | Access priority level that determines batch processing parameters. |
| int | chunkSize | Override for the number of items to process in each chunk. |
| int | interChunkDelay | Override for the delay between chunks in milliseconds. |
Returns
| Type | Description |
|---|---|
| Task | A task representing the asynchronous write operation. |
Remarks
The actual batch processing parameters (chunk size and delay) may be determined by the priority level rather than the provided parameters, depending on the connector implementation.
Events
| Edit this page View SourcePropertyChanged
Implementation of INotifyPropertyChanged
Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
| Type | Description |
|---|---|
| PropertyChangedEventHandler |