| | |
| | | initN = init |
| | | } |
| | | } |
| | | if structure.StaticMap[am.AreaId].Targets == nil || len(structure.StaticMap[am.AreaId].Targets) == 0 { // 即第一帧数据(也不一定),还没有缓存 |
| | | if structure.StaticMap[am.AreaId] == nil || len(structure.StaticMap[am.AreaId].Targets) == 0 { // 即第一帧数据(也不一定),还没有缓存 |
| | | logger.Info("之前无缓存") |
| | | objs := []*structure.Obj{} |
| | | for _, tar := range am.FilterData { |
| | | obj := &structure.Obj{Id: tar.Id, Location: tar.Location, N: initN,InitN:initN} |
| | | obj := &structure.Obj{Id: tar.Id, Location: tar.Location, N: initN,InitN:initN,CacheSdkData:structure.ResultMsg{message, nil}} |
| | | objs = append(objs, obj) |
| | | } |
| | | structure.StaticMap[am.AreaId] = &structure.CameraArea{objs} |
| | |
| | | } |
| | | } |
| | | if flag { // 当前检测对象保持静止(id相等并且重合度高于阈值) |
| | | flagTime := TimerAlarm(lable,person,flag,am.AreaId) |
| | | flagTime := TimerAlarm(o,person,flag,am.AreaId) |
| | | if flagTime == "10" || flagTime == "11" { |
| | | return flag,o |
| | | } else { |
| | | return false,o |
| | | } |
| | | } else { |
| | | TimerAlarm(lable,person,flag,am.AreaId) |
| | | TimerAlarm(o,person,flag,am.AreaId) |
| | | return flag,o |
| | | } |
| | | } |
| | | var rw sync.RWMutex |
| | | // 判断是否符合定时器条件 |
| | | func TimerAlarm(oth *structure.Others,person *structure.Obj, result bool,areaId string) (string) { |
| | | func TimerAlarm(o *structure.Arg,person *structure.Obj, result bool,areaId string) (string) { |
| | | var flagTime string // |
| | | logger.Info("目标的定时器:") |
| | | rw.Lock() |
| | |
| | | if tar.N == 0 && tar.AlarmFlag { |
| | | logger.Debug("-------------------------符合持续时间规则但并不是首次,不报警") |
| | | flagTime = "11" |
| | | oth.TimeLabel = flagTime |
| | | } |
| | | if tar.N == 0 && !tar.AlarmFlag { // 这组规则的定时器要全部等于0 暂且认为一组规则只有一个定时器 |
| | | logger.Debug("———————————-------------首次符合持续时间规则并报警") |
| | | flagTime = "10" |
| | | tar.AlarmFlag = true |
| | | oth.CacheData = []structure.ResultMsg{} |
| | | oth.CacheData = append(oth.CacheData,tar.CacheSdkData) |
| | | oth.TimeLabel = flagTime |
| | | o.CacheData = tar.CacheSdkData |
| | | } |
| | | if tar.N != 0 { |
| | | flagTime = "00" |
| | |
| | | if tar.BufferFlag == 0 { |
| | | logger.Debug("------------------------------杀死计数器,报警此帧状态改变的数据,此时的计数器的值为", tar.N) |
| | | flagTime = "12" |
| | | oth.TimeLabel = flagTime |
| | | structure.StaticMap[areaId].Targets = append(structure.StaticMap[areaId].Targets[:index],structure.StaticMap[areaId].Targets[index+1:]...) |
| | | } else { |
| | | if tar.BufferFlag > 0 { |