I did search for any solutions of my issue, but i am not happy with the results.
The issue:
We use function blocks instances within a visualization. For the first time the frame is called, we would like to initialize some values or references.
We typically use pragmas like call_after_init or the FB_Init method. Unfortunately these don't work in the visualization.
Question: Are you expecting a separate instance of the Function Block for each client that connect to the WebVisu server?
If yes then it is a little more complicated
if no...
The best way, I have found to handle things, is to have a Function Block defined for each Visualization you have defined. this function Block serves as the "View Model"
So like the Main Visualization has a viewModel and it is a reference to an instance in the process code. Because it is in the process code FB_init is called.
Then that main ViewModel, has a viewmodel for each of the visualizations that will be changed in the main Frame, those viewmodels for each screen are then injected in to those visualization with a VAR_IN_OUT. And you can keep doing that and build layers.
since all of it is in side the Main ViewModel FunctionBlock and that is a reference to an instance in the process code, all of the init code functions normally.
It's not a great solution but it works. If you want a better solution go find the Codesys Product Owners on LinkedIn and demand better features.
this is what I recently requested
FB/Class Property Support in CFC (you can't use Properties as Input or Outputs in CFC)
Method/function Pointers (or C# Style delegates), this would be very helpful in Visualization code; it would make UI code so much more structured and reusable.
Interface Implementation Methods should not incorrectly throw a C0094 warning when the Interface only defines the Get, but the implementation has a GET and SET. Using an interface to Mask write access is a perfectly valid OOP technique.
Each user-created visualization instance should have its own VAR instances instead of them being static (shared by all client sessions)
FB_Init Methods should be called if there Function Block is assign as a Visualisaton VAR.
Visualizations should have anchor properties like WPF and WinForms so you can tell set them to move with the bottom or right side of the frame or set them to stretch with the right side or bottom of the frame.
Visualization Table "Use Template" needs to allow user-created visualizations.
Visualizations need a FlowLayoutPanel/WrapPanel that allows a user-created visualization to be used as a template, just like I mentioned for tables.
Visualizations should allow Methods to be defined in them and to be debugged so that visualization/UI-related code can be encapsulated in the visualization where it belongs and not in the control/operations code.
Better error messages when errors occur during application download and initialization.
Messages like "Exception[GlobalInit] Code: App=[Application], Exception=[Access Violation]" are not exactly helpful. They tell the user nothing about where or what is causing the access violation. This could be anywhere in the project.
Ability to set breakpoints in initialization code before download, so that code that is executed during the initialization step can be debugged.
Automatic FB property implementations with implicit backing fields like C#, so you do not have to write so much boilerplate code (this should be allowed to be overridden, though)
Real Generics like in C#
π
1
Last edit: thecolonel26 2023-06-24
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The impression I got from them was that everything on that list had been asked for by other users long ago (Except for function pointers/delegates). They said they were on their "back log" list.
So I assume they will never happen.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I did search for any solutions of my issue, but i am not happy with the results.
The issue:
We use function blocks instances within a visualization. For the first time the frame is called, we would like to initialize some values or references.
We typically use pragmas like call_after_init or the FB_Init method. Unfortunately these don't work in the visualization.
Is there any way for?
more posts ...
I'm looking for the same solution
Question: Are you expecting a separate instance of the Function Block for each client that connect to the WebVisu server?
If yes then it is a little more complicated
if no...
The best way, I have found to handle things, is to have a Function Block defined for each Visualization you have defined. this function Block serves as the "View Model"
So like the Main Visualization has a viewModel and it is a reference to an instance in the process code. Because it is in the process code FB_init is called.
Then that main ViewModel, has a viewmodel for each of the visualizations that will be changed in the main Frame, those viewmodels for each screen are then injected in to those visualization with a VAR_IN_OUT. And you can keep doing that and build layers.
since all of it is in side the Main ViewModel FunctionBlock and that is a reference to an instance in the process code, all of the init code functions normally.
It's not a great solution but it works. If you want a better solution go find the Codesys Product Owners on LinkedIn and demand better features.
this is what I recently requested
Last edit: thecolonel26 2023-06-24
How did they answer?
The impression I got from them was that everything on that list had been asked for by other users long ago (Except for function pointers/delegates). They said they were on their "back log" list.
So I assume they will never happen.
create a function:
Then, in your visu
you might be able to do the same thing with properties of FB_Menu
then in visu
Last edit: tvm 2022-09-01