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 {
private JFrame frmSatelliteTracker;
private final Action action = new SwingAction();
TrackerThread tracker = new TrackerThread();
TrackerList trackList = new TrackerList();
SatelliteDB satellites = new SatelliteDB("SatelliteDB");
/**
......
......@@ -53,7 +53,7 @@ public class satelliteStatus extends JInternalFrame {
btnStartTracking.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent arg0) {
TrackerThread.startTrack(curSat.getTLE().getName(), "Albuquerque");
TrackerList.startTrack(curSat.getTLE().getName(), "Albuquerque");
//thread.setSatellite(curSat);
//(new Thread(new thread())).start();
}
......@@ -66,7 +66,7 @@ public class satelliteStatus extends JInternalFrame {
btnStopTracking.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent arg0) {
tracker.stopTrack(curSat.getTLE().getName());
TrackerList.stopTrack(curSat.getTLE().getName());
//thread.setSatellite(curSat);
//(new Thread(new thread())).start();
}
......
......@@ -160,6 +160,15 @@ public class SatelliteTrack {
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) {
updateSatPassPredictor(gpos);
......
......@@ -3,13 +3,10 @@ package satellite;
import java.util.ArrayList;
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>();
public static void startTrack(String sat, String gs){
int satNum = SatelliteDB.getSatIndex(sat);
SatelliteTrack satellite = SatelliteDB.sat(satNum);
......@@ -17,7 +14,7 @@ public class TrackerThread{
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++){
if(threadList.get(i).name.equals(sat)){
threadList.get(i).stop();
......@@ -25,35 +22,18 @@ public class TrackerThread{
}
}
private void searchThread(String sat){
for(int i = 0;i<threadList.size();i++){
if(sat.trim().equals(threadList.get(i).name)){
//threadList.get(i).stopTrack(sat);;
public static satPosition getSatPos(String sat){
int satNum = searchThread(sat);
return threadList.get(satNum).sat.getPosition();
}
}
}
private class tracker extends Thread{
public tracker(SatelliteTrack satellite){
sat = satellite;
name = satellite.getTLE().getName();
}
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();
}
private static int searchThread(String sat){
for(int i = 0;i<threadList.size();i++){
if(sat.trim().equals(threadList.get(i).name)){
return i;
}
}
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