You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@edgent.apache.org by cd...@apache.org on 2017/12/14 14:32:53 UTC
[36/50] [abbrv] incubator-edgent git commit: remove samples (now in
separate repo)
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/topology/src/main/java/org/apache/edgent/samples/topology/TempSensorApplication.java
----------------------------------------------------------------------
diff --git a/samples/topology/src/main/java/org/apache/edgent/samples/topology/TempSensorApplication.java b/samples/topology/src/main/java/org/apache/edgent/samples/topology/TempSensorApplication.java
deleted file mode 100644
index b1aba6b..0000000
--- a/samples/topology/src/main/java/org/apache/edgent/samples/topology/TempSensorApplication.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-
-package org.apache.edgent.samples.topology;
-
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.providers.direct.DirectProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-/*
- * A basic application used in the Edgent "Getting Started Guide":
- * https://edgent.apache.org/docs/edgent-getting-started.html
- */
-public class TempSensorApplication {
- public static void main(String[] args) throws Exception {
- TempSensor sensor = new TempSensor();
- DirectProvider dp = new DirectProvider();
- Topology topology = dp.newTopology();
-
- TStream<Double> tempReadings = topology.poll(sensor, 1, TimeUnit.MILLISECONDS);
- TStream<Double> filteredReadings = tempReadings.filter(reading -> reading < 50 || reading > 80);
- filteredReadings.print();
-
- dp.submit(topology);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/topology/src/main/java/org/apache/edgent/samples/topology/TerminateAfterNTuples.java
----------------------------------------------------------------------
diff --git a/samples/topology/src/main/java/org/apache/edgent/samples/topology/TerminateAfterNTuples.java b/samples/topology/src/main/java/org/apache/edgent/samples/topology/TerminateAfterNTuples.java
deleted file mode 100644
index f15b3d0..0000000
--- a/samples/topology/src/main/java/org/apache/edgent/samples/topology/TerminateAfterNTuples.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-
-package org.apache.edgent.samples.topology;
-
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.edgent.providers.direct.DirectProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-/**
- * This application simulates a crash and terminates the JVM after processing
- * a preset number of tuples. This application is used in conjunction with a
- * monitoring script to demonstrate the restart of a JVM which has terminated
- * because of an Edgent application crash.
- */
-public class TerminateAfterNTuples {
- /** The application will terminate the JVM after this tuple count */
- public final static int TERMINATE_COUNT = 15;
-
- public static void main(String[] args) throws Exception {
-
- DirectProvider tp = new DirectProvider();
-
- Topology t = tp.newTopology("PeriodicSource");
-
- // Since this is the Direct provider the graph can access
- // objects created while the topology is being defined
- // (in this case the Random object r).
- Random r = new Random();
- TStream<Double> gaussian = t.poll(() -> r.nextGaussian(), 1, TimeUnit.SECONDS);
-
- // Program termination
- AtomicInteger count = new AtomicInteger(0);
- gaussian = gaussian.peek(g -> {
- if (count.incrementAndGet() >= TERMINATE_COUNT) {
- System.err.println("The JVM terminates after processing " +
- TERMINATE_COUNT + " tuples");
- System.exit(1);
- }
- });
-
- // Peek at the value on the Stream printing it to System.out
- gaussian = gaussian.peek(g -> System.out.println("R:" + g));
-
- tp.submit(t);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/topology/src/main/java/org/apache/edgent/samples/topology/package-info.java
----------------------------------------------------------------------
diff --git a/samples/topology/src/main/java/org/apache/edgent/samples/topology/package-info.java b/samples/topology/src/main/java/org/apache/edgent/samples/topology/package-info.java
deleted file mode 100644
index 000cb03..0000000
--- a/samples/topology/src/main/java/org/apache/edgent/samples/topology/package-info.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-
-/**
- * Samples showing creating and executing basic topologies .
- */
-package org.apache.edgent.samples.topology;
-
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/topology/src/main/resources/META-INF/NOTICE
----------------------------------------------------------------------
diff --git a/samples/topology/src/main/resources/META-INF/NOTICE b/samples/topology/src/main/resources/META-INF/NOTICE
deleted file mode 100644
index e02f844..0000000
--- a/samples/topology/src/main/resources/META-INF/NOTICE
+++ /dev/null
@@ -1,12 +0,0 @@
-
-Apache Edgent: Samples: Topology
-Copyright 2016-2017 The Apache Software Foundation
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-
-===============================================================================
-
-Portions of this bundle were developed by IBM Corp.
-Copyright IBM Corp. 2015, 2016
-
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/utils/README.md
----------------------------------------------------------------------
diff --git a/samples/utils/README.md b/samples/utils/README.md
deleted file mode 100644
index 7381f2e..0000000
--- a/samples/utils/README.md
+++ /dev/null
@@ -1,30 +0,0 @@
-See the README.md in the samples root directory for information on building the samples.
-
-The build generated uber jar contains all of the dependent
-Edgent jars and their transitive dependencies.
-
-The desired sample can be run using the run-sample.sh script. e.g.,
-
-```sh
-cd utils
-./run-sample.sh PeriodicSourceWithMetrics
-```
-
-For usage information:
-
-```sh
-./run-sample.sh
-./run-sample.sh --list
-```
-
-If you want to run a sample from the standard jar there are two options:
-a) get a local copy of all of the Edgent jars and their dependencies.
- Form a CLASSPATH to the jars and run the sample's main class.
- The get-edgent-jars.sh script can be used to get the jars from
- a maven repository (local or remote).
-b) create an application package bundle. The bundle includes the
- sample(s) jar and a copy of all of the dependent Edgent jars
- and their dependencies. The package-app.sh script can be
- used to create this bundle.
- The package-app.sh script also creates a run-app.sh script.
- The run-app.sh script configures the CLASSPATH and runs the main class.
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/utils/pom.xml
----------------------------------------------------------------------
diff --git a/samples/utils/pom.xml b/samples/utils/pom.xml
deleted file mode 100644
index 9e9fecc..0000000
--- a/samples/utils/pom.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.edgent.samples</groupId>
- <artifactId>edgent-samples</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>edgent-samples-utils</artifactId>
-
- <name>Apache Edgent Samples ${samples.projname.platform}: Utils</name>
-
- <dependencies>
- <!-- parent pom has Providers and SLF4J dependencies -->
-
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-utils-metrics</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-analytics-sensors</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-console-server</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-math3</artifactId>
- <version>3.4.1</version>
- </dependency>
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/utils/run-sample.sh
----------------------------------------------------------------------
diff --git a/samples/utils/run-sample.sh b/samples/utils/run-sample.sh
deleted file mode 100755
index 760c5bc..0000000
--- a/samples/utils/run-sample.sh
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/usr/bin/env bash
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-USAGE="usage: `basename $0` [--list] simple-main-class-name [sample-args]"
-
-CATEGORY=utils
-
-UBER_JAR=target/edgent-samples-${CATEGORY}-*-uber.jar
-
-SAMPLE_PACKAGE_BASE=org.apache.edgent.samples.${CATEGORY}
-SAMPLES_FQ=`cat <<EOF
-${SAMPLE_PACKAGE_BASE}.metrics.PeriodicSourceWithMetrics
-${SAMPLE_PACKAGE_BASE}.metrics.SplitWithMetrics
-EOF
-`
-
-if [ "$1" = "--list" ] ; then
- SAMPLES=
- for i in ${SAMPLES_FQ}; do
- SAMPLE=`echo ${i} | sed -e 's/.*\.//'`
- SAMPLES="${SAMPLES} ${SAMPLE}"
- done
- echo ${SAMPLES}
- exit 0
-fi
-if [ "$1" = "" ] ; then
- echo $USAGE
- exit 1
-fi
-
-SAMPLE_NAME=$1
-shift
-
-SAMPLE_FQ=
-for i in ${SAMPLES_FQ}; do
- SAMPLE_FQ=`echo $i | grep -- "\.${SAMPLE_NAME}\$"`
- if [ "${SAMPLE_FQ}" != "" ]; then
- break
- fi
-done
-if [ "${SAMPLE_FQ}" = "" ]; then
- echo unrecognized sample name \"${SAMPLE_NAME}\"
- echo ${USAGE}
- exit 1
-fi
-
-java -cp ${UBER_JAR} "${SAMPLE_FQ}" "$@"
-
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/utils/src/main/java/org/apache/edgent/samples/utils/metrics/PeriodicSourceWithMetrics.java
----------------------------------------------------------------------
diff --git a/samples/utils/src/main/java/org/apache/edgent/samples/utils/metrics/PeriodicSourceWithMetrics.java b/samples/utils/src/main/java/org/apache/edgent/samples/utils/metrics/PeriodicSourceWithMetrics.java
deleted file mode 100644
index b883e3e..0000000
--- a/samples/utils/src/main/java/org/apache/edgent/samples/utils/metrics/PeriodicSourceWithMetrics.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-package org.apache.edgent.samples.utils.metrics;
-
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.metrics.Metrics;
-import org.apache.edgent.metrics.MetricsSetup;
-import org.apache.edgent.providers.direct.DirectProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-import com.codahale.metrics.MetricRegistry;
-
-public class PeriodicSourceWithMetrics {
- public static void main(String[] args) throws InterruptedException {
-
- DirectProvider tp = new DirectProvider();
-
- Topology t = tp.newTopology("PeriodicSource");
-
- Random r = new Random();
- TStream<Double> gaussian = t.poll(() -> r.nextGaussian(), 1, TimeUnit.SECONDS);
-
- // Testing Peek
- gaussian = gaussian.peek(g -> System.out.println("R:" + g));
-
- // Measure the tuple count for the gaussian TStream
- gaussian = Metrics.counter(gaussian);
-
- // A filter
- gaussian = gaussian.filter(g -> g > 0.5);
-
- // Measure tuple arrival rate after filtering
- gaussian = Metrics.rateMeter(gaussian);
-
- // A transformation
- TStream<String> gs = gaussian.map(g -> "G:" + g + ":");
- gs.print();
-
- // Initialize the metrics service
- MetricRegistry metrics = new MetricRegistry();
-
- // Start metrics JMX reporter
- MetricsSetup.withRegistry(tp.getServices(), metrics).startJMXReporter(
- PeriodicSourceWithMetrics.class.getName());
-
- // Submit the topology
- tp.submit(t);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/utils/src/main/java/org/apache/edgent/samples/utils/metrics/SplitWithMetrics.java
----------------------------------------------------------------------
diff --git a/samples/utils/src/main/java/org/apache/edgent/samples/utils/metrics/SplitWithMetrics.java b/samples/utils/src/main/java/org/apache/edgent/samples/utils/metrics/SplitWithMetrics.java
deleted file mode 100644
index 43d4444..0000000
--- a/samples/utils/src/main/java/org/apache/edgent/samples/utils/metrics/SplitWithMetrics.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-package org.apache.edgent.samples.utils.metrics;
-
-import java.util.List;
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.console.server.HttpServer;
-import org.apache.edgent.metrics.Metrics;
-import org.apache.edgent.providers.development.DevelopmentProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-/**
- * Instruments a topology with a tuple counter on a specified stream.
- */
-public class SplitWithMetrics {
-
- public static void main(String[] args) throws Exception {
- DevelopmentProvider dtp = new DevelopmentProvider();
-
- Topology t = dtp.newTopology(SplitWithMetrics.class.getSimpleName());
-
- Random r = new Random();
-
- TStream<Integer> d = t.poll(() -> (int)(r.nextGaussian() * 3.0),
- 100, TimeUnit.MILLISECONDS);
-
- List<TStream<Integer>> splits = d.split(3, tuple -> {
- switch (tuple.intValue()) {
- case 0:
- return 0;
- case 1:
- return 1;
- default:
- return 2;
- }
- });
-
- /*
- * Insert a metric counter for the zeroes stream. Note that the
- * DevelopmentProvider submitter will insert metric counters at
- * submit time on the output of each oplet, including the counter
- * explicitly inserted below.
- */
- Metrics.counter(splits.get(0)).sink(tuple -> System.out.print("."));
-
- splits.get(1).sink(tuple -> System.out.print("#"));
- splits.get(2).sink(tuple -> System.out.print("@"));
-
- dtp.submit(t);
- System.out.println(dtp.getServices().getService(HttpServer.class).getConsoleUrl());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/GpsSensor.java
----------------------------------------------------------------------
diff --git a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/GpsSensor.java b/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/GpsSensor.java
deleted file mode 100644
index d18313a..0000000
--- a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/GpsSensor.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-package org.apache.edgent.samples.utils.sensor;
-
-/**
- * A GPS Sensor Reading
- *
- * TODO rename to GpsSensorReading
- */
-public class GpsSensor {
-
- private double latitude;
- private double longitude;
- private double altitude;
- private double speedMetersPerSec; // meters per sec
- private long time;
- private double course;
-
- public GpsSensor(double latitude, double longitude, double altitude, double speedMetersPerSec, long time,
- double course) {
-
- this.latitude = latitude;
- this.longitude = longitude;
- this.altitude = altitude;
- this.speedMetersPerSec = speedMetersPerSec;
- this.time = time;
- this.course = course;
- }
-
- public double getLatitude() {
- return latitude;
- }
-
- public double getLongitude() {
- return longitude;
- }
-
- public double geAltitude() {
- return altitude;
- }
-
- public double getSpeedMetersPerSec() {
- return speedMetersPerSec;
- }
-
- public long getTime() {
- return time;
- }
-
- public double getCourse() {
- return course;
- }
-
- @Override
- public String toString() {
- return latitude + ", " + longitude + ", " + altitude + ", " + speedMetersPerSec + ", " + time + ", " + course;
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/HeartMonitorSensor.java
----------------------------------------------------------------------
diff --git a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/HeartMonitorSensor.java b/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/HeartMonitorSensor.java
deleted file mode 100644
index 729b4ca..0000000
--- a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/HeartMonitorSensor.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-package org.apache.edgent.samples.utils.sensor;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Random;
-
-import org.apache.edgent.function.Supplier;
-
-/**
- * Streams of simulated heart monitor sensors.
- *
- */
-public class HeartMonitorSensor implements Supplier<Map<String,Integer>> {
- private static final long serialVersionUID = 1L;
- // Initial blood pressure
- public Integer currentSystolic = 115;
- public Integer currentDiastolic = 75;
- Random rand;
-
- public HeartMonitorSensor() {
- rand = new Random();
- }
-
- /**
- * Every call to this method returns a map containing a random systolic
- * pressure and a random diastolic pressure.
- */
- @Override
- public Map<String, Integer> get() {
- // Change the current pressure by some random amount between -2 and 2
- Integer newSystolic = rand.nextInt(2 + 1 + 2) - 2 + currentSystolic;
- currentSystolic = newSystolic;
-
- Integer newDiastolic = rand.nextInt(2 + 1 + 2) - 2 + currentDiastolic;
- currentDiastolic = newDiastolic;
-
- Map<String, Integer> pressures = new HashMap<String, Integer>();
- pressures.put("Systolic", currentSystolic);
- pressures.put("Diastolic", currentDiastolic);
- return pressures;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/PeriodicRandomSensor.java
----------------------------------------------------------------------
diff --git a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/PeriodicRandomSensor.java b/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/PeriodicRandomSensor.java
deleted file mode 100644
index 93aa20f..0000000
--- a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/PeriodicRandomSensor.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-package org.apache.edgent.samples.utils.sensor;
-
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.commons.math3.util.Pair;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-/**
- * A factory of simple periodic random sensor reading streams.
- * <p>
- * The generated {@link TStream} has a {@code org.apache.commons.math3.utils.Pair}
- * tuple type where {@link Pair#getFirst()} the reading's msecTimestamp
- * and {@link Pair#getSecond()} is the sensor value reading.
- * <p>
- * The sensor reading values are randomly generated via {@link Random}
- * and have the value distributions, as defined by {@code Random}.
- * <p>
- * Each stream has its own {@code Random} object instance.
- */
-public class PeriodicRandomSensor {
- private Long seed;
-
- /**
- * Create a new random periodic sensor factory configured
- * to use {@link Random#Random()}.
- */
- public PeriodicRandomSensor() {
- }
-
- /**
- * Create a new random periodic sensor factory configured
- * to use {@link Random#Random(long)}.
- *
- * @param seed seed to use when creating new sensor streams.
- */
- public PeriodicRandomSensor(long seed) {
- this.seed = seed;
- }
-
- /**
- * Set the seed to be used by subsequently created sensor streams.
- * @param seed the seed value
- */
- public void setSeed(long seed) {
- this.seed = seed;
- }
-
- private Random newRandom() {
- if (seed != null)
- return new Random(seed);
- return new Random();
- }
-
- /**
- * Create a periodic sensor stream with readings from {@link Random#nextGaussian()}.
- * @param t the topology to add the sensor stream to
- * @param periodMsec how frequently to generate a reading
- * @return the sensor value stream
- */
- public TStream<Pair<Long,Double>> newGaussian(Topology t, long periodMsec) {
- Random r = newRandom();
- return t.poll(() -> new Pair<Long,Double>(System.currentTimeMillis(), r.nextGaussian()),
- periodMsec, TimeUnit.MILLISECONDS);
-
- }
-
- /**
- * Create a periodic sensor stream with readings from {@link Random#nextDouble()}.
- * @param t the topology to add the sensor stream to
- * @param periodMsec how frequently to generate a reading
- * @return the sensor value stream
- */
- public TStream<Pair<Long,Double>> newDouble(Topology t, long periodMsec) {
- Random r = newRandom();
- return t.poll(() -> new Pair<Long,Double>(System.currentTimeMillis(), r.nextDouble()),
- periodMsec, TimeUnit.MILLISECONDS);
-
- }
-
- /**
- * Create a periodic sensor stream with readings from {@link Random#nextFloat()}.
- * @param t the topology to add the sensor stream to
- * @param periodMsec how frequently to generate a reading
- * @return the sensor value stream
- */
- public TStream<Pair<Long,Float>> newFloat(Topology t, long periodMsec) {
- Random r = newRandom();
- return t.poll(() -> new Pair<Long,Float>(System.currentTimeMillis(), r.nextFloat()),
- periodMsec, TimeUnit.MILLISECONDS);
-
- }
-
- /**
- * Create a periodic sensor stream with readings from {@link Random#nextLong()}.
- * @param t the topology to add the sensor stream to
- * @param periodMsec how frequently to generate a reading
- * @return the sensor value stream
- */
- public TStream<Pair<Long,Long>> newLong(Topology t, long periodMsec) {
- Random r = newRandom();
- return t.poll(() -> new Pair<Long,Long>(System.currentTimeMillis(), r.nextLong()),
- periodMsec, TimeUnit.MILLISECONDS);
-
- }
-
- /**
- * Create a periodic sensor stream with readings from {@link Random#nextInt()}.
- * @param t the topology to add the sensor stream to
- * @param periodMsec how frequently to generate a reading
- * @return the sensor value stream
- */
- public TStream<Pair<Long,Integer>> newInteger(Topology t, long periodMsec) {
- Random r = newRandom();
- return t.poll(() -> new Pair<Long,Integer>(System.currentTimeMillis(), r.nextInt()),
- periodMsec, TimeUnit.MILLISECONDS);
-
- }
-
- /**
- * Create a periodic sensor stream with readings from {@link Random#nextInt(int)}.
- * @param t the topology to add the sensor stream to
- * @param periodMsec how frequently to generate a reading
- * @param bound the upper bound (exclusive). Must be positive.
- * @return the sensor value stream
- */
- public TStream<Pair<Long,Integer>> newInteger(Topology t, long periodMsec, int bound) {
- Random r = newRandom();
- return t.poll(() -> new Pair<Long,Integer>(System.currentTimeMillis(), r.nextInt(bound)),
- periodMsec, TimeUnit.MILLISECONDS);
-
- }
-
- /**
- * Create a periodic sensor stream with readings from {@link Random#nextBoolean()}.
- * @param t the topology to add the sensor stream to
- * @param periodMsec how frequently to generate a reading
- * @return the sensor value stream
- */
- public TStream<Pair<Long,Boolean>> newBoolean(Topology t, long periodMsec) {
- Random r = newRandom();
- return t.poll(() -> new Pair<Long,Boolean>(System.currentTimeMillis(), r.nextBoolean()),
- periodMsec, TimeUnit.MILLISECONDS);
-
- }
-
- /**
- * Create a periodic sensor stream with readings from {@link Random#nextBytes(byte[])}.
- * @param t the topology to add the sensor stream to
- * @param periodMsec how frequently to generate a reading
- * @param nBytes the number of bytes in each reading tuple
- * @return the sensor value stream
- */
- public TStream<Pair<Long,byte[]>> newBytes(Topology t, long periodMsec, int nBytes) {
- Random r = newRandom();
- return t.poll(() -> { byte[] bytes = new byte[nBytes];
- r.nextBytes(bytes);
- return new Pair<Long,byte[]>(System.currentTimeMillis(), bytes);
- },
- periodMsec, TimeUnit.MILLISECONDS);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimpleSimulatedSensor.java
----------------------------------------------------------------------
diff --git a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimpleSimulatedSensor.java b/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimpleSimulatedSensor.java
deleted file mode 100644
index 0e306ca..0000000
--- a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimpleSimulatedSensor.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-
-package org.apache.edgent.samples.utils.sensor;
-
-import java.text.DecimalFormat;
-import java.util.Random;
-
-import org.apache.edgent.analytics.sensors.Range;
-import org.apache.edgent.function.Supplier;
-
-/**
- * A simple simulated sensor.
- * <p>
- * The sensor starts off with an initial value.
- * Each call to {@link #get()} changes the current value by
- * a random amount between plus/minus {@code deltaFactor}.
- * The new current value is limited to a {@code range}
- * and then rounded to 1 fractional digit.
- * See {@link #setNumberFractionalDigits(int)}.
- * </p><p>
- * Sample use:
- * <pre>{@code
- * Topology t = ...;
- * // a miles-per-gallon sensor
- * SimpleSimulatedSensor avgMpgSensor = new SimpleSimulatedSensor(10.5, 0.4,
- * Ranges<Double>.closed(7.0,14.0));
- * TStream<Double> avgMpg = t.poll(avgMpgSensor, 1, TimeUnit.SECONDS);
- *
- * // an integer valued sensor
- * SimpleSimulatedSensor doubleSensor = new SimpleSimulatedSensor();
- * TStream<Integer> intSensor = t.poll(() -> doubleSensor.get().intValue(),
- * 1, TimeUnit.SECONDS);
- * }</pre>
- */
-public class SimpleSimulatedSensor implements Supplier<Double> {
- private static final long serialVersionUID = 1L;
- private int numFracDigits;
- private volatile DecimalFormat df;
- private Random r = new Random();
- private final Range<Double> range;
- private final double deltaFactor;
- private double currentValue;
-
- /**
- * Create a sensor.
- * <p>
- * Same as {@code SimpleSimulatedSensor(0.0, 1.0, null)};
- * </p>
- */
- public SimpleSimulatedSensor() {
- this(0.0, 1.0, null);
- }
-
- /**
- * Create a sensor.
- * <p>
- * Same as {@code SimpleSimulatedSensor(initialValue, 1.0, null)};
- * </p>
- * @param initialValue the initial value
- */
- public SimpleSimulatedSensor(double initialValue) {
- this(initialValue, 1.0, null);
- }
-
- /**
- * Create a sensor.
- *
- * <p>
- * Same as {@code SimpleSimulatedSensor(initialValue, deltaFactor, null)};
- * </p>
- * @param initialValue the initial value.
- * @param deltaFactor maximum plus/minus change on each {@code get()}.
- * e.g., 1.0 to limit change to +/- 1.0.
- * Must be > 0.0
- */
- public SimpleSimulatedSensor(double initialValue, double deltaFactor) {
- this(initialValue, deltaFactor, null);
- }
-
- /**
- * Create a sensor.
- *
- * @param initialValue the initial value. Must be within range.
- * @param deltaFactor maximum plus/minus change on each {@link #get()}.
- * e.g., 1.0 to limit change to +/- 1.0.
- * Must be > 0.0
- * @param range maximum sensor value range. Unlimited if null.
- */
- public SimpleSimulatedSensor(double initialValue,
- double deltaFactor, Range<Double> range) {
- if (range!=null && !range.contains(initialValue))
- throw new IllegalArgumentException("initialValue");
- if (deltaFactor <= 0.0)
- throw new IllegalArgumentException("deltaFactor");
- this.currentValue = initialValue;
- this.deltaFactor = deltaFactor;
- this.range = range;
- setNumberFractionalDigits(1);
- }
-
- /**
- * Set number of fractional digits to round sensor values to.
- * <p>
- * This class offers rounding as a convenience and because
- * ancestors of this implementation had such a scheme.
- * </p>
- * @param numFracDigits if <= 0, no rounding will be performed
- */
- public void setNumberFractionalDigits(int numFracDigits) {
- this.numFracDigits = numFracDigits;
- if (numFracDigits <= 0) {
- df = null;
- }
- else {
- String fracPattern = "";
- for (int i = 0; i < numFracDigits; i++)
- fracPattern += "#";
- df = new DecimalFormat("#."+fracPattern);
- }
- }
-
- /** Get the number of fractional digits setting
- * @return the value
- */
- public int getNumberFractionalDigits() {
- return numFracDigits;
- }
-
- /** Get the range setting
- * @return the value
- */
- public Range<Double> getRange() {
- return range;
- }
-
- /** Get the deltaFactor setting
- * @return the value
- */
- public double getDeltaFactor() {
- return deltaFactor;
- }
-
- /** Get the next sensor value as described in the class documentation. */
- @Override
- public Double get() {
- double delta = 2 * r.nextDouble() - 1.0; // between -1.0 and 1.0
- double nextValue = currentValue + delta * deltaFactor;
- if (range!=null && !range.contains(nextValue)) {
- nextValue = nextValue > currentValue
- ? range.upperEndpoint()
- : range.lowerEndpoint();
- }
- if (df != null)
- nextValue = Double.valueOf(df.format(nextValue));
- currentValue = nextValue;
- return currentValue;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimulatedGpsSensor.java
----------------------------------------------------------------------
diff --git a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimulatedGpsSensor.java b/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimulatedGpsSensor.java
deleted file mode 100644
index 0d8145c..0000000
--- a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimulatedGpsSensor.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
- */
-package org.apache.edgent.samples.utils.sensor;
-
-public class SimulatedGpsSensor {
- private int currentIndex;
- private int simulatedSec;
- private int requestedIterations = -1; // -1 means loop through gpsDataArray
- // forever
- private int currentIteration = 0;
-
- public SimulatedGpsSensor() {
- this.currentIndex = -1;
- this.simulatedSec = 1;
- }
-
- // TODO: Replace hard-coded data to reading in GPS data from file
- // GPS data from IBM Silicon Valley Lab to IBM Almaden Research and back to
- // IBM SVL
- private static double[][] gpsDataArray = { { 37.195647, -121.748087 }, // IBM
- // Silicon
- // Valley
- // Lab
- // 555
- // Bailey
- // Ave
- { 37.18110679999999, -121.7865003 }, // Calero Reservoir McKean
- { 37.19926299999999, -121.82234399999999 }, // Santa Clara Horsemen
- // Association 20350
- // McKean
- { 37.198632, -121.82234399999999 }, // Forestry & Fire Protection
- // 20255 McKean
- { 37.19875469999999, -121.82320830000003 }, // St. Anthony Church
- // 20101 McKean
- { 37.2004004, -121.82578030000002 }, // Challenger School 19950
- // McKean
- { 37.199576, -121.82468900000003 }, // Firehouse No.28 19911 McKean
- // Rd
- { 37.211053, -121.806949 }, // IBM Almaden Research Harry Road
- // then go back the reverse direction
- { 37.199576, -121.82468900000003 }, // Firehouse No.28 19911 McKean
- // Rd
- { 37.2004004, -121.82578030000002 }, // Challenger School 19950
- // McKean
- { 37.19875469999999, -121.82320830000003 }, // St. Anthony Church
- // 20101 McKean
- { 37.198632, -121.82234399999999 }, // Forestry & Fire Protection
- // 20255 McKean
- { 37.19926299999999, -121.82234399999999 }, // Santa Clara Horsemen
- // Association 20350
- // McKean
- { 37.18110679999999, -121.7865003 }, // Calero Reservoir McKean
- { 37.195647, -121.748087 }, // IBM Silicon Valley Lab 555 Bailey Ave
- };
-
- // TODO Re-write kluge code to read from a file
- // Returns a GpsSensor using the hard-coded list, then repeats through the
- // list
- // forever when requestedIterations = -1, or until iterations is reached.
- public GpsSensor nextGps() {
-
- GpsSensor result = null;
- if (requestedIterations == -1 || currentIteration < requestedIterations) {
- simulatedSec++;
-
- // Determine the index to use for generating the next GPS coordinate
- // If currentIndex is already at the end of the array, then set
- // currentIndex to start over at the array beginning at index 0
- // Otherwise, increment currentIndex
- if (currentIndex >= gpsDataArray.length - 1) {
- currentIndex = 0;
- currentIteration++;
- } else
- currentIndex++;
-
- // hardcode other data (altitude, course, time, speed, etc.) and at
- // index 5 for hard braking and acceleration speed
- if (currentIndex == 5)
- result = new GpsSensor(gpsDataArray[currentIndex][0], gpsDataArray[currentIndex][1], 32.1, 42.4,
- simulatedSec, 38.2);
- else
- result = new GpsSensor(gpsDataArray[currentIndex][0], gpsDataArray[currentIndex][1], 20.1, 29.0,
- simulatedSec, 28.2);
-
- }
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimulatedSensors.java
----------------------------------------------------------------------
diff --git a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimulatedSensors.java b/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimulatedSensors.java
deleted file mode 100644
index b1856ff..0000000
--- a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimulatedSensors.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-
-package org.apache.edgent.samples.utils.sensor;
-
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-import com.google.gson.JsonObject;
-
-/**
- * Streams of simulated sensors.
- *
- */
-public class SimulatedSensors {
-
- /**
- * Create a stream of simulated bursty sensor readings.
- *
- * Simulation of reading a sensor every 100ms with the readings
- * generally falling below 2.0 (absolute) but randomly have
- * prolonged bursts of higher values.
- *
- * Each tuple is a JSON object containing:
- * <UL>
- * <LI>{@code name} - Name of the sensor from {@code name}.</LI>
- * <LI>{@code reading} - Value.</LI>
- * </UL>
- *
- * @param topology Topology to be added to.
- * @param name Name of the sensor in the JSON output.
- * @return Stream containing bursty data.
- */
- public static TStream<JsonObject> burstySensor(Topology topology, String name) {
-
- Random r = new Random();
-
- TStream<Double> sensor = topology.poll(() -> r.nextGaussian(), 100, TimeUnit.MILLISECONDS);
-
- boolean[] abnormal = new boolean[1];
- int[] count = new int[1];
- double[] delta = new double[1];
- sensor = sensor.modify(t -> {
- if (abnormal[0] || r.nextInt(100) < 4) {
- if (!abnormal[0]) {
- delta[0] = 0.5 + 2 * r.nextGaussian();
- count[0] = 5 + r.nextInt(20);
- abnormal[0] = true;
- }
- count[0]--;
- if (count[0] <= 0)
- abnormal[0] = false;
- return t + delta[0];
- } else
- return t;
- });
-
- sensor = sensor.filter(t -> Math.abs(t) > 1.5);
-
- return sensor.map(t -> {
- JsonObject j = new JsonObject();
- j.addProperty("name", name);
- j.addProperty("reading", t);
- return j;
- });
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimulatedTemperatureSensor.java
----------------------------------------------------------------------
diff --git a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimulatedTemperatureSensor.java b/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimulatedTemperatureSensor.java
deleted file mode 100644
index e749ce8..0000000
--- a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimulatedTemperatureSensor.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-
-package org.apache.edgent.samples.utils.sensor;
-
-import java.util.Objects;
-
-import org.apache.edgent.analytics.sensors.Range;
-import org.apache.edgent.analytics.sensors.Ranges;
-import org.apache.edgent.function.Supplier;
-
-/**
- * A Simulated temperature sensor.
- * <p>
- * The sensor starts off with an initial value.
- * Each call to {@link #get()} changes the current value by
- * a random amount between plus/minus a {@code deltaFactor}.
- * The new current value is limited to a {@code tempRange}
- * and then rounded to 1 fractional digit.
- * </p><p>
- * No temperature scale is implied (e.g., Fahrenheit, Kelvin, ...).
- * The {@code double} temperature values are simply generated as described.
- * The user of the class decides how to interpret them.
- * </p><p>
- * Sample use:
- * <pre>{@code
- * Topology t = ...;
- * SimulatedTemperatureSensor tempSensor = new SimulatedTemperatureSensor();
- * TStream<Double> temp = t.poll(tempSensor, 1, TimeUnit.SECONDS);
- * }</pre>
- * @see SimpleSimulatedSensor
- */
-public class SimulatedTemperatureSensor implements Supplier<Double> {
- private static final long serialVersionUID = 1L;
- private final SimpleSimulatedSensor sensor;
-
- /**
- * Create a temperature sensor.
- * <p>
- * Same as {@code SimulatedTemperatureSensor(80.0,
- * Ranges.closed(28.0, 112.0), 1.0)}
- * </p><p>
- * These default values roughly correspond to normal air temperature
- * in the Fahrenheit scale.
- * </p>
- */
- public SimulatedTemperatureSensor() {
- this(80.0, Ranges.closed(28.0, 112.0), 1.0);
- }
-
- /**
- * Create a temperature sensor.
- * <p>
- * No temperature scale is implied.
- * </p>
- * @param initialTemp the initial temperature. Must be within tempRange.
- * @param tempRange maximum sensor value range
- * @param deltaFactor maximum plus/minus change on each {@code get()}.
- * e.g., 1.0 to limit change to +/- 1.0.
- * Must be > 0.0
- */
- public SimulatedTemperatureSensor(double initialTemp,
- Range<Double> tempRange, double deltaFactor) {
- Objects.requireNonNull(tempRange, "tempRange");
- if (!tempRange.contains(initialTemp))
- throw new IllegalArgumentException("initialTemp");
- if (deltaFactor <= 0.0)
- throw new IllegalArgumentException("deltaFactor");
- sensor = new SimpleSimulatedSensor(initialTemp, deltaFactor, tempRange);
- }
-
- /** Get the tempRange setting
- * @return the value
- */
- public Range<Double> getTempRange() {
- return sensor.getRange();
- }
-
- /** Get the deltaFactor setting
- * @return the value
- */
- public double getDeltaFactor() {
- return sensor.getDeltaFactor();
- }
-
- /** Get the next sensor value. */
- @Override
- public Double get() {
- return sensor.get();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/utils/src/main/resources/META-INF/NOTICE
----------------------------------------------------------------------
diff --git a/samples/utils/src/main/resources/META-INF/NOTICE b/samples/utils/src/main/resources/META-INF/NOTICE
deleted file mode 100644
index a581fd5..0000000
--- a/samples/utils/src/main/resources/META-INF/NOTICE
+++ /dev/null
@@ -1,12 +0,0 @@
-
-Apache Edgent: Samples: Utils
-Copyright 2016-2017 The Apache Software Foundation
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-
-===============================================================================
-
-Portions of this bundle were developed by IBM Corp.
-Copyright IBM Corp. 2015, 2016
-