[Feat]乘客屏直连工控机

This commit is contained in:
chenfufeng
2022-09-19 18:19:03 +08:00
parent 4e123c5f6d
commit d4937769f9
2 changed files with 98 additions and 87 deletions

View File

@@ -2,6 +2,7 @@ package com.mogo.eagle.core.function.call.autopilot
import android.os.SystemClock
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.data.deva.chain.ChainConstant
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_EAGLE_START_AUTOPILOT
@@ -10,6 +11,7 @@ import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LO
import com.mogo.eagle.core.data.trafficlight.TrafficLightResult
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotProvider
import com.mogo.eagle.core.function.call.base.CallerBase
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
import com.zhjt.service.chain.ChainLog
import com.zhjt.service.chain.TracingConstants
import kotlin.random.Random
@@ -40,7 +42,7 @@ object CallerAutoPilotManager {
/**
* 断开与工控机的连接
*/
fun disconnectIpc(){
fun disconnectIpc() {
providerApi?.disconnectIpc()
}
@@ -69,51 +71,70 @@ object CallerAutoPilotManager {
* 发送红绿灯数据至工控机
*/
fun sendTrafficLightData(trafficLightResult: TrafficLightResult) {
providerApi?.sendTrafficLightData(trafficLightResult)
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
providerApi?.sendTrafficLightData(trafficLightResult)
}
}
/**
* 发送 轨迹下载请求
*/
fun sendTrajectoryDownloadReq(autoPilotLine: AutopilotControlParameters.AutoPilotLine) {
providerApi?.sendTrajectoryDownloadReq(autoPilotLine)
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
providerApi?.sendTrajectoryDownloadReq(autoPilotLine)
}
}
/**
* 结束自动驾驶
*/
fun cancelAutoPilot() {
providerApi?.cancelAutoPilot()
// 司机屏才能取消自动驾驶
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
providerApi?.cancelAutoPilot()
}
}
/**
* 开启域控制器录制bag包
*/
fun recordPackage() {
providerApi?.recordPackage(1, Random(SystemClock.elapsedRealtime()).nextInt())
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
providerApi?.recordPackage(1, Random(SystemClock.elapsedRealtime()).nextInt())
}
}
fun recordPackage(duration: Int){
providerApi?.recordPackage(1, Random(SystemClock.elapsedRealtime()).nextInt(),duration)
fun recordPackage(duration: Int) {
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
providerApi?.recordPackage(1, Random(SystemClock.elapsedRealtime()).nextInt(), duration)
}
}
fun recordPackage(type: Int, id: Int) {
providerApi?.recordPackage(type, id)
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
providerApi?.recordPackage(type, id)
}
}
fun recordPackage(type: Int, id: Int, duration: Int) {
providerApi?.recordPackage(type, id, duration)
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
providerApi?.recordPackage(type, id, duration)
}
}
fun recordPackage(type: Int, id: Int, duration: Int,bduration: Int){
providerApi?.recordPackage(type, id, duration, bduration)
fun recordPackage(type: Int, id: Int, duration: Int, bduration: Int) {
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
providerApi?.recordPackage(type, id, duration, bduration)
}
}
/**
* 停止录制bag包
*/
fun stopRecord(type: Int, id: Int) {
providerApi?.stopRecord(type, id)
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
providerApi?.stopRecord(type, id)
}
}
/**
@@ -127,8 +148,8 @@ object CallerAutoPilotManager {
/**
* ADAS日志开启状态
*/
fun isEnableLog(): Boolean{
return providerApi?.isEnableLog()?:false
fun isEnableLog(): Boolean {
return providerApi?.isEnableLog() ?: false
}
@@ -136,11 +157,19 @@ object CallerAutoPilotManager {
* speed单位km/h
*/
fun setAutoPilotSpeed(speed: Int): Boolean {
return providerApi?.setAutoPilotSpeed(speed) ?: false
// 司机屏才可以设置最大速度
return if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
providerApi?.setAutoPilotSpeed(speed) ?: false
} else {
false
}
}
fun recordCause(key: String?, name: String?, id: String?, reason: String?) {
providerApi?.recordCause(key, name, id, reason)
// 乘客屏不需要记录人工接管原因
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
providerApi?.recordCause(key, name, id, reason)
}
}
fun setIPCShutDown() {
@@ -157,7 +186,9 @@ object CallerAutoPilotManager {
* isEnable = false 关闭
*/
fun setDemoMode(isEnable: Boolean) {
providerApi?.setDemoMode(isEnable)
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
providerApi?.setDemoMode(isEnable)
}
}
/**
@@ -173,8 +204,11 @@ object CallerAutoPilotManager {
* isEnable = true 开启
* isEnable = false 关闭
*/
fun setIPCDemoMode(isEnable: Boolean){
providerApi?.setIPCDemoMode(isEnable)
fun setIPCDemoMode(isEnable: Boolean) {
// 司机屏才能控制美化模式(状态是在客户端维护、管理的)
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
providerApi?.setIPCDemoMode(isEnable)
}
}
/**
@@ -182,15 +216,18 @@ object CallerAutoPilotManager {
* isEnable = true 开启
* isEnable = false 关闭
*/
fun setRainMode(isEnable: Boolean){
fun setRainMode(isEnable: Boolean) {
providerApi?.setRainMode(isEnable)
}
/**
* 获取数据采集录制模式配置列表
*/
fun getBadCaseConfig(){
providerApi?.getBadCaseConfig()
fun getBadCaseConfig() {
// 司机屏才能查询数据采集的配置
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
providerApi?.getBadCaseConfig()
}
}
/**
@@ -224,8 +261,10 @@ object CallerAutoPilotManager {
/**
* 发送工控机所有节点重启命令
*/
fun sendIpcReboot(){
providerApi?.sendIpcReboot()
fun sendIpcReboot() {
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
providerApi?.sendIpcReboot()
}
}
/**
@@ -247,22 +286,22 @@ object CallerAutoPilotManager {
/**
* 查询工控机基础配置信息
*/
fun getCarConfig(){
fun getCarConfig() {
providerApi?.getCarConfig()
}
/**
* 获取全局路径
*/
fun getGlobalPath(){
fun getGlobalPath() {
providerApi?.getGlobalPath()
}
/**
*获取协议版本
*/
fun getProtocolVersion(): Int{
return providerApi?.getProtocolVersion() ?:0
fun getProtocolVersion(): Int {
return providerApi?.getProtocolVersion() ?: 0
}
fun connectSpecifiedServer(ip: String) {