/
BoardInfo.java
129 lines (104 loc) · 3.35 KB
/
BoardInfo.java
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
119
120
121
122
123
124
125
126
127
128
129
package org.myrobotlab.arduino;
import java.io.Serializable;
import org.myrobotlab.logging.LoggerFactory;
import org.slf4j.Logger;
/**
* BoardInfo is all info which needs to be published only once after connection
*/
public class BoardInfo implements Serializable {
private static final long serialVersionUID = 1L;
transient public final static Logger log = LoggerFactory.getLogger(BoardInfo.class);
// requested by the user
// String boardName;
// reported from the board
// Integer boardId;
Integer version;
// FIXME - isUserSet isBoardSet isLoaded - BoardType as a class ?? - to String
// give {board}name ?
// boolean valid = false;
// dynamic changing values
Integer sram;
Integer microsPerLoop;
Integer activePins;
DeviceSummary[] deviceSummary; // deviceList with types
// if true boardInfo will be published at a regular 1s interval
boolean enableBoardInfo = false;
public long heartbeatMs;
public BoardInfo() {
// setType(-1);
}
public BoardInfo(int version) {
this.version = version;
// this.boardId = boardId;
}
/*
* public String getName() { return boardName; }
*/
/*
*
* public boolean isUnknown() { return (boardName == null) ||
* boardName.equals("unknown"); }
*/
/**
* called on disconnect() so it can re-initalize if connected to a different
* arduino
*/
public void reset() {
// boardId = -1;
version = null;
// boardName = null;
// valid = false;
}
public Integer getVersion() {
return version;
}
public void setVersion(Integer version) {
// valid = true;
this.version = version;
}
/*
* public boolean isValid() { return valid; }
*/
/*
* public void setType(String board) { boardName = board; if
* (Arduino.BOARD_TYPE_MEGA.equals(board)) { boardId =
* Arduino.BOARD_TYPE_ID_MEGA; } else if
* (Arduino.BOARD_TYPE_MEGA_ADK.equals(board)) { boardId =
* Arduino.BOARD_TYPE_ID_ADK_MEGA; } else if
* (Arduino.BOARD_TYPE_UNO.equals(board)) { boardId =
* Arduino.BOARD_TYPE_ID_UNO; } else if
* (Arduino.BOARD_TYPE_NANO.equals(board)) { boardId =
* Arduino.BOARD_TYPE_ID_NANO; } else if
* (Arduino.BOARD_TYPE_PRO_MINI.equals(board)) { boardId =
* Arduino.BOARD_TYPE_ID_PRO_MINI; } else { boardId =
* Arduino.BOARD_TYPE_ID_UNKNOWN; } }
*/
/*
* public int getBoardType() { return boardId; }
*/
public void setMicrosPerLoop(int microsPerLoop) {
this.microsPerLoop = microsPerLoop;
}
public void setSram(Integer sram) {
this.sram = sram;
}
public void setDeviceSummary(DeviceSummary[] deviceSummary) {
this.deviceSummary = deviceSummary;
}
public void setActivePins(Integer activePins) {
this.activePins = activePins;
}
public String toString() {
if (version != null) {
/*
* return
* String.format("%s version %s load %d heartbeat %d sram %d devices %d",
* boardName, version, microsPerLoop, heartbeatMs, sram, (deviceSummary !=
* null) ? deviceSummary.length : 0);
*/
return String.format("version %s load %d heartbeat %d sram %d devices %d", version, microsPerLoop, heartbeatMs, sram, (deviceSummary != null) ? deviceSummary.length : 0);
} else {
return "unknown";
}
}
}