11.07.2015 Views

BCL Programmers Manual V2.00 (PDF) - Barix

BCL Programmers Manual V2.00 (PDF) - Barix

BCL Programmers Manual V2.00 (PDF) - Barix

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

6.5.4 Multiple branching depending on an integer valueMultiple branching depending on an integer value is possible with the following syntax:ON E {GOSUB | GOTO } L1,[L2,[L3,....]]If E equals 1, then GOSUB/GOTO to label L1 is executed.If E equals 2 and L2 is given, then GOSUB/GOTO to the label L2 is executed.If E equals 3 and L3 is given, then GOSUB/GOTO to the label L3 is executed.etc.If E is less than 1 or greater than the number of given labels, no action is taken.Note: Since it is possible to use complex expressions as E, jumping can take place forvarious values. For example, by shifting the value of integer variable V by 499 we can usemultiple branching to jump in the cases 500, 501, 502:ON (V-499) GOTO 6010,6020,60306.6 TimeSystem variable _DTS_ is inicialized during boot time and then incremented every second.On devices supporting an RTC (realtime clock chip) _DTS_ is initialized to the current timeread from the RTC (number of seconds since 1/1/1970), on other devices _DTS_ is inicializedto zero or set via NTP protocol._DTS_ can be used when programming time dependent programs.Any value can be assigned to _DTS_ using the following code sequence:_DTS_ =0DELAY 0_DTS_=valueIf RTC is supported by the device, it's value is updated as well.DELAY EDelays the execution of the program for E milliseconds (maximum possible delay is 65535ms).Code example:DELAY 500SYSLOG "DONE"waits half a second and then sends syslog message "DONE"Note: DELAY is ignored in ON-call subroutine during the ON-call event handling.6.7 Eve ntsA program can have a limited event-driven structure using the ON..GOSUB construct.6.7.1 TimersFour independent software timers (resolution in milliseconds) can be used to trigger the callof a subroutine. Timers must be set up using the TIMER statementTIMER E0, ESet the timer E0 to trigger every E milliseconds. The timer is reset with this statement so it willbe first triggered after E milliseconds.Valid timers are 1, 2, 3, 4.Code example: TIMER 1,100defines the timer to go off every 100 millisecondsA parameter of 0 disables the timer.<strong>Barix</strong> AG | 23/106

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!