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.
49 lines
1.2 KiB
49 lines
1.2 KiB
// Package adl400Api 电表接口
|
|
package adl400TtyApi
|
|
|
|
import (
|
|
"encoding/json"
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
"github.com/towgo/towgo/towgo"
|
|
"strings"
|
|
"tgk-touch/internal/global"
|
|
"tgk-touch/internal/library/meterControl"
|
|
)
|
|
|
|
var mc meterControl.IMeterControl
|
|
|
|
var deviceInfo map[string]interface{}
|
|
|
|
func Init() {
|
|
marshal, _ := json.Marshal(g.Config().DeviceInfo)
|
|
json.Unmarshal(marshal, &deviceInfo)
|
|
|
|
mc = meterControl.GetMeterControls(meterControl.ADL400)
|
|
initReadFunc()
|
|
initWriteFunc()
|
|
|
|
}
|
|
func initReadFunc() {
|
|
towgo.SetFunc("/adl400/readPhaseData", readPhaseData)
|
|
// 读取通信地址
|
|
towgo.SetFunc("/adl400/getMsgAddress", getMsgAddress)
|
|
// 读取日冻结时间
|
|
towgo.SetFunc("/adl400/getDailyFreezingTime", getDailyFreezingTime)
|
|
// 读取月冻结时间
|
|
towgo.SetFunc("/adl400/getMonthlyFreezingTime", getReadMonthlyFreezingTime)
|
|
// 读取冻结数据
|
|
towgo.SetFunc("/adl400/getFreezeTheData", getFreezeTheData)
|
|
// 读取时间
|
|
towgo.SetFunc("/adl400/geTime", geDeviceTime)
|
|
}
|
|
func initWriteFunc() {
|
|
// 写入通信地址
|
|
towgo.SetFunc("/adl400/setMsgAddress", setMsgAddress)
|
|
}
|
|
func getMeterAddr(cuid string) byte {
|
|
|
|
// 去掉 "0x" 前缀,按 16 进制解析
|
|
return gconv.Byte(strings.TrimPrefix(deviceInfo["meterAddr"].(string), "0x"))
|
|
|
|
}
|