diff --git a/.github/workflows/build.yml b/.github/build.yml
similarity index 94%
rename from .github/workflows/build.yml
rename to .github/build.yml
index c8d608bb4c..b510c17054 100644
--- a/.github/workflows/build.yml
+++ b/.github/build.yml
@@ -1,3 +1,5 @@
+# This file must be in the .github/workflows folder for git actions to work
+# but currently is disabled, since builds are being done by jenkins
name: Java CI
on:
@@ -82,3 +84,4 @@ jobs:
tag_name: ${{ steps.version.outputs.version }}
generate_release_notes: true
body_path: ./release-template.md
+
diff --git a/Jenkinsfile b/Jenkinsfile
index a0e8bed48e..7e85304616 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -6,7 +6,6 @@
* Cancel all jobs - Jenkins.instance.queue.clear()
***********************************************************************************/
-
pipeline {
// https://plugins.jenkins.io/agent-server-parameter/
// agent { label params['agent-name'] }
@@ -51,43 +50,25 @@ pipeline {
echo "VERSION ${VERSION}"
echo "BUILD_NUMBER ${BUILD_NUMBER}"
-
-
print params['agent-name']
// print System.properties['os.name'].toLowerCase() - access to java object requires permission changes
script {
- if (isUnix()) {
sh '''
- echo isUnix true
git --version
java -version
mvn -version
'''
- echo sh(script: 'env|sort', returnStdout: true)
- } else {
- bat '''
- echo isUnix false
- git --version
- java -version
- mvn -version
- set
- '''
}
}
- }
} // stage build
stage('compile') {
steps {
script {
- if (isUnix()) {
sh '''
mvn -Dbuild.number=${BUILD_NUMBER} -DskipTests -q clean compile
'''
- } else {
- bat(/"${MAVEN_HOME}\bin\mvn" -Dbuild.number=${BUILD_NUMBER} -DskipTests -q clean compile /)
- }
}
}
} // stage compile
@@ -98,19 +79,12 @@ pipeline {
}
steps {
script {
- // TODO - integration tests !
- if (isUnix()) {
sh '''
mvn test -Dtest=org.myrobotlab.framework.DependencyTest -q
'''
- } else {
- bat '''
- mvn test -Dtest=org.myrobotlab.framework.DependencyTest -q
- '''
- }
}
}
- } // stage verify
+ } // stage dependencies
stage('verify') {
when {
@@ -118,16 +92,9 @@ pipeline {
}
steps {
script {
- // TODO - integration tests !
- if (isUnix()) {
sh '''
mvn -Dfile.encoding=UTF-8 -DargLine="-Xmx1024m" verify --fail-fast -q
'''
- } else {
- bat '''
- mvn -Dfile.encoding=UTF-8 -DargLine="-Xmx1024m" verify --fail-fast -q
- '''
- }
}
}
} // stage verify
@@ -135,54 +102,42 @@ pipeline {
stage('package') {
steps {
script {
- if (isUnix()) {
sh '''
mvn -Dbuild.number=${BUILD_NUMBER} -DskipTests -q package
'''
- } else {
- bat(/"${MAVEN_HOME}\bin\mvn" -Dbuild.number=${BUILD_NUMBER} -DskipTests -q package /)
- }
}
}
- } // stage compile
+ } // stage package
stage('javadoc') {
- // when {
- // // expression { params.javadoc == 'true' }
- // expression { env.BRANCH_NAME == 'master' || env.BRANCH_NAME == 'develop' }
- // }
+ when {
+ // expression { params.javadoc == 'true' }
+ expression { env.BRANCH_NAME == 'master' || env.BRANCH_NAME == 'develop' }
+ }
steps {
- script {
- if (isUnix()) {
sh '''
mvn -q javadoc:javadoc
'''
- } else {
- bat '''
- mvn -q javadoc:javadoc
- '''
- }
}
- }
} // stage javadoc
- stage('archive-min') {
- when {
- expression { env.BRANCH_NAME != 'master' && env.BRANCH_NAME != 'develop' }
- }
+ stage('archive') {
+ // when {
+ // expression { env.BRANCH_NAME != 'master' && env.BRANCH_NAME != 'develop' }
+ // }
steps {
- archiveArtifacts 'target/myrobotlab.jar, target/surefire-reports/*, target/*.exec'
+ archiveArtifacts 'target/myrobotlab.jar, target/surefire-reports/**, target/*.exec, target/site/**'
}
}
- stage('archive-javadocs') {
- when {
- expression { env.BRANCH_NAME == 'master' || env.BRANCH_NAME == 'develop' }
- }
- steps {
- archiveArtifacts 'target/myrobotlab.zip, target/surefire-reports/*, target/*.exec, target/site/**'
- }
- }
+ // stage('archive-javadocs') {
+ // when {
+ // expression { env.BRANCH_NAME == 'master' || env.BRANCH_NAME == 'develop' }
+ // }
+ // steps {
+ // archiveArtifacts 'target/myrobotlab.zip, target/surefire-reports/*, target/*.exec, target/site/**'
+ // }
+ // }
// stage('jacoco') {
// steps {
@@ -192,9 +147,10 @@ pipeline {
// }
stage('publish-github') {
- when { expression { env.BRANCH_NAME == 'master' || env.BRANCH_NAME == 'develop' } }
+ // when { expression { env.BRANCH_NAME == 'master' || env.BRANCH_NAME == 'develop' } }
+ when { expression { env.BRANCH_NAME == 'master'} }
steps {
- withCredentials([string(credentialsId: 'github-token-2', variable: 'token')]) { // var name "token" is set in cred config and is case senstive
+ withCredentials([string(credentialsId: 'supertick-github-token', variable: 'token')]) { // var name "token" is set in cred config and is case senstive
echo "publishing ${VERSION_PREFIX}.${BUILD_NUMBER}"
echo "version ${VERSION}"
// for security - your supposed to make it non-interpretive single quotes and let the OS process the interpolation
@@ -217,5 +173,12 @@ pipeline {
}
}
+ always {
+ // publish junit
+ junit 'target/surefire-reports/**/*.xml'
+ // Publish JaCoCo coverage report
+ jacoco(execPattern: '**/target/jacoco.exec')
+ }
+
} // post
} // pipeline
diff --git a/pom.xml b/pom.xml
index 66429a97ae..1ddd46462c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2025,9 +2025,8 @@
**/integration/*
- **/OpenCV*
-
+
diff --git a/src/main/java/SampleAsyncCallback.java b/src/main/java/SampleAsyncCallback.java
deleted file mode 100644
index dde262aae1..0000000000
--- a/src/main/java/SampleAsyncCallback.java
+++ /dev/null
@@ -1,511 +0,0 @@
-
-/*******************************************************************************
- * Copyright (c) 2009, 2014 IBM Corp.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v1.0 which accompany this distribution.
- *
- * The Eclipse Public License is available at
- * http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Dave Locke - initial API and implementation and/or initial documentation
- */
-
-import org.eclipse.paho.client.mqttv3.IMqttActionListener;
-import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
-import org.eclipse.paho.client.mqttv3.IMqttToken;
-import org.eclipse.paho.client.mqttv3.MqttAsyncClient;
-import org.eclipse.paho.client.mqttv3.MqttCallback;
-import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
-import org.eclipse.paho.client.mqttv3.MqttException;
-import org.eclipse.paho.client.mqttv3.MqttMessage;
-
-/**
- * A sample application that demonstrates how to use the MQTT v3 Client api in
- * non-blocking callback/notification mode.
- *
- * It can be run from the command line in one of two modes: - as a publisher,
- * sending a single message to a topic on the server - as a subscriber,
- * listening for messages from the server
- *
- * There are three versions of the sample that implement the same features but
- * do so using using different programming styles:
- *
- *
Sample (this one) which uses the API which blocks until the operation
- * completes
- *
SampleAsyncWait shows how to use the asynchronous API with waiters that
- * block until an action completes
- *
SampleAsyncCallBack shows how to use the asynchronous API where events
- * are used to notify the application when an action completes
- *
- *
- *
- * If the application is run with the -h parameter then info is displayed that
- * describes all of the options / parameters.
- */
-public class SampleAsyncCallback implements MqttCallback {
-
- int state = BEGIN;
-
- static final int BEGIN = 0;
- static final int CONNECTED = 1;
- static final int PUBLISHED = 2;
- static final int SUBSCRIBED = 3;
- static final int DISCONNECTED = 4;
- static final int FINISH = 5;
- static final int ERROR = 6;
- static final int DISCONNECT = 7;
-
- // Private instance variables
- MqttAsyncClient client;
- String brokerUrl;
- private boolean quietMode;
- private MqttConnectOptions conOpt;
- private boolean clean;
- Throwable ex = null;
- Object waiter = new Object();
- boolean donext = false;
- private String password;
- private String userName;
-
- /**
- * Constructs an instance of the sample client wrapper
- *
- * @param brokerUrl
- * the url to connect to
- * @param clientId
- * the client id to connect with
- * @param cleanSession
- * clear state at end of connection or not (durable or non-durable
- * subscriptions)
- * @param quietMode
- * whether debug should be printed to standard out
- * @param userName
- * the username to connect with
- * @param password
- * the password for the user
- * @throws MqttException
- * if an error happens
- */
- public SampleAsyncCallback(String brokerUrl, String clientId, boolean cleanSession, boolean quietMode, String userName, String password) throws MqttException {
- this.brokerUrl = brokerUrl;
- this.quietMode = quietMode;
- this.clean = cleanSession;
- this.password = password;
- this.userName = userName;
-
- try {
- // Construct the object that contains connection parameters
- // such as cleansession and LWAT
- conOpt = new MqttConnectOptions();
- conOpt.setCleanSession(clean);
- if (password != null) {
- conOpt.setPassword(this.password.toCharArray());
- }
- if (userName != null) {
- conOpt.setUserName(this.userName);
- }
-
- // Construct the MqttClient instance
- client = new MqttAsyncClient(this.brokerUrl, clientId);
-
- // Set this wrapper as the callback handler
- client.setCallback(this);
-
- } catch (MqttException e) {
- e.printStackTrace();
- log("Unable to set up client: " + e.toString());
- System.exit(1);
- }
- }
-
- /**
- * Publish / send a message to an MQTT server
- *
- * @param topicName
- * the name of the topic to publish to
- * @param qos
- * the quality of service to delivery the message at (0,1,2)
- * @param payload
- * the set of bytes to send to the MQTT server
- * @throws Throwable
- * t
- */
- public void publish(String topicName, int qos, byte[] payload) throws Throwable {
- // Use a state machine to decide which step to do next. State change occurs
- // when a notification is received that an MQTT action has completed
- while (state != FINISH) {
- switch (state) {
- case BEGIN:
- // Connect using a non blocking connect
- MqttConnector con = new MqttConnector();
- con.doConnect();
- break;
- case CONNECTED:
- // Publish using a non blocking publisher
- Publisher pub = new Publisher();
- pub.doPublish(topicName, qos, payload);
- break;
- case PUBLISHED:
- state = DISCONNECT;
- donext = true;
- break;
- case DISCONNECT:
- Disconnector disc = new Disconnector();
- disc.doDisconnect();
- break;
- case ERROR:
- throw ex;
- case DISCONNECTED:
- state = FINISH;
- donext = true;
- break;
- }
-
- waitForStateChange(10000);
- }
- }
-
- /**
- * Wait for a maximum amount of time for a state change event to occur
- *
- * @param maxTTW
- * maximum time to wait in milliseconds
- * @throws MqttException
- */
- private void waitForStateChange(int maxTTW) throws MqttException {
- synchronized (waiter) {
- if (!donext) {
- try {
- waiter.wait(maxTTW);
- } catch (InterruptedException e) {
- log("timed out");
- e.printStackTrace();
- }
-
- if (ex != null) {
- throw (MqttException) ex;
- }
- }
- donext = false;
- }
- }
-
- /**
- * Subscribe to a topic on an MQTT server Once subscribed this method waits
- * for the messages to arrive from the server that match the subscription. It
- * continues listening for messages until the enter key is pressed.
- *
- * @param topicName
- * to subscribe to (can be wild carded)
- * @param qos
- * the maximum quality of service to receive messages at for this
- * subscription
- * @throws Throwable
- * t
- */
- public void subscribe(String topicName, int qos) throws Throwable {
- // Use a state machine to decide which step to do next. State change occurs
- // when a notification is received that an MQTT action has completed
- while (state != FINISH) {
- switch (state) {
- case BEGIN:
- // Connect using a non blocking connect
- MqttConnector con = new MqttConnector();
- con.doConnect();
- break;
- case CONNECTED:
- // Subscribe using a non blocking subscribe
- Subscriber sub = new Subscriber();
- sub.doSubscribe(topicName, qos);
- break;
- case SUBSCRIBED:
- return;
- case DISCONNECT:
- Disconnector disc = new Disconnector();
- disc.doDisconnect();
- break;
- case ERROR:
- throw ex;
- case DISCONNECTED:
- state = FINISH;
- donext = true;
- break;
- }
- waitForStateChange(10000);
- }
- }
-
- /**
- * Utility method to handle logging. If 'quietMode' is set, this method does
- * nothing
- *
- * @param message
- * the message to log
- */
- void log(String message) {
- if (!quietMode) {
- System.out.println(message);
- }
- }
-
- /****************************************************************/
- /* Methods to implement the MqttCallback interface */
- /****************************************************************/
-
- /**
- * @see MqttCallback#connectionLost(Throwable)
- */
- @Override
- public void connectionLost(Throwable cause) {
- // Called when the connection to the server has been lost.
- // An application may choose to implement reconnection
- // logic at this point. This sample simply exits.
- log("Connection to " + brokerUrl + " lost!" + cause);
- System.exit(1);
- }
-
- /**
- * @see MqttCallback#deliveryComplete(IMqttDeliveryToken)
- */
- @Override
- public void deliveryComplete(IMqttDeliveryToken token) {
- // Called when a message has been delivered to the
- // server. The token passed in here is the same one
- // that was returned from the original call to publish.
- // This allows applications to perform asynchronous
- // delivery without blocking until delivery completes.
- //
- // This sample demonstrates asynchronous deliver, registering
- // a callback to be notified on each call to publish.
- //
- // The deliveryComplete method will also be called if
- // the callback is set on the client
- //
- log("Delivery complete callback: Publish Completed " + token.getTopics());
- }
-
- /**
- * @see MqttCallback#messageArrived(String, MqttMessage)
- */
- @Override
- public void messageArrived(String topic, MqttMessage message) throws MqttException {
- // Called when a message arrives from the server that matches any
- // subscription made by the client
- System.out.println("Time:\t" + System.currentTimeMillis() + " Topic:\t" + topic + " Message:\t" + new String(message.getPayload()) + " QoS:\t" + message.getQos());
- }
-
- /****************************************************************/
- /* End of MqttCallback methods */
- /****************************************************************/
- static void printHelp() {
- System.out.println("Syntax:\n\n" + " Sample [-h] [-a publish|subscribe] [-t ] [-m ]\n"
- + " [-s 0|1|2] -b ] [-p ] [-i ]\n\n" + " -h Print this help text and quit\n"
- + " -q Quiet mode (default is false)\n" + " -a Perform the relevant action (default is publish)\n" + " -t Publish/subscribe to instead of the default\n"
- + " (publish: \"Sample/Java/v3\", subscribe: \"Sample/#\")\n" + " -m Use instead of the default\n"
- + " (\"Message from MQTTv3 Java client\")\n" + " -s Use this QoS instead of the default (2)\n"
- + " -b Use this name/IP address instead of the default (localhost)\n" + " -p Use this port instead of the default (1883)\n\n"
- + " -i Use this client ID instead of SampleJavaV3_\n" + " -c Connect to the server with a clean session (default is false)\n"
- + " \n\n Security Options \n" + " -u Username \n" + " -z Password \n" + " \n\n SSL Options \n" + " -v SSL enabled; true - (default is false) "
- + " -k Use this JKS format key store to verify the client\n" + " -w Passpharse to verify certificates in the keys store\n"
- + " -r Use this JKS format keystore to verify the server\n" + " If javax.net.ssl properties have been set only the -v flag needs to be set\n"
- + "Delimit strings containing spaces with \"\"\n\n" + "Publishers transmit a single message then disconnect from the server.\n"
- + "Subscribers remain connected to the server and receive appropriate\n" + "messages until is pressed.\n\n");
- }
-
- /**
- * Connect in a non blocking way and then sit back and wait to be notified
- * that the action has completed.
- */
- public class MqttConnector {
-
- public MqttConnector() {
- }
-
- public void doConnect() {
- // Connect to the server
- // Get a token and setup an asynchronous listener on the token which
- // will be notified once the connect completes
- log("Connecting to " + brokerUrl + " with client ID " + client.getClientId());
-
- IMqttActionListener conListener = new IMqttActionListener() {
- @Override
- public void onSuccess(IMqttToken asyncActionToken) {
- log("Connected");
- state = CONNECTED;
- carryOn();
- }
-
- @Override
- public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
- ex = exception;
- state = ERROR;
- log("connect failed" + exception);
- carryOn();
- }
-
- public void carryOn() {
- synchronized (waiter) {
- donext = true;
- waiter.notifyAll();
- }
- }
- };
-
- try {
- // Connect using a non blocking connect
- client.connect(conOpt, "Connect sample context", conListener);
- } catch (MqttException e) {
- // If though it is a non blocking connect an exception can be
- // thrown if validation of parms fails or other checks such
- // as already connected fail.
- state = ERROR;
- donext = true;
- ex = e;
- }
- }
- }
-
- /**
- * Publish in a non blocking way and then sit back and wait to be notified
- * that the action has completed.
- */
- public class Publisher {
- public void doPublish(String topicName, int qos, byte[] payload) {
- // Send / publish a message to the server
- // Get a token and setup an asynchronous listener on the token which
- // will be notified once the message has been delivered
- MqttMessage message = new MqttMessage(payload);
- message.setQos(qos);
-
- log("Publishing at: " + System.currentTimeMillis() + " to topic \"" + topicName + "\" qos " + qos);
-
- // Setup a listener object to be notified when the publish completes.
- //
- IMqttActionListener pubListener = new IMqttActionListener() {
- @Override
- public void onSuccess(IMqttToken asyncActionToken) {
- log("Publish Completed");
- state = PUBLISHED;
- carryOn();
- }
-
- @Override
- public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
- ex = exception;
- state = ERROR;
- log("Publish failed" + exception);
- carryOn();
- }
-
- public void carryOn() {
- synchronized (waiter) {
- donext = true;
- waiter.notifyAll();
- }
- }
- };
-
- try {
- // Publish the message
- client.publish(topicName, message, "Pub sample context", pubListener);
- } catch (MqttException e) {
- state = ERROR;
- donext = true;
- ex = e;
- }
- }
- }
-
- /**
- * Subscribe in a non blocking way and then sit back and wait to be notified
- * that the action has completed.
- */
- public class Subscriber {
- public void doSubscribe(String topicName, int qos) {
- // Make a subscription
- // Get a token and setup an asynchronous listener on the token which
- // will be notified once the subscription is in place.
- log("Subscribing to topic \"" + topicName + "\" qos " + qos);
-
- IMqttActionListener subListener = new IMqttActionListener() {
- @Override
- public void onSuccess(IMqttToken asyncActionToken) {
- log("Subscribe Completed");
- state = SUBSCRIBED;
- carryOn();
- }
-
- @Override
- public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
- ex = exception;
- state = ERROR;
- log("Subscribe failed" + exception);
- carryOn();
- }
-
- public void carryOn() {
- synchronized (waiter) {
- donext = true;
- waiter.notifyAll();
- }
- }
- };
-
- try {
- client.subscribe(topicName, qos, "Subscribe sample context", subListener);
- } catch (MqttException e) {
- state = ERROR;
- donext = true;
- ex = e;
- }
- }
- }
-
- /**
- * Disconnect in a non blocking way and then sit back and wait to be notified
- * that the action has completed.
- */
- public class Disconnector {
- public void doDisconnect() {
- // Disconnect the client
- log("Disconnecting");
-
- IMqttActionListener discListener = new IMqttActionListener() {
- @Override
- public void onSuccess(IMqttToken asyncActionToken) {
- log("Disconnect Completed");
- state = DISCONNECTED;
- carryOn();
- }
-
- @Override
- public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
- ex = exception;
- state = ERROR;
- log("Disconnect failed" + exception);
- carryOn();
- }
-
- public void carryOn() {
- synchronized (waiter) {
- donext = true;
- waiter.notifyAll();
- }
- }
- };
-
- try {
- client.disconnect("Disconnect sample context", discListener);
- } catch (MqttException e) {
- state = ERROR;
- donext = true;
- ex = e;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/myrobotlab/arduino/VirtualMsg.java b/src/main/java/org/myrobotlab/arduino/VirtualMsg.java
index cc29874af4..d2cc3ddaf7 100644
--- a/src/main/java/org/myrobotlab/arduino/VirtualMsg.java
+++ b/src/main/java/org/myrobotlab/arduino/VirtualMsg.java
@@ -3,6 +3,8 @@
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
+import java.io.IOException;
+import org.myrobotlab.service.Serial;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
@@ -44,8 +46,11 @@ b16 int int (short) 2 bytes -32,768 to 32,767
import org.myrobotlab.logging.LoggerFactory;
import org.myrobotlab.logging.LoggingFactory;
+import org.myrobotlab.service.VirtualArduino;
import java.io.FileOutputStream;
+import java.util.Arrays;
+import org.myrobotlab.service.interfaces.MrlCommPublisher;
import org.myrobotlab.service.Runtime;
import org.myrobotlab.service.Servo;
import org.myrobotlab.service.interfaces.SerialDevice;
@@ -1589,7 +1594,9 @@ public void onBytes(byte[] bytes) {
msgSize = 0;
Arrays.fill(ioCmd, 0); // FIXME - optimize - remove
// warn(String.format("Arduino->MRL error - bad magic number %d - %d rx errors", newByte, ++errorServiceToHardwareRxCnt));
- log.warn("Arduino->MRL error - bad magic number {} - {} rx errors", newByte, ++errorServiceToHardwareRxCnt);
+ if (!arduino.isConnecting()){
+ log.warn("Arduino->MRL error - bad magic number {} - {} rx errors", newByte, ++errorServiceToHardwareRxCnt);
+ }
}
continue;
} else if (byteCount.get() == 2) {
@@ -1622,7 +1629,10 @@ public void onBytes(byte[] bytes) {
}
if (!clearToSend) {
- log.warn("NOT CLEAR TO SEND! resetting parser!");
+ if (!arduino.isConnecting()) {
+ // we're connecting, so we're going to ignore the message.
+ log.warn("NOT CLEAR TO SEND! resetting parser!");
+ }
// We opened the port, and we got some data that isn't a Begin message.
// so, I think we need to reset the parser and continue processing bytes...
// there will be errors until the next magic byte is seen.
@@ -1877,7 +1887,7 @@ public void enableAcks(boolean b){
}
public void waitForAck(){
- if (!ackEnabled) {
+ if (!ackEnabled || serial == null || !serial.isConnected()) {
return;
}
// if there's a pending message, we need to wait for the ack to be received.
@@ -1910,10 +1920,8 @@ public int getMethod(){
public void add(int value) {
- // this explodes - sendBufferSize increases forever ... duh index not valid
- // is this suppose to be round robin buffer ?
- // sendBuffer[sendBufferSize] = (value & 0xFF);
- // sendBufferSize += 1;
+ sendBuffer[sendBufferSize] = (value & 0xFF);
+ sendBufferSize += 1;
}
public int[] getBuffer() {
@@ -2019,4 +2027,8 @@ public void setInvoke(boolean b){
invoke = b;
}
+ public void setSerial(Serial serial) {
+ this.serial = serial;
+ }
+
}
diff --git a/src/main/java/org/myrobotlab/audio/AudioProcessor.java b/src/main/java/org/myrobotlab/audio/AudioProcessor.java
index 46bc11d136..fb5236daef 100644
--- a/src/main/java/org/myrobotlab/audio/AudioProcessor.java
+++ b/src/main/java/org/myrobotlab/audio/AudioProcessor.java
@@ -23,7 +23,6 @@
import org.myrobotlab.service.data.AudioData;
import org.slf4j.Logger;
-// FIXME - make runnable
public class AudioProcessor extends Thread {
static transient Logger log = LoggerFactory.getLogger(AudioProcessor.class);
diff --git a/src/main/java/org/myrobotlab/audio/CaptureThread.java b/src/main/java/org/myrobotlab/audio/CaptureThread.java
deleted file mode 100644
index cab25ede5d..0000000000
--- a/src/main/java/org/myrobotlab/audio/CaptureThread.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package org.myrobotlab.audio;
-
-import java.io.ByteArrayOutputStream;
-import java.io.OutputStream;
-
-import javax.sound.sampled.SourceDataLine;
-import javax.sound.sampled.TargetDataLine;
-
-import org.myrobotlab.logging.LoggerFactory;
-import org.myrobotlab.logging.Logging;
-import org.myrobotlab.service.AudioFile;
-import org.slf4j.Logger;
-
-class CaptureThread extends Thread {
- // An arbitrary-size temporary holding
- // buffer
- static Logger log = LoggerFactory.getLogger(AudioFile.class);
-
- byte buffer[] = new byte[10000];
- OutputStream out = null;
-
- TargetDataLine audioLine;
- SourceDataLine sourceDataLine;
-
- boolean done = false;
-
- public CaptureThread(TargetDataLine audioLine) {
- this(audioLine, null);
- }
-
- public CaptureThread(TargetDataLine audioLine, OutputStream out) {
- this.audioLine = audioLine;
- if (out == null) {
- out = new ByteArrayOutputStream();
- ;
- }
- this.out = out;
- }
-
- @Override
- public void run() {
- out = new ByteArrayOutputStream();
- try {// Loop until stopCapture is set
- // by another thread that
- // services the Stop button.
- while (!done) {
- // Read data from the internal
- // buffer of the data line.
- int cnt = audioLine.read(buffer, 0, buffer.length);
- if (cnt > 0) {
- // Save data in output stream
- // object.
- out.write(buffer, 0, cnt);
- } // end if
- } // end while
- audioLine.close();
- out.close();
- } catch (Exception e) {
- Logging.logError(e);
- } finally {
- if (out != null) {
- try {
- out.close();
- } catch (Exception e) {
- }
- }
- }
- }// end run
-
- public void setBufferLength(int size) {
- buffer = new byte[size];
- }
-
- public void stopCapture() {
- this.interrupt();
- }
-
- public OutputStream getOuputStream() {
- return out;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/myrobotlab/audio/MRLSoundAudioDevice.java b/src/main/java/org/myrobotlab/audio/MRLSoundAudioDevice.java
deleted file mode 100644
index b6fd2b5666..0000000000
--- a/src/main/java/org/myrobotlab/audio/MRLSoundAudioDevice.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package org.myrobotlab.audio;
-
-//import be.tarsos.dsp.AudioEvent;
-//import be.tarsos.dsp.AudioProcessor;
-import javazoom.jl.decoder.JavaLayerException;
-import javazoom.jl.player.JavaSoundAudioDevice;
-
-public class MRLSoundAudioDevice extends JavaSoundAudioDevice {
-
- // private List audioProcessors = null;
-
- private float gain = 1.0F;
-
- @Override
- public void write(short[] paramArrayOfShort, int paramInt1, int paramInt2) throws JavaLayerException {
-
- if (gain == 1.0) {
- // default behavior
- super.write(paramArrayOfShort, paramInt1, paramInt2);
- } else {
- // so some digital signal processing!!! woot!
- short[] volumeAdjusted = new short[paramArrayOfShort.length];
- for (int i = 0; i < paramArrayOfShort.length; i++) {
- // Multiplication is volume control! amplify the signal by the gain
- // EEK that's a lot of type casting!
- volumeAdjusted[i] = (short) ((paramArrayOfShort[i]) * gain);
- }
- // pass the volume adjusted array to the underlying audio device
- super.write(volumeAdjusted, paramInt1, paramInt2);
-
- }
- }
-
- public float getGain() {
- return gain;
- }
-
- /**
- * A value typically between 0.0 to 1.0. (Values larger than 1.0 may clip the
- * original signal)
- *
- * @param gain
- * - the gain to apply. This is multiplied by the underlying audio
- * signal.
- */
- public void setGain(float gain) {
- this.gain = gain;
- }
-
- // public void setLineGain(float gain)
- // {
- // this.getSourceLineInfo()
- // if (source != null)
- // {
- // FloatControl volControl = (FloatControl)
- // source.getControl(FloatControl.Type.MASTER_GAIN);
- // float newGain = Math.min(Math.max(gain, volControl.getMinimum()),
- // volControl.getMaximum());
- //
- // volControl.setValue(newGain);
- // }
- // }
-
-}
diff --git a/src/main/java/org/myrobotlab/client/DrupalNameProvider.java b/src/main/java/org/myrobotlab/client/DrupalNameProvider.java
deleted file mode 100644
index b9ca47e0d5..0000000000
--- a/src/main/java/org/myrobotlab/client/DrupalNameProvider.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package org.myrobotlab.client;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.Statement;
-
-import org.myrobotlab.logging.LoggerFactory;
-import org.myrobotlab.logging.Logging;
-import org.myrobotlab.service.Shoutbox.NameProvider;
-import org.slf4j.Logger;
-
-public class DrupalNameProvider implements NameProvider {
- public static final Logger log = LoggerFactory.getLogger(DrupalNameProvider.class);
- private Connection conn = null;
-
- @Override
- public String getName(String ip) {
- log.info("==DrupalNameProvider.getName({})==", ip);
- try {
- if (this.conn == null) {
- Class.forName("com.mysql.jdbc.Driver");
- log.info("attempting to connect to mysql");
- this.conn = DriverManager.getConnection("jdbc:mysql://localhost/myrobotlab", "root", "");
- if (this.conn == null) {
- log.error("could not connect");
- return ip;
- }
- }
- String sql = String.format("SELECT users.name, sessions.uid, sessions.hostname FROM myrobotlab.users " + " INNER JOIN myrobotlab.sessions ON sessions.uid=users.uid "
- + " WHERE sessions.hostname = '%s' " + " ORDER BY sessions.uid DESC", ip);
-
- Statement statement = this.conn.createStatement();
- log.info("executing query");
- ResultSet records = statement.executeQuery(sql);
-
- String user = null;
- while (records.next()) {
- user = records.getString("name");
- log.info("found [{}] for ip {}", user, ip);
- if ((user == null) || (user.trim().length() == 0 || user.trim().equals(""))) {
- log.info("user null or blank skipping");
- continue;
- } else {
- log.info("found user [{}]", user);
- return user;
- }
- }
- log.info("no not blank records found returning ip [{}]", ip);
- return ip;
- } catch (Exception e) {
- Logging.logError(e);
- }
- return ip;
- }
-}
diff --git a/src/main/java/org/myrobotlab/cmdline/CcmdParam.java b/src/main/java/org/myrobotlab/cmdline/CcmdParam.java
deleted file mode 100644
index 15c69aea72..0000000000
--- a/src/main/java/org/myrobotlab/cmdline/CcmdParam.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- *
- * @author grog (at) myrobotlab.org
- *
- * This file is part of MyRobotLab (http://myrobotlab.org).
- *
- * MyRobotLab is free software: you can redistribute it and/or modify
- * it under the terms of the Apache License 2.0 as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version (subject to the "Classpath" exception
- * as provided in the LICENSE.txt file that accompanied this code).
- *
- * MyRobotLab is distributed in the hope that it will be useful or fun,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * Apache License 2.0 for more details.
- *
- * All libraries in thirdParty bundle are subject to their own license
- * requirements - please refer to http://myrobotlab.org/libraries for
- * details.
- *
- * Enjoy !
- *
- * */
-
-package org.myrobotlab.cmdline;
-
-import java.util.ArrayList;
-
-public class CcmdParam {
-
- public ArrayList m_strings = new ArrayList();
-
- public CcmdParam() {
- }
-
-}
diff --git a/src/main/java/org/myrobotlab/cmdline/CmdLine.java b/src/main/java/org/myrobotlab/cmdline/CmdLine.java
deleted file mode 100644
index 9d764e0a07..0000000000
--- a/src/main/java/org/myrobotlab/cmdline/CmdLine.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/**
- *
- * @author grog (at) myrobotlab.org
- *
- * This file is part of MyRobotLab (http://myrobotlab.org).
- *
- * MyRobotLab is free software: you can redistribute it and/or modify
- * it under the terms of the Apache License 2.0 as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version (subject to the "Classpath" exception
- * as provided in the LICENSE.txt file that accompanied this code).
- *
- * MyRobotLab is distributed in the hope that it will be useful or fun,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * Apache License 2.0 for more details.
- *
- * All libraries in thirdParty bundle are subject to their own license
- * requirements - please refer to http://myrobotlab.org/libraries for
- * details.
- *
- * Enjoy !
- *
- * */
-
-package org.myrobotlab.cmdline;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-public class CmdLine extends HashMap {
-
- private static final long serialVersionUID = 1560723637806853945L;
-
- private String[] args = null;
-
- public static void main(String[] args) {
-
- CmdLine cmdline = new CmdLine(args);
-
- if (cmdline.containsKey("-test")) {
- String service = cmdline.getSafeArgument("-service", 0, "");
- System.out.println("Service: " + service);
- }
- }
-
- public CmdLine(String[] args) {
- splitLine(args);
- }
-
- public String getArgument(final String pSwitch, int iIdx) {
- if (hasSwitch(pSwitch)) {
- if (containsKey(pSwitch)) {
- if (get(pSwitch).m_strings.size() > iIdx) {
- return get(pSwitch).m_strings.get(iIdx);
- }
- }
- }
-
- // throw (int)0;
-
- return "";
-
- }
-
- public int getArgumentCount(final String pSwitch) {
- int iArgumentCount = -1;
-
- if (hasSwitch(pSwitch)) {
- if (containsKey(pSwitch)) {
- iArgumentCount = get(pSwitch).m_strings.size();
- }
- }
-
- return iArgumentCount;
- }
-
- public ArrayList getArgumentList(final String pSwitch) {
- return get(pSwitch).m_strings;
- }
-
- public String getSafeArgument(final String pSwitch, int iIdx, final String pDefault) {
- String sRet = new String("");
-
- if (pDefault != null) {
- sRet = pDefault;
- }
-
- if (!hasSwitch(pSwitch))
- return sRet;
-
- String r = getArgument(pSwitch, iIdx);
- if ((r == null || r.length() == 0) && (pDefault != null && pDefault.length() != 0)) {
- return pDefault;
- } else {
- return r;
- }
- }
-
- public boolean hasSwitch(final String pSwitch) {
- return containsKey(pSwitch);
- }
-
- public boolean isSwitch(final String pParam) {
- if (pParam == null) {
- return false;
- }
- if (pParam.length() <= 1) {
- return false;
- }
-
- if (pParam.charAt(0) == '-') {
- boolean ret = true;
-
- // allow negative numbers as arguments.
- // ie., don't count them as switches
- ret &= !Character.isDigit(pParam.charAt(1));
-
- // if we have a space then the param was escaped
- // if its escaped e.g. -agent "-test -logLevel WARN" then its not a
- // flag
- ret &= !pParam.contains(" ");
- return ret;
- } else {
- return false;
- }
-
- }
-
- public int splitLine(String[] args) {
- // HashMap a = new HashMap();
- // a.put(arg0, arg1)
- this.args = args;
- String curParam = new String();
- for (int i = 0; i < args.length; ++i) {
- if (isSwitch(args[i])) {
- curParam = args[i];
- String arg = "";
-
- // look at next input string to see if it's a switch or an
- // argument
- if (i + 1 < args.length) {
- if (!isSwitch(args[i + 1])) {
- // it's an argument, not a switch
- arg = args[i + 1];
-
- // skip to next
- i++;
- } else {
- arg = "";
- }
- }
-
- // add it
- CcmdParam cmd = new CcmdParam();
-
- // only add non-empty args
- if (arg != "") {
- cmd.m_strings.add(arg);
- }
-
- // add the CCmdParam to 'this'
- put(curParam, cmd);
- } else {
- // it's not a new switch, so it must be more stuff for the last
- // switch
- // ...let's add it
- // get an iterator for the current param
- if (containsKey(curParam)) {
- // (*theIterator).second.m_strings.push_back(argv[i]);
- get(curParam).m_strings.add(args[i]);
- } else {
- // ??
- }
- }
- }
- return 5;
-
- }
-
- @Override
- public String toString() {
- StringBuffer ret = new StringBuffer();
- for (int i = 0; i < args.length; ++i) {
- ret.append("\"" + args[i] + "\"").append(" ");
- }
-
- return ret.toString();
- }
-}
diff --git a/src/main/java/org/myrobotlab/codec/CodecUtils.java b/src/main/java/org/myrobotlab/codec/CodecUtils.java
index ba528b7a10..eb20b2191b 100644
--- a/src/main/java/org/myrobotlab/codec/CodecUtils.java
+++ b/src/main/java/org/myrobotlab/codec/CodecUtils.java
@@ -1685,4 +1685,10 @@ public static int[] hexToRGB(String hexValue) {
}
return rgb;
}
+
+ public static String hashcodeToHex(int hashCode) {
+ String hexString = Long.toHexString(hashCode).toUpperCase();
+ return String.format("%6s", hexString).replace(' ', '0').substring(0, 6);
+ }
+
}
diff --git a/src/main/java/org/myrobotlab/codec/Recorder.java b/src/main/java/org/myrobotlab/codec/Recorder.java
deleted file mode 100644
index 66df1319f8..0000000000
--- a/src/main/java/org/myrobotlab/codec/Recorder.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.myrobotlab.codec;
-
-import java.io.IOException;
-
-import org.myrobotlab.framework.Message;
-import org.myrobotlab.framework.interfaces.NameProvider;
-
-public interface Recorder {
-
- public abstract void start(NameProvider service) throws IOException;
-
- public abstract void stop() throws IOException;
-
- public abstract void write(Message msg) throws IOException;
-
-}
\ No newline at end of file
diff --git a/src/main/java/org/myrobotlab/codec/RecorderPythonFile.java b/src/main/java/org/myrobotlab/codec/RecorderPythonFile.java
deleted file mode 100644
index ed93be7aea..0000000000
--- a/src/main/java/org/myrobotlab/codec/RecorderPythonFile.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package org.myrobotlab.codec;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import org.myrobotlab.framework.Message;
-import org.myrobotlab.framework.interfaces.NameProvider;
-import org.myrobotlab.service.Runtime;
-
-public class RecorderPythonFile implements Recorder {
-
- boolean isRecording = false;
-
- private transient OutputStream recordingPython;
-
- /*
- * (non-Javadoc)
- *
- * @see org.myrobotlab.codec.Recorder#write(org.myrobotlab.framework.Message)
- */
- @Override
- public void write(Message msg) throws IOException {
- // python
- Object[] data = msg.data;
- String msgName = (msg.getName().equals(Runtime.getInstance().getName())) ? "runtime" : msg.getName();
- recordingPython.write(String.format("%s.%s(", msgName, msg.method).getBytes());
- if (data != null) {
- for (int i = 0; i < data.length; ++i) {
- Object d = data[i];
- if (d.getClass() == Integer.class || d.getClass() == Float.class || d.getClass() == Boolean.class || d.getClass() == Double.class || d.getClass() == Short.class
- || d.getClass() == Short.class) {
- recordingPython.write(d.toString().getBytes());
-
- // FIXME Character probably blows up
- } else if (d.getClass() == String.class || d.getClass() == Character.class) {
- recordingPython.write(String.format("\"%s\"", d).getBytes());
- } else {
- recordingPython.write("object".getBytes());
- }
- if (i < data.length - 1) {
- recordingPython.write(",".getBytes());
- }
- }
- }
- recordingPython.write(")\n".getBytes());
- recordingPython.flush();
- }
-
- @Override
- public void start(NameProvider service) throws FileNotFoundException {
- SimpleDateFormat TSFormatter = new SimpleDateFormat("yyyyMMddHHmmssSSS");
- String cfgDir = String.format("%s%s.myrobotlab", System.getProperty("user.dir"), File.separator);
- String filenamePython = String.format("%s/%s_%s.py", cfgDir, service.getName(), TSFormatter.format(new Date()));
-
- // log.info(String.format("started recording %s to file %s", getName(),
- // filename));
-
- recordingPython = new BufferedOutputStream(new FileOutputStream(filenamePython), 8 * 1024);
-
- }
-
- public static void main(String[] args) {
-
- }
-
- @Override
- public void stop() throws IOException {
- // TODO Auto-generated method stub
-
- }
-
-}
diff --git a/src/main/java/org/myrobotlab/codec/RecorderXmlFile.java b/src/main/java/org/myrobotlab/codec/RecorderXmlFile.java
deleted file mode 100644
index 4ae6a98077..0000000000
--- a/src/main/java/org/myrobotlab/codec/RecorderXmlFile.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.myrobotlab.codec;
-
-import java.io.IOException;
-
-import org.myrobotlab.framework.Message;
-import org.myrobotlab.framework.interfaces.NameProvider;
-
-public class RecorderXmlFile implements Recorder {
-
- @Override
- public void write(Message msg) throws IOException {
- // Object[] data = msg.data;
- // String msgName = (msg.name.equals(Runtime.getInstance().getName())) ?
- // "runtime" : msg.name;
- // TODO implement
-
- }
-
- @Override
- public void start(NameProvider service) throws IOException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void stop() throws IOException {
- // TODO Auto-generated method stub
-
- }
-
-}
diff --git a/src/main/java/org/myrobotlab/framework/CmdOptions.java b/src/main/java/org/myrobotlab/framework/CmdOptions.java
index 996d1b0556..f0eb00c0e7 100644
--- a/src/main/java/org/myrobotlab/framework/CmdOptions.java
+++ b/src/main/java/org/myrobotlab/framework/CmdOptions.java
@@ -45,7 +45,7 @@ static boolean contains(List l, String flag) {
// launcher
@Option(names = { "-c",
- "--config" }, description = "Specify a configuration set to start. The config set is a directory which has all the necessary configuration files. It loads runtime.yml first, and subsequent service configuration files will then load. \n example: --config data/config/my-config-dir")
+ "--config" }, fallbackValue="default", description = "Specify a configuration set to start. The config set is a directory which has all the necessary configuration files. It loads runtime.yml first, and subsequent service configuration files will then load. \n example: --config data/config/my-config-dir")
public String config = null;
@Option(names = {
diff --git a/src/main/java/org/myrobotlab/framework/Config.java b/src/main/java/org/myrobotlab/framework/Config.java
deleted file mode 100644
index 80456356d3..0000000000
--- a/src/main/java/org/myrobotlab/framework/Config.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.myrobotlab.framework;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-@Retention(RUNTIME)
-@Target({ TYPE, METHOD })
-public @interface Config {
- boolean required() default true;
-
- int order() default 50;
-
- String description() default "";
-}
diff --git a/src/main/java/org/myrobotlab/framework/Index.java b/src/main/java/org/myrobotlab/framework/Index.java
deleted file mode 100644
index 3e0f9e3525..0000000000
--- a/src/main/java/org/myrobotlab/framework/Index.java
+++ /dev/null
@@ -1,292 +0,0 @@
-package org.myrobotlab.framework;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Set;
-
-import org.myrobotlab.logging.Level;
-import org.myrobotlab.logging.LoggerFactory;
-import org.myrobotlab.logging.LoggingFactory;
-import org.slf4j.Logger;
-
-public class Index {
-
- public final static Logger log = LoggerFactory.getLogger(IndexNode.class);
-
- private IndexNode root = new IndexNode();
-
- public static void main(String[] args) throws IOException {
- LoggingFactory.init(Level.DEBUG);
-
- Index reservations = new Index();
-
- ArrayList ret = reservations.crawlForDataStartingWith("RightArm");
- log.info("size {} from query of RightArm", ret.size());
- log.info(reservations.toString());
- log.info("here");
-
- // reservations.put("arm.database.config", new
- // ServiceReservation("Rotate","Servo","a servo"));
- /*
- * reservations.put("global.database.qa.server", "Db2udb04");
- * reservations.put("global.database.qa.port", "50005");
- * reservations.put("global.database.qa.schema", "TESTDB2");
- * reservations.put("global.database.qa.userid", "odcad01");
- * reservations.put("global.database.qa.password", "3dglasez");
- *
- * reservations.put("global.database.dev.server", "Db2udb03");
- * reservations.put("global.database.dev.port", "50004");
- * reservations.put("global.database.dev.schema", "FIM");
- * reservations.put("global.database.dev.userid", "odcad00");
- * reservations.put("global.database.dev.password", "3dglases");
- */
- /*
- *
- * String test = reservations.get("global.database.dev.userid", "zod");
- * log.info(test);
- *
- * String dbConfigKey = reservations.get("global.database.config");
- * IndexNode dbConfigNode =
- * reservations.getNode(String.format("global.database.%s" ,dbConfigKey));
- * HashMap dbConfig = dbConfigNode.getBranches();
- *
- * log.info(dbConfig.get("server").getValue().toString());
- * log.info(dbConfig.get("port").getValue().toString());
- * log.info(dbConfig.get("schema").getValue().toString());
- * log.info(dbConfig.get("userid").getValue().toString());
- * log.info(dbConfig.get("password").getValue().toString());
- *
- * // reservations.put("global.database.config","qa"); dbConfigKey =
- * reservations.get("global.database.config"); dbConfigNode = reservations
- * .getNode(String.format("global.database.%s",dbConfigKey)); dbConfig =
- * dbConfigNode.getBranches();
- *
- * log.info(dbConfig.get("server").getValue().toString());
- * log.info(dbConfig.get("port").getValue().toString());
- * log.info(dbConfig.get("schema").getValue().toString());
- * log.info(dbConfig.get("userid").getValue().toString());
- * log.info(dbConfig.get("password").getValue().toString());
- */
- HashMap hash = new HashMap();
- ArrayList array = new ArrayList();
- hash.put("hash1", "hashValue1");
- hash.put("hash2", "hashValue2");
- hash.put("hash3", "hashValue3");
- array.add("array1");
- array.add("array2");
- array.add("array3");
- array.add("array4");
- // config.put("arrayList", array);
- // config.put("hashMap", hash);
-
- // File outfile = new File("out.xml");
-
- // FileInputStream in = new FileInputStream(outfile);
- // Index config2 = new Index();
- // config2.loadFromXML(in);
- }
-
- public Index() {
- /*
- * if (properties == null) { properties = new Properties(); }
- */
- }
-
- public void buildTree(String key, T value) {
- root.buildTree(root, key, value);
- }
-
- /*
- *
- *
- * public void load() { load((String) null); }
- *
- * public void load(String path) { load(path, null); }
- *
- * /* public void load(String path, String propFileName) { if (path == null) {
- * path = System.getProperty("user.dir"); }
- *
- * String configPath = propFileName;
- *
- * try { Properties properties = new Properties(); log.info(
- * "loading config file " + configPath); properties.load(new
- * FileInputStream(configPath));
- *
- * for (String key : properties.stringPropertyNames()) { root.buildTree(root,
- * key, properties.getProperty(key)); //IndexNode.buildTree(root, key,
- * properties.getProperty(key)); } } catch (Exception e) { log.error(
- * "config did not load from location " + configPath);
- * Logging.logException(e); } }
- */
-
- public void clear() {
- root.clear();
- }
-
- /*
- * public static Index getInstance() { return getInstance((String) null); }
- *
- * public static Index getInstance(String path) { if (instance == null) {
- * log.debug("new config"); instance = new Index(); } if (path != null) {
- * load(path); } return instance; }
- */
-
- public ArrayList crawlForDataStartingWith(String inkey) {
- return crawlForDataStartingWith(inkey, 20);
- }
-
- public ArrayList crawlForDataStartingWith(String inkey, int maxItemsToReturn) {
-
- // TODO - start with a TreeMap ?
- ArrayList ret = new ArrayList();
-
- // get the limb in the tree which is keyed for this inkey
- return root.crawlForData(ret, maxItemsToReturn, inkey);
-
- }
-
- public ArrayList flatten() {
- return flatten(null);
- }
-
- /* FULL IndexNode + key Set>> */
- public ArrayList flatten(String key) {
- ArrayList ret = new ArrayList();
- return root.crawlForData(ret, 0, key);
- }
-
- // --------------- config / property extensions begin --------------
- public T get(String name) {
- return get(name, null);
- }
-
- public T get(String name, T defaultValue) {
-
- IndexNode n = root.getNode(name);
- if (n == null) {
- return defaultValue;
- } else {
- return n.getValue(defaultValue);
- }
- }
-
- public Set getKeySetFromNode(String key) {
-
- IndexNode n = root.getNode(key);
- if (n != null) {
- return n.getBranches().keySet();
- }
-
- return null;
- }
-
- public IndexNode getNode(String key) {
- return root.getNode(key);
- }
-
- /**
- * find a node key, by browsing the whole tree.. ( wanted to use
- * crawlForDataStartingWith but seem nok )
- *
- * @param parent
- * - parent node key
- * @param key
- * - this key
- * @return - result node found
- */
- public String findNode(String parent, String key) {
-
- Set childs = null;
- if (parent == null) {
- childs = getRootNode().getBranches().keySet();
- } else {
- if (getNode(parent) != null) {
- childs = getNode(parent).getBranches().keySet();
- } else {
- return null;
- }
- }
-
- for (String entrie : childs) {
- String nextNode = "";
- if (!(parent == null)) {
- nextNode = parent + "." + entrie;
- } else {
- nextNode = entrie;
- }
-
- // log.info(key + " key " + nextNode);
- if (nextNode.toLowerCase().contains(key.toLowerCase())) {
- return nextNode;
- }
- String nodeIterated = findNode(nextNode, key);
- if (nodeIterated != null) {
- return nodeIterated;
- }
-
- }
-
- return null;
-
- }
-
- public String findNode(String key) {
- return findNode(null, key);
- }
-
- public IndexNode getOrCreateNode(String key) {
- IndexNode node = getNode(key);
- if (node == null) {
- // IndexNode newNode = new IndexNode();
- return root.putNode(key, null);
- }
- return node;
- }
-
- public IndexNode getRootNode() {
- return root;
- }
-
- /**
- * check if selected node have leafs and return them as key list
- *
- * @param node
- * - node to get leafs from
- * @return all leaves
- */
- public ArrayList getLeafs(String node) {
-
- ArrayList leafs = new ArrayList();
- log.debug("getNodeLeafs for {}", node);
- if (root.getNode(node) != null) {
-
- Set entries = root.getNode(node).getBranches().keySet();
- // log.info(entries+"entries");
-
- for (String key : entries) {
- if (!(root.getNode(node + "." + key) == null) && root.getNode(node + "." + key).size() == 0) {
-
- leafs.add(node + "." + key);
- }
-
- }
- }
- return leafs;
- }
-
- public Enumeration propertyNames() {
- return root.propertyNames();
- }
-
- public IndexNode put(String name, T value) {
- return root.putNode(name, value);
- }
-
- @Override
- public String toString() {
- return root.toString();
- }
-
-}
diff --git a/src/main/java/org/myrobotlab/framework/IndexNode.java b/src/main/java/org/myrobotlab/framework/IndexNode.java
deleted file mode 100644
index 1d9b95385b..0000000000
--- a/src/main/java/org/myrobotlab/framework/IndexNode.java
+++ /dev/null
@@ -1,213 +0,0 @@
-package org.myrobotlab.framework;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Vector;
-
-import org.myrobotlab.logging.LoggerFactory;
-import org.slf4j.Logger;
-
-public class IndexNode {
-
- public final static Logger log = LoggerFactory.getLogger(IndexNode.class);
- private HashMap> branches = new HashMap>();
- private T value;
-
- public IndexNode() {
- }
-
- public IndexNode(T value) {
- // leaf value
- this.value = value;
- }
-
- public void buildTree(IndexNode node, String key, T value) {
- // if there is a "." - then we are a branch - not a leaf
- if (key.indexOf(".") > 0) {
- // if (key.length() > 0) {
- // build branches of tree
- String branch = key.substring(0, key.indexOf("."));
- String theRest = key.substring(key.indexOf(".") + 1);
- log.info("adding branch {}", branch);
- if (!node.branches.containsKey(branch)) {
- // log.debug(String.format("adding branch %s", branch));
- IndexNode twig = new IndexNode();
- node.branches.put(branch, twig);
- }
- buildTree(node.getNode(branch), theRest, value);
- } else {
- // add a leaf
- log.debug("adding leaf {}={}", key, value);
- node.branches.put(key, new IndexNode(value));
- }
- }
-
- public void clear() {
- branches.clear();
- }
-
- public boolean containsKey(String key) {
- IndexNode node = getNode(key);
- return node != null;
- }
-
- // http://stackoverflow.com/questions/2319538/most-concise-way-to-convert-a-setstring-to-a-liststring
- // FIXME not the most effecient - should simply return the Set>> from each branches !!!
- // good thing you put the key in the data node :P (lame)
- // limitCount = 0 means no limit
- public ArrayList crawlForData(ArrayList data, int limitCount, String key) {
-
- if (value != null) {
- // found some data add it
- data.add(value);
- }
- if (key != null && key.contains(".")) {
- String subkey = key.substring(0, 1);
- String climb = key.substring(1);
- IndexNode t = branches.get(subkey);
- if (t == null) {
- return data; // nothing here - return what was passed in
- } else {
- t.crawlForData(data, limitCount, climb); // climb some more
- }
- } else {
- // no key at this point - just get data
- if (limitCount < 1 || data.size() < limitCount) {
- // still under our data limit
- // look for more data - by crawling up children
- for (String k : branches.keySet()) {
- // return crawlForData(data, limitCount,
- // String.format("%s%s",key,k));
- // FIXME - data structure change will do concurrent mod erro
- IndexNode n = branches.get(k);
- n.crawlForData(data, limitCount, "");
- }
- }
-
- }
-
- return data;
- }
-
- public HashMap> getBranches() {
- return branches;
- }
-
- public IndexNode getNode(String key) {
- if (key == null) {
- return this;
- }
- IndexNode target = null;
- if (key.contains(".")) {
- String subkey = key.substring(0, key.indexOf("."));
- String climb = key.substring(key.indexOf(".") + 1);
- IndexNode t = branches.get(subkey);
- if (t == null) {
- return null;
- } else {
- return t.getNode(climb);
- }
- } else {
- target = branches.get(key);
- }
-
- return target;
-
- }
-
- public T getValue() {
- return value;
- }
-
- public T getValue(T defaultValue) {
- return (value == null) ? defaultValue : value;
- }
-
- public Enumeration propertyNames() {
- Vector n = new Vector(branches.keySet());
- return n.elements();
- }
-
- public Enumeration propertySortedNames() {
- List n = new Vector(branches.keySet());
- Collections.sort(n);
- return ((Vector) n).elements();
- }
-
- public IndexNode putNode(String key, T value) {
- if (key == null) {
- setValue(value);
- return this;
- }
-
- if (key.contains(".")) {
- // if (key.length() > 1) {
- // find the last node we from which
- // we need to start building branches
- // String subkey = key.substring(0, 1);
- // String climb = key.substring(1);
- String subkey = key.substring(0, key.indexOf("."));
- String climb = key.substring(key.indexOf(".") + 1);
-
- IndexNode t = branches.get(subkey);
- if (t == null) {
- // no branch - we need to build it
- IndexNode twig = new IndexNode();
- branches.put(subkey, twig);
- return twig.putNode(climb, value);
- } else {
- return t.putNode(climb, value);
- }
- } else {
- IndexNode targetNode = branches.get(key);
- if (targetNode == null) {
- return branches.put(key, new IndexNode(value));
- } else {
- targetNode.setValue(value);
- return targetNode;
- }
- }
-
- // return destination;
- }
-
- public void setValue(T value) {
- this.value = value;
- }
-
- public int size() {
- return branches.size();
- }
-
- @Override
- public String toString() {
- return toString(null);
- }
-
- public String toString(String contextPath) {
- StringBuffer sb = new StringBuffer();
-
- if (contextPath != null && getValue() != null) {
- sb.append(contextPath);
- sb.append("=");
- sb.append(getValue());
- sb.append("\n");
- }
-
- for (String key : branches.keySet()) {
-
- if (contextPath != null) {
- sb.append(branches.get(key).toString(contextPath + "." + key));
- } else {
- sb.append(branches.get(key).toString(key));
- }
- }
-
- return sb.toString();
- }
-
-}
diff --git a/src/main/java/org/myrobotlab/framework/Outbox.java b/src/main/java/org/myrobotlab/framework/Outbox.java
index 01921add9f..cdc1d3f5c0 100644
--- a/src/main/java/org/myrobotlab/framework/Outbox.java
+++ b/src/main/java/org/myrobotlab/framework/Outbox.java
@@ -43,7 +43,6 @@
import org.myrobotlab.service.interfaces.Gateway;
import org.slf4j.Logger;
-
/*
* Outbox is a message based thread which sends messages based on addListener lists and current
* queue status. It is only aware of the Service directory, addListener lists, and operators.
@@ -63,11 +62,17 @@ public class Outbox implements Runnable, Serializable {
static public final String PROCESSANDBROADCAST = "PROCESSANDBROADCAST";
protected String name = null;
- private transient LinkedList msgBox = new LinkedList();
+
+ private transient LinkedList msgBox = new LinkedList();
+
private boolean isRunning = false;
+
private boolean blocking = false;
+
int maxQueue = 1024;
+
int initialThreadCount = 1;
+
transient ArrayList outboxThreadPool = new ArrayList();
protected Map filters = new HashMap<>();
@@ -216,10 +221,10 @@ public void run() {
MRLListener listener = subList.get(i);
msg.setName(listener.callbackName);
msg.method = listener.callbackMethod;
-
+
if (!isFiltered(msg)) {
- send(msg);
- }
+ send(msg);
+ }
// must make new for internal queues
// otherwise you'll change the name on
@@ -228,21 +233,22 @@ public void run() {
}
} else {
if (log.isDebugEnabled()) {
- log.debug("{}/{}({}) notifyList is empty", msg.getName(), msg.method, CodecUtils.getParameterSignature(msg.data));
+ log.debug("{}/{}({}) notifyList is empty", msg.getName(), msg.method,
+ CodecUtils.getParameterSignature(msg.data));
}
continue;
}
} // while (isRunning)
}
-
+
public FilterInterface addFilter(String name, String method, FilterInterface filter) {
return filters.put(String.format("%s.%s", CodecUtils.getFullName(name), method), filter);
}
-
+
public FilterInterface removeFilter(String name, String method) {
return filters.remove(String.format("%s.%s", CodecUtils.getFullName(name), method));
}
-
+
public boolean isFiltered(Message msg) {
String fullname = CodecUtils.getFullName(msg.name);
if (filters.size() == 0 || !filters.containsKey(String.format("%s.%s", fullname, msg.method))) {
@@ -258,7 +264,7 @@ public int size() {
public void start() {
for (int i = outboxThreadPool.size(); i < initialThreadCount; ++i) {
- Thread t = new Thread(this, name + "_outbox_" + i);
+ Thread t = new Thread(this, CodecUtils.getShortName(name) + "_outbox_" + i);
outboxThreadPool.add(t);
t.start();
}
@@ -317,7 +323,8 @@ final public void send(final Message msg) {
// ?
ServiceInterface sw = Runtime.getService(msg.getName());
if (sw == null && autoClean) {
- log.warn("could not find service {} to process {} from sender {} - tearing down route", msg.getName(), msg.method, msg.sender);
+ log.warn("could not find service {} to process {} from sender {} - tearing down route", msg.getName(),
+ msg.method, msg.sender);
ServiceInterface sender = Runtime.getService(msg.sender);
if (sender != null) {
sender.removeListener(msg.sendingMethod, msg.getName(), msg.method);
@@ -358,8 +365,8 @@ public void reset() {
/**
* Safe detach for single subscriber
*
- * @param name
- * the name of the listener to detach
+ * @param service
+ * the name of the listener to detach
*
*/
synchronized public void detach(String service) {
@@ -379,7 +386,4 @@ synchronized public void detach(String service) {
public Map> getNotifyList() {
return notifyList;
}
-
-
-
}
diff --git a/src/main/java/org/myrobotlab/framework/Plan.java b/src/main/java/org/myrobotlab/framework/Plan.java
index 92f48b066e..ab89e2d2bb 100644
--- a/src/main/java/org/myrobotlab/framework/Plan.java
+++ b/src/main/java/org/myrobotlab/framework/Plan.java
@@ -96,7 +96,7 @@ public void clear() {
*/
public ServiceConfig remove(String service) {
RuntimeConfig rtConfig = (RuntimeConfig) config.get("runtime");
- rtConfig.registry.remove(service);
+ rtConfig.remove(service);
return config.remove(service);
}
@@ -142,21 +142,5 @@ public void addRegistry(String service) {
runtime.add(service);
}
- /**
- * good to prune trees of peers from starting - expecially if the peers
- * require re-configuring
- *
- * @param startsWith
- * - removes RuntimeConfig.registry all services that start with
- * input
- */
- public void removeStartsWith(String startsWith) {
- RuntimeConfig runtime = (RuntimeConfig) config.get("runtime");
- if (runtime == null) {
- log.error("removeRegistry - runtime null !");
- return;
- }
- runtime.removeStartsWith(startsWith);
- }
}
diff --git a/src/main/java/org/myrobotlab/framework/Service.java b/src/main/java/org/myrobotlab/framework/Service.java
index 8d4dcc7ab8..4519d0bfbb 100644
--- a/src/main/java/org/myrobotlab/framework/Service.java
+++ b/src/main/java/org/myrobotlab/framework/Service.java
@@ -141,9 +141,9 @@ public abstract class Service implements Runnable, Seri
transient protected Thread thisThread = null;
- transient protected Inbox inbox = null;
+ final transient protected Inbox inbox;
- protected Outbox outbox = null;
+ final protected Outbox outbox;
protected String serviceVersion = null;
@@ -1473,7 +1473,6 @@ public void setPeerConfigValue(String peerKey, String fieldname, Object value) t
// broadcast change
invoke("getPeerConfig", peerKey);
- Runtime.getPlan().put(peerName, sc);
Runtime runtime = Runtime.getInstance();
runtime.broadcastState();
}
@@ -1724,8 +1723,6 @@ final public void run() {
@Override
public boolean save() {
Runtime runtime = Runtime.getInstance();
- // save all services ... weird notation - should have explicit
- // saveAllServices
return runtime.saveService(runtime.getConfigName(), getName(), null);
}
@@ -1994,30 +1991,10 @@ synchronized public ServiceInterface startPeer(String peerKey) {
error("startPeer could not find peerKey of %s in %s", peerKey, getName());
return null;
}
-
- ServiceInterface si = Runtime.getService(peer.name);
- if (si != null) {
- // so this peer is already started, but are we responsible for
- // all subpeers ?
- return si;
- }
-
- // request to modify the plan's runtime to start all service that match
- // actualName.*
- Plan plan = Runtime.getPlan();
- ServiceConfig sc = plan.get(peer.name);
-
- if (sc == null) {
- log.info("no current plan for peer {} - since this is a peer request we can make a plan", peer.name);
- // error("plan.get(%s) == null", actualName);
- Runtime.load(peer.name, peer.type);
- sc = plan.get(peer.name);
- }
-
+
// start peer requested
- Runtime.start(peer.name, sc.type);
broadcastState();
- return Runtime.getService(peer.name);
+ return Runtime.start(peer.name);
}
/**
@@ -2032,8 +2009,13 @@ synchronized public ServiceInterface startPeer(String peerKey) {
synchronized public void releasePeer(String peerKey) {
if (getConfig() != null && getConfig().getPeer(peerKey) != null) {
- Peer peer = getConfig().getPeer(peerKey);
- ServiceConfig sc = Runtime.getPlan().get(peer.name);
+ ServiceConfig sc = null;
+ String peerName = getPeerName(peerKey);
+ ServiceInterface si = Runtime.getService(peerName);
+ if (si != null) {
+ sc = si.getConfig();
+ }
+
// peer recursive
if (sc != null && sc.getPeers() != null) {
for (String subPeerKey : sc.getPeers().keySet()) {
@@ -2043,9 +2025,7 @@ synchronized public void releasePeer(String peerKey) {
}
}
}
- Plan plan = Runtime.getPlan();
- plan.removeRegistry(peer.name);
- Runtime.release(peer.name);
+ Runtime.release(peerName);
broadcastState();
} else {
error("%s.releasePeer(%s) does not exist", getName(), peerKey);
@@ -2827,7 +2807,7 @@ protected void registerForInterfaceChange(Class> clazz) {
}
final public Plan getDefault() {
- return ServiceConfig.getDefault(Runtime.getPlan(), getName(), this.getClass().getSimpleName());
+ return ServiceConfig.getDefault(new Plan("runtime"), getName(), this.getClass().getSimpleName());
}
@Override
@@ -2848,9 +2828,6 @@ public void apply() {
return;
}
- // updating plan - FIXME remove plan
- Runtime.getPlan().put(getName(), sc);
-
// applying config to self
apply((T) sc);
}
@@ -2869,8 +2846,6 @@ public void applyPeerConfig(String peerKey, ServiceConfig config) {
public
void applyPeerConfig(String peerKey, P config, StaticType> configServiceType) {
String peerName = getPeerName(peerKey);
- Runtime.getPlan().put(peerName, config);
-
// meh - templating is not very helpful here
ConfigurableService
si = Runtime.getService(peerName, configServiceType);
if (si != null) {
@@ -2891,7 +2866,7 @@ public void setPeerName(String key, String fullName) {
String oldName = peer.name;
peer.name = fullName;
// update plan ?
- ServiceConfig.getDefault(Runtime.getPlan(), peer.name, peer.type);
+ ServiceConfig.getDefault(new Plan("runtime"), peer.name, peer.type);
// FIXME - determine if only updating the Plan in memory is enough,
// should we also make or update a config file - if the config path is set?
info("updated %s name to %s", oldName, peer.name);
@@ -2915,26 +2890,10 @@ public Map> getNotifyList() {
*/
public void updatePeerType(String key, String peerType) {
- // MAKE NOTE ! - CONFIG IS DIFFERENT THAN PLAN !!!! MODIFY BOTH ???!?
-
- // get current plan
- Plan plan = Runtime.getPlan();
-
- // get self
- ServiceConfig sc = plan.get(getName());
- if (sc != null) {
- sc.putPeerType(key, String.format("%s.%s", getName(), key), peerType);
- }
-
Peer peer = getConfig().getPeer(key);
peer.type = peerType;
- // not Needed
- // config.putPeerType(key, String.format("%s.%s", key, getName()),
- // peerType);
- plan.remove(peer.name);
- // FIXME - rename putDefault
- ServiceConfig.getDefault(Runtime.getPlan(), peer.name, peerType);
+ ServiceConfig.getDefault(new Plan("runtime"), peer.name, peerType);
Runtime runtime = Runtime.getInstance();
String configName = runtime.getConfigName();
// Seems a bit invasive - but yml file overrides everything
diff --git a/src/main/java/org/myrobotlab/framework/CmdConfig.java b/src/main/java/org/myrobotlab/framework/StartYml.java
similarity index 82%
rename from src/main/java/org/myrobotlab/framework/CmdConfig.java
rename to src/main/java/org/myrobotlab/framework/StartYml.java
index f807aaeb81..c8bfb25a44 100644
--- a/src/main/java/org/myrobotlab/framework/CmdConfig.java
+++ b/src/main/java/org/myrobotlab/framework/StartYml.java
@@ -8,17 +8,12 @@
* @author GroG
*
*/
-public class CmdConfig {
+public class StartYml {
/**
* instance id of myrobotlab, default will be dynamically generated
*/
public String id;
-
- /**
- * {configRoot}/{configName}
- */
- public String configRoot = "data/config";
-
+
/**
* configuration set to start under /data/config/{configName}
*/
diff --git a/src/main/java/org/myrobotlab/framework/ToolTip.java b/src/main/java/org/myrobotlab/framework/ToolTip.java
deleted file mode 100644
index 21d79b9bdb..0000000000
--- a/src/main/java/org/myrobotlab/framework/ToolTip.java
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- *
- */
-package org.myrobotlab.framework;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * @author gperry
- *
- */
-
-@Retention(RetentionPolicy.RUNTIME)
-public @interface ToolTip {
- public String value();
-}
diff --git a/src/main/java/org/myrobotlab/framework/TypeConverter.java b/src/main/java/org/myrobotlab/framework/TypeConverter.java
deleted file mode 100644
index 051ae50e34..0000000000
--- a/src/main/java/org/myrobotlab/framework/TypeConverter.java
+++ /dev/null
@@ -1,187 +0,0 @@
-package org.myrobotlab.framework;
-
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-
-import org.myrobotlab.codec.CodecUtils;
-import org.myrobotlab.logging.Level;
-import org.myrobotlab.logging.LoggerFactory;
-import org.myrobotlab.logging.Logging;
-import org.myrobotlab.logging.LoggingFactory;
-import org.slf4j.Logger;
-
-/**
- * JSON TypeConverter - used in general REST api to convert url JSON parameters
- * appropriately to hard types for method invoking used in WebGui and Cli
- *
- * @author GroG
- *
- */
-public class TypeConverter {
-
- public final static Logger log = LoggerFactory.getLogger(TypeConverter.class);
-
- // Possible Optimization -> pointers to known method signatures -
- // optimization so that once a
- // method's signature is processed and
- // known conversion exists - it is saved
- static public HashMap knownMethodSignatureConverters = new HashMap();
-
- // pointers to conversion methods
- // static public HashMap conversions = new HashMap();
-
- /**
- * this method tries to get the appropriate 'Typed parameter array for a
- * specific method It "converts" parameters of strings into typed parameters
- * which can then be used to reflectively invoke the appropriate method
- *
- * @param clazz
- * c
- * @param method
- * m
- * @param stringParams
- * p
- * @return object array
- * @throws IOException
- * e
- *
- */
- static public Object[] getTypedParamsFromJson(Class> clazz, String method, String[] stringParams) throws IOException {
-
- // try {
-
- Method[] methods = clazz.getMethods();
- for (int i = 0; i < methods.length; ++i) {
- Method m = methods[i];
- Class>[] types = m.getParameterTypes();
- // TODO optimize getting name ??? why didn't Java reflect api
- // use a HashMap ???
- if (method.equals(m.getName()) && stringParams.length == types.length) {
- log.debug("method with same ordinal of params found {}.{} - building new converter", method, stringParams.length);
-
- try {
- Object[] newGSONTypedParamters = new Object[stringParams.length];
-
- for (int j = 0; j < types.length; ++j) {
- Class> pType = types[j];
- String param = stringParams[j];
-
- log.debug("attempting conversion into {} from inbound data {}", pType.getSimpleName(), stringParams[j]);
- if (pType == String.class) {
- // escape quotes
- param = param.replaceAll("\"", "\\\"");
- // add quotes
- param = String.format("\"%s\"", param);
- }
- newGSONTypedParamters[j] = CodecUtils.fromJson(param, pType);
-
- }
-
- log.debug("successfully converted all types");
- return newGSONTypedParamters;
-
- } catch (Exception e) {
- // Logging.logException(e);
- log.warn("could not match type from inbound data");
- continue;
- }
-
- } // if name and ordinal match
- } // through each method
-
- String error = String.format("could not find or convert %s", method);
- log.error(error);
-
- /*
- * } catch (Exception e) { Logging.logError(e); }
- *
- * return null;
- */
- throw new IOException(error);
-
- }
-
- public static void main(String[] args) {
-
- try {
- LoggingFactory.init(Level.DEBUG);
-
- /*
- * FIXME PUT IN JUNIT TEST !!
- * org.myrobotlab.service.Runtime.createAndStart("clock", "Clock");
- *
- * ServiceInterface si =
- * org.myrobotlab.service.Runtime.getService("clock");
- *
- *
- * String stringParams[] = new String[] { "13", "1" }; String method =
- * "digitalWrite"; Class> clazz = si.getClass();
- *
- * Object[] params = getTypedParamsFromJson(clazz, method, stringParams);
- *
- * si.invoke(method, params);
- *
- * log.info("here");
- *
- * Object[] params2 = getTypedParamsFromJson(clazz, method, stringParams);
- * log.info("here");
- */
- } catch (Exception e) {
- Logging.logError(e);
- }
- }
-
- static public boolean StringToBoolean(String in) {
- return Boolean.parseBoolean(in);
- }
-
- // -------- primitive boxed types conversion begin ------------
- static public byte StringToByte(String in) {
- return Byte.parseByte(in);
- }
-
- static public char StringToChar(String in) {
- return in.charAt(0);
- }
-
- static public double StringToDouble(String in) {
- return Double.parseDouble(in);
- }
-
- static public float StringToFloat(String in) {
- return Float.parseFloat(in);
- }
-
- static public int StringToInteger(String in) {
- return Integer.parseInt(in);
- }
-
- static public long StringToLong(String in) {
- return Long.parseLong(in);
- }
-
- // -------- primitive boxed types conversion end ------------
-
- static public short StringToShort(String in) {
- return Short.parseShort(in);
- }
-
- /*
- * static public Object[] convert(String[] stringParams, Method[] converter) {
- * try { Object[] newTypedParams = new Object[stringParams.length]; for (int i
- * = 0; i < stringParams.length; ++i) { // static calls on conversion -
- * probably not thread safe newTypedParams[0] = converter[i].invoke(null,
- * stringParams[i]); }
- *
- * return newTypedParams; } catch (Exception e) { Logging.logException(e); }
- *
- * return null; }
- */
-
- static public String StringToString(String in) {
- return in;
- }
-
-}
diff --git a/src/main/java/org/myrobotlab/fsm/api/Event.java b/src/main/java/org/myrobotlab/fsm/api/Event.java
deleted file mode 100644
index f622a5544c..0000000000
--- a/src/main/java/org/myrobotlab/fsm/api/Event.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * The MIT License
- *
- * Copyright (c) 2017, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.myrobotlab.fsm.api;
-
-import java.util.Date;
-
-import org.myrobotlab.fsm.util.Utils;
-
-/**
- * Abstract class for events to which a FSM should react and make transitions.
- *
- * @author Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- */
-public abstract class Event {
-
- protected String name;
- protected long timestamp;
-
- protected Event() {
- this.name = Utils.DEFAULT_EVENT_NAME;
- timestamp = System.currentTimeMillis();
- }
-
- protected Event(final String name) {
- this.name = name;
- timestamp = System.currentTimeMillis();
- }
-
- public String getName() {
- return name;
- }
-
- public long getTimestamp() {
- return timestamp;
- }
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("Event");
- sb.append("{name='").append(name).append('\'');
- sb.append(", timestamp=").append(new Date(timestamp));
- sb.append('}');
- return sb.toString();
- }
-
- public abstract String getId();
-
-}
diff --git a/src/main/java/org/myrobotlab/fsm/api/EventHandler.java b/src/main/java/org/myrobotlab/fsm/api/EventHandler.java
deleted file mode 100644
index 44059cb3f1..0000000000
--- a/src/main/java/org/myrobotlab/fsm/api/EventHandler.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * The MIT License
- *
- * Copyright (c) 2017, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.myrobotlab.fsm.api;
-
-/**
- * Abstraction for actions to perform when an event is triggered.
- *
- * @author Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- */
-public interface EventHandler {
-
- /**
- * Action method to execute when an event occurs.
- *
- * @param event
- * the triggered event
- * @throws Exception
- * thrown if a problem occurs during action performing
- */
- void handleEvent(Event event) throws Exception;
-
-}
diff --git a/src/main/java/org/myrobotlab/fsm/api/FiniteStateMachine.java b/src/main/java/org/myrobotlab/fsm/api/FiniteStateMachine.java
deleted file mode 100644
index 2f16ef3cb6..0000000000
--- a/src/main/java/org/myrobotlab/fsm/api/FiniteStateMachine.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- * The MIT License
- *
- * Copyright (c) 2017, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.myrobotlab.fsm.api;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * FSM interface. This is the main abstraction for a finite state machine.
- *
- * @author Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- */
-public interface FiniteStateMachine {
-
- /**
- * Return current FSM state.
- *
- * @return current FSM state
- */
- State getCurrentState();
-
- /**
- * Return FSM initial state.
- *
- * @return FSM initial state
- */
-
- // State getInitialState();
-
- /**
- * Return FSM final states.
- *
- * @return FSM final states
- */
- Set getFinalStates();
-
- /**
- * Return FSM registered states.
- *
- * @return FSM registered states
- */
- Set getStates();
-
- /**
- * Return FSM registered transitions.
- *
- * @return FSM registered transitions
- */
- Set getTransitions();
-
- /**
- * Return the last triggered event.
- *
- * @return the last triggered event
- */
- Event getLastEvent();
-
- /**
- * Return the last transition made.
- *
- * @return the last transition made
- */
- Transition getLastTransition();
-
- /**
- * Fire an event. According to event type, the FSM will make the right
- * transition.
- *
- * @param event
- * to fire
- * @return The next FSM state defined by the transition to make
- * @throws FiniteStateMachineException
- * thrown if an exception occurs during event handling
- */
- // State fire(Event event) throws FiniteStateMachineException;
-
- List fire(Event event) throws FiniteStateMachineException;
-
-}
diff --git a/src/main/java/org/myrobotlab/fsm/api/FiniteStateMachineException.java b/src/main/java/org/myrobotlab/fsm/api/FiniteStateMachineException.java
deleted file mode 100644
index 19079c3ca1..0000000000
--- a/src/main/java/org/myrobotlab/fsm/api/FiniteStateMachineException.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * The MIT License
- *
- * Copyright (c) 2017, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.myrobotlab.fsm.api;
-
-/**
- * Exception thrown if a problem occurs during event handling. This class gives
- * access to the {@link Transition} and {@link Event} related to the exception.
- *
- * @author Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- */
-public class FiniteStateMachineException extends Exception {
-
- /**
- * The transition where the exception occurred.
- */
- private Transition transition;
-
- /**
- * The event triggered when the exception occurred.
- */
- private Event event;
-
- /**
- * The root cause of the exception.
- */
- private Throwable cause;
-
- /**
- * Create a new {@link FiniteStateMachineException}.
- *
- * @param transition
- * where the exception occurred
- * @param event
- * triggered when the exception occurred
- * @param cause
- * root cause of the exception
- */
- public FiniteStateMachineException(final Transition transition, final Event event, final Throwable cause) {
- this.transition = transition;
- this.event = event;
- this.cause = cause;
- }
-
- /**
- * Get the transition where the exception occurred.
- *
- * @return the transition where the exception occurred.
- */
- public Transition getTransition() {
- return transition;
- }
-
- /**
- * Get the event triggered when the exception occurred.
- *
- * @return the event triggered when the exception occurred.
- */
- public Event getEvent() {
- return event;
- }
-
- /**
- * Get the root cause of the exception.
- *
- * @return the root cause of the exception
- */
- @Override
- public Throwable getCause() {
- return cause;
- }
-}
diff --git a/src/main/java/org/myrobotlab/fsm/api/SimpleEvent.java b/src/main/java/org/myrobotlab/fsm/api/SimpleEvent.java
deleted file mode 100644
index 2e1d36f4ce..0000000000
--- a/src/main/java/org/myrobotlab/fsm/api/SimpleEvent.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * The MIT License
- *
- * Copyright (c) 2017, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.myrobotlab.fsm.api;
-
-import java.util.Date;
-
-import org.myrobotlab.fsm.util.Utils;
-
-/**
- * general event class for invoking transitions
- *
- */
-public class SimpleEvent extends Event {
- @Deprecated
- String source;
- private Transition transition;
- // private State lastState;
-
- public SimpleEvent(String name) {
- this.name = name;
- timestamp = System.currentTimeMillis();
- }
-
- public SimpleEvent() {
- this.name = Utils.DEFAULT_EVENT_NAME;
- timestamp = System.currentTimeMillis();
- }
-
- public SimpleEvent(String fsmName, String eventName) {
- this.source = fsmName;
- this.name = eventName;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public long getTimestamp() {
- return timestamp;
- }
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("Event");
- sb.append("{name='").append(name).append('\'');
- sb.append(", timestamp=").append(new Date(timestamp));
- sb.append('}');
- return sb.toString();
- }
-
- @Override
- public String getId() {
- return name;
- }
-
- public String getSource() {
- return source;
- }
-
- public void setTransition(Transition transition) {
- this.transition = transition;
- }
-
- public Transition getTransition() {
- return transition;
- }
-
-}
diff --git a/src/main/java/org/myrobotlab/fsm/api/State.java b/src/main/java/org/myrobotlab/fsm/api/State.java
deleted file mode 100644
index 050422ee4f..0000000000
--- a/src/main/java/org/myrobotlab/fsm/api/State.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * The MIT License
- *
- * Copyright (c) 2017, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.myrobotlab.fsm.api;
-
-// FIXME - should be an interface in (api)
-
-/**
- * A class representing a FSM state. States have unique names within a
- * FSM instance
- *
- * @author Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- */
-public class State {
-
- private String id;
- transient private Transition lastTransition = null;
-
- /**
- * Create a new {@link State}.
- *
- * @param id
- * of the state
- */
- public State(final String id) {
- this.id = id;
- }
-
- /**
- * Get state name.
- *
- * @return state name
- */
- public String getName() {
- return id;
- }
-
- /*
- * States have unique name within a Easy States FSM instance
- */
-
- @Override
- public boolean equals(Object o) {
- if (this == o)
- return true;
- if (o == null)
- return false;
- return id.equals(o.toString());
- }
-
- @Override
- public int hashCode() {
- return id.hashCode();
- }
-
- @Override
- public String toString() {
- return id;
- }
-
- public void setLastTransition(Transition transition) {
- lastTransition = transition;
- }
-
- public Transition getLastTransition() {
- return lastTransition;
- }
-
- public void setId(String name) {
- this.id = name;
- }
-
-}
diff --git a/src/main/java/org/myrobotlab/fsm/api/StateHandler.java b/src/main/java/org/myrobotlab/fsm/api/StateHandler.java
deleted file mode 100644
index 0c8651c983..0000000000
--- a/src/main/java/org/myrobotlab/fsm/api/StateHandler.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * The MIT License
- *
- * Copyright (c) 2017, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.myrobotlab.fsm.api;
-
-/**
- * Abstraction for actions to perform when an event is triggered.
- *
- * @author Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- */
-public interface StateHandler {
-
- /**
- * Action method to execute when an event occurs.
- *
- * @param event
- * the triggered event
- * @throws Exception
- * thrown if a problem occurs during action performing
- */
- void handleState(State event) throws Exception;
-
-}
diff --git a/src/main/java/org/myrobotlab/fsm/api/Transition.java b/src/main/java/org/myrobotlab/fsm/api/Transition.java
deleted file mode 100644
index 6dc175a95b..0000000000
--- a/src/main/java/org/myrobotlab/fsm/api/Transition.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * The MIT License
- *
- * Copyright (c) 2017, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.myrobotlab.fsm.api;
-
-/**
- * Abstraction for a FSM transition. Transitions are unique according to
- * source state and triggering event type.
- *
- * @author Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- */
-public interface Transition {
-
- /**
- * Return transition name.
- *
- * @return transition name
- */
- String getName();
-
- /**
- * Return transition source state.
- *
- * @return transition source state
- */
- State getSourceState();
-
- /**
- * Return transition target state.
- *
- * @return transition target state
- */
- State getTargetState();
-
- /**
- * Return fired event type upon which the transition should be made.
- *
- * @return Event type class
- */
- // Class getEventType();
-
- /**
- * Return event handler to execute when an event is fired.
- *
- * @return transition event handler
- */
- EventHandler getEventHandler();
-
- StateHandler getNewStateHandler();
-
- String getId();
-
-}
diff --git a/src/main/java/org/myrobotlab/fsm/api/package-info.java b/src/main/java/org/myrobotlab/fsm/api/package-info.java
deleted file mode 100644
index c8147d471e..0000000000
--- a/src/main/java/org/myrobotlab/fsm/api/package-info.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * The MIT License
- *
- * Copyright (c) 2017, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-/**
- * This package contains the public APIs.
- */
-package org.myrobotlab.fsm.api;
diff --git a/src/main/java/org/myrobotlab/fsm/core/SimpleTransition.java b/src/main/java/org/myrobotlab/fsm/core/SimpleTransition.java
deleted file mode 100644
index b03f6cf640..0000000000
--- a/src/main/java/org/myrobotlab/fsm/core/SimpleTransition.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/**
- * The MIT License
- *
- * Copyright (c) 2017, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.myrobotlab.fsm.core;
-
-import org.myrobotlab.fsm.api.EventHandler;
-import org.myrobotlab.fsm.api.State;
-import org.myrobotlab.fsm.api.StateHandler;
-import org.myrobotlab.fsm.api.Transition;
-import org.myrobotlab.fsm.util.Utils;
-
-public class SimpleTransition implements Transition {
-
- private String id;
- private State sourceState;
- private State targetState;
- // private Class eventType;
- transient private EventHandler eventHandler;
- transient private StateHandler newStateHandler;
- // private String source;
-
- public SimpleTransition() {
- id = Utils.DEFAULT_TRANSITION_NAME;
- }
-
- @Override
- public State getSourceState() {
- return sourceState;
- }
-
- public void setSourceState(State sourceState) {
- this.sourceState = sourceState;
- }
-
- @Override
- public State getTargetState() {
- return targetState;
- }
-
- public void setTargetState(State targetState) {
- this.targetState = targetState;
- }
-
- @Override
- public String getName() {
- return id;
- }
-
- public void setName(String name) {
- this.id = name;
- }
-
- @Override
- public EventHandler getEventHandler() {
- return eventHandler;
- }
-
- public void setEventHandler(EventHandler eventHandler) {
- this.eventHandler = eventHandler;
- }
-
- public void setNewStateHandler(StateHandler stateHandler) {
- this.newStateHandler = stateHandler;
- }
-
- /*
- * Transitions are unique according to source state and triggering event type
- */
-
- @Override
- public boolean equals(Object o) {
- if (this == o)
- return true;
- if (o == null)
- return false;
-
- SimpleTransition that = (SimpleTransition) o;
-
- return id.equals(that.id) && sourceState.equals(that.sourceState);
-
- }
-
- @Override
- public int hashCode() {
- int result = sourceState.hashCode();
- // result = 31 * result + eventType.hashCode();
- result = 31 * result + id.hashCode();
- return result;
- }
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append(sourceState.getName());
- sb.append("-(");
- sb.append(getId());
- sb.append(")->");
- sb.append(targetState.getName());
- /*
- * sb.append("Transition"); sb.append("{name='").append(id).append('\'');
- * sb.append(", sourceState=").append(sourceState.getId());
- * sb.append(", targetState=").append(targetState.getId());
- * sb.append(", id=").append(id); if (eventHandler != null) {
- * sb.append(", eventHandler=").append(eventHandler.getClass().getName()); }
- * sb.append('}');
- */
- return sb.toString();
- }
-
- @Override
- public String getId() {
- return id;
- }
-
- @Override
- public StateHandler getNewStateHandler() {
- return newStateHandler;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-}
diff --git a/src/main/java/org/myrobotlab/fsm/core/package-info.java b/src/main/java/org/myrobotlab/fsm/core/package-info.java
deleted file mode 100644
index ebd89a46bc..0000000000
--- a/src/main/java/org/myrobotlab/fsm/core/package-info.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * The MIT License
- *
- * Copyright (c) 2017, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-/**
- * This package contains the core implementation of finite state machine.
- */
-package org.myrobotlab.fsm.core;
diff --git a/src/main/java/org/myrobotlab/fsm/util/Utils.java b/src/main/java/org/myrobotlab/fsm/util/Utils.java
deleted file mode 100644
index e7f489c577..0000000000
--- a/src/main/java/org/myrobotlab/fsm/util/Utils.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * The MIT License
- *
- * Copyright (c) 2017, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package org.myrobotlab.fsm.util;
-
-import java.util.Set;
-
-import org.myrobotlab.fsm.api.State;
-
-/**
- * Constants and utilities class.
- *
- * @author Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- */
-public final class Utils {
-
- private Utils() {
- }
-
- /**
- * Default event name.
- */
- public static final String DEFAULT_EVENT_NAME = "event";
-
- /**
- * Default transition name.
- */
- public static final String DEFAULT_TRANSITION_NAME = "transition";
-
- /**
- * Utility method to print states names as string.
- *
- * @param states
- * the states set to dump
- * @return string concatenation of states names
- */
- public static String dumpFSMStates(final Set states) {
- StringBuilder result = new StringBuilder();
- for (State state : states) {
- result.append(state.getName()).append(";");
- }
- return result.toString();
- }
-
-}
diff --git a/src/main/java/org/myrobotlab/fsm/util/package-info.java b/src/main/java/org/myrobotlab/fsm/util/package-info.java
deleted file mode 100644
index 88374162d4..0000000000
--- a/src/main/java/org/myrobotlab/fsm/util/package-info.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * The MIT License
- *
- * Copyright (c) 2017, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-/**
- * This package contains utility classes.
- */
-package org.myrobotlab.fsm.util;
diff --git a/src/main/java/org/myrobotlab/genetic/Chromosome.java b/src/main/java/org/myrobotlab/genetic/Chromosome.java
deleted file mode 100644
index 1d070a6712..0000000000
--- a/src/main/java/org/myrobotlab/genetic/Chromosome.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package org.myrobotlab.genetic;
-
-import java.util.ArrayList;
-import java.util.Random;
-
-public class Chromosome {
- String genome;
- double fitness;
- ArrayList