This module is (c) 2001 Juan Carlos Orozco and is distributed under the GPL license.
The purpose of this module is to build a GUI (operator screen) to read and write MatPLC points.
The Glade program is used to build the screen.
In a few words, the HMI GTK module works as follows: Glade generates a
.glade file (an XML file representing the GUI). HMI GTK module
reads and interprets this
.glade file and uses a naming
convention to connect widgets with the MatPLC points.
The widgets are connected to the MatPLC points by giving them special
names. The easiest way to construct these names is using the
widgetnamerstarts, it will pop up a dialog box. Fill in the details as follows:
|The MATPLC point that should be connected to this widget.|
|Normally, this will be 0. If you want several widgets showing the same point, you need to number them 0, 1, 2 etc|
|The type of point to which we are connecting. For coils, this will be bool (on/off), for registers you have to check what type they are and pick appropriately. All the points used by DSP are f32 (floating-point number).|
|This has different meanings depending on the type. For instance, for the bool type this will be the ON text or image.|
|This has different meanings depending on the type. For instance, for the bool type this will be the OFF text or image.|
Once you have filled it in, click the "Select" button (or press Enter in one of the text fields), then use the middle button to paste the name into glade. The entries can be cleared with the "Clear" button, or you can simply edit them to get the next widget name.
The names are put together as follows:
number field is needed because every widget in a window
must have a unique name.
type can be bool, i32, i16, i8, u32,
u16, u8 or f32. The default type is bool.
This can be the name of a LabelWidget that will be displaying "on" or "off" depending on the state of the point named "left" at the matplc.conf file.
The widgets that are currently supported are:
In order for input widgets to work one must add a signal with handler = update_value.
In order to be able to write variables, they should be assigned to this module in the matplc.conf file. The default module name for the HMI module is hmi_gtk.
One can place other widgets and they won't interfere with MatPLC as long as their names don't start with an underscore "_".
The suggested way of building a project is to create a project in glade named hmi_gtk. Then add a Gnome Application Window found on the Gnome palette. Delete unwanted menu options and toolbar options. The about menu option will automatically display this project credits. One can add widgets to this window and connect widgets to the MatPLC by following the previously described naming convention.
Closing main window with delete_event (from window-manager, e.g. X-Button):
The main window (app1) must connect the signal "delete_event" with the quit_handler. The quit_handler (when called by "delete_event") sets the point "quit_app1".
In matplc.conf you have to
To build a multi window project one can then add normal Window Widgets found on the GTK+ basic palette of Glade. To open this additional windows we need to link a signal from a button, toolbar button or menu option. There are two ways to link windows to widgets (i.e. button):
One way is to use the 10 predefined names for windows, window1 to window10, each one with a predefined Handler function run_window1 to run_window10. When opening a window from a menu option this is the only way to call windows one just need to add the corresponding Handler name to the menu option (i.e. Handler: run_window5). This limits the number of additional windows to call from the menu options to this 10 predefined ones.
There is an alternative way of calling a window that can be used by other Widgets like the button widget. This method uses a common handler called run_window, this handler expects a window name in the Data parameter of the signal. This method does not impose a limit on the number of windows that the project can open. One could also call the predefined windows from this widgets by adding the window handler to the corresponding signal.
Example of connecting a button widget to a window.
|Data:||WindowName (This has to be the name of the window in Glade)|
Because of performance concerns, there is a feature in the program that only allows one version of each window to be open at one time.
FIXME: How to close windows? ikeya wrote on the mailing list: "... should use delet_event call back."
When saving the project from glade we will get a hmi_gtk.glade file, this file is what the HMI_GTK module uses to run the graphical HMI.
There are two ways to pass the xpm-file filenames to hmi_gtk.
plc-point = abcd, type = bool
This will result in the behaviour:
plc-point = abcd, type = i32
[hmi_gtk] GnomePixmap widgetpattern pixmap1 pixmap2 ...The widgetpattern can be the name of the widget (without _) or a namepattern with wildcards (similar to filename-match) included (e.g. LED* -> all widgets starting with LED). Note: The last pattern match is used. So the order is important. If you have one widget LEDerrorXYZ and many widgets starting with LED you can do the job like this:
[hmi_gtk] # widgetpattern value 0 1 2 3 GnomePixmap LED* grey green yellow red GnomePixmap LEDerrorXYZ off errorThis will result in the behaviour:
There are two ways to define the format:
[hmi_gtk] GtkLabel widgetpattern "format"The widgetpattern can be the name of the widget (without _) or a namepattern with wildcards (similar to filename-match) included (e.g. abc* -> all widgets starting with abc). Note: The last pattern match is used. So the order is important. If you have one widget beltSpeed and many widgets ending with Speed you can do the job like this:
[hmi_gtk] # widgetpattern format GtkLabel "*Speed" "%5.2f km/h" GtkLabel beltSpeed "%7.3f m/s"Note:
If the widgetpattern starts with "*" you have to enclose it in "".
For valid format-definitions see the printf() documentation.
How to create:
Definitions in matplc.conf under section [hmi_gtk]:
[hmi_gtk] #--------------------------------------------------------------------------------------------- # - command - - param 1 - - param 2 - - param 3 - - param 4 - #--------------------------------------------------------------------------------------------- widgetname plotctrl startpoint stoppoint resetpoint widgetname channel y1point y2point widgetname mode timer/plotxy # in plotxy-mode required widgetname plotx xpoint #[optional] Default-Values see below widgetname widget xsize ysize widgetname title title x-axis y-axis widgetname axis xmin xmax ymin ymax widgetname timer scantime widgetname color bg plot_bg legend_bg widgetname channelcolor red widgetname symboltype star widgetname symbolstyle opaque widgetname symbolsize 2 widgetname linestyle solid widgetname linewidth 1 widgetname pointconnect straight
Explanation of the commands
[plc] point widgetname "" hmi_gtk i32 point p1 "" hmi_gtk i32 point p2 "" hmi_gtk i32 [hmi_gtk] widgetname p1 "item1" "item2" ... widgetname p2 "item11" "item12" ...
[plc] point menu1 "Menu 1" hmi_gtk i32 point p1 " " hmi_gtk i32 point p2 " " hmi_gtk i32 [hmi_gtk] # widget point value: 1 2 3 menu1 p1 "choice1 p1" "choice2 p1" "choice3 p1" menu1 p2 "choice1 p2" "choice2 p2" "choice3 p2"
How to create:
Due to a bug in glade 0.6.2 and earlier versions, the GnomePixmap scaled state is not saved. This
will cause the *.glade configuration file to loose this information each
time a change is saved. In this demo the following line was inserted
manually for each scaled widget:
This simple bug makes working with scaled GnomePixmap images uncomfortable. From glade version 0.6.3 this bug was corrected, this new version could be downloaded from: ftp://ftp.gnome.org/pub/GNOME/stable/sources/glade/glade-0.6.3.tar.bz2 ftp://ftp.gnome.org/pub/GNOME/stable/sources/glade/glade-0.6.3.tar.gz
Libglade does not recognise the scaled state either, therefore an
interim solution was implemented in hmi_gtk.c module. The inconvenience is
that the name of the pixmap has to be placed on the name of the widget
using the following format:
The widget is actually scaled to the size of the widget and not using the scale factors of the GnomePixbuf.
$Date: 2005/10/11 13:35:45 $