LingxinMeng hace 1 año
padre
commit
f4e4fef862

+ 1 - 10
aarch64/pji/common/config/c_resource.go

@@ -6,15 +6,6 @@ import (
 	"time"
 )
 
-//type DeviceMonitor struct {
-//	Id               int    `db:"id" json:"id"`                               // 自增id
-//	TotalCpuUsage    string `db:"total_cpu_usage" json:"totalCpuUsage"`       // cpu总占用
-//	TotalMemoryUsage string `db:"total_memory_usage" json:"totalMemoryUsage"` // 内存总占用
-//	Top10Process     string `db:"top10_process" json:"top10Process"`          // cpu占用前十的进程信息
-//	DeviceNumber     string `db:"device_number" json:"deviceNumber"`          // cpu占用前十的进程信息
-//	SocIp            string `db:"soc_ip" json:"socIp"`                        // cpu占用前十的进程信息
-//}
-
 // SendResourceUsage 保存资源占用情况
 func SendResourceUsage() {
 	for {
@@ -25,7 +16,7 @@ func SendResourceUsage() {
 			map[string]string{
 				"totalCpuUsage":    util.ToString(util.GetCpuPercent()),
 				"totalMemoryUsage": util.ToString(util.GetMemoryPercent()),
-				"top10Process":     util.ToString(util.GetTop10()),
+				"top10Process":     util.ToString(util.GetTop10Cpu()),
 				"deviceNumber":     LocalConfig.EquipmentNo,
 				"socIp":            LocalConfig.Node.Ip,
 			},

+ 1 - 10
aarch64/pjisuv/common/config/c_resource.go

@@ -6,15 +6,6 @@ import (
 	"time"
 )
 
-//type DeviceMonitor struct {
-//	Id               int    `db:"id" json:"id"`                               // 自增id
-//	TotalCpuUsage    string `db:"total_cpu_usage" json:"totalCpuUsage"`       // cpu总占用
-//	TotalMemoryUsage string `db:"total_memory_usage" json:"totalMemoryUsage"` // 内存总占用
-//	Top10Process     string `db:"top10_process" json:"top10Process"`          // cpu占用前十的进程信息
-//	DeviceNumber     string `db:"device_number" json:"deviceNumber"`          // cpu占用前十的进程信息
-//	SocIp            string `db:"soc_ip" json:"socIp"`                        // cpu占用前十的进程信息
-//}
-
 // 保存资源占用情况
 func SendResourceUsage() {
 	for {
@@ -25,7 +16,7 @@ func SendResourceUsage() {
 			map[string]string{
 				"totalCpuUsage":    util.ToString(util.GetCpuPercent()),
 				"totalMemoryUsage": util.ToString(util.GetMemoryPercent()),
-				"top10Process":     util.ToString(util.GetTop10()),
+				"top10Process":     util.ToString(util.GetTop10Cpu()),
 				"deviceNumber":     LocalConfig.EquipmentNo,
 				"socIp":            LocalConfig.Node.Ip,
 			},

+ 132 - 0
aarch64/pjisuv/common/config/yaml/pjisuv-006-cloud-config.yaml

@@ -0,0 +1,132 @@
+---
+monitor:
+  url: http://36.110.106.142:12341/web_server/monitor/insert
+platform:
+  url-device-auth: http://1.202.169.139:8081/device/auth
+  url-task-poll: http://1.202.169.139:8081/device/task/poll
+  url-task: http://1.202.169.139:8081/device/task
+full-collect: true
+bag-number: 3 # 无人驾驶比赛期间,这里不需要缓存
+config-refresh-interval: 60
+disk:
+  name: /dev/vdb # 磁盘名称
+  used: 800000000000 # 磁盘占用阈值,单位bytes
+bag-data-dir: /mnt/media/sda1/cicv-data-closedloop/data/
+bag-copy-dir: /mnt/media/sda1/cicv-data-closedloop/copy/
+time-to-label-json-path: /mnt/media/sda1/cicv-data-closedloop/timeToLabel.json
+triggers-dir: /mnt/media/sda1/cicv-data-closedloop/triggers/
+time-window-send-gap: 6
+tcp-port: 12340
+rpc-port: 12341
+ros:
+  master-address: 192.168.1.102:11311
+  nodes:
+    - /camera_output
+    - /ins
+    - /lidar_pretreatment
+    - /sensorfusion
+    - /planner_s4
+    - /control
+hosts:
+  - name: node1
+    ip: 192.168.1.102
+    rosbag:
+      path: "/opt/ros/melodic/bin/rosbag"
+      envs:
+        - "LD_LIBRARY_PATH=/opt/ros/melodic/lib:/usr/lib::/usr/lib:/userdata/third_lib/libaicc"
+        - "ROS_ETC_DIR=/opt/ros/melodic/etc/ros"
+        - "USER=root"
+        - "ROS_OS_OVERRIDE=openembedded"
+        - "PWD=/mnt/media/sda1/cicv-data-closedloop"
+        - "HOME=/home/root"
+        - "CMAKE_PREFIX_PATH=/opt/ros/melodic:/usr"
+        - "ROS_ROOT=/opt/ros/melodic/share/ros"
+        - "ROS_MASTER_URI=http://192.168.1.102:11311"
+        - "ROS_VERSION=1"
+        - "ROS_PYTHON_VERSION=2"
+        - "ROS_IP=192.168.1.102"
+        - "PYTHONPATH=/opt/ros/melodic/lib/python2.7/site-packages:/usr/lib/python2.7/site-packages"
+        - "ROS_PACKAGE_PATH=/opt/ros/melodic/share"
+        - "PATH=/opt/ros/melodic/bin:/usr/bin/cyber/tools/cyber_service:/usr/bin/cyber/tools/cyber_node:/usr/bin/cyber/tools/cyber_channel:/usr/bin/cyber/tools/cyber_launch:/usr/bin/cyber/tools/cyber_monitor:/usr/bin/cyber/tools/cyber_recorder:/apollo/bazel-bin/cyber:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"
+        - "PKG_CONFIG_PATH=/usr/lib/pkgconfig"
+        - "ROS_DISTRO=melodic"
+    topics:
+      - /camera_image # /camera_output
+      - /cicv_amr_trajectory #  /planner_s4
+      - /pj_control_pub # /control
+      - /data_read
+  - name: node2
+    ip: 192.168.1.103
+    rosbag:
+      path: "/opt/ros/melodic/bin/rosbag"
+      envs:
+        - "LD_LIBRARY_PATH=/opt/ros/melodic/lib:/usr/lib::/usr/lib:/userdata/third_lib"
+        - "ROS_ETC_DIR=/opt/ros/melodic/etc/ros"
+        - "USER=root"
+        - "ROS_OS_OVERRIDE=openembedded"
+        - "PWD=/mnt/media/sda1/cicv-data-closedloop"
+        - "HOME=/home/root"
+        - "CMAKE_PREFIX_PATH=/opt/ros/melodic:/usr"
+        - "ROS_ROOT=/opt/ros/melodic/share/ros"
+        - "ROS_MASTER_URI=http://192.168.1.102:11311"
+        - "ROS_VERSION=1"
+        - "ROS_PYTHON_VERSION=2"
+        - "ROS_IP=192.168.1.103"
+        - "PYTHONPATH=/opt/ros/melodic/lib/python2.7/site-packages:/usr/lib/python2.7/site-packages"
+        - "ROS_PACKAGE_PATH=/opt/ros/melodic/share"
+        - "PATH=/opt/ros/melodic/bin:/usr/bin/cyber/tools/cyber_service:/usr/bin/cyber/tools/cyber_node:/usr/bin/cyber/tools/cyber_channel:/usr/bin/cyber/tools/cyber_launch:/usr/bin/cyber/tools/cyber_monitor:/usr/bin/cyber/tools/cyber_recorder:/apollo/bazel-bin/cyber:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin "
+        - "PKG_CONFIG_PATH=/usr/lib/pkgconfig"
+        - "ROS_DISTRO=melodic"
+    topics:
+      - /points_concat  # /lidar_pretreatment
+      - /tpperception # /sensorfusion
+      - /cicv_location  # /ins
+triggers:
+  - label: rapidaccel
+    topics:
+      - /tpperception
+      - /points_concat
+      - /cicv_location
+      - /camera_image
+  - label: brake
+    topics:
+      - /tpperception
+      - /points_concat
+      - /cicv_location
+      - /camera_image
+  - label: EmergencyStop
+    topics:
+      - /tpperception
+      - /points_concat
+      - /cicv_location
+      - /camera_image
+  - label: AutoDLimit
+    topics:
+      - /tpperception
+      - /points_concat
+      - /cicv_location
+      - /camera_image
+  - label: lanechange
+    topics:
+      - /tpperception
+      - /points_concat
+      - /cicv_location
+      - /camera_image
+  - label: brakefault
+    topics:
+      - /tpperception
+      - /points_concat
+      - /cicv_location
+      - /camera_image
+  - label: takeover
+    topics:
+      - /tpperception
+      - /points_concat
+      - /cicv_location
+      - /camera_image
+  - label: TTC
+    topics:
+      - /tpperception
+      - /points_concat
+      - /cicv_location
+      - /camera_image

+ 19 - 0
aarch64/pjisuv/common/config/yaml/pjisuv-006-soc1-local-config.yaml

@@ -0,0 +1,19 @@
+node:
+  name: node1
+  ip: 192.168.1.102
+# 数据闭环平台参数
+equipment-no: pjisuv-006
+secret-key: d1nxtlzwkrc99sf3
+# 获取oss连接信息的接口url
+url-get-oss-config: http://36.110.106.156:18379/oss/config?token=nXonLUcMtGcrQqqKiyygIwyVbvizE0wD
+# 金龙车数据前缀
+oss-base-prefix: pjisuv/
+# oss上的配置文件的名称
+cloud-config-filename: cloud-config.yaml
+# 将oss上的配置文件下载到本地的路径
+cloud-config-local-path: /mnt/media/sda1/cicv-data-closedloop/config/cloud-config.yaml
+restart-cmd:
+  dir: "/mnt/media/sda1/cicv-data-closedloop/"
+  name: "sh"
+  args:
+    - "start-soc1.sh"

+ 18 - 20
aarch64/pjisuv/master/main.go

@@ -2,8 +2,6 @@ package main
 
 import (
 	commonConfig "cicv-data-closedloop/aarch64/pjisuv/common/config"
-	commonService "cicv-data-closedloop/aarch64/pjisuv/common/service"
-	masterConfig "cicv-data-closedloop/aarch64/pjisuv/master/config"
 	"cicv-data-closedloop/aarch64/pjisuv/master/service"
 	"cicv-data-closedloop/common/config/c_log"
 	"cicv-data-closedloop/common/util"
@@ -29,29 +27,29 @@ func init() {
 	commonConfig.InitRosConfig()
 	// 发送资源占用信息
 	go commonConfig.SendResourceUsage()
-	// 维护data目录缓存的包数量
-	go commonService.BagCacheClean()
-	// 磁盘占用过高时根据缓存策略处理copy目录
-	go commonService.DiskClean()
-	// 初始化加载触发器插件文件
-	masterConfig.InitTriggerConfig()
-	// 初始化rpc监听
-	commonConfig.InitKillSignalListener(commonConfig.CloudConfig.Hosts[0].Ip)
-	// 等待重启,接收到重启信号,会把信号分发给以下channel
-	go commonService.WaitKillSelf()
+	//// 维护data目录缓存的包数量
+	//go commonService.BagCacheClean()
+	//// 磁盘占用过高时根据缓存策略处理copy目录
+	//go commonService.DiskClean()
+	//// 初始化加载触发器插件文件
+	//masterConfig.InitTriggerConfig()
+	//// 初始化rpc监听
+	//commonConfig.InitKillSignalListener(commonConfig.CloudConfig.Hosts[0].Ip)
+	//// 等待重启,接收到重启信号,会把信号分发给以下channel
+	//go commonService.WaitKillSelf()
 
 }
 
 func main() {
 
-	// 1 负责打包数据到data目录
-	go commonService.BagRecord(commonConfig.CloudConfig.Hosts[0].Name)
-	// 2 启动第4个线程,负责监控故障,并修改timeWindow
-	go svc.PrepareTimeWindowProducerQueue()
-	// 3
-	go svc.RunTimeWindowProducerQueue()
-	// 4 排队运行时间窗口
-	go commonService.RunTimeWindowConsumerQueue(commonConfig.CloudConfig.Hosts[0].Name)
+	//// 1 负责打包数据到data目录
+	//go commonService.BagRecord(commonConfig.CloudConfig.Hosts[0].Name)
+	//// 2 启动第4个线程,负责监控故障,并修改timeWindow
+	//go svc.PrepareTimeWindowProducerQueue()
+	//// 3
+	//go svc.RunTimeWindowProducerQueue()
+	//// 4 排队运行时间窗口
+	//go commonService.RunTimeWindowConsumerQueue(commonConfig.CloudConfig.Hosts[0].Name)
 
 	// todo 算法比赛临时使用
 	go svc.ForCompetition()

+ 18 - 9
amd64/dispatch-server/package/handler/start_project.go

@@ -1,6 +1,7 @@
 package handler
 
 import (
+	entity2 "cicv-data-closedloop/amd64/dispatch-server/package/entity"
 	"cicv-data-closedloop/common/config/c_log"
 	"cicv-data-closedloop/common/entity"
 	"github.com/gin-gonic/gin"
@@ -116,20 +117,28 @@ import (
  * }
  */
 
-type StartProjectParam struct {
-}
-
 func StartProject(c *gin.Context) {
-	projectStartParam := new(StartProjectParam)
+	projectStartParam := new(entity2.Project)
 	if err := c.ShouldBindJSON(&projectStartParam); err != nil {
 		c_log.GlobalLogger.Error("项目启动接收请求参数报错:", err)
 		c.JSON(http.StatusBadRequest, entity.HttpResult{Status: false, Code: "1003", Message: "请求参数格式错误。"})
 		return
 	}
-	// 1 场景
-	// 2 动力学模型
-	// 3 传感器
-	// 4 算法
-	//service
+	// 1 维护一个运行任务队列,绑定用户id和节点名称,供下面两个判断同时使用(使用redis的队列)
+	// 2 获取正在运行的任务数量,在缓存中
+	// 3 判断用户并行度
+	{
+		// 1 获取接收到的任务数量
+		//taskCount := len(projectStartParam.Tasks)
+
+		// 2 判断是否可以运行,可以运行的加入中间队列进行集群并行度判断,不能运行的加入用户等待队列
+
+	}
+	// 3 判断集群并行度
+	{
+		// 1 获取集群并行度
+		// 2 判断是否可以运行,可以运行的执行运行命令并加入运行队列,不能运行的加入集群等待队列
+	}
+	// 4 返回
 	c.JSON(http.StatusOK, entity.HttpResult{Status: true, Code: "2000", Message: "项目启动请求已被成功接收,等待调度处理。"})
 }

+ 4 - 0
amd64/web_server/handler/h_monitor.go

@@ -15,6 +15,8 @@ type DeviceMonitor struct {
 	TotalCpuUsage    string    `db:"total_cpu_usage" json:"totalCpuUsage"`       // cpu总占用
 	TotalMemoryUsage string    `db:"total_memory_usage" json:"totalMemoryUsage"` // 内存总占用
 	Top10Process     string    `db:"top10_process" json:"top10Process"`          // cpu占用前十的进程信息
+	Top10Cpu         string    `db:"top10_cpu" json:"top10Cpu"`                  // cpu占用前十的进程信息
+	Top10Mem         string    `db:"top10_mem" json:"top10Mem"`                  // 内存占用前十的进程信息
 	DeviceNumber     string    `db:"device_number" json:"deviceNumber"`          // 设备编号
 	SocIp            string    `db:"soc_ip" json:"socIp"`                        // 芯片IP
 	ReportTime       time.Time `db:"report_time" json:"reportTime"`              // 数据上报时间
@@ -38,6 +40,8 @@ func SaveDeviceMonitor(c *gin.Context) {
 		param.TotalCpuUsage,
 		param.TotalMemoryUsage,
 		param.Top10Process,
+		param.Top10Cpu,
+		param.Top10Mem,
 		param.DeviceNumber,
 		param.SocIp,
 		time.Now(),

+ 3 - 2
amd64/web_server/sql/insert_device_monitor.sql

@@ -1,2 +1,3 @@
-insert into device_monitor(total_cpu_usage, total_memory_usage, top10_process, device_number, soc_ip, report_time)
-values (?, ?, ?, ?, ?, ?)
+insert into device_monitor(total_cpu_usage, total_memory_usage, top10_process, top10_cpu, top10_mem, device_number,
+                           soc_ip, report_time)
+values (?, ?, ?, ?, ?, ?, ?, ?)

+ 4 - 5
common/util/u_resource.go

@@ -1,7 +1,6 @@
 package util
 
 import (
-	"fmt"
 	"github.com/shirou/gopsutil/cpu"
 	"github.com/shirou/gopsutil/disk"
 	"github.com/shirou/gopsutil/mem"
@@ -13,11 +12,11 @@ import (
 	"time"
 )
 
-func GetTop10() []string {
+func GetTop10Cpu() []string {
 	// 获取所有进程的CPU占用率
 	processes, err := process.Processes()
 	if err != nil {
-		fmt.Println("Error:", err)
+		//fmt.Println("Error:", err)
 		return nil
 	}
 
@@ -43,7 +42,7 @@ func GetTop10() []string {
 	})
 
 	// 输出前10个CPU占用率最高的进程名称
-	fmt.Println("Top 10 processes by CPU usage:")
+	//fmt.Println("Top 10 processes by CPU usage:")
 	var top10 []string
 	for i, pid := range sortedPids {
 		if i >= 10 {
@@ -55,7 +54,7 @@ func GetTop10() []string {
 		}
 		name, _ := p.Name()
 		top10 = append(top10, name)
-		fmt.Printf("%d. %s (PID: %d, CPU Usage: %.2f%%)\n", i+1, name, pid, cpuPercent[pid])
+		//fmt.Printf("%d. %s (PID: %d, CPU Usage: %.2f%%)\n", i+1, name, pid, cpuPercent[pid])
 	}
 	return top10
 }