123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- package main
- import (
- "cicv-data-closedloop/pjisuv_msgs"
- "fmt"
- "sync"
- "time"
- )
- var (
- threshold float64 = 25 / 3.6
- count1 int = 0
- )
- func Topic() string {
- return "/cicv_location"
- }
- // 禁止存在下划线_
- func Label() string {
- return "OverspeedAtNight"
- }
- func Ifatnight() bool {
- // 获取当前时间
- now := time.Now()
- later := now.Add(0 * time.Hour)
- // 获取当前小时
- hour := later.Hour()
- // 判断当前时间是白天还是夜晚
- if hour >= 0 && hour < 5 || hour >= 20 && hour <= 23 {
- return true
- } else {
- return false
- }
- }
- func Rule(shareVars *sync.Map, data *pjisuv_msgs.PerceptionLocalization) string {
- defer func() {
- if r := recover(); r != nil {
- fmt.Println("Recovered from panic:", r)
- }
- }()
- if count1%100 == 0 {
- Automode, _ := shareVars.Load("AutomodeOfPjVehicleFdbPub")
- OutsideWorkshopFlag, _ := shareVars.Load("OutsideWorkshopFlag")
- Automode = Automode.(int16)
- if OutsideWorkshopFlag.(bool) && Automode == 1 && Ifatnight() {
- absspeed, ok := shareVars.Load("AbsSpeed")
- if ok && absspeed.(float64) >= threshold {
- eventLabel := "OverspeedAtNight"
- fmt.Println(eventLabel)
- count1 = 1
- return Label()
- }
- }
- count1 = 1
- }
- count1++
- return ""
- }
|