- Create a "Standard project" and select CODESYS Control Win V3 as the device.
- Define the target system by means of the Netzwork 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.Create a new POU named ClientInfo and call it from Visu_Task.
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:
Declaration
VAR pClient : POINTER TO VisuElems.VisuElemBase.VisuStructClientData; helper : VisuElems.VisuFbClientTagDataHelper; s1 : STRING; END_VAR
Implementierung
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
Start the project and set a breakpoint in line 6 of the ClientInfo POU.
- Open a browser and type in the following address: http://localhost:8080/webvisu.htm
After the client has connected, execution is halted at the breakpoint and the IP address can be read.
The information is available only for web clients. A TargetVisu connected to the controller does not contain this information.