Skip to content
Commits on Source (2)
......@@ -17,27 +17,32 @@ import org.exolab.castor.xml.ValidationException;
/**
*
* <b>Description : This class allows to load and save data on a XML file. The castor API is used for the data binding.
* The default name for the file is the name of the class with ".xml" for the extension</b>
* <br>
* need a specific library : org.exolab.castor.xml
* <br>
* <b>JOSAST</b> : Java Open Source Amateur Satellite Toolbox
* <br>The aim of the project is to create a set of tools for amateur satellite purpose. All this tools could be used together to create specific software.
* <b>JOSAST</b> project is managed by AVMDTI (<A HREF="http://www.avmdti.org">http://www.avmdti.org </a> )
* <br> This software is an open source software. Please read the <b><i>JOSAST licence</b></i><BR>(<A HREF="http://www.avmdti.org">http://www.avmdti.org </a> )
* <p>for more information contact <a href="mailto:josast@avmdti.org">josast@avmdti.org</a></p>
* <b>Description : This class allows to load and sav data on a XML file. The
* castor API is used for the data binding. The default name for the file is the
* name of the class with ".xml" for the extension</b> <br>
* need a specific library : org.exolab.castor.xml <br>
* <b>JOSAST</b> : Java Open Source Amateur Satellite Toolbox <br>
* The aim of the project is to create a set of tools for amateur satellite
* purpose. All this tools could be used together to create specific software.
* <b>JOSAST</b> project is managed by AVMDTI
* (<A HREF="http://www.avmdti.org">http://www.avmdti.org </a> ) <br>
* This software is an open source software. Please read the <b><i>JOSAST
* licence</b></i><BR>
* (<A HREF="http://www.avmdti.org">http://www.avmdti.org </a> )
* <p>
* for more information contact
* <a href="mailto:josast@avmdti.org">josast@avmdti.org</a>
* </p>
*
* @author <a href="mailto:mercier.josast@avmdti.org">mercier</a>
* @version 1.0
* <p><b><i> Source Update </b></i></p>
* <br> Version : date : name : comments
* <br> V1 : 3 mars 2004 : C. Mercier : create file
* <br> V2 : 01 mai 2019 : C. Mercier : Change log system
* <p>
* <b><i> Source Update </b></i>
* </p>
* <br>
* Version : date : name : comments <br>
* V1 : 3 mars 2004 : C. Mercier : create file <br>
* V2 : 01 mai 2019 : C. Mercier : Change log system
* <p>
*/
public abstract class AbstractDataBinding implements Serializable {
......@@ -46,7 +51,7 @@ public abstract class AbstractDataBinding implements Serializable {
*
*/
private static final long serialVersionUID = 8410353753997330889L;
transient private String folder =".\\";
private transient String folder = ".\\";
private Logger log = Logger.getLogger("AmsatLogger");
......@@ -62,8 +67,7 @@ public abstract class AbstractDataBinding implements Serializable {
Object o = null;
Reader reader = null;
File f = new File(fileName);
if (f.exists() )
{
if (f.exists()) {
try {
reader = new FileReader(fileName);
} catch (FileNotFoundException e) {
......@@ -82,16 +86,13 @@ public abstract class AbstractDataBinding implements Serializable {
e.printStackTrace();
}
}
else
{
} else {
log.warning("file not found");
}
return o;
}
/**
* This method save all parameters of the class in an XML file.
*/
......@@ -121,7 +122,6 @@ public abstract class AbstractDataBinding implements Serializable {
/**
* This method returns true if a configuration file already exist.
*
* @return true if the configuration file exist.
*/
public boolean isExist() {
......@@ -130,28 +130,27 @@ public abstract class AbstractDataBinding implements Serializable {
return f.exists();
}
/**
* return the folder where the configuration file is read or save
*
* @return
*/
public String getFolder() {
return folder;
}
/**
* set the folder where the configuration file is read or save.
* If the folder do not exist, the folder is created.
* set the folder where the configuration file is read or save. If the
* folder do not exist, the folder is created.
*
* @param folder
* @return true if the folder exist else folder is not accessible
*/
public boolean setFolder(String folder) {
public boolean setFolder(final String folder) {
this.folder = folder;
File f = new File(folder);
boolean value = true;
if (!f.exists())
{
if (!f.exists()) {
value = f.mkdir();
}
return value;
......
......@@ -3,10 +3,7 @@
* <b>Description : used for demonstration to the config package.
* see main to understand how to used the AbstactDataBinding. </b>
* <br>
*
*
* <p>Projet : JOSAST <BR>
*
* <br>
* <b>JOSAST</b> : Java Open Source Amateur Satellite Toolbox
* <br>The aim of the project is to create a set of tools for amateur satellite purpose. All this tools could be used together to create specific software.
......@@ -28,9 +25,7 @@ import java.util.Vector;
/**
*
* <b>Description : </b>
*
*
* <p>Projet : JOSAST <BR>
* <p>Projet : JOSAST <br>
*
* <br>
* <b>JOSAST</b> : Java Open Source Amateur Satellite Toolbox
......@@ -56,10 +51,7 @@ public class ConfigurationdataBindingDemo extends AbstractDataBinding {
private Vector<String> V = new Vector<String>();
private String directory = new String("C:\\temp");
private ConfigurationdataBindingDemo()
{
private ConfigurationdataBindingDemo() {
}
/**
......@@ -68,21 +60,18 @@ public class ConfigurationdataBindingDemo extends AbstractDataBinding {
* else the function return a default object.
* @return an instance of the class.
*/
public static ConfigurationdataBindingDemo getInstance()
{
public static ConfigurationdataBindingDemo getInstance() {
// create a default object
ConfigurationdataBindingDemo t = new ConfigurationdataBindingDemo();
// test if the file exist
// TODO : A REVOIR
File f = new File(t.getDirectory());
if (!f.exists())
{
if (!f.exists()) {
f.mkdir();
}
t.setFolder(t.getDirectory());
if (t.isExist())
{
if (t.isExist()) {
// load the object
t = (ConfigurationdataBindingDemo) t.load();
}
......@@ -90,18 +79,14 @@ public static ConfigurationdataBindingDemo getInstance()
return t;
}
/**
* display Vector data and also name of the class and version. <br>
*
* @see java.lang.Object#toString()
*/
public String toString()
{
public String toString() {
return this.V.toString() + name + version;
}
/**
* @return field name.
*/
......@@ -125,10 +110,9 @@ public static ConfigurationdataBindingDemo getInstance()
/**
* set field name.
*
* @param string
*/
public void setName(String string) {
public void setName(final String string) {
name = string;
}
......@@ -137,7 +121,7 @@ public static ConfigurationdataBindingDemo getInstance()
*
* @param vector
*/
public void setV(Vector<String> vector) {
public void setV(final Vector<String> vector) {
V = vector;
}
......@@ -146,14 +130,13 @@ public static ConfigurationdataBindingDemo getInstance()
*
* @param d
*/
public void setVersion(double d) {
public void setVersion(final double d) {
version = d;
}
public void setDirectory(String directory) {
public void setDirectory(final String directory) {
this.directory = directory;
}
......@@ -168,18 +151,14 @@ public static ConfigurationdataBindingDemo getInstance()
* - modification des param�tres de l'objet
* - sauvegarde
* - lecture
*
*
* @param Strings non utilis�
* @param messages non utilis�
*/
public static void main(String[] Strings)
{
public static void main(String[] arg) {
Vector<String> v = new Vector<String>();
v.add("�lement 1");
v.add("�l�ment 2");
v.add("�l�ment 3");
ConfigurationdataBindingDemo t = getInstance();
System.out.println("First Load" + t);
t.setName("d�monstration du fichier");
t.setVersion(1.3);
......
......@@ -8,30 +8,39 @@ import java.io.IOException;
import java.util.Properties;
import java.util.logging.Logger;
/**
*
* <b>Description : This class allows to save data in a configuration file.</b>
* <br>
* for the JOSAST project the org.josast.config.databinding is prefered to this package for storing data.
* for the JOSAST project the org.josast.config.databinding is prefered to this
* package for storing data.
*
*
* <p>Projet : JOSAST <BR>
* <p>
* Projet : JOSAST <BR>
*
* <br>
* <b>JOSAST</b> : Java Open Source Amateur Satellite Toolbox
* <br>The aim of the project is to create a set of tools for amateur satellite purpose. All this tools could be used together to create specific software.
* <b>JOSAST</b> project is managed by AVMDTI (<A HREF="http://www.avmdti.org">http://www.avmdti.org </a> )
* <br> This software is an open source software. Please read the <b><i>JOSAST licence</b></i><BR>(<A HREF="http://www.avmdti.org">http://www.avmdti.org </a> )
* <p>for more information contact <a href="mailto:josast@avmdti.org">josast@avmdti.org</a></p>
* <b>JOSAST</b> : Java Open Source Amateur Satellite Toolbox <br>
* The aim of the project is to create a set of tools for amateur satellite
* purpose. All this tools could be used together to create specific software.
* <b>JOSAST</b> project is managed by AVMDTI
* (<A HREF="http://www.avmdti.org">http://www.avmdti.org </a> ) <br>
* This software is an open source software. Please read the <b><i>JOSAST
* licence</b></i><BR>
* (<A HREF="http://www.avmdti.org">http://www.avmdti.org </a> )
* <p>
* for more information contact
* <a href="mailto:josast@avmdti.org">josast@avmdti.org</a>
* </p>
*
* @author <a href="mailto:mercier.josast@avmdti.org">mercier</a>
* @version 1.0
* <p><b><i> Source Update </b></i></p>
* <br> Version : date : name : comments
* <br> V1 : 3 mars 2004 : C. Mercier : create file
* <br> V2 : 01 mai 2019 : C. Mercier : Change log system
* <p>
* <b><i> Source Update </b></i>
* </p>
* <br>
* Version : date : name : comments <br>
* V1 : 3 mars 2004 : C. Mercier : create file <br>
* V2 : 01 mai 2019 : C. Mercier : Change log system
* <p>
*/
public class CONFIG {
......@@ -41,20 +50,16 @@ public class CONFIG {
private String fileName = "configuration.ini";
/** Constructeur priv� */
private CONFIG()
{}
private CONFIG() {
}
private String getName()
{
private String getName() {
String path = System.getProperty("user.dir") + "/config";
File apath = new File(path);
if (!apath.exists())
{
if (!apath.exists()) {
boolean res = apath.mkdir();
if (!res)
{
if (!res) {
log.severe("fail to create " + path);
}
......@@ -62,28 +67,20 @@ public class CONFIG {
return path + "/" + fileName;
}
/** Holder */
private static class SingletonHolder
{
private static class SingletonHolder {
/** Instance unique non pr�initialis�e */
private final static CONFIG instance = new CONFIG();
private static final CONFIG instance = new CONFIG();
}
/** Point d'acc�s pour l'instance unique du singleton */
public static CONFIG getInstance()
{
public static CONFIG getInstance() {
return SingletonHolder.instance;
}
public String GetProperty(final String Item) {
public String GetProperty(String Item) {
if (P==null)
{
if (P == null) {
try {
P = new Properties();
FileInputStream in = new FileInputStream(getName());
......@@ -95,12 +92,9 @@ public class CONFIG {
}
}
String S = P.getProperty(Item);
if (S == null)
{
if (S == null) {
return null;
}
else
{
} else {
return S.trim(); // $NON-NLS-1$
}
}
......@@ -113,21 +107,17 @@ public class CONFIG {
* @param Valeur value to store
*
*/
public void SetProperty(String Item, String Valeur) {
if (P==null)
{
public void SetProperty(final String Item, final String Valeur) {
if (P == null) {
P = new Properties();
try {
FileInputStream in = new FileInputStream(getName());
P.load(in);
in.close();
}
catch (Exception e2) {
} catch (Exception e2) {
log.severe("Erreur de ouverture du fichier de configuration"); //$NON-NLS-1$
e2.printStackTrace();
}
......@@ -159,6 +149,7 @@ public class CONFIG {
/**
* Returns the nomFichier.
*
* @return String
*/
public String getFileName() {
......@@ -167,9 +158,10 @@ public class CONFIG {
/**
* Sets the nomFichier.
* @param fileName The nomFichier to set
*
* @param nomfichier The nomFichier to set
*/
public void setFileName(String nomfichier) {
public void setFileName(final String nomfichier) {
fileName = nomfichier;
}
......
......@@ -15,26 +15,20 @@ public abstract class ConfigObject {
private Logger log = Logger.getLogger("AmsatLogger");
private String ConfigFilename = null;
private String fullConfigFilename = null;
protected CONFIG ConfigFile = CONFIG.getInstance();
public ConfigObject ()
{
public ConfigObject() {
}
public String getFulFileName()
{
public String getFulFileName() {
fullConfigFilename = System.getProperty("user.dir") + "/config";
File apath = new File(fullConfigFilename);
if (!apath.exists())
{
if (!apath.exists()) {
boolean res = apath.mkdir();
if (!res)
{
if (!res) {
log.severe("fail to create " + fullConfigFilename);
}
}
return fullConfigFilename;
......@@ -45,7 +39,7 @@ public abstract class ConfigObject {
/**
* @param configFilename Configuration file name
*/
public ConfigObject(String configFilename) {
public ConfigObject(final String configFilename) {
super();
ConfigFilename = configFilename;
ConfigFile.setFileName(configFilename);
......@@ -60,7 +54,4 @@ public abstract class ConfigObject {
return ConfigFilename;
}
}
......@@ -29,13 +29,12 @@ public class ConfigHttp {
/**
* @param url URL of the properties file to read
*/
public ConfigHttp(String url) {
public ConfigHttp(final String url) {
super();
this.url = url;
try {
loadProperties();
} catch (Exception e)
{
} catch (Exception e) {
log.severe(e.getMessage());
}
}
......@@ -54,7 +53,8 @@ public class ConfigHttp {
try {
response = client.execute(request);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
BufferedReader rd = new BufferedReader(
new InputStreamReader(response.getEntity().getContent()));
props.load(rd);
connected = true;
......@@ -73,16 +73,13 @@ public class ConfigHttp {
* @param Item property name
* @return property value, null if property not found
*/
public String GetProperty(String Item) {
public String GetProperty(final String Item) {
if (props != null) {
String S = props.getProperty(Item);
if (S == null)
{
if (S == null) {
return null;
}
else
{
} else {
return S.trim(); // $NON-NLS-1$
}
}
......@@ -97,13 +94,10 @@ public class ConfigHttp {
return connected;
}
public static void main(String[] args) {
ConfigHttp c = new ConfigHttp("http://site.amsat-f.org/download/117168/");
ConfigHttp c = new ConfigHttp(
"http://site.amsat-f.org/download/117168/");
System.out.println(c.GetProperty("EntrySatVersion"));
}
}
......@@ -28,10 +28,9 @@ import org.josast.config.databinding.AbstractDataBinding;
public class test extends AbstractDataBinding {
private static final long serialVersionUID = 1L;
int toto;
Vector<String> V = new Vector<String>();
public test()
{
private int toto;
private Vector<String> V = new Vector<String>();
public test() {
V.add("essai");
V.add("test");
}
......@@ -46,12 +45,11 @@ public class test extends AbstractDataBinding {
/**
* @param i
*/
public void setToto(int i) {
public void setToto(final int i) {
toto = i;
}
/**
* @return
*/
......@@ -62,18 +60,14 @@ public class test extends AbstractDataBinding {
/**
* @param vector
*/
public void setV(Vector<String> vector) {
public void setV(final Vector<String> vector) {
V = vector;
}
public static void main(String[] strings)
{
public static void main(String[] strings) {
test t = new test();
t.setFolder("D:\\temps2");
t.setToto(4);
t.save();
}
......
......@@ -33,7 +33,7 @@ import org.apache.http.ssl.TrustStrategy;
*/
public class HttpPostSIDS {
private static Logger logger = Logger.getLogger("AmsatLogger");
private static String USER_AGENT = "Mozilla/5.0";
private static String USERAGENT = "Mozilla/5.0";
private CloseableHttpClient client = null;
private HttpPost post = null;
private StringBuffer result = null;
......@@ -45,11 +45,11 @@ public class HttpPostSIDS {
*
* @param url Database http or https adress
*/
public HttpPostSIDS(String url) {
public HttpPostSIDS(final String url) {
client = getCloseableHttpClient();
post = new HttpPost(url);
post.setHeader("User-Agent", USER_AGENT);
post.setHeader("User-Agent", USERAGENT);
}
......@@ -59,16 +59,16 @@ public class HttpPostSIDS {
* @param url
* @param token provided by satnogs if
*/
public HttpPostSIDS(String url, String token) {
public HttpPostSIDS(final String url, final String token) {
client = getCloseableHttpClient();
post = new HttpPost(url);
post.setHeader("User-Agent", USER_AGENT);
post.setHeader("User-Agent", USERAGENT);
addSatnogsToken(token);
}
public void addSatnogsToken(String token) {
public void addSatnogsToken(final String token) {
post.addHeader("Authorization", "Token " + token);
}
......@@ -76,18 +76,29 @@ public class HttpPostSIDS {
private CloseableHttpClient getCloseableHttpClient() {
CloseableHttpClient httpClient = null;
try {
httpClient = HttpClients.custom().setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
.setSSLContext(new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {
public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
httpClient = HttpClients.custom()
.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
.setSSLContext(new SSLContextBuilder()
.loadTrustMaterial(null, new TrustStrategy() {
public boolean isTrusted(
final X509Certificate[] arg0,
final String arg1)
throws CertificateException {
return true;
}
}).build()).build();
}).build())
.build();
} catch (KeyManagementException e) {
logger.severe("KeyManagementException in creating http client instance " + e.toString());
logger.severe(
"KeyManagementException in creating http client instance "
+ e.toString());
} catch (NoSuchAlgorithmException e) {
logger.severe("NoSuchAlgorithmException in creating http client instance " + e.toString());
logger.severe(
"NoSuchAlgorithmException in creating http client instance "
+ e.toString());
} catch (KeyStoreException e) {
logger.severe("KeyStoreException in creating http client instance " + e.toString());
logger.severe("KeyStoreException in creating http client instance "
+ e.toString());
}
return httpClient;
}
......@@ -96,20 +107,24 @@ public class HttpPostSIDS {
* @param sids
* @return
*/
public int SendSIDSBasic(SIDSData sids) {
public int SendSIDSBasic(final SIDSData sids) {
// Data preparation
int resultat = 0;
HttpResponse response = null;
BufferedReader rd = null;
List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
urlParameters.add(new BasicNameValuePair("noradID", "" + sids.getNoradID()));
urlParameters
.add(new BasicNameValuePair("noradID", "" + sids.getNoradID()));
urlParameters.add(new BasicNameValuePair("source", sids.getSource()));
urlParameters.add(new BasicNameValuePair("timestamp", sids.getTimestamp()));
urlParameters
.add(new BasicNameValuePair("timestamp", sids.getTimestamp()));
urlParameters.add(new BasicNameValuePair("frame", sids.getFrame()));
urlParameters.add(new BasicNameValuePair("locator", sids.getLocator()));
urlParameters.add(new BasicNameValuePair("longitude", "" + sids.getLongitude()));
urlParameters.add(new BasicNameValuePair("latitude", "" + sids.getLatitude()));
urlParameters.add(
new BasicNameValuePair("longitude", "" + sids.getLongitude()));
urlParameters.add(
new BasicNameValuePair("latitude", "" + sids.getLatitude()));
urlParameters.add(new BasicNameValuePair("version", "2.0.2"));
try {
......@@ -127,12 +142,11 @@ public class HttpPostSIDS {
logger.severe("Cient executon error" + e.toString());
}
if (response != null)
{
if (response != null) {
try {
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
rd = new BufferedReader(new InputStreamReader(
response.getEntity().getContent()));
} catch (UnsupportedOperationException | IOException e) {
logger.severe("Buffer reader Exception " + e.toString());
}
......@@ -144,7 +158,8 @@ public class HttpPostSIDS {
result.append(line);
}
} catch (IOException e) {
logger.severe("Error reading line from server " + e.toString());
logger.severe(
"Error reading line from server " + e.toString());
}
}
return resultat;
......
......@@ -4,7 +4,6 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
/**
* SIDSdate is a simple class used to store SIDS data information
*
......@@ -14,56 +13,56 @@ import java.util.TimeZone;
public class SIDSData {
final private SimpleDateFormat ISO8601DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
private final SimpleDateFormat ISO8601DATEFORMAT = new SimpleDateFormat(
"yyyy-MM-dd'T'HH:mm:ss'Z'");
private int noradID; // Norad ID of the spacecraft
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 ...
final private String locator = "longLat"; //Type of the given receiver's location. Currently, only 'longLat' is supported. longLat
private String timestamp; // UTC timestamp (see ISO 8601)
// 2018-01-24T23:42:46Z
private String longitude=null; // Longitude of the receiver (WGS84) 8.95564E
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 latitude=null; //Latitude of the receiver (WGS84) 49.73145N
private final String locator = "longLat"; // Type of the given receiver's
// location. Currently, only
// 'longLat' is supported. longLat
private int tncPort = 0; // Optional as per SiDS standard specification, but not used in PicSat SiDS system 0
private String longitude = null; // Longitude of the receiver (WGS84)
// 8.95564E
private double azimuth = 0.0; // azimuth degree of directionnal antenna (if avaiblable) 10.5
private String latitude = null; // Latitude of the receiver (WGS84)
// 49.73145N
private double elevation= 0.0; // elevation degree of directionnal antenna (if avaiblable) 85.0
private int tncPort = 0; // Optional as per SiDS standard specification, but
// not used in PicSat SiDS system 0
private long fDown = 0; // Frequency of the receiver's downlink channel during reception (with Doppler), in Hz 435525000
private double azimuth = 0.0; // azimuth degree of directionnal antenna (if
// avaiblable) 10.5
final private String version = "2.0.1";
private double elevation = 0.0; // elevation degree of directionnal antenna
// (if avaiblable) 85.0
private long fDown = 0; // Frequency of the receiver's downlink channel
// during reception (with Doppler), in Hz 435525000
private final String version = "2.0.1";
public SIDSData ( )
{
public SIDSData() {
}
/**
* addTelemetryData is used for adding telemetry data with associated TimeStamp.
* The timestamp is formated in correct date format.
* addTelemetryData is used for adding telemetry data with associated
* TimeStamp. The timestamp is formated in correct date format.
*
* @param date Date in local time
* @param inputframe telemetry data
*/
public void setTelemetryData ( Date date, String inputframe)
{
public void setTelemetryData(final Date date, final String inputframe) {
ISO8601DATEFORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
timestamp = ISO8601DATEFORMAT.format(date);
......@@ -71,13 +70,11 @@ public class SIDSData {
}
public String getLongitude() {
return longitude;
}
public void setLongitude(String longitude) {
public void setLongitude(final String longitude) {
this.longitude = longitude;
}
......@@ -85,15 +82,15 @@ public class SIDSData {
return latitude;
}
public void setLatitude(String latitude) {
this.latitude = latitude;
public void setLatitude(final String latitudein) {
this.latitude = latitudein;
}
public int getNoradID() {
return noradID;
}
public void setNoradID(int noradID) {
public void setNoradID(final int noradID) {
this.noradID = noradID;
}
......@@ -101,7 +98,7 @@ public class SIDSData {
return source;
}
public void setSource(String source) {
public void setSource(final String source) {
this.source = source;
}
......@@ -109,7 +106,7 @@ public class SIDSData {
return timestamp;
}
public void setTimestamp(String timestamp) {
public void setTimestamp(final String timestamp) {
this.timestamp = timestamp;
}
......@@ -117,7 +114,7 @@ public class SIDSData {
return frame;
}
public void setFrame(String frame) {
public void setFrame(final String frame) {
this.frame = frame;
}
......@@ -125,7 +122,7 @@ public class SIDSData {
return tncPort;
}
public void setTncPort(int tncPort) {
public void setTncPort(final int tncPort) {
this.tncPort = tncPort;
}
......@@ -133,7 +130,7 @@ public class SIDSData {
return azimuth;
}
public void setAzimuth(double azimuth) {
public void setAzimuth(final double azimuth) {
this.azimuth = azimuth;
}
......@@ -141,7 +138,7 @@ public class SIDSData {
return elevation;
}
public void setElevation(double elevation) {
public void setElevation(final double elevation) {
this.elevation = elevation;
}
......@@ -149,20 +146,16 @@ public class SIDSData {
return fDown;
}
public void setfDown(long fDown) {
public void setfDown(final long fDown) {
this.fDown = fDown;
}
/**
* Set Station information. Fill source, longitude & latitude information.
*
* @param station
*/
public void setStation(Station station)
{
public void setStation(final Station station) {
source = station.getCallsign();
......@@ -177,9 +170,7 @@ public class SIDSData {
return locator;
}
public String toStringBasic()
{
public String toStringBasic() {
StringBuilder sb = new StringBuilder();
sb.append("noradID=");
sb.append(noradID);
......@@ -198,14 +189,8 @@ public class SIDSData {
sb.append("&version=");
sb.append(version);
return sb.toString();
}
}
......@@ -5,12 +5,10 @@ import java.util.regex.Pattern;
public class Station {
private String callsign = "XtopheSwl";
private String longitude = "1.47E";
private String latitude = "43.56N";
public Station(String callsign, String longitude, String latitude) {
public Station(final String callsign, final String longitude, final String latitude) {
super();
this.callsign = callsign;
this.longitude = longitude;
......@@ -24,32 +22,30 @@ public class Station {
public String getCallsign() {
return callsign;
}
public void setCallsign(String callsign) {
public void setCallsign(final String callsign) {
this.callsign = callsign;
}
public String getLongitude() {
return longitude;
}
public void setLongitude(String longitude) {
public void setLongitude(final String longitude) {
this.longitude = longitude;
}
public String getLatitude() {
return latitude;
}
public void setLatitude(String latitude) {
public void setLatitude(final String latitude) {
this.latitude = latitude;
}
public boolean checkLatitude (String latitude)
{
public boolean checkLatitude(final String latitude) {
Pattern p = Pattern.compile("[\\d]*\\.[\\d]*[N,S]");
Matcher m = p.matcher(latitude);
return m.matches();
}
public boolean checkLongitude (String longitude)
{
public boolean checkLongitude(final String longitude) {
Pattern p = Pattern.compile("[\\d]*\\.[\\d]*[E,W]");
Matcher m = p.matcher(longitude);
......@@ -59,5 +55,4 @@ public class Station {
}
......@@ -14,56 +14,47 @@ import org.josast.SIDS.Station;
public class SendFile {
SIDSData sids = new SIDSData();
BufferedReader lecteurAvecBuffer = null;
String ligne;
private SIDSData sids = new SIDSData();
private BufferedReader lecteurAvecBuffer = null;
private String ligne;
public void initSIDS ()
{
public void initSIDS() {
sids.setStation(new Station());
sids.setNoradID(99990);
}
public void OpenFile(String file)
{
try
{
public void openFile(final String file) {
try {
lecteurAvecBuffer = new BufferedReader(new FileReader(file));
}
catch(FileNotFoundException exc)
{
} catch (FileNotFoundException exc) {
System.out.println("Erreur d'ouverture");
}
}
public void readFile ()
{
public void readFile() {
boolean first = false;
Date dateref = null;
try {
while ((ligne = lecteurAvecBuffer.readLine()) != null)
{
while ((ligne = lecteurAvecBuffer.readLine()) != null) {
String[] result1 = ligne.split("=");
String[] date = result1[1].split("]");
String[] trame = result1[2].split("]");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("E MMM dd hh:mm:ss z yyyy",Locale.ENGLISH);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
"E MMM dd hh:mm:ss z yyyy", Locale.ENGLISH);
System.out.println("date : "+date[0]+" - Trame "+trame[0]);
System.out
.println("date : " + date[0] + " - Trame " + trame[0]);
Date date2 = simpleDateFormat.parse(date[0]);
if (first==false)
{
if (first == false) {
dateref = date2;
first = true;
} else {
System.out.println(
(date2.getTime() - dateref.getTime()) / 1000);
}
else
{
System.out.println((date2.getTime() - dateref.getTime())/1000);
}
}
} catch (IOException e) {
......@@ -76,8 +67,7 @@ public class SendFile {
}
public void closeFile()
{
public void closeFile() {
try {
lecteurAvecBuffer.close();
} catch (IOException e) {
......@@ -86,20 +76,14 @@ public class SendFile {
}
}
public static void main(String[] argv) throws IOException
{
public static void main(String[] argv) throws IOException {
SendFile sf = new SendFile();
sf.OpenFile(argv[0]);
sf.openFile(argv[0]);
sf.initSIDS();
sf.readFile();
sf.closeFile();
}
}
......@@ -18,37 +18,30 @@ public class TestSIDS {
private HttpPostSIDS client = null;
public TestSIDS(String url) {
public TestSIDS(final String url) {
super();
client = new HttpPostSIDS(url);
}
public void Send(SIDSData sids)
{
public void send(final SIDSData sids) {
int result = client.SendSIDSBasic(sids);
System.out.println("resutats = " + result);
System.out.println("resutats = " + client.getResult());
}
/**
* @param args
*/
public static void main(String[] args) throws IOException {
// String url = "https://db.satnogs.org/api/telemetry/";
// String url = "https://db-dev.satnogs.org/api/telemetry/";
// String url = "http://127.0.0.1:9000/echoPost";
// String url = "https://amsat.electrolab.fr/SIDS";
String url = "http:/127.0.0.1:8080/SIDS";
TestSIDS test = new TestSIDS(url);
// initialise SIDS data
SIDSData sids = new SIDSData();
......@@ -57,7 +50,7 @@ public class TestSIDS {
sids.setTelemetryData(GregorianCalendar.getInstance().getTime(),
"8c6c96a88240e09e9c60648ca46103f0000000000801ca5c0012100319240a0d4b5f0600ff2800002822443e6fb0870d0a24c0");
System.out.println(sids.toStringBasic());
test.Send(sids);
test.send(sids);
}
......
......@@ -11,18 +11,17 @@
<artifactId>ModuleSoundModem</artifactId>
<!-- <version>0.0.1-SNAPSHOT</version> -->
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> -->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<plugin.compiler.version>2.3.2</plugin.compiler.version>
<commons-cli.version>1.4 </commons-cli.version>
<kaitai-struct-runtime.version>0.9</kaitai-struct-runtime.version>
</properties>
......@@ -34,11 +33,10 @@
<artifactId>ModuleConfig</artifactId>
<version>${josast.version}</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.4</version>
<version>${commons-cli.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
......@@ -46,18 +44,11 @@
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/name.valery1707.kaitai/kaitai-maven-plugin -->
<!-- <dependency> -->
<!-- <groupId>name.valery1707.kaitai</groupId> -->
<!-- <artifactId>kaitai-maven-plugin</artifactId> -->
<!-- <version>${kaitai-maven-plugin-version}</version> -->
<!-- </dependency> -->
<!-- https://mvnrepository.com/artifact/io.kaitai/kaitai-struct-runtime -->
<dependency>
<groupId>io.kaitai</groupId>
<artifactId>kaitai-struct-runtime</artifactId>
<version>0.8</version>
<version>${kaitai-struct-runtime.version}</version>
</dependency>
</dependencies>
......@@ -75,7 +66,6 @@
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
......@@ -89,8 +79,6 @@
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
......
......@@ -75,8 +75,7 @@ public void decodeAX25Frame (byte[] frame , int lenght)
Callsign calsign = new Callsign();
char [] val =new char[6];
for (int i=0;i<6;i++)
{
for (int i=0;i<6;i++){
char c= (char) ((arg0[i+offset] & 0xFF) >>1 & 0x7F);
......@@ -88,8 +87,7 @@ public void decodeAX25Frame (byte[] frame , int lenght)
}
@Deprecated
public Callsign getFromClassign ()
{
public Callsign getFromClassign() {
return from;
}
@Deprecated
......
......@@ -2,6 +2,7 @@ package org.josast.AX25;
import java.util.logging.Level;
import java.util.logging.Logger;
@Deprecated
public class KissFrame {
......@@ -26,38 +27,46 @@ public class KissFrame {
public void setType(byte ax252) {
type = ax252;
}
@Deprecated
public byte DecodeKissType(byte val) {
public byte DecodeKissType(final byte val) {
switch (val) {
case 0x00: type = AX25;
case 0x00:
type = AX25;
log.log(Level.INFO, "AX25 type");
break;
case 0x01: type = TXDELAY;
case 0x01:
type = TXDELAY;
break;
case 0x02: type = P;
case 0x02:
type = P;
break;
case 0x03: type = SlotTime;
case 0x03:
type = SlotTime;
break;
case 0x04: type = TXtail;
case 0x04:
type = TXtail;
break;
case 0x05: type = Fullduplex;
case 0x05:
type = Fullduplex;
break;
case 0x07: type = SetHardware;
case 0x07:
type = SetHardware;
break;
case (byte) 0xFF: type = (byte) Exit;
case (byte) 0xFF:
type = (byte) Exit;
break;
default : type = unknow;
default:
type = unknow;
log.log(Level.INFO, "unknow type");
}
return type;
}
@Deprecated
public KissData extactMessage(byte[] frame, int nb )
{
public KissData extactMessage(byte[] frame, int nb) {
KissData kissData;
type = unknow;
......@@ -68,14 +77,11 @@ public class KissFrame {
cptcontents = 0;
// detect start frame
while (!startFrame )
{
if (((byte)frame[cpt++] & 0xFF)== 0xC0)
{
while (!startFrame) {
if (((byte) frame[cpt++] & 0xFF) == 0xC0) {
startFrame = true;
}
if (cpt==nb)
{
if (cpt == nb) {
startFrame = true;
endFrame = true;
}
......@@ -84,26 +90,21 @@ public class KissFrame {
type = DecodeKissType((byte) (frame[cpt++] & 0xFF));
// Extract data
while (!endFrame )
{
while (!endFrame) {
if (((int)frame[cpt] & 0xFF)== 0xDB)
{
if (((int) frame[cpt] & 0xFF) == 0xDB) {
cpt++;
}
if (((int)frame[cpt] & 0xFF)== 0xDD)
{
if (((int) frame[cpt] & 0xFF) == 0xDD) {
cpt++;
}
if (((int)frame[cpt] & 0xFF)== 0xC0)
{
if (((int) frame[cpt] & 0xFF) == 0xC0) {
endFrame = true;
}
contents[cptcontents++] = (byte) (frame[cpt++] & 0xFF);
if (cpt>=nb)
{
if (cpt >= nb) {
endFrame = true;
}
......@@ -113,5 +114,4 @@ public class KissFrame {
}
}
......@@ -9,12 +9,12 @@ package org.josast.ModuleSoundModem;
*/
public class KissException extends Exception {
/**
/**.
*
*/
private static final long serialVersionUID = 7103474292775784017L;
/**
/**.
*
*/
public KissException() {
......@@ -24,7 +24,7 @@ public class KissException extends Exception {
/**
* @param message
*/
public KissException(String message) {
public KissException(final String message) {
super(message);
// TODO Auto-generated constructor stub
}
......@@ -32,7 +32,7 @@ public class KissException extends Exception {
/**
* @param cause
*/
public KissException(Throwable cause) {
public KissException(final Throwable cause) {
super(cause);
// TODO Auto-generated constructor stub
}
......@@ -41,7 +41,7 @@ public class KissException extends Exception {
* @param message
* @param cause
*/
public KissException(String message, Throwable cause) {
public KissException(final String message, final Throwable cause) {
super(message, cause);
// TODO Auto-generated constructor stub
}
......@@ -52,7 +52,7 @@ public class KissException extends Exception {
* @param enableSuppression
* @param writableStackTrace
*/
public KissException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
public KissException(final String message, final Throwable cause, final boolean enableSuppression, final boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
// TODO Auto-generated constructor stub
}
......
......@@ -24,7 +24,6 @@ import org.apache.commons.cli.ParseException;
public class SoundModemCli {
private Logger log = Logger.getLogger("AmsatLogger");
private static String version = "0.2";
private String configurationfile = "defaultConfigFile.ini";
/*
......
......@@ -26,7 +26,6 @@ public class SoundModemClient {
private InputStream in = null;
private boolean open = false;
private int bufferSize = 1024;
private Path filepath;
/**
......@@ -44,7 +43,7 @@ public class SoundModemClient {
* Initialise connection to soundmodem application with configuration
*
*/
public SoundModemClient(SoundModemConfiguration smConfig) {
public SoundModemClient(final SoundModemConfiguration smConfig) {
smConfiguration = smConfig;
openSocket();
......@@ -52,11 +51,11 @@ public class SoundModemClient {
}
/**
/**.
* Initialise connection to soundmodem application with configuration file
*
*/
public SoundModemClient(String filename) {
public SoundModemClient(final String filename) {
smConfiguration = new SoundModemConfiguration(filename);
openSocket();
......@@ -112,7 +111,7 @@ public class SoundModemClient {
}
/**
/**.
* wait bytes from sound modem
*
* @return bytes received in KISS format
......@@ -154,7 +153,7 @@ public class SoundModemClient {
}
@Deprecated
public int receiveData(byte[] cbuf) {
public int receiveData(final byte[] cbuf) {
try {
return in.read(cbuf);
} catch (IOException e) {
......@@ -172,7 +171,7 @@ public class SoundModemClient {
}
@Deprecated
public AX25Frame decode(byte[] frame, int nb) {
public AX25Frame decode(final byte[] frame, final int nb) {
KissFrame kf = new KissFrame();
KissData kissData = kf.extactMessage(frame, nb);
......@@ -202,9 +201,7 @@ public class SoundModemClient {
public byte[] receivedRawData() {
byte[] temp = receivedKissData();
if (temp != null)
{
if (temp != null) {
kiss k = new kiss(temp);
try {
......@@ -213,14 +210,11 @@ public class SoundModemClient {
log.log(Level.SEVERE, "Extract Raw data " + e.toString());
}
return temp;
}
else
{
else {
log.severe("Buffer read null, return null");
return null;
}
}
}
......@@ -9,11 +9,37 @@ import org.josast.property.ConfigObject;
* @author Christophe
*
*/
/**
* @author christophe
*
*/
/**
* @author christophe
*
*/
/**
* @author christophe
*
*/
/**
* @author christophe
*
*/
/**
* @author christophe
*
*/
/**
* @author christophe
*
*/
public class SoundModemConfiguration extends ConfigObject {
private Logger log = Logger.getLogger("AmsatLogger");
/** Default IP Adress. */
private String smIPadress = "localhost";
/** Default port. */
private int smPort = 8100;
private boolean smGenerateBinarieFile = false;
private String smBinarieOutputFile = "soundmodem.bin";
......@@ -21,19 +47,24 @@ public class SoundModemConfiguration extends ConfigObject {
private boolean smBinarieFilePrefixDate = false;
protected CONFIG configFile = CONFIG.getInstance();
protected CONFIG ConfigFile = CONFIG.getInstance();
public SoundModemConfiguration(String configFilename) {
/**
* @param configFilename
*/
public SoundModemConfiguration(final String configFilename) {
super(configFilename);
// vérifie si la propriété est dans le fichier
String temp = ConfigFile.GetProperty("smPort");
String temp = configFile.GetProperty("smPort");
if (temp == null) {
// config file not initialised
initialisePropertiesFile();
log.severe("properties file not initialised - a file is created with properties with defaults value");
System.out.println("config file does not content required properties \n the file " + configFilename
log.severe(
"properties file not initialised - a file is created with properties with defaults value");
System.out.println(
"config file does not content required properties \n the file "
+ configFilename
+ " has been set up with properties to configure");
} else {
......@@ -43,78 +74,97 @@ public class SoundModemConfiguration extends ConfigObject {
}
private void initialisePropertiesFile() {
ConfigFile.SetProperty("smIPadress", smIPadress);
ConfigFile.SetProperty("smPort", "" + smPort);
ConfigFile.SetProperty("smGenerateBinarieFile",""+smGenerateBinarieFile);
ConfigFile.SetProperty("smBinarieOutputFile",smBinarieOutputFile);
ConfigFile.SetProperty("smBinarieOutputFile",smBinarieOutputDirectory);
ConfigFile.SetProperty("smBinarieFilePrefixDate",""+smBinarieFilePrefixDate);
configFile.SetProperty("smIPadress", smIPadress);
configFile.SetProperty("smPort", "" + smPort);
configFile.SetProperty("smGenerateBinarieFile",
"" + smGenerateBinarieFile);
configFile.SetProperty("smBinarieOutputFile", smBinarieOutputFile);
configFile.SetProperty("smBinarieOutputFile", smBinarieOutputDirectory);
configFile.SetProperty("smBinarieFilePrefixDate",
"" + smBinarieFilePrefixDate);
}
private void initialiseFromProperties()
{
smIPadress = ConfigFile.GetProperty("smIPadress");
smPort = Integer.parseInt(ConfigFile.GetProperty("smPort"));
smGenerateBinarieFile = Boolean.parseBoolean(ConfigFile.GetProperty("smGenerateBinarieFile"));
smBinarieOutputFile = ConfigFile.GetProperty("smBinarieOutputFile");
smBinarieOutputDirectory = ConfigFile.GetProperty("smBinarieOutputDirectory");
smBinarieFilePrefixDate = Boolean.parseBoolean(ConfigFile.GetProperty("smBinarieFilePrefixDate"));
private void initialiseFromProperties() {
smIPadress = configFile.GetProperty("smIPadress");
smPort = Integer.parseInt(configFile.GetProperty("smPort"));
smGenerateBinarieFile = Boolean
.parseBoolean(configFile.GetProperty("smGenerateBinarieFile"));
smBinarieOutputFile = configFile.GetProperty("smBinarieOutputFile");
smBinarieOutputDirectory = configFile
.GetProperty("smBinarieOutputDirectory");
smBinarieFilePrefixDate = Boolean.parseBoolean(
configFile.GetProperty("smBinarieFilePrefixDate"));
}
/**
* @return IP adress
*/
public String getSmIPadress() {
return smIPadress;
}
public void setSmIPadress(String iPadress) {
/**
* @param iPadress
*/
public void setSmIPadress(final String iPadress) {
smIPadress = iPadress;
}
/**
* @return Port
*/
public int getSmPort() {
return smPort;
}
public void setSmPort(int port) {
public void setSmPort(final int port) {
this.smPort = port;
}
public String toString() {
return smIPadress + ":" + smPort;
}
/**
* @return GenerateBinarieFile
*/
public boolean isSmGenerateBinarieFile() {
return smGenerateBinarieFile;
}
public void setSmGenerateBinarieFile(boolean smGenerateBinarieFile) {
public void setSmGenerateBinarieFile(final boolean smGenerateBinarieFile) {
this.smGenerateBinarieFile = smGenerateBinarieFile;
}
/**
* @return BinarieOutputFile
*/
public String getSmBinarieOutputFile() {
return smBinarieOutputFile;
}
public void setSmBinarieOutputFile(String smBinarieOutputFile) {
public void setSmBinarieOutputFile(final String smBinarieOutputFile) {
this.smBinarieOutputFile = smBinarieOutputFile;
}
/**
* @return BinarieFilePrefixDate
*/
public boolean isSmBinarieFilePrefixDate() {
return smBinarieFilePrefixDate;
}
public void setSmBinarieFilePrefixDate(boolean smBinarieFilePrefixDate) {
public void setSmBinarieFilePrefixDate(final boolean smBinarieFilePrefixDate) {
this.smBinarieFilePrefixDate = smBinarieFilePrefixDate;
}
/**
* @return BinarieOutputDirectory
*/
public String getSmBinarieOutputDirectory() {
return smBinarieOutputDirectory;
}
public void setSmBinarieOutputDirectory(String smBinarieOutputDirectory) {
public void setSmBinarieOutputDirectory(final String smBinarieOutputDirectory) {
this.smBinarieOutputDirectory = smBinarieOutputDirectory;
}
}
......@@ -2,11 +2,8 @@ package org.josast.ModuleSoundModem;
import java.util.Arrays;
/**
* manage Kiss frame based on KISS protocol
*
/** manage Kiss frame based on KISS protocol.
* @see http://www.ka9q.net/papers/kiss.html
*
* @author christophe
*
*/
......@@ -75,8 +72,7 @@ public class kiss {
throw new KissException("FEND (0xC0) value not find at the end of the frame ");
}
// Identifie le type de trame
switch (kissdata[1])
{
switch (kissdata[1]) {
case 0 : type = DATA;
break;
case 1 : type = TXDELAY;
......@@ -95,7 +91,6 @@ public class kiss {
break;
default : type = UNKNOW;
}
int cptraw = 0;
......@@ -105,11 +100,9 @@ public class kiss {
rawData[cptraw++] = kissdata[i++];
} else {
if (kissdata[i + 1] == TFEND) {
rawData[cptraw++] = FEND;
i = i + 2;
} else if (kissdata[i + 1] == TFESC) {
rawData[cptraw++] = FESC;
i = i + 2;
} else {
......