81 lines
1.7 KiB
C++
81 lines
1.7 KiB
C++
/*!\file
|
|
* \brief \todo Îïèñàíèå ôàéëà.
|
|
*/
|
|
/*
|
|
* CommunicationLink.h
|
|
*
|
|
* Created on: 31 ìàðòà 2017 ã.
|
|
* Author: titov
|
|
*/
|
|
|
|
#ifndef SOURCES_COMMUNICATION_COMMUNICATIONLINK_H_
|
|
#define SOURCES_COMMUNICATION_COMMUNICATIONLINK_H_
|
|
|
|
#include "../../driver/ISlipCommunication.hh"
|
|
|
|
#include "../service/IMessageLink.hh"
|
|
#include "../service/IMessageHandler.hh"
|
|
|
|
#include "../../systemic/IProcess.hh"
|
|
|
|
#include <cstddef>
|
|
#include <stdint.h>
|
|
|
|
namespace communication { namespace service {
|
|
|
|
class CommunicationLink : public IMessageLink {
|
|
public:
|
|
class Subscrib {
|
|
|
|
friend class CommunicationLink;
|
|
|
|
unsigned int id;
|
|
IMessageHandler * handler;
|
|
|
|
public:
|
|
Subscrib() : id(0u), handler(nullptr) {}
|
|
|
|
};
|
|
|
|
private:
|
|
driver::ISlipCommunication & communication;
|
|
|
|
unsigned int packet_id;
|
|
|
|
Subscrib * const subscribers;
|
|
const std::size_t max_subscribers;
|
|
|
|
unsigned int count_subscriber;
|
|
|
|
bool answer_created;
|
|
bool message_handled;
|
|
|
|
void send_answer();
|
|
void send_default();
|
|
|
|
uint16_t free_counter;
|
|
|
|
|
|
public:
|
|
CommunicationLink( driver::ISlipCommunication & isc, Subscrib * subs, std::size_t max_subs );
|
|
|
|
bool registerMessageHandler( IMessageHandler * handler, size_t id );
|
|
|
|
driver::IRxLink & getData();
|
|
driver::ITxLink & createMessage( std::size_t size);
|
|
|
|
bool createMessageSeries( std::size_t num_messages, IMessageSeriesHandler * handler ) { return false; }
|
|
std::size_t transmitBuffCapacity() const { return communication.transmitBuffCapacity(); }
|
|
std::size_t receiveBuffCapacity() const { return communication.receiveBuffCapacity(); }
|
|
|
|
void process();
|
|
|
|
float getPacketCounter() const;
|
|
};
|
|
|
|
}}
|
|
|
|
|
|
|
|
#endif /* SOURCES_COMMUNICATION_COMMUNICATIONLINK_H_ */
|