Skip to content
Snippets Groups Projects
Commit ea6c66e8 authored by Mahmoud's avatar Mahmoud
Browse files

Initial adding of content

parent f25258d9
No related branches found
No related tags found
No related merge requests found
File added
# Simulink plugin dependencies This repository contains dependencies needed by the simulink connector plugin (https://git.qt.io/mbadri/simulinkconnector). Dependencies are provided by MathWorks (mathworks.com).
Simulink dependency lib and Qt blockset. Those 2 items are needed for the integration between Simulink and a Qt/Qt Design studio app. The package is composed of three components:
\ No newline at end of file 1) Simulink Qt Block Library (QtBlocksetPSP-R2019b_v2.1.3_win64-Install.exe)
2) Qt plugin (simulinkplugin) for connectivity to the Simulink environment using C++
3) QML Extension plugin (simulinkqmlplugin) which allows the simulinkplugin to be used in QML directly.
\ No newline at end of file
File added
File added
/****************************************************************************
** Copyright 2015-2017 The Mathworks, Inc.
*****************************************************************************/
/****************************************************************************
** Copyright (c) 2006 - 2011, the LibQxt project.
** See the Qxt AUTHORS file for a list of authors and copyright holders.
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** * Neither the name of the LibQxt project nor the
** names of its contributors may be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
** DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
** <http://libqxt.org> <foundation@libqxt.org>
*****************************************************************************/
#ifndef SIMULINKPLUGIN_H
#define SIMULINKPLUGIN_H
#include <QObject>
#include <QList>
#include <QVariant>
#include <QPair>
#include <QString>
#include <QHostAddress>
#if defined(BUILD_SLQT_CORE)
# define SLQT_CORE_EXPORT Q_DECL_EXPORT
#elif defined(BUILD_SLQT_QMLPLUGIN)
# define SLQT_CORE_EXPORT
#else
# define SLQT_CORE_EXPORT Q_DECL_IMPORT
#endif
class SimulinkPluginPrivate;
class SLQT_CORE_EXPORT SimulinkPlugin : public QObject
{
Q_OBJECT
public:
/*!
* Class SimulinkPlugin
* The SimulinkPlugin class transmits Qt signals over a QIODevice
*
* SimulinkPlugin is a tool that encapsulates Qt signals and transmits them over a QIODevice to a
* Simulink client.
*
* SimulinkPlugin can act as a client or a server. When acting as a server, it uses a
* SlQtAbstractConnectionManager to accept connections. When acting as a client, the application
* should provide an already-connected QIODevice to the setDevice() function.
*
* Due to a restriction of Qt's signals and slots mechanism, the number of parameters that can be
* passed to call() and its related functions, as well as the number of parameters to any signal
* or slot connected to SimulinkPlugin, is limited to 8.
*/
SimulinkPlugin(QObject* parent = 0);
SimulinkPlugin(QList<QObject *> interfaces, QObject* parent = 0 );
SimulinkPlugin(QIODevice* device, QObject* parent = 0);
virtual ~SimulinkPlugin();
/*!
* Returns true if the connection manager is accepting connections or if any clients are
* currently connected. It is possible for both isServer() and isClient() to return false
* if the connection manager is not accepting connections, no clients are connected, and no
* QIODevice is set for a server.
* See also: isClient()
*/
Q_INVOKABLE bool isServer() const;
/*!
* Returns true if the SimulinkPlugin is currently communicating with a server. It is possible
* for both isServer()and isClient() to return false if the connection manager is not accepting
* connections, no clients are connected, and no QIODevice is set for a server.
* See also: isServer()
*/
Q_INVOKABLE bool isClient() const;
/*!
* Returns a list of client IDs for all connected clients.
*/
QList<quint64> clients() const;
/*!
* When operating as a client, returns the QIODevice connected to the server.
* When operating as a server, or if not connected to a server, returns NULL.
* See also: setDevice()
* See also: takeDevice()
*/
QIODevice* getdevice() const;
/*!
* Begins communicating with a server through the provided QIODevice dev. If called while
* acting as a server, this function is ignored with a warning. If called while another device
* is set, the original QIODevice is deleted. The provided device will be reparented to the
* SimulinkPlugin.
*
* Note that because QIODevice is a generic interface, SimulinkPlugin cannot provide signals
* when this device is disconnected or has low-level errors. Connect to the QIODevice subclass's
* signals directly if you need this information.
* See also: device()
*/
void setDevice(QIODevice* dev);
/*!
* When operating as a client, returns the QIODevice used to communicate with the server. After
* this function is called, the SimulinkPlugin will no longer be connected and device() will
* return NULL. When operating as a server, or if not connected to a server, this function
* returns NULL without any other effect.
* See also: device()
*/
QIODevice* takeDevice();
/*!
* Connects to the specified server addr on the selected port.
* When the connection is complete, the connectedToServer() signal will be emitted. If an error
* occurs, the serverError() signal will be emitted.
*/
void connect(QHostAddress addr, int port = 80);
/*!
* Connects to the specified peer or server addr on the selected port.
* When the connection is complete, the connectedToServer() signal will be emitted. If an
* error occurs, the serverError() signal will be emitted.
*/
Q_INVOKABLE void connect(QString addr, int port = 80);
/*!
* Listens on the specified interface iface on the specified port for connections.
*
* Attempting to listen while in Client mode or while connected in Peer mode will be ignored
* with a warning. In Peer mode, only one connection can be active at a time. Additional
* incoming connections while connected to a peer will be dropped. When a peer connects,
* the peerConnected()signal will be emitted. In Server mode, multiple connections can be
* active at a time. Each client that connects will be provided a unique ID, included in the
* clientConnected() signal that will be emitted. Returns true if succeeds, false otherwise.
*/
Q_INVOKABLE bool listen(QString iface="", int port = 80);
/*!
* Stops listening for connections. Any connections still open will remain connected.
*/
Q_INVOKABLE void stopListening();
/*!
* Binds all Signals, Slots, and Properties in parent with proper suffix naming convention
* to connected network channel.
*/
Q_INVOKABLE bool autoConnect(QObject *parent);
/*!
* Binds all Signals, Slots, and Properties in interface with proper suffix naming convention
* to connected network channel.
*
* For Slots, the arguments should be QVariant type.
*/
Q_INVOKABLE bool autoConnect(QList<QObject *> interface);
/*!
* Binds the slot in recv to the Simulink channel rpcFunction.
*
* When a signal with the name given by rpcFunction is received from the network, the connected
* slot is executed. Use the SLOT() macro to specify the slot, just as you would for QObject::connect().
*
* Like QObject::connect(), connectSlot() returns false if the connection cannot be established.
* Also like QObject::connect(), a signal may be used as a slot; invocation will cause the signal
* to be emitted.
*
* Arguments of the Slot should be QVariant type.
*/
bool connectSlot(const QString& rpcFunction, QObject* recv, const char* slot,
Qt::ConnectionType type = Qt::AutoConnection);
/*!
* Connects the given signal in sender to the Simulink channel rpcFunction.
*
* When the connected signal is emitted by sender, it will be transmitted to all connected servers,
* clients, or peers. If an optional rpcFunction is provided, it will be used in place of the name
* of the transmitted signal. Use the SIGNAL() macro to specify the signal, just as you would for
* QObject::connect().
*
* Like QObject::connect(), connectSignal() returns false if the connection cannot be established.
*/
bool connectSignal(QObject* sender, const char* signal, const QString& rpcFunction = QString());
/*!
* Binds the propert propName in recv to a Simulink channel with the same name.
*
* When a Property with the name given by rpcFunction is received from the network, the connected
* property is updated.
*
* Like QObject::connect(), connectProperty() returns false if the connection cannot be established.
*
*/
bool connectProperty(QObject* recv, const char* propName,
Qt::ConnectionType type = Qt::AutoConnection);
/*!
* Disconnects all signals for the given object obj.
*/
void disconnectSignals(QObject* obj);
/*!
* Disconnects all slots for the given object obj.
*/
void disconnectSlots(QObject* obj);
/*!
* Disconnects all Properties for the given object obj.
*/
void disconnectProperties(QObject* obj);
/*!
* Disconnects all signals and slots for the given object obj.
*/
void disconnectObject(QObject* obj);
/*!
* Sends the signal fn with the given parameter list to the server, or to all connected clients.
*
* The receiver is not obligated to act upon the signal. If no clients are connected, and if not
* communicating with a server, this function does nothing.
*/
void call(QString fn, const QVariant& p1 = QVariant(), const QVariant& p2 = QVariant(),
const QVariant& p3 = QVariant(), const QVariant& p4 = QVariant(), const QVariant& p5 = QVariant(),
const QVariant& p6 = QVariant(), const QVariant& p7 = QVariant(), const QVariant& p8 = QVariant());
/*!
* Sends the signal fn with the given parameter list to the provided list of clients.
*
* The receivers are not obligated to act upon the signal. If no client is connected with a
* provided ID, the ID is ignored with a warning. If acting as a client, this function does nothing.
*/
void call(QList<quint64> ids, QString fn, const QVariant& p1 = QVariant(), const QVariant& p2 = QVariant(),
const QVariant& p3 = QVariant(), const QVariant& p4 = QVariant(), const QVariant& p5 = QVariant(),
const QVariant& p6 = QVariant(), const QVariant& p7 = QVariant(), const QVariant& p8 = QVariant());
/*!
* Sends the signal fn with the given parameter list to the specified client.
*
* The receiver is not obligated to act upon the signal. If no client with the given ID is connected,
* the call will be ignored with a warning. If acting as a client, this function does nothing.
*/
void call(quint64 id, QString fn, const QVariant& p1 = QVariant(), const QVariant& p2 = QVariant(),
const QVariant& p3 = QVariant(), const QVariant& p4 = QVariant(), const QVariant& p5 = QVariant(),
const QVariant& p6 = QVariant(), const QVariant& p7 = QVariant(), const QVariant& p8 = QVariant());
/*!
* Sends the signal fn with the given parameter list to all connected clients except for the client
* specified.
*
* The receiver is not obligated to act upon the signal. This function is useful for rebroadcasting a signal from one
* client to all other connected clients. If acting as a client, this function does nothing.
*/
void callExcept(quint64 id, QString fn, const QVariant& p1 = QVariant(), const QVariant& p2 = QVariant(),
const QVariant& p3 = QVariant(), const QVariant& p4 = QVariant(), const QVariant& p5 = QVariant(),
const QVariant& p6 = QVariant(), const QVariant& p7 = QVariant(), const QVariant& p8 = QVariant());
public Q_SLOTS:
/*!
* Disconnects a client with id using the connected connection manager.
* If connected to a server, this function is ignored with a warning.
*/
void disconnectClient(quint64 id);
/*!
* Disconnects from the server. The QIODevice is deleted. Use takeDevice() to disconnect from the
* server without deleting the device.
*
* If not connected to a server, for instance if acting as a server, this function is ignored with
* a warning.
* See also: device()
* See also: takeDevice()
*/
void disconnectServer();
/*!
* Disconnects all clients, or disconnects from the server.
*/
void disconnectAll();
/*!
* Disconnects all signals and slots for the object that emitted the signal connected to
* disconnectSender().
*/
void disconnectSender();
Q_SIGNALS:
/*!
* This signal is emitted after a successful connection from a client.
*
* The given ID is used for disconnectClient(), call(), and related functions.
*/
void clientConnected(quint64 id);
/*!
* This signal is emitted when a client disconnects. The given ID is no longer valid.
*/
void clientDisconnected(quint64 id);
/*!
* This signal is emitted after a successful connection to a server.
*/
void connectedToServer();
/*!
* This signal is emitted after disconnecting from a server.
*/
void disconnectedFromServer();
/*!
* This signal is emitted if an error occurs on the socket connected to the server.
*/
void serverError(QAbstractSocket::SocketError);
protected:
Q_DECLARE_PRIVATE(SimulinkPlugin)
SimulinkPluginPrivate * const d_ptr;
};
#endif
File added
File added
File added
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment