Example logical typical (basic principle)
With the logical add-on you can generate PLC code, which automatically is filled with project specific information. This window is used to import logical typicals. Logical typicals are small pieces of PLC code (*.txt or *.awl files for an example) which can contain variables. Variables are placed between a begin- and end tag. You can set the begin- and end tag in System -> Options -> System -> Plug-in logical to your needs. This is important before importing your typicals. A file viewer is available which will show you the selected typical.
See also:
Default value typical variable
Press
Select the plugin corresponding to the manufacturer/system type of the used PLC.
Select a file to import by clicking
and browse to the file location.Select the desired file and click
More than one file can be imported at once by selecting multiple files
in the browsing window.
To make managing of imported files more convenient, a group and subgroup can be assigned.
If you do not want an imported typical or template to appear in the library and project windows, it can be disabled by unchecking the 'Enabled' check box.
Click
to start importing the files.If you want to use a typical as a template, you have to check the ‘Is Template’ check box.
Notes:
1. You can define which file extensions you want to import in System - Options.
Select the typical(s) you want to delete from the list in the main panel.
Click
.Click
in the message dialog.
Notes:
1. A typical in use can not be deleted.
In case a typical should be updated or overwritten:
Select the typical in the main panel.
Click
in the column 'Filename'.Browse to the desired file and click
.
The typical is updated now. It is also possible to update more typicals at once with the Import button.
Download the typicals used in this example here.
Basic principle
Templates and typicals are placed using insert points and sections.
A section on a typical is marked by a with specific tags and a name, (e.g. <!CM_VARIABLE!>) this section will start with this mark and the section will end when the next section starts or till the end of the file.
The sections are placed on an insert point of the template with corresponding name (e.g. <$CM_VARIABLE$>)
Template typical
If you want to use a typical as a template, you have to check the ‘Is Template’ check box. A template is used to collect typicals. In a template, you can collect typicals on several places. In the template below we collect typicals at two places:
1. <$CM_VARIABLE$>
2. <$CM_MODULE$>
These two places were the template can collect typicals are called 'Insert points'.
You can change the template settings in System -> Options -> System -> Plug-in logical. Here you can change the begin- and end tag for variables, insert point and sections starts.
Typicals
The typicals below are used to 'fill' the template:
As you can see, the above typical begins with ‘<!CM_MODULE!>‘. So this typical is placed at the template at insert point ‘<$CM_MODULE$>‘.
Second typical:
The above typical is placed at the template at insert point ‘<$CM_VARIABLE$>’.
Example insert typicals
In the picture below you can see how the typicals are inserted on the template:
Download the typicals used in this example here
Principle
Using logical typicals it is possible to create XML (like) structures. Link explained in the 'basic' example above, a typicals with a section mark will be placed on the corresponding insert point on the template.
The same is for templates with sections, these sections will be placed on templates with corresponding insert points.
If a template has a section mark, that section will be placed on the first template it can find with the correct insert point. The section will always be places in a 'higher' level template.
At first the section is tried to be inserted in a template of the top location of the template.
Example pictured below:
If template 'breakfast food template' in location '[1] Belian Waffels' has an section to be placed in an other template. the fist template to look are templates 'Breakfast Food Template' and 'Breakfast Template' in location 'Breakfast master.
If no valid insert point on any template is found, the next top location is used to find insert points, and so on.
This Example will demonstrate how Logical typicals/template are used to generate the flowing XML file, used to store a breakfast menu.
Templates and typical:
To generate this xml file 2 templates where created, 'BreakfastTemplate' and 'BreakfastFoodTemplate' and a typical 'BreakfastFoodTypical'
BreakfastTemplate
BreakfastFoodTemplate:
BreakfastFoodTypical
Example insert typicals
In the picture below you can see how the typicals are inserted on the template when generating.
Assuming the flowing Logical Location structure is created:
when generating. the example XML file is generated as output.
The food template with a typical can/will be place multiple times on the breakfast template to create the different 'foods' in the XML file
NOTE:
This technique, inserting template sections in to insert points on other template is not limited to XML only, this can also be used to control the location of templates/typicals to create a single file. or to create multiple files that have a nested structure, but is no XML file.