yy1717
2020-03-02 d534b3b9b056fff3bcc887d72ed11f4256cdd2fd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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;
    private String mapPath;//绝对路径包含文件名的path
    private String carPath;//绝对路径包含文件名的path
 
    public static ExamPlatformData getInstance() {
        return ourInstance;
    }
 
 
    private ExamPlatformData() {
    }
 
    public String getPlatformIP(){
        ip = (String) SPUtils.get(app.getAppContext(),SPUtils.PLATFORM_IP,"47.93.157.103");
        return ip;
    }
 
    public int getPlatformPort(){
        port = (int) SPUtils.get(app.getAppContext(),SPUtils.PLATFORM_PORT,2020);
        return port;
    }
 
    /**
     * 插入平台IP地址
     * @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;
    }
 
    /**
     * 插入平台端口号
     * @param port
     */
    public void insertPlatformPort(int port){
        SPUtils.put(app.getAppContext(),SPUtils.PLATFORM_PORT,port);
    }
 
 
 
    public String getID() {
        return id;
    }
 
    public void setId(String id) {
        this.id = id;
    }
 
    public int getExam_id() {
        return exam_id;
    }
 
    public void setNewMapPath(String path) {
        this.mapPath = path;
        SPUtils.put(app.getAppContext(),SPUtils.MAP_PATH,mapPath);
    }
 
    public String  getMapPath(){
        mapPath = (String) SPUtils.get(app.getAppContext(),SPUtils.MAP_PATH,"");
        return mapPath;
    }
 
    /**
     * 设置保存地图模型文件(坐标点—)的路径
     * @param car_path
     */
    public void setCarModelPath(String car_path) {
        this.carPath = car_path;
        SPUtils.put(app.getAppContext(),SPUtils.CAR_PATH,car_path);
    }
 
    public String getCarModelPath(){
        carPath = (String) SPUtils.get(app.getAppContext(),SPUtils.CAR_PATH,"");
        return carPath;
    }
}