mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
Event refactor builds on Windows
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
#include "icsneo/communication/packet.h"
|
||||
#include "icsneo/communication/message/callback/messagecallback.h"
|
||||
#include "icsneo/communication/message/serialnumbermessage.h"
|
||||
#include "icsneo/api/errormanager.h"
|
||||
#include "icsneo/api/eventmanager.h"
|
||||
#include "icsneo/communication/packetizer.h"
|
||||
#include "icsneo/communication/encoder.h"
|
||||
#include "icsneo/communication/decoder.h"
|
||||
@@ -23,11 +23,11 @@ namespace icsneo {
|
||||
class Communication {
|
||||
public:
|
||||
Communication(
|
||||
device_errorhandler_t err,
|
||||
device_eventhandler_t report,
|
||||
std::unique_ptr<ICommunication> com,
|
||||
std::shared_ptr<Packetizer> p,
|
||||
std::unique_ptr<Encoder> e,
|
||||
std::unique_ptr<Decoder> md) : packetizer(p), encoder(std::move(e)), decoder(std::move(md)), err(err), impl(std::move(com)) {}
|
||||
std::unique_ptr<Decoder> md) : packetizer(p), encoder(std::move(e)), decoder(std::move(md)), report(report), impl(std::move(com)) {}
|
||||
virtual ~Communication() { close(); }
|
||||
|
||||
bool open();
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
std::shared_ptr<Packetizer> packetizer; // Ownership is shared with the encoder
|
||||
std::unique_ptr<Encoder> encoder;
|
||||
std::unique_ptr<Decoder> decoder;
|
||||
device_errorhandler_t err;
|
||||
device_eventhandler_t report;
|
||||
|
||||
protected:
|
||||
std::unique_ptr<ICommunication> impl;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "icsneo/communication/message/canmessage.h"
|
||||
#include "icsneo/communication/packet.h"
|
||||
#include "icsneo/communication/network.h"
|
||||
#include "icsneo/api/errormanager.h"
|
||||
#include "icsneo/api/eventmanager.h"
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
@@ -16,13 +16,13 @@ class Decoder {
|
||||
public:
|
||||
static uint64_t GetUInt64FromLEBytes(uint8_t* bytes);
|
||||
|
||||
Decoder(device_errorhandler_t err) : err(err) {}
|
||||
Decoder(device_eventhandler_t report) : report(report) {}
|
||||
bool decode(std::shared_ptr<Message>& result, const std::shared_ptr<Packet>& packet);
|
||||
|
||||
uint16_t timestampResolution = 25;
|
||||
|
||||
private:
|
||||
device_errorhandler_t err;
|
||||
device_eventhandler_t report;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace icsneo {
|
||||
|
||||
class Encoder {
|
||||
public:
|
||||
Encoder(device_errorhandler_t err, std::shared_ptr<Packetizer> p) : packetizer(p), err(err) {}
|
||||
Encoder(device_eventhandler_t report, std::shared_ptr<Packetizer> p) : packetizer(p), report(report) {}
|
||||
bool encode(std::vector<uint8_t>& result, const std::shared_ptr<Message>& message);
|
||||
bool encode(std::vector<uint8_t>& result, Command cmd, bool boolean) { return encode(result, cmd, std::vector<uint8_t>({ (uint8_t)boolean })); }
|
||||
bool encode(std::vector<uint8_t>& result, Command cmd, std::vector<uint8_t> arguments = {});
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
bool supportCANFD = false;
|
||||
private:
|
||||
std::shared_ptr<Packetizer> packetizer;
|
||||
device_errorhandler_t err;
|
||||
device_eventhandler_t report;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
#include "icsneo/api/errormanager.h"
|
||||
#include "icsneo/api/eventmanager.h"
|
||||
#include "icsneo/third-party/concurrentqueue/blockingconcurrentqueue.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
class ICommunication {
|
||||
public:
|
||||
ICommunication(const device_errorhandler_t& handler) : err(handler) {}
|
||||
ICommunication(const device_eventhandler_t& handler) : report(handler) {}
|
||||
virtual ~ICommunication() {}
|
||||
virtual bool open() = 0;
|
||||
virtual bool isOpen() = 0;
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
writeCV.notify_one();
|
||||
}
|
||||
|
||||
device_errorhandler_t err;
|
||||
device_eventhandler_t report;
|
||||
|
||||
size_t writeQueueSize = 50;
|
||||
bool writeBlocks = true; // Otherwise it just fails when the queue is full
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace icsneo {
|
||||
class MultiChannelCommunication : public Communication {
|
||||
public:
|
||||
MultiChannelCommunication(
|
||||
device_errorhandler_t err,
|
||||
device_eventhandler_t err,
|
||||
std::unique_ptr<ICommunication> com,
|
||||
std::shared_ptr<Packetizer> p,
|
||||
std::unique_ptr<Encoder> e,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define __CANPACKET_H__
|
||||
|
||||
#include "icsneo/communication/message/canmessage.h"
|
||||
#include "icsneo/api/errormanager.h"
|
||||
#include "icsneo/api/eventmanager.h"
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
@@ -12,7 +12,7 @@ typedef uint16_t icscm_bitfield;
|
||||
|
||||
struct HardwareCANPacket {
|
||||
static std::shared_ptr<CANMessage> DecodeToMessage(const std::vector<uint8_t>& bytestream);
|
||||
static bool EncodeFromMessage(const CANMessage& message, std::vector<uint8_t>& bytestream, const device_errorhandler_t& err);
|
||||
static bool EncodeFromMessage(const CANMessage& message, std::vector<uint8_t>& bytestream, const device_eventhandler_t& report);
|
||||
|
||||
struct {
|
||||
icscm_bitfield IDE : 1;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define __ETHERNETPACKET_H__
|
||||
|
||||
#include "icsneo/communication/message/ethernetmessage.h"
|
||||
#include "icsneo/api/errormanager.h"
|
||||
#include "icsneo/api/eventmanager.h"
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
@@ -12,7 +12,7 @@ typedef uint16_t icscm_bitfield;
|
||||
|
||||
struct HardwareEthernetPacket {
|
||||
static std::shared_ptr<EthernetMessage> DecodeToMessage(const std::vector<uint8_t>& bytestream);
|
||||
static bool EncodeFromMessage(const EthernetMessage& message, std::vector<uint8_t>& bytestream, const device_errorhandler_t& err);
|
||||
static bool EncodeFromMessage(const EthernetMessage& message, std::vector<uint8_t>& bytestream, const device_eventhandler_t& err);
|
||||
|
||||
struct {
|
||||
icscm_bitfield FCS_AVAIL : 1;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define __PACKETIZER_H_
|
||||
|
||||
#include "icsneo/communication/packet.h"
|
||||
#include "icsneo/api/errormanager.h"
|
||||
#include "icsneo/api/eventmanager.h"
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
@@ -13,7 +13,7 @@ class Packetizer {
|
||||
public:
|
||||
static uint8_t ICSChecksum(const std::vector<uint8_t>& data);
|
||||
|
||||
Packetizer(device_errorhandler_t err) : err(err) {}
|
||||
Packetizer(device_eventhandler_t report) : report(report) {}
|
||||
|
||||
std::vector<uint8_t>& packetWrap(std::vector<uint8_t>& data, bool shortFormat);
|
||||
|
||||
@@ -42,7 +42,7 @@ private:
|
||||
|
||||
std::vector<std::shared_ptr<Packet>> processedPackets;
|
||||
|
||||
device_errorhandler_t err;
|
||||
device_eventhandler_t report;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user