Skip to content

Commit

Permalink
Add separate SWIG interfaces for L0 and R1v0
Browse files Browse the repository at this point in the history
  • Loading branch information
sfegan committed Sep 9, 2024
1 parent 9fff6da commit f7ace21
Show file tree
Hide file tree
Showing 4 changed files with 202 additions and 38 deletions.
2 changes: 2 additions & 0 deletions src/iact_data/zfits_acada_data_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ namespace {
template<typename Message> std::string default_message_table_name() { return "unknown"; }
template<> std::string default_message_table_name<ACADA_L0_HeaderMessage>() { return "RunHeader"; }
template<> std::string default_message_table_name<ACADA_L0_EventMessage>() { return "Events"; }
template<> std::string default_message_table_name<ACADA_R1v0_HeaderMessage>() { return "CameraConfig"; }
template<> std::string default_message_table_name<ACADA_R1v0_EventMessage>() { return "Events"; }
} // anonymous namespace

// =============================================================================
Expand Down
2 changes: 1 addition & 1 deletion swig/iact_data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ set(CALIN_SWIG_FILES algorithms.i telescope_data_source.i
if(CTA_CAMERASTOACTL_FOUND)
set(CALIN_SWIG_FILES ${CALIN_SWIG_FILES} raw_actl_l0_event_data_source.i
raw_actl_r1_event_data_source.i actl_event_decoder.i
raw_acada_event_data_source.i)
raw_acada_event_data_source_l0.i raw_acada_event_data_source_r1v0.i)
endif()
set(CALIN_SWIG_TARGET iact_data)

Expand Down
154 changes: 154 additions & 0 deletions swig/iact_data/raw_acada_event_data_source_l0.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/*
calin/iact_data/raw_actl_r1_event_data_source.i -- Stephen Fegan -- 2024-09-09
SWIG interface file for calin.io.raw_acada_event_data_source
Copyright 2024, Stephen Fegan <[email protected]>
Laboratoire Leprince-Ringuet, CNRS/IN2P3, Ecole Polytechnique, Institut Polytechnique de Paris
This file is part of "calin"
"calin" is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License version 2 or
later, as published by the Free Software Foundation.
"calin" is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
*/

%module (package="calin.iact_data") raw_acada_event_data_source_l0
%feature(autodoc,2);

%{
using std::streamoff;
#include <iact_data/telescope_data_source.hpp>
#include <iact_data/zfits_acada_data_source.hpp>
#include <iact_data/nectarcam_data_source.hpp>
#include <iact_data/lstcam_data_source.hpp>
#include <iact_data/cta_data_source.hpp>
#define SWIG_FILE_WITH_INIT
%}

%init %{
import_array();
%}

%include "calin_typemaps.i"
%include "calin_global_config.hpp"
%import "calin_global_definitions.i"

%import "google_protobuf.i"
%import "io/data_source.i"

%ignore get_next(uint64_t& seq_index_out);
%ignore get_next(uint64_t& seq_index_out, google::protobuf::Arena** arena);

%newobject simple_get_next();
%newobject get_run_header();

%include "io/chained_data_source.hpp"
%import "iact_data/telescope_data_source.i"
%include "iact_data/acada_data_source.hpp"
%include "iact_data/zfits_acada_data_source.hpp"

%apply uint64_t& OUTPUT { uint64_t& seq_index_out };
%apply google::protobuf::Arena** CALIN_ARENA_OUTPUT {
google::protobuf::Arena** arena_out };

/*
LLLLLLLLLLL 000000000
L:::::::::L 00:::::::::00
L:::::::::L 00:::::::::::::00
LL:::::::LL 0:::::::000:::::::0
L:::::L 0::::::0 0::::::0
L:::::L 0:::::0 0:::::0
L:::::L 0:::::0 0:::::0
L:::::L 0:::::0 000 0:::::0
L:::::L 0:::::0 000 0:::::0
L:::::L 0:::::0 0:::::0
L:::::L 0:::::0 0:::::0
L:::::L LLLLLL 0::::::0 0::::::0
LL:::::::LLLLLLLLL:::::L 0:::::::000:::::::0
L::::::::::::::::::::::L 00:::::::::::::00
L::::::::::::::::::::::L 00:::::::::00
LLLLLLLLLLLLLLLLLLLLLLLL 000000000
*/

namespace DataModel {
class CameraEvent: public google::protobuf::Message { };
class CameraRunHeader: public google::protobuf::Message { };
}

%typemap(in, numinputs=0) DataModel::CameraEvent** CALIN_PROTOBUF_OUTPUT
(DataModel::CameraEvent* temp = nullptr) {
// typemap(in) DataModel::CameraEvent** CALIN_PROTOBUF_OUTPUT - raw_actl_event_data_source.i
$1 = &temp;
}

%typemap(argout) DataModel::CameraEvent** CALIN_PROTOBUF_OUTPUT {
// typemap(argout) DataModel::CameraEvent** CALIN_PROTOBUF_OUTPUT - raw_actl_event_data_source.i
%append_output(SWIG_NewPointerObj(SWIG_as_voidptr(*$1), $*1_descriptor, SWIG_POINTER_OWN));
}

%apply DataModel::CameraEvent** CALIN_PROTOBUF_OUTPUT {
DataModel::CameraEvent** event_out };

%template(DataSource_L0)
calin::io::data_source::DataSource<DataModel::CameraEvent>;
%template(RandomAccessDataSource_L0)
calin::io::data_source::RandomAccessDataSource<DataModel::CameraEvent>;

%extend calin::io::data_source::DataSource<DataModel::CameraEvent> {
DataModel::CameraEvent* simple_get_next()
{
uint64_t unused_seq_index = 0;
return $self->get_next(unused_seq_index);
}

void get_next(uint64_t& seq_index_out, DataModel::CameraEvent** event_out)
{
seq_index_out = 0;
*event_out = $self->get_next(seq_index_out);
}
}

%template(ACADACameraEventDataSource_L0)
calin::iact_data::acada_data_source::ACADACameraEventDataSource<DataModel::CameraEvent>;
%template(ACADACameraEventDataSourceWithRunHeader_L0)
calin::iact_data::acada_data_source::ACADACameraEventDataSourceWithRunHeader<
DataModel::CameraEvent,DataModel::CameraRunHeader>;
%template(ACADACameraEventRandomAccessDataSourceWithRunHeader_L0)
calin::iact_data::acada_data_source::ACADACameraEventRandomAccessDataSourceWithRunHeader<
DataModel::CameraEvent,DataModel::CameraRunHeader>;

%template(DataSourceOpener_L0)
calin::io::data_source::DataSourceOpener<
calin::iact_data::acada_data_source::ACADACameraEventRandomAccessDataSourceWithRunHeader<
DataModel::CameraEvent,DataModel::CameraRunHeader> >;

%template(BasicChainedDataSource_ACADACameraEventRandomAccessDataSourceWithRunHeader_L0)
calin::io::data_source::BasicChainedDataSource<
calin::iact_data::acada_data_source::ACADACameraEventRandomAccessDataSourceWithRunHeader<
DataModel::CameraEvent,DataModel::CameraRunHeader> >;

%template(BasicChainedRandomAccessDataSource_ACADACameraEventRandomAccessDataSourceWithRunHeader_L0)
calin::io::data_source::BasicChainedRandomAccessDataSource<
calin::iact_data::acada_data_source::ACADACameraEventRandomAccessDataSourceWithRunHeader<
DataModel::CameraEvent,DataModel::CameraRunHeader> >;

%template(ZFITSACADACameraEventDataSourceOpener_L0)
calin::iact_data::zfits_acada_data_source::ZFITSACADACameraEventDataSourceOpener<
DataModel::CameraEvent,DataModel::CameraRunHeader>;

%template(ZFITSSingleFileACADACameraEventDataSource_L0)
calin::iact_data::zfits_acada_data_source::ZFITSSingleFileACADACameraEventDataSource<
DataModel::CameraEvent,DataModel::CameraRunHeader>;
%template(ZFITSACADACameraEventDataSource_L0)
calin::iact_data::zfits_acada_data_source::ZFITSACADACameraEventDataSource<
DataModel::CameraEvent,DataModel::CameraRunHeader>;
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/

%module (package="calin.iact_data") raw_acada_event_data_source
%module (package="calin.iact_data") raw_acada_event_data_source_r1v0
%feature(autodoc,2);

%{
Expand All @@ -47,11 +47,42 @@ using std::streamoff;
%ignore get_next(uint64_t& seq_index_out);
%ignore get_next(uint64_t& seq_index_out, google::protobuf::Arena** arena);

namespace R1 {
%newobject simple_get_next();
%newobject get_run_header();

%include "io/chained_data_source.hpp"
%import "iact_data/telescope_data_source.i"
%include "iact_data/acada_data_source.hpp"
%include "iact_data/zfits_acada_data_source.hpp"

%apply uint64_t& OUTPUT { uint64_t& seq_index_out };
%apply google::protobuf::Arena** CALIN_ARENA_OUTPUT {
google::protobuf::Arena** arena_out };

class CameraEvent: public google::protobuf::Message { };
class CameraConfiguration: public google::protobuf::Message { };
/*
RRRRRRRRRRRRRRRRR 1111111 000000000
R::::::::::::::::R 1::::::1 00:::::::::00
R::::::RRRRRR:::::R 1:::::::1 00:::::::::::::00
RR:::::R R:::::R111:::::1 0:::::::000:::::::0
R::::R R:::::R 1::::1vvvvvvv vvvvvvv0::::::0 0::::::0
R::::R R:::::R 1::::1 v:::::v v:::::v 0:::::0 0:::::0
R::::RRRRRR:::::R 1::::1 v:::::v v:::::v 0:::::0 0:::::0
R:::::::::::::RR 1::::l v:::::v v:::::v 0:::::0 000 0:::::0
R::::RRRRRR:::::R 1::::l v:::::v v:::::v 0:::::0 000 0:::::0
R::::R R:::::R 1::::l v:::::v v:::::v 0:::::0 0:::::0
R::::R R:::::R 1::::l v:::::v:::::v 0:::::0 0:::::0
R::::R R:::::R 1::::l v:::::::::v 0::::::0 0::::::0
RR:::::R R:::::R111::::::111 v:::::::v 0:::::::000:::::::0
R::::::R R:::::R1::::::::::1 v:::::v 00:::::::::::::00
R::::::R R:::::R1::::::::::1 v:::v 00:::::::::00
RRRRRRRR RRRRRRR111111111111 vvv 000000000
*/

namespace R1 {
class CameraEvent: public google::protobuf::Message { };
class CameraConfiguration: public google::protobuf::Message { };
}

%typemap(in, numinputs=0) R1::CameraEvent** CALIN_PROTOBUF_OUTPUT
Expand All @@ -67,58 +98,34 @@ class CameraConfiguration: public google::protobuf::Message { };

%apply R1::CameraEvent** CALIN_PROTOBUF_OUTPUT {
R1::CameraEvent** event_out };
%apply uint64_t& OUTPUT { uint64_t& seq_index_out };
%apply google::protobuf::Arena** CALIN_ARENA_OUTPUT {
google::protobuf::Arena** arena_out };

%import "iact_data/telescope_data_source.i"

%template(DataSource_R1v0)
calin::io::data_source::DataSource<R1::CameraEvent>;
%template(RandomAccessDataSource_R1v0)
calin::io::data_source::RandomAccessDataSource<R1::CameraEvent>;

%newobject simple_get_next();

%extend calin::io::data_source::DataSource<R1::CameraEvent> {

R1::CameraEvent* simple_get_next()
{
uint64_t unused_seq_index = 0;
return $self->get_next(unused_seq_index);
}

#if 0
void get_next(uint64_t& seq_index_out, R1::CameraEvent** event_out,
google::protobuf::Arena** arena_out)
{
seq_index_out = 0;
*event_out = $self->get_next(seq_index_out, arena_out);
if(*event_out != nullptr and *arena_out == nullptr)
throw std::runtime_error("Memory allocation error: no Arena returned");
}
#else
void get_next(uint64_t& seq_index_out, R1::CameraEvent** event_out)
{
seq_index_out = 0;
*event_out = $self->get_next(seq_index_out);
}
#endif

}

%newobject get_run_header();

%include "iact_data/acada_data_source.hpp"

%template(ACADACameraEventDataSource_R1v0)
calin::iact_data::acada_data_source::ACADACameraEventDataSource<R1::CameraEvent>;
%template(ACADACameraEventDataSourceWithRunHeader_R1v0)
calin::iact_data::acada_data_source::ACADACameraEventDataSourceWithRunHeader<R1::CameraEvent,R1::CameraConfiguration>;
calin::iact_data::acada_data_source::ACADACameraEventDataSourceWithRunHeader<
R1::CameraEvent,R1::CameraConfiguration>;
%template(ACADACameraEventRandomAccessDataSourceWithRunHeader_R1v0)
calin::iact_data::acada_data_source::ACADACameraEventRandomAccessDataSourceWithRunHeader<R1::CameraEvent,R1::CameraConfiguration>;

#include "io/chained_data_source.hpp"
calin::iact_data::acada_data_source::ACADACameraEventRandomAccessDataSourceWithRunHeader<
R1::CameraEvent,R1::CameraConfiguration>;

%template(DataSourceOpener_R1v0)
calin::io::data_source::DataSourceOpener<
Expand All @@ -135,12 +142,13 @@ class CameraConfiguration: public google::protobuf::Message { };
calin::iact_data::acada_data_source::ACADACameraEventRandomAccessDataSourceWithRunHeader<
R1::CameraEvent,R1::CameraConfiguration> >;

%include "iact_data/zfits_acada_data_source.hpp"

%template(ZFITSACADACameraEventDataSourceOpener_R1v0)
calin::iact_data::zfits_acada_data_source::ZFITSACADACameraEventDataSourceOpener<R1::CameraEvent,R1::CameraConfiguration>;
calin::iact_data::zfits_acada_data_source::ZFITSACADACameraEventDataSourceOpener<
R1::CameraEvent,R1::CameraConfiguration>;

%template(ZFITSSingleFileACADACameraEventDataSource_R1v0)
calin::iact_data::zfits_acada_data_source::ZFITSSingleFileACADACameraEventDataSource<R1::CameraEvent,R1::CameraConfiguration>;
calin::iact_data::zfits_acada_data_source::ZFITSSingleFileACADACameraEventDataSource<
R1::CameraEvent,R1::CameraConfiguration>;
%template(ZFITSACADACameraEventDataSource_R1v0)
calin::iact_data::zfits_acada_data_source::ZFITSACADACameraEventDataSource<R1::CameraEvent,R1::CameraConfiguration>;
calin::iact_data::zfits_acada_data_source::ZFITSACADACameraEventDataSource<
R1::CameraEvent,R1::CameraConfiguration>;

0 comments on commit f7ace21

Please sign in to comment.