Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Different visu for different ip

kruglovay
2016-08-31
2022-07-29
  • kruglovay - 2016-08-31

    Hello.
    Is it possible to show different start visu for different clients according to their IP?

     
  • Anonymous - 2016-11-11

    Originally created by: scott_cunningham

    I had a system that had two different screens - similar problem: same screens but some parts were read only on the remote monitors. My best solution was to define a variable that is only used by the visu. You set it on the visu screen at first run (setup screen). Make the variable persistent retain and it will live even after power cycle. Maybe that helps you.

     
  • Anonymous - 2016-11-11

    Originally created by: barkamharikrishna

    write small logic in the plc to which Screen to be active depends on Ip .

     
  • TimvH

    TimvH - 2017-05-16

    You can iterate over all connected clients.
    From each client you can get data (including asking it's IP address).
    Then you can set the required visualization of this client.

    Please note that currently you cannot read the current page. According to 3S-Smart Software Solutions with SP11 a new user friendlier library will be released which can do the same as below including reading the actual visualization the client is on.

    Below the example code which I used to changed to a certain visualization when a user logged out at a specific client (local client). In this case I remembered who was already logged on. In your case you could use another array to detect if this is a new client. If yes, then set the start visualization.

    PROGRAM PLC_PRG
    VAR
                    pClient : POINTER TO VisuElems.VisuStructClientData;
                    _VisuFbClientTagDataHelper                    : VisuElems.VisuFbClientTagDataHelper;
                    _asIP: ARRAY[0..5] OF STRING;
                    _asPreviousUserName : ARRAY[0..5] OF WSTRING;
    END_VAR
    
    // Iterate over all currently active visualization clients
    VisuElems.g_ClientManager.BeginIteration();
    WHILE (pClient := VisuElems.g_ClientManager.GetNextClient()) <> 0 DO
                    // Switch the visu of a webclient only if it is a specific client where the admin user is logged out. In this case the current user is empty and the previous was Admin.
                    IF pClient^.GlobalData.ClientType = VisuElems.Visu_ClientType.WebVisualization THEN
                                   _VisuFbClientTagDataHelper(pClientData := pClient);
                                   IF _VisuFbClientTagDataHelper.xIPv4Valid THEN
                                                   _asIP[pClient^.GlobalData.GlobalClientID] := _VisuFbClientTagDataHelper.stIPv4;
                                                   IF pClient^.GlobalData.CurrentUserName = "" AND _asPreviousUserName[pClient^.GlobalData.GlobalClientID] = "Admin" AND _asIP[pClient^.GlobalData.GlobalClientID] = '127.0.0.1' THEN
                                                                   VisuElems.g_VisuManager.SetMainVisu(pClient, 'MainVisu');       
                                                   END_IF
                                   END_IF
                                   _asPreviousUserName[pClient^.GlobalData.GlobalClientID] := pClient^.GlobalData.CurrentUserName;
                    END_IF 
    END_WHILE
    
     
    • ignat - 2022-07-29

      Hi, this won't work for me.
      In debugging it shows -1 for GlobalClientID, seems the property is missing in VisuGlobals.

      The Codesys and library version 3.5.16.3

      Could you please check do you have the same variables in the respective library? (see attached)

       

Log in to post a comment.