module thermostat {
    type state_t = enum { HEATING, COOLING };
    var state : state_t;
    input temp : real;

    output heatOn : boolean;
    output heatOff : boolean;

    init {
        state = HEATING;
    }

    next {
        if (state == HEATING && temp >= 22.0) {
            state' = COOLING;
            heatOn = false;
            heatOff = true;
        } else if (state == COOLING && temp <= 18.0) {
            state' = HEATING;
            heatOn = true;
            heatOff = false;
        } else {
            heatOn = false;
            heatOff = false;
        }
    }
}
