Changing content right after page load

Hi!
I have a seemingly simple navigation task that I can’t get to work properly. When my mappView client starts and loads its starting page I want to swap one of its contents depending on a value in an opcua tag. This fails with an error message in the logger. I’ve tried a couple of different ways to do this:

  • An event binding on a change in the opcua tag that triggers a LoadContentInArea action.
  • An event binding on ContentLoaded on the starting content that I want to replace that also triggers a LoadContentInArea action.

I get the error code 1061090151 which just tells me that there is an error excuting the action.

When my client has started the events work as expected, which makes my suspect that there is some kind of timing issue.

Initial ValueChanged events is set to true in my config, and by using the /server/info page I can see that the value in my tag is read and has a correct value and that the events are triggered.

Any idéas or alternative solution suggestions would be appreciated.

Hello Jonas Berggren

Just to make sure that I undestood correctly your issue: Your starting page has some area content that need to to be changed according to an opcUa value, and it doesn’t work properly and gives the error executing the action.

If the cae, I’d think that some timing issue is indeed involved, without more information I’d suggest the following the secod option you did, just before triggering the LoadContentInArea, check the contentID of the ContentLoaded, since this event is shown whenever a content is loaded. make sure only use the LoadContentInArea, when the content Id belongs to the content that you want to replace.

May also want to activate the pre cache on the starting page to pre load the content more info

Hi Wenbo,
thanks for your reply! I think you descibe my problem spot on. Here’s an example of how the event binding looks:

It has a check for the content named “Start” and another for the tag value.

I can see that all contents on the page are not loaded before the event based LoadContentInArea is called, which means that the event listeners are running before the page has completely loaded.

Hello Jonas,

I have done small replica for you events and it worked just fine


the event binding in question:

Seeing your second image makes think that there is conflict of two actions. You mentioned that with the client started, the changes ocurres correctly, which mean another event-action must handle that.
Judging from the your second picture I assume that an aditional opcua event that would trigger the same ContentLoadInArea is in place somewhere. I believe that two action loading the area may be the cause of your problem.

Edit: Added the mentioned action in my test project, and similar issue happened


If that is the cause of your problem, then a simple solution I found was to add a condition to the action triggered by the opcUa value change such as :

like this, since there shouldnt a change in the “mode” when starting the hmi.

1 Like

I have faced the same issue before. The only way I could reliably solve this issue, was by starting a session timer instead of doing the load content in area.
Then by evaluating the session timer elapsed event I do the load content in area after a little bit.

ContentLoadedEvent does not mean that the page is already ready/loaded after all.

2 Likes

Hi,
sorry about the confusing description above, the two screenshots are from the two different examples of solutions I’ve tried.
Checking that newValue and oldValue are not the same might not work either if the client restarts, then it will not switch content to the one corresponding to the value? (if the default content corresponds to value 0 and both old and new value is 1)

I guess I could check that every area has its content loaded, but that seems a bit awkward?

1 Like

Hi,
If the client is restarted, the event of valueChanged will not take action (because of the condition of the newValue <> oldValue), but the loadedContentEvent should still work.

Nevertheless, another option would be checking the currentpageId


, and then get the value of OpcUa to check the content that need to be loaded.
In my case it worked just fine.

Hi Wenbo,
I’ve tested your suggestions and it works as long as I have one single content in my page layout. Have you tried using more than one? Would be really interesting to know.

Hi Philipp!
What length of time have you typically used? Will it depend on what type of client you use or do you try to find a generic time that works regardless of loading time?

That really depends on a few things.
Amount of contents to load, complexity of the contents and the Target system, as content loads only work once the whole page has been loaded.

In general times between 0.2-5 seconds are what I would consider. 10 seconds is the default for the watchdog, so anything below that is valid.
Mostly I would just go for around 2 seconds.

And as a side note:
Most of the time the most complex content will be loaded last, so if you check in the EventHandler with that ContentID as a condition, it should work most of the time as well :smiley: