I would like the following to happen: Upon pressing a button, one of several dialogs shall be opened, depending on the state of other variables. I managed to realize this by either using the "Execute ST-Code" Option in the Input Configuration or by setting a BOOL Variable on button tap and executing the same code elsewhere. The code is something like this:
When using the client filter "AllClients", and using several visualizations (i.e. several webbrowser instances), the dialog stays open on other visus, which is undesired. Using the option "CurrentClient" is what I am looking for, however it only works when being called in the "Execute ST-Code" section of the button.
How can I record on which client a button was pressed and open a Dialog only in the regarding client? I tried creating a variable of type VU.IVisualizationClientFilter and setting it to VU.Globals.CurrentClient in the Input Configuration of the button, but that does not seem to work.
Would appreciate any ideas!
Cheers
Manuel
Last edit: manuknecht 2023-08-11
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I managed to find a solution that seems to work reliably. As the VU.Globals.CurrentClient-filter accesses the CURRENTCLIENTID or at least a similar, internal variable it can only be used if called from a certain client (e.g. from a button in a visualization). My solution works by implementing a new client filter that compares the client ID of all clients to the ID of the last client that was used. The variable containing the data of the last client is defined as:
G_LastClient:VU.IVisualizationClient;// Copy of last client that detected click
This last client is then updated every time a button is pressed using the Execute ST-Code input configuration of the button:
G_LastClient:=VU.PublicVariables.Clients.Current;
Next, I created a function block that implements the client filter interface as so:
Then i added a method to the FB called IsAccepted which is used to filter out the client. When creating the method, it should automatically be filled with the according variable declaration, as it is defined in the interface:
Now the client can be compared to the last used client as such:
// check if clientID corresponds to clientID of last recorderd clientIFitfCLient.ClientId=G_LastClient.ClientIdTHENIsAccepted:=TRUE;ELSEIsAccepted:=FALSE;END_IF
To make use of this custom client filter, initialize a variable with the client filter:
LastClient:FB_LastClientFilter;// Client filter to find last used client
Then use this client filter when opening or closing a dialog from ST:
Thanks, Manuel, for providing this solution and insight. I too had exactly the same problem as you did. While I did implement a custom filter, I'd also like to point out what jinlee mentioned above...I see no reference to VU.PublicVariables.Clients.Current anywhere?? In my case I only needed to show a dialog on a "master" client, not all the clients, so I filtered by IP address to do this.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I would like the following to happen: Upon pressing a button, one of several dialogs shall be opened, depending on the state of other variables. I managed to realize this by either using the "Execute ST-Code" Option in the Input Configuration or by setting a BOOL Variable on button tap and executing the same code elsewhere. The code is something like this:
When using the client filter "AllClients", and using several visualizations (i.e. several webbrowser instances), the dialog stays open on other visus, which is undesired. Using the option "CurrentClient" is what I am looking for, however it only works when being called in the "Execute ST-Code" section of the button.
How can I record on which client a button was pressed and open a Dialog only in the regarding client? I tried creating a variable of type VU.IVisualizationClientFilter and setting it to VU.Globals.CurrentClient in the Input Configuration of the button, but that does not seem to work.
Would appreciate any ideas!
Cheers
Manuel
Last edit: manuknecht 2023-08-11
I managed to find a solution that seems to work reliably. As the VU.Globals.CurrentClient-filter accesses the CURRENTCLIENTID or at least a similar, internal variable it can only be used if called from a certain client (e.g. from a button in a visualization). My solution works by implementing a new client filter that compares the client ID of all clients to the ID of the last client that was used. The variable containing the data of the last client is defined as:
This last client is then updated every time a button is pressed using the Execute ST-Code input configuration of the button:
Next, I created a function block that implements the client filter interface as so:
Then i added a method to the FB called IsAccepted which is used to filter out the client. When creating the method, it should automatically be filled with the according variable declaration, as it is defined in the interface:
Now the client can be compared to the last used client as such:
To make use of this custom client filter, initialize a variable with the client filter:
Then use this client filter when opening or closing a dialog from ST:
Hi,
for this, G_LastClient := VU.PublicVariables.Clients.Current;
It fails to do it.
Hi
Thanks, Manuel, for providing this solution and insight. I too had exactly the same problem as you did. While I did implement a custom filter, I'd also like to point out what jinlee mentioned above...I see no reference to VU.PublicVariables.Clients.Current anywhere?? In my case I only needed to show a dialog on a "master" client, not all the clients, so I filtered by IP address to do this.