| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- package dataStruct
- import "encoding/json"
- type DTUDevice struct {
- SN string `json:"sn"`
- Name string `json:"name"`
- SimId string `json:"simId"`
- Configs string `json:"configs"`
- TmOnline string `json:"tmOnline"`
- TmOffline string `json:"tmOffline"`
- }
- type DTUDeviceState struct {
- Info *DTUDevice `json:"info"`
- Online bool `json:"online"` //true在线
- PwrOff bool `json:"pwrOff"` //true掉电
- }
- type DtuDevice struct {
- ID int `json:"id"` // 设备ID
- Enable bool `json:"enable"` // 是否启用
- SN string `json:"sn"` // 设备编码SN
- Name string `json:"name"` // 设备名称
- SimId string `json:"simId"` // sim卡ID
- IP string `json:"ip"` // 平台IP
- Port int `json:"port"` // 平台端口
- Protocol string `json:"protocol"` // 平台协议
- Pw string `json:"pw"` // 平台密码
- Mn string `json:"mn"` // 设备MN
- Secs int `json:"secs"` // 上报周期
- St string `json:"st"` // 设备ST
- Cn string `json:"cn"` // 设备CN
- Others string `json:"others"` // 其他
- Slave []DtuSlave `json:"slave"` // 从机
- }
- func (d *DtuDevice) ToDtu() (*DTUDevice, error) {
- var dtuSlave []*DtuSlave
- for _, slave := range d.Slave {
- dtuSlave = append(dtuSlave, &DtuSlave{
- Addr: slave.Addr,
- BmYz: slave.BmYz,
- LvRef: slave.LvRef,
- MType: slave.MType,
- PvRef: slave.PvRef,
- NO: slave.NO,
- })
- }
- dtuConfig := &DtuConfig{
- Enable: d.Enable,
- ID: d.ID,
- IP: d.IP,
- Secs: d.Secs,
- St: d.St,
- Cn: d.Cn,
- Others: d.Others,
- Port: d.Port,
- Protocol: d.Protocol,
- Pw: d.Pw,
- Mn: d.Mn,
- Slave: dtuSlave,
- }
- dtuConfigStr, err := json.Marshal(dtuConfig)
- if err != nil {
- return nil, err
- }
- dtuDevice := &DTUDevice{
- Configs: string(dtuConfigStr),
- Name: d.Name,
- SimId: d.SimId,
- SN: d.SN,
- }
- return dtuDevice, nil
- }
- type HJBaseInfo struct {
- // Name string
- // Protocol string
- Host string
- Port string
- ST string
- CN string
- PW string
- MN string
- // Interval int //上报周期,单位分钟,最小1分钟
- // IsUpload bool //是否允许上报
- }
|