Skip to content

Commit

Permalink
Merge 8cc9eaa into 17464a1
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-ess authored Nov 9, 2023
2 parents 17464a1 + 8cc9eaa commit 5548c3f
Show file tree
Hide file tree
Showing 28 changed files with 3,430 additions and 202 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
92 changes: 34 additions & 58 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 @@ -161,66 +162,49 @@ long dbLoadGroup(const char* jsonFilename, const char* macros) {
}
}

}
} // namespace pvxs::ioc

using namespace pvxs::ioc;
void processGroups()
{
GroupConfigProcessor processor;
epicsGuard<epicsMutex> G(processor.config.groupMapMutex);

namespace {
using namespace pvxs;
// Parse all info(Q:Group... records to configure groups
processor.loadConfigFromDb();

/**
* Initialise qsrv database group records by adding them as sources in our running pvxs server instance
*
* @param theInitHookState the initHook state - we only want to trigger on the initHookAfterIocBuilt state - ignore all others
*/
void qsrvGroupSourceInit(initHookState theInitHookState) {
try {
if(!IOCSource::enabled())
return;
if (theInitHookState == initHookAfterInitDatabase) {
GroupConfigProcessor processor;
epicsGuard<epicsMutex> G(processor.config.groupMapMutex);
// Load group configuration files
processor.loadConfigFiles();

// Parse all info(Q:Group... records to configure groups
processor.loadConfigFromDb();
// checks on groupConfigMap
processor.validateGroups();

// Load group configuration files
processor.loadConfigFiles();
// Configure groups
processor.defineGroups();

// checks on groupConfigMap
processor.validateGroups();
// Resolve triggers
processor.resolveTriggerReferences();

// Configure groups
processor.defineGroups();
// Create Server Groups
processor.createGroups();
}

// Resolve triggers
processor.resolveTriggerReferences();
void addGroupSrc()
{
pvxs::ioc::server()
.addSource("qsrvGroup", std::make_shared<pvxs::ioc::GroupSource>(), 1);
}

// Create Server Groups
processor.createGroups();
} else if (theInitHookState == initHookAfterIocBuilt) {
// Load group configuration from parsed groups in iocServer
pvxs::ioc::server().addSource("qsrvGroup", std::make_shared<pvxs::ioc::GroupSource>(), 1);
}
} catch(std::exception& e) {
fprintf(stderr, "ERROR: Unhandled exception in %s(%d): %s\n",
__func__, theInitHookState, e.what());
}
void resetGroups()
{
auto& config(IOCGroupConfig::instance());

// server stopped at this point, but lock anyway
epicsGuard<epicsMutex> G(config.groupMapMutex);

config.groupMap.clear();
config.groupConfigFiles.clear();
}

/**
* 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.
*<p>
* It is registered by using the `epicsExportRegistrar()` macro.
*<p>
* 1. Register your hook handler to handle any state hooks that you want to implement. Here we install
* an `initHookState` handler connected to the `initHookAfterIocBuilt` state. It will add all of the
* 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 @@ -232,14 +216,6 @@ void pvxsGroupSourceRegistrar() {
IOCShCommand<const char*, const char*>("dbLoadGroup",
"JSON file", "macros", dbLoadGroupMsg)
.implementation<&dbLoadGroupCmd>();

initHookRegister(&qsrvGroupSourceInit);
}

} // namespace

// in .dbd file
//registrar(pvxsGroupSourceRegistrar)
extern "C" {
epicsExportRegistrar(pvxsGroupSourceRegistrar);
}
}} // namespace pvxs::ioc
Loading

0 comments on commit 5548c3f

Please sign in to comment.