{ descr: "Numeric HMI Controller", vars: { params: { optimal_temp: { descr: "Optimal External Temperature", val: 30, unit: "C", }, temp_hysteresis: { descr: "External Temperature Hysteresis", val: 5, unit: "C", }, hot_tick_max: { descr: "Maximum allowed time hot", val: 15000, unit: "ms", }, }, input: { switch: { type: "uint64_t", ui_type: "bool", descr: "Limit Switch", val: false, }, ext_t: { type: "uint32_t", descr: "External Temperature", unit: "C", decimals: 2, val:1000, } }, private: { entropy: { type: "uint64_t", descr: "Internal Entropy", decimals: 4, val:123, }, }, output: { relay: { type: "uint64_t", ui_type: "bool", descr: "Relay Control", val: false, } }, timers: { run_time: { descr: "Counts seconds from start", }, hot_tick: { descr: "Counts seconds we are hot", } }, }, funcs: { is_hot: "ext_t > optimal_temp + temp_hysteresis", is_cold: "ext_t < optimal_temp - temp_hysteresis", hot_sum: "ext_t * hot_tick + 10", is_hot_too_long: "hot_tick > hot_tick_max", buttoni: 'BUTTON__duration > 10' }, transitions: { start: { sources : ["INIT"], when: true, color: "pink", target: "IDLE", set: { entropy : 100, relay : 0, hot_tick: 0, switch: 1, }, }, "got-hot": { sources : ["IDLE", "COLD"], when: "is_hot", target: "HOT", color: "pink", args: { reason: "I AM SUPERHOT!"}, set: { relay: 1, } }, "got-hot-too-long": { sources : ["HOT"], when: "is_hot_too_long", color: "red", target: "ERROR", set: { relay: 0, } }, gotCold: { sources : ["IDLE", "HOT"], when: "is_cold", color: "lightblue", target: "COLD", args: { reason: "I AM COOL!"}, set: { relay: 0, } }, "button-pressed-init": { sources : ["*"], color: "lightcyan", when: "buttoni", target: "INIT", set: { relay: 0, BUTTON__duration: 0, } } }, events: { BUTTON: { descr: "Button is pressed", color: "lightblue", id: 0xf0, args: { duration: { type: "uint32_t", descr: "Duration of button pressure", unit: "ms", }, shift: { type: "bool", descr: "Shift Key", }, // name: { // type: "string", // max_len: 6, // descr: "Button Name", // } }, }, BUTTON2: { descr: "Button two is pressed", id: 0xf1, color: "lightgreen", args: { duration: { type: "uint32_t", descr: "Duration of button pressure", unit: "ms", }, // name: { // type: "string", // max_len: 18, // descr: "Button Name", // } }, }, }, states: { INIT: { descr: "Initial State", color: "gray", on_exit: { run_time: true, } }, IDLE: { descr: "Idle State, not cold nor hot yet", color: "green", }, HOT: { descr: "Hotter state", tick: 10, color: "magenta", args: { reason: { type: "string", descr: "Reason for being hot", } }, on_entry: { hot_tick: true, }, on_exit: { hot_tick: false, }, }, COLD: { descr: "Colder state", tick: 100, color: "lightblue", args: { reason: { type: "string", descr: "Reason for being cool", } } }, ERROR: { descr: "ERROR", color: "red", }, }, }