diff --git a/ApplicationEntrySatDecoder/pom.xml b/ApplicationEntrySatDecoder/pom.xml index 2b0b45327fe12707d1d419d0d58122349b04fdc4..c3833f1163b9de90ec3232d082feef74b1a970f0 100644 --- a/ApplicationEntrySatDecoder/pom.xml +++ b/ApplicationEntrySatDecoder/pom.xml @@ -6,9 +6,9 @@ 4.0.0 - org.josast + org.josast JOSAST-parent - 0.0.2-SNAPSHOT + 0.0.2-SNAPSHOT @@ -17,7 +17,6 @@ http://www.amsat-f.org - @@ -36,19 +35,19 @@ org.josast ModuleConfig - 0.0.1-SNAPSHOT + 0.2 org.josast ModuleSoundModem - 0.0.1-SNAPSHOT + 0.0.2-SNAPSHOT - org.josast - ModuleEntrySatTelemetry - 0.0.1-SNAPSHOT - + org.josast + ModuleEntrySatTelemetry + 0.0.1-SNAPSHOT + @@ -64,9 +63,23 @@ javafx-controls 12 + + org.openjfx + javafx-fxml + 12 + + + + + org.openjfx + javafx-swing + 11-ea+24 + + + org.openjfx javafx-maven-plugin @@ -75,7 +88,41 @@ HelloFX + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + + make-assembly + package + + single + + + + + + + + + org.josast.EntrysatDecoder.Main + + + + + jar-with-dependencies + + + + + + diff --git a/ApplicationEntrySatDecoder/src/main/java/BasicApplication.css b/ApplicationEntrySatDecoder/src/main/java/BasicApplication.css new file mode 100644 index 0000000000000000000000000000000000000000..8b2e428c7e938ca8ad4eb73f5f19a36b2a962841 --- /dev/null +++ b/ApplicationEntrySatDecoder/src/main/java/BasicApplication.css @@ -0,0 +1,25 @@ +.menu-bar { + -fx-background-color: #aeb5ba, linear-gradient(to bottom, #ecf4fa 0%, #ced4d9 100%); + -fx-background-insets: 0, 0 0 1 0; +} + +.menu-bar .menu .label { + -fx-text-fill: #2d3e4c; +} + + +.thick-chart .chart-series-line { +-fx-stroke-width: 1px; +} + +.chart-line-symbol { + + -fx-background-insets: 0, 2; + -fx-background-radius: 2px; + -fx-padding: 2px; +} + +#font-button { + -fx-font: bold italic 20pt "Arial"; + -fx-effect: dropshadow( one-pass-box , black , 8 , 0.0 , 2 , 0 ); +} \ No newline at end of file diff --git a/ApplicationEntrySatDecoder/src/main/java/EntrysatVersion.txt b/ApplicationEntrySatDecoder/src/main/java/EntrysatVersion.txt new file mode 100644 index 0000000000000000000000000000000000000000..350f8526d0ce63265b46f993dcc73a9fe6cf6108 --- /dev/null +++ b/ApplicationEntrySatDecoder/src/main/java/EntrysatVersion.txt @@ -0,0 +1,3 @@ +EntrySatVersion=0.8 +Message=Version for validation purpose +NoradID=9990 \ No newline at end of file diff --git a/ApplicationEntrySatDecoder/src/main/java/LogoCSut.png b/ApplicationEntrySatDecoder/src/main/java/LogoCSut.png new file mode 100644 index 0000000000000000000000000000000000000000..7643bc92999e12b34c48631e9530de80f433dbad Binary files /dev/null and b/ApplicationEntrySatDecoder/src/main/java/LogoCSut.png differ diff --git a/ApplicationEntrySatDecoder/src/main/java/logoAmsat.png b/ApplicationEntrySatDecoder/src/main/java/logoAmsat.png new file mode 100644 index 0000000000000000000000000000000000000000..0d040fba4b8e99ac74424b8e65bf4a9b05995fde Binary files /dev/null and b/ApplicationEntrySatDecoder/src/main/java/logoAmsat.png differ diff --git a/ApplicationEntrySatDecoder/src/main/java/logo_pour_decodeur.jpg b/ApplicationEntrySatDecoder/src/main/java/logo_pour_decodeur.jpg new file mode 100644 index 0000000000000000000000000000000000000000..320f273a8a46ddc80f3940e07719972c9a76ca8a Binary files /dev/null and b/ApplicationEntrySatDecoder/src/main/java/logo_pour_decodeur.jpg differ diff --git a/ApplicationEntrySatDecoder/src/main/java/org/josast/EntrysatDecoder/AlertHelper.java b/ApplicationEntrySatDecoder/src/main/java/org/josast/EntrysatDecoder/AlertHelper.java new file mode 100644 index 0000000000000000000000000000000000000000..87eaa9c5c89f8b1ab06f0d8d735249561e5bd8e7 --- /dev/null +++ b/ApplicationEntrySatDecoder/src/main/java/org/josast/EntrysatDecoder/AlertHelper.java @@ -0,0 +1,38 @@ +package org.josast.EntrysatDecoder; + + +import javafx.scene.control.Alert; +import javafx.stage.Window; + +/** + * Simple helper class to display message to the end user + * @author christophe + * + */ +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/ApplicationEntrySatDecoder/src/main/java/org/josast/EntrysatDecoder/Configuration.java b/ApplicationEntrySatDecoder/src/main/java/org/josast/EntrysatDecoder/Configuration.java new file mode 100644 index 0000000000000000000000000000000000000000..5ebb0aec038a872ad9d421c5490426f6950f4e9c --- /dev/null +++ b/ApplicationEntrySatDecoder/src/main/java/org/josast/EntrysatDecoder/Configuration.java @@ -0,0 +1,235 @@ +/** + * + */ +package org.josast.EntrysatDecoder; + +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 SIDSEntrySatSource="Anonymous"; + private String SIDSEntryUrl="https://amsat.electrolab.fr/SIDS"; + private String SIDSSatnogsSource="Anonymous"; + private String SIDSSatnogsURL="https://db.satnogs.org/api/telemetry/"; + private String SIDSSatnogs="0"; + private String SIDSEntrySat="1"; + private int Norad=99990; // default value - equivalent to satnogs + private boolean SISD_SatNogs = false; + private boolean SIDS_EntrySat = true; + + + private CONFIG conf = CONFIG.getInstance(); + + public static Configuration getInstance() + { + return SingletonHolder.instance; + } + + public boolean isSISD_SatNogs() { + + return SISD_SatNogs; + } + + public boolean isSIDS_EntrySat() { + return SIDS_EntrySat; + } + + private Configuration() + { + if ( conf.GetProperty("Callsign")!=null) + { + callsign = conf.GetProperty("Callsign"); + latitude = conf.GetProperty("Latitude"); + longitude = conf.GetProperty("Longitude"); + + SIDSEntrySatSource=conf.GetProperty("SIDSEntrySatSource"); + SIDSEntryUrl=conf.GetProperty("SIDSEntryUrl"); + SIDSSatnogsSource=conf.GetProperty("SIDSSatnogsSource"); + SIDSSatnogsURL=conf.GetProperty("SIDSSatnogsURL"); + SIDSSatnogs=conf.GetProperty("SIDSSatnogs"); + SIDSEntrySat=conf.GetProperty("SIDSEntrySat"); + soundModemIP = conf.GetProperty("soundModemIP"); + soundModemPort = conf.GetProperty("soundModemPort"); + Norad = Integer.parseUnsignedInt(conf.GetProperty("NoradID").trim()); + if (SIDSSatnogs.contentEquals("1") ) + { + SISD_SatNogs=true; + } else + { + SISD_SatNogs=false; + } + if (SIDSEntrySat.contentEquals("1") ) + { + SIDS_EntrySat=true; + } else + { + SIDS_EntrySat=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 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 getSIDSEntrySatSource() { + return SIDSEntrySatSource; + } + + public void setSIDSEntrySatSource(String sIDSEntrySatSource) { + SIDSEntrySatSource = sIDSEntrySatSource; + } + + public String getSIDSEntryUrl() { + return SIDSEntryUrl; + } + + public void setSIDSEntryUrl(String sIDSEntryUrl) { + SIDSEntryUrl = sIDSEntryUrl; + } + + 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 String getSIDSSatnogs() { + return SIDSSatnogs; + } + + public void setSIDSSatnogs(String sIDSSatnogs) { + SIDSSatnogs = sIDSSatnogs; + if (SIDSSatnogs.contentEquals("1") ) + { + SISD_SatNogs=true; + } else + { + SISD_SatNogs=false; + } + } + + public String getSIDSEntrySat() { + return SIDSEntrySat; + } + + public void setSIDSEntrySat(String sIDSEntrySat) { + SIDSEntrySat = sIDSEntrySat; + if (SIDSEntrySat.contentEquals("1") ) + { + SIDS_EntrySat=true; + } else + { + SIDS_EntrySat=false; + } + } + + 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 void save() { + + conf.SetProperty("Callsign",callsign); + conf.SetProperty("Latitude",latitude); + conf.SetProperty("Longitude",longitude); + + conf.SetProperty("SIDSEntrySatSource",this.SIDSEntrySatSource); + conf.SetProperty("SIDSEntryUrl",this.SIDSEntryUrl); + conf.SetProperty("SIDSSatnogsSource",this.SIDSSatnogsSource); + conf.SetProperty("SIDSSatnogsURL",this.SIDSSatnogsURL); + conf.SetProperty("SIDSSatnogs",this.SIDSSatnogs); + conf.SetProperty("SIDSEntrySat",this.SIDSEntrySat); + conf.SetProperty("soundModemPort",this.soundModemPort); + conf.SetProperty("soundModemIP",this.soundModemIP); + conf.SetProperty("NoradID",""+this.Norad); + } + + public int getNorad() { + + return Norad; + } + + public void setNorad(int norad) { + + Norad=norad; + } + +} diff --git a/ApplicationEntrySatDecoder/src/main/java/org/josast/EntrysatDecoder/Controler.java b/ApplicationEntrySatDecoder/src/main/java/org/josast/EntrysatDecoder/Controler.java new file mode 100644 index 0000000000000000000000000000000000000000..47716716f950239768deff052fb0282e3f0d1feb --- /dev/null +++ b/ApplicationEntrySatDecoder/src/main/java/org/josast/EntrysatDecoder/Controler.java @@ -0,0 +1,564 @@ +package org.josast.EntrysatDecoder; + +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.text.SimpleDateFormat; +import java.util.Date; +import java.util.logging.Logger; + +import javax.imageio.ImageIO; + + +import org.josast.EntrySat.Telemetry; +import org.josast.ModuleSoundModem.SoundModemConfiguration; +import org.josast.SIDS.Station; +import org.josast.kaikai.generated.FrameTlmEntrySat; +import org.josast.kaikai.generated.FrameTlmEntrySat.Ax25Frame; +import org.josast.kaikai.generated.FrameTlmEntrySat.UiFrameTlmEntrySat; +import org.josast.propertyHttp.ConfigHttp; + +import javafx.application.Platform; +import javafx.concurrent.WorkerStateEvent; +import javafx.embed.swing.SwingFXUtils; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.fxml.FXML; +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.scene.control.Alert; + +public class Controler { + + private static final String LINE_SEPARATOR = "\r\n"; + private Logger log = Logger.getLogger("EntrySatLogger"); + private String version = "0.8.1"; + + @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 TextField textFieldbEps33VCurrent; + @FXML + private TextField TextFieldEps5VCurrent; + @FXML + private TextField TextFieldepsBattVcurrent; + @FXML + private TextField TextFieldEpsTemp; + @FXML + private TextField TextFieldTrxTemp; + @FXML + private TextField TextFieldEPSVBAT; + + @FXML + private TextField TFBattTemp; + + @FXML + private ImageView ImageViewAMSAT; + + @FXML + private ImageView imageViewEntrysat; + + @FXML + private TextField TextFieldCallsign; + @FXML + private TextField TextFieldLatitude; + @FXML + private TextField TextFieldLongitude; + + @FXML + private CheckBox CheckbBoxEntrysat; + @FXML + private CheckBox CheckBoxSatNogs; + + @FXML + private Button ButtonSaveConfiguration; + + @FXML + TextField TextFieldSIDSEntrysat; + @FXML + TextField TextFieldSIDSSatnogs; + + Stage primaryStage = null; + + private String imgAmsat = "/logoAmsat.png"; + private String imgEntrysat = "/logo_pour_decodeur.jpg"; + + Station station = new Station(); + + ModelFrame receivedFrame = new ModelFrame(); + + Configuration conf = Configuration.getInstance(); + + private TaskSoundmodemTCP task; + private SendSIDS SendSIDSSatnogs; + private SendSIDS SendSIDSEntrysat; + private PrintWriter pw; + Logger logger = Logger.getLogger("EntrySatLogger"); + + @FXML + private void HandleSaveConfiguration(ActionEvent event) { + Window owner = ButtonSaveConfiguration.getScene().getWindow(); + + 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) { + 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.setSIDSEntrySatSource(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.getSIDSEntrySatSource(), station.getLongitude(), station.getLatitude()); + + if (CheckbBoxEntrysat.isSelected() == true) { + conf.setSIDSEntrySat("1"); + SendSIDSEntrysat = new SendSIDS(StationEntry, conf.getNorad(), conf.getSIDSEntryUrl()); + } else { + conf.setSIDSEntrySat("0"); + + } + + if (CheckBoxSatNogs.isSelected() == true) { + conf.setSIDSSatnogs("1"); + SendSIDSSatnogs = new SendSIDS(StationSatnogs, conf.getNorad(), conf.getSIDSSatnogsURL()); + } else { + conf.setSIDSSatnogs("0"); + } + + conf.save(); + + displayLog("Configuration Saved"); + labelStatus.setText("Configuration Saved"); + } + + @FXML + private void handleStart(ActionEvent event) { + + labelStatus.setText("KISS TCP Start"); + displayLog("KISS TCP Start"); + ButtonStop.setDisable(false); + ButtonStart.setDisable(true); + ButtonSave.setDisable(false); + + SoundModemConfiguration smc = new SoundModemConfiguration("default"); + smc.setIPadress(FieldIP.getText()); + smc.setPort(Integer.parseInt(FieldPort.getText())); + + if (task == null) { + receivedFrame.addPropertyChangeListener(new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + final FrameTlmEntrySat tlmEntrySat = receivedFrame.getLastFrame(); + final EntryFrame tlmEntrySatKISS = receivedFrame.getLastKissFrame(); + if (conf.isSIDS_EntrySat()) { + // Generation SIDS + } + Platform.runLater(new Runnable() { + @Override + public void run() { + try { + + if (tlmEntrySat != null) { + + // update data + Ax25Frame ax = tlmEntrySat.frameTlmEntrySat(); + DecodedData.appendText("destSsidRaw : " + ax.ax25Header().destSsidRaw() + "\t"); + DecodedData.appendText("srcSsidRaw : " + ax.ax25Header().srcSsidRaw() + "\t"); + DecodedData.appendText("destCallsign : " + + ax.ax25Header().destCallsignRaw().destCallsignRor().destCallsign() + + "\t"); + DecodedData.appendText("srcCallsign : " + + ax.ax25Header().srcCallsignRaw().srcCallsignRor().srcCallsign() + "\t"); + DecodedData.appendText("ctl" + ax.ax25Header().ctl() + "\r\n"); + displayLog(tlmEntrySatKISS.toString()); + if ((ax.ax25Header().ctl() & 0x13) == 0x03) { + // identified trame + + displayLog("Entrysat Telemetry Identified \r\n"); + UiFrameTlmEntrySat Ui = (UiFrameTlmEntrySat) ax.payload(); + // verifie que c'est bien la trame avec SID 6 + if (Ui.telemetryData().sid() == 6) { + + Telemetry tlm = new Telemetry(); + tlm.setValue(tlmEntrySat.frameTlmEntrySat()); + DecodedData.appendText(tlm.toStringHeader()); + DecodedData.appendText(tlm.afficheTLM()); + textFieldDate.setText(tlm.getTimetoSting()); + textFieldMode.setText(tlm.getValueDecoded(Telemetry.ModeSafe)); + textFieldbEps33VCurrent.setText(tlm.getValueDecoded(Telemetry.EPS_3_3V_C)); + TextFieldEps5VCurrent.setText(tlm.getValueDecoded(Telemetry.EPS_5_V_C)); + TextFieldepsBattVcurrent + .setText(tlm.getValueDecoded(Telemetry.EPS_BATT_VCURRENT)); + TextFieldEpsTemp.setText(tlm.getValueDecoded(Telemetry.EPS_TEMP)); + TextFieldTrxTemp.setText(tlm.getValueDecoded(Telemetry.TRX_TEMP)); + TFBattTemp.setText(tlm.getValueDecoded(Telemetry.BATT_TEMP)); + TextFieldEPSVBAT.setText(tlm.getValueDecoded(Telemetry.EPS_VBATT)); + } + else + { + displayLog("Entrysat Telemetry with SID : "+Ui.telemetryData().sid()+"\r\n"); + } + } + updateFrame(receivedFrame.getNumberFrame()); + + if (conf.isSIDS_EntrySat() == true) { + int results = SendSIDSEntrysat.Send(tlmEntrySatKISS ); + displayLog("Send SIDS ENtry Sat ; "+results); + } + + if (conf.isSISD_SatNogs() == true) { + int results = SendSIDSSatnogs.Send(tlmEntrySatKISS ); + displayLog("Send SIDS Sat NOGS : "+results ); + } + + } 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. + + labelStatus.setText("KISS TCP DISCONNECTED"); + displayLog("KISS TCP DISCONNECTED"); + ButtonStop.setDisable(true); + ButtonStart.setDisable(false); + ButtonSave.setDisable(false); + } + + }); + + task.setOnFailed(new EventHandler() { + + @Override + public void handle(WorkerStateEvent event) { + // La tache s'est correctement terminee. + displayLog("Deconnection"); + displayLog(event.toString()); + displayLog(event.getSource().toString()); + + labelStatus.setText("KISS TCP CONNECTION FAILED"); + displayLog("KISS TCP DISCONNECTED - Connection failed"); + ButtonStop.setDisable(true); + ButtonStart.setDisable(false); + ButtonSave.setDisable(false); + } + + }); + + Thread backgroundThread = new Thread(task); + backgroundThread.setDaemon(true); + backgroundThread.start(); + + } + + @FXML + private void handleStop(ActionEvent event) { + + ButtonStop.setDisable(true); + ButtonStart.setDisable(false); + ButtonSave.setDisable(false); + task.arreter(); + + labelStatus.setText("Stop received data"); + displayLog("Stop task to receive telemetrie"); + } + + @FXML + private void handleSave(ActionEvent event) { + + ButtonStop.setDisable(true); + ButtonStart.setDisable(false); + ButtonSave.setDisable(true); + saveDataFile(); + labelStatus.setText("Data Saved"); + displayLog("Telemetry Data saved in file"); + } + + @FXML + private void HandleIP(ActionEvent event) { + } + + @FXML + private void HandlePort(ActionEvent event) { + } + + /** + * 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) { + log.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.getFrame(i)); + pw.write(LINE_SEPARATOR); + } + + pw.flush(); + pw.close(); + } catch (IOException e) { + e.printStackTrace(); + } + + } + + private void updateFrame(long nbframe) { + LabelFrame.setText("frame : " + nbframe); + + } + + + public void initMMI() { + + // initialise le log + initdisplayLogFile(); + displayLog("ENTRY SAT - LOG "); + log.warning("Initialise "); + primaryStage.setTitle("EntrySat Decoder - " + 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.getSIDSEntrySatSource()); + TextFieldSIDSSatnogs.setText(conf.getSIDSSatnogsSource()); + + + if (conf.isSIDS_EntrySat()) { + CheckbBoxEntrysat.setSelected(true); + } + if (conf.isSISD_SatNogs()) { + CheckBoxSatNogs.setSelected(true); + } + + displayLog(conf.getSIDSSatnogsURL()); + displayLog(conf.getSIDSEntryUrl()); + displayLog("Initialisation with Properties File Done "); + + BufferedImage bufferedImage1 = null; + BufferedImage bufferedImage2 = null; + try { + bufferedImage1 = ImageIO.read(getClass().getResource((imgAmsat))); + bufferedImage2 = ImageIO.read(getClass().getResource((imgEntrysat))); + } catch (IOException e) { + + log.severe("Error loading Image resources"); + log.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://amsat-f.org/sitewordpress/Documents/EntrysatVersion.txt"); + ConfigHttp c = new ConfigHttp("http://site.amsat-f.org/download/116451"); + String ver; + String message; + int NoradIdConf=conf.getNorad(); + if(c.isConnected()) + { + ver = c.GetProperty("EntrySatVersion"); + message = c.GetProperty("Message"); + NoradIdConf= Integer.parseUnsignedInt(c.GetProperty("NoradID").trim()); + } + else + { + ver = version; + message = "not connected to internet"; + } + if (NoradIdConf!=conf.getNorad()) + { + conf.setNorad(NoradIdConf); + conf.save(); + displayLog("Norad ID updated "); + } + ButtonStop.setDisable(true); + ButtonStart.setDisable(false); + ButtonSave.setDisable(true); + this.LabelInformation.setText(""); + + // initialise SIDS + + Station StationSatnogs = new Station(conf.getSIDSSatnogsSource(), station.getLongitude(), + station.getLatitude()); + Station StationEntry = new Station(conf.getSIDSEntrySatSource(), station.getLongitude(), station.getLatitude()); + + if (conf.isSISD_SatNogs() == true) { + SendSIDSSatnogs = new SendSIDS(StationSatnogs, conf.getNorad(), conf.getSIDSSatnogsURL()); + } + + if (conf.isSIDS_EntrySat() == true) { + SendSIDSEntrysat = new SendSIDS(StationEntry, conf.getNorad(), conf.getSIDSEntryUrl()); + } + + 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; + + } + + private void displayLog(String log) { + pw.println(log); + pw.flush(); + logger.info(log); + TexAreaLog.appendText(log); + TexAreaLog.appendText("\r\n"); + } + + 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) { + log.severe("fail to create " + path); + } + } + try { + pw = new PrintWriter (new FileWriter(path+"/"+formater.format(aujourdhui)+"-"+".log")); + displayLog("log error during decoding data"); + + } catch (IOException e) { + logger.severe("erreur creating log file"); + logger.severe (e.toString()); + } + } +} diff --git a/ApplicationEntrySatDecoder/src/main/java/org/josast/EntrysatDecoder/EntrsatDecoder.fxml b/ApplicationEntrySatDecoder/src/main/java/org/josast/EntrysatDecoder/EntrsatDecoder.fxml new file mode 100644 index 0000000000000000000000000000000000000000..48643dccaaed67d5b2ab00e52b6858e7f1c5fa9f --- /dev/null +++ b/ApplicationEntrySatDecoder/src/main/java/org/josast/EntrysatDecoder/EntrsatDecoder.fxml @@ -0,0 +1,228 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +