forked from SAP-archive/iot-edge-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
custom services samples #1
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
Open
marco-porru
wants to merge
4
commits into
master
Choose a base branch
from
custom-service
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
custom-services-additional-apis-messagebus/edgeApiExtension-interface/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 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> | ||
| <groupId>com.sap.iotservices.gateway.extension</groupId> | ||
| <artifactId>edgeApiExtensionInterface</artifactId> | ||
| <name>edgeApiExtensionInterface</name> | ||
| <version>1.0.0</version> | ||
| <properties> | ||
| <bundle.symbolicName>${project.artifactId}</bundle.symbolicName> | ||
| <bundle.version>${project.version}</bundle.version> | ||
| </properties> | ||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <version>3.3</version> | ||
| <configuration> | ||
| <source>1.8</source> | ||
| <target>1.8</target> | ||
| </configuration> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-jar-plugin</artifactId> | ||
| <configuration> | ||
| <archive> | ||
| <manifestFile>META-INF/MANIFEST.MF</manifestFile> | ||
| </archive> | ||
| </configuration> | ||
| </plugin> | ||
| <!-- the versions plugin can be used to check for new plugin versions | ||
| like this: mvn versions:Display-plugin-updates --> | ||
| <plugin> | ||
| <groupId>org.apache.felix</groupId> | ||
| <artifactId>maven-bundle-plugin</artifactId> | ||
| <extensions>true</extensions> | ||
| <executions> | ||
| <!-- Configure extra execution of 'manifest' in process-classes | ||
| phase to make sure SCR metadata is generated before unit test runs --> | ||
| <execution> | ||
| <id>scr-metadata</id> | ||
| <goals> | ||
| <goal>manifest</goal> | ||
| </goals> | ||
| <configuration> | ||
| <supportIncrementalBuild>true</supportIncrementalBuild> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| <configuration> | ||
| <exportScr>true</exportScr> | ||
| <manifestLocation>META-INF</manifestLocation> | ||
| <instructions> | ||
| <Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName> | ||
| <Bundle-Version>${bundle.version}</Bundle-Version> | ||
| <!-- Enable processing of OSGI DS component annotations --> | ||
| <_dsannotations>*</_dsannotations> | ||
| <!-- Enable processing of OSGI metatype annotations --> | ||
| <_metatypeannotations>*</_metatypeannotations> | ||
| </instructions> | ||
| </configuration> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </project> |
11 changes: 11 additions & 0 deletions
11
...sion-interface/src/main/java/com/sap/iotservices/gateway/extension/IEdgeApiExtension.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.sap.iotservices.gateway.extension; | ||
|
|
||
| public interface IEdgeApiExtension { | ||
|
|
||
| long getUptime(); | ||
|
|
||
| long getDowntime(); | ||
|
|
||
| float getNoisePower(float signal, float variance); | ||
|
|
||
| } |
103 changes: 103 additions & 0 deletions
103
custom-services-additional-apis-messagebus/edgeApiExtension/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 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> | ||
| <groupId>com.sap.iotservices.gateway.extension</groupId> | ||
| <artifactId>edgeApiExtension</artifactId> | ||
| <name>edgeApiExtension</name> | ||
| <version>1.0.0</version> | ||
| <properties> | ||
| <bundle.symbolicName>${project.artifactId}</bundle.symbolicName> | ||
| <bundle.version>${project.version}</bundle.version> | ||
| </properties> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>com.sap.iotservices.gateway.extension</groupId> | ||
| <artifactId>edgeApiExtensionInterface</artifactId> | ||
| <version>${project.version}</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.osgi</groupId> | ||
| <artifactId>osgi.cmpn</artifactId> | ||
| <version>6.0.0</version> | ||
| <scope>compile</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.slf4j</groupId> | ||
| <artifactId>slf4j-api</artifactId> | ||
| <version>1.7.29</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.github.oshi</groupId> | ||
| <artifactId>oshi-core</artifactId> | ||
| <version>4.3.0</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>net.java.dev.jna</groupId> | ||
| <artifactId>jna-platform</artifactId> | ||
| <version>5.5.0</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>net.java.dev.jna</groupId> | ||
| <artifactId>jna</artifactId> | ||
| <version>5.5.0</version> | ||
| </dependency> | ||
| </dependencies> | ||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <version>3.3</version> | ||
| <configuration> | ||
| <source>1.8</source> | ||
| <target>1.8</target> | ||
| </configuration> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-jar-plugin</artifactId> | ||
| <configuration> | ||
| <archive> | ||
| <manifestFile>META-INF/MANIFEST.MF</manifestFile> | ||
| </archive> | ||
| </configuration> | ||
| </plugin> | ||
| <!-- the versions plugin can be used to check for new plugin versions | ||
| like this: mvn versions:Display-plugin-updates --> | ||
| <plugin> | ||
| <groupId>org.apache.felix</groupId> | ||
| <artifactId>maven-bundle-plugin</artifactId> | ||
| <extensions>true</extensions> | ||
| <executions> | ||
| <!-- Configure extra execution of 'manifest' in process-classes | ||
| phase to make sure SCR metadata is generated before unit test runs --> | ||
| <execution> | ||
| <id>scr-metadata</id> | ||
| <goals> | ||
| <goal>manifest</goal> | ||
| </goals> | ||
| <configuration> | ||
| <supportIncrementalBuild>true</supportIncrementalBuild> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| <configuration> | ||
| <exportScr>true</exportScr> | ||
| <manifestLocation>META-INF</manifestLocation> | ||
| <instructions> | ||
| <Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName> | ||
| <Bundle-Version>${bundle.version}</Bundle-Version> | ||
| <!-- Enable processing of OSGI DS component annotations --> | ||
| <_dsannotations>*</_dsannotations> | ||
| <!-- Enable processing of OSGI metatype annotations --> | ||
| <_metatypeannotations>*</_metatypeannotations> | ||
| </instructions> | ||
| </configuration> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </project> |
50 changes: 50 additions & 0 deletions
50
...iExtension/src/main/java/com/sap/iotservices/gateway/extension/impl/EdgeApiExtension.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| package com.sap.iotservices.gateway.extension.impl; | ||
|
|
||
| import java.lang.management.ManagementFactory; | ||
| import java.util.Date; | ||
| import java.util.Random; | ||
|
|
||
| import org.osgi.service.component.annotations.Activate; | ||
| import org.osgi.service.component.annotations.Component; | ||
| import org.osgi.service.component.annotations.Deactivate; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import com.sap.iotservices.gateway.extension.IEdgeApiExtension; | ||
|
|
||
| import oshi.SystemInfo; | ||
|
|
||
| @Component(immediate = true, service = IEdgeApiExtension.class) | ||
| public class EdgeApiExtension | ||
| implements IEdgeApiExtension { | ||
|
|
||
| private static final Logger LOGGER = LoggerFactory.getLogger(EdgeApiExtension.class); | ||
| Random r = new java.util.Random(); | ||
|
|
||
| @Activate | ||
| public void startService() { | ||
| LOGGER.info("Starting Edge API Extension service"); | ||
| } | ||
|
|
||
| @Deactivate | ||
| public void stopService() { | ||
| LOGGER.info("Stopping Edge API Extension service"); | ||
| } | ||
|
|
||
| @Override | ||
| public long getUptime() { | ||
| Date now = new Date(); | ||
| return (now.getTime() - ManagementFactory.getRuntimeMXBean().getStartTime()) / 1000; | ||
| } | ||
|
|
||
| @Override | ||
| public long getDowntime() { | ||
| long uptime = getUptime(); | ||
| return new SystemInfo().getOperatingSystem().getSystemUptime() - (uptime / 1000); | ||
| } | ||
|
|
||
| @Override public float getNoisePower(float signal, float variance) { | ||
| double noise = r.nextGaussian() * Math.sqrt(variance) + signal; | ||
| return (float) noise; | ||
| } | ||
| } | ||
12 changes: 12 additions & 0 deletions
12
...-additional-apis-messagebus/edgeApiExtension/src/main/resources/defaultConfiguration.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "businessPartner": "8FA7D41CD4C448BF9A27962E9055C141", | ||
| "earliestStartDateTime": "2019-12-05T12:28:57.550000Z", | ||
| "dueDateTime": "2019-12-05T14:28:57.550000Z", | ||
| "durationInMinutes": "60", | ||
| "priority": "HIGH", | ||
| "subject": "High temperature on robot_t1", | ||
| "status": "-5", | ||
| "problemType": "-1", | ||
| "origin": "-1", | ||
| "remarks": "High temperature on robot_t1" | ||
| } |
149 changes: 149 additions & 0 deletions
149
custom-services-additional-apis-messagebus/extendedOperations/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 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> | ||
| <groupId>com.sap.iot.edge</groupId> | ||
| <artifactId>extendedOperations</artifactId> | ||
| <name>extendedOperations</name> | ||
| <version>1.0.0</version> | ||
| <properties> | ||
| <bundle.symbolicName>${project.artifactId}</bundle.symbolicName> | ||
| <bundle.version>${project.version}</bundle.version> | ||
| <gateway.version>4.51.0</gateway.version> | ||
| </properties> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.osgi</groupId> | ||
| <artifactId>org.osgi.core</artifactId> | ||
| <version>6.0.0</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.osgi</groupId> | ||
| <artifactId>osgi.cmpn</artifactId> | ||
| <version>6.0.0</version> | ||
| <scope>compile</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.sap.iotservices.gateway</groupId> | ||
| <artifactId>gateway-topology-edge-api-interface</artifactId> | ||
| <version>${gateway.version}</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.sap.iotservices.gateway.extension</groupId> | ||
| <artifactId>edgeApiExtensionInterface</artifactId> | ||
| <version>${bundle.version}</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.sap.iotservices.gateway</groupId> | ||
| <artifactId>netty-server-bundle</artifactId> | ||
| <version>${gateway.version}</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.apache.logging.log4j</groupId> | ||
| <artifactId>log4j-osgi</artifactId> | ||
| <version>2.9.0</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.slf4j</groupId> | ||
| <artifactId>slf4j-api</artifactId> | ||
| <version>1.7.29</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>commons-lang</groupId> | ||
| <artifactId>commons-lang</artifactId> | ||
| <version>2.6</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.fasterxml.jackson.core</groupId> | ||
| <artifactId>jackson-core</artifactId> | ||
| <version>2.9.7</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.fasterxml.jackson.core</groupId> | ||
| <artifactId>jackson-databind</artifactId> | ||
| <version>2.9.7</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>io.swagger.core.v3</groupId> | ||
| <artifactId>swagger-core</artifactId> | ||
| <version>2.0.9</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>io.swagger.core.v3</groupId> | ||
| <artifactId>swagger-annotations</artifactId> | ||
| <version>2.0.9</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>javax.ws.rs</groupId> | ||
| <artifactId>javax.ws.rs-api</artifactId> | ||
| <version>2.0-m10</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| </dependencies> | ||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <version>3.3</version> | ||
| <configuration> | ||
| <source>1.8</source> | ||
| <target>1.8</target> | ||
| </configuration> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-jar-plugin</artifactId> | ||
| <configuration> | ||
| <archive> | ||
| <manifestFile>META-INF/MANIFEST.MF</manifestFile> | ||
| </archive> | ||
| </configuration> | ||
| </plugin> | ||
| <!-- the versions plugin can be used to check for new plugin versions | ||
| like this: mvn versions:Display-plugin-updates --> | ||
| <plugin> | ||
| <groupId>org.apache.felix</groupId> | ||
| <artifactId>maven-bundle-plugin</artifactId> | ||
| <extensions>true</extensions> | ||
| <executions> | ||
| <!-- Configure extra execution of 'manifest' in process-classes | ||
| phase to make sure SCR metadata is generated before unit test runs --> | ||
| <execution> | ||
| <id>scr-metadata</id> | ||
| <goals> | ||
| <goal>manifest</goal> | ||
| </goals> | ||
| <configuration> | ||
| <supportIncrementalBuild>true</supportIncrementalBuild> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| <configuration> | ||
| <exportScr>true</exportScr> | ||
| <manifestLocation>META-INF</manifestLocation> | ||
| <instructions> | ||
| <Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName> | ||
| <Bundle-Version>${bundle.version}</Bundle-Version> | ||
| <!-- Enable processing of OSGI DS component annotations --> | ||
| <_dsannotations>*</_dsannotations> | ||
| <!-- Enable processing of OSGI metatype annotations --> | ||
| <_metatypeannotations>*</_metatypeannotations> | ||
| </instructions> | ||
| </configuration> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </project> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better use a private access