| | |
| | | RuleText string // 文字版规则组 |
| | | Location []Rect // 目标的坐标 |
| | | AlarmPolygon string // 触发的报警框 |
| | | Others map[string]interface{} // cacheData: []ResultMsg,(本组规则中含有持续时间的规则开启的定时器缓存的数据帧),linkCache: []ResultMsg ,timeLabel: 00,01,10,11,12 |
| | | Others |
| | | } |
| | | |
| | | type Others struct { |
| | | CacheData []ResultMsg //(本组规则中含有持续时间的规则开启的定时器缓存的数据帧) |
| | | LinkCache []ResultMsg |
| | | TimeLabel string |
| | | } |
| | | // 过规则库打上的标签 |
| | | type FaceResult struct { |
| | | Result |
| | |
| | | taskId := taskGroup.TaskId |
| | | //logger.Println("------------本组任务下的规则组的数量:",len(ruleList)) |
| | | temp := group.Rules // temp为一组完整规则 在此需要判断规则是否是联动规则 |
| | | label := make(map[string]interface{}) |
| | | label := Others{} |
| | | if len(temp) > 0 { |
| | | if group.SetType != "linkTask" { |
| | | // 独立任务的处理 |
| | |
| | | taskId := taskGroup.TaskId |
| | | //logger.Println("------------本组任务下的规则组的数量:",len(ruleList)) |
| | | temp := group.Rules // temp为一组完整规则 在此需要判断规则是否是联动规则 |
| | | label := make(map[string]interface{}) |
| | | label := Others{} |
| | | if len(temp) > 0 { |
| | | if group.SetType == "linkTask" { |
| | | // groupId中含有link则为联动任务 |
| | |
| | | } |
| | | } |
| | | |
| | | func RunRule(args *SdkDatas, groupRule *protomsg.GroupRule, taskId string, message *protomsg.SdkMessage,label map[string]interface{}) bool { |
| | | func RunRule(args *SdkDatas, groupRule *protomsg.GroupRule, taskId string, message *protomsg.SdkMessage,label Others) bool { |
| | | defer func() { |
| | | if err := recover(); err != nil { |
| | | logger.Error("比对规则有误", err.(string)) |
| | |
| | | } |
| | | } |
| | | // 进行定时器的处理和判断 |
| | | timeFlag := TimerAlarm(label, groupRule.GroupId, result.(bool)) |
| | | if timeFlag == "01" || timeFlag == "10" || timeFlag == "11" { // 满足定时器条件 |
| | | timeFlag := TimerAlarm(&label, groupRule.GroupId, result.(bool)) |
| | | if timeFlag == "01" || timeFlag == "10" || timeFlag == "11" { // 没有定时器或者满足定时器条件 |
| | | // 打人脸标签和yolo标签 |
| | | // 最后成功报警才把符合条件的人脸数据塞进结果标签里 |
| | | // 配了人脸的算法才把人脸的数据甩出来打标签 |
| | |
| | | } |
| | | |
| | | // 联动任务的处理 |
| | | func LinkTask(args *SdkDatas, groupRule *protomsg.GroupRule, taskId string, message *protomsg.SdkMessage,label map[string]interface{}) { |
| | | func LinkTask(args *SdkDatas, groupRule *protomsg.GroupRule, taskId string, message *protomsg.SdkMessage,label Others) { |
| | | // new一个定时器,如果以此groupId为标志的定时器不存在的话 |
| | | logger.Info("------------------------------------------当前是联动任务,规则是:", groupRule.GroupText) |
| | | var flag bool = true |
| | |
| | | for _, va := range timeEle.RuleResults { |
| | | if va.CameraId == args.CameraId { |
| | | va.Result = strconv.FormatBool(isOk) |
| | | //va.CacheData = ResultMsg{message,args.RuleResult} |
| | | tempMap := make(map[string]interface{}) |
| | | for k,result := range args.RuleResult { |
| | | tempMap[k] = result |
| | | } |
| | | for _,result := range args.RuleResult["yolo"].([]Result) { |
| | | logger.Warn("放进联动缓存的长度是",len(result.LinkCache)) |
| | | } |
| | | va.CacheData = ResultMsg{message,tempMap} |
| | | logger.Info("这个摄像机--", args.CameraId, "--被赋予了result", va.Result) |
| | | } |
| | | } |
| | |
| | | if result.(bool) { |
| | | logger.Info("___________________________________________________________________联动任务报警") |
| | | // 把数组里缓存的数据取出来一起报警 |
| | | label["linkCache"] = []ResultMsg{} |
| | | label.LinkCache = []ResultMsg{} |
| | | for _, ruleRes := range TimeEleList[groupRule.GroupId].RuleResults { |
| | | label["linkCache"] = append(label["linkCache"].([]ResultMsg),ruleRes.CacheData) |
| | | label.LinkCache = append(label.LinkCache,ruleRes.CacheData) |
| | | } |
| | | logger.Debug("联动任务缓存了几个数据",len(label["linkCache"].([]ResultMsg))) |
| | | //os.Exit(1) |
| | | logger.Debug("联动任务缓存了几个数据",len(label.LinkCache)) |
| | | //for _,result := range args.RuleResult["yolo"].([]Result) { |
| | | // if result.RuleGroupId == groupRule.GroupId { |
| | | // result.Others["linkCache"] = label |
| | | // } |
| | | //} |
| | | for i := 0; i < len(args.RuleResult["yolo"].([]Result)); i++ { |
| | | if args.RuleResult["yolo"].([]Result)[i].RuleGroupId == groupRule.GroupId { // 把原来那个删掉再存一份新的 |
| | | args.RuleResult["yolo"].([]Result)[i].Others.LinkCache = label.LinkCache |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } else { |