th7/thermocouple/thermocouple.go

99 lines
1.7 KiB
Go
Raw Normal View History

2022-11-12 14:20:29 +00:00
package thermocouple
import (
"th7/data/thermocouple"
)
2022-12-05 12:40:07 +00:00
func WithinTemperatureRange(thermo thermocouple.Type, c float64) bool {
switch thermo {
case thermocouple.B:
return c >= B_MIN_C && c <= B_MAX_C
case thermocouple.E:
return c >= E_MIN_C && c <= E_MAX_C
case thermocouple.J:
return c >= J_MIN_C && c <= J_MAX_C
case thermocouple.K:
return c >= K_MIN_C && c <= K_MAX_C
case thermocouple.N:
return c >= N_MIN_C && c <= N_MAX_C
case thermocouple.R:
return c >= R_MIN_C && c <= R_MAX_C
case thermocouple.S:
return c >= S_MIN_C && c <= S_MAX_C
case thermocouple.T:
return c >= T_MIN_C && c <= T_MAX_C
}
// None type
return false
}
2022-11-12 14:20:29 +00:00
func C(thermo thermocouple.Type, uv float64) (float64, error) {
switch thermo {
case thermocouple.None:
return 0, thermocouple.ErrThermocoupleNone
case thermocouple.B:
return b_uv_to_c(uv)
case thermocouple.E:
return e_uv_to_c(uv)
case thermocouple.J:
return j_uv_to_c(uv)
case thermocouple.K:
return k_uv_to_c(uv)
case thermocouple.N:
return n_uv_to_c(uv)
case thermocouple.R:
return r_uv_to_c(uv)
case thermocouple.S:
return s_uv_to_c(uv)
case thermocouple.T:
return t_uv_to_c(uv)
}
return 0, thermocouple.ErrUnimplemented
}
func UV(thermo thermocouple.Type, c float64) (float64, error) {
switch thermo {
case thermocouple.None:
return 0, thermocouple.ErrThermocoupleNone
case thermocouple.B:
return b_c_to_uv(c)
case thermocouple.E:
return e_c_to_uv(c)
case thermocouple.J:
return j_c_to_uv(c)
case thermocouple.K:
return k_c_to_uv(c)
case thermocouple.N:
return n_c_to_uv(c)
case thermocouple.R:
return r_c_to_uv(c)
case thermocouple.S:
return s_c_to_uv(c)
case thermocouple.T:
return t_c_to_uv(c)
}
return 0, thermocouple.ErrUnimplemented
}