| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- package service
- import (
- "encoding/json"
- "time"
- wdcc "dashoo.cn/labsop"
- "github.com/nsqio/go-nsq"
- )
- //tag说明f:fields,t:tag,-:不赋值
- type ChannelValue struct {
- Time time.Time
- TimeUnix int64
- Sequence int64
- Mxinh int64
- T2bxh float64
- Lat float64 //纬度
- Lng float64 //经度
- Speed float64 //速度
- Temperature float64 //温度
- Humidity float64 //湿度
- Voltage float64 //电压
- RSSI float64 //信号 Signal (sensor到blackbox)
- CSTime time.Time //传输时间
- SensorNo int64 //Sensor序列号 Zbackup4
- BBVoltage float64 //bb电压
- BBCSTime time.Time //BB传输time Zbackup2
- BBMac string //bbmac
- BBMacTag string //bbmactag
- BBNo int64 //bb序列号 SensorNo
- SimSignal int64 //移动信号 Zbackup3
- SimIP string //sim900 IP Zbackup7
- ServiceTime time.Time //服务器时间 Zbackup5
- RequestData string //请求原数据 Zbackup1
- O2 float64 //氧气浓度 Zbackup8
- SO2 float64 //二氧化硫 Zbackup8
- Isreplace int64 //是否替换(0未替换,1已替换) Zbackup9
- RealTemperature float64 //原温度 Zbackup10
- Co2 float64 //Co2
- H2O float64 //水质
- WindSpeed float64 //风速
- Pressure float64 //气压
- Ots float64 //压力大港
- Displacement float64 //位移
- ClO2 float64 //二氧化氯
- C2H4 float64 //乙烯
- C2H2 float64 //乙炔
- Cl2 float64 //氯气
- O3 float64 //臭氧
- TVOC float64 //TVOC
- Waterflow float64 //waterflow
- DeviceState int64 // 监控设备状态
- ElectricalPower int64 // 电器功率
- ElectricalSupply int64 // 市电电压
- NTCR float64 // Sensor端NTC热敏电阻
- ThreeACVA float64 // A相电压
- ThreeACVB float64 // B相电压
- ThreeACVC float64 // C相电压
- ThreeACAA float64 // A相电流
- ThreeACAB float64 // B相电流
- ThreeACAC float64 // C相电流
- ThreeACW float64 // 三相有功总电能
- InfraredBarrier int64 // 红外阻挡物(0 无阻碍物 1有障碍物 other 其他)
- GpsBaseStation string // gps基站信息
- LiquidLevel float64 // 液位
- Doorlock float64 // 门锁
- }
- var Producernsq *nsq.Producer
- type blackboxddata struct {
- Code string
- Datapoint wdcc.DatapointLabSop
- }
- func Writedata(tagmac, bbmac, zbackup1, gpsbasestation string, v1, v2, v3, v4, v5, v6 float64, cjtime, cstime, bbtime time.Time, xulieh, mobilexh, sensornum, isreplace, infraredbarrier int64, o2, realtemperature, co2, waterflow, lng, lat float64, devicestate, wdtype int, electricalpower, electricalsupply int64, ntrc, threeacva, threeacaa, threeacvb, threeacab, threeacvc, threeacac, threeacw, doorlock float64) (wdcc.DatapointLabSop, error) {
- var data wdcc.DatapointLabSop
- data = wdcc.DatapointLabSop{Time: cjtime, Temperature: v1, Humidity: v2, Voltage: v3, RSSI: v4, CSTime: cstime, BBVoltage: v5, BBMac: bbmac, BBNo: xulieh, RequestData: zbackup1, BBCSTime: bbtime, SimSignal: mobilexh, SensorNo: sensornum, ServiceTime: time.Now(), O2: o2, Isreplace: isreplace, RealTemperature: realtemperature, Co2: co2, Waterflow: waterflow, Lat: lat, Lng: lng, DeviceState: int64(devicestate), ElectricalPower: electricalpower, ElectricalSupply: electricalsupply, GpsBaseStation: gpsbasestation, NTCR: ntrc, ThreeACVA: threeacva, ThreeACVB: threeacvb, ThreeACVC: threeacvc, ThreeACAA: threeacaa, ThreeACAB: threeacab, ThreeACAC: threeacac, ThreeACW: threeacw, InfraredBarrier: infraredbarrier, Doorlock: doorlock}
- bdata, err := json.Marshal(blackboxddata{tagmac, data})
- if err == nil {
- errnsq := Producernsq.Publish(Config.Send.Controller.Topic, bdata)
- return data, errnsq
- // return data, nil
- }
- return data, err
- }
|