Selaa lähdekoodia

test all status

HeWang 7 kuukautta sitten
vanhempi
commit
905dd3f4a8

+ 9 - 7
aarch64/pjibot_guide/control/main.go

@@ -37,20 +37,22 @@ func init() {
 }
 
 func main() {
-	//go judgeState1()
-	//go pkg.JudgeLocal()
-	//go judgeState3()
-
-	var localTurnLength = 2
-	var cloudTurnLength = 60
+	localTurnLength := 2
+	cloudTurnLength := 60
+	overallTurnLength := localTurnLength
+	//lastCloudStatus := "NONE"
 
 	go pkg.GetLocalStatus(&localStatus, localTurnLength)
 	go pkg.GetCloudStatus(&cloudStatus, cloudTurnLength)
 
 	for {
-		time.Sleep(1 * time.Second)
+		time.Sleep(time.Duration(overallTurnLength) * time.Second)
 		fmt.Println("localStatus: ", localStatus)
 		fmt.Println("cloudStatus: ", cloudStatus)
+		//if cloudStatus == "UN_CHANGE" {
+		//	lastCloudStatus = "UN_CHANGE"
+		//	continue
+		//}
 	}
 	//select {}
 }

+ 4 - 1
aarch64/pjibot_guide/control/pkg/judge_cloud.go

@@ -6,13 +6,16 @@ import (
 	"time"
 )
 
+// UN_CHANGE 没有新的任务
+// CHANGE 有新的任务
+// NONE 设备没有配置任务
 func GetCloudStatus(status *string, turnLength int) {
 	// 轮询云端任务状态
 	for {
 		time.Sleep(time.Duration(turnLength) * time.Second)
 		taskStatus, err := commonConfig.GetStatus(commonConfig.PlatformConfig.TaskConfigId)
 		if err != nil {
-			c_log.GlobalLogger.Error("获取配置status失败:", err)
+			c_log.GlobalLogger.Error("获取云端配置status失败:", err)
 			continue
 		}
 		*status = taskStatus

+ 4 - 1
aarch64/pjibot_guide/control/pkg/judge_local.go

@@ -8,6 +8,9 @@ import (
 	"time"
 )
 
+// idle 空闲状态,此状态下可进行任务下发
+// processing 繁忙状态,此状态不接受新任务
+// error 错误状态(硬件,不能正常工作的)
 func GetLocalStatus(status *string, turnLength int) {
 	// 轮询本地任务状态
 	for {
@@ -30,7 +33,7 @@ func GetLocalStatus(status *string, turnLength int) {
 			fmt.Println("statusMessage:", statusMessage)
 			data := statusMessage.Data.(map[string]interface{})
 			fmt.Println("statusMessage.Data", data)
-			fmt.Println("statusMessage.Data[\"taskStatus\"]", data["taskStatus"])
+			fmt.Println("statusMessage.Data[\"taskStatus\"]", data["status"])
 			*status = data["taskStatus"].(string)
 		}
 	}