Commit b91373b5 authored by Christopher Reis's avatar Christopher Reis

Made TrackerList global static like satelliteDB

parent 8839b482
...@@ -38,7 +38,7 @@ public class Application { ...@@ -38,7 +38,7 @@ public class Application {
private JFrame frmSatelliteTracker; private JFrame frmSatelliteTracker;
private final Action action = new SwingAction(); private final Action action = new SwingAction();
TrackerThread tracker = new TrackerThread(); TrackerList trackList = new TrackerList();
SatelliteDB satellites = new SatelliteDB("SatelliteDB"); SatelliteDB satellites = new SatelliteDB("SatelliteDB");
/** /**
......
...@@ -53,7 +53,7 @@ public class satelliteStatus extends JInternalFrame { ...@@ -53,7 +53,7 @@ public class satelliteStatus extends JInternalFrame {
btnStartTracking.addMouseListener(new MouseAdapter() { btnStartTracking.addMouseListener(new MouseAdapter() {
@Override @Override
public void mousePressed(MouseEvent arg0) { public void mousePressed(MouseEvent arg0) {
TrackerThread.startTrack(curSat.getTLE().getName(), "Albuquerque"); TrackerList.startTrack(curSat.getTLE().getName(), "Albuquerque");
//thread.setSatellite(curSat); //thread.setSatellite(curSat);
//(new Thread(new thread())).start(); //(new Thread(new thread())).start();
} }
...@@ -66,7 +66,7 @@ public class satelliteStatus extends JInternalFrame { ...@@ -66,7 +66,7 @@ public class satelliteStatus extends JInternalFrame {
btnStopTracking.addMouseListener(new MouseAdapter() { btnStopTracking.addMouseListener(new MouseAdapter() {
@Override @Override
public void mousePressed(MouseEvent arg0) { public void mousePressed(MouseEvent arg0) {
tracker.stopTrack(curSat.getTLE().getName()); TrackerList.stopTrack(curSat.getTLE().getName());
//thread.setSatellite(curSat); //thread.setSatellite(curSat);
//(new Thread(new thread())).start(); //(new Thread(new thread())).start();
} }
......
...@@ -160,6 +160,15 @@ public class SatelliteTrack { ...@@ -160,6 +160,15 @@ public class SatelliteTrack {
tripleOrbit = getTripleOrbit(this.satellite); tripleOrbit = getTripleOrbit(this.satellite);
} }
public satPosition getPosition(){
satellite.calculateSatelliteVectors(new Date());
satPosition pos = new satPosition(satellite.calculateSatelliteGroundTrack().getLatitude(),
satellite.calculateSatelliteGroundTrack().getLongitude(),
satellite.calculateSatelliteGroundTrack().getAltitude(),
satellite.calculateSatelliteGroundTrack().getTime());
return pos;
}
public List<SatPassTime> get24hrPasses(GroundStationPosition gpos) { public List<SatPassTime> get24hrPasses(GroundStationPosition gpos) {
updateSatPassPredictor(gpos); updateSatPassPredictor(gpos);
......
...@@ -3,13 +3,10 @@ package satellite; ...@@ -3,13 +3,10 @@ package satellite;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class TrackerThread{ public class TrackerList {
//trackerThread.setSatellite(curSat);
//(new Thread(new trackerThread())).start();
private static List<tracker> threadList = new ArrayList<tracker>(); private static List<tracker> threadList = new ArrayList<tracker>();
public static void startTrack(String sat, String gs){ public static void startTrack(String sat, String gs){
int satNum = SatelliteDB.getSatIndex(sat); int satNum = SatelliteDB.getSatIndex(sat);
SatelliteTrack satellite = SatelliteDB.sat(satNum); SatelliteTrack satellite = SatelliteDB.sat(satNum);
...@@ -17,7 +14,7 @@ public class TrackerThread{ ...@@ -17,7 +14,7 @@ public class TrackerThread{
threadList.get(threadList.size()-1).start(); threadList.get(threadList.size()-1).start();
} }
public void stopTrack(String sat){ public static void stopTrack(String sat){
for(int i = 0;i<threadList.size();i++){ for(int i = 0;i<threadList.size();i++){
if(threadList.get(i).name.equals(sat)){ if(threadList.get(i).name.equals(sat)){
threadList.get(i).stop(); threadList.get(i).stop();
...@@ -25,35 +22,18 @@ public class TrackerThread{ ...@@ -25,35 +22,18 @@ public class TrackerThread{
} }
} }
private void searchThread(String sat){ public static satPosition getSatPos(String sat){
for(int i = 0;i<threadList.size();i++){ int satNum = searchThread(sat);
if(sat.trim().equals(threadList.get(i).name)){ return threadList.get(satNum).sat.getPosition();
//threadList.get(i).stopTrack(sat);;
} }
}
}
private class tracker extends Thread{
public tracker(SatelliteTrack satellite){ private static int searchThread(String sat){
sat = satellite; for(int i = 0;i<threadList.size();i++){
name = satellite.getTLE().getName(); if(sat.trim().equals(threadList.get(i).name)){
} return i;
public String name;
SatelliteTrack sat;
int seconds = 0;
public void run(){
while(true){
System.out.println("Tracking " + sat.getTLE().getName() + " for: "+ seconds +" seconds");
seconds++;
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
} }
} }
return -1;
} }
} }
package satellite;
public class tracker extends Thread{
public tracker(SatelliteTrack satellite){
sat = satellite;
name = satellite.getTLE().getName();
}
public String name;
public SatelliteTrack sat;
int seconds = 0;
public void run(){
while(true){
System.out.println("Tracking " + sat.getTLE().getName() + " for: "+ seconds +" seconds");
System.out.println(sat.getPosition().getLat() + " " + sat.getPosition().getLon());
seconds++;
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment