This work was supported by the US National Science Foundation award NSF-CPS-1136099/1136104, the Swedish Knowledge Foundation (KK), The Center for Research on Embedded Systems (CERES), and ESPRC, grant EP/C01037X/1.