CJC
This commit is contained in:
parent
cf07519baa
commit
376727840c
12
config.toml
12
config.toml
@ -1,21 +1,13 @@
|
|||||||
[TH7]
|
[TH7]
|
||||||
port = 8080
|
port = 8080
|
||||||
logfreq = 60
|
logfreq = 60
|
||||||
debug = true
|
|
||||||
|
|
||||||
[DB]
|
[DB]
|
||||||
type = "sqlite3"
|
type = "sqlite3"
|
||||||
path = "test.db"
|
path = "test.db"
|
||||||
|
|
||||||
[Channel_1]
|
[Channel_2]
|
||||||
type = 'k'
|
type = 'K'
|
||||||
unit = 'C'
|
unit = 'C'
|
||||||
gain = 106.8
|
gain = 106.8
|
||||||
offset = 2.4
|
offset = 2.4
|
||||||
|
|
||||||
[Channel_5]
|
|
||||||
type = 'N'
|
|
||||||
unit = 'F'
|
|
||||||
|
|
||||||
[Channel_6]
|
|
||||||
type = 'S'
|
|
@ -3,6 +3,8 @@ package th7
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
temp_data "th7/data/temperature"
|
||||||
|
"th7/temperature"
|
||||||
"th7/thermocouple"
|
"th7/thermocouple"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -79,30 +81,48 @@ func startCacheService(t *TH7Adapter) {
|
|||||||
for k := range t.cfg.Channels {
|
for k := range t.cfg.Channels {
|
||||||
|
|
||||||
tc := t.cfg.Channels[k].Thermo
|
tc := t.cfg.Channels[k].Thermo
|
||||||
|
|
||||||
|
// if we can apply CJC with this configuration ...
|
||||||
if thermocouple.WithinTemperatureRange(tc, pcb_temperature) {
|
if thermocouple.WithinTemperatureRange(tc, pcb_temperature) {
|
||||||
// if we can apply CJC with this configuration ...
|
|
||||||
cjc_uv, err := thermocouple.UV(tc, pcb_temperature)
|
cjc_uv, err := thermocouple.UV(tc, pcb_temperature)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error doing CJC", err)
|
log.Println("Error doing CJC", err)
|
||||||
} else {
|
cjc_uv = 0.0
|
||||||
|
}
|
||||||
data[k].Value -= cjc_uv
|
|
||||||
data[k].Unit = t.cfg.Channels[k].Unit
|
data[k].Value -= cjc_uv
|
||||||
|
data[k].Unit = t.cfg.Channels[k].Unit
|
||||||
new_value_c, err := thermocouple.C(tc, data[k].Value)
|
data[k].Id = t.cfg.Channels[k].Id
|
||||||
if err != nil {
|
|
||||||
log.Println("Error converting UV to C", t.cfg.Channels[k], data[k].Value)
|
}
|
||||||
}
|
// CJC can not be applied
|
||||||
|
// board temp out of range for specified thermocouple type
|
||||||
//TODO: different temp units
|
// perhaps just subtract board temperature? dont know
|
||||||
data[k].Value = new_value_c
|
//fmt.Println("No valid CJC for Channel", t.cfg.Channels[k].Id)
|
||||||
|
|
||||||
|
// if the temperature unit is "None", it is probably for UV only.
|
||||||
|
// so do not convert it to a value using t/c polys
|
||||||
|
if data[k].Unit != temp_data.None {
|
||||||
|
new_value_c, err := thermocouple.C(tc, data[k].Value)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error converting UV to C", t.cfg.Channels[k].Id, data[k].Value)
|
||||||
|
new_value_c = data[k].Value
|
||||||
|
}
|
||||||
|
|
||||||
|
data[k].Value = new_value_c
|
||||||
|
|
||||||
|
// It is celsius by default
|
||||||
|
switch data[k].Unit {
|
||||||
|
|
||||||
|
case temp_data.F:
|
||||||
|
data[k].Value = temperature.F(temp_data.C, data[k].Value)
|
||||||
|
|
||||||
|
case temp_data.K:
|
||||||
|
data[k].Value = temperature.K(temp_data.C, data[k].Value)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
// CJC can not be applied
|
|
||||||
// board temp out of range for specified thermocouple type
|
|
||||||
// perhaps just subtract board temperature? dont know
|
|
||||||
fmt.Println("No valid CJC for Channel", t.cfg.Channels[k].Id)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user