Skip to content

Commit

Permalink
More code cleanups.
Browse files Browse the repository at this point in the history
  • Loading branch information
zepinto committed May 13, 2016
1 parent 787e0b1 commit ff2e171
Show file tree
Hide file tree
Showing 8 changed files with 189 additions and 162 deletions.
2 changes: 1 addition & 1 deletion .classpath
Expand Up @@ -6,10 +6,10 @@
<classpathentry exported="true" kind="lib" path="libs/dom4j-1.6.1.jar"/>
<classpathentry exported="true" kind="lib" path="libs/jaxen-1.1.1.jar"/>
<classpathentry kind="lib" path="libs/libimc.jar"/>
<classpathentry kind="lib" path="androidLibs/maps.jar"/>
<classpathentry kind="con" path="org.eclipse.andmore.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry exported="true" kind="con" path="org.eclipse.andmore.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="org.eclipse.andmore.DEPENDENCIES"/>
<classpathentry kind="lib" path="/home/zp/android-sdk-linux/add-ons/addon-google_apis-google-21/libs/maps.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
2 changes: 1 addition & 1 deletion AndroidManifest.xml
Expand Up @@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pt.lsts.accu"
android:versionCode="10"
android:versionName="1.3.6-3-gcf0193d-dirty (master)" >
android:versionName="1.3.6-4-g787e0b1-dirty (master)" >

<instrumentation
android:name="android.test.InstrumentationTestRunner"
Expand Down
2 changes: 1 addition & 1 deletion src/pt/lsts/accu/AboutPanel.java
Expand Up @@ -24,7 +24,7 @@ public void onStart() {
TextView lab = (TextView) getLayout().findViewWithTag("lab");

title.setText(Html.fromHtml(html));
String versionString = "1.3.6-3-gcf0193d-dirty (master)";
String versionString = "1.3.6-4-g787e0b1-dirty (master)";
String dateString = "13-05-2016";
version.setText("Version: " + versionString + "\n" + "Date: "
+ dateString + "\n" + "IMC version: "
Expand Down
1 change: 0 additions & 1 deletion src/pt/lsts/accu/Main.java
@@ -1,6 +1,5 @@
package pt.lsts.accu;

import java.io.File;
import java.io.FileInputStream;

import com.google.android.maps.MapActivity;
Expand Down
18 changes: 10 additions & 8 deletions src/pt/lsts/accu/adapter/SystemListAdapter.java
Expand Up @@ -105,9 +105,11 @@ public View getView(int position, View convertView, ViewGroup parent)
text += timeSinceLastMessage(System.currentTimeMillis(), v.lastMessageReceived);
if (v.isConnected()==false)
text += "\nConnected: " + v.isConnected();
if (v.isError()==true)
text += "\nError: " + v.isError();

if (v.isError())
text += "\nErrors: "+v.getErrors();
else if (!v.getMode().isEmpty())
text += "\nMode: "+v.getMode();

tvInfo.setText(text);
}else{
tvInfo.setText("");
Expand All @@ -116,14 +118,14 @@ public View getView(int position, View convertView, ViewGroup parent)
GradientDrawable shape = (GradientDrawable) container.getBackground();

//color codes
final String ORANGE = "FF8000";//orange
final String RED = "FF1428";//red
final String ORANGE = "998000";//orange
final String RED = "991428";//red
//final String GREEN = "006400";//green
final String BLUE = "2BB6E3";//cyan
final String BLUE = "0FCCE3";//cyan
//final String BLUE_LIGHTER = "B5C6D8";//very light blue
final String BLUE_DARKER = "15596F";//dark blue
final String BLUE_DARKER = "000C6F";//dark blue
//final String OLD = "253F3F";//gray
final String IDLE = "6E6E6E";//brighter gray
final String IDLE = "333333";//brighter gray
final String BLACK = "#000000";//black
final String WHITE = "#FFFFFF";//white

Expand Down
104 changes: 56 additions & 48 deletions src/pt/lsts/accu/components/StateView.java
@@ -1,5 +1,11 @@
package pt.lsts.accu.components;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.TableLayout;
import android.widget.TextView;
import pt.lsts.accu.R;
import pt.lsts.accu.msg.IMCSubscriber;
import pt.lsts.accu.msg.IMCUtils;
import pt.lsts.accu.state.Accu;
Expand All @@ -9,12 +15,7 @@
import pt.lsts.imc.IMCMessage;
import pt.lsts.imc.Rpm;
import pt.lsts.imc.VehicleState;
import pt.lsts.accu.R;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.TableLayout;
import android.widget.TextView;
import pt.lsts.util.WGS84Utilities;

public class StateView extends TableLayout implements IMCSubscriber {
public static final String[] SUBSCRIBED_MSGS = { "EstimatedState", "Rpm",
Expand All @@ -35,6 +36,52 @@ private void initialize() {
Accu.getInstance().getIMCManager().addSubscriber(this, SUBSCRIBED_MSGS);
}

private void on(EstimatedState msg) {
double[] lld = WGS84Utilities.toLatLonDepth((EstimatedState)msg);

TextView tv = (TextView) findViewWithTag("lat");
tv.setText("" + CoordUtil.degreesToDMS(lld[0], true));

tv = (TextView) findViewWithTag("lon");
tv.setText("" + CoordUtil.degreesToDMS(lld[1], false));

tv = (TextView) findViewWithTag("depth");
tv.setText("" + MUtil.roundn(msg.getDepth(), 2));

tv = (TextView) findViewWithTag("roll");
tv.setText(""
+ MUtil.roundn(Math.toDegrees(msg.getPhi()), 2));

tv = (TextView) findViewWithTag("pitch");
tv.setText(""
+ MUtil.roundn(Math.toDegrees(msg.getTheta()), 2));

tv = (TextView) findViewWithTag("yaw");
tv.setText(""
+ MUtil.roundn(Math.toDegrees(msg.getPsi()), 2));

double vx = msg.getVx();
double vy = msg.getVy();
double vz = msg.getVz();
double speed = Math.sqrt(Math.pow(vx, 2) + Math.pow(vy, 2)
+ Math.pow(vz, 2))
* CoordUtil.msToKnot;
tv = (TextView) findViewWithTag("speed");
tv.setText(MUtil.roundn(speed, 2) + " Knot");
}

private void on(VehicleState msg) {
TextView tv = (TextView) findViewWithTag("error_count");
tv.setText("" + msg.getErrorCount());

tv = (TextView) findViewWithTag("last_error");
tv.setText("" + msg.getLastError()); // FIXME add timestamp
// @ msg field
// "last_error_time"
tv = (TextView) findViewWithTag("op_mode");
tv.setText("" + msg.getOpModeStr());
}

@Override
public void onReceive(IMCMessage msg) {
final int ID_STATIC = msg.getMgid();
Expand All @@ -43,50 +90,11 @@ public void onReceive(IMCMessage msg) {
return;

if (ID_STATIC == EstimatedState.ID_STATIC) {
// Process EstimatedState
double res[] = CoordUtil.getAbsoluteLatLonDepthFromMsg(msg);

TextView tv = (TextView) findViewWithTag("lat");
tv.setText("" + CoordUtil.degreesToDMS(res[0], true));

tv = (TextView) findViewWithTag("lon");
tv.setText("" + CoordUtil.degreesToDMS(res[1], false));

tv = (TextView) findViewWithTag("depth");
tv.setText("" + MUtil.roundn(msg.getDouble("depth"), 2));

tv = (TextView) findViewWithTag("roll");
tv.setText(""
+ MUtil.roundn(Math.toDegrees(msg.getFloat("phi")), 2));

tv = (TextView) findViewWithTag("pitch");
tv.setText(""
+ MUtil.roundn(Math.toDegrees(msg.getFloat("theta")), 2));

tv = (TextView) findViewWithTag("yaw");
tv.setText(""
+ MUtil.roundn(Math.toDegrees(msg.getFloat("psi")), 2));

double vx = msg.getDouble("vx");
double vy = msg.getDouble("vy");
double vz = msg.getDouble("vz");
double speed = Math.sqrt(Math.pow(vx, 2) + Math.pow(vy, 2)
+ Math.pow(vz, 2))
* CoordUtil.msToKnot;
tv = (TextView) findViewWithTag("speed");
tv.setText(MUtil.roundn(speed, 2) + " Knot");
on((EstimatedState)msg);
}
if (ID_STATIC == VehicleState.ID_STATIC) {
TextView tv = (TextView) findViewWithTag("error_count");
tv.setText("" + msg.getInteger("error_count"));

tv = (TextView) findViewWithTag("last_error");
tv.setText("" + msg.getString("last_error")); // FIXME add timestamp
// @ msg field
// "last_error_time"

tv = (TextView) findViewWithTag("op_mode");
tv.setText("" + msg.getString("op_mode"));
on((VehicleState)msg);

}
if (ID_STATIC == Rpm.ID_STATIC) {
int rpm = msg.getInteger("value");
Expand Down

0 comments on commit ff2e171

Please sign in to comment.