mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
interfaces: Added initial set of sensor/actuator interfaces
Signed-off-by: Henry Bruce <henry.bruce@intel.com> Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
This commit is contained in:
parent
1aa445b74e
commit
031ed7bf95
10
src/upm/CMakeLists.txt
Normal file
10
src/upm/CMakeLists.txt
Normal file
@ -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()
|
||||
|
||||
|
50
src/upm/iADC.h
Normal file
50
src/upm/iADC.h
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Author: Henry Bruce <henry.bruce@intel.com>
|
||||
* 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 <stdint.h>
|
||||
#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() {}
|
||||
};
|
||||
|
||||
}
|
||||
|
44
src/upm/iCO2Sensor.h
Normal file
44
src/upm/iCO2Sensor.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Author: Henry Bruce <henry.bruce@intel.com>
|
||||
* 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() {}
|
||||
};
|
||||
|
||||
}
|
||||
|
43
src/upm/iHumiditySensor.h
Normal file
43
src/upm/iHumiditySensor.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Author: Henry Bruce <henry.bruce@intel.com>
|
||||
* 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() {}
|
||||
};
|
||||
|
||||
}
|
||||
|
94
src/upm/iLightController.h
Normal file
94
src/upm/iLightController.h
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Author: Henry Bruce <henry.bruce@intel.com>
|
||||
* 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() {}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
67
src/upm/iLightSensor.h
Normal file
67
src/upm/iLightSensor.h
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Author: Henry Bruce <henry.bruce@intel.com>
|
||||
* 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 <stdint.h>
|
||||
#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() {}
|
||||
};
|
||||
}
|
||||
|
62
src/upm/iModuleStatus.h
Normal file
62
src/upm/iModuleStatus.h
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Author: Henry Bruce <henry.bruce@intel.com>
|
||||
* 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 <stdexcept>
|
||||
|
||||
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() {}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
47
src/upm/iPressureSensor.h
Normal file
47
src/upm/iPressureSensor.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Author: Henry Bruce <henry.bruce@intel.com>
|
||||
* 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 <stdint.h>
|
||||
#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() {}
|
||||
};
|
||||
|
||||
}
|
||||
|
43
src/upm/iTemperatureSensor.h
Normal file
43
src/upm/iTemperatureSensor.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Author: Henry Bruce <henry.bruce@intel.com>
|
||||
* 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() {}
|
||||
};
|
||||
|
||||
}
|
||||
|
1
src/upm/interfaces.cxx
Normal file
1
src/upm/interfaces.cxx
Normal file
@ -0,0 +1 @@
|
||||
#include "upm/iLightSensor.h"
|
15
src/upm/javaupm_interfaces.i
Normal file
15
src/upm/javaupm_interfaces.i
Normal file
@ -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"
|
15
src/upm/javaupm_light_sensor.i
Normal file
15
src/upm/javaupm_light_sensor.i
Normal file
@ -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"
|
Loading…
x
Reference in New Issue
Block a user