- Create a "Standard project" and select CODESYS Control Win V3 as the device.
- Define the target system by means of the Network scan.
Insert a visualization in the device tree.
In addition, a Visu_Task is also created automatically.
Then the Visualization Manager is inserted with the visu types TargetVisuand WebVisu.
As of SP17:
- Open the Library Manager and add the following libraries:
VisuUtils - Create a new FB named FB_Iteration and implement the interface VU.IVisualizationClientIteration.
The following methods are created automatically with the FB:
EndIteration
HandleClient
StartIteration - Adapt the FB_Iteration function block as follows:
Section Column width 7 Declaration
Column width 93 Code Block theme Confluence 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 width 7 Declaration
Column width 93 Code Block theme Confluence METHOD EndIteration VAR _iCounter : __XINT; END_VAR
Section Column width 7 Implementation
Column width 93 Code Block theme Confluence FOR _iCounter := (c_MaxClients - 1) TO _iIndex BY -1 DO asIpAddresses[_iCounter] := ''; END_FOR
- Adapt the HandleClient method as follows:
Section Column width 7 Implementation
Column width 93 Code Block theme Confluence IF _iIndex <= (c_MaxClients - 1) THEN asIpAddresses[_iIndex] := itfClient.GetIPv4Address(); _iIndex := _iIndex + 1; END_IF
- Adapt the StartIteration method as follows:
Section Column width 7 Implementation
Column width 93 Code Block theme Confluence _iIndex := 0;
- Adapt the POU PLC_PRG as follows:
Section Column width 7 Declaration
Column width 93 Code Block theme Confluence VAR fbIteration : FB_Iteration; fbIterateClients : VU.FbIterateClients; xIterate : BOOL; END_VAR
Section Column width 7 Implementation
Column width 93 Code Block theme Confluence 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.
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 width 7 Declaration
Column width 93 Code Block theme Confluence VAR pClient : POINTER TO VisuElems.VisuElemBase.VisuStructClientData; helper : VisuElems.VisuFbClientTagDataHelper; s1 : STRING; END_VAR
Section Column width 7 Implementierung
Column width 93 Code Block theme Confluence 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
...