3 import diku
.distlab
.motecontrolclientlib
.client
.SimpleMote
;
4 import diku
.distlab
.motecontrolclientlib
.client
.SimpleMoteStatus
;
5 import diku
.distlab
.motecontrolclientlib
.protocols
.motecontrol
.MsgCommand
;
6 import diku
.distlab
.motecontrolclientlib
.protocols
.motecontrol
.MsgResult
;
7 import diku
.distlab
.remote
.client
.motedata
.Table
;
8 import diku
.distlab
.remote
.client
.motedata
.TableHeader
;
9 import diku
.distlab
.remote
.client
.motedata
.TableRow
;
11 public class MoteControlRow
extends MoteControl
implements TableRow
, Comparable
{
13 public static final int COL_MOTE_ID
= 0;
15 public static final int COL_SITE
= 1;
17 public static final int COL_TOSADDRESS
= 2;
19 public static final int COL_MACADDRESS
= 3;
21 public static final int COL_STATUS
= 4;
23 public static final int COL_LAST_REQUEST
= 5;
25 public static final int COL_LEDS
= 6;
27 public static final int COL_LOGFILE
= 7;
29 MoteControlTable parentTable
;
33 MoteControlRow(SimpleMote mote
, boolean enableLeds
, TableRow infoRow
,
34 MoteControlTable parentTable
) {
35 super(mote
, enableLeds
);
36 this.parentTable
= parentTable
;
37 this.infoRow
= infoRow
;
40 public Table
getTable() {
44 public Object
get(int columnIndex
) {
46 switch (columnIndex
) {
48 return this.infoRow
.get("mote_id");
50 return this.infoRow
.get("site");
52 return this.infoRow
.get("tosaddress");
54 return this.infoRow
.get("macaddress");
56 return MoteStatusRenderer
.getText(this.getMote().getStatus().getStatus());
57 case COL_LAST_REQUEST
:
58 return decodeLastCommandResult(this.getMote().getStatus());
62 if (this.logging
) return this.logFile
.getPath();
65 } catch (Exception e
) {}
69 public Object
get(String columnName
) throws Exception
{
70 return this.get(this.parentTable
.getHeader().indexOf(columnName
));
73 public int compareTo(Object o
) {
74 if (o
==this) return 0;
78 public static String
decodeLastCommandResult(SimpleMoteStatus s
)
81 switch(s
.getLastCommand())
84 prefix
= "No messages received yet - ";
86 case MsgCommand
.CANCELPROGRAMMING
:
87 prefix
= "Cancel programming ";
89 case MsgCommand
.PROGRAM
:
90 prefix
= "Programming ";
92 case MsgCommand
.RESET
:
95 case MsgCommand
.START
:
98 case MsgCommand
.STATUS
:
99 prefix
= "Status request ";
101 case MsgCommand
.STOP
:
105 prefix
= "Unknown command ";
107 switch(s
.getLastResult())
110 suffix
= "no result available";
112 case MsgResult
.FAILURE
:
115 case MsgResult
.NOT_SUPPORTED
:
116 suffix
= "is not supported";
118 case MsgResult
.SUCCESS
:
119 suffix
= "succesful";
122 suffix
= "unknown result";
124 return prefix
+suffix
;