123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package svc
- import (
- commonConfig "cicv-data-closedloop/aarch64/pjisuv/common/config"
- "cicv-data-closedloop/common/util"
- "strings"
- "time"
- )
- /*
- 实车比赛临时使用
- */
- var (
- timeInterval = "5"
- dir = "/root/competition"
- )
- func ForCompetition() {
- util.CreateDir(dir)
- // 1 打包
- var commandArgs = []string{"record", "--split", "--duration=" + timeInterval, "/pji_gps", "/data_read"}
- _, _ = util.ExecuteWithEnvAndDirAsync(commonConfig.RosbagEnvs, dir, commonConfig.RosbagPath, commandArgs...)
- // 2 扫描目录文件
- for {
- time.Sleep(time.Duration(2) * time.Second)
- files, _ := util.ListAbsolutePathAndSort(dir)
- if len(files) >= 2 {
- for i := range files {
- if i == len(files)-1 { // 最后一个包在录制中,不上传
- break
- }
- bagSlice := strings.Split(files[0], "/")
- commonConfig.OssMutex.Lock()
- _ = commonConfig.OssBucket.PutObjectFromFile("competition/"+bagSlice[len(bagSlice)-1], files[0])
- commonConfig.OssMutex.Unlock()
- }
- }
- }
- }
|