Tests: Add time emulation feature for tests with BEREMIZ_TEST_CYCLES CFLAG.
Adding BEREMIZ_TEST_CYCLES=1000 in a project's CFLAGS will:
- run 1000 cycles with no pause
- emulate time flowing normaly for PLC code
- exit PLC thread
This allows:
- testing standard library blocks that deal with time without having to wait
- unit testing and code coverage with POUs that uses time
// widget_back.ysl2
widget_desc("Back") {
longdesc
||
Back widget brings focus back to previous page in history when clicked.
||
shortdesc > Jump to previous page
}
widget_class("Back")
||
on_click(evt) {
if(jump_history.length > 1){
let page_name, index;
do {
jump_history.pop(); // forget current page
if(jump_history.length == 0) return;
[page_name, index] = jump_history[jump_history.length-1];
} while(page_name == "ScreenSaver") // never go back to ScreenSaver
switch_page(page_name, index);
}
}
init() {
this.element.onclick = this.on_click.bind(this);
}
||