diff --git a/processing/sensorhub-process-template/README.md b/processing/sensorhub-process-template/README.md new file mode 100644 index 0000000..3fd776a --- /dev/null +++ b/processing/sensorhub-process-template/README.md @@ -0,0 +1,11 @@ +# [NAME] + +## Configuration + +Configuring the process requires: +Select ```Processing``` from the left hand accordion control and right click for context sensitive menu in accordion control. +Select the ```SensorML Stream Process``` Module +- **Module Name:** A name for the instance of the processing module +- **Description:** A description of the process chain +- **SensorML File:** The path to a process description file, which can be a XML or JSON SensorML process description. +- **Auto Start:** Check the box to start this module when OSH node is launched \ No newline at end of file diff --git a/processing/sensorhub-process-template/build.gradle b/processing/sensorhub-process-template/build.gradle new file mode 100644 index 0000000..91d14dd --- /dev/null +++ b/processing/sensorhub-process-template/build.gradle @@ -0,0 +1,36 @@ +description = 'Put your description here' +ext.details = "Details here" +version = '1.0.0' + +dependencies { + implementation 'org.sensorhub:sensorhub-core:' + oshCoreVersion + testImplementation('junit:junit:4.13.1') +} + +// exclude tests requiring connection to the sensor +// these have to be run manually +// If tests are to be excluded list them here as follows +// exclude '**/TestNameClass.class' +test { + useJUnit() +} + +// add info to OSGi manifest +osgi { + manifest { + attributes ('Bundle-Vendor': 'Botts Inc') + attributes ('Bundle-Activator': 'com.sample.impl.process.processname.Activator') + } +} + +// add info to maven pom +ext.pom >>= { + developers { + developer { + id 'some id' + name 'Your name' + organization '' + organizationUrl '' + } + } +} diff --git a/processing/sensorhub-process-template/src/main/java/com/sample/impl/process/processname/Activator.java b/processing/sensorhub-process-template/src/main/java/com/sample/impl/process/processname/Activator.java new file mode 100644 index 0000000..981398f --- /dev/null +++ b/processing/sensorhub-process-template/src/main/java/com/sample/impl/process/processname/Activator.java @@ -0,0 +1,6 @@ +package com.sample.impl.process.processname; + +import org.sensorhub.utils.OshBundleActivator; + +public class Activator extends OshBundleActivator { +} diff --git a/processing/sensorhub-process-template/src/main/java/com/sample/impl/process/processname/MyProcess.java b/processing/sensorhub-process-template/src/main/java/com/sample/impl/process/processname/MyProcess.java new file mode 100644 index 0000000..258d198 --- /dev/null +++ b/processing/sensorhub-process-template/src/main/java/com/sample/impl/process/processname/MyProcess.java @@ -0,0 +1,45 @@ +package com.sample.impl.process.processname; + +import net.opengis.swe.v20.Count; +import org.sensorhub.api.processing.OSHProcessInfo; +import org.vast.process.ExecutableProcessImpl; +import org.vast.process.ProcessException; +import org.vast.swe.SWEHelper; + +public class MyProcess extends ExecutableProcessImpl { + + public static final OSHProcessInfo INFO = new OSHProcessInfo("myprocessname", "Process Label", "Description of my process goes here", MyProcess.class); + + Count input1; + Count output1; + Count parameter1; + + /** + * Typically, you will initialize your input, output, and parameter data structures in the constructor + */ + protected MyProcess() { + super(INFO); + + SWEHelper fac = new SWEHelper(); + // Create process inputs, outputs, and parameters + this.inputData.add("input1", input1 = fac.createCount().build()); + this.outputData.add("output1", output1 = fac.createCount().build()); + this.paramData.add("parameter1", parameter1 = fac.createCount().build()); // Optional + } + + /** + * Process execution method. This is what gets called when your process runs + * + * @throws ProcessException + */ + @Override + public void execute() throws ProcessException { + int paramValue = parameter1.getData().getIntValue(); + int inputValue = input1.getData().getIntValue(); + + // Do whatever computations/processing with your input and parameter data, and use it to populate the output data blocks + int equation = inputValue * paramValue; + + output1.getData().setIntValue(equation); + } +} diff --git a/processing/sensorhub-process-template/src/main/java/com/sample/impl/process/processname/ProcessDescriptors.java b/processing/sensorhub-process-template/src/main/java/com/sample/impl/process/processname/ProcessDescriptors.java new file mode 100644 index 0000000..5365b78 --- /dev/null +++ b/processing/sensorhub-process-template/src/main/java/com/sample/impl/process/processname/ProcessDescriptors.java @@ -0,0 +1,11 @@ +package com.sample.impl.process.processname; + +import org.sensorhub.impl.processing.AbstractProcessProvider; + +public class ProcessDescriptors extends AbstractProcessProvider { + + public ProcessDescriptors() { + addImpl(MyProcess.INFO); + } + +} \ No newline at end of file diff --git a/processing/sensorhub-process-template/src/main/resources/META-INF/services/org.sensorhub.api.processing.IProcessProvider b/processing/sensorhub-process-template/src/main/resources/META-INF/services/org.sensorhub.api.processing.IProcessProvider new file mode 100644 index 0000000..a95a074 --- /dev/null +++ b/processing/sensorhub-process-template/src/main/resources/META-INF/services/org.sensorhub.api.processing.IProcessProvider @@ -0,0 +1 @@ +com.sample.impl.process.processname.ProcessDescriptors diff --git a/processing/sensorhub-process-template/src/test/java/empty b/processing/sensorhub-process-template/src/test/java/empty new file mode 100644 index 0000000..e69de29 diff --git a/processing/sensorhub-process-template/src/test/resources/myprocess-description.json b/processing/sensorhub-process-template/src/test/resources/myprocess-description.json new file mode 100644 index 0000000..0c778ce --- /dev/null +++ b/processing/sensorhub-process-template/src/test/resources/myprocess-description.json @@ -0,0 +1,93 @@ +{ + "type": "AggregateProcess", + "uniqueId": "[UUID or URN]", + "label": "Human readable label for composite process", + "description": "Description of the composite process", + "outputs": [ + { + "type": "Count", + "name": "output1", + "label": "Output 1", + "definition": "http://sensorml.com/ont/swe/property/[DEFINITION]", + "description": "Description of composite process' output" + } + ], + "components": [ + { + "type": "SimpleProcess", + "name": "source0", + "typeOf": { + "href": "urn:osh:process:datasource:stream" + }, + "configuration": { + "setValues": [ + { + "ref": "parameters/producerURI", + "value": "urn:of:system:with:datastream" + } + ] + } + }, + { + "type": "SimpleProcess", + "name": "process0", + "label": "Process Label", + "description": "Description of my process goes here", + "typeOf": { + "href": "urn:osh:process:myprocessname" + }, + "inputs": [ + { + "type": "Count", + "name": "input1" + } + ], + "outputs": [ + { + "type": "Count", + "name": "output1" + } + ], + "parameters": [ + { + "type": "Count", + "name": "param1", + "value": 12345 + } + ] + }, + { + "type": "SimpleProcess", + "name": "control0", + "typeOf": { + "href": "urn:osh:process:datasink:commandstream" + }, + "configuration": { + "setValues": [ + { + "ref": "parameters/systemUID", + "value": "urn:to:system:with:controlstream" + }, + { + "ref": "parameters/inputName", + "value": "controlStreamInputName" + } + ] + } + } + ], + "connection": [ + { + "source": "components/source0/outputs/anyOutputMatchingInput1Struct", + "destination": "components/process0/inputs/input1" + }, + { + "source": "components/process0/outputs/output1", + "destination": "components/control0/inputs/controlStreamInputName" + }, + { + "source": "components/process0/outputs/output1", + "destination": "outputs/output1" + } + ] +} \ No newline at end of file diff --git a/processing/sensorhub-process-template/src/test/resources/myprocess-description.xml b/processing/sensorhub-process-template/src/test/resources/myprocess-description.xml new file mode 100644 index 0000000..7c77287 --- /dev/null +++ b/processing/sensorhub-process-template/src/test/resources/myprocess-description.xml @@ -0,0 +1,92 @@ + + [UUID or URN] + + + + + Output 1 + + + + + + + + + + + + urn:of:system:with:datastream + + + + + + + + + + + + Input 1 + + + + + + + + + Output 1 + + + + + + + + + Parameter 1 + 12345 + + + + + + + + + + + + urn:to:system:with:controlstreams + controlStream1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 4f2cb4f..c44a033 100644 --- a/settings.gradle +++ b/settings.gradle @@ -59,3 +59,13 @@ subprojects.files.each { File f -> project(projectName).projectDir = projectFolder } } + +FileTree processProjects = fileTree("$rootDir/processing").include('**/build.gradle') +processProjects.files.each { File f -> + File projectFolder = f.parentFile + if (projectFolder != rootDir) { + String projectName = ':' + projectFolder.name + include projectName + project(projectName).projectDir = projectFolder + } +} \ No newline at end of file