diff --git a/src/upm/CMakeLists.txt b/src/upm/CMakeLists.txt new file mode 100644 index 00000000..e275021f --- /dev/null +++ b/src/upm/CMakeLists.txt @@ -0,0 +1,10 @@ +install (DIRECTORY . DESTINATION include/upm FILES_MATCHING PATTERN "*.h") +if (BUILDSWIGJAVA AND BUILDSWIG) + set (libname "interfaces") + set (libdescription "upm interfaces") + set (module_src ${libname}.cxx) +# set (module_h ${libname}.h) + upm_module_init() +endif() + + diff --git a/src/upm/iADC.h b/src/upm/iADC.h new file mode 100644 index 00000000..3ff05d86 --- /dev/null +++ b/src/upm/iADC.h @@ -0,0 +1,50 @@ +/* + * Author: Henry Bruce + * Copyright (c) 2015 Intel Corporation. + * + * 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. + */ + + +#pragma once +#include +#include "mraa/common.h" +#include "iModuleStatus.h" + + +namespace upm +{ +/** + * @brief Interface for ADC Sensors + */ + + class IADC : public IModuleStatus + { + public: + virtual float getReferenceVoltage() = 0; + virtual int getResolutionInBits() = 0; + virtual int getNumInputs() = 0; + virtual int getValue(int input) = 0; + virtual float getVoltage(int input) = 0; + virtual ~IADC() {} + }; + +} + diff --git a/src/upm/iCO2Sensor.h b/src/upm/iCO2Sensor.h new file mode 100644 index 00000000..e8e789ca --- /dev/null +++ b/src/upm/iCO2Sensor.h @@ -0,0 +1,44 @@ +/* + * Author: Henry Bruce + * Copyright (c) 2015 Intel Corporation. + * + * 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. + */ + + +#pragma once +#include "iModuleStatus.h" + + +namespace upm +{ +/** + * @brief Interface for CO Sensor + */ + + class ICO2Sensor : public IModuleStatus + { + public: + virtual uint16_t getPpm() = 0; + virtual ~ICO2Sensor() {} + }; + +} + diff --git a/src/upm/iHumiditySensor.h b/src/upm/iHumiditySensor.h new file mode 100644 index 00000000..bb24f336 --- /dev/null +++ b/src/upm/iHumiditySensor.h @@ -0,0 +1,43 @@ +/* + * Author: Henry Bruce + * Copyright (c) 2015 Intel Corporation. + * + * 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. + */ + +#pragma once +#include "iModuleStatus.h" + +namespace upm +{ +/** + * @brief Interface for Humidity Sensors + */ + + class IHumiditySensor : public IModuleStatus + { + public: + virtual uint16_t getHumidityRaw () = 0; + virtual int getHumidityRelative () = 0; + virtual ~IHumiditySensor() {} + }; + +} + diff --git a/src/upm/iLightController.h b/src/upm/iLightController.h new file mode 100644 index 00000000..d0b8dee3 --- /dev/null +++ b/src/upm/iLightController.h @@ -0,0 +1,94 @@ +/* + * Author: Henry Bruce + * Copyright (c) 2014 Intel Corporation. + * + * 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. + */ + +#pragma once + +#include "iModuleStatus.h" + +namespace upm +{ +/** + * @brief ILightController Interface for Light Controllers + */ + +/** + * + * @brief Interface for Light Controllers + + * This interface is used to represent light controllers + + * @snippet light-controllers.cxx Interesting + */ + + class ILightController : public IModuleStatus + { + public: + /** + * Turn on power + * + * @throws std::runtime_error + */ + virtual void setPowerOn() = 0; + + /** + * Turn off power + * + * @throws std::runtime_error + */ + virtual void setPowerOff() = 0; + + /** + * Get power state + * + * @return true if powered, false otherwise + * + * @throws std::runtime_error + */ + virtual bool isPowered() = 0; + + /** + * Set brightness + * + * @param brightness as percentage + * + * @throws std::runtime_error + */ + virtual void setBrightness(int percent) = 0; + + /** + * Get brightness + * + * @return brightness as percentage + * + * @throws std::runtime_error + */ + virtual int getBrightness() = 0; + + virtual ~ILightController() {} + }; + +} + + + diff --git a/src/upm/iLightSensor.h b/src/upm/iLightSensor.h new file mode 100644 index 00000000..d8eaee29 --- /dev/null +++ b/src/upm/iLightSensor.h @@ -0,0 +1,67 @@ +/* + * Author: Henry Bruce + * Copyright (c) 2015 Intel Corporation. + * + * 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. + */ + + +#pragma once + +#include +#include "iModuleStatus.h" + +namespace upm +{ +/** + * @brief ILightSensor Interface for Light Sensors + */ + +/** + * + * @brief Interface for Light Sensors + + * This interface is used to represent light sensors + + * @snippet light-sensor.cxx Interesting + */ + + class ILightSensor : public IModuleStatus + { + public: + /** + * Get visible illuminance raw value. + * + * @return uint16_t visible illuminance raw value + */ + virtual uint16_t getVisibleRaw() = 0; + + /** + * Get visible illuminance in Lux. + * + * @return double visible illuminance in Lux + */ + virtual double getVisibleLux() = 0; + + + virtual ~ILightSensor() {} + }; +} + diff --git a/src/upm/iModuleStatus.h b/src/upm/iModuleStatus.h new file mode 100644 index 00000000..2fbe8d33 --- /dev/null +++ b/src/upm/iModuleStatus.h @@ -0,0 +1,62 @@ +/* + * Author: Henry Bruce + * Copyright (c) 2014 Intel Corporation. + * + * 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. + */ + +#pragma once + +#include + +namespace upm +{ +/** + * @brief Interface for Module Status. Sensor and Actuactor Interfaces Derive from this Interface. + */ + +#define UPM_THROW(msg) throw std::runtime_error(std::string(__FUNCTION__) + ": " + (msg)) + +class IModuleStatus +{ +public: + /** + * Determines if sensor module is configured correctly + * e.g. if it uses i2c communication can it configure registers + * for correct operation. + * + * @return true if correctly configured, false it not + */ + virtual bool isConfigured() = 0; + + /** + * Returns name of module. This is the string in library name after libupm_ + + * @return name of module + */ + virtual const char* getModuleName() = 0; + + virtual ~IModuleStatus() {} +}; + +} + + + diff --git a/src/upm/iPressureSensor.h b/src/upm/iPressureSensor.h new file mode 100644 index 00000000..cdb52424 --- /dev/null +++ b/src/upm/iPressureSensor.h @@ -0,0 +1,47 @@ +/* + * Author: Henry Bruce + * Copyright (c) 2014 Intel Corporation. + * + * 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. + */ + + +#pragma once + +#include +#include "mraa/common.h" +#include "iModuleStatus.h" + +namespace upm +{ +/** + * @brief Interface for Pressue Sensors + */ + + class IPressureSensor : public IModuleStatus + { + public: + virtual uint32_t getPressureRaw() = 0; + virtual int getPressurePa() = 0; + virtual ~IPressureSensor() {} + }; + +} + diff --git a/src/upm/iTemperatureSensor.h b/src/upm/iTemperatureSensor.h new file mode 100644 index 00000000..3024f1f6 --- /dev/null +++ b/src/upm/iTemperatureSensor.h @@ -0,0 +1,43 @@ +/* + * Author: Henry Bruce + * Copyright (c) 2015 Intel Corporation. + * + * 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. + */ + +#pragma once +#include "iModuleStatus.h" + +namespace upm +{ +/** + * @brief Interface for Temperature Sensors + */ + + class ITemperatureSensor : public IModuleStatus + { + public: + virtual uint16_t getTemperatureRaw () = 0; + virtual int getTemperatureCelcius () = 0; + virtual ~ITemperatureSensor() {} + }; + +} + diff --git a/src/upm/interfaces.cxx b/src/upm/interfaces.cxx new file mode 100644 index 00000000..9a79a68c --- /dev/null +++ b/src/upm/interfaces.cxx @@ -0,0 +1 @@ +#include "upm/iLightSensor.h" diff --git a/src/upm/javaupm_interfaces.i b/src/upm/javaupm_interfaces.i new file mode 100644 index 00000000..51daa1c8 --- /dev/null +++ b/src/upm/javaupm_interfaces.i @@ -0,0 +1,15 @@ +%module(directors="1") javaupm_interfaces + +%feature("director") IModuleStatus; +%feature("director") ILightSensor; +%feature("director") ILightController; + + +%{ + #include "../upm/iLightSensor.h" + #include "../upm/iLightController.h" +%} + +%include "iModuleStatus.h" +%include "iLightSensor.h" +%include "iLightController.h" diff --git a/src/upm/javaupm_light_sensor.i b/src/upm/javaupm_light_sensor.i new file mode 100644 index 00000000..adf5f12a --- /dev/null +++ b/src/upm/javaupm_light_sensor.i @@ -0,0 +1,15 @@ +%module(directors="1") javaupm_light_sensor + +%{ + #include "iLightSensor.h" +%} + +/* +%include "../upm/iModuleStatus.h" +*/ +%include "iLightSensor.h" + +%feature("director") IModuleStatus; +%feature("director") ILightSensor; + +%include "iLightSensor.h"