Skip to content

Commit

Permalink
adapt to WinCCOA 3.16
Browse files Browse the repository at this point in the history
  • Loading branch information
aledeul committed Oct 8, 2021
1 parent f1a5ec9 commit 7d3d519
Show file tree
Hide file tree
Showing 26 changed files with 154 additions and 152 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*/


namespace REMUS
namespace Common
{
template <class Task>
class AsyncRecurringTask
Expand Down
11 changes: 7 additions & 4 deletions REMUS/Constants.cxx → Common/Constants.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "Logger.hxx"
#include "Utils.hxx"

namespace REMUS {
namespace Common {

// Common
std::string Constants::drv_name = "kafka";
Expand All @@ -42,19 +42,22 @@ namespace REMUS {
{ "DEBUGLVL",
[](const char* data)
{
REMUS::Logger::setLogLvl((int)*reinterpret_cast<const int32_t*>(data));
Common::Logger::globalInfo(Common::Logger::L1, "setLogLvl:", CharString(data));
Common::Logger::setLogLvl((int)std::atoi(data));
}
},
{ "DEBOUNCINGTHREADINTERVAL",
[](const char* data)
{
REMUS::Constants::setDebouncingThreadInterval((int)*reinterpret_cast<const int32_t*>(data));
Common::Logger::globalInfo(Common::Logger::L1, "setDebouncingThreadInterval:", CharString(data));
Common::Constants::setDebouncingThreadInterval((int)std::atoi(data));
}
},
{ "MAXPOLLRECORDS",
[](const char* data)
{
REMUS::Constants::setConsumerMaxPollRecords((size_t)*reinterpret_cast<const int32_t*>(data));
Common::Logger::globalInfo(Common::Logger::L1, "setConsumerMaxPollRecords:", CharString(data));
Common::Constants::setConsumerMaxPollRecords((size_t)std::atoi(data));
}
}

Expand Down
22 changes: 11 additions & 11 deletions REMUS/Constants.hxx → Common/Constants.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
**/

#include <map>
#include <REMUS/Utils.hxx>
#include <REMUS/Logger.hxx>
#include <Common/Utils.hxx>
#include <Common/Logger.hxx>

namespace REMUS{
namespace Common{

/*!
* \class Constants
Expand Down Expand Up @@ -199,15 +199,15 @@ inline void Constants::setProducerKafkaStatsInterval(){
int milis;
try
{
if(!REMUS::Utils::convertToInt(REMUS::Constants::GetProducerConfig().at(REMUS::Constants::CONFIG_STATISTICS_INTERVAL_MS), milis))
if(!Common::Utils::convertToInt(Common::Constants::GetProducerConfig().at(Common::Constants::CONFIG_STATISTICS_INTERVAL_MS), milis))
{
milis = REMUS::Constants::CONFIG_STATISTICS_INTERVAL_MS_DEFAULT; // DEFAULT
milis = Common::Constants::CONFIG_STATISTICS_INTERVAL_MS_DEFAULT; // DEFAULT
}
}
catch(std::exception& e)
{
REMUS::Logger::globalWarning(__PRETTY_FUNCTION__," Constants ProducerConfig does not have ", REMUS::Constants::CONFIG_STATISTICS_INTERVAL_MS);
milis = REMUS::Constants::CONFIG_STATISTICS_INTERVAL_MS_DEFAULT; // DEFAULT
Common::Logger::globalWarning(__PRETTY_FUNCTION__," Constants ProducerConfig does not have ", Common::Constants::CONFIG_STATISTICS_INTERVAL_MS);
milis = Common::Constants::CONFIG_STATISTICS_INTERVAL_MS_DEFAULT; // DEFAULT
}
PRODUCER_KAFKA_STATS_INTERVAL = milis;
}
Expand All @@ -220,15 +220,15 @@ inline void Constants::setConsumerKafkaStatsInterval(){
int milis;
try
{
if(!REMUS::Utils::convertToInt(REMUS::Constants::GetConsumerConfig().at(REMUS::Constants::CONFIG_STATISTICS_INTERVAL_MS), milis))
if(!Common::Utils::convertToInt(Common::Constants::GetConsumerConfig().at(Common::Constants::CONFIG_STATISTICS_INTERVAL_MS), milis))
{
milis = REMUS::Constants::CONFIG_STATISTICS_INTERVAL_MS_DEFAULT; // DEFAULT
milis = Common::Constants::CONFIG_STATISTICS_INTERVAL_MS_DEFAULT; // DEFAULT
}
}
catch(std::exception& e)
{
REMUS::Logger::globalWarning(__PRETTY_FUNCTION__," Constants ConsumerConfig does not have ", REMUS::Constants::CONFIG_STATISTICS_INTERVAL_MS);
milis = REMUS::Constants::CONFIG_STATISTICS_INTERVAL_MS_DEFAULT; // DEFAULT
Common::Logger::globalWarning(__PRETTY_FUNCTION__," Constants ConsumerConfig does not have ", Common::Constants::CONFIG_STATISTICS_INTERVAL_MS);
milis = Common::Constants::CONFIG_STATISTICS_INTERVAL_MS_DEFAULT; // DEFAULT
}
CONSUMER_KAFKA_STATS_INTERVAL = milis;
}
Expand Down
6 changes: 3 additions & 3 deletions REMUS/Logger.cxx → Common/Logger.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
**/

#include "Logger.hxx"
#include "REMUS/Constants.hxx"
#include "Common/Constants.hxx"
#include <mutex>

namespace REMUS {
namespace Common {

int Logger::loggingLevel = 2;
int Logger::loggingLevel = 1;
const char * Logger::timestrformat = "%a, %d.%m.%Y %H:%M:%S";

void Logger::globalInfo(int lvl, const char *note1, const char* note2, const char* note3){
Expand Down
2 changes: 1 addition & 1 deletion REMUS/Logger.hxx → Common/Logger.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
using std::mutex;
using std::lock_guard;

namespace REMUS {
namespace Common {

/*!
* \class Debug
Expand Down
2 changes: 1 addition & 1 deletion REMUS/Utils.hxx → Common/Utils.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ std::ostream& operator << (std::ostream& os, const std::vector<T>& iterable)
}


namespace REMUS {
namespace Common {

using std::future;
using std::future_status;
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ define INSTALL_BODY
fi;
endef

REMUS_SOURCE = $(wildcard REMUS/*.cxx)
REMUS_TYPES = $(REMUS_SOURCE:.cxx=.o)
COMMON_SOURCE = $(wildcard Common/*.cxx)
COMMON_TYPES = $(COMMON_SOURCE:.cxx=.o)

TRANSFORMATIONS_SOURCE = $(wildcard Transformations/*.cxx)
TRANSFORMATIONS = $(TRANSFORMATIONS_SOURCE:.cxx=.o)


WCCOAkafkaDrv: $(MYOBJS) $(REMUS_TYPES) $(TRANSFORMATIONS)
WCCOAkafkaDrv: $(MYOBJS) $(COMMON_TYPES) $(TRANSFORMATIONS)
@rm -f addVerInfo.o
@$(MAKE) addVerInfo.o
$(LINK_CMD) -o $(DRV_NAME) *.o $(OBJS) $(LIBS)


installLibs:
sudo yum install --assumeyes cyrus-sasl-gssapi boost* cmake openssl-devel
sudo yum install --assumeyes cyrus-sasl-gssapi cyrus-sasl-devel boost* cmake openssl-devel
git submodule update --init --recursive
cd ./libs/librdkafka && ./configure && make && sudo make install
cd ./libs/cppkafka && mkdir -p build && cd build && cmake .. && make && sudo make install
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
CERN HSE Computing (HSE-CEN-CO)
CERN HSE Computing (HSE-TS-CS)
==================================================

Contact email: [email protected]

REMUS WinCC OA Kafka Driver
WinCC OA Kafka Driver
==================================================


Expand Down
4 changes: 2 additions & 2 deletions Transformations/kafkaBoolTrans.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "kafkaHWMapper.hxx"

#include "REMUS/Logger.hxx"
#include "Common/Logger.hxx"

#include <cmath>

Expand Down Expand Up @@ -84,7 +84,7 @@ VariablePtr kafkaBoolTrans::toVar(const PVSSchar *buffer, const PVSSuint dlen, c
return new BitVar(true);
else
{
REMUS::Logger::globalWarning(__PRETTY_FUNCTION__, "Unable to parse boolean for buffer:", (const char*)buffer);
Common::Logger::globalWarning(__PRETTY_FUNCTION__, "Unable to parse boolean for buffer:", (const char*)buffer);
}
}
return NULL;
Expand Down
4 changes: 2 additions & 2 deletions Transformations/kafkaFloatTrans.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "kafkaHWMapper.hxx"

#include "REMUS/Logger.hxx"
#include "Common/Logger.hxx"

#include <cmath>

Expand Down Expand Up @@ -82,7 +82,7 @@ VariablePtr kafkaFloatTrans::toVar(const PVSSchar *buffer, const PVSSuint dlen,
}
catch(std::exception& e)
{
REMUS::Logger::globalWarning(__PRETTY_FUNCTION__, e.what());
Common::Logger::globalWarning(__PRETTY_FUNCTION__, e.what());
}
}

Expand Down
4 changes: 2 additions & 2 deletions Transformations/kafkaInt32Trans.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "kafkaHWMapper.hxx"

#include "REMUS/Logger.hxx"
#include "Common/Logger.hxx"

#include <cmath>

Expand Down Expand Up @@ -82,7 +82,7 @@ VariablePtr kafkaInt32Trans::toVar(const PVSSchar *buffer, const PVSSuint dlen,
}
catch(std::exception& e)
{
REMUS::Logger::globalWarning(__PRETTY_FUNCTION__, e.what());
Common::Logger::globalWarning(__PRETTY_FUNCTION__, e.what());
}
}

Expand Down
4 changes: 2 additions & 2 deletions Transformations/kafkaInt64Trans.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "kafkaHWMapper.hxx"

#include "REMUS/Logger.hxx"
#include "Common/Logger.hxx"

#include <cmath>

Expand Down Expand Up @@ -82,7 +82,7 @@ VariablePtr kafkaInt64Trans::toVar(const PVSSchar *buffer, const PVSSuint dlen,
}
catch(std::exception& e)
{
REMUS::Logger::globalWarning(__PRETTY_FUNCTION__, e.what());
Common::Logger::globalWarning(__PRETTY_FUNCTION__, e.what());
}
}
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion Transformations/kafkaStringTrans.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include "kafkaHWMapper.hxx"

#include "REMUS/Logger.hxx"
#include "Common/Logger.hxx"

//----------------------------------------------------------------------------
namespace Transformations {
Expand Down
2 changes: 1 addition & 1 deletion Transformations/kafkaTimeTrans.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "kafkaHWMapper.hxx"

#include "REMUS/Logger.hxx"
#include "Common/Logger.hxx"

#include <cmath>

Expand Down
4 changes: 2 additions & 2 deletions Transformations/kafkaUint8Trans.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "kafkaHWMapper.hxx"

#include "REMUS/Logger.hxx"
#include "Common/Logger.hxx"

#include <cmath>

Expand Down Expand Up @@ -85,7 +85,7 @@ VariablePtr kafkaUint8Trans::toVar(const PVSSchar *buffer, const PVSSuint dlen,
}
catch(std::exception& e)
{
REMUS::Logger::globalWarning(__PRETTY_FUNCTION__, e.what());
Common::Logger::globalWarning(__PRETTY_FUNCTION__, e.what());
}

}
Expand Down
4 changes: 2 additions & 2 deletions addVerInfo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

#define SET_VERSINFO(vi) \
vi[0] = version[0]; /* warning-suppression: "version unused ..." */ \
sprintf(vi, "%s %s platform %s linked at %s", \
sprintf(vi, "%s %s linked at %s", \
PVSS_VERSION " " PVSS_VERS_COMMENT PVSS_VERS_WARNING, \
PVSS_PATCH, PVSS_PLATFORM, __DATE__ " " __TIME__);
PVSS_PATCH, __DATE__ " " __TIME__);


#ifndef ADDVERINFO
Expand Down
16 changes: 8 additions & 8 deletions kafkaConsumerFacade.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#include <csignal>

#include "kafkaConsumerFacade.hxx"
#include "REMUS/Constants.hxx"
#include "REMUS/Logger.hxx"
#include "Common/Constants.hxx"
#include "Common/Logger.hxx"

#include "cppkafka/message.h"
#include "cppkafka/kafka_handle_base.h"
Expand All @@ -43,7 +43,7 @@ kafkaConsumerFacade::kafkaConsumerFacade(const std::string& topic, consumeCallba
try{
//Create kafka configuration
Configuration config;
for (const auto & kv : REMUS::Constants::GetConsumerConfig())
for (const auto & kv : Common::Constants::GetConsumerConfig())
{
std::cerr << kv.first << " - "<< kv.second << std::endl;
config.set(kv.first, kv.second);
Expand All @@ -52,12 +52,12 @@ kafkaConsumerFacade::kafkaConsumerFacade(const std::string& topic, consumeCallba
//Update consumer group id to be unique by appending topic and current timestamp
try
{
config.set(REMUS::Constants::GROUP_ID_KEYWORD, config.get(REMUS::Constants::GROUP_ID_KEYWORD) + "_" + topic + "_" + std::to_string(std::chrono::seconds(std::time(NULL)).count()));
config.set(Common::Constants::GROUP_ID_KEYWORD, config.get(Common::Constants::GROUP_ID_KEYWORD) + "_" + topic + "_" + std::to_string(std::chrono::seconds(std::time(NULL)).count()));
}
catch (ConfigOptionNotFound& e)
{
REMUS::Logger::globalWarning("No group id found! Adding default one: topicname_unixtimestamp", e.what());
config.set(REMUS::Constants::GROUP_ID_KEYWORD, topic + "_" + std::to_string(std::chrono::seconds(std::time(NULL)).count()));
Common::Logger::globalWarning("No group id found! Adding default one: topicname_unixtimestamp", e.what());
config.set(Common::Constants::GROUP_ID_KEYWORD, topic + "_" + std::to_string(std::chrono::seconds(std::time(NULL)).count()));
}

// set the error and statistics callbacks on the kafka config
Expand All @@ -80,13 +80,13 @@ kafkaConsumerFacade::kafkaConsumerFacade(const std::string& topic, consumeCallba
}
catch(std::exception& e)
{
REMUS::Logger::globalWarning("Unable to initialize consumer!", e.what());
Common::Logger::globalWarning("Unable to initialize consumer!", e.what());
}
}

void kafkaConsumerFacade::poll(const size_t& maxPollRecords)
{
REMUS::Logger::globalInfo(REMUS::Logger::L2, __PRETTY_FUNCTION__, "Poll batch with maxPollRecords:", CharString(maxPollRecords));
Common::Logger::globalInfo(Common::Logger::L2, __PRETTY_FUNCTION__, "Poll batch with maxPollRecords:", CharString(maxPollRecords));
std::vector<Message> msgVec = std::move(_consumer->poll_batch(maxPollRecords));
for (auto & msg : msgVec )
{
Expand Down
14 changes: 7 additions & 7 deletions kafkaDrv.files
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ Transformations/kafkaTimeTrans.cxx
Transformations/kafkaTimeTrans.hxx
Transformations/kafkaUint8Trans.cxx
Transformations/kafkaUint8Trans.hxx
REMUS/Logger.cxx
REMUS/Logger.hxx
REMUS/Constants.hxx
REMUS/Constants.cxx
REMUS/Utils.hxx
Common/Logger.cxx
Common/Logger.hxx
Common/Constants.hxx
Common/Constants.cxx
Common/Utils.hxx
LICENSE
Makefile
kafkaProducerFacade.hxx
kafkaProducerFacade.cxx
REMUS/Utils.hxx
REMUS/AsyncRecurringTask.hxx
Common/Utils.hxx
Common/AsyncRecurringTask.hxx
kafkaConsumerFacade.cxx
kafkaConsumerFacade.hxx
LICENSE
Expand Down
24 changes: 12 additions & 12 deletions kafkaDrv.includes
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/opt/WinCC_OA/3.15/api/include/Basics/Variables/
/opt/WinCC_OA/3.15/api/include/Basics/Utilities
/opt/WinCC_OA/3.15/api/include/Basics/DpBasics
/opt/WinCC_OA/3.15/api/include/Basics/NoPosix
/opt/WinCC_OA/3.15/api/include/ComDrv/
/opt/WinCC_OA/3.15/api/include/Configs/DrvConfigs/DrvCommon/
/opt/WinCC_OA/3.15/api/include/PVSSUtil
/opt/WinCC_OA/3.15/api/include/Configs
/opt/WinCC_OA/3.15/api/include/Configs/DrvConfigs
/opt/WinCC_OA/3.15/api/include/Ctrl
/opt/WinCC_OA/3.15/api/include/Datapoint
/opt/WinCC_OA/3.16/api/include/Basics/Variables/
/opt/WinCC_OA/3.16/api/include/Basics/Utilities
/opt/WinCC_OA/3.16/api/include/Basics/DpBasics
/opt/WinCC_OA/3.16/api/include/Basics/NoPosix
/opt/WinCC_OA/3.16/api/include/ComDrv/
/opt/WinCC_OA/3.16/api/include/Configs/DrvConfigs/DrvCommon/
/opt/WinCC_OA/3.16/api/include/PVSSUtil
/opt/WinCC_OA/3.16/api/include/Configs
/opt/WinCC_OA/3.16/api/include/Configs/DrvConfigs
/opt/WinCC_OA/3.16/api/include/Ctrl
/opt/WinCC_OA/3.16/api/include/Datapoint
.
REMUS
Common
Loading

0 comments on commit 7d3d519

Please sign in to comment.