You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
1.3 KiB

6 years ago
/*
Package for server related model
*/
package model
const (
SERVER_ZMQ = "zmq"
SERVER_NET = "net"
CMD_START = "start"
CMD_RESTART = "restart"
CMD_STOP = "stop"
DEV_RUPTELA = "RUPTELA"
DEV_TELTONIKA = "TELTONIKA"
MAP_SHARD_COUNT = 32
)
/*
REQ-REP pattern request.
*/
type Request struct {
Origin string
Token string
Type string
Data string
}
type IoMapResponse struct {
Descriptor DeviceDescriptor
DevTags []DevTag
StdTags []StdTag
}
type ServerConfig struct {
Id int
IP string
Port int
MaxSocket int
Mode string
ChanLimit uint32
Device string
TimeoutMilis int
}
/*
Interface for service which provides several information.
*/
type ServiceProvider interface {
IsRegistered(imei uint64) bool
GetDeviceIoMapping(imei uint64) (iom *DeviceIoMapping, err error)
}
//Device server interface
type DeviceServer interface {
Start()
Stop()
}
/*
Get device io mapping
*/
func GetDeviceIoMapping(imei uint64) (iom *DeviceIoMapping, err error) {
//-------------------------------------
//TODO get mapping from server/cache
iom = new(DeviceIoMapping)
iom.Descriptor.Id = 10
iom.Descriptor.Model = "Pro3"
iom.Descriptor.QoS = 1
iom.Descriptor.IMEI = imei
if iom.IOMapping == nil {
iom.IOMapping = make(IOMap)
}
return iom, nil
}