
module main
{
    type state_t = enum { HEATING, COOLING };

    var state : state_t;
    var temp : real; // input temperature
    var heatOn, heatOff : boolean; // outputs

    init {
        state = COOLING;
        heatOn = false;
        heatOff = false;
    }

    next {
        if (state == HEATING) {
            if (temp <= 20) {
                state' = COOLING;
                heatOn = false;
                heatOff = true;
            } else if (temp >= 22) {
                state' = HEATING;
                heatOn = false;
                heatOff = false;
            }
        } else { // state == COOLING
            if (temp >= 20) {
                state' = HEATING;
                heatOn = true;
                heatOff = false;
            } else if (temp <= 18) {
                state' = COOLING;
                heatOn = false;
                heatOff = false;
            }
        }
    }
}
