From 35ea01f165ee1df3f2d9ca5e2c74aa6b22876087 Mon Sep 17 00:00:00 2001 From: wwhai Date: Fri, 15 Mar 2024 21:45:25 +0800 Subject: [PATCH] dev: enhance camera --- .../apis/device_modbus_data_sheet_api.go | 2 +- device/generic_camera_stream.go | 3 + device/generic_camera_stream_arm.go | 32 +--- device/generic_camera_stream_arm64.go | 106 +++++++++++ device/generic_opcua_device.go | 6 +- go.mod | 179 +++++++----------- plugin/mqtt_server/mqtt_server.go | 16 +- typex/version.go | 8 +- utils/gocv_utils.go | 3 + utils/gocv_utils_arm.go | 38 ++++ utils/gocv_utils_arm64.go | 38 ++++ 11 files changed, 279 insertions(+), 152 deletions(-) create mode 100644 device/generic_camera_stream_arm64.go create mode 100644 utils/gocv_utils_arm.go create mode 100644 utils/gocv_utils_arm64.go diff --git a/component/rulex_api_server/apis/device_modbus_data_sheet_api.go b/component/rulex_api_server/apis/device_modbus_data_sheet_api.go index 9b93a1d68..f4481ffd1 100644 --- a/component/rulex_api_server/apis/device_modbus_data_sheet_api.go +++ b/component/rulex_api_server/apis/device_modbus_data_sheet_api.go @@ -469,7 +469,7 @@ func parseModbusPointExcel(r io.Reader, sheetName string, tag := row[0] alias := row[1] function, _ := strconv.ParseUint(row[2], 10, 8) - frequency, _ := strconv.ParseUint(row[3], 10, 8) + frequency, _ := strconv.ParseUint(row[3], 10, 64) slaverId, _ := strconv.ParseUint(row[4], 10, 8) address, _ := strconv.ParseUint(row[5], 10, 16) quantity, _ := strconv.ParseUint(row[6], 10, 16) diff --git a/device/generic_camera_stream.go b/device/generic_camera_stream.go index 0902a472f..e7ec8f9df 100644 --- a/device/generic_camera_stream.go +++ b/device/generic_camera_stream.go @@ -1,3 +1,6 @@ +//go:build amd64 +// +build amd64 + package device import ( diff --git a/device/generic_camera_stream_arm.go b/device/generic_camera_stream_arm.go index f5827579b..de0889fd6 100644 --- a/device/generic_camera_stream_arm.go +++ b/device/generic_camera_stream_arm.go @@ -1,3 +1,6 @@ +//go:build arm +// +build arm + // Copyright (C) 2023 wwhai // // This program is free software: you can redistribute it and/or modify @@ -16,16 +19,14 @@ package device import ( - "github.com/hootrhino/rulex/component/interdb" "github.com/hootrhino/rulex/component/iotschema" - "github.com/hootrhino/rulex/glogger" + "github.com/hootrhino/rulex/typex" - "github.com/hootrhino/rulex/utils" - "time" ) type videoCamera struct { typex.XStatus + status typex.DeviceState } /* @@ -39,31 +40,8 @@ func NewVideoCamera(e typex.RuleX) typex.XDevice { return hd } -type MInternalNotify struct { - ID uint `gorm:"primaryKey" json:"id"` - CreatedAt time.Time `json:"created_at"` - UUID string `gorm:"not null"` // UUID - Type string `gorm:"not null"` // INFO | ERROR | WARNING - Status int `gorm:"not null"` // 1 未读 2 已读 - Event string `gorm:"not null"` // 字符串 - Ts uint64 `gorm:"not null"` // 时间戳 - Summary string `gorm:"not null"` // 概览,为了节省流量,在消息列表只显示这个字段,Info值为“” - Info string `gorm:"not null"` // 消息内容,是个文本,详情显示 -} - func (hd *videoCamera) Init(devId string, configMap map[string]interface{}) error { hd.PointId = devId - msg := `The current stage of multimedia functions on the ARM32 bit platform is not very perfect, please continue to pay attention to the future version iteration.` - glogger.GLogger.Warn(msg) - interdb.DB().Table("m_internal_notifies").Save(MInternalNotify{ - UUID: utils.MakeUUID("NOTIFY"), // UUID - Type: `WARNING`, // INFO | ERROR | WARNING - Status: 1, - Event: `device.camera.warning`, - Ts: uint64(time.Now().UnixMilli()), - Summary: "ARM32 CPU 性能不足", - Info: msg, - }) return nil } diff --git a/device/generic_camera_stream_arm64.go b/device/generic_camera_stream_arm64.go new file mode 100644 index 000000000..563802beb --- /dev/null +++ b/device/generic_camera_stream_arm64.go @@ -0,0 +1,106 @@ +//go:build arm64 +// +build arm64 + +// Copyright (C) 2023 wwhai +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package device + +import ( + "github.com/hootrhino/rulex/component/iotschema" + + "github.com/hootrhino/rulex/typex" +) + +type videoCamera struct { + typex.XStatus + status typex.DeviceState +} + +/* +* +* ARM32不支持 +* + */ +func NewVideoCamera(e typex.RuleX) typex.XDevice { + hd := new(videoCamera) + hd.RuleEngine = e + return hd +} + +func (hd *videoCamera) Init(devId string, configMap map[string]interface{}) error { + hd.PointId = devId + return nil +} + +func (hd *videoCamera) Start(cctx typex.CCTX) error { + hd.Ctx = cctx.Ctx + hd.CancelCTX = cctx.CancelCTX + + hd.status = typex.DEV_UP + return nil +} + +func (hd *videoCamera) OnRead(cmd []byte, data []byte) (int, error) { + + return 0, nil +} + +// 把数据写入设备 +func (hd *videoCamera) OnWrite(cmd []byte, b []byte) (int, error) { + return 0, nil +} + +// 设备当前状态 +func (hd *videoCamera) Status() typex.DeviceState { + return typex.DEV_UP +} + +// 停止设备 +func (hd *videoCamera) Stop() { + hd.status = typex.DEV_STOP + hd.CancelCTX() +} + +// 设备属性,是一系列属性描述 +func (hd *videoCamera) Property() []iotschema.IoTSchema { + return []iotschema.IoTSchema{} +} + +// 真实设备 +func (hd *videoCamera) Details() *typex.Device { + return hd.RuleEngine.GetDevice(hd.PointId) +} + +// 状态 +func (hd *videoCamera) SetState(status typex.DeviceState) { + hd.status = status + +} + +// 驱动 +func (hd *videoCamera) Driver() typex.XExternalDriver { + return nil +} + +// -------------------------------------------------------------------------------------------------- +// +// -------------------------------------------------------------------------------------------------- +func (hd *videoCamera) OnDCACall(UUID string, Command string, Args interface{}) typex.DCAResult { + return typex.DCAResult{} +} +func (hd *videoCamera) OnCtrl(cmd []byte, args []byte) ([]byte, error) { + return []byte{}, nil +} diff --git a/device/generic_opcua_device.go b/device/generic_opcua_device.go index 8e89baa2a..38a9b638e 100644 --- a/device/generic_opcua_device.go +++ b/device/generic_opcua_device.go @@ -140,7 +140,7 @@ func (opcDev *genericOpcuaDevice) Start(cctx typex.CCTX) error { // opts = append(opts, opcua.SecurityFromEndpoint(ep, ua.UserTokenTypeAnonymous)) // } //连接opcua -判断连接是否正常 - opcDev.client = opcua.NewClient(ep.EndpointURL, opcua.SecurityMode(ua.MessageSecurityModeNone)) + opcDev.client, _ = opcua.NewClient(ep.EndpointURL) if err := opcDev.client.Connect(cctx.Ctx); err != nil { glogger.GLogger.Error("Connect opcua client failed:", err) return err @@ -217,7 +217,7 @@ func (opcDev *genericOpcuaDevice) readNodes(cmd []byte, data []byte) (int, error TimestampsToReturn: ua.TimestampsToReturnBoth, } ctx := context.Background() - resp, err := opcDev.client.ReadWithContext(ctx, req) + resp, err := opcDev.client.Read(ctx, req) if err != nil { opcDev.errorCount++ glogger.GLogger.Errorf("Read failed: %s", err) @@ -309,7 +309,7 @@ func (sd *genericOpcuaDevice) Stop() { sd.status = typex.DEV_DOWN sd.CancelCTX() if sd.driver != nil { - sd.client.CloseWithContext(sd.Ctx) + sd.client.Close(sd.Ctx) sd.driver.Stop() } } diff --git a/go.mod b/go.mod index 1e6c5f046..cfb408b0a 100644 --- a/go.mod +++ b/go.mod @@ -4,170 +4,131 @@ go 1.18 require ( github.com/BeatTime/bacnet v0.2.1 - github.com/DrmagicE/gmqtt v0.5.0 - github.com/Kowiste/ProfinetServer v0.0.0-20200929093941-9c422ae1f008 github.com/adrianmo/go-nmea v1.8.0 - github.com/bluele/gcache v0.0.2 github.com/dgrijalva/jwt-go v3.2.0+incompatible - github.com/eclipse/paho.mqtt.golang v1.4.2 - github.com/emirpasic/gods v1.18.1 - github.com/gin-contrib/static v0.0.1 + github.com/eclipse/paho.mqtt.golang v1.4.3 + github.com/gin-contrib/static v1.1.0 github.com/gin-gonic/gin v1.9.1 - github.com/go-ini/ini v1.67.0 - github.com/go-playground/assert/v2 v2.2.0 - github.com/go-playground/validator/v10 v10.14.0 - github.com/go-redis/redis/v8 v8.11.5 + github.com/go-playground/validator/v10 v10.19.0 github.com/google/uuid v1.6.0 - github.com/gopcua/opcua v0.3.15 - github.com/gorilla/websocket v1.5.0 - github.com/gosnmp/gosnmp v1.35.0 + github.com/gopcua/opcua v0.5.3 + github.com/gorilla/websocket v1.5.1 + github.com/gosnmp/gosnmp v1.37.0 github.com/hootrhino/go-ais v1.0.0 - github.com/hootrhino/gopher-lua v1.0.0 + github.com/hootrhino/go-dhcpd-leases v0.0.0-20240116064141-0730f287f9a2 + github.com/hootrhino/gopher-lua v1.0.3 github.com/hootrhino/wmi v0.0.0-20230603082700-cfa077a8cf01 - github.com/itchyny/gojq v0.12.13 - github.com/jinzhu/copier v0.3.5 + github.com/itchyny/gojq v0.12.14 + github.com/jinzhu/copier v0.4.0 github.com/lithammer/shortuuid/v4 v4.0.0 - github.com/makiuchi-d/gozxing v0.1.1 - github.com/mattn/go-sqlite3 v1.14.17 - github.com/mitchellh/go-homedir v1.1.0 + github.com/mattn/go-sqlite3 v1.14.22 github.com/mitchellh/mapstructure v1.5.0 - github.com/mochi-co/mqtt/v2 v2.2.12 - github.com/muka/go-bluetooth v0.0.0-20221213043340-85dc80edc4e1 - github.com/nats-io/nats.go v1.26.0 - github.com/patrikeh/go-deep v0.0.0-20230427173908-a2775168ab3d + github.com/mochi-co/mqtt/v2 v2.2.16 + github.com/nats-io/nats.go v1.33.1 github.com/plgd-dev/go-coap/v2 v2.6.0 + github.com/plgd-dev/kit/v2 v2.0.0-20211006190727-057b33161b90 github.com/robfig/cron/v3 v3.0.1 - github.com/robinson/gos7 v0.0.0-20230421131203-d20ac6ca08cd - github.com/rs/zerolog v1.28.0 + github.com/robinson/gos7 v0.0.0-20231031082500-fb5a72fd499e + github.com/rs/zerolog v1.32.0 github.com/shirou/gopsutil v3.21.11+incompatible - github.com/shirou/gopsutil/v3 v3.23.5 + github.com/shirou/gopsutil/v3 v3.24.2 github.com/sirupsen/logrus v1.9.3 - github.com/suapapa/go_eddystone v1.3.1 github.com/swaggo/files v1.0.1 github.com/swaggo/gin-swagger v1.6.0 - github.com/swaggo/swag v1.16.2 - github.com/tbrandon/mbserver v0.0.0-20211210035124-daf3c8c4269f - github.com/thinkgos/go-iecp5 v1.2.1 - github.com/urfave/cli/v2 v2.25.5 + github.com/swaggo/swag v1.16.3 + github.com/urfave/cli/v2 v2.27.1 github.com/wwhai/gomodbus v0.2.4 github.com/wwhai/goserial v0.2.0 github.com/wwhai/ntp v0.3.0 github.com/wwhai/tarmserial v1.0.0 github.com/wwhai/tinycache v0.0.0-20191004192108-46f407853014 - github.com/xuri/excelize/v2 v2.7.1 - go.bug.st/serial v1.5.0 - go.mongodb.org/mongo-driver v1.11.6 - go.uber.org/zap v1.15.0 + github.com/xuri/excelize/v2 v2.8.1 + go.bug.st/serial v1.6.2 + go.mongodb.org/mongo-driver v1.14.0 gocv.io/x/gocv v0.35.0 - golang.org/x/crypto v0.19.0 - golang.org/x/sys v0.17.0 - google.golang.org/grpc v1.62.0 - google.golang.org/protobuf v1.32.0 + golang.org/x/sys v0.18.0 + google.golang.org/grpc v1.62.1 + google.golang.org/protobuf v1.33.0 gopkg.in/ini.v1 v1.67.0 + gopkg.in/natefinch/lumberjack.v2 v2.2.1 gopkg.in/square/go-jose.v2 v2.6.0 - gorm.io/driver/sqlite v1.5.1 - gorm.io/gorm v1.25.1 + gopkg.in/yaml.v2 v2.4.0 + gorm.io/driver/sqlite v1.5.5 + gorm.io/gorm v1.25.7 ) require ( github.com/KyleBanks/depth v1.2.1 // indirect - github.com/go-openapi/jsonpointer v0.20.0 // indirect - github.com/go-openapi/jsonreference v0.20.2 // indirect - github.com/go-openapi/spec v0.20.9 // indirect - github.com/go-openapi/swag v0.22.4 // indirect - github.com/josharian/intern v1.0.0 // indirect - github.com/juju/errors v0.0.0-20170703010042-c7d06af17c68 // indirect - github.com/mailru/easyjson v0.7.7 // indirect - github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect - github.com/richardlehane/mscfb v1.0.4 // indirect - github.com/richardlehane/msoleps v1.0.3 // indirect - github.com/rogpeppe/go-internal v1.11.0 // indirect - github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 // indirect - github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 // indirect - golang.org/x/tools v0.15.0 // indirect -) - -require ( - github.com/beorn7/perks v1.0.1 // indirect - github.com/blastrain/vitess-sqlparser v0.0.0-20201030050434-a139afbb1aba - github.com/bytedance/sonic v1.9.1 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect + github.com/PuerkitoBio/purell v1.1.1 // indirect + github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect + github.com/bytedance/sonic v1.10.2 // indirect + github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect + github.com/chenzhuoyu/iasm v0.9.1 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/creack/goselect v0.1.2 // indirect - github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/dsnet/golib/memfile v1.0.0 // indirect - github.com/fatih/structs v1.1.0 // indirect - github.com/gabriel-vasile/mimetype v1.4.2 // indirect + github.com/gabriel-vasile/mimetype v1.4.3 // indirect github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-ole/go-ole v1.2.6 // indirect + github.com/go-openapi/jsonpointer v0.19.5 // indirect + github.com/go-openapi/jsonreference v0.19.6 // indirect + github.com/go-openapi/spec v0.20.4 // indirect + github.com/go-openapi/swag v0.19.15 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/goburrow/modbus v0.1.0 // indirect - github.com/goburrow/serial v0.1.0 // indirect github.com/goccy/go-json v0.10.2 // indirect - github.com/godbus/dbus/v5 v5.0.4 // indirect - github.com/golang/mock v1.6.0 // indirect github.com/golang/protobuf v1.5.3 // indirect - github.com/golang/snappy v0.0.4 // indirect - github.com/gomodule/redigo v1.8.2 // indirect - github.com/grpc-ecosystem/go-grpc-middleware v1.2.0 // indirect - github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect - github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect - github.com/hootrhino/go-dhcpd-leases v0.0.0-20240116064141-0730f287f9a2 + github.com/golang/snappy v0.0.3 // indirect github.com/itchyny/timefmt-go v0.1.5 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect + github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/compress v1.16.5 // indirect - github.com/klauspost/cpuid/v2 v2.2.5 // indirect - github.com/leodido/go-urn v1.2.4 // indirect - github.com/lufia/plan9stats v0.0.0-20230326075908-cb1d2100619a // indirect - github.com/mattn/go-colorable v0.1.12 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect + github.com/klauspost/compress v1.17.2 // indirect + github.com/klauspost/cpuid/v2 v2.2.6 // indirect + github.com/leodido/go-urn v1.4.0 // indirect + github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect + github.com/mailru/easyjson v0.7.6 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/montanaflynn/stats v0.7.1 // indirect - github.com/nats-io/nats-server/v2 v2.9.17 // indirect - github.com/nats-io/nkeys v0.4.4 // indirect + github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect + github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect + github.com/nats-io/nkeys v0.4.7 // indirect github.com/nats-io/nuid v1.0.1 // indirect - github.com/pelletier/go-toml/v2 v2.0.8 // indirect - github.com/pion/dtls/v2 v2.2.7 // indirect + github.com/pelletier/go-toml/v2 v2.1.1 // indirect + github.com/pion/dtls/v2 v2.1.5 // indirect github.com/pion/logging v0.2.2 // indirect - github.com/pion/transport/v2 v2.2.1 // indirect + github.com/pion/transport v0.13.0 // indirect + github.com/pion/udp v0.1.1 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/plgd-dev/kit/v2 v2.0.0-20211006190727-057b33161b90 - github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b // indirect - github.com/prometheus/client_golang v1.4.0 // indirect - github.com/prometheus/client_model v0.2.0 // indirect - github.com/prometheus/common v0.9.1 // indirect - github.com/prometheus/procfs v0.0.8 // indirect + github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect + github.com/richardlehane/mscfb v1.0.4 // indirect + github.com/richardlehane/msoleps v1.0.3 // indirect github.com/rs/xid v1.5.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect - github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07 // indirect - github.com/tklauser/go-sysconf v0.3.11 // indirect + github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect - github.com/ugorji/go/codec v1.2.11 // indirect + github.com/ugorji/go/codec v1.2.12 // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/scram v1.1.2 // indirect github.com/xdg-go/stringprep v1.0.4 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect - github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect - github.com/yusufpapurcu/wmi v1.2.3 // indirect - go.uber.org/atomic v1.11.0 // indirect - go.uber.org/multierr v1.5.0 // indirect - golang.org/x/arch v0.3.0 // indirect + github.com/xuri/efp v0.0.0-20231025114914-d1ff6096ae53 // indirect + github.com/xuri/nfp v0.0.0-20230919160717-d98342af3f05 // indirect + github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect + github.com/yusufpapurcu/wmi v1.2.4 // indirect + go.uber.org/atomic v1.9.0 // indirect + golang.org/x/arch v0.7.0 // indirect + golang.org/x/crypto v0.19.0 // indirect + golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/sync v0.6.0 // indirect golang.org/x/text v0.14.0 // indirect - golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect - google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c // indirect - gopkg.in/natefinch/lumberjack.v2 v2.2.1 - gopkg.in/yaml.v2 v2.4.0 + golang.org/x/tools v0.7.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/plugin/mqtt_server/mqtt_server.go b/plugin/mqtt_server/mqtt_server.go index 390fab576..27bb1bc70 100644 --- a/plugin/mqtt_server/mqtt_server.go +++ b/plugin/mqtt_server/mqtt_server.go @@ -70,7 +70,7 @@ func (s *MqttServer) Start(r typex.RuleX) error { // s.mqttServer = server server.AddHook(&ahooks{s: s}, nil) - server.AddHook(&mhooks{s: s, locker: sync.Mutex{}}, nil) + server.AddHook(&mHooks{}, nil) glogger.GLogger.Infof("MqttServer start at [%s:%v] successfully", s.Host, s.Port) return nil } @@ -103,29 +103,29 @@ func (s *MqttServer) PluginMetaInfo() typex.XPluginMetaInfo { * */ -type mhooks struct { +type mHooks struct { mqtt.HookBase s *MqttServer locker sync.Mutex } -func (h *mhooks) ID() string { +func (h *mHooks) ID() string { return "events-hooks" } -func (h *mhooks) Provides(b byte) bool { +func (h *mHooks) Provides(b byte) bool { return true } -func (h *mhooks) OnConnect(client *mqtt.Client, pk packets.Packet) { +func (h *mHooks) OnConnect(client *mqtt.Client, pk packets.Packet) error { h.locker.Lock() h.s.clients[client.ID] = client h.locker.Unlock() glogger.GLogger.Debugf("client OnConnect:[%v] %v", client.ID, string(client.Properties.Username)) - + return nil } -func (h *mhooks) OnDisconnect(client *mqtt.Client, err error, expire bool) { +func (h *mHooks) OnDisconnect(client *mqtt.Client, err error, expire bool) { if h.s.clients[client.ID] != nil { h.locker.Lock() delete(h.s.clients, client.ID) @@ -135,7 +135,7 @@ func (h *mhooks) OnDisconnect(client *mqtt.Client, err error, expire bool) { } } -func (h *mhooks) OnPublish(cl *mqtt.Client, pk packets.Packet) (packets.Packet, error) { +func (h *mHooks) OnPublish(cl *mqtt.Client, pk packets.Packet) (packets.Packet, error) { glogger.GLogger.Debugf("client OnPublish:[%v]=%v", pk.TopicName, string(pk.Payload)) return pk, nil } diff --git a/typex/version.go b/typex/version.go index 8d7b5681a..22ba93af4 100644 --- a/typex/version.go +++ b/typex/version.go @@ -14,10 +14,10 @@ type VersionInfo struct { var DefaultVersionInfo = VersionInfo{ Product: "COMMON", - ReleaseTime: "2024-03-14 11:03:04", + ReleaseTime: "2024-03-15 16:36:25", } var Banner = ` - ** Welcome to RULEX framework world <'_'> - -** Version: v0.6.6-9dbe8fe9b098eb1 - - ** More information: https://hootrhino.github.io - + ** Welcome to RULEX framework world <'_'> -. +** Version: v0.6.6-6cf7b4cfac4f7b7 -. + ** More information: https://hootrhino.github.io -. ` diff --git a/utils/gocv_utils.go b/utils/gocv_utils.go index 1e4b5520c..cb6396be3 100644 --- a/utils/gocv_utils.go +++ b/utils/gocv_utils.go @@ -1,3 +1,6 @@ +//go:build amd64 +// +build amd64 + // Copyright (C) 2024 wwhai // // This program is free software: you can redistribute it and/or modify diff --git a/utils/gocv_utils_arm.go b/utils/gocv_utils_arm.go new file mode 100644 index 000000000..b2a41ff87 --- /dev/null +++ b/utils/gocv_utils_arm.go @@ -0,0 +1,38 @@ +//go:build arm +// +build arm + +// Copyright (C) 2024 wwhai +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package utils + +import "fmt" + +/* +* +* Jpeg Stream 帧 +* + */ +type Resolution struct { + Width int `json:"width"` + Height int `json:"height"` +} + +func (O Resolution) String() string { + return fmt.Sprintf("%dx%d", O.Width, O.Height) +} +func CvMatToImageBytes(FrameBuffer []byte) ([]byte, Resolution, error) { + return nil, Resolution{}, nil +} diff --git a/utils/gocv_utils_arm64.go b/utils/gocv_utils_arm64.go new file mode 100644 index 000000000..8672e53b3 --- /dev/null +++ b/utils/gocv_utils_arm64.go @@ -0,0 +1,38 @@ +//go:build arm64 +// +build arm64 + +// Copyright (C) 2024 wwhai +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package utils + +import "fmt" + +/* +* +* Jpeg Stream 帧 +* + */ +type Resolution struct { + Width int `json:"width"` + Height int `json:"height"` +} + +func (O Resolution) String() string { + return fmt.Sprintf("%dx%d", O.Width, O.Height) +} +func CvMatToImageBytes(FrameBuffer []byte) ([]byte, Resolution, error) { + return nil, Resolution{}, nil +}