Android Open Source - final_project_android Coordinator






From Project

Back to project page final_project_android.

License

The source code is released under:

MIT License

If you think the Android project final_project_android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.geminnu.hexagon;
//w  ww  . j  a  v a2 s . co  m
import java.io.IOException;

import org.xmlpull.v1.XmlPullParserException;

public class Coordinator {
  
  private int mParsingMethod;
  private String mData;
  private ArduinoMessage am;
  private ArduinoParser ap;
  private final int SENSORDATA = 0;
  private final int STATUSDATA = 1;
  
  
  public Coordinator(int parsingMethod, String data) {
    this.mParsingMethod = parsingMethod;
    this.mData = data;
  }
  
  public int decision() {
    if(mParsingMethod == ArduinoService.XML) {
      ap = new ArduinoParser(mData);
      try {
        am = ap.ReadDataXML();
      } catch (XmlPullParserException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      if(am.getMsgType() == SENSORDATA){
        return ArduinoService.SENSOR;
      } else if(am.getMsgType() == STATUSDATA) {
        return ArduinoService.STATUS; 
      }
    } else if(mParsingMethod == ArduinoService.JSON) {
      ap = new ArduinoParser(mData);
    
      am = ap.ReadDataJSON();
    
      if(am.getMsgType() == SENSORDATA){
        return ArduinoService.SENSOR;
      } else if(am.getMsgType() == STATUSDATA) {
        return ArduinoService.STATUS; 
      }
    }
    return -1;
  }
  
  public ArduinoMessage getArduinoMessage() {
    return am;
  }
}




Java Source Code List

com.geminnu.hexagon.Alert.java
com.geminnu.hexagon.ArduinoMessage.java
com.geminnu.hexagon.ArduinoParser.java
com.geminnu.hexagon.ArduinoReceiver.java
com.geminnu.hexagon.ArduinoService.java
com.geminnu.hexagon.ArduinoStatusEventListener.java
com.geminnu.hexagon.ArduinoStatusEvent.java
com.geminnu.hexagon.ArduinoStatusManager.java
com.geminnu.hexagon.ArduinoStatus.java
com.geminnu.hexagon.ArduinoTask.java
com.geminnu.hexagon.ArduinoTransmitter.java
com.geminnu.hexagon.BioSensorEventListener.java
com.geminnu.hexagon.BioSensorEvent.java
com.geminnu.hexagon.BioSensorListenerItem.java
com.geminnu.hexagon.BioSensorManagerService.java
com.geminnu.hexagon.BioSensor.java
com.geminnu.hexagon.Bluetooth.java
com.geminnu.hexagon.CoordinatorActionListener.java
com.geminnu.hexagon.Coordinator.java
com.geminnu.hexagon.MainActivity.java
com.geminnu.hexagon.MessageListener.java
com.geminnu.hexagon.MessageSender.java
com.geminnu.hexagon.MySQLiteHelper.java
com.geminnu.hexagon.Profile.java
com.geminnu.hexagon.Reading.java
com.geminnu.hexagon.Wifi.java