PrintLib provides print functions that can be used in simulations with OMRON's Sysmac Studio. When print functions are executed in a program running on the simulator, the string is output to the specified file in the virtual SD card. You can also monitor the output in real time by tailing the specified file with PowerShell's Get-Content cmdlet.
If you run the sample program and monitor it in the PowerShell terminal, you will see the following.
You can monitor the print output by running the following in the PowerShell terminal.
Get-Content -Path C:\OMRON\Data\SimulatorData\CARD\Memory001\dev\print -wait -tail 0 -Encoding UTF8
The media file can be created and cleared by executing the following.
New-Item -Path C:\OMRON\Data\SimulatorData\CARD\Memory001\dev -Name print -ItemType "File" -Force
The following environment is required to use this project
Sysmac Studio | I always recommend the latest version. |
PowerShell | I always recommend the latest LTS version. |
This project was built in the following environment.
Sysmac Studio | Ver.1.62 |
Target CPU | NX1-9000 Ver.1.50 |
PowwerShell | v7.5.0 |
The Target CPU can be changed by changing the CPU in PrintLib.smc2 and creating a library. No POUs with restrictions are used.
The print function is used in the following steps.
- Reference related libraries in your project
Reference lib/LogStreamLib.slr and PrintLib.slr in your project. - Registering a singleton variable as a global variable
RegistergPrintSingleton: stfreakjp\develop\PrintContext
. - Register the output program to the task
RegisterPOU/Program/DefaultPrintRunner
to the task.
PrintLib.smc2 is a project for developing PrintLib. This project will build PrintLib.slr.
PrintLib.slr is a library for using the print function. To use it, you must also reference the dependent libraries under lib/.
This is an example of using PrintLib. It can be run as is because it bundles related libraries.