package org.josast.SIDS;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;


/** 
 *  SIDSdate is a simple class used to store SIDS data information 
 * 
 * @author Xtophe
 *
 */

public class SIDSData {
	
	
	final private 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 longitude=null; // Longitude of the receiver (WGS84)       8.95564E

	private String  latitude=null; //Latitude of the receiver (WGS84)             49.73145N

	private int tncPort = 0;  // Optional as per SiDS standard specification, but not used in PicSat SiDS system      0

	private double azimuth = 0.0;  // azimuth degree of directionnal antenna (if avaiblable)        10.5

	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

	final private String version =  "2.0.1";




	public SIDSData ( )

	{

	}

	
	/**
	 *  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)

	{
	
		ISO8601DATEFORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
		timestamp = ISO8601DATEFORMAT.format(date);
		frame=inputframe;
		
	}
 
	 

	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 int getNoradID() {
		return noradID;
	}

	public void setNoradID(int noradID) {
		this.noradID = noradID;
	}

	public String getSource() {
		return source;
	}

	public void setSource(String source) {
		this.source = source;
	}

	public String getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(String timestamp) {
		this.timestamp = timestamp;
	}

	public String getFrame() {
		return frame;
	}

	public void setFrame(String frame) {
		this.frame = frame;
	}

	public int getTncPort() {
		return tncPort;
	}

	public void setTncPort(int tncPort) {
		this.tncPort = tncPort;
	}

	public double getAzimuth() {
		return azimuth;
	}

	public void setAzimuth(double azimuth) {
		this.azimuth = azimuth;
	}

	public double getElevation() {
		return elevation;
	}

	public void setElevation(double elevation) {
		this.elevation = elevation;
	}

	public long getfDown() {
		return fDown;
	}

	public void setfDown(long fDown) {
		this.fDown = fDown;
	}



	
	/**
	 *  Set Station information. Fill source, longitude & latitude information.
	 * @param station
	 */
	public void setStation(Station station)

	{

	source = station.getCallsign();

	longitude = station.getLongitude();

	latitude = station.getLatitude();

	}

	public String getLocator() {
	
		return locator;
	}

	 
	public String toStringBasic()
	{
		StringBuilder sb = new StringBuilder ();
		sb.append("noradID=");
		sb.append(noradID);
		sb.append("&source=");
		sb.append(source);
		sb.append("&timestamp=");
		sb.append(timestamp);
		sb.append("&frame=");
		sb.append(frame);	
		sb.append("&locator=");
		sb.append(locator);
		sb.append("&longitude=");
		sb.append(longitude);	
		sb.append("&latitude=");
		sb.append(latitude);
		sb.append("&version=");
		sb.append(version);	
			
		
		return sb.toString() ;
		
	}


	 

	
	
}
