// controller for the bouncingball // macro timeOut = 0.001; macro K = -24254; macro epsilon = 0.01; module Controller(hybrid real position, hybrid real velocity, hybrid real force) { hybrid real t; t = 0; while(true) { //sample the plant // discrete logic of controller next(t) = 0; if (0 <= velocity and velocity <= epsilon and epsilon <= position) next(force) = K; else next(force) = 0; // to enable the plant to see the change flow {} until (true); // hold the actuator flow { drv(t) <- 1.0; } until (cont(t) >= timeOut); } }