2 Star 0 Fork 0

Admin/bd_sender

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Config.go 1.72 KB
一键复制 编辑 原始数据 按行查看 历史
钟林峰 提交于 2019-03-06 15:41 +08:00 . add tests
package main
import (
"encoding/json"
"strconv"
"strings"
)
// Bytes type wrapper for json bytes
type Bytes struct {
Data []byte
}
// UnmarshalJSON implemnents json interface
func (b *Bytes) UnmarshalJSON(data []byte) error {
d := []byte{}
s := strings.Trim(string(data), `, "`)
bs := strings.Split(s, ",")
for _, b := range bs {
value, err := strconv.ParseUint(b, 0, 8)
if err != nil {
return err
}
bval := byte(value)
d = append(d, bval)
}
b.Data = d
return nil
}
// ParserConfig parser config
type ParserConfig struct {
Type string `json:"type,omitempty"`
Head Bytes `json:"head,omitempty"`
Items []ParserItem `json:"items,omitempty"`
}
// SlotItem slot item
type SlotItem struct {
Kind string `json:"kind,omitempty"`
Type string `json:"type,omitempty"`
Path string `json:"path,omitempty"`
Width int `json:"width,omitempty"`
Scale string `json:"scale,omitempty"`
Value string `json:"value,omitempty"`
Max float64 `json:"max,omitempty"`
Min float64 `json:"min,omitempty"`
}
// SlotConfig slot config
type SlotConfig struct {
Head Bytes `json:"head,omitempty"`
Items []SlotItem `json:"items,omitempty"`
}
// SourceConfig source config
type SourceConfig struct {
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
Params json.RawMessage `json:"params,omitempty"`
Options json.RawMessage `json:"options,omitempty"`
}
// Config config container
type Config struct {
Sources []SourceConfig `json:"sources,omitempty"`
Parsers []ParserConfig `json:"parsers,omitempty"`
Slots []SlotConfig `json:"slots,omitempty"`
BeidouSenderConfig BeidouSenderConfig `json:"beidouSender,omitempty"`
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/shipnet_masterclock/bd_sender.git
git@gitee.com:shipnet_masterclock/bd_sender.git
shipnet_masterclock
bd_sender
bd_sender
master

搜索帮助