dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
iboardtype.cpp
Go to the documentation of this file.
1 #include "iboardtype.h"
3 
4 #include <QSet>
5 
6 namespace Core {
7 
14 {
15  QStringList banksStringList = QStringList();
16 
17  foreach (QVector<qint32> channelBank, getChannelBanks()) {
18  bool sequential = false;
19  QString banksString;
20 
21  for (int i = 0; i < channelBank.size(); ++i) {
22  if (i == 0) { // First channel in bank
23  banksString.append(QString("%1").arg(channelBank[i]));
24 
25  if (channelBank.size() > 1) { // If more than 1 channel in bank, add separator
26  if ((channelBank[i] + 1) == channelBank[i + 1]) {
27  banksString.append(
28  QString("-")); // Next channel is sequential, add '-' to the string
29  sequential = true;
30  } else {
31  banksString.append(
32  QString(",")); // Next channel is not sequential, add ',' to the string
33  sequential = false;
34  }
35  }
36  } else if (i == channelBank.size() - 1) // Last channel in bank
37  banksString.append(QString("%1").arg(channelBank[i]));
38  else { // Mid channel(s) in bank
39  if (sequential) {
40  if ((channelBank[i] + 1) == channelBank[i + 1]) { // Still sequential channels,
41  // nothing to add to string
42  sequential = true;
43  } else {
44  banksString.append(QString("%1,").arg(
45  channelBank[i])); // End of sequence, add channel and ',' to string
46  sequential = false;
47  }
48  } else {
49  banksString.append(QString("%1").arg(channelBank[i]));
50 
51  if ((channelBank[i] + 1) == channelBank[i + 1]) {
52  banksString.append(
53  QString("-")); // Next channel is sequential, add '-' to the string
54  sequential = true;
55  } else {
56  banksString.append(
57  QString(",")); // Next channel is not sequential, add ',' to the string
58  sequential = false;
59  }
60  }
61  }
62  }
63 
64  // If there are no elements in the bank, print a hyphen
65  if (banksString.isEmpty())
66  banksString.append("-");
67 
68  // Add string to list
69  banksStringList << banksString;
70  }
71 
72  return banksStringList;
73 }
74 
76 {
77  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
78  if (pm == NULL)
79  return "Unknown";
80 
81  QList<Core::IBoardType *> boards = pm->getObjects<Core::IBoardType>();
82  foreach (Core::IBoardType *board, boards) {
83  if (board->getBoardType() == (id >> 8))
84  return board->shortName();
85  }
86 
87  return "Unknown";
88 }
89 
91 {
92  QVector<QVector<int>> cb;
93 
94  cb = getChannelBanks();
95 
96  for (int i = 0; i < cb.count(); i++) {
97  foreach (const qint32 chan, cb.at(i)) {
98  if (chan == channel)
99  return i;
100  }
101  }
102 
103  return -1;
104 }
105 
107 {
108  QSet<int> vids;
109  for (const auto &info : qAsConst(m_firmwareUSBInfo))
110  vids.insert(info.vendorID);
111  for (const auto &info : qAsConst(m_bootloaderUSBInfo))
112  vids.insert(info.vendorID);
113  vids.remove(0);
114  return vids.toList();
115 }
116 
117 } // Core
QList< int > getVendorIDs()
Definition: iboardtype.cpp:106
QList< USBInfo > m_firmwareUSBInfo
Definition: iboardtype.h:280
virtual QVector< QVector< int > > getChannelBanks()
Get banks of output PWM channels banks on the board.
Definition: iboardtype.h:121
Core plugin system that manages the plugins, their life cycle and their registered objects...
Definition: pluginmanager.h:53
int getBankFromOutputChannel(int channel)
Definition: iboardtype.cpp:90
QList< USBInfo > m_bootloaderUSBInfo
Definition: iboardtype.h:281
for i
Definition: OPPlots.m:140
virtual QStringList queryChannelBanks()
Query number & names of output PWM channels banks on the board.
Definition: iboardtype.cpp:13
int getBoardType()
Get the board type number.
Definition: iboardtype.h:147
static QString getBoardNameFromID(int id)
Definition: iboardtype.cpp:75
virtual QString shortName()=0