Skip to content

Commit

Permalink
plugins/swiotrefactor: Created a new plugin for swiot refactoring pro…
Browse files Browse the repository at this point in the history
…cess.

In this way i will not affect the functionality of the swiot plugin and
I will be able to notice the differences (between old and new plugin)
more easily.
This commit already includes some changes for the max14906 instrument.

Signed-off-by: andrei.danila <[email protected]>
  • Loading branch information
andreidanila1 committed Mar 22, 2024
1 parent 34bb297 commit b4e7e2b
Show file tree
Hide file tree
Showing 59 changed files with 10,780 additions and 0 deletions.
7 changes: 7 additions & 0 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ option(ENABLE_PLUGIN_DATALOGGER "Enable datalogger plugin" OFF)
option(ENABLE_PLUGIN_ADC "Enable ADC plugin" ON)
option(ENABLE_PLUGIN_PQM "Enable PQM plugin" ON)

option(ENABLE_PLUGIN_SWIOTREFACTOR "Enable SWIOTREFACTOR plugin" ON)

if(ENABLE_PLUGIN_TEST)
add_subdirectory(guitestplugin)
list(APPEND PLUGINS ${PLUGIN_NAME})
Expand All @@ -34,6 +36,11 @@ if(ENABLE_PLUGIN_SWIOT)
list(APPEND PLUGINS ${PLUGIN_NAME})
endif()

if(ENABLE_PLUGIN_SWIOTREFACTOR)
add_subdirectory(swiotrefactor)
list(APPEND PLUGINS ${PLUGIN_NAME})
endif()

if(ENABLE_PLUGIN_PQM)
add_subdirectory(pqm)
list(APPEND PLUGINS ${PLUGIN_NAME})
Expand Down
103 changes: 103 additions & 0 deletions plugins/swiotrefactor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
cmake_minimum_required(VERSION 3.9)

set(SCOPY_MODULE swiotrefactor)

message(STATUS "building plugin: " ${SCOPY_MODULE})

project(scopy-${SCOPY_MODULE} VERSION 0.1 LANGUAGES CXX)

include(GenerateExportHeader)

# TODO: split stylesheet/resources and add here TODO: export header files correctly

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_AUTOUIC_SEARCH_PATHS ${CMAKE_CURRENT_SOURCE_DIR}/ui)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

message(CMAKE_AUTOUIC_SEARCH_PATHS="${CMAKE_AUTOUIC_SEARCH_PATHS}")

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN TRUE)

set(SCOPY_QT_COMPONENTS Widgets Concurrent Svg Xml)

file(
GLOB
SRC_LIST
# some of these will eventually be moved to the core/gui directories
src/max14906/*.cpp
src/max14906/*.cc
src/*.cpp
src/*.cc
model/*
)

file(
GLOB
HEADER_LIST
include/${SCOPY_MODULE}/*.h
include/${SCOPY_MODULE}/*.hpp
include/${SCOPY_MODULE}/max14906/*.h
include/${SCOPY_MODULE}/max14906/*.hpp
)
file(GLOB UI_LIST ui/*.ui)

if(ENABLE_TESTING)
add_subdirectory(test)
endif()

message(UI_LIST= "${UI_LIST}")

set(PROJECT_SOURCES ${SRC_LIST} ${HEADER_LIST} ${UI_LIST})

find_package(Qt${QT_VERSION_MAJOR} COMPONENTS ${SCOPY_QT_COMPONENTS} REQUIRED)

if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${SCOPY_PLUGIN_BUILD_PATH})
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/Scopy.app/Contents/MacOS/plugins/plugins")
else()
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${SCOPY_PLUGIN_BUILD_PATH})
endif()

if(ANDROID)
find_library(QWT_LIBRARIES REQUIRED NAMES qwt_${ANDROID_ABI})
else()
find_library(QWT_LIBRARIES REQUIRED NAMES qwt)
endif()

qt_add_resources(PROJECT_RESOURCES res/resources.qrc ../../resources/resources.qrc)

add_library(${PROJECT_NAME} SHARED ${PROJECT_SOURCES} ${PROJECT_RESOURCES})

generate_export_header(
${PROJECT_NAME} EXPORT_FILE_NAME ${CMAKE_CURRENT_SOURCE_DIR}/include/${SCOPY_MODULE}/${PROJECT_NAME}_export.h
)

target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/${SCOPY_MODULE})

include_directories(${Qt${QT_VERSION_MAJOR}Concurrent_INCLUDE_DIRS})

foreach(comp ${SCOPY_QT_COMPONENTS})
set(SCOPY_QT_LIBRARIES ${SCOPY_QT_LIBRARIES} Qt${QT_VERSION_MAJOR}::${comp})
endforeach()

target_link_libraries(
${PROJECT_NAME}
PUBLIC ${SCOPY_QT_LIBRARIES}
scopy-pluginbase
scopy-iioutil
scopy-gui
scopy-core
scopy-iio-widgets
${QWT_LIBRARIES}
)

set(PLUGIN_NAME ${PROJECT_NAME} PARENT_SCOPE)
16 changes: 16 additions & 0 deletions plugins/swiotrefactor/include/swiotrefactor/faults.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef FAULTS_H
#define FAULTS_H

#include "scopy-swiotrefactor_export.h"
#include <QWidget>

namespace scopy::swiotrefactor {
class SCOPY_SWIOTREFACTOR_EXPORT Faults : public QWidget
{
Q_OBJECT
public:
Faults(QWidget *parent = nullptr);
~Faults();
};
} // namespace scopy::swiotrefactor
#endif // FAULTS_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2023 Analog Devices Inc.
*
* This file is part of Scopy
* (see https://www.github.com/analogdevicesinc/scopy).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#ifndef SCOPY_DIOCONTROLLER_H
#define SCOPY_DIOCONTROLLER_H

#include <iio.h>
#include "scopy-swiotrefactor_export.h"
#include <QString>
#include <QThread>
#include <QTimer>

#include <utility>

namespace scopy::swiotrefactor {
class SCOPY_SWIOTREFACTOR_EXPORT DioController : public QObject
{
Q_OBJECT
public:
explicit DioController(struct iio_context *context_, QString deviceName = "max14906");
~DioController() override;

int getChannelCount();

iio_device *getDevice() const;

QString getChannelName(unsigned int index);
QString getChannelType(unsigned int index);

private:
QString m_deviceName;
struct iio_context *m_context;
struct iio_device *m_device;
};
} // namespace scopy::swiotrefactor

#endif // SCOPY_DIOCONTROLLER_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2023 Analog Devices Inc.
*
* This file is part of Scopy
* (see https://www.github.com/analogdevicesinc/scopy).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#ifndef SCOPY_DIODIGITALCHANNEL_H
#define SCOPY_DIODIGITALCHANNEL_H

#include "ui_diodigitalchannel.h"
#include "scopy-swiotrefactor_export.h"
#include <QDockWidget>
#include <QWidget>
#include <gui/generic_menu.hpp>

namespace scopy::swiotrefactor {
class SCOPY_SWIOTREFACTOR_EXPORT DioDigitalChannel : public QWidget
{
Q_OBJECT
public:
explicit DioDigitalChannel(const QString &deviceName, const QString &deviceType, QWidget *parent = nullptr);
~DioDigitalChannel() override;

void updateTimeScale(double newMax);
void addDataSample(double value);
const std::vector<std::string> getConfigModes() const;
void setConfigModes(std::vector<std::string> &configModes);
const QString &getSelectedConfigMode() const;
void setSelectedConfigMode(const QString &selectedConfigMode);
void resetSismograph();

private:
void connectSignalsAndSlots();

Ui::DioDigitalChannel *ui;
QString m_deviceName;
QString m_deviceType;

std::vector<std::string> m_configModes;
QString m_selectedConfigMode;

friend class DioDigitalChannelController;

Q_SIGNALS:
void outputValueChanged(bool value);
};
} // namespace scopy::swiotrefactor

#endif // SCOPY_DIODIGITALCHANNEL_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright (c) 2023 Analog Devices Inc.
*
* This file is part of Scopy
* (see https://www.github.com/analogdevicesinc/scopy).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#ifndef SCOPY_DIODIGITALCHANNELCONTROLLER_H
#define SCOPY_DIODIGITALCHANNELCONTROLLER_H

#include "diodigitalchannel.h"
#include "scopy-swiotrefactor_export.h"
#include <iio.h>

#include <iioutil/commandqueue.h>
#include <string>

#define ATTR_BUFFER_LEN 200

namespace scopy::swiotrefactor {
class SCOPY_SWIOTREFACTOR_EXPORT DioDigitalChannelController : public QWidget
{
Q_OBJECT
public:
explicit DioDigitalChannelController(struct iio_channel *channel, const QString &deviceName,
const QString &deviceType, CommandQueue *cmdQueue, QWidget *parent);
~DioDigitalChannelController() override;

DioDigitalChannel *getDigitalChannel() const;
private Q_SLOTS:
void createWriteCurrentLimitCommand(int index);
void createWriteRawCommand(bool value);
void createWriteTypeCommand(int index);

private:
DioDigitalChannel *m_digitalChannel;

QString m_channelName;
QString m_channelType; // output or input

std::string m_iioAttrAvailableTypes; // iio attribute
std::vector<std::string> m_availableTypes;

std::string m_iioAttrType; // iio attribute
std::string m_type;

CommandQueue *m_cmdQueue;

struct iio_channel *m_channel;
};

} // namespace scopy::swiotrefactor

#endif // SCOPY_DIODIGITALCHANNELCONTROLLER_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2023 Analog Devices Inc.
*
* This file is part of Scopy
* (see https://www.github.com/analogdevicesinc/scopy).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#ifndef DIOSETTINGSTAB_H
#define DIOSETTINGSTAB_H

#include "scopy-swiotrefactor_export.h"
#include <QWidget>

#include <gui/spinbox_a.hpp>

namespace scopy::swiotrefactor {
class SCOPY_SWIOTREFACTOR_EXPORT DioSettingsTab : public QWidget
{
Q_OBJECT
public:
explicit DioSettingsTab(QWidget *parent = nullptr);

~DioSettingsTab();

double getTimeValue() const;

Q_SIGNALS:

void timeValueChanged(double value);

private:
PositionSpinButton *m_maxSpinButton;
};
} // namespace scopy::swiotrefactor
#endif // DIOSETTINGSTAB_H
Loading

0 comments on commit b4e7e2b

Please sign in to comment.