C++ Core: Add base class per sensor/actuator type

Adding base classes for UPM sensors and actuators.

Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
Noel Eck
2017-06-08 13:50:09 -07:00
parent b55501e327
commit 0223cd2b85
184 changed files with 4462 additions and 1099 deletions

View File

@ -24,7 +24,7 @@
*/
import upm_bmp280.*;
import upm_interfaces.*;
import upm_core.*;
public class BME280_Interface_Example
{
@ -35,9 +35,9 @@ public class BME280_Interface_Example
// Instantiate a BME280 instance using default i2c bus and address
BME280 sensor = new BME280();
ITemperatureSensor t_sensor = sensor;
IHumiditySensor h_sensor = sensor;
IPressureSensor p_sensor = sensor;
iTemperatureSensor t_sensor = sensor;
iHumiditySensor h_sensor = sensor;
iPressureSensor p_sensor = sensor;
// For SPI, bus 0, you would pass -1 as the address, and a
// valid pin for CS:
@ -51,15 +51,15 @@ public class BME280_Interface_Example
System.out.println("Calling Interface Functions: ");
System.out.println("Compensation Temperature: "
+ t_sensor.getTemperatureCelsius()
+ t_sensor.TemperatureForSource("temperature")
+ " C / ");
System.out.println("Pressure: "
+ p_sensor.getPressurePa()
+ p_sensor.PressureForSource("pressure")
+ " Pa");
System.out.println("Humidity: "
+ h_sensor.getHumidityRelative()
+ h_sensor.HumidityForSource("humidity")
+ " %RH");
System.out.println();

View File

@ -24,9 +24,9 @@ include(UseJava)
# add_example(SensorFooExample sensorfoo)
#
# # Creates SensorFooExample JAVA target, depends on targets: sensorfoo,
# # and interfaces and will add both upm_sensorfoo.jar and upm_interfaces.jar
# # and core and will add both upm_sensorfoo.jar and upm_core.jar
# # to the javac classpath.
# add_example(SensorFooExample "sensorfoo;interfaces"")
# add_example(SensorFooExample "sensorfoo;core"")
#
function(add_example example_class_name dependency_list)
set(example_file "${example_class_name}.java")
@ -68,7 +68,7 @@ add_example(A110X_Example a110x)
add_example(A110X_intr_Example a110x)
add_example(Ad8232_Example ad8232)
add_example(ADC121C021_Example adc121c021)
add_example(Ads1015_Example "ads1x15;interfaces")
add_example(Ads1015_Example "ads1x15;core")
add_example(Ads1115_Example ads1x15)
add_example(Adxl345_Example adxl345)
add_example(AM2315_Example am2315)
@ -78,13 +78,13 @@ add_example(BH1750_Example bh1750)
add_example(BISS0001_Example biss0001)
add_example(BMA250E_Example bma250e)
add_example(BMC150_Example bmx055)
add_example(BME280_Example "bmp280;interfaces")
add_example(BME280_Example "bmp280;core")
add_example(BMG160_Example bmg160)
add_example(BMI055_Example bmx055)
add_example(BMI160_Example bmi160)
add_example(BMM150_Example bmm150)
add_example(BMP280_Example "bmp280;interfaces")
add_example(BMPX8X_Example "bmpx8x;interfaces")
add_example(BMP280_Example "bmp280;core")
add_example(BMPX8X_Example "bmpx8x;core")
add_example(BMX055_Example bmx055)
add_example(BNO055_Example bno055)
add_example(Button_Example button)
@ -101,7 +101,7 @@ add_example(ECS1030_Example ecs1030)
add_example(EHR_Example ehr)
add_example(Emg_Example emg)
add_example(ENC03R_Example enc03r)
add_example(ES08A_Example "servo;interfaces")
add_example(ES08A_Example "servo;core")
add_example(FlexSensor_Example flex)
add_example(Gp2y0a_Example gp2y0a)
add_example(GroveButton_Example grove)
@ -229,9 +229,9 @@ add_example(YG1006_Example yg1006)
add_example(ZFM20_Example zfm20)
if(SWIG_VERSION VERSION_GREATER 3.0.8)
add_example(BME280_Interface_Example "bmp280;interfaces")
add_example(IMS_Example "ims;interfaces")
add_example(RHUSB_Example "rhusb;interfaces")
add_example(BME280_Interface_Example "bmp280;core")
add_example(IMS_Example "ims;core")
add_example(RHUSB_Example "rhusb;core")
endif()
if (OPENZWAVE_FOUND)

View File

@ -50,4 +50,4 @@ public class ES08A_Example {
System.out.println("Set angle to 180");
// ! [Interesting]
}
}
}

View File

@ -22,8 +22,6 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import upm_ims.IMS;
public class IMS_Example
{
public static void main(String[] args) throws InterruptedException
@ -31,18 +29,18 @@ public class IMS_Example
// ! [Interesting]
// Instantiate a IMS instance using bus 0 and default i2c address
IMS sensor = new IMS((short)0);
upm_ims.IMS sensor = new upm_ims.IMS((short)0);
while (true)
{
System.out.println("Version: "
+ sensor.get_version()
+ upm_ims.javaupm_ims.LibraryVersion()
+ " light: "
+ sensor.get_light()
+ sensor.LightForSource("light")
+ " moisture: "
+ sensor.get_moisture()
+ sensor.MoistureForSource("moisture")
+ " temp: "
+ sensor.get_temperature()
+ sensor.TemperatureForSource("temperature")
+ " C");
Thread.sleep(1000);

View File

@ -0,0 +1,42 @@
/*
* The MIT License (MIT)
*
* Author: Your Full Name <your@email.address>
* Copyright (c) <year> <copyright holder>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import upm_noelstemplightreader.*;
public class NoelsTempLightReaderSample {
public static void main (String args[]) throws InterruptedException {
//! [Interesting]
// Instantiate new sensor instance
upm_noelstemplightreader.NoelsTempLightReader sensor = new upm_noelstemplightreader.NoelsTempLightReader();
while (true) {
//System.out.println("NoelsTempLightReader says: " + sensor.Name());
// Repeate every 2 seconds
Thread.sleep(2000);
}
//! [Interesting]
}
}

View File

@ -39,6 +39,12 @@ public class RHUSB_Example {
// Instantiate an RHUSB instance on defaultDev
upm_rhusb.RHUSB sensor = new upm_rhusb.RHUSB(defaultDev);
// Print out info from the sensor core
System.out.println("UPM Version:" + System.lineSeparator()
+ upm_rhusb.javaupm_rhusb.LibraryVersion() + System.lineSeparator());
System.out.println("JSON Definition:" + System.lineSeparator()
+ sensor.JsonDefinition() + System.lineSeparator());
// output the firmware ID
System.out.println("Firmware ID: " + sensor.getFirmwareID());