iCub-main
embObjMais.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 #ifndef __embObjMais_h__
5 #define __embObjMais_h__
6 
7 #include <yarp/dev/DeviceDriver.h>
8 #include <yarp/os/PeriodicThread.h>
9 #include <yarp/dev/MultipleAnalogSensorsInterfaces.h>
10 #include <string>
11 #include <list>
12 #include <mutex>
13 
14 #include <iCub/FactoryInterface.h>
15 #include <iCub/LoggerInterfaces.h>
16 
17 
18 #include "IethResource.h"
19 #include <ethManager.h>
20 #include <abstractEthResource.h>
21 
22 
23 #include <yarp/os/LogStream.h>
24 
25 #include "serviceParser.h"
26 
27 namespace yarp {
28  namespace dev {
29  class embObjMais;
30  }
31 }
32 
33 
34 #define EMBOBJMAIS_USESERVICEPARSER
35 
36 
37 // -- class embObjMais
38 
39 class yarp::dev::embObjMais: public yarp::dev::DeviceDriver,
40  public eth::IethResource,
41  public yarp::dev::IEncoderArrays
42 {
43 
44 public:
45 
46  enum { mais_Channels = 15, mais_FormatData = 8 };
47 
48 public:
49 
50  embObjMais();
51  ~embObjMais();
52 
53  // An open function yarp factory compatible
54  bool open(yarp::os::Searchable &config);
55  bool close();
56 
57  // IEncoderArrays interface
58  virtual size_t getNrOfEncoderArrays() const override;
59  virtual yarp::dev::MAS_status getEncoderArrayStatus(size_t sens_index) const override;
60  virtual bool getEncoderArrayName(size_t sens_index, std::string &name) const override;
61  virtual bool getEncoderArrayMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
62  virtual size_t getEncoderArraySize(size_t sens_index) const override;
63 
64  // IethResource interface
65  virtual bool initialised();
66  virtual eth::iethresType_t type();
67  virtual bool update(eOprotID32_t id32, double timestamp, void* rxdata);
68 
69 private:
70 
71  string boardIPstring;
72  string boardName;
73  eOipv4addr_t ipv4addr;
74 
75  eth::TheEthManager* ethManager;
77  ServiceParser* parser;
78 
79  bool opened;
80  bool verbosewhenok;
81 
82  unsigned int counterSat;
83  unsigned int counterError;
84  unsigned int counterTimeout;
85 
87  // parameters
88  servConfigMais_t serviceConfig;
89 
90  std::mutex mtx;
91 
92  yarp::sig::Vector analogdata;
93 
94  short status;
95  double timeStamp;
96 
97 private:
98 
99  // for all
100  bool extractGroup(Bottle &input, Bottle &out, const std::string &key1, const std::string &txt, int size);
101  bool fromConfig(yarp::os::Searchable &config);
102  bool initRegulars();
103  void cleanup(void);
104  void printServiceConfig(void);
105 
106  // for mais
107  bool sendConfig2Mais(void);
108 
109 
110  // for ??
111  void resetCounters();
112  void getCounters(unsigned int &saturations, unsigned int &errors, unsigned int &timeouts);
113 };
114 
115 
116 #endif
117 
Interface for a factory device; a device that can create objects.
virtual bool initialised()
Definition: embObjMais.cpp:168
virtual bool getEncoderArrayMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Definition: embObjMais.cpp:459
virtual bool getEncoderArrayName(size_t sens_index, std::string &name) const override
Definition: embObjMais.cpp:453
virtual bool update(eOprotID32_t id32, double timestamp, void *rxdata)
Definition: embObjMais.cpp:479
virtual size_t getNrOfEncoderArrays() const override
Definition: embObjMais.cpp:444
bool open(yarp::os::Searchable &config)
Definition: embObjMais.cpp:176
virtual yarp::dev::MAS_status getEncoderArrayStatus(size_t sens_index) const override
Definition: embObjMais.cpp:448
virtual eth::iethresType_t type()
Definition: embObjMais.cpp:473
virtual size_t getEncoderArraySize(size_t sens_index) const override
Definition: embObjMais.cpp:467
iethresType_t
Definition: IethResource.h:62
Copyright (C) 2008 RobotCub Consortium.
out
Definition: sine.m:8