2021-06-18 11:27:02 -04:00
|
|
|
/** An temper get started with new implementations of new node-types
|
|
|
|
*
|
|
|
|
* @file
|
2022-12-14 17:41:58 +01:00
|
|
|
* @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
|
2021-06-18 11:27:02 -04:00
|
|
|
*********************************************************************************/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
#include <villas/node/config.hpp>
|
2021-06-18 11:27:02 -04:00
|
|
|
#include <villas/format.hpp>
|
2021-08-10 10:12:48 -04:00
|
|
|
#include <villas/timing.hpp>
|
2021-06-18 11:27:02 -04:00
|
|
|
#include <villas/usb.hpp>
|
|
|
|
#include <villas/log.hpp>
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
namespace villas {
|
|
|
|
namespace node {
|
|
|
|
|
2021-06-21 16:11:42 -04:00
|
|
|
/* Forward declarations */
|
2021-08-10 10:12:48 -04:00
|
|
|
class NodeCompat;
|
2021-06-21 16:11:42 -04:00
|
|
|
|
2021-06-18 11:27:02 -04:00
|
|
|
class TEMPerDevice : public villas::usb::Device {
|
|
|
|
|
|
|
|
protected:
|
|
|
|
constexpr static unsigned char question_temperature[] = { 0x01, 0x80, 0x33, 0x01, 0x00, 0x00, 0x00, 0x00 };
|
|
|
|
|
|
|
|
float scale;
|
|
|
|
float offset;
|
|
|
|
|
|
|
|
int timeout;
|
|
|
|
|
|
|
|
villas::Logger logger;
|
|
|
|
|
|
|
|
virtual void decode(unsigned char *answer, float *temp) = 0;
|
|
|
|
public:
|
|
|
|
static TEMPerDevice * make(struct libusb_device *desc);
|
|
|
|
|
|
|
|
TEMPerDevice(struct libusb_device *dev);
|
|
|
|
virtual ~TEMPerDevice()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
void open(bool reset = true);
|
|
|
|
void close();
|
|
|
|
|
|
|
|
virtual int getNumSensors() const
|
|
|
|
{ return 1; }
|
|
|
|
|
|
|
|
virtual bool hasHumiditySensor() const
|
|
|
|
{ return false; };
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
void read(struct Sample *smp);
|
2021-06-18 11:27:02 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
class TEMPer1Device : public TEMPerDevice {
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void decode(unsigned char *answer, float *temp);
|
|
|
|
|
|
|
|
using TEMPerDevice::TEMPerDevice;
|
|
|
|
|
|
|
|
public:
|
|
|
|
static bool match(struct libusb_device *dev);
|
|
|
|
|
|
|
|
static std::string getName()
|
|
|
|
{ return "TEMPer1"; }
|
|
|
|
};
|
|
|
|
|
|
|
|
class TEMPer2Device : public TEMPer1Device {
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void decode(unsigned char *answer, float *temp);
|
|
|
|
|
|
|
|
using TEMPer1Device::TEMPer1Device;
|
|
|
|
|
|
|
|
public:
|
|
|
|
static bool match(struct libusb_device *dev);
|
|
|
|
|
|
|
|
static std::string getName()
|
|
|
|
{ return "TEMPer2"; }
|
|
|
|
|
|
|
|
virtual int getNumSensors() const
|
|
|
|
{ return 2; }
|
|
|
|
};
|
|
|
|
|
|
|
|
class TEMPerHUMDevice : public TEMPerDevice {
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void decode(unsigned char *answer, float *temp);
|
|
|
|
|
|
|
|
using TEMPerDevice::TEMPerDevice;
|
|
|
|
|
|
|
|
public:
|
|
|
|
static bool match(struct libusb_device *dev);
|
|
|
|
|
|
|
|
static std::string getName()
|
|
|
|
{ return "TEMPerHUM"; }
|
|
|
|
|
|
|
|
virtual bool hasHumiditySensor() const
|
|
|
|
{ return true; }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct temper {
|
|
|
|
struct {
|
|
|
|
double scale;
|
|
|
|
double offset;
|
|
|
|
} calibration;
|
|
|
|
|
|
|
|
struct villas::usb::Filter filter;
|
|
|
|
|
|
|
|
TEMPerDevice *device;
|
|
|
|
};
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int temper_type_start(SuperNode *sn);
|
2021-06-18 11:27:02 -04:00
|
|
|
|
|
|
|
int temper_type_stop();
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int temper_init(NodeCompat *n);
|
|
|
|
|
|
|
|
int temper_prepare(NodeCompat *n);
|
2021-06-18 11:27:02 -04:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int temper_destroy(NodeCompat *n);
|
2021-06-18 11:27:02 -04:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int temper_parse(NodeCompat *n, json_t *json);
|
2021-06-18 11:27:02 -04:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
char * temper_print(NodeCompat *n);
|
2021-06-18 11:27:02 -04:00
|
|
|
|
|
|
|
int temper_check();
|
|
|
|
|
|
|
|
int temper_prepare();
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int temper_start(NodeCompat *n);
|
2021-06-18 11:27:02 -04:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int temper_stop(NodeCompat *n);
|
2021-06-18 11:27:02 -04:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int temper_pause(NodeCompat *n);
|
2021-06-18 11:27:02 -04:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int temper_resume(NodeCompat *n);
|
2021-06-18 11:27:02 -04:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int temper_write(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
2021-06-18 11:27:02 -04:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int temper_read(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
2021-06-18 11:27:02 -04:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int temper_reverse(NodeCompat *n);
|
2021-06-18 11:27:02 -04:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int temper_poll_fds(NodeCompat *n, int fds[]);
|
2021-06-18 11:27:02 -04:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int temper_netem_fds(NodeCompat *n, int fds[]);
|
2021-06-18 11:27:02 -04:00
|
|
|
|
2023-08-28 09:34:02 +02:00
|
|
|
} // namespace node
|
|
|
|
} // namespace villas
|