Current Visu name without Current Visu Variable

2025-08-07
2025-08-13
  • williamjmak1 - 2025-08-07

    Hello everyone, I was just wondering if anybody knows if there's a way to pull the string name of the current visualization without using the current visu variable. I'm working on a project where we don't want web clients to change the current visualization on the HMI of the machine. Thanks!!

     
  • TimvH

    TimvH - 2025-08-13

    To change the current visualization for (all) webclients:

    Add the library β€œVisu Utils” and use the following example code:

    VAR 
        xChangeVisu: BOOL;
        fbChangeVisu : VU.FbChangeVisu;
    END_VAR
    
    // Change to Visu2 when setting xChangeVisu to TRUE
    fbChangeVisu(
        xExecute:= xChangeVisu, 
        xDone=> , 
        xBusy=> , 
        xError=> , 
        itfClientFilter:= VU.Globals.OnlyWebVisu, //itfFilter, 
        eError=> , 
        sVisuName:= 'Visu2');
    IF fbChangeVisu.xDone OR fbChangeVisu.xError THEN
        xChangeVisu := FALSE;
    END_IF
    
     
  • TimvH

    TimvH - 2025-08-13

    To get the current visu for all your individual web clients, you could iterate over them, using the same library

    1)
    Create a new function block which implements VU.IVisualizationClientIteration
    2)
    Create an instance of this function block + add an instance of the "iterate" function block

        fbIterateCallBack : FB_IterateOverClients; // this implements VU.IVisualizationClientIteration
        fbVuIterate : VU.FbIterateClients; // this FB iterates over all clients
    

    3)
    Call the fbVuIterate and set the reference to the call back FB. Then it will automatically call the method "HandleClient" of this function block.

    fbVuIterate(
        xExecute:= NOT fbVuIterate.xDone, 
        xDone=> , 
        xBusy=> , 
        xError=> , 
        itfClientFilter:= VU.Globals.OnlyWebVisu, 
        eError=> , 
        itfIterationCallback:= fbIterateCallBack);
    

    In the HandleClients method you can use the property of the interface of your webclient to which page it is currently on:

    sCurrentVisuOfClient := itfClient.CurrentVisuName;
    

    4)
    Optionally from here you could also set the visu for the webclient, but this might be obsolete, because the other function block is now available...

        xQueryOK : BOOL;
        xChangePage : BOOL;
        itfVisuClientRawData : VU.IVisualizationClientRaw;
    
    xQueryOK := __QUERYINTERFACE(itfClient, itfVisuClientRawData);
    IF xQueryOK AND xChangePage THEN
        VisuElems.g_VisuManager.SetMainVisu(pClientData := itfVisuClientRawData.ClientDataPointer, stVisu := 'Visu2');
        xChangePage := FALSE;
    END_IF
    
     

Log in to post a comment.