Skip to content
Open
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
1 change: 1 addition & 0 deletions pkgs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ in
# EPICS support modules

support = recurseExtensible (_self: {
adcore = callPackage ./epnix/support/adcore {};
adsDriver = callPackage ./epnix/support/adsDriver {};
asyn = callPackage ./epnix/support/asyn {};
autoparamDriver = callPackage ./epnix/support/autoparamDriver {};
Expand Down
46 changes: 46 additions & 0 deletions pkgs/epnix/support/adcore/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
mkEpicsPackage,
fetchFromGitHub,
epnix,
lib,
epnixLib,
libxml2,

withHDF5 ? false,
hdf5,
}:
mkEpicsPackage rec {
pname = "adcore";
version = "3-14";

varname = "ADCORE";

src = fetchFromGitHub {
owner = "areaDetector";
repo = pname;
rev = "R${version}";
hash = "sha256-il/mP6muwar5BclYTjUERy6LUyh3MUJZVkTxXzCecvA=";
};

propagatedBuildInputs = with epnix.support; [asyn libxml2];

patches = lib.optional withHDF5 ./include-xmllib-global.patch;

postPatch = ''
echo "RELEASE_INCLUDES += -I${libxml2.dev}/include/libxml2" >> configure/RELEASE
cat configure/RELEASE
'' + lib.optionalString withHDF5 ''
echo "WITH_HDF5=YES" >> configure/RELEASE
echo "HDF5_EXTERNAL=YES" >> configure/RELEASE
echo "HDF5_LIB=${hdf5}/lib" >> configure/RELEASE
'';

buildInputs = [libxml2] ++ lib.optional withHDF5 hdf5;

meta = {
description = "An asyn driver that creates parameters dynamically based on content of record links";
homepage = "https://epics.cosylab.com/documentation/autoparamDriver/";
license = lib.licenses.mit;
maintainers = with epnixLib.maintainers; [synthetica];
};
}
183 changes: 183 additions & 0 deletions pkgs/epnix/support/adcore/include-xmllib-global.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
diff --git a/ADApp/pluginSrc/NDFileHDF5LayoutXML.cpp b/ADApp/pluginSrc/NDFileHDF5LayoutXML.cpp
index e5f08466..83c1020d 100644
--- a/ADApp/pluginSrc/NDFileHDF5LayoutXML.cpp
+++ b/ADApp/pluginSrc/NDFileHDF5LayoutXML.cpp
@@ -346,7 +346,7 @@ namespace hdf5
attr_src = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_SOURCE.c_str());
if (attr_src == NULL) return ret;
str_attr_src = (char*)attr_src;
- xmlGetGlobalState()->xmlFree(attr_src);
+ xmlFree(attr_src);

if (str_attr_src == LayoutXML::ATTR_SRC_DETECTOR){
out = DataSource( detector );
@@ -374,7 +374,7 @@ namespace hdf5
attr_src = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_SOURCE.c_str());
if (attr_src == NULL) return ret;
str_attr_src = (char*)attr_src;
- xmlGetGlobalState()->xmlFree(attr_src);
+ xmlFree(attr_src);

std::string str_attr_val = "";
xmlChar *attr_val = NULL;
@@ -389,14 +389,14 @@ namespace hdf5
attr_val = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_SRC_NDATTR.c_str());
if (attr_val != NULL) {
str_attr_val = (char*)attr_val;
- xmlGetGlobalState()->xmlFree(attr_val);
+ xmlFree(attr_val);
}
out.source = DataSource( ndattribute, str_attr_val );
// Check for a when="OnFileClose" or when="OnFileOpen" tag
attr_when = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_SRC_WHEN.c_str());
if (attr_when != NULL) {
str_attr_when = (char*)attr_when;
- xmlGetGlobalState()->xmlFree(attr_when);
+ xmlFree(attr_when);
}
if (str_attr_when == "OnFileOpen"){
out.source.set_when_to_save(OnFileOpen);
@@ -414,13 +414,13 @@ namespace hdf5
attr_val = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_SRC_CONST_VALUE.c_str());
if (attr_val != NULL) {
str_attr_val = (char*)attr_val;
- xmlGetGlobalState()->xmlFree(attr_val);
+ xmlFree(attr_val);
}
out.source = DataSource( constant, str_attr_val );
attr_type = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_SRC_CONST_TYPE.c_str());
if (attr_type != NULL) {
str_attr_type = (char*)attr_type;
- xmlGetGlobalState()->xmlFree(attr_type);
+ xmlFree(attr_type);
DataType_t dtype = string;
if (str_attr_type == "int") dtype = int32;
else if (str_attr_type == "float") dtype = float64;
@@ -446,7 +446,7 @@ namespace hdf5

// Get the standard string representation of the tag
std::string str_root_auto((char*)root_auto);
- xmlGetGlobalState()->xmlFree(root_auto);
+ xmlFree(root_auto);

// Now check if we have the correct string
if (str_root_auto == "false"){
@@ -472,7 +472,7 @@ namespace hdf5
if (group_name == NULL) return -1;

std::string str_group_name((const char*)group_name);
- xmlGetGlobalState()->xmlFree(group_name);
+ xmlFree(group_name);

// Initialise the tree if it has not already been done.
if (this->ptr_tree == NULL){
@@ -495,7 +495,7 @@ namespace hdf5
ndattr_default = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar *)LayoutXML::ATTR_GRP_NDATTR_DEFAULT.c_str());
if (ndattr_default != NULL){
std::string str_ndattr_default((char*)ndattr_default);
- xmlGetGlobalState()->xmlFree(ndattr_default);
+ xmlFree(ndattr_default);
// if the group has tag: ndattr_default="true" (true in lower case)
// then set the group as the default container for NDAttributes.
if (str_ndattr_default == "true"){
@@ -524,7 +524,7 @@ namespace hdf5
if (dset_name == NULL) return -1;

std::string str_dset_name((char*)dset_name);
- xmlGetGlobalState()->xmlFree(dset_name);
+ xmlFree(dset_name);
Group *parent = (Group *)this->ptr_curr_element;
Dataset *dset = NULL;
dset = parent->new_dset(str_dset_name);
@@ -537,7 +537,7 @@ namespace hdf5
attr_def = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_SRC_DET_DEFAULT.c_str());
if (attr_def != NULL){
str_attr_def = (char*)attr_def;
- xmlGetGlobalState()->xmlFree(attr_def);
+ xmlFree(attr_def);
if (str_attr_def == "true"){
detector_default = true;
}
@@ -556,14 +556,14 @@ namespace hdf5
attr_ndname = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_SRC_NDATTR.c_str());
if (attr_ndname != NULL){
str_attr_ndname = (char*)attr_ndname;
- xmlGetGlobalState()->xmlFree(attr_ndname);
+ xmlFree(attr_ndname);
dset->set_ndattr_name(str_attr_ndname);
//if ndattribute, check for 'when' tag
xmlChar *attr_when = NULL;
attr_when = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_SRC_WHEN.c_str());
if (attr_when != NULL){
std::string str_attr_when( (char*)attr_when );
- xmlGetGlobalState()->xmlFree(attr_when);
+ xmlFree(attr_when);
When_t when_to_save = OnFrame; //Default is to save every frame
if (str_attr_when == "OnFileOpen"){
when_to_save = OnFileOpen;
@@ -578,12 +578,12 @@ namespace hdf5
c_val = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_SRC_CONST_VALUE.c_str());
if (c_val != NULL) {
str_val = (char*)c_val;
- xmlGetGlobalState()->xmlFree(c_val);
+ xmlFree(c_val);
}
c_type = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_SRC_CONST_TYPE.c_str());
if (c_type != NULL){
str_type = (char*)c_type;
- xmlGetGlobalState()->xmlFree(c_type);
+ xmlFree(c_type);
DataType_t dtype = string;
if (str_type == "int") dtype = int32;
else if (str_type == "float") dtype = float64;
@@ -608,7 +608,7 @@ namespace hdf5
if (ndattr_name == NULL) return -1;

std::string str_ndattr_name((char*)ndattr_name);
- xmlGetGlobalState()->xmlFree(ndattr_name);
+ xmlFree(ndattr_name);
Attribute ndattr(str_ndattr_name);
this->process_attribute_xml_attribute(ndattr);

@@ -625,12 +625,12 @@ namespace hdf5
global_name = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_GLOBAL_NAME.c_str());
if (global_name == NULL) return -1;
std::string str_global_name((char*)global_name);
- xmlGetGlobalState()->xmlFree(global_name);
+ xmlFree(global_name);
xmlChar *global_value = NULL;
global_value = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_GLOBAL_VALUE.c_str());
if (global_value == NULL) return -1;
std::string str_global_value((char*)global_value);
- xmlGetGlobalState()->xmlFree(global_value);
+ xmlFree(global_value);

this->globals[str_global_name] = str_global_value;
return ret;
@@ -644,12 +644,12 @@ namespace hdf5
hardlink_name = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_ELEMENT_NAME.c_str());
if (hardlink_name == NULL) return -1;
std::string str_hardlink_name((char*)hardlink_name);
- xmlGetGlobalState()->xmlFree(hardlink_name);
+ xmlFree(hardlink_name);
xmlChar *hardlink_target = NULL;
hardlink_target = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_HARDLINK_TARGET.c_str());
if (hardlink_target == NULL) return -1;
const std::string str_hardlink_target((char*)hardlink_target);
- xmlGetGlobalState()->xmlFree(hardlink_target);
+ xmlFree(hardlink_target);
Group *parent = (Group *)this->ptr_curr_element;
HardLink *hardlink = NULL;
hardlink = parent->new_hardlink(str_hardlink_name);
diff --git a/ADApp/pluginSrc/NDFileHDF5LayoutXML.h b/ADApp/pluginSrc/NDFileHDF5LayoutXML.h
index c1ad4929..a3a612c8 100644
--- a/ADApp/pluginSrc/NDFileHDF5LayoutXML.h
+++ b/ADApp/pluginSrc/NDFileHDF5LayoutXML.h
@@ -8,6 +8,7 @@
#ifndef NDFILEHDF5LAYOUTXML_H_
#define NDFILEHDF5LAYOUTXML_H_

+#include <libxml/globals.h>
#include <libxml/xmlreader.h>
#include <string>
#include <map>