diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e156538 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "midas_lan_gpib"] + path = midas_lan_gpib + url = git@gitea.psi.ch:lin-midas-drivers/midas_lan_gpib.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b14aca..ff3da57 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required(VERSION 3.03) +# This cmake file build 2 targets, one for tcpip and one for langpib + project(lakeshore_340 VERSION 0.1) add_compile_options( @@ -11,26 +13,11 @@ add_compile_options( -Wno-unused-function ) -option( - BUILD_FRONTEND - "If ON, build the default frontend executable" - OFF -) - set(CMAKE_PREFIX_PATH "$ENV{MIDASSYS}") find_package(Midas REQUIRED) -set( - TCPIP_DRIVER_DIR - $ENV{MIDASSYS}/drivers/bus/tcpip.cxx - CACHE STRING - "path to tcpip driver that should be used" -) - -set( - DRIVERS - $ENV{MIDASSYS}/drivers/class/multi.cxx -) +#build midas_lan_gib if not already there +add_subdirectory(midas_lan_gpib) set(SYS_LIBS pthread @@ -46,88 +33,96 @@ set(MIDAS_LIBS midas::mscb ) -set(LIBS ${SYS_LIBS} ${MIDAS_LIBS}) - ################################################################################ ## make tcpip library configurable ################################################################################ -if(IS_DIRECTORY ${TCPIP_DRIVER_DIR}) - add_subdirectory( - # TODO not sure, should it be a submodule? does it really make sense to - # separate everything? - ${TCPIP_DRIVER_DIR} ./bus/tcpip - ) - - set( - LIBS - ${LIBS} - tcpip - ) -else() - set( - DRIVERS - ${DRIVERS} - ${TCPIP_DRIVER_DIR} - ) -endif() - ################################################################################ -## Device Library +## Device Libraries ################################################################################ -add_library( - lakeshore_340 - device/lakeshore_340.cxx - ${DRIVERS} -) +foreach(target IN ITEMS lakeshore_340 lakeshore_340langpib) -set_property( - TARGET - lakeshore_340 - PROPERTY - CXX_STANDARD 11 -) - -target_include_directories( - lakeshore_340 - PUBLIC - $ - ${CMAKE_CURRENT_SOURCE_DIR} -) - -target_link_libraries( - lakeshore_340 - ${LIBS} -) - -################################################################################ -## Test Frontend -################################################################################ - -if(${}) - - add_executable( - lakeshore_340_fe - frontend/lakeshore_340_scfe.cxx + add_library( + ${target} + device/lakeshore_340.cxx ) + set_property( TARGET - lakeshore_340_fe + ${target} PROPERTY CXX_STANDARD 11 ) target_include_directories( - lakeshore_340_fe - PRIVATE - $ENV{MIDASSYS}/drivers + ${target} + PUBLIC + $ + ${CMAKE_CURRENT_SOURCE_DIR} ) target_link_libraries( - lakeshore_340_fe - lakeshore_340 + ${target} + ${SYS_LIBS} + ${MIDAS_LIBS} ) -endif() \ No newline at end of file +endforeach() + +target_sources( + lakeshore_340 PRIVATE + $ENV{MIDASSYS}/drivers/bus/tcpip.cxx +) + +target_link_libraries( + lakeshore_340langpib + midas_lan_gpib +) + +# Compile the device driver for use with GPIB +target_compile_definitions(lakeshore_340langpib PRIVATE LANGPIB_SUPPORT) + +################################################################################ +## Test Frontend +################################################################################ +set(_DEFAULT_LAKESHORE_340_FRONTEND_DIR "${CMAKE_CURRENT_LIST_DIR}" CACHE INTERNAL "") + +function(default_lakeshore_340_frontend F_TARGET F_NAME F_EVENT_ID LIB_TARGET) + + if(NOT ("${LIB_TARGET}" STREQUAL "lakeshore_340" OR "${LIB_TARGET}" STREQUAL "lakeshore_340langpib")) + message(FATAL_ERROR "Invalid lakeshore 340 target") + endif() + + message("LAKESHORE_340: ${F_NAME} ${F_EVENT_ID} ${LIB_TARGET}") + + add_executable( + ${F_TARGET} + ${_DEFAULT_LAKESHORE_340_FRONTEND_DIR}/frontend/lakeshore_340_scfe.cxx + $ENV{MIDASSYS}/drivers/class/multi.cxx + ) + + target_compile_definitions(${F_TARGET} PRIVATE FRONTEND_NAME="${F_NAME}") + target_compile_definitions(${F_TARGET} PRIVATE FRONTEND_ID=${F_EVENT_ID}) + target_compile_definitions(${F_TARGET} PRIVATE TARGET_LIB=${LIB_TARGET}) + + set_property( + TARGET + ${F_TARGET} + PROPERTY + CXX_STANDARD 11 + ) + + target_include_directories( + ${F_TARGET} + PRIVATE + $ENV{MIDASSYS}/drivers + ) + + target_link_libraries( + ${F_TARGET} + ${LIB_TARGET} + ) + +endfunction() diff --git a/README.md b/README.md index 9da287d..a6dd087 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,12 @@ cmake -S "$(pwd)" -B -DBUILD_FRONTEND=ON cmake --build --clean-first -- -j8 ``` -## Run +## Configuration files: +This frontend has file-system interactions. It should be started in a dedicated configuration file folder. As a start command in the odb, simply prepend a ```cd``` command. +## Run ```bash -/build/driver/lakeshore_340_fe -e flame +cd /home/repos/programs/frontends/ccr_oven_ls340_scfe/config; /build/driver/lakeshore_340_fe -e gps ``` ## Including in Custom Frontend diff --git a/device/lakeshore_340.cxx b/device/lakeshore_340.cxx index c7297c0..a6cc0b8 100644 --- a/device/lakeshore_340.cxx +++ b/device/lakeshore_340.cxx @@ -77,7 +77,7 @@ #endif #ifdef LANGPIB_SUPPORT -#include "bus/langpib.h" +#include "midas_lan_gpib.h" #endif #define WATCHDOG // disable checking of this front end by watchdog during diff --git a/frontend/lakeshore_340_scfe.cxx b/frontend/lakeshore_340_scfe.cxx index a4df756..7bff96b 100644 --- a/frontend/lakeshore_340_scfe.cxx +++ b/frontend/lakeshore_340_scfe.cxx @@ -6,14 +6,20 @@ #include "midas.h" #include "mfe.h" +// Depending on preprocess var +#if TARGET_LIB == lakeshore_340langpib +#include "midas_lan_gpib.h" +#else #include "bus/tcpip.h" +#endif + #include "class/multi.h" #include "lakeshore_340.h" //-- Globals ------------------------------------------------------- //! The frontend name (client name) as seen by other MIDAS clients -const char *frontend_name = "Lakeshore340"; +const char *frontend_name = FRONTEND_NAME; //! The frontend file name, don't change it const char *frontend_file_name = __FILE__; @@ -42,8 +48,13 @@ BOOL should_exit=FALSE; *

device driver list for sample cryo and flow */ DEVICE_DRIVER ls340_driver[] = { +#if TARGET_LIB == lakeshore_340langpib + { "LS340in", ls340_in, 48, langpib, DF_INPUT}, + { "LS340out", ls340_out, 24, langpib, DF_OUTPUT}, +#else { "LS340in", ls340_in, 48, tcpip, DF_INPUT}, { "LS340out", ls340_out, 24, tcpip, DF_OUTPUT}, +#endif { "" } }; @@ -60,8 +71,8 @@ BOOL equipment_common_overwrite = FALSE; //! equipment structure for the mfe.c EQUIPMENT equipment[] = { - { "Lakeshore340", /* equipment name */ - {95, 0, /* event ID, trigger mask */ + { FRONTEND_NAME, /* equipment name */ + {FRONTEND_ID, 0, /* event ID, trigger mask */ "SYSTEM", /* event buffer */ EQ_SLOW, /* equipment type */ 0, /* event source */ diff --git a/midas_lan_gpib b/midas_lan_gpib new file mode 160000 index 0000000..32cc20d --- /dev/null +++ b/midas_lan_gpib @@ -0,0 +1 @@ +Subproject commit 32cc20d943cb3ecf4c7a6b7565960591b5442b6e