You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
126 lines
5.3 KiB
OpenEdge ABL
126 lines
5.3 KiB
OpenEdge ABL
4 years ago
|
%feature("notabstract") Gempa::CAPS::AnyDataRecord;
|
||
|
%include "stdint.i"
|
||
|
|
||
|
%init
|
||
|
%{
|
||
|
import_array();
|
||
|
%}
|
||
|
|
||
|
%module CAPS
|
||
|
%{
|
||
|
#define SWIG_FILE_WITH_INIT
|
||
|
#include <gempa/caps/utils.h>
|
||
|
#include <gempa/caps/anypacket.h>
|
||
|
#include <gempa/caps/datetime.h>
|
||
|
#include <gempa/caps/log.h>
|
||
|
#include <gempa/caps/mseedpacket.h>
|
||
|
#include <gempa/caps/packet.h>
|
||
|
#include <gempa/caps/plugin.h>
|
||
|
typedef Gempa::CAPS::Plugin::Buffer Buffer;
|
||
|
#include <gempa/caps/rawpacket.h>
|
||
|
#include <gempa/caps/riff.h>
|
||
|
#include <gempa/caps/rtcm2packet.h>
|
||
|
#include <gempa/caps/socket.h>
|
||
|
#include <gempa/caps/mseed/spclock.h>
|
||
|
#include <numpy/ndarrayobject.h>
|
||
|
|
||
|
%}
|
||
|
|
||
|
%extend Gempa::CAPS::Plugin {
|
||
|
Gempa::CAPS::Plugin::Status push(const std::string &net, const std::string &sta,
|
||
|
const std::string &loc, const std::string &cha,
|
||
|
const Time &stime, int16_t numerator, int16_t denominator,
|
||
|
const std::string &uom,
|
||
|
PyObject *obj, int type
|
||
|
) {
|
||
|
PyArrayObject *arr = NULL;
|
||
|
Gempa::CAPS::DataType dataType = (Gempa::CAPS::DataType)type;
|
||
|
Gempa::CAPS::Plugin::Status status = Gempa::CAPS::Plugin::PacketLoss;
|
||
|
switch(type) {
|
||
|
case Gempa::CAPS::DT_INT8:
|
||
|
arr = (PyArrayObject*) PyArray_ContiguousFromObject(obj, PyArray_CHAR, 1, 1);
|
||
|
if ( arr == NULL )
|
||
|
break;
|
||
|
|
||
|
status = self->push(net, sta, loc, cha, stime, numerator, denominator,
|
||
|
uom, (int8_t*)(arr->data), arr->dimensions[0], dataType);
|
||
|
break;
|
||
|
case Gempa::CAPS::DT_INT16:
|
||
|
arr = (PyArrayObject*) PyArray_ContiguousFromObject(obj, PyArray_INT16, 1, 1);
|
||
|
if ( arr == NULL )
|
||
|
break;
|
||
|
|
||
|
status = self->push(net, sta, loc, cha, stime, numerator, denominator,
|
||
|
uom, (int16_t*)(arr->data), arr->dimensions[0], dataType);
|
||
|
break;
|
||
|
case Gempa::CAPS::DT_INT32:
|
||
|
arr = (PyArrayObject*) PyArray_ContiguousFromObject(obj, PyArray_INT32, 1, 1);
|
||
|
if ( arr == NULL )
|
||
|
break;
|
||
|
|
||
|
status = self->push(net, sta, loc, cha, stime, numerator, denominator,
|
||
|
uom, (int32_t*)(arr->data), arr->dimensions[0], dataType);
|
||
|
break;
|
||
|
case Gempa::CAPS::DT_FLOAT:
|
||
|
arr = (PyArrayObject*) PyArray_ContiguousFromObject(obj, PyArray_FLOAT32, 1, 1);
|
||
|
if ( arr == NULL )
|
||
|
break;
|
||
|
|
||
|
status = self->push(net, sta, loc, cha, stime, numerator, denominator,
|
||
|
uom, (float*)(arr->data), arr->dimensions[0], dataType);
|
||
|
break;
|
||
|
case Gempa::CAPS::DT_DOUBLE:
|
||
|
arr = (PyArrayObject*) PyArray_ContiguousFromObject(obj, PyArray_FLOAT64, 1, 1);
|
||
|
if ( arr == NULL )
|
||
|
break;
|
||
|
|
||
|
status = self->push(net, sta, loc, cha, stime, numerator, denominator,
|
||
|
uom, (double*)(arr->data), arr->dimensions[0], dataType);
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
Py_XDECREF(arr);
|
||
|
return status;
|
||
|
}
|
||
|
|
||
|
Gempa::CAPS::Plugin::Status push(const std::string &net, const std::string &sta,
|
||
|
const std::string &loc, const std::string &cha,
|
||
|
const Time &stime, uint16_t numerator,
|
||
|
uint16_t denominator, const std::string &format,
|
||
|
PyObject *obj) {
|
||
|
char *data;
|
||
|
Py_ssize_t len;
|
||
|
if ( PyBytes_AsStringAndSize(obj, &data, &len) == -1 )
|
||
|
return Gempa::CAPS::Plugin::PacketLoss;
|
||
|
|
||
|
return self->push(net, sta, loc, cha, stime, numerator,
|
||
|
denominator, format, data, len);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
%include "exception.i"
|
||
|
%include "std_string.i"
|
||
|
%include "numpy.i"
|
||
|
|
||
|
%include "gempa/caps/api.h"
|
||
|
%include "gempa/caps/datetime.h"
|
||
|
%include "gempa/caps/packet.h"
|
||
|
%include "gempa/caps/pluginpacket.h"
|
||
|
%include "gempa/caps/anypacket.h"
|
||
|
%include "gempa/caps/log.h"
|
||
|
%include "gempa/caps/mseed/spclock.h"
|
||
|
%include "gempa/caps/mseed/encoder.h"
|
||
|
%include "gempa/caps/encoderfactory.h"
|
||
|
%include "gempa/caps/mseedpacket.h"
|
||
|
typedef Gempa::CAPS::Plugin::Buffer Buffer;
|
||
|
%include "gempa/caps/plugin.h"
|
||
|
%include "gempa/caps/rawpacket.h"
|
||
|
%include "gempa/caps/riff.h"
|
||
|
%include "gempa/caps/rtcm2packet.h"
|
||
|
%include "gempa/caps/socket.h"
|
||
|
%include <carrays.i>
|
||
|
%array_class(char, charArray);
|
||
|
%include "gempa/caps/utils.h"
|