mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-26 21:51:13 +01:00
server extensions
move gpio and visa extensions to extensions folder
This commit is contained in:
@@ -15,14 +15,10 @@ set_target_properties(
|
|||||||
LINK_FLAGS "-Wl,--export-dynamic"
|
LINK_FLAGS "-Wl,--export-dynamic"
|
||||||
)
|
)
|
||||||
|
|
||||||
file(GLOB_RECURSE CANSOURCES "CAN/*.[hc]pp")
|
file(GLOB_RECURSE EXTSOURCES "extensions/*.[hc]pp")
|
||||||
file(GLOB_RECURSE VISASOURCES "VISA/*.[hc]pp")
|
|
||||||
file(GLOB_RECURSE GPIOSOURCES "gpio/*.[hc]pp")
|
|
||||||
|
|
||||||
target_sources(unisim_server PRIVATE
|
target_sources(unisim_server PRIVATE
|
||||||
${CANSOURCES}
|
${EXTSOURCES}
|
||||||
${VISASOURCES}
|
|
||||||
${GPIOSOURCES}
|
|
||||||
main.cpp
|
main.cpp
|
||||||
message_parser.cpp
|
message_parser.cpp
|
||||||
simulator_base.cpp
|
simulator_base.cpp
|
||||||
@@ -41,9 +37,8 @@ target_include_directories(unisim_server
|
|||||||
PUBLIC
|
PUBLIC
|
||||||
${CMAKE_CURRENT_LIST_DIR}
|
${CMAKE_CURRENT_LIST_DIR}
|
||||||
${CMAKE_CURRENT_LIST_DIR}/simulators
|
${CMAKE_CURRENT_LIST_DIR}/simulators
|
||||||
${CMAKE_CURRENT_LIST_DIR}/CAN
|
${CMAKE_CURRENT_LIST_DIR}/extensions/CAN
|
||||||
${CMAKE_CURRENT_LIST_DIR}/VISA
|
${CMAKE_CURRENT_LIST_DIR}/extensions
|
||||||
${CMAKE_CURRENT_LIST_DIR}/gpio
|
|
||||||
PRIVATE
|
PRIVATE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
#include "tcp_client.hpp"
|
|
||||||
|
|
||||||
Tcp_client::Tcp_client() : QObject(0)
|
|
||||||
{
|
|
||||||
m_tcp_socket = new QTcpSocket(this);
|
|
||||||
|
|
||||||
connect(m_tcp_socket, &QTcpSocket::readyRead, this, [=, this] { ready_to_read(); });
|
|
||||||
connect(m_tcp_socket, &QTcpSocket::connected, this, [=, this] { emit connected(); });
|
|
||||||
connect(m_tcp_socket, &QTcpSocket::disconnected, this, [=, this] { emit disconnected(); });
|
|
||||||
}
|
|
||||||
|
|
||||||
void Tcp_client::tcp_connect(QString ip, quint16 port)
|
|
||||||
{
|
|
||||||
m_tcp_socket->connectToHost(ip, port);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Tcp_client::tcp_disconnect()
|
|
||||||
{
|
|
||||||
m_tcp_socket->disconnectFromHost();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Tcp_client::tcp_send(QString data)
|
|
||||||
{
|
|
||||||
m_tcp_socket->write((const char *)data.data());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Tcp_client::ready_to_read()
|
|
||||||
{
|
|
||||||
emit data_ready(m_tcp_socket->read(1024));
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
#ifndef TCPCLIENT_H
|
|
||||||
#define TCPCLIENT_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QTcpSocket>
|
|
||||||
|
|
||||||
#define QD qDebug() << "File:" << __FILE__ << "Function:" << __PRETTY_FUNCTION__ << "Line:" << __LINE__ << "=>"
|
|
||||||
|
|
||||||
class Tcp_client : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
Tcp_client();
|
|
||||||
void tcp_connect(QString ip, quint16 port);
|
|
||||||
void tcp_disconnect(void);
|
|
||||||
void tcp_send(QString data);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void data_ready(QString data);
|
|
||||||
void connected();
|
|
||||||
void disconnected();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void ready_to_read();
|
|
||||||
QTcpSocket *m_tcp_socket;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // TCPCLIENT_H
|
|
||||||
@@ -1,14 +1,15 @@
|
|||||||
#include "visa.hpp"
|
#include "visa.hpp"
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
#include <QTcpSocket>
|
||||||
|
|
||||||
Visa::Visa(QObject *parent)
|
Visa::Visa(QObject *parent)
|
||||||
: QObject(parent), m_tcp_socket(new QTcpSocket(this)), m_connected(false), m_reconnect(false)
|
: QObject(parent), m_tcp_socket(new QTcpSocket(this)), m_connected(false), m_reconnect(false)
|
||||||
{
|
{
|
||||||
QObject::connect(&m_client, &Tcp_client::connected, this, [=, this] {
|
QObject::connect(m_tcp_socket, &QTcpSocket::connected, this, [=, this] {
|
||||||
m_connected = true;
|
m_connected = true;
|
||||||
emit s_connected();
|
emit s_connected();
|
||||||
});
|
});
|
||||||
QObject::connect(&m_client, &Tcp_client::disconnected, this, [=, this] {
|
QObject::connect(m_tcp_socket, &QTcpSocket::disconnected, this, [=, this] {
|
||||||
m_connected = false;
|
m_connected = false;
|
||||||
emit s_disconnected();
|
emit s_disconnected();
|
||||||
if (m_reconnect)
|
if (m_reconnect)
|
||||||
@@ -24,25 +25,25 @@ Visa::Visa(QObject *parent)
|
|||||||
Visa::~Visa()
|
Visa::~Visa()
|
||||||
{
|
{
|
||||||
if (m_connected)
|
if (m_connected)
|
||||||
m_client.disconnect();
|
m_tcp_socket->disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Visa::connect(QString ip, quint16 port)
|
void Visa::connect(QString ip, quint16 port)
|
||||||
{
|
{
|
||||||
if (m_connected)
|
if (m_connected)
|
||||||
{
|
{
|
||||||
m_client.disconnect();
|
m_tcp_socket->disconnect();
|
||||||
m_ip = ip;
|
m_ip = ip;
|
||||||
m_port = port;
|
m_port = port;
|
||||||
m_reconnect = true;
|
m_reconnect = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_client.tcp_connect(ip, port);
|
m_tcp_socket->connectToHost(ip, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Visa::disconnect()
|
void Visa::disconnect()
|
||||||
{
|
{
|
||||||
m_client.tcp_disconnect();
|
m_tcp_socket->disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Visa::connected() const
|
bool Visa::connected() const
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
Q_FORWARD_DECLARE_OBJC_CLASS(QTcpSocket);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Class representing a VISA interface also known as SCIPI over TCP/IP
|
* @brief Class representing a VISA interface also known as SCIPI over TCP/IP
|
||||||
*
|
*
|
||||||
@@ -75,7 +77,7 @@ class Visa : public QObject
|
|||||||
void s_data_ready(QString data);
|
void s_data_ready(QString data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Tcp_client m_client;
|
QTcpSocket *m_tcp_socket;
|
||||||
QString m_ip;
|
QString m_ip;
|
||||||
quint16 m_port;
|
quint16 m_port;
|
||||||
bool m_connected;
|
bool m_connected;
|
||||||
Reference in New Issue
Block a user