-
Notifications
You must be signed in to change notification settings - Fork 1
THC Version 2
The THC version 2 contains several changes compared to the version 1. These changes require some adaptations of the user configuration scripts. This document summarizes both the relevant internal changes of THC and the required user configuration script adaptations.
The internal changes are :
Description | |
---|---|
THC namespace | All THC core functions and variables are now placed inside the namespace ::thc. |
Module namespaces | All modules are placed inside their namespace ::thc::<ModuleName>. |
THC API extensions | New functions are available to configure THC and to read the device states. |
The following section provides guidelines to update user configuration scripts from THC version 1 to THC version 2.
THC 2 provides a dedicated function to define the heartbeat of the system.
set HeartBeatMS 1000
thc::DefineHeartBeat 1000 MS
Any THC core functions are now placed in the namespace ::thc.
DefineLog 1 "/var/thc/thc_server.log" 1
DefineDevice LightLiving,state -get {thc_zWay "SwitchBinary 8.1"} \
-set {thc_zWay "SwitchBinary 8.1"}
}
thc::DefineLog 1 "/var/thc/thc_server.log" 1
thc::DefineDevice LightLiving,state -get {thc_zWay "SwitchBinary 8.1"} \
-set {thc_zWay "SwitchBinary 8.1"}
}
Also any THC core variables that were previously placed in the global namespace are now accessible via the ::thc namespace (example for variables Event and State).
DefineJob -tag Surv -description "Alarm detection" \
-condition {$Event(Alarm,state)==1} {
Set {Sirene,state LightLiving,state} 1
}
DefineJob -tag RdmLight -time +5s -repeat 1m -description "Random light activity" \
-condition {$State(Alarm,state)!=1} {
thc_RandomLight::Control
Log "Changed light, time=$Time"
}
thc::DefineJob -tag Surv -description "Alarm detection" \
-condition {$Event(Alarm,state)==1} {
thc::Set {Sirene,state LightLiving,state} 1
}
thc::DefineJob -tag RdmLight -time +5s -repeat 1m -description "Random light activity" \
-condition {$thc::State(Alarm,state)!=1} {
thc::RandomLight::Control
Log "Changed light, time=$thc::Time"
}
While THC version 1 placed a module into the namespace ::thc_<Module>, THC version 2 places it into namespace ::thc::Module.
thc_Web::Start 8086
thc_zWay::Init "http://localhost:8083"
thc::Web::Start 8086
thc::zWay::Init "http://localhost:8083"
The module thc_RandomLight uses a new configuration function to set the geographical location and time zone.
namespace eval thc_RandomLight {
set Longitude 6.8250
set Latitude 47.1013
set Zone "auto"
Define LightLiv,state -time {7.2 $SunriseT-0.3 $SunsetT+0.0 21.5} -min_interval 0.30 -probability_on 0.2
...
namespace eval thc::RandomLight {
Configure -longitude 6.8250 -latitude 47.1013 -zone "auto"
Define LightLiv,state -time {7.2 $SunriseT-0.3 $SunsetT+0.0 21.5} -min_interval 0.30 -probability_on 0.2
...
THC, Tight Home Control - See THC index register - THC repository on github.com/Drolla/thc