|
|
@@ -12,7 +12,6 @@ import "C"
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
- "sync"
|
|
|
"time"
|
|
|
|
|
|
"hnyfkj.com.cn/rtu/linux/baseapp"
|
|
|
@@ -38,56 +37,6 @@ func mcuCtrlBoard_ComExit() error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-// 定义_RTU_数据板的工作状态
|
|
|
-type WorkState uint32
|
|
|
-
|
|
|
-const (
|
|
|
- Idle WorkState = 0 // 空闲(默认)
|
|
|
- AppUpgrading WorkState = 1 << 0 // 应用程序-升级中
|
|
|
- PhotoCapturing WorkState = 1 << 1 // 相机数据-拍照中
|
|
|
- PhotoUploading WorkState = 1 << 2 // 相机数据-上传中
|
|
|
- SensorDataReceiving WorkState = 1 << 3 // 环境数据-收集中
|
|
|
- SensorDataUploading WorkState = 1 << 4 // 环境数据-上传中
|
|
|
- SensorHistUploading WorkState = 1 << 5 // 历史数据-上传中
|
|
|
-)
|
|
|
-
|
|
|
-// RTU数据板的工作状态管理器
|
|
|
-type WorkStateMgr struct {
|
|
|
- mu sync.RWMutex
|
|
|
- state WorkState
|
|
|
-}
|
|
|
-
|
|
|
-var GlobalWorkState = &WorkStateMgr{state: Idle}
|
|
|
-
|
|
|
-// 工作状态管理-添加一个状态
|
|
|
-func (mgr *WorkStateMgr) Add(s WorkState) {
|
|
|
- mgr.mu.Lock()
|
|
|
- defer mgr.mu.Unlock()
|
|
|
- mgr.state |= s
|
|
|
-}
|
|
|
-
|
|
|
-// 工作状态管理-清除一个状态
|
|
|
-func (mgr *WorkStateMgr) Remove(s WorkState) {
|
|
|
- mgr.mu.Lock()
|
|
|
- defer mgr.mu.Unlock()
|
|
|
- mgr.state &^= s
|
|
|
-}
|
|
|
-
|
|
|
-// 工作状态管理-获取当前状态
|
|
|
-// 判断某个状态是否存在
|
|
|
-func (mgr *WorkStateMgr) Get() WorkState {
|
|
|
- mgr.mu.RLock()
|
|
|
- defer mgr.mu.RUnlock()
|
|
|
- return mgr.state
|
|
|
-}
|
|
|
-
|
|
|
-// 工作状态管理-状态是否存在
|
|
|
-func (mgr *WorkStateMgr) Has(s WorkState) bool {
|
|
|
- mgr.mu.RLock()
|
|
|
- defer mgr.mu.RUnlock()
|
|
|
- return mgr.state&s != 0
|
|
|
-}
|
|
|
-
|
|
|
// 判断输入字符串是请求/应答
|
|
|
func DetectJsonRole(jsonStr string) string {
|
|
|
var obj map[string]json.RawMessage
|
|
|
@@ -104,10 +53,6 @@ func DetectJsonRole(jsonStr string) string {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// 处理控制板返回的-请求应答
|
|
|
-func (board *MCUCtrlBoard) handleResponse(jsonStr string) {
|
|
|
-}
|
|
|
-
|
|
|
//export RTU_JsonMsgProcCb
|
|
|
func RTU_JsonMsgProcCb(jsonStr *C.char) *C.char {
|
|
|
s := C.GoString(jsonStr)
|
|
|
@@ -246,3 +191,7 @@ func (board *MCUCtrlBoard) powerDown(r *jsonrpc2.Request) (*jsonrpc2.Response, e
|
|
|
|
|
|
return jsonrpc2.BuildResult(r, wjson)
|
|
|
}
|
|
|
+
|
|
|
+// 处理控制板返回的请求
|
|
|
+func (board *MCUCtrlBoard) handleResponse(jsonStr string) {
|
|
|
+}
|