BadCase
完善逻辑
This commit is contained in:
@@ -23,8 +23,10 @@ import com.mogo.eagle.core.utilcode.reminder.Reminder
|
||||
import com.mogo.eagle.core.utilcode.reminder.api.IReminder
|
||||
import com.mogo.eagle.core.utilcode.reminder.api.IReminder.IGlobalStateChangeListener
|
||||
import com.mogo.eagle.core.utilcode.util.ClickUtils
|
||||
import com.mogo.eagle.core.utilcode.util.NetworkUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.biz.*
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.consts.BadCaseConfig
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.repository.db.entity.AutoPilotRecord
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.repository.net.api.entity.BadCaseResponse.Reason
|
||||
import com.zhjt.mogo_core_function_devatools.ext.enqueuePop
|
||||
@@ -104,14 +106,21 @@ internal object BadCaseManager : LifecycleEventObserver {
|
||||
val activity = view.context as? FragmentActivity ?: throw IllegalStateException("please ensure context is FragmentActivity.")
|
||||
view.setOnClickListener {
|
||||
if(ClickUtils.isFastClick()){
|
||||
val initiativeBadCaseWindow = InitiativeBadCaseWindow(activity)
|
||||
initiativeBadCaseWindow.setClickListener(object: InitiativeBadCaseWindow.ClickListener{
|
||||
override fun closeWindow() {
|
||||
initiativeBadCaseWindow.hideFloatWindow()
|
||||
if(NetworkUtils.isConnected()){
|
||||
if(BadCaseConfig.dockerVersion!=null){
|
||||
val initiativeBadCaseWindow = InitiativeBadCaseWindow(activity)
|
||||
initiativeBadCaseWindow.setClickListener(object: InitiativeBadCaseWindow.ClickListener{
|
||||
override fun closeWindow() {
|
||||
initiativeBadCaseWindow.hideFloatWindow()
|
||||
}
|
||||
})
|
||||
initiativeBadCaseWindow.showFloatWindow()
|
||||
}else{
|
||||
ToastUtils.showShort("工控机连接状态异常")
|
||||
}
|
||||
|
||||
})
|
||||
initiativeBadCaseWindow.showFloatWindow()
|
||||
}else{
|
||||
ToastUtils.showShort("网络异常,请检查网络")
|
||||
}
|
||||
}else{
|
||||
ToastUtils.showShort("请勿连续点击,稍后再试")
|
||||
}
|
||||
@@ -126,13 +135,21 @@ internal object BadCaseManager : LifecycleEventObserver {
|
||||
val activity = view.context as? FragmentActivity ?: throw IllegalStateException("please ensure context is FragmentActivity.")
|
||||
view.setOnClickListener {
|
||||
if(ClickUtils.isFastClick()){
|
||||
val aiDataCollectWindow = AIDataCollectWindow(activity)
|
||||
aiDataCollectWindow.setClickListener(object: AIDataCollectWindow.ClickListener{
|
||||
override fun closeWindow() {
|
||||
aiDataCollectWindow.hideFloatWindow()
|
||||
if(NetworkUtils.isConnected()){
|
||||
if(BadCaseConfig.dockerVersion!=null){
|
||||
val aiDataCollectWindow = AIDataCollectWindow(activity)
|
||||
aiDataCollectWindow.setClickListener(object: AIDataCollectWindow.ClickListener{
|
||||
override fun closeWindow() {
|
||||
aiDataCollectWindow.hideFloatWindow()
|
||||
}
|
||||
})
|
||||
aiDataCollectWindow.showFloatWindow()
|
||||
}else{
|
||||
ToastUtils.showShort("工控机连接状态异常")
|
||||
}
|
||||
})
|
||||
aiDataCollectWindow.showFloatWindow()
|
||||
}else{
|
||||
ToastUtils.showShort("网络异常,请检查网络")
|
||||
}
|
||||
}else{
|
||||
ToastUtils.showShort("请勿连续点击,稍后再试")
|
||||
}
|
||||
|
||||
@@ -5,15 +5,21 @@ import android.app.Activity
|
||||
import android.graphics.PixelFormat
|
||||
import android.os.SystemClock
|
||||
import android.util.DisplayMetrics
|
||||
import android.util.Log
|
||||
import android.view.*
|
||||
import android.widget.RadioButton
|
||||
import android.widget.TextView
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.eagle.core.data.app.AppConfigInfo
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarStateListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotRecordListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_DEVA
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast
|
||||
import com.mogo.eagle.core.utilcode.util.AppUtils
|
||||
import com.mogo.eagle.core.utilcode.util.TimeUtils
|
||||
import com.mogo.eagle.core.utilcode.util.TimeUtils.millis2String
|
||||
import com.zhjt.mogo_core_function_devatools.R
|
||||
@@ -21,6 +27,7 @@ import com.zhjt.mogo_core_function_devatools.badcase.consts.BadCaseConfig
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.toRecord
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import record_cache.RecordPanelOuterClass
|
||||
import java.lang.reflect.Field
|
||||
import java.util.*
|
||||
@@ -31,7 +38,7 @@ import java.util.*
|
||||
* @since: 2022/7/12
|
||||
*/
|
||||
class AIDataCollectWindow constructor(activity: Activity) : View.OnTouchListener,
|
||||
IMoGoAutopilotRecordListener {
|
||||
IMoGoAutopilotRecordListener , IMoGoAutopilotCarStateListener {
|
||||
|
||||
companion object {
|
||||
const val TAG = "AIDataCollectWindow"
|
||||
@@ -56,6 +63,10 @@ class AIDataCollectWindow constructor(activity: Activity) : View.OnTouchListener
|
||||
private lateinit var tvCollectCancel: TextView //取消按钮
|
||||
|
||||
private var collectReason: String = "大型车:大货、大巴、特种车辆"
|
||||
private var recordKey: String?=null //录制bag包key
|
||||
private var recordFileName: String?=null //录制文件包名
|
||||
private var longitude: Double?=null
|
||||
private var latitude: Double?=null
|
||||
|
||||
private lateinit var mFloatLayout: View
|
||||
private var mInViewX = 0f
|
||||
@@ -96,14 +107,17 @@ class AIDataCollectWindow constructor(activity: Activity) : View.OnTouchListener
|
||||
tvCollectNum.text = BadCaseConfig.windowNum.toString()
|
||||
BadCaseConfig.windowNum++
|
||||
tvCollectTime.text ="时间:${millis2String(System.currentTimeMillis(),TimeUtils.getHourMinSecondFormat())}"
|
||||
|
||||
//采集结果回调监听
|
||||
CallerAutopilotRecordListenerManager.addListener(TAG,this)
|
||||
// 添加 ADAS车辆状态&定位 监听
|
||||
CallerAutopilotCarStatusListenerManager.addListener(TAG, this)
|
||||
//开始录制AI数据采集Bag包
|
||||
CallerAutoPilotManager.recordPackage(
|
||||
99,
|
||||
Random(SystemClock.elapsedRealtime()).nextInt(),
|
||||
20,
|
||||
12
|
||||
)
|
||||
|
||||
//大型车
|
||||
rbLargeCar.setOnClickListener{
|
||||
setRadioButtonStatus(
|
||||
@@ -200,26 +214,28 @@ class AIDataCollectWindow constructor(activity: Activity) : View.OnTouchListener
|
||||
tvCollectReport.setOnClickListener {
|
||||
GlobalScope.launch{
|
||||
val uploadResult = presenter.upload(mutableMapOf<String, String>().also { itx ->
|
||||
itx["carLicense"] = "DFD02313"
|
||||
itx["filename"] = "/home/mogo/data/bags/badcase/20220706145143/20220706145143-265939904-rosmaster-XXXX000000.bag"
|
||||
itx["filesize"] = "0"
|
||||
itx["key"] = "265939904"
|
||||
itx["reason"] = collectReason
|
||||
itx["duration"] = "16"
|
||||
itx["startTime"] = "20220706145203"
|
||||
itx["channel"] = "AI"
|
||||
itx["carSn"] = MoGoAiCloudClientConfig.getInstance().sn
|
||||
itx["userRole"] = "安全员"
|
||||
itx["audioUrl"] = "http://petchfile-1255510688.cos.ap-beijing.myqcloud.com/CarPad/mogopadlog/deviceId/2022-07-07/AUDIO_myTest.wav"
|
||||
itx["mapVersion"] = "MAP-taxi-hq_RoboTaxi_hq_H9_2.3.0.5_20220410"
|
||||
itx["eyeVersion"] = "2.8.0"
|
||||
itx["coordinate"] = ""
|
||||
itx["carLicense"] = AppConfigInfo.plateNumber?:"" //车牌号
|
||||
itx["filename"] = recordFileName?:"" //bag包文件地址
|
||||
itx["filesize"] = "0" //bag包文件大小
|
||||
itx["key"] = recordKey?:"" //key
|
||||
itx["reason"] = collectReason //采集原因
|
||||
itx["duration"] = "20" //采集时长,固定为20S
|
||||
itx["startTime"] = System.currentTimeMillis().toString() //上报时间(时间戳格式)
|
||||
itx["channel"] = "AI" //渠道
|
||||
itx["carSn"] = MoGoAiCloudClientConfig.getInstance().sn //SN
|
||||
itx["userRole"] = "" //采集者角色
|
||||
itx["audioUrl"] = "" //音频COS地址
|
||||
itx["mapVersion"] = BadCaseConfig.dockerVersion ?:"" //工控机版本
|
||||
itx["eyeVersion"] = AppUtils.getAppVersionName() //鹰眼版本
|
||||
itx["coordinate"] = "latitude:${latitude};longitude:${longitude}" //坐标
|
||||
|
||||
})
|
||||
if (uploadResult == null || uploadResult.code != 200) {
|
||||
TipToast.shortTip("上报失败")
|
||||
} else {
|
||||
TipToast.shortTip("上报成功")
|
||||
BadCaseConfig.windowNum--
|
||||
clickListener?.closeWindow()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -241,17 +257,24 @@ class AIDataCollectWindow constructor(activity: Activity) : View.OnTouchListener
|
||||
it.gravity = Gravity.START or Gravity.TOP
|
||||
it.width = 924
|
||||
it.height = 668
|
||||
it.alpha = 0.9f
|
||||
it.alpha = 1.0f
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
override fun onAutopilotRecordResult(recordPanel: RecordPanelOuterClass.RecordPanel) {
|
||||
CallerLogger.d("${M_DEVA}${TAG}", "-- 收到工控机录制任务回调 -- $recordPanel")
|
||||
when(recordPanel.toRecord().stat){
|
||||
if(recordKey==null){
|
||||
recordKey = recordPanel.key.toString()
|
||||
}
|
||||
if(recordFileName==null){
|
||||
recordFileName = recordPanel.filename
|
||||
}
|
||||
when(recordPanel.stat){
|
||||
100, 101 ->{
|
||||
//成功结束录制
|
||||
TipToast.shortTip("bag录制成功")
|
||||
|
||||
TipToast.shortTip("${millis2String(System.currentTimeMillis(),TimeUtils.getHourMinSecondFormat())}bag录制成功")
|
||||
}
|
||||
300 ->{
|
||||
//开始录制
|
||||
@@ -259,7 +282,7 @@ class AIDataCollectWindow constructor(activity: Activity) : View.OnTouchListener
|
||||
}
|
||||
200 ->{
|
||||
//录制失败
|
||||
TipToast.shortTip("bag录制失败")
|
||||
TipToast.shortTip("${millis2String(System.currentTimeMillis(),TimeUtils.getHourMinSecondFormat())}bag录制失败")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -296,9 +319,6 @@ class AIDataCollectWindow constructor(activity: Activity) : View.OnTouchListener
|
||||
// 手指移动的时候更新小悬浮窗的位置
|
||||
mWindowManager!!.updateViewLayout(mFloatLayout, mWindowParams)
|
||||
}
|
||||
// MotionEvent.ACTION_UP -> // 如果手指离开屏幕时,xDownInScreen和xInScreen相等,且yDownInScreen和yInScreen相等,则视为触发了单击事件。
|
||||
// if (mDownInScreenX === mInScreenX && mDownInScreenY === mInScreenY) {
|
||||
// }
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -309,12 +329,16 @@ class AIDataCollectWindow constructor(activity: Activity) : View.OnTouchListener
|
||||
// 默认固定位置,靠屏幕右边缘的中间
|
||||
mWindowManager!!.defaultDisplay.getMetrics(metrics)
|
||||
mWindowParams!!.x = metrics.widthPixels
|
||||
mWindowParams!!.y = metrics.heightPixels / 2 - getSysBarHeight(mActivity)
|
||||
mWindowParams!!.y = metrics.heightPixels / 2 - getSysBarHeight(mActivity)-350
|
||||
mWindowManager!!.addView(mFloatLayout, mWindowParams)
|
||||
}
|
||||
}
|
||||
|
||||
fun hideFloatWindow() {
|
||||
//注销采集结果回调监听
|
||||
CallerAutopilotRecordListenerManager.removeListener(TAG)
|
||||
// 移除 ADAS车辆状态&定位 监听
|
||||
CallerAutopilotCarStatusListenerManager.removeListener(TAG)
|
||||
if (mFloatLayout.parent != null) mWindowManager!!.removeView(mFloatLayout)
|
||||
}
|
||||
|
||||
@@ -345,4 +369,9 @@ class AIDataCollectWindow constructor(activity: Activity) : View.OnTouchListener
|
||||
fun closeWindow()
|
||||
}
|
||||
|
||||
override fun onAutopilotCarStateData(gnssInfo: MessagePad.GnssInfo?) {
|
||||
latitude = gnssInfo?.latitude
|
||||
longitude = gnssInfo?.longitude
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,25 +3,52 @@ package com.zhjt.mogo_core_function_devatools.badcase.biz
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.graphics.PixelFormat
|
||||
import android.os.CountDownTimer
|
||||
import android.os.Handler
|
||||
import android.os.SystemClock
|
||||
import android.util.DisplayMetrics
|
||||
import android.view.*
|
||||
import android.widget.CheckBox
|
||||
import android.widget.TextView
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.eagle.core.data.app.AppConfigInfo
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarStateListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotRecordListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_DEVA
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast
|
||||
import com.mogo.eagle.core.utilcode.util.AppUtils
|
||||
import com.mogo.eagle.core.utilcode.util.TimeUtils
|
||||
import com.mogo.eagle.core.utilcode.util.TimeUtils.millis2String
|
||||
import com.zhidao.loglib.call.LogInfoManagerFactory
|
||||
import com.zhidao.loglib.upload.OnUploadListener
|
||||
import com.zhjt.mogo_core_function_devatools.R
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.consts.BadCaseConfig
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.record.RecordManager
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import record_cache.RecordPanelOuterClass
|
||||
import java.io.File
|
||||
import java.lang.StringBuilder
|
||||
import java.lang.reflect.Field
|
||||
import java.util.*
|
||||
|
||||
|
||||
/**
|
||||
* @author XuXinChao
|
||||
* @description BadCase主动录包
|
||||
* @since: 2022/7/13
|
||||
*/
|
||||
class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchListener{
|
||||
class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchListener,
|
||||
IMoGoAutopilotRecordListener, IMoGoAutopilotCarStateListener {
|
||||
|
||||
companion object {
|
||||
const val TAG = "InitiativeBadCaseWindow"
|
||||
}
|
||||
|
||||
private var mActivity: Activity = activity
|
||||
private var mWindowParams: WindowManager.LayoutParams? = null
|
||||
@@ -33,12 +60,27 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList
|
||||
private lateinit var tvInitiativeTime: TextView
|
||||
private lateinit var tvInitiativeIdentity: TextView
|
||||
|
||||
private lateinit var rbOne: CheckBox
|
||||
private lateinit var rbTwo: CheckBox
|
||||
private lateinit var rbThree: CheckBox
|
||||
private lateinit var rbFour: CheckBox
|
||||
private lateinit var rbFive: CheckBox
|
||||
private lateinit var rbSix: CheckBox
|
||||
|
||||
private lateinit var viewAudioButton: View
|
||||
private lateinit var tvAudioCountDown: TextView
|
||||
|
||||
private lateinit var tvInitiativeReport: TextView
|
||||
private lateinit var tvInitiativeCancel: TextView
|
||||
|
||||
private var audioStatus = false
|
||||
private var audioFileName:String?=null //录音文件名称
|
||||
|
||||
private var uploadReason: StringBuilder = StringBuilder() //上报原因,标签
|
||||
private var recordKey: String?=null //录制bag包key
|
||||
private var recordFileName: String?=null //录制文件包名
|
||||
private var longitude: Double?=null
|
||||
private var latitude: Double?=null
|
||||
|
||||
private var mInViewX = 0f
|
||||
private var mInViewY = 0f
|
||||
@@ -66,7 +108,15 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList
|
||||
tvInitiativeTime = mFloatLayout.findViewById(R.id.tvInitiativeTime)
|
||||
tvInitiativeIdentity = mFloatLayout.findViewById(R.id.tvInitiativeIdentity)
|
||||
|
||||
rbOne = mFloatLayout.findViewById(R.id.rbOne)
|
||||
rbTwo = mFloatLayout.findViewById(R.id.rbTwo)
|
||||
rbThree = mFloatLayout.findViewById(R.id.rbThree)
|
||||
rbFour = mFloatLayout.findViewById(R.id.rbFour)
|
||||
rbFive = mFloatLayout.findViewById(R.id.rbFive)
|
||||
rbSix = mFloatLayout.findViewById(R.id.rbSix)
|
||||
|
||||
viewAudioButton = mFloatLayout.findViewById(R.id.viewAudioButton)
|
||||
tvAudioCountDown = mFloatLayout.findViewById(R.id.tvAudioCountDown)
|
||||
|
||||
tvInitiativeReport = mFloatLayout.findViewById(R.id.tvInitiativeReport)
|
||||
tvInitiativeCancel = mFloatLayout.findViewById(R.id.tvInitiativeCancel)
|
||||
@@ -76,25 +126,59 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList
|
||||
tvInitiativeTime.text = "时间:${millis2String(System.currentTimeMillis(),TimeUtils.getHourMinSecondFormat())}"
|
||||
tvInitiativeIdentity.text = "身份:${BadCaseConfig.identity}"
|
||||
|
||||
viewAudioButton.setOnClickListener {
|
||||
audioStatus = !audioStatus
|
||||
if(audioStatus){
|
||||
viewAudioButton.background = mActivity.getDrawable(R.drawable.bad_case_audio_select)
|
||||
//开始录音
|
||||
RecordManager.getInstance().start("audio_test")
|
||||
}else{
|
||||
viewAudioButton.background = mActivity.getDrawable(R.drawable.bad_case_audio_normal)
|
||||
//结束录音
|
||||
RecordManager.getInstance().stop()
|
||||
}
|
||||
}
|
||||
|
||||
tvInitiativeReport.setOnClickListener {
|
||||
CallerAutoPilotManager.recordPackage(BadCaseConfig.type,
|
||||
//采集结果回调监听
|
||||
CallerAutopilotRecordListenerManager.addListener(TAG,this)
|
||||
// 添加 ADAS车辆状态&定位 监听
|
||||
CallerAutopilotCarStatusListenerManager.addListener(TAG, this)
|
||||
//开启录包
|
||||
CallerAutoPilotManager.recordPackage(BadCaseConfig.type,
|
||||
Random(SystemClock.elapsedRealtime()).nextInt(),
|
||||
BadCaseConfig.totalDuration,
|
||||
BadCaseConfig.previousDuration
|
||||
)
|
||||
|
||||
viewAudioButton.setOnClickListener {
|
||||
audioStatus = !audioStatus
|
||||
setAudio(audioStatus)
|
||||
}
|
||||
|
||||
tvInitiativeReport.setOnClickListener {
|
||||
if(!rbOne.isChecked && !rbTwo.isChecked && !rbThree.isChecked &&
|
||||
!rbFour.isChecked && !rbFive.isChecked && !rbSix.isChecked){
|
||||
TipToast.shortTip("请选择至少一个Case")
|
||||
return@setOnClickListener
|
||||
}
|
||||
if(rbOne.isChecked){
|
||||
uploadReason.append("严重画龙 ")
|
||||
}
|
||||
if(rbTwo.isChecked){
|
||||
uploadReason.append("速度过慢 ")
|
||||
}
|
||||
if(rbThree.isChecked){
|
||||
uploadReason.append("感知、定位、地图等其他 ")
|
||||
}
|
||||
if(rbFour.isChecked){
|
||||
uploadReason.append("速度过快 ")
|
||||
}
|
||||
if(rbFive.isChecked){
|
||||
uploadReason.append("存在碰撞风险 ")
|
||||
}
|
||||
if(rbSix.isChecked){
|
||||
uploadReason.append("点刹、顿挫")
|
||||
}
|
||||
//点击上报时,如果没有停止录音则先停止录音
|
||||
//TODO 未结束录音,点击上报,未能上传语音成功
|
||||
if(audioStatus){
|
||||
audioStatus = !audioStatus
|
||||
setAudio(audioStatus)
|
||||
Handler().postDelayed({
|
||||
uploadAudio()
|
||||
},1000)
|
||||
}else{
|
||||
uploadAudio()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
tvInitiativeCancel.setOnClickListener {
|
||||
BadCaseConfig.windowNum--
|
||||
@@ -110,7 +194,100 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList
|
||||
it.gravity = Gravity.START or Gravity.TOP
|
||||
it.width = 924
|
||||
it.height = 668
|
||||
it.alpha = 0.9f
|
||||
it.alpha = 1.0f
|
||||
}
|
||||
}
|
||||
|
||||
var countDownTimer: CountDownTimer?=null
|
||||
|
||||
private fun setAudio(status: Boolean){
|
||||
if(status){
|
||||
//开始录音
|
||||
audioFileName = "Audio_${System.currentTimeMillis()}_BadCase"
|
||||
RecordManager.getInstance().start(audioFileName)
|
||||
//更改录音按钮背景
|
||||
viewAudioButton.background = mActivity.getDrawable(R.drawable.bad_case_audio_select)
|
||||
tvAudioCountDown.visibility = View.VISIBLE
|
||||
//开始倒计时
|
||||
if(countDownTimer==null){
|
||||
countDownTimer = object : CountDownTimer(60000, 1000) {
|
||||
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
tvAudioCountDown.text = "${millisUntilFinished/1000}S"
|
||||
}
|
||||
|
||||
override fun onFinish() {
|
||||
tvAudioCountDown.visibility = View.GONE
|
||||
//结束录音
|
||||
RecordManager.getInstance().stop()
|
||||
//更改录音按钮背景
|
||||
viewAudioButton.background = mActivity.getDrawable(R.drawable.bad_case_audio_normal)
|
||||
}
|
||||
}
|
||||
countDownTimer?.start()
|
||||
}
|
||||
}else{
|
||||
//结束倒计时
|
||||
countDownTimer?.cancel()
|
||||
countDownTimer?.onFinish()
|
||||
//将倒计时置空
|
||||
countDownTimer = null
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun uploadAudio(){
|
||||
val singlePath = "/mnt/sdcard/mogo/DataCollection/${audioFileName}.wav"
|
||||
val file = File(singlePath)
|
||||
if(file.exists()){
|
||||
LogInfoManagerFactory.createAudioUpload(mActivity,"Audio",singlePath,
|
||||
object : OnUploadListener {
|
||||
override fun onUploadSuccess(filePath: String, downloadUrl: String) {
|
||||
CallerLogger.d("$M_DEVA$TAG", "语音文件上传成功:downloadUrl=$downloadUrl")
|
||||
//上传到服务器
|
||||
upload(downloadUrl)
|
||||
}
|
||||
|
||||
override fun onUploadFail(filePath: String) {
|
||||
TipToast.shortTip("上传语音文件失败")
|
||||
}
|
||||
})
|
||||
}else{
|
||||
//上传到服务器
|
||||
upload(null)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将记录上传到服务器
|
||||
* @param downloadUrl 语音文件下载地址
|
||||
*/
|
||||
private fun upload(downloadUrl: String?){
|
||||
GlobalScope.launch{
|
||||
val uploadResult = presenter.upload(mutableMapOf<String, String>().also { itx ->
|
||||
itx["carLicense"] = AppConfigInfo.plateNumber?:"" //车牌号
|
||||
itx["filename"] = recordFileName?:"" //bag包文件地址
|
||||
itx["filesize"] = "0" //bag包文件大小
|
||||
itx["key"] = recordKey?:"" //key
|
||||
itx["reason"] = uploadReason.toString()?:"" //采集原因
|
||||
itx["duration"] = BadCaseConfig.totalDuration.toString() //采集时长,固定为20S
|
||||
itx["startTime"] = System.currentTimeMillis().toString() //上报时间(时间戳格式)
|
||||
itx["channel"] = "1" //渠道
|
||||
itx["carSn"] = MoGoAiCloudClientConfig.getInstance().sn //SN
|
||||
itx["userRole"] = BadCaseConfig.identity //采集者角色
|
||||
itx["audioUrl"] = downloadUrl?:"" //音频COS地址
|
||||
itx["mapVersion"] = BadCaseConfig.dockerVersion ?:"" //工控机版本
|
||||
itx["eyeVersion"] = AppUtils.getAppVersionName() //鹰眼版本
|
||||
itx["coordinate"] = "latitude:${latitude};longitude:${longitude}" //坐标
|
||||
|
||||
})
|
||||
if (uploadResult == null || uploadResult.code != 200) {
|
||||
TipToast.shortTip("上报失败")
|
||||
} else {
|
||||
TipToast.shortTip("上报成功")
|
||||
BadCaseConfig.windowNum--
|
||||
clickListener?.closeWindow()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,9 +312,6 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList
|
||||
// 手指移动的时候更新小悬浮窗的位置
|
||||
mWindowManager!!.updateViewLayout(mFloatLayout, mWindowParams)
|
||||
}
|
||||
// MotionEvent.ACTION_UP -> // 如果手指离开屏幕时,xDownInScreen和xInScreen相等,且yDownInScreen和yInScreen相等,则视为触发了单击事件。
|
||||
// if (mDownInScreenX === mInScreenX && mDownInScreenY === mInScreenY) {
|
||||
// }
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -148,12 +322,16 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList
|
||||
// 默认固定位置,靠屏幕右边缘的中间
|
||||
mWindowManager!!.defaultDisplay.getMetrics(metrics)
|
||||
mWindowParams!!.x = metrics.widthPixels
|
||||
mWindowParams!!.y = metrics.heightPixels / 2 - getSysBarHeight(mActivity)
|
||||
mWindowParams!!.y = metrics.heightPixels / 2 - getSysBarHeight(mActivity)-350
|
||||
mWindowManager!!.addView(mFloatLayout, mWindowParams)
|
||||
}
|
||||
}
|
||||
|
||||
fun hideFloatWindow() {
|
||||
//注销采集结果回调监听
|
||||
CallerAutopilotRecordListenerManager.removeListener(TAG)
|
||||
// 移除 ADAS车辆状态&定位 监听
|
||||
CallerAutopilotCarStatusListenerManager.removeListener(TAG)
|
||||
if (mFloatLayout.parent != null) mWindowManager!!.removeView(mFloatLayout)
|
||||
}
|
||||
|
||||
@@ -176,6 +354,30 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList
|
||||
return sbar
|
||||
}
|
||||
|
||||
override fun onAutopilotRecordResult(recordPanel: RecordPanelOuterClass.RecordPanel) {
|
||||
CallerLogger.d("${M_DEVA}${TAG}", "-- 收到工控机录制任务回调 -- $recordPanel")
|
||||
if(recordKey==null){
|
||||
recordKey = recordPanel.key.toString()
|
||||
}
|
||||
if(recordFileName==null){
|
||||
recordFileName = recordPanel.filename
|
||||
}
|
||||
when(recordPanel.stat){
|
||||
100, 101 ->{
|
||||
//成功结束录制
|
||||
TipToast.shortTip("${millis2String(System.currentTimeMillis(),TimeUtils.getHourMinSecondFormat())}bag录制成功")
|
||||
}
|
||||
300 ->{
|
||||
//开始录制
|
||||
|
||||
}
|
||||
200 ->{
|
||||
//录制失败
|
||||
TipToast.shortTip("${millis2String(System.currentTimeMillis(),TimeUtils.getHourMinSecondFormat())}bag录制失败")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setClickListener(clickListener: ClickListener) {
|
||||
this.clickListener = clickListener
|
||||
}
|
||||
@@ -184,4 +386,9 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList
|
||||
fun closeWindow()
|
||||
}
|
||||
|
||||
override fun onAutopilotCarStateData(gnssInfo: MessagePad.GnssInfo?) {
|
||||
latitude = gnssInfo?.latitude
|
||||
longitude = gnssInfo?.longitude
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,5 +24,8 @@ object BadCaseConfig {
|
||||
//BadCase采集和AI数据采集弹窗数量
|
||||
@JvmField
|
||||
var windowNum = 1
|
||||
//工控机版本
|
||||
@JvmField
|
||||
var dockerVersion:String ?= null
|
||||
|
||||
}
|
||||
@@ -4,8 +4,8 @@ import com.mogo.commons.debug.DebugConfig
|
||||
|
||||
internal object BadCaseHost {
|
||||
|
||||
private const val HOST_DEV = "http://dzt.zhidaozhixing.com/"
|
||||
private const val HOST_RELEASE = "https://dzt-test.zhidaozhixing.com/"
|
||||
private const val HOST_DEV = "http://dzt-test.zhidaozhixing.com/"
|
||||
private const val HOST_RELEASE = "http://dzt.zhidaozhixing.com/"
|
||||
|
||||
fun getHost(): String{
|
||||
return when (DebugConfig.getNetMode()) {
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
android:layout_marginEnd="@dimen/dp_50"
|
||||
/>
|
||||
|
||||
<RadioButton
|
||||
<CheckBox
|
||||
android:id="@+id/rbOne"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -61,46 +61,46 @@
|
||||
android:textSize="34px"
|
||||
android:button="@null"
|
||||
android:drawableLeft="@drawable/badcase_radio_button_style"
|
||||
android:drawablePadding="@dimen/dp_20"
|
||||
android:drawablePadding="@dimen/dp_10"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvInitiativeNum"
|
||||
android:layout_marginStart="@dimen/dp_50"
|
||||
android:layout_marginTop="@dimen/dp_50"
|
||||
android:layout_marginStart="@dimen/dp_30"
|
||||
android:layout_marginTop="@dimen/dp_40"
|
||||
/>
|
||||
|
||||
<RadioButton
|
||||
<CheckBox
|
||||
android:id="@+id/rbTwo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="点刹、顿挫"
|
||||
android:textColor="#FFFFFFFF"
|
||||
android:textSize="34px"
|
||||
android:button="@null"
|
||||
android:drawableLeft="@drawable/badcase_radio_button_style"
|
||||
android:drawablePadding="@dimen/dp_20"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvInitiativeNum"
|
||||
app:layout_constraintLeft_toRightOf="@id/rbOne"
|
||||
android:layout_marginStart="@dimen/dp_50"
|
||||
android:layout_marginTop="@dimen/dp_50"
|
||||
/>
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbThree"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="速度过慢"
|
||||
android:textColor="#FFFFFFFF"
|
||||
android:textSize="34px"
|
||||
android:button="@null"
|
||||
android:drawableLeft="@drawable/badcase_radio_button_style"
|
||||
android:drawablePadding="@dimen/dp_10"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvInitiativeNum"
|
||||
app:layout_constraintLeft_toRightOf="@id/rbOne"
|
||||
android:layout_marginStart="@dimen/dp_20"
|
||||
android:layout_marginTop="@dimen/dp_40"
|
||||
/>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/rbThree"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="感知、定位、地图等其他"
|
||||
android:textColor="#FFFFFFFF"
|
||||
android:textSize="34px"
|
||||
android:button="@null"
|
||||
android:drawableLeft="@drawable/badcase_radio_button_style"
|
||||
android:drawablePadding="@dimen/dp_20"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvInitiativeNum"
|
||||
app:layout_constraintLeft_toRightOf="@id/rbTwo"
|
||||
android:layout_marginStart="@dimen/dp_50"
|
||||
android:layout_marginTop="@dimen/dp_50"
|
||||
android:layout_marginStart="@dimen/dp_20"
|
||||
android:layout_marginTop="@dimen/dp_40"
|
||||
/>
|
||||
|
||||
<RadioButton
|
||||
<CheckBox
|
||||
android:id="@+id/rbFour"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -109,13 +109,13 @@
|
||||
android:textSize="34px"
|
||||
android:button="@null"
|
||||
android:drawableLeft="@drawable/badcase_radio_button_style"
|
||||
android:drawablePadding="@dimen/dp_20"
|
||||
android:drawablePadding="@dimen/dp_10"
|
||||
app:layout_constraintTop_toBottomOf="@id/rbOne"
|
||||
app:layout_constraintLeft_toLeftOf="@id/rbOne"
|
||||
android:layout_marginTop="@dimen/dp_50"
|
||||
android:layout_marginTop="@dimen/dp_40"
|
||||
/>
|
||||
|
||||
<RadioButton
|
||||
<CheckBox
|
||||
android:id="@+id/rbFive"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -127,22 +127,23 @@
|
||||
android:drawablePadding="@dimen/dp_20"
|
||||
app:layout_constraintTop_toBottomOf="@id/rbTwo"
|
||||
app:layout_constraintLeft_toLeftOf="@id/rbTwo"
|
||||
android:layout_marginTop="@dimen/dp_50"
|
||||
android:layout_marginTop="@dimen/dp_40"
|
||||
/>
|
||||
|
||||
<RadioButton
|
||||
<CheckBox
|
||||
android:id="@+id/rbSix"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="感知、定位、地图等其他"
|
||||
android:text="点刹、顿挫"
|
||||
android:textColor="#FFFFFFFF"
|
||||
android:textSize="34px"
|
||||
android:button="@null"
|
||||
android:drawableLeft="@drawable/badcase_radio_button_style"
|
||||
android:drawablePadding="@dimen/dp_20"
|
||||
app:layout_constraintTop_toBottomOf="@id/rbThree"
|
||||
app:layout_constraintLeft_toLeftOf="@id/rbThree"
|
||||
android:layout_marginTop="@dimen/dp_50"
|
||||
app:layout_constraintTop_toBottomOf="@id/rbOne"
|
||||
app:layout_constraintLeft_toRightOf="@id/rbFive"
|
||||
android:layout_marginTop="@dimen/dp_40"
|
||||
android:layout_marginStart="@dimen/dp_30"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
@@ -207,4 +208,16 @@
|
||||
app:layout_constraintBottom_toBottomOf="@id/viewAudioButton"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvAudioCountDown"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FFFFFFFF"
|
||||
android:textSize="30px"
|
||||
app:layout_constraintTop_toTopOf="@id/viewAudioButton"
|
||||
app:layout_constraintBottom_toBottomOf="@id/viewAudioButton"
|
||||
app:layout_constraintLeft_toRightOf="@id/viewAudioButton"
|
||||
android:layout_marginStart="@dimen/dp_30"
|
||||
/>
|
||||
|
||||
</com.mogo.eagle.core.widget.RoundConstraintLayout>
|
||||
Reference in New Issue
Block a user