• Create a "Standard project" and select CODESYS Control Win V3 as the device.
  • Define the target system by means of the Network scan.



  • Open the Library Manager and add the following library:
    VisuUtils



  • Insert a visualization in the device tree.
    Then the Visualization Manager is inserted with the visu types TargetVisu and WebVisu.
    Delete both of these are add a RemoteTargetvisualization. Then assign the Visualization to it as the start page.
    In addition, a VISU_TASK is also created automatically.



  • Create a new FB named FB_Iteration and implement the VU.IVisualizationClientIteration interface.



    The following methods are created automatically with the FB:
    EndIteration
    HandleClient
    StartIteration




  • Adapt the FB_Iteration function block as follows:


    Declaration

    FUNCTION_BLOCK FB_Iteration IMPLEMENTS VU.IVisualizationClientIteration
    VAR_INPUT
    END_VAR
    VAR_OUTPUT
    END_VAR
    VAR
    	sRtvName1 : STRING;
    END_VAR

  • Adapt the HandleClient method as follows:


    Declaration

    (* This method will be called for each client that is currently within the list
     of active visualization clients.
    
     .. note:: Please remark that this method will be called from VISU_TASK*)
    METHOD HandleClient
    VAR_INPUT
        (* The object representing the according client. Will not be 0.*)
        itfClient    : VU.IVisualizationClient;
    END_VAR

    Implementation

    IF itfClient.ClientType = VU.VisuClientType.RemoteTargetVisualization THEN
        sRtvName1 := itfClient.GetClientName();
    END_IF


  • Adapt the POU PLC_PRG as follows:


    Declaration

    VAR
        fbIteration			: FB_Iteration;
        fbIterateClients	: VU.FbIterateClients;
    END_VAR

    Implementation

    fbIterateClients(xExecute:=TRUE, itfClientFilter:=VU.Globals.AllClients, itfIterationCallback:=fbIteration);
    IF fbIterateClients.xDone THEN
        fbIterateClients(xExecute:=FALSE, itfClientFilter:=VU.Globals.AllClients, itfIterationCallback:=fbIteration);
    END_IF


  • Load the project to the controller and start it.



  • Open the targetvisuremote.cfg file and add the following entries to the CmpVisuHandlerRemote section:

    [CmpVisuHandlerRemote]
    VisuClient.Name=CodesysRemoteClient1

  • After the remote target visu is started, the specified name is shown in the project: