-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alexandru Lie <[email protected]>
- Loading branch information
Showing
11 changed files
with
200 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Time, xadc:voltage0, xadc:voltage1 | ||
19/08/2024 16:27:26, 1.01587, 1.7981 | ||
19/08/2024 16:27:27, 1.01587, 1.7981 | ||
19/08/2024 16:27:28, 1.01587, 1.7981 | ||
19/08/2024 16:27:29, 1.01587, 1.7981 | ||
19/08/2024 16:27:30, 1.01587, 1.7981 | ||
19/08/2024 16:27:31, 1.01587, 1.7981 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
#ifndef SCOPY_IIODEBUG_EXPORT_H | ||
#define SCOPY_IIODEBUG_EXPORT_H | ||
|
||
#ifdef SCOPY_IIODEBUG_STATIC_DEFINE | ||
#define SCOPY_IIODEBUG_EXPORT | ||
#define SCOPY_IIODEBUG_NO_EXPORT | ||
#else | ||
#ifndef SCOPY_IIODEBUG_EXPORT | ||
#ifdef scopy_iiodebug_EXPORTS | ||
/* We are building this library */ | ||
#define SCOPY_IIODEBUG_EXPORT __attribute__((visibility("default"))) | ||
#else | ||
/* We are using this library */ | ||
#define SCOPY_IIODEBUG_EXPORT __attribute__((visibility("default"))) | ||
#endif | ||
#endif | ||
|
||
#ifndef SCOPY_IIODEBUG_NO_EXPORT | ||
#define SCOPY_IIODEBUG_NO_EXPORT __attribute__((visibility("hidden"))) | ||
#endif | ||
#endif | ||
|
||
#ifndef SCOPY_IIODEBUG_DEPRECATED | ||
#define SCOPY_IIODEBUG_DEPRECATED __attribute__((__deprecated__)) | ||
#endif | ||
|
||
#ifndef SCOPY_IIODEBUG_DEPRECATED_EXPORT | ||
#define SCOPY_IIODEBUG_DEPRECATED_EXPORT SCOPY_IIODEBUG_EXPORT SCOPY_IIODEBUG_DEPRECATED | ||
#endif | ||
|
||
#ifndef SCOPY_IIODEBUG_DEPRECATED_NO_EXPORT | ||
#define SCOPY_IIODEBUG_DEPRECATED_NO_EXPORT SCOPY_IIODEBUG_NO_EXPORT SCOPY_IIODEBUG_DEPRECATED | ||
#endif | ||
|
||
#if 0 /* DEFINE_NO_DEPRECATED */ | ||
#ifndef SCOPY_IIODEBUG_NO_DEPRECATED | ||
#define SCOPY_IIODEBUG_NO_DEPRECATED | ||
#endif | ||
#endif | ||
|
||
#endif /* SCOPY_IIODEBUG_EXPORT_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#include "regmap_api.h" | ||
|
||
using namespace scopy::regmap; | ||
|
||
Q_LOGGING_CATEGORY(CAT_REGMAP_API, "RegMap_API") | ||
|
||
RegMap_API::RegMap_API(RegmapPlugin *regMapPlugin) | ||
: ApiObject() | ||
, m_regMapPlugin(regMapPlugin) | ||
{} | ||
|
||
RegMap_API::~RegMap_API() {} | ||
|
||
void RegMap_API::write(QString addr, QString val) | ||
{ | ||
DeviceRegisterMap *devRegMap = getActiveDevRegMap(); | ||
Q_EMIT devRegMap->registerMapValues->requestWrite(addr.toUInt(nullptr, 16), val.toUInt(nullptr, 16)); | ||
} | ||
|
||
QStringList RegMap_API::getAvailableDevicesName() | ||
{ | ||
QStringList devicesName; | ||
if(m_regMapPlugin->m_deviceList->size() != 0) { | ||
for(const auto &dev : *(m_regMapPlugin->m_deviceList)) { | ||
devicesName.append(iio_device_get_name(dev)); | ||
} | ||
} else { | ||
qWarning(CAT_REGMAP_API) << "No devices available"; | ||
} | ||
return devicesName; | ||
} | ||
|
||
bool RegMap_API::setDevice(QString device) | ||
{ | ||
m_regMapPlugin->registerMapTool->updateActiveRegisterMap(device); | ||
QString currentRegMap = m_regMapPlugin->registerMapTool->activeRegisterMap; | ||
if(currentRegMap == device) { | ||
return true; | ||
} | ||
qWarning(CAT_REGMAP_API) << "Device " << device << " was not set"; | ||
return false; | ||
} | ||
|
||
QStringList RegMap_API::search(QString searchParam) | ||
{ | ||
QList<uint32_t> resultIndexes; | ||
DeviceRegisterMap *devRegMap = getActiveDevRegMap(); | ||
resultIndexes = Search::searchForRegisters(devRegMap->registerMapTemplate->getRegisterList(), searchParam); | ||
|
||
QStringList resultList; | ||
for(int i = 0; i < resultIndexes.size(); i++) { | ||
RegisterModel *model = devRegMap->registerMapTemplate->getRegisterTemplate(resultIndexes[i]); | ||
resultList.append(model->getName()); | ||
} | ||
return resultList; | ||
} | ||
|
||
QStringList RegMap_API::readInterval(QString startAddr, QString stopAddr) | ||
{ | ||
DeviceRegisterMap *devRegMap = getActiveDevRegMap(); | ||
uint32_t start = startAddr.toUInt(nullptr, 16); | ||
uint32_t stop = stopAddr.toUInt(nullptr, 16); | ||
QStringList readValues; | ||
for(int i = start; i < stop; i++) { | ||
Q_EMIT readValues.append(devRegMap->registerMapValues->requestRead(i)); | ||
} | ||
} | ||
|
||
bool RegMap_API::enableAutoread(bool enable) | ||
{ | ||
DeviceRegisterMap *devRegMap = getActiveDevRegMap(); | ||
devRegMap->toggleAutoread(enable); | ||
if(devRegMap->getAutoread() == enable) { | ||
return true; | ||
} | ||
qWarning(CAT_REGMAP_API) << "Autoread was not changed to " << enable; | ||
return false; | ||
} | ||
|
||
bool RegMap_API::isAutoreadEnabled() | ||
{ | ||
DeviceRegisterMap *devRegMap = getActiveDevRegMap(); | ||
return devRegMap->getAutoread(); | ||
} | ||
|
||
DeviceRegisterMap *RegMap_API::getActiveDevRegMap() | ||
{ | ||
return m_regMapPlugin->registerMapTool->deviceList->value(m_regMapPlugin->registerMapTool->activeRegisterMap); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#ifndef REGMAP_API_H | ||
#define REGMAP_API_H | ||
|
||
#include "scopy-regmap_export.h" | ||
|
||
#include <regmapplugin.h> | ||
#include <deviceregistermap.hpp> | ||
#include <registermaptool.hpp> | ||
#include <register/registermodel.hpp> | ||
#include <registermapvalues.hpp> | ||
#include "search.hpp" | ||
|
||
namespace scopy::regmap { | ||
|
||
class SCOPY_REGMAP_EXPORT RegMap_API : public ApiObject | ||
{ | ||
|
||
Q_OBJECT | ||
|
||
public: | ||
explicit RegMap_API(RegmapPlugin *regMapPlugin); | ||
~RegMap_API(); | ||
|
||
Q_INVOKABLE void write(QString addr, QString val); | ||
Q_INVOKABLE QStringList getAvailableDevicesName(); | ||
Q_INVOKABLE bool setDevice(QString device); | ||
Q_INVOKABLE QStringList search(QString searchParam); | ||
Q_INVOKABLE QStringList readInterval(QString startAddr, QString stopAddr); | ||
Q_INVOKABLE bool enableAutoread(bool enable); | ||
Q_INVOKABLE bool isAutoreadEnabled(); | ||
Q_INVOKABLE void registerDump(QString filePath); | ||
Q_INVOKABLE void writeFromFile(QString filePath); | ||
|
||
private: | ||
RegmapPlugin *m_regMapPlugin; | ||
DeviceRegisterMap *getActiveDevRegMap(); | ||
}; | ||
} // namespace scopy::regmap | ||
#endif // REGMAP_API_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters