I am using Codesys 3.5.7 for Wago (aka: e!Cockpit). I need to change the visualization within a frame using structured text, but only on the current client. Since the code is embedded in a button, I assumed the button would have a pointer to the client it is displayed on and have tried to access it via:
pClientData := THIS^._pCurrentClientData; // unless I'm mistaken, THIS should point to the current button, or at least the current visualization
iClientIndex := VisuElems.g_ClientManager.GetClientId(THIS^._pCurrentClientData);
pClientData := VisuElems.g_ClientManager.GetClientData(iClientIndex);
In both examples, it fails to compile with: Cannot convert type 'Unknown Type: 'THIS^._pCurrentClientData'' to type 'POINTER TO VisuStructClientData'.
I have checked the following example projects: Client Independent Visualization Switching, Visualization Switching, and Responsive Design. None of these give any example on how to determine what the current visualization is.
Also, does anyone know if there is a way to create client specific variables? I know if I can get an index for the current client I can simply use an array of variables, just wondering if there is a simpler way?
Thank you in advance.
Did you managed to find out how to get independent visualizations?
@paulolouro what are you trying to to?
Was trying to make the visualization independent from each other, but in fact I had the "User CurrentVisu variable" in the Visualization Manager checked, that forced all clients to behave as one. If I uncheck that, then it works independent from each other.
Anyways if anyone else wants to get the visualization id directly from a visualization picture this works within a text field or any other visu objects that support tags or logic.
Return user visu clientId.
Another problem I have it to move a dialog around with the mouse without affecting all the other visulization clients. Any idea who this can be done?
Atm I have a EventHandler for the mouse movement, but ofc thats shared between all visu clients. So I was thinking on creating a list of active clients and then depending on each client pass the mouse positions in an array, from there using the cliendid i can access the current visu client position within the array and get the X,Y for the mouse.
Another way to do this simpler?
Example code of FB with Method Handle MouseMove.
FUNCTION_BLOCK EventHandler IMPLEMENTS VisuElems.VisuElemBase.IMouseEventHandler
Then with method
METHOD HandleMouseMoveEvent : BOOL
/// The position where the mouse was moved to.
ptMouse : VisuElems.CmpVisuHandler.VisuStructPoint;
/// A pointer to the client structure were the event occurred.
pClient : POINTER TO VisuElems.VisuStructClientData;
clientId := VisuElems.g_ClientManager.GetClientId(pClient);
GVL_mouseMove[clientId].eventCounter := GVL_mouseMove.eventCounter + 1;
GVL_mouseMove[clientId].iX := ptMouse.iX;
GVL_mouseMove[clientId].iY := ptMouse.iY;
Then i can get the mouse position for each visulization client like.
You can get the currentclient id with CURRENTCLIENTID.
If you use the variable CURRENTCLIENTID e.g. in a rectangle as text variable a new library will be added and you can use this for your code.
Hi there, I wonder how to use this CURRENTCLIENTID.
However, what I am trying to do is to use PLC_PRG.aIndexVisu[CURRENTCLIENTID]. to switch the frame within the mainpage without affecting the other screen same as the first question of this post. However, I failed to do it.
Can you tell me how to do it ? Or can you advise me on this issue
Moveable dialogs are on the roadmap but no ETA yet
There is some problem between the CURRENTCLIENTID and the VisuElems.VisuElemBase.IMouseEventHandler in case you refresh the page, looks like the CURRENTCLIENTID gets updated but the IMouseEventHandler for the mouse, reports the old client id. This gets solved after refreshing the page a couple of times.
Also I have 2 text fields in the visualization showing the CURRENTCLIENTID and the VisuElems.g_ClientManager.GetClientId(THIS^._pCurrentClientData), only the CURRENTCLIENTID gets incremented every time i refresh the page the _pCurrentClientData reports the old client id as the same client id reports by the IMouseEventHandler.
You are mixing two different values here.
I did a small post in german here (https://forge.codesys.com/forge/talk/Deutsch/thread/f14041c158/#8477).
In short, GetClientId has a different value range than CURRENTCLIENTID.
Yes, it makes sense, but then i will need to use getclientid to grab the correct mouse location.
Is there other way to get the mouse position directly from the visu, so i can open a dialog at a specific position?
Also is there a way to read the graphic element position, in conjunction the mouse position to display the dialog at a position relative to the element? Example: click on a button and show a dialog on the left hand side of it.
You can open the dialog relative to the element see attached project.
There is no real API to access the element position. But you can achieve this with the example attached.
Knowing the mouse position relative to the screen already helps and allows me to program a function to be called before opening the dialog.
So there is a reference pointer for the mouse position for each visualization, like there is the pClientData pointer. What other pointers exist? Where is this documentation?
No, the position provided with ptMouse is not the global position for the visu, but for the actual event.
But then for each visualization and instance/client, some objects and variables are available. There is no auto complete for those variables, how shall we know they exits?
Before i was trying to access the mouse position via the interface for mouse event and then create a global variable array with a index for each client id. But if we have the ptMouse directly on the visu, then we dont event need that extra mouse event handling.
Where is the documentation for those variables/pointers?
Most of those variables are internal.
No, ptMouse is the event position triggered on the specific element, not a global event triggered by all events and elements.
Sir Marcel, ptMouse is some system variable?
I can't see where she's declared in this example.
ptMouse is an input variable used in the generated code which handles the input events
Thank you. I agree with Paul - I think there's will be nice to see this info in online help.
Hey @m.prestel, any documentation on those global variables like ptMouse?
Log in to post a comment.