Skip to content

Commit f1d016a

Browse files
Merge branch 'system/caravel' into develop
2 parents e7716b4 + 1161d47 commit f1d016a

File tree

33 files changed

+3764
-920
lines changed

33 files changed

+3764
-920
lines changed

plugins-dev/caravel-env/plugins.lst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pt.lsts.neptus.plugins.caravelenv.CaravelDataPlotter

plugins-dev/caravel-env/src/java/pt/lsts/neptus/plugins/caravelenv/CaravelDataPlotter.java

Lines changed: 1009 additions & 0 deletions
Large diffs are not rendered by default.

plugins-dev/oplimits/src/java/pt/lsts/neptus/plugins/oplimits/OperationLimitsSubPanel.java

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
import javax.swing.JOptionPane;
7070
import javax.swing.JPanel;
7171
import javax.swing.JPopupMenu;
72+
import javax.swing.SwingWorker;
7273
import javax.swing.border.EmptyBorder;
7374

7475
import com.google.common.eventbus.Subscribe;
@@ -251,10 +252,17 @@ public void actionPerformed(ActionEvent e) {
251252

252253
synchronized (OperationLimitsSubPanel.this) {
253254
lastMD5 = msg.payloadMD5();
254-
boolean ret = send(msg);
255-
if (ret) {
256-
send(new GetOperationalLimits());
257-
}
255+
SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() {
256+
@Override
257+
protected Boolean doInBackground() throws Exception {
258+
boolean ret = send(msg);
259+
if (ret) {
260+
send(new GetOperationalLimits());
261+
}
262+
return ret;
263+
}
264+
};
265+
worker.execute();
258266
}
259267
}
260268
};
@@ -273,7 +281,13 @@ public void actionPerformed(ActionEvent e) {
273281
updateAction.putValue(AbstractAction.SMALL_ICON, ICON_UPDATE_REQUEST);
274282
}
275283
updateAction.putValue(AbstractAction.SHORT_DESCRIPTION, TEXT_REQUEST_RESPONSE_WAITING);
276-
send(IMCDefinition.getInstance().create("GetOperationalLimits"));
284+
SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() {
285+
@Override
286+
protected Boolean doInBackground() throws Exception {
287+
return send(IMCDefinition.getInstance().create("GetOperationalLimits"));
288+
}
289+
};
290+
worker.execute();
277291
}
278292
};
279293

@@ -365,8 +379,7 @@ public boolean send(IMCMessage message) {
365379
if (userAproveRequest) {
366380
lastRequest = new Date();
367381
}
368-
sendViaIridium(destination, message);
369-
return true;
382+
return sendViaIridium(destination, message);
370383
} else {
371384
return false;
372385
}

plugins-dev/remote-actions-extra/src/java/pt/lsts/neptus/plugins/remoteactionsextra/RemoteActionsExtra.java

Lines changed: 117 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import com.google.common.eventbus.Subscribe;
3636
import net.miginfocom.swing.MigLayout;
3737
import pt.lsts.imc.EntityState;
38+
import pt.lsts.imc.IMCMessage;
3839
import pt.lsts.imc.RemoteActions;
3940
import pt.lsts.imc.RemoteActionsRequest;
4041
import pt.lsts.imc.VehicleState;
@@ -50,14 +51,19 @@
5051
import pt.lsts.neptus.plugins.Popup;
5152
import pt.lsts.neptus.plugins.update.Periodic;
5253
import pt.lsts.neptus.util.MathMiscUtils;
54+
import pt.lsts.neptus.util.PropertiesLoader;
55+
import pt.lsts.neptus.util.conf.ConfigFetch;
5356

5457
import javax.swing.JButton;
5558
import javax.swing.JLabel;
5659
import javax.swing.SwingConstants;
5760
import java.awt.event.KeyEvent;
61+
import java.io.File;
62+
import java.io.IOException;
5863
import java.util.ArrayList;
5964
import java.util.Arrays;
6065
import java.util.Collections;
66+
import java.util.Enumeration;
6167
import java.util.LinkedHashMap;
6268
import java.util.List;
6369
import java.util.Map;
@@ -70,6 +76,7 @@
7076
description = "This plugin listen for non motion related remote actions and displays its controls.")
7177
@Popup(name = "Remote Actions Extra", width = 300, height = 200, pos = Popup.POSITION.BOTTOM, accelerator = KeyEvent.VK_3)
7278
public class RemoteActionsExtra extends ConsolePanel implements MainVehicleChangeListener, ConfigurationListener {
79+
public static final String REMOTE_ACTIONS_EXTRA_PROPERTIES_FILE = ".cache/db/remote-actions-extra.properties";
7380

7481
static final boolean DEFAULT_AXIS_DECIMAL_VAL = false;
7582
private static final int DECIMAL_HOUSES_FOR_DECIMAL_AXIS = 6;
@@ -129,6 +136,44 @@ enum ActionTypeEnum {
129136

130137
private final TakeControlMonitor takeControlMonitor;
131138

139+
private static PropertiesLoader properties = null;
140+
static {
141+
String propertiesFile = ConfigFetch.resolvePathBasedOnConfigFile(REMOTE_ACTIONS_EXTRA_PROPERTIES_FILE);
142+
if (!new File(propertiesFile).exists()) {
143+
String testFile = ConfigFetch.resolvePathBasedOnConfigFile("../" + REMOTE_ACTIONS_EXTRA_PROPERTIES_FILE);
144+
if (new File(testFile).exists())
145+
propertiesFile = testFile;
146+
}
147+
new File(propertiesFile).getParentFile().mkdirs();
148+
properties = new PropertiesLoader(propertiesFile, PropertiesLoader.PROPERTIES);
149+
150+
Enumeration<Object> it = properties.keys();
151+
while (it.hasMoreElements()) {
152+
String key = it.nextElement().toString();
153+
String value = properties.getProperty(key);
154+
setRemoteActionsExtra(key, value, false);
155+
}
156+
}
157+
158+
private static void saveProperties() {
159+
try {
160+
properties.store("RemoteActionsExtra properties");
161+
}
162+
catch (IOException e) {
163+
NeptusLog.pub().error("saveProperties", e);
164+
}
165+
}
166+
167+
private static void setRemoteActionsExtra(String system, String actionsStr, boolean save) {
168+
if (save) {
169+
String old = properties.getProperty(system);
170+
if (old == null || !old.equals(actionsStr)) {
171+
properties.setProperty(system, actionsStr);
172+
saveProperties();
173+
}
174+
}
175+
}
176+
132177
@NeptusProperty(name = "OBS Entity Name", userLevel = NeptusProperty.LEVEL.ADVANCED,
133178
description = "Used to check the state of the OBS take control status.")
134179
public String obsEntityName = "OBS Broker";
@@ -145,6 +190,7 @@ public RemoteActionsExtra(ConsoleLayout console, boolean usedInsideAnotherConsol
145190

146191
@Override
147192
public void initSubPanel() {
193+
updateForMainSystems();
148194
resetUIWithActions();
149195
}
150196

@@ -165,64 +211,66 @@ private synchronized void resetUIWithActions() {
165211
removeAll();
166212
setLayout(new MigLayout("insets 10px"));
167213

168-
if (extraActionsTypesMap.isEmpty()) {
169-
add(new JLabel("No actions available", SwingConstants.CENTER), "dock center");
170-
invalidate();
171-
validate();
172-
repaint(100);
173-
return;
174-
}
175-
176-
// Let us process the actions list
177-
List<List<String>> groupedActions = groupActionsBySimilarity(extraActionsTypesMap.keySet(), true);
178-
groupedActions = processActions(groupedActions, 2, false);
179-
180-
int grpIdx = 0;
181-
for (List<String> grp1 : groupedActions) {
182-
grpIdx++;
183-
String lastAct = grp1.get(grp1.size() - 1);
184-
for (String action : grp1) {
185-
String wrapLay = "";
186-
if (lastAct.equals(action)) {
187-
wrapLay = "wrap";
188-
}
214+
synchronized (extraActionsTypesMap) {
215+
if (extraActionsTypesMap.isEmpty()) {
216+
add(new JLabel("No actions available", SwingConstants.CENTER), "dock center");
217+
invalidate();
218+
validate();
219+
repaint(100);
220+
return;
221+
}
189222

190-
boolean provideLock = false;
191-
if (curState.extraActionsLocksMap.containsKey(action)) {
192-
Boolean v = curState.extraActionsLocksMap.get(action);
193-
if (v != null && v) {
194-
provideLock = true;
223+
// Let us process the actions list
224+
List<List<String>> groupedActions = groupActionsBySimilarity(extraActionsTypesMap.keySet(), true);
225+
groupedActions = processActions(groupedActions, 2, false);
226+
227+
int grpIdx = 0;
228+
for (List<String> grp1 : groupedActions) {
229+
grpIdx++;
230+
String lastAct = grp1.get(grp1.size() - 1);
231+
for (String action : grp1) {
232+
String wrapLay = "";
233+
if (lastAct.equals(action)) {
234+
wrapLay = "wrap";
195235
}
196-
}
197236

198-
switch (extraActionsTypesMap.get(action)) {
199-
case BUTTON:
200-
boolean isToProvideLock = provideLock || isActionForLock(action);
201-
JButton button = isToProvideLock ? new HoldFillButton(action, 2000) : new JButton(action);
202-
button.addActionListener(e -> {
203-
curState.changeButtonActionValue(action, 1);
204-
});
205-
String lay = "dock center, sg grp" + grpIdx;
206-
lay += ", " + wrapLay;
207-
add(button, lay);
208-
if (isToProvideLock) {
209-
extraLockableButtons.add(button);
237+
boolean provideLock = false;
238+
if (curState.extraActionsLocksMap.containsKey(action)) {
239+
Boolean v = curState.extraActionsLocksMap.get(action);
240+
if (v != null && v) {
241+
provideLock = true;
210242
}
211-
if ("Take Control".equalsIgnoreCase(action)) {
212-
takeControlMonitor.setButton(button);
213-
takeControlMonitor.askedControl();
214-
}
215-
break;
216-
case AXIS:
217-
// TODO
218-
case SLIDER:
219-
// TODO
220-
case HALF_SLIDER:
221-
// TODO
222-
break;
223-
}
224-
}
225-
}
243+
}
244+
245+
switch (extraActionsTypesMap.get(action)) {
246+
case BUTTON:
247+
boolean isToProvideLock = provideLock || isActionForLock(action);
248+
JButton button = isToProvideLock ? new HoldFillButton(action, 2000) : new JButton(action);
249+
button.addActionListener(e -> {
250+
curState.changeButtonActionValue(action, 1);
251+
});
252+
String lay = "dock center, sg grp" + grpIdx;
253+
lay += ", " + wrapLay;
254+
add(button, lay);
255+
if (isToProvideLock) {
256+
extraLockableButtons.add(button);
257+
}
258+
if ("Take Control".equalsIgnoreCase(action)) {
259+
takeControlMonitor.setButton(button);
260+
takeControlMonitor.askedControl();
261+
}
262+
break;
263+
case AXIS:
264+
// TODO
265+
case SLIDER:
266+
// TODO
267+
case HALF_SLIDER:
268+
// TODO
269+
break;
270+
}
271+
}
272+
}
273+
}
226274

227275
invalidate();
228276
validate();
@@ -232,9 +280,22 @@ private synchronized void resetUIWithActions() {
232280
@Subscribe
233281
public void on(ConsoleEventMainSystemChange evt) {
234282
configureActions("", DEFAULT_AXIS_DECIMAL_VAL, false);
283+
updateForMainSystems();
235284
takeControlMonitor.on(evt);
236285
}
237286

287+
private void updateForMainSystems() {
288+
String actionsString = "";
289+
try {
290+
if (properties.containsKey(getConsole().getMainSystem())) {
291+
actionsString = (String) properties.get(getConsole().getMainSystem());
292+
}
293+
} catch (Exception e) {
294+
NeptusLog.pub().error(e.getMessage());
295+
}
296+
configureActions(actionsString, DEFAULT_AXIS_DECIMAL_VAL, false);
297+
}
298+
238299
@Subscribe
239300
public void on(RemoteActionsRequest msg) {
240301
if (!msg.getSourceName().equals(getMainVehicleId())) {
@@ -243,7 +304,8 @@ public void on(RemoteActionsRequest msg) {
243304

244305
if (msg.getOp() != RemoteActionsRequest.OP.REPORT) return;
245306

246-
configureActions(msg.getAsString("actions"), DEFAULT_AXIS_DECIMAL_VAL, false);
307+
setRemoteActionsExtra(msg.getSourceName(), IMCMessage.encodeTupleList(msg.getActions()), true);
308+
configureActions(msg.getActions(), DEFAULT_AXIS_DECIMAL_VAL, false);
247309
}
248310

249311
@Subscribe

plugins-dev/sunfish/src/java/pt/lsts/neptus/plugins/sunfish/iridium/feedback/IridiumStatus.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,16 @@ public void run() {
187187

188188
@Override
189189
public int compare(String sdf1, String sdf2) {
190+
if (sdf1 == null && sdf2 == null) {
191+
return 0;
192+
}
193+
else if (sdf1 == null) {
194+
return -1;
195+
}
196+
else if (sdf2 == null) {
197+
return 1;
198+
}
199+
190200
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.SSS dd-MM-yyyy 'Z'");
191201
sdf1 = sdf1.replaceAll("V ", "");
192202
sdf2 = sdf2.replaceAll("V ", "");

0 commit comments

Comments
 (0)