Class TwinObjectExtensions
Extensions methods for ITwinObject.
Inherited Members
Namespace: AXSharp.Connector
Assembly: AXSharp.Connector.dll
Syntax
public static class TwinObjectExtensions
Fields
| Edit this page View SourceHasChangedMethodName
Declaration
public static readonly string HasChangedMethodName
Field Value
| Type | Description |
|---|---|
| string |
OnlineToPlainMethodName
Declaration
public static readonly string OnlineToPlainMethodName
Field Value
| Type | Description |
|---|---|
| string |
PlainToOnlineMethodName
Declaration
public static readonly string PlainToOnlineMethodName
Field Value
| Type | Description |
|---|---|
| string |
PlainToShadowMethodName
Declaration
public static readonly string PlainToShadowMethodName
Field Value
| Type | Description |
|---|---|
| string |
ShadowToPlainMethodName
Declaration
public static readonly string ShadowToPlainMethodName
Field Value
| Type | Description |
|---|---|
| string |
Methods
| Edit this page View SourceCreatePoco(ITwinObject)
Creates new unpopulated instance of POCO object for this twin object.
Declaration
public static object CreatePoco(this ITwinObject obj)
Parameters
| Type | Name | Description |
|---|---|---|
| ITwinObject | obj |
Returns
| Type | Description |
|---|---|
| object | New empty instance of POCO object for this twin object |
HasAttribute<T>(ITwinElement)
Declaration
public static bool HasAttribute<T>(this ITwinElement twinElement) where T : Attribute
Parameters
| Type | Name | Description |
|---|---|---|
| ITwinElement | twinElement |
Returns
| Type | Description |
|---|---|
| bool |
Type Parameters
| Name | Description |
|---|---|
| T |
MakeReadOnce(ITwinObject)
Makes ITwinObject access only once during the lifetime of the application.
Declaration
public static void MakeReadOnce(this ITwinObject structure)
Parameters
| Type | Name | Description |
|---|---|---|
| ITwinObject | structure | Object to be rendered readonly |
Examples
// Renders whole complex type access only once.
ReadonlyStructure.MakeReadOnce();
// Renders element [0,0] of the array readonly.
roArray[0, 0].MakeReadOnce();
|
Edit this page
View Source
MakeReadOnly(ITwinObject)
Makes ITwinObject readonly for this application.
Declaration
public static void MakeReadOnly(this ITwinObject structure)
Parameters
| Type | Name | Description |
|---|---|---|
| ITwinObject | structure | Object to be rendered readonly |
Examples
// Renders whole structure value tag readonly
ReadonlyStructure.MakeReadOnly();
// Renders element [0,0] of the array readonly.
roArray[0, 0].MakeReadOnly();
|
Edit this page
View Source
OnlineToShadowAsync(ITwinObject)
Copies the data from Online primitive items (PLC) of an ITwinObject to shadow value holders.
Declaration
public static Task OnlineToShadowAsync(this ITwinObject obj)
Parameters
| Type | Name | Description |
|---|---|---|
| ITwinObject | obj | Twin object to copy. |
Returns
| Type | Description |
|---|---|
| Task |
ReadAsync(ITwinObject)
Reads all value tags of instance ITwinOnlineObject.
Declaration
public static Task<IEnumerable<ITwinPrimitive>> ReadAsync(this ITwinObject structure)
Parameters
| Type | Name | Description |
|---|---|---|
| ITwinObject | structure |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<ITwinPrimitive>> |
Examples
// Reads all value tags of the MAIN PRG. The value is stored in property 'Cyclic' and 'LastValue' of the respective value tag.
Connector.MAIN.ReadAsync();
|
Edit this page
View Source
ReadAsync<T>(ITwinObject)
Reads all value tags of instance ITwinOnlineObject, but ignores members that are annotated with attribute as generic parameter.
Important
This method is used for specific framework purposed and there is no specific reason to use it in your application. Use non generic version of this method ReadAsync(ITwinObject) instead.
Declaration
public static Task<IEnumerable<ITwinPrimitive>> ReadAsync<T>(this ITwinObject structure) where T : Attribute
Parameters
| Type | Name | Description |
|---|---|---|
| ITwinObject | structure | Structure to be read |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<ITwinPrimitive>> | List of read items. |
Type Parameters
| Name | Description |
|---|---|
| T | Attribute parameter to be ignored |
RetrievePrimitives(ITwinObject, List<ITwinPrimitive>)
Retrieves all value tags of given object recursively.
Declaration
public static IEnumerable<ITwinPrimitive> RetrievePrimitives(this ITwinObject onlineObject, List<ITwinPrimitive> valueTags = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ITwinObject | onlineObject | Object from which the value tags are to be retrieved. |
| List<ITwinPrimitive> | valueTags | Pre-existing value tags. |
Returns
| Type | Description |
|---|---|
| IEnumerable<ITwinPrimitive> | Value tags of given object. |
Examples
This example demonstrates how to get all value tags of the MAIN PRG object.
var mainProgramTags = Connector.MAIN.RetrievePrimitives();
|
Edit this page
View Source
ShadowToOnlineAsync(ITwinObject)
Copies the data from Shadow value holder to online primitive items (PLC) of an ITwinObject.
Declaration
public static Task ShadowToOnlineAsync(this ITwinObject obj)
Parameters
| Type | Name | Description |
|---|---|---|
| ITwinObject | obj | Twin object to copy. |
Returns
| Type | Description |
|---|---|
| Task |
StartPolling(ITwinElement, int, object)
Starts polling data from a ITwinElement at given interval.
Declaration
public static void StartPolling(this ITwinElement obj, int interval, object holder)
Parameters
| Type | Name | Description |
|---|---|---|
| ITwinElement | obj | Object to be polled. |
| int | interval | Polling interval in ms. |
| object | holder | Object which owns this polling. |
StopPolling(ITwinElement, object)
Stop polling data from a ITwinElement. Polling mechanism checks whether there is another polling instance active for the given object. If there is any remaining instance active the polling will continue until the last instance is stopped.
Declaration
public static void StopPolling(this ITwinElement obj, object holder)
Parameters
| Type | Name | Description |
|---|---|---|
| ITwinElement | obj | Object for which the polling should be stopped. |
| object | holder | Object which owns this polling. |
SubscribeEditValueChange(ITwinObject, ValueChangeDelegate)
Subscribes a delegate to be invoked when any Edit value on given object changes its value.ITwinObject
Declaration
public static IEnumerable<ITwinPrimitive> SubscribeEditValueChange(this ITwinObject obj, OnlinerBase.ValueChangeDelegate valueChangeDelegate)
Parameters
| Type | Name | Description |
|---|---|---|
| ITwinObject | obj | Observed object. |
| OnlinerBase.ValueChangeDelegate | valueChangeDelegate | Delegate to be invoked on Edit value change. |
Returns
| Type | Description |
|---|---|
| IEnumerable<ITwinPrimitive> |
Examples
class EditValueChangeObserver
{
public EditValueChangeObserver()
{
Connector.MAIN.SubscribeEditValueChange(DetectEditValueChange);
}
private void DetectEditValueChange(IValueTag valueTag, dynamic original, dynamic newValue)
{
Console.WriteLine($"Value '{valueTag.Symbol}' has changed form {original} to {newValue}.")
}
}
|
Edit this page
View Source
SubscribeShadowValueChange(ITwinObject, ValueChangeDelegate)
Subscribes a delegate to be invoked when any Shadow value on given object changes its value.ITwinObject
Declaration
public static IEnumerable<ITwinPrimitive> SubscribeShadowValueChange(this ITwinObject obj, OnlinerBase.ValueChangeDelegate valueChangeDelegate)
Parameters
| Type | Name | Description |
|---|---|---|
| ITwinObject | obj | Observed object. |
| OnlinerBase.ValueChangeDelegate | valueChangeDelegate | Delegate to be invoked on shadow value change. |
Returns
| Type | Description |
|---|---|
| IEnumerable<ITwinPrimitive> | Primitives that have been subscribed for shadow value change. |
Examples
class ShadowValueChangeObserver
{
public ShadowValueChangeObserver()
{
Connector.MAIN.SubscribeShadowValueChange(DetectShadowValueChange);
}
private void DetectShadowValueChange(IValueTag valueTag, dynamic original, dynamic newValue)
{
Console.WriteLine($"Value '{valueTag.Symbol}' has changed form {original} to {newValue}.")
}
}
|
Edit this page
View Source
UnSubscribeEditValueChange(ITwinObject)
Un-subscribes Edit value change delegate from the value tags of given object.
Declaration
public static void UnSubscribeEditValueChange(this ITwinObject obj)
Parameters
| Type | Name | Description |
|---|---|---|
| ITwinObject | obj | Object from which the Edit value change delegate has to be removed. |
UnSubscribeShadowValueChange(ITwinObject)
Un-subscribes Shadow value change delegate from the value tags of given object.
Declaration
public static void UnSubscribeShadowValueChange(this ITwinObject obj)
Parameters
| Type | Name | Description |
|---|---|---|
| ITwinObject | obj | Object from which the shadow value change delegate has to be removed. |
WriteAsync(ITwinObject)
Writes all value tags of instance ITwinOnlineObject
Declaration
public static Task<IEnumerable<ITwinPrimitive>> WriteAsync(this ITwinObject structure)
Parameters
| Type | Name | Description |
|---|---|---|
| ITwinObject | structure | Structure to be written |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<ITwinPrimitive>> | Primitives that have been written. |
Examples
// Writes all modified values of the MAIN PRG.
Connector.Online.MAIN.GrowingLayoutStructure.Write()
|
Edit this page
View Source
WriteAsync<T>(ITwinObject)
Writes all value tags of instance ITwinOnlineObject, but ignores members that are annotated with attribute as generic parameter.
Important
This method is used for specific framework purposed and there is no specific reason to use it in your application. Use non generic version of this method WriteAsync(ITwinObject) instead.
Declaration
public static Task<IEnumerable<ITwinPrimitive>> WriteAsync<T>(this ITwinObject structure) where T : Attribute
Parameters
| Type | Name | Description |
|---|---|---|
| ITwinObject | structure | Structure to be written. |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<ITwinPrimitive>> | List of written items. |
Type Parameters
| Name | Description |
|---|---|
| T | Attribute parameter to be ignored |