Merge branch 'master' of https://gitee.com/endian11/DriveJudge
| | |
| | | |
| | | public static final int ENTER_OR_EXIT_ITEM = 0x000D; |
| | | public static final int HAS_BEEN_START_EXAM = 1; |
| | | public static final int REAL_TIME_CAR_POS = 0x000E; |
| | | public static final String REAL_TIME_POS_CAR_TOPIC = "real_time_car_pos_topic"; |
| | | public static final String BIND_SPEED_TOPIC = "BIND_SPEED_TOPIC"; |
| | | public static final int PASSING_SCORE = 80; |
| | | public static String exam_enter_exitdata="exam_enter_exitdata"; |
| | | } |
| | |
| | | |
| | | |
| | | MyLog.i(TAG, "onCreate"); |
| | | MainViewModel mainViewModel = ViewModelProviders.of(this).get(MainViewModel.class); |
| | | mainViewModel.getJson().observe(this, new Observer<String>() { |
| | | @Override |
| | | public void onChanged(@Nullable String json) { |
| | | Toast.makeText(MainActivity.this, json, Toast.LENGTH_SHORT).show(); |
| | | MyLog.i(TAG, "json==========" + json + " ThreadName:" + Thread.currentThread().getName()); |
| | | |
| | | } |
| | | }); |
| | | |
| | | //加载根Fragment |
| | | if (findFragment(HomeFragment.class) == null) { |
| | |
| | | OneTimeWorkRequest examStatusWorker = new OneTimeWorkRequest.Builder(ExamStatusWoker.class).setInputData(exam_enter_exitdata).build(); |
| | | WorkManager.getInstance(getApplicationContext()).enqueue(examStatusWorker); |
| | | break; |
| | | case Constant.REAL_TIME_CAR_POS: |
| | | try { |
| | | JSONObject jsSpeed = new JSONObject(json); |
| | | double speed = jsSpeed.getDouble("speed"); |
| | | CEventCenter.dispatchEvent(Constant.BIND_SPEED_TOPIC,cmd,0,speed); |
| | | } catch (JSONException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | CEventCenter.dispatchEvent(Constant.REAL_TIME_POS_CAR_TOPIC,cmd,0,json); |
| | | break; |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package safeluck.drive.evaluation.bean; |
| | | |
| | | import java.util.List; |
| | | |
| | | public class RealTimeCarPos { |
| | | /** |
| | | * utc : 20200114035518.40 |
| | | * qf : 2 |
| | | * map_id : -1 |
| | | * move : -1 |
| | | * speed : 0.21068459839297035 |
| | | * heading : 0.0 |
| | | * main_ant : [8.278,-0.533] |
| | | * axial : [0,3] |
| | | * left_front_tire : [1,0] |
| | | * right_front_tire : [5,0] |
| | | * left_rear_tire : [2,3] |
| | | * right_rear_tire : [4,3] |
| | | * point : [8.278,1.467,7.2780000000000005,1.467,7.2780000000000005,-1.533,8.278,-1.533,9.278,-1.5330000000000004,9.277999999999999,1.467000000000001] |
| | | */ |
| | | |
| | | private String utc; |
| | | private int qf; |
| | | private int map_id; |
| | | private int move; |
| | | private double speed; |
| | | private double heading; |
| | | private List<Double> main_ant; |
| | | private List<Integer> axial; |
| | | private List<Integer> left_front_tire; |
| | | private List<Integer> right_front_tire; |
| | | private List<Integer> left_rear_tire; |
| | | private List<Integer> right_rear_tire; |
| | | private List<Double> point; |
| | | |
| | | public String getUtc() { |
| | | return utc; |
| | | } |
| | | |
| | | public void setUtc(String utc) { |
| | | this.utc = utc; |
| | | } |
| | | |
| | | public int getQf() { |
| | | return qf; |
| | | } |
| | | |
| | | public void setQf(int qf) { |
| | | this.qf = qf; |
| | | } |
| | | |
| | | public int getMap_id() { |
| | | return map_id; |
| | | } |
| | | |
| | | public void setMap_id(int map_id) { |
| | | this.map_id = map_id; |
| | | } |
| | | |
| | | public int getMove() { |
| | | return move; |
| | | } |
| | | |
| | | public void setMove(int move) { |
| | | this.move = move; |
| | | } |
| | | |
| | | public double getSpeed() { |
| | | return speed; |
| | | } |
| | | |
| | | public void setSpeed(double speed) { |
| | | this.speed = speed; |
| | | } |
| | | |
| | | public double getHeading() { |
| | | return heading; |
| | | } |
| | | |
| | | public void setHeading(double heading) { |
| | | this.heading = heading; |
| | | } |
| | | |
| | | public List<Double> getMain_ant() { |
| | | return main_ant; |
| | | } |
| | | |
| | | public void setMain_ant(List<Double> main_ant) { |
| | | this.main_ant = main_ant; |
| | | } |
| | | |
| | | public List<Integer> getAxial() { |
| | | return axial; |
| | | } |
| | | |
| | | public void setAxial(List<Integer> axial) { |
| | | this.axial = axial; |
| | | } |
| | | |
| | | public List<Integer> getLeft_front_tire() { |
| | | return left_front_tire; |
| | | } |
| | | |
| | | public void setLeft_front_tire(List<Integer> left_front_tire) { |
| | | this.left_front_tire = left_front_tire; |
| | | } |
| | | |
| | | public List<Integer> getRight_front_tire() { |
| | | return right_front_tire; |
| | | } |
| | | |
| | | public void setRight_front_tire(List<Integer> right_front_tire) { |
| | | this.right_front_tire = right_front_tire; |
| | | } |
| | | |
| | | public List<Integer> getLeft_rear_tire() { |
| | | return left_rear_tire; |
| | | } |
| | | |
| | | public void setLeft_rear_tire(List<Integer> left_rear_tire) { |
| | | this.left_rear_tire = left_rear_tire; |
| | | } |
| | | |
| | | public List<Integer> getRight_rear_tire() { |
| | | return right_rear_tire; |
| | | } |
| | | |
| | | public void setRight_rear_tire(List<Integer> right_rear_tire) { |
| | | this.right_rear_tire = right_rear_tire; |
| | | } |
| | | |
| | | public List<Double> getPoint() { |
| | | return point; |
| | | } |
| | | |
| | | public void setPoint(List<Double> point) { |
| | | this.point = point; |
| | | } |
| | | } |
| | |
| | | package safeluck.drive.evaluation.fragment; |
| | | |
| | | import android.content.Context; |
| | | import android.graphics.Bitmap; |
| | | import android.graphics.Canvas; |
| | | import android.graphics.Color; |
| | |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.Toast; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.annotation.Nullable; |
| | | import androidx.appcompat.widget.Toolbar; |
| | | |
| | | |
| | | import com.anyun.exam.lib.MyLog; |
| | | import com.google.gson.Gson; |
| | | |
| | | |
| | | import java.util.List; |
| | | |
| | | import me.yokeyword.fragmentation.SupportFragment; |
| | | import safeluck.drive.evaluation.Constant; |
| | | import safeluck.drive.evaluation.R; |
| | | import safeluck.drive.evaluation.bean.RealTimeCarPos; |
| | | import safeluck.drive.evaluation.cEventCenter.CEventCenter; |
| | | import safeluck.drive.evaluation.cEventCenter.ICEventListener; |
| | | import safeluck.drive.evaluation.util.CThreadPoolExecutor; |
| | | |
| | | |
| | | /** |
| | |
| | | public static SupportFragment newInstance(){ |
| | | return new MapFragment(); |
| | | } |
| | | |
| | | private SurfaceView mSurfaceView; |
| | | private static final String TAG = "MapFragment"; |
| | | private SurfaceHolder holder; |
| | |
| | | private String osd = null; |
| | | private String osd2 = null; |
| | | private String osd3 = null; |
| | | |
| | | |
| | | double map[][] = {{1, 1}, {10, 1}, {10, 10}, {1, 10}}; |
| | | double car[][] = {{8.278, 1.467}, {7.2780000000000009, 1.467}, {7.2780000000000009, -1.533}, {8.278, -1.533} |
| | | , {9.278, -1.5330000000000004}, {9.277999999999999, 1.467000000000001}}; |
| | | Gson gson; |
| | | private LinearLayout linearLayout;//surfaceview的父容器,为了移动surfaceview而使用,因为scrollto不能移动view, |
| | | |
| | | |
| | |
| | | @Override |
| | | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| | | View view = inflater.inflate(R.layout.layout_mapfragment,container,false); |
| | | gson = new Gson(); |
| | | initView(view); |
| | | return view; |
| | | } |
| | |
| | | holder.unlockCanvasAndPost(canvas); |
| | | } |
| | | |
| | | new Thread(new NeedForSpeed()).start(); |
| | | // new Thread(new NeedForSpeed(car, map)).start(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | |
| | | class NeedForSpeed implements Runnable { |
| | | public NeedForSpeed(double[][] car, double[][] map) { |
| | | DrawMap(map, car); |
| | | } |
| | | |
| | | @Override |
| | | public void run() { |
| | | double map[][] = {{1,1}, {10,1}, {10,10}, {1,10}}; |
| | | double car[][] = {{3,3}, {8,3}, {8,8}, {3,8}}; |
| | | |
| | | // double car[][] = {{3,3}, {8,3}, {8,8}, {3,8}}; |
| | | |
| | | |
| | | DrawMap(map, car); |
| | | } |
| | |
| | | }); |
| | | } |
| | | |
| | | int line = 0; |
| | | private ICEventListener icEventListener = new ICEventListener() { |
| | | @Override |
| | | public void onCEvent(String topic, int msgCode, int resultCode, Object obj) { |
| | | MyLog.i(TAG, (String) obj); |
| | | RealTimeCarPos timeCarPos = gson.fromJson((String) obj, RealTimeCarPos.class); |
| | | List<Double> points = timeCarPos.getPoint(); |
| | | line = 0; |
| | | |
| | | for (int i = 0; i < points.size(); i++) { |
| | | if ((i % 2) == 0) { |
| | | car[line][0] = points.get(i); |
| | | } else { |
| | | double value = 0 - points.get(i); |
| | | Log.i(TAG, "onCEvent: 新值=" + value + " 位置:" + i); |
| | | car[line][1] = value; |
| | | line++; |
| | | } |
| | | |
| | | } |
| | | CThreadPoolExecutor.runInBackground(new NeedForSpeed(car,map)); |
| | | } |
| | | }; |
| | | |
| | | @Override |
| | | public void onAttach(Context context) { |
| | | super.onAttach(context); |
| | | CEventCenter.onBindEvent(true, icEventListener, Constant.REAL_TIME_POS_CAR_TOPIC); |
| | | } |
| | | |
| | | @Override |
| | | public void onDetach() { |
| | | super.onDetach(); |
| | | CEventCenter.onBindEvent(false, icEventListener, Constant.REAL_TIME_POS_CAR_TOPIC); |
| | | } |
| | | } |
| | |
| | | package safeluck.drive.evaluation.fragment; |
| | | |
| | | import android.content.Context; |
| | | import android.os.Bundle; |
| | | |
| | | import android.os.Handler; |
| | |
| | | import safeluck.drive.evaluation.adapter.ScoreAdapter; |
| | | import safeluck.drive.evaluation.DB.exam_status.ExamStatus; |
| | | import safeluck.drive.evaluation.bean.ScoreBean; |
| | | import safeluck.drive.evaluation.cEventCenter.CEventCenter; |
| | | import safeluck.drive.evaluation.cEventCenter.ICEventListener; |
| | | import safeluck.drive.evaluation.customview.ArrowView; |
| | | import safeluck.drive.evaluation.customview.HouseView; |
| | | |
| | |
| | | private int item_id;//扣分分数总和 |
| | | private ExamStatusViewModel examStatusViewModel; |
| | | private static final int ADD_DATA = 1; |
| | | private TextView tv_speed,tv_total_score; |
| | | private double speed=0.0; |
| | | |
| | | private int currTotalScore = 100; |
| | | private List<ScoreBean> mArrayList = new ArrayList<>(); |
| | | private static final int SPEED_DATA = 2; |
| | | |
| | | public static SupportFragment newInstance() { |
| | | return new NetWorkTrainFragment(); |
| | |
| | | @Override |
| | | public boolean handleMessage(Message msg) { |
| | | if (msg.what == ADD_DATA){ |
| | | tv_total_score.setText(getResources().getString(R.string.total_score,currTotalScore)); |
| | | houseView.setColor(whatPaintColor(examStatusList.get(0))); |
| | | av_podao.setColor(whatPaintColor(examStatusList.get(1))); |
| | | av_park.setColor(whatPaintColor(examStatusList.get(2))); |
| | | av_curve.setColor(whatPaintColor(examStatusList.get(3))); |
| | | av_zhijiao.setColor(whatPaintColor(examStatusList.get(4))); |
| | | } |
| | | if (msg.what == SPEED_DATA){ |
| | | tv_speed.setText(getResources().getString(R.string.speed,speed)); |
| | | } |
| | | return false; |
| | | } |
| | |
| | | item_conents.add(f.getItem_content()); |
| | | mScoreAdapter.addDatas(mArrayList); |
| | | } |
| | | |
| | | currTotalScore -=item_id; |
| | | if (currTotalScore < Constant.PASSING_SCORE){ |
| | | MyLog.i(TAG,"低于80,不合格"); |
| | | } |
| | | MyLog.i(TAG,"监测到有失败项目加入,通知UI更新颜色"); |
| | | mHandler.obtainMessage(ADD_DATA).sendToTarget(); |
| | | } |
| | |
| | | av_zhijiao = view.findViewById(R.id.av4); |
| | | houseView = view.findViewById(R.id.hv); |
| | | |
| | | tv_speed = view.findViewById(R.id.tv_speed); |
| | | tv_total_score = view.findViewById(R.id.tv_total_score); |
| | | tv_speed.setText(getResources().getString(R.string.speed,speed)); |
| | | |
| | | view.findViewById(R.id.btn_return).setOnClickListener(this); |
| | | mListView = view.findViewById(R.id.lv); |
| | | mListView.setFocusable(false); |
| | |
| | | } |
| | | } |
| | | |
| | | private ICEventListener icEventListener = new ICEventListener() { |
| | | @Override |
| | | public void onCEvent(String topic, int msgCode, int resultCode, Object obj) { |
| | | speed = (double)obj; |
| | | mHandler.obtainMessage(SPEED_DATA).sendToTarget(); |
| | | } |
| | | }; |
| | | @Override |
| | | public void onAttach(Context context) { |
| | | super.onAttach(context); |
| | | CEventCenter.onBindEvent(true,icEventListener,Constant.BIND_SPEED_TOPIC); |
| | | } |
| | | |
| | | @Override |
| | | public void onDetach() { |
| | | super.onDetach(); |
| | | CEventCenter.onBindEvent(false,icEventListener,Constant.BIND_SPEED_TOPIC); |
| | | } |
| | | } |
| | |
| | | import android.view.ViewGroup; |
| | | import android.widget.Button; |
| | | import android.widget.ListView; |
| | | import android.widget.TextView; |
| | | import android.widget.Toast; |
| | | |
| | | import com.anyun.exam.lib.AYSdk; |
| | |
| | | |
| | | private ExamStatusViewModel examStatusViewModel; |
| | | private static final int ADD_DATA = 1; |
| | | private static final int SPEED_DATA = 2; |
| | | |
| | | private List<ScoreBean> mArrayList = new ArrayList<>(); |
| | | private View tv_stop; |
| | | |
| | | private TextView tv_speed,tv_total_score; |
| | | private int currTotalScore = 100; |
| | | private double speed=0.0; |
| | | |
| | | private Handler mHandler = new Handler(new Handler.Callback() { |
| | | @Override |
| | | public boolean handleMessage(Message msg) { |
| | | if (msg.what == ADD_DATA){ |
| | | tv_total_score.setText(getResources().getString(R.string.total_score,currTotalScore)); |
| | | houseView.setColor(whatPaintColor(examStatusList.get(0))); |
| | | av_podao.setColor(whatPaintColor(examStatusList.get(1))); |
| | | av_park.setColor(whatPaintColor(examStatusList.get(2))); |
| | | av_curve.setColor(whatPaintColor(examStatusList.get(3))); |
| | | av_zhijiao.setColor(whatPaintColor(examStatusList.get(4))); |
| | | } |
| | | if (msg.what == SPEED_DATA){ |
| | | tv_speed.setText(getResources().getString(R.string.speed,speed)); |
| | | } |
| | | return false; |
| | | } |
| | | }); |
| | | |
| | | |
| | | @Override |
| | | public void onAttach(Context context) { |
| | | super.onAttach(context); |
| | | } |
| | | |
| | | @Override |
| | | public void onDetach() { |
| | | super.onDetach(); |
| | | } |
| | | |
| | | public static SupportFragment newInstance(){ |
| | | return new TrainFragment(); |
| | |
| | | mArrayList.add(new ScoreBean(f.getScore_deducting(), f.getItem_content(), f.getDeducting_reason())); |
| | | item_conents.add(f.getItem_content()); |
| | | mScoreAdapter.addDatas(mArrayList); |
| | | } |
| | | currTotalScore -=item_id; |
| | | if (currTotalScore < Constant.PASSING_SCORE){ |
| | | MyLog.i(TAG,"低于80,不合格"); |
| | | } |
| | | |
| | | MyLog.i(TAG,"监测到有失败项目加入,通知UI更新颜色"); |
| | |
| | | av_zhijiao = view.findViewById(R.id.av4); |
| | | houseView = view.findViewById(R.id.hv); |
| | | |
| | | tv_speed = view.findViewById(R.id.tv_speed); |
| | | tv_total_score = view.findViewById(R.id.tv_total_score); |
| | | tv_speed.setText(getResources().getString(R.string.speed,speed)); |
| | | view.findViewById(R.id.btn_return).setOnClickListener(this); |
| | | mListView = view.findViewById(R.id.lv); |
| | | tv_stop = view.findViewById(R.id.tv_stop); |
| | |
| | | break; |
| | | } |
| | | } |
| | | |
| | | private ICEventListener icEventListener = new ICEventListener() { |
| | | @Override |
| | | public void onCEvent(String topic, int msgCode, int resultCode, Object obj) { |
| | | speed = (double)obj; |
| | | mHandler.obtainMessage(SPEED_DATA).sendToTarget(); |
| | | } |
| | | }; |
| | | @Override |
| | | public void onAttach(Context context) { |
| | | super.onAttach(context); |
| | | CEventCenter.onBindEvent(true,icEventListener,Constant.BIND_SPEED_TOPIC); |
| | | } |
| | | |
| | | @Override |
| | | public void onDetach() { |
| | | super.onDetach(); |
| | | CEventCenter.onBindEvent(false,icEventListener,Constant.BIND_SPEED_TOPIC); |
| | | } |
| | | } |
| | |
| | | android:gravity="center" |
| | | android:padding="10dp" |
| | | android:id="@+id/tv_speed" |
| | | android:text="车速:"/> |
| | | android:text="@string/speed"/> |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | |
| | | android:id="@+id/tv_pos" |
| | | android:padding="10dp" |
| | | android:gravity="center" |
| | | android:text="已行驶:45km"/> |
| | | android:text="@string/licheng"/> |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | |
| | | android:textColor="@android:color/white" |
| | | android:background="@android:color/holo_green_dark" |
| | | android:padding="5dp" |
| | | android:text="100" /> |
| | | android:id="@+id/tv_total_score" |
| | | android:text="@string/total_score" /> |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | |
| | | <string name="rtk_config_sn">SN:%1$s</string> |
| | | <string name="rtk_connect_status">RTK连接状态:%1$d</string> |
| | | <string name="rtk_config_login">RTK登录结果:%1$d</string> |
| | | <string name="speed">车速:%1$.2fkm/h</string> |
| | | <string name="licheng">已行驶:451km</string> |
| | | <string name="total_score">%1$d</string> |
| | | </resources> |