automotive-message-broker  0.14.803
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
cansimplugin.h
1 /*
2 Copyright (C) 2012 Intel Corporation
3 
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8 
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13 
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #ifndef _CANSIMPLUGINIMPL_H_
20 #define _CANSIMPLUGINIMPL_H_
21 
22 #include <map>
23 #include <memory>
24 #include <tgmath.h>
25 
26 #include <canbus.h>
27 #include <canobserver.h>
28 
29 #include "ambpluginimpl.h"
30 
67 class CANSimPlugin : public AmbPluginImpl, public CANObserver {
68 
69 public:
75  CANSimPlugin(AbstractRoutingEngine* re, const std::map<std::string, std::string>& config, AbstractSource& parent);
76  virtual ~CANSimPlugin(); // has to be virtual because of unit tests
77 
78  // from AbstractSink
79 public:
80 
84  const std::string uuid() const { return "3f43e231-11ec-4782-9b5a-3dbcc5221eeb"; }
85 
89  void supportedChanged(const PropertyList& supportedProperties);
90 
95  int supportedOperations() const;
96 
97  // from CANObserver
98 public:
104  virtual void errorOccured(CANObserver::CANError error);/* socket error */
110  virtual void standardFrameReceived(const can_frame& frame);/* SFF was present */
116  virtual void extendedFrameReceived(const can_frame& frame);/* EFF was present */
122  virtual void errorFrameReceived(const can_frame& frame);/* error frame */
128  virtual void remoteTransmissionRequest(const can_frame& frame);/* remote transmission request (SFF/EFF is still present)*/
134  virtual void timeoutDetected(const can_frame& frame);
135 
140  virtual void init();
141 
142 private:
143 
150  void printFrame(const can_frame& frame) const;
151 
158  void createMappingTable(const PropertyList& supported);
159 
160 //
161 // data:
162 //
163 
169  std::map< canid_t, std::tuple<std::string, VehicleProperty::Property, Zone::Type> > mappingTable;
170 
176  std::map<std::string, std::shared_ptr<CANBus> > interfaces;
177 };
178 #endif // _CANSIMPLUGINIMPL_H_
179