lizhanwei
2020-02-26 c9fc43ded908425af405f61a1df3474dd3105e92
完成所有协议
11个文件已修改
3个文件已添加
362 ■■■■■ 已修改文件
app/src/main/java/safeluck/drive/evaluation/DB/failitems/FailProjDao.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/DB/failitems/FailedProj.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/DB/failitems/FailedProj_select.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/MainActivity.java 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/app.java 67 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/bean/ExamPlatformData.java 49 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/fragment/BaseDatasFragment.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/fragment/TcpFragment.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/platformMessage/JKMessage0203.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/platformMessage/JKMessage0206.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/platformMessage/decoder/SPEED.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/platformMessage/decoder/SpeedCoder.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/viewmodels/ExamPlatformModel.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/DB/failitems/FailProjDao.java
@@ -25,14 +25,14 @@
     * 如果要添加 科目二II   III类考场失败项目,需要建立相应的评判标准表数据表
     * @return
     */
    @Query("SELECT emp_id,stu_id,deducting_reason,score_deducting,item_content from criteria_one INNER JOIN fail_projects ON  criteria_one.item_id= fail_projects.emp_id where fail_projects.stu_id=:stu_id and fail_projects.subject=1")
    @Query("SELECT emp_id,stu_id, utc ,sn ,deducting_reason,score_deducting,item_content from criteria_one INNER JOIN fail_projects ON  criteria_one.item_id= fail_projects.emp_id where fail_projects.stu_id=:stu_id and fail_projects.subject=1")
    LiveData<List<FailedProj_select>> getFailedProjectsForI(long stu_id);
    /**
     * 查询 科目二 II类考场的失败项目 (多表查询)
     * 如果要添加 科目二II   III类考场失败项目,需要建立相应的评判标准表数据表
     * @return
     */
    @Query("SELECT emp_id,stu_id,deducting_reason,score_deducting,item_content from criteria_two INNER JOIN fail_projects ON  criteria_two.item_id= fail_projects.emp_id where fail_projects.stu_id=:stu_id and fail_projects.subject=2")
    @Query("SELECT emp_id,stu_id,utc,sn,deducting_reason,score_deducting,item_content from criteria_two INNER JOIN fail_projects ON  criteria_two.item_id= fail_projects.emp_id where fail_projects.stu_id=:stu_id and fail_projects.subject=2")
    LiveData<List<FailedProj_select>> getFailedProjectsForII(long stu_id);
    /**
app/src/main/java/safeluck/drive/evaluation/DB/failitems/FailedProj.java
@@ -37,13 +37,30 @@
    //作为外键,对应I类考场的item_id
    @ColumnInfo(name = "emp_id")
    private int emp_id;
    public FailedProj(int subject, int emp_id,long stu_id) {
    private int  sn;
    private String utc;
    public FailedProj(int subject, int emp_id,long stu_id,String utc,int sn) {
        this.subject = subject;
        this.emp_id = emp_id;
        this.stu_id = stu_id;
        this.sn = sn;
        this.utc = utc;
    }
    public int getSn() {
        return sn;
    }
    public void setSn(int sn) {
        this.sn = sn;
    }
    public String getUtc() {
        return utc;
    }
    public void setUtc(String utc) {
        this.utc = utc;
    }
    public int getId() {
        return id;
    }
@@ -75,4 +92,16 @@
    public void setEmp_id(int emp_id) {
        this.emp_id = emp_id;
    }
    @Override
    public String toString() {
        return "FailedProj{" +
                "id=" + id +
                ", stu_id=" + stu_id +
                ", subject=" + subject +
                ", emp_id=" + emp_id +
                ", sn=" + sn +
                ", utc='" + utc + '\'' +
                '}';
    }
}
app/src/main/java/safeluck/drive/evaluation/DB/failitems/FailedProj_select.java
@@ -16,6 +16,8 @@
    private long stu_id;
    private String item_content;
    private String deducting_reason;
    private int  sn;
    private String utc;
    private int score_deducting;
    public int getEmp_id() {
@@ -42,6 +44,22 @@
        this.deducting_reason = deducting_reason;
    }
    public int getSn() {
        return sn;
    }
    public void setSn(int sn) {
        this.sn = sn;
    }
    public String getUtc() {
        return utc;
    }
    public void setUtc(String utc) {
        this.utc = utc;
    }
    public long getStu_id() {
        return stu_id;
    }
app/src/main/java/safeluck/drive/evaluation/MainActivity.java
@@ -25,6 +25,7 @@
import safeluck.drive.evaluation.DB.rtktb.RTKConfigViewModel;
import safeluck.drive.evaluation.DB.signalConfigdb.SignalConfigViewModel;
import safeluck.drive.evaluation.DB.signalConfigdb.SingalConfig;
import safeluck.drive.evaluation.bean.ExamPlatformData;
import safeluck.drive.evaluation.bean.SignalConfigRemote;
import safeluck.drive.evaluation.cEventCenter.CEventCenter;
import safeluck.drive.evaluation.cEventCenter.ICEventListener;
@@ -54,6 +55,7 @@
import safeluck.drive.evaluation.util.FileUtil;
import safeluck.drive.evaluation.util.PermissionManager;
import safeluck.drive.evaluation.util.SPUtils;
import safeluck.drive.evaluation.viewmodels.ExamPlatformModel;
import safeluck.drive.evaluation.viewmodels.MainViewModel;
import safeluck.drive.evaluation.viewmodels.RTKConnAndLogin;
import safeluck.drive.evaluation.viewmodels.RTKConnAndLoginViewModel;
@@ -158,10 +160,27 @@
        setContentView(R.layout.activity_main);
        // TODO
        //  进行tcp连接
        String userId = "100002";
        String token = "token_" + userId;
        String hosts = "[{\"host\":\"192.168.31.77\", \"port\":12125}]";
        IMSClientBootstrap.getInstance().init(userId,token,hosts,1,this);
        final String userId = "100002";
        final String token = "token_" + userId;
        ExamPlatformModel examPlatformModel = ViewModelProviders.of(this).get(ExamPlatformModel.class);
        examPlatformModel.getDataChange().observe(this, new Observer<Integer>() {
            @Override
            public void onChanged(Integer integer) {
                Log.i(TAG, "ExamPlatformModel onChanged: integer=="+integer);
                if (integer == 1){
                    MyLog.i("重新连接考试平台");
                }else{
                }
                String str = ExamPlatformData.getInstance().getPlatformIP();
                String hosts = "[{\"host\":"+str+","+ "\"port\":"+ExamPlatformData.getInstance().getPlatformPort()+"}]";
                MyLog.i("hosts="+hosts);
                IMSClientBootstrap.getInstance().init(userId,token,hosts,1,MainActivity.this);
            }
        });
app/src/main/java/safeluck/drive/evaluation/app.java
@@ -43,6 +43,7 @@
import safeluck.drive.evaluation.DB.exam_status.ExamStatusWoker;
import safeluck.drive.evaluation.DB.failitems.FailedProj;
import safeluck.drive.evaluation.DB.failitems.FailedProjRepository;
import safeluck.drive.evaluation.DB.failitems.FailedProj_select;
import safeluck.drive.evaluation.DB.gps.GpsInfoWorker;
import safeluck.drive.evaluation.DB.rtktb.RTKConfig;
import safeluck.drive.evaluation.DB.rtktb.RTKWorkRepository;
@@ -51,9 +52,11 @@
import safeluck.drive.evaluation.im.IMSClientBootstrap;
import safeluck.drive.evaluation.im.IMSConnectStatusListener;
import safeluck.drive.evaluation.im.MessageProcessor;
import safeluck.drive.evaluation.platformMessage.AttachInfo;
import safeluck.drive.evaluation.platformMessage.JKMessage0100;
import safeluck.drive.evaluation.platformMessage.JKMessage0101;
import safeluck.drive.evaluation.platformMessage.JKMessage0203;
import safeluck.drive.evaluation.platformMessage.JKMessage0206;
import safeluck.drive.evaluation.util.FileUtil;
import safeluck.drive.evaluation.util.SPUtils;
import safeluck.drive.evaluation.util.SystemUtil;
@@ -175,24 +178,23 @@
            case Constant.JUDGE_INFO:
                if(!TextUtils.isEmpty(json)){
                    JKMessage0203 jkMessage0203 = new JKMessage0203();
                    jkMessage0203.phone = "0314200100000004";
                    jkMessage0203.timeBCD = new Date();
                    jkMessage0203.fail_item_id = 4;
                    jkMessage0203.fail_score = 10;
                    jkMessage0203.fail_reason = "发动机启动后,不及时松开启动开关";
                    jkMessage0203.ID = "123456789";
                    jkMessage0203.exam_id = 123456;
                    MessageProcessor.getInstance().sendMessage(jkMessage0203);
                    JsonArray jsonArray = JsonParser.parseString(json).getAsJsonArray();
                    for (int i = 0; i < jsonArray.size(); i++) {
                        JsonObject jsonObject = jsonArray.get(i).getAsJsonObject();
                        int emp_id = jsonObject.get("wrong_id").getAsInt();
                        String utc = jsonObject.get("utc").getAsString();
                        MyLog.i("评判消息解析之前的utc="+utc);
                        utc = utc.substring(2,utc.length()-3);
                        MyLog.i("评判消息解析之后的utc="+utc);
                        int sn = jsonObject.get("sn").getAsInt();
                        if (emp_id>31|| emp_id<0){
                            MyLog.i(TAG,"emp_id超出范围不能插入数据库(I类考场)");
                            return;
                        }
                        failedProjRepository.insert(new FailedProj(Constant.SUBJECT_I, emp_id, Constant.TEST_STU_ID));
                        FailedProj failedProj = new FailedProj(Constant.SUBJECT_I, emp_id, Constant.TEST_STU_ID,utc,sn);
                        MyLog.i("插入fail_projects表="+failedProj.toString());
                        failedProjRepository.insert(failedProj);
                    }
                }
@@ -266,6 +268,51 @@
                CEventCenter.dispatchEvent(Constant.BIND_SPEED_TOPIC,cmd,0,json);
                break;
            case Constant.RTK_INFO:
                try {
                    JSONObject jsSpeed = new JSONObject(json);
                    double latitude = jsSpeed.getDouble("latitude");
                    double longitude = jsSpeed.getDouble("longitude");
                    double altitude = jsSpeed.getDouble("altitude");
                    double speed = jsSpeed.getDouble("speed");
                    int  qf = jsSpeed.getInt("qf");
                    double track_ture = jsSpeed.getDouble("track_ture");
                    String utc = jsSpeed.getString("utc");
                    utc = utc.replace(".","");
                    MyLog.i("RTK info 修改后的utc"+utc);
                    JKMessage0206 jkMessage0206 = new JKMessage0206();
                    jkMessage0206.alert = 0;
                    jkMessage0206.status = 0;
                    jkMessage0206.jd = longitude;
                    jkMessage0206.wd = latitude;
                    jkMessage0206.gaoCheng = (int)altitude;
                    jkMessage0206.speed = speed;
                    jkMessage0206.fangXiang = (int)track_ture;
                    jkMessage0206.rf = qf;
                    jkMessage0206.timeBCD = utc;
                    jkMessage0206.json =json;
                    jkMessage0206.length = jkMessage0206.json.length();
                    AttachInfo attachInfo = new AttachInfo();
                    attachInfo.attach_message_id = Integer.parseInt(String.valueOf(0x40));
                    attachInfo.attach_message_length = 4;
                    Log.i(TAG, "attachInfo.attach_message_id ="+attachInfo.attach_message_id );
                    if (attachInfo.attach_message_id == 0x41){
                        Log.i(TAG, "onClick: 41");
                        attachInfo.attach_data="00000000";
                    }else{
                        //18个字节 ascii
                        attachInfo.attach_data="303030303030303030303030303030303030";
                    }
                    jkMessage0206.attachInfo = attachInfo;
                    Log.i(TAG, "位置上报="+jkMessage0206.toString());
                    MessageProcessor.getInstance().sendMessage(jkMessage0206);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                break;
        }
app/src/main/java/safeluck/drive/evaluation/bean/ExamPlatformData.java
@@ -1,31 +1,46 @@
package safeluck.drive.evaluation.bean;
import android.content.Context;
import android.util.Log;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.ViewModelProviders;
import com.anyun.exam.lib.MyLog;
import java.util.Random;
import safeluck.drive.evaluation.app;
import safeluck.drive.evaluation.util.SPUtils;
import safeluck.drive.evaluation.viewmodels.ExamPlatformModel;
import safeluck.drive.evaluation.viewmodels.MainViewModel;
public class ExamPlatformData {
    private static final ExamPlatformData ourInstance = new ExamPlatformData();
    private int exam_id =12345;//考试唯一ID
    private String id;//身份证
    private String ip;
    private int port;
    public static ExamPlatformData getInstance() {
        return ourInstance;
    }
    private ExamPlatformData() {
    private ExamPlatformData() {
    }
    public String getPlatformIP(){
        return (String) SPUtils.get(app.getAppContext(),SPUtils.PLATFORM_IP,"");
        ip = (String) SPUtils.get(app.getAppContext(),SPUtils.PLATFORM_IP,"47.93.157.103");
        return ip;
    }
    public int getPlatformPort(){
        return (int) SPUtils.get(app.getAppContext(),SPUtils.PLATFORM_PORT,0);
        port = (int) SPUtils.get(app.getAppContext(),SPUtils.PLATFORM_PORT,2020);
        return port;
    }
    /**
@@ -33,8 +48,24 @@
     * @param ip
     */
    public void insertPlatformIp(String ip){
        SPUtils.put(app.getAppContext(),SPUtils.PLATFORM_IP,ip);
    }
    /**
     * 比较ip地址和端口号,
     * @param ip
     * @param port
     * @return ip和端口其中有变化,返回true,否则返回false
     */
    public boolean compareIPandPort(String ip,int port){
        MyLog.i( "compareIPandPort: "+ip+" "+port);
        if(!getPlatformIP().equalsIgnoreCase(ip) || getPlatformPort()!=port){
            MyLog.i("ip和端口有变化");
            return true;
        }
        return false;
    }
    /**
@@ -45,11 +76,17 @@
        SPUtils.put(app.getAppContext(),SPUtils.PLATFORM_PORT,port);
    }
    public int getExamUniqueID(){
        return exam_id;
    public String getID() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public int getExam_id() {
        return exam_id;
    }
}
app/src/main/java/safeluck/drive/evaluation/fragment/BaseDatasFragment.java
@@ -3,6 +3,7 @@
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.ViewModelProviders;
import android.util.Log;
import android.view.LayoutInflater;
@@ -25,6 +26,7 @@
import safeluck.drive.evaluation.R;
import safeluck.drive.evaluation.bean.ExamPlatformData;
import safeluck.drive.evaluation.util.FileUtil;
import safeluck.drive.evaluation.viewmodels.ExamPlatformModel;
/**
 * 基础数据设置
@@ -41,7 +43,7 @@
    private Button btn_config_signal;
    private Button btn_mcu_upgrade;
    private EditText et_ip,et_port;
    private ExamPlatformModel examPlatformModel;
    public static SupportFragment newInstance() {
        return new BaseDatasFragment();
    }
@@ -53,11 +55,12 @@
        View view = inflater.inflate(R.layout.layout_base_datas, container, false);
        initView(view);
        examPlatformModel = ViewModelProviders.of(this).get(ExamPlatformModel.class);
        return view;
    }
    private void initView(View view) {
        view.findViewById(R.id.btn_save_platform);
        view.findViewById(R.id.btn_save_platform).setOnClickListener(this);
        et_ip = view.findViewById(R.id.et_platform_ip);
        et_port = view.findViewById(R.id.et_platform_port);
        btn_inspect_signal = view.findViewById(R.id.btn_inpsect_signal);
@@ -97,8 +100,11 @@
                }
                break;
            case R.id.btn_save_platform:
                if(ExamPlatformData.getInstance().compareIPandPort(et_ip.getText().toString().trim(),Integer.parseInt(et_port.getText().toString().trim()))){
                    examPlatformModel.changeDataValue(1);
                ExamPlatformData.getInstance().insertPlatformIp(et_ip.getText().toString().trim());
                ExamPlatformData.getInstance().insertPlatformPort(Integer.parseInt(et_port.getText().toString().trim()));
                }
                break;
            default:
                break;
app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java
@@ -49,6 +49,7 @@
import safeluck.drive.evaluation.R;
import safeluck.drive.evaluation.adapter.ScoreAdapter;
import safeluck.drive.evaluation.DB.exam_status.ExamStatus;
import safeluck.drive.evaluation.bean.ExamPlatformData;
import safeluck.drive.evaluation.bean.ScoreBean;
import safeluck.drive.evaluation.cEventCenter.CEventCenter;
import safeluck.drive.evaluation.cEventCenter.ICEventListener;
@@ -57,6 +58,7 @@
import safeluck.drive.evaluation.im.MessageProcessor;
import safeluck.drive.evaluation.platformMessage.JKMessage0201;
import safeluck.drive.evaluation.platformMessage.JKMessage0202;
import safeluck.drive.evaluation.platformMessage.JKMessage0203;
import safeluck.drive.evaluation.platformMessage.JKMessage0204;
/**
@@ -156,6 +158,7 @@
                        mScoreAdapter.addDatas(mArrayList);
                    }
                    //TODO 发送JKMessage0203 给平台,这儿有点复杂,看怎么处理
                    sendJKMessage0203(failedProj_selects);
                    currTotalScore -=item_id;
                    if (currTotalScore < Constant.PASSING_SCORE){
                        MyLog.i(TAG,"低于80,不合格");
@@ -213,6 +216,7 @@
                        tv_name.setText(getString(R.string.name)+student.getName());
                        tv_id.setText(getString(R.string.user_id)+student.getID());
                        ExamPlatformData.getInstance().setId(student.getID());
                    }
                }
            }
@@ -231,6 +235,53 @@
        });
        return view;
    }
    private List<Integer> sns =new ArrayList<>();
    private void sendJKMessage0203(List<FailedProj_select> failedProj_selects) {
        JKMessage0203 jkMessage0203 = new JKMessage0203();
        jkMessage0203.phone = "0314200100000004";
        jkMessage0203.ID = ExamPlatformData.getInstance().getID();
        jkMessage0203.exam_id = ExamPlatformData.getInstance().getExam_id();
        for (int i = 0; i < failedProj_selects.size(); i++) {
            if (hasSnEqulas(failedProj_selects)){
            }else{
                MyLog.i("没有相同的sn,发送");
                sns.add(failedProj_selects.get(i).getSn());
                jkMessage0203.timeBCD = failedProj_selects.get(i).getUtc();
                jkMessage0203.fail_item_id = failedProj_selects.get(i).getEmp_id();
                jkMessage0203.fail_score = failedProj_selects.get(i).getScore_deducting();
                jkMessage0203.fail_reason = failedProj_selects.get(i).getDeducting_reason();
            }
        }
        MessageProcessor.getInstance().sendMessage(jkMessage0203);
    }
    private boolean hasSnEqulas(List<FailedProj_select> failedProj_selects){
        if (sns.size() > 0){
            for (int i = 0; i < failedProj_selects.size(); i++) {
            for (int j = 0; j < sns.size(); j++) {
                if (sns.get(j) == failedProj_selects.get(i).getSn()){
                    MyLog.i("sn相同,不发");
                    return true;
                }else{
                    continue;
                }
                }
            }
        }
        return false;
    }
    private int whatPaintColor(ExamStatus examStat) {
@@ -344,8 +395,8 @@
                jkMessage0202.phone = "0314200100000004";
                jkMessage0202.timeBCD = new Date();
                jkMessage0202.curr_exam = 0;
                jkMessage0202.ID = "123456789";
                jkMessage0202.exam_id = 123456;
                jkMessage0202.ID = ExamPlatformData.getInstance().getID();
                jkMessage0202.exam_id = ExamPlatformData.getInstance().getExam_id();
                MessageProcessor.getInstance().sendMessage(jkMessage0202);
                break;
            case R.id.tv_stop:
@@ -399,8 +450,8 @@
        jkMessage0204.timeBCD = new Date();
        jkMessage0204.score = 10;
        jkMessage0204.stop = JKMessage0204.SUCC_STOP;
        jkMessage0204.ID = "123456789";
        jkMessage0204.exam_id = 123456;
        jkMessage0204.ID = ExamPlatformData.getInstance().getID();
        jkMessage0204.exam_id = ExamPlatformData.getInstance().getExam_id();
        MessageProcessor.getInstance().sendMessage(jkMessage0204);
    }
app/src/main/java/safeluck/drive/evaluation/fragment/TcpFragment.java
@@ -236,7 +236,7 @@
            case R.id.btn_fail:
                JKMessage0203 jkMessage0203 = new JKMessage0203();
                jkMessage0203.phone = "0314200100000004";
                jkMessage0203.timeBCD = new Date();
                jkMessage0203.timeBCD = "200226135444";
                jkMessage0203.fail_item_id = 4;
                jkMessage0203.fail_score = 10;
                jkMessage0203.fail_reason = "发动机启动后,不及时松开启动开关";
app/src/main/java/safeluck/drive/evaluation/platformMessage/JKMessage0203.java
@@ -2,6 +2,7 @@
import com.safeluck.aykj.annotation.Ascii;
import com.safeluck.aykj.annotation.BcdDateTime;
import com.safeluck.aykj.annotation.Hex;
import com.safeluck.aykj.annotation.Int32;
import com.safeluck.aykj.annotation.Int8;
import com.safeluck.aykj.annotation.Length;
@@ -15,8 +16,12 @@
    @Ascii
    public String ID;
    @Order(2)
    @BcdDateTime
    public Date timeBCD;
    @Length(6)
    @Hex
    public String timeBCD;
//    @Order(2)
//    @BcdDateTime
//    public Date timeBCD;
    @Order(3)
    @Int32
    public int exam_id;
app/src/main/java/safeluck/drive/evaluation/platformMessage/JKMessage0206.java
@@ -3,6 +3,7 @@
import com.safeluck.aykj.annotation.*;
import safeluck.drive.evaluation.platformMessage.decoder.JWD;
import safeluck.drive.evaluation.platformMessage.decoder.SPEED;
public class JKMessage0206 extends JK2019MessageBase {
    @Order(1)
@@ -22,8 +23,8 @@
    @Int16
    public int gaoCheng;
    @Order(6)
    @Int16
    public int speed;
    @SPEED
    public double speed;
    @Order(7)
    @Int16
    public int fangXiang;
app/src/main/java/safeluck/drive/evaluation/platformMessage/decoder/SPEED.java
New file
@@ -0,0 +1,19 @@
package safeluck.drive.evaluation.platformMessage.decoder;
import com.safeluck.aykj.annotation.Length;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
 * Created by zw on 2017/6/15.
 */
@Length(2)
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface SPEED {
//    Class<? extends IMessageCoder<?>>[] coder() default Int32Coder.class;
}
app/src/main/java/safeluck/drive/evaluation/platformMessage/decoder/SpeedCoder.java
New file
@@ -0,0 +1,29 @@
package safeluck.drive.evaluation.platformMessage.decoder;
import com.safeluck.aykj.decoder.BaseDecoder;
import com.safeluck.aykj.decoder.Int16Coder;
import com.safeluck.aykj.decoder.Int32Coder;
import java.math.BigDecimal;
/**
 * Created by zw on 2017/6/15.
 */
public class SpeedCoder extends BaseDecoder<Double> {
    Int16Coder coder = new Int16Coder();
    @Override
    public Double decode(String str) {
        double ret = coder.decode(str);
        double x = ret / 10;
        BigDecimal bg = new BigDecimal(x);
        double f1 = bg.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
        return f1;
    }
    @Override
    public String encode(Double str) {
        int speed = (int)(str * 10);
        return coder.encode(speed);
    }
}
app/src/main/java/safeluck/drive/evaluation/viewmodels/ExamPlatformModel.java
New file
@@ -0,0 +1,31 @@
package safeluck.drive.evaluation.viewmodels;
import android.util.Log;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import com.anyun.exam.lib.MyLog;
import java.util.concurrent.atomic.AtomicInteger;
public class ExamPlatformModel extends ViewModel {
    private static final String TAG = "ExamPlatformModel";
    private MutableLiveData<Integer> dataChange = new MutableLiveData<>(0);
    public LiveData<Integer> getDataChange(){
        return dataChange;
    }
    public void changeDataValue(final int value){
        new Thread(new Runnable() {
            @Override
            public void run() {
                dataChange.postValue(value);
            }
        }).start();
    }
}