diff --git a/ApplicationAmicalsat/src/main/java/org/josast/ApplicationAmicalsat/App.java b/ApplicationAmicalsat/src/main/java/org/josast/ApplicationAmicalsat/App.java index 4c17a16f51fdbfe9d99fe28390232780459bc907..5ea4d08c951a6cacc0e5b54fe1b4f15ee9748bd6 100644 --- a/ApplicationAmicalsat/src/main/java/org/josast/ApplicationAmicalsat/App.java +++ b/ApplicationAmicalsat/src/main/java/org/josast/ApplicationAmicalsat/App.java @@ -17,7 +17,7 @@ public class App extends Application { private static Scene scene; private static FXMLLoader fxmlLoader; private static Logger logger = Logger.getLogger("AmsatLogger"); - private static final String fxmlFile = "Amicalsat"; + private static final String fxmlFile = "Amicalsat"; @Override public void start(Stage stage) throws IOException { diff --git a/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/AmsatToUvsqsatSyncConfig.java b/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/AmsatToUvsqsatSyncConfig.java index 3d057d5e35b02487d09835131d5b6984413cb0d7..9cfd701cbb0202a82845983fd4dd3f2e9b25b98a 100644 --- a/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/AmsatToUvsqsatSyncConfig.java +++ b/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/AmsatToUvsqsatSyncConfig.java @@ -1,111 +1,87 @@ - package org.josast.databaseSync; public class AmsatToUvsqsatSyncConfig { - - public String login; - public String password; - public String sftpUrl; - public String amsatDatabaseUrl; - public String sshUrl; - public String deltaTime; - public String satelliteNasaId; - /** - * @return the login - */ - public String getLogin() { - return login; - } - /** - * @param login the login to set - */ - public void setLogin(String login) { - this.login = login; - } - /** - * @return the password - */ - public String getPassword() { - return password; - } - /** - * @param password the password to set - */ - public void setPassword(String password) { - this.password = password; - } - /** - * @return the sftpUrl - */ - public String getSftpUrl() { - return sftpUrl; - } - /** - * @param sftpUrl the sftpUrl to set - */ - public void setSftpUrl(String sftpUrl) { - this.sftpUrl = sftpUrl; - } - /** - * @return the amsatDatabaseUrl - */ - public String getAmsatDatabaseUrl() { - return amsatDatabaseUrl; - } - /** - * @param amsatDatabaseUrl the amsatDatabaseUrl to set - */ - public void setAmsatDatabaseUrl(String amsatDatabaseUrl) { - this.amsatDatabaseUrl = amsatDatabaseUrl; - } - /** - * @return the sshUrl - */ - public String getSshUrl() { - return sshUrl; - } - /** - * @param sshUrl the sshUrl to set - */ - public void setSshUrl(String sshUrl) { - this.sshUrl = sshUrl; - } - /** - * @return the deltaTime - */ - public String getDeltaTime() { - return deltaTime; - } - /** - * @param deltaTime the deltaTime to set - */ - public void setDeltaTime(String deltaTime) { - this.deltaTime = deltaTime; - } - /** - * @return the satelliteNasaId - */ - public String getSatelliteNasaId() { - return satelliteNasaId; - } - /** - * @param satelliteNasaId the satelliteNasaId to set - */ - public void setSatelliteNasaId(String satelliteNasaId) { - this.satelliteNasaId = satelliteNasaId; - } - - - @Override - public String toString() { - return "AmsatToUvsqsatSyncConfig [login=" + login + ", password=" + password + ", sftpUrl=" + sftpUrl - + ", amsatDatabaseUrl=" + amsatDatabaseUrl + ", sshUrl=" + sshUrl + ", deltaTime=" + deltaTime - + ", satelliteNasaId=" + satelliteNasaId + "]"; - } - - - - + public String login; + public String password; + public String sftpUrl; + public String amsatDatabaseUrl; + public String sshUrl; + public String deltaTime; + public String satelliteNasaId; + /** @return the login */ + public String getLogin() { + return login; + } + /** @param login the login to set */ + public void setLogin(String login) { + this.login = login; + } + /** @return the password */ + public String getPassword() { + return password; + } + /** @param password the password to set */ + public void setPassword(String password) { + this.password = password; + } + /** @return the sftpUrl */ + public String getSftpUrl() { + return sftpUrl; + } + /** @param sftpUrl the sftpUrl to set */ + public void setSftpUrl(String sftpUrl) { + this.sftpUrl = sftpUrl; + } + /** @return the amsatDatabaseUrl */ + public String getAmsatDatabaseUrl() { + return amsatDatabaseUrl; + } + /** @param amsatDatabaseUrl the amsatDatabaseUrl to set */ + public void setAmsatDatabaseUrl(String amsatDatabaseUrl) { + this.amsatDatabaseUrl = amsatDatabaseUrl; + } + /** @return the sshUrl */ + public String getSshUrl() { + return sshUrl; + } + /** @param sshUrl the sshUrl to set */ + public void setSshUrl(String sshUrl) { + this.sshUrl = sshUrl; + } + /** @return the deltaTime */ + public String getDeltaTime() { + return deltaTime; + } + /** @param deltaTime the deltaTime to set */ + public void setDeltaTime(String deltaTime) { + this.deltaTime = deltaTime; + } + /** @return the satelliteNasaId */ + public String getSatelliteNasaId() { + return satelliteNasaId; + } + /** @param satelliteNasaId the satelliteNasaId to set */ + public void setSatelliteNasaId(String satelliteNasaId) { + this.satelliteNasaId = satelliteNasaId; + } + @Override + public String toString() { + return "AmsatToUvsqsatSyncConfig [login=" + + login + + ", password=" + + password + + ", sftpUrl=" + + sftpUrl + + ", amsatDatabaseUrl=" + + amsatDatabaseUrl + + ", sshUrl=" + + sshUrl + + ", deltaTime=" + + deltaTime + + ", satelliteNasaId=" + + satelliteNasaId + + "]"; + } } diff --git a/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/AppSynchroAmsatToUvsqsat.java b/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/AppSynchroAmsatToUvsqsat.java index 6780bc04491a5f60279b27dace630dbf847b2f6b..cc2081bd1f9c7fa4b34a27625e48a03b73451358 100644 --- a/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/AppSynchroAmsatToUvsqsat.java +++ b/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/AppSynchroAmsatToUvsqsat.java @@ -15,132 +15,155 @@ import org.json.JSONObject; public class AppSynchroAmsatToUvsqsat { - private static Logger appLogger = Logger.getLogger("AmsatLogger"); - - private static long MN = 1000 * 60; - - private Path filepath; - private String RepositoryPath = "config"; - private AmsatToUvsqsatSyncConfig config = new AmsatToUvsqsatSyncConfig(); - private String fileIn = null; - SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss.SSS"); - - public void execute() { - - formater.setTimeZone(TimeZone.getTimeZone("UTC")); - // lecture de la configuration - - ManageJSonConfigFile mjcf = new ManageJSonConfigFile(); - config = (AmsatToUvsqsatSyncConfig) mjcf - .readJson(new AmsatToUvsqsatSyncConfig()); - - // Récupération des données - - GetDataFromAmsatDatabase dataAmsatDb = new GetDataFromAmsatDatabase( - config.getAmsatDatabaseUrl()); - - Date endDate = new Date(); - - long temp = endDate.getTime() - - MN * Integer.parseInt(config.getDeltaTime()); - Date startDate = new Date(temp); - DataToExchange[] results = dataAmsatDb.getTelemetrydata(startDate, - endDate, Integer.parseInt(config.getSatelliteNasaId())); - DataToExchange[] results2 = dataAmsatDb.getTelemetrydata(startDate, - endDate, 47438); - // et écriture dans un fichier - DataToUVSQsatControlCenter dtc = null; - String creationdate = formater.format(startDate); - fileIn = creationdate + "-Data.json"; - - if (results != null) { - // file format 2020-12-21-17-42-19.409-Data.json - - - dtc = new DataToUVSQsatControlCenter(results, fileIn); - dtc.save(); - - } - - if (results2 != null) { - if (dtc == null) { - dtc = new DataToUVSQsatControlCenter(results2, fileIn); - dtc.save(); - } else { - dtc.append(results2, fileIn); - } - } - if (dtc != null) { - - // Envoie du fichier vers Latmos - SendSftp sfp = new SendSftp(config.getSftpUrl(), config.getLogin(), - config.getPassword()); - - String remotefile = "/toLATMOS/json/" + fileIn; - String localfile = fileIn; - sfp.upload(localfile, remotefile); - System.out.println("Upload"); - // efface fichier local. - - try { - Files.delete(Paths.get(fileIn)); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - System.exit(0); - } - } + private static Logger appLogger = Logger.getLogger("AmsatLogger"); + + private static long MN = 1000 * 60; + + private Path filepath; + private String RepositoryPath = "config"; + private AmsatToUvsqsatSyncConfig config = new AmsatToUvsqsatSyncConfig(); + private String fileIn = null; + SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss.SSS"); + + public void execute() { + + formater.setTimeZone(TimeZone.getTimeZone("UTC")); + // lecture de la configuration + + ManageJSonConfigFile mjcf = new ManageJSonConfigFile(); + config = (AmsatToUvsqsatSyncConfig) mjcf.readJson(new AmsatToUvsqsatSyncConfig()); + + // Récupération des données + + GetDataFromAmsatDatabase dataAmsatDb = + new GetDataFromAmsatDatabase(config.getAmsatDatabaseUrl()); + + Date endDate = new Date(); + + long temp = endDate.getTime() - MN * Integer.parseInt(config.getDeltaTime()); + + Date startDate = new Date(temp); + DataToExchange[] results = + dataAmsatDb.getTelemetrydata( + startDate, endDate, Integer.parseInt(config.getSatelliteNasaId())); + + DataToExchange[] results2 = dataAmsatDb.getTelemetrydata(startDate, endDate, 47438); - public int SaveConfigFile(AmsatToUvsqsatSyncConfig tlmData) { + DataToExchange[] results3 = dataAmsatDb.getTelemetrydata(startDate, endDate, 99245); + // et écriture dans un fichier + DataToExchange[] results4 = dataAmsatDb.getTelemetrydata(startDate, endDate, 56211); - int erreur = 0; + DataToUVSQsatControlCenter dtc = null; + String creationdate = formater.format(startDate); + fileIn = creationdate + "-Data.json"; - JSONObject jasonObject = new JSONObject(tlmData); + if (results != null) { + // file format 2020-12-21-17-42-19.409-Data.json + System.out.println("R1 : " + results.length); + dtc = new DataToUVSQsatControlCenter(results, fileIn); + dtc.save(); + } + + if (results2 != null) { + System.out.println("R2 : " + results2.length); + if (dtc == null) { + dtc = new DataToUVSQsatControlCenter(results2, fileIn); + dtc.save(); + } else { + dtc.append(results2, fileIn); + } + } -// AmsatToUvsqsatSyncConfig jasonObject2 = (AmsatToUvsqsatSyncConfig) toBean(jasonObject, new AmsatToUvsqsatSyncConfig()); + if (results3 != null) { + System.out.println("R3 : " + results3.length); + if (dtc == null) { + dtc = new DataToUVSQsatControlCenter(results3, fileIn); + dtc.save(); + } else { + dtc.append(results3, fileIn); + } + } + + if (results4 != null) { + System.out.println("R4 : " + results4.length); + if (dtc == null) { + dtc = new DataToUVSQsatControlCenter(results4, fileIn); + dtc.save(); + } else { + dtc.append(results4, fileIn); + } + } - filepath = Paths.get(this.RepositoryPath + "\\Data.json"); + if (dtc != null) { - try { - if (!Files.exists(filepath)) { - Files.createFile(filepath); - Files.writeString(filepath, " " + "\r\n", - StandardOpenOption.CREATE); - } + // Envoie du fichier vers Latmos + SendSftp sfp = new SendSftp(config.getSftpUrl(), config.getLogin(), config.getPassword()); - Files.writeString(filepath, jasonObject.toString() + "\r\n", - StandardOpenOption.CREATE); - if (Files.size(filepath) < 10) { - appLogger.severe("file not created "); - erreur = -1; - } + String remotefile = "/toLATMOS/json/" + fileIn; + String localfile = fileIn; + sfp.upload(localfile, remotefile); + System.out.println("Upload"); + // efface fichier local. - } catch (IOException e) { - appLogger.severe(e.toString()); - erreur = -1; - } + try { + Files.delete(Paths.get(fileIn)); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } - return erreur; + System.exit(0); } + System.out.println("fin traitement"); + } + + public int SaveConfigFile(AmsatToUvsqsatSyncConfig tlmData) { + + int erreur = 0; + + JSONObject jasonObject = new JSONObject(tlmData); + + // AmsatToUvsqsatSyncConfig jasonObject2 = (AmsatToUvsqsatSyncConfig) toBean(jasonObject, new + // AmsatToUvsqsatSyncConfig()); + + filepath = Paths.get(this.RepositoryPath + "\\Data.json"); + + try { + if (!Files.exists(filepath)) { + Files.createFile(filepath); + Files.writeString(filepath, " " + "\r\n", StandardOpenOption.CREATE); + } - public static void main(String[] args) { - - AppSynchroAmsatToUvsqsat app = new AppSynchroAmsatToUvsqsat(); - app.execute(); -// app.initDirectory(); -// AmsatToUvsqsatSyncConfig config = new AmsatToUvsqsatSyncConfig(); -// config.setAmsatDatabaseUrl("AMSATDataBase"); -// config.setDeltaTimeLong(10); -// config.setDeltaTime("10"); -// config.setLogin("login"); -// config.setPassword("password"); -// config.setSftpUrl("URL SFTP"); -// config.setSshUrl("SSH file"); -//// -// app.readJson( ); -// app.saveTlmData(config); + Files.writeString(filepath, jasonObject.toString() + "\r\n", StandardOpenOption.CREATE); + if (Files.size(filepath) < 10) { + appLogger.severe("file not created "); + erreur = -1; + } + } catch (IOException e) { + appLogger.severe(e.toString()); + erreur = -1; } + return erreur; + } + + public static void main(String[] args) { + + AppSynchroAmsatToUvsqsat app = new AppSynchroAmsatToUvsqsat(); + app.execute(); + // app.initDirectory(); + // AmsatToUvsqsatSyncConfig config = new AmsatToUvsqsatSyncConfig(); + // config.setAmsatDatabaseUrl("AMSATDataBase"); + // config.setDeltaTimeLong(10); + // config.setDeltaTime("10"); + // config.setLogin("login"); + // config.setPassword("password"); + // config.setSftpUrl("URL SFTP"); + // config.setSshUrl("SSH file"); + //// + // app.readJson( ); + // app.saveTlmData(config); + + } } diff --git a/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/Commande.java b/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/Commande.java index 323fd2c8878f51b913801100592ebdb17e8f01eb..e08e257dfb2a93415988f19f27a215fa1cf52dd6 100644 --- a/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/Commande.java +++ b/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/Commande.java @@ -1,7 +1,6 @@ package org.josast.databaseSync; public interface Commande { - - public void excecute(); + public void excecute(); } diff --git a/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/DataToExchange.java b/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/DataToExchange.java index c5debaf6c021f1ae5eeb38cdeea8e58b0492881b..3bf5e5a95c547aa61e730d49d9b9aee09b1a0262 100644 --- a/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/DataToExchange.java +++ b/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/DataToExchange.java @@ -2,98 +2,75 @@ package org.josast.databaseSync; public class DataToExchange { - - private String source=""; // Callsign or user name of the receiver - - private String timestamp; // UTC timestamp (see ISO 8601) 2018-01-24T23:42:46Z - - private String frame; // The received data, in hexadecimal string (AX.25 packet with or without KISS 'C0 00 .. C0'. Whitespaces optional. C0 00 A9 05 DE ... - - private String longitude=null; // Longitude of the receiver (WGS84) 8.95564E - - private String latitude=null; //Latitude of the receiver (WGS84) 49.73145N - - - - - public DataToExchange(String source, String timestamp, String frame, String longitude, String latitude) { - super(); - this.source = source; - this.timestamp = timestamp; - this.frame = frame; - this.longitude = longitude; - this.latitude = latitude; - } - - /** - * @return the source - */ - public String getSource() { - return source; - } - - /** - * @param source the source to set - */ - public void setSource(String source) { - this.source = source; - } - - /** - * @return the timestamp - */ - public String getTimestamp() { - return timestamp; - } - - /** - * @param timestamp the timestamp to set - */ - public void setTimestamp(String timestamp) { - this.timestamp = timestamp; - } - - /** - * @return the frame - */ - public String getFrame() { - return frame; - } - - /** - * @param frame the frame to set - */ - public void setFrame(String frame) { - this.frame = frame; - } - - /** - * @return the longitude - */ - public String getLongitude() { - return longitude; - } - - /** - * @param longitude the longitude to set - */ - public void setLongitude(String longitude) { - this.longitude = longitude; - } - - /** - * @return the latitude - */ - public String getLatitude() { - return latitude; - } - - /** - * @param latitude the latitude to set - */ - public void setLatitude(String latitude) { - this.latitude = latitude; - } - - + private String source = ""; // Callsign or user name of the receiver + + private String timestamp; // UTC timestamp (see ISO 8601) 2018-01-24T23:42:46Z + + private String + frame; // The received data, in hexadecimal string (AX.25 packet with or without KISS 'C0 00 + // .. C0'. Whitespaces optional. C0 00 A9 05 DE ... + + private String longitude = null; // Longitude of the receiver (WGS84) 8.95564E + + private String latitude = null; // Latitude of the receiver (WGS84) 49.73145N + + public DataToExchange( + String source, String timestamp, String frame, String longitude, String latitude) { + super(); + this.source = source; + this.timestamp = timestamp; + this.frame = frame; + this.longitude = longitude; + this.latitude = latitude; + } + + /** @return the source */ + public String getSource() { + return source; + } + + /** @param source the source to set */ + public void setSource(String source) { + this.source = source; + } + + /** @return the timestamp */ + public String getTimestamp() { + return timestamp; + } + + /** @param timestamp the timestamp to set */ + public void setTimestamp(String timestamp) { + this.timestamp = timestamp; + } + + /** @return the frame */ + public String getFrame() { + return frame; + } + + /** @param frame the frame to set */ + public void setFrame(String frame) { + this.frame = frame; + } + + /** @return the longitude */ + public String getLongitude() { + return longitude; + } + + /** @param longitude the longitude to set */ + public void setLongitude(String longitude) { + this.longitude = longitude; + } + + /** @return the latitude */ + public String getLatitude() { + return latitude; + } + + /** @param latitude the latitude to set */ + public void setLatitude(String latitude) { + this.latitude = latitude; + } } diff --git a/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/DataToUVSQsatControlCenter.java b/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/DataToUVSQsatControlCenter.java index 6c9b1688cffb0c955eb7cf1fc2216b2b89afca61..b341cb6e643b5544ee6c509658e73c1091c7c753 100644 --- a/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/DataToUVSQsatControlCenter.java +++ b/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/DataToUVSQsatControlCenter.java @@ -11,48 +11,49 @@ import java.util.logging.Logger; import org.json.JSONArray; public class DataToUVSQsatControlCenter implements Commande { - - private static Logger appLogger = Logger.getLogger("AmsatLogger"); - private DataToExchange[] data; - private String file = null; - - public DataToUVSQsatControlCenter(DataToExchange[] sidsdataIn, String fileIn) { - - data = sidsdataIn.clone(); - file = fileIn; - - } - - @Override - public void excecute() { - - save(); - } - - public void save() { - - JSONArray ja = new JSONArray(data); - Path path = Paths.get(file); - - try { - Files.writeString(path, ja.toString(), StandardCharsets.UTF_8); - } catch (IOException ex) { - appLogger.severe("can not write "+file+ " "+ex.getMessage()); - } - - } - - public void append(DataToExchange[] sidsdataIn2, String fileIn2) { - DataToExchange[] data2 = sidsdataIn2.clone(); - JSONArray ja = new JSONArray(data2); - Path path = Paths.get(fileIn2); - - try { - Files.writeString(path, ja.toString(), StandardCharsets.UTF_8,StandardOpenOption.CREATE,StandardOpenOption.APPEND); - } catch (IOException ex) { - appLogger.severe("can not write "+file+ " "+ex.getMessage()); - } - - } + private static Logger appLogger = Logger.getLogger("AmsatLogger"); + private DataToExchange[] data; + private String file = null; + + public DataToUVSQsatControlCenter(DataToExchange[] sidsdataIn, String fileIn) { + + data = sidsdataIn.clone(); + file = fileIn; + } + + @Override + public void excecute() { + + save(); + } + + public void save() { + + JSONArray ja = new JSONArray(data); + Path path = Paths.get(file); + + try { + Files.writeString(path, ja.toString(), StandardCharsets.UTF_8); + } catch (IOException ex) { + appLogger.severe("can not write " + file + " " + ex.getMessage()); + } + } + + public void append(DataToExchange[] sidsdataIn2, String fileIn2) { + DataToExchange[] data2 = sidsdataIn2.clone(); + JSONArray ja = new JSONArray(data2); + Path path = Paths.get(fileIn2); + + try { + Files.writeString( + path, + ja.toString(), + StandardCharsets.UTF_8, + StandardOpenOption.CREATE, + StandardOpenOption.APPEND); + } catch (IOException ex) { + appLogger.severe("can not write " + file + " " + ex.getMessage()); + } + } } diff --git a/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/GetDataFromAmsatDatabase.java b/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/GetDataFromAmsatDatabase.java index 8aed299b57232be8971727e3a6b16b06c91ce12e..d250e531bc1ca6eb412d9eb91f4faab0fc871c98 100644 --- a/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/GetDataFromAmsatDatabase.java +++ b/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/GetDataFromAmsatDatabase.java @@ -9,48 +9,53 @@ import org.json.JSONObject; public class GetDataFromAmsatDatabase implements Commande { - - private String urlDatabase = null; - - final private SimpleDateFormat ISO8601DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); - - public GetDataFromAmsatDatabase(String urlIn) { - urlDatabase = urlIn; - ISO8601DATEFORMAT.setTimeZone(TimeZone.getTimeZone("UTC")); - } - - public DataToExchange[] getTelemetrydata(Date startdate, Date endate, int noradid) { - - String startDate = ISO8601DATEFORMAT.format(startdate); - String endDate = ISO8601DATEFORMAT.format(endate); - DataToExchange dte[] = null; - - // ?endTimeStamp=2021-10-08T15:00:00Z&noradID=1000&startTimeStamp=2021-09-08T13:00:00Z - String url = urlDatabase + "?startTimeStamp=" + startDate + "&endTimeStamp=" +endDate + "&noradID=" + noradid; - - HttpGetDatabasse httpget = new HttpGetDatabasse(); - String results = httpget.sendGET(url); - JSONArray json = new JSONArray(results); - - if (json.length() != 0) { - JSONObject jsonObject = (JSONObject) json.get(0); - dte = new DataToExchange[json.length()]; - for (int i = 0; i < json.length(); i++) { - jsonObject = (JSONObject) json.get(i); - dte[i] = new DataToExchange(jsonObject.getString("source"), jsonObject.getString("timestamp"), - jsonObject.getString("frame"), jsonObject.getString("latitude"),jsonObject.getString("longitude")); - - } - } - return dte; - - } - - @Override - public void excecute() { - - } - - - + private String urlDatabase = null; + + private final SimpleDateFormat ISO8601DATEFORMAT = + new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); + + public GetDataFromAmsatDatabase(String urlIn) { + urlDatabase = urlIn; + ISO8601DATEFORMAT.setTimeZone(TimeZone.getTimeZone("UTC")); + } + + public DataToExchange[] getTelemetrydata(Date startdate, Date endate, int noradid) { + + String startDate = ISO8601DATEFORMAT.format(startdate); + String endDate = ISO8601DATEFORMAT.format(endate); + DataToExchange dte[] = null; + + // ?endTimeStamp=2021-10-08T15:00:00Z&noradID=1000&startTimeStamp=2021-09-08T13:00:00Z + String url = + urlDatabase + + "?startTimeStamp=" + + startDate + + "&endTimeStamp=" + + endDate + + "&noradID=" + + noradid; + + HttpGetDatabasse httpget = new HttpGetDatabasse(); + String results = httpget.sendGET(url); + JSONArray json = new JSONArray(results); + + if (json.length() != 0) { + JSONObject jsonObject = (JSONObject) json.get(0); + dte = new DataToExchange[json.length()]; + for (int i = 0; i < json.length(); i++) { + jsonObject = (JSONObject) json.get(i); + dte[i] = + new DataToExchange( + jsonObject.getString("source"), + jsonObject.getString("timestamp"), + jsonObject.getString("frame"), + jsonObject.getString("latitude"), + jsonObject.getString("longitude")); + } + } + return dte; + } + + @Override + public void excecute() {} } diff --git a/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/SendFilesToSids.java b/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/SendFilesToSids.java index 90bf75cdff04ab7a0cf64898b5c45f6ab5cae717..d9e6fff26e296f646c08fe039eaf2d516e58f2bb 100644 --- a/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/SendFilesToSids.java +++ b/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/SendFilesToSids.java @@ -1,19 +1,16 @@ package org.josast.databaseSync; public class SendFilesToSids implements Commande { - - String path = null; - - - public SendFilesToSids( String pathIN) - { - path=pathIN; - } - @Override - public void excecute() { - // TODO Auto-generated method stub + String path = null; - } + public SendFilesToSids(String pathIN) { + path = pathIN; + } + @Override + public void excecute() { + // TODO Auto-generated method stub + + } } diff --git a/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/SendSftp.java b/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/SendSftp.java index f99689db826e8608ad07d141bd1671d5eff33635..8370851c949fef45a89be0afc62f2a4190a95d7c 100644 --- a/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/SendSftp.java +++ b/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/SendSftp.java @@ -10,70 +10,65 @@ import com.jcraft.jsch.SftpException; public class SendSftp { - private static Logger appLogger = Logger.getLogger("AmsatLogger"); - - private String remoteHost = null; - private String username = null; - private String password = null; - private String KnownHosts = "LATMOS_SSH"; - - private ChannelSftp channelSftp = null; - - public SendSftp(String remoteHost, String username, String password) { - super(); - this.remoteHost = remoteHost; - this.username = username; - this.password = password; - - channelSftp = setupJsch(); - } - - - - public ChannelSftp setupJsch() { - Session jschSession = null; - ChannelSftp channel = null; - try { - - JSch jsch = new JSch(); - jsch.setKnownHosts(KnownHosts); - jschSession = jsch.getSession(username, remoteHost); - jschSession.setPassword(password); - jschSession.connect(); - } catch (Exception e) { - appLogger.severe("error connection to " + remoteHost + " " + e.getMessage()); - } - - try { - channel = (ChannelSftp) jschSession.openChannel("sftp"); - - } catch (JSchException e) { - appLogger.severe("error to open channel sftp " + e.getMessage()); - - } - - return channel; - - } - - public void upload(String filein, String fileout) { - - try { - channelSftp.connect(); - } catch (JSchException e) { - appLogger.severe("error to connect channel " + e.getMessage()); -e.printStackTrace(); - } - - try { - channelSftp.put(filein, fileout); - } catch (SftpException e) { - - appLogger.severe("error to send file " + e.getMessage()); - e.printStackTrace(); - } - System.out.println("sentn"); - channelSftp.exit(); - } - + private static Logger appLogger = Logger.getLogger("AmsatLogger"); + + private String remoteHost = null; + private String username = null; + private String password = null; + private String KnownHosts = "LATMOS_SSH"; + + private ChannelSftp channelSftp = null; + + public SendSftp(String remoteHost, String username, String password) { + super(); + this.remoteHost = remoteHost; + this.username = username; + this.password = password; + + channelSftp = setupJsch(); + } + + public ChannelSftp setupJsch() { + Session jschSession = null; + ChannelSftp channel = null; + try { + + JSch jsch = new JSch(); + jsch.setKnownHosts(KnownHosts); + jschSession = jsch.getSession(username, remoteHost); + jschSession.setPassword(password); + jschSession.connect(); + } catch (Exception e) { + appLogger.severe("error connection to " + remoteHost + " " + e.getMessage()); + } + + try { + channel = (ChannelSftp) jschSession.openChannel("sftp"); + + } catch (JSchException e) { + appLogger.severe("error to open channel sftp " + e.getMessage()); + } + + return channel; + } + + public void upload(String filein, String fileout) { + + try { + channelSftp.connect(); + } catch (JSchException e) { + appLogger.severe("error to connect channel " + e.getMessage()); + e.printStackTrace(); + } + + try { + channelSftp.put(filein, fileout); + } catch (SftpException e) { + + appLogger.severe("error to send file " + e.getMessage()); + e.printStackTrace(); + } + + channelSftp.exit(); + } } diff --git a/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/config/ManageFolder.java b/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/config/ManageFolder.java index fde3739aa6526fe9a6b0f87565b772a9c9b2f7c9..c7f27ba667040edc326902640f96f7b2b7f6260f 100644 --- a/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/config/ManageFolder.java +++ b/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/config/ManageFolder.java @@ -9,58 +9,50 @@ import java.util.logging.Logger; public class ManageFolder { - private static Logger appLogger = Logger.getLogger("AmsatLogger"); - private String RepositoryPath = null; - - - private String defaultrepository = "data"; - - public ManageFolder() { - RepositoryPath = System.getProperty("user.dir") + "\\" + defaultrepository; - } - - public ManageFolder(String path) { - - if (path == null) { - RepositoryPath = System.getProperty("user.dir") + "\\" + defaultrepository; - - } else if (path.length() == 0) { - RepositoryPath = System.getProperty("user.dir") + "\\+defaultrepository"; - } else { - RepositoryPath = System.getProperty("user.dir") + "\\" + path; - } - } - - /** - * @return the repositoryPath - */ - public String getRepositoryPath() { - return RepositoryPath; - } - - /** - * @param repositoryPath the repositoryPath to set - */ - public void setRepositoryPath(String repositoryPath) { - RepositoryPath = repositoryPath; - } - - public void createdDirectories() { - - Path path = Paths.get(RepositoryPath); - // if directory exists? - if (!Files.exists(path)) { - try { - Files.createDirectories(path); - appLogger.info("directory created : " + RepositoryPath); - } catch (IOException e) { - appLogger.log(Level.SEVERE, "cannot create outpout directorie " + e.toString()); - } - } else - { - appLogger.info("directory already exist : " + RepositoryPath); - } - - } - + private static Logger appLogger = Logger.getLogger("AmsatLogger"); + private String RepositoryPath = null; + + private String defaultrepository = "data"; + + public ManageFolder() { + RepositoryPath = System.getProperty("user.dir") + "\\" + defaultrepository; + } + + public ManageFolder(String path) { + + if (path == null) { + RepositoryPath = System.getProperty("user.dir") + "\\" + defaultrepository; + + } else if (path.length() == 0) { + RepositoryPath = System.getProperty("user.dir") + "\\+defaultrepository"; + } else { + RepositoryPath = System.getProperty("user.dir") + "\\" + path; + } + } + + /** @return the repositoryPath */ + public String getRepositoryPath() { + return RepositoryPath; + } + + /** @param repositoryPath the repositoryPath to set */ + public void setRepositoryPath(String repositoryPath) { + RepositoryPath = repositoryPath; + } + + public void createdDirectories() { + + Path path = Paths.get(RepositoryPath); + // if directory exists? + if (!Files.exists(path)) { + try { + Files.createDirectories(path); + appLogger.info("directory created : " + RepositoryPath); + } catch (IOException e) { + appLogger.log(Level.SEVERE, "cannot create outpout directorie " + e.toString()); + } + } else { + appLogger.info("directory already exist : " + RepositoryPath); + } + } } diff --git a/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/config/ManageJSonConfigFile.java b/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/config/ManageJSonConfigFile.java index 924d5b8e9173c557179e0f810b04e951bd38261a..7d7af0736f28ad728b91ac35dbde81fa22274234 100644 --- a/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/config/ManageJSonConfigFile.java +++ b/ApplicationDatabaseSynchronisation/src/main/java/org/josast/databaseSync/config/ManageJSonConfigFile.java @@ -16,74 +16,69 @@ import org.json.JSONException; import org.json.JSONObject; public class ManageJSonConfigFile { - private static Logger appLogger = Logger.getLogger("AmsatLogger"); - - private String configRepository = "config"; - private String configName = "Data.json"; - - public int SaveConfigFile(Object bean) { - ManageFolder mn = new ManageFolder(configRepository); - mn.createdDirectories(); - Path filepath = Paths.get(mn.getRepositoryPath() + "/"+configName); - - int erreur = 0; - - JSONObject jasonObject = new JSONObject(bean); - - try { - if (!Files.exists(filepath)) { - Files.createFile(filepath); - Files.writeString(filepath, " " + "\r\n", StandardOpenOption.CREATE); - } - - Files.writeString(filepath, jasonObject.toString() + "\r\n", StandardOpenOption.CREATE); - if (Files.size(filepath) < 10) { - appLogger.severe("file not created "); - erreur = -1; - } - - } catch (IOException e) { - appLogger.severe(e.toString()); - erreur = -1; - } - - return erreur; - } - - public Object readJson(Object object ) - { - Object tempobject = null; - String RepositoryPath = System.getProperty("user.dir") + "/"+configRepository; - System.out.println(RepositoryPath); - Path filepath = Paths.get(RepositoryPath + "/"+configName); - try { - - InputStream is = Files.newInputStream(filepath); - String text = IOUtils.toString(is, "UTF-8"); - JSONObject myJsonObject = new JSONObject(text); - tempobject = toBean(myJsonObject, object); - - } catch (IOException | JSONException e) { - e.printStackTrace(); - appLogger.severe("Erreor reading json file"+filepath.getFileName()); - } - return tempobject; - - - } - - - public static Object toBean(JSONObject jobject, Object object) { - - for (Field field : object.getClass().getDeclaredFields()) { - try { - field.set(object, jobject.getString(field.getName())); - } catch (IllegalArgumentException | IllegalAccessException | JSONException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - return object; - } + private static Logger appLogger = Logger.getLogger("AmsatLogger"); + private String configRepository = "config"; + private String configName = "Data.json"; + + public int SaveConfigFile(Object bean) { + ManageFolder mn = new ManageFolder(configRepository); + mn.createdDirectories(); + Path filepath = Paths.get(mn.getRepositoryPath() + "/" + configName); + + int erreur = 0; + + JSONObject jasonObject = new JSONObject(bean); + + try { + if (!Files.exists(filepath)) { + Files.createFile(filepath); + Files.writeString(filepath, " " + "\r\n", StandardOpenOption.CREATE); + } + + Files.writeString(filepath, jasonObject.toString() + "\r\n", StandardOpenOption.CREATE); + if (Files.size(filepath) < 10) { + appLogger.severe("file not created "); + erreur = -1; + } + + } catch (IOException e) { + appLogger.severe(e.toString()); + erreur = -1; + } + + return erreur; + } + + public Object readJson(Object object) { + Object tempobject = null; + String RepositoryPath = System.getProperty("user.dir") + "/" + configRepository; + System.out.println(RepositoryPath); + Path filepath = Paths.get(RepositoryPath + "/" + configName); + try { + + InputStream is = Files.newInputStream(filepath); + String text = IOUtils.toString(is, "UTF-8"); + JSONObject myJsonObject = new JSONObject(text); + tempobject = toBean(myJsonObject, object); + + } catch (IOException | JSONException e) { + e.printStackTrace(); + appLogger.severe("Erreor reading json file" + filepath.getFileName()); + } + return tempobject; + } + + public static Object toBean(JSONObject jobject, Object object) { + + for (Field field : object.getClass().getDeclaredFields()) { + try { + field.set(object, jobject.getString(field.getName())); + } catch (IllegalArgumentException | IllegalAccessException | JSONException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return object; + } } diff --git a/ApplicationJMultisat/pom.xml b/ApplicationJMultisat/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..419efecd63bae35baf003289d84e4ab29500a66c --- /dev/null +++ b/ApplicationJMultisat/pom.xml @@ -0,0 +1,395 @@ + + + 4.0.0 + + org.josast + JOSAST-parent + 0.0.2 + + + + ApplicationJMultiSat + + jar + + satellitePrediction + + https://www.amsat-f.org + + UTF-8 + 17 + 5.9.2 + 2.0.9 + + 18 + + org.josast.application + org.josast.application.App + 2.8.1 + 3.1.2 + 3.15.0 + 3.1.2 + + + + + + + + com.google.code.gson + gson + 2.10.1 + + + + + org.josast + ModuleAutomation + 0.0.2 + + + org.openjfx + javafx-controls + ${openjfx.version} + + + org.openjfx + javafx-fxml + ${openjfx.version} + + + org.junit.jupiter + junit-jupiter + ${junit.jupiter.version} + test + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + slf4j-simple + ${slf4j.version} + + + uk.me.g4dpz + predict4java + 1.1.3 + + + + + + + org.apache.logging.log4j + log4j-core + 2.21.1 + + + org.apache.logging.log4j + log4j-api + 2.21.1 + + + + joda-time + joda-time + 2.12.5 + + + + + + jakarta.xml.bind + jakarta.xml.bind-api + 4.0.1 + + + com.sun.xml.bind + jaxb-impl + 4.0.4 + runtime + + + + + + + + + + + + + + + com.github.spotbugs + + + spotbugs-maven-plugin + + + 4.5.3.0 + + + + + + + + + org.owasp + + + dependency-check-maven + + + 5.3.2 + + + + + + + + + + + + aggregate + + + + + + + + + + + + + + + + + + org.apache.maven.plugins + + + maven-project-info-reports-plugin + + + ${plugin.project-info-reports.version} + + + + + + + + + org.apache.maven.plugins + + + maven-pmd-plugin + + + ${plugin.pmd-plugin.version} + + + + + + + + + org.apache.maven.plugins + + + maven-checkstyle-plugin + + + ${plugin.checkstyle.version} + + + + + google_checks.xml + + + + + + + + + + checkstyle + + + + + + + checkstyle-aggregate + false + + true + + + checkstyle-aggregate + + + + + + + org.codehaus.mojo + versions-maven-plugin + ${plugin.versions-maven.version} + + + + + + + + + + + org.codehaus.mojo + exec-maven-plugin + + ${main.class} + + + + org.openjfx + javafx-maven-plugin + 0.0.8 + + ${main.class} + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.5.0 + + + package + + shade + + + + + + ${main.class} + + + + + + ${project.build.directory}/${project.artifactId}-${project.version}-fat.jar + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.2.1 + + + enforce-maven + + enforce + + + + + 3.4.0 + + + + + + + + org.jacoco + jacoco-maven-plugin + 0.8.8 + + + default-prepare-agent + + prepare-agent + + + + default-report + test + + report + + + + + + + + + + maven-clean-plugin + 3.1.0 + + + maven-site-plugin + 3.11.0 + + + maven-project-info-reports-plugin + 3.2.2 + + + maven-resources-plugin + 3.2.0 + + + maven-compiler-plugin + 3.10.1 + + + maven-surefire-plugin + 3.0.0-M5 + + false + + + + + maven-jar-plugin + 3.2.2 + + + maven-install-plugin + 3.0.0-M1 + + + maven-deploy-plugin + 3.0.0-M2 + + + org.codehaus.mojo + exec-maven-plugin + 3.1.0 + + + + + diff --git a/ApplicationJMultisat/src/main/java/org/.gitkeep b/ApplicationJMultisat/src/main/java/org/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/ApplicationJMultisat/src/main/java/org/josast/.gitkeep b/ApplicationJMultisat/src/main/java/org/josast/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/ApplicationJMultisat/src/main/java/org/josast/application/App.java b/ApplicationJMultisat/src/main/java/org/josast/application/App.java new file mode 100644 index 0000000000000000000000000000000000000000..442528c4e600c5c8b351361139d1386cf5de276b --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/application/App.java @@ -0,0 +1,42 @@ +package org.josast.application; + +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.stage.Stage; + +import java.io.IOException; + +/** JavaFX App */ +public class App extends Application { + + private static Scene scene; + private static FXMLLoader fxmlLoader; + + @Override + public void start(Stage stage) throws IOException { + + scene = new Scene(loadFXML("multisat"), 640, 480); + + stage.setScene(scene); + + PrimaryController ctrl = fxmlLoader.getController(); + ctrl.setStage(stage); + ctrl.init(); + stage.show(); + } + + static void setRoot(String fxml) throws IOException { + scene.setRoot(loadFXML(fxml)); + } + + private static Parent loadFXML(String fxml) throws IOException { + fxmlLoader = new FXMLLoader(App.class.getResource(fxml + ".fxml")); + return fxmlLoader.load(); + } + + public static void main(String[] args) { + launch(); + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/application/BooleanEditingCell.java b/ApplicationJMultisat/src/main/java/org/josast/application/BooleanEditingCell.java new file mode 100644 index 0000000000000000000000000000000000000000..24083edf11c7754999e8ea1eb4926fb01b2cc1e6 --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/application/BooleanEditingCell.java @@ -0,0 +1,66 @@ +package org.josast.application; + +import org.josast.satellite.SatelliteInformationInterface; + +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; +import javafx.scene.control.CheckBox; +import javafx.scene.control.TableCell; + +public class BooleanEditingCell extends TableCell { + + private CheckBox checkBox; + + public BooleanEditingCell() { + checkBox = new CheckBox(); + checkBox + .selectedProperty() + .addListener( + new ChangeListener() { + @Override + public void changed( + ObservableValue observable, + Boolean oldValue, + Boolean newValue) { + if (isEditing()) { + commitEdit(newValue); + } + } + }); + } + + @Override + protected void updateItem(Boolean item, boolean empty) { + super.updateItem(item, empty); + + if (empty) { + setText(null); + setGraphic(null); + } else { + checkBox.setSelected(item); + setGraphic(checkBox); + } + } + + @Override + public void startEdit() { + super.startEdit(); + checkBox.setSelected(getItem()); + setGraphic(checkBox); + checkBox.requestFocus(); + System.out.println("Start"); + } + + @Override + public void cancelEdit() { + super.cancelEdit(); + setGraphic(null); + } + + @Override + public void commitEdit(Boolean newValue) { + super.commitEdit(newValue); + setGraphic(null); + System.out.println(newValue); + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/application/DurationTableCell.java b/ApplicationJMultisat/src/main/java/org/josast/application/DurationTableCell.java new file mode 100644 index 0000000000000000000000000000000000000000..424cad989aca7fb3fc2e45e5a23f27c673bc9bfe --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/application/DurationTableCell.java @@ -0,0 +1,24 @@ +package org.josast.application; + +import javafx.scene.control.TableCell; +import javafx.scene.control.TableColumn; +import javafx.util.Callback; +import java.time.Duration; + +public class DurationTableCell extends TableCell { + @Override + protected void updateItem(Long item, boolean empty) { + super.updateItem(item, empty); + if (empty || item == null) { + setText(null); + } else { + Duration duration = Duration.ofMillis(item); + long minutes = duration.toMinutes(); + setText(String.format("%d min %d sec", minutes, duration.toSecondsPart())); + } + } + + public static Callback, TableCell> forTableColumn() { + return column -> new DurationTableCell<>(); + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/application/IntegerEditingCell.java b/ApplicationJMultisat/src/main/java/org/josast/application/IntegerEditingCell.java new file mode 100644 index 0000000000000000000000000000000000000000..a6e338b74d2d5a2fc957990a88a3d1586796a43c --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/application/IntegerEditingCell.java @@ -0,0 +1,79 @@ +package org.josast.application; + +import org.josast.satellite.SatelliteInformationInterface; + +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; +import javafx.scene.control.TableCell; +import javafx.scene.control.TextField; + +public class IntegerEditingCell extends TableCell { + private TextField textField; + + public IntegerEditingCell() { + textField = new TextField(); + textField.setOnAction(event -> commitEdit(Integer.parseInt(textField.getText()))); + textField + .focusedProperty() + .addListener( + (observable, oldValue, newValue) -> { + if (!newValue) { + commitEdit(Integer.parseInt(textField.getText())); + } + }); + textField + .textProperty() + .addListener( + new ChangeListener() { + @Override + public void changed( + ObservableValue observable, String oldValue, String newValue) { + if (!newValue.matches("\\d*")) { + textField.setText(newValue.replaceAll("[^\\d]", "")); + } + } + }); + } + + @Override + protected void updateItem(Integer item, boolean empty) { + super.updateItem(item, empty); + + if (empty) { + setText(null); + setGraphic(null); + } else { + if (isEditing()) { + textField.setText(item.toString()); + setGraphic(textField); + } else { + setText(item.toString()); + setGraphic(null); + } + } + } + + @Override + public void startEdit() { + super.startEdit(); + textField.setText(getItem().toString()); + setGraphic(textField); + textField.requestFocus(); + textField.selectAll(); + System.out.println("Start"); + } + + @Override + public void cancelEdit() { + super.cancelEdit(); + setText(getItem().toString()); + setGraphic(null); + System.out.println("Cancel"); + } + + @Override + public void commitEdit(Integer newValue) { + System.out.println(newValue); + super.commitEdit(Integer.parseInt(textField.getText())); + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/application/PrimaryController.java b/ApplicationJMultisat/src/main/java/org/josast/application/PrimaryController.java new file mode 100644 index 0000000000000000000000000000000000000000..c0f84f81a9140a0ac5966f656e91cb986edbcbfa --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/application/PrimaryController.java @@ -0,0 +1,612 @@ +package org.josast.application; + +import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; + +import java.util.List; +import java.util.Optional; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; + +import org.joda.time.DateTime; +import org.josast.automation.ProcessBuilderCollection; +import org.josast.automation.ProcessBuilderWrapper; +import org.josast.automation.application.Application; +import org.josast.automation.application.ApplicationRadio; +import org.josast.automation.application.ApplicationRadioHamlib; +import org.josast.automation.application.ApplicationType; +import org.josast.keplerelement.IKelplerianElementManager; +import org.josast.keplerelement.IkeplerienElement; +import org.josast.keplerelement.file.KeplerianFileManagerFromUrl; +import org.josast.satellite.ManageSatellites; +import org.josast.satellite.SatelliteInformationInterface; +import org.josast.satellite.mode.CollectionModulationMode; +import org.josast.satellite.mode.ModulationMode; +import org.josast.satellitePrediction.InterfaceSatellitePropagation; +import org.josast.satellitePrediction.KeplerianElementTwoLine; +import org.josast.satellitePrediction.KeplerianElementTwoLineInterface; +import org.josast.satellitePrediction.ManageSatellitePass; +import org.josast.satellitePrediction.SatellitePassfromGroundStation; +import org.josast.satellitePrediction.SortbyAOS; +import org.josast.satellitePredictionG4DPZ.SatellitePropagation; +import org.josast.station.GroundStation; +import org.josast.station.GroundStationInterface; + +import javafx.beans.property.BooleanPropertyBase; +import javafx.beans.property.SimpleBooleanProperty; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.ButtonBar.ButtonData; +import javafx.scene.control.ButtonType; +import javafx.scene.control.ComboBox; +import javafx.scene.control.Dialog; +import javafx.scene.control.Label; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.control.TextField; +import javafx.scene.control.cell.CheckBoxTableCell; +import javafx.scene.control.cell.PropertyValueFactory; +import javafx.scene.layout.GridPane; +import javafx.stage.FileChooser; +import javafx.stage.Stage; +import javafx.util.Callback; + +public class PrimaryController { + ScheduledExecutorService ses = Executors.newScheduledThreadPool(1); + private ScheduledFuture scheduledFuture = null; + private int delayRefresh = 1; // toute les 10 mn + @FXML private TableView tvSatellites; + + @FXML private TableColumn tcname; + + @FXML private TableColumn tcnoaradid; + + @FXML private TableColumn tcpriority; + + @FXML private TableColumn tcselect; + + @FXML private TableView TableComputePass; + + @FXML private TableColumn TcCPAos; + + @FXML private TableColumn TcCPDuration; + + @FXML private TableColumn TcCPLos; + + @FXML private TableColumn TcCPMaxElevation; + + @FXML private TableColumn TcCPSatelliteName; + + @FXML private TableView tvApplication; + + @FXML private TableColumn tcApplicationName; + + @FXML private TableColumn tcApplicationStatus; + + @FXML private TableColumn tcApplicationType; + + @FXML private TableColumn tcApplicationArgument; + + @FXML private TableColumn tcApplicationCommande; + + @FXML private TableColumn tcApplicationPath; + + @FXML private TableColumn tcApplicationScope; + + @FXML private TableView tvModulationMode; + + @FXML private TableColumn tcModulationBandwith; + + @FXML private TableColumn tcModulationName; + + @FXML private TableColumn tcModulationOffset; + + @FXML private TableColumn tcModulationRadioMode; + + @FXML private TextField tfElevation; + + @FXML private TextField tfduration; + + ProcessBuilderCollection appliList = null; + + private Stage primaryStage; + + private KeplerianFileManagerFromUrl kepsMngt = null;; + + private ManageSatellites mngSat = new ManageSatellites();; + + @FXML private Button BtSatelliteLoadFile; + @FXML private Button BtSave; + + ManageSatellitePass mngtSatPass = null; + + ObservableList observableSatellite = + FXCollections.observableArrayList(); + + private ObservableList observablePass = + FXCollections.observableArrayList(); + private ObservableList observableApplication = FXCollections.observableArrayList(); + private CollectionModulationMode collectionMode; + private ObservableList observableModulationMode = + FXCollections.observableArrayList(); + + // + // @FXML + // void handleEdit(ActionEvent event) { + // System.out.println(" value " + event); + // } + + public void init() { + tvSatellites.setEditable(true); + + tvSatellites + .getSelectionModel() + .selectedItemProperty() + .addListener( + (observable, oldValue, newValue) -> { + if (newValue != null) { + int selectedIndex = tvSatellites.getSelectionModel().getSelectedIndex(); + System.out.println("Ligne sélectionnée : " + selectedIndex); + } + }); + + tcname.setEditable(false); + tcname.setCellValueFactory( + new PropertyValueFactory("name")); + tcnoaradid.setEditable(false); + tcnoaradid.setCellValueFactory(new PropertyValueFactory<>("noradIdentifier")); + tcpriority.setCellValueFactory(new PropertyValueFactory<>("priority")); + tcpriority.setEditable(true); + + tcpriority.setCellFactory(tc -> new IntegerEditingCell()); + + tcpriority.setOnEditCommit( + event -> { + System.out.println(event); + SatelliteInformationInterface dataModel = event.getRowValue(); + dataModel.setPriority(event.getNewValue()); + }); + + tcselect.setEditable(true); + // tcselect.setCellValueFactory(new PropertyValueFactory<>("selected")); + tcselect.setCellFactory(column -> new CheckBoxTableCell<>()); + tcselect.setCellValueFactory( + cellData -> { + SatelliteInformationInterface cellValue = cellData.getValue(); + // BooleanProperty property = new BooleanProperty() ;// cellValue.isSelected(); + BooleanPropertyBase property = new SimpleBooleanProperty(cellValue.isSelected()); + + // Add listener to handler change + property.addListener((observable, oldValue, newValue) -> cellValue.setSelected(newValue)); + + return property; + }); + + tvSatellites.setItems(observableSatellite); + + TcCPSatelliteName.setCellValueFactory(new PropertyValueFactory<>("name")); + TcCPAos.setCellValueFactory(new PropertyValueFactory<>("AOSDate")); + TcCPLos.setCellValueFactory(new PropertyValueFactory<>("LOSDate")); + TcCPDuration.setCellValueFactory(new PropertyValueFactory<>("duration")); + TcCPDuration.setCellFactory(DurationTableCell.forTableColumn()); + + initApplication(); + } + + @FXML + void loadSatellite(ActionEvent event) { + kepsMngt = new KeplerianFileManagerFromUrl(); + SatelliteInformationInterface[] listSat = kepsMngt.getSatelliteInformation(); + + mngSat.setSatellites(listSat); + observableSatellite.addAll(mngSat.getSatellites()); + } + + @FXML + void HandlerCompute(ActionEvent event) { + + System.out.println(" Step 1 : configuration station sol "); + double latitude = 48.858365; // 48.8330; + double longitude = 2.294532; // -2.3330; + double altitude = 75; + String name = "test Xtophe"; + GroundStationInterface groundStation = new GroundStation(name, altitude, longitude, latitude); + + IKelplerianElementManager kepsMngt = new KeplerianFileManagerFromUrl(); + // SatelliteInformationInterface[] listSat = kepsMngt.getSatelliteInformation() ; + + SatelliteInformationInterface[] listSat = mngSat.getSelectedSatellites(); + + System.out.println("nombre satellite " + listSat.length); + + mngtSatPass = new ManageSatellitePass(); + + KeplerianElementTwoLineInterface keps = new KeplerianElementTwoLine(); + InterfaceSatellitePropagation satProg = new SatellitePropagation(); + satProg.setGroundStation(groundStation); + + List passages; + for (int i = 0; i < listSat.length; i++) { + + System.out.println("" + i + " " + listSat[i].getName()); + + IkeplerienElement keplerElt = kepsMngt.getSatelliteKeplerianElement(listSat[i].getName()); + // @TODO : A simplifier + String twoLines = + keplerElt.getTwoline()[0] + + "\r\n" + + keplerElt.getTwoline()[1] + + "\r\n" + + keplerElt.getTwoline()[2] + + "\r\n"; + + keps.setTwoLine(twoLines); + + satProg.setSatelliteKeplerianElement(keps); + passages = satProg.getNextPass(24); + mngtSatPass.addSatellitePass(passages); + } + System.out.println("Nombre de passage calculés " + mngtSatPass.getSize()); + mngtSatPass.sort(new SortbyAOS()); + observablePass.addAll(mngtSatPass.getSatellitePassList()); + TableComputePass.setItems(observablePass); + } + + @FXML + void HandleFilterElevation(ActionEvent event) { + List filtered = + mngtSatPass.filter(mngtSatPass.minElevationPredicate); + mngtSatPass.setSatellitePassList(filtered); + observablePass.clear(); + observablePass.addAll(mngtSatPass.getSatellitePassList()); + System.out.println("Nombre de passage calculés " + mngtSatPass.getSize()); + TableComputePass.setItems(observablePass); + } + + @FXML + void handleFilterDuration(ActionEvent event) { + + List filtered = + mngtSatPass.filter(mngtSatPass.minDurationnPredicate); + mngtSatPass.setSatellitePassList(filtered); + observablePass.clear(); + observablePass.addAll(mngtSatPass.getSatellitePassList()); + System.out.println("Nombre de passage calculés " + mngtSatPass.getSize()); + TableComputePass.setItems(observablePass); + } + + @FXML + void handlerFilterPass(ActionEvent event) { + List filtered = mngtSatPass.selectPassByPriority(mngSat); + mngtSatPass.setSatellitePassList(filtered); + observablePass.clear(); + observablePass.addAll(mngtSatPass.getSatellitePassList()); + System.out.println("Nombre de passage calculés " + mngtSatPass.getSize()); + TableComputePass.setItems(observablePass); + } + + private void initApplication() { + Application radioSDR = + new ApplicationRadioHamlib( + "SDR CONSOLE", + "C:\\Program Files\\SDR-Radio.com (V3)\\", + "SDR Console.exe", + "", + "GLOBAL"); + Application rotorHamlib = + new Application( + "ROTCLD", "C:\\00-PRG\\hamlib-w64-4.4\\bin\\", "rotctld.exe", "-v", "GLOBAL"); + Application radioHamlib = + new Application( + "RIGCLD", "C:\\00-PRG\\hamlib-w64-4.4\\bin\\", "rigctld.exe", "-v", "GLOBAL"); + + appliList = new ProcessBuilderCollection(); + collectionMode = new CollectionModulationMode(); + + ModulationMode gr3uhMode = new ModulationMode("GR3UH 9600", "USB", 8000.0, 22.000); + + collectionMode.put(gr3uhMode.getName(), gr3uhMode); + + appliList.put(radioHamlib, new ProcessBuilderWrapper(radioHamlib.toList())); + appliList.put(rotorHamlib, new ProcessBuilderWrapper(rotorHamlib.toList())); + appliList.put(radioSDR, new ProcessBuilderWrapper(radioSDR.toList())); + + tcApplicationName.setCellValueFactory(new PropertyValueFactory<>("Name")); + tcApplicationStatus.setCellValueFactory(new PropertyValueFactory<>("Status")); + tcApplicationType.setCellValueFactory(new PropertyValueFactory<>("Type")); + tcApplicationArgument.setCellValueFactory(new PropertyValueFactory<>("Argument")); + tcApplicationCommande.setCellValueFactory(new PropertyValueFactory<>("Commande")); + tcApplicationPath.setCellValueFactory(new PropertyValueFactory<>("Path")); + tcApplicationScope.setCellValueFactory(new PropertyValueFactory<>("Scope")); + + tcModulationBandwith.setCellValueFactory(new PropertyValueFactory<>("RadioBandwith")); + + tcModulationName.setCellValueFactory(new PropertyValueFactory<>("Name")); + + tcModulationOffset.setCellValueFactory(new PropertyValueFactory<>("RadioOffset")); + ; + + tcModulationRadioMode.setCellValueFactory(new PropertyValueFactory<>("RadioMode")); + ; + observableModulationMode.clear(); + observableModulationMode.addAll(collectionMode.values()); + tvModulationMode.setItems(observableModulationMode); + observableApplication.clear(); + observableApplication.addAll(appliList.keySet()); + tvApplication.setItems(observableApplication); + } + + public void setStage(Stage stage) { + primaryStage = stage; + } + + /** + * ******************************************************************************************** + * Management des applications génériques + * ******************************************************************************************** + */ + @FXML + void HandlerLoadGeneric(ActionEvent event) { + FileChooser fileChooser = new FileChooser(); + Path currRelativePath = Paths.get(""); + String currAbsolutePathString = currRelativePath.toAbsolutePath().toString(); + System.out.println("Current absolute path is - " + currAbsolutePathString); + fileChooser + .getExtensionFilters() + .addAll( + new FileChooser.ExtensionFilter("Json Files", "*.json"), + new FileChooser.ExtensionFilter("Text Files", "*.txt")); + fileChooser.setInitialDirectory(new File(currAbsolutePathString)); + File selectedDirectory = fileChooser.showOpenDialog(primaryStage); + + if (selectedDirectory != null) { + System.out.println(selectedDirectory.getAbsolutePath()); + appliList.clear(); + appliList.loadApplication(selectedDirectory.getAbsolutePath()); + List applist = appliList.getListApplication(); + observableApplication.clear(); + observableApplication.addAll(applist); + + } else { + System.out.println("no file selected"); + } + + System.out.println("Load"); + } + + @FXML + void handlerSaveGeneric(ActionEvent event) { + // List setApp = appliList.getListApplication(); + System.out.println("save"); + FileChooser fileChooser = new FileChooser(); + Path currRelativePath = Paths.get(""); + String currAbsolutePathString = currRelativePath.toAbsolutePath().toString(); + System.out.println("Current absolute path is - " + currAbsolutePathString); + fileChooser + .getExtensionFilters() + .addAll( + new FileChooser.ExtensionFilter("Json Files", "*.json"), + new FileChooser.ExtensionFilter("Text Files", "*.txt")); + fileChooser.setInitialDirectory(new File(currAbsolutePathString)); + File selectedFile = fileChooser.showSaveDialog(primaryStage); + if (selectedFile != null) { + appliList.saveApplication(selectedFile.getAbsolutePath()); + } else { + System.out.println("no file selected"); + } + } + + @FXML + void HandlerAddApplication(ActionEvent event) { + + ObservableList scopeList = FXCollections.observableArrayList("Global", "Satellite"); + ApplicationType typeAp = new ApplicationType(); + ObservableList TypeList = + FXCollections.observableArrayList(typeAp.getlistApplicationType()); + Dialog dialog = new Dialog<>(); + dialog.setTitle("Add new application"); + dialog.setHeaderText( + " Add a new application \n" + "press Okay (or click title bar 'X' for cancel)."); + dialog.setResizable(true); + + Label labelName = new Label("Name : "); + Label labelScope = new Label("Scope: "); + Label labelCommande = new Label("Commande: "); + Label labelPath = new Label("path: "); + Label labelArgument = new Label("Argument: "); + Label labelType = new Label("Type : "); + + TextField textName = new TextField(); + ComboBox scope = new ComboBox(scopeList); + TextField textCommande = new TextField(); + TextField textPath = new TextField(); + TextField textArgument = new TextField(); + ComboBox type = new ComboBox(TypeList); + GridPane grid = new GridPane(); + grid.add(labelName, 1, 1); + grid.add(textName, 2, 1); + grid.add(labelScope, 1, 2); + grid.add(scope, 2, 2); + grid.add(labelCommande, 1, 3); + grid.add(textCommande, 2, 3); + grid.add(labelPath, 1, 4); + grid.add(textPath, 2, 4); + grid.add(labelArgument, 1, 5); + grid.add(textArgument, 2, 5); + grid.add(labelType, 1, 6); + grid.add(type, 2, 6); + dialog.getDialogPane().setContent(grid); + + ButtonType buttonTypeOk = new ButtonType("Okay", ButtonData.OK_DONE); + dialog.getDialogPane().getButtonTypes().add(buttonTypeOk); + + dialog.setResultConverter( + (Callback) + new Callback() { + @Override + public Application call(ButtonType b) { + + if (b == buttonTypeOk) { + + return new Application( + textName.getText(), + textCommande.getText(), + scope.getValue(), + textPath.getText(), + textArgument.getText(), + type.getValue()); + } + + return null; + } + }); + + Optional result = dialog.showAndWait(); + + if (result.isPresent()) { + + // Labeled actionStatus = null; + Application app = result.get(); + System.out.println("resultat" + app); + appliList.put(app, new ProcessBuilderWrapper(app.toList())); + List applist = appliList.updateApplicationStatus(); + observableApplication.clear(); + observableApplication.addAll(applist); + } + } + + @FXML + void handlerStartGeneric(ActionEvent event) { + + Runnable task1 = + () -> { + List applist = appliList.updateApplicationStatus(); + observableApplication.clear(); + observableApplication.addAll(applist); + }; + scheduledFuture = ses.scheduleAtFixedRate(task1, delayRefresh, delayRefresh, TimeUnit.MINUTES); + appliList.startApplication(); + } + + @FXML + void handlerAddMode(ActionEvent event) {} + + @FXML + void handlerLoadMode(ActionEvent event) { + FileChooser fileChooser = new FileChooser(); + Path currRelativePath = Paths.get(""); + String currAbsolutePathString = currRelativePath.toAbsolutePath().toString(); + System.out.println("Current absolute path is - " + currAbsolutePathString); + fileChooser + .getExtensionFilters() + .addAll( + new FileChooser.ExtensionFilter("Json Files", "*.json"), + new FileChooser.ExtensionFilter("Text Files", "*.txt")); + fileChooser.setInitialDirectory(new File(currAbsolutePathString)); + File selectedDirectory = fileChooser.showOpenDialog(primaryStage); + + if (selectedDirectory != null) { + System.out.println(selectedDirectory.getAbsolutePath()); + collectionMode.clear(); + collectionMode.load(selectedDirectory.getAbsolutePath()); + observableModulationMode.clear(); + observableModulationMode.addAll(collectionMode.values()); + tvModulationMode.setItems(observableModulationMode); + + } else { + System.out.println("no file selected"); + } + + System.out.println("Load"); + } + + @FXML + void handlerSaveMode(ActionEvent event) { + + // List setApp = appliList.getListApplication(); + System.out.println("save mode"); + FileChooser fileChooser = new FileChooser(); + Path currRelativePath = Paths.get(""); + String currAbsolutePathString = currRelativePath.toAbsolutePath().toString(); + System.out.println("Current absolute path is - " + currAbsolutePathString); + fileChooser + .getExtensionFilters() + .addAll( + new FileChooser.ExtensionFilter("Json Files", "*.json"), + new FileChooser.ExtensionFilter("Text Files", "*.txt")); + fileChooser.setInitialDirectory(new File(currAbsolutePathString)); + File selectedFile = fileChooser.showSaveDialog(primaryStage); + if (selectedFile != null) { + collectionMode.save(selectedFile.getAbsolutePath()); + } else { + System.out.println("no file selected"); + } + } + + /** + * ******************************************************************************************* + * Gestion des satellites + */ + @FXML + void handlerSatelliteLoadFile(ActionEvent event) { + FileChooser fileChooser = new FileChooser(); + Path currRelativePath = Paths.get(""); + String currAbsolutePathString = currRelativePath.toAbsolutePath().toString(); + System.out.println("Current absolute path is - " + currAbsolutePathString); + fileChooser + .getExtensionFilters() + .addAll( + new FileChooser.ExtensionFilter("Json Files", "*.json"), + new FileChooser.ExtensionFilter("Text Files", "*.txt")); + fileChooser.setInitialDirectory(new File(currAbsolutePathString)); + File selectedDirectory = fileChooser.showOpenDialog(primaryStage); + + if (selectedDirectory != null) { + System.out.println(selectedDirectory.getAbsolutePath()); + mngSat.load(selectedDirectory.getAbsolutePath()); + observableSatellite.clear(); + observableSatellite.addAll(mngSat.getSatellites()); + + } else { + System.out.println("no file selected"); + } + + System.out.println("Load"); + } + + @FXML + void HandlerDeselecyAll(ActionEvent event) { + for (SatelliteInformationInterface satellite : observableSatellite) { + satellite.setSelected(false); + } + tvSatellites.refresh(); + } + + @FXML + void handlerSatelliteSaveFile(ActionEvent event) { + System.out.println("save "); + FileChooser fileChooser = new FileChooser(); + Path currRelativePath = Paths.get(""); + String currAbsolutePathString = currRelativePath.toAbsolutePath().toString(); + System.out.println("Current absolute path is - " + currAbsolutePathString); + fileChooser + .getExtensionFilters() + .addAll( + new FileChooser.ExtensionFilter("Json Files", "*.json"), + new FileChooser.ExtensionFilter("Text Files", "*.txt")); + fileChooser.setInitialDirectory(new File(currAbsolutePathString)); + File selectedFile = fileChooser.showSaveDialog(primaryStage); + if (selectedFile != null) { + + mngSat.save(selectedFile.getAbsolutePath()); + } else { + System.out.println("no file selected"); + } + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/application/SecondaryController.java b/ApplicationJMultisat/src/main/java/org/josast/application/SecondaryController.java new file mode 100644 index 0000000000000000000000000000000000000000..ebc92e04bdb148fd79dc35b72a08a4afdf5ff024 --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/application/SecondaryController.java @@ -0,0 +1,12 @@ +package org.josast.application; + +import java.io.IOException; +import javafx.fxml.FXML; + +public class SecondaryController { + + @FXML + private void switchToPrimary() throws IOException { + App.setRoot("primary"); + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/hamlib/ManagePass.java b/ApplicationJMultisat/src/main/java/org/josast/hamlib/ManagePass.java new file mode 100644 index 0000000000000000000000000000000000000000..7d86463e751042f7dac9d24cd6c63f472b9324a8 --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/hamlib/ManagePass.java @@ -0,0 +1,75 @@ +package org.josast.hamlib; + +import java.io.IOException; +import java.util.Date; +import java.util.Timer; +import java.util.TimerTask; + +public class ManagePass { + private RotorController rotorController; + private TransceiverController transceiverController; + private Date aos; + private Date los; + private SatellitePositionCalculator positionCalculator; + + public ManagePass( + String rotorIpAddress, + int rotorPort, + String transceiverIpAddress, + int transceiverPort, + Date aos, + Date los, + SatellitePositionCalculator positionCalculator) + throws IOException { + // Initialiser les contrôleurs de rotor et de transceiver + rotorController = new RotorController(rotorIpAddress, rotorPort); + transceiverController = new TransceiverController(transceiverIpAddress, transceiverPort); + + // Enregistrer les dates de début AOS et de fin LOS du passage et le calculateur de position du + // satellite + this.aos = aos; + this.los = los; + this.positionCalculator = positionCalculator; + } + + public void start() { + // Créer une tâche pour envoyer la fréquence corrigée du doppler chaque seconde pendant le + // passage + TimerTask transceiverTask = + new TimerTask() { + @Override + public void run() { + try { + // Calculer la fréquence corrigée du doppler en temps réel + double frequency = positionCalculator.getCorrectedFrequency(); + + // Envoyer la fréquence corrigée du doppler vers le transceiver + transceiverController.setFrequency(frequency); + } catch (IOException e) { + e.printStackTrace(); + } + } + }; + + // Planifier la tâche pour s'exécuter chaque seconde pendant le passage + Timer timer = new Timer(); + timer.schedule(transceiverTask, aos, 1000); + + // Créer une tâche pour fermer les connexions à la fin du passage + TimerTask closeTask = + new TimerTask() { + @Override + public void run() { + try { + rotorController.close(); + transceiverController.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + }; + + // Planifier la tâche pour s'exécuter à la date de fin LOS du passage + timer.schedule(closeTask, los); + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/hamlib/RotorController.java b/ApplicationJMultisat/src/main/java/org/josast/hamlib/RotorController.java new file mode 100644 index 0000000000000000000000000000000000000000..2f71859dcbe15f37fcc6cd445c2f79d8d8d9d63e --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/hamlib/RotorController.java @@ -0,0 +1,137 @@ +package org.josast.hamlib; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; + +public class RotorController { + private Socket socket; + private OutputStream outputStream; + private InputStream inputStream; + + public RotorController(String ipAddress, int port) throws IOException { + // Ouvrir une connexion socket vers le serveur ROTCTLD + socket = new Socket(ipAddress, port); + + // Créer un flux de sortie pour envoyer des commandes + outputStream = socket.getOutputStream(); + + // Créer un flux d'entrée pour recevoir les réponses + inputStream = socket.getInputStream(); + } + + public void setPosition(double azimuth, double elevation) throws IOException { + // Envoyer une commande au serveur ROTCTLD pour définir la position du rotor + String command = "P " + azimuth + " " + elevation + "\n"; + outputStream.write(command.getBytes()); + + // Lire la réponse du serveur ROTCTLD + byte[] buffer = new byte[1024]; + int bytesRead = inputStream.read(buffer); + String response = new String(buffer, 0, bytesRead); + + // Vérifier si la commande a été exécutée avec succès + if (!response.startsWith("RPRT 0")) { + throw new IOException("Failed to set rotor position: " + response); + } + } + + public void setSpeed(int speed) throws IOException { + // Envoyer une commande au serveur ROTCTLD pour définir la vitesse de rotation du rotor + String command = "S " + speed + "\n"; + outputStream.write(command.getBytes()); + + // Lire la réponse du serveur ROTCTLD + byte[] buffer = new byte[1024]; + int bytesRead = inputStream.read(buffer); + String response = new String(buffer, 0, bytesRead); + + // Vérifier si la commande a été exécutée avec succès + if (!response.startsWith("RPRT 0")) { + throw new IOException("Failed to set rotor speed: " + response); + } + } + + public void stop() throws IOException { + // Envoyer une commande au serveur ROTCTLD pour arrêter le rotor + String command = "H\n"; + outputStream.write(command.getBytes()); + + // Lire la réponse du serveur ROTCTLD + byte[] buffer = new byte[1024]; + int bytesRead = inputStream.read(buffer); + String response = new String(buffer, 0, bytesRead); + + // Vérifier si la commande a été exécutée avec succès + if (!response.startsWith("RPRT 0")) { + throw new IOException("Failed to stop rotor: " + response); + } + } + + public void close() throws IOException { + // Fermer la connexion socket + socket.close(); + } + + public void emergencyStop() { + try { + // Envoyer une commande au serveur ROTCTLD pour mettre en sécurité le rotor + String command = "M\n"; + outputStream.write(command.getBytes()); + + // Lire la réponse du serveur ROTCTLD + byte[] buffer = new byte[1024]; + int bytesRead = inputStream.read(buffer); + String response = new String(buffer, 0, bytesRead); + + // Vérifier si la commande a été exécutée avec succès + if (!response.startsWith("RPRT 0")) { + System.err.println("Failed to put rotor in emergency stop: " + response); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + // Fermer la connexion socket + socket.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + public double[] getPosition() throws IOException { + // Envoyer une commande au serveur ROTCTLD pour obtenir la position actuelle du rotor + String command = "p\n"; + outputStream.write(command.getBytes()); + + // Lire la réponse du serveur ROTCTLD + byte[] buffer = new byte[1024]; + int bytesRead = inputStream.read(buffer); + String response = new String(buffer, 0, bytesRead); + System.out.println(response); + // Vérifier si la commande a été exécutée avec succès + // if (!response.startsWith("RPRT 0")) { + // throw new IOException("Failed to get rotor position: " + response); + // } + + // Extraire la position du rotor de la réponse + String[] parts = response.split("\n"); + double azimuth = Double.parseDouble(parts[0]); + double elevation = Double.parseDouble(parts[1]); + + return new double[] {azimuth, elevation}; + } + + public static void main(String args[]) throws IOException { + + RotorController rot = new RotorController("127.0.0.1", 4533); + // rot.emergencyStop(); + double[] value = rot.getPosition(); + System.out.println(value); + rot.setPosition(10.0, 20.0); + value = rot.getPosition(); + System.out.println(value); + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/hamlib/SatellitePositionCalculator.java b/ApplicationJMultisat/src/main/java/org/josast/hamlib/SatellitePositionCalculator.java new file mode 100644 index 0000000000000000000000000000000000000000..ad84ec986f9b35aa4ac9e68f3327ecc13cbea963 --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/hamlib/SatellitePositionCalculator.java @@ -0,0 +1,9 @@ +package org.josast.hamlib; + +public class SatellitePositionCalculator { + + public double getCorrectedFrequency() { + // TODO Auto-generated method stub + return 0; + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/hamlib/TransceiverController.java b/ApplicationJMultisat/src/main/java/org/josast/hamlib/TransceiverController.java new file mode 100644 index 0000000000000000000000000000000000000000..cb3cd6869476b043a0dbd0568a1adc14ccf3f439 --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/hamlib/TransceiverController.java @@ -0,0 +1,127 @@ +package org.josast.hamlib; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; + +public class TransceiverController { + private Socket socket; + private OutputStream outputStream; + private InputStream inputStream; + + public TransceiverController(String ipAddress, int port) throws IOException { + // Ouvrir une connexion socket vers le transceiver + socket = new Socket(ipAddress, port); + + // Créer un flux de sortie pour envoyer des commandes + outputStream = socket.getOutputStream(); + + // Créer un flux d'entrée pour recevoir les réponses + inputStream = socket.getInputStream(); + } + + public void setFrequency(double frequency) throws IOException { + // Envoyer une commande au transceiver pour définir la fréquence + String command = "F " + frequency + "\n"; + outputStream.write(command.getBytes()); + + // Lire la réponse du transceiver + byte[] buffer = new byte[1024]; + int bytesRead = inputStream.read(buffer); + String response = new String(buffer, 0, bytesRead); + + // Vérifier si la commande a été exécutée avec succès + if (!response.startsWith("RPRT 0")) { + throw new IOException("Failed to set frequency: " + response); + } + } + + public void setMode(String mode) throws IOException { + // Envoyer une commande au transceiver pour définir le mode + String command = "M " + mode + "\n"; + outputStream.write(command.getBytes()); + + // Lire la réponse du transceiver + byte[] buffer = new byte[1024]; + int bytesRead = inputStream.read(buffer); + String response = new String(buffer, 0, bytesRead); + + // Vérifier si la commande a été exécutée avec succès + if (!response.startsWith("RPRT 0")) { + throw new IOException("Failed to set mode: " + response); + } + } + + public String getMode() throws IOException { + // Envoyer une commande au transceiver pour obtenir le mode + String command = "m\n"; + outputStream.write(command.getBytes()); + + // Lire la réponse du transceiver + byte[] buffer = new byte[1024]; + int bytesRead = inputStream.read(buffer); + String response = new String(buffer, 0, bytesRead); + + // Vérifier si la commande a été exécutée avec succès + if (!response.startsWith("RPRT 0")) { + throw new IOException("Failed to get mode: " + response); + } + + // Extraire le mode de la réponse + String[] parts = response.split(" "); + return parts[2]; + } + + public double getFrequency() throws IOException { + // Envoyer une commande au transceiver pour obtenir la fréquence + String command = "f\n"; + outputStream.write(command.getBytes()); + + // Lire la réponse du transceiver + byte[] buffer = new byte[1024]; + int bytesRead = inputStream.read(buffer); + String response = new String(buffer, 0, bytesRead); + + // Vérifier si la commande a été exécutée avec succès + if (!response.startsWith("RPRT 0")) { + throw new IOException("Failed to get frequency: " + response); + } + + // Extraire la fréquence de la réponse + String[] parts = response.split(" "); + return Double.parseDouble(parts[2]); + } + + public void close() throws IOException { + // Fermer la connexion socket + socket.close(); + } + + public void emergencyStop() { + try { + // Envoyer une commande au transceiver pour mettre en sécurité le transceiver + String command = "M 0\n"; + outputStream.write(command.getBytes()); + + // Lire la réponse du transceiver + byte[] buffer = new byte[1024]; + int bytesRead = inputStream.read(buffer); + String response = new String(buffer, 0, bytesRead); + + // Vérifier si la commande a été exécutée avec succès + if (!response.startsWith("RPRT 0")) { + System.err.println("Failed to put transceiver in emergency stop: " + response); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + // Fermer la connexion socket + socket.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/keplerelement/AbstractKeplerienElement.java b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/AbstractKeplerienElement.java new file mode 100644 index 0000000000000000000000000000000000000000..fc2383da168169b59a3611558e3909c93df83e12 --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/AbstractKeplerienElement.java @@ -0,0 +1,304 @@ +package org.josast.keplerelement; + +import org.josast.satellitePrediction.KeplerianElementTwoLineInterface; + +/** @author XTOPHE */ +public abstract class AbstractKeplerienElement + implements IkeplerienElement, KeplerianElementTwoLineInterface { + + protected String[] twoLine = null; + /** */ + protected String name = null; + + /** */ + protected double _EpochOrbit = 0; + + /** */ + protected double _JulianDate = 0; + + /** */ + protected double _MeanMotion = 0; + + /** */ + protected double _BSTAR = 0; + + /** */ + protected double _InclinationRadian = 0; + + /** */ + protected double _Eccentricity = 0; + + /** */ + protected double _MeanAnomalyRadian = 0; + + /** */ + protected double _ArgumentOfPerigeeRadian = 0; + + /** */ + protected double _RightAccensionRadian = 0; + + /** */ + protected double _FirstTimeDerivative = 0; + + /** */ + protected double _SecondTimeDerivative = 0; + + /** */ + protected int _SatNum = 0; + + protected int orbitnum; + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#getArgumentOfPerigeeRadian() + */ + @Override + public double getArgumentOfPerigeeRadian() { + return _ArgumentOfPerigeeRadian; + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#getBSTAR() + */ + @Override + public double getBSTAR() { + return _BSTAR; + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#getEccentricity() + */ + @Override + public double getEccentricity() { + return _Eccentricity; + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#getEpochOrbit() + */ + @Override + public double getEpochOrbit() { + return _EpochOrbit; + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#getFirstTimeDerivative() + */ + @Override + public double getFirstTimeDerivative() { + return _FirstTimeDerivative; + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#getInclinationRadian() + */ + @Override + public double getInclinationRadian() { + return _InclinationRadian; + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#getJulianDate() + */ + @Override + public double getJulianDate() { + return _JulianDate; + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#getMeanAnomalyRadian() + */ + @Override + public double getMeanAnomalyRadian() { + return _MeanAnomalyRadian; + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#getMeanMotion() + */ + @Override + public double getMeanMotion() { + return _MeanMotion; + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#getMeanPeriod() + */ + @Override + public double getMeanPeriod() { + return (24 / _MeanMotion); + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#getName() + */ + @Override + public String getName() { + return name; + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#getOrbitnum() + */ + @Override + public int getOrbitnum() { + return orbitnum; + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#getRightAccensionRadian() + */ + @Override + public double getRightAccensionRadian() { + return _RightAccensionRadian; + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#getSatelliteNumber() + */ + @Override + public int getSatelliteNumber() { + return _SatNum; + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#getSecondTimeDerivative() + */ + @Override + public double getSecondTimeDerivative() { + return _SecondTimeDerivative; + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#isGeostationary() + */ + @Override + public boolean isGeostationary() { + if (Math.abs(_MeanAnomalyRadian - Math.toRadians(1.0027)) < 0.0002) { + return true; + } else { + return false; + } + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#setArgumentOfPerigeeRadian(double) + */ + @Override + public void setArgumentOfPerigeeRadian(double argumentOfPerigeeRadian) { + _ArgumentOfPerigeeRadian = argumentOfPerigeeRadian; + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#setBSTAR(double) + */ + @Override + public void setBSTAR(double bstar) { + _BSTAR = bstar; + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#setEccentricity(double) + */ + @Override + public void setEccentricity(double eccentricity) { + _Eccentricity = eccentricity; + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#setEpochOrbit(double) + */ + @Override + public void setEpochOrbit(double epochOrbit) { + _EpochOrbit = epochOrbit; + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#setFirstTimeDerivative(double) + */ + @Override + public void setFirstTimeDerivative(double FirstTimeDerivative) { + this._FirstTimeDerivative = FirstTimeDerivative; + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#setInclinationRadian(double) + */ + @Override + public void setInclinationRadian(double inclinationRadian) { + _InclinationRadian = inclinationRadian; + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#setJulianDate(double) + */ + @Override + public void setJulianDate(double julianDate) { + _JulianDate = julianDate; + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#setMeanAnomalyRadian(double) + */ + @Override + public void setMeanAnomalyRadian(double meanAnomalyRadian) { + _MeanAnomalyRadian = meanAnomalyRadian; + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#setMeanMotion(double) + */ + @Override + public void setMeanMotion(double meanMotion) { + _MeanMotion = meanMotion; + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#setOrbitnum(int) + */ + @Override + public void setOrbitnum(int orbitnum) { + this.orbitnum = orbitnum; + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#setRightAccensionRadian(double) + */ + @Override + public void setRightAccensionRadian(double rightAccensionRadian) { + _RightAccensionRadian = rightAccensionRadian; + } + + /* (non-Javadoc) + * @see org.avmdti.josast.keplerelement.IkeplerienElement#setSecondTimeDerivative(double) + */ + @Override + public void setSecondTimeDerivative(double secondTimeDerivative) { + _SecondTimeDerivative = secondTimeDerivative; + } + + @Override + public double getArgumentOfPerigeeDegree() { + return Math.toDegrees(this._ArgumentOfPerigeeRadian); + } + + @Override + public double getInclinationDegree() { + return Math.toDegrees(this._InclinationRadian); + } + + @Override + public double getMeanAnomalyDegree() { + return Math.toDegrees(this._MeanAnomalyRadian); + } + + @Override + public double getRightAccensionDegree() { + return Math.toDegrees(this._RightAccensionRadian); + } + + @Override + public String[] getTwoline() { + + return this.twoLine; + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/keplerelement/IKelplerianElementManager.java b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/IKelplerianElementManager.java new file mode 100644 index 0000000000000000000000000000000000000000..99fc8058fea3c71189ccb9f320b26715e762b687 --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/IKelplerianElementManager.java @@ -0,0 +1,12 @@ +package org.josast.keplerelement; + +import org.josast.satellite.SatelliteInformationInterface; + +public interface IKelplerianElementManager { + + public String[] getListeSatelliteName(); + + public IkeplerienElement getSatelliteKeplerianElement(String satname); + + public SatelliteInformationInterface[] getSatelliteInformation(); +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/keplerelement/IkeplerienElement.java b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/IkeplerienElement.java new file mode 100644 index 0000000000000000000000000000000000000000..71c2d4b64a169cc3f21bd75894857389387d9d9e --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/IkeplerienElement.java @@ -0,0 +1,355 @@ +package org.josast.keplerelement; + +/** + * Description : this interface gives acces to the TLE field.
+ * Some data should be available in Degree or Radian
+ * * + * + *

NORAD Two-Line Element Set Format

+ * + *

Data for each satellite consists of three lines in the following format: + * + *

+ * AAAAAAAAAAAAAAAAAAAAAAAA
+ * 1 NNNNNU NNNNNAAA NNNNN.NNNNNNNN +.NNNNNNNN +NNNNN-N +NNNNN-N N NNNNN
+ * 2 NNNNN NNN.NNNN NNN.NNNN NNNNNNN NNN.NNNN NNN.NNNN NN.NNNNNNNNNNNNNN
+ * 
+ * + *

Line 0 is a twenty-four character name (to be consistent with the name length in the NORAD + * SATCAT). + * + *

Lines 1 and 2 are the standard Two-Line Orbital Element Set Format identical to that used by + * NORAD and NASA. The format description is:

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Line 1
ColumnDescription
01Line Number of Element Data
03-07Satellite Number
08Classification (U=Unclassified)
10-11International Designator (Last two digits of launch year)
12-14International Designator (Launch number of the year)
15-17International Designator (Piece of the launch)
19-20Epoch Year (Last two digits of year)
21-32Epoch (Day of the year and fractional portion of the day)
34-43First Time Derivative of the Mean Motion
45-52Second Time Derivative of Mean Motion (decimal point assumed)
54-61BSTAR drag term (decimal point assumed)
63Ephemeris type
65-68Element number
69Checksum (Modulo 10)
+ * (Letters, blanks, periods, plus signs = 0; minus signs = 1)
+ * + *
+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Line 2
ColumnDescription
01Line Number of Element Data
03-07Satellite Number
09-16Inclination [Degrees]
18-25Right Ascension of the Ascending Node [Degrees]
27-33Eccentricity (decimal point assumed)
35-42Argument of Perigee [Degrees]
44-51Mean Anomaly [Degrees]
53-63Mean Motion [Revs per day]
64-68Revolution number at epoch [Revs]
69Checksum (Modulo 10)
+ * + *
+ * + *

All other columns are blank or fixed. + * + *

Example: + * + *

+ * NOAA 14
+ * 1 23455U 94089A   97320.90946019  .00000140  00000-0  10191-3 0  2621
+ * 2 23455  99.0090 272.6745 0008546 223.1686 136.8816 14.11711747148495
+ * 
+ * + *

For further information, see "Frequently Asked Questions: Two-Line + * Element Set Format" in the Computers & + * + *

Satellites column of Satellite Times, Volume 4 Number 3.


+ * + * @author XTOPHE + * @version 1.0 + *

Source Update
+ * Version : date : name : comments
+ * V1 : 27 juil. 2005 : C. Mercier : create file + *

+ */ +public interface IkeplerienElement { + + /** @return the satellite name. */ + public String getName(); + /** @return the satellite number (NORAD) */ + public int getSatelliteNumber(); + /** + * Returns the julianDate of the epoch. + * + * @return double + */ + public double getJulianDate(); + /** + * First Time Derivative of the Mean Motion + * + * @return Return FirstTimeDerivative. + */ + public double getFirstTimeDerivative(); + /** + * Returns the secondTimeDerivative. + * + * @return double + */ + public double getSecondTimeDerivative(); + /** + * Returns the bSTAR. + * + * @return double + */ + public double getBSTAR(); + /** + * Returns the inclinationRadian. + * + * @return double + */ + public double getInclinationRadian(); + /** + * Returns the rightAccensionRadian. + * + * @return double + */ + public double getInclinationDegree(); + /** + * Returns the rightAccensionDegree. + * + * @return double + */ + public double getRightAccensionRadian(); + /** + * Returns the RightAccension. + * + * @return double + */ + public double getRightAccensionDegree(); + /** + * Returns the eccentricity. + * + * @return double + */ + public double getEccentricity(); + /** + * Returns the argumentOfPerigeeRadian. + * + * @return double + */ + public double getArgumentOfPerigeeRadian(); + /** + * Returns the argumentOfPerigeeDegree. + * + * @return double + */ + public double getArgumentOfPerigeeDegree(); + /** + * Returns the meanAnomaly in Radian. + * + * @return double + */ + public double getMeanAnomalyRadian(); + /** + * Returns the meanAnomaly in Degree. + * + * @return double + */ + public double getMeanAnomalyDegree(); + /** + * Returns the meanMotion. + * + * @return double + */ + public double getMeanMotion(); + + public double getEpochOrbit(); + + public int getOrbitnum(); + /** @return */ + public double getMeanPeriod(); + + /** @param FirstTimeDerivative */ + public void setFirstTimeDerivative(double FirstTimeDerivative); + /** @param _EpochOrbit */ + public void setEpochOrbit(double _EpochOrbit); + /** + * return true if the satellite is geostationary. + * + * @return true = satellite is geostationary + */ + public boolean isGeostationary(); + /** + * Surcharge de la methode toString + * + * @return String + */ + public String toString(); + + public void setArgumentOfPerigeeRadian(double argumentOfPerigeeRadian); + /** + * Sets the bSTAR. + * + * @param bSTAR The bSTAR to set + */ + public void setBSTAR(double bSTAR); + /** + * Sets the eccentricity. + * + * @param eccentricity The eccentricity to set + */ + public void setEccentricity(double eccentricity); + /** + * Sets the inclinationRadian. + * + * @param inclinationRadian The inclinationRadian to set + */ + public void setInclinationRadian(double inclinationRadian); + /** + * Sets the meanAnomalyRadian. + * + * @param meanAnomalyRadian The meanAnomalyRadian to set + */ + public void setMeanAnomalyRadian(double meanAnomalyRadian); + /** + * Sets the meanMotion. + * + * @param meanMotion The meanMotion to set + */ + public void setMeanMotion(double meanMotion); + /** + * Sets the rightAccensionRadian. + * + * @param rightAccensionRadian The rightAccensionRadian to set + */ + public void setRightAccensionRadian(double rightAccensionRadian); + /** + * Sets the secondTimeDerivative. + * + * @param secondTimeDerivative The secondTimeDerivative to set + */ + public void setSecondTimeDerivative(double secondTimeDerivative); + + /** + * Sets the julianDate. + * + * @param julianDate The julianDate to set + */ + public void setJulianDate(double julianDate); + /** @param orbitnum The orbitnum to set. */ + public void setOrbitnum(int orbitnum); + + public int getEpochYear(); + + public double getEpochDay(); + + public String[] getTwoline(); +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/keplerelement/KeplerianElementCollection.java b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/KeplerianElementCollection.java new file mode 100644 index 0000000000000000000000000000000000000000..796dcfd0075702d85bab45240aff620f7f7243e4 --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/KeplerianElementCollection.java @@ -0,0 +1,23 @@ +package org.josast.keplerelement; + +import java.util.HashMap; +import java.util.Map; + +public class KeplerianElementCollection extends HashMap { + + private static final long serialVersionUID = 1L; + + public KeplerianElementCollection() {} + + public KeplerianElementCollection(int initialCapacity) { + super(initialCapacity); + } + + public KeplerianElementCollection(Map m) { + super(); + } + + public KeplerianElementCollection(int initialCapacity, float loadFactor) { + super(initialCapacity, loadFactor); + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/keplerelement/KeplerienElement.java b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/KeplerienElement.java new file mode 100644 index 0000000000000000000000000000000000000000..a04b0e04cb5110a6c9437850c55db4d3082d2386 --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/KeplerienElement.java @@ -0,0 +1,208 @@ +package org.josast.keplerelement; + +import org.josast.keplerelement.file.Read2line; +import org.josast.keplerelement.util.JulianDay; +import org.josast.keplerelement.util.ParseCharArray; + +/** + * @author xtophe + * @version 1.0 + */ +public class KeplerienElement extends AbstractKeplerienElement { + + /** */ + private static final double _ae = 1.0; + + // ~ Instance fields --------------------------------------------------- + + // ~ Constructors ------------------------------------------------------ + + /** */ + public KeplerienElement() {} + + /** + * Set keplerian element. + * + * @param EpochTime + * @param Inclination + * @param Eccentricity + * @param MeanMotion + * @param ArgumentOfPerigee in radian + * @param MeanAnomaly in radian + * @param RightAccension in radian + * @param EpochOrbit + * @param FirstTimeDerivative + * @param SecondTimeDerivative + * @param BSTAR + */ + public KeplerienElement( + double Inclination, + double Eccentricity, + double MeanMotion, + double ArgumentOfPerigee, + double MeanAnomaly, + double RightAccension, + double EpochOrbit, + double FirstTimeDerivative, + double SecondTimeDerivative, + double BSTAR) { + _InclinationRadian = Math.toRadians(Inclination); + _Eccentricity = Eccentricity; + _MeanMotion = MeanMotion; + _RightAccensionRadian = Math.toRadians(RightAccension); + _ArgumentOfPerigeeRadian = Math.toRadians(ArgumentOfPerigee); + _FirstTimeDerivative = FirstTimeDerivative; + _SecondTimeDerivative = SecondTimeDerivative; + _BSTAR = BSTAR; + _MeanAnomalyRadian = Math.toRadians(MeanAnomaly); + _EpochOrbit = EpochOrbit; + } + + /** + * ------------------------------------------------------------------- ----------------------- + * Convert_Satellite_Data -------------------- + * ------------------------------------------------------------------- + * + * @param tle + */ + public KeplerienElement(Read2line tle) { + int iexp; + int ibexp; + name = new String(tle.l[0]).trim(); + + twoLine = tle.getStrings(); + + /* first line */ + _SatNum = ParseCharArray.integer_value(tle.l[1], 1, 6); + _EpochOrbit = ParseCharArray.double_value(tle.l[1], 18, 14); + _JulianDate = JulianDay.convertToJulianDay(_EpochOrbit); + _FirstTimeDerivative = ParseCharArray.double_value(tle.l[1], 33, 10); + _SecondTimeDerivative = ParseCharArray.double_value(tle.l[1], 44, 6) * 1.0E-5; + iexp = ParseCharArray.integer_value(tle.l[1], 50, 2); + _BSTAR = ParseCharArray.double_value(tle.l[1], 53, 6) * 1.0E-5; + ibexp = ParseCharArray.integer_value(tle.l[1], 59, 2); + + /* second line */ + _InclinationRadian = ParseCharArray.double_value(tle.l[2], 8, 8); + _RightAccensionRadian = ParseCharArray.double_value(tle.l[2], 17, 8); + _Eccentricity = ParseCharArray.double_value(tle.l[2], 26, 7) * 1E-7; + _ArgumentOfPerigeeRadian = ParseCharArray.double_value(tle.l[2], 34, 8); + _MeanAnomalyRadian = ParseCharArray.double_value(tle.l[2], 43, 8); + _MeanMotion = ParseCharArray.double_value(tle.l[2], 52, 11); + orbitnum = ParseCharArray.integer_value(tle.l[2], 63, 5); + /* Convert to proper units */ + // _SecondTimeDerivative = (_SecondTimeDerivative) * Math.pow(10.0, + // -iexp); + _SecondTimeDerivative = (_SecondTimeDerivative) * Math.pow(10.0, iexp); + + // _BSTAR = ((_BSTAR) * Math.pow(10.0, -ibexp)) / _ae; + _BSTAR = ((_BSTAR) * Math.pow(10.0, -ibexp)) / _ae; + _RightAccensionRadian = Math.toRadians(_RightAccensionRadian); + _ArgumentOfPerigeeRadian = Math.toRadians(_ArgumentOfPerigeeRadian); + _MeanAnomalyRadian = Math.toRadians(_MeanAnomalyRadian); + _InclinationRadian = Math.toRadians(_InclinationRadian); + // _MeanMotion = ((_MeanMotion) * 2.0 * Math.PI) / _xmnpda; + // _FirstTimeDerivative = ((_FirstTimeDerivative) * 2.0 * Math.PI) / MathTools.sqr(_xmnpda); + // _SecondTimeDerivative = ((_SecondTimeDerivative) * 2.0 * Math.PI) / + // MathTools.cube(_xmnpda); + + } + + public String toString() { + return toStringAll(); + } + + public String toStringAll() { + String s = "Satellite name :" + name + "\n"; + s = s + "Satellite Number :" + _SatNum + "\n"; + s = + s + + "Right Accension :" + + Math.toDegrees(_RightAccensionRadian) + + " Degrees\n"; + s = + s + + "Inclination :" + + Math.toDegrees(_InclinationRadian) + + " Degrees\n"; + s = s + "Eccentricity :" + _Eccentricity + " Degrees \n"; + s = s + "Mean Motion :" + _MeanMotion + " Revs per day\n"; + s = s + "Epoch Time :" + this._JulianDate + "\n"; + s = s + "Epoch Orbit :" + _EpochOrbit + "\n"; + s = + s + + "Argument Of Perigee :" + + Math.toDegrees(_ArgumentOfPerigeeRadian) + + " Degrees\n"; + s = + s + + "Mean Anomaly :" + + Math.toDegrees(_MeanAnomalyRadian) + + " Degrees\n"; + s = s + "First Time Derivative of Mean Motion :" + _FirstTimeDerivative + "\n"; + s = s + "Second Time Derivative of Mean Motion :" + _SecondTimeDerivative + "\n"; + s = s + "BSTAR drag term :" + _BSTAR + "\n"; + + return (s); + } + + /** @return */ + public String toStringXML() { + String s = " \n "; + + // s =s+"\t"+ _name+"\n"; + s = s + "\t" + _SatNum + "\n"; + s = s + "\t" + Math.toDegrees(_RightAccensionRadian) + "\n"; + s = s + "\t" + Math.toDegrees(_InclinationRadian) + "\n"; + s = s + "\t" + _Eccentricity + "\n"; + s = s + "\t" + _MeanMotion + "\n"; + s = s + "\t" + this._JulianDate + "\n"; + s = + s + + "\t" + + Math.toDegrees(_ArgumentOfPerigeeRadian) + + "\n"; + s = s + "\t" + Math.toDegrees(_MeanAnomalyRadian) + "\n"; + s = + s + + "\t" + + _FirstTimeDerivative + + "\n"; + s = + s + + "\t" + + _SecondTimeDerivative + + "\n"; + s = s + "\t" + _BSTAR + "\n"; + s = s + "\n"; + + return (s); + } + + @Override + public double getEpochDay() { + return (_EpochOrbit - (Math.floor(_EpochOrbit * 1.0E-3)) * 1.0E3); + } + + @Override + public int getEpochYear() { + + int year = (int) Math.floor(_EpochOrbit * 1.0E-3); + if (year < 57) year += 2000; + else year += 1900; + + return year; + } + + @Override + public String[] getTwoLine() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void setTwoLine(String twoLine) { + // TODO Auto-generated method stub + + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/keplerelement/celestrak/KeplerianElementManager.java b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/celestrak/KeplerianElementManager.java new file mode 100644 index 0000000000000000000000000000000000000000..82f7b77cb2c7e1c2f4a4753561015e3a518b149a --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/celestrak/KeplerianElementManager.java @@ -0,0 +1,64 @@ +package org.josast.keplerelement.celestrak; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.josast.keplerelement.IKelplerianElementManager; +import org.josast.keplerelement.IkeplerienElement; +import org.josast.satellite.SatelliteInformationInterface; + +/** manage a collection of keplerian element */ +public class KeplerianElementManager implements IKelplerianElementManager { + + private Map elementsMap; + + public KeplerianElementManager() { + elementsMap = new HashMap<>(); + } + + public void addSatellite(long satelliteId) { + TleDataRetriever retriever = new TleDataRetriever(); + String elements = retriever.getTle(satelliteId); + elementsMap.put(satelliteId, elements); + } + + public void updateSatellite(long satelliteId) { + TleDataRetriever retriever = new TleDataRetriever(); + String elements = retriever.getTle(satelliteId); + elementsMap.put(satelliteId, elements); + } + + public void updateAllSatellites() { + for (long satelliteId : elementsMap.keySet()) { + updateSatellite(satelliteId); + } + } + + public List getSatelliteIds() { + return new ArrayList<>(elementsMap.keySet()); + } + + public String getElements(long satelliteId) { + return elementsMap.get(satelliteId); + } + + @Override + public String[] getListeSatelliteName() { + // TODO Auto-generated method stub + return null; + } + + @Override + public IkeplerienElement getSatelliteKeplerianElement(String satname) { + // TODO Auto-generated method stub + return null; + } + + @Override + public SatelliteInformationInterface[] getSatelliteInformation() { + // TODO Auto-generated method stub + return null; + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/keplerelement/celestrak/TleDataRetriever.java b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/celestrak/TleDataRetriever.java new file mode 100644 index 0000000000000000000000000000000000000000..3e21d2c11dab8189d0aa10d1d0465349b6b12838 --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/celestrak/TleDataRetriever.java @@ -0,0 +1,70 @@ +package org.josast.keplerelement.celestrak; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; + +public class TleDataRetriever { + + private long satelliteID; + + private String apiUrlBaseCelestrack = "https://celestrak.org/"; + private String apiUrlQueyCelestrack = "NORAD/elements/gp.php?CATNR="; + private String apiUrlOptionCelestrack = "&FORMAT=TLE"; + + public TleDataRetriever() {} + + public String getTle(long satelliteId) { + String apiUrl = + apiUrlBaseCelestrack + apiUrlQueyCelestrack + satelliteId + apiUrlOptionCelestrack; + URL url = null; + HttpURLConnection connection = null; + BufferedReader reader = null; + StringBuilder response = null; + try { + url = new URL(apiUrl); + } catch (java.net.MalformedURLException e) { + System.out.println(e); + } + // Open a connection to the API URL + try { + connection = (HttpURLConnection) url.openConnection(); + + } catch (java.io.IOException e) { + System.out.println(e); + } + + try { + connection.setRequestMethod("GET"); + + } catch (java.io.IOException e) { + System.out.println(e); + } + + // Read the response from the API + try { + reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String line; + response = new StringBuilder(); + while ((line = reader.readLine()) != null) { + response.append(line); + response.append("\n"); + } + reader.close(); + + } catch (java.io.IOException e) { + System.out.println(e); + } + + return response.toString(); + } + + public static void main(String[] args) { + + TleDataRetriever tdr = new TleDataRetriever(); + + System.out.println(tdr.getTle(25544)); + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/keplerelement/demo/Demo.java b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/demo/Demo.java new file mode 100644 index 0000000000000000000000000000000000000000..f778a91df227c6da2e112e80b2930521d139001b --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/demo/Demo.java @@ -0,0 +1,30 @@ +/* + * Created on Jul 22, 2004 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package org.josast.keplerelement.demo; + +import org.josast.keplerelement.file.KeplerianFileManager; + +/** + * DOCUMENT ME! + * + * @author mercier TODO To change the template for this generated type comment go to Window - + * Preferences - Java - Code Style - Code Templates + */ +public class Demo { + // ~ Methods ----------------------------------------------------------- + + /** @param args DOCUMENT ME! */ + public static void main(String args[]) { + + KeplerianFileManager KFM = new KeplerianFileManager("amateur.txt"); + System.out.println("number of satellite : " + KFM.getNumberOfSatellite()); + for (int i = 0; i < KFM.getNumberOfSatellite(); i++) { + System.out.println(KFM.getListeSatelliteName()[i]); + System.out.println(KFM.getSatelliteKeplerianElement(KFM.getListeSatelliteName()[i])); + } + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/keplerelement/demo/DisplayAltitude.java b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/demo/DisplayAltitude.java new file mode 100644 index 0000000000000000000000000000000000000000..7df53ec57f8546ff65c8c9c117f4e62f1ab407a0 --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/demo/DisplayAltitude.java @@ -0,0 +1,17 @@ +package org.josast.keplerelement.demo; + +import org.josast.keplerelement.KeplerienElement; +import org.josast.keplerelement.file.Read2line; + +public class DisplayAltitude { + private static String Filename = "arissat.txt"; + + public static void main(String args[]) { + KeplerienElement KE; + Read2line tab[] = Read2line.readTleFile(Filename); + for (int i = 0; i < tab.length; i++) { + KE = new KeplerienElement(tab[i]); + System.out.println("" + KE.getOrbitnum() + ";" + KE.getMeanPeriod() + ";"); + } + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/keplerelement/file/KeplerianFileManager.java b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/file/KeplerianFileManager.java new file mode 100644 index 0000000000000000000000000000000000000000..6848d4f15f0c2bfecd5ff870e3099f3c0c9b1ea4 --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/file/KeplerianFileManager.java @@ -0,0 +1,112 @@ +package org.josast.keplerelement.file; + +/** + * Description :
+ * this class help to manage the kepleriens element from a text file + * + * @author XTOPHE + * @version 1.0 + *

date 9 mai 2004 + *

Source Update
+ * date : name : comments
+ * V1 : XTOPHE : create file + *

+ */ +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.logging.Logger; + +import org.josast.keplerelement.IkeplerienElement; +import org.josast.keplerelement.IKelplerianElementManager; +import org.josast.keplerelement.KeplerienElement; +import org.josast.satellite.SatelliteInformation; +import org.josast.satellite.SatelliteInformationInterface; + +public class KeplerianFileManager implements IKelplerianElementManager { + + private static Logger appLogger = Logger.getLogger("AmsatLogger"); + + private String listeSatellite[]; + private SatelliteInformationInterface satelliteInfo[]; + String _inputFileName = null; + Hashtable listeSatTLE = new Hashtable(); + TleCollection tlec; + + public KeplerianFileManager() {} + + /** @param inputFile 2 line text file. */ + public KeplerianFileManager(String inputFile) { + _inputFileName = inputFile; + load(); + } + + protected void load() { + tlec = new TleCollection(_inputFileName); + // read TLE + + Enumeration en = tlec.elements(); + int i = 0; + listeSatellite = new String[tlec.size()]; + satelliteInfo = new SatelliteInformationInterface[tlec.size()]; + while (en.hasMoreElements()) { + IkeplerienElement elt = en.nextElement(); + listeSatellite[i] = elt.getName(); + satelliteInfo[i] = new SatelliteInformation(elt.getName(), elt.getSatelliteNumber()); + listeSatTLE.put(elt.getName(), elt); + i = i + 1; + } + } + + /** + * get the list of satellite available. + * + * @return the list of satellite + */ + public String[] getListeSatelliteName() { + return listeSatellite.clone(); + } + + /** reload the current file. */ + public int reload() { + + int nb = tlec.update(_inputFileName); + listeSatTLE.clear(); + Enumeration en = tlec.elements(); + int i = 0; + + listeSatellite = new String[tlec.size()]; + while (en.hasMoreElements()) { + IkeplerienElement elt = en.nextElement(); + + listeSatellite[i++] = elt.getName(); + listeSatTLE.put(elt.getName(), elt); + } + return nb; + } + + /** + * return the TLE of the selected satellite. + * + * @return the TLE of the satellite. A default TLE is returned if the satellite do not exist. + */ + public IkeplerienElement getSatelliteKeplerianElement(String satname) { + + IkeplerienElement E = listeSatTLE.get(satname); + if (E == null) { + E = (IkeplerienElement) new KeplerienElement(); + appLogger.warning("satellite not found"); + } + return (E); + } + + /** @return the number of satellite available. */ + public int getNumberOfSatellite() { + return tlec.size(); + } + + @Override + public SatelliteInformationInterface[] getSatelliteInformation() { + + return satelliteInfo; + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/keplerelement/file/KeplerianFileManagerFromUrl.java b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/file/KeplerianFileManagerFromUrl.java new file mode 100644 index 0000000000000000000000000000000000000000..489bf8c2b8d6de05a18eb78cbf6c76d7b0bcc19a --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/file/KeplerianFileManagerFromUrl.java @@ -0,0 +1,31 @@ +package org.josast.keplerelement.file; + +import java.io.*; +import java.net.*; +import java.nio.channels.Channels; +import java.nio.channels.ReadableByteChannel; +import java.util.logging.Logger; + +public class KeplerianFileManagerFromUrl extends KeplerianFileManager { + + String url = "https://www.amsat.org/tle/current/dailytle.txt"; + String fileName = "dailytle.txt"; + private static Logger appLogger = Logger.getLogger("AmsatLogger"); + + public KeplerianFileManagerFromUrl() { + + try { + URL website = new URL(url); + ReadableByteChannel rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(fileName); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + appLogger.fine("File downloaded successfully."); + _inputFileName = fileName; + load(); + + } catch (IOException e) { + appLogger.severe("Error downloading file: " + e.getMessage()); + } + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/keplerelement/file/Read2line.java b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/file/Read2line.java new file mode 100644 index 0000000000000000000000000000000000000000..e25acfdb5bf9e7e5a62b39292366a0efbba912ec --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/file/Read2line.java @@ -0,0 +1,102 @@ +package org.josast.keplerelement.file; + +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; + +import java.util.Vector; +import java.util.logging.Logger; + +/** + * @author xtophe + * @version 1.0 + */ +public class Read2line { + + private static Logger appLogger = Logger.getLogger("AmsatLogger"); + // ~ Instance fields --------------------------------------------------- + + public char l[][] = new char[3][71]; + + // ~ Methods ----------------------------------------------------------- + + /** + * @param filename + * @return array of TleAsciiLine + */ + public static Read2line[] readTleFile(String filename) { + + Vector v = new Vector(); + FileReader inputFile = null; + + try { + inputFile = new FileReader(filename); + } catch (FileNotFoundException e) { + appLogger.severe("File " + filename + " not Open " + e.getMessage()); + } + + BufferedReader in = new BufferedReader(inputFile); + + String s; + + try { + boolean encore = true; + + while (encore) { + Read2line sat_data1 = new Read2line(); + + s = in.readLine(); + + if (s == null) { + encore = false; + } else { + // v�rifie si nom du sat pr�sent + if (s.length() < 60) { + s = s.trim(); + s = s.replace(' ', '_'); + sat_data1.l[0] = s.toCharArray(); + s = in.readLine(); + } + sat_data1.l[1] = s.toCharArray(); + s = in.readLine(); + sat_data1.l[2] = s.toCharArray(); + v.add(sat_data1); + } + } + } catch (IOException e1) { + appLogger.severe("File " + filename + " error during the read " + e1.getMessage()); + } + try { + in.close(); + } catch (IOException e2) { + appLogger.severe("File " + filename + " error close " + e2.getMessage()); + } + + try { + inputFile.close(); + } catch (IOException e3) { + appLogger.severe("File " + filename + " error close " + e3.getMessage()); + } + + Read2line tab[] = new Read2line[v.size()]; + v.copyInto(tab); + + return (tab); + } + + /** @see java.lang.Object#toString() */ + public String toString() { + return new String(l[0]) + "\n" + new String(l[1]) + "\n" + new String(l[2]); + } + + public String[] getStrings() { + String[] twoLine = new String[3]; + + twoLine[0] = new String(l[0]); + twoLine[1] = new String(l[1]); + twoLine[2] = new String(l[2]); + + return twoLine; + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/keplerelement/file/TleCollection.java b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/file/TleCollection.java new file mode 100644 index 0000000000000000000000000000000000000000..3526d34c90f7b85282414c5a286b95555505c510 --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/file/TleCollection.java @@ -0,0 +1,63 @@ +package org.josast.keplerelement.file; + +import java.util.Hashtable; +import java.util.logging.Logger; + +import org.josast.keplerelement.IkeplerienElement; +import org.josast.keplerelement.KeplerienElement; + +/** @author XTOPHE */ +public class TleCollection extends Hashtable { + // ~ Constructors ------------------------------------------------------ + private static Logger appLogger = Logger.getLogger("AmsatLogger"); + /** */ + private static final long serialVersionUID = -6080939017722529827L; + + /** + * Creates a new TleCollection object. + * + * @param Filename TLE filename. + */ + public TleCollection(String Filename) { + super(); + + KeplerienElement KE; + Read2line tab[] = Read2line.readTleFile(Filename); + + for (int i = 0; i < tab.length; i++) { + KE = new KeplerienElement(tab[i]); + put(Integer.valueOf(KE.getSatelliteNumber()), KE); + } + } + + // ~ Methods ----------------------------------------------------------- + + /** + * @param TLE filename + * @return the number of TLE modified. + */ + public int update(String Filename) { + int modified = 0; + KeplerienElement KE; + KeplerienElement KEold; + Read2line tab[] = Read2line.readTleFile(Filename); + + for (int i = 0; i < tab.length; i++) { + KE = new KeplerienElement(tab[i]); + KEold = (KeplerienElement) this.get(Integer.valueOf(KE.getSatelliteNumber())); + + if (KEold == null) { + put(KE.getSatelliteNumber(), KE); + appLogger.info("Add " + KE.toStringAll()); + modified++; + } else if (KE.getJulianDate() > KEold.getJulianDate()) { + this.remove(KEold); + put(KE.getSatelliteNumber(), KE); + appLogger.info("UPdate " + KE.toStringAll()); + modified++; + } + } + + return modified; + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/keplerelement/util/GenericDate.java b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/util/GenericDate.java new file mode 100644 index 0000000000000000000000000000000000000000..8fb9b653aa60d052a2cd542b8d3c4da358954c61 --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/util/GenericDate.java @@ -0,0 +1,153 @@ +package org.josast.keplerelement.util; + +/** + * Description : generic container for a date. + * + *

Projet : JOSAST
+ *
+ * + * @author mercier + * @version 1.0 + *

Source Update
+ * Version : date : name : comments
+ * V1 : 1 avr. 2005 : C. Mercier : create file + *

+ */ +public class GenericDate { + // ~ Instance fields --------------------------------------------------- + + /** DOCUMENT ME! */ + private int _year; + + /** DOCUMENT ME! */ + private int _month; + + /** DOCUMENT ME! */ + private int _day; + + /** DOCUMENT ME! */ + private int _hour; + + /** DOCUMENT ME! */ + private int _minute; + + /** DOCUMENT ME! */ + private int _seconde; + + // ~ Constructors ------------------------------------------------------ + + /** + * Creates a new GenericDate object.
+ * no verification on the input value
+ * + * @param year 4 digit + * @param month 1 to 12 + * @param day 1 to 31 + * @param hour 1 to 24 + * @param minute 1 to 59 ! + * @param seconde 1 to 59 + */ + public GenericDate(int year, int month, int day, int hour, int minute, int seconde) { + _year = year; + _month = month; + _day = day; + _hour = hour; + _minute = minute; + _seconde = seconde; + } + + /** + * Creates a new GenericDate object. + * + * @param JulianDate julian day + */ + public GenericDate(double JulianDate) { + GenericDate Gd = JulianDay.convertToGenericDate(JulianDate); + _year = Gd._year; + _month = Gd._month; + _day = Gd._day; + _hour = Gd._hour; + _minute = Gd._minute; + _seconde = Gd._seconde; + } + + // ~ Methods ----------------------------------------------------------- + + /** + * return the julian day + * + * @return return julian day + */ + public double getJulianDay() { + return JulianDay.convertToJulianDay(_year, _month, _day, _hour, _minute, _seconde); + } + + /** @return day */ + public int get_day() { + return _day; + } + + /** @return hours */ + public int get_hour() { + return _hour; + } + + /** @return minute */ + public int get_minute() { + return _minute; + } + + /** @return month */ + public int get_month() { + return _month; + } + + /** @return seconde */ + public int get_seconde() { + return _seconde; + } + + /** @return year */ + public int get_year() { + return _year; + } + + /** @param _day day */ + public void set_day(int _day) { + this._day = _day; + } + + /** @param _hour hour */ + public void set_hour(int _hour) { + this._hour = _hour; + } + + /** @param _minute minute */ + public void set_minute(int _minute) { + this._minute = _minute; + } + + /** @param _month month */ + public void set_month(int _month) { + this._month = _month; + } + + /** @param _seconde seconde */ + public void set_seconde(int _seconde) { + this._seconde = _seconde; + } + + /** @param _year year */ + public void set_year(int _year) { + this._year = _year; + } + + /** + * print generic date with the following format dd mm yy hh mn ss + * + * @return string + */ + public String toString() { + return " " + _day + " " + _month + " " + _year + " " + _hour + " " + _minute + " " + _seconde; + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/keplerelement/util/JulianDay.java b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/util/JulianDay.java new file mode 100644 index 0000000000000000000000000000000000000000..75ff10fa7e4e3cd02bdf86268f4561f2ad085039 --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/util/JulianDay.java @@ -0,0 +1,379 @@ +package org.josast.keplerelement.util; + +import java.util.GregorianCalendar; + +/** + * Description : Julian day computing
+ * + *

date 7 ao�t 2003 + * + *

Source Update
+ * date : name : comments
+ * V1 : mercier : create file
+ * V1.1 : Mercier : correction bug moi de f�vrier + * + *

This class is a set of static method to use Julian day. + * + *

Algorithm are based on french version of the Jean Meeus book "Calculs Astronomiques � l'usage + * des Amateurs" editor : soci�t� Astronomique de France. + * + *

+ * + * @author XTOPHE josast at avmdti.org + * @version 1.1 + */ +public class JulianDay { + // ~ Static fields/initializers ---------------------------------------- + + private static final double EPOCH_JAN1_00H_1900 = 2415019.5; // Jan 1.0 1900 + // = Jan 1 1900 + // 00h UTC + + // = Jan 1 1900 + // 12h UTC + + // = Jan 1 2000 + + /** DOCUMENT ME! */ + private static final double EPOCH_JAN1_12H_1900 = 2415020.0; // Jan 1.5 1900 = Jan 1 1900 12h UTC + // 12h UTC + + // ~ Constructors ------------------------------------------------------ + + // ~ Methods ----------------------------------------------------------- + + // static method in the class, the constructor is not needed + + private JulianDay() {} + + /** + * Convert epoch from TLE data to julian day this method is valid from 1957 through 2056 epoch is + * : yyddd.ddddddd where yy is year ddd.ddddddd is day of the curent year + * + * @param epoch + * @return + */ + public static double convertToJulianDay(double epoch) { + double year, day, JDoE; + /* Valid 1957 through 2056 */ + year = Math.floor(epoch * 1.0E-3); + if (year < 57) year += 2000; + else year += 1900; + day = epoch - (Math.floor(epoch * 1.0E-3)) * 1.0E3; + JDoE = Julian_Date_of_Year(year) + day; + + return JDoE; + } + + /** + * Astronomical Formulae for Calculators, Jean Meeus, pages 23-25 Calculate Julian Date of 0.0 Jan + * year + * + * @param year + * @return Julian day + */ + public static double Julian_Date_of_Year(double year) { + /* Astronomical Formulae for Calculators, Jean Meeus, pages 23-25 + Calculate Julian Date of 0.0 Jan year */ + double A, B, JDoY; + year = year - 1.0; + A = Math.floor(year / 100.0); + B = 2.0 - A + Math.floor(A / 4.0); + JDoY = Math.floor(365.25 * year) + Math.floor(30.6001 * 14.0) + 1720994.5 + B; + + return JDoY; + } + + /** + * Method diffdate + * + *

This method realise the difference between 2 date. The folowing treatement is made : - + * convert the 2 date in Julian Day - return the difference between the 2 Julian Day . + * + * @param d1 + * @param d2 + * @return double + */ + public static double diffdate(GregorianCalendar d1, GregorianCalendar d2) { + return convertToJulianDay(d1) - convertToJulianDay(d2); + } + + /** + * Method addJours. + * + *

This method allows to add a number of day to a date. The folowing treatement is made : - + * convert the date to Julian Day - add the number of day - convert the date to GregorianCalendar + * + * @param d1 date + * @param jour number of day to add + * @return GregorianCalendar + */ + public static GregorianCalendar addDays(GregorianCalendar d1, long jour) { + double JDd1 = convertToJulianDay(d1); + JDd1 += jour; + return convertToGregorianCalendar(JDd1); + } + + /** + * Method convertToJourJulien. + * + *

This method convert a date in Julian Day. + * + *

This method call the convertToJourJulien(int annee,int mois,int jour,int heure,int + * minute,int seconde) + * + * @param date + * @return double + */ + public static double convertToJulianDay(GregorianCalendar date) { + + return convertToJulianDay( + date.get(GregorianCalendar.YEAR), + date.get(GregorianCalendar.MONTH) + 1, + date.get(GregorianCalendar.DAY_OF_MONTH), + date.get(GregorianCalendar.HOUR_OF_DAY), + date.get(GregorianCalendar.MINUTE), + date.get(GregorianCalendar.SECOND)); + } + /** + * Method convertToJourJulien. + * + *

This method convert a date in Julian Day. + * + *

This method call the convertToJourJulien(int annee,int mois,int jour,int heure,int + * minute,int seconde) + * + * @param date + * @return double + */ + public static double convertToJulianDay(GenericDate date) { + return convertToJulianDay( + date.get_year(), + date.get_month(), + date.get_day(), + date.get_hour(), + date.get_minute(), + date.get_seconde()); + } + + /** + * Method convertToJourJulien. + * + *

This method concert a date in Julian Date. The algorithm from the Jean Meeus book is used. + * + *

This method as been tested with the exemple of the book. cf Unit test. + * + *

Be carrefull the input are not checked. + * + * @param annee positive and negative year coold be used + * @param mois 1->junary 12->december + * @param jour 1 to 31 + * @param heure 0-24 + * @param minute 0-59 + * @param seconde 0-59 + * @return double julian date. + */ + public static double convertToJulianDay( + int annee, int mois, int jour, int heure, int minute, int seconde) { + // d�tection si la date est > 1582.1015 + double A = 0; + double B = 0; + double date = annee + mois / 100.0 + jour / 10000.0; + double JulianDate = 0; + + double y = annee; + double m = mois; + double j = heure / 24.0 + (minute / (24 * 60.0)) + (seconde / (3600.0 * 24.0)); + // MCR 15-2-2004 correction suite a un d�faut d�tect� sur le mois de f�vier + // remplacement du < par <= puisque les mois de janvier et f�vier sont consid�r� comme + // les 13eme et 14eme mois. + + if (mois <= 2) { + y = y - 1; + m = m + 12; + } + + if (date > 1582.1015) { + A = ENT(y / 100.0); + B = 2 - A + ENT(A / 4.0); + } else { + A = 0; + B = 0; + } + + if (y > 0) { + JulianDate = ENT(365.25 * y) + ENT(30.6001 * (m + 1)) + jour + j + 1720994.5 + B; + } else { + JulianDate = ENT(365.25 * y - 0.75) + ENT(30.6001 * (m + 1)) + jour + j + 1720994.5 + B; + } + + return JulianDate; + } + + /** + * This method concert a date in Julian Date Modified with origin 1/1/2000 0H. + * + *

The time scale used here is a "day number" from 2000 Jan 0.0 TDT, which is the same as 1999 + * Dec 31.0 TDT, i.e. precisely at midnight TDT at the start of the last day of this century. With + * the modest accuracy we strive for here, one can usually disregard the difference between TDT + * (formerly canned ET) and UT. + * + * @param annee + * @param mois + * @param jour + * @param heure + * @param minute + * @param seconde + * @return + */ + public static double convertToJulianDay2000( + int annee, int mois, int jour, int heure, int minute, int seconde) { + return convertToJulianDay(annee, mois, jour, heure, minute, seconde) - 2451543.5d; + } + + /** + * Method convertToGregorianCalendar. + * + *

This method convert an Julian date to a Gregorian Calendar date. + * + * @param JulianDate + * @return GregorianCalendar + */ + public static GregorianCalendar convertToGregorianCalendar(double JulianDate) { + double Z = ENT(JulianDate + 0.5); + double A = 0; + if (Z < 2299161) { + A = Z; + } else { + double alpha = ENT((Z - 1867216.25) / 36524.35); + A = Z + 1 + alpha - ENT(alpha / 4); + } + + double F = JulianDate + 0.5 - Z; + + double B = A + 1524; + double C = ENT((B - 122.1) / 365.25); + double D = ENT(365.25 * C); + double E = ENT((B - D) / 30.6001); + double tempjour = B - D - ENT(30.6001 * E) + F; + + int jour = (int) ENT(tempjour); + double temp = tempjour - jour; + + double ensecondes = 24 * 60 * 60 * temp; + + int heure = (int) ENT(ensecondes / 3600); + int minute = (int) ENT((ensecondes - (3600 * heure)) / 60.0); + int secondes = (int) ensecondes - ((3600 * heure) + (60 * minute)); + int mois = (int) E - 1; + + if (E > 13.5) { + mois = (int) E - 13; + } + + int annee = (int) C - 4716; + if (mois < 2.5) { + annee = (int) C - 4715; + } + System.err.println("" + annee + "" + mois + "" + jour); + return new GregorianCalendar(annee, mois - 1, jour, heure, minute, secondes); + } + + /** + * Method ENT. + * + * @param valeur + * @return double + */ + private static double ENT(double valeur) { + long l = (long) valeur; + return l * 1.0; + } + + /** + * Method convertToGenericDate. + * + * @param JulianDate + * @return GenericDate + */ + public static GenericDate convertToGenericDate(double JulianDate) { + double Z = ENT(JulianDate + 0.5); + double A = 0; + if (Z < 2299161) { + A = Z; + } else { + double alpha = ENT((Z - 1867216.25) / 36524.35); + A = Z + 1 + alpha - ENT(alpha / 4); + } + + double F = JulianDate + 0.5 - Z; + + double B = A + 1524; + double C = ENT((B - 122.1) / 365.25); + double D = ENT(365.25 * C); + double E = ENT((B - D) / 30.6001); + double tempjour = B - D - ENT(30.6001 * E) + F; + + int jour = (int) ENT(tempjour); + double temp = tempjour - jour; + + double ensecondes = 24 * 60 * 60 * temp; + + int heure = (int) ENT(ensecondes / 3600); + int minute = (int) ENT((ensecondes - (3600 * heure)) / 60.0); + int secondes = (int) ensecondes - ((3600 * heure) + (60 * minute)); + int mois = (int) E - 1; + + if (E > 13.5) { + mois = (int) E - 13; + } + + int annee = (int) C - 4716; + if (mois < 2.5) { + annee = (int) C - 4715; + } + + return new GenericDate(annee, mois, jour, heure, minute, secondes); + } + /** + * DOCUMENT ME! + * + * @param m_Date julian day + * @return number of day from 1/1/1900 OH + */ + public static double FromJan1_00h_1900(double m_Date) { + return m_Date - EPOCH_JAN1_00H_1900; + } + + /** + * DOCUMENT ME! + * + * @param m_Date julian day + * @return number of day from 1/1/1900 12H + */ + public static double FromJan1_12h_1900(double m_Date) { + return m_Date - EPOCH_JAN1_12H_1900; + } + + /** + * DOCUMENT ME! + * + * @param m_Date julian day + * @return number of day from 1/1/2000 12H + */ + public static double FromJan1_12h_2000(double m_Date) { + return m_Date - EPOCH_JAN1_12H_2000; + } + + /** DOCUMENT ME! */ + private static final double EPOCH_JAN1_12H_2000 = 2451545.0; // Jan 1.5 2000 = Jan 1 2000 12h UTC + + public static double getFromJan1_12h_2000(double date) { + return date - EPOCH_JAN1_12H_2000; + } + + // ~ Constructors ------------------------------------------------------ + + // static method in the class, the constructor is not needed + +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/keplerelement/util/ParseCharArray.java b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/util/ParseCharArray.java new file mode 100644 index 0000000000000000000000000000000000000000..6fd6911e7bcc1c94907396775a3ca5c813b36d2b --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/keplerelement/util/ParseCharArray.java @@ -0,0 +1,196 @@ +package org.josast.keplerelement.util; + +/* + * Created on Jul 22, 2004 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ + +/** + * convert an array of char in double or integer + * + * @author Xtophe + * @version 1.0 + */ +public class ParseCharArray { + // ~ Methods ----------------------------------------------------------- + + /* + * ------------------------------------------------------------------- * + * ---------------------------- double_value ------------------------- * + * ------------------------------------------------------------------- + */ + + /** + * @param c1 Array of char + * @param pos First caractere to convert + * @param len Lenght of the convertion + * @return + */ + public static double double_value(char c1[], int pos, int len) { + double d = 0; + int i; + int j = 0; + + for (i = 0; (i < len); i++) { + switch (c1[i + pos]) { + case ' ': + break; + + case '0': + d *= 10; + + break; + + case '1': + d *= 10; + d++; + + break; + + case '2': + d *= 10; + d += 2; + + break; + + case '3': + d *= 10; + d += 3; + + break; + + case '4': + d *= 10; + d += 4; + + break; + + case '5': + d *= 10; + d += 5; + + break; + + case '6': + d *= 10; + d += 6; + + break; + + case '7': + d *= 10; + d += 7; + + break; + + case '8': + d *= 10; + d += 8; + + break; + + case '9': + d *= 10; + d += 9; + + break; + + case '.': + j = len - i - 1; + + break; + + default: + break; + } + } + + d /= Math.pow(10.0, j); + + return d; + } + + /** + * @param c1 Array of char + * @param pos First caractere to convert + * @param len Lenght of the convertion + * @return + */ + public static int integer_value(char c1[], int pos, int len) { + int d = 0; + int i; + + for (i = 0; (i < len); i++) { + switch (c1[i + pos]) { + case ' ': + break; + + case '0': + d *= 10; + + break; + + case '1': + d *= 10; + d++; + + break; + + case '2': + d *= 10; + d += 2; + + break; + + case '3': + d *= 10; + d += 3; + + break; + + case '4': + d *= 10; + d += 4; + + break; + + case '5': + d *= 10; + d += 5; + + break; + + case '6': + d *= 10; + d += 6; + + break; + + case '7': + d *= 10; + d += 7; + + break; + + case '8': + d *= 10; + d += 8; + + break; + + case '9': + d *= 10; + d += 9; + + break; + + default: + break; + } + } + + return d; + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/satellite/ManageSatellites.java b/ApplicationJMultisat/src/main/java/org/josast/satellite/ManageSatellites.java new file mode 100644 index 0000000000000000000000000000000000000000..7630f75b76cb7b8522b4e7db65ef3882552c0f65 --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/satellite/ManageSatellites.java @@ -0,0 +1,129 @@ +package org.josast.satellite; + +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import javax.json.Json; +import javax.json.JsonArray; +import javax.json.JsonObject; +import javax.json.JsonReader; +import javax.json.JsonValue; +import javax.json.bind.Jsonb; +import javax.json.bind.JsonbBuilder; + +public class ManageSatellites { + + SatelliteInformationInterface[] satellites = null; + + Map productsByName = new HashMap<>(); + + public ManageSatellites() {} + + /** @return the satellites */ + public final synchronized SatelliteInformationInterface[] getSatellites() { + return satellites; + } + + /** @param satellites the satellites to set */ + public final synchronized void setSatellites(SatelliteInformationInterface[] satellites) { + this.satellites = satellites; + for (int i = 0; i < satellites.length; i++) { + productsByName.put(satellites[i].getName(), satellites[i]); + } + } + + public SatelliteInformationInterface getSatelliteFromName(String activesat) { + return productsByName.get(activesat); + } + + public boolean setSatellitePriority(String string, int i) { + boolean b = false; + SatelliteInformationInterface sat = productsByName.get(string); + if (sat != null) { + sat.setPriority(i); + b = true; + } + + return b; + } + + public void load(String file) { + + Jsonb jsonb = JsonbBuilder.create(); + // List applicationDataList = new ArrayList<>(); + ArrayList newList = + new ArrayList(); + try (JsonReader reader = Json.createReader(new FileReader(file))) { + JsonArray jsonArray = reader.readArray(); + for (JsonValue jsonValue : jsonArray) { + JsonObject jsonObject = (JsonObject) jsonValue; + SatelliteInformationInterface genericObjectData = + jsonb.fromJson(jsonObject.toString(), SatelliteInformation.class); + newList.add(genericObjectData); + } + reader.close(); + + } catch (IOException e) { + e.printStackTrace(); + } + + System.out.println(newList.size()); + satellites = new SatelliteInformationInterface[newList.size()]; + for (int i = 0; i < newList.size(); i++) { + satellites[i] = newList.get(i); + } + } + + public void save(String filename) { + + Jsonb jsonb = JsonbBuilder.create(); + + String jsonData = null; + + try { + FileWriter fileWriter = new FileWriter(filename); + jsonData = jsonb.toJson(satellites); + fileWriter.write(jsonData); + fileWriter.close(); + } catch (IOException e) { + e.printStackTrace(); + } + + // try { + // PrintWriter writer = new PrintWriter(filename, "UTF-8"); + // for (SatelliteInformationInterface satellite : satellites) { + // writer.println(satellite.toString()); + // } + // writer.close(); + // } catch (FileNotFoundException | UnsupportedEncodingException e) { + // + // e.printStackTrace(); + // } + } + + public void DeselectAllSatellites() { + for (SatelliteInformationInterface satellite : satellites) { + satellite.setSelected(false); + } + } + + public SatelliteInformationInterface[] getSelectedSatellites() { + + ArrayList newList = + new ArrayList(); + Map selected = new HashMap<>(); + for (SatelliteInformationInterface satellite : satellites) { + if (satellite.isSelected()) { + newList.add(satellite); + selected.put(satellite.getName(), satellite); + } + } + SatelliteInformationInterface[] selectedArray = + newList.toArray(new SatelliteInformationInterface[0]); + return selectedArray; + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/satellite/SatelliteInformation.java b/ApplicationJMultisat/src/main/java/org/josast/satellite/SatelliteInformation.java new file mode 100644 index 0000000000000000000000000000000000000000..fef94bd1f42c4b8a1279c33e352446a207eeab33 --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/satellite/SatelliteInformation.java @@ -0,0 +1,125 @@ +/** */ +package org.josast.satellite; + +import org.josast.automation.ProcessBuilderCollection; +import org.josast.satellite.mode.ModulationMode; + +/** */ +public class SatelliteInformation implements SatelliteInformationInterface { + + private boolean selected = true; + private String name = null; + private long noradIdentifier = 0; + private int priority = 0; + private long frequency = 0; + private ModulationMode modulation = null; + private ProcessBuilderCollection preocessBuilder = new ProcessBuilderCollection(); + + /** @return the frequency */ + @Override + public final synchronized long getFrequency() { + return frequency; + } + + /** @param frequency the frequency to set */ + @Override + public final synchronized void setFrequency(long frequency) { + this.frequency = frequency; + } + + /** */ + public SatelliteInformation() { + // TODO Auto-generated constructor stub + } + + /** + * @param name + * @param noradIdentifier + */ + public SatelliteInformation(String name, long noradIdentifier) { + super(); + this.name = name; + this.noradIdentifier = noradIdentifier; + } + + @Override + public String getName() { + + return name; + } + + @Override + public long getNoradIdentifier() { + + return noradIdentifier; + } + + @Override + public boolean isSelected() { + return selected; + } + + @Override + public void setSelected(boolean b) { + selected = b; + } + + @Override + public int getPriority() { + return priority; + } + + @Override + public void setPriority(int priority) { + this.priority = priority; + } + + /** @param name the name to set */ + @Override + public final synchronized void setName(String name) { + this.name = name; + } + + /** @param noradIdentifier the noradIdentifier to set */ + @Override + public final synchronized void setNoradIdentifier(long noradIdentifier) { + this.noradIdentifier = noradIdentifier; + } + + /** @return the modulation */ + @Override + public final synchronized ModulationMode getModulation() { + return modulation; + } + + /** @param modulation the modulation to set */ + @Override + public final synchronized void setModulation(ModulationMode modulation) { + this.modulation = modulation; + } + + /** @return the preocessBuilder */ + @Override + public final synchronized ProcessBuilderCollection getPreocessBuilder() { + return preocessBuilder; + } + + /** @param preocessBuilder the preocessBuilder to set */ + @Override + public final synchronized void setPreocessBuilder(ProcessBuilderCollection preocessBuilder) { + this.preocessBuilder = preocessBuilder; + } + + @Override + public String toString() { + return "SatelliteInformation [selected=" + + selected + + ", name=" + + name + + ", noradIdentifier=" + + noradIdentifier + + ", priority=" + + priority + + "]"; + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/satellite/SatelliteInformationInterface.java b/ApplicationJMultisat/src/main/java/org/josast/satellite/SatelliteInformationInterface.java new file mode 100644 index 0000000000000000000000000000000000000000..84248cbf685374c0be8aecd50e3153ebfc353a8a --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/satellite/SatelliteInformationInterface.java @@ -0,0 +1,43 @@ +package org.josast.satellite; + +import org.josast.automation.ProcessBuilderCollection; +import org.josast.satellite.mode.ModulationMode; + +public interface SatelliteInformationInterface { + + /** @return the frequency */ + long getFrequency(); + + /** @param frequency the frequency to set */ + void setFrequency(long frequency); + + String getName(); + + long getNoradIdentifier(); + + boolean isSelected(); + + void setSelected(boolean b); + + int getPriority(); + + void setPriority(int priority); + + /** @param name the name to set */ + void setName(String name); + + /** @param noradIdentifier the noradIdentifier to set */ + void setNoradIdentifier(long noradIdentifier); + + /** @return the modulation */ + ModulationMode getModulation(); + + /** @param modulation the modulation to set */ + void setModulation(ModulationMode modulation); + + /** @return the preocessBuilder */ + ProcessBuilderCollection getPreocessBuilder(); + + /** @param preocessBuilder the preocessBuilder to set */ + void setPreocessBuilder(ProcessBuilderCollection preocessBuilder); +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/satellite/mode/CollectionModulationMode.java b/ApplicationJMultisat/src/main/java/org/josast/satellite/mode/CollectionModulationMode.java new file mode 100644 index 0000000000000000000000000000000000000000..8e583448a841735c256736604ad92f9e1a1eaf89 --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/satellite/mode/CollectionModulationMode.java @@ -0,0 +1,59 @@ +package org.josast.satellite.mode; + +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Hashtable; + +import javax.json.Json; +import javax.json.JsonArray; +import javax.json.JsonObject; +import javax.json.JsonReader; +import javax.json.JsonValue; +import javax.json.bind.Jsonb; +import javax.json.bind.JsonbBuilder; + +public class CollectionModulationMode extends Hashtable { + + /** */ + private static final long serialVersionUID = -2561419842059637727L; + + public void save(String filename) { + Jsonb jsonb = JsonbBuilder.create(); + + String jsonData = jsonb.toJson(this.values()); + + try { + FileWriter fileWriter = new FileWriter(filename); + fileWriter.write(jsonData); + fileWriter.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public void load(String absolutePath) { + Jsonb jsonb = JsonbBuilder.create(); + // List applicationDataList = new ArrayList<>(); + ModulationMode genericObjectData = null; + try (JsonReader reader = Json.createReader(new FileReader(absolutePath))) { + JsonArray jsonArray = reader.readArray(); + for (JsonValue jsonValue : jsonArray) { + JsonObject jsonObject = (JsonObject) jsonValue; + genericObjectData = jsonb.fromJson(jsonObject.toString(), ModulationMode.class); + + // Application applicationData = jsonb.fromJson(jsonObject.toString(), + // Application.class); + // applicationDataList.add(applicationData); + + this.put(genericObjectData.getName(), genericObjectData); + } + reader.close(); + + } catch (IOException e) { + e.printStackTrace(); + } + + System.out.println(this.size()); + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/satellite/mode/ModulationMode.java b/ApplicationJMultisat/src/main/java/org/josast/satellite/mode/ModulationMode.java new file mode 100644 index 0000000000000000000000000000000000000000..d8a9ec32b84e3b43836bd7d6bc618854b2c9512c --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/satellite/mode/ModulationMode.java @@ -0,0 +1,74 @@ +package org.josast.satellite.mode; + +public class ModulationMode { + + private String name; + /* + USB’, ‘LSB’, ‘CW’, ‘CWR’, ‘RTTY’, ‘RTTYR’, ‘AM’, ‘FM’, ‘WFM’, ‘AMS’, ‘PKTLSB’, ‘PKTUSB’, ‘PKTFM’, ‘ECSSUSB’, ‘ECSSLSB’, ‘FA’, ‘SAM’, ‘SAL’, ‘SAH’, ‘DSB’ + */ + private String radioMode; + + private double radioOffset; + + private double radioBandwith; + + /** */ + public ModulationMode() { + super(); + // TODO Auto-generated constructor stub + } + + /** + * @param name + * @param radioMode + * @param radioOffset + * @param radioBandwith + */ + public ModulationMode(String name, String radioMode, double radioOffset, double radioBandwith) { + super(); + this.name = name; + this.radioMode = radioMode; + this.radioOffset = radioOffset; + this.radioBandwith = radioBandwith; + } + + /** @return the name */ + public final synchronized String getName() { + return name; + } + + /** @param name the name to set */ + public final synchronized void setName(String name) { + this.name = name; + } + + /** @return the radioMode */ + public final synchronized String getRadioMode() { + return radioMode; + } + + /** @param radioMode the radioMode to set */ + public final synchronized void setRadioMode(String radioMode) { + this.radioMode = radioMode; + } + + /** @return the radioOffset */ + public final synchronized double getRadioOffset() { + return radioOffset; + } + + /** @param radioOffset the radioOffset to set */ + public final synchronized void setRadioOffset(double radioOffset) { + this.radioOffset = radioOffset; + } + + /** @return the radioBandwith */ + public final synchronized double getRadioBandwith() { + return radioBandwith; + } + + /** @param radioBandwith the radioBandwith to set */ + public final synchronized void setRadioBandwith(double radioBandwith) { + this.radioBandwith = radioBandwith; + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/InterfaceSatellitePropagation.java b/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/InterfaceSatellitePropagation.java new file mode 100644 index 0000000000000000000000000000000000000000..67a6724c5026da229da60a18590635721354d4ac --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/InterfaceSatellitePropagation.java @@ -0,0 +1,23 @@ +package org.josast.satellitePrediction; + +import java.util.List; + +import org.joda.time.DateTime; +import org.josast.station.GroundStationInterface; + +public interface InterfaceSatellitePropagation { + + public void setSatelliteKeplerianElement(KeplerianElementTwoLineInterface satellite); + + public void setGroundStation(GroundStationInterface groundStation); + + public GroundStationInterface getGroundStation(); + + public SatellitePositionfromGroundStation getCurrentPosition(); + + public SatellitePositionfromGroundStation getPosition(DateTime date); + + public SatellitePassfromGroundStation getNextPass(); + + public List getNextPass(int hour); +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/KeplerianElementTwoLine.java b/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/KeplerianElementTwoLine.java new file mode 100644 index 0000000000000000000000000000000000000000..8a4f89ccbd8d4f2177759740e896d29ea06a34d4 --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/KeplerianElementTwoLine.java @@ -0,0 +1,18 @@ +package org.josast.satellitePrediction; + +public class KeplerianElementTwoLine implements KeplerianElementTwoLineInterface { + + private String twoLine[]; + + /** @return the twoLine */ + @Override + public final synchronized String[] getTwoLine() { + return twoLine; + } + + /** @param twoLine the twoLine to set */ + @Override + public final synchronized void setTwoLine(String twoLine) { + this.twoLine = twoLine.split("\n"); + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/KeplerianElementTwoLineInterface.java b/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/KeplerianElementTwoLineInterface.java new file mode 100644 index 0000000000000000000000000000000000000000..153ad0bf9937acf6c03906df4c63b4f540efaa02 --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/KeplerianElementTwoLineInterface.java @@ -0,0 +1,10 @@ +package org.josast.satellitePrediction; + +public interface KeplerianElementTwoLineInterface { + + /** @return the twoLine */ + String[] getTwoLine(); + + /** @param twoLine the twoLine to set */ + void setTwoLine(String twoLine); +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/ManageSatellitePass.java b/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/ManageSatellitePass.java new file mode 100644 index 0000000000000000000000000000000000000000..680ba0fb2db0c3935715491c64a71282e156a010 --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/ManageSatellitePass.java @@ -0,0 +1,117 @@ +package org.josast.satellitePrediction; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Iterator; +import java.util.function.Predicate; +import java.util.stream.Collectors; +import java.util.Collections; +import org.joda.time.DateTime; +import org.josast.satellite.ManageSatellites; +import org.josast.satellite.SatelliteInformationInterface; + +public class ManageSatellitePass { + + private List satellitePassList = new ArrayList<>(); + + private int minDuration = 60000; + private double minElevation = 5.0; + + public Predicate minDurationnPredicate = + p -> p.getDuration() >= minDuration; + public Predicate minElevationPredicate = + p -> p.getTca().getElevation() >= minElevation; + + public ManageSatellitePass() {} + + /** @return the satellitePassList */ + public final synchronized List getSatellitePassList() { + return satellitePassList; + } + + /** @param satellitePassList the satellitePassList to set */ + public final synchronized void setSatellitePassList( + List satellitePassList) { + this.satellitePassList = satellitePassList; + } + + public void addSatellitePass(List list) { + satellitePassList.addAll(list); + } + + public int getSize() { + return satellitePassList.size(); + } + + public List filter( + Predicate predicate) { + + List filteredPassages = + satellitePassList.stream().filter(predicate).collect(Collectors.toList()); + + return (filteredPassages); + } + + public void sort(Comparator comparator) { + Collections.sort(satellitePassList, comparator); + } + + public List selectPassListSimple() { + // parcour de la liste + List selectedSatPassList = new ArrayList<>(); + DateTime losDate = null; + SatellitePassfromGroundStation pass; + Iterator it = satellitePassList.iterator(); + boolean passSelected = false; + while (it.hasNext()) { + pass = it.next(); + // selection du passage + if (!passSelected) { + selectedSatPassList.add(pass); + losDate = pass.getLOSDate(); + passSelected = true; + } else { + if (losDate.isBefore(pass.getAOSDate())) { + selectedSatPassList.add(pass); + losDate = pass.getLOSDate(); + passSelected = true; + } + } + // recherche passage suivant qui démarre aprés la fin passage sélectionné + + } + + return selectedSatPassList; + } + + public List selectPassByPriority(ManageSatellites mngSat) { + List possiblePasses = new ArrayList<>(); + + SatellitePassfromGroundStation activePass = null; + SatelliteInformationInterface activesat = null; + SatelliteInformationInterface currentsat = null; + + for (SatellitePassfromGroundStation pass : satellitePassList) { + + if (activePass == null || pass.getAos().getDate().isAfter(activePass.getLos().getDate())) { + // No active pass or new pass starts after active pass ends + activePass = pass; + possiblePasses.add(pass); + } else { + + activesat = mngSat.getSatelliteFromName(activePass.getName()); + currentsat = mngSat.getSatelliteFromName(pass.getName()); + + if (currentsat.getPriority() > activesat.getPriority()) { + // New pass starts while active pass is still ongoing, and has higher priority + possiblePasses.remove(activePass); + activePass = pass; + possiblePasses.add(pass); + } + } + } + + return possiblePasses; + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/SatellitePassfromGroundStation.java b/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/SatellitePassfromGroundStation.java new file mode 100644 index 0000000000000000000000000000000000000000..0d473c99280baef0e5803fdd8ade85ddd0a239b9 --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/SatellitePassfromGroundStation.java @@ -0,0 +1,108 @@ +package org.josast.satellitePrediction; + +import org.joda.time.DateTime; + +public class SatellitePassfromGroundStation { + + // AOS stands for Acquisition of Signal (or Satellite). AOS is the time that a satellite rises + // above the horizon of an observer. + // TCA stands for Time of Closest Approach. This is the time when the satellite is closest to the + // observer and when Doppler shift is zero. This usually corresponds to the time that the + // satellite reaches maximum elevation above the horizon. + // LOS stands for Loss of Signal (or Satellite). LOS is the time that a satellite passes below the + // observer’s horizon. + + private SatellitePositionfromGroundStation aos; + private SatellitePositionfromGroundStation los; + private SatellitePositionfromGroundStation tca; + private long duration; + private String name; + + public DateTime getAOSDate() { + return aos.getDate(); + } + + public DateTime getLOSDate() { + if (los != null) return los.getDate(); + else return aos.getDate(); + } + + public long getDuration() { + if (aos != null && los != null) { + duration = los.getDate().getMillis() - aos.getDate().getMillis(); + } + return duration; + } + + // Compare method + public int compareTo(Object obj) { + + return this.getAOSDate().compareTo(((SatellitePassfromGroundStation) obj).getAOSDate()); + } + + public SatellitePositionfromGroundStation getAos() { + return aos; + } + + public void setAos(SatellitePositionfromGroundStation aos) { + this.aos = aos; + name = aos.getSatelliteName(); + } + + public SatellitePositionfromGroundStation getLos() { + return los; + } + + public void setLos(SatellitePositionfromGroundStation los) { + this.los = los; + duration = this.getDuration(); + } + + public SatellitePositionfromGroundStation getTca() { + return tca; + } + + public void setTca(SatellitePositionfromGroundStation tca) { + this.tca = tca; + } + + @Override + public String toString() { + + return "Passage [ \r\n aos=" + + aos + + ", \r\n los=" + + los + + ", \r\n tca=" + + tca + + ", duration=" + + duration + + "]"; + } + + public void satName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public boolean overlaps(SatellitePassfromGroundStation other) { + + boolean finishbefore = other.getLOSDate().isBefore(other.getLOSDate()); + boolean startafter = other.getAOSDate().isBefore(other.getLOSDate()); + + return finishbefore || startafter; + } + + /** @param duration the duration to set */ + public final synchronized void setDuration(long duration) { + this.duration = duration; + } + + /** @param name the name to set */ + public final synchronized void setName(String name) { + this.name = name; + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/SatellitePositionfromGroundStation.java b/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/SatellitePositionfromGroundStation.java new file mode 100644 index 0000000000000000000000000000000000000000..8d8bd8c613eb25801257653fac09703cd0854951 --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/SatellitePositionfromGroundStation.java @@ -0,0 +1,116 @@ +package org.josast.satellitePrediction; + +import org.joda.time.DateTime; + +public class SatellitePositionfromGroundStation { + + /** + * @param satelliteName + * @param noradId + * @param azimuth + * @param elevation + * @param range + * @param date + */ + public SatellitePositionfromGroundStation( + String satelliteName, + int noradId, + double azimuth, + double elevation, + double range, + DateTime date) { + super(); + this.satelliteName = satelliteName; + this.noradId = noradId; + this.azimuth = azimuth; + this.elevation = elevation; + this.range = range; + this.date = date; + } + + private String satelliteName; + private int noradId; + private double azimuth; + private double elevation; + private double range; + private DateTime date; + + public SatellitePositionfromGroundStation() {} + + /** @return the satelliteName */ + public final synchronized String getSatelliteName() { + return satelliteName; + } + + /** @param satelliteName the satelliteName to set */ + public final synchronized void setSatelliteName(String satelliteName) { + this.satelliteName = satelliteName; + } + + /** @return the noradId */ + public final synchronized int getNoradId() { + return noradId; + } + + /** @param noradId the noradId to set */ + public final synchronized void setNoradId(int noradId) { + this.noradId = noradId; + } + + /** @return the azimuth */ + public final synchronized double getAzimuth() { + return azimuth; + } + + /** @param azimuth the azimuth to set */ + public final synchronized void setAzimuth(double azimuth) { + this.azimuth = azimuth; + } + + /** @return the elevation */ + public final synchronized double getElevation() { + return elevation; + } + + /** @param elevation the elevation to set */ + public final synchronized void setElevation(double elevation) { + this.elevation = elevation; + } + + /** @return the range */ + public final synchronized double getRange() { + return range; + } + + /** @param range the range to set */ + public final synchronized void setRange(double range) { + this.range = range; + } + + /** @return the date */ + public final synchronized DateTime getDate() { + return date; + } + + /** @param date the date to set */ + public final synchronized void setDate(DateTime date) { + this.date = date; + } + + @Override + public String toString() { + return "SatellitePositionfromGroundStation [satelliteName=" + + satelliteName + + ", noradId=" + + noradId + + ", azimuth=" + + azimuth + + ", elevation=" + + elevation + + ", range=" + + range + + ", date=" + + date + + "]"; + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/SortbyAOS.java b/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/SortbyAOS.java new file mode 100644 index 0000000000000000000000000000000000000000..46b4139b392985e49ac7b2445fb553504d64d82a --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/SortbyAOS.java @@ -0,0 +1,14 @@ +/** */ +package org.josast.satellitePrediction; + +import java.util.Comparator; + +/** */ +public class SortbyAOS implements Comparator { + + /** */ + @Override + public int compare(SatellitePassfromGroundStation o1, SatellitePassfromGroundStation o2) { + return o1.getAOSDate().compareTo(o2.getAOSDate()); + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/SortbyLOS.java b/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/SortbyLOS.java new file mode 100644 index 0000000000000000000000000000000000000000..a27e400b90c583a589c8598b052ed1a901484e68 --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/SortbyLOS.java @@ -0,0 +1,13 @@ +package org.josast.satellitePrediction; + +import java.util.Comparator; + +/** */ +public class SortbyLOS implements Comparator { + + /** */ + @Override + public int compare(SatellitePassfromGroundStation o1, SatellitePassfromGroundStation o2) { + return o1.getLOSDate().compareTo(o2.getLOSDate()); + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/demo/SimpleDemo.java b/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/demo/SimpleDemo.java new file mode 100644 index 0000000000000000000000000000000000000000..0eb21e5506236836c0d2ea91a311c581e9278fff --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/demo/SimpleDemo.java @@ -0,0 +1,190 @@ +/** */ +package org.josast.satellitePrediction.demo; + +import java.util.List; +import java.util.Iterator; + +import org.josast.keplerelement.celestrak.TleDataRetriever; +import org.josast.satellitePrediction.InterfaceSatellitePropagation; +import org.josast.satellitePrediction.KeplerianElementTwoLine; +import org.josast.satellitePrediction.KeplerianElementTwoLineInterface; +import org.josast.satellitePrediction.ManageSatellitePass; +import org.josast.satellitePrediction.SatellitePassfromGroundStation; +import org.josast.satellitePrediction.SatellitePositionfromGroundStation; +import org.josast.satellitePredictionG4DPZ.SatellitePropagation; +import org.josast.keplerelement.IKelplerianElementManager; +import org.josast.keplerelement.IkeplerienElement; +import org.josast.station.GroundStation; +import org.josast.station.GroundStationInterface; +import org.josast.satellitePrediction.SortbyAOS; + +import org.josast.keplerelement.file.*; +import org.josast.satellite.ManageSatellites; +import org.josast.satellite.SatelliteInformationInterface; +/** */ +public class SimpleDemo { + + /** */ + public SimpleDemo() { + // TODO Auto-generated constructor stub + } + + /** @param args */ + public static void main(String[] args) { + + SimpleDemo demo = new SimpleDemo(); + demo.start(); + } + + public void start() { + System.out.println(" Simulation application prediction"); + + System.out.println(" Step 1 : configuration station sol "); + double latitude = 48.858365; // 48.8330; + double longitude = 2.294532; // -2.3330; + double altitude = 75; + String name = "test Xtophe"; + GroundStationInterface groundStation = new GroundStation(name, altitude, longitude, latitude); + + System.out.println(" Step 2 : récupération 2 line"); + TleDataRetriever tdr = new TleDataRetriever(); + String twoLine = tdr.getTle(47438); + KeplerianElementTwoLineInterface keps = new KeplerianElementTwoLine(); + // 1 47438U 21006AB 23257.15692707 .00023015 00000-0 86002-3 0 9991 + // 2 47438 97.3754 313.1180 0010700 125.0717 235.1527 15.27308596146216 + String tl2test = + "UVSQ-SAT \n1 47438U 21006AB 23257.15692707 .00023015 00000-0 86002-3 0 9991\n2 47438 97.3754 313.1180 0010700 125.0717 235.1527 15.27308596146216"; + + keps.setTwoLine(tl2test); + + System.out.println(tl2test); + InterfaceSatellitePropagation satProg = new SatellitePropagation(); + + System.out.println(" Step 3 : setup propagation"); + + satProg.setGroundStation(groundStation); + satProg.setSatelliteKeplerianElement(keps); + + System.out.println(" Step 4 : Display curent position"); + + SatellitePositionfromGroundStation pos = satProg.getCurrentPosition(); + System.out.println(pos); + + System.out.println(" Step 5 : Calcul passage "); + + SatellitePassfromGroundStation pass = satProg.getNextPass(); + System.out.println(pass); + + System.out.println(" Step 6 : Calcul ALL passage for 1 satellite"); + + List passages = satProg.getNextPass(24); + System.out.println(passages); + + System.out.println(" Step 6 : Calcul ALL passage for N satellites"); + + IKelplerianElementManager kepsMngt = new KeplerianFileManagerFromUrl(); + SatelliteInformationInterface[] listSat = kepsMngt.getSatelliteInformation(); + System.out.println("nombre satellite " + listSat.length); + + // List allPassages = new + // ArrayList(); + + ManageSatellitePass mngtSatPass = new ManageSatellitePass(); + + for (int i = 0; i < listSat.length; i++) { + + System.out.println("" + i + " " + listSat[i].getName()); + + IkeplerienElement keplerElt = kepsMngt.getSatelliteKeplerianElement(listSat[i].getName()); + // @TODO : A simplifier + String twoLines = + keplerElt.getTwoline()[0] + + "\r\n" + + keplerElt.getTwoline()[1] + + "\r\n" + + keplerElt.getTwoline()[2] + + "\r\n"; + keps.setTwoLine(twoLines); + + satProg.setSatelliteKeplerianElement(keps); + passages = satProg.getNextPass(24); + mngtSatPass.addSatellitePass(passages); + } + + ManageSatellites mngSat = new ManageSatellites(); + mngSat.setSatellites(listSat); + if (!mngSat.setSatellitePriority("UVSQ-SAT", 5)) { + System.err.println("SatNot found UVSQSAT"); + } + + if (!mngSat.setSatellitePriority("AmicalSat", 4)) { + System.err.println("SatNot found AmicalSat"); + } + + System.out.println("Nombre de passage calculés " + mngtSatPass.getSize()); + + mngtSatPass.sort(new SortbyAOS()); + // List filtered = + // mngtSatPass.filter(mngtSatPass.minDurationnPredicate); + // System.out.println(filtered.size()); + // mngtSatPass.setSatellitePassList(filtered); + // filtered = mngtSatPass.filter(mngtSatPass.minElevationPredicate); + // System.out.println(filtered.size()); + System.out.println("Satellite \t AOS \t LOS \t Duration \t Max El"); + Iterator it = mngtSatPass.getSatellitePassList().iterator(); + while (it.hasNext()) { + pass = it.next(); + System.out.println( + pass.getName() + + "\t" + + pass.getAOSDate() + + "\t" + + pass.getLOSDate() + + "\t" + + pass.getDuration() + + "\t" + + pass.getTca().getElevation()); + } + List filtered = mngtSatPass.selectPassByPriority(mngSat); + + System.out.println("Nombre de passage retenu " + filtered.size()); + pass = null; + System.out.println("Satellite \t AOS \t LOS \t Duration \t Max El"); + it = filtered.iterator(); + while (it.hasNext()) { + pass = it.next(); + System.out.println( + pass.getName() + + "\t" + + pass.getAOSDate() + + "\t" + + pass.getLOSDate() + + "\t" + + pass.getDuration() + + "\t" + + pass.getTca().getElevation()); + } + + // System.out.println(allPassages); + + // filtrage + + // int nbpassage = allPassages.size(); + // System.out.println("nb Passage "+nbpassage ); + // List filteredPassages = new ArrayList<>(); + // for (int i = 0; i < nbpassage-1; i++) { + // boolean overlap = false; + // for (int j = i + 1; j < nbpassage; j++) { + // if (allPassages.get(i).overlaps(allPassages.get(j))) { + // overlap = true; + // break; + // } + // } + // if (!overlap) { + // filteredPassages.add(passages.get(i)); + // } + // } + // // twoLine = tdr.getTle(keplerElt.getSatelliteNumber()); + // System.out.println(filteredPassages.size()); + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/performSatellitePass.java b/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/performSatellitePass.java new file mode 100644 index 0000000000000000000000000000000000000000..cfd443094df87673b538549ceaf63c70df764f5f --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/satellitePrediction/performSatellitePass.java @@ -0,0 +1,135 @@ +package org.josast.satellitePrediction; + +import java.util.List; +import java.util.Timer; +import java.util.TimerTask; + +import org.josast.satellite.SatelliteInformation; +import org.josast.satellite.SatelliteInformationInterface; +import org.josast.satellitePredictionG4DPZ.SatellitePropagation; +import org.josast.station.GroundStation; +import org.josast.station.GroundStationInterface; + +public class performSatellitePass { + + private long intervalle = 1000L; + private Treatment treatment; + private EndTreatment endtreatment; + + public void waitEnd() { + synchronized (treatment) { + try { + treatment.wait(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + public performSatellitePass( + GroundStationInterface groundStation, + SatelliteInformationInterface satellite, + SatellitePositionfromGroundStation aos, + SatellitePositionfromGroundStation los) { + treatment = new Treatment(groundStation, satellite); + endtreatment = new EndTreatment(treatment); + Timer timer = new Timer(); + + System.out.println(aos.getDate()); + System.out.println(los.getDate()); + timer.schedule(treatment, aos.getDate().toDate(), intervalle); + timer.schedule(endtreatment, los.getDate().toDate()); + } + + private class Treatment extends TimerTask { + + GroundStationInterface groundStation; + SatelliteInformationInterface satellite; + + public Treatment( + GroundStationInterface groundStation, SatelliteInformationInterface satellite) { + this.groundStation = groundStation; + this.satellite = satellite; + } + + @Override + public void run() { + System.out.println("compute Position"); + KeplerianElementTwoLineInterface keps = new KeplerianElementTwoLine(); + String tl2test = + "UVSQ-SAT \n1 47438U 21006AB 23257.15692707 .00023015 00000-0 86002-3 0 9991\n2 47438 97.3754 313.1180 0010700 125.0717 235.1527 15.27308596146216"; + + keps.setTwoLine(tl2test); + + InterfaceSatellitePropagation satProg = new SatellitePropagation(); + + System.out.println(" Step 3 : setup propagation"); + + satProg.setGroundStation(groundStation); + satProg.setSatelliteKeplerianElement(keps); + + System.out.println(" Step 4 : Display curent position"); + + SatellitePositionfromGroundStation pos = satProg.getCurrentPosition(); + System.out.println(pos); + } + } + + private class EndTreatment extends TimerTask { + + public EndTreatment(Treatment treatment) {} + + @Override + public void run() { + treatment.cancel(); + } + } + + public static void main(String[] args) { + System.out.println(" Step 1 : configuration station sol "); + double latitude = 48.858365; // 48.8330; + double longitude = 2.294532; // -2.3330; + double altitude = 75; + String name = "test Xtophe"; + GroundStationInterface groundStation = new GroundStation(name, altitude, longitude, latitude); + SatelliteInformationInterface sat = new SatelliteInformation("UVSQ-SAT", 47438); + + KeplerianElementTwoLineInterface keps = new KeplerianElementTwoLine(); + String tl2test = + "UVSQ-SAT \n1 47438U 21006AB 23257.15692707 .00023015 00000-0 86002-3 0 9991\n2 47438 97.3754 313.1180 0010700 125.0717 235.1527 15.27308596146216"; + + keps.setTwoLine(tl2test); + + InterfaceSatellitePropagation satProg = new SatellitePropagation(); + + System.out.println(" Step 3 : setup propagation"); + + satProg.setGroundStation(groundStation); + satProg.setSatelliteKeplerianElement(keps); + + System.out.println(" Step 4 : Display curent position"); + + SatellitePositionfromGroundStation pos = satProg.getCurrentPosition(); + System.out.println(pos); + + System.out.println(" Step 5 : Calcul passage "); + + SatellitePassfromGroundStation pass = satProg.getNextPass(); + System.out.println(pass); + + System.out.println(" Step 6 : Calcul ALL passage for 1 satellite"); + + List passages = satProg.getNextPass(24); + System.out.println(passages); + + if (passages.size() > 0) { + SatellitePassfromGroundStation passa = passages.get(0); + performSatellitePass perf = + new performSatellitePass(groundStation, sat, passa.getAos(), passa.getLos()); + perf.waitEnd(); + } else { + System.out.println("not found"); + } + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/satellitePredictionG4DPZ/SatellitePropagation.java b/ApplicationJMultisat/src/main/java/org/josast/satellitePredictionG4DPZ/SatellitePropagation.java new file mode 100644 index 0000000000000000000000000000000000000000..765137be10a410cd29df4ae576c48c783d311e9c --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/satellitePredictionG4DPZ/SatellitePropagation.java @@ -0,0 +1,182 @@ +package org.josast.satellitePredictionG4DPZ; + +import java.util.ArrayList; +import java.util.List; + +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; +import org.josast.satellitePrediction.InterfaceSatellitePropagation; +import org.josast.satellitePrediction.KeplerianElementTwoLineInterface; +import org.josast.satellitePrediction.SatellitePassfromGroundStation; +import org.josast.satellitePrediction.SatellitePositionfromGroundStation; +import org.josast.station.GroundStationInterface; + +import uk.me.g4dpz.satellite.GroundStationPosition; +import uk.me.g4dpz.satellite.SatPos; +import uk.me.g4dpz.satellite.Satellite; +import uk.me.g4dpz.satellite.SatelliteFactory; +import uk.me.g4dpz.satellite.TLE; + +public class SatellitePropagation implements InterfaceSatellitePropagation { + + private GroundStationInterface groundStation; + private GroundStationPosition groundStationPos; + Satellite satellite; + + public void setGroundStation(GroundStationInterface groundStation) { + this.groundStation = groundStation; + groundStationPos = + new GroundStationPosition( + groundStation.getLatitude(), + groundStation.getLongitude(), + groundStation.getAltitude(), + groundStation.getName()); + } + + public GroundStationInterface getGroundStation() { + return groundStation; + } + + public SatellitePositionfromGroundStation getCurrentPosition() { + DateTime timeNow = new DateTime(DateTimeZone.UTC); + SatPos satellitePosition = satellite.getPosition(groundStationPos, timeNow.toDate()); + SatellitePositionfromGroundStation satPos = + new SatellitePositionfromGroundStation( + satellite.getTLE().getName(), + satellite.getTLE().getCatnum(), + satellitePosition.getAzimuth(), + satellitePosition.getElevation(), + satellitePosition.getRange(), + timeNow); + + return satPos; + } + + public SatellitePositionfromGroundStation getPosition(DateTime date) { + return null; + } + + public SatellitePassfromGroundStation getNextPass() { + SatellitePassfromGroundStation pass = null; + DateTime timeNow = new DateTime(DateTimeZone.UTC); + DateTime timeNowRef = timeNow.plusDays(1); + SatPos satellitePosition = null; + SatPos satellitePositionPrev = null; + boolean visible = false; + DateTime timeTca = null; + + boolean found = false; + boolean timeOut = false; + + while (!found && !timeOut) { + + // for (int j = 0; j < 10000; j++) { + + satellitePosition = satellite.getPosition(groundStationPos, timeNow.toDate()); + + // satPos[i] = calcualteCurrentPosition(timeNow, list.get(i), groundStation); + if (satellitePosition.getElevation() > 0 && visible == false) { + pass = new SatellitePassfromGroundStation(); + pass.setAos(convertFrom(satellitePosition, timeNow)); + // System.out.println("AOS :"+ pass.getAos()); + visible = true; + satellitePositionPrev = satellitePosition; + + } else if (satellitePosition.getElevation() < 0 && visible == true) { + pass.setLos(convertFrom(satellitePosition, timeNow)); + // System.out.println("LOS :"+ pass.getLos()); + visible = false; + found = true; + } + + if (visible) { + if (satellitePositionPrev.getElevation() < satellitePosition.getElevation()) { + satellitePositionPrev = satellitePosition; + timeTca = timeNow; + } + } + timeNow = timeNow.plus(250); + if (timeNow.compareTo(timeNowRef) > 0) { + timeOut = true; + } + } + if (satellitePositionPrev != null) { + pass.setTca(convertFrom(satellitePositionPrev, timeTca)); + } + + return pass; + } + + @Override + public void setSatelliteKeplerianElement(KeplerianElementTwoLineInterface keplerien) { + + TLE tle = new TLE(keplerien.getTwoLine()); + satellite = SatelliteFactory.createSatellite(tle); + } + + private SatellitePositionfromGroundStation convertFrom(SatPos satellitePosition, DateTime time) { + + return new SatellitePositionfromGroundStation( + satellite.getTLE().getName(), + satellite.getTLE().getCatnum(), + satellitePosition.getAzimuth() / (Math.PI * 2.0) * 360.0, + satellitePosition.getElevation() / (Math.PI * 2.0) * 360.0, + satellitePosition.getRange(), + time); + } + + @Override + public List getNextPass(int hour) { + + List listPassage = + new ArrayList(); + SatellitePassfromGroundStation pass = null; + DateTime timeNow = new DateTime(DateTimeZone.UTC); + DateTime timeNowRef = timeNow.plusHours(hour); + SatPos satellitePosition = null; + SatPos satellitePositionPrev = null; + boolean visible = false; + DateTime timeTca = null; + + boolean timeOut = false; + + while (!timeOut) { + + // for (int j = 0; j < 10000; j++) { + + satellitePosition = satellite.getPosition(groundStationPos, timeNow.toDate()); + + // satPos[i] = calcualteCurrentPosition(timeNow, list.get(i), groundStation); + if (satellitePosition.getElevation() > 0 && visible == false) { + pass = new SatellitePassfromGroundStation(); + pass.setAos(convertFrom(satellitePosition, timeNow)); + // System.out.println("AOS :"+ pass.getAos()); + visible = true; + satellitePositionPrev = satellitePosition; + + } else if (satellitePosition.getElevation() < 0 && visible == true) { + pass.setLos(convertFrom(satellitePosition, timeNow)); + // System.out.println("LOS :"+ pass.getLos()); + visible = false; + + if (satellitePositionPrev != null) { + pass.setTca(convertFrom(satellitePositionPrev, timeTca)); + } + listPassage.add(pass); + } + + if (visible) { + if (satellitePositionPrev.getElevation() < satellitePosition.getElevation()) { + satellitePositionPrev = satellitePosition; + timeTca = timeNow; + } + } + timeNow = timeNow.plus(250); + if (timeNow.compareTo(timeNowRef) > 0) { + timeOut = true; + } + } + + return listPassage; + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/station/GroundStation.java b/ApplicationJMultisat/src/main/java/org/josast/station/GroundStation.java new file mode 100644 index 0000000000000000000000000000000000000000..134fe6fb83b94e65895200f7786948646c057a49 --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/station/GroundStation.java @@ -0,0 +1,128 @@ +/** */ +package org.josast.station; + +/** + * Cette classe représente une station au sol pour un radioamateur. Elle contient les informations + * suivantes : nom, altitude, longitude et latitude. + */ +public class GroundStation implements GroundStationInterface { + private String nom; + private double altitude; + private double longitude; + private double latitude; + + /** + * Constructeur de la classe GroundStation. + * + * @param nom Le nom de la station. + * @param altitude L'altitude de la station. + * @param longitude La longitude de la station. + * @param latitude La latitude de la station. + */ + public GroundStation(String nom, double altitude, double longitude, double latitude) { + this.nom = nom; + this.altitude = altitude; + this.longitude = longitude; + this.latitude = latitude; + } + + /** + * Retourne le nom de la station. + * + * @return Le nom de la station. + */ + @Override + public String getName() { + return nom; + } + + /** + * Modifie le nom de la station. + * + * @param nom Le nouveau nom de la station. + */ + @Override + public void setName(String nom) { + this.nom = nom; + } + + /** + * Retourne l'altitude de la station. + * + * @return L'altitude de la station. + */ + @Override + public double getAltitude() { + return altitude; + } + + /** + * Modifie l'altitude de la station. + * + * @param altitude La nouvelle altitude de la station. + */ + @Override + public void setAltitude(double altitude) { + this.altitude = altitude; + } + + /** + * Retourne la longitude de la station. + * + * @return La longitude de la station. + */ + @Override + public double getLongitude() { + return longitude; + } + + /** + * Modifie la longitude de la station. + * + * @param longitude La nouvelle longitude de la station. + */ + @Override + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + /** + * Retourne la latitude de la station. + * + * @return La latitude de la station. + */ + @Override + public double getLatitude() { + return latitude; + } + + /** + * Modifie la latitude de la station. + * + * @param latitude La nouvelle latitude de la station. + */ + @Override + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + /** + * Retourne une chaîne de caractères représentant la station. + * + * @return Une chaîne de caractères représentant la station. + */ + @Override + public String toString() { + return "GroundStation{" + + "nom='" + + nom + + '\'' + + ", altitude=" + + altitude + + ", longitude=" + + longitude + + ", latitude=" + + latitude + + '}'; + } +} diff --git a/ApplicationJMultisat/src/main/java/org/josast/station/GroundStationInterface.java b/ApplicationJMultisat/src/main/java/org/josast/station/GroundStationInterface.java new file mode 100644 index 0000000000000000000000000000000000000000..babb57178abd59d49185550fa7fe3276de4c22a5 --- /dev/null +++ b/ApplicationJMultisat/src/main/java/org/josast/station/GroundStationInterface.java @@ -0,0 +1,67 @@ +package org.josast.station; + +public interface GroundStationInterface { + + /** + * Retourne le nom de la station. + * + * @return Le nom de la station. + */ + String getName(); + + /** + * Modifie le nom de la station. + * + * @param nom Le nouveau nom de la station. + */ + void setName(String nom); + + /** + * Retourne l'altitude de la station. + * + * @return L'altitude de la station. + */ + double getAltitude(); + + /** + * Modifie l'altitude de la station. + * + * @param altitude La nouvelle altitude de la station. + */ + void setAltitude(double altitude); + + /** + * Retourne la longitude de la station. + * + * @return La longitude de la station. + */ + double getLongitude(); + + /** + * Modifie la longitude de la station. + * + * @param longitude La nouvelle longitude de la station. + */ + void setLongitude(double longitude); + + /** + * Retourne la latitude de la station. + * + * @return La latitude de la station. + */ + double getLatitude(); + + /** + * Modifie la latitude de la station. + * + * @param latitude La nouvelle latitude de la station. + */ + void setLatitude(double latitude); + + /** + * Retourne une chaîne de caractères représentant la station. + * + * @return Une chaîne de caractères représentant la station. + */ + String toString(); +} diff --git a/ApplicationJMultisat/src/main/resources/log4j2.xml b/ApplicationJMultisat/src/main/resources/log4j2.xml new file mode 100644 index 0000000000000000000000000000000000000000..d43be8abcec81013b6776554a81bf7a9107495ac --- /dev/null +++ b/ApplicationJMultisat/src/main/resources/log4j2.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ApplicationJMultisat/src/main/resources/org/josast/application/dialogApplication.fxml b/ApplicationJMultisat/src/main/resources/org/josast/application/dialogApplication.fxml new file mode 100644 index 0000000000000000000000000000000000000000..9b8a8b8ce218c9b068021e9c0f9b8d20681bad92 --- /dev/null +++ b/ApplicationJMultisat/src/main/resources/org/josast/application/dialogApplication.fxml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + +

+
+ + + + + + + + + + + + + + + + + + + + +