Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
  • Create a "Standard project" and select CODESYS Control Win V3 as the device.
  • Define the target system by means of the Netzwork Network scan.



  • Insert a visualization in the device tree.
    Then the Visualization Manager is inserted with the visu types TargetVisuand WebVisu.

    In addition, a Visu_Task is also created automatically.





As of SP17:

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

    Image Added


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

    Image Added

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



  • Adapt the FB_Iteration function block as follows:



    Section
    Column
    width7

    Declaration

    Column
    width93
    Code Block
    themeConfluence
    FUNCTION_BLOCK FB_Iteration IMPLEMENTS VU.IVisualizationClientIteration
    VAR CONSTANT
    	c_MaxClients	: __XINT := 5;
    END_VAR
    VAR
    	_iIndex			: __XINT;
    	asIpAddresses	: ARRAY [0..c_MaxClients-1] OF STRING;
    END_VAR






  • Adapt the EndIteration method as follows:



    Section
    Column
    width7

    Declaration

    Column
    width93
    Code Block
    themeConfluence
    METHOD EndIteration
    VAR
    	_iCounter : __XINT;
    END_VAR




    Section
    Column
    width7

    Implementation

    Column
    width93
    Code Block
    themeConfluence
    FOR _iCounter := (c_MaxClients - 1) TO _iIndex BY -1 DO
    	asIpAddresses[_iCounter] := '';
    END_FOR






  • Adapt the HandleClient method as follows:



    Section
    Column
    width7

    Implementation

    Column
    width93
    Code Block
    themeConfluence
    IF _iIndex <= (c_MaxClients - 1) THEN
    	asIpAddresses[_iIndex] := itfClient.GetIPv4Address();
    	_iIndex := _iIndex + 1;
    END_IF






  • Adapt the StartIteration method as follows:



    Section
    Column
    width7

    Implementation

    Column
    width93
    Code Block
    themeConfluence
    _iIndex := 0;





  • Adapt the POU PLC_PRG as follows:



    Section
    Column
    width7

    Declaration

    Column
    width93
    Code Block
    themeConfluence
    VAR
        fbIteration         : FB_Iteration;
        fbIterateClients    : VU.FbIterateClients;	
    	xIterate			: BOOL;
    END_VAR




    Section
    Column
    width7

    Implementation

    Column
    width93
    Code Block
    themeConfluence
    fbIterateClients(xExecute := xIterate, itfClientFilter := VU.Globals.OnlyWebVisu, itfIterationCallback := fbIteration);
    
    IF fbIterateClients.xDone  THEN
    	xIterate := FALSE;
    END_IF






  • Start the project and insert the variable PLC_PRG.fbIteration in the watch list.
  • Open a browser and type in the following address: http://localhost:8080/webvisu.htm
  • Set the PLC_PRG.xIterate variable to TRUE.

    Image Added



Up to SP16:

  • Create a new POU named ClientInfo and call it from Visu_Task.

    Info

    The call of the ClientInfo POU must originate from the Visu_Task because only then is the required client handle passed.




  • Adapt the ClientInfo POU as follows:



    Section
    Column
    width7

    Declaration

    Column
    width93
    Code Block
    themeConfluence
    VAR
        pClient       :    POINTER TO VisuElems.VisuElemBase.VisuStructClientData;
        helper        :    VisuElems.VisuFbClientTagDataHelper;
        s1            :    STRING;
    END_VAR




    Section
    Column
    width7

    Implementierung

    Column
    width93
    Code Block
    themeConfluence
    VisuElems.g_ClientManager.BeginIteration();
    
    WHILE (pClient := VisuElems.VisuElemBase.g_ClientManager.GetNextClient()) <> 0 DO
        IF pClient^.GlobalData.ClientType = VisuElems.VisuElemBase.Visu_ClientType.WebVisualization THEN
            helper(pClientData := pClient);
            s1 := helper.stIPv4;
        END_IF
    END_WHILE




...