Class TwinIdentityProvider
Provides access to the objects by their identities.
Inherited Members
Namespace: AXSharp.Connector.Identity
Assembly: AXSharp.Connector.dll
Syntax
public class TwinIdentityProvider
Constructors
| Edit this page View SourceTwinIdentityProvider()
Creates new instance of TwinIdentityProvider.
Declaration
[Obsolete("Use `TwinIdentityProvider(Connector connector)` instead.")]
public TwinIdentityProvider()
TwinIdentityProvider(Connector)
Creates an instance of TwinIdentityProvider
Declaration
public TwinIdentityProvider(Connector connector)
Parameters
| Type | Name | Description |
|---|---|---|
| Connector | connector |
Properties
| Edit this page View SourceIdentities
Get dictionary of identities.
Declaration
public SortedDictionary<ulong, ITwinIdentity> Identities { get; }
Property Value
| Type | Description |
|---|---|
| SortedDictionary<ulong, ITwinIdentity> |
IdentitiesCount
Get count of identities.
Declaration
public long IdentitiesCount { get; }
Property Value
| Type | Description |
|---|---|
| long |
Methods
| Edit this page View SourceAddIdentity(ITwinIdentity)
Adds twin object to the list of identities.
Declaration
public void AddIdentity(ITwinIdentity twinObject)
Parameters
| Type | Name | Description |
|---|---|---|
| ITwinIdentity | twinObject | twin object |
AssignIdentities(IEnumerable<OnlinerULInt>, Func<OnlinerULInt, ulong>)
Assigns identities to all elements.
Declaration
public IEnumerable<OnlinerULInt> AssignIdentities(IEnumerable<OnlinerULInt> identities, Func<OnlinerULInt, ulong> identityProvider = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<OnlinerULInt> | identities | Identities |
| Func<OnlinerULInt, ulong> | identityProvider | Identity creator. |
Returns
| Type | Description |
|---|---|
| IEnumerable<OnlinerULInt> | Assigned identities. |
ConstructIdentitiesAsync(Func<OnlinerULInt, ulong>, bool)
Constructs identities by assigning them locally, writing to PLC, and sorting by the assigned values. Identity values are always written fresh to the PLC regardless of any previously stored values. This ensures that stale or inconsistent identity values from prior sessions do not cause duplicate identity errors.
Declaration
public Task ConstructIdentitiesAsync(Func<OnlinerULInt, ulong> identityProvider = null, bool failOnDuplicate = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<OnlinerULInt, ulong> | identityProvider | Function that assigns and returns an identity value for each OnlinerULInt tag.
When |
| bool | failOnDuplicate | When |
Returns
| Type | Description |
|---|---|
| Task |
GetTwinByIdentity(ITwinIdentity)
Gets twin object by identity.
Declaration
public dynamic GetTwinByIdentity(ITwinIdentity obj)
Parameters
| Type | Name | Description |
|---|---|---|
| ITwinIdentity | obj | Twin object. |
Returns
| Type | Description |
|---|---|
| dynamic | Twin object with given identity. |
GetTwinByIdentity(object)
Gets twin object by identity, if the object implements ITwinIdentity. If object does not implements ITwinIdentity the same object is returned.
Declaration
public dynamic GetTwinByIdentity(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | Object with identity |
Returns
| Type | Description |
|---|---|
| dynamic | twin object with given identity. |
GetTwinByIdentity(ulong)
Gets twin object by identity.
Declaration
public ITwinIdentity GetTwinByIdentity(ulong identity)
Parameters
| Type | Name | Description |
|---|---|---|
| ulong | identity | Twin identity address. |
Returns
| Type | Description |
|---|---|
| ITwinIdentity | Twin object with given identity. |
WriteIdentities(IEnumerable<OnlinerULInt>)
Writes identities to the PLC.
Declaration
public Task WriteIdentities(IEnumerable<OnlinerULInt> identitiesToWrite)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<OnlinerULInt> | identitiesToWrite | List of identities to be written. |
Returns
| Type | Description |
|---|---|
| Task |