mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
Device: Refactor ComponentVersions
Also: - Add setGenericData() - Add ExtendedResponseFilter
This commit is contained in:
committed by
Kyle Schwarz
parent
b1e875980c
commit
7eeb1b6c38
@@ -7,8 +7,8 @@
|
||||
namespace icsneo {
|
||||
class ComponentVersion {
|
||||
public:
|
||||
ComponentVersion(uint8_t valid, uint8_t componentInfo, uint32_t identifier, uint32_t dotVersion, uint32_t commitHash) :
|
||||
valid(valid), componentInfo(componentInfo), identifier(identifier), dotVersion(dotVersion), commitHash(commitHash) {}
|
||||
ComponentVersion(uint8_t valid, uint8_t componentInfo, uint32_t identifier, uint32_t dotVersion, uint32_t commitHash, uint8_t expansionSlot) :
|
||||
valid(valid), componentInfo(componentInfo), identifier(identifier), dotVersion(dotVersion), commitHash(commitHash), expansionSlot(expansionSlot) {}
|
||||
|
||||
static ComponentVersion FromAppVersion(uint32_t identifier, uint8_t appMajor, uint8_t appMinor) {
|
||||
uint32_t dotVersion = (appMajor << 24) | (appMinor << 16);
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
static_cast<uint8_t>(0u),
|
||||
identifier,
|
||||
dotVersion,
|
||||
static_cast<uint8_t>(0u),
|
||||
static_cast<uint8_t>(0u)
|
||||
);
|
||||
}
|
||||
@@ -28,6 +29,7 @@ public:
|
||||
const uint32_t identifier;
|
||||
const uint32_t dotVersion;
|
||||
const uint32_t commitHash;
|
||||
const uint8_t expansionSlot;
|
||||
};
|
||||
|
||||
class ComponentVersionsMessage : public Message {
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef __EXTENDEDRESPONSEFILTER_H_
|
||||
#define __EXTENDEDRESPONSEFILTER_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "icsneo/communication/message/filter/messagefilter.h"
|
||||
#include "icsneo/communication/network.h"
|
||||
#include "icsneo/communication/communication.h"
|
||||
#include "icsneo/communication/command.h"
|
||||
#include "icsneo/communication/message/extendedresponsemessage.h"
|
||||
#include <memory>
|
||||
#include <iostream>
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
class ExtendedResponseFilter : public MessageFilter {
|
||||
public:
|
||||
ExtendedResponseFilter(icsneo::ExtendedResponse resp) : MessageFilter(Message::Type::ExtendedResponse), response(resp) {}
|
||||
|
||||
bool match(const std::shared_ptr<Message>& message) const override {
|
||||
if(!MessageFilter::match(message)) {
|
||||
return false;
|
||||
}
|
||||
const auto respMsg = std::static_pointer_cast<ExtendedResponseMessage>(message);
|
||||
return respMsg && matchResponse(respMsg->response);
|
||||
}
|
||||
|
||||
private:
|
||||
icsneo::ExtendedResponse response;
|
||||
bool matchResponse(icsneo::ExtendedResponse resp) const {
|
||||
return response == resp;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user