iCub-main
icub-main
src
libraries
icubmod
embObjLib
IethResource.h
Go to the documentation of this file.
1
2
// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
3
4
/* Copyright (C) 2014 iCub Facility, Istituto Italiano di Tecnologia
5
* Author: Marco Accame
6
* email: marco.accame@iit.it
7
* Permission is granted to copy, distribute, and/or modify this program
8
* under the terms of the GNU General Public License, version 2 or any
9
* later version published by the Free Software Foundation.
10
*
11
* A copy of the license can be found at
12
* http://www.robotcub.org/icub/license/gpl.txt
13
*
14
* This program is distributed in the hope that it will be useful, but
15
* WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17
* Public License for more details
18
*/
19
20
//
21
// $Id: TheEthManager.h,v 1.5 2008/06/25 22:33:53 nat Exp $
22
//
23
//
24
25
#ifndef __IethResource__
26
#define __IethResource__
27
28
29
#include "EoProtocol.h"
30
31
32
// marco.accame on 20 oct 2014.
33
// the objects which use ethResource to communicate with the ethernet boards inside the robot
34
// must be derived from this class IethResource.
35
// these objects are: embObjMotionControl, embObjSkin, embObjAnalogSensor, and future ones.
36
// these object must implement the virtual functions initialised() and update() so that:
37
// - initialised() must return true only if the object is opened (its method open() has returned).
38
// - update() takes care of filling private data structures with bytes contained in the relevant ROPs coming from remote boards.
39
// as an example, see how the skin data is moved from ems board to embObjSkin.
40
// when a ROP containing a EOarray of skin data arrives, the callback eoprot_fun_UPDT_sk_skin_status_arrayof10canframes() is called.
41
// this function calls feat_manage_skin_data() and passes the boardnumber, the id32, and the pointer to the received EOarray.
42
// this function uses TheEthManager::getHandle() to retrieve a pointer to the relevant IethResource which matches (boardnumber, id32)
43
// the pointer is used directly or transformed with dynamic_cast to a pointer to embObjSkin and the function update() is called.
44
// needless to say, the update(0 function whcich is called is always the embObjSkin::update() which gets the EOarray and copies its
45
// items inside embObjSkin::data.
46
//
47
// warning: the caller of function embObjSkin::update() is the ethReceiver thread. if it writes something into embObjSkin::data,
48
// and the same embObjSkin::data is read by other threads via EmbObjSkin::read(), then ..... the two concurrent operations
49
// must be protected with a mutex.
50
// the rxdata passed from eoprot_fun_UPDT_sk_skin_status_arrayof10canframes() upto embObjSkin::update() does not need to be
51
// protected vs concurrent use because ... the only thread which writes into it is the caller of teh function: the ethReceiver thread
52
//
53
// the name of the class is IethResource because this class acts as an interface from ethResource which is the one which
54
// manages decoding of received UDP packets and calls the callbacks of the EOnv which in turn call IethResource::update().
55
//
56
57
58
namespace
eth
{
59
60
typedef
enum
61
{
62
iethres_none
= 255,
63
iethres_management
= 0,
64
iethres_analogmais
= 1,
65
iethres_analogstrain
= 2,
66
iethres_motioncontrol
= 3,
67
iethres_skin
= 4,
68
iethres_analogvirtual
= 5,
69
iethres_analoginertial
= 6,
70
iethres_analogmultienc
= 7,
71
iethres_analoginertial3
= 8,
72
iethres_temperature
= 9,
73
iethres_analogpsc
= 10,
74
iethres_analogpos
= 11,
75
iethres_analogft
= 12,
76
iethres_analogbattery
= 13
77
}
iethresType_t
;
78
79
enum
{
iethresType_numberof
= 14 };
80
81
82
class
IethResource
83
{
84
85
public
:
86
virtual
~IethResource
() {}
87
88
virtual
bool
initialised
() = 0;
89
virtual
bool
update
(eOprotID32_t id32,
double
timestamp,
void
*rxdata) = 0;
90
virtual
iethresType_t
type
() = 0;
91
92
public
:
93
const
char
*
stringOfType
();
94
95
private
:
96
static
const
char
* names[
iethresType_numberof
+1];
97
};
98
99
}
// namespace eth
100
101
#endif
102
103
// eof
104
eth::IethResource
Definition:
IethResource.h:83
eth::IethResource::type
virtual iethresType_t type()=0
eth::IethResource::~IethResource
virtual ~IethResource()
Definition:
IethResource.h:86
eth::IethResource::update
virtual bool update(eOprotID32_t id32, double timestamp, void *rxdata)=0
eth::IethResource::initialised
virtual bool initialised()=0
eth::IethResource::stringOfType
const char * stringOfType()
Definition:
IethResource.cpp:60
eth
Definition:
abstractEthResource.h:38
eth::iethresType_t
iethresType_t
Definition:
IethResource.h:61
eth::iethres_motioncontrol
@ iethres_motioncontrol
Definition:
IethResource.h:66
eth::iethres_analogmais
@ iethres_analogmais
Definition:
IethResource.h:64
eth::iethres_analoginertial3
@ iethres_analoginertial3
Definition:
IethResource.h:71
eth::iethres_analogpsc
@ iethres_analogpsc
Definition:
IethResource.h:73
eth::iethres_analoginertial
@ iethres_analoginertial
Definition:
IethResource.h:69
eth::iethres_analogft
@ iethres_analogft
Definition:
IethResource.h:75
eth::iethres_management
@ iethres_management
Definition:
IethResource.h:63
eth::iethres_analogmultienc
@ iethres_analogmultienc
Definition:
IethResource.h:70
eth::iethres_skin
@ iethres_skin
Definition:
IethResource.h:67
eth::iethres_analogbattery
@ iethres_analogbattery
Definition:
IethResource.h:76
eth::iethres_none
@ iethres_none
Definition:
IethResource.h:62
eth::iethres_analogpos
@ iethres_analogpos
Definition:
IethResource.h:74
eth::iethres_analogstrain
@ iethres_analogstrain
Definition:
IethResource.h:65
eth::iethres_temperature
@ iethres_temperature
Definition:
IethResource.h:72
eth::iethres_analogvirtual
@ iethres_analogvirtual
Definition:
IethResource.h:68
eth::iethresType_numberof
@ iethresType_numberof
Definition:
IethResource.h:79
Generated on Thu Mar 16 2023 14:39:21 for iCub-main by
1.9.1