mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 09:28:40 +02:00
Add device sharing support
This commit is contained in:
@@ -24,10 +24,10 @@ public:
|
||||
bool isOpen() override;
|
||||
bool close() override;
|
||||
bool isEthernet() const override { return true; }
|
||||
bool enableHeartbeat() const override { return true; }
|
||||
private:
|
||||
const PCAPDLL& pcap;
|
||||
char errbuf[PCAP_ERRBUF_SIZE] = { 0 };
|
||||
neodevice_t& device;
|
||||
uint8_t deviceMAC[6];
|
||||
bool openable = true;
|
||||
EthernetPacketizer ethPacketizer;
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef __SHAREDMEMORY_WINDOWS_H_
|
||||
#define __SHAREDMEMORY_WINDOWS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include "icsneo/platform/windows.h"
|
||||
#include "icsneo/api/eventmanager.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
class SharedMemory {
|
||||
public:
|
||||
SharedMemory() : report(makeEventHandler()) {};
|
||||
~SharedMemory();
|
||||
bool open(const std::string& name, uint32_t size, bool create = false);
|
||||
bool close();
|
||||
uint8_t* data();
|
||||
|
||||
private:
|
||||
virtual device_eventhandler_t makeEventHandler() {
|
||||
return [](APIEvent::Type type, APIEvent::Severity severity)
|
||||
{ EventManager::GetInstance().add(type, severity); };
|
||||
}
|
||||
|
||||
device_eventhandler_t report;
|
||||
std::optional<HANDLE> mHandle;
|
||||
std::optional<std::pair<uint8_t*, uint32_t>> mData;
|
||||
std::optional<bool> mCreated;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef __SHAREDSEMAPHORE_WINDOWS_H_
|
||||
#define __SHAREDSEMAPHORE_WINDOWS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
#include <optional>
|
||||
#include "icsneo/platform/windows.h"
|
||||
#include "icsneo/api/eventmanager.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
class SharedSemaphore {
|
||||
public:
|
||||
~SharedSemaphore();
|
||||
bool open(const std::string& name, bool create = false, unsigned initialCount = 0);
|
||||
bool close();
|
||||
bool wait(const std::chrono::milliseconds& timeout);
|
||||
bool post();
|
||||
|
||||
private:
|
||||
virtual device_eventhandler_t makeEventHandler() {
|
||||
return [](APIEvent::Type type, APIEvent::Severity severity)
|
||||
{ EventManager::GetInstance().add(type, severity); };
|
||||
}
|
||||
|
||||
bool closing = false;
|
||||
device_eventhandler_t report = makeEventHandler();
|
||||
std::optional<HANDLE> semaphore;
|
||||
std::optional<bool> created;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
||||
@@ -31,7 +31,6 @@ public:
|
||||
private:
|
||||
bool open(bool fromAsync);
|
||||
bool opening = false;
|
||||
neodevice_t& device;
|
||||
|
||||
struct Detail;
|
||||
std::shared_ptr<Detail> detail;
|
||||
|
||||
Reference in New Issue
Block a user