Commit f3ff9439 authored by Andrej Mosat's avatar Andrej Mosat

Added zipped archives of binary distributions, just unzip and run

parent d40631c2
Pipeline #3026922 pending
This is using a modified version of Java Simple Serial Connector by Alexey Sokolov. See https://github.com/gohai/java-simple-serial-connector for details on the modifications.
To compile the C++ portion of the library on OS X:
g++ -shared [or: -dynamiclib?] -arch i386 -arch x86_64 -I/System/Library/Frameworks/IOKit.framework/Versions/A/Headers -I$JAVA_HOME/include -I$JAVA_HOME/include/darwin -framework IOKit -framework CoreFoundation -o libjSSC-2.6.jnilib jssc.cpp
#!/bin/sh
APPDIR=$(dirname "$0")
java -Xms64m -Xmx1400m -Djna.nosys=true -Djava.library.path="$APPDIR:$APPDIR/lib" -cp "$APPDIR/lib/mySight3.jar:$APPDIR/lib/core.jar:$APPDIR/lib/jogl-all.jar:$APPDIR/lib/gluegen-rt.jar:$APPDIR/lib/jogl-all-natives-linux-i586.jar:$APPDIR/lib/gluegen-rt-natives-linux-i586.jar:$APPDIR/lib/jssc.jar:$APPDIR/lib/serial.jar" mySight3 "$@"
//// These functions generate data in simulation mode
void fillMockData(byte[] arr) {
//// This generates a sinus function with random noise
int PXSIZE = arr.length;
for (int ii=0; ii<arr.length; ii++) {
arr[ii] = byte( 250*sin( ii*3.14/PXSIZE )*(-0.5+1/( this.random(200000)-100000))-30 - this.random(4));
}
arr[arr.length-3] = 121;
arr[arr.length-2] = 67;
}
// The FileRecorder writes/appends the interval data to the recorder tab delineated text file.
//
class FileRecorder {
String _filePath;
String[] _textLine = new String[4];
void setFilePath(String theFName) {
_filePath = theFName;
println("File record name is " + _filePath);
}
void writeHeader(String customText) {
_textLine[0] = "Spectruino Beta v1.0 mySight " + TAB + "Light intensity vs. Wavelength [nm] / Pixel count [#]" + TAB; //_textLine[0] +
_textLine[1] = "Timestamp: " + datetime();
_textLine[2] = customText;
////@TODO: "Wavelength [nm] (to be implemented...) ,";
_textLine[3] = "Pixel #," + TAB + "Light Intensity [a.u.],"+ TAB + "Wavelength [nm] (to be implemented...) ,";
if (_filePath != null) {
saveStrings(savePath(_filePath), _textLine);
println("Wrote header to " + savePath(_filePath));
println(_textLine[0]);
}
}
//// Write data from measurement history into a file
void writeData(Vector S) {
PrintWriter pw = null;
try {
pw = new PrintWriter(new BufferedWriter(new FileWriter(savePath(_filePath), true))); // true means: "append"
int[] data = (int[]) S.get(0);
int[][] mx = new int[S.size()][data.length];
for (int h=S.size()-1;h>=0; h--)
{ data = (int[]) S.get(h);
mx[h]= data; //data = (int[]) S.get(h);
}
for (int i = 0; i < data.length; i++) {
pw.print(i);
for (int j=0; j<S.size();j++){
pw.print("," + TAB + mx[j][i]);
}
pw.print("\r\n");
}
//dataLine = dataLine.replaceAll(" ","\t");
}
catch (IOException e) {
// Report problem or handle it
e.printStackTrace();
}
finally {
if (pw != null) {
pw.close();
}
}
}
}
This diff is collapsed.
This diff is collapsed.
import processing.serial.*;
class PortDetector {
int detectionInterval = 2 * 1000; // N miliseconds 2000 min for windows
Timer timer = new Timer(detectionInterval);
String[] ports = new String[0];
String portNameDevice;
String portNameShort;
Serial[] serials = new Serial[ports.length];
boolean deviceConnected = false;
boolean portInitializationInProgress = false;
boolean spectruinoDetectionInProgress = false;
boolean detectionTimedOut = false;
boolean mockPort = false; // is simulation mode running?
boolean portReady() {
// is the physical port connected to spectruino?
// meaning application just started, or application has detected spectruino
return (deviceConnected && !spectruinoDetectionInProgress && !portInitializationInProgress);
}
void init() {
ports = Serial.list();
serials = new Serial[ports.length];
mockPort = false;
deviceConnected = false;
}
void startPortDetection(PApplet parent) {
String[] portFound; // null if spectruino serial port not found (true if port was found)
String[] portIsSpecial; // we do not want special serial ports, otherwise errors when opening
init();
detectionTimedOut = false;
spectruinoDetectionInProgress = true;
println("Available ports:");
println(ports);
portInitializationInProgress = true;
for (int i=0; i<ports.length; i++) {
println("Probing: " + i + ports[i]);
portFound = match(ports[i].toLowerCase(), "usb|com\\d*$"); //[uUcC][sSoO][bBmM]
portIsSpecial = match(ports[i].toLowerCase(), "cu.");
//portFound = match(portFound, "!!!!!!!!!!!not cu.Bluetooth alebo cu."); //[uUcC][sSoO][bBmM]
if (portFound!=null && portIsSpecial==null) {
try {
println("Attempting: " + i + ports[i]);
serials[i] = new Serial(parent, ports[i], bitrate);
} catch (Exception e) {
serials[i] = null;
println("Problem probing port " + ports[i] + ".");
e.printStackTrace();
continue;
}
serials[i].bufferUntil(_c);
}// End if portFound
}
timer.start();
portInitializationInProgress = false;
}
Serial checkPortDetection(Serial p) {
println("Checking ports...");
if (portInitializationInProgress || detectionTimedOut() || !spectruinoDetectionInProgress) {
return null;
}
else {
//// if (spectruinoDetectionInProgress) {
byte[] portBytes = p.readBytes();
//// if (!mySight3.this.isHeaderPresent(portBytes, portBytes.length)) {
if (!isHeaderPresent(portBytes, portBytes.length)) {
return null;
}
// close other ports
for (int i=0; i<serials.length; i++) {
if (serials[i]==p)
{
// found spectruino on port
//if (_DBG) {
println("Spectruino on port Nr. ["+i+"] "+ ports[i] );
//printMainText("\nSpectruino connected on port "+ports[i]);
portNameDevice = new String(ports[i]);
String tmp3[] = match(ports[i], "(?<=-).*$|com"); // |com
if (tmp3!=null) {
portNameShort = tmp3[0];
} else {
portNameShort = "unknown";
}
//}
spectruinoDetectionInProgress = false;
} else {
if (serials[i]!=null) {
println("Closing port: " + i);
serials[i].stop();
}
}
}
deviceConnected = true;
return p;
}
/*else {
deviceConnected = false;
return null;
} */
}
boolean detectionTimedOut() {
if (!detectionTimedOut && spectruinoDetectionInProgress && timer.isFinished()) {
for (int i=0; i<serials.length; i++) {
if (serials[i]!=null) {
println("Detection timeout on [" +i);
serials[i].stop();
}
}
detectionTimedOut = true;
println("timer timed out");
}
return detectionTimedOut;
}
}
class Timer {
int savedTime; // When Timer started
int totalTime; // How long Timer should last
boolean timerRunning = false;
Timer(int tempTotalTime) {
totalTime = tempTotalTime;
}
// Starting the timer
void start() {
// When the timer starts it stores the current time in milliseconds.
savedTime = millis();
timerRunning = true;
}
void stop() {
timerRunning = false;
}
// The function isFinished() returns true if 5,000 ms have passed.
// The work of the timer is farmed out to this method.
boolean isFinished() {
if (!timerRunning) {
return true;
}
// Check how much time has passed
int passedTime = millis()- savedTime;
if (passedTime > totalTime) {
return true;
} else {
return false;
}
}
}
String mydate(int offset)
{
Date d = new Date();
long timestamp = d.getTime() + (86400000 * offset);
String date = new java.text.SimpleDateFormat("yyyyMMdd").format(timestamp);
return date;
}
String today()
{
return mydate(0);
}
String mytime()
{ Date d = new Date();
long timestamp = d.getTime();
String date = new java.text.SimpleDateFormat("HHmmss").format(timestamp);
return date;
}
String datetimefile()
{ Date d = new Date();
long timestamp = d.getTime();
String date = new java.text.SimpleDateFormat("yyyyMMddHHmmss").format(timestamp);
return date;
}
String datetime()
{ Date d = new Date();
long timestamp = d.getTime();
String date = new java.text.SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(timestamp);
return date;
}
void printDataDigest(byte[] arr) {
int digestStartLength = 5;
int digestEndLength = 5;
int digestStartEndIndex = min(arr.length, digestStartLength);
int digestEndStartIndex = arr.length-(digestEndLength+HEADER_SIZE);
StringBuilder sb = new StringBuilder();
for (int i=0; i<digestStartEndIndex; i++) {
sb.append(String.valueOf(arr[i]));
sb.append(",");
}
if (digestEndStartIndex>=0 && digestEndStartIndex>digestStartEndIndex) {
sb.append("..., ");
for (int i=digestEndStartIndex; i<arr.length; i++) {
sb.append(String.valueOf(arr[i]));
sb.append(",");
}
}
println(sb.toString());
}
void printDataDigest(int[] arr) {
int digestStartLength = 5;
int digestEndLength = 5;
int digestStartEndIndex = min(arr.length, digestStartLength);
int digestEndStartIndex = arr.length-(digestEndLength+HEADER_SIZE);
StringBuilder sb = new StringBuilder();
for (int i=0; i<digestStartEndIndex; i++) {
sb.append(String.valueOf(arr[i]));
sb.append(",");
}
if (digestEndStartIndex>=0 && digestEndStartIndex>digestStartEndIndex) {
sb.append("..., ");
for (int i=digestEndStartIndex; i<arr.length; i++) {
sb.append(String.valueOf(arr[i]));
sb.append(",");
}
}
println(sb.toString());
}
<?xml version="1.0" ?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>mySight3</string>
<key>CFBundleIconFile</key>
<string>sketch.icns</string>
<key>CFBundleIdentifier</key>
<string>mySight3</string>
<key>CFBundleDisplayName</key>
<string>mySight3</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>mySight3</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<!-- Customize this set as you wish -->
<key>CFBundleShortVersionString</key>
<string>1</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>NSHumanReadableCopyright</key>
<string>Your copyright here</string>
<key>CFBundleGetInfoString</key>
<string>Created with Processing</string>
<!-- End of the set that can be customized -->
<key>JVMRuntime</key>
<string>jdk1.8.0_51.jdk</string>
<key>JVMMainClassName</key>
<string>mySight3</string>
<key>LSMinimumSystemVersion</key>
<string>10.7.3</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>LSArchitecturePriority</key>
<array>
<string>x86_64</string>
</array>
<key>LSEnvironment</key>
<dict>
<key>LC_CTYPE</key>
<string>UTF-8</string>
</dict>
<key>LSUIPresentationMode</key>
<integer>0</integer>
<key>JVMOptions</key>
<array>
<string>-Xms64m</string>
<string>-Xmx1400m</string>
<string>-Djna.nosys=true</string>
<string>-Xdock:icon=$APP_ROOT/Contents/Resources/sketch.icns</string>
<string>-Djava.library.path=$APP_ROOT/Contents/Java</string>
<string>-Dapple.laf.useScreenMenuBar=true</string>
<string>-Dcom.apple.macos.use-file-dialog-packages=true</string>
<string>-Dcom.apple.macos.useScreenMenuBar=true</string>
<string>-Dcom.apple.mrj.application.apple.menu.about.name=mySight3</string>
<string>-Dcom.apple.smallTabs=true</string>
</array>
<key>JVMArguments</key>
<array>
</array>
</dict>
</plist>
This is using a modified version of Java Simple Serial Connector by Alexey Sokolov. See https://github.com/gohai/java-simple-serial-connector for details on the modifications.
To compile the C++ portion of the library on OS X:
g++ -shared [or: -dynamiclib?] -arch i386 -arch x86_64 -I/System/Library/Frameworks/IOKit.framework/Versions/A/Headers -I$JAVA_HOME/include -I$JAVA_HOME/include/darwin -framework IOKit -framework CoreFoundation -o libjSSC-2.6.jnilib jssc.cpp
Copyright © 1993, 2015, Oracle and/or its affiliates.
All rights reserved.
This software and related documentation are provided under a
license agreement containing restrictions on use and
disclosure and are protected by intellectual property laws.
Except as expressly permitted in your license agreement or
allowed by law, you may not use, copy, reproduce, translate,
broadcast, modify, license, transmit, distribute, exhibit,
perform, publish, or display any part, in any form, or by
any means. Reverse engineering, disassembly, or
decompilation of this software, unless required by law for
interoperability, is prohibited.
The information contained herein is subject to change
without notice and is not warranted to be error-free. If you
find any errors, please report them to us in writing.
If this is software or related documentation that is
delivered to the U.S. Government or anyone licensing it on
behalf of the U.S. Government, the following notice is
applicable:
U.S. GOVERNMENT END USERS: Oracle programs, including any
operating system, integrated software, any programs
installed on the hardware, and/or documentation, delivered
to U.S. Government end users are "commercial computer
software" pursuant to the applicable Federal Acquisition
Regulation and agency-specific supplemental regulations. As
such, use, duplication, disclosure, modification, and