Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Richard Lin
SceneChangingFramework
Commits
e273648e
Commit
e273648e
authored
Jan 14, 2018
by
Richard Lin
Browse files
Complete: instrument cluster
parent
6306f597
Changes
24
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
e273648e
...
...
@@ -30,6 +30,7 @@
moc_*.cpp
qrc_*.cpp
ui_*.h
*build*
Makefile*
*-build-*
*.qmlc
...
...
InstrumentCluster/InstrumentCluster.pro
View file @
e273648e
...
...
@@ -13,7 +13,8 @@ DEFINES += QT_DEPRECATED_WARNINGS
#
DEFINES
+=
QT_DISABLE_DEPRECATED_BEFORE
=
0
x060000
#
disables
all
the
APIs
deprecated
before
Qt
6.0
.
0
SOURCES
+=
main
.
cpp
\
contentsupplier
.
cpp
scenemanager
.
cpp
\
sceneinfo
.
cpp
RESOURCES
+=
qml
.
qrc
...
...
@@ -29,6 +30,7 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
!
isEmpty
(
target
.
path
)
:
INSTALLS
+=
target
HEADERS
+=
\
contentsupplier
.
h
scenemanager
.
h
\
sceneinfo
.
h
include
(..
/
Interface
/
Interface
.
pri
)
InstrumentCluster/contentsupplier.cpp
deleted
100644 → 0
View file @
6306f597
#include "contentsupplier.h"
ContentSupplier
::
ContentSupplier
(
QObject
*
parent
)
:
QObject
(
parent
)
{
}
InstrumentCluster/contentsupplier.h
deleted
100644 → 0
View file @
6306f597
#ifndef CONTENTSUPPLIER_H
#define CONTENTSUPPLIER_H
#include <QObject>
class
ContentSupplier
:
public
QObject
{
Q_OBJECT
Q_PROPERTY
(
QPixmap
bg
READ
bg
NOTIFY
bgChanged
)
public:
explicit
ContentSupplier
(
QObject
*
parent
=
nullptr
);
signals:
public
slots
:
private:
QMap
<
QString
,
iDriver
*>
_drivers
;
QList
<
QThread
*>
_threads
;
QList
<
DriverInfo
>
_supportedDriversInfo
;
QList
<
QPluginLoader
*>
_supportedDriversLoader
;
};
#endif // CONTENTSUPPLIER_H
InstrumentCluster/main.cpp
View file @
e273648e
#include <QGuiApplication>
#include <QQmlContext>
#include <QQmlApplicationEngine>
#include "
contentsuppli
er.h"
#include "
scenemanag
er.h"
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -9,10 +9,10 @@ int main(int argc, char *argv[])
QGuiApplication
app
(
argc
,
argv
);
ContentSuppli
er
*
c
s
=
new
ContentSuppli
er
();
SceneManag
er
*
c
m
=
new
SceneManag
er
();
QQmlApplicationEngine
engine
;
engine
.
rootContext
()
->
setContextProperty
(
"
contentSuppli
er"
,
QVariant
::
fromValue
(
c
s
));
engine
.
rootContext
()
->
setContextProperty
(
"
sceneManag
er"
,
QVariant
::
fromValue
(
c
m
));
engine
.
load
(
QUrl
(
QStringLiteral
(
"qrc:/main.qml"
)));
if
(
engine
.
rootObjects
().
isEmpty
())
...
...
InstrumentCluster/main.qml
View file @
e273648e
...
...
@@ -3,60 +3,54 @@ import QtQuick.Window 2.2
import
QtQuick
.
VirtualKeyboard
2.1
Window
{
id
:
root
visible
:
true
width
:
640
height
:
480
title
:
qsTr
(
"
Hello World
"
)
id
:
root
MouseArea
{
color
:
"
grey
"
Loader
{
id
:
content
anchors.fill
:
parent
onClicked
:
{
console
.
log
(
qsTr
(
'
Clicked on background. Text: "
'
+
textEdit
.
text
+
'
"
'
))
}
}
TextEdit
{
id
:
textEdit
text
:
qsTr
(
"
Enter some text...
"
)
verticalAlignment
:
Text
.
AlignVCenter
anchors.top
:
parent
.
top
anchors.horizontalCenter
:
parent
.
horizontalCenter
anchors.topMargin
:
20
Rectangle
{
anchors.fill
:
parent
anchors.margins
:
-
10
color
:
"
transparent
"
border.width
:
1
Item
{
id
:
s
property
int
sceneNumber
:
0
property
int
sceneCounts
:
0
Connections
{
target
:
sceneManager
onSceneListChanged
:
{
s
.
sceneCounts
=
sceneManager
.
sceneList
.
size
();
s
.
sceneNumber
=
0
}
}
function
selectScene
(
number
)
{
if
(
number
<
0
||
number
>
s
.
sceneCounts
)
return
;
s
.
sceneNumber
=
number
;
content
.
setSource
(
sceneManager
.
sceneList
.
at
(
number
).
entryPath
);
}
}
InputPanel
{
id
:
inputPanel
z
:
99
ListView
{
id
:
sceneSelector
x
:
0
y
:
root
.
height
width
:
root
.
width
states
:
State
{
name
:
"
visible
"
when
:
inputPanel
.
active
PropertyChanges
{
target
:
inputPanel
y
:
root
.
height
-
inputPanel
.
height
}
}
transitions
:
Transition
{
from
:
""
to
:
"
visible
"
reversible
:
true
ParallelAnimation
{
NumberAnimation
{
properties
:
"
y
"
duration
:
250
easing.type
:
Easing
.
InOutQuad
}
y
:
0
width
:
parent
.
width
/
3
height
:
parent
.
height
/
1.5
model
:
sceneManager
.
sceneList
delegate
:
Rectangle
{
width
:
sceneSelector
.
width
height
:
sceneSelector
.
height
/
3
Text
{
text
:
sceneManager
.
sceneList
[
index
].
name
}
}
}
}
InstrumentCluster/sceneinfo.cpp
0 → 100644
View file @
e273648e
#include "sceneinfo.h"
#include <QDebug>
SceneInfo
::
SceneInfo
(
QObject
*
parent
)
:
QObject
(
parent
),
_pSnapShot
(
nullptr
)
{
}
SceneInfo
::~
SceneInfo
(
void
)
{
unload
();
}
bool
SceneInfo
::
loadFile
(
const
QString
&
filePath
)
{
if
(
QLibrary
::
isLibrary
(
filePath
))
{
QPluginLoader
*
newLoader
=
new
QPluginLoader
(
filePath
);
const
QJsonObject
meta
=
newLoader
->
metaData
();
if
(
meta
[
"MetaData"
][
"type"
].
toString
(
QString
())
==
QString
(
"scenePlugin"
)
&&
meta
[
"MetaData"
][
"version"
].
toInt
(
0
)
>
0
&&
meta
[
"MetaData"
][
"name"
].
toString
(
QString
())
!=
_name
)
{
iPlugin
*
plugin
=
qobject_cast
<
iPlugin
*>
(
newLoader
->
instance
());
if
(
plugin
)
{
//success
unload
();
_version
=
meta
[
"MetaData"
][
"version"
].
toInt
(
0
);
_name
=
meta
[
"MetaData"
][
"name"
].
toString
(
QString
());
_entryPath
=
meta
[
"MetaData"
][
"entryPath"
].
toString
(
QString
());
_pLoader
=
newLoader
;
_pSnapShot
=
plugin
->
snapShot
();
plugin
->
deleteLater
();
return
true
;
}
}
newLoader
->
deleteLater
();
}
//failed
return
false
;
}
void
SceneInfo
::
unload
(
void
)
{
if
(
!
_pLoader
)
{
_pLoader
->
deleteLater
();
_pLoader
=
nullptr
;
}
_version
=
0
;
_name
=
QString
();
_entryPath
=
QString
();
_pSnapShot
.
clear
();
}
QPluginLoader
*
SceneInfo
::
loader
(
void
)
{
return
_pLoader
;
}
QSharedPointer
<
QImage
>
SceneInfo
::
snapShot
(
void
)
{
return
_pSnapShot
;
}
InstrumentCluster/sceneinfo.h
0 → 100644
View file @
e273648e
#ifndef SCENEINFO_H
#define SCENEINFO_H
#include <QObject>
#include <QPluginLoader>
#include "iplugin.h"
class
SceneInfo
:
public
QObject
{
Q_OBJECT
Q_PROPERTY
(
QString
name
MEMBER
_name
)
Q_PROPERTY
(
int
version
MEMBER
_version
)
Q_PROPERTY
(
QString
entryPath
MEMBER
_entryPath
)
public:
explicit
SceneInfo
(
QObject
*
parent
=
nullptr
);
virtual
~
SceneInfo
(
void
);
bool
loadFile
(
const
QString
&
filePath
);
void
unload
(
void
);
QPluginLoader
*
loader
(
void
);
QSharedPointer
<
QImage
>
snapShot
(
void
);
private:
QString
_name
;
int
_version
;
QString
_entryPath
;
QSharedPointer
<
QImage
>
_pSnapShot
;
QPluginLoader
*
_pLoader
;
};
#endif // SCENEINFO_H
InstrumentCluster/scenemanager.cpp
View file @
e273648e
#include "scenemanager.h"
#include "sceneinfo.h"
sceneManager
::
sceneManager
(
QObject
*
parent
)
:
QObject
(
parent
)
{
#include <QGuiApplication>
#include <QDir>
SceneManager
::
SceneManager
(
QObject
*
parent
)
:
QObject
(
parent
)
{
_sceneInit
();
_loadScene
();
}
SceneManager
::~
SceneManager
()
{
}
QList
<
QObject
*>
SceneManager
::
sceneList
(
void
)
{
QList
<
QObject
*
>
ret
;
foreach
(
SceneInfo
*
s
,
_pSceneInfo
)
{
ret
<<
qobject_cast
<
QObject
*>
(
s
);
}
return
ret
;
}
void
SceneManager
::
_sceneInit
(
void
){
QList
<
SceneInfo
*>
_pSceneInfo
;
foreach
(
SceneInfo
*
d
,
_pSceneInfo
)
{
d
->
deleteLater
();
_pSceneInfo
.
removeOne
(
d
);
}
}
void
SceneManager
::
_loadScene
(
void
)
{
QDir
_pluginsDir
=
QDir
(
qApp
->
applicationDirPath
());
#if defined(Q_OS_WIN)
if
(
_pluginsDir
.
dirName
().
toLower
()
==
"debug"
||
_pluginsDir
.
dirName
().
toLower
()
==
"release"
)
_pluginsDir
.
cdUp
();
#elif defined(Q_OS_MAC)
if
(
_pluginsDir
.
dirName
()
==
"MacOS"
)
{
_pluginsDir
.
cdUp
();
_pluginsDir
.
cdUp
();
_pluginsDir
.
cdUp
();
}
#endif
_pluginsDir
.
cd
(
"Scenes"
);
foreach
(
QString
fileName
,
_pluginsDir
.
entryList
(
QDir
::
Files
))
{
SceneInfo
*
newScene
=
new
SceneInfo
();
bool
ret
=
newScene
->
loadFile
(
_pluginsDir
.
absoluteFilePath
(
fileName
));
if
(
ret
)
{
_pSceneInfo
.
append
(
newScene
);
emit
sceneListChanged
();
}
else
{
newScene
->
deleteLater
();
}
}
}
InstrumentCluster/scenemanager.h
View file @
e273648e
...
...
@@ -3,15 +3,26 @@
#include <QObject>
class
sceneManager
:
public
QObject
class
SceneInfo
;
class
SceneManager
:
public
QObject
{
Q_OBJECT
Q_PROPERTY
(
QList
<
QObject
*>
sceneList
READ
sceneList
NOTIFY
sceneListChanged
)
public:
explicit
s
ceneManager
(
QObject
*
parent
=
nullptr
);
explicit
S
ceneManager
(
QObject
*
parent
=
nullptr
);
virtual
~
SceneManager
();
signals:
void
sceneListChanged
(
void
);
public
slots
:
QList
<
QObject
*>
sceneList
(
void
);
private:
void
_sceneInit
(
void
);
void
_loadScene
(
void
);
QList
<
SceneInfo
*>
_pSceneInfo
;
};
#endif // SCENEMANAGER_H
\ No newline at end of file
#endif // SCENEMANAGER_H
Interface/iplugin.h
View file @
e273648e
#ifndef IDRIVER_H
#define IDRIVER_H
#include <QObject>
#include <QImage>
#include <QSharedPointer>
class
iPlugin
:
public
QObject
{
...
...
@@ -11,11 +13,9 @@ public:
virtual
~
iPlugin
(){}
public
slots
:
QString
property
(
const
QString
&
name
)
const
=
0
;
QImage
snapShot
(
void
)
const
=
0
;
virtual
void
initialRes
(
void
)
=
0
;
virtual
void
cleanUpRes
(
void
)
=
0
;
virtual
QSharedPointer
<
QImage
>
snapShot
(
void
)
const
=
0
;
};
Q_DECLARE_INTERFACE
(
iPlugin
,
"iPlugin_iid"
)
...
...
ScenePlugin/Archermind/Archermind.pro
→
ScenePlugin/Archermind
Scene
/Archermind
Scene
.pro
View file @
e273648e
File moved
ScenePlugin/Archermind/udpdatabaseProtocol.json
→
ScenePlugin/Archermind
Scene
/udpdatabaseProtocol.json
View file @
e273648e
File moved
ScenePlugin/Archermind/udpdatabaseprotocoldriver.cpp
→
ScenePlugin/Archermind
Scene
/udpdatabaseprotocoldriver.cpp
View file @
e273648e
File moved
ScenePlugin/Archermind/udpdatabaseprotocoldriver.h
→
ScenePlugin/Archermind
Scene
/udpdatabaseprotocoldriver.h
View file @
e273648e
File moved
ScenePlugin/ScenePlugin.pro
View file @
e273648e
TEMPLATE
=
subdirs
SUBDIRS
+=
Archermind
SUBDIRS
+=
Triton
#
SUBDIRS
+=
Archermind
Scene
SUBDIRS
+=
Triton
Scene
ScenePlugin/Triton/Triton.pro
deleted
100644 → 0
View file @
6306f597
QT
+=
network
widgets
TEMPLATE
=
lib
CONFIG
+=
plugin
TARGET
=
$$
qtLibraryTarget
(
TritonScene
)
DESTDIR
=
..
/../
ScenePlugin
CONFIG
+=
c
++
11
INCLUDEPATH
+=
$$
PWD
\
HEADERS
+=
\
$$
PWD
/
udpdatabaseprotocoldriver
.
h
SOURCES
+=
\
$$
PWD
/
udpdatabaseprotocoldriver
.
cpp
#
interface
:
include
(..
/../
Interface
/
Interface
.
pri
)
ScenePlugin/Triton/tritonScene.h
deleted
100644 → 0
View file @
6306f597
#ifndef UDPDATABASEPROTOCOLDRIVER_H
#define UDPDATABASEPROTOCOLDRIVER_H
#include <QObject>
#include <QTimer>
#include <QtNetwork>
#include <QtNetwork/QUdpSocket>
#include "iplugin.h"
class
QUdpSocket
;
class
QHostAddress
;
class
UdpDatabaseProtocolDriverUI
;
class
UdpDatabaseProtocolDriver
:
public
iDriver
{
Q_OBJECT
Q_PLUGIN_METADATA
(
IID
"com.csic711.appServer.drivers.udpdatabaseProtocol"
FILE
"udpdatabaseProtocol.json"
)
Q_INTERFACES
(
iDriver
)
public:
/*!
* 构造函数
* 功能描述:
* 1、初始化参数
* 2、进入停止状态
*/
explicit
UdpDatabaseProtocolDriver
(
QObject
*
parent
=
0
);
~
UdpDatabaseProtocolDriver
();
public
slots
:
DriverInfo
driverInfo
()
const
override
;
void
save
(
iLoadSaveProcessor
*
processor
)
override
;
void
load
(
iLoadSaveProcessor
*
processor
)
override
;
int
start
()
override
;
int
stop
()
override
;
int
restart
()
override
;
int
state
()
override
{
return
_state
;
}
QList
<
int
>
availableRWStrategy
(
void
)
const
override
;
QList
<
int
>
availableRWStrategy
(
const
QString
&
addr
)
const
override
;
bool
isAddressCorrect
(
const
QString
&
addr
)
const
override
;
QString
addressErrorString
(
const
QString
&
addr
)
const
override
;
int
setRelatedTagAddresses
(
const
QList
<
TagAddress
*>&
relatedTagAddresses
)
override
;
void
showUI
(
bool
show
=
true
,
QWidget
*
parent
=
0
)
override
;
public
slots
:
/*!
* 设置组播的Address和Port
* 返回数值:0:成功 -1:失败
* 功能描述:
* 1、如果是组播的地址则成功,否则失败
*/
int
setUdpDatabaseAddress
(
const
QHostAddress
&
hostaddr
,
qint16
hostport
,
qint16
localport
);
/*!
* 设置组播的网卡接口
* 返回数值:0:成功 -1:失败
* 功能描述:
* 1、如果是组播的网卡接口则成功,否则失败
*/
int
setNetworkInterface
(
const
QNetworkInterface
&
networkInterface
);
/*!
* 设置站号-csic711定制
* 返回数值:0:成功 -1:失败
* 功能描述:
* 站号范围:1-255
*/
int
setSMDERIMStation
(
qint16
station
);
QString
udpdatabaseAddress
(
void
)
const
;
int
udpdatabasePort
(
void
)
const
;
QNetworkInterface
&
networkInterface
(
void
);
signals:
void
msgEventString
(
const
QString
&
msg
);
//accept per udp package
void
dataReceived
();
//emit per accepted tag
void
dataAccepted
();
private
slots
:
void
_processPendingDatagrams
();
void
_setState
(
enum_states
state
);
void
_watchDogTimeOver
();
bool
_getTime
(
QDateTime
&
t
,
int
year
,
int
month
,
int
day
,
int
hour
,
int
minute
,
int
second
,
int
millisecond
=
0
);
void
_scheduleProcess
();
private:
/*!
* For sorting
* instead of operator<() to compare the TagInfo*
*/
static
bool
compareTagAddress
(
const
TagAddress
*
t1
,
const
TagAddress
*
t2
);
QUdpSocket
*
_pUdpSocket
;
QHostAddress
_udpdatabaseAddress
;
QHostAddress
_hostAddress
;
QNetworkInterface
_networkInterface
;
UdpDatabaseProtocolDriverUI
*
_pUI
;
int
_port
;
quint16
_hostPort
;
char
_stationID
;
enum_states
_state
;
QTimer
*
_pWatchDogTimer
;
QList
<
TagAddress
*>
_relatedTags
;
QTimer
*
_scheduleTimer
;
//UDP发送定时器
};
#endif // UDPDATABASEPROTOCOLDRIVER_H
ScenePlugin/Triton/tritonscene.qrc
deleted
100644 → 0
View file @
6306f597
<!DOCTYPE RCC>
<RCC
version=
"1.0"
/>
ScenePlugin/Triton/udpdatabaseProtocol.json
deleted
100644 → 0
View file @
6306f597
{}
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment