Changed Cookie to CookieIF

This commit is contained in:
Robin Müller 2020-04-18 14:10:38 +02:00
parent 81ab5a6914
commit 9c958c06fe
6 changed files with 35 additions and 34 deletions

View File

@ -17,6 +17,7 @@ typedef uint32_t address_t;
* calling @code{.cpp} CookieIF* childCookie = new ChildCookie(...) * calling @code{.cpp} CookieIF* childCookie = new ChildCookie(...)
* @endcode . * @endcode .
* *
* [not implemented yet]
* This cookie is then passed to the child device handlers, which stores the * This cookie is then passed to the child device handlers, which stores the
* pointer and passes it to the communication interface functions. * pointer and passes it to the communication interface functions.
* *

View File

@ -1,7 +1,7 @@
#ifndef DEVICECOMMUNICATIONIF_H_ #ifndef DEVICECOMMUNICATIONIF_H_
#define DEVICECOMMUNICATIONIF_H_ #define DEVICECOMMUNICATIONIF_H_
#include <framework/devicehandlers/Cookie.h> #include <framework/devicehandlers/CookieIF.h>
#include <framework/returnvalues/HasReturnvaluesIF.h> #include <framework/returnvalues/HasReturnvaluesIF.h>
class DeviceCommunicationIF: public HasReturnvaluesIF { class DeviceCommunicationIF: public HasReturnvaluesIF {
@ -20,7 +20,7 @@ public:
} }
virtual ReturnValue_t open(Cookie **cookie, uint32_t address, virtual ReturnValue_t open(CookieIF **cookie, uint32_t address,
uint32_t maxReplyLen) = 0; uint32_t maxReplyLen) = 0;
/** /**
@ -34,29 +34,29 @@ public:
* @param maxReplyLen * @param maxReplyLen
* @return * @return
*/ */
virtual ReturnValue_t reOpen(Cookie *cookie, uint32_t address, virtual ReturnValue_t reOpen(CookieIF *cookie, uint32_t address,
uint32_t maxReplyLen) = 0; uint32_t maxReplyLen) = 0;
virtual void close(Cookie *cookie) = 0; virtual void close(CookieIF *cookie) = 0;
//SHOULDDO can data be const? //SHOULDDO can data be const?
virtual ReturnValue_t sendMessage(Cookie *cookie, uint8_t *data, virtual ReturnValue_t sendMessage(CookieIF *cookie, uint8_t *data,
uint32_t len) = 0; uint32_t len) = 0;
virtual ReturnValue_t getSendSuccess(Cookie *cookie) = 0; virtual ReturnValue_t getSendSuccess(CookieIF *cookie) = 0;
virtual ReturnValue_t requestReceiveMessage(Cookie *cookie) = 0; virtual ReturnValue_t requestReceiveMessage(CookieIF *cookie) = 0;
virtual ReturnValue_t readReceivedMessage(Cookie *cookie, uint8_t **buffer, virtual ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
uint32_t *size) = 0; uint32_t *size) = 0;
virtual ReturnValue_t setAddress(Cookie *cookie, uint32_t address) = 0; virtual ReturnValue_t setAddress(CookieIF *cookie, uint32_t address) = 0;
virtual uint32_t getAddress(Cookie *cookie) = 0; virtual uint32_t getAddress(CookieIF *cookie) = 0;
virtual ReturnValue_t setParameter(Cookie *cookie, uint32_t parameter) = 0; virtual ReturnValue_t setParameter(CookieIF *cookie, uint32_t parameter) = 0;
virtual uint32_t getParameter(Cookie *cookie) = 0; virtual uint32_t getParameter(CookieIF *cookie) = 0;
}; };

View File

@ -244,7 +244,7 @@ protected:
/** /**
* Cookie used for communication * Cookie used for communication
*/ */
Cookie *cookie; CookieIF *cookie;
/** /**
* The MessageQueue used to receive device handler commands and to send replies. * The MessageQueue used to receive device handler commands and to send replies.

View File

@ -1,12 +1,12 @@
#ifndef RMAPCOOKIE_H_ #ifndef RMAPCOOKIE_H_
#define RMAPCOOKIE_H_ #define RMAPCOOKIE_H_
#include <framework/devicehandlers/Cookie.h> #include <framework/devicehandlers/CookieIF.h>
#include <framework/rmap/rmapStructs.h> #include <framework/rmap/rmapStructs.h>
class RMAPChannelIF; class RMAPChannelIF;
class RMAPCookie : public Cookie{ class RMAPCookie : public CookieIF {
public: public:
//To Uli: Sorry, I need an empty ctor to initialize an array of cookies. //To Uli: Sorry, I need an empty ctor to initialize an array of cookies.
RMAPCookie(); RMAPCookie();

View File

@ -5,43 +5,43 @@
RmapDeviceCommunicationIF::~RmapDeviceCommunicationIF() { RmapDeviceCommunicationIF::~RmapDeviceCommunicationIF() {
} }
ReturnValue_t RmapDeviceCommunicationIF::sendMessage(Cookie* cookie, ReturnValue_t RmapDeviceCommunicationIF::sendMessage(CookieIF* cookie,
uint8_t* data, uint32_t len) { uint8_t* data, uint32_t len) {
return RMAP::sendWriteCommand((RMAPCookie *) cookie, data, len); return RMAP::sendWriteCommand((RMAPCookie *) cookie, data, len);
} }
ReturnValue_t RmapDeviceCommunicationIF::getSendSuccess(Cookie* cookie) { ReturnValue_t RmapDeviceCommunicationIF::getSendSuccess(CookieIF* cookie) {
return RMAP::getWriteReply((RMAPCookie *) cookie); return RMAP::getWriteReply((RMAPCookie *) cookie);
} }
ReturnValue_t RmapDeviceCommunicationIF::requestReceiveMessage( ReturnValue_t RmapDeviceCommunicationIF::requestReceiveMessage(
Cookie* cookie) { CookieIF* cookie) {
return RMAP::sendReadCommand((RMAPCookie *) cookie, return RMAP::sendReadCommand((RMAPCookie *) cookie,
((RMAPCookie *) cookie)->getMaxReplyLen()); ((RMAPCookie *) cookie)->getMaxReplyLen());
} }
ReturnValue_t RmapDeviceCommunicationIF::readReceivedMessage(Cookie* cookie, ReturnValue_t RmapDeviceCommunicationIF::readReceivedMessage(CookieIF* cookie,
uint8_t** buffer, uint32_t* size) { uint8_t** buffer, uint32_t* size) {
return RMAP::getReadReply((RMAPCookie *) cookie, buffer, size); return RMAP::getReadReply((RMAPCookie *) cookie, buffer, size);
} }
ReturnValue_t RmapDeviceCommunicationIF::setAddress(Cookie* cookie, ReturnValue_t RmapDeviceCommunicationIF::setAddress(CookieIF* cookie,
uint32_t address) { uint32_t address) {
((RMAPCookie *) cookie)->setAddress(address); ((RMAPCookie *) cookie)->setAddress(address);
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
uint32_t RmapDeviceCommunicationIF::getAddress(Cookie* cookie) { uint32_t RmapDeviceCommunicationIF::getAddress(CookieIF* cookie) {
return ((RMAPCookie *) cookie)->getAddress(); return ((RMAPCookie *) cookie)->getAddress();
} }
ReturnValue_t RmapDeviceCommunicationIF::setParameter(Cookie* cookie, ReturnValue_t RmapDeviceCommunicationIF::setParameter(CookieIF* cookie,
uint32_t parameter) { uint32_t parameter) {
//TODO Empty? //TODO Empty?
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
uint32_t RmapDeviceCommunicationIF::getParameter(Cookie* cookie) { uint32_t RmapDeviceCommunicationIF::getParameter(CookieIF* cookie) {
return 0; return 0;
} }

View File

@ -25,7 +25,7 @@ public:
* @param maxReplyLen Maximum length of expected reply * @param maxReplyLen Maximum length of expected reply
* @return * @return
*/ */
virtual ReturnValue_t open(Cookie **cookie, uint32_t address, virtual ReturnValue_t open(CookieIF **cookie, uint32_t address,
uint32_t maxReplyLen) = 0; uint32_t maxReplyLen) = 0;
/** /**
@ -39,7 +39,7 @@ public:
* @param maxReplyLen * @param maxReplyLen
* @return * @return
*/ */
virtual ReturnValue_t reOpen(Cookie *cookie, uint32_t address, virtual ReturnValue_t reOpen(CookieIF *cookie, uint32_t address,
uint32_t maxReplyLen) = 0; uint32_t maxReplyLen) = 0;
@ -47,7 +47,7 @@ public:
* Closing call of connection and memory free of cookie. Mission dependent call * Closing call of connection and memory free of cookie. Mission dependent call
* @param cookie * @param cookie
*/ */
virtual void close(Cookie *cookie) = 0; virtual void close(CookieIF *cookie) = 0;
//SHOULDDO can data be const? //SHOULDDO can data be const?
/** /**
@ -58,23 +58,23 @@ public:
* @param len Length of the data to be send * @param len Length of the data to be send
* @return - Return codes of RMAP::sendWriteCommand() * @return - Return codes of RMAP::sendWriteCommand()
*/ */
virtual ReturnValue_t sendMessage(Cookie *cookie, uint8_t *data, virtual ReturnValue_t sendMessage(CookieIF *cookie, uint8_t *data,
uint32_t len); uint32_t len);
virtual ReturnValue_t getSendSuccess(Cookie *cookie); virtual ReturnValue_t getSendSuccess(CookieIF *cookie);
virtual ReturnValue_t requestReceiveMessage(Cookie *cookie); virtual ReturnValue_t requestReceiveMessage(CookieIF *cookie);
virtual ReturnValue_t readReceivedMessage(Cookie *cookie, uint8_t **buffer, virtual ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
uint32_t *size); uint32_t *size);
virtual ReturnValue_t setAddress(Cookie *cookie, uint32_t address); virtual ReturnValue_t setAddress(CookieIF *cookie, uint32_t address);
virtual uint32_t getAddress(Cookie *cookie); virtual uint32_t getAddress(CookieIF *cookie);
virtual ReturnValue_t setParameter(Cookie *cookie, uint32_t parameter); virtual ReturnValue_t setParameter(CookieIF *cookie, uint32_t parameter);
virtual uint32_t getParameter(Cookie *cookie); virtual uint32_t getParameter(CookieIF *cookie);
}; };
#endif /* MISSION_RMAP_RMAPDEVICECOMMUNICATIONINTERFACE_H_ */ #endif /* MISSION_RMAP_RMAPDEVICECOMMUNICATIONINTERFACE_H_ */