spliting in progress

This commit is contained in:
2026-04-30 15:46:07 +02:00
parent 5f1175c5e3
commit 6bac7a5e7b
7 changed files with 179 additions and 63 deletions
+55 -12
View File
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.03)
project(ePowerSwitchFront VERSION 1.0)
project(ePowerSwitchFrontend VERSION 1.0)
add_subdirectory(submodule/mepicsca)
@@ -44,20 +44,32 @@ set(LIBS
find_package(Midas REQUIRED)
add_executable(ePowerSwitchFront
src/ePowerSwitchFront.cpp
################################################################################
## Device Library
################################################################################
add_library(
ePowerSwitchEquipment
src/device/ePowerSwitchEquipment.cpp
)
set_property(
TARGET
ePowerSwitchFront
ePowerSwitchEquipment
PROPERTY
CXX_STANDARD 17
)
target_link_libraries(
ePowerSwitchEquipment
PRIVATE
midas::mfe
m_epics_ca
${LIBS}
)
target_include_directories(
ePowerSwitchFront
ePowerSwitchEquipment
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE
@@ -68,15 +80,46 @@ target_include_directories(
${EPICSSYS}/include/compiler/clang
)
target_link_libraries(ePowerSwitchFront
################################################################################
## Frontend
################################################################################
add_executable(ePowerSwitchFrontend
src/frontend/ePowerSwitchFrontend.cpp
)
set_property(
TARGET
ePowerSwitchFrontend
PROPERTY
CXX_STANDARD 17
)
target_include_directories(
ePowerSwitchFrontend
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE
${EPICSSYS}/include
${EPICSSYS}/include/os/Linux
${EPICSSYS}/include/os/Darwin
${EPICSSYS}/include/compiler/gcc
${EPICSSYS}/include/compiler/clang
)
target_link_libraries(
ePowerSwitchFrontend
PRIVATE
ePowerSwitchEquipment
midas::mfe
m_epics_ca
${LIBS}
)
install(
TARGETS
ePowerSwitchFront
RUNTIME DESTINATION bin
)
# install(
# TARGETS
# ePowerSwitchFrontend
# RUNTIME DESTINATION bin
# )
@@ -1,6 +1,5 @@
#include "../include/ePowerSwitchFront.h"
#include "../include/ePowerSwitchConfig.h"
#include "m_epics_ca.h"
#include "ePowerSwitchEquipment.h"
#include "ePowerSwitchEquipmentConfig.h"
#include "tmfe.h"
#include <sstream>
@@ -17,45 +16,6 @@ std::string format(std::string str, int value) {
return ss.str();
}
int main(int argc, char *argv[]) {
if (argv[0][0] == '.') {
TMFE::Instance()->Msg(MERROR, __FUNCTION__,
"Relative paths are strongly discouraged; "
"please use an absolute path.");
}
std::string frontendName;
std::string equipmentName;
if (argc == 1) {
frontendName = DEFAULT_FRONTEND_NAME;
TMFE::Instance()->Msg(MINFO, __FUNCTION__,
"No frontend name provided; %s will be used",
DEFAULT_FRONTEND_NAME);
equipmentName = DEFAULT_EQUIPMENT_NAME;
TMFE::Instance()->Msg(MINFO, __FUNCTION__,
"No equipment name provided; %s will be used",
DEFAULT_EQUIPMENT_NAME);
}
if (argc == 2) {
frontendName = std::string(argv[1]);
argv++;
argc--;
TMFE::Instance()->Msg(MINFO, __FUNCTION__,
"No equipment name provided; %s will be use",
DEFAULT_EQUIPMENT_NAME);
} else if (argc == 3) {
frontendName = std::string(argv[1]);
equipmentName = std::string(argv[2]);
argv += 2;
argc -= 2;
}
auto front = new ePowerSwitchFrontend(frontendName, equipmentName);
front->FeMain(argc, argv);
}
ePowerSwitchEquipment::ePowerSwitchEquipment(std::string equipmentName,
const char *equipmentFileName)
: TMFeEquipment(equipmentName.c_str(), equipmentFileName),
@@ -203,9 +163,3 @@ void ePowerSwitchEquipment::updateSocketNumber() {
this->numberOfOutlet = epicsOutletNumber;
}
ePowerSwitchFrontend::ePowerSwitchFrontend(std::string frontendName,
std::string equipmentName) {
FeSetName(frontendName.c_str());
FeAddEquipment(new ePowerSwitchEquipment(equipmentName.c_str(), __FILE__));
}
+49
View File
@@ -0,0 +1,49 @@
#ifndef EPOWERSWITCH_EQUIPMENT_H
#define EPOWERSWITCH_EQUIPMENT_H
#include "m_epics_ca.h"
#include "tmfe.h"
#include <vector>
class ePowerSwitchEquipment : public TMFeEquipment {
public:
/**
* @brief constructor
*
* @param equipmentName name show on Midas for the equipment
* @param equipmentFileName file name for automatically tagged message
*/
ePowerSwitchEquipment(std::string equipmentName,
const char *equipmentFileName);
/**
* @brief called periodically by Midas
*/
void HandlePeriodic();
private:
std::vector<mEpicsCa<std::string> *> outletSetRecords;
std::vector<mEpicsCa<std::string> *> outletGetRecords;
mEpicsCa<int> outletNumberRecord;
int numberOfOutlet;
/**
* @brief refresh information about the given socket ID
*
* @param socketId which socket to refresh
*/
void refreshSocket(int socketId);
/**
* @brief refresh information about all the available sockets
*/
void refreshAllSockets();
/**
* @brief detect and modify the current socket pool in case of change
*/
void updateSocketNumber();
};
#endif
@@ -5,7 +5,4 @@
#define EPOWERSWITCH_SOCKET_GET_PREFIX "ePowerSwitch_get_outlet_"
#define EPOWERSWITCH_SOCKETNUMBER_INFO_PREFIX "ePowerSwitch_config_maxOutlet"
#define DEFAULT_FRONTEND_NAME "ePowerSwitch"
#define DEFAULT_EQUIPMENT_NAME "powerswitch"
#endif
+49
View File
@@ -0,0 +1,49 @@
#include "ePowerSwitchFrontend.h"
#include "../device/ePowerSwitchEquipment.h"
#include "ePowerSwitchFrontendConfig.h"
#include "tmfe.h"
int main(int argc, char *argv[]) {
if (argv[0][0] == '.') {
TMFE::Instance()->Msg(MERROR, __FUNCTION__,
"Relative paths are strongly discouraged; "
"please use an absolute path.");
}
std::string frontendName;
std::string equipmentName;
if (argc == 1) {
frontendName = DEFAULT_FRONTEND_NAME;
TMFE::Instance()->Msg(MINFO, __FUNCTION__,
"No frontend name provided; %s will be used",
DEFAULT_FRONTEND_NAME);
equipmentName = DEFAULT_EQUIPMENT_NAME;
TMFE::Instance()->Msg(MINFO, __FUNCTION__,
"No equipment name provided; %s will be used",
DEFAULT_EQUIPMENT_NAME);
}
if (argc == 2) {
frontendName = std::string(argv[1]);
argv++;
argc--;
TMFE::Instance()->Msg(MINFO, __FUNCTION__,
"No equipment name provided; %s will be use",
DEFAULT_EQUIPMENT_NAME);
} else if (argc == 3) {
frontendName = std::string(argv[1]);
equipmentName = std::string(argv[2]);
argv += 2;
argc -= 2;
}
auto front = new ePowerSwitchFrontend(frontendName, equipmentName);
front->FeMain(argc, argv);
}
ePowerSwitchFrontend::ePowerSwitchFrontend(std::string frontendName,
std::string equipmentName) {
FeSetName(frontendName.c_str());
FeAddEquipment(new ePowerSwitchEquipment(equipmentName.c_str(), __FILE__));
}
+17
View File
@@ -0,0 +1,17 @@
#ifndef EPOWERSWITCH_FRONTEND_H
#define EPOWERSWITCH_FRONTEND_H
#include "tmfe.h"
class ePowerSwitchFrontend : public TMFrontend {
public:
/**
* @brief constructor
*
* @param frontendName name shown on Midas for the frontend
* @param equipmentName name shown on Midas for the equipment
*/
ePowerSwitchFrontend(std::string frontendName, std::string equipmentName);
};
#endif
@@ -0,0 +1,7 @@
#ifndef EPOWERSWITCH_CONFIG_H
#define EPOWERSWITCH_CONFIG_H
#define DEFAULT_FRONTEND_NAME "ePowerSwitch"
#define DEFAULT_EQUIPMENT_NAME "powerswitch"
#endif