Skip to content

Commit

Permalink
Fix skychart date set and infinite loop (#78)
Browse files Browse the repository at this point in the history
* Fix date format and infinite loop

* New snapshot version
  • Loading branch information
capape authored Jun 20, 2023
1 parent 4775f4c commit 9404904
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 24 deletions.
2 changes: 1 addition & 1 deletion observation-manager/deepsky-extension/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>observation-manager</artifactId>
<groupId>de.lehmannet.om</groupId>
<version>1.6.0-RC12</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<groupId>de.lehmannet.om</groupId>
Expand Down
2 changes: 1 addition & 1 deletion observation-manager/imager-extension/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>observation-manager</artifactId>
<groupId>de.lehmannet.om</groupId>
<version>1.6.0-RC12</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<groupId>de.lehmannet.om</groupId>
Expand Down
2 changes: 1 addition & 1 deletion observation-manager/observation-manager-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>observation-manager</artifactId>
<groupId>de.lehmannet.om</groupId>
<version>1.6.0-RC12</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<groupId>de.lehmannet.om</groupId>
Expand Down
2 changes: 1 addition & 1 deletion observation-manager/observation-manager-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<artifactId>observation-manager</artifactId>
<groupId>de.lehmannet.om</groupId>
<version>1.6.0-RC12</version>
<version>1.6.0-SNAPSHOT</version>
</parent>
<properties>
<eap.fits.version>1.3</eap.fits.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>observation-manager</artifactId>
<groupId>de.lehmannet.om</groupId>
<version>1.6.0-RC12</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<groupId>de.lehmannet.om</groupId>
Expand Down
2 changes: 1 addition & 1 deletion observation-manager/observation-planner-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<artifactId>observation-manager</artifactId>
<groupId>de.lehmannet.om</groupId>
<version>1.6.0-RC12</version>
<version>1.6.0-SNAPSHOT</version>
</parent>


Expand Down
2 changes: 1 addition & 1 deletion observation-manager/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<packaging>pom</packaging>
<artifactId>observation-manager</artifactId>
<groupId>de.lehmannet.om</groupId>
<version>1.6.0-RC12</version>
<version>1.6.0-SNAPSHOT</version>

<scm>
<connection>scm:git:git@github.com:capape/observation-manager.git</connection>
Expand Down
2 changes: 1 addition & 1 deletion observation-manager/skychart-extension/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>observation-manager</artifactId>
<groupId>de.lehmannet.om</groupId>
<version>1.6.0-RC12</version>
<version>1.6.0-SNAPSHOT</version>
</parent>
<groupId>de.lehmannet.om</groupId>
<artifactId>skychart-extension</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

package de.lehmannet.om.extension.skychart;

import static de.lehmannet.om.util.Sanitizer.toLogMessage;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
Expand All @@ -15,6 +17,7 @@
import java.net.URL;
import java.net.UnknownHostException;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Collections;
import java.util.HashSet;
import java.util.Locale;
Expand Down Expand Up @@ -472,14 +475,12 @@ public void run() {

} catch (IOException ioe) {
om.createWarning(SkyChartClient.this.bundle.getString("skychart.application.start.failed"));
LOGGER.error("Unable to start Skychart application ({}})", applicationPath, ioe);
} catch (IllegalMonitorStateException isme) {
// Ignore. This comes from the p.wait() call, when
// skychart is already launched
LOGGER.error("Ingnoring", isme);
LOGGER.error("Unable to start Skychart application ({}). {}", toLogMessage(applicationPath),
toLogMessage(ioe.toString()));
} catch (Exception e) {
om.createWarning(SkyChartClient.this.bundle.getString("skychart.application.start.failed"));
LOGGER.error("Failed to start Skychart application ({})", applicationPath, e);
LOGGER.error("Failed to start Skychart application ({}) {}", toLogMessage(applicationPath),
toLogMessage(e.toString()));
}
}

Expand Down Expand Up @@ -625,7 +626,7 @@ private String createREFRESHCommand() {

private String createDateCommand(ZonedDateTime date) {

String dateString = date.toString();
String dateString = DateTimeFormatter.ISO_INSTANT.format(date);

return "SETDATE " + dateString.substring(0, dateString.lastIndexOf("T") + 9);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.nio.charset.Charset;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -24,28 +25,28 @@ public StarchartSocket(String ip, int port) throws IOException {

super(ip, port);

this.out = new PrintWriter(super.getOutputStream(), true);
this.in = new BufferedReader(new InputStreamReader(super.getInputStream()));
this.out = new PrintWriter(super.getOutputStream(), true, Charset.forName("UTF-8"));
this.in = new BufferedReader(new InputStreamReader(super.getInputStream(), Charset.forName("UTF-8")));

String response = this.in.readLine();

LOGGER.debug("Socket creation response from Skychart: {}", response);

}

public String send(String command) throws IOException {
public String send(String paramCommand) throws IOException {

// Add CR+LF (Byte 10 and 13) to end of command as PrintWriter.println()
// uses system
// line separator which is 13+10 on windows and e.g. only 10 on Linux.
// Skycharts expects 13+10 so we've to make sure the CR+LF comes as
// expected to Skychart
byte[] b = command.getBytes();
byte[] b = paramCommand.getBytes("UTF-8");
byte[] lfB = new byte[b.length + 2];
System.arraycopy(b, 0, lfB, 0, b.length);
lfB[lfB.length - 2] = 13;
lfB[lfB.length - 1] = 10;
command = new String(lfB);
String command = new String(lfB, "UTF-8");
StringBuilder byteString = new StringBuilder();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Skychart command is: {}", command);
Expand Down Expand Up @@ -90,10 +91,14 @@ public void close() throws IOException {

try {
if (out != null) {

this.out.close();
this.out = null;
}
if (in != null) {
this.in.close();
BufferedReader aux = this.in;
this.in = null;
aux.close();
}
} catch (IllegalStateException ise) {
// Readers and writers cannot be closed...can't do anything here
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
skychart.move.ok=Skychart movido a
skychart.move.ok=Skychart movido a
skychart.move.failed=Error al mover Skychart. No se encontr\u00f3 el objetivo o no se proporcionaron datos de posici\u00f3n.
skychart.communication.failed=No es posible conectar con Skychart. Por favor compruebe el archivo de registro y la configuraci\u00f3n.
skychart.communication.failed.host=No es posible conectar con Skychart. Host desconocido. Por favor compruebe la configuraci\u00f3n.
Expand Down
2 changes: 1 addition & 1 deletion observation-manager/solar-system-extension/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>observation-manager</artifactId>
<groupId>de.lehmannet.om</groupId>
<version>1.6.0-RC12</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<groupId>de.lehmannet.om</groupId>
Expand Down
2 changes: 1 addition & 1 deletion observation-manager/variable-stars-extension/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>observation-manager</artifactId>
<groupId>de.lehmannet.om</groupId>
<version>1.6.0-RC12</version>
<version>1.6.0-SNAPSHOT</version>
</parent>
<groupId>de.lehmannet.om</groupId>
<artifactId>variable-stars-extension</artifactId>
Expand Down

0 comments on commit 9404904

Please sign in to comment.