Skip to content

edge-ml/java

Repository files navigation

Java

Test and Deploy Maven Central

Java library for https://github.com/edge-ml. Can be used to upload datasets as whole or incrementally. Written in Java. Can be used in Android projects.

How to install

The library can be found in Maven Central.

Gradle

  1. Add mavenCentral to you repositories if it is not alreaedy there
repositories {
  mavenCentral()
}
  1. Import the library
dependencies {
  implementation 'edu.teco.explorer:ExplorerJava:${VERSION}
}

Maven

Include the library as a dependency in pom.xml

<dependencies>
  <dependency>
    <groupId>edu.teco.explorer</groupId>
    <artifactId>ExplorerJava</artifactId>
    <version>${VERSION}</version>
  </dependency>
</dependencies>

How to use

Upload datasets as a whole

Recorder recorder = new Recorder("explorerBackendUrl", "deviceApiKey");
boolean res = recorder.sendDataset(JSONObject); // Dataset as JSONObject

Upload datasets in increments with custom timestamps

Recorder recorder = new Recorder("explorerBackendUrl", "deviceApiKey");
try {
  IncrementalRecorder incRecorder = recorder.getIncrementalDataset("datasetName", false); // false to use custom timestamps

  // time should be a unix timestamp
  incRecorder.addDataPoint(1595506316000L, "accX", 123);

  // This will throw an UnsupportedOperationException because no timestamp was provided
  incRecorder.addDataPoint("accX", 124);

  // Tells the libarary that all data has been recorded
  // Uploads all remaining datapoints to the server
  incRecorder.onComplete();
}
} catch (Exception e) {
    e.printStackTrace();
}

Upload datasets in increments with timestamps from the device

Recorder recorder = new Recorder("explorerBackendUrl", "deviceApiKey");
try {
  IncrementalRecorder incRecorder = recorder.getIncrementalDataset("datasetName", true); // true to use deviceTime


  incRecorder.addDataPoint("accX", 123);

  // This will throw an UnsupportedOperationException because a timestamp was provided
  incRecorder.addDataPoint(1595506316000L, "accX", 123);

  // Wait until all values have been send
  incRecorder.onComplete();
} catch (Exception e) {
    e.printStackTrace();
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages