From 63e580e1533e62fbef227349f3e3925a12478d47 Mon Sep 17 00:00:00 2001 From: Martin Hierholzer <martin.hierholzer@desy.de> Date: Thu, 13 Jul 2023 09:27:31 +0200 Subject: [PATCH] doc: modernise example(s) --- CMakeLists.txt | 2 +- example/.clang-format | 1 + example/CMakeLists.txt | 40 +++--- example/DemoDummyDevice.cc | 45 ------- example/HowTo_project-template.md | 1 + example/TimerDummyDevice.cc | 120 ------------------ example/config/DemoDummy.map | 14 +- example/config/TimerDummy.map | 2 - .../demo_example-DoocsVariableConfig.xml | 2 +- example/config/demo_example-config.xml | 16 +++ example/config/demo_example.dmap | 2 + example/config/dummy.dmap | 2 - .../config/exampleApp-DoocsVariableConfig.xml | 6 - example/config/oven.xlmap | 57 +++++++++ example/config/ovenInit.py | 19 +++ example/demoApp.cc | 79 ------------ example/include/AverageCurrent.h | 31 +++++ example/include/Controller.h | 30 +++++ example/include/ExampleApp.h | 83 ++++++++++++ example/include/SetpointRamp.h | 33 +++++ example/pyproject.toml | 1 + example/src/AverageCurrent.cc | 33 +++++ example/src/Controller.cc | 29 +++++ example/src/ExampleApp.cc | 23 ++++ example/src/SetpointRamp.cc | 26 ++++ example/src_factory/FactoryInstance.cc | 21 +++ example2/CMakeLists.txt | 56 -------- example2/COPYING | 1 - example2/COPYING.LESSER | 1 - ...This_project_uses_the_project-template.txt | 1 - example2/cmake | 1 - .../config/demoApp2-DoocsVariableConfig.xml | 6 - example2/config/demo_example2.conf | 8 -- example2/config/example2.dmap | 2 - example2/config/oven.map | 5 - example2/demoApp2.cc | 40 ------ example2/oven_sim/oven_sim.py | 27 ---- example2a/CMakeLists.txt | 56 -------- example2a/COPYING | 1 - example2a/COPYING.LESSER | 1 - ...This_project_uses_the_project-template.txt | 1 - example2a/cmake | 1 - example2a/config/demoApp2a.xml | 4 - example2a/config/demo_example2a.conf | 119 ----------------- example2a/config/example2.dmap | 2 - example2a/config/oven.map | 4 - example2a/demoApp2a.cc | 65 ---------- example2c/CMakeLists.txt | 57 --------- example2c/COPYING | 1 - example2c/COPYING.LESSER | 1 - ...This_project_uses_the_project-template.txt | 1 - example2c/cmake | 1 - .../config/demoApp2-DoocsVariableConfig.xml | 5 - example2c/config/demo_example2c.conf | 8 -- example2c/config/example2.dmap | 3 - example2c/config/oven.map | 7 - example2c/config/oven.xlmap | 51 -------- example2c/demoApp2c.cc | 65 ---------- example2c/oven_sim/oven_sim2c.py | 46 ------- example3/CMakeLists.txt | 59 --------- example3/COPYING | 1 - example3/COPYING.LESSER | 1 - ...This_project_uses_the_project-template.txt | 1 - example3/cmake | 1 - example3/config/demo_example3.conf | 119 ----------------- example3/config/example2.dmap | 2 - .../exampleApp3-DoocsVariableConfig.xml | 6 - example3/config/oven.map | 4 - example3/demoApp3.cc | 27 ---- example_template/CMakeLists.txt | 97 -------------- example_template/COPYING | 1 - example_template/COPYING.LESSER | 1 - ...This_project_uses_the_project-template.txt | 1 - example_template/cmake | 1 - .../config/TemplateServer-Config.xml | 7 - .../TemplateServer-DoocsVariableConfig.xml | 12 -- example_template/config/TemplateServer.conf | 19 --- example_template/config/TemplateServer.dmap | 2 - example_template/config/dummydevice.map | 3 - example_template/config/name_mapping.xlmap | 21 --- example_template/include/Server.h | 32 ----- example_template/include/TemplateModule.h | 15 --- example_template/include/version.h.in | 12 -- example_template/src/Server.cc | 21 --- example_template/src/TemplateModule.cc | 17 --- .../src_server/ApplicationInstance.cc | 7 - .../src_xmlGenerator/XmlGenerator.cc | 9 -- .../executables_src/testTemplateModule.cc | 37 ------ 88 files changed, 443 insertions(+), 1459 deletions(-) create mode 120000 example/.clang-format delete mode 100644 example/DemoDummyDevice.cc create mode 120000 example/HowTo_project-template.md delete mode 100644 example/TimerDummyDevice.cc delete mode 100644 example/config/TimerDummy.map rename example2a/config/exampleApp2a-DoocsVariableConfig.xml => example/config/demo_example-DoocsVariableConfig.xml (86%) create mode 100644 example/config/demo_example-config.xml create mode 100644 example/config/demo_example.dmap delete mode 100644 example/config/dummy.dmap delete mode 100644 example/config/exampleApp-DoocsVariableConfig.xml create mode 100644 example/config/oven.xlmap create mode 100755 example/config/ovenInit.py delete mode 100644 example/demoApp.cc create mode 100644 example/include/AverageCurrent.h create mode 100644 example/include/Controller.h create mode 100644 example/include/ExampleApp.h create mode 100644 example/include/SetpointRamp.h create mode 120000 example/pyproject.toml create mode 100644 example/src/AverageCurrent.cc create mode 100644 example/src/Controller.cc create mode 100644 example/src/ExampleApp.cc create mode 100644 example/src/SetpointRamp.cc create mode 100644 example/src_factory/FactoryInstance.cc delete mode 100644 example2/CMakeLists.txt delete mode 120000 example2/COPYING delete mode 120000 example2/COPYING.LESSER delete mode 120000 example2/This_project_uses_the_project-template.txt delete mode 120000 example2/cmake delete mode 100644 example2/config/demoApp2-DoocsVariableConfig.xml delete mode 100644 example2/config/demo_example2.conf delete mode 100644 example2/config/example2.dmap delete mode 100644 example2/config/oven.map delete mode 100644 example2/demoApp2.cc delete mode 100755 example2/oven_sim/oven_sim.py delete mode 100644 example2a/CMakeLists.txt delete mode 120000 example2a/COPYING delete mode 120000 example2a/COPYING.LESSER delete mode 120000 example2a/This_project_uses_the_project-template.txt delete mode 120000 example2a/cmake delete mode 100644 example2a/config/demoApp2a.xml delete mode 100644 example2a/config/demo_example2a.conf delete mode 100644 example2a/config/example2.dmap delete mode 100644 example2a/config/oven.map delete mode 100644 example2a/demoApp2a.cc delete mode 100644 example2c/CMakeLists.txt delete mode 120000 example2c/COPYING delete mode 120000 example2c/COPYING.LESSER delete mode 120000 example2c/This_project_uses_the_project-template.txt delete mode 120000 example2c/cmake delete mode 100644 example2c/config/demoApp2-DoocsVariableConfig.xml delete mode 100644 example2c/config/demo_example2c.conf delete mode 100644 example2c/config/example2.dmap delete mode 100644 example2c/config/oven.map delete mode 100644 example2c/config/oven.xlmap delete mode 100644 example2c/demoApp2c.cc delete mode 100755 example2c/oven_sim/oven_sim2c.py delete mode 100644 example3/CMakeLists.txt delete mode 120000 example3/COPYING delete mode 120000 example3/COPYING.LESSER delete mode 120000 example3/This_project_uses_the_project-template.txt delete mode 120000 example3/cmake delete mode 100644 example3/config/demo_example3.conf delete mode 100644 example3/config/example2.dmap delete mode 100644 example3/config/exampleApp3-DoocsVariableConfig.xml delete mode 100644 example3/config/oven.map delete mode 100644 example3/demoApp3.cc delete mode 100644 example_template/CMakeLists.txt delete mode 120000 example_template/COPYING delete mode 120000 example_template/COPYING.LESSER delete mode 120000 example_template/This_project_uses_the_project-template.txt delete mode 120000 example_template/cmake delete mode 100644 example_template/config/TemplateServer-Config.xml delete mode 100644 example_template/config/TemplateServer-DoocsVariableConfig.xml delete mode 100644 example_template/config/TemplateServer.conf delete mode 100644 example_template/config/TemplateServer.dmap delete mode 100644 example_template/config/dummydevice.map delete mode 100644 example_template/config/name_mapping.xlmap delete mode 100644 example_template/include/Server.h delete mode 100644 example_template/include/TemplateModule.h delete mode 100644 example_template/include/version.h.in delete mode 100644 example_template/src/Server.cc delete mode 100644 example_template/src/TemplateModule.cc delete mode 100644 example_template/src_server/ApplicationInstance.cc delete mode 100644 example_template/src_xmlGenerator/XmlGenerator.cc delete mode 100644 example_template/tests/executables_src/testTemplateModule.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index bef958e7..2d06ae3d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ include(cmake/set_version_numbers.cmake) option(BUILD_TESTS "Build tests." ON) # Find the ControlSystemAdapter -FIND_PACKAGE(ChimeraTK-ControlSystemAdapter 02.06 REQUIRED) +FIND_PACKAGE(ChimeraTK-ControlSystemAdapter 02.07 REQUIRED) # Find the DeviceAccess FIND_PACKAGE(ChimeraTK-DeviceAccess 03.11 REQUIRED) diff --git a/example/.clang-format b/example/.clang-format new file mode 120000 index 00000000..7cab60ce --- /dev/null +++ b/example/.clang-format @@ -0,0 +1 @@ +../.clang-format \ No newline at end of file diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index fc29d4f5..8a32b0d1 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -1,9 +1,9 @@ # Note: This CMakeLists.txt is a minimal complete example how to use the # *installed* application core library. It is not included from the main CMakeLists.txt # which is used to build ApplicationCore itself. -PROJECT(demo_example) +project(demo_example) -CMAKE_MINIMUM_REQUIRED(VERSION 3.16) +cmake_minimum_required(VERSION 3.16) # Use the project template to get the settings required for an application core project set(${PROJECT_NAME}_MAJOR_VERSION 01) @@ -17,30 +17,39 @@ include(cmake/set_default_flags.cmake) # Add the dependencies. We need ApplicationCore and a control system adapter implementation. find_package(ChimeraTK-ApplicationCore 03.00 REQUIRED) -#FIXME: Make the adapter configurable via command line parameter -find_package(ChimeraTK-ControlSystemAdapter-DoocsAdapter 00.10 REQUIRED) -AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR} demo_sources) +# Choose control system adapater implementation to link against based on the ADAPTER cmake argument. When not +# specifying this at the cmake command line, a list of possible options will be presented. +include(cmake/set_control_system_adapter.cmake) -# The server proper. It depends on application core and the control system adapter implementation. -add_executable(${PROJECT_NAME} ${demo_sources}) -target_link_libraries(${PROJECT_NAME} - PRIVATE ChimeraTK::ChimeraTK-ApplicationCore ChimeraTK::ChimeraTK-ControlSystemAdapter-DoocsAdapter ) +aux_source_directory(${CMAKE_SOURCE_DIR}/src sources) +aux_source_directory(${CMAKE_SOURCE_DIR}/include headers) +aux_source_directory(${CMAKE_SOURCE_DIR}/src_factory factory) -# We compile the same sources with the GENERATE_XML flag to get an xml generator. -# This one does not depent on a control system adapter implementation. -add_executable(${PROJECT_NAME}-xmlGenerator ${demo_sources}) +include_directories(${CMAKE_SOURCE_DIR}/include) + +# Server library links all ApplicationModules and ApplicationCore +add_library(${PROJECT_NAME}lib ${sources} ${headers}) +target_link_libraries(${PROJECT_NAME}lib ChimeraTK::ChimeraTK-ApplicationCore) + +# Server executable: link the server library with the application factory and the chose control system adapter +add_executable(${PROJECT_NAME} ${factory}) +target_link_libraries(${PROJECT_NAME} PRIVATE ${PROJECT_NAME}lib ChimeraTK::SelectedAdapter) + +# XML generator executable: generate XML application description. Links the server library with the application +# factory, but sets a special C++ preprocessor symbol to put ApplicationCore into the XML generation mode. +add_executable(${PROJECT_NAME}-xmlGenerator ${factory}) target_compile_options(${PROJECT_NAME}-xmlGenerator PRIVATE "-DGENERATE_XML") -target_link_libraries(${PROJECT_NAME}-xmlGenerator PRIVATE ChimeraTK::ChimeraTK-ApplicationCore) +target_link_libraries(${PROJECT_NAME}-xmlGenerator PRIVATE ${PROJECT_NAME}lib) # copy the (test) config files to the build directory for tests -FILE( COPY config/ DESTINATION ${PROJECT_BINARY_DIR}) +file(COPY config/ DESTINATION ${PROJECT_BINARY_DIR}) # Tests: # There are no dedicated tests for this demo. But we run the xml generator to # check that the variable household can successfully be initialised. # The test will fail if the xml generator crashes, just a smoke test. -ENABLE_TESTING() +enable_testing() add_test(${PROJECT_NAME}-xmlGenerator ${PROJECT_NAME}-xmlGenerator) # Installation: @@ -50,5 +59,6 @@ if("${CMAKE_INSTALL_PREFIX}" STREQUAL "/export/doocs/server") else() install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}-xmlGenerator RUNTIME DESTINATION bin) endif() + # Do not install the config. It is only a test config. # The real config will come from a config generator and usually depends on the instance. diff --git a/example/DemoDummyDevice.cc b/example/DemoDummyDevice.cc deleted file mode 100644 index b2cbfb9a..00000000 --- a/example/DemoDummyDevice.cc +++ /dev/null @@ -1,45 +0,0 @@ -// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de> -// SPDX-License-Identifier: LGPL-3.0-or-later -#include <ChimeraTK/BackendFactory.h> -#include <ChimeraTK/DeviceAccessVersion.h> -#include <ChimeraTK/DummyBackend.h> - -class DemoDummy : public ChimeraTK::DummyBackend { - public: - DemoDummy(std::string mapFileName) : DummyBackend(mapFileName) {} - - static boost::shared_ptr<DeviceBackend> createInstance( - std::string /* address */, std::map<std::string, std::string> parameters) { - return boost::shared_ptr<DeviceBackend>(new DemoDummy(parameters["map"])); - } - - void read(uint64_t bar, uint64_t address, int32_t* data, size_t sizeInBytes) override { - // if probeSignal register is read, fill it first - if(bar == 2) { - assert(address == 0); - assert(sizeInBytes == 65536); - - // build average of feed forward and setpoint tables - for(int i = 0; i < 65536; ++i) { - _barContents[2][i] = (_barContents[0][i] + _barContents[1][i]) / 2; - } - } - - // perform the original read - DummyBackend::read(bar, address, data, sizeInBytes); - } - - /** Class to register the backend type with the factory. */ - class BackendRegisterer { - public: - BackendRegisterer(); - }; - static BackendRegisterer backendRegisterer; -}; - -DemoDummy::BackendRegisterer DemoDummy::backendRegisterer; - -DemoDummy::BackendRegisterer::BackendRegisterer() { - std::cout << "DemoDummy::BackendRegisterer: registering backend type DemoDummy" << std::endl; - ChimeraTK::BackendFactory::getInstance().registerBackendType("DemoDummy", &DemoDummy::createInstance); -} diff --git a/example/HowTo_project-template.md b/example/HowTo_project-template.md new file mode 120000 index 00000000..3d7c4cf9 --- /dev/null +++ b/example/HowTo_project-template.md @@ -0,0 +1 @@ +../HowTo_project-template.md \ No newline at end of file diff --git a/example/TimerDummyDevice.cc b/example/TimerDummyDevice.cc deleted file mode 100644 index ffb3dac2..00000000 --- a/example/TimerDummyDevice.cc +++ /dev/null @@ -1,120 +0,0 @@ -// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de> -// SPDX-License-Identifier: LGPL-3.0-or-later -#include <ChimeraTK/BackendFactory.h> -#include <ChimeraTK/BackendRegisterCatalogue.h> -#include <ChimeraTK/DeviceAccessVersion.h> -#include <ChimeraTK/DeviceBackendImpl.h> -#include <ChimeraTK/LNMBackendRegisterInfo.h> -#include <ChimeraTK/NDRegisterAccessor.h> - -template<typename UserType> -class TimerDummyRegisterAccessor; -namespace ctk = ChimeraTK; - -class TimerDummy : public ChimeraTK::DeviceBackendImpl { - public: - TimerDummy() : DeviceBackendImpl() { FILL_VIRTUAL_FUNCTION_TEMPLATE_VTABLE(getRegisterAccessor_impl); } - - static boost::shared_ptr<DeviceBackend> createInstance( - std::string /* address */, std::map<std::string, std::string> /* parameters */) { - return boost::shared_ptr<DeviceBackend>(new TimerDummy()); - } - - template<typename UserType> - boost::shared_ptr<ChimeraTK::NDRegisterAccessor<UserType>> getRegisterAccessor_impl( - const ChimeraTK::RegisterPath& registerPathName, size_t, size_t, ChimeraTK::AccessModeFlags flags); - DEFINE_VIRTUAL_FUNCTION_TEMPLATE_VTABLE_FILLER(TimerDummy, getRegisterAccessor_impl, 4); - - void open() override {} - - void close() override {} - - bool isFunctional() const override { return true; } - - void setException() override {} - - std::string readDeviceInfo() override { return std::string("Dummy timing device "); } - - // return just an empty Catalogue for interface compability - ctk::RegisterCatalogue getRegisterCatalogue() const override { - return ctk::RegisterCatalogue(std::make_unique<ctk::BackendRegisterCatalogue<ctk::LNMBackendRegisterInfo>>()); - } - - /** Class to register the backend type with the factory. */ - class BackendRegisterer { - public: - BackendRegisterer(); - }; - static BackendRegisterer backendRegisterer; -}; - -TimerDummy::BackendRegisterer TimerDummy::backendRegisterer; - -TimerDummy::BackendRegisterer::BackendRegisterer() { - std::cout << "TimerDummy::BackendRegisterer: registering backend type TimerDummy" << std::endl; - ChimeraTK::BackendFactory::getInstance().registerBackendType("TimerDummy", &TimerDummy::createInstance); -} - -template<typename UserType> -class TimerDummyRegisterAccessor : public ChimeraTK::NDRegisterAccessor<UserType> { - public: - TimerDummyRegisterAccessor(const ChimeraTK::RegisterPath& registerPathName) - : ChimeraTK::NDRegisterAccessor<UserType>(registerPathName, {ChimeraTK::AccessMode::wait_for_new_data}) { - ChimeraTK::NDRegisterAccessor<UserType>::buffer_2D.resize(1); - ChimeraTK::NDRegisterAccessor<UserType>::buffer_2D[0].resize(1); - ChimeraTK::NDRegisterAccessor<UserType>::buffer_2D[0][0] = UserType(); - - this->_readQueue = {3}; - } - - ~TimerDummyRegisterAccessor() override {} - - void doReadTransferSynchronously() override { usleep(1000000); } - - void doPostRead(ChimeraTK::TransferType, bool hasNewData) override { - if(!hasNewData) return; - ChimeraTK::NDRegisterAccessor<UserType>::buffer_2D[0][0]++; - this->_versionNumber = {}; - } - - bool doWriteTransfer(ChimeraTK::VersionNumber) override { return false; } - - bool isReadOnly() const override { return true; } - bool isReadable() const override { return true; } - bool isWriteable() const override { return false; } - - bool mayReplaceOther(const boost::shared_ptr<ChimeraTK::TransferElement const>&) const override { return false; } - - std::vector<boost::shared_ptr<ChimeraTK::TransferElement>> getHardwareAccessingElements() override { - return {this->shared_from_this()}; - } - - void replaceTransferElement(boost::shared_ptr<ChimeraTK::TransferElement>) override {} - - std::list<boost::shared_ptr<ChimeraTK::TransferElement>> getInternalElements() override { return {}; } - - private: - boost::thread _timerThread; -}; - -template<> -void TimerDummyRegisterAccessor<std::string>::doPostRead(ChimeraTK::TransferType, bool /*hasNewData*/) { - this->_versionNumber = {}; -} -template<> -void TimerDummyRegisterAccessor<ChimeraTK::Boolean>::doPostRead(ChimeraTK::TransferType, bool /*hasNewData*/) { - this->_versionNumber = {}; -} -template<> -void TimerDummyRegisterAccessor<ChimeraTK::Void>::doPostRead(ChimeraTK::TransferType, bool /*hasNewData*/) { - this->_versionNumber = {}; -} - -template<typename UserType> -boost::shared_ptr<ChimeraTK::NDRegisterAccessor<UserType>> TimerDummy::getRegisterAccessor_impl( - const ChimeraTK::RegisterPath& registerPathName, size_t, size_t, ChimeraTK::AccessModeFlags flags) { - assert(registerPathName == "/macropulseNr"); - flags.checkForUnknownFlags({ChimeraTK::AccessMode::wait_for_new_data}); - return boost::shared_ptr<ChimeraTK::NDRegisterAccessor<UserType>>( - new TimerDummyRegisterAccessor<UserType>(registerPathName)); -} diff --git a/example/config/DemoDummy.map b/example/config/DemoDummy.map index f3ceb181..9c8f8e1f 100644 --- a/example/config/DemoDummy.map +++ b/example/config/DemoDummy.map @@ -1,4 +1,10 @@ -# name nr of elements address size bar width fracbits signed -setpointTable 16384 0 65536 0 32 0 0 -feedforwardTable 16384 0 65536 1 32 0 0 -probeSignal 16384 0 65536 2 32 0 0 +# name nr of elements address size bar width fracbits signed R/W +HEATER.MODE 1 0 4 0 2 0 0 RW +HEATER.CURRENT_SET 1 4 4 0 32 16 0 RW +HEATER.CURRENT_READBACK 1 8 4 0 32 16 0 RO +SENSORS.TEMPERATURE1 1 16 4 0 32 16 0 RO +SENSORS.TEMPERATURE2 1 20 4 0 32 16 0 RO +SENSORS.TEMPERATURE3 1 24 4 0 32 16 0 RO +SENSORS.TEMPERATURE4 1 28 4 0 32 16 0 RO +BOARD.RESET_N 1 32 4 0 1 0 0 RW +BOARD.GPIO_OUT0 1 36 4 0 1 0 0 RW \ No newline at end of file diff --git a/example/config/TimerDummy.map b/example/config/TimerDummy.map deleted file mode 100644 index 5541646b..00000000 --- a/example/config/TimerDummy.map +++ /dev/null @@ -1,2 +0,0 @@ -# name nr of elements address size bar width fracbits signed -macropulseNr 1 0 4 0 32 0 0 diff --git a/example2a/config/exampleApp2a-DoocsVariableConfig.xml b/example/config/demo_example-DoocsVariableConfig.xml similarity index 86% rename from example2a/config/exampleApp2a-DoocsVariableConfig.xml rename to example/config/demo_example-DoocsVariableConfig.xml index 1687a42b..8a4c0fa7 100644 --- a/example2a/config/exampleApp2a-DoocsVariableConfig.xml +++ b/example/config/demo_example-DoocsVariableConfig.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <device_server xmlns="https://github.com/ChimeraTK/ControlSystemAdapter-DoocsAdapter"> - <location name="Bakery"> + <location name="DEMO"> <import>/</import> </location> </device_server> diff --git a/example/config/demo_example-config.xml b/example/config/demo_example-config.xml new file mode 100644 index 00000000..4cee8da1 --- /dev/null +++ b/example/config/demo_example-config.xml @@ -0,0 +1,16 @@ +<configuration> + + <module name="Configuration"> + <variable name="enableSetpointRamping" type="boolean" value="true"/> + <variable name="heaterMode" type="uint8" value="2"/> + </module> + + <module name="Information"> + <variable name="ovenName" type="string" value="Cookie Oven 42"/> + </module> + + <module name="Timer"> + <variable name="period" type="uint32" value="500"/> + </module> + +</configuration> \ No newline at end of file diff --git a/example/config/demo_example.dmap b/example/config/demo_example.dmap new file mode 100644 index 00000000..b483bb2a --- /dev/null +++ b/example/config/demo_example.dmap @@ -0,0 +1,2 @@ +device (sharedMemoryDummy:0?map=DemoDummy.map) +oven (logicalNameMap?map=oven.xlmap) diff --git a/example/config/dummy.dmap b/example/config/dummy.dmap deleted file mode 100644 index 5ac270d4..00000000 --- a/example/config/dummy.dmap +++ /dev/null @@ -1,2 +0,0 @@ -Device (DemoDummy:0?map=DemoDummy.map) -Timer (TimerDummy:0?map=TimerDummy.map) diff --git a/example/config/exampleApp-DoocsVariableConfig.xml b/example/config/exampleApp-DoocsVariableConfig.xml deleted file mode 100644 index cf202059..00000000 --- a/example/config/exampleApp-DoocsVariableConfig.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<device_server xmlns="https://github.com/ChimeraTK/ControlSystemAdapter-DoocsAdapter"> - <location name="THE_ONLY_LOCATION"> - <import>/</import> - </location> -</device_server> diff --git a/example/config/oven.xlmap b/example/config/oven.xlmap new file mode 100644 index 00000000..51689773 --- /dev/null +++ b/example/config/oven.xlmap @@ -0,0 +1,57 @@ +<logicalNameMap> + + <module name="Configuration"> + + <redirectedRegister name="heaterMode"> + <targetDevice>device</targetDevice> + <targetRegister>HEATER.MODE</targetRegister> + </redirectedRegister> + + <redirectedRegister name="lightOn"> + <targetDevice>device</targetDevice> + <targetRegister>BOARD.GPIO_OUT0</targetRegister> + </redirectedRegister> + + </module> + + <module name="ControlUnit"> + <module name="Controller"> + + <redirectedRegister name="heatingCurrent"> + <targetDevice>device</targetDevice> + <targetRegister>HEATER.CURRENT_SET</targetRegister> + </redirectedRegister> + + <redirectedRegister name="temperatureReadback"> + <targetDevice>device</targetDevice> + <targetRegister>SENSORS.TEMPERATURE1</targetRegister> + </redirectedRegister> + + </module> + </module> + + <module name="Monitoring"> + + <redirectedRegister name="heatingCurrent"> + <targetDevice>device</targetDevice> + <targetRegister>HEATER.CURRENT_READBACK</targetRegister> + </redirectedRegister> + + <redirectedRegister name="temperatureOvenTop"> + <targetDevice>device</targetDevice> + <targetRegister>SENSORS.TEMPERATURE2</targetRegister> + </redirectedRegister> + + <redirectedRegister name="temperatureOvenBottom"> + <targetDevice>device</targetDevice> + <targetRegister>SENSORS.TEMPERATURE3</targetRegister> + </redirectedRegister> + + <redirectedRegister name="temperatureOutside"> + <targetDevice>device</targetDevice> + <targetRegister>SENSORS.TEMPERATURE4</targetRegister> + </redirectedRegister> + + </module> + +</logicalNameMap> diff --git a/example/config/ovenInit.py b/example/config/ovenInit.py new file mode 100755 index 00000000..d3f9a22c --- /dev/null +++ b/example/config/ovenInit.py @@ -0,0 +1,19 @@ +#!/bin/env python3 +import deviceaccess as da +import time + +# Set DMAP file name +da.setDMapFilePath("demo_example.dmap") + +# Open the oven device directly, without logical name mapping, to access all registers +dev = da.Device("device") +dev.open() + +# reset the device +print("Resetting oven device...") +dev.write("BOARD.RESET_N", 0) +time.sleep(0.1) +dev.write("BOARD.RESET_N", 1) + +# (inverted) reset line is released now. Additional initialisation would go here. +print("Reset done, device is now ready.") diff --git a/example/demoApp.cc b/example/demoApp.cc deleted file mode 100644 index f34c54dd..00000000 --- a/example/demoApp.cc +++ /dev/null @@ -1,79 +0,0 @@ -// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de> -// SPDX-License-Identifier: LGPL-3.0-or-later -#include <ChimeraTK/ApplicationCore/ApplicationCore.h> -#include <ChimeraTK/ApplicationCore/EnableXMLGenerator.h> - -#include <iostream> - -namespace ctk = ChimeraTK; - -struct Automation : public ctk::ApplicationModule { - using ctk::ApplicationModule::ApplicationModule; - ctk::ScalarPollInput<double> opSP{this, "opSP", "MV", "..."}; - ctk::ScalarOutput<double> curSP{this, "curSP", "MV", "..."}; - ctk::ScalarPushInput<int> trigger{this, "trigger", "", "..."}; - - void mainLoop() { - while(true) { - trigger.read(); - opSP.readLatest(); // opSP.read() would be equivalent - if(std::abs(opSP - curSP) > 0.01) { - curSP += std::max(std::min(opSP - curSP, 0.1), -0.1); - curSP.write(); - } - } - } -}; - -constexpr size_t tableLength{16384}; -constexpr double samplingFrequency = 9.0; // MHz -constexpr double bitScalingFactor = 2000.0; // bits/MV - -struct TableGeneration : public ctk::ApplicationModule { - using ctk::ApplicationModule::ApplicationModule; - struct TableParameters : public ctk::VariableGroup { - using ctk::VariableGroup::VariableGroup; - ctk::ScalarPushInput<double> pulseLength{this, "pulseLength", "us", "..."}; - ctk::ScalarPushInput<double> setpoint{this, "setpoint", "MV", "..."}; - }; - TableParameters tableParameters{this, "tableParameters", "..."}; - - ctk::ArrayOutput<int32_t> setpointTable{this, "setpointTable", "bits", tableLength, "..."}; - ctk::ArrayOutput<int32_t> feedforwardTable{this, "feedforwardTable", "bits", tableLength, "..."}; - - void mainLoop() { - ctk::ReadAnyGroup tableParametersReadGroup = tableParameters.readAnyGroup(); - while(true) { - tableParametersReadGroup.readAny(); // block until the any table parameter is changed - - for(size_t i = 0; i < tableLength; ++i) { - if(i < tableParameters.pulseLength * samplingFrequency) { - setpointTable[i] = tableParameters.setpoint * bitScalingFactor; - feedforwardTable[i] = 0.5 * tableParameters.setpoint * bitScalingFactor; - } - else { - setpointTable[i] = 0; - feedforwardTable[i] = 0; - } - } - - setpointTable.write(); - feedforwardTable.write(); - } - } -}; - -struct ExampleApp : public ctk::Application { - ExampleApp() : Application("exampleApp") {} - ~ExampleApp() { shutdown(); } - - ctk::SetDMapFilePath dmapPath{"dummy.dmap"}; - - Automation automation{this, "automation", "..."}; - TableGeneration tableGeneration{this, "tableGeneration", "..."}; - // ctk::DeviceModule dev{this, "Device"}; - ctk::DeviceModule dev{this, "Device"}; - // ctk::DeviceModule timer{this, "Timer"}; - ctk::DeviceModule timer{this, "Timer"}; -}; -ExampleApp theExampleApp; diff --git a/example/include/AverageCurrent.h b/example/include/AverageCurrent.h new file mode 100644 index 00000000..4c4776f7 --- /dev/null +++ b/example/include/AverageCurrent.h @@ -0,0 +1,31 @@ +// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de> +// SPDX-License-Identifier: LGPL-3.0-or-later +#pragma once + +/* + * This example is explained as part of the \ref conceptualOverview. Please refere there for step-by-step explanations. + * Reading the full example might not be a good starting point for learning ApplicationCore as it can be overwelming + * and lacks important background information. + * + * Please ignore all comments of the format "//! [some name]", those are used for Doxygen to include code snippets in + * the documentation pages. + */ + +#include <ChimeraTK/ApplicationCore/ApplicationCore.h> + +namespace ctk = ChimeraTK; + +//! [Snippet: Class Definition] +class AverageCurrent : public ctk::ApplicationModule { + using ctk::ApplicationModule::ApplicationModule; + + // Take the heaterCurrent from the Controller module as an input + //! [Snippet: heatingCurrent Definition] + ctk::ScalarPushInput<float> current{this, "../Controller/heatingCurrent", "mA", "Actuator output of the controller"}; + //! [Snippet: heatingCurrent Definition] + + ctk::ScalarOutput<float> currentAveraged{this, "heatingCurrentAveraged", "mA", "Averaged heating current"}; + + void mainLoop() override; +}; +//! [Snippet: Class Definition] diff --git a/example/include/Controller.h b/example/include/Controller.h new file mode 100644 index 00000000..f82f0212 --- /dev/null +++ b/example/include/Controller.h @@ -0,0 +1,30 @@ +// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de> +// SPDX-License-Identifier: LGPL-3.0-or-later +#pragma once + +/* + * This example is explained as part of the \ref conceptualOverview. Please refere there for step-by-step explanations. + * Reading the full example might not be a good starting point for learning ApplicationCore as it can be overwelming + * and lacks important background information. + * + * Please ignore all comments of the format "//! [some name]", those are used for Doxygen to include code snippets in + * the documentation pages. + */ + +#include <ChimeraTK/ApplicationCore/ApplicationCore.h> + +namespace ctk = ChimeraTK; + +//! [Snippet: Class Definition] +class Controller : public ctk::ApplicationModule { + using ctk::ApplicationModule::ApplicationModule; + + ctk::ScalarPollInput<float> temperatureSetpoint{ + this, "temperatureSetpoint", "degC", "Setpoint for the temperature controller"}; + ctk::ScalarPushInput<float> temperatureReadback{ + this, "temperatureReadback", "degC", "Actual temperature used as controller input"}; + ctk::ScalarOutput<float> heatingCurrent{this, "heatingCurrent", "mA", "Actuator output of the controller"}; + + void mainLoop() override; +}; +//! [Snippet: Class Definition] diff --git a/example/include/ExampleApp.h b/example/include/ExampleApp.h new file mode 100644 index 00000000..3aad33a1 --- /dev/null +++ b/example/include/ExampleApp.h @@ -0,0 +1,83 @@ +// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de> +// SPDX-License-Identifier: LGPL-3.0-or-later +#pragma once + +/* + * This example is explained as part of the \ref conceptualOverview. Please refere there for step-by-step explanations. + * Reading the full example might not be a good starting point for learning ApplicationCore as it can be overwelming + * and lacks important background information. + * + * Please ignore all comments of the format "//! [some name]", those are used for Doxygen to include code snippets in + * the documentation pages. + */ + +#include "AverageCurrent.h" +#include "Controller.h" +#include "SetpointRamp.h" + +#include <ChimeraTK/ApplicationCore/ApplicationCore.h> +#include <ChimeraTK/ApplicationCore/ConfigReader.h> +#include <ChimeraTK/ApplicationCore/PeriodicTrigger.h> +#include <ChimeraTK/ApplicationCore/ScriptedInitialisationHandler.h> + +namespace ctk = ChimeraTK; + +//! [Snippet: Class Definition Start] +class ExampleApp : public ctk::Application { + public: + using ctk::Application::Application; + ~ExampleApp() override; + + private: + //! [Snippet: Class Definition Start] + // Set the name of the DMAP file to define the devices. Must be done before instantiating any DeviceModule. + // Using the application name as a base helps for automated testing against different config files. + //! [Snippet: SetDMapFilePath] + ctk::SetDMapFilePath dmapPath{getName() + ".dmap"}; + //! [Snippet: SetDMapFilePath] + + // Provide configuration constants as process variables and for use at construction phase + // Using the application name as a base helps for automated testing against different config files. + ctk::ConfigReader config{this, "/", getName() + "-config.xml"}; + + // Periodic trigger used to readout data from the device periodically. + //! [Snippet: PeriodicTrigger Instance] + ctk::PeriodicTrigger timer{this, "Timer", "Periodic timer for the controller"}; + //! [Snippet: PeriodicTrigger Instance] + + // Publish the content of the device "oven" defined in the DMAP file to the control system and to the application + // modules. The "tick" output of the PeriodicTimer "Timer" defined above is used as a readout trigger (for all + // poll-typed device registers). + //! [Snippet: Device] + ctk::DeviceModule oven{this, "oven", "/Timer/tick"}; + //! [Snippet: Device] + + // Initialisation handler: execute Python script to initialise oven device + //! [Snippet: ScriptedInitHandler] + ctk::ScriptedInitHandler ovenInit{this, "ovenInit", "Initialisation of oven device", "./ovenInit.py", oven}; + //! [Snippet: ScriptedInitHandler] + + //! [Snippet: ControlUnit ModuleGroup] + struct ControlUnit : ctk::ModuleGroup { + using ctk::ModuleGroup::ModuleGroup; + + //! [Snippet: Controller Instance] + // Instantiate the temperature controller module + Controller controller{this, "Controller", "The temperature controller"}; + //! [Snippet: Controller Instance] + + //! [Snippet: AverageCurrent Instance] + // Instantiate the heater current averaging module + AverageCurrent averageCurrent{this, "AverageCurrent", "Provide averaged heater current"}; + //! [Snippet: AverageCurrent Instance] + }; + ControlUnit controlUnit{this, "ControlUnit", "Unit for controlling the oven temperature"}; + //! [Snippet: ControlUnit ModuleGroup] + + // Optionally instantiate the automated setpoint ramping module + SetpointRamp ramp{config.get<ChimeraTK::Boolean>("Configuration/enableSetpointRamping") ? + SetpointRamp(this, "SetpointRamp", "Slow ramping of temperator setpoint") : + SetpointRamp()}; + //! [Snippet: Class Definition End] +}; +//! [Snippet: Class Definition End] diff --git a/example/include/SetpointRamp.h b/example/include/SetpointRamp.h new file mode 100644 index 00000000..13ada979 --- /dev/null +++ b/example/include/SetpointRamp.h @@ -0,0 +1,33 @@ +// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de> +// SPDX-License-Identifier: LGPL-3.0-or-later +#pragma once + +/* + * This example is explained as part of the \ref conceptualOverview. Please refere there for step-by-step explanations. + * Reading the full example might not be a good starting point for learning ApplicationCore as it can be overwelming + * and lacks important background information. + * + * Please ignore all comments of the format "//! [some name]", those are used for Doxygen to include code snippets in + * the documentation pages. + */ + +#include <ChimeraTK/ApplicationCore/ApplicationCore.h> + +namespace ctk = ChimeraTK; + +class SetpointRamp : public ctk::ApplicationModule { + using ctk::ApplicationModule::ApplicationModule; + + ctk::ScalarPollInput<float> operatorSetpoint{this, "operatorSetpoint", "degC", "..."}; + + struct ControllerInterface : ctk::VariableGroup { + using ctk::VariableGroup::VariableGroup; + ctk::ScalarOutput<float> actualSetpoint{this, "temperatureSetpoint", "degC", "..."}; + }; + + ControllerInterface ctrl{this, "/ControlUnit/Controller", ""}; + + ctk::ScalarPushInput<uint64_t> trigger{this, "/Timer/tick", "", "..."}; + + void mainLoop() override; +}; diff --git a/example/pyproject.toml b/example/pyproject.toml new file mode 120000 index 00000000..1e11d782 --- /dev/null +++ b/example/pyproject.toml @@ -0,0 +1 @@ +../pyproject.toml \ No newline at end of file diff --git a/example/src/AverageCurrent.cc b/example/src/AverageCurrent.cc new file mode 100644 index 00000000..06383fbd --- /dev/null +++ b/example/src/AverageCurrent.cc @@ -0,0 +1,33 @@ +// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de> +// SPDX-License-Identifier: LGPL-3.0-or-later + +#include "AverageCurrent.h" + +/* + * This example is explained as part of the \ref conceptualOverview. Please refere there for step-by-step explanations. + * Reading the full example might not be a good starting point for learning ApplicationCore as it can be overwelming + * and lacks important background information. + * + * Please ignore all comments of the format "//! [some name]", those are used for Doxygen to include code snippets in + * the documentation pages. + */ + +/*********************************************************************************************************************/ + +//! [Snippet: mainLoop implementation] +void AverageCurrent::mainLoop() { + const float coeff = 0.1; + currentAveraged.setAndWrite(current); // initialise currentAveraged with initial value + + while(true) { + current.read(); + + // Often, it can be considered a good practise to only write values if they have actually changed. This will + // prevent subsequent computations from running unneccessarily. On the other hand, it may prevent receivers from + // getting a consistent "snapshot" for each trigger. This has to be decided case by case. + currentAveraged.writeIfDifferent((1 - coeff) * currentAveraged + coeff * current); + } +} +//! [Snippet: mainLoop implementation] + +/*********************************************************************************************************************/ diff --git a/example/src/Controller.cc b/example/src/Controller.cc new file mode 100644 index 00000000..a16a01b1 --- /dev/null +++ b/example/src/Controller.cc @@ -0,0 +1,29 @@ +// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de> +// SPDX-License-Identifier: LGPL-3.0-or-later + +#include "Controller.h" + +/* + * This example is explained as part of the \ref conceptualOverview. Please refere there for step-by-step explanations. + * Reading the full example might not be a good starting point for learning ApplicationCore as it can be overwelming + * and lacks important background information. + * + * Please ignore all comments of the format "//! [some name]", those are used for Doxygen to include code snippets in + * the documentation pages. + */ + +/*********************************************************************************************************************/ + +//! [Snippet: mainLoop implementation] +void Controller::mainLoop() { + const float gain = 100.0F; + while(true) { + heatingCurrent = gain * (temperatureSetpoint - temperatureReadback); + writeAll(); // writes any outputs + + readAll(); // waits until temperatureReadback updated, then reads temperatureSetpoint + } +} +//! [Snippet: mainLoop implementation] + +/*********************************************************************************************************************/ diff --git a/example/src/ExampleApp.cc b/example/src/ExampleApp.cc new file mode 100644 index 00000000..39401e05 --- /dev/null +++ b/example/src/ExampleApp.cc @@ -0,0 +1,23 @@ +// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de> +// SPDX-License-Identifier: LGPL-3.0-or-later + +/* + * This example is explained as part of the \ref conceptualOverview. Please refere there for step-by-step explanations. + * Reading the full example might not be a good starting point for learning ApplicationCore as it can be overwelming + * and lacks important background information. + * + * Please ignore all comments of the format "//! [some name]", those are used for Doxygen to include code snippets in + * the documentation pages. + */ + +#include "ExampleApp.h" + +/*********************************************************************************************************************/ + +//! [Snippet: Destructor] +ExampleApp::~ExampleApp() { + shutdown(); +} +//! [Snippet: Destructor] + +/*********************************************************************************************************************/ diff --git a/example/src/SetpointRamp.cc b/example/src/SetpointRamp.cc new file mode 100644 index 00000000..7776eba9 --- /dev/null +++ b/example/src/SetpointRamp.cc @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de> +// SPDX-License-Identifier: LGPL-3.0-or-later + +/* + * This example is explained as part of the \ref conceptualOverview. Please refere there for step-by-step explanations. + * Reading the full example might not be a good starting point for learning ApplicationCore as it can be overwelming + * and lacks important background information. + * + * Please ignore all comments of the format "//! [some name]", those are used for Doxygen to include code snippets in + * the documentation pages. + */ + +#include "SetpointRamp.h" + +/*********************************************************************************************************************/ + +void SetpointRamp::mainLoop() { + const float maxStep = 0.1F; + while(true) { + readAll(); // waits until trigger received, then read operatorSetpoint + ctrl.actualSetpoint += std::max(std::min(operatorSetpoint - ctrl.actualSetpoint, maxStep), -maxStep); + writeAll(); + } +} + +/*********************************************************************************************************************/ diff --git a/example/src_factory/FactoryInstance.cc b/example/src_factory/FactoryInstance.cc new file mode 100644 index 00000000..6a2a92e7 --- /dev/null +++ b/example/src_factory/FactoryInstance.cc @@ -0,0 +1,21 @@ +// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de> +// SPDX-License-Identifier: LGPL-3.0-or-later + +/* + * This example is explained as part of the \ref conceptualOverview. Please refere there for step-by-step explanations. + * Reading the full example might not be a good starting point for learning ApplicationCore as it can be overwelming + * and lacks important background information. + * + * Please ignore all comments of the format "//! [some name]", those are used for Doxygen to include code snippets in + * the documentation pages. + */ + +#include "ExampleApp.h" + +#include <ChimeraTK/ApplicationCore/EnableXMLGenerator.h> + +/*********************************************************************************************************************/ + +static ctk::ApplicationFactory<ExampleApp> appFactory("demo_example"); + +/*********************************************************************************************************************/ diff --git a/example2/CMakeLists.txt b/example2/CMakeLists.txt deleted file mode 100644 index 015fa47e..00000000 --- a/example2/CMakeLists.txt +++ /dev/null @@ -1,56 +0,0 @@ -# Note: This CMakeLists.txt is a minimal complete example how to use the -# *installed* application core library. It is not included from the main CMakeLists.txt -# which is used to build ApplicationCore itself. -PROJECT(demo_example2) - -CMAKE_MINIMUM_REQUIRED(VERSION 3.16) - -# Use the project template to get the settings required for an application core project -set(${PROJECT_NAME}_MAJOR_VERSION 01) -set(${PROJECT_NAME}_MINOR_VERSION 00) -set(${PROJECT_NAME}_PATCH_VERSION 00) -include(cmake/set_version_numbers.cmake) - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules) -include(cmake/set_default_build_to_release.cmake) -include(cmake/set_default_flags.cmake) - -# Add the dependencies. We need ApplicationCore and a control system adapter implementation. -find_package(ChimeraTK-ApplicationCore 03.01 REQUIRED) - -# Use cmake option -DADAPTER=DOOCS, -DADAPTER=OPCUA or -DADAPTER=EPICSIOC to select a -# control system adapter implementation. -include(cmake/set_control_system_adapter.cmake) - -AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR} demo_sources) - -# The server proper. It depends on application core and the control system adapter implementation. -add_executable(${PROJECT_NAME} ${demo_sources}) -target_link_libraries(${PROJECT_NAME} PRIVATE ChimeraTK::ChimeraTK-ApplicationCore ChimeraTK::SelectedAdapter) - -# We compile the same sources with the GENERATE_XML flag to get an xml generator. -# This one does not depent on a control system adapter implementation. -add_executable(${PROJECT_NAME}-xmlGenerator ${demo_sources}) -target_compile_options(${PROJECT_NAME}-xmlGenerator PRIVATE "-DGENERATE_XML") -target_link_libraries(${PROJECT_NAME}-xmlGenerator PRIVATE ChimeraTK::ChimeraTK-ApplicationCore) - -# copy the (test) config files and the test simulation to the build directory for tests -FILE( COPY config/ DESTINATION ${PROJECT_BINARY_DIR}) -FILE( COPY oven_sim/ DESTINATION ${PROJECT_BINARY_DIR}) - -# Tests: -# There are no dedicated tests for this demo. But we run the xml generator to -# check that the variable household can successfully be initialised. -# The test will fail if the xml generator crashes, just a smoke test. -ENABLE_TESTING() -add_test(${PROJECT_NAME}-xmlGenerator ${PROJECT_NAME}-xmlGenerator) - -# Installation: -# FIXME: For doocs we need a special treatment when installing to /export/doocs/server (don't install to bin subdirectory, but a directory named like the server). This should go to the project template. -if("${CMAKE_INSTALL_PREFIX}" STREQUAL "/export/doocs/server") - install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}-xmlGenerator RUNTIME DESTINATION ${PROJECT_NAME}) -else() - install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}-xmlGenerator RUNTIME DESTINATION bin) -endif() -# Do not install the config. It is only a test config. -# The real config will come from a config generator and usually depends on the instance. diff --git a/example2/COPYING b/example2/COPYING deleted file mode 120000 index 012065c8..00000000 --- a/example2/COPYING +++ /dev/null @@ -1 +0,0 @@ -../COPYING \ No newline at end of file diff --git a/example2/COPYING.LESSER b/example2/COPYING.LESSER deleted file mode 120000 index ce9a3ce2..00000000 --- a/example2/COPYING.LESSER +++ /dev/null @@ -1 +0,0 @@ -../COPYING.LESSER \ No newline at end of file diff --git a/example2/This_project_uses_the_project-template.txt b/example2/This_project_uses_the_project-template.txt deleted file mode 120000 index 606f6262..00000000 --- a/example2/This_project_uses_the_project-template.txt +++ /dev/null @@ -1 +0,0 @@ -../This_project_uses_the_project-template.txt \ No newline at end of file diff --git a/example2/cmake b/example2/cmake deleted file mode 120000 index 8e8a460f..00000000 --- a/example2/cmake +++ /dev/null @@ -1 +0,0 @@ -../cmake/ \ No newline at end of file diff --git a/example2/config/demoApp2-DoocsVariableConfig.xml b/example2/config/demoApp2-DoocsVariableConfig.xml deleted file mode 100644 index 4ebac497..00000000 --- a/example2/config/demoApp2-DoocsVariableConfig.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<device_server xmlns="https://github.com/ChimeraTK/ControlSystemAdapter-DoocsAdapter"> - <location name="TestOven"> - <import>/</import> - </location> -</device_server> diff --git a/example2/config/demo_example2.conf b/example2/config/demo_example2.conf deleted file mode 100644 index aff09d05..00000000 --- a/example2/config/demo_example2.conf +++ /dev/null @@ -1,8 +0,0 @@ -eq_conf: - -eq_fct_name: "LOCAHOST._SVR" -eq_fct_type: 1 -{ -SVR.RPC_NUMBER: 610498009 -SVR.RATE: 6 0 0 0 -} diff --git a/example2/config/example2.dmap b/example2/config/example2.dmap deleted file mode 100644 index 33f6cbf3..00000000 --- a/example2/config/example2.dmap +++ /dev/null @@ -1,2 +0,0 @@ -oven (sharedMemoryDummy?map=oven.map) - diff --git a/example2/config/oven.map b/example2/config/oven.map deleted file mode 100644 index 0ebcde87..00000000 --- a/example2/config/oven.map +++ /dev/null @@ -1,5 +0,0 @@ -# name nr of elements address size bar width fracbits signed R/W -Heater.temperatureReadback 1 0 4 0 32 16 0 RO -Heater.heatingCurrent 1 4 4 0 32 16 0 RW -Heater.supplyVoltages 4 8 16 0 32 16 0 RO - diff --git a/example2/demoApp2.cc b/example2/demoApp2.cc deleted file mode 100644 index 512e9088..00000000 --- a/example2/demoApp2.cc +++ /dev/null @@ -1,40 +0,0 @@ -// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de> -// SPDX-License-Identifier: LGPL-3.0-or-later -#include <ChimeraTK/ApplicationCore/ApplicationCore.h> -#include <ChimeraTK/ApplicationCore/EnableXMLGenerator.h> -#include <ChimeraTK/ApplicationCore/PeriodicTrigger.h> - -namespace ctk = ChimeraTK; - -struct Controller : public ctk::ApplicationModule { - using ctk::ApplicationModule::ApplicationModule; - ctk::ScalarPollInput<float> sp{this, "temperatureSetpoint", "degC", "Description"}; - ctk::ScalarPushInput<float> rb{this, "temperatureReadback", "degC", "..."}; - ctk::ScalarOutput<float> cur{this, "heatingCurrent", "mA", "..."}; - - void mainLoop() { - const float gain = 100.0; - while(true) { - readAll(); // waits until rb updated, then reads sp - - cur = gain * (sp - rb); - writeAll(); // writes any outputs - } - } -}; - -struct ExampleApp : public ctk::Application { - ExampleApp() : Application("demoApp2") {} - ~ExampleApp() { shutdown(); } - - ctk::SetDMapFilePath dmapPath{"example2.dmap"}; - - ctk::PeriodicTrigger timer{this, "Timer", "Periodic timer for the controller", 1000}; - // Look at the map file: This device provides "Heater/temperatureReadback" and "Heater/heatingCurrent". - ctk::DeviceModule oven{this, "oven", "/Timer/tick"}; - // Pick the name "Heater" for the controller module. Now the variable "Heater/temperatureReadback" and - // "Heater/heatingCurrent" are automatically connected to the matching variables on the device. - Controller controller{this, "Heater", "A controller for the heater of the oven."}; -}; - -static ExampleApp theExampleApp; diff --git a/example2/oven_sim/oven_sim.py b/example2/oven_sim/oven_sim.py deleted file mode 100755 index f0e073ed..00000000 --- a/example2/oven_sim/oven_sim.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/python3 - -import mtca4u -import time - -mtca4u.set_dmap_location('example2.dmap') -d=mtca4u.Device('oven') - -#cooling rate c -c=0.001 #deg /(deg*s) - -#heating rate h -h=0.0003 #deg/(A*s) - -ovenTemp = 25. -environment = 25. - -while True: - I=d.read('Heater','heatingCurrent')[0] - tempChange = 1 * (I*h + (environment-ovenTemp)*c) - # 1s current*heating rate deltaT * cooling rate - - ovenTemp = ovenTemp + tempChange - d.write('Heater','temperatureReadback.DUMMY_WRITEABLE',ovenTemp) - print('change ' + str(tempChange) +', new temp ' +str(ovenTemp)) - - time.sleep(1) diff --git a/example2a/CMakeLists.txt b/example2a/CMakeLists.txt deleted file mode 100644 index 1ef8a1ab..00000000 --- a/example2a/CMakeLists.txt +++ /dev/null @@ -1,56 +0,0 @@ -# Note: This CMakeLists.txt is a minimal complete example how to use the -# *installed* application core library. It is not included from the main CMakeLists.txt -# which is used to build ApplicationCore itself. -PROJECT(demo_example2a) - -CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1) - -# Use the project template to get the settings required for an application core project -set(${PROJECT_NAME}_MAJOR_VERSION 01) -set(${PROJECT_NAME}_MINOR_VERSION 00) -set(${PROJECT_NAME}_PATCH_VERSION 00) -include(cmake/set_version_numbers.cmake) - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules) -include(cmake/add_dependency.cmake) -include(cmake/set_default_build_to_release.cmake) -include(cmake/set_default_flags.cmake) - -# Add the dependencies. We need ApplicationCore and a control system adapter implementation. -add_dependency(ChimeraTK-ApplicationCore 03.00 REQUIRED) -#FIXME: Make the adapter configurable via command line parameter -add_dependency(ChimeraTK-ControlSystemAdapter-DoocsAdapter 00.10 REQUIRED) - -AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR} demo_sources) - -# The server proper. It depends on application core and the control system adapter implementation. -add_executable(${PROJECT_NAME} ${demo_sources}) -set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "${ChimeraTK-ApplicationCore_LINK_FLAGS} ${ChimeraTK-ControlSystemAdapter-DoocsAdapter_LINK_FLAGS}") - target_link_libraries(${PROJECT_NAME} ${ChimeraTK-ApplicationCore_LIBRARIES} ${ChimeraTK-ControlSystemAdapter-DoocsAdapter_LIBRARIES} ) - -# We compile the same sources with the GENERATE_XML flag to get an xml generator. -# This one does not depent on a control system adapter implementation. -add_executable(${PROJECT_NAME}-xmlGenerator ${demo_sources}) -set_target_properties( ${PROJECT_NAME}-xmlGenerator PROPERTIES COMPILE_FLAGS "-DGENERATE_XML") -set_target_properties(${PROJECT_NAME}-xmlGenerator PROPERTIES LINK_FLAGS "${ChimeraTK-ApplicationCore_LINK_FLAGS}") -target_link_libraries(${PROJECT_NAME}-xmlGenerator ${ChimeraTK-ApplicationCore_LIBRARIES}) - -# copy the (test) config files to the build directory for tests -FILE( COPY config/ DESTINATION ${PROJECT_BINARY_DIR}) - -# Tests: -# There are no dedicated tests for this demo. But we run the xml generator to -# check that the variable household can successfully be initialised. -# The test will fail if the xml generator crashes, just a smoke test. -ENABLE_TESTING() -add_test(${PROJECT_NAME}-xmlGenerator ${PROJECT_NAME}-xmlGenerator) - -# Installation: -# FIXME: For doocs we need a special treatment when installing to /export/doocs/server (don't install to bin subdirectory, but a directory named like the server). This should go to the project template. -if("${CMAKE_INSTALL_PREFIX}" STREQUAL "/export/doocs/server") - install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}-xmlGenerator RUNTIME DESTINATION ${PROJECT_NAME}) -else() - install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}-xmlGenerator RUNTIME DESTINATION bin) -endif() -# Do not install the config. It is only a test config. -# The real config will come from a config generator and usually depends on the instance. diff --git a/example2a/COPYING b/example2a/COPYING deleted file mode 120000 index 012065c8..00000000 --- a/example2a/COPYING +++ /dev/null @@ -1 +0,0 @@ -../COPYING \ No newline at end of file diff --git a/example2a/COPYING.LESSER b/example2a/COPYING.LESSER deleted file mode 120000 index ce9a3ce2..00000000 --- a/example2a/COPYING.LESSER +++ /dev/null @@ -1 +0,0 @@ -../COPYING.LESSER \ No newline at end of file diff --git a/example2a/This_project_uses_the_project-template.txt b/example2a/This_project_uses_the_project-template.txt deleted file mode 120000 index 606f6262..00000000 --- a/example2a/This_project_uses_the_project-template.txt +++ /dev/null @@ -1 +0,0 @@ -../This_project_uses_the_project-template.txt \ No newline at end of file diff --git a/example2a/cmake b/example2a/cmake deleted file mode 120000 index 8e8a460f..00000000 --- a/example2a/cmake +++ /dev/null @@ -1 +0,0 @@ -../cmake/ \ No newline at end of file diff --git a/example2a/config/demoApp2a.xml b/example2a/config/demoApp2a.xml deleted file mode 100644 index d35553f3..00000000 --- a/example2a/config/demoApp2a.xml +++ /dev/null @@ -1,4 +0,0 @@ -<configuration> - <variable name="enableAutomation" type="int32" value="1"/> -</configuration> - diff --git a/example2a/config/demo_example2a.conf b/example2a/config/demo_example2a.conf deleted file mode 100644 index 7fb375c6..00000000 --- a/example2a/config/demo_example2a.conf +++ /dev/null @@ -1,119 +0,0 @@ -# Conf file created at 17:08.38 13. Jun. 2016 -# eq_fct_type's are defined in eq_fct_code.h - -eq_conf: - -oper_uid: -1 -oper_gid: 422 -xpert_uid: 0 -xpert_gid: 0 -ring_buffer: 10000 -memory_buffer: 500 - -eq_fct_name: "NODENAME._SVR" -eq_fct_type: 1 -{ -SVR.NAME: "NODENAME._SVR" -STS: 0x1c -STS.ERROR: 0 -STS.NEWERROR: 1 -STS.ERRORMASK: 1 -STS.ONLINE: 1 -ERROR.STR: 0 0 0 1078761493 "" -SYS_MASK: 1 -FCT_CODE: 1 -FCT_PANEL: "" -X_POS: 0 -Z_POS: 0 -Z_POS.STRING: "" -DEVICE.INFO: 235672 0 0 0 "Device OK" -MESSAGE: "" -LAST_UPDATE: 1112798768 350 0 0 -LAST_USR1: 0 0 0 0 -SVR.ALIAS: 0 -SVR.ARCFLUSH: 0 -SVR.ARCFLUSH_B: 0 -SVR.UPDATE: 1465830518 -SVR.RATE: 1 0 0 0 -SVR.RESIZE: 200 -SVR.FILE: "demoApp.conf" -SVR.DESC: "" -SVR.PROGRAMMER: "mhier" -SVR.XMLFILE: "" -SVR.ERRORLOG: "/doocs/nodename/server/InstaCoSADevExample_server/InstaCoSADevExample_server.log" -SVR.STORE.RATE: 10 -SVR.STORE.AUTO: 4 -SVR.HOST_NAME: "mskpcx19821" -SVR.PROCESSNAME: "demoApp" -SVR.RPC_NUMBER: 610498009 -SVR.STARTTIME: 1465830430 -SVR.LIBINFO: "18.10.6" -SVR.LIBDATE: "Jun 2 13:38" -SVR.WDADDR: "" -SVR.CONTR: 0x0 -SVR.MUST_RUN: 0 -SVR.STOP_SVR: 0 -SVR.START_CMD: "" -SVR.RPC_CALL_TIME.COMMENT: "Time per Call" -SVR.RPC_CALL_TIME.EGU: 1 1 100000 0 "rate" -SVR.RPC_CALL_TIME.XEGU: 0 0 100 0 "ms" -SVR.UPDATE_TIME.COMMENT: "Time per Update" -SVR.UPDATE_TIME.EGU: 1 1 100000 0 "rate" -SVR.UPDATE_TIME.XEGU: 0 0 100 0 "ms" -SVR.USR1_TIME.COMMENT: "run time of SIGUSR1" -SVR.USR1_TIME.EGU: 1 1 1e+06 1427728880 "counts" -SVR.USR1_TIME.XEGU: 0 0 100 1427728880 "ms" -SVR.USR1_PERIOD.COMMENT: "time between SIGUSR1" -SVR.USR1_PERIOD.EGU: 1 1 1e+06 1427728880 "counts" -SVR.USR1_PERIOD.XEGU: 0 0 500 1427728880 "ms" -SVR.ARCH_GET_TIME.COMMENT: "time per archiver get" -SVR.ARCH_GET_TIME.EGU: 1 1 1e+06 1459338630 "counts" -SVR.ARCH_GET_TIME.XEGU: 0 0 100 1459338630 "ms" -SVR.LAFL: 0 -SVR.ERROR_COUNT: 0 -DEVICE.ONLINE: 1 -DEVICE.OFFLINE: 0 -SVR.DEVMAX: 0 -SVR.TINERUN: 0 -SVR.TINEVERS: "4.05.0009" -SVR.TINEPREF: "" -SVR.TINESUFF: "" -SVR.TINE_DBG: 0 -SVR.TINE_LOG: 0 -SVR.TINE_FEC: 0 0 0 0 "" -SVR.TINE_PORT: 0 -SVR.TINE_MTU: 1472 -SVR.TINE_CTSZ: 32 -SVR.TINE_MCTTL: 16 -SVR.TINE_BLIM: 1000 -SVR.TINE_CDLY: 20 -SVR.TINE_GROUP: 0 -SVR.FACILITY: "TEST.DOOCS" -SVR.DEVICE: "InstaCoSADevExample" -T_ZERO: 700 -SVR.BPN: 0 -SVR.SPR: 0 -} -eq_fct_name: "Bakery" -eq_fct_type: 10 -{ -NAME: "Bakery" -STS: 0xc -STS.ERROR: 0 -STS.NEWERROR: 1 -STS.ERRORMASK: 0 -STS.ONLINE: 1 -ERROR.STR: 0 0 0 1112798768 "ok" -SYS_MASK: 222 -FCT_CODE: 10 -FCT_PANEL: "" -X_POS: 0 -Z_POS: 0 -Z_POS.STRING: "" -DEVICE.INFO: 0 0 0 0 "HALLO" -MESSAGE: "" -LAST_UPDATE: 1465830518 750 0 0 -LAST_USR1: 0 0 0 0 -readback: 20 -setpoint: 10 -} diff --git a/example2a/config/example2.dmap b/example2a/config/example2.dmap deleted file mode 100644 index 33f6cbf3..00000000 --- a/example2a/config/example2.dmap +++ /dev/null @@ -1,2 +0,0 @@ -oven (sharedMemoryDummy?map=oven.map) - diff --git a/example2a/config/oven.map b/example2a/config/oven.map deleted file mode 100644 index 97a8aee9..00000000 --- a/example2a/config/oven.map +++ /dev/null @@ -1,4 +0,0 @@ -# name nr of elements address size bar width fracbits signed R/W -heater.temperatureReadback 1 0 4 0 32 16 0 RO -heater.heatingCurrent 1 4 4 0 32 16 0 RW - diff --git a/example2a/demoApp2a.cc b/example2a/demoApp2a.cc deleted file mode 100644 index 19cd4da6..00000000 --- a/example2a/demoApp2a.cc +++ /dev/null @@ -1,65 +0,0 @@ -// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de> -// SPDX-License-Identifier: LGPL-3.0-or-later - -#include <ChimeraTK/ApplicationCore/ApplicationCore.h> -#include <ChimeraTK/ApplicationCore/ConfigReader.h> -#include <ChimeraTK/ApplicationCore/EnableXMLGenerator.h> -#include <ChimeraTK/ApplicationCore/PeriodicTrigger.h> - -namespace ctk = ChimeraTK; - -struct Controller : public ctk::ApplicationModule { - using ctk::ApplicationModule::ApplicationModule; - ctk::ScalarPollInput<float> sp{this, "temperatureSetpoint", "degC", "Description"}; - ctk::ScalarPushInput<float> rb{this, "/heater/temperatureReadback", "degC", "..."}; - ctk::ScalarOutput<float> cur{this, "/heater/heatingCurrent", "mA", "..."}; - - void mainLoop() final { - const float gain = 100.0F; - while(true) { - readAll(); // waits until rb updated, then reads sp - - cur = gain * (sp - rb); - writeAll(); // writes any outputs - } - } -}; - -struct Automation : public ctk::ApplicationModule { - using ctk::ApplicationModule::ApplicationModule; - ctk::ScalarPollInput<float> opSp{this, "operatorSetpoint", "degC", "..."}; - ctk::ScalarOutput<float> actSp{this, "/Controller/temperatureSetpoint", "degC", "..."}; - ctk::ScalarPushInput<uint64_t> trigger{this, "/Timer/tick", "", "..."}; - - void mainLoop() final { - const float maxStep = 0.1F; - while(true) { - readAll(); // waits until trigger received, then read opSp - actSp += std::max(std::min(opSp - actSp, maxStep), -maxStep); - writeAll(); - } - } -}; - -struct ExampleApp final : public ctk::Application { - ExampleApp() : Application("exampleApp2a") { - if(config.get<int>("enableAutomation")) { - automation = Automation(this, "Automation", "Slow setpoint ramping algorithm"); - } - } - ~ExampleApp() final { shutdown(); } - - ctk::SetDMapFilePath dmapPath{"example2.dmap"}; - - ctk::ConfigReader config{this, "config", "demoApp2a.xml"}; - - Controller controller{this, "Controller", "The Controller"}; - - ctk::PeriodicTrigger timer{this, "Timer", "Periodic timer for the controller", 1000}; - - // ctk::DeviceModule oven{this, "oven"}; - ctk::DeviceModule oven{this, "oven", "/Timer/tick"}; - - Automation automation; -}; -static ExampleApp theExampleApp; diff --git a/example2c/CMakeLists.txt b/example2c/CMakeLists.txt deleted file mode 100644 index dfbbacb4..00000000 --- a/example2c/CMakeLists.txt +++ /dev/null @@ -1,57 +0,0 @@ -# Note: This CMakeLists.txt is a minimal complete example how to use the -# *installed* application core library. It is not included from the main CMakeLists.txt -# which is used to build ApplicationCore itself. -PROJECT(demo_example2c) - -CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1) - -# Use the project template to get the settings required for an application core project -set(${PROJECT_NAME}_MAJOR_VERSION 01) -set(${PROJECT_NAME}_MINOR_VERSION 00) -set(${PROJECT_NAME}_PATCH_VERSION 00) -include(cmake/set_version_numbers.cmake) - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules) -include(cmake/add_dependency.cmake) -include(cmake/set_default_build_to_release.cmake) -include(cmake/set_default_flags.cmake) - -# Add the dependencies. We need ApplicationCore and a control system adapter implementation. -add_dependency(ChimeraTK-ApplicationCore 03.00 REQUIRED) -#FIXME: Make the adapter configurable via command line parameter -add_dependency(ChimeraTK-ControlSystemAdapter-DoocsAdapter 00.10 REQUIRED) - -AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR} demo_sources) - -# The server proper. It depends on application core and the control system adapter implementation. -add_executable(${PROJECT_NAME} ${demo_sources}) -set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "${ChimeraTK-ApplicationCore_LINK_FLAGS} ${ChimeraTK-ControlSystemAdapter-DoocsAdapter_LINK_FLAGS}") - target_link_libraries(${PROJECT_NAME} ${ChimeraTK-ApplicationCore_LIBRARIES} ${ChimeraTK-ControlSystemAdapter-DoocsAdapter_LIBRARIES} ) - -# We compile the same sources with the GENERATE_XML flag to get an xml generator. -# This one does not depent on a control system adapter implementation. -add_executable(${PROJECT_NAME}-xmlGenerator ${demo_sources}) -set_target_properties( ${PROJECT_NAME}-xmlGenerator PROPERTIES COMPILE_FLAGS "-DGENERATE_XML") -set_target_properties(${PROJECT_NAME}-xmlGenerator PROPERTIES LINK_FLAGS "${ChimeraTK-ApplicationCore_LINK_FLAGS}") -target_link_libraries(${PROJECT_NAME}-xmlGenerator ${ChimeraTK-ApplicationCore_LIBRARIES}) - -# copy the (test) config files to the build directory for tests -FILE( COPY config/ DESTINATION ${PROJECT_BINARY_DIR}) -FILE( COPY oven_sim/ DESTINATION ${PROJECT_BINARY_DIR}) - -# Tests: -# There are no dedicated tests for this demo. But we run the xml generator to -# check that the variable household can successfully be initialised. -# The test will fail if the xml generator crashes, just a smoke test. -ENABLE_TESTING() -add_test(${PROJECT_NAME}-xmlGenerator ${PROJECT_NAME}-xmlGenerator) - -# Installation: -# FIXME: For doocs we need a special treatment when installing to /export/doocs/server (don't install to bin subdirectory, but a directory named like the server). This should go to the project template. -if("${CMAKE_INSTALL_PREFIX}" STREQUAL "/export/doocs/server") - install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}-xmlGenerator RUNTIME DESTINATION ${PROJECT_NAME}) -else() - install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}-xmlGenerator RUNTIME DESTINATION bin) -endif() -# Do not install the config. It is only a test config. -# The real config will come from a config generator and usually depends on the instance. diff --git a/example2c/COPYING b/example2c/COPYING deleted file mode 120000 index 012065c8..00000000 --- a/example2c/COPYING +++ /dev/null @@ -1 +0,0 @@ -../COPYING \ No newline at end of file diff --git a/example2c/COPYING.LESSER b/example2c/COPYING.LESSER deleted file mode 120000 index ce9a3ce2..00000000 --- a/example2c/COPYING.LESSER +++ /dev/null @@ -1 +0,0 @@ -../COPYING.LESSER \ No newline at end of file diff --git a/example2c/This_project_uses_the_project-template.txt b/example2c/This_project_uses_the_project-template.txt deleted file mode 120000 index 606f6262..00000000 --- a/example2c/This_project_uses_the_project-template.txt +++ /dev/null @@ -1 +0,0 @@ -../This_project_uses_the_project-template.txt \ No newline at end of file diff --git a/example2c/cmake b/example2c/cmake deleted file mode 120000 index 8e8a460f..00000000 --- a/example2c/cmake +++ /dev/null @@ -1 +0,0 @@ -../cmake/ \ No newline at end of file diff --git a/example2c/config/demoApp2-DoocsVariableConfig.xml b/example2c/config/demoApp2-DoocsVariableConfig.xml deleted file mode 100644 index 5eb90d66..00000000 --- a/example2c/config/demoApp2-DoocsVariableConfig.xml +++ /dev/null @@ -1,5 +0,0 @@ -<device_server> - <location name="Bakery"> - <import>/</import> - </location> -</device_server> diff --git a/example2c/config/demo_example2c.conf b/example2c/config/demo_example2c.conf deleted file mode 100644 index aff09d05..00000000 --- a/example2c/config/demo_example2c.conf +++ /dev/null @@ -1,8 +0,0 @@ -eq_conf: - -eq_fct_name: "LOCAHOST._SVR" -eq_fct_type: 1 -{ -SVR.RPC_NUMBER: 610498009 -SVR.RATE: 6 0 0 0 -} diff --git a/example2c/config/example2.dmap b/example2c/config/example2.dmap deleted file mode 100644 index 801ea940..00000000 --- a/example2c/config/example2.dmap +++ /dev/null @@ -1,3 +0,0 @@ -oven_raw (sharedMemoryDummy?map=oven.map) -oven (logicalNameMap?map=oven.xlmap) - diff --git a/example2c/config/oven.map b/example2c/config/oven.map deleted file mode 100644 index ea6918b8..00000000 --- a/example2c/config/oven.map +++ /dev/null @@ -1,7 +0,0 @@ -# name n_elements address size bar width fracbits signed R/W -APP.0.TEMPERATURE_ADC 1 0 4 0 16 0 0 RO -APP.0.HEATING_CURRENT 1 4 4 0 32 16 0 RW -APP.0.SUPPLY_ADCS 4 8 16 0 16 0 0 RO -APP.0.POWER 1 24 4 0 1 0 0 RW -APP.0.SUPPLY_ADCS_GAIN 4 28 16 0 32 0 0 RW -APP.0.AREA_FW_UPGRADE 1024 256 4096 0 32 0 0 RW diff --git a/example2c/config/oven.xlmap b/example2c/config/oven.xlmap deleted file mode 100644 index ad5fe9a4..00000000 --- a/example2c/config/oven.xlmap +++ /dev/null @@ -1,51 +0,0 @@ -<logicalNameMap> - <module name="heater"> - - <redirectedRegister name="heatingCurrent"> - <targetDevice>oven_raw</targetDevice> - <targetRegister>APP/0/HEATING_CURRENT</targetRegister> - </redirectedRegister> - - <redirectedRegister name="temperatureReadback"> - <targetDevice>oven_raw</targetDevice> - <targetRegister>APP/0/TEMPERATURE_ADC</targetRegister> - <plugin name="math"> - <!-- 16 bit ADC with 10 V, Sensor: 65 V/degC --> - <parameter name="formula">x / 2.^16 * 10. * 65.</parameter> - </plugin> - </redirectedRegister> - - <redirectedRegister name="managementVoltage"> - <targetDevice>oven_raw</targetDevice> - <targetRegister>APP/0/SUPPLY_ADCS</targetRegister> - <numberOfElements>1</numberOfElements> - <plugin name="math"> - <!-- 16 bit ADC with 32 V --> - <parameter name="formula">x / 2.^16 * 32.</parameter> - </plugin> - </redirectedRegister> - - <redirectedRegister name="threePhaseVoltages"> - <targetDevice>oven_raw</targetDevice> - <targetRegister>APP/0/SUPPLY_ADCS</targetRegister>\ - <targetStartIndex>1</targetStartIndex> - <numberOfElements>3</numberOfElements> - <plugin name="math"> - <!-- 16 bit ADC with 650 V --> - <parameter name="formula">return[x / 2.^16 * 650.]</parameter> - </plugin> - </redirectedRegister> - - <redirectedRegister name="power"> - <targetDevice>oven_raw</targetDevice> - <targetRegister>APP/0/POWER</targetRegister> - </redirectedRegister> - </module> - - <module name="settings"> - <redirectedRegister name="supplyVoltageAdcGains"> - <targetDevice>oven_raw</targetDevice> - <targetRegister>APP/0/SUPPLY_ADCS_GAIN</targetRegister> - </redirectedRegister> - </module> -</logicalNameMap> diff --git a/example2c/demoApp2c.cc b/example2c/demoApp2c.cc deleted file mode 100644 index fba63293..00000000 --- a/example2c/demoApp2c.cc +++ /dev/null @@ -1,65 +0,0 @@ -// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de> -// SPDX-License-Identifier: LGPL-3.0-or-later -#include <ChimeraTK/ApplicationCore/ApplicationCore.h> -#include <ChimeraTK/ApplicationCore/DeviceManager.h> -#include <ChimeraTK/ApplicationCore/EnableXMLGenerator.h> -#include <ChimeraTK/ApplicationCore/PeriodicTrigger.h> - -namespace ctk = ChimeraTK; - -struct Controller : public ctk::ApplicationModule { - using ctk::ApplicationModule::ApplicationModule; - ctk::ScalarPollInput<double> sp{this, "temperatureSetpoint", "degC", "Description"}; - ctk::ScalarPushInput<double> rb{this, "temperatureReadback", "degC", "..."}; - ctk::ScalarOutput<double> cur{this, "heatingCurrent", "mA", "..."}; - - void mainLoop() { - const double gain = 100.0; - while(true) { - readAll(); // waits until rb updated, then reads sp - - cur = gain * (sp - rb); - writeAll(); // writes any outputs - } - } -}; - -struct ExampleApp : public ctk::Application { - ExampleApp() : Application("demoApp2") { - // ChimeraTK::setDMapFilePath("example2.dmap"); - // ovenManger.addInitialisationHandler(&initialiseOven); - } - ~ExampleApp() { shutdown(); } - - ctk::SetDMapFilePath dmapPath{"example2.dmap"}; - - // We can pick any name for the module. "Oven" is what we want to see in the CS - Controller controller{this, "Oven", "The controller of the oven"}; - - ctk::PeriodicTrigger timer{this, "Timer", "Periodic timer for the controller", 1000}; - - // ctk::DeviceManager ovenManger{this, "oven"}; - - // ctk::DeviceModule oven{this, "oven", &initialiseOven}; -> replaced with ConnectingDeviceModule - ctk::DeviceModule oven{this, "oven", "/Timer/tick", &initialiseOven}; - // ctk::ControlSystemModule cs; -> not needed anymore as all is connected to cs automatically - - // void defineConnections(); -> not needed anymore as all is connected to cs automatically - static void initialiseOven(ChimeraTK::DeviceManager* oven); -}; -static ExampleApp theExampleApp; - -void ExampleApp::initialiseOven(ChimeraTK::DeviceManager* ovenManager) { - // set the gain factors for the voltage monitoring ADCs - // ovenManager->device.write<uint32_t>("/settings/supplyVoltageAdcGains", {20, 1, 1, 1}); - ovenManager->getDevice().write<uint32_t>("/settings/supplyVoltageAdcGains", {20, 1, 1, 1}); -} - -// void ExampleApp::defineConnections() { -// ChimeraTK::setDMapFilePath("example2.dmap"); - -// // Connect everything to the CS (except for the device, which is special) -// findTag(".*").connectTo(cs); -// // Connect device's "heater" to "Oven" in the CS, and use timer.tick as trigger -// oven["heater"].connectTo(cs["Oven"], timer.tick); -//} diff --git a/example2c/oven_sim/oven_sim2c.py b/example2c/oven_sim/oven_sim2c.py deleted file mode 100755 index e2b9be0e..00000000 --- a/example2c/oven_sim/oven_sim2c.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/python3 - -import mtca4u -import time, math - -mtca4u.set_dmap_location('example2.dmap') -d=mtca4u.Device('oven_raw') - -#cooling rate c -c=0.001 #deg /(deg*s) - -#heating rate h -h=0.0003 #deg/(A*s) - -ovenTemp = 25. -environment = 25. - -gains = d.read('APP.0','SUPPLY_ADCS_GAIN') - -for i in range(4): - if gains[i] == 0: - gains[i] = 1 - -d.write('APP.0','SUPPLY_ADCS_GAIN',gains) - -while True: - I = d.read('APP.0','HEATING_CURRENT')[0] - if d.read('APP.0','POWER') == 0: - I = 0 - - tempChange = 1 * (I*h + (environment-ovenTemp)*c) - # 1s current*heating rate deltaT * cooling rate - - ovenTemp = ovenTemp + tempChange - tempRaw = ovenTemp / 65 * math.pow(2,16) / 10 # 65 V/degC, 10V on 16 bits - d.write('APP.0','TEMPERATURE_ADC.DUMMY_WRITEABLE',tempRaw) - print('change ' + str(tempChange) +', new temp ' +str(ovenTemp)) - - gains = d.read('APP.0','SUPPLY_ADCS_GAIN') - voltagesRaw = [24./650.*pow(2,16)*gains[0], - 400./650.*pow(2,16)*gains[1], - 400./650.*pow(2,16)*gains[2], - 400./650.*pow(2,16)*gains[3] ] - d.write('APP.0','SUPPLY_ADCS.DUMMY_WRITEABLE', voltagesRaw) - - time.sleep(1) diff --git a/example3/CMakeLists.txt b/example3/CMakeLists.txt deleted file mode 100644 index 3cfcee53..00000000 --- a/example3/CMakeLists.txt +++ /dev/null @@ -1,59 +0,0 @@ -# Note: This CMakeLists.txt is a minimal complete example how to use the -# *installed* application core library. It is not included from the main CMakeLists.txt -# which is used to build ApplicationCore itself. -CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1) -#The regex matches everthing that is not a / until the end of the string (i.e. everyting after the last slash, if any) -string(REGEX MATCH "[^/]*$" PROJECT_BASE_NAME ${CMAKE_SOURCE_DIR}) -message("REGEX MATCH is ${PROJECT_BASE_NAME}") - -SET(PROJECT_NAME demo_${PROJECT_BASE_NAME}) - -# Use the project template to get the settings required for an application core project -set(${PROJECT_NAME}_MAJOR_VERSION 01) -set(${PROJECT_NAME}_MINOR_VERSION 00) -set(${PROJECT_NAME}_PATCH_VERSION 00) -include(cmake/set_version_numbers.cmake) - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules) -include(cmake/add_dependency.cmake) -include(cmake/set_default_build_to_release.cmake) -include(cmake/set_default_flags.cmake) - -# Add the dependencies. We need ApplicationCore and a control system adapter implementation. -add_dependency(ChimeraTK-ApplicationCore 03.00 REQUIRED) -#FIXME: Make the adapter configurable via command line parameter -add_dependency(ChimeraTK-ControlSystemAdapter-DoocsAdapter 00.10 REQUIRED) - -AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR} demo_sources) - -# The server proper. It depends on application core and the control system adapter implementation. -add_executable(${PROJECT_NAME} ${demo_sources}) -set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "${ChimeraTK-ApplicationCore_LINK_FLAGS} ${ChimeraTK-ControlSystemAdapter-DoocsAdapter_LINK_FLAGS}") - target_link_libraries(${PROJECT_NAME} ${ChimeraTK-ApplicationCore_LIBRARIES} ${ChimeraTK-ControlSystemAdapter-DoocsAdapter_LIBRARIES} ) - -# We compile the same sources with the GENERATE_XML flag to get an xml generator. -# This one does not depent on a control system adapter implementation. -add_executable(${PROJECT_NAME}-xmlGenerator ${demo_sources}) -set_target_properties( ${PROJECT_NAME}-xmlGenerator PROPERTIES COMPILE_FLAGS "-DGENERATE_XML") -set_target_properties(${PROJECT_NAME}-xmlGenerator PROPERTIES LINK_FLAGS "${ChimeraTK-ApplicationCore_LINK_FLAGS}") -target_link_libraries(${PROJECT_NAME}-xmlGenerator ${ChimeraTK-ApplicationCore_LIBRARIES}) - -# copy the (test) config files to the build directory for tests -FILE( COPY config/ DESTINATION ${PROJECT_BINARY_DIR}) - -# Tests: -# There are no dedicated tests for this demo. But we run the xml generator to -# check that the variable household can successfully be initialised. -# The test will fail if the xml generator crashes, just a smoke test. -ENABLE_TESTING() -add_test(${PROJECT_NAME}-xmlGenerator ${PROJECT_NAME}-xmlGenerator) - -# Installation: -# FIXME: For doocs we need a special treatment when installing to /export/doocs/server (don't install to bin subdirectory, but a directory named like the server). This should go to the project template. -if("${CMAKE_INSTALL_PREFIX}" STREQUAL "/export/doocs/server") - install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}-xmlGenerator RUNTIME DESTINATION ${PROJECT_NAME}) -else() - install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}-xmlGenerator RUNTIME DESTINATION bin) -endif() -# Do not install the config. It is only a test config. -# The real config will come from a config generator and usually depends on the instance. diff --git a/example3/COPYING b/example3/COPYING deleted file mode 120000 index 012065c8..00000000 --- a/example3/COPYING +++ /dev/null @@ -1 +0,0 @@ -../COPYING \ No newline at end of file diff --git a/example3/COPYING.LESSER b/example3/COPYING.LESSER deleted file mode 120000 index ce9a3ce2..00000000 --- a/example3/COPYING.LESSER +++ /dev/null @@ -1 +0,0 @@ -../COPYING.LESSER \ No newline at end of file diff --git a/example3/This_project_uses_the_project-template.txt b/example3/This_project_uses_the_project-template.txt deleted file mode 120000 index 606f6262..00000000 --- a/example3/This_project_uses_the_project-template.txt +++ /dev/null @@ -1 +0,0 @@ -../This_project_uses_the_project-template.txt \ No newline at end of file diff --git a/example3/cmake b/example3/cmake deleted file mode 120000 index 8e8a460f..00000000 --- a/example3/cmake +++ /dev/null @@ -1 +0,0 @@ -../cmake/ \ No newline at end of file diff --git a/example3/config/demo_example3.conf b/example3/config/demo_example3.conf deleted file mode 100644 index 7fb375c6..00000000 --- a/example3/config/demo_example3.conf +++ /dev/null @@ -1,119 +0,0 @@ -# Conf file created at 17:08.38 13. Jun. 2016 -# eq_fct_type's are defined in eq_fct_code.h - -eq_conf: - -oper_uid: -1 -oper_gid: 422 -xpert_uid: 0 -xpert_gid: 0 -ring_buffer: 10000 -memory_buffer: 500 - -eq_fct_name: "NODENAME._SVR" -eq_fct_type: 1 -{ -SVR.NAME: "NODENAME._SVR" -STS: 0x1c -STS.ERROR: 0 -STS.NEWERROR: 1 -STS.ERRORMASK: 1 -STS.ONLINE: 1 -ERROR.STR: 0 0 0 1078761493 "" -SYS_MASK: 1 -FCT_CODE: 1 -FCT_PANEL: "" -X_POS: 0 -Z_POS: 0 -Z_POS.STRING: "" -DEVICE.INFO: 235672 0 0 0 "Device OK" -MESSAGE: "" -LAST_UPDATE: 1112798768 350 0 0 -LAST_USR1: 0 0 0 0 -SVR.ALIAS: 0 -SVR.ARCFLUSH: 0 -SVR.ARCFLUSH_B: 0 -SVR.UPDATE: 1465830518 -SVR.RATE: 1 0 0 0 -SVR.RESIZE: 200 -SVR.FILE: "demoApp.conf" -SVR.DESC: "" -SVR.PROGRAMMER: "mhier" -SVR.XMLFILE: "" -SVR.ERRORLOG: "/doocs/nodename/server/InstaCoSADevExample_server/InstaCoSADevExample_server.log" -SVR.STORE.RATE: 10 -SVR.STORE.AUTO: 4 -SVR.HOST_NAME: "mskpcx19821" -SVR.PROCESSNAME: "demoApp" -SVR.RPC_NUMBER: 610498009 -SVR.STARTTIME: 1465830430 -SVR.LIBINFO: "18.10.6" -SVR.LIBDATE: "Jun 2 13:38" -SVR.WDADDR: "" -SVR.CONTR: 0x0 -SVR.MUST_RUN: 0 -SVR.STOP_SVR: 0 -SVR.START_CMD: "" -SVR.RPC_CALL_TIME.COMMENT: "Time per Call" -SVR.RPC_CALL_TIME.EGU: 1 1 100000 0 "rate" -SVR.RPC_CALL_TIME.XEGU: 0 0 100 0 "ms" -SVR.UPDATE_TIME.COMMENT: "Time per Update" -SVR.UPDATE_TIME.EGU: 1 1 100000 0 "rate" -SVR.UPDATE_TIME.XEGU: 0 0 100 0 "ms" -SVR.USR1_TIME.COMMENT: "run time of SIGUSR1" -SVR.USR1_TIME.EGU: 1 1 1e+06 1427728880 "counts" -SVR.USR1_TIME.XEGU: 0 0 100 1427728880 "ms" -SVR.USR1_PERIOD.COMMENT: "time between SIGUSR1" -SVR.USR1_PERIOD.EGU: 1 1 1e+06 1427728880 "counts" -SVR.USR1_PERIOD.XEGU: 0 0 500 1427728880 "ms" -SVR.ARCH_GET_TIME.COMMENT: "time per archiver get" -SVR.ARCH_GET_TIME.EGU: 1 1 1e+06 1459338630 "counts" -SVR.ARCH_GET_TIME.XEGU: 0 0 100 1459338630 "ms" -SVR.LAFL: 0 -SVR.ERROR_COUNT: 0 -DEVICE.ONLINE: 1 -DEVICE.OFFLINE: 0 -SVR.DEVMAX: 0 -SVR.TINERUN: 0 -SVR.TINEVERS: "4.05.0009" -SVR.TINEPREF: "" -SVR.TINESUFF: "" -SVR.TINE_DBG: 0 -SVR.TINE_LOG: 0 -SVR.TINE_FEC: 0 0 0 0 "" -SVR.TINE_PORT: 0 -SVR.TINE_MTU: 1472 -SVR.TINE_CTSZ: 32 -SVR.TINE_MCTTL: 16 -SVR.TINE_BLIM: 1000 -SVR.TINE_CDLY: 20 -SVR.TINE_GROUP: 0 -SVR.FACILITY: "TEST.DOOCS" -SVR.DEVICE: "InstaCoSADevExample" -T_ZERO: 700 -SVR.BPN: 0 -SVR.SPR: 0 -} -eq_fct_name: "Bakery" -eq_fct_type: 10 -{ -NAME: "Bakery" -STS: 0xc -STS.ERROR: 0 -STS.NEWERROR: 1 -STS.ERRORMASK: 0 -STS.ONLINE: 1 -ERROR.STR: 0 0 0 1112798768 "ok" -SYS_MASK: 222 -FCT_CODE: 10 -FCT_PANEL: "" -X_POS: 0 -Z_POS: 0 -Z_POS.STRING: "" -DEVICE.INFO: 0 0 0 0 "HALLO" -MESSAGE: "" -LAST_UPDATE: 1465830518 750 0 0 -LAST_USR1: 0 0 0 0 -readback: 20 -setpoint: 10 -} diff --git a/example3/config/example2.dmap b/example3/config/example2.dmap deleted file mode 100644 index 33f6cbf3..00000000 --- a/example3/config/example2.dmap +++ /dev/null @@ -1,2 +0,0 @@ -oven (sharedMemoryDummy?map=oven.map) - diff --git a/example3/config/exampleApp3-DoocsVariableConfig.xml b/example3/config/exampleApp3-DoocsVariableConfig.xml deleted file mode 100644 index 1687a42b..00000000 --- a/example3/config/exampleApp3-DoocsVariableConfig.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<device_server xmlns="https://github.com/ChimeraTK/ControlSystemAdapter-DoocsAdapter"> - <location name="Bakery"> - <import>/</import> - </location> -</device_server> diff --git a/example3/config/oven.map b/example3/config/oven.map deleted file mode 100644 index 97a8aee9..00000000 --- a/example3/config/oven.map +++ /dev/null @@ -1,4 +0,0 @@ -# name nr of elements address size bar width fracbits signed R/W -heater.temperatureReadback 1 0 4 0 32 16 0 RO -heater.heatingCurrent 1 4 4 0 32 16 0 RW - diff --git a/example3/demoApp3.cc b/example3/demoApp3.cc deleted file mode 100644 index e3f8cb7e..00000000 --- a/example3/demoApp3.cc +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de> -// SPDX-License-Identifier: LGPL-3.0-or-later -#include <ChimeraTK/ApplicationCore/ApplicationCore.h> -#include <ChimeraTK/ApplicationCore/EnableXMLGenerator.h> -#include <ChimeraTK/ApplicationCore/PeriodicTrigger.h> - -namespace ctk = ChimeraTK; - -struct ExampleApp : public ctk::Application { - ExampleApp() : Application("exampleApp3") { debugMakeConnections(); } - ~ExampleApp() { shutdown(); } - - ctk::SetDMapFilePath dmapPath{"example2.dmap"}; - - ctk::PeriodicTrigger timer{this, "Timer", "Periodic timer for the controller", 1000}; - - // ctk::DeviceModule dev{this, "oven"}; - ctk::DeviceModule dev{this, "oven", "/Timer/tick"}; - // ctk::ControlSystemModule cs; - // void defineConnections(); -}; -static ExampleApp theExampleApp; - -// void ExampleApp::defineConnections() { -// ChimeraTK::setDMapFilePath("example2.dmap"); -// dev.connectTo(cs, timer.tick); -// } diff --git a/example_template/CMakeLists.txt b/example_template/CMakeLists.txt deleted file mode 100644 index d8ac9812..00000000 --- a/example_template/CMakeLists.txt +++ /dev/null @@ -1,97 +0,0 @@ -project(TemplateServer) -cmake_minimum_required(VERSION 3.5.1) - -list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) - -# Use the project template to get the settings required for an application core project -set(${PROJECT_NAME}_MAJOR_VERSION 01) -set(${PROJECT_NAME}_MINOR_VERSION 00) -set(${PROJECT_NAME}_PATCH_VERSION 00) -include(cmake/set_version_numbers.cmake) -include(cmake/set_default_build_to_release.cmake) - -# configure version.h -configure_file(include/version.h.in ${PROJECT_BINARY_DIR}/version/version.h) -include_directories(${PROJECT_BINARY_DIR}/version) - -# Add the dependencies. We need ApplicationCore and a control system adapter implementation. -# -# /!\ if you need the DeviceAccess-DoocsBackend, you have to add the dependency _after_ -# /!\ selecting the control system adapter, otherwise your server will not work. -# -# Define dependences -include(cmake/add_dependency.cmake) -add_dependency(ChimeraTK-ApplicationCore 03.00 REQUIRED) - -# Select the control system adapter -include(cmake/set_control_system_adapter.cmake) - -# Define compiler and linker flags - extend compiler flags with flags from dependencies -include(cmake/set_default_flags.cmake) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ChimeraTK-ApplicationCore_CXX_FLAGS}") -set(CMAKE_LINK_FLAGS "-Wl,--no-as-needed ${Adapter_LINK_FLAGS} ${ChimeraTK-ApplicationCore_LINK_FLAGS}") - -############################################################################################################ -# server library config -############################################################################################################ -# set include directories for library -include_directories(${CMAKE_SOURCE_DIR}/include) -file(GLOB library_headers "${CMAKE_SOURCE_DIR}/include/*.h") -set(${PROJECT_NAME}_INCLUDE_DIRS ${${PROJECT_NAME}_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include/) -# create lists with source files for library -aux_source_directory(${CMAKE_SOURCE_DIR}/src library_sources) - -# server library (to avoid compiling everyting multiple times) -add_library(${PROJECT_NAME}lib SHARED ${library_sources} ${library_headers} ${PROJECT_BINARY_DIR}/version/version.h) -set_target_properties(${PROJECT_NAME}lib PROPERTIES VERSION ${${PROJECT_NAME}_FULL_LIBRARY_VERSION} - SOVERSION ${${PROJECT_NAME}_SOVERSION}) -target_link_libraries(${PROJECT_NAME}lib ${ChimeraTK-ApplicationCore_LIBRARIES} ${ADAPTER_LIBRARIES}) - -############################################################################################################ -# server executable config -############################################################################################################ -# The server executable. It depends on application core and the control system adapter implementation. -add_executable(${PROJECT_NAME} src_server/ApplicationInstance.cc) -set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "${CMAKE_LINK_FLAGS}") -target_link_libraries(${PROJECT_NAME} ${PROJECT_NAME}lib ${ChimeraTK-ApplicationCore_LIBRARIES} ${Adapter_LIBRARIES} ) - -# We compile the same sources with the GENERATE_XML flag to get an xml generator. -# This one does not depent on a control system adapter implementation. -add_executable(${PROJECT_NAME}-xmlGenerator src_xmlGenerator/XmlGenerator.cc) -set_target_properties( ${PROJECT_NAME}-xmlGenerator PROPERTIES COMPILE_FLAGS "-DGENERATE_XML") -set_target_properties(${PROJECT_NAME}-xmlGenerator PROPERTIES LINK_FLAGS "${ChimeraTK-ApplicationCore_LINK_FLAGS}") -target_link_libraries(${PROJECT_NAME}-xmlGenerator ${PROJECT_NAME}lib ${ChimeraTK-ApplicationCore_LIBRARIES}) - -############################################################################################################ -# server tests config -############################################################################################################ -enable_testing() -find_package(Boost COMPONENTS thread system unit_test_framework REQUIRED) - -# Create the executables for automated unit testing (new modular tests). -# add one test executable per source file -aux_source_directory(${CMAKE_SOURCE_DIR}/tests/executables_src testExecutables) -foreach( testExecutableSrcFile ${testExecutables}) - #NAME_WE means the base name without path and (longest) extension - get_filename_component(excutableName ${testExecutableSrcFile} NAME_WE) - add_executable(${excutableName} ${testExecutableSrcFile}) - target_link_libraries(${excutableName} ${PROJECT_NAME}lib) - set_target_properties(${excutableName} PROPERTIES LINK_FLAGS "${CMAKE_LINK_FLAGS}") - add_test(${excutableName} ${excutableName}) -endforeach( testExecutableSrcFile ) - -# Copy the (test) config files to the build directory -file( COPY ${CMAKE_SOURCE_DIR}/config/ DESTINATION ${PROJECT_BINARY_DIR}) - -############################################################################################################ -# server installation config -############################################################################################################ -# Installation: -# FIXME: For doocs we need a special treatment when installing to /export/doocs/server (don't install to bin subdirectory, but a directory named like the server). This should go to the project template. -if("${CMAKE_INSTALL_PREFIX}" STREQUAL "/export/doocs/server") - install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}-xmlGenerator RUNTIME DESTINATION ${PROJECT_NAME}) -else() - install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}-xmlGenerator RUNTIME DESTINATION bin) -endif() -# Do not install the config. It is only a test config. -# The real config will come from a config generator and usually depends on the instance. diff --git a/example_template/COPYING b/example_template/COPYING deleted file mode 120000 index 012065c8..00000000 --- a/example_template/COPYING +++ /dev/null @@ -1 +0,0 @@ -../COPYING \ No newline at end of file diff --git a/example_template/COPYING.LESSER b/example_template/COPYING.LESSER deleted file mode 120000 index ce9a3ce2..00000000 --- a/example_template/COPYING.LESSER +++ /dev/null @@ -1 +0,0 @@ -../COPYING.LESSER \ No newline at end of file diff --git a/example_template/This_project_uses_the_project-template.txt b/example_template/This_project_uses_the_project-template.txt deleted file mode 120000 index 606f6262..00000000 --- a/example_template/This_project_uses_the_project-template.txt +++ /dev/null @@ -1 +0,0 @@ -../This_project_uses_the_project-template.txt \ No newline at end of file diff --git a/example_template/cmake b/example_template/cmake deleted file mode 120000 index 1a8cebff..00000000 --- a/example_template/cmake +++ /dev/null @@ -1 +0,0 @@ -../cmake \ No newline at end of file diff --git a/example_template/config/TemplateServer-Config.xml b/example_template/config/TemplateServer-Config.xml deleted file mode 100644 index 3a8aa78c..00000000 --- a/example_template/config/TemplateServer-Config.xml +++ /dev/null @@ -1,7 +0,0 @@ -<configuration> - <variable name="config_var1" type="int32" value="42"/> - <module name="Configuration"> - <variable name="config_var1" type="int32" value="3"/> - <variable name="config_var2" type="int32" value="7"/> - </module> -</configuration> diff --git a/example_template/config/TemplateServer-DoocsVariableConfig.xml b/example_template/config/TemplateServer-DoocsVariableConfig.xml deleted file mode 100644 index 35f5db0d..00000000 --- a/example_template/config/TemplateServer-DoocsVariableConfig.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<device_server xmlns="https://github.com/ChimeraTK/ControlSystemAdapter-DoocsAdapter"> - - <location name="TEMPLATE_LOCATION"> - - <!-- Simply import all variables provided by the application - Adapt to your needs! - --> - <import>/</import> - </location> - -</device_server> diff --git a/example_template/config/TemplateServer.conf b/example_template/config/TemplateServer.conf deleted file mode 100644 index 7579ea7b..00000000 --- a/example_template/config/TemplateServer.conf +++ /dev/null @@ -1,19 +0,0 @@ -eq_conf: -oper_uid: -1 -oper_gid: 405 -xpert_uid: 1000 -xpert_gid: 1000 -ring_buffer: 10000 -memory_buffer: 500 -eq_fct_name: "TEMPLATE_SERVER._SVR" -eq_fct_type: 1 -{ -SVR.RPC_NUMBER: 610498009 -SVR.NAME: "TEMPLATE_SERVER._SVR" -SVR.BPN: 6000 -} -eq_fct_name: "TEMPLATE_LOCATION" -eq_fct_type: 10 -{ -NAME: "TEMPLATE_LOCATION" -} diff --git a/example_template/config/TemplateServer.dmap b/example_template/config/TemplateServer.dmap deleted file mode 100644 index 3d8ce0da..00000000 --- a/example_template/config/TemplateServer.dmap +++ /dev/null @@ -1,2 +0,0 @@ -DummyDevice (sharedMemoryDummy:?map=dummydevice.map) -MappedDummyDevice (logicalNameMap?map=name_mapping.xlmap&target=DummyDevice) diff --git a/example_template/config/dummydevice.map b/example_template/config/dummydevice.map deleted file mode 100644 index 575e3265..00000000 --- a/example_template/config/dummydevice.map +++ /dev/null @@ -1,3 +0,0 @@ -#name n_words address n_bytes BAR n_bits n_fractionalBits signed -WORD_1 1 0 4 0 32 0 0 RW -MODULE_1.AREA 2 4 8 0 32 0 0 RW diff --git a/example_template/config/name_mapping.xlmap b/example_template/config/name_mapping.xlmap deleted file mode 100644 index 5f001f69..00000000 --- a/example_template/config/name_mapping.xlmap +++ /dev/null @@ -1,21 +0,0 @@ -<logicalNameMap> - <redirectedRegister name="SingleWord"> - <targetDevice><par>target</par></targetDevice> - <targetRegister>WORD_1</targetRegister> - </redirectedRegister> - - <module name="Module1"> - <redirectedRegister name="Channel0"> - <targetDevice><par>target</par></targetDevice> - <targetRegister>MODULE_1.AREA</targetRegister> - <targetStartIndex>0</targetStartIndex> - <numberOfElements>1</numberOfElements> - </redirectedRegister> - <redirectedRegister name="Channel1"> - <targetDevice><par>target</par></targetDevice> - <targetRegister>MODULE_1.AREA</targetRegister> - <targetStartIndex>1</targetStartIndex> - <numberOfElements>1</numberOfElements> - </redirectedRegister> - </module> -</logicalNameMap> diff --git a/example_template/include/Server.h b/example_template/include/Server.h deleted file mode 100644 index 1b561651..00000000 --- a/example_template/include/Server.h +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de> -// SPDX-License-Identifier: LGPL-3.0-or-later -#pragma once - -#include <ChimeraTK/ApplicationCore/ApplicationCore.h> -#include <ChimeraTK/ApplicationCore/ConfigReader.h> - -// TODO Note to optionally use to trigger -//#include <ChimeraTK/ApplicationCore/PeriodicTrigger.h> - -#include "TemplateModule.h" - -namespace ctk = ChimeraTK; - -/** - * Server - An ApplicationCore template server - * - * The Application object for this server. It provides - * dummy Device- and ApplicationModules and a ConfigReader. - * - * All modules are simply connected to the ControlSystem. - * No triggering is implemented, as this is specific to the application - * (either provided by a Device or a ChimeraTK::PeriodicTrigger). - */ -struct Server : public ctk::Application { - Server(std::string appName = "TemplateServer"); - ~Server() override; - ctk::SetDMapFilePath dmapPath; - ctk::ConfigReader config; - ctk::DeviceModule device; - TemplateModule templateModule; -}; diff --git a/example_template/include/TemplateModule.h b/example_template/include/TemplateModule.h deleted file mode 100644 index bef9625d..00000000 --- a/example_template/include/TemplateModule.h +++ /dev/null @@ -1,15 +0,0 @@ -// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de> -// SPDX-License-Identifier: LGPL-3.0-or-later -#pragma once - -#include <ChimeraTK/ApplicationCore/ApplicationCore.h> - -namespace ctk = ChimeraTK; - -struct TemplateModule : public ctk::ApplicationModule { - using ctk::ApplicationModule::ApplicationModule; - /* - * Add input/output definition - * */ - void mainLoop() override; -}; diff --git a/example_template/include/version.h.in b/example_template/include/version.h.in deleted file mode 100644 index f3c26acc..00000000 --- a/example_template/include/version.h.in +++ /dev/null @@ -1,12 +0,0 @@ -// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de> -// SPDX-License-Identifier: LGPL-3.0-or-later -#pragma once - -class AppVersion { - public: - // About 1xx-100: This is to prevent 08 and 09 being interpreted as - // octal, which would result in a compiler error. - static constexpr uint32_t major = 1${${PROJECT_NAME}_MAJOR_VERSION}-100; - static constexpr uint32_t minor = 1${${PROJECT_NAME}_MINOR_VERSION}-100; - static constexpr uint32_t patch = 1${${PROJECT_NAME}_PATCH_VERSION}-100; -}; diff --git a/example_template/src/Server.cc b/example_template/src/Server.cc deleted file mode 100644 index b81bb579..00000000 --- a/example_template/src/Server.cc +++ /dev/null @@ -1,21 +0,0 @@ -// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de> -// SPDX-License-Identifier: LGPL-3.0-or-later - -#include "Server.h" - -#include "version.h" - -Server::Server(std::string appName) -: ctk::Application(appName), - dmapPath(appName + ".dmap"), config{this, "Configuration", getName() + "-Config.xml"}, device{this, - "MappedDummyDevice"}, - templateModule{this, "TemplateModule", "This is a template module, adapt as needed!"} { - std::cout << "*** Construction of " << appName << " in version " << AppVersion::major << "." << AppVersion::minor - << "." << AppVersion::patch << " starts. ***" << std::endl; - std::cout << "*** Construction of " << appName << " in version " << AppVersion::major << "." << AppVersion::minor - << "." << AppVersion::patch << " done. ***" << std::endl; -} - -Server::~Server() { - shutdown(); -} diff --git a/example_template/src/TemplateModule.cc b/example_template/src/TemplateModule.cc deleted file mode 100644 index e6079b0e..00000000 --- a/example_template/src/TemplateModule.cc +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de> -// SPDX-License-Identifier: LGPL-3.0-or-later - -#include "TemplateModule.h" - -void TemplateModule::mainLoop() { - /* - * Here a main infinite loop for the Module should be defined. - * It is commented out on purpose in this TemplateModule. - * - */ - /* - while(true) { - - } - */ -} diff --git a/example_template/src_server/ApplicationInstance.cc b/example_template/src_server/ApplicationInstance.cc deleted file mode 100644 index bcbbef24..00000000 --- a/example_template/src_server/ApplicationInstance.cc +++ /dev/null @@ -1,7 +0,0 @@ -// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de> -// SPDX-License-Identifier: LGPL-3.0-or-later - -#include "Server.h" - -/// The Server instance -static Server theServer; diff --git a/example_template/src_xmlGenerator/XmlGenerator.cc b/example_template/src_xmlGenerator/XmlGenerator.cc deleted file mode 100644 index 228cbd7b..00000000 --- a/example_template/src_xmlGenerator/XmlGenerator.cc +++ /dev/null @@ -1,9 +0,0 @@ -// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de> -// SPDX-License-Identifier: LGPL-3.0-or-later - -#include "Server.h" - -#include <ChimeraTK/ApplicationCore/EnableXMLGenerator.h> - -/// The Server instance -static Server theServer; diff --git a/example_template/tests/executables_src/testTemplateModule.cc b/example_template/tests/executables_src/testTemplateModule.cc deleted file mode 100644 index d555b431..00000000 --- a/example_template/tests/executables_src/testTemplateModule.cc +++ /dev/null @@ -1,37 +0,0 @@ -// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de> -// SPDX-License-Identifier: LGPL-3.0-or-later - -// Define a name for the test module. -#define BOOST_TEST_MODULE testTemplateServer -// Only after defining the name include the unit test header. -#include "Server.h" - -#include <ChimeraTK/ApplicationCore/TestFacility.h> - -#include <boost/test/included/unit_test.hpp> - -// Declare the server instance -static Server theServer; - -static ChimeraTK::TestFacility testFacility{theServer}; - -struct TestFixture { - TestFixture() { testFacility.runApplication(); } -}; -static TestFixture fixture; - -using namespace boost::unit_test_framework; - -/// TestSuite for the server, adapt name -BOOST_AUTO_TEST_SUITE(TemplateServerTestSuite) - -/**********************************************************************************************************************/ - -/// A template test case -BOOST_AUTO_TEST_CASE(testTemplate) { - std::cout << "testTemplate" << std::endl; -} - -/**********************************************************************************************************************/ - -BOOST_AUTO_TEST_SUITE_END() -- GitLab