Commit 66507be6 authored by Micha Müller's avatar Micha Müller
Browse files

Tiny fixes to plugin generatorScripts; Unify formatting: replace tabs with whitespaces

parent 9f2f7707
......@@ -32,41 +32,41 @@ cat << EOF > ${PLUGIN_NAME}Configurator.cpp
#include "${PLUGIN_NAME}Configurator.h"
${PLUGIN_NAME}Configurator::${PLUGIN_NAME}Configurator() {
/*
* TODO
* If you want sensor or group to be named differently in the config file, you can change it here
*/
/*
* TODO
* If you want sensor or group to be named differently in the config file, you can change it here
*/
EOF
if [ "$enableEntities" = true ]
then
echo " _entityName = \"${ENTITY_NAME_LWC}\";" >> ${PLUGIN_NAME}Configurator.cpp
echo " _entityName = \"${ENTITY_NAME_LWC}\";" >> ${PLUGIN_NAME}Configurator.cpp
fi
cat << EOF >> ${PLUGIN_NAME}Configurator.cpp
_groupName = "group";
_baseName = "sensor";
_groupName = "group";
_baseName = "sensor";
}
${PLUGIN_NAME}Configurator::~${PLUGIN_NAME}Configurator() {}
void ${PLUGIN_NAME}Configurator::sensorBase(${PLUGIN_NAME}SensorBase& s, CFG_VAL config) {
ADD {
/*
* TODO
* Add ATTRIBUTE macros for sensorBase attributes
*/
//ATTRIBUTE("attributeName", attributeSetter);
}
ADD {
/*
* TODO
* Add ATTRIBUTE macros for sensorBase attributes
*/
//ATTRIBUTE("attributeName", attributeSetter);
}
}
void ${PLUGIN_NAME}Configurator::sensorGroup(${PLUGIN_NAME}SensorGroup& s, CFG_VAL config) {
ADD {
/*
* TODO
* Add ATTRIBUTE macros for sensorGroup attributes
*/
}
ADD {
/*
* TODO
* Add ATTRIBUTE macros for sensorGroup attributes
*/
}
}
EOF
......@@ -75,12 +75,12 @@ if [ "$enableEntities" = true ]
then
cat << EOF >> ${PLUGIN_NAME}Configurator.cpp
void ${PLUGIN_NAME}Configurator::sensorEntity(${PLUGIN_NAME}${ENTITY_NAME}& s, CFG_VAL config) {
ADD {
/*
* TODO
* Add ATTRIBUTE macros for ${ENTITY_NAME} attributes
*/
}
ADD {
/*
* TODO
* Add ATTRIBUTE macros for ${ENTITY_NAME} attributes
*/
}
}
EOF
fi
......@@ -88,11 +88,11 @@ fi
cat << EOF >> ${PLUGIN_NAME}Configurator.cpp
void ${PLUGIN_NAME}Configurator::printConfiguratorConfig(LOG_LEVEL ll) {
/*
* TODO
* Log attributes here for debug reasons or delete this method if there are
* not attributes to log.
*/
LOG_VAR(ll) << " NumSpacesAsIndention: " << 2;
/*
* TODO
* Log attributes here for debug reasons or delete this method if there are
* not attributes to log.
*/
LOG_VAR(ll) << " NumSpacesAsIndention: " << 2;
}
EOF
......@@ -60,19 +60,19 @@ fi
cat << EOF >> ${PLUGIN_NAME}Configurator.h
public:
${PLUGIN_NAME}Configurator();
virtual ~${PLUGIN_NAME}Configurator();
${PLUGIN_NAME}Configurator();
virtual ~${PLUGIN_NAME}Configurator();
protected:
/* Overwritten from ConfiguratorTemplate */
void sensorBase(${PLUGIN_NAME}SensorBase& s, CFG_VAL config) override;
void sensorGroup(${PLUGIN_NAME}SensorGroup& s, CFG_VAL config) override;
/* Overwritten from ConfiguratorTemplate */
void sensorBase(${PLUGIN_NAME}SensorBase& s, CFG_VAL config) override;
void sensorGroup(${PLUGIN_NAME}SensorGroup& s, CFG_VAL config) override;
EOF
if [ "$enableEntities" = true ]
then
cat << EOF >> ${PLUGIN_NAME}Configurator.h
void sensorEntity(${PLUGIN_NAME}${ENTITY_NAME}& s, CFG_VAL config) override;
void sensorEntity(${PLUGIN_NAME}${ENTITY_NAME}& s, CFG_VAL config) override;
EOF
fi
......@@ -80,17 +80,17 @@ cat << EOF >> ${PLUGIN_NAME}Configurator.h
//TODO implement if required
//void global(CFG_VAL config) override;
//void derivedSetGlobalSettings(const pluginSettings_t& pluginSettings) override;
void printConfiguratorConfig(LOG_LEVEL ll) final override;
//void derivedSetGlobalSettings(const pluginSettings_t& pluginSettings) override;
void printConfiguratorConfig(LOG_LEVEL ll) final override;
};
extern "C" ConfiguratorInterface* create() {
return new ${PLUGIN_NAME}Configurator;
return new ${PLUGIN_NAME}Configurator;
}
extern "C" void destroy(ConfiguratorInterface* c) {
delete c;
delete c;
}
#endif /* ${PLUGIN_NAME_UPC}_${PLUGIN_NAME_UPC}CONFIGURATOR_H_ */
......
......@@ -4,7 +4,7 @@
cat << EOF > ${PLUGIN_NAME}${ENTITY_NAME}.cpp
//================================================================================
// Name : ${PLUGIN_NAME}${ENTITY_NAME}.h
// Name : ${PLUGIN_NAME}${ENTITY_NAME}.cpp
// Author : ${AUTHOR}
// Copyright :
// Description : Source file for ${PLUGIN_NAME}${ENTITY_NAME} class.
......@@ -34,54 +34,54 @@ cat << EOF > ${PLUGIN_NAME}${ENTITY_NAME}.cpp
${PLUGIN_NAME}${ENTITY_NAME}::${PLUGIN_NAME}${ENTITY_NAME}(const std::string& name) :
EntityInterface(name) {
/*
* TODO
* Construct attributes
* TODO
* Construct attributes
*/
}
${PLUGIN_NAME}${ENTITY_NAME}::${PLUGIN_NAME}${ENTITY_NAME}(const ${PLUGIN_NAME}${ENTITY_NAME}& other) :
EntityInterface(other) {
/*
* TODO
* Copy construct attributes
*/
* TODO
* Copy construct attributes
*/
}
${PLUGIN_NAME}${ENTITY_NAME}::~${PLUGIN_NAME}${ENTITY_NAME}() {
/*
* TODO
* Tear down attributes
* TODO
* Tear down attributes
*/
}
${PLUGIN_NAME}${ENTITY_NAME}& ${PLUGIN_NAME}${ENTITY_NAME}::operator=(const ${PLUGIN_NAME}${ENTITY_NAME}& other) {
EntityInterface::operator=(other);
/*
* TODO
* Implement assignment operator here
*/
* TODO
* Implement assignment operator here
*/
return *this;
}
/*
* TODO
* Implement own methods
* TODO
* Implement own methods
*/
void ${PLUGIN_NAME}${ENTITY_NAME}::execOnInit() {
/*
* TODO
* Implement logic to initialize the entity here or remove method if not required.
* Will be called exactly once at startup.
*/
/*
* TODO
* Implement logic to initialize the entity here or remove method if not required.
* Will be called exactly once at startup.
*/
}
void ${PLUGIN_NAME}${ENTITY_NAME}::printEntityConfig(LOG_LEVEL ll) {
/*
* TODO
* Log attributes here for debug reasons
*/
* TODO
* Log attributes here for debug reasons
*/
LOG_VAR(ll) << eInd << "Att: " << 3;
}
EOF
......@@ -48,9 +48,9 @@ public:
${PLUGIN_NAME}${ENTITY_NAME}& operator=(const ${PLUGIN_NAME}${ENTITY_NAME}& other);
/*
* TODO
* Add methods the entity provides to the SensorGroups.
* Add getter/setter for the attributes as required.
* TODO
* Add methods the entity provides to the SensorGroups.
* Add getter/setter for the attributes as required.
*/
void execOnInit() final override;
......@@ -59,8 +59,8 @@ public:
private:
/*
* TODO
* Add attributes required for your entity
* TODO
* Add attributes required for your entity
*/
};
......
......@@ -44,70 +44,75 @@ EOF
if [ "$enableEntities" = true ]
then
echo "" >> ${PLUGIN_NAME}SensorBase.h
echo "#include \"${PLUGIN_NAME}${ENTITY_NAME}.h\"" >> ${PLUGIN_NAME}SensorBase.h
echo "" >> ${PLUGIN_NAME}SensorBase.h
echo "#include \"${PLUGIN_NAME}${ENTITY_NAME}.h\"" >> ${PLUGIN_NAME}SensorBase.h
fi
cat << EOF >> ${PLUGIN_NAME}SensorBase.h
/*
* TODO
* Add plugin specific includes
* TODO
* Add plugin specific includes
*/
/**
* @brief SensorBase specialization for this plugin.
*
* @ingroup ${PLUGIN_NAME_LWC}
*/
class ${PLUGIN_NAME}SensorBase : public SensorBase {
public:
${PLUGIN_NAME}SensorBase(const std::string& name) :
SensorBase(name) {
/*
* TODO
* Initialize plugin specific attributes
*/
}
${PLUGIN_NAME}SensorBase(const ${PLUGIN_NAME}SensorBase& other) :
SensorBase(other) {
/*
* TODO
* Copy construct plugin specific attributes
*/
}
virtual ~${PLUGIN_NAME}SensorBase() {
/*
* TODO
* If necessary, deconstruct plugin specific attributes
*/
}
${PLUGIN_NAME}SensorBase(const std::string& name) :
SensorBase(name) {
/*
* TODO
* Initialize plugin specific attributes
*/
}
${PLUGIN_NAME}SensorBase(const ${PLUGIN_NAME}SensorBase& other) :
SensorBase(other) {
/*
* TODO
* Copy construct plugin specific attributes
*/
}
virtual ~${PLUGIN_NAME}SensorBase() {
/*
* TODO
* If necessary, deconstruct plugin specific attributes
*/
}
${PLUGIN_NAME}SensorBase& operator=(const ${PLUGIN_NAME}SensorBase& other) {
SensorBase::operator=(other);
/*
* TODO
* Implement assignment operator for plugin specific attributes
* TODO
* Implement assignment operator for plugin specific attributes
*/
return *this;
return *this;
}
/*
* TODO
* Getters and Setters for plugin specific attributes
*/
/*
* TODO
* Getters and Setters for plugin specific attributes
*/
void printConfig(LOG_LEVEL ll, LOGGER& lg) {
/*
* TODO
* Log attributes here for debug reasons
* TODO
* Log attributes here for debug reasons
*/
LOG_VAR(ll) << " NumSpacesAsIndention: " << 5;
}
protected:
/*
* TODO
* Add plugin specific attributes here
*/
/*
* TODO
* Add plugin specific attributes here
*/
};
......
......@@ -34,107 +34,107 @@ cat << EOF > ${PLUGIN_NAME}SensorGroup.cpp
#include "timestamp.h"
${PLUGIN_NAME}SensorGroup::${PLUGIN_NAME}SensorGroup(const std::string& name) :
SensorGroupTemplate(name) {
/*
* TODO
* Construct attributes
*/
SensorGroupTemplate(name) {
/*
* TODO
* Construct attributes
*/
}
${PLUGIN_NAME}SensorGroup::${PLUGIN_NAME}SensorGroup(const ${PLUGIN_NAME}SensorGroup& other) :
SensorGroupTemplate(other) {
/*
* TODO
* Copy construct attributes
* TODO
* Copy construct attributes
*/
}
${PLUGIN_NAME}SensorGroup::~${PLUGIN_NAME}SensorGroup() {
/*
* TODO
* Tear down attributes
*/
/*
* TODO
* Tear down attributes
*/
}
${PLUGIN_NAME}SensorGroup& ${PLUGIN_NAME}SensorGroup::operator=(const ${PLUGIN_NAME}SensorGroup& other) {
SensorGroupTemplate::operator=(other);
SensorGroupTemplate::operator=(other);
/*
* TODO
* Implement assignment operator
* TODO
* Implement assignment operator
*/
return *this;
return *this;
}
void ${PLUGIN_NAME}SensorGroup::execOnInit() {
/*
* TODO
* Implement one time initialization logic for this group here
* (e.g. allocate memory for buffer) or remove this method if not
* required.
*/
/*
* TODO
* Implement one time initialization logic for this group here
* (e.g. allocate memory for buffer) or remove this method if not
* required.
*/
}
bool ${PLUGIN_NAME}SensorGroup::execOnStart() {
/*
* TODO
* Implement logic before the group starts polling here
* (e.g. open a file descriptor) or remove this method if not required.
*/
return true;
/*
* TODO
* Implement logic before the group starts polling here
* (e.g. open a file descriptor) or remove this method if not required.
*/
return true;
}
void ${PLUGIN_NAME}SensorGroup::execOnStop() {
/*
* TODO
* Implement logic when the group stops polling here
* (e.g. close a file descriptor) or remove this method if not required.
*/
void ${PLUGIN_NAME}SensorGroup::execOnStop() {
/*
* TODO
* Implement logic when the group stops polling here
* (e.g. close a file descriptor) or remove this method if not required.
*/
}
void ${PLUGIN_NAME}SensorGroup::read() {
reading_t reading;
reading.timestamp = getTimestamp();
try {
for(auto s : _sensors) {
reading.value = /*
* TODO
* Read a value for every sensor affiliated with this group and store
* it with the appropriate sensor.
reading_t reading;
reading.timestamp = getTimestamp();
try {
for(auto s : _sensors) {
reading.value = /*
* TODO
* Read a value for every sensor affiliated with this group and store
* it with the appropriate sensor.
EOF
if [ "$enableEntities" = true ]
then
echo " * Make use of _${ENTITY_NAME_LWC} as required." >> ${PLUGIN_NAME}SensorGroup.cpp
echo " * Make use of _${ENTITY_NAME_LWC} as required." >> ${PLUGIN_NAME}SensorGroup.cpp
fi
cat << EOF >> ${PLUGIN_NAME}SensorGroup.cpp
*/ 0;
s->storeReading(reading);
*/ 0;
s->storeReading(reading);
#ifdef DEBUG
LOG(debug) << _groupName << "::" << s->getName() << " raw reading: \"" << reading.value << "\"";
LOG(debug) << _groupName << "::" << s->getName() << " raw reading: \"" << reading.value << "\"";
#endif
}
} catch (const std::exception& e) {
LOG(error) << "Sensorgroup" << _groupName << " could not read value: " << e.what();
}
}
} catch (const std::exception& e) {
LOG(error) << "Sensorgroup" << _groupName << " could not read value: " << e.what();
}
}
void ${PLUGIN_NAME}SensorGroup::printGroupConfig(LOG_LEVEL ll) {
/*
* TODO
* Log attributes here for debug reasons
/*
* TODO
* Log attributes here for debug reasons
EOF
if [ "$enableEntities" = true ]
then
echo " * Printing the name of _${ENTITY_NAME_LWC} may be a good idea." >> ${PLUGIN_NAME}SensorGroup.cpp
echo " * Printing the name of associated _entity may be a good idea." >> ${PLUGIN_NAME}SensorGroup.cpp
fi
cat << EOF >> ${PLUGIN_NAME}SensorGroup.cpp
*/
LOG_VAR(ll) << " NumSpacesAsIndention: " << 12;
*/
LOG_VAR(ll) << " NumSpacesAsIndention: " << 12;
}
EOF
......@@ -45,36 +45,36 @@ EOF
if [ "$enableEntities" = true ]
then
echo "class ${PLUGIN_NAME}SensorGroup : public SensorGroupTemplate<${PLUGIN_NAME}SensorBase> {" >> ${PLUGIN_NAME}SensorGroup.h
else
echo "class ${PLUGIN_NAME}SensorGroup : public SensorGroupTemplate<${PLUGIN_NAME}SensorBase, ${PLUGIN_NAME}${ENTITY_NAME}> {" >> ${PLUGIN_NAME}SensorGroup.h
else
echo "class ${PLUGIN_NAME}SensorGroup : public SensorGroupTemplate<${PLUGIN_NAME}SensorBase> {" >> ${PLUGIN_NAME}SensorGroup.h
fi
cat << EOF >> ${PLUGIN_NAME}SensorGroup.h
public:
${PLUGIN_NAME}SensorGroup(const std::string& name);
${PLUGIN_NAME}SensorGroup(const ${PLUGIN_NAME}SensorGroup& other);
virtual ~${PLUGIN_NAME}SensorGroup();
${PLUGIN_NAME}SensorGroup& operator=(const ${PLUGIN_NAME}SensorGroup& other);
${PLUGIN_NAME}SensorGroup(const std::string& name);
${PLUGIN_NAME}SensorGroup(const ${PLUGIN_NAME}SensorGroup& other);
virtual ~${PLUGIN_NAME}SensorGroup();
${PLUGIN_NAME}SensorGroup& operator=(const ${PLUGIN_NAME}SensorGroup& other);
void execOnInit() final override;
bool execOnStart() final override;
void execOnStop() final override;
void execOnInit() final override;
bool execOnStart() final override;
void execOnStop() final override;
/*
* TODO
* Add getter and setters for group attributes if required
*/
void printGroupConfig(LOG_LEVEL ll) final override;
/*
* TODO
* Add getter and setters for group attributes if required
*/
void printGroupConfig(LOG_LEVEL ll) final override;
private:
void read() final override;
void read() final override;
/*
* TODO
* Add group internal attributes
*/
/*
* TODO
* Add group internal attributes
*/
};
#endif /* ${PLUGIN_NAME_UPC}_${PLUGIN_NAME_UPC}SENSORGROUP_H_ */
......
......@@ -6,9 +6,9 @@ cat << EOF > ${PLUGIN_NAME_LWC}.conf
;comments in config files are indicated by a semicolon
global {
mqttPrefix /FF112233445566778899AABB
;add here other global attributes for your plugin
mqttPrefix /${PLUGIN_NAME_LWC}Prefix
;add here other global attributes for your plugin
}
EOF
......@@ -17,75 +17,75 @@ if [ "$enableEntities" = true ]
then
cat << EOF >> ${PLUGIN_NAME_LWC}.conf
template_group def1 {
;define template groups by appending "template_"