// Temperature Control Application // Model obtained from the translation of an OASIS program into RT-BIP model TempControl header {# typedef char* String; typedef int type_temperature; //typedef enum {posDown = 0, posRest = 1, posReady = 2} type_pos; //typedef enum {cmdUp = 0, cmdDown = 1, cmdShut = 2} type_command; typedef int type_pos; typedef int type_command; // #define REACTOR_RISE 1 /* degrees/second */ // #define REACTOR_COOL 2 // #define ROD_REST_PERIOD 3600 static char *print_position (int pos) { switch (pos) { case 0: return "down"; case 1: return "rest"; case 2: return "ready"; default: return "ERROR!"; } } static char *print_command (int cmd) { switch (cmd) { case 0: return "up"; case 1: return "down"; case 2: return "Shutdown!"; default: return "ERROR!"; } } #} port type ePort_temperature(type_temperature x) port type ePort_pos1(type_pos x) port type ePort_pos2(type_pos x) port type ePort_command1(type_command x) port type ePort_command2(type_command x) port type iPort connector type RDV_temperature(ePort_temperature p1, ePort_temperature p2) define [p1 p2] on p1 p2 down {p1.x=p2.x;} end connector type RDV_pos1(ePort_pos1 p1, ePort_pos1 p2) define [p1 p2] on p1 p2 down {p1.x=p2.x;} end connector type RDV_pos2(ePort_pos2 p1, ePort_pos2 p2) define [p1 p2] on p1 p2 down {p1.x=p2.x;} end connector type RDV_command1(ePort_command1 p1, ePort_command1 p2) define [p1 p2] on p1 p2 down {p1.x=p2.x;} end connector type RDV_command2(ePort_command2 p1, ePort_command2 p2) define [p1 p2] on p1 p2 down {p1.x=p2.x;} end atomic type Reactor data type_temperature tmpw_temperature = 100 export port ePort_temperature write_temperature(tmpw_temperature)=write_temperature data type_pos tmpr_pos1 export port ePort_pos1 read_pos1(tmpr_pos1)=read_pos1 data type_pos tmpr_pos2 export port ePort_pos2 read_pos2(tmpr_pos2)=read_pos2 port Port start port Port compute port Port advance clock x unit 1 microsecond const data int period= 50000 const data int phase= 0 const data int initTime = 500000 const data int S =1 const data int R = (initTime-phase)%period place S1, S2, S3, S4, S5, S6 initial to S1 on write_temperature from S1 to S3 when x in (S*period - R,S*period-R) eager reset x on read_pos1 from S3 to S4 when x in [0,0] eager on read_pos2 from S4 to S5 when x in [0,0] eager on compute from S5 to S6 when x in [0, period] delayable do { if (tmpr_pos1 == 0 || tmpr_pos2 == 0) { tmpw_temperature = tmpw_temperature - 2; } else { tmpw_temperature = tmpw_temperature + 1; } } on write_temperature from S6 to S3 when x in [period,period] eager reset x end atomic type Rod1 data type_pos tmpw_pos1 = 2 export port ePort_pos1 write_pos1(tmpw_pos1)=write_pos1 data type_command tmpr_command1 export port ePort_command1 read_command1(tmpr_command1)=read_command1 port Port start port Port compute_ready port Port compute_down port Port compute_rest port Port advance clock x unit 1 microsecond const data int period= 50000 const data int phase= 0 const data int initTime = 500000 const data int S =1 const data int R = (initTime-phase)%period place S1, S2, S3, S4, S5, rest initial to S1 on write_pos1 from S1 to S3 when x in (S*period - R,S*period-R) eager reset x on read_command1 from S3 to S4 when x in [0, 0] eager on compute_ready from S4 to S5 provided tmpw_pos1 == 2 when x in [0, period] delayable do { if (tmpr_command1 == 1) { tmpw_pos1 = 0; } } on compute_down from S4 to S5 provided tmpw_pos1 == 0 when x in [0, period] delayable do { if (tmpr_command1 == 0) { tmpw_pos1 = 1; } } on write_pos1 from S5 to S3 when x in [period, period] eager reset x on compute_rest from S4 to rest provided tmpw_pos1 == 1 when x in [0, period*3600] delayable do { tmpw_pos1 = 2; } on write_pos1 from rest to S3 when x in [period*3600, period*3600] eager reset x end atomic type Rod2 data type_pos tmpw_pos2 = 2 export port ePort_pos2 write_pos2(tmpw_pos2)=write_pos2 data type_command tmpr_command2 export port ePort_command2 read_command2(tmpr_command2)=read_command2 port Port start port Port compute_ready port Port compute_down port Port compute_rest port Port advance clock x unit 1 microsecond const data int period= 50000 const data int phase= 0 const data int initTime = 500000 const data int S =1 const data int R = (initTime-phase)%period place S1, S2, S3, S4, S5, rest initial to S1 on write_pos2 from S1 to S3 when x in (S*period - R,S*period-R) eager reset x on read_command2 from S3 to S4 when x in [0, 0] eager on compute_ready from S4 to S5 provided tmpw_pos2 == 2 when x in [0, period] delayable do { if (tmpr_command2 == 1) { tmpw_pos2 = 0; } } on compute_down from S4 to S5 provided tmpw_pos2 == 0 when x in [0, period] delayable do { if (tmpr_command2 == 0) { tmpw_pos2 = 1; } } on write_pos2 from S5 to S3 when x in [period, period] eager reset x on compute_rest from S4 to rest provided tmpw_pos2 == 1 when x in [0, period*3600] delayable do { tmpw_pos2 = 2; } on write_pos2 from rest to S3 when x in [period*3600, period*3600] eager reset x end atomic type Controller data type_command tmpw_command1 = 0 export port ePort_command1 write_command1(tmpw_command1)=write_command1 data type_command tmpw_command2 = 0 export port ePort_command2 write_command2(tmpw_command2)=write_command2 data type_temperature tmpr_temperature export port ePort_temperature read_temperature(tmpr_temperature)=read_temperature data type_pos tmpr_pos1 export port ePort_pos1 read_pos1(tmpr_pos1)=read_pos1 data type_pos tmpr_pos2 export port ePort_pos2 read_pos2(tmpr_pos2)=read_pos2 port Port start port Port compute_low port Port compute_high port Port compute_shutdown port Port advance clock x unit 1 microsecond const data int period= 50000 const data int phase= 0 const data int initTime = 500000 const data int S =1 const data int R = (initTime-phase)%period place S1, S2, S3, S4, S5, S6, low, high, high_write1, high_write2, high_latency, shutdown1, shutdown2 initial to S1 on write_command1 from S1 to S2 when x in (S*period - R,S*period-R) eager reset x on write_command2 from S2 to S3 when x in [0, 0] eager on read_temperature from S3 to S4 when x in [0, 0] eager on read_pos1 from S4 to S5 when x in [0, 0] eager on read_pos2 from S5 to S6 when x in [0, 0] eager on compute_low from S6 to low provided tmpr_temperature <= (100 + 2*2) when x in [0, period] delayable do { tmpw_command1 = 0; tmpw_command2 = 0; } on write_command1 from low to S3 provided tmpr_pos1 == 0 when x in [period, period] eager reset x on write_command2 from low to S3 provided tmpr_pos2 == 0 when x in [period, period] eager reset x on advance from low to S3 provided tmpr_pos1 != 0 && tmpr_pos2 != 0 when x in [period, period] eager reset x on compute_high from S6 to high provided (tmpr_temperature >= 1000 - 2) && (tmpr_pos1 == 2 || tmpr_pos2 == 2) when x in [0, period] delayable do { if (tmpr_pos1 == 2) { tmpw_command1 = 1; } else if (tmpr_pos2 == 2) { tmpw_command2 = 1; } } on write_command1 from high to high_latency provided tmpr_pos1 == 2 when x in [period, period] eager reset x on write_command2 from high to high_latency provided tmpr_pos1 != 2 && tmpr_pos2 == 2 when x in [period, period] eager reset x on advance from high_latency to S3 when x in [3*period, 3*period] eager reset x on advance from S6 to S3 provided (tmpr_temperature > (100 + 2*2)) && (tmpr_temperature < 1000 - 2) when x in [period, period] eager reset x on compute_shutdown from S6 to shutdown1 provided (tmpr_temperature >= 1000 - 2) && tmpr_pos1 != 2 && tmpr_pos2 != 2 when x in [0, period] delayable do { tmpw_command1 = 2; tmpw_command2 = 2; } on write_command1 from shutdown1 to shutdown2 when x in [period, period] eager reset x on write_command2 from shutdown2 to shutdown1 when x in [0, 0] eager end atomic type Monitor data type_temperature tmpr_temperature export port ePort_temperature read_temperature(tmpr_temperature)=read_temperature data type_pos tmpr_pos1 export port ePort_pos1 read_pos1(tmpr_pos1)=read_pos1 data type_pos tmpr_pos2 export port ePort_pos2 read_pos2(tmpr_pos2)=read_pos2 data type_command tmpr_command1 export port ePort_command1 read_command1(tmpr_command1)=read_command1 data type_command tmpr_command2 export port ePort_command2 read_command2(tmpr_command2)=read_command2 port Port start port Port compute port Port advance clock x unit 1 microsecond const data int period= 50000 const data int phase= 0 const data int initTime = 500000 const data int S =2 const data int R = (initTime-phase)%period const data int counter = 0 const data int first = 1 place S1, S2, S3, S4, S5, S6, S7, S8 initial to S1 on start from S1 to S2 when x in (S*period - R,S*period-R) eager reset x on read_pos1 from S2 to S3 when x in [0, 0] eager on read_pos2 from S3 to S4 when x in [0, 0] eager on read_command1 from S4 to S5 when x in [0, 0] eager on read_command2 from S5 to S6 when x in [0, 0] eager on read_temperature from S6 to S7 when x in [0, 0] eager on compute from S7 to S8 when x in [0, period] delayable do { if (first) { counter++; printf ("# STEP Reactor/Temp Rod1/Pos Rod2/pos Control/cmd1 Control/cmd2\n"); first = 0; } printf ("%6d %12d %8s %8s %12s %12s\n", counter, tmpr_temperature, print_position(tmpr_pos1), print_position(tmpr_pos2), print_command(tmpr_command1), print_command(tmpr_command2)); counter++; } on advance from S8 to S2 when x in [period,period] eager reset x end atomic type temperature clock x unit 1 microsecond const data int period= 50000 const data int phase= 0 const data int initTime = 500000 const data int S =1 const data int R = (initTime-phase)%period data type_temperature tmpw data type_temperature tmpr export port ePort_temperature write(tmpw)=write export port ePort_temperature read(tmpr)=read port Port start place S1, S2 initial to S1 on start from S1 to S2 when x in (S*period-R, S*period-R) eager on write from S2 to S2 do {tmpr=tmpw;} on read from S2 to S2 end atomic type pos1 clock x unit 1 microsecond const data int period= 50000 const data int phase= 0 const data int initTime = 500000 const data int S =1 const data int R = (initTime-phase)%period data type_pos tmpw data type_pos tmpr export port ePort_pos1 write(tmpw)=write export port ePort_pos1 read(tmpr)=read port Port start place S1, S2 initial to S1 on start from S1 to S2 when x in (S*period-R, S*period-R) eager on write from S2 to S2 do {tmpr=tmpw;} on read from S2 to S2 end atomic type pos2 clock x unit 1 microsecond const data int period= 50000 const data int phase= 0 const data int initTime = 500000 const data int S =1 const data int R = (initTime-phase)%period data type_pos tmpw data type_pos tmpr export port ePort_pos2 write(tmpw)=write export port ePort_pos2 read(tmpr)=read port Port start place S1, S2 initial to S1 on start from S1 to S2 when x in (S*period-R, S*period-R) eager on write from S2 to S2 do {tmpr=tmpw;} on read from S2 to S2 end atomic type command1 clock x unit 1 microsecond const data int period= 50000 const data int phase= 0 const data int initTime = 500000 const data int S =1 const data int R = (initTime-phase)%period data type_command tmpw data type_command tmpr export port ePort_command1 write(tmpw)=write export port ePort_command1 read(tmpr)=read port Port start place S1, S2 initial to S1 on start from S1 to S2 when x in (S*period-R, S*period-R) eager on write from S2 to S2 do {tmpr=tmpw;} on read from S2 to S2 end atomic type command2 clock x unit 1 microsecond const data int period= 50000 const data int phase= 0 const data int initTime = 500000 const data int S =1 const data int R = (initTime-phase)%period data type_command tmpw data type_command tmpr export port ePort_command2 write(tmpw)=write export port ePort_command2 read(tmpr)=read port Port start place S1, S2 initial to S1 on start from S1 to S2 when x in (S*period-R, S*period-R) eager on write from S2 to S2 do {tmpr=tmpw;} on read from S2 to S2 end compound type Top component Reactor Reactor_instance component Rod1 Rod1_instance component Rod2 Rod2_instance component Controller Controller_instance component Monitor Monitor_instance component temperature temperature_instance component pos1 pos1_instance component pos2 pos2_instance component command1 command1_instance component command2 command2_instance connector RDV_temperature write_Reactor_temperature (temperature_instance.write,Reactor_instance.write_temperature) connector RDV_pos1 write_Rod1_pos1 (pos1_instance.write,Rod1_instance.write_pos1) connector RDV_pos2 write_Rod2_pos2 (pos2_instance.write,Rod2_instance.write_pos2) connector RDV_command1 write_Controller_command1 (command1_instance.write,Controller_instance.write_command1) connector RDV_command2 write_Controller_command2 (command2_instance.write,Controller_instance.write_command2) connector RDV_pos1 read_Reactor_pos1(Reactor_instance.read_pos1,pos1_instance.read) connector RDV_pos2 read_Reactor_pos2(Reactor_instance.read_pos2,pos2_instance.read) connector RDV_command1 read_Rod1_command1(Rod1_instance.read_command1,command1_instance.read) connector RDV_command2 read_Rod2_command2(Rod2_instance.read_command2,command2_instance.read) connector RDV_temperature read_Controller_temperature(Controller_instance.read_temperature,temperature_instance.read) connector RDV_pos1 read_Controller_pos1(Controller_instance.read_pos1,pos1_instance.read) connector RDV_pos2 read_Controller_pos2(Controller_instance.read_pos2,pos2_instance.read) connector RDV_temperature read_Monitor_temperature(Monitor_instance.read_temperature,temperature_instance.read) connector RDV_pos1 read_Monitor_pos1(Monitor_instance.read_pos1,pos1_instance.read) connector RDV_pos2 read_Monitor_pos2(Monitor_instance.read_pos2,pos2_instance.read) connector RDV_command1 read_Monitor_command1(Monitor_instance.read_command1,command1_instance.read) connector RDV_command2 read_Monitor_command2(Monitor_instance.read_command2,command2_instance.read) priority prio_Reactor_pos1 read_Reactor_pos1 < write_Rod1_pos1 priority prio_Controller_pos1 read_Controller_pos1 < write_Rod1_pos1 priority prio_Monitor_pos1 read_Monitor_pos1 < write_Rod1_pos1 priority prio_Reactor_pos2 read_Reactor_pos2 < write_Rod2_pos2 priority prio_Controller_pos2 read_Controller_pos2 < write_Rod2_pos2 priority prio_Monitor_pos2 read_Monitor_pos2 < write_Rod2_pos2 priority prio_Monitor_temperature read_Monitor_temperature < write_Reactor_temperature priority prio_Controller_temperature read_Controller_temperature < write_Reactor_temperature priority prio_Rod1_command1 read_Rod1_command1 < write_Controller_command1 priority prio_Monitor_command1 read_Monitor_command1 < write_Controller_command1 priority prio_Rod2_command2 read_Rod2_command2 < write_Controller_command2 priority prio_Monitor_command2 read_Monitor_command2 < write_Controller_command2 end component Top top end