09.12.2012 Views

Basic Characteristics RAPID

Basic Characteristics RAPID

Basic Characteristics RAPID

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.

<strong>Basic</strong> <strong>Characteristics</strong> <strong>RAPID</strong> Multitasking<br />

MODULE module1<br />

PERS BOOL startsync:=FALSE;<br />

PROC main()<br />

SetDO do1,1;<br />

.<br />

ENDPROC<br />

ENDMODULE<br />

TASK 1<br />

MODULE module2<br />

LOCAL VAR intnum isiint1;<br />

PROC main()<br />

CONNECT isiint1 WITH isi_trap;<br />

ISignalDI di1, 1, isiint1;<br />

WHILE TRUE DO<br />

WaitTime 200;<br />

ENDWHILE<br />

ENDPROC<br />

TRAP isi_trap<br />

.<br />

ENDTRAP<br />

ENDMODULE<br />

11.2 Intertask communication<br />

All types of data can be sent between two (or more) tasks with persistent variables.<br />

A persistent variable is global in all tasks. The persistent variable must be of the same<br />

type and size (array dimension) in all tasks that declared it. Otherwise a runtime error<br />

will occur.<br />

All declarations must specify an init value to the persistent variable, but only the first<br />

module loaded with the declaration will use it.<br />

Example<br />

TASK 0<br />

MODULE module1<br />

PERS BOOL startsync:=FALSE;<br />

PERS STRING stringtosend:=””;<br />

PROC main()<br />

<strong>RAPID</strong> Reference Manual 5-41

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

Saved successfully!

Ooh no, something went wrong!