iCub-main
Loading...
Searching...
No Matches
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
30using namespace std;
31
32#include "downloader.h"
33
34
36{
37public:
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 {
48 unsigned char txrate; // in ms
50 const string& get_networkstring() const {
51 static const string nets[] = {"ETH", "socketcan", "ecan"}; return nets[static_cast<unsigned char>(network)];
52 }
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) {}
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
70public:
71
73
74private:
75
76 bool opened;
77 Config config;
78
79};
80
81#endif // include-guard
82
83// marco.accame: end
@ everyCANbus
Definition driver.h:51
bool get(const unsigned int number, vector< cDownloader::strain_value_t > &values)
bool print(const vector< cDownloader::strain_value_t > &values, FILE *fp=NULL)
cDownloader downloader
bool open(const Config &cfg=Config())
static struct bpf_program fp
const string & get_networkstring() const