Commit c0af16dd authored by p x's avatar p x
Browse files

first

parent 0b4d4d4e
Pipeline #3217 failed with stages
in 0 seconds
package com.sd.cavphmi.bean.mock
//模拟路径
data class MRoutes(
val rs: List<List<Double>>
)
\ No newline at end of file
package com.sd.cavphmi.bean.mock
/**全局用的我的当前位置**/
class MyCLoc {
companion object{
val instance:MyCLoc by lazy { MyCLoc() }
}
//当前经纬度
var lat = 0.0
var lng = 0.0
//速度 KM/H
var speed = 0f
//航向角
var bearing = 0f
//精度
var accuracy = 0f
//高程
var altitude = 0.0
}
\ No newline at end of file
package com.sd.cavphmi.bean.mock
//模拟倒车路径
data class ParkPath(
val code: String,
val msg: String,
val result: PResult
)
data class PResult(
val execType: Any,
val execTypeDesc: Any,
val parkingPlace: Any,
val parkingPlaceId: String,
val points: Any,
val routes: List<PRoute>,
val time: Any,
val vehicleId: String,
val vehicleInfo: Any
)
data class PRoute(
val destination: List<Double>,
val gear: Int,//3=前进 1=后退
val origin: List<Double>,
val polyline: List<List<Double>>,
val routeId: Int
)
\ No newline at end of file
package com.sd.cavphmi.bean.req
/*缺少停车场id入参、类型等入参、车位状态等
停车场id =1 亦庄基地P2停车场
类型 = 1 停车位
车位状态
0, "空闲
1, "占用"*/
class SpaceInfo {
var placeId = 1
var spaceType = 1
var state = 1
}
\ No newline at end of file
package com.sd.cavphmi.bindadapters
import android.graphics.Color
import android.view.View
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.ProgressBar
import android.widget.TextView
import androidx.core.graphics.toColorInt
import androidx.databinding.BindingAdapter
import com.sd.cavphmi.R
import com.sd.cavphmi.bean.GearStatus
import com.sd.cavphmi.ui.view.HeadAngelView
import com.sd.cavphmi.utils.AvpContants
object ShowCarPanelObject {
@JvmStatic
@BindingAdapter(value = ["showSpeed", "spdExp"], requireAll = false)
fun showSpeed(tv: TextView, speed: Int, spdExp: Int) {
tv.setText(speed.toString())
}
//档位 gear
@JvmStatic
@BindingAdapter("showTapPos")
fun showTapPos(tv: TextView, gear: Int) {
if (gear == 7) {
tv.setTextColor("#66000000".toColorInt())
return
}
var tag = tv.tag.toString().toInt()
// println("--------tag = ${tag} gear = ${gear}")
if (tag == gear) {
tv.setTextColor(Color.BLACK)
} else {
// tv.setTextColor(Color.GRAY)
tv.setTextColor("#66000000".toColorInt())
// tv.setTextColor("#A59C9C".toColorInt())
}
}
/***剩余油或者电***/
@JvmStatic
@BindingAdapter("showProTv")
fun showProTv(tv: TextView, pro: Int) {
tv.text = "${pro}%"
}
/***剩余油或者电***/
@JvmStatic
@BindingAdapter("showProgress")
fun showProgress(bar: ProgressBar, pro: Int) {
bar.setProgress(pro)
}
/***汽车转向灯 32769 0x8009=右转 ***/
@JvmStatic
@BindingAdapter("showTurnLight")
fun showTurnLight(ll: LinearLayout, lights: Int) {
if (lights == -1)
return
var temp = lights
//0:有效;1:车灯状态字段全部无效(或未获取数据)
var valid = temp.shr(15)
//取第3-4位 bit3=左转灯 bit4=右转灯 2个都开deng=12
val turn = lights.and(0xC)
var count = ll.childCount
for (i in 0..count - 1) {
var iv = ll.getChildAt(i) as ImageView
var tag = iv.tag
if (tag.equals("left")) {
if (turn == 4) {
iv.setImageResource(R.drawable.trun_left_blue)
} else {
iv.setImageResource(R.drawable.trun_left_grey)
}
} else if (tag.equals("right")) {
if (turn == 8) {
iv.setImageResource(R.drawable.trun_right_blue)
} else {
iv.setImageResource(R.drawable.trun_right_grey)
}
}
// if (turn == 4) {
// if (tag.equals("left")) {
// iv.setImageResource(R.drawable.trun_left_blue)
// } else {
// iv.setImageResource(R.drawable.trun_right_grey)
// }
// } else if (turn == 8) {
// if (tag.equals("right")) {
// iv.setImageResource(R.drawable.trun_right_blue)
// } else {
// iv.setImageResource(R.drawable.trun_left_grey)
// }
// }
}
}
/***
* 驾驶模式
* UNKNOWN(0, "未知"),
* AUTOMATIC(1, "自动驾驶"),
* MANUAL(2, "人工驾驶"),
* REMOTE(3, "远程驾驶");
*/
@JvmStatic
@BindingAdapter("showAutoDri")
fun showAutoDri(tv: TextView, auto: String) {
when (auto) {
AvpContants.DRIVE_MODE_UNKNOWN -> {
tv.text = "未知"
}
AvpContants.DRIVE_MODE_AUTOMATIC -> {
tv.text = "自动驾驶"
}
AvpContants.DRIVE_MODE_MANUAL -> {
tv.text = "人工驾驶"
}
AvpContants.DRIVE_MODE_REMOTE -> {
tv.text = "远程驾驶"
}
}
}
/***航向角***/
@JvmStatic
@BindingAdapter("showHeading")
fun showHeading(iv: HeadAngelView, heading: Float) {
// println("---------showHeading = ${heading}")
iv.setHeadAngel(heading)
}
/***高精地图里的车辆仪表界面***/
@JvmStatic
@BindingAdapter(value = ["showMapCarPan", "isStartNai"], requireAll = false)
fun showMapCarPan(fl: FrameLayout, isHighMap: Boolean, isStartNai: Boolean) {
// println("---------showHeading = ${heading}")
if (isHighMap) {
// if (isStartNai){
fl.visibility = View.VISIBLE
// var params=fl.layoutParams as RelativeLayout.LayoutParams
// params.height= DisplayUtil.dp2px(106f)
// fl.layoutParams=params
// }
} else {
fl.visibility = View.GONE
}
}
}
\ No newline at end of file
package com.sd.cavphmi.bindadapters
import android.widget.ImageView
import androidx.annotation.DrawableRes
import androidx.databinding.BindingAdapter
object ShowEarTipBase {
@JvmStatic
@BindingAdapter("showEarlyTipImg")
fun showEarlyTipImg(iv: ImageView, @DrawableRes res: Int) {
iv.setImageResource(res)
}
}
\ No newline at end of file
package com.sd.cavphmi.bindadapters
import android.text.Spannable
import android.text.SpannableStringBuilder
import android.text.style.ForegroundColorSpan
import android.view.View
import android.widget.LinearLayout
import android.widget.TextView
import androidx.core.graphics.toColorInt
import androidx.databinding.BindingAdapter
object ShowOrderObject {
@JvmStatic
@BindingAdapter("showOrderLayout")
fun showOrderLayout(ll: LinearLayout, avpStatus: Int?) {
when (avpStatus) {
in 1..6 -> ll.visibility = View.VISIBLE
else -> {
ll.visibility = View.GONE
}
}
}
@JvmStatic
@BindingAdapter("showOrderCost")
fun showOrderCost(tv: TextView, actualCost: Float) {
var color = ForegroundColorSpan("#3C61E2".toColorInt())
var sb = SpannableStringBuilder()
sb.append("${actualCost}元")
sb.setSpan(color, 0, actualCost.toString().count(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE)
tv.setText(sb)
}
}
\ No newline at end of file
package com.sd.cavphmi.highmap
/**
* Alert path
* 传入点的坐标数组绘制路面状况颜色2=(路径里的红色、施工区域红色、人行道红色) 3=绿色(绿波) 4=感知车前的红色)
*/
data class AlertPath(
val lines: List<AlertLine>,
val alertType: Int
)
class AlertLine {
// val evel: Int,
var lat: Double=0.0
var lon: Double=0.0
}
\ No newline at end of file
package com.sd.cavphmi.highmap
/**
* 开启(关闭)绘制主车底盘下的光圈
*/
data class BottomCircle(
val isOn: Boolean
)
\ No newline at end of file
package com.sd.cavphmi.highmap
/**
*全局路径绘制
*/
class CarNavPath {
var lines: List<AllLine>? = null
var through = "8e959e" //通过路的颜色颜色HEX RRGGBB
var notthrough = "2868D8" //未通过路的颜色颜色HEX RRGGBB
var drawpassed = true //绘制通过路
var showdistance = 45 //显示路径的距离,超过这个范围的路径点不绘制
//注意,目前的是否通过是程序根据点的顺序判断距离车最近的点为当前点,后面的未通过,前面的点为已通过
}
class AllLine {
// val evel: Int,
constructor()
constructor(lat: Double, lon: Double) {
this.lat = lat
this.lon = lon
}
var lat: Double = 0.0
var lon: Double = 0.0
}
\ No newline at end of file
package com.sd.cavphmi.highmap
/**
* 根据外界传入的坐标,航向角,速度使主车移动
* {
* "lat": 116.50272672296624, //纬度
* "lon": 116.49886019, //经度
* "evel": 20.80189, //高度
* "heading": 0, //汽车姿态方向角度
* }
*/
class CarPos {
var evel = 20.80189
var heading = 0.0
var lat = 0.0
var lon = 0.0
}
package com.sd.cavphmi.highmap
import com.google.gson.Gson
import com.unity3d.player.UnityPlayer
/**
* 高精地图Api
*
* 在EarlyWarnVM.kt里setAssEvent函数里用到了
*/
object HighMapApi {
private var gson = Gson()
private const val MODELNAME = "MsgBridge"
/**
* 给unity读取3d tile json配置
*/
fun setTileInit(tileJsonBean: TileJsonBean) {
UnityPlayer.UnitySendMessage(MODELNAME, "SetTileInit", gson.toJson(tileJsonBean))
}
/**
* 根据外界传入的坐标,航向角,速度使主车移动
* @param heading 航向角
* @param evel 高程
*/
fun setCarPosition(
heading: Double,
lat: Double,
lon: Double,
evel: Double,
) {
val carPos = CarPos().apply {
this.heading = heading
this.lat = lat
this.lon = lon
this.evel = evel
}
UnityPlayer.UnitySendMessage(MODELNAME, "SetCarPosition", gson.toJson(carPos))
}
/**
* 开启(关闭)绘制主车底盘下的光圈
*/
fun setCarBottomCircle(isOn: Boolean) {
var bottomCircle = BottomCircle(isOn)
UnityPlayer.UnitySendMessage(MODELNAME, "SetCarBottomCircle", gson.toJson(bottomCircle))
}
/**
* 开启(关闭)主车前方的雷达6个方向
* 0=关闭 1=左前 2=正前 3=右前 4=右后 5=正后 6=左后
*/
fun setCarRadarDirection(dirent: Int) {
var radarDirection = RadarDirection(dirent)
UnityPlayer.UnitySendMessage(MODELNAME, "SetCarRadarDirection", gson.toJson(radarDirection))
}
/**
* 车辆行驶全局路径绘制 - 蓝色渐变引导线
* @param lines 全局路径
* @param through = "8e959e" 通过路的颜色颜色HEX RRGGBB
* @param notthrough = "2868D8" 未通过路的颜色颜色HEX RRGGBB
* @param drawpassed = true 绘制通过路
* @param showdistance = 45 显示路径的距离,超过这个范围的路径点不绘制
*/
fun setCarNavPath(
lines: List<AllLine>,
notthrough: String = "2868D8",
through: String = "8e959e",
drawpassed: Boolean = true,
showdistance: Int = 75
) {
var carNavPath = CarNavPath().apply {
this.lines = lines
this.notthrough = notthrough
this.through = through
this.drawpassed = drawpassed
this.showdistance = showdistance
}
UnityPlayer.UnitySendMessage(MODELNAME, "SetCarNavPath", gson.toJson(carNavPath))
}
/**
* 传入点的坐标数组绘制路面状况颜色2=(路径里的红色、施工区域红色、人行道红色) 3=绿色(绿波) 4=感知车前的红色)
* @param alertLins 危险路径
* @param alertType 危险类型
*/
fun setAlertPath(alertLine: List<AlertLine>, alertType: Int) {
var alertPath = AlertPath(alertLine, alertType)
UnityPlayer.UnitySendMessage(MODELNAME, "SetAlertPath", gson.toJson(alertPath))
}
/**
* 绘制感知物
* @param ptcList
*/
fun setPtcData(ptcList: List<UnityPtc>) {
var ptcData = PtcData(ptcList)
UnityPlayer.UnitySendMessage(MODELNAME, "SetPtcData", gson.toJson(ptcData))
}
/**
* 感知物预警
*/
fun setWarnPtc(warnPtc: List<WarnPtc>) {
UnityPlayer.UnitySendMessage(
MODELNAME,
"SetWarnPre",
gson.toJson(warnPtc)
)
}
/**
* 设置相机角度
*/
fun setCameraAngle(angle: Float = 30f) {
UnityPlayer.UnitySendMessage(MODELNAME, "SetCameraAngle", "$angle")
}
/**
* 清除所有感知物
*/
fun clearPtcData() {
UnityPlayer.UnitySendMessage(MODELNAME, "ClearAllPtcData", "{}")
}
/**
* 选中车位的动效(四周流光效果加一个P的弹跳)
* @param spaceCode 车位编号
* 目前测试ID范围:B001~B075
*/
fun parkRoundLight(spaceCode: String) {
var parkRoundLight = ParkRoundLight().apply {
this.spaceCode = spaceCode
}
UnityPlayer.UnitySendMessage(MODELNAME, "parkRoundLight", gson.toJson(parkRoundLight))
}
// 停车位绘制 - 上面有其他车的状态(传入车辆占用情况绘制)
fun setParkStatu(parkStatu: ParkStatu) {
UnityPlayer.UnitySendMessage(MODELNAME, "SetSpaceParkStatu", gson.toJson(parkStatu))
}
// 正在倒车,计算倒车弧线
fun setParkRever(reverCar: ReverCar) {
UnityPlayer.UnitySendMessage(MODELNAME, "SetParking", gson.toJson(reverCar))
}
// 设置相机距离 如:SendMessage("MsgBridge","SetCameraDistance",10);//设置相机与查看点(车正上方2米)距离10米
fun setCameraDistance(cDistance: Float) {
UnityPlayer.UnitySendMessage(MODELNAME, "SetCameraDistance", "$cDistance")
}
// 泊车完成 用来清除倒车特效
fun setParkComplete(complete: Boolean) {
var parkComplete = ParkComplete().apply {
this.complete = complete
}
UnityPlayer.UnitySendMessage(MODELNAME, "SetParkComplete", gson.toJson(parkComplete))
}
// 设置地锁状态
fun setLockStatus(lockStatu: LockStatu) {
UnityPlayer.UnitySendMessage(MODELNAME, "SetLockStatus", gson.toJson(lockStatu))
}
// 小地图开关
fun showMap(showSmallMap: String) {
// fun showMap(showSmallMap: ShowSmallMap) {
UnityPlayer.UnitySendMessage(MODELNAME, "showMap", showSmallMap)
// UnityPlayer.UnitySendMessage(MODELNAME, "showMap", gson.toJson(showSmallMap))
}
}
\ No newline at end of file
package com.sd.cavphmi.highmap
class LockStatu {
var code = ""//车位编号
var isHide = false
var up = false//// true是升起, false是降下
}
\ No newline at end of file
package com.sd.cavphmi.highmap
//泊车完成
class ParkComplete {
var complete = false
}
\ No newline at end of file
package com.sd.cavphmi.highmap
/**
* Park round light
* 停车位流光特效
*/
class ParkRoundLight {
//车位编号
var spaceCode = ""
}
\ No newline at end of file
package com.sd.cavphmi.highmap
//停车位绘制 - 上面有其他车的状态(传入车辆占用情况绘制)
data class ParkStatu(
var spinfo: List<Spinfo>
)
class Spinfo {
var code: String = ""
var state=false
}
\ No newline at end of file
package com.sd.cavphmi.highmap
/**
* 感知物数据
*
* {
* ptcList: //感知物数组
* [
* {
* ptcid:xxx,//感知物id
* "lat": 43.826145, //纬度
* "lon": 125.12990, //经度
* "pType":1 //感知物类型 1=车 2=人
* "heading": 125.12990, //航向角
* “isRed”:false //是否变红
* isFlash:fasle //是否闪烁
* aniTime:1(单位秒) //此字段具有高优先级,以第一帧接收为准开始计时,控制闪烁和变红在X秒后消失,如果传0已上面的bool值为准。
* },
*
* }
*/
data class PtcData(
val ptcList: List<UnityPtc>
)
class UnityPtc {
//闪烁时间
var aniTime = 0L
//感知物类型 1=车 2=人
var pType = 0
var heading = 0.0
var isFlash = false
var isRed = false
var lat: Double = 0.0
var lon: Double = 0.0
var ptcid: String = ""
}
class WarnPtc {
//闪烁时间
var aniTime = 0L
var isFlash = false
var isRed = false
var ptcid: String = ""
}
package com.sd.cavphmi.highmap
/**
* 车前雷达
* {dirent:1} 0=关闭 1=左前 2=正前 3=右前 4=右后 5=正后 6=左后
*/
data class RadarDirection(
val dirent: Int
)
\ No newline at end of file
package com.sd.cavphmi.highmap
class ReverCar {
var cenLat: Double = 0.0 //车位中心点坐标
var cenLng: Double = 0.0 //车位中心点坐标
var code: String = ""//车位编号
}
\ No newline at end of file
package com.sd.cavphmi.highmap
//显示小地图
class ShowSmallMap {
var show = false
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment