select filter in config file
This commit is contained in:
parent
0ffeb62954
commit
321f2e0e53
@ -3,13 +3,19 @@
|
|||||||
port = 9090 # web port
|
port = 9090 # web port
|
||||||
debug = true # enable to use simulated PCB for development
|
debug = true # enable to use simulated PCB for development
|
||||||
|
|
||||||
|
# all DB settings are individual to each DB
|
||||||
[DB]
|
[DB]
|
||||||
type = "sqlite3"
|
type = "sqlite3"
|
||||||
path = "test.db"
|
path = "test.db"
|
||||||
freq = 60
|
freq = 60
|
||||||
|
|
||||||
|
# Configure channel 1
|
||||||
|
# type = 'U' => UV, else use other letters for resp type
|
||||||
|
# filter.samples => sample buffer size
|
||||||
|
# filter.type => filtering function to use [0-3; 0 default]
|
||||||
|
|
||||||
[Channel_1]
|
[Channel_1]
|
||||||
type = 'U'
|
type = 'U'
|
||||||
filter.samples = 100
|
filter.samples = 100
|
||||||
filter.type = 1
|
filter.type = 1
|
||||||
|
|
||||||
|
@ -76,6 +76,7 @@ func Load() (config.Config, error) {
|
|||||||
v.SetDefault(head+".unit", "UV")
|
v.SetDefault(head+".unit", "UV")
|
||||||
// filter settings
|
// filter settings
|
||||||
v.SetDefault(head+".filter.samples", 50)
|
v.SetDefault(head+".filter.samples", 50)
|
||||||
|
v.SetDefault(head+".filter.type", 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 1; i < 8; i++ {
|
for i := 1; i < 8; i++ {
|
||||||
|
@ -50,11 +50,9 @@ func startCacheService(t *TH7Adapter) {
|
|||||||
time.Sleep(DurWaitBetweenChannel)
|
time.Sleep(DurWaitBetweenChannel)
|
||||||
}
|
}
|
||||||
|
|
||||||
// do alpha~beta on each channel,
|
// apply filter to each set of samples. First run will be noisy.
|
||||||
// putting the value in
|
|
||||||
// TODO: in config have different types.
|
|
||||||
for i := range samples {
|
for i := range samples {
|
||||||
data[i].Value = filter.AlphaBetaFilter(samples[i], data[i].Value)
|
data[i].Value = filter.FilterByType(t.cfg.Channels[i].Filter.Type, samples[i], data[i].Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// read pcb temp and apply CJC
|
// read pcb temp and apply CJC
|
||||||
|
@ -1,6 +1,21 @@
|
|||||||
package filter
|
package filter
|
||||||
|
|
||||||
func AlphaBetaFilter(arr []float64, init float64) float64 {
|
func FilterByType(t int, arr []float64, init float64) float64 {
|
||||||
|
switch t {
|
||||||
|
case 0:
|
||||||
|
return AlphaBeta(arr, init)
|
||||||
|
case 1:
|
||||||
|
return Lag_1(arr, init)
|
||||||
|
case 2:
|
||||||
|
return Lag_2(arr, init)
|
||||||
|
case 3:
|
||||||
|
return Lag_3(arr, init)
|
||||||
|
}
|
||||||
|
|
||||||
|
return AlphaBeta(arr, init)
|
||||||
|
}
|
||||||
|
|
||||||
|
func AlphaBeta(arr []float64, init float64) float64 {
|
||||||
|
|
||||||
value := init
|
value := init
|
||||||
for i := range arr {
|
for i := range arr {
|
||||||
|
Loading…
Reference in New Issue
Block a user