Skip to content
Snippets Groups Projects
Commit a584f29d authored by Andrea Michelotti's avatar Andrea Michelotti
Browse files

Adding support epics

parent 4fcd2de0
No related branches found
No related tags found
No related merge requests found
......@@ -217,6 +217,7 @@ IF (CHAOS_PROMETHEUS)
add_definitions(-DCHAOS_PROMETHEUS=1)
ENDIF()
IF (CLING_VIRTUAL_MACHINE_ENABLE)
MESG("Using ${CMAKE_BINARY_DIR}/ext_dep/cling-src for download cling")
IF(NOT EXISTS ${CMAKE_BINARY_DIR}/ext_dep/cling-src)
......@@ -261,6 +262,20 @@ ENDIF()
SET(BUILD_LIBRARY )
IF(CHAOS_EPICS_SUPPORT)
foreach(elib libpvData.a libCom.a)
find_library(epicslibs_${elib} ${elib} HINTS "${CMAKE_INSTALL_PREFIX}/lib/linux-x86_64")
if(NOT epicslibs_${elib})
message(FATAL_ERROR "EPICS LIBRARY ${elib} NOT FOUND")
else()
SET(BUILD_LIBRARY ${BUILD_LIBRARY} ${epicslibs_${elib}})
endif()
endforeach()
MESG("Adding Epics support ${BUILD_LIBRARY}")
ENDIF(CHAOS_EPICS_SUPPORT)
#add_subdirectory(libbson)
# ExternalProject_Add(
......
......@@ -63,6 +63,8 @@ typedef std::chrono::seconds ChaosCronoSeconds;
typedef std::chrono::milliseconds ChaosCronoMilliseconds;
typedef std::chrono::microseconds ChaosCronoMicroseconds;
#define ChaosMutex std::mutex
#define ChaosRecursiveMutex std::recursive_mutex
#define ChaosLockGuard std::lock_guard<std::mutex>
#define ChaosUniqueLock std::unique_lock<std::mutex>
#define ChaosConditionVariable std::condition_variable
......@@ -123,7 +125,9 @@ using ChaosFunction = std::function< R >;
#include <boost/thread/future.hpp>
#include <boost/chrono.hpp>
#include <boost/function.hpp>
#define ChaosMutex boost::mutex
#define ChaosMutex boost::mutex
#define ChaosRecursiveMutex boost::recursive_mutex
#define ChaosLockGuard boost::lock_guard<boost::mutex>
#define ChaosUniqueLock boost::unique_lock<boost::mutex>
#define ChaosConditionVariable boost::condition_variable
......
......@@ -22,6 +22,9 @@
#include <chaos/common/data/CDataWrapper.h>
#include <chaos/common/utility/Base64Util.h>
#include <boost/lexical_cast.hpp>
#ifdef EPICS
#include <pv/pvData.h>
#endif
using namespace chaos;
using namespace chaos::common::data;
......@@ -1524,6 +1527,59 @@ int CDataWrapper::setBson(const bson_iter_t *v ,const CDataWrapper* val){
}
return -1;
}
#ifdef EPICS
void CDataWrapper::setSerializedData(epics::pvData::StructureConstPtr ptr){
std::string id= ptr->getID();
addStringValue("type",id);
size_t numberFields = ptr->getNumberFields();
for(size_t i=0; i<numberFields; i++) {
epics::pvData::FieldConstPtr pfield = ptr->getField(i);
CDataWrapper cs;
cs.addStringValue(ptr->getFieldName(i),pfield->getID());
switch(pfield->getType()) {
case epics::pvData::Type::scalar:
case epics::pvData::Type::scalarArray:
break;
case epics::pvData::Type::structure:
{
epics::pvData::Field const *xxx = pfield.get();
epics::pvData::Structure const *pstruct = static_cast<epics::pvData::Structure const*>(xxx);
cs.setSerializedData(epics::pvData::StructureConstPtr(pstruct));
break;
}
/* case epics::pvData::Type::structureArray:
{
format::indent_scope s(o);
Field const *xxx = pfield.get();
StructureArray const *pstructureArray = static_cast<StructureArray const*>(xxx);
o << *pstructureArray->getStructure();
break;
}
case epics::pvData::Type::union_:
{
Field const *xxx = pfield.get();
Union const *punion = static_cast<Union const*>(xxx);
format::indent_scope s(o);
punion->dumpFields(o);
break;
}
case epics::pvData::Type::unionArray:
{
format::indent_scope s(o);
Field const *xxx = pfield.get();
UnionArray const *punionArray = static_cast<UnionArray const*>(xxx);
o << *punionArray->getUnion();
break;
}*/
default:
break;
}
}
}
#endif
#pragma mark CMultiTypeDataArrayWrapper
CMultiTypeDataArrayWrapper::CMultiTypeDataArrayWrapper(const ChaosBsonShrdPtr& _document_shrd_ptr,
......@@ -1721,3 +1777,4 @@ ChaosUniquePtr<CDataWrapper> CMultiTypeDataArrayWrapper::getCDataWrapperElementA
size_t CMultiTypeDataArrayWrapper::size() const{
return values.size();
}
\ No newline at end of file
......@@ -33,6 +33,15 @@
#define __PRETTY_FUNCTION__ __FUNCSIG__
#endif
#endif
#ifdef EPICS
namespace epics{
namespace pvData{
class Structure;
typedef std::shared_ptr<const Structure> StructureConstPtr;
}
}
#endif
#if defined(__GNUC__) && (__GNUC__ >= 6) && !defined(__clang__)
// See libmongoc.hh for details on this diagnostic suppression
......@@ -207,6 +216,10 @@ namespace chaos {
//get a projection of a vector of keys
ChaosUniquePtr<chaos::common::data::CDataWrapper> getCSProjection(const std::vector<std::string>&) const;
#ifdef EPICS
void setSerializedData(epics::pvData::StructureConstPtr ptr);
#endif
//add a string value
//void addStringValue(const char *, const char *);
/**
......@@ -484,6 +497,7 @@ throw chaos::CException(-2, ss.str(), __PRETTY_FUNCTION__);
const char* getBSONRawData() const;
const int getBSONRawSize() const;
chaos::common::data::ChaosBsonShrdPtr getBSONShrPtr() const { return bson;}
//return the json data
//SerializationBuffer* getJSONData();
//return the json representation for this data wrapper
......
......@@ -67,7 +67,7 @@ namespace chaos {
ChaosConditionVariable cond;
boost::thread th;
void thfunc();
std::recursive_mutex io;
ChaosRecursiveMutex io;
uint64_t counter,oks,errs;
public:
......
......@@ -61,6 +61,11 @@ option(KAFKA_RDK_ENABLE "Enable KAFKA" ON)
option(GPUFIT "Fast Fitting libraries (needs CUDA toolkit)" OFF)
IF(CHAOS_EPICS_SUPPORT)
add_definitions(-DEPICS)
INCLUDE_DIRECTORIES(${CMAKE_INSTALL_PREFIX}/include/compiler/gcc ${CMAKE_INSTALL_PREFIX}/include/os/Linux )
ENDIF()
IF(NOT CHAOS_VERSION_MAJOR)
SET(CHAOS_VERSION_MAJOR "1")
ENDIF()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment