| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- package main
- import (
- "sync"
- "time"
- )
- //气象环境,实时MQTT订阅
- //车速阈值,固定配置
- //车牌、车速,
- type EnvData struct {
- Time time.Time `json:"-"`
- Tianqi string `json:"tq"` //天气
- Wendu string `json:"wd"` //温度
- Zhishu string `json:"zs"` //控制质量
- Aqi string `json:"aqi"` //指数
- Fengxiang string `json:"fx"` //风向
- Fengji string `json:"fj"` //风急
- Shidu string `json:"sd"`//hidu
- PM25 string `json:"pm25"` //PM2.5
- PM10 string `json:"pm10"` //PM10
- }
- type DisplayData struct {
- EnvData
- Chesu int `json:"cs"` //测速
- Chesufazhi int `json:"csfz"` //测速阈值
- }
- func (o * DisplayData) Reset(){
- o.Chesu = 0
- o.Chesufazhi = 0
- }
- var _datapoolonce sync.Once
- var _datapoolsingle *DisplayDataPool
- func GetDataPool() *DisplayDataPool {
- _datapoolonce.Do(func() {
- _datapoolsingle = &DisplayDataPool{
- pool: sync.Pool{New: func() interface{} { return &DisplayData{} }}}
- })
- return _datapoolsingle
- }
- type DisplayDataPool struct {
- pool sync.Pool
- }
- func (o *DisplayDataPool) GetData() *DisplayData {
- p := o.pool.Get()
- return p.(*DisplayData)
- }
- func (o *DisplayDataPool) Release(p *DisplayData) {
- if p != nil {
- o.pool.Put(p)
- }
- }
|