Skip to content

Commit

Permalink
Docs #2 function (#17)
Browse files Browse the repository at this point in the history
* Remove: unused functions(ActionController)

* Remove: unused functions(BuildCommandUtility)

* Remve:unused SatelliteActivity

* remove:final

* added: docs for satelliteActivity

* added: docs for satelite packet adapter

* added: docs for satelliteAcivity

* added:docs for MainActivity

* added: raw facts in packets

* added:raw in packets
  • Loading branch information
GoutamVerma authored Sep 3, 2022
1 parent a882a8b commit a80945c
Show file tree
Hide file tree
Showing 14 changed files with 244 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
18 changes: 18 additions & 0 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": 2,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.goutam.TinyGSVisualizationTool",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"versionCode": 1,
"versionName": "1.0",
"outputFile": "app-release.apk"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,10 @@ private void sendMessageError(LGCommand lgCommand, Dialog dialog) {
changeToNewView();
ActionController actionController = ActionController.getInstance();
actionController.exitTour();
ActionController.getInstance().sendBalloonWithLogos(MainActivity.this);
SharedPreferences sharedPreferences = getSharedPreferences(ConstantPrefs.SHARED_PREFS.name(), MODE_PRIVATE);
String rig = sharedPreferences.getString(ConstantPrefs.SHARED_PREFS.LG_RIGS.name(), "");
int rig_no= Integer.parseInt(rig);
ActionController.getInstance().sendBalloonWithLogos(MainActivity.this,rig_no);
loadConnectionStatus(sharedPreferences);

}
Expand Down Expand Up @@ -302,7 +304,10 @@ private void ClearKML() {
boolean isConnected = sharedPreferences.getBoolean(ConstantPrefs.IS_CONNECTED.name(), false);
if (isConnected) {
ActionController actionController = ActionController.getInstance();
actionController.sendcleanballloon(MainActivity.this);
String rig = sharedPreferences.getString(ConstantPrefs.SHARED_PREFS.LG_RIGS.name(), "");
int rig_no= Integer.parseInt(rig);
double rigs = Math.floor( rig_no/ 2) + 1;
actionController.sendcleanballloon(MainActivity.this,(int)rigs);
actionController.exitTour();
}else{
CustomDialogUtility.showDialog(MainActivity.this,"LG is not connected, Please connect first!");
Expand Down Expand Up @@ -458,7 +463,9 @@ private void clean_logo(){
SharedPreferences sharedPreferences = getSharedPreferences(ConstantPrefs.SHARED_PREFS.name(), MODE_PRIVATE);
boolean isConnected = sharedPreferences.getBoolean(ConstantPrefs.IS_CONNECTED.name(), false);
if (isConnected) {
ActionController.getInstance().sendcleanlogo(MainActivity.this);
String rig = sharedPreferences.getString(ConstantPrefs.SHARED_PREFS.LG_RIGS.name(), "");
int rig_no= Integer.parseInt(rig);
ActionController.getInstance().sendcleanlogo(MainActivity.this,rig_no);
}else{
CustomDialogUtility.showDialog(MainActivity.this,"LG is not connected,Please connect first!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
Expand All @@ -19,6 +20,7 @@
import android.widget.Spinner;
import android.widget.TextView;

import androidx.annotation.RequiresApi;
import androidx.core.content.ContextCompat;

import com.Goutam.TinygsDataVisualization.R;
Expand All @@ -36,9 +38,11 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;

Expand All @@ -57,6 +61,7 @@ public class PacketsActivity extends TopBarActivity {

ArrayList<packet_card_model> packetcardmodelArrayList = new ArrayList<packet_card_model>();

@RequiresApi(api = Build.VERSION_CODES.O)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -96,6 +101,7 @@ private void activity_handler(){


grid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
loadContent(i,view);
Expand All @@ -113,11 +119,24 @@ public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
* @param view
* This function is in charge of load content on layout activity_packets_info
*/
public void loadContent(int i,View view){
@RequiresApi(api = Build.VERSION_CODES.O)
public void loadContent(int i, View view){
setContentView(R.layout.activity_packets_info);
HashMap<Integer,List<String>> packet = getHashMap("1");
TextView name = findViewById(R.id.packet_name);
TextView data = findViewById(R.id.packet_description);
TextView raw = findViewById(R.id.hexa_description);
String guid = packet.get(i).get(13);
byte[] decoded = Base64.getDecoder().decode(guid);
String datas = String.format("%040x", new BigInteger(1, decoded));
String finl ="";
for(int j=0;j<datas.length();j++){
finl+= datas.charAt(j);
if(j%2!=0){
finl+=" ";
}
}
raw.setText(finl.toUpperCase());
name.setText(packet.get(i).get(5));
String description = "Received on:\n" +
"LoRa "+ packet.get(i).get(1)+" Mhz SF: "+packet.get(i).get(2)+" CR: "+packet.get(i).get(4)+" BW: "+packet.get(i).get(3)+" kHz\n" +
Expand All @@ -139,7 +158,8 @@ public void loadContent(int i,View view){
String lon[]= pos[0].split(":");
String alti[]= pos[1].split(":");
String lat[]= pos[2].split(":");
buttTest.setOnClickListener(view2 -> sendOrbit(view, lon[1], lat[1].substring(0, lat[1].length() - 1), alti[1], description, packet.get(i).get(5)));
String finalFinl = finl;
buttTest.setOnClickListener(view2 -> sendOrbit(view, finalFinl.toUpperCase() ,lon[1], lat[1].substring(0, lat[1].length() - 1), alti[1], description, packet.get(i).get(5)));
buttStop.setOnClickListener(view2 -> stopTestStoryBoard());
}
private void stopTestStoryBoard() {
Expand Down Expand Up @@ -200,6 +220,7 @@ public void run() {
boolean mainvolt = pay.get("tinygsMainVoltage") == null ? data.add("null") : data.add(pay.get("tinygsMainVoltage").toString());
boolean sat = obj1.get("satPos") == null ? data.add("null") : data.add(obj1.get("satPos").toString());
boolean number = obj1.get("stationNumber") == null ? data.add("null") : data.add(obj1.get("stationNumber").toString());
boolean raw = obj1.get("raw") == null? data.add("null"): data.add(obj1.get("raw").toString());
packets.put(i, data);
System.out.println(i + " " + data);
}
Expand Down Expand Up @@ -245,6 +266,7 @@ public void run() {
packet_adapter adapter = new packet_adapter(PacketsActivity.this, packetcardmodelArrayList);
grid.setAdapter(adapter);
grid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
loadContent(i,view);
Expand Down Expand Up @@ -292,12 +314,14 @@ public HashMap<Integer,List<String>> getHashMap(String key) {
* @param name Name of satellite
* @return
*/
public void sendOrbit(View view, String longi, String lat, String alti, String des, String name) {
public void sendOrbit(View view, String raw ,String longi, String lat, String alti, String des, String name) {
Button test = findViewById(R.id.test);
SharedPreferences sharedPreferences = getSharedPreferences(ConstantPrefs.SHARED_PREFS.name(), MODE_PRIVATE);
boolean isConnected = sharedPreferences.getBoolean(ConstantPrefs.IS_CONNECTED.name(), false);
if (isConnected) {
ActionController.getInstance().sendBalloon(this, des);
String rig = sharedPreferences.getString(ConstantPrefs.SHARED_PREFS.LG_RIGS.name(), "");
int rig_no= Integer.parseInt(rig);
ActionController.getInstance().sendBalloonRaw(this, des, raw,rig_no);
ActionController.getInstance().sendOribitfile(PacketsActivity.this, longi, lat, alti,des,name);
test.setVisibility(view.INVISIBLE);
buttStop.setVisibility(view.VISIBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,6 @@ private void loadConnectionStatus(SharedPreferences sharedPreferences) {
}
}


private satellite_packet_adapter get_data_satellite(String name){
satellite_packet_adapter adapter= new satellite_packet_adapter(this,satellitepacketcardmodelArrayList);
HashMap<Integer,List<String>> sat_packet = new HashMap<Integer, List<String>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public View getView(int position, @Nullable View convertView, @NonNull ViewGroup
JSONObject json = null;
try {
json = new JSONObject(locatios);
System.out.println(json.toString());
String lng = json.getString("lng");
String lat = json.getString("lat");
String Description = "Name : "+ packetcardmodel.getPacket_name()+" Sats :"+packetcardmodel.get_location()+ "Data :"+packetcardmodel.get_satelite_data();
Expand Down Expand Up @@ -104,13 +103,16 @@ private void stopTestStoryBoard(Button buttTest,Button buttStop) {
*/
public void sendOrbit(AppCompatActivity activity, String longi, String lat, String alti, String des, String name, Button orbit, Button stop,SharedPreferences sharedPreferences) {
boolean isConnected = sharedPreferences.getBoolean(ConstantPrefs.IS_CONNECTED.name(), false);

if (isConnected) {
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("statesate",longi);
editor.apply();
orbit.setVisibility(View.INVISIBLE);
stop.setVisibility(View.VISIBLE);
ActionController.getInstance().sendBalloon(activity,des);
String rig = sharedPreferences.getString(ConstantPrefs.SHARED_PREFS.LG_RIGS.name(), "");
int rig_no= Integer.parseInt(rig);
ActionController.getInstance().sendBalloon(activity,des,rig_no);
ActionController.getInstance().sendOribitfile(activity, longi, lat, alti,des,name);
} else {
CustomDialogUtility.showDialog(activity, "LG is not connected, Please visit connect tab.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,11 @@ public void run() {
});

}

/**
/**
* @param key over which data is stored
* @param obj Hashmap store in the form of object
*/

public void saveHashMap(String key , Object obj) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(StationActivity.this);
SharedPreferences.Editor editor = prefs.edit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ public void sendOrbit(AppCompatActivity activity, String longi, String lat, Stri
editor.apply();
orbit.setVisibility(View.INVISIBLE);
stop.setVisibility(View.VISIBLE);
ActionController.getInstance().sendBalloon(activity,des);
String rig = sharedPreferences.getString(ConstantPrefs.SHARED_PREFS.LG_RIGS.name(), "");
int rig_no= Integer.parseInt(rig);
ActionController.getInstance().sendBalloon(activity,des,rig_no);
ActionController.getInstance().sendOribitStation(activity, longi, lat, alti, des, name);
} else {
CustomDialogUtility.showDialog(activity, "LG is not connected, Please visit connect tab.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,22 +527,22 @@ private static String POICommandStation(String lon,String lat,String alti) {
return command;
}

public static String clean_logo(){
public static String clean_logo(int rig){
String clean_logo= "echo '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<kml xmlns=\"http://www.opengis.net/kml/2.2\" xmlns:gx=\"http://www.google.com/kml/ext/2.2\" xmlns:kml=\"http://www.opengis.net/kml/2.2\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n" +
" <Document id=\"1\">\n" +
" </Document>\n" +
"</kml>' > /var/www/html/kml/slave_4.kml";
"</kml>' > /var/www/html/kml/slave_"+rig+".kml";
Log.d("TAG_DEBUG",clean_logo);
return clean_logo;
}

public static String clean_balloon(){
public static String clean_balloon(int rig){
String command = "echo '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<kml xmlns=\"http://www.opengis.net/kml/2.2\" xmlns:gx=\"http://www.google.com/kml/ext/2.2\" xmlns:kml=\"http://www.opengis.net/kml/2.2\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n" +
" <Document id=\"1\">\n" +
" </Document>\n" +
"</kml>' > /var/www/html/kml/slave_3.kml";
"</kml>' > /var/www/html/kml/slave_"+rig+".kml";
Log.d("TAG_DEBUG",command);
return command;
}
Expand Down Expand Up @@ -583,7 +583,7 @@ public static String buildCommandReLaunch(String username,String password,Intege
* Build the command to paint a balloon in Liquid Galaxy
* @return String with command
*/
public static String buildCommandBalloonWithLogos() {
public static String buildCommandBalloonWithLogos(int rig) {

String startCommand = "echo '" +
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
Expand Down Expand Up @@ -615,7 +615,7 @@ public static String buildCommandBalloonWithLogos() {
"</Document>\n" +
"</kml>\n"+
"' > " +
"/var/www/html/kml/slave_4.kml";
"/var/www/html/kml/slave_"+rig+".kml";
Log.w(TAG_DEBUG, "Command: " + startCommand);
return startCommand;
}
Expand Down Expand Up @@ -674,7 +674,7 @@ public static String buildCommandCleanSlaves() {
return command;
}

public static String buildCommandBalloon(String des) {
public static String buildCommandBalloon(String des,int rig) {
String startCommand = "echo '" +
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<kml xmlns=\"http://www.opengis.net/kml/2.2\" xmlns:gx=\"http://www.google.com/kml/ext/2.2\" xmlns:kml=\"http://www.opengis.net/kml/2.2\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n" +
Expand Down Expand Up @@ -741,7 +741,92 @@ public static String buildCommandBalloon(String des) {
"</Document>\n" +
"</kml> "+
"' > " +
"/var/www/html/kml/slave_3.kml";
"/var/www/html/kml/slave_"+rig+".kml";
Log.d("TAG DEBUG",startCommand);
return startCommand;
}

public static String buildCommandBalloonRaw(String des,String raw,int rig) {
String startCommand = "echo '" +
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<kml xmlns=\"http://www.opengis.net/kml/2.2\" xmlns:gx=\"http://www.google.com/kml/ext/2.2\" xmlns:kml=\"http://www.opengis.net/kml/2.2\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n" +
"<Document>\n" +
" <name>historic.kml</name>\n" +
" <Style id=\"purple_paddle\">\n" +
" <BalloonStyle>\n" +
" <text>$[description]</text>\n" +
" <bgColor>ff1e1e1e</bgColor>\n" +
" </BalloonStyle>\n" +
" </Style>\n" +
" <Placemark id=\"0A7ACC68BF23CB81B354\">\n" +
" <name>TinyGS Data Visualization</name>\n" +
" <Snippet maxLines=\"0\"></Snippet>\n" +
" <description><![CDATA[<!-- BalloonStyle background color:\n" +
"ffffffff\n" +
"-->\n" +
"<!-- Icon URL:\n" +
"http://maps.google.com/mapfiles/kml/paddle/purple-blank.png\n" +
"-->\n" +
"<table width=\"400\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n" +
" <tr>\n" +
" <td colspan=\"2\" align=\"center\">\n" +
" <img src=\"https://raw.githubusercontent.com/GoutamVerma/TinyGS-data-visualization-for-Liquid-Galaxy-GSoC-2022/main/app/src/main/res/drawable-xxxhdpi/applogo.png\" alt=\"picture\" width=\"150\" height=\"150\" />\n" +
" </td>\n" +
" </tr>\n" +
" <tr>\n" +
" <td colspan=\"2\" align=\"center\">\n" +
" <h2><font color='#00CC99'>TinyGS Data Visualization Tool</font></h2>\n" +
" </td>\n" +
" </tr>\n" +
" <tr>\n" +
" <td colspan=\"2\">\n" +
" <p><font color=\"#FFFFFF\">Description: \n" +
des+
"</font></p>\n" +
" </td>\n" +
" </tr>\n" +

" <tr>\n" +
" <td colspan=\"2\" align=\"center\">\n" +
" <h3><font color='#00CC99'>Hexadecimal view</font></h3>\n" +
" </td>\n" +
" </tr>\n" +

" <tr>\n" +
" <td colspan=\"2\" align=\"center\">\n" +
" <font color=\"#FFFFFF\">"+raw+"</font>\n" +
" </td>\n" +
" </tr>\n" +

" <tr>\n" +
" <td align=\"center\">\n" +
" <a href=\"#\"> </a>\n" +
" </td>\n" +
" </tr>\n" +
" <tr>\n" +
" <td colspan=\"2\" align=\"center\">\n" +
" <font color=\"#FFFFFF\">TinyGS Data Visualization Tool 2022</font>\n" +
" </td>\n" +
" </tr>\n" +
"</table>]]></description>\n" +
" <LookAt>\n" +
" <longitude>-17.841486</longitude>\n" +
" <latitude>28.638478</latitude>\n" +
" <altitude>0</altitude>\n" +
" <heading>0</heading>\n" +
" <tilt>0</tilt>\n" +
" <range>24000</range>\n" +
" </LookAt>\n" +
" <styleUrl>#purple_paddle</styleUrl>\n" +
" <gx:balloonVisibility>1</gx:balloonVisibility>\n" +
" <Point>\n" +
" <coordinates>-17.841486,28.638478,0</coordinates>\n" +
" </Point>\n" +
" </Placemark>\n" +
"</Document>\n" +
"</kml> "+
"' > " +
"/var/www/html/kml/slave_"+rig+".kml";
Log.d("TAG DEBUG",startCommand);
return startCommand;
}
Expand Down
Loading

0 comments on commit a80945c

Please sign in to comment.