Roboid Control for C++
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | List of all members
RoboidControl::SiteServer Class Reference

Detailed Description

A participant is device which can communicate with other participants.

#include <SiteServer.h>

Inheritance diagram for RoboidControl::SiteServer:
RoboidControl::LocalParticipant RoboidControl::Participant

Public Member Functions

 SiteServer (int port=7681)
 
template<typename ThingClass >
void Register (unsigned char thingType)
 
void begin ()
 
virtual void Update (unsigned long currentTimeMs=0)
 
void SendThingInfo (Participant *remoteParticipant, Thing *thing)
 
void PublishThingInfo (Thing *thing)
 
bool Send (Participant *remoteParticipant, IMessage *msg)
 
bool Publish (IMessage *msg)
 
void ReceiveData (unsigned char bufferSize, char *senderIpAddress, unsigned int senderPort)
 
void ReceiveData (unsigned char bufferSize, Participant *remoteParticipant)
 
ThingGet (unsigned char networkId, unsigned char thingId)
 Find a thing managed by this participant.
 
void Add (Thing *thing, bool checkId=true)
 Add a new thing for this participant.
 
void Remove (Thing *thing)
 Remove a thing for this participant.
 

Static Public Member Functions

static LocalParticipantIsolated ()
 Isolated participant is used when the application is run without networking.
 

Public Attributes

bool isIsolated = false
 True if the participant is running isolated. Isolated participants do not communicate with other participants.
 
long publishInterval = 3000
 
const char * name = "LocalParticipant"
 The name of the participant.
 
ParticipantremoteSite = nullptr
 The remote site when this participant is connected to a site.
 
int sock
 
sockaddr_in remote_addr
 
sockaddr_in server_addr
 
sockaddr_in broadcast_addr
 
bool connected = false
 
unsigned char senderCount = 0
 
Participantsenders [MAX_SENDER_COUNT]
 
std::list< Participant * > senders
 
const char * ipAddress = "0.0.0.0"
 The Ip Address of a participant. When the participant is local, this contains 0.0.0.0.
 
int port = 0
 The port number for UDP communication with the participant. This is 0 for isolated participants.
 
unsigned char networkId = 0
 The network Id to identify the participant.
 

Protected Types

using ThingConstructor = std::function< Thing *(Participant *participant, unsigned char networkId, unsigned char thingId)>
 

Protected Member Functions

virtual void Process (Participant *sender, ParticipantMsg *msg) override
 
virtual void Process (Participant *sender, SiteMsg *msg) override
 
virtual void Process (Participant *sender, ThingMsg *msg) override
 
void SetupUDP (int localPort, const char *remoteIpAddress, int remotePort)
 
ParticipantGetParticipant (const char *ipAddress, int port)
 
ParticipantAddParticipant (const char *ipAddress, int port)
 
void ReceiveUDP ()
 
virtual void Process (Participant *sender, InvestigateMsg *msg)
 
virtual void Process (Participant *sender, NameMsg *msg)
 
virtual void Process (Participant *sender, PoseMsg *msg)
 
virtual void Process (Participant *sender, BinaryMsg *msg)
 

Protected Attributes

unsigned long nextPublishMe = 0
 
std::unordered_map< unsigned char, ThingConstructor > thingMsgProcessors
 
char buffer [1024]
 
unsigned char thingCount = 0
 
Thingthings [MAX_THING_COUNT]
 
std::list< Thing * > things
 The list of things managed by this participant.
 

Member Function Documentation

◆ Process() [1/3]

void RoboidControl::SiteServer::Process ( Participant sender,
ParticipantMsg msg 
)
overrideprotectedvirtual

Reimplemented from RoboidControl::LocalParticipant.

◆ Process() [2/3]

void RoboidControl::SiteServer::Process ( Participant sender,
SiteMsg msg 
)
overrideprotectedvirtual

Reimplemented from RoboidControl::LocalParticipant.

◆ Process() [3/3]

void RoboidControl::SiteServer::Process ( Participant sender,
ThingMsg msg 
)
overrideprotectedvirtual

Reimplemented from RoboidControl::LocalParticipant.

◆ Isolated()

LocalParticipant * RoboidControl::LocalParticipant::Isolated ( )
staticinherited

Isolated participant is used when the application is run without networking.

Returns
A participant without networking support

◆ Get()

Thing * RoboidControl::Participant::Get ( unsigned char  networkId,
unsigned char  thingId 
)
inherited

Find a thing managed by this participant.

Parameters
networkIdThe network ID for the thing
thingIdThe ID of the thing
Returns
The thing if found or nullptr when no thing has been found
Note
The use of the network ID is likely to disappear in future versions.

◆ Add()

void RoboidControl::Participant::Add ( Thing thing,
bool  checkId = true 
)
inherited

Add a new thing for this participant.

Parameters
thingThe thing to add
checkIdChecks the thing ID of the thing. If it is 0, a new thing Id will be assigned.

◆ Remove()

void RoboidControl::Participant::Remove ( Thing thing)
inherited

Remove a thing for this participant.

Parameters
thingThe thing to remove

Member Data Documentation

◆ publishInterval

long RoboidControl::LocalParticipant::publishInterval = 3000
inherited

The interval in milliseconds for publishing (broadcasting) data on the local network

◆ networkId

unsigned char RoboidControl::Participant::networkId = 0
inherited

The network Id to identify the participant.

Note
This field is likely to disappear in future versions