Repository: incubator-edgent Updated Branches: refs/heads/master 7961bb524 -> 46daa38e7
Edgent-257 cleanup samples/scenarios/iotp Project: http://git-wip-us.apache.org/repos/asf/incubator-edgent/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-edgent/commit/2cea0dd9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-edgent/tree/2cea0dd9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-edgent/diff/2cea0dd9 Branch: refs/heads/master Commit: 2cea0dd90af7f75c047b65f680ccd1cba179ed5c Parents: bd71ad8 Author: Dale LaBossiere <dlab...@us.ibm.com> Authored: Fri Sep 30 12:18:38 2016 -0400 Committer: Dale LaBossiere <dlab...@us.ibm.com> Committed: Fri Sep 30 12:18:38 2016 -0400 ---------------------------------------------------------------------- samples/.classpath | 2 ++ .../iotp/range/sensor/IotpRangeSensor.java | 2 +- .../scenarios/iotp/range/sensor/README.md | 22 +++++++++++--------- 3 files changed, 15 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/2cea0dd9/samples/.classpath ---------------------------------------------------------------------- diff --git a/samples/.classpath b/samples/.classpath index d864d95..634de7f 100644 --- a/samples/.classpath +++ b/samples/.classpath @@ -3,6 +3,7 @@ <classpathentry kind="src" path="apps/src/main/java"/> <classpathentry kind="src" path="connectors/src/main/java"/> <classpathentry kind="src" path="console/src/main/java"/> + <classpathentry kind="src" path="scenarios/src/main/java"/> <classpathentry kind="src" path="topology/src/main/java"/> <classpathentry kind="src" path="utils/src/main/java"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> @@ -14,6 +15,7 @@ <classpathentry combineaccessrules="false" kind="src" path="/providers"/> <classpathentry combineaccessrules="false" kind="src" path="/spi"/> <classpathentry combineaccessrules="false" kind="src" path="/utils"/> + <classpathentry kind="lib" path="../externalJars/java8/samples/ext/pi4j-core-1.0.jar"/> <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> <classpathentry combineaccessrules="false" kind="src" path="/runtime"/> <classpathentry combineaccessrules="false" kind="src" path="/provider_iot"/> http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/2cea0dd9/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/range/sensor/IotpRangeSensor.java ---------------------------------------------------------------------- diff --git a/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/range/sensor/IotpRangeSensor.java b/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/range/sensor/IotpRangeSensor.java index 936a813..b75be33 100644 --- a/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/range/sensor/IotpRangeSensor.java +++ b/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/range/sensor/IotpRangeSensor.java @@ -58,7 +58,7 @@ public class IotpRangeSensor { if (args.length != 3) { System.out.println("Proper Usage is:\n " + " java program device.cfg sensorIsSimulated LEDIsSimulated\n" + "Example: \n" - + " java -cp $EDGENT/target/java8/samples/lib/'*':$PI4J_LIB/'*':bin/ com.ibm.streamsx.iotp.range.IotpRangeSensor device.cfg false true"); + + " java -cp $EDGENT/build/distributions/java8/samples/lib/edgent.samples.scenarios.jar org.apache.edgent.samples.scenarios.iotp.range.sensor.IotpRangeSensor device.cfg false true"); System.exit(0); } http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/2cea0dd9/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/range/sensor/README.md ---------------------------------------------------------------------- diff --git a/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/range/sensor/README.md b/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/range/sensor/README.md index 0122abc..f32e729 100644 --- a/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/range/sensor/README.md +++ b/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/range/sensor/README.md @@ -3,30 +3,32 @@ See Recipe this was created for [here](https://developer.ibm.com/recipes/tutorials/apache-edgent-on-pi-to-watson-iot-foundation/). ## Requirements: -* You must have Pi4J installed on the device (if you are running outside of a Raspberry Pi, you will have to download the JARs and include them in your classpath) -* You must have Edgent downloaded and built +* You must have Edgent downloaded and built. The sample uses Pi4J. It is included with the built sample under `samples/ext`. * You will need to have an HC-SR04 Range sensor hooked up with your EchoPin set to pin 18 and your TripPin at pin 16 (see these instructions on hardware setup: http://www.modmypi.com/blog/hc-sr04-ultrasonic-range-sensor-on-the-raspberry-pi). To use a simulated sensor, pass in true as your second argument. * You will need to have an LED hooked up to pin 12 (See these instructions to set up an LED, however use pin 12 as your control pin: https://projects.drogon.net/raspberry-pi/gpio-examples/tux-crossing/gpio-examples-1-a-single-led/). To use a simulated LED, pass in true as your third argument. * You will need to have your device registered with Watson IoTF and a device.cfg file, or you can use a quickstart version by passing in "quickstart" as your first argument. -To compile, export your Edgent install and PI4J libraries (on Raspberry Pi, the default Pi4J location is `/opt/pi4j/lib`): +To compile: -`$ export EDGENT=<edgent-root-dir>` - -`$ export PI4J_LIB=<Pi4J-libs>` +`$ EDGENT=<edgent-root-dir>` `$ cd $EDGENT` -`$ ant # this builds the range sensor sample only if the PI4J_LIB environment variable is set` +`$ ./gradlew` To run: + +`$ CP=$EDGENT/build/distributions/java8/samples/lib/edgent.samples.scenarios.jar` + +`$ MAIN=org.apache.edgent.samples.scenarios.iotp.range.sensor.IotpRangeSensor` + -`$ java -cp $EDGENT/target/java8/samples/lib/'*':$PI4J_LIB/'*' org.apache.edgent.samples.scenarios.iotf.range.sensor.IotfRangeSensor <device cfg file> <simulatedSensor?> <simulatedLED?>` +`$ java -cp $CP $MAIN <device cfg file> <simulatedSensor?> <simulatedLED?>` To run with a device.cfg file, range sensor, and LED: -`$ java -cp $EDGENT/target/java8/samples/lib/'*':$PI4J_LIB/'*' org.apache.edgent.samples.scenarios.iotf.range.sensor.IotfRangeSensor device.cfg false false` +`$ java -cp $CP $MAIN device.cfg false false` To run in fully simulated mode (no sensors and using IoTF quickstart): -`$ java -cp $EDGENT/target/java8/samples/lib/'*':$PI4J_LIB/'*' org.apache.edgent.samples.scenarios.iotf.range.sensor.IotfRangeSensor quickstart true true` \ No newline at end of file +`$ java -cp $CP $MAIN quickstart true true` \ No newline at end of file