MIRA
CANMessageViewerPlugin.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 MetraLabs GmbH (MLAB), GERMANY.
3  * All rights reserved.
4  * Contact: info@MetraLabs.com
5  *
6  * Commercial Usage:
7  * Licensees holding valid commercial licenses may use this file in
8  * accordance with the commercial license agreement provided with the
9  * software or, alternatively, in accordance with the terms contained in
10  * a written agreement between you and MetraLabs.
11  *
12  * GNU General Public License Usage:
13  * Alternatively, this file may be used under the terms of the GNU
14  * General Public License version 3.0 as published by the Free Software
15  * Foundation and appearing in the file LICENSE.GPL3 included in the
16  * packaging of this file. Please review the following information to
17  * ensure the GNU General Public License version 3.0 requirements will be
18  * met: http://www.gnu.org/copyleft/gpl.html.
19  * Alternatively you may (at your option) use any later version of the GNU
20  * General Public License if such license has been publicly approved by
21  * MetraLabs (or its successors, if any).
22  *
23  * IN NO EVENT SHALL "MLAB" BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
24  * SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE
25  * OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF "MLABS" HAS BEEN
26  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * "MLAB" SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
29  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30  * A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
31  * "AS IS" BASIS, AND "MLAB" HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
32  * SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS.
33  */
34 
43 #ifndef _MLAB_CANMESSAGEVIEWERPLUGIN_H_
44 #define _MLAB_CANMESSAGEVIEWERPLUGIN_H_
45 
46 #ifndef Q_MOC_RUN
47 #include <boost/thread/mutex.hpp>
48 #endif
49 
50 #include <QTableWidget>
51 
52 #include <gui/views/CANToolsView.h>
54 
55 namespace mira { namespace can {
56 
58 
63 {
64  Q_OBJECT;
65  MIRA_META_OBJECT(CANMessageViewerPlugin,
66  ("Name", "CAN message viewer")
67  ("Category", "CAN")
68  ("Description", "Lists all received can messages and displays info")
69  ("Title", "Messages"));
70 public:
72 
73 public slots:
74 
75  void removeRow();
76  void showContextMenu(const QPoint& pos);
77  void updateWidget();
78 
79 protected:
80 
81  virtual void initialize();
82  void onCanMessage(const can::CANMessage& message, const Time& timestamp);
83  void addRow(const QString& pdo);
84  void createCombo(int row);
85 
86 protected:
87 
89  boost::mutex mUpdateMutex;
90  QTableWidget* mPDOTable;
91  QTableWidget* mPDOReadTable;
92  QTimer *mUpdateTimer;
93 
94  struct QueueEntry
95  {
98  };
99  QList<QueueEntry> mCANMessageQueue;
100 
101  struct MessageInfo
102  {
103  MessageInfo(const Time& t = Time::now()) :
104  count(1),
105  last(t),
106  minInterval(std::numeric_limits<uint32>::max()),
107  maxInterval(0) {}
108  uint32 count;
110  uint32 minInterval;
111  uint32 maxInterval;
112  };
113  std::map<uint32, MessageInfo> mPDOEntries;
114 
115  struct CANInfo
116  {
117  int start;
118  int length;
119  std::string description;
120  std::string ID;
121 
122  template <typename Reflector>
123  void reflect(Reflector& r)
124  {
125  r.member("Start", start, "");
126  r.member("ID", ID, "");
127  r.member("Length", length, "");
128  r.member("Description", description, "");
129  }
130  };
131 };
132 
134 
135 }} // namespaces
136 
137 #endif /* CANMESSAGEVIEWERPLUGIN_H_ */
void showContextMenu(const QPoint &pos)
void reflect(Reflector &r)
Definition: CANMessageViewerPlugin.h:123
virtual void initialize()
This method must be implemented for each CAN tool.
Definition: CANMessageViewerPlugin.h:115
Definition: CANMessageViewerPlugin.h:94
Time last
Definition: CANMessageViewerPlugin.h:109
The base class for all CAN tools.
Definition: CANToolsViewPlugin.h:61
A view for CAN tools.
QList< QueueEntry > mCANMessageQueue
Definition: CANMessageViewerPlugin.h:99
boost::mutex mUpdateMutex
Definition: CANMessageViewerPlugin.h:89
void addRow(const QString &pdo)
STL namespace.
std::string ID
Definition: CANMessageViewerPlugin.h:120
std::string description
Definition: CANMessageViewerPlugin.h:119
void onCanMessage(const can::CANMessage &message, const Time &timestamp)
uint32 minInterval
Definition: CANMessageViewerPlugin.h:110
MessageInfo(const Time &t=Time::now())
Definition: CANMessageViewerPlugin.h:103
QTableWidget * mPDOTable
Definition: CANMessageViewerPlugin.h:90
Time timestamp
Definition: CANMessageViewerPlugin.h:97
uint32 messageRecvListenerId
Definition: CANMessageViewerPlugin.h:88
static Time now() static Time eternity()
QTimer * mUpdateTimer
Definition: CANMessageViewerPlugin.h:92
Definition: CANMessageViewerPlugin.h:101
QTableWidget * mPDOReadTable
Definition: CANMessageViewerPlugin.h:91
A definition of a CAN message.
Definition: CANDefs.h:105
std::map< uint32, MessageInfo > mPDOEntries
Definition: CANMessageViewerPlugin.h:113
can::CANMessage message
Definition: CANMessageViewerPlugin.h:96
int length
Definition: CANMessageViewerPlugin.h:118
The base class for CAN tools.
uint32 maxInterval
Definition: CANMessageViewerPlugin.h:111
int start
Definition: CANMessageViewerPlugin.h:117
CAN message viewer plugin that displays info about CAN messages.
Definition: CANMessageViewerPlugin.h:62
uint32 count
Definition: CANMessageViewerPlugin.h:108