et-go 20240919重建
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

41 lines
1015 B

package algorithm
import (
"gitea.anxinyun.cn/container/common_models"
"log"
)
// StrainCompensationByExternalTemperature
// y=x-k*(T-To)
func StrainCompensationByExternalTemperature(device common_models.SecureStationDevice, RawData map[string]any, RawsUnit map[string]string, temperature float64) (result map[string]any, unit map[string]string) {
var k float64
var x float64
var Tid int
var To float64
paramsMap := device.Params
if kObj, ok := paramsMap["k"]; ok {
k = kObj.(float64)
}
if xObj, ok := RawData["physicalvalue"]; ok {
x = xObj.(float64)
}
if TidObj, ok := paramsMap["Ti"]; ok {
Tid64 := TidObj.(float64)
Tid = int(Tid64)
}
if ToObj, ok := paramsMap["To"]; ok {
To = ToObj.(float64)
}
T := temperature
y := x - k*(T-To)
log.Printf("%v=%v-%v*(%v-%v),Tid=%d", y, x, k, To, temperature, Tid)
result = make(map[string]any)
unit = make(map[string]string)
//注意 y是中间变量 也是公式的最终输出
result["y"] = y
unit["y"] = "με"
return result, unit
}