Base class for fast, thread-safe interface communication providing automatic signal management, connection handling, and high-performance data exchange between Unity and external systems. More...
Public Member Functions | |
| override void | OpenInterface () |
| Opens the interface and starts communication thread. | |
| override void | CloseInterface () |
| Closes the interface and stops communication thread. | |
| virtual void | PreFixedUpdate () |
| Processes PLC outputs before FixedUpdate - applies data FROM PLC TO Unity objects IMPLEMENTS IPreFixedUpdate::PreFixedUpdate. | |
| virtual void | PostFixedUpdate () |
| Processes PLC inputs after FixedUpdate - reads data FROM Unity objects TO send to PLC IMPLEMENTS IPostFixedUpdate::PostFixedUpdate. | |
| void | SetManualPhysicsMode (bool enabled) |
| Enables or disables manual physics control mode. | |
| void | StepPhysics (float timestep=0f) |
| Steps physics simulation forward by a specified time duration. | |
| override void | PostAllScenesLoaded () |
| Override PostAllScenesLoaded to prevent base class from opening interface too early. | |
| void | OnInterfaceEnable () |
| Called by realvirtualController after all scenes are loaded to enable the interface. | |
Public Member Functions inherited from realvirtual.InterfaceBaseClass | |
| void | UpdateInterfaceSignals (ref int inputs, ref int outputs) |
| Creates a new List of InterfaceSignals based on the Components under this Interface GameObject. | |
| Signal | CreateSignalObject (string name, SIGNALTYPE type, SIGNALDIRECTION direction) |
| Create a signal object as sub gameobject. | |
| Signal | AddSignal (InterfaceSignal interfacesignal) |
| void | RemoveSignal (InterfaceSignal interfacesignal) |
| virtual GameObject | GetSignal (string name) |
| Gets a signal with a name. | |
| void | SetAllSignalStatus (bool connected) |
| void | DestroyAllSignals () |
| void | DeleteSignals () |
Public Member Functions inherited from realvirtual.realvirtualBehavior | |
| virtual void | OnOwnershipChanged (bool isOwner) |
| Called when network ownership changes. | |
| void | SetNetworkOwner (bool isOwner) |
| Sets IsNetworkOwner and triggers OnOwnershipChanged callback. | |
| void | PreStartSim () |
| Is called by the realvirtualController before the component is started. | |
| void | StartSim () |
| Is called by the realvirtualController to start or stop the component. | |
| void | StopSim () |
| Vector3 | DirectionToVector (DIRECTION direction) |
| Transfers the direction enumeration to a vector. | |
| DIRECTION | VectorToDirection (bool torotatoin, Vector3 vector) |
| Transfers a vector to the direction enumeration. | |
| float | GetLocalScale (Transform thetransform, DIRECTION direction) |
| List< BehaviorInterfaceConnection > | UpdateConnectionInfo () |
| List< Signal > | GetConnectedSignals () |
| void | SetVisibility (bool visibility) |
| Sets the visibility of this object including all subobjects. | |
| List< BehaviorInterfaceConnection > | GetConnections () |
| List< Signal > | GetSignals () |
| GameObject | GetChildByName (string name) |
| Gets a child by name. | |
| List< GameObject > | GetChildsByName (string name) |
| Gets all child by name. | |
| GameObject | GetChildByNameAlsoHidden (string name) |
| List< GameObject > | GetAllMeshesWithGroup (string group) |
| List< GameObject > | GetAllWithGroup (string group) |
| List< GameObject > | GetAllWithGroups (List< string > groups) |
| List< GameObject > | GetAllMeshesWithGroups (List< string > groups) |
| List< string > | GetMyGroups () |
| List< GameObject > | GetMeshesWithSameGroups () |
| List< GameObject > | GetAllWithSameGroups () |
| MeshRenderer | GetMeshRenderer () |
| Gets the mesh renderers in the childrens. | |
| void | SetCollider (bool enabled, bool includeTriggers=true) |
| sets the collider in all child objects | |
| void | ErrorMessage (string message) |
| Displays an error message. | |
| void | ChangeConnectionMode (bool isconnected) |
| void | Log (string message) |
| Logs a message. | |
| void | Log (string message, object obj) |
| Logs a message with a relation to an object. | |
| void | Warning (string message, object obj) |
| Logs a warning with a relation to an object. | |
| void | Error (string message, object obj) |
| Logs an error with a relation to an object. | |
| void | Error (string message) |
| Logs an error. | |
| GameObject | DebugPosition (string debugname, Vector3 position, Quaternion quaternation, float scale) |
| Displays a gizmo for debugging positions. | |
| void | SetFreezePosition (bool enabled) |
| Freezes all child components to the current poosition. | |
| void | SetRbConstraints (RigidbodyConstraints constraints) |
| virtual void | AwakeAlsoDeactivated () |
Static Public Member Functions | |
| static bool | IsManualPhysicsMode () |
| Gets whether manual physics mode is currently enabled globally. | |
Static Public Member Functions inherited from realvirtual.realvirtualBehavior | |
| static bool | DirectionIsLinear (DIRECTION direction) |
| Gets back if the direction is linear or a rotation. | |
Public Attributes | |
| string | State |
| Current connection status with visual indicator. | |
| InterfaceState | state |
| Internal connection state enum. | |
| new string | ErrorMessage |
| Last error message if connection failed. | |
| int | ReconnectAttemptCount |
| Number of reconnection attempts made. | |
| bool | IsReconnecting |
| Whether interface is currently attempting to reconnect. | |
| int | InputSignals |
| Total number of input signals found. | |
| int | OutputSignals |
| Total number of output signals found. | |
| int | CommCycleMs |
| Actual communication cycle time in milliseconds. | |
| int | CycleCount |
| Total number of communication cycles completed. | |
| int | UpdateCycleMs |
| Communication thread update interval in milliseconds. | |
| bool | OnlyTransmitChangedInputs |
| Only send input signals that have changed since last transmission (performance optimization) | |
| bool | AutoReconnect |
| Automatically attempt to reconnect on connection loss. | |
| float | ReconnectIntervalSeconds |
| Time to wait between reconnection attempts. | |
| int | MaxReconnectAttempts |
| Maximum reconnection attempts (-1 = unlimited) | |
| bool | DebugMode |
Public Attributes inherited from realvirtual.InterfaceBaseClass | |
| bool | IsConnected |
| List< InterfaceSignal > | InterfaceSignals |
| Hashtable | SignalNamesOutputs |
| Hashtable | SignalNamesInputs |
Public Attributes inherited from realvirtual.realvirtualBehavior | |
| string | Name |
| The name of the component if it should be different from the GameObject name. | |
| ActiveOnly | Active |
| GameObject | FromTemplate |
| realvirtualController | realvirtualController |
| bool | HideNonG44Components |
| bool | SceneIsAdditive |
| bool | ForceStop |
| bool | IsNetworkOwner |
| True when this component owns its simulation (local authority). Set to false by MultiplayerWEB on remote clients. | |
Protected Member Functions | |
| virtual async Task | EstablishConnection (CancellationToken cancellationToken) |
| Establishes connection to the external system. | |
| virtual async Task | CommunicationLoop (CancellationToken cancellationToken) |
| Main communication loop executed each cycle after connection is established. | |
| virtual void | CloseConnection () |
| Closes the connection to the external system. | |
| virtual void | OnCommunicationError (Exception exception) |
| Handles communication errors and manages reconnection logic. | |
| virtual void | OnCommunicationStarted () |
| Called when communication thread starts successfully. | |
| virtual void | OnCommunicationStopped () |
| Called when communication thread stops. | |
| void | Start () |
| Unity Start - block base class behavior. | |
| new void | OnEnable () |
| Unity OnEnable - opens interface when component is enabled. | |
| new void | OnDisable () |
| virtual void | OnApplicationPause (bool pauseStatus) |
| Handles application pause events. | |
| void | FixedUpdate () |
| Unity FixedUpdate for main thread operations (signal sync moved to PrePost FixedUpdate) | |
| Dictionary< string, object > | GetInputsForPLC () |
| Gets all input signal values to send to PLC from background threads. | |
| Dictionary< string, object > | GetChangedInputsForPLC () |
| Gets only changed input signal values to send to PLC from background threads. | |
| void | ResetInputChangeDetection () |
| Resets change detection forcing all inputs to be considered changed on next call. | |
| void | SetOutputsFromPLC (Dictionary< string, object > outputs) |
| Sets output signal values from PLC data in background threads. | |
| void | SetOutputFromPLC (string signalName, object value) |
| Sets single output signal value from PLC data in background threads. | |
| void | RebuildCachedSignalArrays () |
| Rebuilds the cached signal arrays used by SyncOutputsToUnity/SyncInputsFromUnity. | |
| Dictionary< string, object > | ReadInputsThreadSafe () |
| [DEPRECATED] Use GetInputsForPLC() instead for clearer data flow direction | |
| Dictionary< string, object > | ReadChangedInputsThreadSafe () |
| [DEPRECATED] Use GetChangedInputsForPLC() instead for clearer data flow direction | |
| void | WriteOutputsThreadSafe (Dictionary< string, object > outputs) |
| [DEPRECATED] Use SetOutputsFromPLC() instead for clearer data flow direction | |
| void | WriteOutputThreadSafe (string signalName, object value) |
| [DEPRECATED] Use SetOutputFromPLC() instead for clearer data flow direction | |
| virtual void | CopyPropertiesToThreadSafe () |
| Copies MonoBehaviour properties to thread-safe variables before background thread starts. | |
| virtual void | PrepareForBackgroundThread () |
| Called on main thread to prepare any Unity GameObject data before background thread starts Override this to cache signal names, GameObject references, or other Unity-specific data that the background thread will need to access. | |
| virtual void | CleanupAfterBackgroundThread () |
| Called on main thread after background thread stops to clean up Unity-specific resources Override this to clean up cached data, reset Unity components, or perform other main-thread cleanup. | |
| virtual void | UpdateSignalCounts () |
| Updates input and output signal counts. | |
Protected Member Functions inherited from realvirtual.InterfaceBaseClass | |
| void | OnConnected () |
| void | OnDisconnected () |
| void | OnEnable () |
| void | OnDisable () |
Protected Member Functions inherited from realvirtual.realvirtualBehavior | |
| bool | hidename () |
| bool | hideactiveonly () |
| virtual void | OnStopSim () |
| virtual void | OnPreStartSim () |
| virtual void | OnStartSim () |
| MU | GetTopOfMu (GameObject obj) |
| Gets the top of an MU component (the first MU script going up in the hierarchy) | |
| void | InitGame4Automation () |
| Initialiates the components and gets the reference to the realvirtualController in the scene. | |
| virtual void | AfterAwake () |
| void | Awake () |
Protected Attributes | |
| string | threadSafeErrorMessage |
| int | privateCycleCount |
| int | privateCommCycleMs |
| bool | threadSafeDebugMode |
| int | threadSafeUpdateCycleMs |
Properties | |
| new bool | IsConnected [get] |
| override bool | ShowIsConnectedField [get] |
| Used by [ShowIf] to hide IsConnected field for FastInterface classes - always returns false. | |
| bool | IsInterfaceReady [get] |
| Returns true if the interface has been initialized via OnInterfaceEnable. | |
Properties inherited from realvirtual.InterfaceBaseClass | |
| virtual string | InterfaceDisplayName [get] |
| Display name for interface in UI lists (removes "Interface" suffix by default, can be overridden for custom names) | |
| virtual bool | ShowIsConnectedField [get] |
Properties inherited from realvirtual.IOnInterfaceEnable | |
Additional Inherited Members | |
Public Types inherited from realvirtual.realvirtualBehavior | |
| enum | ActiveOnly { Always , Connected , Disconnected , Never , DontChange } |
Detailed Description
Base class for fast, thread-safe interface communication providing automatic signal management, connection handling, and high-performance data exchange between Unity and external systems.
Member Function Documentation
◆ CleanupAfterBackgroundThread()
|
protectedvirtual |
Called on main thread after background thread stops to clean up Unity-specific resources Override this to clean up cached data, reset Unity components, or perform other main-thread cleanup.
Reimplemented in realvirtual.FestoInterface, and realvirtual.ManualPhysicsBlueprint.
◆ CloseConnection()
|
protectedvirtual |
Closes the connection to the external system.
Reimplemented in realvirtual.EthernetIPInterface, realvirtual.FestoInterface, realvirtual.KukaInterface, realvirtual.MitsubishiMcpXInterface, realvirtual.BlueprintFastInterface, realvirtual.BlueprintFastInterfaceSimple, realvirtual.ManualPhysicsBlueprint, realvirtual.PerformanceTestInterface, and realvirtual.TestFastInterface.
◆ CloseInterface()
|
virtual |
Closes the interface and stops communication thread.
Reimplemented from realvirtual.InterfaceBaseClass.
◆ CommunicationLoop()
|
protectedvirtual |
Main communication loop executed each cycle after connection is established.
Reimplemented in realvirtual.EthernetIPInterface, realvirtual.FestoInterface, realvirtual.KukaInterface, realvirtual.MitsubishiMcpXInterface, realvirtual.BlueprintFastInterface, realvirtual.BlueprintFastInterfaceSimple, realvirtual.FastThreadedInterface, realvirtual.PerformanceTestInterface, and realvirtual.TestFastInterface.
◆ CopyPropertiesToThreadSafe()
|
protectedvirtual |
Copies MonoBehaviour properties to thread-safe variables before background thread starts.
Reimplemented in realvirtual.EthernetIPInterface, realvirtual.FestoInterface, realvirtual.KukaInterface, and realvirtual.MitsubishiMcpXInterface.
◆ EstablishConnection()
|
protectedvirtual |
Establishes connection to the external system.
Reimplemented in realvirtual.EthernetIPInterface, realvirtual.FestoInterface, realvirtual.KukaInterface, realvirtual.MitsubishiMcpXInterface, realvirtual.BlueprintFastInterface, realvirtual.BlueprintFastInterfaceSimple, and realvirtual.FastThreadedInterface.
◆ FixedUpdate()
|
protected |
Unity FixedUpdate for main thread operations (signal sync moved to PrePost FixedUpdate)
◆ GetChangedInputsForPLC()
|
protected |
Gets only changed input signal values to send to PLC from background threads.
◆ GetInputsForPLC()
|
protected |
Gets all input signal values to send to PLC from background threads.
◆ IsManualPhysicsMode()
|
static |
Gets whether manual physics mode is currently enabled globally.
Returns true if any FastInterfaceBase instance has enabled manual physics mode.
◆ OnApplicationPause()
|
protectedvirtual |
Handles application pause events.
◆ OnCommunicationError()
|
protectedvirtual |
Handles communication errors and manages reconnection logic.
◆ OnCommunicationStarted()
|
protectedvirtual |
Called when communication thread starts successfully.
Reimplemented in realvirtual.FestoInterface, realvirtual.BlueprintFastInterface, realvirtual.FastThreadedInterface, and realvirtual.PerformanceTestInterface.
◆ OnCommunicationStopped()
|
protectedvirtual |
Called when communication thread stops.
Reimplemented in realvirtual.FastThreadedInterface.
◆ OnEnable()
|
protected |
Unity OnEnable - opens interface when component is enabled.
◆ OnInterfaceEnable()
| void realvirtual.FastInterfaceBase.OnInterfaceEnable | ( | ) |
Called by realvirtualController after all scenes are loaded to enable the interface.
Also called by OnEnable for late-added (dynamically created) interfaces.
Implements realvirtual.IOnInterfaceEnable.
◆ OpenInterface()
|
virtual |
Opens the interface and starts communication thread.
Reimplemented from realvirtual.InterfaceBaseClass.
Reimplemented in realvirtual.FestoInterface.
◆ PostAllScenesLoaded()
|
virtual |
Override PostAllScenesLoaded to prevent base class from opening interface too early.
Reimplemented from realvirtual.InterfaceBaseClass.
◆ PostFixedUpdate()
|
virtual |
Processes PLC inputs after FixedUpdate - reads data FROM Unity objects TO send to PLC IMPLEMENTS IPostFixedUpdate::PostFixedUpdate.
Implements realvirtual.IPostFixedUpdate.
Reimplemented in realvirtual.ManualPhysicsBlueprint.
◆ PreFixedUpdate()
|
virtual |
Processes PLC outputs before FixedUpdate - applies data FROM PLC TO Unity objects IMPLEMENTS IPreFixedUpdate::PreFixedUpdate.
Implements realvirtual.IPreFixedUpdate.
Reimplemented in realvirtual.ManualPhysicsBlueprint.
◆ PrepareForBackgroundThread()
|
protectedvirtual |
Called on main thread to prepare any Unity GameObject data before background thread starts Override this to cache signal names, GameObject references, or other Unity-specific data that the background thread will need to access.
Reimplemented in realvirtual.FestoInterface, realvirtual.MitsubishiMcpXInterface, and realvirtual.ManualPhysicsBlueprint.
◆ ReadChangedInputsThreadSafe()
|
protected |
[DEPRECATED] Use GetChangedInputsForPLC() instead for clearer data flow direction
◆ ReadInputsThreadSafe()
|
protected |
[DEPRECATED] Use GetInputsForPLC() instead for clearer data flow direction
◆ RebuildCachedSignalArrays()
|
protected |
Rebuilds the cached signal arrays used by SyncOutputsToUnity/SyncInputsFromUnity.
Call this after dynamically creating or removing signals (e.g., after import). Must be called on the main thread.
◆ ResetInputChangeDetection()
|
protected |
Resets change detection forcing all inputs to be considered changed on next call.
◆ SetManualPhysicsMode()
| void realvirtual.FastInterfaceBase.SetManualPhysicsMode | ( | bool | enabled | ) |
Enables or disables manual physics control mode.
When enabled, disables Physics.autoSimulation and requires manual stepping via StepPhysics(). Interface signal synchronization continues automatically in PreFixedUpdate and PostFixedUpdate. Uses reference counting to coordinate multiple interfaces - physics is restored only when all interfaces disable manual mode.
◆ SetOutputFromPLC()
|
protected |
Sets single output signal value from PLC data in background threads.
◆ SetOutputsFromPLC()
|
protected |
Sets output signal values from PLC data in background threads.
◆ Start()
|
protected |
Unity Start - block base class behavior.
◆ StepPhysics()
| void realvirtual.FastInterfaceBase.StepPhysics | ( | float | timestep = 0f | ) |
Steps physics simulation forward by a specified time duration.
Only affects physics simulation - interface signal synchronization continues automatically. Must be called when manual physics mode is enabled via SetManualPhysicsMode(true).
◆ UpdateSignalCounts()
|
protectedvirtual |
Updates input and output signal counts.
◆ WriteOutputsThreadSafe()
|
protected |
[DEPRECATED] Use SetOutputsFromPLC() instead for clearer data flow direction
◆ WriteOutputThreadSafe()
|
protected |
[DEPRECATED] Use SetOutputFromPLC() instead for clearer data flow direction
Member Data Documentation
◆ AutoReconnect
| bool realvirtual.FastInterfaceBase.AutoReconnect |
Automatically attempt to reconnect on connection loss.
◆ CommCycleMs
| int realvirtual.FastInterfaceBase.CommCycleMs |
Actual communication cycle time in milliseconds.
◆ CycleCount
| int realvirtual.FastInterfaceBase.CycleCount |
Total number of communication cycles completed.
◆ ErrorMessage
| new string realvirtual.FastInterfaceBase.ErrorMessage |
Last error message if connection failed.
◆ InputSignals
| int realvirtual.FastInterfaceBase.InputSignals |
Total number of input signals found.
◆ IsReconnecting
| bool realvirtual.FastInterfaceBase.IsReconnecting |
Whether interface is currently attempting to reconnect.
◆ MaxReconnectAttempts
| int realvirtual.FastInterfaceBase.MaxReconnectAttempts |
Maximum reconnection attempts (-1 = unlimited)
◆ OnlyTransmitChangedInputs
| bool realvirtual.FastInterfaceBase.OnlyTransmitChangedInputs |
Only send input signals that have changed since last transmission (performance optimization)
◆ OutputSignals
| int realvirtual.FastInterfaceBase.OutputSignals |
Total number of output signals found.
◆ ReconnectAttemptCount
| int realvirtual.FastInterfaceBase.ReconnectAttemptCount |
Number of reconnection attempts made.
◆ ReconnectIntervalSeconds
| float realvirtual.FastInterfaceBase.ReconnectIntervalSeconds |
Time to wait between reconnection attempts.
◆ State
| string realvirtual.FastInterfaceBase.State |
Current connection status with visual indicator.
◆ state
| InterfaceState realvirtual.FastInterfaceBase.state |
Internal connection state enum.
◆ UpdateCycleMs
| int realvirtual.FastInterfaceBase.UpdateCycleMs |
Communication thread update interval in milliseconds.
Property Documentation
◆ IsInterfaceReady
|
get |
Returns true if the interface has been initialized via OnInterfaceEnable.
Implements realvirtual.IOnInterfaceEnable.
◆ ShowIsConnectedField
|
getprotected |
Used by [ShowIf] to hide IsConnected field for FastInterface classes - always returns false.
Public Member Functions inherited from