From 527b26f3990b7c7a0a90df4508edd1b7ef310f23 Mon Sep 17 00:00:00 2001 From: Simon Ebner Date: Tue, 16 Apr 2013 08:04:55 +0200 Subject: [PATCH] Initial commit --- ch.psi.fdaq/.classpath | 32 +++++++ ch.psi.fdaq/.gitignore | 1 + ch.psi.fdaq/.project | 23 +++++ .../.settings/org.eclipse.jdt.core.prefs | 2 + .../.settings/org.eclipse.m2e.core.prefs | 4 + ch.psi.fdaq/pom.xml | 20 +++++ .../main/java/ch/psi/fdaq/SocketClient.java | 87 +++++++++++++++++++ .../java/ch/psi/fdaq/SocketClientStop.java | 56 ++++++++++++ ch.psi.fdaq/src/main/resources/.gitignore | 0 ch.psi.fdaq/src/test/java/.gitignore | 0 ch.psi.fdaq/src/test/resources/.gitignore | 0 11 files changed, 225 insertions(+) create mode 100644 ch.psi.fdaq/.classpath create mode 100644 ch.psi.fdaq/.gitignore create mode 100644 ch.psi.fdaq/.project create mode 100644 ch.psi.fdaq/.settings/org.eclipse.jdt.core.prefs create mode 100644 ch.psi.fdaq/.settings/org.eclipse.m2e.core.prefs create mode 100644 ch.psi.fdaq/pom.xml create mode 100644 ch.psi.fdaq/src/main/java/ch/psi/fdaq/SocketClient.java create mode 100644 ch.psi.fdaq/src/main/java/ch/psi/fdaq/SocketClientStop.java create mode 100644 ch.psi.fdaq/src/main/resources/.gitignore create mode 100644 ch.psi.fdaq/src/test/java/.gitignore create mode 100644 ch.psi.fdaq/src/test/resources/.gitignore diff --git a/ch.psi.fdaq/.classpath b/ch.psi.fdaq/.classpath new file mode 100644 index 0000000..8dee4f3 --- /dev/null +++ b/ch.psi.fdaq/.classpath @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ch.psi.fdaq/.gitignore b/ch.psi.fdaq/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/ch.psi.fdaq/.gitignore @@ -0,0 +1 @@ +/target diff --git a/ch.psi.fdaq/.project b/ch.psi.fdaq/.project new file mode 100644 index 0000000..75b1b8f --- /dev/null +++ b/ch.psi.fdaq/.project @@ -0,0 +1,23 @@ + + + ch.psi.fdaq + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/ch.psi.fdaq/.settings/org.eclipse.jdt.core.prefs b/ch.psi.fdaq/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..4ede96d --- /dev/null +++ b/ch.psi.fdaq/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning diff --git a/ch.psi.fdaq/.settings/org.eclipse.m2e.core.prefs b/ch.psi.fdaq/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/ch.psi.fdaq/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/ch.psi.fdaq/pom.xml b/ch.psi.fdaq/pom.xml new file mode 100644 index 0000000..6ca92d8 --- /dev/null +++ b/ch.psi.fdaq/pom.xml @@ -0,0 +1,20 @@ + + 4.0.0 + ch.psi + ch.psi.fdaq + 0.0.1-SNAPSHOT + + + + i.snapshots + Artifactory Snapshots + http://slsyoke1/artifactory/libs-snapshots-local + + + i.releases + Atrifactory Releases + http://slsyoke1/artifactory/libs-releases-local + + + \ No newline at end of file diff --git a/ch.psi.fdaq/src/main/java/ch/psi/fdaq/SocketClient.java b/ch.psi.fdaq/src/main/java/ch/psi/fdaq/SocketClient.java new file mode 100644 index 0000000..878211c --- /dev/null +++ b/ch.psi.fdaq/src/main/java/ch/psi/fdaq/SocketClient.java @@ -0,0 +1,87 @@ +/** + * + * Copyright 2013 Paul Scherrer Institute. All rights reserved. + * + * This code is free software: you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * This code is distributed in the hope that it will be useful, but without any + * warranty; without even the implied warranty of merchantability or fitness for + * a particular purpose. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + * + */ +package ch.psi.fdaq; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.net.Socket; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + +/** + * Simple socket client to connect to the fdaq black box. + * @author ebner + * + */ +public class SocketClient { + + /** + * Requires connection to: + * ssh -L9999:mchip015:2233 x10da-gw + * + * @param args + * @throws IOException + * @throws InterruptedException + */ + public static void main(String[] args) throws IOException, InterruptedException { + +// Socket echoSocket = new Socket("localhost", 9999); + Socket echoSocket = new Socket("mchip015", 2233); + DataOutputStream out = new DataOutputStream(echoSocket.getOutputStream()); + DataInputStream in = new DataInputStream(echoSocket.getInputStream()); + + int nMessages = 100; + +// struct fdaqbloc_in {int fnum;int nsample;}; + ByteBuffer bytebuffer = ByteBuffer.allocate(2*4); // 2 times Integers + bytebuffer.order(ByteOrder.LITTLE_ENDIAN); + bytebuffer.putInt(26); + bytebuffer.putInt(nMessages); + out.write(bytebuffer.array()); + out.flush(); + + + + for (int t=0;t>16)&0xffff; + int c = buffer.getInt(); + int c1 = c&0xffff; + int c2 = (c>>16)&0xffff; + int d = buffer.getInt(); + + System.out.println(a+ " " +b1+ " " +b2+ " " + c1+ " " +c2+ " " +d ); + } + + out.close(); + in.close(); + echoSocket.close(); + } +} diff --git a/ch.psi.fdaq/src/main/java/ch/psi/fdaq/SocketClientStop.java b/ch.psi.fdaq/src/main/java/ch/psi/fdaq/SocketClientStop.java new file mode 100644 index 0000000..46045f5 --- /dev/null +++ b/ch.psi.fdaq/src/main/java/ch/psi/fdaq/SocketClientStop.java @@ -0,0 +1,56 @@ +/** + * + * Copyright 2013 Paul Scherrer Institute. All rights reserved. + * + * This code is free software: you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * This code is distributed in the hope that it will be useful, but without any + * warranty; without even the implied warranty of merchantability or fitness for + * a particular purpose. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + * + */ +package ch.psi.fdaq; + +import java.io.DataOutputStream; +import java.io.IOException; +import java.net.Socket; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + +/** + * Simple socket client to connect to the fdaq black box. + * @author ebner + * + */ +public class SocketClientStop { + + /** + * Requires connection to: + * ssh -L9999:mchip015:2234 x10da-gw + * + * @param args + * @throws IOException + * @throws InterruptedException + */ + public static void main(String[] args) throws IOException, InterruptedException { + + Socket echoSocket = new Socket("localhost", 9998); + DataOutputStream out = new DataOutputStream(echoSocket.getOutputStream()); + + ByteBuffer bytebuffer = ByteBuffer.allocate(1*4); // 2 times Integers + bytebuffer.order(ByteOrder.LITTLE_ENDIAN); + bytebuffer.putInt(666); + out.write(bytebuffer.array()); + out.flush(); + + out.close(); + echoSocket.close(); + } +} diff --git a/ch.psi.fdaq/src/main/resources/.gitignore b/ch.psi.fdaq/src/main/resources/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/ch.psi.fdaq/src/test/java/.gitignore b/ch.psi.fdaq/src/test/java/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/ch.psi.fdaq/src/test/resources/.gitignore b/ch.psi.fdaq/src/test/resources/.gitignore new file mode 100644 index 0000000..e69de29