2023-09-04 12:21:37 +02:00
|
|
|
/* RAW IO format.
|
2017-08-14 14:42:07 +02:00
|
|
|
*
|
2022-03-15 09:18:01 -04:00
|
|
|
* Author: Steffen Vogel <post@steffenvogel.de>
|
2022-03-15 09:28:57 -04:00
|
|
|
* SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
|
2022-07-04 18:20:03 +02:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2017-08-14 14:42:07 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-06-23 16:57:00 +02:00
|
|
|
#include <cstdlib>
|
2023-09-07 11:46:39 +02:00
|
|
|
#include <sstream>
|
2017-08-14 14:42:07 +02:00
|
|
|
|
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__)
|
2023-09-07 11:46:39 +02:00
|
|
|
#define HAS_128BIT
|
2018-08-20 18:31:27 +02:00
|
|
|
#endif
|
|
|
|
|
2021-05-10 00:12:30 +02:00
|
|
|
namespace villas {
|
|
|
|
namespace node {
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
// Forward declarations
|
|
|
|
struct Sample;
|
|
|
|
|
2021-05-10 00:12:30 +02:00
|
|
|
class RawFormat : public BinaryFormat {
|
|
|
|
|
|
|
|
public:
|
2023-09-07 11:46:39 +02:00
|
|
|
enum Endianess { BIG, LITTLE };
|
2021-05-10 00:12:30 +02:00
|
|
|
|
|
|
|
protected:
|
2023-09-07 11:46:39 +02:00
|
|
|
enum Endianess endianess;
|
|
|
|
int bits;
|
|
|
|
bool fake;
|
2021-05-10 00:12:30 +02:00
|
|
|
|
|
|
|
public:
|
2023-09-07 11:46:39 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual int sscan(const char *buf, size_t len, size_t *rbytes,
|
|
|
|
struct Sample *const smps[], unsigned cnt);
|
|
|
|
virtual int sprint(char *buf, size_t len, size_t *wbytes,
|
|
|
|
const struct Sample *const smps[], unsigned cnt);
|
|
|
|
|
|
|
|
virtual void parse(json_t *json);
|
2017-08-14 14:42:07 +02:00
|
|
|
};
|
|
|
|
|
2021-05-10 00:12:30 +02:00
|
|
|
class GtnetRawFormat : public RawFormat {
|
2017-08-14 14:42:07 +02:00
|
|
|
|
2021-05-10 00:12:30 +02:00
|
|
|
public:
|
2023-09-07 11:46:39 +02:00
|
|
|
GtnetRawFormat(int fl) : RawFormat(fl, 32, Endianess::BIG) {}
|
2021-05-10 00:12:30 +02:00
|
|
|
};
|
2018-06-29 08:37:14 +02:00
|
|
|
|
2023-08-28 09:34:02 +02:00
|
|
|
} // namespace node
|
|
|
|
} // namespace villas
|