mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-07 18:38:36 +02:00
Device: Refactor heartbeat
This commit is contained in:
@@ -346,6 +346,7 @@ add_library(icsneocpp
|
|||||||
api/icsneocpp/icsneocpp.cpp
|
api/icsneocpp/icsneocpp.cpp
|
||||||
api/icsneocpp/event.cpp
|
api/icsneocpp/event.cpp
|
||||||
api/icsneocpp/eventmanager.cpp
|
api/icsneocpp/eventmanager.cpp
|
||||||
|
api/icsneocpp/heartbeat.cpp
|
||||||
api/icsneocpp/version.cpp
|
api/icsneocpp/version.cpp
|
||||||
${SRC_FILES}
|
${SRC_FILES}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
#include "icsneo/api/heartbeat.h"
|
||||||
|
#include "icsneo/api/lifetime.h"
|
||||||
|
#include "icsneo/device/device.h"
|
||||||
|
|
||||||
|
using namespace icsneo;
|
||||||
|
|
||||||
|
Heartbeat::Heartbeat(Device& device) :
|
||||||
|
device(device), mode(device.isOnline() ? Mode::Passive : Mode::Active), thread(&Heartbeat::run, this) {
|
||||||
|
}
|
||||||
|
|
||||||
|
Heartbeat::~Heartbeat() {
|
||||||
|
{
|
||||||
|
std::lock_guard lk(mutex);
|
||||||
|
stop = true;
|
||||||
|
}
|
||||||
|
cv.notify_one();
|
||||||
|
thread.join();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Heartbeat::run() {
|
||||||
|
EventManager::GetInstance().downgradeErrorsOnCurrentThread();
|
||||||
|
|
||||||
|
auto filter = std::make_shared<MessageFilter>(Message::Type::ResetStatus);
|
||||||
|
bool status = false;
|
||||||
|
auto cbHandle = device.com->addMessageCallback(std::make_shared<MessageCallback>(filter, [&](std::shared_ptr<Message>) {
|
||||||
|
{
|
||||||
|
std::lock_guard lk(mutex);
|
||||||
|
status = true;
|
||||||
|
}
|
||||||
|
cv.notify_one();
|
||||||
|
}));
|
||||||
|
Lifetime cbLifetime([&] {
|
||||||
|
device.com->removeMessageCallback(cbHandle);
|
||||||
|
});
|
||||||
|
while(true) {
|
||||||
|
std::unique_lock lk(mutex);
|
||||||
|
if(mode == Mode::Active) {
|
||||||
|
if(cv.wait_for(lk, std::chrono::milliseconds(100), [&] { return stop; })) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
device.com->sendCommand(Command::RequestStatusUpdate);
|
||||||
|
}
|
||||||
|
if(!cv.wait_for(lk, std::chrono::seconds(2), [&] { return status || stop; })) {
|
||||||
|
// we disconnect instead of close because it indicates to the user that a cleanup is still required (our thread join)
|
||||||
|
device.report(APIEvent::Type::DeviceDisconnected, APIEvent::Severity::Error);
|
||||||
|
device.com->driver->setIsDisconnected(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(stop)
|
||||||
|
break;
|
||||||
|
status = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
+32
-112
@@ -92,10 +92,6 @@ Device::~Device() {
|
|||||||
disableMessagePolling();
|
disableMessagePolling();
|
||||||
if(isOpen())
|
if(isOpen())
|
||||||
close();
|
close();
|
||||||
if(heartbeatThread.joinable()) {
|
|
||||||
stopHeartbeatThread = true;
|
|
||||||
heartbeatThread.join();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t Device::getTimestampResolution() const {
|
uint16_t Device::getTimestampResolution() const {
|
||||||
@@ -288,6 +284,8 @@ bool Device::open(OpenFlags flags, OpenStatusHandler handler) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
startHeartbeat();
|
||||||
|
|
||||||
APIEvent::Type attemptErr = attemptToBeginCommunication();
|
APIEvent::Type attemptErr = attemptToBeginCommunication();
|
||||||
if(attemptErr != APIEvent::Type::NoErrorFound) {
|
if(attemptErr != APIEvent::Type::NoErrorFound) {
|
||||||
// We could not communicate with the device, let's see if an extension can
|
// We could not communicate with the device, let's see if an extension can
|
||||||
@@ -334,79 +332,6 @@ bool Device::open(OpenFlags flags, OpenStatusHandler handler) {
|
|||||||
EventManager::GetInstance().cancelErrorDowngradingOnCurrentThread();
|
EventManager::GetInstance().cancelErrorDowngradingOnCurrentThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageFilter filter;
|
|
||||||
filter.includeInternalInAny = true;
|
|
||||||
internalHandlerCallbackID = com->addMessageCallback(std::make_shared<MessageCallback>(filter, [this](std::shared_ptr<Message> message) {
|
|
||||||
handleInternalMessage(message);
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Clear the previous heartbeat thread, in case open() was called on this instance more than once
|
|
||||||
if(heartbeatThread.joinable())
|
|
||||||
heartbeatThread.join();
|
|
||||||
|
|
||||||
stopHeartbeatThread = false;
|
|
||||||
|
|
||||||
heartbeatThread = std::thread([this]() {
|
|
||||||
EventManager::GetInstance().downgradeErrorsOnCurrentThread();
|
|
||||||
|
|
||||||
MessageFilter filter;
|
|
||||||
filter.includeInternalInAny = true;
|
|
||||||
|
|
||||||
std::condition_variable heartbeatCV;
|
|
||||||
std::mutex receivedMessageMutex;
|
|
||||||
bool receivedMessage = false;
|
|
||||||
auto messageReceivedCallbackID = com->addMessageCallback(std::make_shared<MessageCallback>(filter, [&](std::shared_ptr<Message>) {
|
|
||||||
{
|
|
||||||
std::scoped_lock<std::mutex> lk(receivedMessageMutex);
|
|
||||||
receivedMessage = true;
|
|
||||||
}
|
|
||||||
heartbeatCV.notify_all();
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Give the device time to get situated
|
|
||||||
auto i = 150;
|
|
||||||
while(!stopHeartbeatThread && i != 0) {
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
|
|
||||||
while(!stopHeartbeatThread) {
|
|
||||||
std::unique_lock<std::mutex> recvLk(receivedMessageMutex);
|
|
||||||
// Wait for 110ms for a possible heartbeat
|
|
||||||
if(heartbeatCV.wait_for(recvLk, std::chrono::milliseconds(110), [&]() { return receivedMessage; })) {
|
|
||||||
receivedMessage = false;
|
|
||||||
} else if(!stopHeartbeatThread) { // Add this condition here in case the thread was stopped while waiting for the last message
|
|
||||||
|
|
||||||
// Some communication, such as the bootloader and extractor interfaces, must
|
|
||||||
// redirect the input stream from the device as it will no longer be in the
|
|
||||||
// packet format we expect here. As a result, status updates will not reach
|
|
||||||
// us here and suppressDisconnects() must be used. We don't want to request
|
|
||||||
// a status and then redirect the stream, as we'll then be polluting an
|
|
||||||
// otherwise quiet stream. This lock makes sure suppressDisconnects() will
|
|
||||||
// block until we've either gotten our status update or disconnected from
|
|
||||||
// the device.
|
|
||||||
std::unique_lock<std::mutex> lk(heartbeatMutex);
|
|
||||||
if(heartbeatSuppressed()) continue;
|
|
||||||
|
|
||||||
// No heartbeat received, request a status
|
|
||||||
com->sendCommand(Command::RequestStatusUpdate);
|
|
||||||
|
|
||||||
// Check if we got a message, and if not, if settings are being applied
|
|
||||||
if(heartbeatCV.wait_for(recvLk, std::chrono::milliseconds(3500), [&](){ return receivedMessage; })) {
|
|
||||||
receivedMessage = false;
|
|
||||||
} else {
|
|
||||||
if(!stopHeartbeatThread) {
|
|
||||||
close();
|
|
||||||
report(APIEvent::Type::DeviceDisconnected, APIEvent::Severity::Error);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
com->removeMessageCallback(messageReceivedCallbackID);
|
|
||||||
});
|
|
||||||
|
|
||||||
if(supportsLiveData())
|
if(supportsLiveData())
|
||||||
clearAllLiveData();
|
clearAllLiveData();
|
||||||
|
|
||||||
@@ -503,7 +428,7 @@ bool Device::close() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
stopHeartbeatThread = true;
|
stopHeartbeat();
|
||||||
|
|
||||||
if (isMessagePollingEnabled()) {
|
if (isMessagePollingEnabled()) {
|
||||||
disableMessagePolling();
|
disableMessagePolling();
|
||||||
@@ -534,31 +459,15 @@ bool Device::goOnline() {
|
|||||||
if(!enableNetworkCommunication(true, onlineTimeoutMs))
|
if(!enableNetworkCommunication(true, onlineTimeoutMs))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto startTime = std::chrono::system_clock::now();
|
|
||||||
|
|
||||||
ledState = LEDState::Online;
|
ledState = LEDState::Online;
|
||||||
|
|
||||||
updateLEDState();
|
updateLEDState();
|
||||||
|
|
||||||
std::shared_ptr<MessageFilter> filter = std::make_shared<MessageFilter>(Network::NetID::Reset_Status);
|
// (re)start the keeponline
|
||||||
filter->includeInternalInAny = true;
|
keeponline = std::make_unique<Periodic>([this] {
|
||||||
|
static std::vector<uint8_t> timeoutBytes = std::vector<uint8_t>((uint8_t*)&onlineTimeoutMs, (uint8_t*)&onlineTimeoutMs + sizeof(onlineTimeoutMs));
|
||||||
// Wait until communication is enabled or 5 seconds, whichever comes first
|
return com->sendCommand(Command::KeepAlive, timeoutBytes);
|
||||||
while((std::chrono::system_clock::now() - startTime) < std::chrono::seconds(5)) {
|
}, std::chrono::milliseconds(onlineTimeoutMs / 4));
|
||||||
if(latestResetStatus && latestResetStatus->comEnabled)
|
|
||||||
break;
|
|
||||||
|
|
||||||
bool failOut = false;
|
|
||||||
com->waitForMessageSync([this, &failOut]() {
|
|
||||||
if(!com->sendCommand(Command::RequestStatusUpdate)) {
|
|
||||||
failOut = true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}, filter, std::chrono::milliseconds(100));
|
|
||||||
if(failOut)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(supportsNetworkMutex) {
|
if(supportsNetworkMutex) {
|
||||||
assignedClientId = com->getClientIDSync();
|
assignedClientId = com->getClientIDSync();
|
||||||
@@ -591,29 +500,30 @@ bool Device::goOnline() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// (re)start the keeponline
|
|
||||||
keeponline = std::make_unique<Periodic>([this] {
|
|
||||||
static std::vector<uint8_t> timeoutBytes = std::vector<uint8_t>((uint8_t*)&onlineTimeoutMs, (uint8_t*)&onlineTimeoutMs + sizeof(onlineTimeoutMs));
|
|
||||||
return com->sendCommand(Command::KeepAlive, timeoutBytes);
|
|
||||||
}, std::chrono::milliseconds(onlineTimeoutMs / 4));
|
|
||||||
|
|
||||||
online = true;
|
online = true;
|
||||||
|
|
||||||
|
// restart the heartbeat in online mode
|
||||||
|
restartHeartbeat();
|
||||||
|
|
||||||
forEachExtension([](const std::shared_ptr<DeviceExtension>& ext) { ext->onGoOnline(); return true; });
|
forEachExtension([](const std::shared_ptr<DeviceExtension>& ext) { ext->onGoOnline(); return true; });
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Device::goOffline() {
|
bool Device::goOffline() {
|
||||||
|
online = false;
|
||||||
|
|
||||||
keeponline.reset();
|
keeponline.reset();
|
||||||
|
|
||||||
|
// restart the heartbeat in offline mode
|
||||||
|
restartHeartbeat();
|
||||||
|
|
||||||
if(networkMutexCallbackHandle)
|
if(networkMutexCallbackHandle)
|
||||||
removeMessageCallback(*networkMutexCallbackHandle);
|
removeMessageCallback(*networkMutexCallbackHandle);
|
||||||
|
|
||||||
forEachExtension([](const std::shared_ptr<DeviceExtension>& ext) { ext->onGoOffline(); return true; });
|
forEachExtension([](const std::shared_ptr<DeviceExtension>& ext) { ext->onGoOffline(); return true; });
|
||||||
|
|
||||||
if(isDisconnected()) {
|
if(isDisconnected()) {
|
||||||
online = false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -629,8 +539,6 @@ bool Device::goOffline() {
|
|||||||
|
|
||||||
updateLEDState();
|
updateLEDState();
|
||||||
|
|
||||||
online = false;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1992,11 +1900,9 @@ void Device::stopScriptStatusThreadIfNecessary(std::unique_lock<std::mutex> lk)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Lifetime Device::suppressDisconnects() {
|
Lifetime Device::suppressDisconnects() {
|
||||||
std::lock_guard<std::mutex> lk(heartbeatMutex);
|
stopHeartbeat();
|
||||||
heartbeatSuppressedByUser++;
|
|
||||||
return Lifetime([this] {
|
return Lifetime([this] {
|
||||||
std::lock_guard<std::mutex> lk2(heartbeatMutex);
|
startHeartbeat();
|
||||||
heartbeatSuppressedByUser--;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4176,3 +4082,17 @@ bool Device::unlockAllNetworks()
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Device::startHeartbeat() {
|
||||||
|
if(!heartbeat)
|
||||||
|
heartbeat = std::make_unique<Heartbeat>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Device::stopHeartbeat() {
|
||||||
|
heartbeat.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Device::restartHeartbeat() {
|
||||||
|
stopHeartbeat();
|
||||||
|
startHeartbeat();
|
||||||
|
}
|
||||||
|
|||||||
+24
-17
@@ -1,9 +1,16 @@
|
|||||||
|
#include "icsneo/device/device.h"
|
||||||
#include "icsneo/device/idevicesettings.h"
|
#include "icsneo/device/idevicesettings.h"
|
||||||
#include "icsneo/communication/message/filter/main51messagefilter.h"
|
#include "icsneo/communication/message/filter/main51messagefilter.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
using namespace icsneo;
|
using namespace icsneo;
|
||||||
|
|
||||||
|
IDeviceSettings::IDeviceSettings(Device* device, size_t size)
|
||||||
|
: device(device), report(device->report), structSize(size) {}
|
||||||
|
|
||||||
|
IDeviceSettings::IDeviceSettings(warn_t createInoperableSettings, Device* device)
|
||||||
|
: disabled(true), readonly(true), report(device->report), structSize(0) { (void)createInoperableSettings; }
|
||||||
|
|
||||||
std::optional<uint16_t> IDeviceSettings::CalculateGSChecksum(const std::vector<uint8_t>& settings) {
|
std::optional<uint16_t> IDeviceSettings::CalculateGSChecksum(const std::vector<uint8_t>& settings) {
|
||||||
const uint16_t* p = reinterpret_cast<const uint16_t*>(settings.data());
|
const uint16_t* p = reinterpret_cast<const uint16_t*>(settings.data());
|
||||||
size_t words = settings.size();
|
size_t words = settings.size();
|
||||||
@@ -166,7 +173,7 @@ bool IDeviceSettings::refresh() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<uint8_t> rxSettings;
|
std::vector<uint8_t> rxSettings;
|
||||||
bool ret = com->getSettingsSync(rxSettings);
|
bool ret = device->com->getSettingsSync(rxSettings);
|
||||||
if(!ret) {
|
if(!ret) {
|
||||||
report(APIEvent::Type::SettingsReadError, APIEvent::Severity::Error);
|
report(APIEvent::Type::SettingsReadError, APIEvent::Severity::Error);
|
||||||
return false;
|
return false;
|
||||||
@@ -231,10 +238,10 @@ bool IDeviceSettings::apply(bool temporary) {
|
|||||||
memcpy(bytestream.data() + 7, getMutableRawStructurePointer(), settings.size());
|
memcpy(bytestream.data() + 7, getMutableRawStructurePointer(), settings.size());
|
||||||
|
|
||||||
// Pause I/O with the device while the settings are applied
|
// Pause I/O with the device while the settings are applied
|
||||||
applyingSettings = true;
|
device->stopHeartbeat();
|
||||||
|
|
||||||
std::shared_ptr<Main51Message> msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this, &bytestream]() {
|
std::shared_ptr<Main51Message> msg = std::dynamic_pointer_cast<Main51Message>(device->com->waitForMessageSync([this, &bytestream]() {
|
||||||
return com->sendCommand(Command::SetSettings, bytestream);
|
return device->com->sendCommand(Command::SetSettings, bytestream);
|
||||||
}, std::make_shared<Main51MessageFilter>(Command::SetSettings), std::chrono::milliseconds(5000)));
|
}, std::make_shared<Main51MessageFilter>(Command::SetSettings), std::chrono::milliseconds(5000)));
|
||||||
|
|
||||||
if(!msg || msg->data[0] != 1) { // We did not receive a response
|
if(!msg || msg->data[0] != 1) { // We did not receive a response
|
||||||
@@ -259,8 +266,8 @@ bool IDeviceSettings::apply(bool temporary) {
|
|||||||
bytestream[6] = (uint8_t)(*gsChecksum >> 8);
|
bytestream[6] = (uint8_t)(*gsChecksum >> 8);
|
||||||
memcpy(bytestream.data() + 7, getMutableRawStructurePointer(), settings.size());
|
memcpy(bytestream.data() + 7, getMutableRawStructurePointer(), settings.size());
|
||||||
|
|
||||||
msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this, &bytestream]() {
|
msg = std::dynamic_pointer_cast<Main51Message>(device->com->waitForMessageSync([this, &bytestream]() {
|
||||||
return com->sendCommand(Command::SetSettings, bytestream);
|
return device->com->sendCommand(Command::SetSettings, bytestream);
|
||||||
}, std::make_shared<Main51MessageFilter>(Command::SetSettings), std::chrono::milliseconds(5000)));
|
}, std::make_shared<Main51MessageFilter>(Command::SetSettings), std::chrono::milliseconds(5000)));
|
||||||
if(!msg || msg->data[0] != 1) {
|
if(!msg || msg->data[0] != 1) {
|
||||||
// Attempt to get the settings from the device so we're up to date if possible
|
// Attempt to get the settings from the device so we're up to date if possible
|
||||||
@@ -272,12 +279,12 @@ bool IDeviceSettings::apply(bool temporary) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!temporary) {
|
if(!temporary) {
|
||||||
msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this]() {
|
msg = std::dynamic_pointer_cast<Main51Message>(device->com->waitForMessageSync([this]() {
|
||||||
return com->sendCommand(Command::SaveSettings);
|
return device->com->sendCommand(Command::SaveSettings);
|
||||||
}, std::make_shared<Main51MessageFilter>(Command::SaveSettings), std::chrono::milliseconds(5000)));
|
}, std::make_shared<Main51MessageFilter>(Command::SaveSettings), std::chrono::milliseconds(5000)));
|
||||||
}
|
}
|
||||||
|
|
||||||
applyingSettings = false;
|
device->startHeartbeat();
|
||||||
|
|
||||||
refresh(); // Refresh our buffer with what the device has, whether we were successful or not
|
refresh(); // Refresh our buffer with what the device has, whether we were successful or not
|
||||||
|
|
||||||
@@ -299,10 +306,10 @@ bool IDeviceSettings::applyDefaults(bool temporary) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
applyingSettings = true;
|
device->stopHeartbeat();
|
||||||
|
|
||||||
std::shared_ptr<Main51Message> msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this]() {
|
std::shared_ptr<Main51Message> msg = std::dynamic_pointer_cast<Main51Message>(device->com->waitForMessageSync([this]() {
|
||||||
return com->sendCommand(Command::SetDefaultSettings);
|
return device->com->sendCommand(Command::SetDefaultSettings);
|
||||||
}, std::make_shared<Main51MessageFilter>(Command::SetDefaultSettings), std::chrono::milliseconds(5000)));
|
}, std::make_shared<Main51MessageFilter>(Command::SetDefaultSettings), std::chrono::milliseconds(5000)));
|
||||||
if(!msg || msg->data[0] != 1) {
|
if(!msg || msg->data[0] != 1) {
|
||||||
// Attempt to get the settings from the device so we're up to date if possible
|
// Attempt to get the settings from the device so we're up to date if possible
|
||||||
@@ -336,8 +343,8 @@ bool IDeviceSettings::applyDefaults(bool temporary) {
|
|||||||
bytestream[6] = (uint8_t)(*gsChecksum >> 8);
|
bytestream[6] = (uint8_t)(*gsChecksum >> 8);
|
||||||
memcpy(bytestream.data() + 7, getMutableRawStructurePointer(), settings.size());
|
memcpy(bytestream.data() + 7, getMutableRawStructurePointer(), settings.size());
|
||||||
|
|
||||||
msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this, &bytestream]() {
|
msg = std::dynamic_pointer_cast<Main51Message>(device->com->waitForMessageSync([this, &bytestream]() {
|
||||||
return com->sendCommand(Command::SetSettings, bytestream);
|
return device->com->sendCommand(Command::SetSettings, bytestream);
|
||||||
}, std::make_shared<Main51MessageFilter>(Command::SetSettings), std::chrono::milliseconds(5000)));
|
}, std::make_shared<Main51MessageFilter>(Command::SetSettings), std::chrono::milliseconds(5000)));
|
||||||
if(!msg || msg->data[0] != 1) {
|
if(!msg || msg->data[0] != 1) {
|
||||||
// Attempt to get the settings from the device so we're up to date if possible
|
// Attempt to get the settings from the device so we're up to date if possible
|
||||||
@@ -349,12 +356,12 @@ bool IDeviceSettings::applyDefaults(bool temporary) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!temporary) {
|
if(!temporary) {
|
||||||
msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this]() {
|
msg = std::dynamic_pointer_cast<Main51Message>(device->com->waitForMessageSync([this]() {
|
||||||
return com->sendCommand(Command::SaveSettings);
|
return device->com->sendCommand(Command::SaveSettings);
|
||||||
}, std::make_shared<Main51MessageFilter>(Command::SaveSettings), std::chrono::milliseconds(5000)));
|
}, std::make_shared<Main51MessageFilter>(Command::SaveSettings), std::chrono::milliseconds(5000)));
|
||||||
}
|
}
|
||||||
|
|
||||||
applyingSettings = false;
|
device->startHeartbeat();
|
||||||
|
|
||||||
refresh(); // Refresh our buffer with what the device has, whether we were successful or not
|
refresh(); // Refresh our buffer with what the device has, whether we were successful or not
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
#ifndef __HEARTBEAT_H__
|
||||||
|
#define __HEARTBEAT_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
#include <condition_variable>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
class Device;
|
||||||
|
|
||||||
|
class Heartbeat {
|
||||||
|
public:
|
||||||
|
Heartbeat(Device& device);
|
||||||
|
~Heartbeat();
|
||||||
|
|
||||||
|
private:
|
||||||
|
enum class Mode {
|
||||||
|
Passive, // ResetStatus messages arrive without requesting
|
||||||
|
Active, // RequestStatusUpdate needs to be sent
|
||||||
|
};
|
||||||
|
Device& device;
|
||||||
|
const Mode mode;
|
||||||
|
bool stop = false;
|
||||||
|
std::mutex mutex;
|
||||||
|
std::condition_variable cv;
|
||||||
|
std::thread thread;
|
||||||
|
|
||||||
|
void run();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // icsneo
|
||||||
|
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
#endif // __HEARTBEAT_H__
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "icsneo/communication/message/extendedresponsemessage.h"
|
#include "icsneo/communication/message/extendedresponsemessage.h"
|
||||||
#include "icsneo/device/deviceversion.h"
|
#include "icsneo/device/deviceversion.h"
|
||||||
#include "icsneo/api/eventmanager.h"
|
#include "icsneo/api/eventmanager.h"
|
||||||
|
#include "icsneo/api/heartbeat.h"
|
||||||
#include "icsneo/communication/packetizer.h"
|
#include "icsneo/communication/packetizer.h"
|
||||||
#include "icsneo/communication/encoder.h"
|
#include "icsneo/communication/encoder.h"
|
||||||
#include "icsneo/communication/decoder.h"
|
#include "icsneo/communication/decoder.h"
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public:
|
|||||||
virtual driver_finder_t getFinder() = 0;
|
virtual driver_finder_t getFinder() = 0;
|
||||||
|
|
||||||
inline bool isDisconnected() const { return disconnected; };
|
inline bool isDisconnected() const { return disconnected; };
|
||||||
|
inline void setIsDisconnected(bool isDisconnected) { disconnected = isDisconnected; }
|
||||||
inline bool isClosing() const { return closing; }
|
inline bool isClosing() const { return closing; }
|
||||||
|
|
||||||
bool waitForRx(size_t limit, std::chrono::milliseconds timeout);
|
bool waitForRx(size_t limit, std::chrono::milliseconds timeout);
|
||||||
@@ -62,7 +63,6 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline void setIsClosing(bool isClosing) { closing = isClosing; }
|
inline void setIsClosing(bool isClosing) { closing = isClosing; }
|
||||||
inline void setIsDisconnected(bool isDisconnected) { disconnected = isDisconnected; }
|
|
||||||
|
|
||||||
// Overridable in case the driver doesn't want to use writeTask and writeQueue
|
// Overridable in case the driver doesn't want to use writeTask and writeQueue
|
||||||
virtual bool writeQueueFull() { return writeQueue.size_approx() > writeQueueSize; }
|
virtual bool writeQueueFull() { return writeQueue.size_approx() > writeQueueSize; }
|
||||||
|
|||||||
@@ -743,6 +743,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
std::optional<bool> SetRootDirectoryEntryFlags(uint8_t mask, uint8_t values, uint32_t collectionEntryByteAddress);
|
std::optional<bool> SetRootDirectoryEntryFlags(uint8_t mask, uint8_t values, uint32_t collectionEntryByteAddress);
|
||||||
|
|
||||||
|
device_eventhandler_t report;
|
||||||
std::shared_ptr<Communication> com;
|
std::shared_ptr<Communication> com;
|
||||||
std::shared_ptr<IDeviceSettings> settings;
|
std::shared_ptr<IDeviceSettings> settings;
|
||||||
|
|
||||||
@@ -900,11 +901,14 @@ public:
|
|||||||
bool unlockAllNetworks();
|
bool unlockAllNetworks();
|
||||||
std::shared_ptr<NetworkMutexMessage> getNetworkMutexStatus(Network::NetID network);
|
std::shared_ptr<NetworkMutexMessage> getNetworkMutexStatus(Network::NetID network);
|
||||||
|
|
||||||
|
void startHeartbeat();
|
||||||
|
void stopHeartbeat();
|
||||||
|
void restartHeartbeat();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool online = false;
|
bool online = false;
|
||||||
int messagePollingCallbackID = 0;
|
int messagePollingCallbackID = 0;
|
||||||
int internalHandlerCallbackID = 0;
|
int internalHandlerCallbackID = 0;
|
||||||
device_eventhandler_t report;
|
|
||||||
|
|
||||||
std::mutex ioMutex;
|
std::mutex ioMutex;
|
||||||
std::optional<bool> ethActivationStatus;
|
std::optional<bool> ethActivationStatus;
|
||||||
@@ -937,7 +941,7 @@ protected:
|
|||||||
std::move(decoder)
|
std::move(decoder)
|
||||||
);
|
);
|
||||||
setupCommunication(*com);
|
setupCommunication(*com);
|
||||||
settings = makeSettings<Settings>(com);
|
settings = makeSettings<Settings>(this);
|
||||||
setupSettings(*settings);
|
setupSettings(*settings);
|
||||||
diskReadDriver = std::unique_ptr<DiskRead>(new DiskRead());
|
diskReadDriver = std::unique_ptr<DiskRead>(new DiskRead());
|
||||||
diskWriteDriver = std::unique_ptr<DiskWrite>(new DiskWrite());
|
diskWriteDriver = std::unique_ptr<DiskWrite>(new DiskWrite());
|
||||||
@@ -973,8 +977,8 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename Settings>
|
template<typename Settings>
|
||||||
std::shared_ptr<IDeviceSettings> makeSettings(std::shared_ptr<Communication> comm) {
|
std::shared_ptr<IDeviceSettings> makeSettings(Device* device) {
|
||||||
return std::make_shared<Settings>(comm);
|
return std::make_shared<Settings>(device);
|
||||||
}
|
}
|
||||||
virtual void setupSettings(IDeviceSettings&) {}
|
virtual void setupSettings(IDeviceSettings&) {}
|
||||||
|
|
||||||
@@ -1039,10 +1043,6 @@ private:
|
|||||||
|
|
||||||
APIEvent::Type attemptToBeginCommunication();
|
APIEvent::Type attemptToBeginCommunication();
|
||||||
|
|
||||||
// Use heartbeatSuppressed instead when reading
|
|
||||||
std::atomic<int> heartbeatSuppressedByUser{0};
|
|
||||||
bool heartbeatSuppressed() const { return heartbeatSuppressedByUser > 0 || (settings && settings->applyingSettings); }
|
|
||||||
|
|
||||||
void handleNeoVIMessage(std::shared_ptr<CANMessage> message);
|
void handleNeoVIMessage(std::shared_ptr<CANMessage> message);
|
||||||
|
|
||||||
bool firmwareUpdateSupported();
|
bool firmwareUpdateSupported();
|
||||||
@@ -1053,10 +1053,6 @@ private:
|
|||||||
moodycamel::BlockingConcurrentQueue<std::shared_ptr<Message>> pollingContainer;
|
moodycamel::BlockingConcurrentQueue<std::shared_ptr<Message>> pollingContainer;
|
||||||
void enforcePollingMessageLimit();
|
void enforcePollingMessageLimit();
|
||||||
|
|
||||||
std::atomic<bool> stopHeartbeatThread{false};
|
|
||||||
std::mutex heartbeatMutex;
|
|
||||||
std::thread heartbeatThread;
|
|
||||||
|
|
||||||
std::mutex diskMutex;
|
std::mutex diskMutex;
|
||||||
|
|
||||||
// Wireless neoVI Stack
|
// Wireless neoVI Stack
|
||||||
@@ -1179,6 +1175,7 @@ private:
|
|||||||
|
|
||||||
// Keeponline (keepalive for online)
|
// Keeponline (keepalive for online)
|
||||||
std::unique_ptr<Periodic> keeponline;
|
std::unique_ptr<Periodic> keeponline;
|
||||||
|
std::unique_ptr<Heartbeat> heartbeat;
|
||||||
|
|
||||||
std::optional<uint32_t> assignedClientId;
|
std::optional<uint32_t> assignedClientId;
|
||||||
std::unordered_set<icsneo::Network::NetID> lockedNetworks;
|
std::unordered_set<icsneo::Network::NetID> lockedNetworks;
|
||||||
|
|||||||
@@ -811,13 +811,17 @@ typedef struct
|
|||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#include "icsneo/communication/communication.h"
|
#include "icsneo/communication/network.h"
|
||||||
|
#include "icsneo/api/event.h"
|
||||||
|
#include "icsneo/api/eventmanager.h"
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
|
class Device;
|
||||||
|
|
||||||
enum class MiscIOAnalogVoltage : uint8_t
|
enum class MiscIOAnalogVoltage : uint8_t
|
||||||
{
|
{
|
||||||
V0 = icsneoc2_misc_io_analog_voltage_v0,
|
V0 = icsneoc2_misc_io_analog_voltage_v0,
|
||||||
@@ -845,7 +849,7 @@ public:
|
|||||||
static int64_t GetBaudrateValueForEnum(CANBaudrate enumValue);
|
static int64_t GetBaudrateValueForEnum(CANBaudrate enumValue);
|
||||||
static bool ValidateLINBaudrate(int64_t baudrate);
|
static bool ValidateLINBaudrate(int64_t baudrate);
|
||||||
|
|
||||||
IDeviceSettings(std::shared_ptr<Communication> com, size_t size) : com(com), report(com->report), structSize(size) {}
|
IDeviceSettings(Device* device, size_t size);
|
||||||
virtual ~IDeviceSettings() {}
|
virtual ~IDeviceSettings() {}
|
||||||
bool ok() const { return !disabled && settingsLoaded; }
|
bool ok() const { return !disabled && settingsLoaded; }
|
||||||
|
|
||||||
@@ -1392,10 +1396,8 @@ public:
|
|||||||
bool disabled = false;
|
bool disabled = false;
|
||||||
|
|
||||||
bool readonly = false;
|
bool readonly = false;
|
||||||
|
|
||||||
std::atomic<bool> applyingSettings{false};
|
|
||||||
protected:
|
protected:
|
||||||
std::shared_ptr<Communication> com;
|
Device* device;
|
||||||
device_eventhandler_t report;
|
device_eventhandler_t report;
|
||||||
size_t structSize;
|
size_t structSize;
|
||||||
|
|
||||||
@@ -1407,8 +1409,7 @@ protected:
|
|||||||
|
|
||||||
// Parameter createInoperableSettings exists because it is serving as a warning that you probably don't want to do this
|
// Parameter createInoperableSettings exists because it is serving as a warning that you probably don't want to do this
|
||||||
typedef void* warn_t;
|
typedef void* warn_t;
|
||||||
IDeviceSettings(warn_t createInoperableSettings, std::shared_ptr<Communication> com)
|
IDeviceSettings(warn_t createInoperableSettings, Device* device);
|
||||||
: disabled(true), readonly(true), report(com->report), structSize(0) { (void)createInoperableSettings; }
|
|
||||||
|
|
||||||
// Devices that embed a Fire3LinuxSettings block in their settings structure override these to
|
// Devices that embed a Fire3LinuxSettings block in their settings structure override these to
|
||||||
// expose it; all other devices report not-available (nullptr / nullopt) and the Linux accessors
|
// expose it; all other devices report not-available (nullptr / nullopt) and the Linux accessors
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace icsneo {
|
|||||||
class NullSettings : public IDeviceSettings {
|
class NullSettings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
// Calls the protected base constructor with "createInoperableSettings"
|
// Calls the protected base constructor with "createInoperableSettings"
|
||||||
NullSettings(std::shared_ptr<Communication> com) : IDeviceSettings(nullptr, com) {}
|
NullSettings(Device* device) : IDeviceSettings(nullptr, device) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ static_assert(sizeof(etherbadge_settings_t) == 316, "EtherBadge settings size mi
|
|||||||
|
|
||||||
class EtherBADGESettings : public IDeviceSettings {
|
class EtherBADGESettings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
EtherBADGESettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(etherbadge_settings_t)) {}
|
EtherBADGESettings(Device* device) : IDeviceSettings(device, sizeof(etherbadge_settings_t)) {}
|
||||||
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<etherbadge_settings_t>();
|
auto cfg = getStructurePointer<etherbadge_settings_t>();
|
||||||
if(cfg == nullptr)
|
if(cfg == nullptr)
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ static_assert(sizeof(neoviconnect_settings_t) == 628, "NeoVIConnect settings siz
|
|||||||
|
|
||||||
class NeoVIConnectSettings : public IDeviceSettings {
|
class NeoVIConnectSettings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
NeoVIConnectSettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(neoviconnect_settings_t)) {}
|
NeoVIConnectSettings(Device* device) : IDeviceSettings(device, sizeof(neoviconnect_settings_t)) {}
|
||||||
const Fire3LinuxSettings* getLinuxSettings() const override {
|
const Fire3LinuxSettings* getLinuxSettings() const override {
|
||||||
auto cfg = getStructurePointer<neoviconnect_settings_t>();
|
auto cfg = getStructurePointer<neoviconnect_settings_t>();
|
||||||
return cfg ? &cfg->os_settings : nullptr;
|
return cfg ? &cfg->os_settings : nullptr;
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ static_assert(sizeof(neovifire_settings_t) == 744, "NeoVIFire settings size mism
|
|||||||
|
|
||||||
class NeoVIFIRESettings : public IDeviceSettings {
|
class NeoVIFIRESettings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
NeoVIFIRESettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(neovifire_settings_t)) {}
|
NeoVIFIRESettings(Device* device) : IDeviceSettings(device, sizeof(neovifire_settings_t)) {}
|
||||||
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<neovifire_settings_t>();
|
auto cfg = getStructurePointer<neovifire_settings_t>();
|
||||||
if(cfg == nullptr)
|
if(cfg == nullptr)
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ static_assert(sizeof(neovifire2_settings_t) == 936, "NeoVIFire2 settings size mi
|
|||||||
|
|
||||||
class NeoVIFIRE2Settings : public IDeviceSettings {
|
class NeoVIFIRE2Settings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
NeoVIFIRE2Settings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(neovifire2_settings_t)) {}
|
NeoVIFIRE2Settings(Device* device) : IDeviceSettings(device, sizeof(neovifire2_settings_t)) {}
|
||||||
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<neovifire2_settings_t>();
|
auto cfg = getStructurePointer<neovifire2_settings_t>();
|
||||||
if(cfg == nullptr)
|
if(cfg == nullptr)
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ static_assert(sizeof(neovifire3_settings_t) == 1722, "NeoVIFire3 settings size m
|
|||||||
|
|
||||||
class NeoVIFIRE3Settings : public IDeviceSettings {
|
class NeoVIFIRE3Settings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
NeoVIFIRE3Settings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(neovifire3_settings_t)) {}
|
NeoVIFIRE3Settings(Device* device) : IDeviceSettings(device, sizeof(neovifire3_settings_t)) {}
|
||||||
const Fire3LinuxSettings* getLinuxSettings() const override {
|
const Fire3LinuxSettings* getLinuxSettings() const override {
|
||||||
auto cfg = getStructurePointer<neovifire3_settings_t>();
|
auto cfg = getStructurePointer<neovifire3_settings_t>();
|
||||||
return cfg ? &cfg->os_settings : nullptr;
|
return cfg ? &cfg->os_settings : nullptr;
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ static_assert(sizeof(neovifire3flexray_settings_t) == 1372, "NeoVIFire3Flexray s
|
|||||||
|
|
||||||
class NeoVIFIRE3FlexRaySettings : public IDeviceSettings {
|
class NeoVIFIRE3FlexRaySettings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
NeoVIFIRE3FlexRaySettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(neovifire3flexray_settings_t)) {}
|
NeoVIFIRE3FlexRaySettings(Device* device) : IDeviceSettings(device, sizeof(neovifire3flexray_settings_t)) {}
|
||||||
const Fire3LinuxSettings* getLinuxSettings() const override {
|
const Fire3LinuxSettings* getLinuxSettings() const override {
|
||||||
auto cfg = getStructurePointer<neovifire3flexray_settings_t>();
|
auto cfg = getStructurePointer<neovifire3flexray_settings_t>();
|
||||||
return cfg ? &cfg->os_settings : nullptr;
|
return cfg ? &cfg->os_settings : nullptr;
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ static_assert(sizeof(neovifire3t1slin_settings_t) == 1594, "NeoVIFire3T1SLIN set
|
|||||||
|
|
||||||
class NeoVIFIRE3T1SLINSettings : public IDeviceSettings {
|
class NeoVIFIRE3T1SLINSettings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
NeoVIFIRE3T1SLINSettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(neovifire3t1slin_settings_t)) {}
|
NeoVIFIRE3T1SLINSettings(Device* device) : IDeviceSettings(device, sizeof(neovifire3t1slin_settings_t)) {}
|
||||||
const Fire3LinuxSettings* getLinuxSettings() const override {
|
const Fire3LinuxSettings* getLinuxSettings() const override {
|
||||||
auto cfg = getStructurePointer<neovifire3t1slin_settings_t>();
|
auto cfg = getStructurePointer<neovifire3t1slin_settings_t>();
|
||||||
return cfg ? &cfg->os_settings : nullptr;
|
return cfg ? &cfg->os_settings : nullptr;
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ static_assert(sizeof(neovired2_settings_t) == 918, "NeoVIRED2 settings size mism
|
|||||||
|
|
||||||
class NeoVIRED2Settings : public IDeviceSettings {
|
class NeoVIRED2Settings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
NeoVIRED2Settings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(neovired2_settings_t)) {}
|
NeoVIRED2Settings(Device* device) : IDeviceSettings(device, sizeof(neovired2_settings_t)) {}
|
||||||
const Fire3LinuxSettings* getLinuxSettings() const override {
|
const Fire3LinuxSettings* getLinuxSettings() const override {
|
||||||
auto cfg = getStructurePointer<neovired2_settings_t>();
|
auto cfg = getStructurePointer<neovired2_settings_t>();
|
||||||
return cfg ? &cfg->os_settings : nullptr;
|
return cfg ? &cfg->os_settings : nullptr;
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public:
|
|||||||
Node
|
Node
|
||||||
};
|
};
|
||||||
|
|
||||||
RADA2BSettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(rada2b_settings_t)) {}
|
RADA2BSettings(Device* device) : IDeviceSettings(device, sizeof(rada2b_settings_t)) {}
|
||||||
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<rada2b_settings_t>();
|
auto cfg = getStructurePointer<rada2b_settings_t>();
|
||||||
if(cfg == nullptr)
|
if(cfg == nullptr)
|
||||||
@@ -141,27 +141,27 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TDMMode getTDMMode(RADA2BDevice device) const {
|
TDMMode getTDMMode(RADA2BDevice a2bDevice) const {
|
||||||
auto cfg = getStructurePointer<rada2b_settings_t>();
|
auto cfg = getStructurePointer<rada2b_settings_t>();
|
||||||
auto &deviceSettings = device == RADA2BDevice::Monitor ? cfg->a2b_monitor : cfg->a2b_node;
|
auto &deviceSettings = a2bDevice == RADA2BDevice::Monitor ? cfg->a2b_monitor : cfg->a2b_node;
|
||||||
|
|
||||||
return static_cast<TDMMode>(deviceSettings.tdmMode);
|
return static_cast<TDMMode>(deviceSettings.tdmMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getNumChannels(RADA2BDevice device) const {
|
uint8_t getNumChannels(RADA2BDevice a2bDevice) const {
|
||||||
return tdmModeToChannelNum(getTDMMode(device));
|
return tdmModeToChannelNum(getTDMMode(a2bDevice));
|
||||||
}
|
}
|
||||||
|
|
||||||
ChannelSize getChannelSize(RADA2BDevice device) const {
|
ChannelSize getChannelSize(RADA2BDevice a2bDevice) const {
|
||||||
auto cfg = getStructurePointer<rada2b_settings_t>();
|
auto cfg = getStructurePointer<rada2b_settings_t>();
|
||||||
auto &deviceSettings = device == RADA2BDevice::Monitor ? cfg->a2b_monitor : cfg->a2b_node;
|
auto &deviceSettings = a2bDevice == RADA2BDevice::Monitor ? cfg->a2b_monitor : cfg->a2b_node;
|
||||||
|
|
||||||
return static_cast<ChannelSize>(deviceSettings.flags & a2bSettingsFlag16bit);
|
return static_cast<ChannelSize>(deviceSettings.flags & a2bSettingsFlag16bit);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getChannelOffset(RADA2BDevice device, A2BMessage::Direction dir) const {
|
uint8_t getChannelOffset(RADA2BDevice a2bDevice, A2BMessage::Direction dir) const {
|
||||||
auto cfg = getStructurePointer<rada2b_settings_t>();
|
auto cfg = getStructurePointer<rada2b_settings_t>();
|
||||||
auto &deviceSettings = device == RADA2BDevice::Monitor ? cfg->a2b_monitor : cfg->a2b_node;
|
auto &deviceSettings = a2bDevice == RADA2BDevice::Monitor ? cfg->a2b_monitor : cfg->a2b_node;
|
||||||
|
|
||||||
if(dir == A2BMessage::Direction::Upstream) {
|
if(dir == A2BMessage::Direction::Upstream) {
|
||||||
return deviceSettings.upstreamChannelOffset;
|
return deviceSettings.upstreamChannelOffset;
|
||||||
@@ -170,30 +170,30 @@ public:
|
|||||||
return deviceSettings.downstreamChannelOffset;
|
return deviceSettings.downstreamChannelOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeType getNodeType(RADA2BDevice device) const {
|
NodeType getNodeType(RADA2BDevice a2bDevice) const {
|
||||||
auto cfg = getStructurePointer<rada2b_settings_t>();
|
auto cfg = getStructurePointer<rada2b_settings_t>();
|
||||||
auto &deviceSettings = device == RADA2BDevice::Monitor ? cfg->a2b_monitor : cfg->a2b_node;
|
auto &deviceSettings = a2bDevice == RADA2BDevice::Monitor ? cfg->a2b_monitor : cfg->a2b_node;
|
||||||
|
|
||||||
return static_cast<NodeType>(deviceSettings.nodeType);
|
return static_cast<NodeType>(deviceSettings.nodeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setNodeType(RADA2BDevice device, NodeType newType) {
|
void setNodeType(RADA2BDevice a2bDevice, NodeType newType) {
|
||||||
auto cfg = getMutableStructurePointer<rada2b_settings_t>();
|
auto cfg = getMutableStructurePointer<rada2b_settings_t>();
|
||||||
auto &deviceSettings = device == RADA2BDevice::Monitor ? cfg->a2b_monitor : cfg->a2b_node;
|
auto &deviceSettings = a2bDevice == RADA2BDevice::Monitor ? cfg->a2b_monitor : cfg->a2b_node;
|
||||||
|
|
||||||
deviceSettings.nodeType = static_cast<uint8_t>(newType);
|
deviceSettings.nodeType = static_cast<uint8_t>(newType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTDMMode(RADA2BDevice device, TDMMode newMode) {
|
void setTDMMode(RADA2BDevice a2bDevice, TDMMode newMode) {
|
||||||
auto cfg = getMutableStructurePointer<rada2b_settings_t>();
|
auto cfg = getMutableStructurePointer<rada2b_settings_t>();
|
||||||
auto &deviceSettings = device == RADA2BDevice::Monitor ? cfg->a2b_monitor : cfg->a2b_node;
|
auto &deviceSettings = a2bDevice == RADA2BDevice::Monitor ? cfg->a2b_monitor : cfg->a2b_node;
|
||||||
|
|
||||||
deviceSettings.tdmMode = static_cast<uint8_t>(newMode);
|
deviceSettings.tdmMode = static_cast<uint8_t>(newMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setChannelOffset(RADA2BDevice device, A2BMessage::Direction dir, uint8_t newOffset) {
|
void setChannelOffset(RADA2BDevice a2bDevice, A2BMessage::Direction dir, uint8_t newOffset) {
|
||||||
auto cfg = getMutableStructurePointer<rada2b_settings_t>();
|
auto cfg = getMutableStructurePointer<rada2b_settings_t>();
|
||||||
auto &deviceSettings = device == RADA2BDevice::Monitor ? cfg->a2b_monitor : cfg->a2b_node;
|
auto &deviceSettings = a2bDevice == RADA2BDevice::Monitor ? cfg->a2b_monitor : cfg->a2b_node;
|
||||||
|
|
||||||
if(dir == A2BMessage::Direction::Upstream) {
|
if(dir == A2BMessage::Direction::Upstream) {
|
||||||
deviceSettings.upstreamChannelOffset = newOffset;
|
deviceSettings.upstreamChannelOffset = newOffset;
|
||||||
@@ -203,9 +203,9 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setChannelSize(RADA2BDevice device, ChannelSize newChannelSize) {
|
void setChannelSize(RADA2BDevice a2bDevice, ChannelSize newChannelSize) {
|
||||||
auto cfg = getMutableStructurePointer<rada2b_settings_t>();
|
auto cfg = getMutableStructurePointer<rada2b_settings_t>();
|
||||||
auto &deviceSettings = device == RADA2BDevice::Monitor ? cfg->a2b_monitor : cfg->a2b_node;
|
auto &deviceSettings = a2bDevice == RADA2BDevice::Monitor ? cfg->a2b_monitor : cfg->a2b_node;
|
||||||
|
|
||||||
if(newChannelSize == ChannelSize::chSize16) {
|
if(newChannelSize == ChannelSize::chSize16) {
|
||||||
deviceSettings.flags |= a2bSettingsFlag16bit;
|
deviceSettings.flags |= a2bSettingsFlag16bit;
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ static_assert(sizeof(radcomet2_settings_t) == 498, "RADComet2 settings size mism
|
|||||||
|
|
||||||
class RADComet2Settings : public IDeviceSettings {
|
class RADComet2Settings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
RADComet2Settings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(radcomet2_settings_t)) {}
|
RADComet2Settings(Device* device) : IDeviceSettings(device, sizeof(radcomet2_settings_t)) {}
|
||||||
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<radcomet2_settings_t>();
|
auto cfg = getStructurePointer<radcomet2_settings_t>();
|
||||||
if(cfg == nullptr)
|
if(cfg == nullptr)
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ static_assert(sizeof(radcomet3_settings_t) == 674, "RADComet3 settings size mism
|
|||||||
|
|
||||||
class RADComet3Settings : public IDeviceSettings {
|
class RADComet3Settings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
RADComet3Settings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(radcomet3_settings_t)) {}
|
RADComet3Settings(Device* device) : IDeviceSettings(device, sizeof(radcomet3_settings_t)) {}
|
||||||
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<radcomet3_settings_t>();
|
auto cfg = getStructurePointer<radcomet3_settings_t>();
|
||||||
if(cfg == nullptr)
|
if(cfg == nullptr)
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ static_assert(sizeof(radepsilon_settings_t) == 400, "RADEpsilon settings size mi
|
|||||||
|
|
||||||
class RADEpsilonSettings : public IDeviceSettings {
|
class RADEpsilonSettings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
RADEpsilonSettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(radepsilon_settings_t)) {}
|
RADEpsilonSettings(Device* device) : IDeviceSettings(device, sizeof(radepsilon_settings_t)) {}
|
||||||
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<radepsilon_settings_t>();
|
auto cfg = getStructurePointer<radepsilon_settings_t>();
|
||||||
if(cfg == nullptr)
|
if(cfg == nullptr)
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ static_assert(sizeof(radgalaxy_settings_t) == 776, "RADGalaxy settings size mism
|
|||||||
|
|
||||||
class RADGalaxySettings : public IDeviceSettings {
|
class RADGalaxySettings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
RADGalaxySettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(radgalaxy_settings_t)) {}
|
RADGalaxySettings(Device* device) : IDeviceSettings(device, sizeof(radgalaxy_settings_t)) {}
|
||||||
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<radgalaxy_settings_t>();
|
auto cfg = getStructurePointer<radgalaxy_settings_t>();
|
||||||
if(cfg == nullptr)
|
if(cfg == nullptr)
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ static_assert(sizeof(radgalaxy2_settings_t) == 960, "RADGalaxy2 settings size mi
|
|||||||
|
|
||||||
class RADGalaxy2Settings : public IDeviceSettings {
|
class RADGalaxy2Settings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
RADGalaxy2Settings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(radgalaxy2_settings_t)) {}
|
RADGalaxy2Settings(Device* device) : IDeviceSettings(device, sizeof(radgalaxy2_settings_t)) {}
|
||||||
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<radgalaxy2_settings_t>();
|
auto cfg = getStructurePointer<radgalaxy2_settings_t>();
|
||||||
if(cfg == nullptr)
|
if(cfg == nullptr)
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ static_assert(sizeof(radgemini_settings_t) == 86, "RADGemini settings size misma
|
|||||||
|
|
||||||
class RADGeminiSettings : public IDeviceSettings {
|
class RADGeminiSettings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
RADGeminiSettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(radgemini_settings_t)) {}
|
RADGeminiSettings(Device* device) : IDeviceSettings(device, sizeof(radgemini_settings_t)) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ static_assert(sizeof(radgigastar_settings_t) == 1026, "RADGigastar settings size
|
|||||||
|
|
||||||
class RADGigastarSettings : public IDeviceSettings {
|
class RADGigastarSettings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
RADGigastarSettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(radgigastar_settings_t)) {}
|
RADGigastarSettings(Device* device) : IDeviceSettings(device, sizeof(radgigastar_settings_t)) {}
|
||||||
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<radgigastar_settings_t>();
|
auto cfg = getStructurePointer<radgigastar_settings_t>();
|
||||||
if(cfg == nullptr)
|
if(cfg == nullptr)
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ namespace icsneo
|
|||||||
class RADGigastar2Settings : public IDeviceSettings
|
class RADGigastar2Settings : public IDeviceSettings
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RADGigastar2Settings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(radgigastar2_settings_t)) {}
|
RADGigastar2Settings(Device* device) : IDeviceSettings(device, sizeof(radgigastar2_settings_t)) {}
|
||||||
const CAN_SETTINGS *getCANSettingsFor(Network net) const override
|
const CAN_SETTINGS *getCANSettingsFor(Network net) const override
|
||||||
{
|
{
|
||||||
auto cfg = getStructurePointer<radgigastar2_settings_t>();
|
auto cfg = getStructurePointer<radgigastar2_settings_t>();
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ static_assert(sizeof(radjupiter_settings_t) == 348, "RAD-Jupiter Settings are no
|
|||||||
|
|
||||||
class RADJupiterSettings : public IDeviceSettings {
|
class RADJupiterSettings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
RADJupiterSettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(radjupiter_settings_t)) {}
|
RADJupiterSettings(Device* device) : IDeviceSettings(device, sizeof(radjupiter_settings_t)) {}
|
||||||
|
|
||||||
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<radjupiter_settings_t>();
|
auto cfg = getStructurePointer<radjupiter_settings_t>();
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ static_assert(sizeof(radmars_settings_t) == 666, "RAD-Mars settings size mismatc
|
|||||||
|
|
||||||
class RADMarsSettings : public IDeviceSettings {
|
class RADMarsSettings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
RADMarsSettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(radmars_settings_t)) {}
|
RADMarsSettings(Device* device) : IDeviceSettings(device, sizeof(radmars_settings_t)) {}
|
||||||
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<radmars_settings_t>();
|
auto cfg = getStructurePointer<radmars_settings_t>();
|
||||||
if(cfg == nullptr)
|
if(cfg == nullptr)
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ static_assert(sizeof(radmoon2_settings_t) == 170, "RADMoon2 settings size mismat
|
|||||||
|
|
||||||
class RADMoon2Settings : public IDeviceSettings {
|
class RADMoon2Settings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
RADMoon2Settings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(radmoon2_settings_t)) {}
|
RADMoon2Settings(Device* device) : IDeviceSettings(device, sizeof(radmoon2_settings_t)) {}
|
||||||
|
|
||||||
const RAD_GPTP_SETTINGS* getGPTPSettings() const override {
|
const RAD_GPTP_SETTINGS* getGPTPSettings() const override {
|
||||||
auto cfg = getStructurePointer<radmoon2_settings_t>();
|
auto cfg = getStructurePointer<radmoon2_settings_t>();
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ static_assert(sizeof(radmoon3_settings_t) == 68, "RADMoon3 settings size mismatc
|
|||||||
|
|
||||||
class RADMoon3Settings : public IDeviceSettings {
|
class RADMoon3Settings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
RADMoon3Settings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(radmoon3_settings_t)) {}
|
RADMoon3Settings(Device* device) : IDeviceSettings(device, sizeof(radmoon3_settings_t)) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ static_assert(sizeof(radmoonduo_settings_t) == 38, "RAD-Moon Duo settings size e
|
|||||||
|
|
||||||
class RADMoonDuoSettings : public IDeviceSettings {
|
class RADMoonDuoSettings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
RADMoonDuoSettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(radmoonduo_settings_t)) {}
|
RADMoonDuoSettings(Device* device) : IDeviceSettings(device, sizeof(radmoonduo_settings_t)) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ static_assert(sizeof(radmoont1s_settings_t) == 160, "RADMoonT1S settings size mi
|
|||||||
|
|
||||||
class RADMoonT1SSettings : public IDeviceSettings {
|
class RADMoonT1SSettings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
RADMoonT1SSettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(radmoont1s_settings_t)) {}
|
RADMoonT1SSettings(Device* device) : IDeviceSettings(device, sizeof(radmoont1s_settings_t)) {}
|
||||||
|
|
||||||
std::optional<bool> isT1SPLCAEnabledFor(Network net) const override {
|
std::optional<bool> isT1SPLCAEnabledFor(Network net) const override {
|
||||||
const ETHERNET10T1S_SETTINGS* t1s = getT1SSettingsFor(net);
|
const ETHERNET10T1S_SETTINGS* t1s = getT1SSettingsFor(net);
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ static_assert(sizeof(radpluto_settings_t) == 322, "RAD-Pluto Settings are not pa
|
|||||||
|
|
||||||
class RADPlutoSettings : public IDeviceSettings {
|
class RADPlutoSettings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
RADPlutoSettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(radpluto_settings_t)) {
|
RADPlutoSettings(Device* device) : IDeviceSettings(device, sizeof(radpluto_settings_t)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ static_assert(sizeof(radstar2_settings_t) == 422, "RADStar2 settings size mismat
|
|||||||
|
|
||||||
class RADStar2Settings : public IDeviceSettings {
|
class RADStar2Settings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
RADStar2Settings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(radstar2_settings_t)) {
|
RADStar2Settings(Device* device) : IDeviceSettings(device, sizeof(radstar2_settings_t)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ typedef struct {
|
|||||||
|
|
||||||
class RADSupermoonSettings : public IDeviceSettings {
|
class RADSupermoonSettings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
RADSupermoonSettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(radsupermoon_settings_t)) {}
|
RADSupermoonSettings(Device* device) : IDeviceSettings(device, sizeof(radsupermoon_settings_t)) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ static_assert(sizeof(radwbms_settings_t) == 156, "RAD-wBMS settings size mismatc
|
|||||||
|
|
||||||
class RADwBMSSettings : public IDeviceSettings {
|
class RADwBMSSettings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
RADwBMSSettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(radwbms_settings_t)) {}
|
RADwBMSSettings(Device* device) : IDeviceSettings(device, sizeof(radwbms_settings_t)) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ static_assert(sizeof(valuecan3_settings_t) == 40, "ValueCAN3 settings size misma
|
|||||||
|
|
||||||
class ValueCAN3Settings : public IDeviceSettings {
|
class ValueCAN3Settings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
ValueCAN3Settings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(valuecan3_settings_t)) {}
|
ValueCAN3Settings(Device* device) : IDeviceSettings(device, sizeof(valuecan3_settings_t)) {}
|
||||||
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<valuecan3_settings_t>();
|
auto cfg = getStructurePointer<valuecan3_settings_t>();
|
||||||
if(cfg == nullptr)
|
if(cfg == nullptr)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace icsneo {
|
|||||||
|
|
||||||
class ValueCAN4_1_2Settings : public IDeviceSettings {
|
class ValueCAN4_1_2Settings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
ValueCAN4_1_2Settings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(valuecan4_1_2_settings_t)) {}
|
ValueCAN4_1_2Settings(Device* device) : IDeviceSettings(device, sizeof(valuecan4_1_2_settings_t)) {}
|
||||||
// We do not override getCANSettingsFor or getCANFDSettingsFor here because they will be device specific
|
// We do not override getCANSettingsFor or getCANFDSettingsFor here because they will be device specific
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace icsneo {
|
|||||||
|
|
||||||
class ValueCAN4_1Settings : public ValueCAN4_1_2Settings {
|
class ValueCAN4_1Settings : public ValueCAN4_1_2Settings {
|
||||||
public:
|
public:
|
||||||
ValueCAN4_1Settings(std::shared_ptr<Communication> com) : ValueCAN4_1_2Settings(com) {}
|
ValueCAN4_1Settings(Device* device) : ValueCAN4_1_2Settings(device) {}
|
||||||
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<valuecan4_1_2_settings_t>();
|
auto cfg = getStructurePointer<valuecan4_1_2_settings_t>();
|
||||||
if(cfg == nullptr)
|
if(cfg == nullptr)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace icsneo {
|
|||||||
|
|
||||||
class ValueCAN4_2ELSettings : public ValueCAN4_4_2ELSettings {
|
class ValueCAN4_2ELSettings : public ValueCAN4_4_2ELSettings {
|
||||||
public:
|
public:
|
||||||
ValueCAN4_2ELSettings(std::shared_ptr<Communication> com) : ValueCAN4_4_2ELSettings(com) {}
|
ValueCAN4_2ELSettings(Device* device) : ValueCAN4_4_2ELSettings(device) {}
|
||||||
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<valuecan4_4_2el_settings_t>();
|
auto cfg = getStructurePointer<valuecan4_4_2el_settings_t>();
|
||||||
if(cfg == nullptr)
|
if(cfg == nullptr)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace icsneo {
|
|||||||
|
|
||||||
class ValueCAN4_2Settings : public ValueCAN4_1_2Settings {
|
class ValueCAN4_2Settings : public ValueCAN4_1_2Settings {
|
||||||
public:
|
public:
|
||||||
ValueCAN4_2Settings(std::shared_ptr<Communication> com) : ValueCAN4_1_2Settings(com) {}
|
ValueCAN4_2Settings(Device* device) : ValueCAN4_1_2Settings(device) {}
|
||||||
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<valuecan4_1_2_settings_t>();
|
auto cfg = getStructurePointer<valuecan4_1_2_settings_t>();
|
||||||
if(cfg == nullptr)
|
if(cfg == nullptr)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace icsneo {
|
|||||||
|
|
||||||
class ValueCAN4_4_2ELSettings : public IDeviceSettings {
|
class ValueCAN4_4_2ELSettings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
ValueCAN4_4_2ELSettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(valuecan4_4_2el_settings_t)) {}
|
ValueCAN4_4_2ELSettings(Device* device) : IDeviceSettings(device, sizeof(valuecan4_4_2el_settings_t)) {}
|
||||||
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<valuecan4_4_2el_settings_t>();
|
auto cfg = getStructurePointer<valuecan4_4_2el_settings_t>();
|
||||||
if(cfg == nullptr)
|
if(cfg == nullptr)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace icsneo {
|
|||||||
|
|
||||||
class ValueCAN4_4Settings : public ValueCAN4_4_2ELSettings {
|
class ValueCAN4_4Settings : public ValueCAN4_4_2ELSettings {
|
||||||
public:
|
public:
|
||||||
ValueCAN4_4Settings(std::shared_ptr<Communication> com) : ValueCAN4_4_2ELSettings(com) {}
|
ValueCAN4_4Settings(Device* device) : ValueCAN4_4_2ELSettings(device) {}
|
||||||
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<valuecan4_4_2el_settings_t>();
|
auto cfg = getStructurePointer<valuecan4_4_2el_settings_t>();
|
||||||
if(cfg == nullptr)
|
if(cfg == nullptr)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace icsneo {
|
|||||||
|
|
||||||
class ValueCAN4IndustrialSettings : public IDeviceSettings {
|
class ValueCAN4IndustrialSettings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
ValueCAN4IndustrialSettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(valuecan4_industrial_settings_t)) {}
|
ValueCAN4IndustrialSettings(Device* device) : IDeviceSettings(device, sizeof(valuecan4_industrial_settings_t)) {}
|
||||||
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<valuecan4_industrial_settings_t>();
|
auto cfg = getStructurePointer<valuecan4_industrial_settings_t>();
|
||||||
if(cfg == nullptr)
|
if(cfg == nullptr)
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ static_assert(sizeof(vividcan_settings_t) == 64, "VividCAN settings size mismatc
|
|||||||
|
|
||||||
class VividCANSettings : public IDeviceSettings {
|
class VividCANSettings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
VividCANSettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(vividcan_settings_t)) {}
|
VividCANSettings(Device* device) : IDeviceSettings(device, sizeof(vividcan_settings_t)) {}
|
||||||
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<vividcan_settings_t>();
|
auto cfg = getStructurePointer<vividcan_settings_t>();
|
||||||
if(cfg == nullptr)
|
if(cfg == nullptr)
|
||||||
|
|||||||
Reference in New Issue
Block a user