Skip to content

fix: code formatting #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions examples/cosade/IndependentControlCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

// FIXME: in a real example an installed version of the adapter has to be used,
// which has the headers installed under the namespace folder
//#include <ControlSystemAdapter/DevicePVManager.h>
//#include <ControlSystemAdapter/ProcessScalar.h>
//#include <ControlSystemAdapter/DeviceSynchronizationUtility.h>
//#include <ControlSystemAdapter/SynchronizationDirection.h>
// #include <ControlSystemAdapter/DevicePVManager.h>
// #include <ControlSystemAdapter/ProcessScalar.h>
// #include <ControlSystemAdapter/DeviceSynchronizationUtility.h>
// #include <ControlSystemAdapter/SynchronizationDirection.h>
#include <ChimeraTK/ControlSystemAdapter/DevicePVManager.h>
#include <ChimeraTK/ControlSystemAdapter/DeviceSynchronizationUtility.h>
#include <ChimeraTK/ControlSystemAdapter/ProcessScalar.h>
Expand Down Expand Up @@ -53,9 +53,8 @@ class IndependentControlCore {
*/
IndependentControlCore(boost::shared_ptr<ChimeraTK::DevicePVManager> const& processVariableManager)
// initialise all process variables, using the factory
: _processVariableManager(processVariableManager),
_targetVoltage(
processVariableManager->createProcessScalar<int>(ChimeraTK::controlSystemToDevice, "TARGET_VOLTAGE")),
: _processVariableManager(processVariableManager), _targetVoltage(processVariableManager->createProcessScalar<int>(
ChimeraTK::controlSystemToDevice, "TARGET_VOLTAGE")),
_monitorVoltage(
processVariableManager->createProcessScalar<int>(ChimeraTK::deviceToControlSystem, "MONITOR_VOLTAGE")) {
// initialise the hardware here
Expand Down
4 changes: 2 additions & 2 deletions examples/cosade/testIndependentControlCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#define BOOST_TEST_MODULE IndependentControlCoreTest
// Only after defining the name include the unit test header.
#include <boost/test/included/unit_test.hpp>
#include "IndependentControlCore.h"

#include <ChimeraTK/ControlSystemAdapter/ControlSystemSynchronizationUtility.h>

#include "IndependentControlCore.h"
#include <boost/test/included/unit_test.hpp>

using namespace boost::unit_test_framework;
using namespace ChimeraTK;
Expand Down
15 changes: 8 additions & 7 deletions include/ChimeraTK/ControlSystemAdapter/ApplicationBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
#ifndef CHIMERA_TK_CONTROL_SYSTEM_ADAPTER_APPLICATION_BASE_H
#define CHIMERA_TK_CONTROL_SYSTEM_ADAPTER_APPLICATION_BASE_H

#include <mutex>

#include "DevicePVManager.h"

#include <mutex>

namespace ChimeraTK {

/** Base class for applications. Note: The class intended for use by the
Expand Down Expand Up @@ -39,10 +39,10 @@ namespace ChimeraTK {

/** Optimise unmapped variables to avoid unnecessary copies. The application must implement this function. The
* ControlSystemAdapter implementation should call it with a list of PV names which are not mapped, i.e. the
* Application does not need to update the values of these PVs. If this function is not called, no such optimisation
* can be done and the application may have an increased CPU usage. If the function is called, it must be called
* after initialise() and before run(). */
virtual void optimiseUnmappedVariables(const std::set<std::string> &unmappedVariables) { (void)unmappedVariables; }
* Application does not need to update the values of these PVs. If this function is not called, no such
* optimisation can be done and the application may have an increased CPU usage. If the function is called, it must
* be called after initialise() and before run(). */
virtual void optimiseUnmappedVariables(const std::set<std::string>& unmappedVariables) { (void)unmappedVariables; }

/** Run the application. This function must be implemented by the application
* programmer. It will be called after initialise() and after all process
Expand Down Expand Up @@ -75,7 +75,8 @@ namespace ChimeraTK {
[[nodiscard]] const std::string& getName() const { return _applicationName; }

/** Obtain the PersistentDataStorage object. You can specify the write interval in seconds. */
boost::shared_ptr<PersistentDataStorage> getPersistentDataStorage(unsigned int writeInterval = PersistentDataStorage::DEFAULT_WRITE_INTERVAL) {
boost::shared_ptr<PersistentDataStorage> getPersistentDataStorage(
unsigned int writeInterval = PersistentDataStorage::DEFAULT_WRITE_INTERVAL) {
if(!_persistentDataStorage) {
_persistentDataStorage.reset(new PersistentDataStorage(_applicationName, writeInterval));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#ifndef CHIMERA_TK_CONTROL_SYSTEM_ADAPTER_BIDIRECTIONAL_PROCESS_ARRAY_H
#define CHIMERA_TK_CONTROL_SYSTEM_ADAPTER_BIDIRECTIONAL_PROCESS_ARRAY_H

#include "PersistentDataStorage.h"
#include "UnidirectionalProcessArray.h"

#include <boost/shared_ptr.hpp>

#include <limits>
#include <stdexcept>
#include <typeinfo>
#include <utility>
#include <vector>

#include <boost/shared_ptr.hpp>

#include "PersistentDataStorage.h"
#include "UnidirectionalProcessArray.h"

namespace ChimeraTK {

/**
Expand Down Expand Up @@ -85,8 +85,7 @@ namespace ChimeraTK {
std::pair<typename ProcessArray<T>::SharedPtr, typename ProcessArray<T>::SharedPtr>
createBidirectionalSynchronizedProcessArray(const std::vector<T>& initialValue,
const ChimeraTK::RegisterPath& name = "", const std::string& unit = "", const std::string& description = "",
std::size_t numberOfBuffers = 3,
const AccessModeFlags& flags = {AccessMode::wait_for_new_data});
std::size_t numberOfBuffers = 3, const AccessModeFlags& flags = {AccessMode::wait_for_new_data});

/**
* Implementation of the process array that transports data in both
Expand Down
10 changes: 5 additions & 5 deletions include/ChimeraTK/ControlSystemAdapter/ControlSystemPVManager.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#ifndef CHIMERA_TK_CONTROL_SYSTEM_ADAPTER_CONTROL_SYSTEM_PV_MANAGER_H
#define CHIMERA_TK_CONTROL_SYSTEM_ADAPTER_CONTROL_SYSTEM_PV_MANAGER_H

#include <list>
#include <map>
#include "ApplicationBase.h"
#include "PVManager.h"

#include <boost/shared_ptr.hpp>

#include "ApplicationBase.h"
#include "PVManager.h"
#include <list>
#include <map>

namespace ChimeraTK {

Expand Down Expand Up @@ -59,7 +59,7 @@ namespace ChimeraTK {
* std::string&, T, bool, std::size_t, const AccessModeFlags&) or
* DevicePVManager::createProcessArray(SynchronizationDirection, const
* ChimeraTK::RegisterPath&, const std::vector<T>&, const std::string&, const
* std::string&, bool, std::size_t, const AccessModeFlags&) method.
* std::string&, bool, std::size_t, const AccessModeFlags&) method.
* Throws logic_error if there is no process scalar or array with
* the specified name. Also throws a logic_error if there is a process
* scalar or array with the specified name but its type does not match.
Expand Down
12 changes: 6 additions & 6 deletions include/ChimeraTK/ControlSystemAdapter/DevicePVManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ namespace ChimeraTK {
class DevicePVManager;
} // namespace ChimeraTK

#include <map>
#include <string>
#include "PVManager.h"
#include "SynchronizationDirection.h"

#include <boost/shared_ptr.hpp>

#include "PVManager.h"
#include "SynchronizationDirection.h"
#include <map>
#include <string>

namespace ChimeraTK {

Expand Down Expand Up @@ -111,7 +111,7 @@ namespace ChimeraTK {
* std::string&, T, bool, std::size_t, const AccessModeFlags&) or
* createProcessArray(SynchronizationDirection, const
* ChimeraTK::RegisterPath&, const std::vector<T>&, const std::string&, const
* std::string&, bool, std::size_t, const AccessModeFlags&) method.
* std::string&, bool, std::size_t, const AccessModeFlags&) method.
* Throws a logic_error if there is no process scalar or array with
* the specified name. Also throws logic_error if there is a process
* scalar or array with the specified name but its type does not match.
Expand All @@ -127,7 +127,7 @@ namespace ChimeraTK {
* std::string&, T, bool, std::size_t, const AccessModeFlags&), or
* createProcessArray(SynchronizationDirection, const
* ChimeraTK::RegisterPath&, const std::vector<T>&, const std::string&, const
* std::string&, bool, std::size_t, const AccessModeFlags&) method.
* std::string&, bool, std::size_t, const AccessModeFlags&) method.
* Throws a logic_error if there is no process scalar or array with
* the specified name. Also throws logic_error if there is a process
* scalar or array with the specified name but its type does not match.
Expand Down
20 changes: 10 additions & 10 deletions include/ChimeraTK/ControlSystemAdapter/PVManager.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#ifndef CHIMERA_TK_CONTROL_SYSTEM_ADAPTER_PV_MANAGER_H
#define CHIMERA_TK_CONTROL_SYSTEM_ADAPTER_PV_MANAGER_H

#include <list>
#include <utility>
#include "BidirectionalProcessArray.h"
#include "ProcessVariable.h"
#include "PVManagerDecl.h"
#include "UnidirectionalProcessArray.h"

#include <ChimeraTK/RegisterPath.h>

#include <boost/lockfree/queue.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/thread.hpp>
#include <map>

#include <ChimeraTK/RegisterPath.h>

#include "BidirectionalProcessArray.h"
#include "PVManagerDecl.h"
#include "UnidirectionalProcessArray.h"
#include "ProcessVariable.h"
#include <list>
#include <map>
#include <utility>

namespace ChimeraTK {

Expand Down Expand Up @@ -149,7 +149,7 @@ namespace ChimeraTK {

/**
* Returns a reference to a process array that has been created earlier
* using one of the <code>createProcessArray...</code> methods.
* using one of the <code>createProcessArray...</code> methods.
* Throws a logic_error if there is a process scalar or array with the specified name but its type does not match.
* A pair of two process arrays is returned: The first member of the pair is
* a reference to the instance intended for the control system and the
Expand Down
36 changes: 18 additions & 18 deletions include/ChimeraTK/ControlSystemAdapter/PersistentDataStorage.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#ifndef CHIMERA_TK_CONTROL_SYSTEM_ADAPTER_PERSISTENT_DATA_STORAGE_H
#define CHIMERA_TK_CONTROL_SYSTEM_ADAPTER_PERSISTENT_DATA_STORAGE_H

#include <ChimeraTK/cppext/future_queue.hpp>
#include <ChimeraTK/RegisterPath.h>
#include <ChimeraTK/SupportedUserTypes.h>

#include <boost/fusion/include/for_each.hpp>
#include <boost/thread.hpp>

#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <typeinfo>
#include <vector>

#include <boost/fusion/include/for_each.hpp>
#include <boost/thread.hpp>

#include <ChimeraTK/RegisterPath.h>
#include <ChimeraTK/SupportedUserTypes.h>
#include <ChimeraTK/cppext/future_queue.hpp>

namespace xmlpp {
class Element;
} // namespace xmlpp
Expand Down Expand Up @@ -45,7 +45,6 @@ namespace ChimeraTK {
*/
class PersistentDataStorage {
public:

/** unit in seconds */
static const unsigned int DEFAULT_WRITE_INTERVAL{30}; // 30 seconds

Expand Down Expand Up @@ -107,18 +106,19 @@ namespace ChimeraTK {
std::vector<std::type_info const*> _variableTypes;

/** Thread safe queue for write to file thread. */
template <typename DataType> class Queue {
template<typename DataType>
class Queue {
cppext::future_queue<std::vector<DataType>> _q;
std::vector<DataType> _latestValue{};

public:
explicit Queue(size_t queueSize = 2) : _q(queueSize) {}
void pushOverwrite(const std::vector<DataType>& e) { _q.push_overwrite(e); }
std::vector<DataType>& readLatest() {
while(_q.pop(_latestValue)) {
}
return _latestValue;
}
public:
explicit Queue(size_t queueSize = 2) : _q(queueSize) {}
void pushOverwrite(const std::vector<DataType>& e) { _q.push_overwrite(e); }
std::vector<DataType>& readLatest() {
while(_q.pop(_latestValue)) {
}
return _latestValue;
}
};

/** Type definition for the map holding the values for one specific data type.
Expand Down Expand Up @@ -244,7 +244,7 @@ namespace ChimeraTK {
/*********************************************************************************************************************/

template<typename DataType>
void PersistentDataStorage::updateValue(int id, std::vector<DataType> const &value) {
void PersistentDataStorage::updateValue(int id, std::vector<DataType> const& value) {
boost::fusion::at_key<DataType>(_dataMap.table)[id].pushOverwrite(value);
}

Expand Down
14 changes: 7 additions & 7 deletions include/ChimeraTK/ControlSystemAdapter/ProcessArray.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#ifndef CHIMERA_TK_CONTROL_SYSTEM_ADAPTER_PROCESS_ARRAY_H
#define CHIMERA_TK_CONTROL_SYSTEM_ADAPTER_PROCESS_ARRAY_H

#include "PersistentDataStorage.h"

#include <ChimeraTK/NDRegisterAccessor.h>
#include <ChimeraTK/VersionNumber.h>

#include <boost/shared_ptr.hpp>

#include <limits>
#include <stdexcept>
#include <typeinfo>
#include <utility>
#include <vector>

#include <boost/shared_ptr.hpp>

#include <ChimeraTK/NDRegisterAccessor.h>
#include <ChimeraTK/VersionNumber.h>

#include "PersistentDataStorage.h"

namespace ChimeraTK {

/**
Expand Down
5 changes: 3 additions & 2 deletions include/ChimeraTK/ControlSystemAdapter/StatusAccessorBase.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#pragma once

#include <assert.h>

#include <cstdint>
#include <string>
#include <assert.h>

namespace ChimeraTK {

/** Base class - used to avoid code duplication in StatusOutput, StatusPushInput and StatusPollInput. */
struct StatusAccessorBase {
/**
* These are the states which can be reported.
*
*
* Note: The values are exposed to the control system and hence are part of the public interface!
*/
enum class Status : int32_t { OK = 0, FAULT = 1, OFF = 2, WARNING = 3 };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#pragma once

#include "StatusAccessorBase.h"

#include <ChimeraTK/DataConsistencyGroup.h>
#include <ChimeraTK/ForwardDeclarations.h>
#include <ChimeraTK/RegisterPath.h>
#include <ChimeraTK/ScalarRegisterAccessor.h>
#include <ChimeraTK/DataConsistencyGroup.h>

#include "StatusAccessorBase.h"

namespace ChimeraTK {

Expand Down Expand Up @@ -66,7 +66,7 @@ namespace ChimeraTK {

/**
* This is for consistent readout of StatusWithMessage - DeviceAccess version.
* It can be instantiated wih or without message string.
* It can be instantiated wih or without message string.
* If instantiated without message, the message is generated automatically from the status.
*/
struct StatusWithMessageReader : StatusWithMessageReaderBase<StatusWithMessageReader> {
Expand Down
Loading