Skip to content

Commit

Permalink
Merge branch 'master' of github.com:paulscherrerinstitute/ecmccfg
Browse files Browse the repository at this point in the history
  • Loading branch information
anderssandstrom committed Oct 2, 2024
2 parents bbc7035 + 24b2105 commit a4923f2
Show file tree
Hide file tree
Showing 37 changed files with 1,307 additions and 973 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ hugo/content/source/
*.pyc

.hugo_build.lock
hugo/public
2 changes: 1 addition & 1 deletion hugo/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Observe the CLI output for details.
1. gawk at the beauty of the produced web-site :)

### editing the code
* contend is found in the `content` directory
* content is found in the `content` directory
* mostly everything is done in markdown
* the HUGO theme ["learn"](http://github.com/matcornic/hugo-theme-learn) is used. Follow the instructions [here](https://learn.netlify.app/en/) for examples and an overview of it's capabilities.
* changes are reflected immediately in the browser after saving your changes.
Expand Down
2 changes: 2 additions & 0 deletions hugo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ title = 'ecmccfg'
theme = "hugo-theme-learn"
relativeURLs = true
canonifyURLs = true

[markup]
[markup.goldmark]
[markup.goldmark.renderer]
Expand All @@ -15,3 +16,4 @@ canonifyURLs = true
themeVariant = "green"
# Set this to true to disable copy-to-clipboard button for inline code.
disableInlineCopyToClipBoard = true
custom_css = ["css/custom.css"]
4 changes: 2 additions & 2 deletions hugo/content/manual/PLC_cfg/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ All keys are mandatory.

- `id`: PLC id, unique **uint**
- `enable`: PLC enabled at start
- `rateMilliseconds`: execution rate in ms. To execute every cycle, independant of cycle rate, use `-1`.
- `rateMilliseconds`: execution rate in ms. To execute every cycle, independent of cycle rate, use `-1`.
- `code`: dictionary of code lines.

{{% notice note %}}
Expand Down Expand Up @@ -73,7 +73,7 @@ All keys are mandatory.

- `id`: PLC id, unique **uint**
- `enable`: PLC enabled at start
- `rateMilliseconds`: execution rate in ms. To execute every cycle, independant of cycle rate, use `-1`.
- `rateMilliseconds`: execution rate in ms. To execute every cycle, independent of cycle rate, use `-1`.
- `file`: PLC text file to load.

{{% notice warning %}}
Expand Down
12 changes: 6 additions & 6 deletions hugo/content/manual/PLC_cfg/best_practice.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ chapter = false
+++

## best practice
Here you can find some best practice configurations for common usecases.
Here you can find some best practice configurations for common use cases.
* Macros
* MSI include, substitute
* Printouts
* Description

The complete examples with starup files can be found [here](https://github.com/paulscherrerinstitute/ecmccfg/tree/master/examples/PSI/best_practice)
The complete examples with startup files can be found [here](https://github.com/paulscherrerinstitute/ecmccfg/tree/master/examples/PSI/best_practice)

### macros
Use of macros makes the code more generic. When loading a PLC file with "loadPLCFile.cmd", custom macros can be defined in "PLC\_MACROS":
Expand All @@ -27,7 +27,7 @@ In addition to the custom macros, a few macros, that are often needed, are prede
4. M : ec<M\_ID>

#### SELF_ID and SELF example
A common usecase is that some initiation is needed, could be triggering of a custom homing sequence:
A common use case is that some initiation is needed, could be triggering of a custom homing sequence:

```C
if(${SELF}.firstscan) {
Expand Down Expand Up @@ -72,8 +72,8 @@ ${SCRIPTEXEC} ${ecmccfg_DIR}loadPLCFile.cmd, "FILE=./cfg/main.plc, INC=.:./cf
The "INC" parameter can contain several directories separated with a ":", making it possible to include PLC files from several locations/modules.

#### example: Toggle a few outputs
As a demo usecase let's consider that a few outputs needs to be toggled.
NOTE: There are simpler ways to write this specifc code but it's used to demo how code can be divided.
As a demo use case let's consider that a few outputs needs to be toggled.
NOTE: There are simpler ways to write this specific code but it's used to demo how code can be divided.

Lets first define some code that toggles a bit (toggle\_output.plc\_inc):
```shell
Expand Down Expand Up @@ -104,7 +104,7 @@ The resulting code will toggle two different outputs, the state of the last outp
NOTE: Macros cannot be used in the filename when including a file. Instead the dir should be defined in the INC param when loading the PLC, see above.
### printouts
Adding a DBG macro can be usefull to be able to turn on/off printouts. Typically during commsioning it can be usefull to have many printouts but later when system goes into production, it could be a good idea to turn (some) printouts off.
Adding a DBG macro can be use full to be able to turn on/off printouts. Typically during commissioning it can be use full to have many printouts but later when system goes into production, it could be a good idea to turn (some) printouts off.
Example of a printout that can be turned on/off (default off)
```C
Expand Down
12 changes: 6 additions & 6 deletions hugo/content/manual/PLC_cfg/function_libs.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ chapter = false

## function libs
Function libraries can be loaded into ecmc PLCs by loadPLCLib.cmd. The command takes these parameters:
* FILE PLC: definition file, i.e. ./plc/homeSlit.plc
* FILE: definition file, i.e. ./plc/homeSlit.plc
* PLC_ID: (optional) PLC number, default last loaded PLC
* PLC_MACROS: (optional) Substitution macros for PLC code. The macros "SELF_ID","SELF",M_ID, and M are reserved:
- "SELF_ID" = PLC Id of this plc
Expand All @@ -22,7 +22,7 @@ Example:
${SCRIPTEXEC} ${ECMC_CONFIG_ROOT}loadPLCLib.cmd, "FILE=./plc/test.plc_lib, PLC_MACROS='OFFSET=3'"
```

The functions must be defined accordning to this template (max 5 parameters):
The functions must be defined according to this template (max 5 parameters):
```C
function <name>(<param1>,...,<param5>) {
<code body>;
Expand All @@ -38,9 +38,9 @@ function <name>() {

* Several functions can be defined in the same file.
* For syntax of the "code body", check [plc syntax](../syntax) and the exprtk website.
* The parameters aswell as the return value must be scalars, however, local vectors can be defined and used in calculations (initiations of vector can be done with MACROS, constants or parameters).
* The parameters as well as the return value must be scalars, however, local vectors can be defined and used in calculations (initiations of vector can be done with MACROS, constants or parameters).
* "#" as a first char in a line is considered a comment (the line will be removed before compile).
* The lib file will be parsed through MSI allowing macro expansion, "include" and "subsitute" commands. For more info check [best practice](../best_practice) and msi documentation/help.
* The lib file will be parsed through MSI allowing macro expansion, "include" and "substitute" commands. For more info check [best practice](../best_practice) and msi documentation/help.

### can be used in functions
1. The parameters
Expand Down Expand Up @@ -105,8 +105,8 @@ function testm2m() {
```

### debugging
Unfortunately debugging of function libs is not as easy as normal PLC:s since exprtk returns less infomation at compile failure.
Unfortunately debugging of function libs is not as easy as normal PLC:s since exprtk returns less information at compile failure.

{{% notice tip %}}
In order to troubleshoot, load the code as a normal PLC instead. This way you will get more diagnostics. Also remember, ecmc varaibles cannot be accessed in plc libs.
In order to troubleshoot, load the code as a normal PLC instead. This way you will get more diagnostics. Also remember, ecmc variables cannot be accessed in plc libs.
{{% /notice %}}
Loading

0 comments on commit a4923f2

Please sign in to comment.