diff --git a/ApplicationCubesatSim/pom.xml b/ApplicationCubesatSim/pom.xml index aadbca333cfadd3f45d820b7f0cfb79705d76fe4..1c0fe64da1e55d012013c705b9d8ab74b89ba0ce 100644 --- a/ApplicationCubesatSim/pom.xml +++ b/ApplicationCubesatSim/pom.xml @@ -9,7 +9,7 @@ ApplicationCubesatSim - 1.2 + ApplicationCubesatSim @@ -22,6 +22,7 @@ 1.8 ${env.JAVA_HOME} 0.1.5 + ${josast.version} @@ -34,7 +35,7 @@ org.josast ModuleCubesatSim - 1.2 + ${ModuleCubesatSim.version} commons-cli diff --git a/ApplicationKissTool/pom.xml b/ApplicationKissTool/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..aa8e34adee53ebe5c7d4b8475cd7b860b057b531 --- /dev/null +++ b/ApplicationKissTool/pom.xml @@ -0,0 +1,136 @@ + + 4.0.0 + + + org.josast + JOSAST-parent + 0.0.2 + + + + ApplicationKissTool + 0.0.1-SNAPSHOT + + UTF-8 + 11 + 11 + + + + + ${josast.version} + ${josast.version} + ${josast.version} + 13 + + + + + + org.openjfx + javafx-controls + ${JavaFx.version} + + + org.openjfx + javafx-graphics + ${JavaFx.version} + + + org.openjfx + javafx-base + ${JavaFx.version} + + + org.openjfx + javafx-fxml + ${JavaFx.version} + + + org.openjfx + javafx-web + ${JavaFx.version} + + + org.openjfx + javafx-media + ${JavaFx.version} + + + org.openjfx + javafx-swing + ${JavaFx.version} + + + + + + + + + + + + org.josast + ModuleSIDS + ${ModuleSIDS.version} + + + org.josast + ModuleSoundModem + ${ModuleSoundModem.version} + + + org.josast + ModuleConfig + ${ModuleConfig.version} + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 11 + + + + org.openjfx + javafx-maven-plugin + 0.0.4 + + org.josast.ApplicationKissTool.App + + + + org.apache.maven.plugins + maven-assembly-plugin + + + make-assembly + package + + single + + + + + + + + org.josast.ApplicationKissTool.App + + + + + jar-with-dependencies + + + + + + \ No newline at end of file diff --git a/ApplicationKissTool/src/main/java/module-info.java b/ApplicationKissTool/src/main/java/module-info.java new file mode 100644 index 0000000000000000000000000000000000000000..3691fcbb8c4b6ff52577a63f3dac53541406c945 --- /dev/null +++ b/ApplicationKissTool/src/main/java/module-info.java @@ -0,0 +1,14 @@ +module org.josast.ApplicationKissTool { + requires javafx.controls; + requires javafx.fxml; + requires java.logging; + requires javafx.graphics; + requires java.desktop; + requires ModuleSoundModem; + requires ModuleSIDS; + requires ModuleConfig; + requires javafx.swing; + + opens org.josast.ApplicationKissTool to javafx.fxml; + exports org.josast.ApplicationKissTool; +} \ No newline at end of file diff --git a/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/AlertHelper.java b/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/AlertHelper.java new file mode 100644 index 0000000000000000000000000000000000000000..6ba50ef331bd9c420cf30e3e4270a797fa6b94aa --- /dev/null +++ b/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/AlertHelper.java @@ -0,0 +1,28 @@ +package org.josast.ApplicationKissTool; + +import javafx.scene.control.Alert; +import javafx.stage.Window; + +public class AlertHelper { + + private AlertHelper() + { + + } + /** + * Display a window in order to display a message + * @param alertType Type of alert + * @param owner + * @param title title of the windows + * @param message message to display + */ + public static void showAlert(Alert.AlertType alertType, Window owner, String title, String message) { + Alert alert = new Alert(alertType); + alert.setTitle(title); + alert.setHeaderText(null); + alert.setContentText(message); + alert.initOwner(owner); + alert.show(); + } + +} diff --git a/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/App.java b/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/App.java new file mode 100644 index 0000000000000000000000000000000000000000..8545ad993c126dc0ec98e6c08c6fa58ff2cbb6f2 --- /dev/null +++ b/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/App.java @@ -0,0 +1,82 @@ +package org.josast.ApplicationKissTool; + +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.stage.Stage; + +import java.io.File; +import java.io.IOException; +import java.util.logging.FileHandler; +import java.util.logging.Handler; +import java.util.logging.Logger; + + + +/** + * JavaFX App + */ +public class App extends Application { + + private static Scene scene; + private static FXMLLoader fxmlLoader; + private static Logger logger = Logger.getLogger("AmsatLogger"); + + @Override + public void start(Stage stage) throws IOException { + + System.setProperty("glass.accessible.force", "false"); + scene = new Scene(loadFXML("KissTool"), 800, 600); + stage.setScene(scene); + + + Controler ctrl = fxmlLoader.getController(); + ctrl.setPrimaryStage(stage); + scene.getStylesheets().add(this.getClass().getResource("boot.css").toExternalForm()); + stage.setTitle("KISS tool"); + ctrl.initMMI(); + 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) { + // initialisation du systéme de log en premier + try { + String path = System.getProperty("user.dir") + "/log"; + File apath = new File(path); + + if (!apath.exists()) { + if (apath.mkdir() == false) { + System.err.println("fail to create " + path); + } + } + FileHandler fh = new FileHandler(path + "/" + "KissTool.log"); + logger.setUseParentHandlers(false); + Handler[] handlers = logger.getHandlers(); + for (Handler handler : handlers) { + logger.removeHandler(handler); + } + logger.addHandler(fh); + + } catch (SecurityException e) { + + e.printStackTrace(); + + } catch (IOException e) { + + e.printStackTrace(); + + } + launch(); + } + +} \ No newline at end of file diff --git a/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/Configuration.java b/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/Configuration.java new file mode 100644 index 0000000000000000000000000000000000000000..33af419cb2162f01bcee1fb970a9342771b507db --- /dev/null +++ b/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/Configuration.java @@ -0,0 +1,237 @@ +/** + * + */ +package org.josast.ApplicationKissTool; + +import org.josast.property.CONFIG; + +/** + * Singleton to manage all application parameter + * The default configuration is automaticaly saved in a properties file. + * @author christophe + * + * + */ +public class Configuration { + + + /* + * parameter with default value + */ + private String callsign="Anonymous"; + private String longitude="0.0W"; + private String latitude="0.0N"; + + private String soundModemIP="127.0.0.1"; + private String soundModemPort="8100"; + + private String SIDSAMSATSource="Anonymous"; + private String SIDSAMSATUrl="https://amsat.electrolab.fr/SIDS"; + private String SIDSSatnogsSource="Anonymous"; + private String SIDSSatnogsURL="https://db.satnogs.org/api/telemetry/"; + private String SIDSSatnogs="0"; + private String SIDSAMSAT="1"; + private boolean SISD_SatNogs = false; + private boolean SIDS_AMSAT = true; + + + private CONFIG conf = CONFIG.getInstance(); + + public static Configuration getInstance() + { + return SingletonHolder.instance; + } + + public boolean isSISD_SatNogs() { + + return SISD_SatNogs; + } + + + + private Configuration() + { + if ( conf.GetProperty("Callsign")!=null) + { + callsign = conf.GetProperty("Callsign"); + latitude = conf.GetProperty("Latitude"); + longitude = conf.GetProperty("Longitude"); + + SIDSAMSATSource=conf.GetProperty("SIDSAMSATSource"); + SIDSAMSATUrl=conf.GetProperty("SIDSAMSATUrl"); + SIDSSatnogsSource=conf.GetProperty("SIDSSatnogsSource"); + SIDSSatnogsURL=conf.GetProperty("SIDSSatnogsURL"); + SIDSSatnogs=conf.GetProperty("SIDSSatnogs"); + SIDSAMSAT=conf.GetProperty("SIDSAMSAT"); + soundModemIP = conf.GetProperty("soundModemIP"); + soundModemPort = conf.GetProperty("soundModemPort"); + if (SIDSSatnogs.contentEquals("1") ) + { + SISD_SatNogs=true; + } else + { + SISD_SatNogs=false; + } + if (SIDSAMSAT.contentEquals("1") ) + { + SIDS_AMSAT=true; + } else + { + SIDS_AMSAT=false; + } + + } + else // si le fichier n'existe pas, il est créé par défaut + { + save(); + } + + + } + + + private static class SingletonHolder + { + + private final static Configuration instance = new Configuration(); + } + + + + + public void setSIDSSatnogs(String sIDSSatnogs) { + SIDSSatnogs = sIDSSatnogs; + if (SIDSSatnogs.contentEquals("1") ) + { + SISD_SatNogs=true; + } else + { + SISD_SatNogs=false; + } + } + + + public void setSIDSAMSAT(String sIDSEntrySat) { + SIDSAMSAT = sIDSEntrySat; + if (SIDSAMSAT.contentEquals("1") ) + { + SIDS_AMSAT=true; + } else + { + SIDS_AMSAT=false; + } + } + + + public void save() { + + conf.SetProperty("Callsign",callsign); + conf.SetProperty("Latitude",latitude); + conf.SetProperty("Longitude",longitude); + conf.SetProperty("SIDSAMSATSource",this.SIDSAMSATSource); + conf.SetProperty("SIDSAMSATUrl",this.SIDSAMSATUrl); + conf.SetProperty("SIDSSatnogsSource",this.SIDSSatnogsSource); + conf.SetProperty("SIDSSatnogsURL",this.SIDSSatnogsURL); + conf.SetProperty("SIDSSatnogs",this.SIDSSatnogs); + conf.SetProperty("SIDSAMSAT",this.SIDSAMSAT); + conf.SetProperty("soundModemPort",this.soundModemPort); + conf.SetProperty("soundModemIP",this.soundModemIP); + } + + public String getCallsign() { + return callsign; + } + + public void setCallsign(String callsign) { + this.callsign = callsign; + } + + public String getLongitude() { + return longitude; + } + + public void setLongitude(String longitude) { + this.longitude = longitude; + } + + public String getLatitude() { + return latitude; + } + + public void setLatitude(String latitude) { + this.latitude = latitude; + } + + public String getSoundModemIP() { + return soundModemIP; + } + + public void setSoundModemIP(String soundModemIP) { + this.soundModemIP = soundModemIP; + } + + public String getSoundModemPort() { + return soundModemPort; + } + + public void setSoundModemPort(String soundModemPort) { + this.soundModemPort = soundModemPort; + } + + public String getSIDSAMSATSource() { + return SIDSAMSATSource; + } + + public void setSIDSAMSATSource(String sIDSAMSATSource) { + SIDSAMSATSource = sIDSAMSATSource; + } + + public String getSIDSAMSATUrl() { + return SIDSAMSATUrl; + } + + public void setSIDSAMSATUrl(String sIDSAMSATUrl) { + SIDSAMSATUrl = sIDSAMSATUrl; + } + + public String getSIDSSatnogsSource() { + return SIDSSatnogsSource; + } + + public void setSIDSSatnogsSource(String sIDSSatnogsSource) { + SIDSSatnogsSource = sIDSSatnogsSource; + } + + public String getSIDSSatnogsURL() { + return SIDSSatnogsURL; + } + + public void setSIDSSatnogsURL(String sIDSSatnogsURL) { + SIDSSatnogsURL = sIDSSatnogsURL; + } + + + + + + public boolean isSIDS_AMSAT() { + return SIDS_AMSAT; + } + + + + public CONFIG getConf() { + return conf; + } + + public void setConf(CONFIG conf) { + this.conf = conf; + } + + public void setSISD_SatNogs(boolean sISD_SatNogs) { + SISD_SatNogs = sISD_SatNogs; + } + + + +} diff --git a/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/Controler.java b/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/Controler.java new file mode 100644 index 0000000000000000000000000000000000000000..6e7823fa52ed9cd9b8765aabb0f306add29d591a --- /dev/null +++ b/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/Controler.java @@ -0,0 +1,565 @@ +package org.josast.ApplicationKissTool; + +import java.awt.image.BufferedImage; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.logging.Logger; + +import javax.imageio.ImageIO; + +import org.josast.AX25.AX25DecodedData; +import org.josast.ModuleSoundModem.SoundModemConfiguration; +import org.josast.SIDS.Station; + + + + +import org.josast.propertyHttp.ConfigHttp; +//import org.josast.uvsqsat.Frame; +//import org.josast.uvsqsat.generated.Uvsqsat; + +import io.kaitai.struct.ByteBufferKaitaiStream; +import javafx.application.Platform; +import javafx.concurrent.WorkerStateEvent; + +import javafx.event.ActionEvent; +import javafx.event.EventHandler; + +//import java.util.logging.Logger; + +import javafx.fxml.FXML; +import javafx.scene.control.Alert; +import javafx.scene.control.Button; +import javafx.scene.control.CheckBox; +import javafx.scene.control.Label; +import javafx.scene.control.TextArea; +import javafx.scene.control.TextField; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.stage.Stage; +import javafx.stage.Window; +import javafx.embed.swing.SwingFXUtils; + +public class Controler { + + private static final String LINE_SEPARATOR = "\r\n"; + private static final int STATE_INIT = 0; + private static final int STATE_START = 1; + protected static final int STATE_STOP = 2; + private static final int STATE_SAVE = 3; + + private static Logger appLogger = Logger.getLogger("AmsatLogger"); + + private String version = "1.0"; + + @FXML + private Button ButtonStart; + @FXML + private Button ButtonStop; + @FXML + private Button ButtonSave; + @FXML + private Label LabelIP; + + @FXML + private Button ButtonFile; + @FXML + private Button ButtonSerial; + @FXML + private Button ButtonKiss; + + @FXML + private TextField FieldIP; + @FXML + private TextField FieldPort; + + @FXML + private Label labelStatus; + @FXML + private Label LabelFrame; + + @FXML + private TextArea DecodedData; + + @FXML + private TextArea TexAreaLog; + + @FXML + private TextField textFieldMode; + + @FXML + private TextField textFieldDate; + + @FXML + private Label LabelInformation; + + @FXML + private ImageView ImageViewAMSAT; + + @FXML + private ImageView imageViewEntrysat; + + @FXML + private TextField TextFieldCallsign; + @FXML + private TextField TextFieldLatitude; + @FXML + private TextField TextFieldLongitude; + + @FXML + private CheckBox CheckbBoxAmicalSat; + @FXML + private CheckBox CheckBoxSatNogs; + + @FXML + private Button ButtonSaveConfiguration; + + @FXML + private TextField TextFieldSIDSEntrysat; + @FXML + private TextField TextFieldSIDSSatnogs; + + + + Stage primaryStage = null; + + private String imgAmsat = "logoAmsat.png"; + private String imgAmicalsat = "logoAmsat.png"; + + Station station = new Station(); + + ModelReceivedData receivedFrame = new ModelReceivedData(); + Configuration conf = Configuration.getInstance(); + + private TaskSoundmodemTCP task; + private SendSIDS SendSIDSSatnogs; + private SendSIDS SendSIDSMVPAmsat; + + private LogFile logfile = null; + private String generateRepository ="./ouputFile"; + private int cpt=0; + + @FXML + private void HandleSaveConfiguration(ActionEvent event) { + + String erreurmsg = null; + String Callsign = null; + + if (TextFieldCallsign.getText().isEmpty()) { + erreurmsg += "please enter a CallSign \r\n"; + } else { + Callsign = TextFieldCallsign.getText(); + } + + String Latitude = TextFieldLatitude.getText(); + String Longitude = TextFieldLongitude.getText(); + + if (station.checkLatitude(Latitude) == false) { + erreurmsg += "Wrong format for Latitude : XX.XXE/W \r\n"; + } + + if (station.checkLongitude(Longitude) == false) { + erreurmsg += "Wrong format for Longitude : XX.XXS/N \r\n"; + } + if (erreurmsg != null) { + Window owner = ButtonSaveConfiguration.getScene().getWindow(); + AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Form Error!", + erreurmsg); + return; + } + + station.setCallsign(Callsign); + station.setLatitude(Latitude); + station.setLongitude(Longitude); + + conf.setCallsign(Callsign); + conf.setLatitude(Latitude); + conf.setLongitude(Longitude); + + conf.setSIDSAMSATSource(TextFieldSIDSEntrysat.getText()); + conf.setSIDSSatnogsSource(TextFieldSIDSSatnogs.getText()); + conf.setSoundModemIP(FieldIP.getText()); + conf.setSoundModemPort(FieldPort.getText()); + + Station StationSatnogs = new Station(conf.getSIDSSatnogsSource(), + station.getLongitude(), station.getLatitude()); + Station StationEntry = new Station(conf.getSIDSAMSATSource(), + station.getLongitude(), station.getLatitude()); + + if (CheckbBoxAmicalSat.isSelected() == true) { + conf.setSIDSAMSAT("1"); +//@Todo : revoir SendSIDS +// SendSIDSMVPAmsat = new SendSIDS(StationEntry, conf.getNorad(), +// conf.getSIDSAMSATUrl()); + } else { + conf.setSIDSAMSAT("0"); + + } + + if (CheckBoxSatNogs.isSelected() == true) { + conf.setSIDSSatnogs("1"); +//@Todo : revoir SendSIDS +// SendSIDSSatnogs = new SendSIDS(StationSatnogs, conf.getNorad(), +// conf.getSIDSSatnogsURL()); + } else { + conf.setSIDSSatnogs("0"); + } + + conf.save(); + manageStatusinformation("Configuration Saved", "Configuration Saved"); + + } + + @FXML + private void handleStart(ActionEvent event) { + + manageStatusinformation("Connected to modem", "Connection to modem"); + manageStateMMI(STATE_START); + + // TODO : to improve + SoundModemConfiguration smc = new SoundModemConfiguration("default"); + smc.setSmIPadress(FieldIP.getText()); + smc.setSmPort(Integer.parseInt(FieldPort.getText())); + + if (task == null) { + receivedFrame + .addPropertyChangeListener(new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + final ReceivedData decodedData = receivedFrame + .getLastReceivedData(); + Platform.runLater(new Runnable() { + @Override + public void run() { + try { + + if (decodedData != null) { + displayLog(decodedData.toString()); + AX25DecodedData ax25 = new AX25DecodedData(decodedData.getData()); + DecodedData.appendText("\r\n"); + DecodedData.appendText(decodedData.getTime().toString()); + DecodedData.appendText(ax25.toStringHeader()); + DecodedData.appendText(ax25.toStringData()); + DecodedData.appendText("\r\n"); + + saveRawFile(decodedData.getData()); + + updateFrame(receivedFrame + .getNumberFrame()); +// if (ax25.source.contains("LATMOS")) +// { +// System.out.println("UVSqat"); +// Uvsqsat cube = new Uvsqsat(new ByteBufferKaitaiStream(decodedData.getData())); +// Frame frame = new Frame (); +// frame.setUp(cube); +// DecodedData.appendText(frame.toString()); +// DecodedData.appendText("\r\n"); +// } + +// UpdateDecodedData(decodedData); +// SendSids(receivedFrame.getLastReceivedData()); + + } else { + displayLog( + "received frame : null"); + } + + } catch (Exception e) { + displayLog("Run - error"); + displayLog(e.toString()); + e.printStackTrace(); + } + + } + + + }); + } + + } + + ); + + } + task = new TaskSoundmodemTCP(smc, receivedFrame); + + task.setOnSucceeded(new EventHandler() { + + @Override + public void handle(WorkerStateEvent event) { + // La tache s'est correctement terminee. + manageStatusinformation("KISS TCP CONNECTION FAILED", + "KISS TCP DISCONNECTED"); + manageStateMMI(STATE_STOP); + + } + + }); + + task.setOnFailed(new EventHandler() { + + @Override + public void handle(WorkerStateEvent event) { + // La tache s'est correctement terminee. + manageStatusinformation("KISS TCP CONNECTION FAILED", + "KISS TCP DISCONNECTED - Connection failed"); + displayLog(event.toString()); + displayLog(event.getSource().toString()); + manageStateMMI(STATE_STOP); + } + + }); + + Thread backgroundThread = new Thread(task); + backgroundThread.setDaemon(true); + backgroundThread.start(); + + } + + @FXML + private void handleStop(ActionEvent event) { + + manageStateMMI(STATE_STOP); + task.arreter(); + manageStatusinformation("Stop received data", + "Stop task to receive telemetrie"); + } + + @FXML + private void handleSave(ActionEvent event) { + + manageStateMMI(STATE_SAVE); + manageStatusinformation("save data", "save Telemetry in file"); + saveDataFile(); + manageStatusinformation("Data Saved", "Telemetry Data saved in file"); + } + + @FXML + private void HandleIP(ActionEvent event) { + } + + @FXML + private void HandlePort(ActionEvent event) { + } + + public void initMMI() { + + logfile = new LogFile(); + // initialise le log + // initdisplayLogFile(); + + manageStatusinformation("Initialised", + "KISS TOOL - LOG \r\n Initialise application"); + appLogger.warning("Initialise "); + primaryStage.setTitle("KISS TOOL - " + version); + + station.setCallsign(conf.getCallsign()); + station.setLatitude(conf.getLatitude()); + station.setLongitude(conf.getLongitude()); + + TextFieldCallsign.setText(station.getCallsign()); + TextFieldLatitude.setText(station.getLatitude()); + TextFieldLongitude.setText(station.getLongitude()); + + TextFieldSIDSEntrysat.setText(conf.getSIDSAMSATSource()); + TextFieldSIDSSatnogs.setText(conf.getSIDSSatnogsSource()); + + if (conf.isSIDS_AMSAT()) { + CheckbBoxAmicalSat.setSelected(true); + } + if (conf.isSISD_SatNogs()) { + CheckBoxSatNogs.setSelected(true); + } + + displayLog(conf.getSIDSSatnogsURL()); + displayLog(conf.getSIDSAMSATUrl()); + displayLog("Initialisation with Properties File Done "); + + BufferedImage bufferedImage1 = null; + BufferedImage bufferedImage2 = null; + + try { + + bufferedImage1 = ImageIO.read(getClass().getResource((imgAmsat))); + bufferedImage2 = ImageIO + .read(getClass().getResource((imgAmicalsat))); + } catch (IOException e) { + + appLogger.severe("Error loading Image resources"); + appLogger.severe(e.toString()); + } + Image imageamsat = SwingFXUtils.toFXImage(bufferedImage1, null); + ImageViewAMSAT.setImage(imageamsat); + Image imgQB = SwingFXUtils.toFXImage(bufferedImage2, null); + imageViewEntrysat.setImage(imgQB); + + ConfigHttp c = new ConfigHttp( + "http://site.amsat-f.org/download/117168/"); + String ver; + String message; + + if (c.isConnected()) { + ver = c.GetProperty("AmicalsatVersion"); + message = c.GetProperty("Message"); + } else { + ver = version; + message = "not connected to internet"; + } + + + manageStateMMI(STATE_INIT); + manageStatusinformation("Application Ready", "Application initialised"); + this.LabelInformation.setText(""); + + // initialise SIDS + + Station StationSatnogs = new Station(conf.getSIDSSatnogsSource(), + station.getLongitude(), station.getLatitude()); + Station StationEntry = new Station(conf.getSIDSAMSATSource(), + station.getLongitude(), station.getLatitude()); + + if (conf.isSISD_SatNogs() == true) { +// SendSIDSSatnogs = new SendSIDS(StationSatnogs, conf.getNorad(), +// conf.getSIDSSatnogsURL()); + } + + if (conf.isSIDS_AMSAT() == true) { +// SendSIDSMVPAmsat = new SendSIDS(StationEntry, conf.getNorad(), +// conf.getSIDSAMSATUrl()); + } + + String erreurmsg = message; + + if (ver.equals(version) == false) { + erreurmsg += " New version " + ver + " available ! "; + + } + this.LabelInformation.setText(erreurmsg); + + } + + public void setPrimaryStage(Stage primaryStage) { + this.primaryStage = primaryStage; + + } + + /** + * Save telemetry data received in text file. The file is stored in data + * folder. + */ + public void saveDataFile() { + SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd-HHmmss"); + Date aujourdhui = new Date(); + + // + + String path = System.getProperty("user.dir") + "/data"; + File apath = new File(path); + + if (!apath.exists()) { + if (apath.mkdir() == false) { + appLogger.severe("fail to create " + path); + } + } + + PrintWriter pw = null; + + long NbFrame = receivedFrame.getNumberFrame(); + + try { + pw = new PrintWriter(new FileWriter(path + "/" + + formater.format(aujourdhui) + "-tlm-Hexa.txt")); + for (int i = 0; i < NbFrame; i++) { + pw.write(receivedFrame.getRawFrame(i)); + pw.write(LINE_SEPARATOR); + } + + pw.flush(); + pw.close(); + } catch (IOException e) { + e.printStackTrace(); + } + + } + + private void updateFrame(long nbframe) { + LabelFrame.setText("frame : " + nbframe); + + } + + private void displayLog(String log) { + appLogger.info(log); + logfile.displayLog(log); + TexAreaLog.appendText(log); + TexAreaLog.appendText("\r\n"); + } + + private void manageStateMMI(int state) { + switch (state) { + case STATE_INIT: + ButtonStop.setDisable(true); + ButtonStart.setDisable(false); + ButtonSave.setDisable(true); + break; + case STATE_START: + ButtonStop.setDisable(false); + ButtonStart.setDisable(true); + ButtonSave.setDisable(false); + break; + case STATE_STOP: + ButtonStop.setDisable(true); + ButtonStart.setDisable(false); + ButtonSave.setDisable(false); + break; + case STATE_SAVE: + ButtonStop.setDisable(true); + ButtonStart.setDisable(false); + ButtonSave.setDisable(true); + break; + default : + ButtonStop.setDisable(true); + ButtonStart.setDisable(false); + ButtonSave.setDisable(false); + break; + } + } + + private void manageStatusinformation(String statusMessage, + String logMessage) { + labelStatus.setText(statusMessage); + displayLog(logMessage); + + } + + + private void SendSids(ReceivedData receivedData) { + + if (conf.isSIDS_AMSAT() == true) { + int results = SendSIDSMVPAmsat.Send(receivedData); + displayLog("Send SIDS AMSAT-F Database ; "+results); + } + + if (conf.isSISD_SatNogs() == true) { + int results = SendSIDSSatnogs.Send(receivedData); + displayLog("Send SIDS SatNogs Database : "+results ); + } + } + + private void saveRawFile(byte[] data) + { + try { + Files.write(Paths.get(generateRepository + "\\Frame_" + cpt+++".bin"), data); + } catch (IOException e) { + displayLog(e.toString()); + } + } + +} diff --git a/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/LogFile.java b/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/LogFile.java new file mode 100644 index 0000000000000000000000000000000000000000..78263019ae93c656be4f92229de5f6ec8a924c41 --- /dev/null +++ b/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/LogFile.java @@ -0,0 +1,65 @@ +/** + * + */ +package org.josast.ApplicationKissTool; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.logging.Logger; + +/** + * @author christophe + * + */ +public class LogFile { + + private static Logger appLogger = Logger.getLogger("AmsatLogger"); + private PrintWriter pw; + + /** + * + */ + public LogFile() { + // TODO Auto-generated constructor stub + initdisplayLogFile(); + } + + + private void initdisplayLogFile() + { + + + SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd-HHmmss"); + Date aujourdhui = new Date(); + String path = System.getProperty("user.dir") + "/log"; + File apath = new File(path); + + if (!apath.exists()) { + if (apath.mkdir() == false) { + appLogger.severe("fail to create " + path); + } + } + try { + pw = new PrintWriter (new FileWriter(path+"/"+formater.format(aujourdhui)+"-"+".log")); + } catch (IOException e) { + appLogger.severe("erreur creating log file"); + appLogger.severe (e.toString()); + } + } + + public void displayLog(String log) { + if(pw!=null) + { + pw.println(log); + pw.flush(); + } + appLogger.info(log); + + } + + +} diff --git a/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/ModelReceivedData.java b/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/ModelReceivedData.java new file mode 100644 index 0000000000000000000000000000000000000000..a2c89014398dc88f78296c721935486d510ae308 --- /dev/null +++ b/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/ModelReceivedData.java @@ -0,0 +1,65 @@ +package org.josast.ApplicationKissTool; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.util.Date; +import java.util.Vector; + + + + + + +public class ModelReceivedData { + + long numberFrame = 0; + Vector vecRawData = new Vector(); + + + + private PropertyChangeSupport listenerList = new PropertyChangeSupport(this); + + public void addPropertyChangeListener(PropertyChangeListener listener) { + listenerList.addPropertyChangeListener(listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + listenerList.removePropertyChangeListener(listener); + } + + public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { + listenerList.addPropertyChangeListener(propertyName, listener); + } + + public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { + listenerList.removePropertyChangeListener(propertyName, listener); + } + + public long getNumberFrame() { + return numberFrame; + } + + public ReceivedData getLastReceivedData() { + return vecRawData.lastElement(); + } + + + + + + public void addFrame(byte[] received) { + long oldNumberFrame = numberFrame; + numberFrame++; + vecRawData.add(new ReceivedData(new Date(),received)); + listenerList.firePropertyChange("numberFrame", oldNumberFrame, numberFrame); + + } + + public String getRawFrame(int i) { + + return vecRawData.get(i).toString(); + } + + + +} diff --git a/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/PrimaryController.java b/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/PrimaryController.java new file mode 100644 index 0000000000000000000000000000000000000000..bd1ddfe09d8b458b0d669f92d34a29c7340bfb41 --- /dev/null +++ b/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/PrimaryController.java @@ -0,0 +1,12 @@ +package org.josast.ApplicationKissTool; + +import java.io.IOException; +import javafx.fxml.FXML; + +public class PrimaryController { + + @FXML + private void switchToSecondary() throws IOException { + App.setRoot("secondary"); + } +} diff --git a/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/ReceivedData.java b/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/ReceivedData.java new file mode 100644 index 0000000000000000000000000000000000000000..27a6173fb229d5f294645ad9c4b1dc35d2236fbb --- /dev/null +++ b/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/ReceivedData.java @@ -0,0 +1,40 @@ +package org.josast.ApplicationKissTool; + +import java.util.Date; + + +public class ReceivedData { + + private Date time; + private byte [] data; + + public ReceivedData(Date receivedTime, byte [] receivedData) { + super(); + time = receivedTime; + data = receivedData ; + } + + public Date getTime() { + return time; + } + + public void setTime(Date time) { + this.time = time; + } + + + public byte[] getData() { + return data; + } + + public void setData(byte[] data) { + this.data = data; + } + + @Override + public String toString() { + return "Frame [time=" + time + "][ Frame=" + new String(data) + "]"; + } + + +} diff --git a/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/SecondaryController.java b/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/SecondaryController.java new file mode 100644 index 0000000000000000000000000000000000000000..9c5ae0069f7024fedc3f6c60d7bd3328b3b42e98 --- /dev/null +++ b/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/SecondaryController.java @@ -0,0 +1,12 @@ +package org.josast.ApplicationKissTool; + +import java.io.IOException; +import javafx.fxml.FXML; + +public class SecondaryController { + + @FXML + private void switchToPrimary() throws IOException { + App.setRoot("primary"); + } +} \ No newline at end of file diff --git a/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/SendSIDS.java b/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/SendSIDS.java new file mode 100644 index 0000000000000000000000000000000000000000..a91c48e49fe2ec77145fec399487f8768ad4be9f --- /dev/null +++ b/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/SendSIDS.java @@ -0,0 +1,43 @@ +package org.josast.ApplicationKissTool; + +import java.math.BigInteger; +import java.util.logging.Logger; + +import org.josast.SIDS.HttpPostSIDS; +import org.josast.SIDS.SIDSData; +import org.josast.SIDS.Station; + +/** + * + * @author christophe + * + */ +public class SendSIDS { + + private static Logger appLogger = Logger.getLogger("AmsatLogger"); + SIDSData sids = new SIDSData(); + HttpPostSIDS client; + + public SendSIDS ( Station station, int norad, String url) + { + sids.setStation(station); + sids.setNoradID(norad); + client = new HttpPostSIDS(url); + + + } + + public int Send(ReceivedData data) + { + //BasicConfigurator.configure(); + + // transforme en hexa String + String hexaString = new BigInteger(1, data.getData()).toString(16); + sids.setTelemetryData(data.getTime(),hexaString); + appLogger.info(sids.toStringBasic()); + int result = client.SendSIDSBasic(sids); + return result; + + } + +} diff --git a/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/TaskSoundmodemTCP.java b/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/TaskSoundmodemTCP.java new file mode 100644 index 0000000000000000000000000000000000000000..672bfe3337851a8d02787a52a0e48a93cbd7066e --- /dev/null +++ b/ApplicationKissTool/src/main/java/org/josast/ApplicationKissTool/TaskSoundmodemTCP.java @@ -0,0 +1,89 @@ +package org.josast.ApplicationKissTool; + +import java.util.logging.Logger; + + +import org.josast.ModuleSoundModem.SoundModemClient; +import org.josast.ModuleSoundModem.SoundModemConfiguration; + +import javafx.concurrent.Task; + +public class TaskSoundmodemTCP extends Task { + + private Logger log = Logger.getLogger("AmsatLogger"); + + private volatile boolean running = true; + + SoundModemConfiguration smConfiguration = null; + SoundModemClient smc = null; + ModelReceivedData receivedFrame = null; + + /** + * @param smConfiguration fichier de configuration + * @param receivedFrame Frame Data model + */ + public TaskSoundmodemTCP(SoundModemConfiguration smConfiguration, ModelReceivedData receivedFrame) { + this.smConfiguration = smConfiguration; + smc = new SoundModemClient(smConfiguration); + if (smc.isOpen() == false) { + this.failed(); + } + this.receivedFrame = receivedFrame; + + } + + public TaskSoundmodemTCP(ModelReceivedData receivedFrame) { + + smConfiguration = new SoundModemConfiguration("default"); + smc = new SoundModemClient(smConfiguration); + if (smc.isOpen() == false) { + this.failed(); + } + this.receivedFrame = receivedFrame; + } + + /** + * while the connection is open, the modem is listening. When a frame is received, + * this frame is added to the model + */ + @Override + protected String call() { + try { + + while (running == true) { + if(smc.isOpen()) + { + byte[] temp = smc.receivedRawData(); + receivedFrame.addFrame(temp); + this.updateValue(receivedFrame.toString()); + } else + { + this.running=false; + log.severe("Erreur SoundModem closed"); + } + } + } catch (Exception e) { + log.severe("Erreur SoundModem not available"); + log.severe(e.toString()); + this.failed(); + + } + return receivedFrame.toString(); + } + + + + public void arreter() { + + this.running = false; + + } + + public void redemarrer() + { + + this.running = true; + + } + +} diff --git a/ApplicationKissTool/src/main/resources/org/josast/ApplicationKissTool/KissTool.fxml b/ApplicationKissTool/src/main/resources/org/josast/ApplicationKissTool/KissTool.fxml new file mode 100644 index 0000000000000000000000000000000000000000..fdaa97ef651ad9144f4d495f0e6a2766a5052ea5 --- /dev/null +++ b/ApplicationKissTool/src/main/resources/org/josast/ApplicationKissTool/KissTool.fxml @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +