Skip to content

Commit

Permalink
v0.9 changelog
Browse files Browse the repository at this point in the history
Prepare release jsle-0.9

cleanup
added a method to format the ccsds time as string including the picoseconds
  • Loading branch information
Nicolae Mihalache committed Jul 14, 2020
1 parent 1e8dd03 commit a219f62
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 22 deletions.
3 changes: 3 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Version 0.9 released 2-July-2020
- minor fixes

Version 0.8 released 28-May-2020
- implemented the Return Channel Frame (RCF) service

Expand Down
6 changes: 3 additions & 3 deletions distribution/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fi

mvn -q clean

clonedir=$jslehome/distribution/target/yamcs-clone
clonedir=$jslehome/distribution/target/jsle-clone

mkdir -p $clonedir
git clone . $clonedir
Expand All @@ -58,13 +58,13 @@ echo
if [ $snapshot -eq 0 ]; then
read -p "Do you want to stage $pomversion maven artifacts to Maven Central? [y/N] " yesNo
if [[ $yesNo == 'y' ]]; then
mvn -f $clonedir -P yamcs-release -DskipTests deploy
mvn -f $clonedir -P jsle-release -DskipTests deploy
echo 'Release the staging repository at https://oss.sonatype.org'
fi
else
read -p "Do you want to publish $pomversion maven artifacts to Sonatype Snapshots? [y/N] " yesNo
if [[ $yesNo == 'y' ]]; then
mvn -f $clonedir -P yamcs-release -DskipTests -DskipStaging deploy
mvn -f $clonedir -P jsle-release -DskipTests -DskipStaging deploy
fi
fi

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>org.yamcs</groupId>
<artifactId>jsle</artifactId>
<packaging>jar</packaging>
<version>0.9-SNAPSHOT</version>
<version>0.9</version>
<name>jsle</name>
<url>https://github.com/yamcs/jsle</url>
<description>Java implementation for the SLE (Space Link Extension) protocol.</description>
Expand Down
27 changes: 22 additions & 5 deletions src/main/java/org/yamcs/sle/CcsdsTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public class CcsdsTime implements Comparable<CcsdsTime> {
final private int numDays;

final private long picosecInDay;
final static DateTimeFormatter formatter = new DateTimeFormatterBuilder().appendInstant(3).toFormatter();
final static DateTimeFormatter FORMATTER = DateTimeFormatter.ISO_INSTANT;
final static DateTimeFormatter FORMATTER_SEC = new DateTimeFormatterBuilder().appendInstant(0).toFormatter();

public CcsdsTime(int numDays, long picosecInDay) {
this.numDays = numDays;
Expand Down Expand Up @@ -237,10 +238,7 @@ public long toJavaMillisec() {
return ((long) numDays - NUM_DAYS_1958_1970) * MS_IN_DAY + picosecInDay / 1000_000_000;
}

public String toString() {
return formatter
.format(Instant.ofEpochSecond(((long) numDays - NUM_DAYS_1958_1970) * SEC_IN_DAY, picosecInDay / 1000));
}


@Override
public int compareTo(CcsdsTime o) {
Expand All @@ -250,4 +248,23 @@ public int compareTo(CcsdsTime o) {
}
return x;
}

/**
* Formats the time with up to nanosecond resolution
*/
public String toString() {
Instant inst = Instant.ofEpochSecond(((long) numDays - NUM_DAYS_1958_1970) * SEC_IN_DAY, picosecInDay / 1000);
return FORMATTER.format(inst);
}

/**
* Converts to ISO8860 string with 12 digits picoseconds after dot
* @return
*/
public String toStringPico() {
Instant inst = Instant.ofEpochSecond(((long) numDays - NUM_DAYS_1958_1970) * SEC_IN_DAY, picosecInDay / 1000);
String s = FORMATTER_SEC.format(inst);
//silly we have to remove the 'Z' from the string formatted by DateTimeFormatter
return String.format("%s.%012dZ", s.substring(0, s.length()-1), picosecInDay % 1_000_000_000_000L);
}
}
31 changes: 18 additions & 13 deletions src/main/java/org/yamcs/sle/udpslebridge/UdpCltuUplinker.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,30 @@
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.yamcs.sle.CcsdsTime;
import org.yamcs.sle.Constants.ForwardDuStatus;
import org.yamcs.sle.provider.CltuUplinker;

import io.netty.buffer.ByteBufUtil;

public class UdpCltuUplinker implements CltuUplinker {
static Logger logger = Logger.getLogger(UdpFrameReceiver.class.getName());

String hostname;
int port;
int bitrate;
InetAddress address;
DatagramSocket socket;

public UdpCltuUplinker(String hostname, int port, int bitrate) {
this.hostname = hostname;
this.port = port;
this.bitrate = bitrate;
}


@Override
public int start() {
try {
Expand All @@ -35,36 +37,39 @@ public int start() {
logger.warning(e.toString());
return 1;// unable to comply
}
return -1;//ok
return -1;// ok
}

@Override
public UplinkResult uplink(byte[] cltuData) {
UplinkResult ur = new UplinkResult();

DatagramPacket dtg = new DatagramPacket(cltuData, cltuData.length, address, port);
ur.startTime = CcsdsTime.now();
long durationNs = cltuData.length*8*1000_000_000/bitrate;
int millis = (int) (durationNs/1000_000);
int nanos = (int) (durationNs%1000_000);
long durationNs = cltuData.length * 8 * 1000_000_000 / bitrate;
int millis = (int) (durationNs / 1000_000);
int nanos = (int) (durationNs % 1000_000);

try {
Thread.sleep(millis, nanos);
} catch (InterruptedException e1) {
Thread.currentThread().interrupt();
ur.cltuStatus = ForwardDuStatus.interrupted;
return ur;
}

if (logger.isLoggable(Level.FINE)) {
logger.fine("Sending UDP CLTU " + ByteBufUtil.hexDump(cltuData));
}

try {
socket.send(dtg);
ur.cltuStatus = ForwardDuStatus.radiated;
ur.stopTime = CcsdsTime.now();
return ur;
} catch (IOException e) {
logger.warning("Error sending datagram"+ e);
ur.cltuStatus = ForwardDuStatus.interrupted;
return ur;
logger.warning("Error sending datagram" + e);
ur.cltuStatus = ForwardDuStatus.interrupted;
return ur;
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/test/java/org/yamcs/sle/CcsdsTimeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@ public void test4() {
assertEquals("2020-05-05T20:50:00.001Z", t.toString());
}

@Test
public void test5() {
CcsdsTime t = new CcsdsTime(1, 301123456789012L);
assertEquals("1958-01-02T00:05:01.123456789012Z", t.toStringPico());
}
}

0 comments on commit a219f62

Please sign in to comment.