Documentation ¶
Index ¶
- Constants
- Variables
- func DownloadFile(filename string, v interface{}) (interface{}, error)
- func FileSess(r *FileTransfer) string
- func LogAlarm(b []byte, arg interface{}, a *Alarm)
- func LogEvent(b []byte, arg interface{}, e *Event)
- func LogFrame(arg interface{}, f *Frame) error
- func LogStatus(tag string, arg interface{}, s *Status)
- func NewUUID(s *string)
- func StopAll()
- func SyncSend(cmd ReqCode, s interface{}, r interface{}, args ...string) error
- func SyncStop(args ...string)
- func SyncWrite(s *RawData) error
- func UUID() string
- func UploadFile(a *Access, filename string, showProgress bool) error
- type Access
- type ActCode
- type AdapterHandler
- type Alarm
- type AlrChannel
- type AlrShake
- type AlrSpeed
- type AlrThreshold
- type CaptureResult
- type Conn
- func (o *Conn) Body() []byte
- func (c *Conn) Close()
- func (c *Conn) NotifyAccess(b []byte) (err error)
- func (c *Conn) NotifyAlarm(b []byte, a *Alarm)
- func (c *Conn) NotifyDropped(err error)
- func (c *Conn) NotifyEvent(b []byte, e *Event)
- func (c *Conn) NotifyFile(file *File)
- func (c *Conn) NotifyFrame(f *Frame) error
- func (c *Conn) NotifyStatus(tag string, s *Status)
- func (c *Conn) WriteBytes(data []byte) error
- type Context
- type Control
- type CtrlCode
- type CtrlLive
- type CtrlOsd
- type CtrlPTZ
- type CtrlSnapshot
- type CtrlText
- type CtrlVehi
- type Disk
- type Driver
- type Event
- type EventCode
- type EventFile
- type File
- type FileCode
- type FileTransfer
- type Frame
- type FrameCode
- type FtpTransfer
- type Gsensor
- type Handler
- type IClient
- type IClientOptions
- type LinkCode
- type LiveStream
- type Location
- type Mileage
- type Mobile
- type Module
- type NetCode
- type Obd
- type Oil
- type Options
- type PTZCode
- type People
- type Playback
- type Query
- type RawData
- type ReqCode
- type Response
- type Result
- type SerialData
- type SerialTransparent
- type Server
- type Status
- type User
- type VehiCode
- type Voice
Constants ¶
View Source
const ( Alarm_Unknow = 0x00 //未知 //unknow Alarm_VideoLost = 0x01 //视频丢失 //video lost Alarm_MotionDetection = 0x02 //移动侦测 //motion detection Alarm_VideoMask = 0x03 //视频遮挡 //video blind Alarm_InputGenerate = 0x04 //输入触发 //input trigger Alarm_Urgency = 0x05 //紧急告警 //emmergency alarm Alarm_LowSpeed = 0x06 //低速告警 //low speed alarm Alarm_OverSpeed = 0x07 //超速告警 //overspeed alarm Alarm_LowTemperature = 0x08 //低温告警 //low temperature alarm Alarm_OverTemperature = 0x09 //高温告警 //high temperature alarm Alarm_Humidity = 0x0a //湿度告警 //humidity alarm Alarm_ParkTimeout = 0x0b //超时停车 //park timeout alarm Alarm_Shake = 0x0c //震动告警 //vibration alarm Alarm_Geofence = 0x0d //电子围栏 //electronic defence Alarm_GeoLine = 0x0e //电子线路 //electronic line Alarm_DoorException = 0x0f //异常开关门 //door open/ close exception Alarm_StorageException = 0x10 //存储介质异常 //storage exception Alarm_FatigueDriving = 0x11 //疲劳驾驶 //fatigue driving Alarm_FuelException = 0x12 //油量异常 //fuel exception Alarm_IllegalFire = 0x13 //非法点火 //illegal ACC Alarm_LocationModuleException = 0x14 //定位模块异常 //location module exception Alarm_FrontPanelPrise = 0x15 //前面板打开 //front panel prise Alarm_SwipeCard = 0x16 //刷卡 //swipe card Alarm_HarshAcceleration = 0x18 //急加速 Alarm_HarshBraking = 0x19 //急减速 Alarm_LowSpeedWarn = 0x1a //低速预警 26 Alarm_OverSpeedWarn = 0x1b //高速预警 Alarm_VoltageWarn = 0x1c //电压告警 Alarm_PeopleCounting = 0x1d //人数统计 Alarm_DmsOrAdas = 0x1e //dms和adas报警(主动安全) Alarm_AccOn = 0x1f //acc on Alarm_SpeedIdle = 0x20 //怠速告警 Alarm_GpsAntennaOpen = 0x21 //Gps天线开路 Alarm_GpsAntennaCircuit = 0x22 //Gps天线短路 Alarm_IoOutput = 0x23 //IO输出 Alarm_CanbusException = 0x24 //CANBus连接异常 Alarm_Ttrailer = 0x25 //拖车 Alarm_Glide = 0x26 //空挡滑行 Alarm_RpmHigh = 0x27 //转速过高 Alarm_VehicleMovement = 0x28 //车辆移动 Alarm_TripStart = 0x29 //行程开始 Alarm_TripDuring = 0x2A //行程中 Alarm_TripEnd = 0x2B //行程结束 Alarm_LocateRecovery = 0x2C //定位恢复 Alarm_VideoAnomaly = 0x2D //视频异常 Alarm_NoneTripPositon = 0x2E //视频异常 Alarm_DisconnectServer = 0x2F //断开连接 )
报警类型
Variables ¶
View Source
var ( ErrNo = errors.New("success") // ErrTimeout = errors.New("timeout") // 超时 ErrParam = errors.New("parameter error") // 参数错误 ErrNoResult = errors.New("no result") // 结果错误 ErrObjectExist = errors.New("already exists") // 链接已存在 ErrObjectNoExist = errors.New("doesn't exist") // 链接不存在 ErrInvalidDevice = errors.New("invalid device") ErrUnSupport = errors.New("unsupport") ErrRecvOver = errors.New("data over") )
View Source
var DefaultAdapters []AdapterHandler
View Source
var DefaultResult = &Result{
reqTimeout: 30,
}
Functions ¶
func DownloadFile ¶
Types ¶
type Access ¶
type Access struct { Tag string `json:"-"` DeviceNo string `json:"deviceNo"` // 设备号 DeviceTime string `json:"deviceTime"` // 设备时间 Online bool `json:"online"` RemoteAddress string `json:"remoteAddress"` // 设备网络地址 Session string `json:"session"` // 链路会话号 LinkType LinkCode `json:"linkType"` // 链路类型 UpTraffic int64 `json:"upTraffic"` // 上行流量 DownTraffic int64 `json:"downTraffic"` // 下行流量 NetType NetCode `json:"netType"` // 网络类型 Version string `json:"version"` // 版本信息 DevType string `json:"devType"` // 设备类型 }
Access 链路注册
type AdapterHandler ¶
type Alarm ¶
type Alarm struct { Tag string `json:"-"` DeviceNo string `json:"deviceNo"` DTU string `json:"dtu"` UUID string `json:"uuid"` Type int `json:"type"` SubType int `json:"subType"` StartTime string `json:"startTime"` EndTime string `json:"endTime"` Data interface{} `json:"data"` Status *Status `json:"status"` }
Alarm 报警
type AlrChannel ¶
type AlrChannel struct {
Channel int `json:"ch"`
}
Channel 和通道相关的报警数据如: io/video...等,具体数据自定义 和通道相关的报警
type AlrShake ¶
type AlrShake struct { Type int `json:"dt"` // 1-x 2-y 3-z 4-hit 5-tilt AlrThreshold }
AlrShake
type AlrSpeed ¶
type AlrSpeed struct { AlrThreshold Dur uint `json:"dur"` // 时长 Spds int `json:"spds"` // 速度来源 }
type AlrThreshold ¶
type AlrThreshold struct { Value int `json:"vt"` // 触发 Time int `json:"tt"` Min float32 `json:"min"` Max float32 `json:"max"` Avg float32 `json:"avg"` Cur float32 `json:"cur"` Pre float32 `json:"pre"` }
Threshold 和阈值相关的报警
type CaptureResult ¶
type Conn ¶
type Conn struct { Srv *Server Result *Result UsrArg interface{} // 一个conn链接对应一个context, 解析后在map中刷新context Context // contains filtered or unexported fields }
Conn tcp Conn
type Control ¶
type Control struct { Type CtrlCode `json:"ctrlCode"` Data interface{} `json:"data"` }
type CtrlSnapshot ¶
type Disk ¶
type Disk struct { Type uint8 `json:"tp"` // 类型 Status uint8 `json:"st"` // 状态 Size uint32 `json:"sz"` // 大小 Residue uint32 `json:"re"` // 剩余 }
Disk 磁盘
type Event ¶
type Event struct { Tag string `json:"-"` DeviceNo string `json:"deviceNo"` Session string `json:"session"` DTU string `json:"dtu"` Type EventCode `json:"type"` Data interface{} `json:"data"` // 负载数据 Status *Status `json:"status"` }
Event 事件
type EventFile ¶
type EventFile struct { FileName string `josn:"fileName"` FileType FileCode `json:"fileType"` Capture struct { Channel int `json:"channel"` Latitude float32 `json:"latitude"` Longitude float32 `json:"longitude"` Speed float32 `json:"speed"` } `json:"capture"` Little struct { Channel int `json:"channel"` Size int `json:"size"` Duration int `json:"duration"` } Ftp string `json:"ftp"` }
EventFile
type File ¶
type File struct { FileName string `json:"fileName"` FileType FileCode `json:"fileType"` Channel int `json:"channel"` StartTime string `json:"startTime"` EndTime string `json:"endTime"` FileSize int `json:"fileSize"` FileDuration int `json:"fileDuration"` }
File 查找结果
type FileTransfer ¶
type FileTransfer struct { Session string `json:"session"` // 自动生成session FileType int `json:"fileType"` // 1:录像;2:报警录像;3:照片;4:报警照片;5:升级文件;6:日志文件;7:配置文件;8:黑匣子文件 FileName string `json:"fileName"` Server string `json:"server"` Action ActCode `json:"action"` // FileSize int `json:"fileSize"` // 文件大小,上传文件到设备时要设置做校验用 Offset int `json:"offset"` }
FileTransfer 文件传输
func FileOfSess ¶
func FileOfSess(ss string) (r FileTransfer)
type FtpTransfer ¶
type FtpTransfer struct { Session string `json:"session"` FtpURL string `json:"ftpUrl"` // ftp://admin:admin@192.168.1.101:21 FileType int `json:"fileType"` // 1:录像;2:报警录像;3:照片;4:报警照片;5:升级文件;6:日志文件;7:配置文件;8:黑匣子文件 FileSrc string `json:"fileSrc"` // 源文件 // jt1078协议虚拟文件格式 /tmp/jrec/chl_stimestamp_etimestamp_alarm_source_strem_store_net FileDst string `json:"fileDst"` // 目标文件 Action ActCode `json:"action"` // }
FtpTransfer 文件传输
type Gsensor ¶
type Gsensor struct { X float32 `json:"x"` Y float32 `json:"y"` Z float32 `json:"z"` Tilt float32 `json:"tilt"` // 倾斜 Hit float32 `json:"hit"` // 撞击 }
Gsensor gsensor 状态
type Handler ¶
type Handler struct { // Access register Access func([]byte, *Access) (interface{}, error) // Dropped Dropped func(interface{}, *Access, error) // status callback Status func(string, interface{}, *Status) // alarm callback Alarm func([]byte, interface{}, *Alarm) // event callback Event func([]byte, interface{}, *Event) // bin frame callback Frame func(interface{}, *Frame) error // File callback File func(interface{}, *File) }
type IClient ¶
type IClient interface { // callback handler; if return error not nil, will close connection OnHandler([]byte) (int, error) // callback idel; for Proactively respond to tasks OnIdle(*time.Time, *time.Time) error // Request 发送指令 Request(ReqCode, interface{}, interface{}) error }
InterProtocol 协议接口
type IClientOptions ¶
type IClientOptions interface {
GetOptions() interface{}
}
type LiveStream ¶
type LiveStream struct { Session string `json:"session"` Channel int `json:"channel"` StreamType int `json:"streamType"` // 0-主码流 1-子码流 On int `json:"on"` // 0-停止 1-开启 Frames string `json:"frames"` // 1;2;3 Protocol int `json:"protocol"` Server string `json:"server"` }
LiveStream 实时流
type Location ¶
type Location struct { Type uint8 `json:"tp"` // 定位类型 Speed float32 `json:"spd"` // 速度 Angle float32 `json:"agl"` // 角度 Longitude float32 `json:"lng"` // 经度 Latitude float32 `json:"lat"` // 纬度 Altitude int `json:"alt"` // 海拔 }
Gps 上报Location
type Module ¶
type Module struct { Dial uint8 `json:"dial"` // 移动网络(0:数据不存在,1:数据存在) Gps uint8 `json:"gps"` // 定位模块(0:数据不存在,1:数据存在) Wifi uint8 `json:"wifi"` // WIFI模块(0:数据不存在,1:数据存在) Gsensor uint8 `json:"gs"` // GSensor(0:数据不存在,1:数据存在) Record uint16 `json:"rec"` // 每一位代表一个通道 VideoLoss uint16 `json:"vlos"` }
Module 模块状态
type Obd ¶
type Obd struct { Rpm int `json:"rpm"` // 转速 Speed float32 `json:"spd"` // 速度 Acc int `json:"acc"` // acc状态 JQTemp int `json:"jtp"` // 燃油进气温度 JQMPos int `json:"jms"` // 节气阀位置 Voltage float32 `json:"vol"` // 电压 Mileage float32 `jons:"mile"` // 里程 TotalFuel uint32 `json:"tfuel"` // 当前启动后总油耗 InstanFuel float32 `json:"ifuel"` // 瞬时油耗 Efoa uint8 `json:"efoa"` // 剩余油量 % Airshed uint8 `json:"airs"` // 进气流量 StressMPa uint8 `json:"strpa"` // 进气管压力 CoolantsTemp uint8 `json:"ctemp"` // 冷却液温度 AirTemp uint8 `json:"atemp"` // 进气温度 MotorLimit uint8 `json:"molmt"` // 发动机负荷计算值 Position uint8 `json:"pos"` // 节气门绝对位置 % Vin string `json:"vin"` EStatus uint8 `json:"eStatus"` // 引擎状态 1:on 0:off EOnTime string `json:"eOnTime"` // 引擎开启时间 EOffTime string `json:"eOffTime"` // 引擎关闭时间 IdleStatus uint8 `json:"idleStatus"` // 怠速状态 1:start 0:end Ha uint8 `json:"ha"` Hb uint8 `json:"hb"` Hc uint8 `json:"hc"` LowBatteryVol uint8 `json:"lowbat"` }
Obd obd数据
type PTZCode ¶
type PTZCode = int
const ( PTZ_Unknow PTZCode = iota PTZ_Up PTZ_Down PTZ_Left PTZ_Right PTZ_LeftUp PTZ_LeftDown PTZ_RightUp PTZ_RightDown PTZ_PreSetGoto PTZ_PreSetSet PTZ_PreSetClear PTZ_IrisOpen PTZ_IrisClose PTZ_ZoomIn PTZ_ZoomOut PTZ_FocusNear PTZ_FocusFar PTZ_AutoScan PTZ_BrushOn PTZ_BrushOff PTZ_CruiseOpen PTZ_CruiseClose PTZ_LightOn PTZ_LightOff )
type Playback ¶
type Playback struct { Session string `json:"session"` FileName string `json:"fileName"` Server string `json:"server"` StartTime string `json:"startTime"` EndTime string `json:"endTime"` Channels string `json:"channels"` Frames string `json:"frames"` // 1;2;3 Action int `json:"action"` // 0-下载式回放,1-流式回放 }
Playback 录像文件回放
type Query ¶
type Query struct { Server string `json:"server"` Session string `json:"session"` StartTime string `json:"startTime"` EndTime string `json:"endTime"` FileType FileCode `json:"fileType"` Channels string `json:"channels"` // StreamType int `json:"streamType"` // StoreType int `json:"storeType"` // 1 主录像 2 }
Query 查找
type ReqCode ¶
type ReqCode = int
type
const ( Req_None ReqCode = iota // 空指令 Req_Query Req_Parameters Req_LiveStream // 实时视频 Req_FtpTransfer // Ftp升级 Req_Control // 控制 Req_SerialTransparent // 串口透传设置 Req_SerialTransfer // 串口传输数据 Req_Playback // 录像文件回放 Req_FileTransfer // 文件传输 Req_Voice Req_WriteData // 裸数据(文件、语音...) Req_User // 自定义请求 Req_Close // 关闭链接 )
type Response ¶
type Response struct { Session string `json:"ss"` Details interface{} `json:"details"` }
Response 通用请求应答
type SerialData ¶
SerialData 透传数据
type SerialTransparent ¶
type SerialTransparent struct { Session string `json:"session"` Port int `json:"port"` BaudRate int `json:"baudRate"` DatBit int `json:"dataBit"` CheckBit int `json:"checkBit"` StopBit int `json:"stopBit"` }
SerialTransparent 串口透传设置
type Server ¶
type Server struct { Handler Handler Result *Result *Options // contains filtered or unexported fields }
Serve 服务
func (*Server) ListenTCPAndServe ¶
func (o *Server) ListenTCPAndServe()
ListenTCPAndServe start server
func (*Server) Use ¶
func (o *Server) Use(decode ...AdapterHandler)
type Status ¶
type Status struct { DeviceNo string `json:"deviceNo"` DTU string `json:"dtu"` // DTU Flag uint8 `json:"flag"` // 0-实时 1-补传 2-报警开始Gps 3-报警结束Gps Acc uint8 `json:"acc"` // acc Location Location `json:"loc"` // 位置信息 Tempers []float32 `json:"temps"` // 温度 Humiditys []float32 `json:"humis"` // 湿度 Mileage Mileage `json:"mile"` // 里程 Oils []Oil `json:"oils"` // 油耗 Module Module `json:"mod"` // 模块状态 Gsensor Gsensor `json:"gs"` // GSensor Mobile Mobile `json:"mobile"` // 移动网络 Disks []Disk `json:"disks"` // 磁盘 People People `json:"peop"` // 人数统计 Obds []Obd `json:"obds"` // obd Vol []float32 `json:"vol"` Driver Driver `json:"driver"` }
Status 状态数据
Source Files ¶
Click to show internal directories.
Click to hide internal directories.