From 2d25b62b60da018412ed164b6fd29470498cea17 Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期五, 13 十二月 2019 12:27:39 +0800
Subject: [PATCH] update

---
 proc/single.go |   74 ++++++++++++++++++++++++++----------
 1 files changed, 53 insertions(+), 21 deletions(-)

diff --git a/proc/single.go b/proc/single.go
index bb2c730..31145c4 100644
--- a/proc/single.go
+++ b/proc/single.go
@@ -3,37 +3,66 @@
 import (
 	"analysis/logo"
 	"analysis/util"
-	"analysis/work"
 	"context"
+	"strings"
 )
 
-// SingleRole 鍗曡繘绋�
-func SingleRole(ctx context.Context, typ string, ipcID string, gpu int, shm bool) {
-	util.InitDBAPI()
-
-	if typ == util.FeatAll { // run all proc per proc
-
-		allProc(ctx, gpu, shm)
-	} else if typ == util.FeatFace || typ == util.FeatYolo { // run all face sdk
-
-		sdkProc(ctx, typ, gpu, shm)
-	} else { // run one sdk per proc, typ is facedetect/yolodetect/facecompare etc. id is ipc
-		slaveProc(ctx, typ, ipcID, gpu, shm)
+func slaveProc(ctx context.Context, typ string, id string, gpu int, shm bool) bool {
+	name, ok := prepare(typ, gpu)
+	if !ok {
+		logo.Errorln("SLAVEPROC ERROR: ", name)
+		return false
 	}
 
+	if id != util.FakeSdkID {
+		build(name, id, shm)
+		runAll(ctx)
+	} else {
+
+		util.InitDBAPI()
+
+		sdks := util.SDKInfo()
+		// 棣栧厛杩愯yolo
+		for k, v := range sdks {
+			if strings.EqualFold(typ, v.SdkType) {
+				build(v.SdkType, v.IpcId, shm)
+				logo.Infof("SINGLE PROC ID %s TYPE %s\n", k, v.IpcId, v.SdkType)
+			}
+		}
+
+		runAll(ctx)
+	}
+	return true
 }
 
-func sdkProc(ctx context.Context, typ string, gpu int, shm bool) {
+// SingleRole 鍗曡繘绋�
+func SingleRole(ctx context.Context, typ string, ipcID string, gpu int, shm bool) bool {
+	util.InitDBAPI()
+
+	ret := false
+	if typ == util.FeatAll { // run all proc per proc
+
+		ret = allProc(ctx, gpu, shm)
+	} else if typ == util.FeatFace || typ == util.FeatYolo { // run all face sdk
+
+		ret = sdkProc(ctx, typ, gpu, shm)
+	} else { // run one sdk per proc, typ is facedetect/yolodetect/facecompare etc. id is ipc
+		ret = slaveProc(ctx, typ, ipcID, gpu, shm)
+	}
+	return ret
+}
+
+func sdkProc(ctx context.Context, typ string, gpu int, shm bool) bool {
 	if typ != util.FeatYolo && typ != util.FeatFace {
 		logo.Errorf("NO THIS SDK PROC SDKPROC : ", typ)
 	}
 	rSDK := []string{
-		work.FDetect,
-		work.FCompare,
+		FDetect,
+		FCompare,
 	}
 	if typ == util.FeatYolo {
 		rSDK = rSDK[0:0]
-		rSDK = append(rSDK, work.YDetect)
+		rSDK = append(rSDK, YDetect)
 	}
 	var res []bool
 	for _, v := range rSDK {
@@ -43,7 +72,7 @@
 	for k, v := range res {
 		if !v {
 			logo.Errorln(k, " type proc failed to init")
-			return
+			return false
 		}
 	}
 
@@ -59,12 +88,13 @@
 	}
 
 	runAll(ctx)
+	return true
 }
 
-func allProc(ctx context.Context, gpu int, shm bool) {
+func allProc(ctx context.Context, gpu int, shm bool) bool {
 	var res []bool
 
-	for _, v := range work.SDK {
+	for _, v := range SDK {
 		_, f := prepare(v, gpu)
 		res = append(res, f)
 	}
@@ -72,7 +102,7 @@
 	for k, v := range res {
 		if !v {
 			logo.Errorln(k, " ALL PROC FAILED TO INIT")
-			return
+			return false
 		}
 	}
 
@@ -94,4 +124,6 @@
 	}
 
 	runAll(ctx)
+
+	return true
 }

--
Gitblit v1.8.0