# Hysteresis
Hysteresis
V
O
# 入力
| ID | 略称 | 名前 | 型 | デフォルト | 説明 |
|---|---|---|---|---|---|
value | V | value | NUMBER | 0 |
# 出力
| ID | 略称 | 名前 | 型 | デフォルト | 説明 |
|---|---|---|---|---|---|
output | O | output | BOOLEAN | false |
# 設定
| ID | 名前 | 型 | デフォルト | 単位 | 説明 |
|---|---|---|---|---|---|
mode | mode | ENUM | 0 | 詳細: 値: Midpoint + Hysteresis, Threshold (On/Off) | |
midpoint | midpoint | NUMBER | 50.0 | 詳細: 表示条件 mode = Midpoint + Hysteresis | |
hysteresis | hysteresis | NUMBER | 5.0 | 詳細: 表示条件 mode = Midpoint + Hysteresis> 0 | |
value_on | value_on | NUMBER | 55.0 | 詳細: 表示条件 mode = Threshold (On/Off)neq value_off | |
value_off | value_off | NUMBER | 45.0 | 詳細: 表示条件 mode = Threshold (On/Off)neq value_on |
# ソースコード
Volang ソースを表示
value = input::get("value")
output = output::get("output")
mode = config::get("mode") // 0=midpoint+hysteresis, 1=threshold
new_output = false
if (mode == 0) { // Midpoint + Hysteresis
midpoint = config::get("midpoint")
hysteresis = config::get("hysteresis")
threshold_on = midpoint + hysteresis
threshold_off = midpoint - hysteresis
if (value >= threshold_on) {
new_output = true
} else if (value <= threshold_off) {
new_output = false
} else {
// In hysteresis range, maintain current state
new_output = output
}
} else if (mode == 1) { // Threshold (On/Off)
value_on = config::get("value_on")
value_off = config::get("value_off")
if (value_on > value_off) {
// Standard hysteresis: on when high, off when low
if (value >= value_on) {
new_output = true
} else if (value <= value_off) {
new_output = false
} else {
// In hysteresis range, maintain current state
new_output = output
}
} else {
// Inverted hysteresis: on when low, off when high (value_off > value_on)
if (value <= value_on) {
new_output = true
} else if (value >= value_off) {
new_output = false
} else {
// In hysteresis range, maintain current state
new_output = output
}
}
}
output::set("output", new_output)
