Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sensorhub-process-template #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions processing/sensorhub-process-template/README.md
Original file line number Diff line number Diff line change
@@ -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
36 changes: 36 additions & 0 deletions processing/sensorhub-process-template/build.gradle
Original file line number Diff line number Diff line change
@@ -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 ''
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.sample.impl.process.processname;

import org.sensorhub.utils.OshBundleActivator;

public class Activator extends OshBundleActivator {
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.sample.impl.process.processname.ProcessDescriptors
Empty file.
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<sml:AggregateProcess xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sml="http://www.opengis.net/sensorml/2.0" xmlns:swe="http://www.opengis.net/swe/2.0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:gmd="http://www.isotc211.org/2005/gmd" gml:id="F1">
<gml:identifier codeSpace="uid">[UUID or URN]</gml:identifier>
<sml:outputs>
<sml:OutputList>
<sml:output name="output1">
<swe:Count>
<swe:label>Output 1</swe:label>
</swe:Count>
</sml:output>
</sml:OutputList>
</sml:outputs>
<sml:components>
<sml:ComponentList>
<sml:component name="source0">
<sml:SimpleProcess gml:id="F2">
<sml:typeOf xlink:href="urn:osh:process:datasource:stream"/>
<sml:configuration>
<sml:Settings>
<sml:setValue ref="parameters/producerURI">urn:of:system:with:datastream</sml:setValue>
</sml:Settings>
</sml:configuration>
</sml:SimpleProcess>
</sml:component>
<sml:component name="process0">
<sml:SimpleProcess gml:id="F3">
<sml:typeOf xlink:href="urn:osh:process:myprocessname"/>
<sml:inputs>
<sml:InputList>
<sml:input name="input1">
<swe:Count>
<swe:label>Input 1</swe:label>
</swe:Count>
</sml:input>
</sml:InputList>
</sml:inputs>
<sml:outputs>
<sml:OutputList>
<sml:output name="output1">
<swe:Count>
<swe:label>Output 1</swe:label>
</swe:Count>
</sml:output>
</sml:OutputList>
</sml:outputs>
<sml:parameters>
<sml:ParameterList>
<sml:parameter name="param1">
<swe:Count>
<swe:label>Parameter 1</swe:label>
<swe:value>12345</swe:value>
</swe:Count>
</sml:parameter>
</sml:ParameterList>
</sml:parameters>
</sml:SimpleProcess>
</sml:component>
<sml:component name="control0">
<sml:SimpleProcess gml:id="F4">
<sml:typeOf xlink:href="urn:osh:process:datasink:commandstream"/>
<sml:configuration>
<sml:Settings>
<sml:setValue ref="parameters/systemUID">urn:to:system:with:controlstreams</sml:setValue>
<sml:setValue ref="parameters/inputName">controlStream1</sml:setValue>
</sml:Settings>
</sml:configuration>
</sml:SimpleProcess>
</sml:component>
</sml:ComponentList>
</sml:components>
<sml:connections>
<sml:ConnectionList>
<sml:connection>
<sml:Link>
<sml:source ref="components/source0/outputs/GenericOutput/anyOutputMatchingInput1Struct"/>
<sml:destination ref="components/process0/inputs/input1"/>
</sml:Link>
</sml:connection>
<sml:connection>
<sml:Link>
<sml:source ref="components/process0/outputs/output1"/>
<sml:destination ref="components/control0/inputs/controlStream1/anyInputMatchingOutput1Struct"/>
</sml:Link>
</sml:connection>
<sml:connection>
<sml:Link>
<sml:source ref="components/process0/outputs/output1"/>
<sml:destination ref="outputs/output1"/>
</sml:Link>
</sml:connection>
</sml:ConnectionList>
</sml:connections>
</sml:AggregateProcess>
10 changes: 10 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,13 @@ subprojects.files.each { File f ->
project(projectName).projectDir = projectFolder
}
}

FileTree processProjects = fileTree("$rootDir/processing").include('**/build.gradle')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be best to use

subprojects = filetree(...)

as the processProjects is not currently visible in build.gradle, unless you add logic in build.gradle to pull in the sensorML descriptions and add them to the deployment configuration like subprojects

processProjects.files.each { File f ->
File projectFolder = f.parentFile
if (projectFolder != rootDir) {
String projectName = ':' + projectFolder.name
include projectName
project(projectName).projectDir = projectFolder
}
}