iCub-main
Loading...
Searching...
No Matches
icub-main
src
tools
strainCalib
strainCalibLib
strainInterface.h
Go to the documentation of this file.
1
// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2
3
/*
4
* Copyright (C) 2017 iCub Facility - Istituto Italiano di Tecnologia
5
* Author: Marco Accame
6
* email: marco.accame@iit.it
7
* website: www.robotcub.org
8
* Permission is granted to copy, distribute, and/or modify this program
9
* under the terms of the GNU General Public License, version 2 or any
10
* later version published by the Free Software Foundation.
11
*
12
* A copy of the license can be found at
13
* http://www.robotcub.org/icub/license/gpl.txt
14
*
15
* This program is distributed in the hope that it will be useful, but
16
* WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
18
* Public License for more details
19
*/
20
21
// - include guard ----------------------------------------------------------------------------------------------------
22
23
#ifndef _STRAININTERFACE_H_
24
#define _STRAININTERFACE_H_
25
26
27
#include <stdio.h>
28
#include <vector>
29
30
using namespace
std;
31
32
#include "
downloader.h
"
33
34
35
class
strainInterface
36
{
37
public
:
38
39
enum class
Network
{
ETH
= 0,
socketcan
= 1,
ecan
= 2,
unknown
= 8 };
40
enum class
CanBus
{
zero
= 0,
one
= 1,
two
= 2,
all
=
CanPacket::everyCANbus
};
41
enum class
CanAddress
{
one
= 1,
two
= 2,
three
= 3,
four
= 4,
five
= 5,
six
= 6,
seven
= 7,
eigth
= 8,
42
nine
= 9,
ten
= 10,
eleven
= 11,
twelve
= 12,
thirteen
= 13,
fourteen
= 14 };
43
struct
Config
44
{
45
Network
network
;
46
CanBus
canbus
;
47
CanAddress
canaddress
;
48
unsigned
char
txrate
;
// in ms
49
Config
() {
load_default
(); }
50
const
string
&
get_networkstring
()
const
{
51
static
const
string
nets[] = {
"ETH"
,
"socketcan"
,
"ecan"
};
return
nets[
static_cast<
unsigned
char
>
(
network
)];
52
}
53
void
load_default
() {
network
=
Network::ETH
;
canbus
=
CanBus::two
;
canaddress
=
CanAddress::two
;
txrate
= 2; }
54
int
get_canaddress
()
const
{
return
static_cast<
int
>
(
canaddress
); }
55
int
get_canbus
()
const
{
return
static_cast<
int
>
(
canbus
); }
56
int
get_txrate
()
const
{
return
txrate
; }
57
};
58
59
60
strainInterface
() : opened(false) {}
61
~strainInterface
(){}
62
63
bool
open
(
const
Config &cfg = Config());
64
bool
close
();
65
66
bool
get
(
const
unsigned
int
number, vector<cDownloader::strain_value_t> &values);
67
68
bool
print
(
const
vector<cDownloader::strain_value_t> &values, FILE *
fp
= NULL);
69
70
public
:
71
72
cDownloader
downloader
;
73
74
private
:
75
76
bool
opened;
77
Config
config;
78
79
};
80
81
#endif
// include-guard
82
83
// marco.accame: end
CanPacket::everyCANbus
@ everyCANbus
Definition
driver.h:51
cDownloader
Definition
downloader.h:112
strainInterface
Definition
strainInterface.h:36
strainInterface::get
bool get(const unsigned int number, vector< cDownloader::strain_value_t > &values)
Definition
strainInterface.cpp:162
strainInterface::print
bool print(const vector< cDownloader::strain_value_t > &values, FILE *fp=NULL)
Definition
strainInterface.cpp:127
strainInterface::Network
Network
Definition
strainInterface.h:39
strainInterface::Network::ecan
@ ecan
strainInterface::Network::socketcan
@ socketcan
strainInterface::Network::unknown
@ unknown
strainInterface::Network::ETH
@ ETH
strainInterface::close
bool close()
Definition
strainInterface.cpp:116
strainInterface::downloader
cDownloader downloader
Definition
strainInterface.h:72
strainInterface::~strainInterface
~strainInterface()
Definition
strainInterface.h:61
strainInterface::open
bool open(const Config &cfg=Config())
Definition
strainInterface.cpp:52
strainInterface::strainInterface
strainInterface()
Definition
strainInterface.h:60
strainInterface::CanBus
CanBus
Definition
strainInterface.h:40
strainInterface::CanBus::all
@ all
strainInterface::CanBus::two
@ two
strainInterface::CanBus::zero
@ zero
strainInterface::CanBus::one
@ one
strainInterface::CanAddress
CanAddress
Definition
strainInterface.h:41
strainInterface::CanAddress::twelve
@ twelve
strainInterface::CanAddress::fourteen
@ fourteen
strainInterface::CanAddress::five
@ five
strainInterface::CanAddress::three
@ three
strainInterface::CanAddress::thirteen
@ thirteen
strainInterface::CanAddress::four
@ four
strainInterface::CanAddress::eleven
@ eleven
strainInterface::CanAddress::ten
@ ten
strainInterface::CanAddress::two
@ two
strainInterface::CanAddress::seven
@ seven
strainInterface::CanAddress::nine
@ nine
strainInterface::CanAddress::eigth
@ eigth
strainInterface::CanAddress::six
@ six
downloader.h
fp
static struct bpf_program fp
Definition
pcap_wrapper_linux.cpp:89
strainInterface::Config
Definition
strainInterface.h:44
strainInterface::Config::get_networkstring
const string & get_networkstring() const
Definition
strainInterface.h:50
strainInterface::Config::get_canbus
int get_canbus() const
Definition
strainInterface.h:55
strainInterface::Config::canbus
CanBus canbus
Definition
strainInterface.h:46
strainInterface::Config::load_default
void load_default()
Definition
strainInterface.h:53
strainInterface::Config::get_txrate
int get_txrate() const
Definition
strainInterface.h:56
strainInterface::Config::network
Network network
Definition
strainInterface.h:45
strainInterface::Config::canaddress
CanAddress canaddress
Definition
strainInterface.h:47
strainInterface::Config::get_canaddress
int get_canaddress() const
Definition
strainInterface.h:54
strainInterface::Config::txrate
unsigned char txrate
Definition
strainInterface.h:48
strainInterface::Config::Config
Config()
Definition
strainInterface.h:49
Generated on Wed Dec 18 2024 16:34:49 for iCub-main by
1.9.8