MotorControlModuleSDFM_TMS3.../Projects/EFC_Communication/UMLibrary/communication/service/CommunicationLink.hh
2024-06-07 11:12:56 +03:00

81 lines
1.7 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*!\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_ */