Skip to content

Commit

Permalink
Merge 1975a36 into 18c8d69
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-ess authored Nov 4, 2023
2 parents 18c8d69 + 1975a36 commit ffe5261
Show file tree
Hide file tree
Showing 28 changed files with 3,173 additions and 74 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ __pycache__/
*.orig
*.log
.*.swp
.vscode
36 changes: 36 additions & 0 deletions documentation/pvalink-schema-0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://mdavidsaver.github.io/pvxs/pvalink-schema-0.json",
"title": "PVA Link schema",
"type": ["string", "object"],
"properties": {
"pv": { "type": "string" },
"field": {
"type": "string",
"default": "value"
},
"Q": {
"type": "integer",
"default": 4
},
"proc": {
"type": ["boolean", "string", "null"],
"enum": [true, false, null, "", "NPP", "PP", "CP", "CPP"],
"default": null
},
"sevr": {
"type": ["boolean", "string"],
"enum": [true, false, "NMS", "MS", "MSI", "MSS"],
"default": "NMS"
},
"time": { "type": "boolean", "default": false },
"monorder": { "type": "integer", "default": 0 },
"defer": { "type": "boolean", "default": false },
"retry": { "type": "boolean", "default": false },
"pipeline": { "type": "boolean", "default": false },
"always": { "type": "boolean", "default": false },
"atomic": { "type": "boolean", "default": false },
"local": { "type": "boolean", "default": false }
},
"additionalProperties": false
}
14 changes: 13 additions & 1 deletion ioc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ pvxsIoc_SRCS += groupconfigprocessor.cpp
pvxsIoc_SRCS += groupprocessorcontext.cpp
pvxsIoc_SRCS += groupsource.cpp
pvxsIoc_SRCS += groupsourcehooks.cpp
pvxsIoc_SRCS += pvalink.cpp
pvxsIoc_SRCS += pvalink_channel.cpp
pvxsIoc_SRCS += pvalink_jlif.cpp
pvxsIoc_SRCS += pvalink_link.cpp
pvxsIoc_SRCS += pvalink_lset.cpp

else # BASE_7_0
else

pvxsIoc_SRCS += dummygroup.cpp

Expand All @@ -84,3 +89,10 @@ include $(TOP)/configure/RULES_PVXS_MODULE
#----------------------------------------
# ADD RULES AFTER THIS LINE

ifdef BASE_7_0
../O.Common/pvxsIoc.dbd: ../pvxs7x.dbd
$(CP) $< $@
else
../O.Common/pvxsIoc.dbd: ../pvxs3x.dbd
$(CP) $< $@
endif
17 changes: 7 additions & 10 deletions ioc/groupsourcehooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <pvxs/source.h>
#include <pvxs/iochooks.h>

#include "qsrvpvt.h"
#include "groupsource.h"
#include "groupconfigprocessor.h"
#include "iocshcommand.h"
Expand Down Expand Up @@ -176,8 +177,6 @@ using namespace pvxs;
*/
void qsrvGroupSourceInit(initHookState theInitHookState) {
try {
if(!IOCSource::enabled())
return;
if (theInitHookState == initHookAfterInitDatabase) {
GroupConfigProcessor processor;
epicsGuard<epicsMutex> G(processor.config.groupMapMutex);
Expand Down Expand Up @@ -209,6 +208,10 @@ void qsrvGroupSourceInit(initHookState theInitHookState) {
}
}

} // namespace

namespace pvxs {
namespace ioc {
/**
* IOC pvxs Group Source registrar. This implements the required registrar function that is called by xxxx_registerRecordDeviceDriver,
* the auto-generated stub created for all IOC implementations.
Expand All @@ -220,7 +223,7 @@ void qsrvGroupSourceInit(initHookState theInitHookState) {
* group record type sources defined so far. Note that you can define sources up until the `iocInit()` call,
* after which point the `initHookAfterIocBuilt` handlers are called and will register all the defined records.
*/
void pvxsGroupSourceRegistrar() {
void group_enable() {
// Register commands to be available in the IOC shell
IOCShCommand<int, const char*>("pvxgl", "[level, [pattern]]",
"Group Sources list.\n"
Expand All @@ -236,10 +239,4 @@ void pvxsGroupSourceRegistrar() {
initHookRegister(&qsrvGroupSourceInit);
}

} // namespace

// in .dbd file
//registrar(pvxsGroupSourceRegistrar)
extern "C" {
epicsExportRegistrar(pvxsGroupSourceRegistrar);
}
}} // namespace pvxs::ioc
69 changes: 64 additions & 5 deletions ioc/iochooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@

#include <epicsExport.h>
#include <epicsExit.h>
#include <epicsString.h>
#include <initHooks.h>
#include <iocsh.h>
#include <dbAccess.h>
#include <dbStaticLib.h>
#include <registryDeviceSupport.h>

#include <pvxs/iochooks.h>
#include <pvxs/log.h>
Expand All @@ -28,14 +32,11 @@

#include "iocshcommand.h"
#include "utilpvt.h"
#include "qsrvpvt.h"

// include last to avoid clash of #define printf with other headers
#include <epicsStdio.h>

#if EPICS_VERSION_INT >= VERSION_INT(7, 0, 4, 0)
# define USE_DEINIT_HOOKS
#endif

namespace pvxs {
namespace ioc {

Expand Down Expand Up @@ -286,6 +287,56 @@ using namespace pvxs::ioc;

namespace {

bool enable2() {
// detect if also linked with qsrv.dbd
const bool permit = !registryDeviceSupportFind("devWfPDBDemo");
bool request = permit;
bool quiet = false;

auto env_dis = getenv("EPICS_IOC_IGNORE_SERVERS");
auto env_ena = getenv("PVXS_QSRV_ENABLE");

if(env_dis && strstr(env_dis, "qsrv2")) {
request = false;
quiet = true;

} else if(env_ena && epicsStrCaseCmp(env_ena, "YES")==0) {
request = true;

} else if(env_ena && epicsStrCaseCmp(env_ena, "NO")==0) {
request = false;
quiet = true;

} else if(env_ena) {
// will be seen during initialization, print synchronously
fprintf(stderr, "ERROR: PVXS_QSRV_ENABLE=%s not YES/NO. Defaulting to %s.\n",
env_ena,
request ? "YES" : "NO");
}

const bool enable = permit && request;

if(quiet) {
// shut up, I know what I'm doing...
} else if(request && !permit) {
fprintf(stderr,
"WARNING: QSRV1 detected, disabling QSRV2.\n"
" If not intended, omit qsrv.dbd when including pvxsIoc.dbd\n");

} else {
printf("INFO: PVXS QSRV2 is loaded, %spermitted, and %s.\n",
permit ? "" : "NOT ",
enable ? "ENABLED" : "disabled");

if(!permit) {
printf(" Not permitted due to confict with QSRV1.\n"
" Remove qsrv.dbd from IOC.\n");
}
}

return enable;
}

/**
* IOC pvxs base registrar. This implements the required registrar function that is called by xxxx_registerRecordDeviceDriver,
* the auto-generated stub created for all IOC implementations.
Expand All @@ -296,10 +347,12 @@ namespace {
* 2. Also make sure that you initialize your server implementation - PVXS in our case - so that it will be available for the shell.
* 3. Lastly register your hook handler to handle any state hooks that you want to implement
*/
void pvxsBaseRegistrar() {
void pvxsBaseRegistrar() noexcept {
try {
pvxs::logger_config_env();

bool enableQ = enable2();

pvxServer = new pvxServer_t();

IOCShCommand<int>("pvxsr", "[show_detailed_information?]", "PVXS Server Report. "
Expand All @@ -320,6 +373,12 @@ void pvxsBaseRegistrar() {

// Register our hook handler to intercept certain state changes
initHookRegister(&pvxsInitHook);

if(enableQ) {
single_enable();
group_enable();
pvalink_enable();
}
} catch (std::exception& e) {
fprintf(stderr, "Error in %s : %s\n", __func__, e.what());
}
Expand Down
40 changes: 0 additions & 40 deletions ioc/iocsource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,46 +36,6 @@ DEFINE_LOGGER(_log, "pvxs.ioc.db");
namespace pvxs {
namespace ioc {


bool IOCSource::enabled()
{
/* -1 - disabled
* 0 - lazy init, check environment
* 1 - enabled
*/
static std::atomic<int> ena{};

auto e = ena.load();
if(e==0) {
e = inUnitTest() ? 1 : -1; // default to disabled normally (not unittest)

auto env_dis = getenv("EPICS_IOC_IGNORE_SERVERS");
auto env_ena = getenv("PVXS_QSRV_ENABLE");

if(env_dis && strstr(env_dis, "qsrv2")) {
e = -1;

} else if(env_ena && epicsStrCaseCmp(env_ena, "YES")==0) {
e = 1;

} else if(env_ena && epicsStrCaseCmp(env_ena, "NO")==0) {
e = -1;

} else if(env_ena) {
// will be seen during initialization, print synchronously
fprintf(stderr, "ERROR: PVXS_QSRV_ENABLE=%s not YES/NO. Defaulting to %s.\n",
env_ena,
e==1 ? "YES" : "NO");
}
printf("INFO: PVXS QSRV2 is loaded and %s\n",
e==1 ? "ENABLED." : "disabled.\n"
" To enable set: epicsEnvSet(\"PVXS_QSRV_ENABLE\",\"YES\")\n"
" and ensure that $EPICS_IOC_IGNORE_SERVERS does not contain \"qsrv2\".");
ena = e;
}
return e==1;
}

void IOCSource::initialize(Value& value, const MappingInfo &info, const Channel& chan)
{
if(info.type==MappingInfo::Scalar) {
Expand Down
2 changes: 0 additions & 2 deletions ioc/iocsource.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ enum type {

class IOCSource {
public:
static bool enabled();

static void initialize(Value& value, const MappingInfo &info, const Channel &chan);

static void get(Value& valuePrototype,
Expand Down
Loading

0 comments on commit ffe5261

Please sign in to comment.