server

package
v0.0.0-...-f0dea4b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	IC          IotConnection
	IotServer   Server
	SphInfo     map[string]*Sphinfo
	CphInfo     map[string]*Cphinfo
	TM          = timer.NewTimer()
	SetBytes, _ = hex.DecodeString("01030000001445C5")
)

Functions

func IotStart

func IotStart()

服务软件开启

func MessageCenter

func MessageCenter(itoChan chan *ItoInfo, tname string, db *gorm.DB, file *os.File, redis *redis.Pool)

func TimeStart

func TimeStart()

时间轮模块启动

Types

type ConnType

type ConnType struct {
	Conn      gnet.Conn
	ConnTime  string
	UpTime    string
	Imei      string
	Register  bool     //是否解析过注册包头
	Etype     int      //设备类型 1.传感器,2 控制器
	Rst       string   //注册的包头,可以直接识别协议
	Protocol  *Sphinfo //连接协议
	CProtocol *Cphinfo
	Task      timer.TimeNoder //时间轮处理句柄
	CStatus   string
}

type Cphinfo

type Cphinfo struct {
	Hgp      string `gorm:"column:hgp;type:text"`
	Htp      string `gorm:"column:htp;type:text"`
	Ctrl     string `gorm:"column:ctrl;type:text"`
	Cycle    int    `gorm:"column:cycle;type:int"`
	Sw       int    `gorm:"column:sw;type:int"`
	Protocol []*model.Ctrlinfo
}

type DataHandlerType

type DataHandlerType func([]SaveType, *gorm.DB, *os.File, *redis.Pool)

type IotConnection

type IotConnection struct {
	Conn map[string]*ConnType
	Mx   sync.RWMutex
}

连接描述

type ItoInfo

type ItoInfo struct {
	ScanTime string      `json:"scan_time"` //采集时间
	IData    []*SaveType `json:"data"`
	Imei     string      `json:"imei"`
}

type SaveType

type SaveType struct {
	Name  string
	Value string
}

type Server

type Server struct {
	Port int    `gorm:"column:port;type:int"`
	Info string `gorm:"column:info;type:text"`
}

Server [...]

type Sphinfo

type Sphinfo struct {
	ID          uint   `gorm:"primary_key;column:id;type:int unsigned;not null"`
	Hgp         string `gorm:"column:hgp;type:text"`
	Htp         string `gorm:"column:htp;type:text"`
	Ctrl        string `gorm:"column:ctrl;type:text"`
	Cycle       int    `gorm:"column:cycle;type:int"`
	Sw          int    `gorm:"column:sw;type:int"`
	Protocol    []*model.Sensorinfo
	Database    *gorm.DB
	Tname       string //存储的表名字
	File        *os.File
	Redis       *redis.Pool
	DataHandler *DataHandlerType
	ItoChan     chan *ItoInfo
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL