Skip to content

Commit

Permalink
Merged dev
Browse files Browse the repository at this point in the history
  • Loading branch information
hfedcba committed Jul 15, 2019
2 parents 9b432da + a99a51a commit 6e1ddeb
Show file tree
Hide file tree
Showing 140 changed files with 4,936 additions and 623 deletions.
24 changes: 20 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ set(SOURCE_FILES
basic-logic/and/Factory.h
basic-logic/and/MyNode.cpp
basic-logic/and/MyNode.h
basic-logic/change/Factory.cpp
basic-logic/change/Factory.h
basic-logic/change/MyNode.cpp
basic-logic/change/MyNode.h
basic-logic/fallingedge/Factory.cpp
basic-logic/fallingedge/Factory.h
basic-logic/fallingedge/MyNode.cpp
Expand All @@ -36,10 +40,18 @@ set(SOURCE_FILES
basic-logic/switch/Factory.h
basic-logic/switch/MyNode.cpp
basic-logic/switch/MyNode.h
basic-logic/variable-switch/Factory.cpp
basic-logic/variable-switch/Factory.h
basic-logic/variable-switch/MyNode.cpp
basic-logic/variable-switch/MyNode.h
debug/Factory.cpp
debug/Factory.h
debug/MyNode.cpp
debug/MyNode.h
exec/Factory.cpp
exec/Factory.h
exec/Exec.cpp
exec/Exec.h
http/http-in/Factory.cpp
http/http-in/Factory.h
http/http-in/MyNode.cpp
Expand Down Expand Up @@ -128,10 +140,10 @@ set(SOURCE_FILES
pulsecounter/Factory.h
pulsecounter/MyNode.cpp
pulsecounter/MyNode.h
runscript/Factory.cpp
runscript/Factory.h
runscript/RunScript.cpp
runscript/RunScript.h
python/Factory.cpp
python/Factory.h
python/Python.cpp
python/Python.h
serial/serial-port/Factory.cpp
serial/serial-port/Factory.h
serial/serial-port/MyNode.cpp
Expand Down Expand Up @@ -177,6 +189,10 @@ set(SOURCE_FILES
timers/on-delay/Factory.h
timers/on-delay/MyNode.cpp
timers/on-delay/MyNode.h
timers/rate-limiter/Factory.cpp
timers/rate-limiter/Factory.h
timers/rate-limiter/MyNode.cpp
timers/rate-limiter/MyNode.h
timers/slow-pwm/Factory.cpp
timers/slow-pwm/Factory.h
timers/slow-pwm/MyNode.cpp
Expand Down
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
AUTOMAKE_OPTIONS = foreign
ACLOCAL_AMFLAGS = -I m4 -I cfg
SUBDIRS = average basic-logic comment debug function gpio http influxdb light link modbus mqtt notification parsers passthrough ping pulsecounter presence-light press-pattern runscript serial synchronous storage template timers tls-config tls-server-config variable
SUBDIRS = average basic-logic comment debug exec function gpio http influxdb light link modbus mqtt notification parsers passthrough ping pulsecounter presence-light press-pattern python serial synchronous storage template timers tls-config tls-server-config variable
32 changes: 18 additions & 14 deletions average/MyNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,21 +155,25 @@ void MyNode::worker()
}
if(_stopThread) break;

double average = 0.0;
if(!_values.empty())
{
double average = 0.0;

{
std::lock_guard<std::mutex> valuesGuard(_valuesMutex);
for(auto value : _values)
{
average += value;
}
if(!_values.empty()) average /= _values.size();
_values.clear();
}

Flows::PVariable message = std::make_shared<Flows::Variable>(Flows::VariableType::tStruct);
message->structValue->emplace("payload", std::make_shared<Flows::Variable>(_inputIsDouble ? average : std::lround(average)));
output(0, message);
}

{
std::lock_guard<std::mutex> valuesGuard(_valuesMutex);
for(auto value : _values)
{
average += value;
}
if(!_values.empty()) average /= _values.size();
_values.clear();
}

Flows::PVariable message = std::make_shared<Flows::Variable>(Flows::VariableType::tStruct);
message->structValue->emplace("payload", std::make_shared<Flows::Variable>(_inputIsDouble ? average : std::lround(average)));
output(0, message);
int64_t diff = Flows::HelperFunctions::getTime() - startTime;
if(diff <= _interval) sleepingTime = _interval;
else sleepingTime = _interval - (diff - _interval);
Expand Down
3 changes: 2 additions & 1 deletion average/average.hni
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
{
"name": "average",
"readableName": "average",
"version": "0.0.1",
"version": "1.0.0",
"coreNode": true,
"maxThreadCount": 1
}
</script>
Expand Down
14 changes: 11 additions & 3 deletions basic-logic/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ LIBS += -Wl,-Bdynamic -lhomegear-node

libdir = $(localstatedir)/lib/homegear/node-blue/nodes/basic-logic

lib_LTLIBRARIES = and.la fallingedge.la not.la or.la risingedge.la srflipflop.la switch.la
lib_LTLIBRARIES = and.la change.la fallingedge.la not.la or.la risingedge.la srflipflop.la switch.la variable-switch.la

and_la_SOURCES = and/Factory.cpp and/MyNode.cpp
and_la_LDFLAGS =-module -avoid-version -shared

change_la_SOURCES = change/Factory.cpp change/MyNode.cpp
change_la_LDFLAGS =-module -avoid-version -shared

fallingedge_la_SOURCES = fallingedge/Factory.cpp fallingedge/MyNode.cpp
fallingedge_la_LDFLAGS =-module -avoid-version -shared

Expand All @@ -29,16 +32,21 @@ srflipflop_la_LDFLAGS =-module -avoid-version -shared
switch_la_SOURCES = switch/Factory.cpp switch/MyNode.cpp
switch_la_LDFLAGS =-module -avoid-version -shared

variable_switch_la_SOURCES = variable-switch/Factory.cpp variable-switch/MyNode.cpp
variable_switch_la_LDFLAGS =-module -avoid-version -shared

logic_ladir = $(libdir)
logic_la_DATA = and/and.hni fallingedge/fallingedge.hni not/not.hni or/or.hni risingedge/risingedge.hni srflipflop/srflipflop.hni switch/switch.hni
logic_la_DATA = and/and.hni change/change.hni fallingedge/fallingedge.hni not/not.hni or/or.hni risingedge/risingedge.hni srflipflop/srflipflop.hni switch/switch.hni variable-switch/variable-switch.hni
locale_en_usdir = $(libdir)/locales/en-US
locale_en_us_DATA = and/locales/en-US/and fallingedge/locales/en-US/fallingedge not/locales/en-US/not or/locales/en-US/or risingedge/locales/en-US/risingedge srflipflop/locales/en-US/srflipflop switch/locales/en-US/switch
locale_en_us_DATA = and/locales/en-US/and change/locales/en-US/change fallingedge/locales/en-US/fallingedge not/locales/en-US/not or/locales/en-US/or risingedge/locales/en-US/risingedge srflipflop/locales/en-US/srflipflop switch/locales/en-US/switch variable-switch/locales/en-US/variable-switch

install-exec-hook:
rm -f $(DESTDIR)$(libdir)/and.la
rm -f $(DESTDIR)$(libdir)/change.la
rm -f $(DESTDIR)$(libdir)/fallingedge.la
rm -f $(DESTDIR)$(libdir)/not.la
rm -f $(DESTDIR)$(libdir)/or.la
rm -f $(DESTDIR)$(libdir)/risingedge.la
rm -f $(DESTDIR)$(libdir)/srflipflop.la
rm -f $(DESTDIR)$(libdir)/switch.la
rm -f $(DESTDIR)$(libdir)/variable-switch.la
3 changes: 2 additions & 1 deletion basic-logic/and/and.hni
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
{
"name": "and",
"readableName": "And",
"version": "0.0.1",
"version": "1.0.0",
"coreNode": true,
"maxThreadCount": 0
}
</script>
Expand Down
41 changes: 41 additions & 0 deletions basic-logic/change/Factory.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* Copyright 2013-2019 Homegear GmbH
*
* Homegear is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Homegear is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Homegear. If not, see <http://www.gnu.org/licenses/>.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/

#include "Factory.h"
#include "MyNode.h"

Flows::INode* MyFactory::createNode(std::string path, std::string nodeNamespace, std::string type, const std::atomic_bool* frontendConnected)
{
return new MyNode::MyNode(path, nodeNamespace, type, frontendConnected);
}

Flows::NodeFactory* getFactory()
{
return (Flows::NodeFactory*) (new MyFactory);
}
27 changes: 7 additions & 20 deletions runscript/RunScript.h → basic-logic/change/Factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,18 @@
* files in the program, then also delete it here.
*/

#ifndef RUNSCRIPT_H_
#define RUNSCRIPT_H_
#ifndef FACTORY_H
#define FACTORY_H

#include <homegear-node/INode.h>
#include <homegear-base/BaseLib.h>
#include <mutex>
#include <homegear-node/NodeFactory.h>
#include "MyNode.h"

namespace RunScript
{

class RunScript: public Flows::INode
class MyFactory : Flows::NodeFactory
{
public:
RunScript(std::string path, std::string nodeNamespace, std::string type, const std::atomic_bool* frontendConnected);
virtual ~RunScript();

virtual bool init(Flows::PNodeInfo info);
private:
bool _onBoolean = false;
Flows::PVariable _input1;
bool _input2 = false;

virtual void input(const Flows::PNodeInfo info, uint32_t index, const Flows::PVariable message);
virtual Flows::INode* createNode(std::string path, std::string nodeNamespace, std::string type, const std::atomic_bool* frontendConnected);
};

}
extern "C" Flows::NodeFactory* getFactory();

#endif
Loading

0 comments on commit 6e1ddeb

Please sign in to comment.