1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-23 00:00:01 +01:00
VILLASnode/include/villas/formats/raw.hpp

71 lines
1.4 KiB
C++
Raw Normal View History

/** RAW IO format
*
* @file
* @author Steffen Vogel <post@steffenvogel.de>
2022-03-15 09:28:57 -04:00
* @copyright 2014-2022, Institute for Automation of Complex Power Systems, EONERC
2022-07-04 18:20:03 +02:00
* @license Apache 2.0
*********************************************************************************/
#pragma once
2021-05-10 00:12:30 +02:00
#include <sstream>
#include <cstdlib>
2021-05-10 00:12:30 +02:00
#include <villas/format.hpp>
2018-08-20 18:31:27 +02:00
/* float128 is currently not yet supported as htole128() functions a missing */
#if 0 && defined(__GNUC__) && defined(__linux__)
#define HAS_128BIT
#endif
2021-05-10 00:12:30 +02:00
namespace villas {
namespace node {
/* Forward declarations */
struct Sample;
2021-05-10 00:12:30 +02:00
class RawFormat : public BinaryFormat {
public:
enum Endianess {
BIG,
LITTLE
};
protected:
enum Endianess endianess;
int bits;
bool fake;
public:
RawFormat(int fl, int b = 32, enum Endianess e = Endianess::LITTLE) :
BinaryFormat(fl),
endianess(e),
bits(b),
fake(false)
{
if (fake)
flags |= (int) SampleFlags::HAS_SEQUENCE | (int) SampleFlags::HAS_TS_ORIGIN;
}
2021-10-04 11:07:23 +02:00
virtual
int sscan(const char *buf, size_t len, size_t *rbytes, struct Sample * const smps[], unsigned cnt);
2021-10-04 11:07:23 +02:00
virtual
int sprint(char *buf, size_t len, size_t *wbytes, const struct Sample * const smps[], unsigned cnt);
2021-05-10 00:12:30 +02:00
2021-10-04 11:07:23 +02:00
virtual
void parse(json_t *json);
};
2021-05-10 00:12:30 +02:00
class GtnetRawFormat : public RawFormat {
2021-05-10 00:12:30 +02:00
public:
GtnetRawFormat(int fl) :
RawFormat(fl, 32, Endianess::BIG)
{ }
};
2018-06-29 08:37:14 +02:00
} // namespace node
} // namespace villas