/* A first attempt at a traffic intersection verification */ #define NumberOfLanes 4 /*number of sensors and lights*/ #define NumberOfLightSets 2 /*Number of Light sets*/ mtype = {untripped,tripped}; chan interruptChannel[NumberOfLanes] = [1] of {mtype}; chan reportStatus[NumberOfLightSets] = [1] of {mtype,byte}; chan setLights[NumberOfLightSets]=[1] of {byte}; proctype sensor(chan from; byte s) { byte name = s; mtype ss = untripped; byte n =0; do ::if ::ss==untripped->ss=tripped;from!ss; /*printf("first\n");*/ ::ss==tripped->if ::n==10->ss=untripped;n=0; /*printf("second %d %d\n",s,n);*/ ::else->n=n+1; /*printf("third %d %d\n",s,n);*/ fi fi od } proctype trafficLight(chan to; byte s,chan out,chan in) { byte name = s; byte color = 0; mtype ss = untripped; do ::to?ss; out!ss;out!s;printf("tripped %d \n",name); od } proctype lightSet(chan in;chan out;byte one;byte two) { mtype ss; byte n; run trafficLight(interruptChannel[one],one,out,in); run trafficLight(interruptChannel[two],two,out,in); do ::out?ss;out?n;printf("lightSet %d %d\n"); od } proctype intersection(){ run sensor(interruptChannel[0],0); run sensor(interruptChannel[1],1); run sensor(interruptChannel[2],2); run sensor(interruptChannel[3],3); run lightSet(setLights[0],reportStatus[0],0,1); run lightSet(setLights[1],reportStatus[1],2,3); do ::skip->printf("in intersection\n"); od } init{ run intersection(); }