Class TwinObjectExtensions
Extensions methods for ITwin
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 |
---|---|---|
ITwin |
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 |
---|---|---|
ITwin |
twinElement |
Returns
Type | Description |
---|---|
bool |
Type Parameters
Name | Description |
---|---|
T |
MakeReadOnce(ITwinObject)
Makes ITwin
Declaration
public static void MakeReadOnce(this ITwinObject structure)
Parameters
Type | Name | Description |
---|---|---|
ITwin |
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 ITwin
Declaration
public static void MakeReadOnly(this ITwinObject structure)
Parameters
Type | Name | Description |
---|---|---|
ITwin |
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 ITwin
Declaration
public static Task OnlineToShadowAsync(this ITwinObject obj)
Parameters
Type | Name | Description |
---|---|---|
ITwin |
obj | Twin object to copy. |
Returns
Type | Description |
---|---|
Task |
ReadAsync(ITwinObject)
Reads all value tags of instance ITwin
Declaration
public static Task<IEnumerable<ITwinPrimitive>> ReadAsync(this ITwinObject structure)
Parameters
Type | Name | Description |
---|---|---|
ITwin |
structure |
Returns
Type | Description |
---|---|
Task<IEnumerable<ITwin |
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 ITwin
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 Read
Declaration
public static Task<IEnumerable<ITwinPrimitive>> ReadAsync<T>(this ITwinObject structure) where T : Attribute
Parameters
Type | Name | Description |
---|---|---|
ITwin |
structure | Structure to be read |
Returns
Type | Description |
---|---|
Task<IEnumerable<ITwin |
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 |
---|---|---|
ITwin |
onlineObject | Object from which the value tags are to be retrieved. |
List<ITwin |
valueTags | Pre-existing value tags. |
Returns
Type | Description |
---|---|
IEnumerable<ITwin |
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 ITwin
Declaration
public static Task ShadowToOnlineAsync(this ITwinObject obj)
Parameters
Type | Name | Description |
---|---|---|
ITwin |
obj | Twin object to copy. |
Returns
Type | Description |
---|---|
Task |
StartPolling(ITwinElement, int, object)
Starts polling data from a ITwin
Declaration
public static void StartPolling(this ITwinElement obj, int interval, object holder)
Parameters
Type | Name | Description |
---|---|---|
ITwin |
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 ITwin
Declaration
public static void StopPolling(this ITwinElement obj, object holder)
Parameters
Type | Name | Description |
---|---|---|
ITwin |
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.ITwin
Declaration
public static IEnumerable<ITwinPrimitive> SubscribeEditValueChange(this ITwinObject obj, OnlinerBase.ValueChangeDelegate valueChangeDelegate)
Parameters
Type | Name | Description |
---|---|---|
ITwin |
obj | Observed object. |
Onliner |
valueChangeDelegate | Delegate to be invoked on Edit value change. |
Returns
Type | Description |
---|---|
IEnumerable<ITwin |
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.ITwin
Declaration
public static IEnumerable<ITwinPrimitive> SubscribeShadowValueChange(this ITwinObject obj, OnlinerBase.ValueChangeDelegate valueChangeDelegate)
Parameters
Type | Name | Description |
---|---|---|
ITwin |
obj | Observed object. |
Onliner |
valueChangeDelegate | Delegate to be invoked on shadow value change. |
Returns
Type | Description |
---|---|
IEnumerable<ITwin |
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 |
---|---|---|
ITwin |
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 |
---|---|---|
ITwin |
obj | Object from which the shadow value change delegate has to be removed. |
WriteAsync(ITwinObject)
Writes all value tags of instance ITwin
Declaration
public static Task<IEnumerable<ITwinPrimitive>> WriteAsync(this ITwinObject structure)
Parameters
Type | Name | Description |
---|---|---|
ITwin |
structure | Structure to be written |
Returns
Type | Description |
---|---|
Task<IEnumerable<ITwin |
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 ITwin
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 Write
Declaration
public static Task<IEnumerable<ITwinPrimitive>> WriteAsync<T>(this ITwinObject structure) where T : Attribute
Parameters
Type | Name | Description |
---|---|---|
ITwin |
structure | Structure to be written. |
Returns
Type | Description |
---|---|
Task<IEnumerable<ITwin |
List of written items. |
Type Parameters
Name | Description |
---|---|
T | Attribute parameter to be ignored |