Creation
14
.gitignore
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
ANG
|
||||||
|
BUQ4
|
||||||
|
CVRT
|
||||||
|
HBGR
|
||||||
|
MMO
|
||||||
|
SMIC
|
||||||
|
SNW5
|
||||||
|
/OutilZT.pro.user
|
||||||
|
/OutilZT.pro.user.0000000
|
||||||
|
/debug
|
||||||
|
/release
|
||||||
|
/Temp
|
||||||
|
/Trains/ZTLogs.zdb
|
||||||
|
/Trains/Trains.zdb
|
||||||
BIN
Configuration/Settings.ozs
Normal file
BIN
Images/GuiBackground.jpg
Normal file
|
After Width: | Height: | Size: 79 KiB |
BIN
Images/Play Normal.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
Images/Save-icon.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
Images/Slider_Green.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
Images/Slider_Red.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
Images/csv.png
Normal file
|
After Width: | Height: | Size: 34 KiB |
BIN
Images/database.png
Normal file
|
After Width: | Height: | Size: 84 KiB |
BIN
Images/ethernet.png
Normal file
|
After Width: | Height: | Size: 75 KiB |
BIN
Images/file_delete.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
Images/gps_disconnected-.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
Images/green-led-off-md.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
Images/green-led-on-md.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
Images/green_check.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
Images/log.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
Images/open-file-icon.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
Images/pushbutton-green.png
Normal file
|
After Width: | Height: | Size: 148 KiB |
BIN
Images/red-led-off-md.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
Images/red-led-on-md.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
Images/red_cross.png
Normal file
|
After Width: | Height: | Size: 68 KiB |
BIN
Images/tools.png
Normal file
|
After Width: | Height: | Size: 9.2 KiB |
147
Makefile
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
#############################################################################
|
||||||
|
# Makefile for building: OutilZT
|
||||||
|
# Generated by qmake (2.01a) (Qt 4.8.1) on: Wed May 18 10:55:42 2016
|
||||||
|
# Project: OutilZT.pro
|
||||||
|
# Template: app
|
||||||
|
# Command: c:\Qt\4.8.1\bin\qmake.exe -spec ..\..\Qt\4.8.1\mkspecs\win32-g++ CONFIG+=release -o Makefile OutilZT.pro
|
||||||
|
#############################################################################
|
||||||
|
|
||||||
|
first: release
|
||||||
|
install: release-install
|
||||||
|
uninstall: release-uninstall
|
||||||
|
MAKEFILE = Makefile
|
||||||
|
QMAKE = c:\Qt\4.8.1\bin\qmake.exe
|
||||||
|
DEL_FILE = del
|
||||||
|
CHK_DIR_EXISTS= if not exist
|
||||||
|
MKDIR = mkdir
|
||||||
|
COPY = copy /y
|
||||||
|
COPY_FILE = $(COPY)
|
||||||
|
COPY_DIR = xcopy /s /q /y /i
|
||||||
|
INSTALL_FILE = $(COPY_FILE)
|
||||||
|
INSTALL_PROGRAM = $(COPY_FILE)
|
||||||
|
INSTALL_DIR = $(COPY_DIR)
|
||||||
|
DEL_FILE = del
|
||||||
|
SYMLINK =
|
||||||
|
DEL_DIR = rmdir
|
||||||
|
MOVE = move
|
||||||
|
CHK_DIR_EXISTS= if not exist
|
||||||
|
MKDIR = mkdir
|
||||||
|
SUBTARGETS = \
|
||||||
|
release \
|
||||||
|
debug
|
||||||
|
|
||||||
|
release: $(MAKEFILE).Release FORCE
|
||||||
|
$(MAKE) -f $(MAKEFILE).Release
|
||||||
|
release-make_default: $(MAKEFILE).Release FORCE
|
||||||
|
$(MAKE) -f $(MAKEFILE).Release
|
||||||
|
release-make_first: $(MAKEFILE).Release FORCE
|
||||||
|
$(MAKE) -f $(MAKEFILE).Release first
|
||||||
|
release-all: $(MAKEFILE).Release FORCE
|
||||||
|
$(MAKE) -f $(MAKEFILE).Release all
|
||||||
|
release-clean: $(MAKEFILE).Release FORCE
|
||||||
|
$(MAKE) -f $(MAKEFILE).Release clean
|
||||||
|
release-distclean: $(MAKEFILE).Release FORCE
|
||||||
|
$(MAKE) -f $(MAKEFILE).Release distclean
|
||||||
|
release-install: $(MAKEFILE).Release FORCE
|
||||||
|
$(MAKE) -f $(MAKEFILE).Release install
|
||||||
|
release-uninstall: $(MAKEFILE).Release FORCE
|
||||||
|
$(MAKE) -f $(MAKEFILE).Release uninstall
|
||||||
|
debug: $(MAKEFILE).Debug FORCE
|
||||||
|
$(MAKE) -f $(MAKEFILE).Debug
|
||||||
|
debug-make_default: $(MAKEFILE).Debug FORCE
|
||||||
|
$(MAKE) -f $(MAKEFILE).Debug
|
||||||
|
debug-make_first: $(MAKEFILE).Debug FORCE
|
||||||
|
$(MAKE) -f $(MAKEFILE).Debug first
|
||||||
|
debug-all: $(MAKEFILE).Debug FORCE
|
||||||
|
$(MAKE) -f $(MAKEFILE).Debug all
|
||||||
|
debug-clean: $(MAKEFILE).Debug FORCE
|
||||||
|
$(MAKE) -f $(MAKEFILE).Debug clean
|
||||||
|
debug-distclean: $(MAKEFILE).Debug FORCE
|
||||||
|
$(MAKE) -f $(MAKEFILE).Debug distclean
|
||||||
|
debug-install: $(MAKEFILE).Debug FORCE
|
||||||
|
$(MAKE) -f $(MAKEFILE).Debug install
|
||||||
|
debug-uninstall: $(MAKEFILE).Debug FORCE
|
||||||
|
$(MAKE) -f $(MAKEFILE).Debug uninstall
|
||||||
|
|
||||||
|
Makefile: OutilZT.pro ../../Qt/4.8.1/mkspecs/win32-g++/qmake.conf ../../Qt/4.8.1/mkspecs/qconfig.pri \
|
||||||
|
../../Qt/4.8.1/mkspecs/modules/qt_webkit_version.pri \
|
||||||
|
../../Qt/4.8.1/mkspecs/features/qt_functions.prf \
|
||||||
|
../../Qt/4.8.1/mkspecs/features/qt_config.prf \
|
||||||
|
../../Qt/4.8.1/mkspecs/features/exclusive_builds.prf \
|
||||||
|
../../Qt/4.8.1/mkspecs/features/default_pre.prf \
|
||||||
|
../../Qt/4.8.1/mkspecs/features/win32/default_pre.prf \
|
||||||
|
../../Qt/4.8.1/mkspecs/features/release.prf \
|
||||||
|
../../Qt/4.8.1/mkspecs/features/debug_and_release.prf \
|
||||||
|
../../Qt/4.8.1/mkspecs/features/default_post.prf \
|
||||||
|
../../Qt/4.8.1/mkspecs/features/win32/default_post.prf \
|
||||||
|
../../Qt/4.8.1/mkspecs/features/win32/rtti.prf \
|
||||||
|
../../Qt/4.8.1/mkspecs/features/win32/exceptions.prf \
|
||||||
|
../../Qt/4.8.1/mkspecs/features/win32/stl.prf \
|
||||||
|
../../Qt/4.8.1/mkspecs/features/shared.prf \
|
||||||
|
../../Qt/4.8.1/mkspecs/features/warn_on.prf \
|
||||||
|
../../Qt/4.8.1/mkspecs/features/qt.prf \
|
||||||
|
../../Qt/4.8.1/mkspecs/features/win32/thread.prf \
|
||||||
|
../../Qt/4.8.1/mkspecs/features/moc.prf \
|
||||||
|
../../Qt/4.8.1/mkspecs/features/win32/windows.prf \
|
||||||
|
../../Qt/4.8.1/mkspecs/features/resources.prf \
|
||||||
|
../../Qt/4.8.1/mkspecs/features/uic.prf \
|
||||||
|
../../Qt/4.8.1/mkspecs/features/yacc.prf \
|
||||||
|
../../Qt/4.8.1/mkspecs/features/lex.prf \
|
||||||
|
../../Qt/4.8.1/mkspecs/features/include_source_dir.prf \
|
||||||
|
c:/Qt/4.8.1/lib/qtmain.prl
|
||||||
|
$(QMAKE) -spec ..\..\Qt\4.8.1\mkspecs\win32-g++ CONFIG+=release -o Makefile OutilZT.pro
|
||||||
|
..\..\Qt\4.8.1\mkspecs\qconfig.pri:
|
||||||
|
..\..\Qt\4.8.1\mkspecs\modules\qt_webkit_version.pri:
|
||||||
|
..\..\Qt\4.8.1\mkspecs\features\qt_functions.prf:
|
||||||
|
..\..\Qt\4.8.1\mkspecs\features\qt_config.prf:
|
||||||
|
..\..\Qt\4.8.1\mkspecs\features\exclusive_builds.prf:
|
||||||
|
..\..\Qt\4.8.1\mkspecs\features\default_pre.prf:
|
||||||
|
..\..\Qt\4.8.1\mkspecs\features\win32\default_pre.prf:
|
||||||
|
..\..\Qt\4.8.1\mkspecs\features\release.prf:
|
||||||
|
..\..\Qt\4.8.1\mkspecs\features\debug_and_release.prf:
|
||||||
|
..\..\Qt\4.8.1\mkspecs\features\default_post.prf:
|
||||||
|
..\..\Qt\4.8.1\mkspecs\features\win32\default_post.prf:
|
||||||
|
..\..\Qt\4.8.1\mkspecs\features\win32\rtti.prf:
|
||||||
|
..\..\Qt\4.8.1\mkspecs\features\win32\exceptions.prf:
|
||||||
|
..\..\Qt\4.8.1\mkspecs\features\win32\stl.prf:
|
||||||
|
..\..\Qt\4.8.1\mkspecs\features\shared.prf:
|
||||||
|
..\..\Qt\4.8.1\mkspecs\features\warn_on.prf:
|
||||||
|
..\..\Qt\4.8.1\mkspecs\features\qt.prf:
|
||||||
|
..\..\Qt\4.8.1\mkspecs\features\win32\thread.prf:
|
||||||
|
..\..\Qt\4.8.1\mkspecs\features\moc.prf:
|
||||||
|
..\..\Qt\4.8.1\mkspecs\features\win32\windows.prf:
|
||||||
|
..\..\Qt\4.8.1\mkspecs\features\resources.prf:
|
||||||
|
..\..\Qt\4.8.1\mkspecs\features\uic.prf:
|
||||||
|
..\..\Qt\4.8.1\mkspecs\features\yacc.prf:
|
||||||
|
..\..\Qt\4.8.1\mkspecs\features\lex.prf:
|
||||||
|
..\..\Qt\4.8.1\mkspecs\features\include_source_dir.prf:
|
||||||
|
c:\Qt\4.8.1\lib\qtmain.prl:
|
||||||
|
qmake: qmake_all FORCE
|
||||||
|
@$(QMAKE) -spec ..\..\Qt\4.8.1\mkspecs\win32-g++ CONFIG+=release -o Makefile OutilZT.pro
|
||||||
|
|
||||||
|
qmake_all: FORCE
|
||||||
|
|
||||||
|
make_default: release-make_default debug-make_default FORCE
|
||||||
|
make_first: release-make_first debug-make_first FORCE
|
||||||
|
all: release-all debug-all FORCE
|
||||||
|
clean: release-clean debug-clean FORCE
|
||||||
|
distclean: release-distclean debug-distclean FORCE
|
||||||
|
-$(DEL_FILE) Makefile
|
||||||
|
|
||||||
|
check: first
|
||||||
|
|
||||||
|
release-mocclean: $(MAKEFILE).Release
|
||||||
|
$(MAKE) -f $(MAKEFILE).Release mocclean
|
||||||
|
debug-mocclean: $(MAKEFILE).Debug
|
||||||
|
$(MAKE) -f $(MAKEFILE).Debug mocclean
|
||||||
|
mocclean: release-mocclean debug-mocclean
|
||||||
|
|
||||||
|
release-mocables: $(MAKEFILE).Release
|
||||||
|
$(MAKE) -f $(MAKEFILE).Release mocables
|
||||||
|
debug-mocables: $(MAKEFILE).Debug
|
||||||
|
$(MAKE) -f $(MAKEFILE).Debug mocables
|
||||||
|
mocables: release-mocables debug-mocables
|
||||||
|
FORCE:
|
||||||
|
|
||||||
|
$(MAKEFILE).Release: Makefile
|
||||||
|
$(MAKEFILE).Debug: Makefile
|
||||||
709
Makefile.Debug
Normal file
@ -0,0 +1,709 @@
|
|||||||
|
#############################################################################
|
||||||
|
# Makefile for building: OutilZT
|
||||||
|
# Generated by qmake (2.01a) (Qt 4.8.1) on: Wed May 18 10:55:42 2016
|
||||||
|
# Project: OutilZT.pro
|
||||||
|
# Template: app
|
||||||
|
#############################################################################
|
||||||
|
|
||||||
|
####### Compiler, tools and options
|
||||||
|
|
||||||
|
CC = gcc
|
||||||
|
CXX = g++
|
||||||
|
DEFINES = -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN
|
||||||
|
CFLAGS = -g -Wall $(DEFINES)
|
||||||
|
CXXFLAGS = -g -frtti -fexceptions -mthreads -Wall $(DEFINES)
|
||||||
|
INCPATH = -I"..\..\Qt\4.8.1\include\QtCore" -I"..\..\Qt\4.8.1\include\QtNetwork" -I"..\..\Qt\4.8.1\include\QtGui" -I"..\..\Qt\4.8.1\include" -I"." -I"sources" -I"sources\GuiElements" -I"..\..\Qt\4.8.1\include\ActiveQt" -I"debug" -I"..\..\Qt\4.8.1\mkspecs\win32-g++"
|
||||||
|
LINK = g++
|
||||||
|
LFLAGS = -mthreads -Wl,-subsystem,windows
|
||||||
|
LIBS = -L"c:\Qt\4.8.1\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtNetworkd4 -lQtCored4
|
||||||
|
QMAKE = c:\Qt\4.8.1\bin\qmake.exe
|
||||||
|
IDC = c:\Qt\4.8.1\bin\idc.exe
|
||||||
|
IDL = midl
|
||||||
|
ZIP = zip -r -9
|
||||||
|
DEF_FILE =
|
||||||
|
RES_FILE =
|
||||||
|
COPY = copy /y
|
||||||
|
SED =
|
||||||
|
COPY_FILE = $(COPY)
|
||||||
|
COPY_DIR = xcopy /s /q /y /i
|
||||||
|
DEL_FILE = del
|
||||||
|
DEL_DIR = rmdir
|
||||||
|
MOVE = move
|
||||||
|
CHK_DIR_EXISTS= if not exist
|
||||||
|
MKDIR = mkdir
|
||||||
|
INSTALL_FILE = $(COPY_FILE)
|
||||||
|
INSTALL_PROGRAM = $(COPY_FILE)
|
||||||
|
INSTALL_DIR = $(COPY_DIR)
|
||||||
|
|
||||||
|
####### Output directory
|
||||||
|
|
||||||
|
OBJECTS_DIR = debug
|
||||||
|
|
||||||
|
####### Files
|
||||||
|
|
||||||
|
SOURCES = sources\main.cpp \
|
||||||
|
sources\OutilZT.cpp \
|
||||||
|
sources\MainPanel.cpp \
|
||||||
|
sources\GuiElements\MainPage.cpp \
|
||||||
|
sources\GuiElements\GuiPage.cpp \
|
||||||
|
sources\GuiElements\PushButton.cpp \
|
||||||
|
sources\GuiElements\LogViewPage.cpp \
|
||||||
|
sources\GuiElements\TextButtonWidget.cpp \
|
||||||
|
sources\GuiElements\RankRulerWidget.cpp \
|
||||||
|
sources\GuiElements\GraphCursorWidget.cpp \
|
||||||
|
sources\GuiElements\EventsRulerWidget.cpp \
|
||||||
|
sources\GuiElements\AnalogGraphItem.cpp \
|
||||||
|
sources\GuiElements\GraphItem.cpp \
|
||||||
|
sources\GuiElements\GraphRulerWidget.cpp \
|
||||||
|
sources\ZTData.cpp \
|
||||||
|
sources\LogMgr.cpp \
|
||||||
|
sources\TrainLogFileMgr.cpp \
|
||||||
|
sources\GuiElements\LogsListPage.cpp \
|
||||||
|
sources\GuiElements\OptionsPage.cpp \
|
||||||
|
sources\Settings.cpp \
|
||||||
|
sources\GuiElements\NetworkZTListPage.cpp \
|
||||||
|
sources\GuiElements\ToggleTextButtonWidget.cpp \
|
||||||
|
sources\GuiElements\NetworkCtrlPage.cpp \
|
||||||
|
sources\NetworkManager.cpp \
|
||||||
|
sources\GuiElements\TxRxWidget.cpp \
|
||||||
|
sources\TCPProtocol.cpp \
|
||||||
|
sources\GuiElements\RemoteZTPage.cpp \
|
||||||
|
sources\GuiElements\ZTLogViewerPage.cpp \
|
||||||
|
sources\GuiElements\ProgressBarPage.cpp \
|
||||||
|
sources\GuiElements\RemoteZTCtrlPage.cpp \
|
||||||
|
sources\GuiElements\ToggleButtonWidget.cpp \
|
||||||
|
sources\UDPProtocol.cpp \
|
||||||
|
sources\GuiElements\DatabaseMgrPage.cpp \
|
||||||
|
sources\GuiElements\ZTLogsListPage.cpp \
|
||||||
|
sources\ZTLogFilesMgr.cpp \
|
||||||
|
sources\DirParserThread.cpp debug\moc_OutilZT.cpp \
|
||||||
|
debug\moc_MainPanel.cpp \
|
||||||
|
debug\moc_MainPage.cpp \
|
||||||
|
debug\moc_Guipage.cpp \
|
||||||
|
debug\moc_PushButton.cpp \
|
||||||
|
debug\moc_LogViewPage.cpp \
|
||||||
|
debug\moc_TextButtonWidget.cpp \
|
||||||
|
debug\moc_RankRulerWidget.cpp \
|
||||||
|
debug\moc_GraphCursorWidget.cpp \
|
||||||
|
debug\moc_EventsRulerWidget.cpp \
|
||||||
|
debug\moc_AnalogGraphItem.cpp \
|
||||||
|
debug\moc_GraphItem.cpp \
|
||||||
|
debug\moc_GraphRulerWidget.cpp \
|
||||||
|
debug\moc_LogMgr.cpp \
|
||||||
|
debug\moc_LogsListPage.cpp \
|
||||||
|
debug\moc_OptionsPage.cpp \
|
||||||
|
debug\moc_NetworkZTListPage.cpp \
|
||||||
|
debug\moc_ToggleTextButtonWidget.cpp \
|
||||||
|
debug\moc_NetworkCtrlPage.cpp \
|
||||||
|
debug\moc_NetworkManager.cpp \
|
||||||
|
debug\moc_TxRxWidget.cpp \
|
||||||
|
debug\moc_RemoteZTPage.cpp \
|
||||||
|
debug\moc_ZTLogViewerPage.cpp \
|
||||||
|
debug\moc_ProgressBarPage.cpp \
|
||||||
|
debug\moc_RemoteZTCtrlPage.cpp \
|
||||||
|
debug\moc_ToggleButtonWidget.cpp \
|
||||||
|
debug\moc_DatabaseMgrPage.cpp \
|
||||||
|
debug\moc_ZTLogsListPage.cpp \
|
||||||
|
debug\moc_ZTLogFilesMgr.cpp \
|
||||||
|
debug\moc_DirParserThread.cpp
|
||||||
|
OBJECTS = debug/main.o \
|
||||||
|
debug/OutilZT.o \
|
||||||
|
debug/MainPanel.o \
|
||||||
|
debug/MainPage.o \
|
||||||
|
debug/GuiPage.o \
|
||||||
|
debug/PushButton.o \
|
||||||
|
debug/LogViewPage.o \
|
||||||
|
debug/TextButtonWidget.o \
|
||||||
|
debug/RankRulerWidget.o \
|
||||||
|
debug/GraphCursorWidget.o \
|
||||||
|
debug/EventsRulerWidget.o \
|
||||||
|
debug/AnalogGraphItem.o \
|
||||||
|
debug/GraphItem.o \
|
||||||
|
debug/GraphRulerWidget.o \
|
||||||
|
debug/ZTData.o \
|
||||||
|
debug/LogMgr.o \
|
||||||
|
debug/TrainLogFileMgr.o \
|
||||||
|
debug/LogsListPage.o \
|
||||||
|
debug/OptionsPage.o \
|
||||||
|
debug/Settings.o \
|
||||||
|
debug/NetworkZTListPage.o \
|
||||||
|
debug/ToggleTextButtonWidget.o \
|
||||||
|
debug/NetworkCtrlPage.o \
|
||||||
|
debug/NetworkManager.o \
|
||||||
|
debug/TxRxWidget.o \
|
||||||
|
debug/TCPProtocol.o \
|
||||||
|
debug/RemoteZTPage.o \
|
||||||
|
debug/ZTLogViewerPage.o \
|
||||||
|
debug/ProgressBarPage.o \
|
||||||
|
debug/RemoteZTCtrlPage.o \
|
||||||
|
debug/ToggleButtonWidget.o \
|
||||||
|
debug/UDPProtocol.o \
|
||||||
|
debug/DatabaseMgrPage.o \
|
||||||
|
debug/ZTLogsListPage.o \
|
||||||
|
debug/ZTLogFilesMgr.o \
|
||||||
|
debug/DirParserThread.o \
|
||||||
|
debug/moc_OutilZT.o \
|
||||||
|
debug/moc_MainPanel.o \
|
||||||
|
debug/moc_MainPage.o \
|
||||||
|
debug/moc_Guipage.o \
|
||||||
|
debug/moc_PushButton.o \
|
||||||
|
debug/moc_LogViewPage.o \
|
||||||
|
debug/moc_TextButtonWidget.o \
|
||||||
|
debug/moc_RankRulerWidget.o \
|
||||||
|
debug/moc_GraphCursorWidget.o \
|
||||||
|
debug/moc_EventsRulerWidget.o \
|
||||||
|
debug/moc_AnalogGraphItem.o \
|
||||||
|
debug/moc_GraphItem.o \
|
||||||
|
debug/moc_GraphRulerWidget.o \
|
||||||
|
debug/moc_LogMgr.o \
|
||||||
|
debug/moc_LogsListPage.o \
|
||||||
|
debug/moc_OptionsPage.o \
|
||||||
|
debug/moc_NetworkZTListPage.o \
|
||||||
|
debug/moc_ToggleTextButtonWidget.o \
|
||||||
|
debug/moc_NetworkCtrlPage.o \
|
||||||
|
debug/moc_NetworkManager.o \
|
||||||
|
debug/moc_TxRxWidget.o \
|
||||||
|
debug/moc_RemoteZTPage.o \
|
||||||
|
debug/moc_ZTLogViewerPage.o \
|
||||||
|
debug/moc_ProgressBarPage.o \
|
||||||
|
debug/moc_RemoteZTCtrlPage.o \
|
||||||
|
debug/moc_ToggleButtonWidget.o \
|
||||||
|
debug/moc_DatabaseMgrPage.o \
|
||||||
|
debug/moc_ZTLogsListPage.o \
|
||||||
|
debug/moc_ZTLogFilesMgr.o \
|
||||||
|
debug/moc_DirParserThread.o
|
||||||
|
DIST =
|
||||||
|
QMAKE_TARGET = OutilZT
|
||||||
|
DESTDIR = debug\ #avoid trailing-slash linebreak
|
||||||
|
TARGET = OutilZT.exe
|
||||||
|
DESTDIR_TARGET = debug\OutilZT.exe
|
||||||
|
|
||||||
|
####### Implicit rules
|
||||||
|
|
||||||
|
.SUFFIXES: .cpp .cc .cxx .c
|
||||||
|
|
||||||
|
.cpp.o:
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
|
||||||
|
|
||||||
|
.cc.o:
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
|
||||||
|
|
||||||
|
.cxx.o:
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
|
||||||
|
|
||||||
|
.c.o:
|
||||||
|
$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
|
||||||
|
|
||||||
|
####### Build rules
|
||||||
|
|
||||||
|
first: all
|
||||||
|
all: Makefile.Debug $(DESTDIR_TARGET)
|
||||||
|
|
||||||
|
$(DESTDIR_TARGET): $(OBJECTS)
|
||||||
|
$(LINK) $(LFLAGS) -o $(DESTDIR_TARGET) object_script.OutilZT.Debug $(LIBS)
|
||||||
|
|
||||||
|
qmake: FORCE
|
||||||
|
@$(QMAKE) -spec ..\..\Qt\4.8.1\mkspecs\win32-g++ CONFIG+=release -o Makefile.Debug OutilZT.pro
|
||||||
|
|
||||||
|
dist:
|
||||||
|
$(ZIP) OutilZT.zip $(SOURCES) $(DIST) OutilZT.pro ..\..\Qt\4.8.1\mkspecs\qconfig.pri ..\..\Qt\4.8.1\mkspecs\modules\qt_webkit_version.pri ..\..\Qt\4.8.1\mkspecs\features\qt_functions.prf ..\..\Qt\4.8.1\mkspecs\features\qt_config.prf ..\..\Qt\4.8.1\mkspecs\features\exclusive_builds.prf ..\..\Qt\4.8.1\mkspecs\features\default_pre.prf ..\..\Qt\4.8.1\mkspecs\features\win32\default_pre.prf ..\..\Qt\4.8.1\mkspecs\features\debug.prf ..\..\Qt\4.8.1\mkspecs\features\debug_and_release.prf ..\..\Qt\4.8.1\mkspecs\features\default_post.prf ..\..\Qt\4.8.1\mkspecs\features\win32\default_post.prf ..\..\Qt\4.8.1\mkspecs\features\build_pass.prf ..\..\Qt\4.8.1\mkspecs\features\win32\rtti.prf ..\..\Qt\4.8.1\mkspecs\features\win32\exceptions.prf ..\..\Qt\4.8.1\mkspecs\features\win32\stl.prf ..\..\Qt\4.8.1\mkspecs\features\shared.prf ..\..\Qt\4.8.1\mkspecs\features\warn_on.prf ..\..\Qt\4.8.1\mkspecs\features\qt.prf ..\..\Qt\4.8.1\mkspecs\features\win32\thread.prf ..\..\Qt\4.8.1\mkspecs\features\moc.prf ..\..\Qt\4.8.1\mkspecs\features\win32\windows.prf ..\..\Qt\4.8.1\mkspecs\features\resources.prf ..\..\Qt\4.8.1\mkspecs\features\uic.prf ..\..\Qt\4.8.1\mkspecs\features\yacc.prf ..\..\Qt\4.8.1\mkspecs\features\lex.prf ..\..\Qt\4.8.1\mkspecs\features\include_source_dir.prf c:\Qt\4.8.1\lib\qtmaind.prl HEADERS RESOURCES IMAGES SOURCES OBJECTIVE_SOURCES FORMS YACCSOURCES YACCSOURCES LEXSOURCES
|
||||||
|
|
||||||
|
clean: compiler_clean
|
||||||
|
-$(DEL_FILE) debug\main.o debug\OutilZT.o debug\MainPanel.o debug\MainPage.o debug\GuiPage.o debug\PushButton.o debug\LogViewPage.o debug\TextButtonWidget.o debug\RankRulerWidget.o debug\GraphCursorWidget.o debug\EventsRulerWidget.o debug\AnalogGraphItem.o debug\GraphItem.o debug\GraphRulerWidget.o debug\ZTData.o debug\LogMgr.o debug\TrainLogFileMgr.o debug\LogsListPage.o debug\OptionsPage.o debug\Settings.o debug\NetworkZTListPage.o debug\ToggleTextButtonWidget.o debug\NetworkCtrlPage.o debug\NetworkManager.o debug\TxRxWidget.o debug\TCPProtocol.o debug\RemoteZTPage.o debug\ZTLogViewerPage.o debug\ProgressBarPage.o debug\RemoteZTCtrlPage.o debug\ToggleButtonWidget.o debug\UDPProtocol.o debug\DatabaseMgrPage.o debug\ZTLogsListPage.o debug\ZTLogFilesMgr.o debug\DirParserThread.o debug\moc_OutilZT.o debug\moc_MainPanel.o debug\moc_MainPage.o debug\moc_Guipage.o debug\moc_PushButton.o debug\moc_LogViewPage.o debug\moc_TextButtonWidget.o debug\moc_RankRulerWidget.o debug\moc_GraphCursorWidget.o debug\moc_EventsRulerWidget.o debug\moc_AnalogGraphItem.o debug\moc_GraphItem.o debug\moc_GraphRulerWidget.o debug\moc_LogMgr.o debug\moc_LogsListPage.o debug\moc_OptionsPage.o debug\moc_NetworkZTListPage.o debug\moc_ToggleTextButtonWidget.o debug\moc_NetworkCtrlPage.o debug\moc_NetworkManager.o debug\moc_TxRxWidget.o debug\moc_RemoteZTPage.o debug\moc_ZTLogViewerPage.o debug\moc_ProgressBarPage.o debug\moc_RemoteZTCtrlPage.o debug\moc_ToggleButtonWidget.o debug\moc_DatabaseMgrPage.o debug\moc_ZTLogsListPage.o debug\moc_ZTLogFilesMgr.o debug\moc_DirParserThread.o
|
||||||
|
|
||||||
|
distclean: clean
|
||||||
|
-$(DEL_FILE) $(DESTDIR_TARGET)
|
||||||
|
-$(DEL_FILE) Makefile.Debug
|
||||||
|
|
||||||
|
check: first
|
||||||
|
|
||||||
|
mocclean: compiler_moc_header_clean compiler_moc_source_clean
|
||||||
|
|
||||||
|
mocables: compiler_moc_header_make_all compiler_moc_source_make_all
|
||||||
|
|
||||||
|
compiler_moc_header_make_all: debug/moc_OutilZT.cpp debug/moc_MainPanel.cpp debug/moc_MainPage.cpp debug/moc_Guipage.cpp debug/moc_PushButton.cpp debug/moc_LogViewPage.cpp debug/moc_TextButtonWidget.cpp debug/moc_RankRulerWidget.cpp debug/moc_GraphCursorWidget.cpp debug/moc_EventsRulerWidget.cpp debug/moc_AnalogGraphItem.cpp debug/moc_GraphItem.cpp debug/moc_GraphRulerWidget.cpp debug/moc_LogMgr.cpp debug/moc_LogsListPage.cpp debug/moc_OptionsPage.cpp debug/moc_NetworkZTListPage.cpp debug/moc_ToggleTextButtonWidget.cpp debug/moc_NetworkCtrlPage.cpp debug/moc_NetworkManager.cpp debug/moc_TxRxWidget.cpp debug/moc_RemoteZTPage.cpp debug/moc_ZTLogViewerPage.cpp debug/moc_ProgressBarPage.cpp debug/moc_RemoteZTCtrlPage.cpp debug/moc_ToggleButtonWidget.cpp debug/moc_DatabaseMgrPage.cpp debug/moc_ZTLogsListPage.cpp debug/moc_ZTLogFilesMgr.cpp debug/moc_DirParserThread.cpp
|
||||||
|
compiler_moc_header_clean:
|
||||||
|
-$(DEL_FILE) debug\moc_OutilZT.cpp debug\moc_MainPanel.cpp debug\moc_MainPage.cpp debug\moc_Guipage.cpp debug\moc_PushButton.cpp debug\moc_LogViewPage.cpp debug\moc_TextButtonWidget.cpp debug\moc_RankRulerWidget.cpp debug\moc_GraphCursorWidget.cpp debug\moc_EventsRulerWidget.cpp debug\moc_AnalogGraphItem.cpp debug\moc_GraphItem.cpp debug\moc_GraphRulerWidget.cpp debug\moc_LogMgr.cpp debug\moc_LogsListPage.cpp debug\moc_OptionsPage.cpp debug\moc_NetworkZTListPage.cpp debug\moc_ToggleTextButtonWidget.cpp debug\moc_NetworkCtrlPage.cpp debug\moc_NetworkManager.cpp debug\moc_TxRxWidget.cpp debug\moc_RemoteZTPage.cpp debug\moc_ZTLogViewerPage.cpp debug\moc_ProgressBarPage.cpp debug\moc_RemoteZTCtrlPage.cpp debug\moc_ToggleButtonWidget.cpp debug\moc_DatabaseMgrPage.cpp debug\moc_ZTLogsListPage.cpp debug\moc_ZTLogFilesMgr.cpp debug\moc_DirParserThread.cpp
|
||||||
|
debug/moc_OutilZT.cpp: sources/MainPanel.h \
|
||||||
|
sources/GlobalDefine.h \
|
||||||
|
sources/LogMgr.h \
|
||||||
|
sources/ZTData.h \
|
||||||
|
sources/DirParserThread.h \
|
||||||
|
sources/TrainLogFileMgr.h \
|
||||||
|
sources/Settings.h \
|
||||||
|
sources/TCPProtocol.h \
|
||||||
|
sources/ZTLogFilesMgr.h \
|
||||||
|
sources/OutilZT.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\OutilZT.h -o debug\moc_OutilZT.cpp
|
||||||
|
|
||||||
|
debug/moc_MainPanel.cpp: sources/GlobalDefine.h \
|
||||||
|
sources/MainPanel.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\MainPanel.h -o debug\moc_MainPanel.cpp
|
||||||
|
|
||||||
|
debug/moc_MainPage.cpp: sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/MainPage.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\MainPage.h -o debug\moc_MainPage.cpp
|
||||||
|
|
||||||
|
debug/moc_Guipage.cpp: sources/GuiElements/Guipage.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\Guipage.h -o debug\moc_Guipage.cpp
|
||||||
|
|
||||||
|
debug/moc_PushButton.cpp: sources/GuiElements/PushButton.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\PushButton.h -o debug\moc_PushButton.cpp
|
||||||
|
|
||||||
|
debug/moc_LogViewPage.cpp: sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/GraphItem.h \
|
||||||
|
sources/GuiElements/GraphCursorWidget.h \
|
||||||
|
sources/GuiElements/GraphRulerWidget.h \
|
||||||
|
sources/GuiElements/AnalogGraphItem.h \
|
||||||
|
sources/GuiElements/RankRulerWidget.h \
|
||||||
|
sources/GuiElements/EventsRulerWidget.h \
|
||||||
|
sources/GuiElements/LogViewPage.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\LogViewPage.h -o debug\moc_LogViewPage.cpp
|
||||||
|
|
||||||
|
debug/moc_TextButtonWidget.cpp: sources/GuiElements/TextButtonWidget.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\TextButtonWidget.h -o debug\moc_TextButtonWidget.cpp
|
||||||
|
|
||||||
|
debug/moc_RankRulerWidget.cpp: sources/GuiElements/RankRulerWidget.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\RankRulerWidget.h -o debug\moc_RankRulerWidget.cpp
|
||||||
|
|
||||||
|
debug/moc_GraphCursorWidget.cpp: sources/GuiElements/GraphCursorWidget.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\GraphCursorWidget.h -o debug\moc_GraphCursorWidget.cpp
|
||||||
|
|
||||||
|
debug/moc_EventsRulerWidget.cpp: sources/GuiElements/EventsRulerWidget.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\EventsRulerWidget.h -o debug\moc_EventsRulerWidget.cpp
|
||||||
|
|
||||||
|
debug/moc_AnalogGraphItem.cpp: sources/GuiElements/AnalogGraphItem.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\AnalogGraphItem.h -o debug\moc_AnalogGraphItem.cpp
|
||||||
|
|
||||||
|
debug/moc_GraphItem.cpp: sources/GuiElements/GraphItem.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\GraphItem.h -o debug\moc_GraphItem.cpp
|
||||||
|
|
||||||
|
debug/moc_GraphRulerWidget.cpp: sources/GuiElements/GraphRulerWidget.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\GraphRulerWidget.h -o debug\moc_GraphRulerWidget.cpp
|
||||||
|
|
||||||
|
debug/moc_LogMgr.cpp: sources/ZTData.h \
|
||||||
|
sources/GlobalDefine.h \
|
||||||
|
sources/DirParserThread.h \
|
||||||
|
sources/TrainLogFileMgr.h \
|
||||||
|
sources/LogMgr.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\LogMgr.h -o debug\moc_LogMgr.cpp
|
||||||
|
|
||||||
|
debug/moc_LogsListPage.cpp: sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/LogsListPage.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\LogsListPage.h -o debug\moc_LogsListPage.cpp
|
||||||
|
|
||||||
|
debug/moc_OptionsPage.cpp: sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/OptionsPage.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\OptionsPage.h -o debug\moc_OptionsPage.cpp
|
||||||
|
|
||||||
|
debug/moc_NetworkZTListPage.cpp: sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/NetworkZTListPage.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\NetworkZTListPage.h -o debug\moc_NetworkZTListPage.cpp
|
||||||
|
|
||||||
|
debug/moc_ToggleTextButtonWidget.cpp: sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/ToggleTextButtonWidget.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\ToggleTextButtonWidget.h -o debug\moc_ToggleTextButtonWidget.cpp
|
||||||
|
|
||||||
|
debug/moc_NetworkCtrlPage.cpp: sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/ToggleTextButtonWidget.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/TxRxWidget.h \
|
||||||
|
sources/GuiElements/NetworkCtrlPage.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\NetworkCtrlPage.h -o debug\moc_NetworkCtrlPage.cpp
|
||||||
|
|
||||||
|
debug/moc_NetworkManager.cpp: sources/GlobalDefine.h \
|
||||||
|
sources/ZTData.h \
|
||||||
|
sources/TCPProtocol.h \
|
||||||
|
sources/UDPProtocol.h \
|
||||||
|
sources/NetworkManager.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\NetworkManager.h -o debug\moc_NetworkManager.cpp
|
||||||
|
|
||||||
|
debug/moc_TxRxWidget.cpp: sources/GuiElements/TxRxWidget.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\TxRxWidget.h -o debug\moc_TxRxWidget.cpp
|
||||||
|
|
||||||
|
debug/moc_RemoteZTPage.cpp: sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/ToggleTextButtonWidget.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/RemoteZTPage.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\RemoteZTPage.h -o debug\moc_RemoteZTPage.cpp
|
||||||
|
|
||||||
|
debug/moc_ZTLogViewerPage.cpp: sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/ZTLogViewerPage.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\ZTLogViewerPage.h -o debug\moc_ZTLogViewerPage.cpp
|
||||||
|
|
||||||
|
debug/moc_ProgressBarPage.cpp: sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/ProgressBarPage.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\ProgressBarPage.h -o debug\moc_ProgressBarPage.cpp
|
||||||
|
|
||||||
|
debug/moc_RemoteZTCtrlPage.cpp: sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/ToggleButtonWidget.h \
|
||||||
|
sources/GuiElements/RemoteZTCtrlPage.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\RemoteZTCtrlPage.h -o debug\moc_RemoteZTCtrlPage.cpp
|
||||||
|
|
||||||
|
debug/moc_ToggleButtonWidget.cpp: sources/GuiElements/ToggleButtonWidget.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\ToggleButtonWidget.h -o debug\moc_ToggleButtonWidget.cpp
|
||||||
|
|
||||||
|
debug/moc_DatabaseMgrPage.cpp: sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/DatabaseMgrPage.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\DatabaseMgrPage.h -o debug\moc_DatabaseMgrPage.cpp
|
||||||
|
|
||||||
|
debug/moc_ZTLogsListPage.cpp: sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/ZTLogsListPage.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\ZTLogsListPage.h -o debug\moc_ZTLogsListPage.cpp
|
||||||
|
|
||||||
|
debug/moc_ZTLogFilesMgr.cpp: sources/ZTData.h \
|
||||||
|
sources/GlobalDefine.h \
|
||||||
|
sources/DirParserThread.h \
|
||||||
|
sources/TrainLogFileMgr.h \
|
||||||
|
sources/ZTLogFilesMgr.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\ZTLogFilesMgr.h -o debug\moc_ZTLogFilesMgr.cpp
|
||||||
|
|
||||||
|
debug/moc_DirParserThread.cpp: sources/GlobalDefine.h \
|
||||||
|
sources/TrainLogFileMgr.h \
|
||||||
|
sources/ZTData.h \
|
||||||
|
sources/DirParserThread.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\DirParserThread.h -o debug\moc_DirParserThread.cpp
|
||||||
|
|
||||||
|
compiler_rcc_make_all:
|
||||||
|
compiler_rcc_clean:
|
||||||
|
compiler_image_collection_make_all: qmake_image_collection.cpp
|
||||||
|
compiler_image_collection_clean:
|
||||||
|
-$(DEL_FILE) qmake_image_collection.cpp
|
||||||
|
compiler_moc_source_make_all:
|
||||||
|
compiler_moc_source_clean:
|
||||||
|
compiler_uic_make_all:
|
||||||
|
compiler_uic_clean:
|
||||||
|
compiler_yacc_decl_make_all:
|
||||||
|
compiler_yacc_decl_clean:
|
||||||
|
compiler_yacc_impl_make_all:
|
||||||
|
compiler_yacc_impl_clean:
|
||||||
|
compiler_lex_make_all:
|
||||||
|
compiler_lex_clean:
|
||||||
|
compiler_clean: compiler_moc_header_clean
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
####### Compile
|
||||||
|
|
||||||
|
debug/main.o: sources/main.cpp sources/OutilZT.h \
|
||||||
|
sources/MainPanel.h \
|
||||||
|
sources/GlobalDefine.h \
|
||||||
|
sources/LogMgr.h \
|
||||||
|
sources/ZTData.h \
|
||||||
|
sources/DirParserThread.h \
|
||||||
|
sources/TrainLogFileMgr.h \
|
||||||
|
sources/Settings.h \
|
||||||
|
sources/TCPProtocol.h \
|
||||||
|
sources/ZTLogFilesMgr.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\main.o sources\main.cpp
|
||||||
|
|
||||||
|
debug/OutilZT.o: sources/OutilZT.cpp sources/OutilZT.h \
|
||||||
|
sources/MainPanel.h \
|
||||||
|
sources/GlobalDefine.h \
|
||||||
|
sources/LogMgr.h \
|
||||||
|
sources/ZTData.h \
|
||||||
|
sources/DirParserThread.h \
|
||||||
|
sources/TrainLogFileMgr.h \
|
||||||
|
sources/Settings.h \
|
||||||
|
sources/TCPProtocol.h \
|
||||||
|
sources/ZTLogFilesMgr.h \
|
||||||
|
sources/NetworkManager.h \
|
||||||
|
sources/UDPProtocol.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\OutilZT.o sources\OutilZT.cpp
|
||||||
|
|
||||||
|
debug/MainPanel.o: sources/MainPanel.cpp sources/MainPanel.h \
|
||||||
|
sources/GlobalDefine.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\MainPanel.o sources\MainPanel.cpp
|
||||||
|
|
||||||
|
debug/MainPage.o: sources/GuiElements/MainPage.cpp sources/GuiElements/MainPage.h \
|
||||||
|
sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\MainPage.o sources\GuiElements\MainPage.cpp
|
||||||
|
|
||||||
|
debug/GuiPage.o: sources/GuiElements/GuiPage.cpp sources/GuiElements/Guipage.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\GuiPage.o sources\GuiElements\GuiPage.cpp
|
||||||
|
|
||||||
|
debug/PushButton.o: sources/GuiElements/PushButton.cpp sources/GuiElements/PushButton.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\PushButton.o sources\GuiElements\PushButton.cpp
|
||||||
|
|
||||||
|
debug/LogViewPage.o: sources/GuiElements/LogViewPage.cpp sources/GuiElements/LogViewPage.h \
|
||||||
|
sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/GraphItem.h \
|
||||||
|
sources/GuiElements/GraphCursorWidget.h \
|
||||||
|
sources/GuiElements/GraphRulerWidget.h \
|
||||||
|
sources/GuiElements/AnalogGraphItem.h \
|
||||||
|
sources/GuiElements/RankRulerWidget.h \
|
||||||
|
sources/GuiElements/EventsRulerWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\LogViewPage.o sources\GuiElements\LogViewPage.cpp
|
||||||
|
|
||||||
|
debug/TextButtonWidget.o: sources/GuiElements/TextButtonWidget.cpp sources/GuiElements/TextButtonWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\TextButtonWidget.o sources\GuiElements\TextButtonWidget.cpp
|
||||||
|
|
||||||
|
debug/RankRulerWidget.o: sources/GuiElements/RankRulerWidget.cpp sources/GuiElements/RankRulerWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\RankRulerWidget.o sources\GuiElements\RankRulerWidget.cpp
|
||||||
|
|
||||||
|
debug/GraphCursorWidget.o: sources/GuiElements/GraphCursorWidget.cpp sources/GuiElements/GraphCursorWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\GraphCursorWidget.o sources\GuiElements\GraphCursorWidget.cpp
|
||||||
|
|
||||||
|
debug/EventsRulerWidget.o: sources/GuiElements/EventsRulerWidget.cpp sources/GuiElements/EventsRulerWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\EventsRulerWidget.o sources\GuiElements\EventsRulerWidget.cpp
|
||||||
|
|
||||||
|
debug/AnalogGraphItem.o: sources/GuiElements/AnalogGraphItem.cpp sources/GuiElements/AnalogGraphItem.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\AnalogGraphItem.o sources\GuiElements\AnalogGraphItem.cpp
|
||||||
|
|
||||||
|
debug/GraphItem.o: sources/GuiElements/GraphItem.cpp sources/GuiElements/GraphItem.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\GraphItem.o sources\GuiElements\GraphItem.cpp
|
||||||
|
|
||||||
|
debug/GraphRulerWidget.o: sources/GuiElements/GraphRulerWidget.cpp sources/GuiElements/GraphRulerWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\GraphRulerWidget.o sources\GuiElements\GraphRulerWidget.cpp
|
||||||
|
|
||||||
|
debug/ZTData.o: sources/ZTData.cpp sources/ZTData.h \
|
||||||
|
sources/GlobalDefine.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\ZTData.o sources\ZTData.cpp
|
||||||
|
|
||||||
|
debug/LogMgr.o: sources/LogMgr.cpp sources/LogMgr.h \
|
||||||
|
sources/ZTData.h \
|
||||||
|
sources/GlobalDefine.h \
|
||||||
|
sources/DirParserThread.h \
|
||||||
|
sources/TrainLogFileMgr.h \
|
||||||
|
sources/OutilZT.h \
|
||||||
|
sources/MainPanel.h \
|
||||||
|
sources/Settings.h \
|
||||||
|
sources/TCPProtocol.h \
|
||||||
|
sources/ZTLogFilesMgr.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\LogMgr.o sources\LogMgr.cpp
|
||||||
|
|
||||||
|
debug/TrainLogFileMgr.o: sources/TrainLogFileMgr.cpp sources/TrainLogFileMgr.h \
|
||||||
|
sources/GlobalDefine.h \
|
||||||
|
sources/ZTData.h \
|
||||||
|
sources/LogMgr.h \
|
||||||
|
sources/DirParserThread.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\TrainLogFileMgr.o sources\TrainLogFileMgr.cpp
|
||||||
|
|
||||||
|
debug/LogsListPage.o: sources/GuiElements/LogsListPage.cpp sources/GuiElements/LogsListPage.h \
|
||||||
|
sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\LogsListPage.o sources\GuiElements\LogsListPage.cpp
|
||||||
|
|
||||||
|
debug/OptionsPage.o: sources/GuiElements/OptionsPage.cpp sources/GuiElements/OptionsPage.h \
|
||||||
|
sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\OptionsPage.o sources\GuiElements\OptionsPage.cpp
|
||||||
|
|
||||||
|
debug/Settings.o: sources/Settings.cpp sources/Settings.h \
|
||||||
|
sources/GlobalDefine.h \
|
||||||
|
sources/ZTData.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\Settings.o sources\Settings.cpp
|
||||||
|
|
||||||
|
debug/NetworkZTListPage.o: sources/GuiElements/NetworkZTListPage.cpp sources/GuiElements/NetworkZTListPage.h \
|
||||||
|
sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\NetworkZTListPage.o sources\GuiElements\NetworkZTListPage.cpp
|
||||||
|
|
||||||
|
debug/ToggleTextButtonWidget.o: sources/GuiElements/ToggleTextButtonWidget.cpp sources/GuiElements/TextButtonWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\ToggleTextButtonWidget.o sources\GuiElements\ToggleTextButtonWidget.cpp
|
||||||
|
|
||||||
|
debug/NetworkCtrlPage.o: sources/GuiElements/NetworkCtrlPage.cpp sources/GuiElements/NetworkCtrlPage.h \
|
||||||
|
sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/ToggleTextButtonWidget.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/TxRxWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\NetworkCtrlPage.o sources\GuiElements\NetworkCtrlPage.cpp
|
||||||
|
|
||||||
|
debug/NetworkManager.o: sources/NetworkManager.cpp sources/NetworkManager.h \
|
||||||
|
sources/GlobalDefine.h \
|
||||||
|
sources/ZTData.h \
|
||||||
|
sources/TCPProtocol.h \
|
||||||
|
sources/UDPProtocol.h \
|
||||||
|
sources/OutilZT.h \
|
||||||
|
sources/MainPanel.h \
|
||||||
|
sources/LogMgr.h \
|
||||||
|
sources/DirParserThread.h \
|
||||||
|
sources/TrainLogFileMgr.h \
|
||||||
|
sources/Settings.h \
|
||||||
|
sources/ZTLogFilesMgr.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\NetworkManager.o sources\NetworkManager.cpp
|
||||||
|
|
||||||
|
debug/TxRxWidget.o: sources/GuiElements/TxRxWidget.cpp sources/GuiElements/TxRxWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\TxRxWidget.o sources\GuiElements\TxRxWidget.cpp
|
||||||
|
|
||||||
|
debug/TCPProtocol.o: sources/TCPProtocol.cpp sources/TCPProtocol.h \
|
||||||
|
sources/GlobalDefine.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\TCPProtocol.o sources\TCPProtocol.cpp
|
||||||
|
|
||||||
|
debug/RemoteZTPage.o: sources/GuiElements/RemoteZTPage.cpp sources/GuiElements/RemoteZTPage.h \
|
||||||
|
sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/ToggleTextButtonWidget.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\RemoteZTPage.o sources\GuiElements\RemoteZTPage.cpp
|
||||||
|
|
||||||
|
debug/ZTLogViewerPage.o: sources/GuiElements/ZTLogViewerPage.cpp sources/GuiElements/ZTLogViewerPage.h \
|
||||||
|
sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\ZTLogViewerPage.o sources\GuiElements\ZTLogViewerPage.cpp
|
||||||
|
|
||||||
|
debug/ProgressBarPage.o: sources/GuiElements/ProgressBarPage.cpp sources/GuiElements/ProgressBarPage.h \
|
||||||
|
sources/GuiElements/Guipage.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\ProgressBarPage.o sources\GuiElements\ProgressBarPage.cpp
|
||||||
|
|
||||||
|
debug/RemoteZTCtrlPage.o: sources/GuiElements/RemoteZTCtrlPage.cpp sources/GuiElements/RemoteZTCtrlPage.h \
|
||||||
|
sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/ToggleButtonWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\RemoteZTCtrlPage.o sources\GuiElements\RemoteZTCtrlPage.cpp
|
||||||
|
|
||||||
|
debug/ToggleButtonWidget.o: sources/GuiElements/ToggleButtonWidget.cpp sources/GuiElements/ToggleButtonWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\ToggleButtonWidget.o sources\GuiElements\ToggleButtonWidget.cpp
|
||||||
|
|
||||||
|
debug/UDPProtocol.o: sources/UDPProtocol.cpp sources/UDPProtocol.h \
|
||||||
|
sources/GlobalDefine.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\UDPProtocol.o sources\UDPProtocol.cpp
|
||||||
|
|
||||||
|
debug/DatabaseMgrPage.o: sources/GuiElements/DatabaseMgrPage.cpp sources/GuiElements/DatabaseMgrPage.h \
|
||||||
|
sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\DatabaseMgrPage.o sources\GuiElements\DatabaseMgrPage.cpp
|
||||||
|
|
||||||
|
debug/ZTLogsListPage.o: sources/GuiElements/ZTLogsListPage.cpp sources/GuiElements/ZTLogsListPage.h \
|
||||||
|
sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\ZTLogsListPage.o sources\GuiElements\ZTLogsListPage.cpp
|
||||||
|
|
||||||
|
debug/ZTLogFilesMgr.o: sources/ZTLogFilesMgr.cpp sources/ZTLogFilesMgr.h \
|
||||||
|
sources/ZTData.h \
|
||||||
|
sources/GlobalDefine.h \
|
||||||
|
sources/DirParserThread.h \
|
||||||
|
sources/TrainLogFileMgr.h \
|
||||||
|
sources/OutilZT.h \
|
||||||
|
sources/MainPanel.h \
|
||||||
|
sources/LogMgr.h \
|
||||||
|
sources/Settings.h \
|
||||||
|
sources/TCPProtocol.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\ZTLogFilesMgr.o sources\ZTLogFilesMgr.cpp
|
||||||
|
|
||||||
|
debug/DirParserThread.o: sources/DirParserThread.cpp sources/DirParserThread.h \
|
||||||
|
sources/GlobalDefine.h \
|
||||||
|
sources/TrainLogFileMgr.h \
|
||||||
|
sources/ZTData.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\DirParserThread.o sources\DirParserThread.cpp
|
||||||
|
|
||||||
|
debug/moc_OutilZT.o: debug/moc_OutilZT.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_OutilZT.o debug\moc_OutilZT.cpp
|
||||||
|
|
||||||
|
debug/moc_MainPanel.o: debug/moc_MainPanel.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_MainPanel.o debug\moc_MainPanel.cpp
|
||||||
|
|
||||||
|
debug/moc_MainPage.o: debug/moc_MainPage.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_MainPage.o debug\moc_MainPage.cpp
|
||||||
|
|
||||||
|
debug/moc_Guipage.o: debug/moc_Guipage.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_Guipage.o debug\moc_Guipage.cpp
|
||||||
|
|
||||||
|
debug/moc_PushButton.o: debug/moc_PushButton.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_PushButton.o debug\moc_PushButton.cpp
|
||||||
|
|
||||||
|
debug/moc_LogViewPage.o: debug/moc_LogViewPage.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_LogViewPage.o debug\moc_LogViewPage.cpp
|
||||||
|
|
||||||
|
debug/moc_TextButtonWidget.o: debug/moc_TextButtonWidget.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_TextButtonWidget.o debug\moc_TextButtonWidget.cpp
|
||||||
|
|
||||||
|
debug/moc_RankRulerWidget.o: debug/moc_RankRulerWidget.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_RankRulerWidget.o debug\moc_RankRulerWidget.cpp
|
||||||
|
|
||||||
|
debug/moc_GraphCursorWidget.o: debug/moc_GraphCursorWidget.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_GraphCursorWidget.o debug\moc_GraphCursorWidget.cpp
|
||||||
|
|
||||||
|
debug/moc_EventsRulerWidget.o: debug/moc_EventsRulerWidget.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_EventsRulerWidget.o debug\moc_EventsRulerWidget.cpp
|
||||||
|
|
||||||
|
debug/moc_AnalogGraphItem.o: debug/moc_AnalogGraphItem.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_AnalogGraphItem.o debug\moc_AnalogGraphItem.cpp
|
||||||
|
|
||||||
|
debug/moc_GraphItem.o: debug/moc_GraphItem.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_GraphItem.o debug\moc_GraphItem.cpp
|
||||||
|
|
||||||
|
debug/moc_GraphRulerWidget.o: debug/moc_GraphRulerWidget.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_GraphRulerWidget.o debug\moc_GraphRulerWidget.cpp
|
||||||
|
|
||||||
|
debug/moc_LogMgr.o: debug/moc_LogMgr.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_LogMgr.o debug\moc_LogMgr.cpp
|
||||||
|
|
||||||
|
debug/moc_LogsListPage.o: debug/moc_LogsListPage.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_LogsListPage.o debug\moc_LogsListPage.cpp
|
||||||
|
|
||||||
|
debug/moc_OptionsPage.o: debug/moc_OptionsPage.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_OptionsPage.o debug\moc_OptionsPage.cpp
|
||||||
|
|
||||||
|
debug/moc_NetworkZTListPage.o: debug/moc_NetworkZTListPage.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_NetworkZTListPage.o debug\moc_NetworkZTListPage.cpp
|
||||||
|
|
||||||
|
debug/moc_ToggleTextButtonWidget.o: debug/moc_ToggleTextButtonWidget.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_ToggleTextButtonWidget.o debug\moc_ToggleTextButtonWidget.cpp
|
||||||
|
|
||||||
|
debug/moc_NetworkCtrlPage.o: debug/moc_NetworkCtrlPage.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_NetworkCtrlPage.o debug\moc_NetworkCtrlPage.cpp
|
||||||
|
|
||||||
|
debug/moc_NetworkManager.o: debug/moc_NetworkManager.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_NetworkManager.o debug\moc_NetworkManager.cpp
|
||||||
|
|
||||||
|
debug/moc_TxRxWidget.o: debug/moc_TxRxWidget.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_TxRxWidget.o debug\moc_TxRxWidget.cpp
|
||||||
|
|
||||||
|
debug/moc_RemoteZTPage.o: debug/moc_RemoteZTPage.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_RemoteZTPage.o debug\moc_RemoteZTPage.cpp
|
||||||
|
|
||||||
|
debug/moc_ZTLogViewerPage.o: debug/moc_ZTLogViewerPage.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_ZTLogViewerPage.o debug\moc_ZTLogViewerPage.cpp
|
||||||
|
|
||||||
|
debug/moc_ProgressBarPage.o: debug/moc_ProgressBarPage.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_ProgressBarPage.o debug\moc_ProgressBarPage.cpp
|
||||||
|
|
||||||
|
debug/moc_RemoteZTCtrlPage.o: debug/moc_RemoteZTCtrlPage.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_RemoteZTCtrlPage.o debug\moc_RemoteZTCtrlPage.cpp
|
||||||
|
|
||||||
|
debug/moc_ToggleButtonWidget.o: debug/moc_ToggleButtonWidget.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_ToggleButtonWidget.o debug\moc_ToggleButtonWidget.cpp
|
||||||
|
|
||||||
|
debug/moc_DatabaseMgrPage.o: debug/moc_DatabaseMgrPage.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_DatabaseMgrPage.o debug\moc_DatabaseMgrPage.cpp
|
||||||
|
|
||||||
|
debug/moc_ZTLogsListPage.o: debug/moc_ZTLogsListPage.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_ZTLogsListPage.o debug\moc_ZTLogsListPage.cpp
|
||||||
|
|
||||||
|
debug/moc_ZTLogFilesMgr.o: debug/moc_ZTLogFilesMgr.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_ZTLogFilesMgr.o debug\moc_ZTLogFilesMgr.cpp
|
||||||
|
|
||||||
|
debug/moc_DirParserThread.o: debug/moc_DirParserThread.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_DirParserThread.o debug\moc_DirParserThread.cpp
|
||||||
|
|
||||||
|
####### Install
|
||||||
|
|
||||||
|
install: FORCE
|
||||||
|
|
||||||
|
uninstall: FORCE
|
||||||
|
|
||||||
|
FORCE:
|
||||||
|
|
||||||
709
Makefile.Release
Normal file
@ -0,0 +1,709 @@
|
|||||||
|
#############################################################################
|
||||||
|
# Makefile for building: OutilZT
|
||||||
|
# Generated by qmake (2.01a) (Qt 4.8.1) on: Wed May 18 10:55:42 2016
|
||||||
|
# Project: OutilZT.pro
|
||||||
|
# Template: app
|
||||||
|
#############################################################################
|
||||||
|
|
||||||
|
####### Compiler, tools and options
|
||||||
|
|
||||||
|
CC = gcc
|
||||||
|
CXX = g++
|
||||||
|
DEFINES = -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN
|
||||||
|
CFLAGS = -O2 -Wall $(DEFINES)
|
||||||
|
CXXFLAGS = -O2 -frtti -fexceptions -mthreads -Wall $(DEFINES)
|
||||||
|
INCPATH = -I"..\..\Qt\4.8.1\include\QtCore" -I"..\..\Qt\4.8.1\include\QtNetwork" -I"..\..\Qt\4.8.1\include\QtGui" -I"..\..\Qt\4.8.1\include" -I"." -I"sources" -I"sources\GuiElements" -I"..\..\Qt\4.8.1\include\ActiveQt" -I"release" -I"..\..\Qt\4.8.1\mkspecs\win32-g++"
|
||||||
|
LINK = g++
|
||||||
|
LFLAGS = -Wl,-s -mthreads -Wl,-subsystem,windows
|
||||||
|
LIBS = -L"c:\Qt\4.8.1\lib" -lmingw32 -lqtmain -lQtGui4 -lQtNetwork4 -lQtCore4
|
||||||
|
QMAKE = c:\Qt\4.8.1\bin\qmake.exe
|
||||||
|
IDC = c:\Qt\4.8.1\bin\idc.exe
|
||||||
|
IDL = midl
|
||||||
|
ZIP = zip -r -9
|
||||||
|
DEF_FILE =
|
||||||
|
RES_FILE =
|
||||||
|
COPY = copy /y
|
||||||
|
SED =
|
||||||
|
COPY_FILE = $(COPY)
|
||||||
|
COPY_DIR = xcopy /s /q /y /i
|
||||||
|
DEL_FILE = del
|
||||||
|
DEL_DIR = rmdir
|
||||||
|
MOVE = move
|
||||||
|
CHK_DIR_EXISTS= if not exist
|
||||||
|
MKDIR = mkdir
|
||||||
|
INSTALL_FILE = $(COPY_FILE)
|
||||||
|
INSTALL_PROGRAM = $(COPY_FILE)
|
||||||
|
INSTALL_DIR = $(COPY_DIR)
|
||||||
|
|
||||||
|
####### Output directory
|
||||||
|
|
||||||
|
OBJECTS_DIR = release
|
||||||
|
|
||||||
|
####### Files
|
||||||
|
|
||||||
|
SOURCES = sources\main.cpp \
|
||||||
|
sources\OutilZT.cpp \
|
||||||
|
sources\MainPanel.cpp \
|
||||||
|
sources\GuiElements\MainPage.cpp \
|
||||||
|
sources\GuiElements\GuiPage.cpp \
|
||||||
|
sources\GuiElements\PushButton.cpp \
|
||||||
|
sources\GuiElements\LogViewPage.cpp \
|
||||||
|
sources\GuiElements\TextButtonWidget.cpp \
|
||||||
|
sources\GuiElements\RankRulerWidget.cpp \
|
||||||
|
sources\GuiElements\GraphCursorWidget.cpp \
|
||||||
|
sources\GuiElements\EventsRulerWidget.cpp \
|
||||||
|
sources\GuiElements\AnalogGraphItem.cpp \
|
||||||
|
sources\GuiElements\GraphItem.cpp \
|
||||||
|
sources\GuiElements\GraphRulerWidget.cpp \
|
||||||
|
sources\ZTData.cpp \
|
||||||
|
sources\LogMgr.cpp \
|
||||||
|
sources\TrainLogFileMgr.cpp \
|
||||||
|
sources\GuiElements\LogsListPage.cpp \
|
||||||
|
sources\GuiElements\OptionsPage.cpp \
|
||||||
|
sources\Settings.cpp \
|
||||||
|
sources\GuiElements\NetworkZTListPage.cpp \
|
||||||
|
sources\GuiElements\ToggleTextButtonWidget.cpp \
|
||||||
|
sources\GuiElements\NetworkCtrlPage.cpp \
|
||||||
|
sources\NetworkManager.cpp \
|
||||||
|
sources\GuiElements\TxRxWidget.cpp \
|
||||||
|
sources\TCPProtocol.cpp \
|
||||||
|
sources\GuiElements\RemoteZTPage.cpp \
|
||||||
|
sources\GuiElements\ZTLogViewerPage.cpp \
|
||||||
|
sources\GuiElements\ProgressBarPage.cpp \
|
||||||
|
sources\GuiElements\RemoteZTCtrlPage.cpp \
|
||||||
|
sources\GuiElements\ToggleButtonWidget.cpp \
|
||||||
|
sources\UDPProtocol.cpp \
|
||||||
|
sources\GuiElements\DatabaseMgrPage.cpp \
|
||||||
|
sources\GuiElements\ZTLogsListPage.cpp \
|
||||||
|
sources\ZTLogFilesMgr.cpp \
|
||||||
|
sources\DirParserThread.cpp release\moc_OutilZT.cpp \
|
||||||
|
release\moc_MainPanel.cpp \
|
||||||
|
release\moc_MainPage.cpp \
|
||||||
|
release\moc_Guipage.cpp \
|
||||||
|
release\moc_PushButton.cpp \
|
||||||
|
release\moc_LogViewPage.cpp \
|
||||||
|
release\moc_TextButtonWidget.cpp \
|
||||||
|
release\moc_RankRulerWidget.cpp \
|
||||||
|
release\moc_GraphCursorWidget.cpp \
|
||||||
|
release\moc_EventsRulerWidget.cpp \
|
||||||
|
release\moc_AnalogGraphItem.cpp \
|
||||||
|
release\moc_GraphItem.cpp \
|
||||||
|
release\moc_GraphRulerWidget.cpp \
|
||||||
|
release\moc_LogMgr.cpp \
|
||||||
|
release\moc_LogsListPage.cpp \
|
||||||
|
release\moc_OptionsPage.cpp \
|
||||||
|
release\moc_NetworkZTListPage.cpp \
|
||||||
|
release\moc_ToggleTextButtonWidget.cpp \
|
||||||
|
release\moc_NetworkCtrlPage.cpp \
|
||||||
|
release\moc_NetworkManager.cpp \
|
||||||
|
release\moc_TxRxWidget.cpp \
|
||||||
|
release\moc_RemoteZTPage.cpp \
|
||||||
|
release\moc_ZTLogViewerPage.cpp \
|
||||||
|
release\moc_ProgressBarPage.cpp \
|
||||||
|
release\moc_RemoteZTCtrlPage.cpp \
|
||||||
|
release\moc_ToggleButtonWidget.cpp \
|
||||||
|
release\moc_DatabaseMgrPage.cpp \
|
||||||
|
release\moc_ZTLogsListPage.cpp \
|
||||||
|
release\moc_ZTLogFilesMgr.cpp \
|
||||||
|
release\moc_DirParserThread.cpp
|
||||||
|
OBJECTS = release/main.o \
|
||||||
|
release/OutilZT.o \
|
||||||
|
release/MainPanel.o \
|
||||||
|
release/MainPage.o \
|
||||||
|
release/GuiPage.o \
|
||||||
|
release/PushButton.o \
|
||||||
|
release/LogViewPage.o \
|
||||||
|
release/TextButtonWidget.o \
|
||||||
|
release/RankRulerWidget.o \
|
||||||
|
release/GraphCursorWidget.o \
|
||||||
|
release/EventsRulerWidget.o \
|
||||||
|
release/AnalogGraphItem.o \
|
||||||
|
release/GraphItem.o \
|
||||||
|
release/GraphRulerWidget.o \
|
||||||
|
release/ZTData.o \
|
||||||
|
release/LogMgr.o \
|
||||||
|
release/TrainLogFileMgr.o \
|
||||||
|
release/LogsListPage.o \
|
||||||
|
release/OptionsPage.o \
|
||||||
|
release/Settings.o \
|
||||||
|
release/NetworkZTListPage.o \
|
||||||
|
release/ToggleTextButtonWidget.o \
|
||||||
|
release/NetworkCtrlPage.o \
|
||||||
|
release/NetworkManager.o \
|
||||||
|
release/TxRxWidget.o \
|
||||||
|
release/TCPProtocol.o \
|
||||||
|
release/RemoteZTPage.o \
|
||||||
|
release/ZTLogViewerPage.o \
|
||||||
|
release/ProgressBarPage.o \
|
||||||
|
release/RemoteZTCtrlPage.o \
|
||||||
|
release/ToggleButtonWidget.o \
|
||||||
|
release/UDPProtocol.o \
|
||||||
|
release/DatabaseMgrPage.o \
|
||||||
|
release/ZTLogsListPage.o \
|
||||||
|
release/ZTLogFilesMgr.o \
|
||||||
|
release/DirParserThread.o \
|
||||||
|
release/moc_OutilZT.o \
|
||||||
|
release/moc_MainPanel.o \
|
||||||
|
release/moc_MainPage.o \
|
||||||
|
release/moc_Guipage.o \
|
||||||
|
release/moc_PushButton.o \
|
||||||
|
release/moc_LogViewPage.o \
|
||||||
|
release/moc_TextButtonWidget.o \
|
||||||
|
release/moc_RankRulerWidget.o \
|
||||||
|
release/moc_GraphCursorWidget.o \
|
||||||
|
release/moc_EventsRulerWidget.o \
|
||||||
|
release/moc_AnalogGraphItem.o \
|
||||||
|
release/moc_GraphItem.o \
|
||||||
|
release/moc_GraphRulerWidget.o \
|
||||||
|
release/moc_LogMgr.o \
|
||||||
|
release/moc_LogsListPage.o \
|
||||||
|
release/moc_OptionsPage.o \
|
||||||
|
release/moc_NetworkZTListPage.o \
|
||||||
|
release/moc_ToggleTextButtonWidget.o \
|
||||||
|
release/moc_NetworkCtrlPage.o \
|
||||||
|
release/moc_NetworkManager.o \
|
||||||
|
release/moc_TxRxWidget.o \
|
||||||
|
release/moc_RemoteZTPage.o \
|
||||||
|
release/moc_ZTLogViewerPage.o \
|
||||||
|
release/moc_ProgressBarPage.o \
|
||||||
|
release/moc_RemoteZTCtrlPage.o \
|
||||||
|
release/moc_ToggleButtonWidget.o \
|
||||||
|
release/moc_DatabaseMgrPage.o \
|
||||||
|
release/moc_ZTLogsListPage.o \
|
||||||
|
release/moc_ZTLogFilesMgr.o \
|
||||||
|
release/moc_DirParserThread.o
|
||||||
|
DIST =
|
||||||
|
QMAKE_TARGET = OutilZT
|
||||||
|
DESTDIR = release\ #avoid trailing-slash linebreak
|
||||||
|
TARGET = OutilZT.exe
|
||||||
|
DESTDIR_TARGET = release\OutilZT.exe
|
||||||
|
|
||||||
|
####### Implicit rules
|
||||||
|
|
||||||
|
.SUFFIXES: .cpp .cc .cxx .c
|
||||||
|
|
||||||
|
.cpp.o:
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
|
||||||
|
|
||||||
|
.cc.o:
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
|
||||||
|
|
||||||
|
.cxx.o:
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
|
||||||
|
|
||||||
|
.c.o:
|
||||||
|
$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
|
||||||
|
|
||||||
|
####### Build rules
|
||||||
|
|
||||||
|
first: all
|
||||||
|
all: Makefile.Release $(DESTDIR_TARGET)
|
||||||
|
|
||||||
|
$(DESTDIR_TARGET): $(OBJECTS)
|
||||||
|
$(LINK) $(LFLAGS) -o $(DESTDIR_TARGET) object_script.OutilZT.Release $(LIBS)
|
||||||
|
|
||||||
|
qmake: FORCE
|
||||||
|
@$(QMAKE) -spec ..\..\Qt\4.8.1\mkspecs\win32-g++ CONFIG+=release -o Makefile.Release OutilZT.pro
|
||||||
|
|
||||||
|
dist:
|
||||||
|
$(ZIP) OutilZT.zip $(SOURCES) $(DIST) OutilZT.pro ..\..\Qt\4.8.1\mkspecs\qconfig.pri ..\..\Qt\4.8.1\mkspecs\modules\qt_webkit_version.pri ..\..\Qt\4.8.1\mkspecs\features\qt_functions.prf ..\..\Qt\4.8.1\mkspecs\features\qt_config.prf ..\..\Qt\4.8.1\mkspecs\features\exclusive_builds.prf ..\..\Qt\4.8.1\mkspecs\features\default_pre.prf ..\..\Qt\4.8.1\mkspecs\features\win32\default_pre.prf ..\..\Qt\4.8.1\mkspecs\features\release.prf ..\..\Qt\4.8.1\mkspecs\features\debug_and_release.prf ..\..\Qt\4.8.1\mkspecs\features\default_post.prf ..\..\Qt\4.8.1\mkspecs\features\win32\default_post.prf ..\..\Qt\4.8.1\mkspecs\features\build_pass.prf ..\..\Qt\4.8.1\mkspecs\features\win32\rtti.prf ..\..\Qt\4.8.1\mkspecs\features\win32\exceptions.prf ..\..\Qt\4.8.1\mkspecs\features\win32\stl.prf ..\..\Qt\4.8.1\mkspecs\features\shared.prf ..\..\Qt\4.8.1\mkspecs\features\warn_on.prf ..\..\Qt\4.8.1\mkspecs\features\qt.prf ..\..\Qt\4.8.1\mkspecs\features\win32\thread.prf ..\..\Qt\4.8.1\mkspecs\features\moc.prf ..\..\Qt\4.8.1\mkspecs\features\win32\windows.prf ..\..\Qt\4.8.1\mkspecs\features\resources.prf ..\..\Qt\4.8.1\mkspecs\features\uic.prf ..\..\Qt\4.8.1\mkspecs\features\yacc.prf ..\..\Qt\4.8.1\mkspecs\features\lex.prf ..\..\Qt\4.8.1\mkspecs\features\include_source_dir.prf c:\Qt\4.8.1\lib\qtmain.prl HEADERS RESOURCES IMAGES SOURCES OBJECTIVE_SOURCES FORMS YACCSOURCES YACCSOURCES LEXSOURCES
|
||||||
|
|
||||||
|
clean: compiler_clean
|
||||||
|
-$(DEL_FILE) release\main.o release\OutilZT.o release\MainPanel.o release\MainPage.o release\GuiPage.o release\PushButton.o release\LogViewPage.o release\TextButtonWidget.o release\RankRulerWidget.o release\GraphCursorWidget.o release\EventsRulerWidget.o release\AnalogGraphItem.o release\GraphItem.o release\GraphRulerWidget.o release\ZTData.o release\LogMgr.o release\TrainLogFileMgr.o release\LogsListPage.o release\OptionsPage.o release\Settings.o release\NetworkZTListPage.o release\ToggleTextButtonWidget.o release\NetworkCtrlPage.o release\NetworkManager.o release\TxRxWidget.o release\TCPProtocol.o release\RemoteZTPage.o release\ZTLogViewerPage.o release\ProgressBarPage.o release\RemoteZTCtrlPage.o release\ToggleButtonWidget.o release\UDPProtocol.o release\DatabaseMgrPage.o release\ZTLogsListPage.o release\ZTLogFilesMgr.o release\DirParserThread.o release\moc_OutilZT.o release\moc_MainPanel.o release\moc_MainPage.o release\moc_Guipage.o release\moc_PushButton.o release\moc_LogViewPage.o release\moc_TextButtonWidget.o release\moc_RankRulerWidget.o release\moc_GraphCursorWidget.o release\moc_EventsRulerWidget.o release\moc_AnalogGraphItem.o release\moc_GraphItem.o release\moc_GraphRulerWidget.o release\moc_LogMgr.o release\moc_LogsListPage.o release\moc_OptionsPage.o release\moc_NetworkZTListPage.o release\moc_ToggleTextButtonWidget.o release\moc_NetworkCtrlPage.o release\moc_NetworkManager.o release\moc_TxRxWidget.o release\moc_RemoteZTPage.o release\moc_ZTLogViewerPage.o release\moc_ProgressBarPage.o release\moc_RemoteZTCtrlPage.o release\moc_ToggleButtonWidget.o release\moc_DatabaseMgrPage.o release\moc_ZTLogsListPage.o release\moc_ZTLogFilesMgr.o release\moc_DirParserThread.o
|
||||||
|
|
||||||
|
distclean: clean
|
||||||
|
-$(DEL_FILE) $(DESTDIR_TARGET)
|
||||||
|
-$(DEL_FILE) Makefile.Release
|
||||||
|
|
||||||
|
check: first
|
||||||
|
|
||||||
|
mocclean: compiler_moc_header_clean compiler_moc_source_clean
|
||||||
|
|
||||||
|
mocables: compiler_moc_header_make_all compiler_moc_source_make_all
|
||||||
|
|
||||||
|
compiler_moc_header_make_all: release/moc_OutilZT.cpp release/moc_MainPanel.cpp release/moc_MainPage.cpp release/moc_Guipage.cpp release/moc_PushButton.cpp release/moc_LogViewPage.cpp release/moc_TextButtonWidget.cpp release/moc_RankRulerWidget.cpp release/moc_GraphCursorWidget.cpp release/moc_EventsRulerWidget.cpp release/moc_AnalogGraphItem.cpp release/moc_GraphItem.cpp release/moc_GraphRulerWidget.cpp release/moc_LogMgr.cpp release/moc_LogsListPage.cpp release/moc_OptionsPage.cpp release/moc_NetworkZTListPage.cpp release/moc_ToggleTextButtonWidget.cpp release/moc_NetworkCtrlPage.cpp release/moc_NetworkManager.cpp release/moc_TxRxWidget.cpp release/moc_RemoteZTPage.cpp release/moc_ZTLogViewerPage.cpp release/moc_ProgressBarPage.cpp release/moc_RemoteZTCtrlPage.cpp release/moc_ToggleButtonWidget.cpp release/moc_DatabaseMgrPage.cpp release/moc_ZTLogsListPage.cpp release/moc_ZTLogFilesMgr.cpp release/moc_DirParserThread.cpp
|
||||||
|
compiler_moc_header_clean:
|
||||||
|
-$(DEL_FILE) release\moc_OutilZT.cpp release\moc_MainPanel.cpp release\moc_MainPage.cpp release\moc_Guipage.cpp release\moc_PushButton.cpp release\moc_LogViewPage.cpp release\moc_TextButtonWidget.cpp release\moc_RankRulerWidget.cpp release\moc_GraphCursorWidget.cpp release\moc_EventsRulerWidget.cpp release\moc_AnalogGraphItem.cpp release\moc_GraphItem.cpp release\moc_GraphRulerWidget.cpp release\moc_LogMgr.cpp release\moc_LogsListPage.cpp release\moc_OptionsPage.cpp release\moc_NetworkZTListPage.cpp release\moc_ToggleTextButtonWidget.cpp release\moc_NetworkCtrlPage.cpp release\moc_NetworkManager.cpp release\moc_TxRxWidget.cpp release\moc_RemoteZTPage.cpp release\moc_ZTLogViewerPage.cpp release\moc_ProgressBarPage.cpp release\moc_RemoteZTCtrlPage.cpp release\moc_ToggleButtonWidget.cpp release\moc_DatabaseMgrPage.cpp release\moc_ZTLogsListPage.cpp release\moc_ZTLogFilesMgr.cpp release\moc_DirParserThread.cpp
|
||||||
|
release/moc_OutilZT.cpp: sources/MainPanel.h \
|
||||||
|
sources/GlobalDefine.h \
|
||||||
|
sources/LogMgr.h \
|
||||||
|
sources/ZTData.h \
|
||||||
|
sources/DirParserThread.h \
|
||||||
|
sources/TrainLogFileMgr.h \
|
||||||
|
sources/Settings.h \
|
||||||
|
sources/TCPProtocol.h \
|
||||||
|
sources/ZTLogFilesMgr.h \
|
||||||
|
sources/OutilZT.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\OutilZT.h -o release\moc_OutilZT.cpp
|
||||||
|
|
||||||
|
release/moc_MainPanel.cpp: sources/GlobalDefine.h \
|
||||||
|
sources/MainPanel.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\MainPanel.h -o release\moc_MainPanel.cpp
|
||||||
|
|
||||||
|
release/moc_MainPage.cpp: sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/MainPage.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\MainPage.h -o release\moc_MainPage.cpp
|
||||||
|
|
||||||
|
release/moc_Guipage.cpp: sources/GuiElements/Guipage.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\Guipage.h -o release\moc_Guipage.cpp
|
||||||
|
|
||||||
|
release/moc_PushButton.cpp: sources/GuiElements/PushButton.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\PushButton.h -o release\moc_PushButton.cpp
|
||||||
|
|
||||||
|
release/moc_LogViewPage.cpp: sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/GraphItem.h \
|
||||||
|
sources/GuiElements/GraphCursorWidget.h \
|
||||||
|
sources/GuiElements/GraphRulerWidget.h \
|
||||||
|
sources/GuiElements/AnalogGraphItem.h \
|
||||||
|
sources/GuiElements/RankRulerWidget.h \
|
||||||
|
sources/GuiElements/EventsRulerWidget.h \
|
||||||
|
sources/GuiElements/LogViewPage.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\LogViewPage.h -o release\moc_LogViewPage.cpp
|
||||||
|
|
||||||
|
release/moc_TextButtonWidget.cpp: sources/GuiElements/TextButtonWidget.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\TextButtonWidget.h -o release\moc_TextButtonWidget.cpp
|
||||||
|
|
||||||
|
release/moc_RankRulerWidget.cpp: sources/GuiElements/RankRulerWidget.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\RankRulerWidget.h -o release\moc_RankRulerWidget.cpp
|
||||||
|
|
||||||
|
release/moc_GraphCursorWidget.cpp: sources/GuiElements/GraphCursorWidget.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\GraphCursorWidget.h -o release\moc_GraphCursorWidget.cpp
|
||||||
|
|
||||||
|
release/moc_EventsRulerWidget.cpp: sources/GuiElements/EventsRulerWidget.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\EventsRulerWidget.h -o release\moc_EventsRulerWidget.cpp
|
||||||
|
|
||||||
|
release/moc_AnalogGraphItem.cpp: sources/GuiElements/AnalogGraphItem.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\AnalogGraphItem.h -o release\moc_AnalogGraphItem.cpp
|
||||||
|
|
||||||
|
release/moc_GraphItem.cpp: sources/GuiElements/GraphItem.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\GraphItem.h -o release\moc_GraphItem.cpp
|
||||||
|
|
||||||
|
release/moc_GraphRulerWidget.cpp: sources/GuiElements/GraphRulerWidget.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\GraphRulerWidget.h -o release\moc_GraphRulerWidget.cpp
|
||||||
|
|
||||||
|
release/moc_LogMgr.cpp: sources/ZTData.h \
|
||||||
|
sources/GlobalDefine.h \
|
||||||
|
sources/DirParserThread.h \
|
||||||
|
sources/TrainLogFileMgr.h \
|
||||||
|
sources/LogMgr.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\LogMgr.h -o release\moc_LogMgr.cpp
|
||||||
|
|
||||||
|
release/moc_LogsListPage.cpp: sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/LogsListPage.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\LogsListPage.h -o release\moc_LogsListPage.cpp
|
||||||
|
|
||||||
|
release/moc_OptionsPage.cpp: sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/OptionsPage.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\OptionsPage.h -o release\moc_OptionsPage.cpp
|
||||||
|
|
||||||
|
release/moc_NetworkZTListPage.cpp: sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/NetworkZTListPage.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\NetworkZTListPage.h -o release\moc_NetworkZTListPage.cpp
|
||||||
|
|
||||||
|
release/moc_ToggleTextButtonWidget.cpp: sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/ToggleTextButtonWidget.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\ToggleTextButtonWidget.h -o release\moc_ToggleTextButtonWidget.cpp
|
||||||
|
|
||||||
|
release/moc_NetworkCtrlPage.cpp: sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/ToggleTextButtonWidget.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/TxRxWidget.h \
|
||||||
|
sources/GuiElements/NetworkCtrlPage.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\NetworkCtrlPage.h -o release\moc_NetworkCtrlPage.cpp
|
||||||
|
|
||||||
|
release/moc_NetworkManager.cpp: sources/GlobalDefine.h \
|
||||||
|
sources/ZTData.h \
|
||||||
|
sources/TCPProtocol.h \
|
||||||
|
sources/UDPProtocol.h \
|
||||||
|
sources/NetworkManager.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\NetworkManager.h -o release\moc_NetworkManager.cpp
|
||||||
|
|
||||||
|
release/moc_TxRxWidget.cpp: sources/GuiElements/TxRxWidget.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\TxRxWidget.h -o release\moc_TxRxWidget.cpp
|
||||||
|
|
||||||
|
release/moc_RemoteZTPage.cpp: sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/ToggleTextButtonWidget.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/RemoteZTPage.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\RemoteZTPage.h -o release\moc_RemoteZTPage.cpp
|
||||||
|
|
||||||
|
release/moc_ZTLogViewerPage.cpp: sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/ZTLogViewerPage.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\ZTLogViewerPage.h -o release\moc_ZTLogViewerPage.cpp
|
||||||
|
|
||||||
|
release/moc_ProgressBarPage.cpp: sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/ProgressBarPage.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\ProgressBarPage.h -o release\moc_ProgressBarPage.cpp
|
||||||
|
|
||||||
|
release/moc_RemoteZTCtrlPage.cpp: sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/ToggleButtonWidget.h \
|
||||||
|
sources/GuiElements/RemoteZTCtrlPage.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\RemoteZTCtrlPage.h -o release\moc_RemoteZTCtrlPage.cpp
|
||||||
|
|
||||||
|
release/moc_ToggleButtonWidget.cpp: sources/GuiElements/ToggleButtonWidget.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\ToggleButtonWidget.h -o release\moc_ToggleButtonWidget.cpp
|
||||||
|
|
||||||
|
release/moc_DatabaseMgrPage.cpp: sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/DatabaseMgrPage.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\DatabaseMgrPage.h -o release\moc_DatabaseMgrPage.cpp
|
||||||
|
|
||||||
|
release/moc_ZTLogsListPage.cpp: sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/ZTLogsListPage.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\GuiElements\ZTLogsListPage.h -o release\moc_ZTLogsListPage.cpp
|
||||||
|
|
||||||
|
release/moc_ZTLogFilesMgr.cpp: sources/ZTData.h \
|
||||||
|
sources/GlobalDefine.h \
|
||||||
|
sources/DirParserThread.h \
|
||||||
|
sources/TrainLogFileMgr.h \
|
||||||
|
sources/ZTLogFilesMgr.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\ZTLogFilesMgr.h -o release\moc_ZTLogFilesMgr.cpp
|
||||||
|
|
||||||
|
release/moc_DirParserThread.cpp: sources/GlobalDefine.h \
|
||||||
|
sources/TrainLogFileMgr.h \
|
||||||
|
sources/ZTData.h \
|
||||||
|
sources/DirParserThread.h
|
||||||
|
C:\Qt\4.8.1\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 sources\DirParserThread.h -o release\moc_DirParserThread.cpp
|
||||||
|
|
||||||
|
compiler_rcc_make_all:
|
||||||
|
compiler_rcc_clean:
|
||||||
|
compiler_image_collection_make_all: qmake_image_collection.cpp
|
||||||
|
compiler_image_collection_clean:
|
||||||
|
-$(DEL_FILE) qmake_image_collection.cpp
|
||||||
|
compiler_moc_source_make_all:
|
||||||
|
compiler_moc_source_clean:
|
||||||
|
compiler_uic_make_all:
|
||||||
|
compiler_uic_clean:
|
||||||
|
compiler_yacc_decl_make_all:
|
||||||
|
compiler_yacc_decl_clean:
|
||||||
|
compiler_yacc_impl_make_all:
|
||||||
|
compiler_yacc_impl_clean:
|
||||||
|
compiler_lex_make_all:
|
||||||
|
compiler_lex_clean:
|
||||||
|
compiler_clean: compiler_moc_header_clean
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
####### Compile
|
||||||
|
|
||||||
|
release/main.o: sources/main.cpp sources/OutilZT.h \
|
||||||
|
sources/MainPanel.h \
|
||||||
|
sources/GlobalDefine.h \
|
||||||
|
sources/LogMgr.h \
|
||||||
|
sources/ZTData.h \
|
||||||
|
sources/DirParserThread.h \
|
||||||
|
sources/TrainLogFileMgr.h \
|
||||||
|
sources/Settings.h \
|
||||||
|
sources/TCPProtocol.h \
|
||||||
|
sources/ZTLogFilesMgr.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\main.o sources\main.cpp
|
||||||
|
|
||||||
|
release/OutilZT.o: sources/OutilZT.cpp sources/OutilZT.h \
|
||||||
|
sources/MainPanel.h \
|
||||||
|
sources/GlobalDefine.h \
|
||||||
|
sources/LogMgr.h \
|
||||||
|
sources/ZTData.h \
|
||||||
|
sources/DirParserThread.h \
|
||||||
|
sources/TrainLogFileMgr.h \
|
||||||
|
sources/Settings.h \
|
||||||
|
sources/TCPProtocol.h \
|
||||||
|
sources/ZTLogFilesMgr.h \
|
||||||
|
sources/NetworkManager.h \
|
||||||
|
sources/UDPProtocol.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\OutilZT.o sources\OutilZT.cpp
|
||||||
|
|
||||||
|
release/MainPanel.o: sources/MainPanel.cpp sources/MainPanel.h \
|
||||||
|
sources/GlobalDefine.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\MainPanel.o sources\MainPanel.cpp
|
||||||
|
|
||||||
|
release/MainPage.o: sources/GuiElements/MainPage.cpp sources/GuiElements/MainPage.h \
|
||||||
|
sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\MainPage.o sources\GuiElements\MainPage.cpp
|
||||||
|
|
||||||
|
release/GuiPage.o: sources/GuiElements/GuiPage.cpp sources/GuiElements/Guipage.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\GuiPage.o sources\GuiElements\GuiPage.cpp
|
||||||
|
|
||||||
|
release/PushButton.o: sources/GuiElements/PushButton.cpp sources/GuiElements/PushButton.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\PushButton.o sources\GuiElements\PushButton.cpp
|
||||||
|
|
||||||
|
release/LogViewPage.o: sources/GuiElements/LogViewPage.cpp sources/GuiElements/LogViewPage.h \
|
||||||
|
sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/GraphItem.h \
|
||||||
|
sources/GuiElements/GraphCursorWidget.h \
|
||||||
|
sources/GuiElements/GraphRulerWidget.h \
|
||||||
|
sources/GuiElements/AnalogGraphItem.h \
|
||||||
|
sources/GuiElements/RankRulerWidget.h \
|
||||||
|
sources/GuiElements/EventsRulerWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\LogViewPage.o sources\GuiElements\LogViewPage.cpp
|
||||||
|
|
||||||
|
release/TextButtonWidget.o: sources/GuiElements/TextButtonWidget.cpp sources/GuiElements/TextButtonWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\TextButtonWidget.o sources\GuiElements\TextButtonWidget.cpp
|
||||||
|
|
||||||
|
release/RankRulerWidget.o: sources/GuiElements/RankRulerWidget.cpp sources/GuiElements/RankRulerWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\RankRulerWidget.o sources\GuiElements\RankRulerWidget.cpp
|
||||||
|
|
||||||
|
release/GraphCursorWidget.o: sources/GuiElements/GraphCursorWidget.cpp sources/GuiElements/GraphCursorWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\GraphCursorWidget.o sources\GuiElements\GraphCursorWidget.cpp
|
||||||
|
|
||||||
|
release/EventsRulerWidget.o: sources/GuiElements/EventsRulerWidget.cpp sources/GuiElements/EventsRulerWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\EventsRulerWidget.o sources\GuiElements\EventsRulerWidget.cpp
|
||||||
|
|
||||||
|
release/AnalogGraphItem.o: sources/GuiElements/AnalogGraphItem.cpp sources/GuiElements/AnalogGraphItem.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\AnalogGraphItem.o sources\GuiElements\AnalogGraphItem.cpp
|
||||||
|
|
||||||
|
release/GraphItem.o: sources/GuiElements/GraphItem.cpp sources/GuiElements/GraphItem.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\GraphItem.o sources\GuiElements\GraphItem.cpp
|
||||||
|
|
||||||
|
release/GraphRulerWidget.o: sources/GuiElements/GraphRulerWidget.cpp sources/GuiElements/GraphRulerWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\GraphRulerWidget.o sources\GuiElements\GraphRulerWidget.cpp
|
||||||
|
|
||||||
|
release/ZTData.o: sources/ZTData.cpp sources/ZTData.h \
|
||||||
|
sources/GlobalDefine.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\ZTData.o sources\ZTData.cpp
|
||||||
|
|
||||||
|
release/LogMgr.o: sources/LogMgr.cpp sources/LogMgr.h \
|
||||||
|
sources/ZTData.h \
|
||||||
|
sources/GlobalDefine.h \
|
||||||
|
sources/DirParserThread.h \
|
||||||
|
sources/TrainLogFileMgr.h \
|
||||||
|
sources/OutilZT.h \
|
||||||
|
sources/MainPanel.h \
|
||||||
|
sources/Settings.h \
|
||||||
|
sources/TCPProtocol.h \
|
||||||
|
sources/ZTLogFilesMgr.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\LogMgr.o sources\LogMgr.cpp
|
||||||
|
|
||||||
|
release/TrainLogFileMgr.o: sources/TrainLogFileMgr.cpp sources/TrainLogFileMgr.h \
|
||||||
|
sources/GlobalDefine.h \
|
||||||
|
sources/ZTData.h \
|
||||||
|
sources/LogMgr.h \
|
||||||
|
sources/DirParserThread.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\TrainLogFileMgr.o sources\TrainLogFileMgr.cpp
|
||||||
|
|
||||||
|
release/LogsListPage.o: sources/GuiElements/LogsListPage.cpp sources/GuiElements/LogsListPage.h \
|
||||||
|
sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\LogsListPage.o sources\GuiElements\LogsListPage.cpp
|
||||||
|
|
||||||
|
release/OptionsPage.o: sources/GuiElements/OptionsPage.cpp sources/GuiElements/OptionsPage.h \
|
||||||
|
sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\OptionsPage.o sources\GuiElements\OptionsPage.cpp
|
||||||
|
|
||||||
|
release/Settings.o: sources/Settings.cpp sources/Settings.h \
|
||||||
|
sources/GlobalDefine.h \
|
||||||
|
sources/ZTData.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\Settings.o sources\Settings.cpp
|
||||||
|
|
||||||
|
release/NetworkZTListPage.o: sources/GuiElements/NetworkZTListPage.cpp sources/GuiElements/NetworkZTListPage.h \
|
||||||
|
sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\NetworkZTListPage.o sources\GuiElements\NetworkZTListPage.cpp
|
||||||
|
|
||||||
|
release/ToggleTextButtonWidget.o: sources/GuiElements/ToggleTextButtonWidget.cpp sources/GuiElements/TextButtonWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\ToggleTextButtonWidget.o sources\GuiElements\ToggleTextButtonWidget.cpp
|
||||||
|
|
||||||
|
release/NetworkCtrlPage.o: sources/GuiElements/NetworkCtrlPage.cpp sources/GuiElements/NetworkCtrlPage.h \
|
||||||
|
sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/ToggleTextButtonWidget.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/TxRxWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\NetworkCtrlPage.o sources\GuiElements\NetworkCtrlPage.cpp
|
||||||
|
|
||||||
|
release/NetworkManager.o: sources/NetworkManager.cpp sources/NetworkManager.h \
|
||||||
|
sources/GlobalDefine.h \
|
||||||
|
sources/ZTData.h \
|
||||||
|
sources/TCPProtocol.h \
|
||||||
|
sources/UDPProtocol.h \
|
||||||
|
sources/OutilZT.h \
|
||||||
|
sources/MainPanel.h \
|
||||||
|
sources/LogMgr.h \
|
||||||
|
sources/DirParserThread.h \
|
||||||
|
sources/TrainLogFileMgr.h \
|
||||||
|
sources/Settings.h \
|
||||||
|
sources/ZTLogFilesMgr.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\NetworkManager.o sources\NetworkManager.cpp
|
||||||
|
|
||||||
|
release/TxRxWidget.o: sources/GuiElements/TxRxWidget.cpp sources/GuiElements/TxRxWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\TxRxWidget.o sources\GuiElements\TxRxWidget.cpp
|
||||||
|
|
||||||
|
release/TCPProtocol.o: sources/TCPProtocol.cpp sources/TCPProtocol.h \
|
||||||
|
sources/GlobalDefine.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\TCPProtocol.o sources\TCPProtocol.cpp
|
||||||
|
|
||||||
|
release/RemoteZTPage.o: sources/GuiElements/RemoteZTPage.cpp sources/GuiElements/RemoteZTPage.h \
|
||||||
|
sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/ToggleTextButtonWidget.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\RemoteZTPage.o sources\GuiElements\RemoteZTPage.cpp
|
||||||
|
|
||||||
|
release/ZTLogViewerPage.o: sources/GuiElements/ZTLogViewerPage.cpp sources/GuiElements/ZTLogViewerPage.h \
|
||||||
|
sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\ZTLogViewerPage.o sources\GuiElements\ZTLogViewerPage.cpp
|
||||||
|
|
||||||
|
release/ProgressBarPage.o: sources/GuiElements/ProgressBarPage.cpp sources/GuiElements/ProgressBarPage.h \
|
||||||
|
sources/GuiElements/Guipage.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\ProgressBarPage.o sources\GuiElements\ProgressBarPage.cpp
|
||||||
|
|
||||||
|
release/RemoteZTCtrlPage.o: sources/GuiElements/RemoteZTCtrlPage.cpp sources/GuiElements/RemoteZTCtrlPage.h \
|
||||||
|
sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/ToggleButtonWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\RemoteZTCtrlPage.o sources\GuiElements\RemoteZTCtrlPage.cpp
|
||||||
|
|
||||||
|
release/ToggleButtonWidget.o: sources/GuiElements/ToggleButtonWidget.cpp sources/GuiElements/ToggleButtonWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\ToggleButtonWidget.o sources\GuiElements\ToggleButtonWidget.cpp
|
||||||
|
|
||||||
|
release/UDPProtocol.o: sources/UDPProtocol.cpp sources/UDPProtocol.h \
|
||||||
|
sources/GlobalDefine.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\UDPProtocol.o sources\UDPProtocol.cpp
|
||||||
|
|
||||||
|
release/DatabaseMgrPage.o: sources/GuiElements/DatabaseMgrPage.cpp sources/GuiElements/DatabaseMgrPage.h \
|
||||||
|
sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\DatabaseMgrPage.o sources\GuiElements\DatabaseMgrPage.cpp
|
||||||
|
|
||||||
|
release/ZTLogsListPage.o: sources/GuiElements/ZTLogsListPage.cpp sources/GuiElements/ZTLogsListPage.h \
|
||||||
|
sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\ZTLogsListPage.o sources\GuiElements\ZTLogsListPage.cpp
|
||||||
|
|
||||||
|
release/ZTLogFilesMgr.o: sources/ZTLogFilesMgr.cpp sources/ZTLogFilesMgr.h \
|
||||||
|
sources/ZTData.h \
|
||||||
|
sources/GlobalDefine.h \
|
||||||
|
sources/DirParserThread.h \
|
||||||
|
sources/TrainLogFileMgr.h \
|
||||||
|
sources/OutilZT.h \
|
||||||
|
sources/MainPanel.h \
|
||||||
|
sources/LogMgr.h \
|
||||||
|
sources/Settings.h \
|
||||||
|
sources/TCPProtocol.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\ZTLogFilesMgr.o sources\ZTLogFilesMgr.cpp
|
||||||
|
|
||||||
|
release/DirParserThread.o: sources/DirParserThread.cpp sources/DirParserThread.h \
|
||||||
|
sources/GlobalDefine.h \
|
||||||
|
sources/TrainLogFileMgr.h \
|
||||||
|
sources/ZTData.h
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\DirParserThread.o sources\DirParserThread.cpp
|
||||||
|
|
||||||
|
release/moc_OutilZT.o: release/moc_OutilZT.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_OutilZT.o release\moc_OutilZT.cpp
|
||||||
|
|
||||||
|
release/moc_MainPanel.o: release/moc_MainPanel.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_MainPanel.o release\moc_MainPanel.cpp
|
||||||
|
|
||||||
|
release/moc_MainPage.o: release/moc_MainPage.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_MainPage.o release\moc_MainPage.cpp
|
||||||
|
|
||||||
|
release/moc_Guipage.o: release/moc_Guipage.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_Guipage.o release\moc_Guipage.cpp
|
||||||
|
|
||||||
|
release/moc_PushButton.o: release/moc_PushButton.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_PushButton.o release\moc_PushButton.cpp
|
||||||
|
|
||||||
|
release/moc_LogViewPage.o: release/moc_LogViewPage.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_LogViewPage.o release\moc_LogViewPage.cpp
|
||||||
|
|
||||||
|
release/moc_TextButtonWidget.o: release/moc_TextButtonWidget.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_TextButtonWidget.o release\moc_TextButtonWidget.cpp
|
||||||
|
|
||||||
|
release/moc_RankRulerWidget.o: release/moc_RankRulerWidget.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_RankRulerWidget.o release\moc_RankRulerWidget.cpp
|
||||||
|
|
||||||
|
release/moc_GraphCursorWidget.o: release/moc_GraphCursorWidget.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_GraphCursorWidget.o release\moc_GraphCursorWidget.cpp
|
||||||
|
|
||||||
|
release/moc_EventsRulerWidget.o: release/moc_EventsRulerWidget.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_EventsRulerWidget.o release\moc_EventsRulerWidget.cpp
|
||||||
|
|
||||||
|
release/moc_AnalogGraphItem.o: release/moc_AnalogGraphItem.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_AnalogGraphItem.o release\moc_AnalogGraphItem.cpp
|
||||||
|
|
||||||
|
release/moc_GraphItem.o: release/moc_GraphItem.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_GraphItem.o release\moc_GraphItem.cpp
|
||||||
|
|
||||||
|
release/moc_GraphRulerWidget.o: release/moc_GraphRulerWidget.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_GraphRulerWidget.o release\moc_GraphRulerWidget.cpp
|
||||||
|
|
||||||
|
release/moc_LogMgr.o: release/moc_LogMgr.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_LogMgr.o release\moc_LogMgr.cpp
|
||||||
|
|
||||||
|
release/moc_LogsListPage.o: release/moc_LogsListPage.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_LogsListPage.o release\moc_LogsListPage.cpp
|
||||||
|
|
||||||
|
release/moc_OptionsPage.o: release/moc_OptionsPage.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_OptionsPage.o release\moc_OptionsPage.cpp
|
||||||
|
|
||||||
|
release/moc_NetworkZTListPage.o: release/moc_NetworkZTListPage.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_NetworkZTListPage.o release\moc_NetworkZTListPage.cpp
|
||||||
|
|
||||||
|
release/moc_ToggleTextButtonWidget.o: release/moc_ToggleTextButtonWidget.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_ToggleTextButtonWidget.o release\moc_ToggleTextButtonWidget.cpp
|
||||||
|
|
||||||
|
release/moc_NetworkCtrlPage.o: release/moc_NetworkCtrlPage.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_NetworkCtrlPage.o release\moc_NetworkCtrlPage.cpp
|
||||||
|
|
||||||
|
release/moc_NetworkManager.o: release/moc_NetworkManager.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_NetworkManager.o release\moc_NetworkManager.cpp
|
||||||
|
|
||||||
|
release/moc_TxRxWidget.o: release/moc_TxRxWidget.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_TxRxWidget.o release\moc_TxRxWidget.cpp
|
||||||
|
|
||||||
|
release/moc_RemoteZTPage.o: release/moc_RemoteZTPage.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_RemoteZTPage.o release\moc_RemoteZTPage.cpp
|
||||||
|
|
||||||
|
release/moc_ZTLogViewerPage.o: release/moc_ZTLogViewerPage.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_ZTLogViewerPage.o release\moc_ZTLogViewerPage.cpp
|
||||||
|
|
||||||
|
release/moc_ProgressBarPage.o: release/moc_ProgressBarPage.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_ProgressBarPage.o release\moc_ProgressBarPage.cpp
|
||||||
|
|
||||||
|
release/moc_RemoteZTCtrlPage.o: release/moc_RemoteZTCtrlPage.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_RemoteZTCtrlPage.o release\moc_RemoteZTCtrlPage.cpp
|
||||||
|
|
||||||
|
release/moc_ToggleButtonWidget.o: release/moc_ToggleButtonWidget.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_ToggleButtonWidget.o release\moc_ToggleButtonWidget.cpp
|
||||||
|
|
||||||
|
release/moc_DatabaseMgrPage.o: release/moc_DatabaseMgrPage.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_DatabaseMgrPage.o release\moc_DatabaseMgrPage.cpp
|
||||||
|
|
||||||
|
release/moc_ZTLogsListPage.o: release/moc_ZTLogsListPage.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_ZTLogsListPage.o release\moc_ZTLogsListPage.cpp
|
||||||
|
|
||||||
|
release/moc_ZTLogFilesMgr.o: release/moc_ZTLogFilesMgr.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_ZTLogFilesMgr.o release\moc_ZTLogFilesMgr.cpp
|
||||||
|
|
||||||
|
release/moc_DirParserThread.o: release/moc_DirParserThread.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_DirParserThread.o release\moc_DirParserThread.cpp
|
||||||
|
|
||||||
|
####### Install
|
||||||
|
|
||||||
|
install: FORCE
|
||||||
|
|
||||||
|
uninstall: FORCE
|
||||||
|
|
||||||
|
FORCE:
|
||||||
|
|
||||||
84
OutilZT.pro
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
QT += network
|
||||||
|
#CONFIG += console
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
sources/OutilZT.h \
|
||||||
|
sources/MainPanel.h \
|
||||||
|
sources/GlobalDefine.h \
|
||||||
|
sources/GuiElements/MainPage.h \
|
||||||
|
sources/GuiElements/Guipage.h \
|
||||||
|
sources/GuiElements/PushButton.h \
|
||||||
|
sources/GuiElements/LogViewPage.h \
|
||||||
|
sources/GuiElements/TextButtonWidget.h \
|
||||||
|
sources/GuiElements/RankRulerWidget.h \
|
||||||
|
sources/GuiElements/GraphCursorWidget.h \
|
||||||
|
sources/GuiElements/EventsRulerWidget.h \
|
||||||
|
sources/GuiElements/AnalogGraphItem.h \
|
||||||
|
sources/GuiElements/GraphItem.h \
|
||||||
|
sources/GuiElements/GraphRulerWidget.h \
|
||||||
|
sources/ZTData.h \
|
||||||
|
sources/LogMgr.h \
|
||||||
|
sources/TrainLogFileMgr.h \
|
||||||
|
sources/GuiElements/LogsListPage.h \
|
||||||
|
sources/GuiElements/OptionsPage.h \
|
||||||
|
sources/Settings.h \
|
||||||
|
sources/GuiElements/NetworkZTListPage.h \
|
||||||
|
sources/GuiElements/ToggleTextButtonWidget.h \
|
||||||
|
sources/GuiElements/NetworkCtrlPage.h \
|
||||||
|
sources/NetworkManager.h \
|
||||||
|
sources/GuiElements/TxRxWidget.h \
|
||||||
|
sources/TCPProtocol.h \
|
||||||
|
sources/GuiElements/RemoteZTPage.h \
|
||||||
|
sources/GuiElements/ZTLogViewerPage.h \
|
||||||
|
sources/GuiElements/ProgressBarPage.h \
|
||||||
|
sources/GuiElements/RemoteZTCtrlPage.h \
|
||||||
|
sources/GuiElements/ToggleButtonWidget.h \
|
||||||
|
sources/UDPProtocol.h \
|
||||||
|
sources/GuiElements/DatabaseMgrPage.h \
|
||||||
|
sources/GuiElements/ZTLogsListPage.h \
|
||||||
|
sources/ZTLogFilesMgr.h \
|
||||||
|
sources/OutilZTVersion.h \
|
||||||
|
sources/DirParserThread.h
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
sources/main.cpp \
|
||||||
|
sources/OutilZT.cpp \
|
||||||
|
sources/MainPanel.cpp \
|
||||||
|
sources/GuiElements/MainPage.cpp \
|
||||||
|
sources/GuiElements/GuiPage.cpp \
|
||||||
|
sources/GuiElements/PushButton.cpp \
|
||||||
|
sources/GuiElements/LogViewPage.cpp \
|
||||||
|
sources/GuiElements/TextButtonWidget.cpp \
|
||||||
|
sources/GuiElements/RankRulerWidget.cpp \
|
||||||
|
sources/GuiElements/GraphCursorWidget.cpp \
|
||||||
|
sources/GuiElements/EventsRulerWidget.cpp \
|
||||||
|
sources/GuiElements/AnalogGraphItem.cpp \
|
||||||
|
sources/GuiElements/GraphItem.cpp \
|
||||||
|
sources/GuiElements/GraphRulerWidget.cpp \
|
||||||
|
sources/ZTData.cpp \
|
||||||
|
sources/LogMgr.cpp \
|
||||||
|
sources/TrainLogFileMgr.cpp \
|
||||||
|
sources/GuiElements/LogsListPage.cpp \
|
||||||
|
sources/GuiElements/OptionsPage.cpp \
|
||||||
|
sources/Settings.cpp \
|
||||||
|
sources/GuiElements/NetworkZTListPage.cpp \
|
||||||
|
sources/GuiElements/ToggleTextButtonWidget.cpp \
|
||||||
|
sources/GuiElements/NetworkCtrlPage.cpp \
|
||||||
|
sources/NetworkManager.cpp \
|
||||||
|
sources/GuiElements/TxRxWidget.cpp \
|
||||||
|
sources/TCPProtocol.cpp \
|
||||||
|
sources/GuiElements/RemoteZTPage.cpp \
|
||||||
|
sources/GuiElements/ZTLogViewerPage.cpp \
|
||||||
|
sources/GuiElements/ProgressBarPage.cpp \
|
||||||
|
sources/GuiElements/RemoteZTCtrlPage.cpp \
|
||||||
|
sources/GuiElements/ToggleButtonWidget.cpp \
|
||||||
|
sources/UDPProtocol.cpp \
|
||||||
|
sources/GuiElements/DatabaseMgrPage.cpp \
|
||||||
|
sources/GuiElements/ZTLogsListPage.cpp \
|
||||||
|
sources/ZTLogFilesMgr.cpp \
|
||||||
|
sources/DirParserThread.cpp
|
||||||
|
|
||||||
|
|
||||||
|
INCLUDEPATH += $$PWD/ \
|
||||||
|
$$PWD/sources/ \
|
||||||
|
$$PWD/sources/GuiElements
|
||||||
103
sources/DirParserThread.cpp
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
#include "DirParserThread.h"
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void CDirParserThread::ParseDirectories()
|
||||||
|
{
|
||||||
|
if(mRootDir.absolutePath().isEmpty() == true)
|
||||||
|
{
|
||||||
|
emit ParsingFinished(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ParseDir(mRootDir,mKeepData);
|
||||||
|
|
||||||
|
emit ParsingFinished(1);
|
||||||
|
qDebug("Worker thread finished");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CDirParserThread::CDirParserThread()
|
||||||
|
{
|
||||||
|
mExecThread = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CDirParserThread::ParseDir(QDir dir, bool KeepData)
|
||||||
|
{
|
||||||
|
mMutex.lockForRead();
|
||||||
|
bool Run = mExecThread;
|
||||||
|
mMutex.unlock();
|
||||||
|
if(Run == false)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
QStringList LogFilters;
|
||||||
|
QFileInfoList list;
|
||||||
|
// QString LogDataDir = mProgramHandle->GetLogDataPath();
|
||||||
|
LogFilters << mFilter;//"*.bin";
|
||||||
|
|
||||||
|
//Load files in base directory
|
||||||
|
QDir LogDir(dir);
|
||||||
|
LogDir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
|
||||||
|
LogDir.setNameFilters(LogFilters);
|
||||||
|
LogDir.setSorting(QDir::Name);
|
||||||
|
list = LogDir.entryInfoList();
|
||||||
|
if(list.size() != 0)
|
||||||
|
{
|
||||||
|
//Extract data for each passage
|
||||||
|
for(int i = 0; i < list.size(); i++)
|
||||||
|
{
|
||||||
|
//ParseNewLog(list.at(i).filePath(),KeepData);
|
||||||
|
unsigned int ret;
|
||||||
|
// CLogElement *NewLog = CTrainLogFileMgr::instance()->OpenTrainLog(list.at(i).filePath(),ret);
|
||||||
|
// if(ret == RET_OK)
|
||||||
|
if(mFilter == "*.bin")
|
||||||
|
{
|
||||||
|
CLogElement *NewLog = CTrainLogFileMgr::instance()->OpenTrainLog(list.at(i).filePath(),ret);
|
||||||
|
if(ret == RET_OK)
|
||||||
|
{
|
||||||
|
emit NewLogParsed(NewLog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
emit NewLogParsed(list.at(i).filePath(),KeepData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
emit EmptyDirParsed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Check for subdirectories
|
||||||
|
QDir SubDirectories(dir);
|
||||||
|
|
||||||
|
SubDirectories.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
|
|
||||||
|
QFileInfoList SubDirList = SubDirectories.entryInfoList();
|
||||||
|
for(int i = 0; i < SubDirList.size(); i++)
|
||||||
|
{
|
||||||
|
ParseDir(QDir(SubDirList.at(i).absoluteFilePath()), KeepData);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDirParserThread::SetParsingInfo(QDir dir, QString Filter, bool KeepData)
|
||||||
|
{
|
||||||
|
qDebug("DirParserThread parsing info: dir: %s, Filter: ",dir.dirName().toAscii().data(),Filter.toAscii().data());
|
||||||
|
mRootDir = dir;
|
||||||
|
mKeepData = KeepData;
|
||||||
|
mFilter = Filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDirParserThread::KillThread()
|
||||||
|
{
|
||||||
|
mMutex.lockForWrite();
|
||||||
|
mExecThread = false;
|
||||||
|
mMutex.unlock();
|
||||||
|
}
|
||||||
34
sources/DirParserThread.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#ifndef DIRPARSERTHREAD_H
|
||||||
|
#define DIRPARSERTHREAD_H
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QDir>
|
||||||
|
#include <QReadWriteLock>
|
||||||
|
#include "TrainLogFileMgr.h"
|
||||||
|
|
||||||
|
class CDirParserThread : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CDirParserThread();
|
||||||
|
void SetParsingInfo(QDir dir,QString Filter,bool KeepData = false);
|
||||||
|
void KillThread();
|
||||||
|
int ParseDir(QDir dir, bool KeepData = false);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QDir mRootDir;
|
||||||
|
bool mKeepData;
|
||||||
|
QReadWriteLock mMutex;
|
||||||
|
bool mExecThread;
|
||||||
|
QString mFilter;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void ParseDirectories();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void NewLogParsed(QString,bool);
|
||||||
|
void NewLogParsed(CLogElement*);
|
||||||
|
void ParsingFinished(int);
|
||||||
|
void EmptyDirParsed();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DIRPARSERTHREAD_H
|
||||||
77
sources/GlobalDefine.h
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Description du fichier si nécessaire.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20121210 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
#ifndef GLOBAL_DEFINE
|
||||||
|
#define GLOBAL_DEFINE
|
||||||
|
|
||||||
|
//Screen resolution.
|
||||||
|
#define SCREEN_RES_WIDTH 1600
|
||||||
|
#define SCREEN_RES_HEIGHT 768
|
||||||
|
|
||||||
|
//Train parameters
|
||||||
|
#define MR_BOGIE_LENGTH 1.52 //meters
|
||||||
|
#define MPM_BOGIE_LENGTH 2.0 //meters
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Misc definitions
|
||||||
|
#define USE_FAST_LOGFILE_LOADING
|
||||||
|
#define MAX_LOG_FILE_COUNT 25000
|
||||||
|
#define MAX_LOG_DIR_SIZE (qint64)1073741824 //in bytes = 1 GB
|
||||||
|
#define USE_ANALOG_ACQUISITION
|
||||||
|
|
||||||
|
|
||||||
|
#define ZT_TCP_PORT 1234
|
||||||
|
#define ZT_UDP_PORT 41245
|
||||||
|
|
||||||
|
//Debug defs
|
||||||
|
//#define LOG_RAM_USAGE
|
||||||
|
|
||||||
|
//General purpose return values.
|
||||||
|
enum eGeneralRetValue
|
||||||
|
{
|
||||||
|
RET_OK,
|
||||||
|
RET_ERROR
|
||||||
|
};
|
||||||
|
|
||||||
|
enum eZTID
|
||||||
|
{
|
||||||
|
ANGRIGNON_ZT_ID,
|
||||||
|
HONORE_BEAUGRAND_ZT_ID,
|
||||||
|
LONGUEUIL_ZT_ID,
|
||||||
|
BERRI_UQAM_ZT_ID,
|
||||||
|
SNOWDON_ZT_ID,
|
||||||
|
SAINT_MICHEL_ZT_ID,
|
||||||
|
COTE_VERTU_ZT_ID,
|
||||||
|
HENRI_BOURASSA_ZT_ID,
|
||||||
|
MONTMORENCY_ZT_ID,
|
||||||
|
MONTMORENCY_10_12_ZT_ID,
|
||||||
|
MONTMORENCY_10_22_ZT_ID,
|
||||||
|
|
||||||
|
NB_ZT_ID
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
412
sources/GuiElements/AnalogGraphItem.cpp
Normal file
@ -0,0 +1,412 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2013 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Classe d'affichage d'un graphique analogique (vitesse du train, sondes lazer,
|
||||||
|
etc.) La fonction SetData permet d'associer la liste de points à tracer. La
|
||||||
|
fonction DisplayData() permet de fixer le timespan à afficher. La fonction détermine
|
||||||
|
quels points sont dans le span et crée une liste de lignes qui sont ensuite affichés
|
||||||
|
dans la fonction de rappel paint().
|
||||||
|
|
||||||
|
Utilisée dans la page de visualisation des passages de train.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131024 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "AnalogGraphItem.h"
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QGraphicsSceneMouseEvent>
|
||||||
|
#include <limits>
|
||||||
|
#include <QStyleOptionGraphicsItem>
|
||||||
|
|
||||||
|
CAnalogGraphItem::CAnalogGraphItem(QGraphicsItem *Parent)
|
||||||
|
{
|
||||||
|
setParentItem(Parent);
|
||||||
|
mDataSet = 0;
|
||||||
|
mStartTime = mStopTime = 0;
|
||||||
|
mDataValid = false;
|
||||||
|
mLabel = new QGraphicsTextItem(this);
|
||||||
|
|
||||||
|
mGraphPixmap = new QPixmap(boundingRect().width(),boundingRect().height());
|
||||||
|
mHorizLine = 0;
|
||||||
|
mYOffset = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
CAnalogGraphItem::~CAnalogGraphItem()
|
||||||
|
{
|
||||||
|
delete mGraphPixmap;
|
||||||
|
|
||||||
|
if(mHorizLine != 0)
|
||||||
|
delete mHorizLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAnalogGraphItem::SetData(QList<CGraphAnalogDataPair*> *DataList)
|
||||||
|
{
|
||||||
|
mDataSet = DataList;
|
||||||
|
//Build the lines list
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CAnalogGraphItem::DisplayData(quint64 StartTime, quint64 StopTime)
|
||||||
|
{
|
||||||
|
|
||||||
|
mPainterPath = QPainterPath();
|
||||||
|
|
||||||
|
if(mDataSet == 0)
|
||||||
|
return RET_OK;
|
||||||
|
|
||||||
|
if(mDataSet->isEmpty())
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
quint64 MinTime = mDataSet->first()->mTime;
|
||||||
|
quint64 MaxTime = mDataSet->last()->mTime;
|
||||||
|
|
||||||
|
if(StartTime >= StopTime)
|
||||||
|
return RET_ERROR;
|
||||||
|
if(StartTime < MinTime)
|
||||||
|
return RET_ERROR;
|
||||||
|
if(StopTime > MaxTime)
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
quint64 TimeSpan = StopTime - StartTime;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
mStartTime = StartTime;
|
||||||
|
mStopTime = StopTime;
|
||||||
|
|
||||||
|
|
||||||
|
//Find the index of the first and last point included in the timespan.
|
||||||
|
int StartIndex = 0, StopIndex = 0;
|
||||||
|
int i = 0;
|
||||||
|
bool StartFound = false, StopFound = false;
|
||||||
|
|
||||||
|
quint64 StartDrawTime = StartTime ,EndDrawTime = StopTime;
|
||||||
|
|
||||||
|
if(StartTime < mAbsoluteStartTime)
|
||||||
|
StartDrawTime = mAbsoluteStartTime;
|
||||||
|
|
||||||
|
|
||||||
|
if(StopTime > mAbsoluteEndTime)
|
||||||
|
EndDrawTime = mAbsoluteEndTime;
|
||||||
|
|
||||||
|
|
||||||
|
while(StartFound == false || StopFound == false)
|
||||||
|
{
|
||||||
|
if(i >= mDataSet->size())
|
||||||
|
{
|
||||||
|
qDebug("GraphItem::Array overflow while searching for time index");
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
quint64 CurTime = mDataSet->at(i)->mTime;
|
||||||
|
if(CurTime <= StartDrawTime)
|
||||||
|
{
|
||||||
|
StartIndex = i;
|
||||||
|
StartFound = true;
|
||||||
|
}
|
||||||
|
if(CurTime >= EndDrawTime && !StopFound)
|
||||||
|
{
|
||||||
|
StopIndex = i;
|
||||||
|
StopFound = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Find the Y scaling (vertical)
|
||||||
|
qreal MaxValue = std::numeric_limits<float>::min();
|
||||||
|
qreal MinValue = std::numeric_limits<float>::max();
|
||||||
|
|
||||||
|
for(int i = 0; i < mDataSet->size(); i++)
|
||||||
|
{
|
||||||
|
qreal CurValue = mDataSet->at(i)->mValue;
|
||||||
|
|
||||||
|
if(CurValue != -1 && CurValue != 0) //-1 is the value for "NO DATA" and 0 is not a valid value
|
||||||
|
{
|
||||||
|
if(MaxValue < CurValue)
|
||||||
|
MaxValue = CurValue;
|
||||||
|
if(MinValue > CurValue)
|
||||||
|
MinValue = CurValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(MinValue < 0)
|
||||||
|
{
|
||||||
|
MinValue *= -1;
|
||||||
|
MinValue += 1;
|
||||||
|
mYOffset = MinValue;
|
||||||
|
|
||||||
|
for(int i = 0; i < mDataSet->size(); i++)
|
||||||
|
{
|
||||||
|
mDataSet->at(i)->mValue += MinValue;
|
||||||
|
}
|
||||||
|
MaxValue += MinValue;
|
||||||
|
MinValue = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Build the lines list
|
||||||
|
mLinesList.clear();
|
||||||
|
qreal Width = boundingRect().width();
|
||||||
|
qreal Height = boundingRect().height();
|
||||||
|
qreal tick = (Width)/TimeSpan; //pixels per microsec
|
||||||
|
qreal YFactor = (Height-2)/(MaxValue - MinValue);
|
||||||
|
mYScaling = YFactor;
|
||||||
|
mXScaling = tick;
|
||||||
|
|
||||||
|
|
||||||
|
qreal X1,X2,Y1,Y2;
|
||||||
|
|
||||||
|
//There is no quadratic interpolation, simply draw a straight
|
||||||
|
//line between the points. When needed, execute a linear
|
||||||
|
//interpolation when one of the two points creating a line is
|
||||||
|
//outside the timespan (at both extremities of the view).
|
||||||
|
|
||||||
|
// P2 P3
|
||||||
|
// P1 | *-------* |
|
||||||
|
// * | | P4
|
||||||
|
// | | *
|
||||||
|
// |<----timespan---->|
|
||||||
|
// Start End
|
||||||
|
//
|
||||||
|
//Interpolation needed between Start->P2 and P3->End so there is no
|
||||||
|
//"gap" in the graph between the first/last points and the view.
|
||||||
|
|
||||||
|
|
||||||
|
for(int i = StartIndex; i < StopIndex; i++)
|
||||||
|
{
|
||||||
|
if(mDataSet->at(i)->mValue != -1) //-1 is the value for "NO DATA".
|
||||||
|
{
|
||||||
|
QLine NewLine;
|
||||||
|
|
||||||
|
//Check if interpolation is needed at the left
|
||||||
|
//of the span
|
||||||
|
if(mDataSet->at(i)->mTime < StartTime)
|
||||||
|
{
|
||||||
|
//Interpolate Y value at StartTime
|
||||||
|
qreal x1 = mDataSet->at(i)->mTime;
|
||||||
|
qreal y1 = mDataSet->at(i)->mValue - MinValue;
|
||||||
|
qreal x2 = mDataSet->at(i+1)->mTime;
|
||||||
|
qreal y2 = mDataSet->at(i+1)->mValue - MinValue;
|
||||||
|
|
||||||
|
// Y = mX + B
|
||||||
|
qreal DeltaX = x2 - x1;
|
||||||
|
qreal DeltaY = y2 - y1;
|
||||||
|
|
||||||
|
qreal m = DeltaY/DeltaX;
|
||||||
|
|
||||||
|
Y1 = (qreal)StartTime*m;
|
||||||
|
|
||||||
|
Y1 += (y2 - m*x2);
|
||||||
|
|
||||||
|
X1 = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
X1 = mDataSet->at(i)->mTime - StartTime;
|
||||||
|
Y1 = mDataSet->at(i)->mValue - MinValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Check if interpolation is needed at the right
|
||||||
|
//of the span
|
||||||
|
if(mDataSet->at(i+1)->mTime > StopTime)
|
||||||
|
{
|
||||||
|
//Interpolate Y value at StopTime
|
||||||
|
qreal x1 = mDataSet->at(i)->mTime;
|
||||||
|
qreal y1 = mDataSet->at(i)->mValue - MinValue;
|
||||||
|
qreal x2 = mDataSet->at(i+1)->mTime;
|
||||||
|
qreal y2 = mDataSet->at(i+1)->mValue - MinValue;
|
||||||
|
|
||||||
|
qreal DeltaX = x2 - x1;
|
||||||
|
qreal DeltaY = y2 - y1;
|
||||||
|
|
||||||
|
qreal m = DeltaY/DeltaX;
|
||||||
|
|
||||||
|
Y2 = (qreal)(StopTime)*m;
|
||||||
|
|
||||||
|
Y2 += (y2 - m*x2);
|
||||||
|
|
||||||
|
X2 = StopTime - StartTime;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
X2 = mDataSet->at(i+1)->mTime - StartTime;
|
||||||
|
Y2 = mDataSet->at(i+1)->mValue - MinValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Y1 = Height - Y1*YFactor;
|
||||||
|
Y2 = Height - Y2*YFactor;
|
||||||
|
|
||||||
|
NewLine.setLine(X1*tick,Y1-1,X2*tick,Y2-1);
|
||||||
|
mLinesList.append(NewLine);
|
||||||
|
|
||||||
|
if(mPainterPath.isEmpty())
|
||||||
|
mPainterPath.moveTo(X1*tick,Y1-1);
|
||||||
|
|
||||||
|
// mPainterPath.lineTo(X2*tick,Y2-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mHorizLine != 0)
|
||||||
|
{
|
||||||
|
Y1 = (mHorizLineYPos+mYOffset-MinValue);
|
||||||
|
Y1 = Height - Y1*YFactor;
|
||||||
|
mHorizLine->setP1(QPoint(0,Y1-1));
|
||||||
|
mHorizLine->setP2(QPoint((mDataSet->at(StopIndex)->mTime - StartTime)*tick,Y1-1));
|
||||||
|
}
|
||||||
|
|
||||||
|
mDataValid = true;
|
||||||
|
|
||||||
|
//#ifndef WINDOWS_OS
|
||||||
|
mGraphPixmap->fill(QColor(245, 245, 255));
|
||||||
|
QPainter *painter = new QPainter(mGraphPixmap);
|
||||||
|
painter->drawLines(mLinesList);
|
||||||
|
delete painter;
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
update();
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal CAnalogGraphItem::GetValueForTime(quint64 time)
|
||||||
|
{
|
||||||
|
qreal value = 0.0;
|
||||||
|
for(int i = 0; i < mDataSet->size()-1; i++)
|
||||||
|
{
|
||||||
|
if(time >= mDataSet->at(i)->mTime && time < mDataSet->at(i+1)->mTime)
|
||||||
|
{
|
||||||
|
value = mDataSet->at(i)->mValue - mYOffset;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString label = mLabelTitle;
|
||||||
|
label += "\n";
|
||||||
|
label += QString().sprintf("%.2f",value);
|
||||||
|
|
||||||
|
mLabel->setPlainText(label);
|
||||||
|
mLabel->setPos(mLabel->pos().x(),boundingRect().height()/2 - mLabel->boundingRect().height()/2);
|
||||||
|
update();
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAnalogGraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
{
|
||||||
|
Q_UNUSED(option)
|
||||||
|
Q_UNUSED(widget)
|
||||||
|
|
||||||
|
if(mDataValid == false)
|
||||||
|
return ;
|
||||||
|
if(mDataSet == 0)
|
||||||
|
return;
|
||||||
|
if(mDataSet->size() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// painter->setClipRect(option->exposedRect);
|
||||||
|
|
||||||
|
|
||||||
|
// QPen pen;
|
||||||
|
// pen.setWidth(1);
|
||||||
|
|
||||||
|
//// pen.setColor(Qt::red);
|
||||||
|
//// painter->setPen(pen);
|
||||||
|
//// painter->drawRect(boundingRect());
|
||||||
|
|
||||||
|
// pen.setColor(Qt::black);
|
||||||
|
// painter->setPen(pen);
|
||||||
|
|
||||||
|
//#ifdef WINDOWS_OS
|
||||||
|
// painter->drawLines(mLinesList);
|
||||||
|
//#else
|
||||||
|
|
||||||
|
|
||||||
|
painter->drawPixmap(0,0,*mGraphPixmap);
|
||||||
|
if(mHorizLine != 0)
|
||||||
|
{
|
||||||
|
painter->setPen(QPen(Qt::red));
|
||||||
|
painter->drawLine(*mHorizLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
//painter->drawPath(mPainterPath);
|
||||||
|
|
||||||
|
|
||||||
|
//#endif
|
||||||
|
// for(int i = 0; i < mLinesList.size(); i++)
|
||||||
|
// {
|
||||||
|
// painter->drawEllipse(mLinesList.at(i).p1(),2,2);
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//void CGraphItem::UpdateDisplay()
|
||||||
|
//{
|
||||||
|
// DisplayData(mStartIndex,mStopIndex);
|
||||||
|
// update();
|
||||||
|
//}
|
||||||
|
|
||||||
|
void CAnalogGraphItem::AddHorizontalLine(qreal YPosition)
|
||||||
|
{
|
||||||
|
if(mHorizLine == 0)
|
||||||
|
mHorizLine = new QLine();
|
||||||
|
|
||||||
|
mHorizLineYPos = YPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAnalogGraphItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CAnalogGraphItem::mouseReleaseEvent( QGraphicsSceneMouseEvent * event)
|
||||||
|
{
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAnalogGraphItem::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
//mBackgroundRect->setRect(boundingRect());
|
||||||
|
delete mGraphPixmap;
|
||||||
|
mGraphPixmap = new QPixmap(boundingRect().width(),boundingRect().height());
|
||||||
|
DisplayData(mStartTime,mStopTime);
|
||||||
|
}
|
||||||
|
void CAnalogGraphItem::SetLabel(QString label,int Offset)
|
||||||
|
{
|
||||||
|
QFont font;
|
||||||
|
font.setBold(true);
|
||||||
|
mLabelTitle = label;
|
||||||
|
mLabel->setFont(font);
|
||||||
|
mLabel->setPlainText(label);
|
||||||
|
mLabel->setPos(-Offset,boundingRect().height()/2 - mLabel->boundingRect().height()/2);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGraphAnalogDataPair::CGraphAnalogDataPair(qreal Value, quint64 Time):
|
||||||
|
mValue(Value),
|
||||||
|
mTime(Time)
|
||||||
|
{
|
||||||
|
}
|
||||||
60
sources/GuiElements/AnalogGraphItem.h
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
#ifndef ANALOGGRAPHITEM_H
|
||||||
|
#define ANALOGGRAPHITEM_H
|
||||||
|
|
||||||
|
#include <GlobalDefine.h>
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
#include <QRect>
|
||||||
|
#include <QTimeLine>
|
||||||
|
#include <QList>
|
||||||
|
#include <QPainterPath>
|
||||||
|
|
||||||
|
class CGraphAnalogDataPair
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CGraphAnalogDataPair(qreal Value, quint64 Time);
|
||||||
|
qreal mValue; //changed from qint32
|
||||||
|
quint64 mTime;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CAnalogGraphItem : public QGraphicsWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CAnalogGraphItem(QGraphicsItem *Parent = 0);
|
||||||
|
~CAnalogGraphItem();
|
||||||
|
|
||||||
|
QList<CGraphAnalogDataPair*> *mDataSet;
|
||||||
|
QGraphicsRectItem *mBackgroundRect;
|
||||||
|
|
||||||
|
unsigned int DisplayData(quint64 StartTime, quint64 StopTime);
|
||||||
|
void SetData(QList<CGraphAnalogDataPair*> *DataList);
|
||||||
|
void SetLabel(QString label,int Offset);
|
||||||
|
void SetAbsoluteLimits(quint64 StartTime,quint64 EndTime){mAbsoluteStartTime = StartTime; mAbsoluteEndTime = EndTime;}
|
||||||
|
void AddHorizontalLine(qreal YPosition);
|
||||||
|
qreal GetValueForTime(quint64 time);
|
||||||
|
|
||||||
|
virtual void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
|
||||||
|
virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
|
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event);
|
||||||
|
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
bool mDataValid;
|
||||||
|
quint64 mStartTime, mStopTime, mAbsoluteEndTime,mAbsoluteStartTime;
|
||||||
|
QVector<QLine> mLinesList;
|
||||||
|
QString mLabelTitle;
|
||||||
|
QGraphicsTextItem *mLabel;
|
||||||
|
QPixmap *mGraphPixmap;
|
||||||
|
qreal mYScaling,mXScaling;
|
||||||
|
qreal mYOffset;
|
||||||
|
qreal mHorizLineYPos;
|
||||||
|
QLine *mHorizLine;
|
||||||
|
|
||||||
|
QPainterPath mPainterPath;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ANALOGGRAPHITEM_H
|
||||||
904
sources/GuiElements/DatabaseMgrPage.cpp
Normal file
@ -0,0 +1,904 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Page de sélection des options (sélection des fonctions de détection, ingénierie,
|
||||||
|
mode entretien, etc.).
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131021 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#include "DatabaseMgrPage.h"
|
||||||
|
#include <QPainter>
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include "OutilZT.h"
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QFont>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QTextEdit>
|
||||||
|
#include "OutilZT.h"
|
||||||
|
#include <QGraphicsProxyWidget>
|
||||||
|
#include <QListView>
|
||||||
|
#include <QTreeView>
|
||||||
|
#include <QList>
|
||||||
|
#include <TrainLogFileMgr.h>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
|
|
||||||
|
CDatabaseMgrPage::~CDatabaseMgrPage()
|
||||||
|
{
|
||||||
|
delete mDatabaseImporterThread;
|
||||||
|
delete mDatabaseImporterWorkerThread;
|
||||||
|
}
|
||||||
|
|
||||||
|
CDatabaseMgrPage::CDatabaseMgrPage(QGraphicsWidget *Parent, bool EngMode)
|
||||||
|
{
|
||||||
|
Q_UNUSED(Parent)
|
||||||
|
|
||||||
|
mProgramHandle = 0;
|
||||||
|
|
||||||
|
mBackgroundRect = new QGraphicsRectItem(boundingRect(), this);
|
||||||
|
QBrush BackgroundBrush(QColor(245, 245, 255));
|
||||||
|
mBackgroundRect->setBrush(BackgroundBrush);
|
||||||
|
|
||||||
|
QGraphicsTextItem *Title = new QGraphicsTextItem("Base de données",this);
|
||||||
|
QFont font;
|
||||||
|
font.setPointSize(18);
|
||||||
|
Title->setFont(font);
|
||||||
|
Title->setPos(40,10);
|
||||||
|
|
||||||
|
mCancelButton = new CTextButtonWidget("Fermer");
|
||||||
|
mCancelButton->setParentItem(this);
|
||||||
|
mCancelButton->setPos(50,360);
|
||||||
|
connect(mCancelButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||||
|
|
||||||
|
mImportDataButton = new CTextButtonWidget("Importer");
|
||||||
|
mImportDataButton->setParentItem(this);
|
||||||
|
mImportDataButton->setPos(125,200);
|
||||||
|
connect(mImportDataButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||||
|
mImportDataButton->hide();
|
||||||
|
|
||||||
|
|
||||||
|
mCancelImportButton = new CTextButtonWidget("Annuler");
|
||||||
|
mCancelImportButton->setParentItem(this);
|
||||||
|
mCancelImportButton->setPos(125,200);
|
||||||
|
mCancelImportButton->hide();
|
||||||
|
connect(mCancelImportButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Title = new QGraphicsTextItem("Importation de passages",this);
|
||||||
|
font.setPointSize(14);
|
||||||
|
Title->setFont(font);
|
||||||
|
Title->setPos(40,70);
|
||||||
|
|
||||||
|
QPen RectPen;
|
||||||
|
RectPen.setWidth(2);
|
||||||
|
QGraphicsRectItem *ImportZoneFrame = new QGraphicsRectItem(this);
|
||||||
|
ImportZoneFrame->setRect(QRectF(0,0,230,230));
|
||||||
|
ImportZoneFrame->setPos(40,100);
|
||||||
|
ImportZoneFrame->setPen(RectPen);
|
||||||
|
|
||||||
|
QGraphicsProxyWidget *WidgetProxy = new QGraphicsProxyWidget(this);
|
||||||
|
mImportErrorDataOnlyChkBx = new QCheckBox("Seulement les déclenchements");
|
||||||
|
WidgetProxy->setWidget(mImportErrorDataOnlyChkBx);
|
||||||
|
WidgetProxy->setPos(60,110);
|
||||||
|
mImportErrorDataOnlyChkBx->setChecked(false);
|
||||||
|
|
||||||
|
WidgetProxy = new QGraphicsProxyWidget(this);
|
||||||
|
mFilterDuplicateChkBx = new QCheckBox("Filtrer les doublons");
|
||||||
|
WidgetProxy->setWidget(mFilterDuplicateChkBx);
|
||||||
|
WidgetProxy->setPos(60,140);
|
||||||
|
mFilterDuplicateChkBx->setChecked(true);
|
||||||
|
|
||||||
|
// WidgetProxy = new QGraphicsProxyWidget(this);
|
||||||
|
// mDeleteSourceDataChkBx = new QCheckBox("Effacer données sources");
|
||||||
|
// WidgetProxy->setWidget(mDeleteSourceDataChkBx);
|
||||||
|
// WidgetProxy->setPos(60,170);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
mProgressBar = new QProgressBar();
|
||||||
|
WidgetProxy = new QGraphicsProxyWidget(this);
|
||||||
|
WidgetProxy->setWidget(mProgressBar);
|
||||||
|
WidgetProxy->setPos(60,240);
|
||||||
|
|
||||||
|
font.setPointSize(8);
|
||||||
|
mProgressStatusText = new QGraphicsTextItem(this);
|
||||||
|
mProgressStatusText->setFont(font);
|
||||||
|
mProgressStatusText->setPos(60,260);
|
||||||
|
mProgressStatusText->setPlainText("Progrès de l'importation");
|
||||||
|
|
||||||
|
|
||||||
|
mDatabaseImporterWorkerThread = new CDatabaseImporterThread();
|
||||||
|
mDatabaseImporterThread = new QThread();
|
||||||
|
mDatabaseImporterWorkerThread->moveToThread(mDatabaseImporterThread);
|
||||||
|
connect(mDatabaseImporterThread,SIGNAL(started()),mDatabaseImporterWorkerThread,SLOT(ImportLogs()));
|
||||||
|
connect(mDatabaseImporterWorkerThread,SIGNAL(DatabaseImportFinished(bool,QStringList*)),this,SLOT(DatabaseImportFinished(bool,QStringList*)));
|
||||||
|
connect(mDatabaseImporterWorkerThread,SIGNAL(ResetProgressBar()),mProgressBar,SLOT(reset()));
|
||||||
|
connect(mDatabaseImporterWorkerThread,SIGNAL(SetProgressBarRange(int,int)),mProgressBar,SLOT(setRange(int,int)));
|
||||||
|
connect(mDatabaseImporterWorkerThread,SIGNAL(SetProgressBarVal(int)),mProgressBar,SLOT(setValue(int)));
|
||||||
|
connect(mDatabaseImporterWorkerThread,SIGNAL(SetProgressText(QString)),this,SLOT(SetProgressText(QString)));
|
||||||
|
|
||||||
|
|
||||||
|
Title = new QGraphicsTextItem("Maintenance de la BD",this);
|
||||||
|
font.setPointSize(14);
|
||||||
|
Title->setFont(font);
|
||||||
|
Title->setPos(350,70);
|
||||||
|
|
||||||
|
QGraphicsRectItem *MaintenanceZoneFrame = new QGraphicsRectItem(this);
|
||||||
|
MaintenanceZoneFrame->setRect(QRectF(0,0,260,240));
|
||||||
|
MaintenanceZoneFrame->setPos(350,100);
|
||||||
|
MaintenanceZoneFrame->setPen(RectPen);
|
||||||
|
|
||||||
|
mDeleteDBDuplicatesBtn = new CTextButtonWidget("Effacer doublons");
|
||||||
|
mDeleteDBDuplicatesBtn->setParentItem(this);
|
||||||
|
mDeleteDBDuplicatesBtn->setPos(360,110);
|
||||||
|
connect(mDeleteDBDuplicatesBtn,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||||
|
|
||||||
|
mDeleteNonErrorLogs = new CTextButtonWidget("Effacer passages sans décl.");
|
||||||
|
mDeleteNonErrorLogs->setParentItem(this);
|
||||||
|
mDeleteNonErrorLogs->setPos(360,140);
|
||||||
|
connect(mDeleteNonErrorLogs,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||||
|
|
||||||
|
mDeleteZTLogFiles = new CTextButtonWidget("Effacer fichiers ZTLOG orphelins");
|
||||||
|
mDeleteZTLogFiles->setParentItem(this);
|
||||||
|
mDeleteZTLogFiles->setPos(360,170);
|
||||||
|
connect(mDeleteZTLogFiles,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||||
|
|
||||||
|
mRebuildDatabaseFile = new CTextButtonWidget("Reconstruire le fichier BD");
|
||||||
|
mRebuildDatabaseFile->setParentItem(this);
|
||||||
|
mRebuildDatabaseFile->setPos(360,200);
|
||||||
|
connect(mRebuildDatabaseFile,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
mDBMaintenanceProgressBar = new QProgressBar();
|
||||||
|
WidgetProxy = new QGraphicsProxyWidget(this);
|
||||||
|
WidgetProxy->setWidget(mDBMaintenanceProgressBar);
|
||||||
|
WidgetProxy->setPos(360,240);
|
||||||
|
|
||||||
|
font.setPointSize(8);
|
||||||
|
mDBMaintenanceProgressStatusText = new QGraphicsTextItem(this);
|
||||||
|
mDBMaintenanceProgressStatusText->setFont(font);
|
||||||
|
mDBMaintenanceProgressStatusText->setPos(360,260);
|
||||||
|
mDBMaintenanceProgressStatusText->setPlainText("");
|
||||||
|
|
||||||
|
if(EngMode == false)
|
||||||
|
{
|
||||||
|
mDeleteDBDuplicatesBtn->hide();
|
||||||
|
mDeleteNonErrorLogs->hide();
|
||||||
|
mDeleteZTLogFiles->hide();
|
||||||
|
mRebuildDatabaseFile->hide();
|
||||||
|
mDBMaintenanceProgressBar->hide();
|
||||||
|
mDBMaintenanceProgressStatusText->hide();
|
||||||
|
mFilterDuplicateChkBx->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
font.setPointSize(12);
|
||||||
|
mDBFileCountText = new QGraphicsTextItem(this);
|
||||||
|
mDBFileCountText->setFont(font);
|
||||||
|
mDBFileCountText->setPos(300,10);
|
||||||
|
mDBFileCountText->setPlainText("Nombre de passages: 440\nNombre de fichiers ZTLog: 30");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDatabaseMgrPage::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
mBackgroundRect->setRect(boundingRect());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDatabaseMgrPage::ButtonClicked(CTextButtonWidget *BtnPtr)
|
||||||
|
{
|
||||||
|
if(BtnPtr == mCancelButton)
|
||||||
|
{
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
else if(BtnPtr == mImportDataButton)
|
||||||
|
{
|
||||||
|
ImportData(mImportErrorDataOnlyChkBx->isChecked(), mFilterDuplicateChkBx->isChecked());
|
||||||
|
}
|
||||||
|
else if(BtnPtr == mCancelImportButton)
|
||||||
|
{
|
||||||
|
mDatabaseImporterWorkerThread->KillThread();
|
||||||
|
}
|
||||||
|
else if(BtnPtr == mDeleteDBDuplicatesBtn)
|
||||||
|
{
|
||||||
|
CleanDBDuplicates();
|
||||||
|
}
|
||||||
|
else if(BtnPtr == mDeleteNonErrorLogs)
|
||||||
|
{
|
||||||
|
if(QMessageBox::question(0,"Attention","Voulez vous vraiment éliminer les passages\nsans déclenchements?\nCette action est irréversible",QMessageBox::Yes,QMessageBox::No) == QMessageBox::Yes)
|
||||||
|
{
|
||||||
|
CleanDBNormalPasses();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(BtnPtr == mDeleteZTLogFiles)
|
||||||
|
{
|
||||||
|
if(QMessageBox::question(0,"Attention","Voulez vous vraiment éliminer les fichiers orphelins?\nCette action est irréversible",QMessageBox::Yes,QMessageBox::No) == QMessageBox::Yes)
|
||||||
|
{
|
||||||
|
CleanSingleZTLogFiles();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(BtnPtr == mRebuildDatabaseFile)
|
||||||
|
{
|
||||||
|
mProgramHandle->RebuildDatabaseFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool CDatabaseMgrPage::ImportData(bool OnlyErrorLogs, bool FilterDuplicates)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Ask the user to select the data source directories...
|
||||||
|
QStringList SelectedDirs;
|
||||||
|
SelectedDirs.clear();
|
||||||
|
QFileDialog FileDlg;
|
||||||
|
|
||||||
|
|
||||||
|
FileDlg.setFileMode(QFileDialog::DirectoryOnly);
|
||||||
|
|
||||||
|
QListView *l = FileDlg.findChild<QListView*>("listView");
|
||||||
|
if (l)
|
||||||
|
{
|
||||||
|
l->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||||
|
}
|
||||||
|
QTreeView *t = FileDlg.findChild<QTreeView*>();
|
||||||
|
if (t)
|
||||||
|
{
|
||||||
|
t->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||||
|
}
|
||||||
|
if(FileDlg.exec() == QDialog::Rejected)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectedDirs = FileDlg.selectedFiles();
|
||||||
|
|
||||||
|
if(SelectedDirs.isEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
mDatabaseImporterWorkerThread->SetDatabasePath(mProgramHandle->GetLogDataPath());
|
||||||
|
mDatabaseImporterWorkerThread->SetImporParams(SelectedDirs,FilterDuplicates,OnlyErrorLogs);
|
||||||
|
mDatabaseImporterWorkerThread->SetLogMgrHandle(mLogMgrHandle);
|
||||||
|
|
||||||
|
mCancelButton->hide();
|
||||||
|
mImportDataButton->hide();
|
||||||
|
mCancelImportButton->show();
|
||||||
|
|
||||||
|
mDatabaseImporterThread->start();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool CDatabaseMgrPage::CleanDBDuplicates()
|
||||||
|
{
|
||||||
|
|
||||||
|
int NbDeletedFiles = 0;
|
||||||
|
QList<CLogElement*> *LogsList = mLogMgrHandle->GetLogsList();
|
||||||
|
|
||||||
|
mDBMaintenanceProgressStatusText->setPlainText("Analyse en cours");
|
||||||
|
mDBMaintenanceProgressBar->setRange(0,LogsList->size());
|
||||||
|
for(int i = 0; i < LogsList->size(); i++)
|
||||||
|
{
|
||||||
|
mDBMaintenanceProgressBar->setValue(i+1);
|
||||||
|
for(int j = i+1; j < LogsList->size(); j++)
|
||||||
|
{
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
|
||||||
|
if((LogsList->at(i)->mZTLogType == ZT1_LOG_TYPE) && (LogsList->at(j)->mZTLogType == ZT1_LOG_TYPE))
|
||||||
|
{
|
||||||
|
CZT1LogElement *ZT1LogElement_A = (CZT1LogElement*)LogsList->at(i);
|
||||||
|
CZT1LogElement *ZT1LogElement_B = (CZT1LogElement*)LogsList->at(j);
|
||||||
|
|
||||||
|
if(ZT1LogElement_A->mStationName == ZT1LogElement_B->mStationName)
|
||||||
|
{
|
||||||
|
if(ZT1LogElement_A->mPassageDateTime == ZT1LogElement_B->mPassageDateTime)
|
||||||
|
{
|
||||||
|
//delete file from element B...
|
||||||
|
DeleteFile(ZT1LogElement_B->mLogFileName);
|
||||||
|
NbDeletedFiles++;
|
||||||
|
mDBMaintenanceProgressStatusText->setPlainText(QString().sprintf("Analyse en cours\n%d passages éliminés",NbDeletedFiles));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if((LogsList->at(i)->mZTLogType == ZT2_LOG_TYPE) && (LogsList->at(j)->mZTLogType == ZT2_LOG_TYPE))
|
||||||
|
{
|
||||||
|
CZT2LogElement *ZT2LogElement_A = (CZT2LogElement*)LogsList->at(i);
|
||||||
|
CZT2LogElement *ZT2LogElement_B = (CZT2LogElement*)LogsList->at(j);
|
||||||
|
|
||||||
|
if(ZT2LogElement_A->mStationName == ZT2LogElement_B->mStationName)
|
||||||
|
{
|
||||||
|
if(ZT2LogElement_A->mPassageDateTime == ZT2LogElement_B->mPassageDateTime)
|
||||||
|
{
|
||||||
|
//delete file from element B...
|
||||||
|
DeleteFile(ZT2LogElement_B->mLogFileName);
|
||||||
|
NbDeletedFiles++;
|
||||||
|
mDBMaintenanceProgressStatusText->setPlainText(QString().sprintf("Analyse en cours\n%d passages éliminés",NbDeletedFiles));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mDBMaintenanceProgressStatusText->setPlainText(QString().sprintf("Analyse des doublons terminée\n%d passages éliminés",NbDeletedFiles));
|
||||||
|
mProgramHandle->LogsDatabaseChanged(0);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CDatabaseMgrPage::CleanDBNormalPasses()
|
||||||
|
{
|
||||||
|
int NbDeletedFiles = 0;
|
||||||
|
QList<CLogElement*> *LogsList = mLogMgrHandle->GetLogsList();
|
||||||
|
|
||||||
|
mDBMaintenanceProgressStatusText->setPlainText("Analyse en cours");
|
||||||
|
mDBMaintenanceProgressBar->setRange(0,LogsList->size());
|
||||||
|
for(int i = 0; i < LogsList->size(); i++)
|
||||||
|
{
|
||||||
|
mDBMaintenanceProgressBar->setValue(i+1);
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
|
||||||
|
if(LogsList->at(i)->mZTLogType == ZT1_LOG_TYPE)
|
||||||
|
{
|
||||||
|
CZT1LogElement *ZT1LogElement = (CZT1LogElement*)LogsList->at(i);
|
||||||
|
|
||||||
|
if(ZT1LogElement->mZTDetections.size() == 0 /*&& ZT1LogElement->mFlags.mIsProblematicPassage != 1*/ && ZT1LogElement->mFileProtected == false)
|
||||||
|
{
|
||||||
|
|
||||||
|
DeleteFile(ZT1LogElement->mLogFileName);
|
||||||
|
NbDeletedFiles++;
|
||||||
|
mDBMaintenanceProgressStatusText->setPlainText(QString().sprintf("Analyse en cours\n%d passages éliminés",NbDeletedFiles));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CZT2LogElement *ZT2LogElement = (CZT2LogElement*)LogsList->at(i);
|
||||||
|
|
||||||
|
if(ZT2LogElement->mZTDetections.size() == 0 /*&& ZT2LogElement->mFlags.mIsProblematicPassage != 1*/ && ZT2LogElement->mFileProtected == false)
|
||||||
|
{
|
||||||
|
|
||||||
|
//delete file from element B...
|
||||||
|
DeleteFile(ZT2LogElement->mLogFileName);
|
||||||
|
NbDeletedFiles++;
|
||||||
|
mDBMaintenanceProgressStatusText->setPlainText(QString().sprintf("Analyse en cours\n%d passages éliminés",NbDeletedFiles));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mDBMaintenanceProgressStatusText->setPlainText(QString().sprintf("Analyse des passages terminée\n%d passages éliminés",NbDeletedFiles));
|
||||||
|
mProgramHandle->LogsDatabaseChanged(0);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CDatabaseMgrPage::CleanSingleZTLogFiles()
|
||||||
|
{
|
||||||
|
QList<CZTLogFileInfo> *ZTLogFilesList;
|
||||||
|
|
||||||
|
ZTLogFilesList = mZTLogFilesManager->GetZTLogsList();
|
||||||
|
|
||||||
|
if(ZTLogFilesList->size() == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
mDBMaintenanceProgressStatusText->setPlainText("Analyse en cours");
|
||||||
|
mDBMaintenanceProgressBar->setRange(0,ZTLogFilesList->size());
|
||||||
|
int NbRemoved = 0;
|
||||||
|
for(int i = 0; i < ZTLogFilesList->size(); i++)
|
||||||
|
{
|
||||||
|
mDBMaintenanceProgressBar->setValue(i+1);
|
||||||
|
QFileInfo ZTLogFile(ZTLogFilesList->at(i).mZTLogFilePath);
|
||||||
|
QDir ZTLogFileDir = ZTLogFile.absoluteDir();
|
||||||
|
|
||||||
|
ZTLogFileDir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
|
||||||
|
if(ZTLogFileDir.entryList().size() == 1)
|
||||||
|
{
|
||||||
|
NbRemoved++;
|
||||||
|
if(ZTLogFileDir.remove(ZTLogFile.absoluteFilePath()))
|
||||||
|
{
|
||||||
|
//qDebug("Removed %s",ZTLogFile.absoluteFilePath().toUtf8().data());
|
||||||
|
}
|
||||||
|
ZTLogFileDir.rmdir(ZTLogFile.absolutePath());
|
||||||
|
{
|
||||||
|
//qDebug("Removed %s",ZTLogFile.absolutePath().toUtf8().data());
|
||||||
|
}
|
||||||
|
ZTLogFilesList->removeAt(i);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mDBMaintenanceProgressStatusText->setPlainText(QString().sprintf("Analyse des fichiers terminée\n%d fichiers ZTLOG éliminés",NbRemoved));
|
||||||
|
mDBMaintenanceProgressBar->setRange(0,ZTLogFilesList->size());
|
||||||
|
mProgramHandle->ZTLogFilesChanged();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDatabaseMgrPage::DatabaseImportFinished(bool ret,QStringList* FilesList)
|
||||||
|
{
|
||||||
|
if(ret == false)
|
||||||
|
{
|
||||||
|
mProgressBar->reset();
|
||||||
|
mProgressStatusText->setPlainText("Importation non terminée...");
|
||||||
|
}
|
||||||
|
|
||||||
|
mDatabaseImporterThread->quit();
|
||||||
|
mCancelButton->show();
|
||||||
|
mImportDataButton->show();
|
||||||
|
mCancelImportButton->hide();
|
||||||
|
if(ret == true)
|
||||||
|
{
|
||||||
|
mProgramHandle->LogsDatabaseChanged(FilesList);
|
||||||
|
FilesList->clear();
|
||||||
|
delete FilesList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDatabaseMgrPage::SetProgressText(QString Text)
|
||||||
|
{
|
||||||
|
mProgressStatusText->setPlainText(Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CDatabaseMgrPage::DeleteFile(QString FilePath)
|
||||||
|
{
|
||||||
|
QDir dir;
|
||||||
|
if(dir.remove(FilePath) == false)
|
||||||
|
{
|
||||||
|
qDebug("Could not delete file %s",FilePath.toUtf8().data());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
qDebug("File deleted: %s",FilePath.toUtf8().data());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void CDatabaseMgrPage::UpdateDBStats()
|
||||||
|
{
|
||||||
|
int NbTrains, NbZTLog;
|
||||||
|
|
||||||
|
NbTrains = mLogMgrHandle->GetLogsCount();
|
||||||
|
NbZTLog = mZTLogFilesManager->GetZTLogFilesCount();
|
||||||
|
|
||||||
|
mDBFileCountText->setPlainText(QString().sprintf("Nombre de passages: %d\nNombre de fichiers ZTLog: %d",NbTrains,NbZTLog));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDatabaseMgrPage::EnableEngineeringMode()
|
||||||
|
{
|
||||||
|
mDeleteDBDuplicatesBtn->show();
|
||||||
|
mDeleteNonErrorLogs->show();
|
||||||
|
mDeleteZTLogFiles->show();
|
||||||
|
mRebuildDatabaseFile->show();
|
||||||
|
mDBMaintenanceProgressBar->show();
|
||||||
|
mDBMaintenanceProgressStatusText->show();
|
||||||
|
mFilterDuplicateChkBx->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDatabaseMgrPage::EnableLogImport()
|
||||||
|
{
|
||||||
|
mImportDataButton->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Grab the mouse if the user clicks outside buttons
|
||||||
|
void CDatabaseMgrPage::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
}
|
||||||
|
void CDatabaseMgrPage::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
}
|
||||||
|
void CDatabaseMgrPage::showEvent(QShowEvent *event)
|
||||||
|
{
|
||||||
|
//qDebug("Show");
|
||||||
|
UpdateDBStats();
|
||||||
|
}
|
||||||
|
|
||||||
|
CDatabaseImporterThread::CDatabaseImporterThread()
|
||||||
|
{
|
||||||
|
mLogMgrHandle = 0;
|
||||||
|
mKillThread = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDatabaseImporterThread::ImportLogs()
|
||||||
|
{
|
||||||
|
mKillThread = false;
|
||||||
|
bool OnlyErrorLogs = mOnlyErrorLogs;
|
||||||
|
bool FilterDuplicates = mFilterDuplicates;
|
||||||
|
QStringList SelectedDirs = mSelectedDirs;
|
||||||
|
|
||||||
|
int NbDeletedFiles = 0;
|
||||||
|
int NbCopiedFiles = 0;
|
||||||
|
int NbCopiedDirs = 0;
|
||||||
|
|
||||||
|
|
||||||
|
ClearDir(QDir("./Temp"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
emit SetProgressBarRange(0,SelectedDirs.size());
|
||||||
|
emit ResetProgressBar();
|
||||||
|
emit SetProgressText("Copie des répertoires temporaires");
|
||||||
|
//Copy the files
|
||||||
|
for(int i = 0; i < SelectedDirs.size(); i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
QDir SrcDir(SelectedDirs.at(i));
|
||||||
|
QString tmp = "./Temp/" + SrcDir.dirName();
|
||||||
|
QDir DestDir(tmp);
|
||||||
|
|
||||||
|
CopyDir(SrcDir,DestDir);
|
||||||
|
emit SetProgressBarVal(i+1);
|
||||||
|
|
||||||
|
if(IsThreadKilled())
|
||||||
|
{
|
||||||
|
emit DatabaseImportFinished(false,0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse each directory to add.
|
||||||
|
QFileInfoList DataFilePath;
|
||||||
|
DataFilePath.clear();
|
||||||
|
QDir TempDir("./Temp");
|
||||||
|
DataFilePath = TempDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
|
|
||||||
|
if(DataFilePath.isEmpty())
|
||||||
|
{
|
||||||
|
emit DatabaseImportFinished(false,0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DatabasePath = mDatabasePath;
|
||||||
|
QList<CLogElement*> *ExistingLogsList = mLogMgrHandle->GetLogsList();
|
||||||
|
|
||||||
|
QStringList LogFilters;
|
||||||
|
LogFilters << "*.bin";
|
||||||
|
bool CopyDirectory = true;
|
||||||
|
|
||||||
|
if(FilterDuplicates == true || OnlyErrorLogs == true)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < DataFilePath.size(); i++)
|
||||||
|
{
|
||||||
|
QFileInfoList list;
|
||||||
|
|
||||||
|
//Load files in base directory
|
||||||
|
QDir LogDir(DataFilePath.at(i).absoluteFilePath());
|
||||||
|
LogDir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
|
||||||
|
LogDir.setNameFilters(LogFilters);
|
||||||
|
LogDir.setSorting(QDir::Name);
|
||||||
|
list = LogDir.entryInfoList();
|
||||||
|
if(list.size() != 0)
|
||||||
|
{
|
||||||
|
//If no filtering is required, just copy the directory...
|
||||||
|
if(FilterDuplicates == false && OnlyErrorLogs == false)
|
||||||
|
{
|
||||||
|
CopyDirectory = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unsigned int ret;
|
||||||
|
emit SetProgressBarRange(0,list.size());
|
||||||
|
emit ResetProgressBar();
|
||||||
|
emit SetProgressText(QString().sprintf("Vérification du répertoire:\n%s",DataFilePath.at(i).fileName().toUtf8().data()));
|
||||||
|
|
||||||
|
for(int NewLogIndex = 0; NewLogIndex < list.size(); NewLogIndex++)
|
||||||
|
{
|
||||||
|
CLogElement *CurLogElement = CTrainLogFileMgr::instance()->OpenTrainLog(list.at(NewLogIndex).absoluteFilePath(),ret);
|
||||||
|
|
||||||
|
if(CurLogElement->mZTLogType == ZT1_LOG_TYPE)
|
||||||
|
{
|
||||||
|
CZT1LogElement * NewZT1Element = (CZT1LogElement*)CurLogElement;
|
||||||
|
bool FileDeleted = false;
|
||||||
|
|
||||||
|
if(OnlyErrorLogs && (FileDeleted == false))
|
||||||
|
{
|
||||||
|
if(NewZT1Element->mZTDetections.size() == 0)
|
||||||
|
{
|
||||||
|
DeleteFile(list.at(NewLogIndex).absoluteFilePath());
|
||||||
|
FileDeleted = true;
|
||||||
|
NbDeletedFiles++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(FilterDuplicates && (FileDeleted == false))
|
||||||
|
{
|
||||||
|
for(int ExistingLogIndex = 0; ExistingLogIndex < ExistingLogsList->size(); ExistingLogIndex++)
|
||||||
|
{
|
||||||
|
if(ExistingLogsList->at(ExistingLogIndex)->mZTLogType == ZT1_LOG_TYPE)
|
||||||
|
{
|
||||||
|
CZT1LogElement * ExistingZT1Element = (CZT1LogElement*)ExistingLogsList->at(ExistingLogIndex);
|
||||||
|
|
||||||
|
if(ExistingZT1Element->mStationName == NewZT1Element->mStationName)
|
||||||
|
{
|
||||||
|
if(ExistingZT1Element->mPassageDateTime == NewZT1Element->mPassageDateTime)
|
||||||
|
{
|
||||||
|
//Delete the file from the temporary directory.
|
||||||
|
DeleteFile(list.at(NewLogIndex).absoluteFilePath());
|
||||||
|
FileDeleted = true;
|
||||||
|
NbDeletedFiles++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else //ZT2
|
||||||
|
{
|
||||||
|
CZT2LogElement * NewZT2Element = (CZT2LogElement*)CurLogElement;
|
||||||
|
bool FileDeleted = false;
|
||||||
|
|
||||||
|
if(OnlyErrorLogs && (FileDeleted == false))
|
||||||
|
{
|
||||||
|
if(NewZT2Element->mZTDetections.size() == 0)
|
||||||
|
{
|
||||||
|
DeleteFile(list.at(NewLogIndex).absoluteFilePath());
|
||||||
|
FileDeleted = true;
|
||||||
|
NbDeletedFiles++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(FilterDuplicates && (FileDeleted == false))
|
||||||
|
{
|
||||||
|
for(int ExistingLogIndex = 0; ExistingLogIndex < ExistingLogsList->size(); ExistingLogIndex++)
|
||||||
|
{
|
||||||
|
if(ExistingLogsList->at(ExistingLogIndex)->mZTLogType == ZT2_LOG_TYPE)
|
||||||
|
{
|
||||||
|
CZT2LogElement * ExistingZT2Element = (CZT2LogElement*)ExistingLogsList->at(ExistingLogIndex);
|
||||||
|
|
||||||
|
if(ExistingZT2Element->mStationName == NewZT2Element->mStationName)
|
||||||
|
{
|
||||||
|
if(ExistingZT2Element->mPassageDateTime == NewZT2Element->mPassageDateTime)
|
||||||
|
{
|
||||||
|
//Delete the file from the temporary directory.
|
||||||
|
DeleteFile(list.at(NewLogIndex).absoluteFilePath());
|
||||||
|
FileDeleted = true;
|
||||||
|
NbDeletedFiles++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
emit SetProgressBarVal(NewLogIndex+1);
|
||||||
|
delete CurLogElement;
|
||||||
|
if(IsThreadKilled())
|
||||||
|
{
|
||||||
|
emit DatabaseImportFinished(false,0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CopyDirectory = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList *NewFilesList = new QStringList;
|
||||||
|
if(CopyDirectory)
|
||||||
|
{
|
||||||
|
QDir TmpDir("./Temp");
|
||||||
|
DataFilePath.clear();
|
||||||
|
DataFilePath = TmpDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
|
|
||||||
|
//Find the number of files to copy for the progress bar...
|
||||||
|
int NbFilesToCopy = 0;
|
||||||
|
for(int i = 0; i < DataFilePath.size(); i++)
|
||||||
|
{
|
||||||
|
QDir SrcDir(DataFilePath.at(i).absoluteFilePath());
|
||||||
|
NbFilesToCopy += SrcDir.entryList(QDir::Files).size();
|
||||||
|
}
|
||||||
|
|
||||||
|
emit SetProgressBarRange(0,NbFilesToCopy);
|
||||||
|
emit ResetProgressBar();
|
||||||
|
ProgressValue = 0;
|
||||||
|
emit SetProgressText("Copie des fichiers dans la BD");
|
||||||
|
|
||||||
|
for(int i = 0; i < DataFilePath.size(); i++)
|
||||||
|
{
|
||||||
|
QString StationDir;
|
||||||
|
StationDir.clear();
|
||||||
|
|
||||||
|
QStringList DirNameNibbles = DataFilePath.at(i).fileName().split('_');
|
||||||
|
if(DirNameNibbles.size() == 3)
|
||||||
|
{
|
||||||
|
StationDir = DirNameNibbles.at(1);
|
||||||
|
QDir SrcDir(DataFilePath.at(i).absoluteFilePath());
|
||||||
|
QString tmp = DatabasePath + SrcDir.separator() + StationDir + SrcDir.separator() + SrcDir.dirName();
|
||||||
|
QDir DestDir(QDir::cleanPath(tmp));
|
||||||
|
|
||||||
|
NbCopiedFiles += CopyDir(SrcDir,DestDir,true);
|
||||||
|
NbCopiedDirs++;
|
||||||
|
|
||||||
|
QFileInfoList FilesList = DestDir.entryInfoList(QDir::Files);
|
||||||
|
for(int i = 0; i < FilesList.size(); i++)
|
||||||
|
{
|
||||||
|
NewFilesList->append(FilesList.at(i).absoluteFilePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug("Erreur, nom de répertoire illégal : %s",DataFilePath.at(i).absoluteFilePath().toUtf8().data());
|
||||||
|
}
|
||||||
|
if(IsThreadKilled())
|
||||||
|
{
|
||||||
|
emit DatabaseImportFinished(false,0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// emit SetProgressBarVal(i+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
emit ResetProgressBar();
|
||||||
|
emit SetProgressText(QString().sprintf("Importation terminée avec succès\n%d passages ignorés\n%d fichiers copiés dans %d répertoires",NbDeletedFiles,NbCopiedFiles,NbCopiedDirs));
|
||||||
|
|
||||||
|
emit DatabaseImportFinished(true,NewFilesList);
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int CDatabaseImporterThread::CopyDir(QDir Dir, QDir DestDir, bool NotifyWhenCopied)
|
||||||
|
{
|
||||||
|
|
||||||
|
int CopiedFiles = 0;
|
||||||
|
|
||||||
|
if (!Dir.exists())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Dir.mkpath(DestDir.absolutePath());
|
||||||
|
|
||||||
|
foreach (QString f, Dir.entryList(QDir::Files))
|
||||||
|
{
|
||||||
|
QFile::copy(Dir.absolutePath() + QDir::separator() + f, DestDir.absolutePath() + QDir::separator() + f);
|
||||||
|
CopiedFiles++;
|
||||||
|
if(NotifyWhenCopied)
|
||||||
|
{
|
||||||
|
ProgressValue++;
|
||||||
|
emit SetProgressBarVal(ProgressValue);
|
||||||
|
emit SetProgressText(QString().sprintf("Copie des fichiers dans la BD\n%s",f.toUtf8().data()));
|
||||||
|
}
|
||||||
|
if(IsThreadKilled())
|
||||||
|
{
|
||||||
|
return CopiedFiles;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return CopiedFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CDatabaseImporterThread::ClearDir(QDir Dir)
|
||||||
|
{
|
||||||
|
if (!Dir.exists())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
QFileInfoList DirList = Dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
|
||||||
|
for(int i = 0; i < DirList.size(); i++)
|
||||||
|
{
|
||||||
|
// QFileInfo info(DirList.at(i));
|
||||||
|
if (DirList.at(i).isDir())
|
||||||
|
{
|
||||||
|
if (!ClearDir(QDir(DirList.at(i).filePath())))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(Dir.rmdir(DirList.at(i).absoluteFilePath()) == false)
|
||||||
|
{
|
||||||
|
qDebug("Could not delete %s",DirList.at(i).filePath().toUtf8().data());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Dir.remove(DirList.at(i).absoluteFilePath()) == false)
|
||||||
|
{
|
||||||
|
qDebug("Cannot delete %s",DirList.at(i).absoluteFilePath().toUtf8().data()); // return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CDatabaseImporterThread::DeleteFile(QString FilePath)
|
||||||
|
{
|
||||||
|
QDir dir;
|
||||||
|
if(dir.remove(FilePath) == false)
|
||||||
|
{
|
||||||
|
qDebug("Could not delete file %s",FilePath.toUtf8().data());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
qDebug("File deleted: %s",FilePath.toUtf8().data());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CDatabaseImporterThread::ParseDir(QDir dir)
|
||||||
|
{
|
||||||
|
|
||||||
|
QStringList LogFilters;
|
||||||
|
QFileInfoList list;
|
||||||
|
// QString LogDataDir = mProgramHandle->GetLogDataPath();
|
||||||
|
LogFilters << "*.bin";
|
||||||
|
|
||||||
|
//Load files in base directory
|
||||||
|
QDir LogDir(dir);
|
||||||
|
LogDir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
|
||||||
|
LogDir.setNameFilters(LogFilters);
|
||||||
|
LogDir.setSorting(QDir::Name);
|
||||||
|
list = LogDir.entryInfoList();
|
||||||
|
if(list.size() != 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDatabaseImporterThread::SetImporParams(QStringList SelectedDirs, bool FilterDuplicates, bool OnlyErrorLogs)
|
||||||
|
{
|
||||||
|
mSelectedDirs = SelectedDirs;
|
||||||
|
mFilterDuplicates = FilterDuplicates;
|
||||||
|
mOnlyErrorLogs = OnlyErrorLogs;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDatabaseImporterThread::KillThread()
|
||||||
|
{
|
||||||
|
mMutex.lockForWrite();
|
||||||
|
mKillThread = true;
|
||||||
|
mMutex.unlock();
|
||||||
|
|
||||||
|
qDebug("Thread killed");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CDatabaseImporterThread::IsThreadKilled()
|
||||||
|
{
|
||||||
|
bool tmp;
|
||||||
|
mMutex.lockForRead();
|
||||||
|
tmp = mKillThread;
|
||||||
|
mMutex.unlock();
|
||||||
|
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
157
sources/GuiElements/DatabaseMgrPage.h
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Description du fichier si nécessaire.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131021 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef DATABASEMGRPAGE_H
|
||||||
|
#define DATABASEMGRPAGE_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
#include "Guipage.h"
|
||||||
|
#include <QString>
|
||||||
|
#include "PushButton.h"
|
||||||
|
#include "TextButtonWidget.h"
|
||||||
|
#include "ZTData.h"
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include "LogMgr.h"
|
||||||
|
#include <QProgressBar>
|
||||||
|
#include <QThread>
|
||||||
|
#include <QReadWriteLock>
|
||||||
|
#include "ZTLogFilesMgr.h"
|
||||||
|
|
||||||
|
class COutilZT;
|
||||||
|
|
||||||
|
class CDatabaseImporterThread : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CDatabaseImporterThread();
|
||||||
|
|
||||||
|
void SetDatabasePath(QString path){mDatabasePath = path;}
|
||||||
|
void SetLogMgrHandle(CLogMgr *Handle){mLogMgrHandle = Handle;}
|
||||||
|
void SetImporParams(QStringList SelectedDirs, bool FilterDuplicates, bool OnlyErrorLogs);
|
||||||
|
void KillThread();
|
||||||
|
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void ImportLogs();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
int ParseDir(QDir dir);
|
||||||
|
int CopyDir(QDir Dir, QDir DestDir,bool NotifyWhenCopied = false);
|
||||||
|
bool ClearDir(QDir Dir);
|
||||||
|
bool DeleteFile(QString FilePath);
|
||||||
|
bool mKillThread;
|
||||||
|
QReadWriteLock mMutex;
|
||||||
|
|
||||||
|
QString mDatabasePath;
|
||||||
|
CLogMgr *mLogMgrHandle;
|
||||||
|
|
||||||
|
|
||||||
|
QStringList mSelectedDirs;
|
||||||
|
bool mFilterDuplicates;
|
||||||
|
bool mOnlyErrorLogs;
|
||||||
|
|
||||||
|
bool IsThreadKilled();
|
||||||
|
int ProgressValue;
|
||||||
|
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void DatabaseImportFinished(bool,QStringList*);
|
||||||
|
void SetProgressBarRange(int,int);
|
||||||
|
void SetProgressBarVal(int);
|
||||||
|
void ResetProgressBar();
|
||||||
|
void SetProgressText(QString);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class CDatabaseMgrPage : public CGuiPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CDatabaseMgrPage(QGraphicsWidget *Parent = 0,bool EngMode = false);
|
||||||
|
~CDatabaseMgrPage();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
COutilZT *mProgramHandle;
|
||||||
|
CLogMgr *mLogMgrHandle;
|
||||||
|
CZTLogFilesMgr *mZTLogFilesManager;
|
||||||
|
|
||||||
|
void UpdateDBStats();
|
||||||
|
void EnableEngineeringMode();
|
||||||
|
void EnableLogImport();
|
||||||
|
|
||||||
|
virtual void showEvent(QShowEvent *event);
|
||||||
|
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||||
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
QGraphicsRectItem *mBackgroundRect;
|
||||||
|
CTextButtonWidget *mCancelButton, *mImportDataButton, *mCancelImportButton;
|
||||||
|
QCheckBox *mImportErrorDataOnlyChkBx, *mFilterDuplicateChkBx, *mDeleteSourceDataChkBx;
|
||||||
|
QProgressBar *mProgressBar;
|
||||||
|
QGraphicsTextItem *mProgressStatusText;
|
||||||
|
|
||||||
|
CTextButtonWidget *mDeleteDBDuplicatesBtn, *mDeleteNonErrorLogs, *mDeleteZTLogFiles, *mRebuildDatabaseFile;
|
||||||
|
QProgressBar *mDBMaintenanceProgressBar;
|
||||||
|
QGraphicsTextItem *mDBMaintenanceProgressStatusText;
|
||||||
|
QGraphicsTextItem *mDBFileCountText;
|
||||||
|
|
||||||
|
|
||||||
|
CDatabaseImporterThread *mDatabaseImporterWorkerThread;
|
||||||
|
QThread *mDatabaseImporterThread;
|
||||||
|
|
||||||
|
bool ImportData(bool OnlyError, bool FilterDuplicates);
|
||||||
|
bool CleanDBDuplicates();
|
||||||
|
bool CleanDBNormalPasses();
|
||||||
|
bool CleanSingleZTLogFiles();
|
||||||
|
bool DeleteFile(QString FilePath);
|
||||||
|
|
||||||
|
|
||||||
|
// int ParseDir(QDir dir);
|
||||||
|
// bool CopyDir(QDir Dir, QDir DestDir);
|
||||||
|
// bool ClearDir(QDir Dir);
|
||||||
|
// bool DeleteFile(QString FilePath);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void ButtonClicked(CTextButtonWidget *);
|
||||||
|
void DatabaseImportFinished(bool,QStringList*);
|
||||||
|
void SetProgressText(QString);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // DATABASEMGRPAGE_H
|
||||||
127
sources/GuiElements/EventsRulerWidget.cpp
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 - 2013 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Dessine une règle temporelle sur laquelle sont affichés les déclenchements.
|
||||||
|
Une ligne rouge est dessinée au temps correspondant au déclenchement et du
|
||||||
|
texte identifiant le type de déclenchement est aussi affiché.
|
||||||
|
|
||||||
|
Utilisée dans la page de visualisation des passages de train.
|
||||||
|
|
||||||
|
CETTE CLASSE DEVRAIT ÊTRE OPTIMISÉE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### YYYMMDD JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#include "EventsRulerWidget.h"
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QTextStream>
|
||||||
|
|
||||||
|
CEventRulerWidget::CEventRulerWidget(qreal RulerPixelWidth, QGraphicsItem *Parent)
|
||||||
|
{
|
||||||
|
setParentItem(Parent);
|
||||||
|
mPixelWidth = RulerPixelWidth;
|
||||||
|
mLabel = new QGraphicsTextItem(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CEventRulerWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
{
|
||||||
|
Q_UNUSED(option)
|
||||||
|
Q_UNUSED(widget)
|
||||||
|
|
||||||
|
if(mEventItems.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QFont font;
|
||||||
|
font.setPixelSize(12);
|
||||||
|
painter->setFont(font);
|
||||||
|
qreal pitch = mPixelWidth/(mEndTime - mStartTime); //pixel/ns
|
||||||
|
|
||||||
|
QPen LinePen,TextPen;
|
||||||
|
LinePen.setColor(Qt::red);
|
||||||
|
LinePen.setWidth(2);
|
||||||
|
TextPen.setColor(Qt::black);
|
||||||
|
TextPen.setWidth(1);
|
||||||
|
|
||||||
|
qreal Height = boundingRect().height();
|
||||||
|
|
||||||
|
for(int i = 0; i < mEventItems.size(); i++)
|
||||||
|
{
|
||||||
|
if(mEventItems.at(i).mEventTime >= mStartTime)
|
||||||
|
{
|
||||||
|
if(mEventItems.at(i).mEventTime <= mEndTime)
|
||||||
|
{
|
||||||
|
qreal PixelPos = (mEventItems.at(i).mEventTime - mStartTime)*pitch;
|
||||||
|
painter->setPen(LinePen);
|
||||||
|
painter->drawLine(PixelPos,0,PixelPos,Height);
|
||||||
|
painter->setPen(TextPen);
|
||||||
|
painter->drawText(QRectF(PixelPos+3,0,50,Height),mEventItems.at(i).mLabel,Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CEventRulerWidget::SetRange(quint64 StartTime, quint64 EndTime)
|
||||||
|
{
|
||||||
|
if(StartTime > EndTime)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(mEventItems.isEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
mStartTime = StartTime;
|
||||||
|
mEndTime = EndTime;
|
||||||
|
|
||||||
|
update();
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CEventRulerWidget::AddEventItem(QString Rank, quint64 EventTime)
|
||||||
|
{
|
||||||
|
CEventRulerWidgetItem NewItem;
|
||||||
|
NewItem.mLabel = Rank;
|
||||||
|
NewItem.mEventTime = EventTime;
|
||||||
|
|
||||||
|
mEventItems.append(NewItem);
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CEventRulerWidget::SetLabel(QString Label, int Offset)
|
||||||
|
{
|
||||||
|
QFont font;
|
||||||
|
font.setBold(true);
|
||||||
|
mLabel->setFont(font);
|
||||||
|
mLabel->setPlainText(Label);
|
||||||
|
mLabel->setPos(-Offset,boundingRect().height()/2 - mLabel->boundingRect().height()/2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CEventRulerWidget::ClearRuler()
|
||||||
|
{
|
||||||
|
mEventItems.clear();
|
||||||
|
update();
|
||||||
|
}
|
||||||
65
sources/GuiElements/EventsRulerWidget.h
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 - 2013 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Description du fichier si nécessaire.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131030 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### 20131107 Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef EVENTSRULERWIDGET_H
|
||||||
|
#define EVENTSRULERWIDGET_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
|
||||||
|
class CEventRulerWidgetItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QString mLabel;
|
||||||
|
quint64 mEventTime;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CEventRulerWidget : public QGraphicsWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CEventRulerWidget(qreal RulerPixelWidth,QGraphicsItem *Parent = 0);
|
||||||
|
|
||||||
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
|
||||||
|
unsigned int SetRange(quint64 StartTime, quint64 EndTime);
|
||||||
|
unsigned int AddEventItem(QString EventLabel,quint64 EventTime);
|
||||||
|
void SetLabel(QString Label,int Offset);
|
||||||
|
void ClearRuler();
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
qreal mPixelWidth;
|
||||||
|
quint64 mStartTime, mEndTime;
|
||||||
|
qreal mPixelPitch;
|
||||||
|
QGraphicsTextItem *mLabel;
|
||||||
|
|
||||||
|
QList<CEventRulerWidgetItem> mEventItems;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // RANKRULERWIDGET_H
|
||||||
138
sources/GuiElements/GraphCursorWidget.cpp
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 - 2013 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Dessine une ligne verticale et garde certaines information sur la position du
|
||||||
|
curseur
|
||||||
|
|
||||||
|
|
||||||
|
Utilisée dans la page de visualisation des passages de train..
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### YYYMMDD JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "GraphCursorWidget.h"
|
||||||
|
#include <QPen>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
CVerticalGraphCursorWidget::CVerticalGraphCursorWidget(qreal Height,QGraphicsItem *Parent)
|
||||||
|
{
|
||||||
|
setParentItem(Parent);
|
||||||
|
resize(3,Height);
|
||||||
|
mLine.setLine(0,0,0,Height);
|
||||||
|
mColor = Qt::blue;
|
||||||
|
mCursorTime = 0;
|
||||||
|
mCursorSet = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CVerticalGraphCursorWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
{
|
||||||
|
Q_UNUSED(option)
|
||||||
|
Q_UNUSED(widget)
|
||||||
|
|
||||||
|
QPen pen;
|
||||||
|
pen.setWidth(1);
|
||||||
|
pen.setColor(mColor);
|
||||||
|
painter->setPen(pen);
|
||||||
|
|
||||||
|
painter->drawLine(mLine);
|
||||||
|
|
||||||
|
// if(mWidth != 0)
|
||||||
|
// painter->drawLine(mHLine);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal CVerticalGraphCursorWidget::GetPixelPos()
|
||||||
|
{
|
||||||
|
return pos().x();
|
||||||
|
}
|
||||||
|
quint64 CVerticalGraphCursorWidget::GetTime()
|
||||||
|
{
|
||||||
|
return mCursorTime;
|
||||||
|
}
|
||||||
|
void CVerticalGraphCursorWidget::SetTime(quint64 time)
|
||||||
|
{
|
||||||
|
mCursorTime = time;
|
||||||
|
}
|
||||||
|
bool CVerticalGraphCursorWidget::IsCursorSet()
|
||||||
|
{
|
||||||
|
return mCursorSet;
|
||||||
|
}
|
||||||
|
void CVerticalGraphCursorWidget::ClearCursor()
|
||||||
|
{
|
||||||
|
mCursorSet = false;
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
void CVerticalGraphCursorWidget::SetCursor()
|
||||||
|
{
|
||||||
|
mCursorSet = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CHorizontalGraphCursorWidget::CHorizontalGraphCursorWidget(qreal Width,QGraphicsItem *Parent)
|
||||||
|
{
|
||||||
|
setParentItem(Parent);
|
||||||
|
resize(3,Width);
|
||||||
|
mLine.setLine(0,0,Width,0);
|
||||||
|
mColor = Qt::blue;
|
||||||
|
mCursorSet = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CHorizontalGraphCursorWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
{
|
||||||
|
Q_UNUSED(option)
|
||||||
|
Q_UNUSED(widget)
|
||||||
|
|
||||||
|
QPen pen;
|
||||||
|
pen.setWidth(1);
|
||||||
|
pen.setColor(mColor);
|
||||||
|
painter->setPen(pen);
|
||||||
|
|
||||||
|
painter->drawLine(mLine);
|
||||||
|
|
||||||
|
// if(mWidth != 0)
|
||||||
|
// painter->drawLine(mHLine);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal CHorizontalGraphCursorWidget::GetPixelPos()
|
||||||
|
{
|
||||||
|
return pos().y();
|
||||||
|
}
|
||||||
|
bool CHorizontalGraphCursorWidget::IsCursorSet()
|
||||||
|
{
|
||||||
|
return mCursorSet;
|
||||||
|
}
|
||||||
|
void CHorizontalGraphCursorWidget::ClearCursor()
|
||||||
|
{
|
||||||
|
mCursorSet = false;
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
void CHorizontalGraphCursorWidget::SetCursor()
|
||||||
|
{
|
||||||
|
mCursorSet = true;
|
||||||
|
}
|
||||||
76
sources/GuiElements/GraphCursorWidget.h
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 - 2013 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Description du fichier si nécessaire.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### YYYMMDD JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef GRAPHCURSORWIDGET_H
|
||||||
|
#define GRAPHCURSORWIDGET_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
|
||||||
|
class CVerticalGraphCursorWidget : public QGraphicsWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CVerticalGraphCursorWidget(qreal Height, QGraphicsItem *Parent = 0);
|
||||||
|
|
||||||
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
qreal GetPixelPos();
|
||||||
|
void SetColor(QColor color){mColor = color;}
|
||||||
|
quint64 GetTime();
|
||||||
|
void SetTime(quint64 time);
|
||||||
|
bool IsCursorSet();
|
||||||
|
void ClearCursor();
|
||||||
|
void SetCursor();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QLine mLine;
|
||||||
|
QColor mColor;
|
||||||
|
quint64 mCursorTime;
|
||||||
|
bool mCursorSet;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CHorizontalGraphCursorWidget : public QGraphicsWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CHorizontalGraphCursorWidget(qreal Width, QGraphicsItem *Parent = 0);
|
||||||
|
|
||||||
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
qreal GetPixelPos();
|
||||||
|
void SetColor(QColor color){mColor = color;}
|
||||||
|
bool IsCursorSet();
|
||||||
|
void ClearCursor();
|
||||||
|
void SetCursor();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QLine mLine;
|
||||||
|
QColor mColor;
|
||||||
|
quint64 mCursorPos;
|
||||||
|
bool mCursorSet;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GRAPHCURSORWIDGET_H
|
||||||
254
sources/GuiElements/GraphItem.cpp
Normal file
@ -0,0 +1,254 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2013 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Classe d'affichage d'un graphique discret (sondes magnétiques, pédales, etc.)La
|
||||||
|
fonction SetData permet d'associer la liste des transitions. La
|
||||||
|
fonction DisplayData() permet de fixer le timespan à afficher. La fonction détermine
|
||||||
|
quels points sont dans le span et crée une liste de lignes qui sont ensuite affichés
|
||||||
|
dans la fonction de rappel paint().
|
||||||
|
|
||||||
|
Utilisée dans la page de visualisation des passages de train.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131024 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "GraphItem.h"
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QGraphicsSceneMouseEvent>
|
||||||
|
#include <QStyleOptionGraphicsItem>
|
||||||
|
|
||||||
|
CGraphItem::CGraphItem(QGraphicsItem *Parent)
|
||||||
|
{
|
||||||
|
setParentItem(Parent);
|
||||||
|
mDataSet = 0;
|
||||||
|
mStartTime = mStopTime = 0;
|
||||||
|
mDataValid = false;
|
||||||
|
mLabel = new QGraphicsTextItem(this);
|
||||||
|
mGraphPixmap = new QPixmap(boundingRect().width(),boundingRect().height());
|
||||||
|
}
|
||||||
|
|
||||||
|
CGraphItem::~CGraphItem()
|
||||||
|
{
|
||||||
|
delete mGraphPixmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGraphItem::SetData(QList<CGraphDiscreteDataPair*> *DataList)
|
||||||
|
{
|
||||||
|
|
||||||
|
mDataSet = DataList;
|
||||||
|
//Build the lines list
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CGraphItem::DisplayData(quint64 StartTime, quint64 StopTime)
|
||||||
|
{
|
||||||
|
if(mDataSet == 0)
|
||||||
|
return RET_OK;
|
||||||
|
|
||||||
|
quint64 MinTime = mDataSet->first()->mTime;
|
||||||
|
quint64 MaxTime = mDataSet->last()->mTime;
|
||||||
|
|
||||||
|
if(StartTime >= StopTime)
|
||||||
|
return RET_ERROR;
|
||||||
|
if(StartTime < MinTime)
|
||||||
|
return RET_ERROR;
|
||||||
|
if(StopTime > MaxTime)
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
mStartTime = StartTime;
|
||||||
|
mStopTime = StopTime;
|
||||||
|
quint64 TimeSpan = StopTime - StartTime;
|
||||||
|
|
||||||
|
//Find the index of the first and last point in the timespan.
|
||||||
|
int StartIndex = 0, StopIndex = 0;
|
||||||
|
quint64 StartDeltaTime, StopDeltaTime;
|
||||||
|
int i = 0;
|
||||||
|
bool StartFound = false, StopFound = false;
|
||||||
|
while(StartFound == false || StopFound == false)
|
||||||
|
{
|
||||||
|
if(i >= mDataSet->size())
|
||||||
|
{
|
||||||
|
qDebug("GraphItem::Array overflow while searching for time index");
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
quint64 CurTime = mDataSet->at(i)->mTime;
|
||||||
|
if(CurTime <= StartTime)
|
||||||
|
{
|
||||||
|
StartIndex = i;
|
||||||
|
StartDeltaTime = CurTime - StartTime;
|
||||||
|
StartFound = true;
|
||||||
|
}
|
||||||
|
if(CurTime >= StopTime && !StopFound)
|
||||||
|
{
|
||||||
|
StopIndex = i;
|
||||||
|
StopDeltaTime = StopTime - mDataSet->at(StopIndex)->mTime;
|
||||||
|
StopFound = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Build the lines list
|
||||||
|
mLinesList.clear();
|
||||||
|
qreal Width = boundingRect().width();
|
||||||
|
qreal Height = boundingRect().height()-2;
|
||||||
|
qreal tick = (Width)/TimeSpan; //pixels per microsec
|
||||||
|
|
||||||
|
qreal X1,X2,Y1,Y2;
|
||||||
|
|
||||||
|
//Add all the lines to create the graph. When there is a transition
|
||||||
|
//the horizontal line must be continued to the next point and a vertical
|
||||||
|
//line must be drawn.
|
||||||
|
for(int i = StartIndex; i < StopIndex; i++)
|
||||||
|
{
|
||||||
|
QLine NewLine;
|
||||||
|
if(mDataSet->at(i)->mTime < StartTime)
|
||||||
|
X1 = 0;
|
||||||
|
else
|
||||||
|
X1 = (qreal)(mDataSet->at(i)->mTime - StartTime);
|
||||||
|
|
||||||
|
Y1 = mDataSet->at(i)->mValue;
|
||||||
|
|
||||||
|
if(mDataSet->at(i+1)->mTime > StopTime)
|
||||||
|
{
|
||||||
|
X2 = StopTime - StartTime;
|
||||||
|
Y2 = mDataSet->at(i)->mValue; //Do not draw the vertical line if the point outside the span is not the same value.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
X2 = mDataSet->at(i+1)->mTime - StartTime;
|
||||||
|
Y2 = mDataSet->at(i+1)->mValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Reverse the Y axis
|
||||||
|
if(Y1 == 0)
|
||||||
|
Y1 = 1;
|
||||||
|
else
|
||||||
|
Y1 = 0;
|
||||||
|
if(Y2 == 0)
|
||||||
|
Y2 = 1;
|
||||||
|
else
|
||||||
|
Y2 = 0;
|
||||||
|
|
||||||
|
|
||||||
|
if(Y1 == Y2) //no transition
|
||||||
|
{
|
||||||
|
NewLine.setLine(X1*tick,Y1*Height+1,X2*tick,Y2*Height+1);
|
||||||
|
mLinesList.append(NewLine);
|
||||||
|
}
|
||||||
|
else //value transition...
|
||||||
|
{
|
||||||
|
NewLine.setLine(X1*tick,Y1*Height+1,X2*tick,Y1*Height+1); //horizontal line
|
||||||
|
mLinesList.append(NewLine);
|
||||||
|
NewLine.setLine(X2*tick,Y1*Height+1,X2*tick,Y2*Height+1); //vertical line
|
||||||
|
mLinesList.append(NewLine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mDataValid = true;
|
||||||
|
|
||||||
|
//#ifndef WINDOWS_OS
|
||||||
|
mGraphPixmap->fill(QColor(245, 245, 255));
|
||||||
|
QPainter *painter = new QPainter(mGraphPixmap);
|
||||||
|
painter->drawLines(mLinesList);
|
||||||
|
delete painter;
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
update();
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
{
|
||||||
|
Q_UNUSED(option)
|
||||||
|
Q_UNUSED(widget)
|
||||||
|
|
||||||
|
// static int toto = 0;
|
||||||
|
// qDebug("CGraphItem::paint %d",toto++);
|
||||||
|
|
||||||
|
if(mDataValid == false)
|
||||||
|
return ;
|
||||||
|
if(mDataSet == 0)
|
||||||
|
return;
|
||||||
|
if(mDataSet->size() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// painter->setClipRect(option->exposedRect);
|
||||||
|
|
||||||
|
// QPen pen;
|
||||||
|
// pen.setWidth(1);
|
||||||
|
|
||||||
|
// pen.setColor(Qt::red);
|
||||||
|
// painter->setPen(pen);
|
||||||
|
// painter->drawRect(boundingRect());
|
||||||
|
|
||||||
|
// pen.setColor(Qt::black);
|
||||||
|
// painter->setPen(pen);
|
||||||
|
|
||||||
|
//#ifdef WINDOWS_OS
|
||||||
|
// painter->drawLines(mLinesList);
|
||||||
|
//#else
|
||||||
|
painter->drawPixmap(0,0,*mGraphPixmap);
|
||||||
|
//#endif
|
||||||
|
// for(int i = 0; i < mLinesList.size(); i++)
|
||||||
|
// {
|
||||||
|
// painter->drawEllipse(mLinesList.at(i).p1(),2,2);
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGraphItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CGraphItem::mouseReleaseEvent( QGraphicsSceneMouseEvent * event)
|
||||||
|
{
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGraphItem::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
//mBackgroundRect->setRect(boundingRect());
|
||||||
|
delete mGraphPixmap;
|
||||||
|
mGraphPixmap = new QPixmap(boundingRect().width(),boundingRect().height());
|
||||||
|
DisplayData(mStartTime,mStopTime);
|
||||||
|
}
|
||||||
|
void CGraphItem::SetLabel(QString label,int Offset)
|
||||||
|
{
|
||||||
|
QFont font;
|
||||||
|
font.setBold(true);
|
||||||
|
mLabel->setFont(font);
|
||||||
|
mLabel->setPlainText(label);
|
||||||
|
mLabel->setPos(-Offset,boundingRect().height()/2 - mLabel->boundingRect().height()/2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CGraphDiscreteDataPair::CGraphDiscreteDataPair(quint32 Value, quint64 Time):
|
||||||
|
mValue(Value),
|
||||||
|
mTime(Time)
|
||||||
|
{
|
||||||
|
}
|
||||||
56
sources/GuiElements/GraphItem.h
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#ifndef CGRAPHITEM_H
|
||||||
|
#define CGRAPHITEM_H
|
||||||
|
|
||||||
|
#include <GlobalDefine.h>
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
#include <QRect>
|
||||||
|
#include <QTimeLine>
|
||||||
|
#include <QList>
|
||||||
|
#include <QPainterPath>
|
||||||
|
|
||||||
|
class CGraphDiscreteDataPair
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CGraphDiscreteDataPair(quint32 Value, quint64 Time);
|
||||||
|
quint32 mValue;
|
||||||
|
quint64 mTime;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CGraphItem : public QGraphicsWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CGraphItem(QGraphicsItem *Parent = 0);
|
||||||
|
~CGraphItem();
|
||||||
|
|
||||||
|
QList<CGraphDiscreteDataPair*> *mDataSet;
|
||||||
|
QGraphicsRectItem *mBackgroundRect;
|
||||||
|
|
||||||
|
// unsigned int DisplayData(quint32 StartIndex, quint32 StopIndex);
|
||||||
|
unsigned int DisplayData(quint64 StartTime, quint64 StopTime);
|
||||||
|
void SetData(QList<CGraphDiscreteDataPair*> *DataList);
|
||||||
|
// void UpdateDisplay(void);
|
||||||
|
void SetLabel(QString label,int Offset);
|
||||||
|
|
||||||
|
virtual void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
|
||||||
|
virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
|
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event);
|
||||||
|
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
//quint64 mTimeSpan;
|
||||||
|
//quint64 mOffset;
|
||||||
|
bool mDataValid;
|
||||||
|
//quint32 mStartIndex,mStopIndex;
|
||||||
|
quint64 mStartTime, mStopTime;
|
||||||
|
QVector<QLine> mLinesList;
|
||||||
|
QGraphicsTextItem *mLabel;
|
||||||
|
|
||||||
|
QPixmap *mGraphPixmap;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CGRAPHITEM_H
|
||||||
228
sources/GuiElements/GraphRulerWidget.cpp
Normal file
@ -0,0 +1,228 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2013 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Élément graphique qui affiche une règle de graduation temporelle dans le bas
|
||||||
|
de la zone d'affichage.
|
||||||
|
|
||||||
|
Utilisée dans la page de visualisation des passages de train.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131024 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#include "GraphRulerWidget.h"
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QTextStream>
|
||||||
|
#include <QStyleOptionGraphicsItem>
|
||||||
|
|
||||||
|
CGraphRulerWidget::CGraphRulerWidget(qreal RulerPixelWidth, QGraphicsItem *Parent)
|
||||||
|
{
|
||||||
|
setParentItem(Parent);
|
||||||
|
mPixelWidth = RulerPixelWidth;
|
||||||
|
mPixelPitch = RulerPixelWidth/RULER_NB_TICKS;
|
||||||
|
|
||||||
|
mRulerPixmap = new QPixmap(RulerPixelWidth,boundingRect().height()+1);
|
||||||
|
|
||||||
|
mValidRange = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGraphRulerWidget::~CGraphRulerWidget()
|
||||||
|
{
|
||||||
|
delete mRulerPixmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGraphRulerWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
{
|
||||||
|
Q_UNUSED(option)
|
||||||
|
Q_UNUSED(widget)
|
||||||
|
|
||||||
|
if(mValidRange == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
painter->setClipRect(option->exposedRect);
|
||||||
|
painter->drawPixmap(0,0,*mRulerPixmap);
|
||||||
|
|
||||||
|
// static int toto = 0;
|
||||||
|
// qDebug("CGraphRulerWidget::paint %d",toto++);
|
||||||
|
|
||||||
|
// qreal x = 0;
|
||||||
|
// QRectF TextRect(0,0,100,10);
|
||||||
|
// QString TimeText;
|
||||||
|
// qreal tick = (mEndTime - mStartTime)/mPixelWidth;
|
||||||
|
// QFont font;
|
||||||
|
// font.setPixelSize(12);
|
||||||
|
// painter->setFont(font);
|
||||||
|
// for(int i = 0; i <= RULER_NB_TICKS; i++)
|
||||||
|
// {
|
||||||
|
// QLine line;
|
||||||
|
// if(i%20 == 0)
|
||||||
|
// {
|
||||||
|
// TimeText.clear();
|
||||||
|
// line.setLine(x,0,x,10); //long line
|
||||||
|
// TextRect.moveCenter(QPoint(x,15));
|
||||||
|
// qreal time = (x*tick) + mStartTime;
|
||||||
|
|
||||||
|
// if(time < 1000)
|
||||||
|
// {
|
||||||
|
// QTextStream(&TimeText) << time << " ns";
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// time /= 1000;
|
||||||
|
// if(time < 1000)
|
||||||
|
// {
|
||||||
|
// QTextStream(&TimeText) << time << " us";
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// time /= 1000;
|
||||||
|
// if(time < 1000)
|
||||||
|
// {
|
||||||
|
// QTextStream(&TimeText) << time << " ms";
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// time /= 1000;
|
||||||
|
// if(time < 1000)
|
||||||
|
// {
|
||||||
|
// QTextStream(&TimeText) << time << " s";
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// painter->drawText(TextRect,Qt::AlignCenter,TimeText);
|
||||||
|
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// line.setLine(x,0,x,5);
|
||||||
|
// }
|
||||||
|
// painter->drawLine(line);
|
||||||
|
// x += mPixelPitch;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CGraphRulerWidget::SetRange(quint64 StartTime, quint64 EndTime)
|
||||||
|
{
|
||||||
|
if(StartTime > EndTime)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
mStartTime = StartTime;
|
||||||
|
mEndTime = EndTime;
|
||||||
|
mValidRange = true;
|
||||||
|
|
||||||
|
Render();
|
||||||
|
|
||||||
|
update();
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGraphRulerWidget::Render()
|
||||||
|
{
|
||||||
|
qreal x = 0;
|
||||||
|
QRectF TextRect(0,0,100,10);
|
||||||
|
QString TimeText;
|
||||||
|
qreal tick = (mEndTime - mStartTime)/mPixelWidth;
|
||||||
|
QFont font;
|
||||||
|
|
||||||
|
mRulerPixmap->fill(Qt::white);
|
||||||
|
QPainter *painter = new QPainter(mRulerPixmap);
|
||||||
|
|
||||||
|
font.setPixelSize(12);
|
||||||
|
painter->setFont(font);
|
||||||
|
for(int i = 0; i <= RULER_NB_TICKS; i++)
|
||||||
|
{
|
||||||
|
QLine line;
|
||||||
|
if(i%20 == 0)
|
||||||
|
{
|
||||||
|
TimeText.clear();
|
||||||
|
line.setLine(x,0,x,10); //long line
|
||||||
|
|
||||||
|
TextRect.moveCenter(QPoint(x,15));
|
||||||
|
if(i == 0)
|
||||||
|
TextRect.moveLeft(x);
|
||||||
|
else if(i == RULER_NB_TICKS)
|
||||||
|
TextRect.moveRight(x);
|
||||||
|
|
||||||
|
|
||||||
|
qreal time = (x*tick) + mStartTime;
|
||||||
|
|
||||||
|
if(time < 1000)
|
||||||
|
{
|
||||||
|
QTextStream(&TimeText) << time << " ns";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
time /= 1000;
|
||||||
|
if(time < 1000)
|
||||||
|
{
|
||||||
|
QTextStream(&TimeText) << time << " us";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
time /= 1000;
|
||||||
|
if(time < 1000)
|
||||||
|
{
|
||||||
|
QTextStream(&TimeText) << time << " ms";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
time /= 1000;
|
||||||
|
if(time < 1000)
|
||||||
|
{
|
||||||
|
QTextStream(&TimeText) << time << " s";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(i == 0)
|
||||||
|
painter->drawText(TextRect,Qt::AlignLeft | Qt::AlignVCenter,TimeText);
|
||||||
|
else if(i == RULER_NB_TICKS)
|
||||||
|
painter->drawText(TextRect,Qt::AlignRight | Qt::AlignVCenter,TimeText);
|
||||||
|
else
|
||||||
|
painter->drawText(TextRect,Qt::AlignCenter,TimeText);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
line.setLine(x,0,x,5);
|
||||||
|
}
|
||||||
|
painter->drawLine(line);
|
||||||
|
x += mPixelPitch;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete painter;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGraphRulerWidget::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
|
||||||
|
delete mRulerPixmap;
|
||||||
|
mRulerPixmap = new QPixmap(mPixelWidth,boundingRect().height()+1);
|
||||||
|
}
|
||||||
60
sources/GuiElements/GraphRulerWidget.h
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 - 2013 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Description du fichier si nécessaire.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131030 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef GRAPHRULERWIDGET_H
|
||||||
|
#define GRAPHRULERWIDGET_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
|
||||||
|
#define RULER_NB_TICKS 200
|
||||||
|
|
||||||
|
class CGraphRulerWidget : public QGraphicsWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CGraphRulerWidget(qreal RulerPixelWidth,QGraphicsItem *Parent = 0);
|
||||||
|
~CGraphRulerWidget();
|
||||||
|
|
||||||
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
|
||||||
|
unsigned int SetRange(quint64 StartTime, quint64 EndTime);
|
||||||
|
|
||||||
|
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
qreal mPixelWidth;
|
||||||
|
quint64 mStartTime, mEndTime;
|
||||||
|
qreal mPixelPitch;
|
||||||
|
bool mValidRange;
|
||||||
|
|
||||||
|
QPixmap *mRulerPixmap;
|
||||||
|
|
||||||
|
void Render();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GRAPHRULERWIDGET_H
|
||||||
42
sources/GuiElements/GuiPage.cpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Classe de base d'une page de l'interface graphique (GUI = Graphics User Interface).
|
||||||
|
Une page contient les éléments graphiques affichés à l'écran.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20121220 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#include "Guipage.h"
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
|
||||||
|
|
||||||
|
CGuiPage::CGuiPage()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGuiPage::ShowPage()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
52
sources/GuiElements/Guipage.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Description du fichier si nécessaire.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 201212120 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GUIPAGE_H
|
||||||
|
#define GUIPAGE_H
|
||||||
|
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
#include <QTimeLine>
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
|
||||||
|
class CGuiPage : public QGraphicsWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
CGuiPage();
|
||||||
|
|
||||||
|
virtual void ShowPage();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GUIPAGE_H
|
||||||
1229
sources/GuiElements/LogViewPage.cpp
Normal file
205
sources/GuiElements/LogViewPage.h
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Description du fichier si nécessaire.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131024 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef LOGVIEWPAGE_H
|
||||||
|
#define LOGVIEWPAGE_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
#include "Guipage.h"
|
||||||
|
#include <QString>
|
||||||
|
#include "PushButton.h"
|
||||||
|
#include "TextButtonWidget.h"
|
||||||
|
#include "LogMgr.h"
|
||||||
|
#include <QTableWidget>
|
||||||
|
#include "GraphItem.h"
|
||||||
|
//#include "qcustomplot.h"
|
||||||
|
#include "GraphCursorWidget.h"
|
||||||
|
#include "GraphRulerWidget.h"
|
||||||
|
#include "AnalogGraphItem.h"
|
||||||
|
#include "RankRulerWidget.h"
|
||||||
|
#include "EventsRulerWidget.h"
|
||||||
|
#include "QElapsedTimer"
|
||||||
|
|
||||||
|
#define GRAPH_ZONE_WIDTH 880//900
|
||||||
|
#define GRAPH_ZONE_HEIGHT 650//700
|
||||||
|
#define GRAPH_ZONE_X_OFFSET 70 //50
|
||||||
|
#define MIN_TIMESPAN 1000 //1 millisecond
|
||||||
|
|
||||||
|
#define ZOOM_TICK 10
|
||||||
|
#define SCROLL_TICK 1
|
||||||
|
#define ZOOM_CENTERED_ON_CURSOR
|
||||||
|
|
||||||
|
class COutilZT;
|
||||||
|
|
||||||
|
enum eZT1DiscreetPlottableParamID
|
||||||
|
{
|
||||||
|
ZT1_DISCREET_PLOTTABLE_S1_PARAM,
|
||||||
|
ZT1_DISCREET_PLOTTABLE_S2_PARAM,
|
||||||
|
ZT1_DISCREET_PLOTTABLE_PPINT_PARAM,
|
||||||
|
ZT1_DISCREET_PLOTTABLE_PPEXT_PARAM,
|
||||||
|
ZT1_DISCREET_PLOTTABLE_PG_PARAM,
|
||||||
|
ZT1_DISCREET_PLOTTABLE_FN_PARAM,
|
||||||
|
ZT1_DISCREET_PLOTTABLE_CI_PARAM,
|
||||||
|
ZT1_DISCREET_PLOTTABLE_ZT1_CDV_PARAM,
|
||||||
|
|
||||||
|
ZT1_DISCREET_PLOTTABLE_NB_PARAM
|
||||||
|
};
|
||||||
|
|
||||||
|
enum eZT1AnalogPlottableParamID
|
||||||
|
{
|
||||||
|
ZT1_ANALOG_PLOTTABLE_PGINT_PARAM,
|
||||||
|
ZT1_ANALOG_PLOTTABLE_PGEXT_PARAM,
|
||||||
|
ZT1_ANALOG_PLOTTABLE_PGCOMBINED_PARAM,
|
||||||
|
ZT1_ANALOG_PLOTTABLE_TRAIN_SPEED_PARAM,
|
||||||
|
ZT1_ANALOG_PLOTTABLE_SDF_DATA_PARAM,
|
||||||
|
|
||||||
|
|
||||||
|
ZT1_ANALOG_PLOTTABLE_NB_PARAM
|
||||||
|
};
|
||||||
|
|
||||||
|
enum eZT2DiscreetPlottableParamID
|
||||||
|
{
|
||||||
|
ZT2_DISCREET_PLOTTABLE_S1_PARAM,
|
||||||
|
ZT2_DISCREET_PLOTTABLE_PPEXT_PARAM,
|
||||||
|
ZT2_DISCREET_PLOTTABLE_PPINT_PARAM,
|
||||||
|
ZT2_DISCREET_PLOTTABLE_CI_PARAM,
|
||||||
|
ZT2_DISCREET_PLOTTABLE_APPROACH_CDV_PARAM,
|
||||||
|
ZT2_DISCREET_PLOTTABLE_CDV_PARAM,
|
||||||
|
|
||||||
|
ZT2_DISCREET_PLOTTABLE_NB_PARAM
|
||||||
|
};
|
||||||
|
|
||||||
|
enum eZT2AnalogPlottableParamID
|
||||||
|
{
|
||||||
|
ZT2_ANALOG_PLOTTABLE_NB_PARAM
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CDiscreetPlottableItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
unsigned int mParamID;
|
||||||
|
QList<CGraphDiscreteDataPair*> *mDataSet;
|
||||||
|
CGraphItem *mPlotGaph;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CAnalogPlottableItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
unsigned int mParamID;
|
||||||
|
QList<CGraphAnalogDataPair*> *mDataSet;
|
||||||
|
CAnalogGraphItem *mPlotGaph;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class CLogViewPage : public CGuiPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CLogViewPage(QGraphicsWidget *Parent = 0);
|
||||||
|
~CLogViewPage();
|
||||||
|
|
||||||
|
COutilZT *mProgramHandle;
|
||||||
|
CLogElement *mLogElement;
|
||||||
|
CDiscreetPlottableItem mZT1DiscreetPlots[ZT1_DISCREET_PLOTTABLE_NB_PARAM];
|
||||||
|
CAnalogPlottableItem mZT1AnalogPlots[ZT1_ANALOG_PLOTTABLE_NB_PARAM];
|
||||||
|
CDiscreetPlottableItem mZT2DiscreetPlots[ZT2_DISCREET_PLOTTABLE_NB_PARAM];
|
||||||
|
|
||||||
|
void SetLogData(CLogElement *element);
|
||||||
|
void DestroyData();
|
||||||
|
void EnableCloseButton();
|
||||||
|
void DisableCloseButton();
|
||||||
|
|
||||||
|
|
||||||
|
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||||
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
|
||||||
|
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
|
||||||
|
// virtual void keyReleaseEvent(QKeyEvent *event);
|
||||||
|
virtual bool eventFilter(QObject *obj, QEvent *event);
|
||||||
|
|
||||||
|
// QCustomPlot mPlotWidget;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
QGraphicsRectItem *mBackgroundRect;
|
||||||
|
CTextButtonWidget *mCancelButton;
|
||||||
|
CTextButtonWidget *mCursorsZoomButton, *mZoomInButton, *mZoomOutButton, *mZoomResetButton;
|
||||||
|
int mZoomValue;
|
||||||
|
quint64 mStartTime, mStopTime;
|
||||||
|
quint64 mCurTimeSpan;
|
||||||
|
quint64 mTotalTimeSpan;
|
||||||
|
quint64 mMinTime, mMaxTime;
|
||||||
|
qreal mCurPixelTickValue;
|
||||||
|
qint32 mPGTreshold;
|
||||||
|
CVerticalGraphCursorWidget *mStaticCursor1, *mStaticCursor2, *mVCursor;
|
||||||
|
CHorizontalGraphCursorWidget *mHCursor;
|
||||||
|
QGraphicsTextItem *mCursorPosTxt;
|
||||||
|
QGraphicsTextItem *mStaticCursorDeltaTimeTxt, *mCursor1TimeTxt, *mCursor2TimeTxt;
|
||||||
|
QGraphicsTextItem *mPassageStats1Txt,*mPassageStats2Txt;
|
||||||
|
QString mPassageDateTime, mPassageStation;
|
||||||
|
|
||||||
|
CGraphRulerWidget *mRuler;
|
||||||
|
CRankRulerWidget *mRankRuler;
|
||||||
|
CEventRulerWidget *mEventRuler;
|
||||||
|
unsigned int mViewType;
|
||||||
|
|
||||||
|
int mStaticCursor1Pos, mStaticCursor2Pos;
|
||||||
|
int mCursorPos;
|
||||||
|
|
||||||
|
bool mMouseDragging;
|
||||||
|
bool mMouseMoved;
|
||||||
|
|
||||||
|
QElapsedTimer mScrollAnimationTimer;
|
||||||
|
qreal mLastMousePos;
|
||||||
|
|
||||||
|
void SetZoom(int ZoomValue);
|
||||||
|
void ZoomIn(bool CenterOnCursor = true);
|
||||||
|
void ZoomOut(bool CenterOnCursor = true);
|
||||||
|
void ScrollGraphs(qint64 Delta);
|
||||||
|
quint64 GetTimeForPixel(qreal PixelPos);
|
||||||
|
qreal GetPixelForTime(quint64 Time);
|
||||||
|
unsigned int ShowSpan(qreal PixelPos1, qreal PixelPos2);
|
||||||
|
unsigned int ShowSpan(quint64 TimePos1, quint64 TimePos2);
|
||||||
|
unsigned int AdjustStaticCursorsPos();
|
||||||
|
unsigned int AdjustMouseCursorPos(qreal PosX, qreal PosY);
|
||||||
|
unsigned int UpdateStaticCursorsDeltaTime();
|
||||||
|
void ShowPlots(unsigned int ViewType);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void ButtonClicked(CTextButtonWidget *);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOGVIEWPAGE_H
|
||||||
802
sources/GuiElements/LogsListPage.cpp
Normal file
@ -0,0 +1,802 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Page affichant la liste des passages de train.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131021 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#include "LogsListPage.h"
|
||||||
|
#include <QGraphicsProxyWidget>
|
||||||
|
#include "OutilZT.h"
|
||||||
|
#include "TrainLogFileMgr.h"
|
||||||
|
#include <QString>
|
||||||
|
#include <QTextCodec>
|
||||||
|
#include <QTextStream>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CLogsListPage::~CLogsListPage()
|
||||||
|
{
|
||||||
|
// delete mListParsingTimer;
|
||||||
|
}
|
||||||
|
|
||||||
|
CLogsListPage::CLogsListPage(QGraphicsWidget *Parent)
|
||||||
|
{
|
||||||
|
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
|
||||||
|
setParentItem(Parent);
|
||||||
|
mProgramHandle = 0;
|
||||||
|
mStationFilter.clear();
|
||||||
|
|
||||||
|
mLogsTable = new QTableWidget(0,4);
|
||||||
|
QGraphicsProxyWidget *TableProxy = new QGraphicsProxyWidget(this);
|
||||||
|
TableProxy->setWidget(mLogsTable);
|
||||||
|
TableProxy->setPos(3,20);
|
||||||
|
TableProxy->resize(380,350);
|
||||||
|
mLogsTable->resize(380,350);
|
||||||
|
mLogsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
|
mLogsTable->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
|
mLogsTable->clearContents();
|
||||||
|
mLogsTable->setRowCount(0);
|
||||||
|
mLogsTable->setHorizontalHeaderLabels(QStringList() << "Date du passage" << "Station" << "Décl." << "Type");
|
||||||
|
// connect(mLogsTable,SIGNAL(cellClicked(int,int)),this,SLOT(LogsTableCellClicked(int,int)));
|
||||||
|
connect(mLogsTable,SIGNAL(currentCellChanged(int,int,int,int)),this,SLOT(LogsTableCellSelected(int,int,int,int)));
|
||||||
|
connect(mLogsTable,SIGNAL(cellDoubleClicked(int,int)),SLOT(TableDoubleClicked(int,int)));
|
||||||
|
|
||||||
|
mSummaryText = new QGraphicsTextItem(this);
|
||||||
|
QFont textfont;
|
||||||
|
textfont.setPointSize(12);
|
||||||
|
mSummaryText->setFont(textfont);
|
||||||
|
mSummaryText->setPlainText("Passage:");
|
||||||
|
mSummaryText->setPos(3,370);
|
||||||
|
|
||||||
|
QGraphicsProxyWidget *WidgetProxy = new QGraphicsProxyWidget(this);
|
||||||
|
mShowZT1ItemsChkBx = new QCheckBox("ZT1");
|
||||||
|
WidgetProxy->setWidget(mShowZT1ItemsChkBx);
|
||||||
|
WidgetProxy->setPos(190,450);
|
||||||
|
mShowZT1ItemsChkBx->setChecked(true);
|
||||||
|
connect(mShowZT1ItemsChkBx,SIGNAL(stateChanged(int)),this,SLOT(CheckBoxClicked(int)));
|
||||||
|
|
||||||
|
WidgetProxy = new QGraphicsProxyWidget(this);
|
||||||
|
mShowZT2ItemsChkBx = new QCheckBox("ZT2");
|
||||||
|
WidgetProxy->setWidget(mShowZT2ItemsChkBx);
|
||||||
|
//WidgetProxy->setPos(410,550);
|
||||||
|
WidgetProxy->setPos(250,450);
|
||||||
|
mShowZT2ItemsChkBx->setChecked(true);
|
||||||
|
connect(mShowZT2ItemsChkBx,SIGNAL(stateChanged(int)),this,SLOT(CheckBoxClicked(int)));
|
||||||
|
|
||||||
|
WidgetProxy = new QGraphicsProxyWidget(this);
|
||||||
|
mShowNoDetectionsChkBx = new QCheckBox("Sans décl.");
|
||||||
|
WidgetProxy->setWidget(mShowNoDetectionsChkBx);
|
||||||
|
WidgetProxy->setPos(300,450);
|
||||||
|
mShowNoDetectionsChkBx->setChecked(true);
|
||||||
|
connect(mShowNoDetectionsChkBx,SIGNAL(stateChanged(int)),this,SLOT(CheckBoxClicked(int)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int x = 190, y = 480;
|
||||||
|
int xSpacing = 100, ySpacing = 30;
|
||||||
|
|
||||||
|
WidgetProxy = new QGraphicsProxyWidget(this);
|
||||||
|
mShowFNChkBx = new QCheckBox("Frotteur");
|
||||||
|
WidgetProxy->setWidget(mShowFNChkBx);
|
||||||
|
WidgetProxy->setPos(x,y+ySpacing);
|
||||||
|
mShowFNChkBx->setChecked(true);
|
||||||
|
connect(mShowFNChkBx,SIGNAL(stateChanged(int)),this,SLOT(CheckBoxClicked(int)));
|
||||||
|
|
||||||
|
WidgetProxy = new QGraphicsProxyWidget(this);
|
||||||
|
mShowCountChkBx = new QCheckBox("Comptage");
|
||||||
|
WidgetProxy->setWidget(mShowCountChkBx);
|
||||||
|
WidgetProxy->setPos(x+xSpacing,y+ySpacing);
|
||||||
|
mShowCountChkBx->setChecked(true);
|
||||||
|
connect(mShowCountChkBx,SIGNAL(stateChanged(int)),this,SLOT(CheckBoxClicked(int)));
|
||||||
|
|
||||||
|
WidgetProxy = new QGraphicsProxyWidget(this);
|
||||||
|
mShowPGChkBx = new QCheckBox("P. Guidage");
|
||||||
|
WidgetProxy->setWidget(mShowPGChkBx);
|
||||||
|
WidgetProxy->setPos(x+(xSpacing),y+(ySpacing*2));
|
||||||
|
mShowPGChkBx->setChecked(true);
|
||||||
|
connect(mShowPGChkBx,SIGNAL(stateChanged(int)),this,SLOT(CheckBoxClicked(int)));
|
||||||
|
|
||||||
|
WidgetProxy = new QGraphicsProxyWidget(this);
|
||||||
|
mShowPPChkBx = new QCheckBox("P. Porteur");
|
||||||
|
WidgetProxy->setWidget(mShowPPChkBx);
|
||||||
|
WidgetProxy->setPos(x,y+(ySpacing*2));
|
||||||
|
mShowPPChkBx->setChecked(true);
|
||||||
|
connect(mShowPPChkBx,SIGNAL(stateChanged(int)),this,SLOT(CheckBoxClicked(int)));
|
||||||
|
|
||||||
|
WidgetProxy = new QGraphicsProxyWidget(this);
|
||||||
|
mShowMPM10ChkBx = new QCheckBox("MPM10");
|
||||||
|
WidgetProxy->setWidget(mShowMPM10ChkBx);
|
||||||
|
WidgetProxy->setPos(x,y);
|
||||||
|
mShowMPM10ChkBx->setChecked(true);
|
||||||
|
connect(mShowMPM10ChkBx,SIGNAL(stateChanged(int)),this,SLOT(CheckBoxClicked(int)));
|
||||||
|
|
||||||
|
WidgetProxy = new QGraphicsProxyWidget(this);
|
||||||
|
mShowMRChkBx = new QCheckBox("MR63/73");
|
||||||
|
WidgetProxy->setWidget(mShowMRChkBx);
|
||||||
|
WidgetProxy->setPos(x+(xSpacing),y);
|
||||||
|
mShowMRChkBx->setChecked(true);
|
||||||
|
connect(mShowMRChkBx,SIGNAL(stateChanged(int)),this,SLOT(CheckBoxClicked(int)));
|
||||||
|
|
||||||
|
WidgetProxy = new QGraphicsProxyWidget(this);
|
||||||
|
mShowProblematicTrainsChkbx = new QCheckBox("Passage Problématique");
|
||||||
|
WidgetProxy->setWidget(mShowProblematicTrainsChkbx);
|
||||||
|
WidgetProxy->setPos(x,y+(ySpacing*3));
|
||||||
|
mShowProblematicTrainsChkbx->setChecked(true);
|
||||||
|
connect(mShowProblematicTrainsChkbx,SIGNAL(stateChanged(int)),this,SLOT(CheckBoxClicked(int)));
|
||||||
|
|
||||||
|
|
||||||
|
QGraphicsTextItem *Label = new QGraphicsTextItem(this);
|
||||||
|
Label->setPlainText("Station:");
|
||||||
|
Label->setPos(190,418);
|
||||||
|
|
||||||
|
WidgetProxy = new QGraphicsProxyWidget(this);
|
||||||
|
mProtectLogChkBx = new QCheckBox("Passage protégé");
|
||||||
|
WidgetProxy->setWidget(mProtectLogChkBx);
|
||||||
|
WidgetProxy->setPos(190,390);
|
||||||
|
mProtectLogChkBx->setChecked(false);
|
||||||
|
connect(mProtectLogChkBx,SIGNAL(clicked()),this,SLOT(ProtectLogCheckBoxClicked()));
|
||||||
|
mProtectLogChkBx->setEnabled(false);
|
||||||
|
|
||||||
|
WidgetProxy = new QGraphicsProxyWidget(this);
|
||||||
|
mStationsFilterComboBox = new QComboBox();
|
||||||
|
WidgetProxy->setWidget(mStationsFilterComboBox);
|
||||||
|
WidgetProxy->setPos(250,420);
|
||||||
|
mStationsFilterComboBox->insertItems(0,QStringList() << "Toutes" << "Angrignon" << "Snowdon" << "Henri Bourassa" << "Honoré Beaugrand" << "Longueuil" << "Berri UQAM" << "Montmorency (10/12)" << "Montmorency (10/22)" << "Côte Vertu" << "Saint-Michel");
|
||||||
|
mStationsFilterComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||||
|
mStationsFilterComboBox->adjustSize();
|
||||||
|
mStationsFilterComboBox->setMaxVisibleItems(15);
|
||||||
|
connect(mStationsFilterComboBox,SIGNAL(activated(int)),this,SLOT(StationFilterSelected(int)));
|
||||||
|
|
||||||
|
mViewZTLogBtn = new CPushButton(this,"./Images/log.png",false,0);
|
||||||
|
mViewZTLogBtn->resize(50,50);
|
||||||
|
mViewZTLogBtn->setPos(400,25);
|
||||||
|
connect(mViewZTLogBtn,SIGNAL(clicked(CPushButton*)),this,SLOT(ViewZTLogBtnClicked(CPushButton*)));
|
||||||
|
|
||||||
|
mSaveCSVLogBtn = new CPushButton(this,"./Images/csv.png",false,0);
|
||||||
|
mSaveCSVLogBtn->resize(50,50);
|
||||||
|
mSaveCSVLogBtn->setPos(400,100);
|
||||||
|
connect(mSaveCSVLogBtn,SIGNAL(clicked(CPushButton*)),this,SLOT(SaveCSVLogBtnClicked(CPushButton*)));
|
||||||
|
|
||||||
|
mDeleteFileButton = new CPushButton(this,"./Images/file_delete.png",false,0);
|
||||||
|
mDeleteFileButton->resize(50,50);
|
||||||
|
mDeleteFileButton->setPos(400,175);
|
||||||
|
connect(mDeleteFileButton,SIGNAL(clicked(CPushButton*)),this,SLOT(DeleteSelectedLog(CPushButton*)));
|
||||||
|
|
||||||
|
|
||||||
|
mSaveCSVLogBtn->hide();
|
||||||
|
mDeleteFileButton->hide();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLogsListPage::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
// mBackgroundRect->setRect(boundingRect());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLogsListPage::ButtonClicked(CTextButtonWidget *BtnPtr)
|
||||||
|
{
|
||||||
|
if(BtnPtr == mViewLogDataButton)
|
||||||
|
{
|
||||||
|
if(mLogMgrHandle->GetLogsCount() == 0)
|
||||||
|
return;
|
||||||
|
int cursel = mLogsTable->selectedItems().at(0)->data(Qt::UserRole).toInt();
|
||||||
|
CLogElement* Element = mLogMgrHandle->GetLogsList()->at(cursel);
|
||||||
|
mProgramHandle->LogViewRequest(mLogMgrHandle->LoadLogData(Element),this);
|
||||||
|
mLogMgrHandle->FreeLogData(Element);
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(BtnPtr == mExportCSVLogButton)
|
||||||
|
{
|
||||||
|
if(mLogMgrHandle->GetLogsCount() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QString Filename;
|
||||||
|
int cursel = mLogsTable->selectedItems().at(0)->data(Qt::UserRole).toInt();
|
||||||
|
CLogElement* Element = mLogMgrHandle->GetLogsList()->at(cursel);
|
||||||
|
mLogMgrHandle->LoadLogData(Element);
|
||||||
|
if(Element->mZTLogType == ZT1_LOG_TYPE)
|
||||||
|
{
|
||||||
|
CZT1LogElement *temp = (CZT1LogElement*)Element;
|
||||||
|
Filename = temp->mLogFileName.replace("bin","csv");
|
||||||
|
CTrainLogFileMgr::instance()->SaveCSVFile(Filename,&temp->mZTLogData,&temp->mFlags,&temp->mZTDetections,temp->mStationName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CZT2LogElement *temp = (CZT2LogElement*)Element;
|
||||||
|
Filename = temp->mLogFileName.replace("bin","csv");
|
||||||
|
CTrainLogFileMgr::instance()->SaveCSVFile(Filename,&temp->mZTLogData,&temp->mZTDetections,temp->mStationName);
|
||||||
|
}
|
||||||
|
mLogMgrHandle->FreeLogData(Element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLogsListPage::EnableEngineeringMode()
|
||||||
|
{
|
||||||
|
mSaveCSVLogBtn->show();
|
||||||
|
mDeleteFileButton->show();
|
||||||
|
mProtectLogChkBx->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CLogsListPage::RefreshList()
|
||||||
|
{
|
||||||
|
ClearTable();
|
||||||
|
|
||||||
|
bool ShowZT1Items = (mShowZT1ItemsChkBx->checkState() == Qt::Checked);
|
||||||
|
bool ShowZT2Items = (mShowZT2ItemsChkBx->checkState() == Qt::Checked);
|
||||||
|
bool ShowNoDetections = (mShowNoDetectionsChkBx->checkState() == Qt::Checked);
|
||||||
|
|
||||||
|
bool ShowPPDetections = (mShowPPChkBx->checkState() == Qt::Checked);
|
||||||
|
bool ShowPGDetections = (mShowPGChkBx->checkState() == Qt::Checked);
|
||||||
|
bool ShowCountDetections = (mShowCountChkBx->checkState() == Qt::Checked);
|
||||||
|
bool ShowFNDetections = (mShowFNChkBx->checkState() == Qt::Checked);
|
||||||
|
bool ShowMRTrains = (mShowMRChkBx->checkState() == Qt::Checked);
|
||||||
|
bool ShowMPM10Trains = (mShowMPM10ChkBx->checkState() == Qt::Checked);
|
||||||
|
bool ShowProblematicTrains = (mShowProblematicTrainsChkbx->checkState() == Qt::Checked);
|
||||||
|
|
||||||
|
|
||||||
|
mLogsTable->setRowCount(mLogMgrHandle->GetLogsCount());
|
||||||
|
|
||||||
|
if(mLogMgrHandle->GetLogsCount() == 0)
|
||||||
|
return RET_OK;
|
||||||
|
|
||||||
|
int CurRow = 0;
|
||||||
|
|
||||||
|
QList<CLogElement*> *LogsList = mLogMgrHandle->GetLogsList();
|
||||||
|
for(unsigned int i = 0; i < mLogMgrHandle->GetLogsCount(); i++)
|
||||||
|
{
|
||||||
|
if(LogsList->at(i)->mZTLogType == ZT1_LOG_TYPE && ShowZT1Items == true)
|
||||||
|
{
|
||||||
|
CZT1LogElement *ZT1LogElement = (CZT1LogElement*)LogsList->at(i);
|
||||||
|
QString stationtext = mStationsFilterComboBox->currentText();
|
||||||
|
if((ZT1LogElement->mStationName == mStationsFilterComboBox->currentText() || mStationsFilterComboBox->currentText() == "Toutes") &&
|
||||||
|
((ShowMPM10Trains == true) || (ShowMPM10Trains == false && ZT1LogElement->mTrainType != TRAIN_TYPE_MPM10)) &&
|
||||||
|
((ShowMRTrains == true) || (ShowMRTrains == false && ZT1LogElement->mTrainType != TRAIN_TYPE_MR63_MR73)) &&
|
||||||
|
(ShowProblematicTrains == true || (ShowProblematicTrains == false && ZT1LogElement->mFlags.mIsProblematicPassage != 1)))
|
||||||
|
{
|
||||||
|
|
||||||
|
int NbDetections = ZT1LogElement->mZTDetections.size();
|
||||||
|
if(ShowNoDetections == true && NbDetections == 0)
|
||||||
|
{
|
||||||
|
QTableWidgetItem * NewItem = new QTableWidgetItem(ZT1LogElement->mPassageDateTime.toString("yyyy/MM/dd - hh:mm:ss"));
|
||||||
|
NewItem->setData(Qt::UserRole,QVariant(i));
|
||||||
|
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
mLogsTable->setItem(CurRow,0,NewItem);
|
||||||
|
|
||||||
|
NewItem = new QTableWidgetItem(ZT1LogElement->mStationName);
|
||||||
|
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
mLogsTable->setItem(CurRow,1,NewItem);
|
||||||
|
|
||||||
|
NewItem = new QTableWidgetItem(QString().sprintf("%d",NbDetections));
|
||||||
|
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
mLogsTable->setItem(CurRow,2,NewItem);
|
||||||
|
|
||||||
|
NewItem = new QTableWidgetItem(QString().sprintf("ZT1"));
|
||||||
|
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
mLogsTable->setItem(CurRow,3,NewItem);
|
||||||
|
|
||||||
|
CurRow++;
|
||||||
|
}
|
||||||
|
else if(ShowNoDetections == false && NbDetections == 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bool FilterItem = true;
|
||||||
|
|
||||||
|
for(int trig = 0; trig < NbDetections; trig++)
|
||||||
|
{
|
||||||
|
quint32 DetectionID = ZT1LogElement->mZTDetections.at(trig)->mDetectionID;
|
||||||
|
|
||||||
|
if((ShowCountDetections == true && DetectionID == DETECTION_MAGNETIC_SENSOR_COUNT) ||
|
||||||
|
(ShowFNDetections == true && DetectionID == DETECTION_FN_DETECTION) ||
|
||||||
|
(ShowPGDetections == true && DetectionID == DETECTION_PG_DETECTION) ||
|
||||||
|
(ShowPPDetections == true && (DetectionID == DETECTION_PPI_DETECTION || DetectionID == DETECTION_PPE_DETECTION)) ||
|
||||||
|
(DetectionID == DETECTION_PEQ1_DETECTION) ||
|
||||||
|
(DetectionID == DETECTION_PEQ2_DETECTION))
|
||||||
|
{
|
||||||
|
FilterItem = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(FilterItem == false)
|
||||||
|
{
|
||||||
|
QTableWidgetItem * NewItem = new QTableWidgetItem(ZT1LogElement->mPassageDateTime.toString("yyyy/MM/dd - hh:mm:ss"));
|
||||||
|
NewItem->setData(Qt::UserRole,QVariant(i));
|
||||||
|
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
mLogsTable->setItem(CurRow,0,NewItem);
|
||||||
|
|
||||||
|
NewItem = new QTableWidgetItem(ZT1LogElement->mStationName);
|
||||||
|
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
mLogsTable->setItem(CurRow,1,NewItem);
|
||||||
|
|
||||||
|
NewItem = new QTableWidgetItem(QString().sprintf("%d",NbDetections));
|
||||||
|
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
mLogsTable->setItem(CurRow,2,NewItem);
|
||||||
|
|
||||||
|
NewItem = new QTableWidgetItem(QString().sprintf("ZT1"));
|
||||||
|
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
mLogsTable->setItem(CurRow,3,NewItem);
|
||||||
|
|
||||||
|
CurRow++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(LogsList->at(i)->mZTLogType == ZT2_LOG_TYPE && ShowZT2Items == true)
|
||||||
|
{
|
||||||
|
CZT2LogElement *ZT2LogElement = (CZT2LogElement*)LogsList->at(i);
|
||||||
|
|
||||||
|
if((ZT2LogElement->mStationName == mStationsFilterComboBox->currentText() || mStationsFilterComboBox->currentText() == "Toutes") &&
|
||||||
|
(ShowProblematicTrains == true || (ShowProblematicTrains == false && ZT2LogElement->mFlags.mIsProblematicPassage != 1)))
|
||||||
|
{
|
||||||
|
int NbDetections = ZT2LogElement->mZTDetections.size();
|
||||||
|
if(ShowNoDetections == true && NbDetections == 0)
|
||||||
|
{
|
||||||
|
QTableWidgetItem * NewItem = new QTableWidgetItem(ZT2LogElement->mPassageDateTime.toString("yyyy/MM/dd - hh:mm:ss"));
|
||||||
|
NewItem->setData(Qt::UserRole,QVariant(i));
|
||||||
|
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
mLogsTable->setItem(CurRow,0,NewItem);
|
||||||
|
|
||||||
|
NewItem = new QTableWidgetItem(ZT2LogElement->mStationName);
|
||||||
|
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
mLogsTable->setItem(CurRow,1,NewItem);
|
||||||
|
|
||||||
|
NewItem = new QTableWidgetItem(QString().sprintf("%d",ZT2LogElement->mZTDetections.size()));
|
||||||
|
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
mLogsTable->setItem(CurRow,2,NewItem);
|
||||||
|
|
||||||
|
NewItem = new QTableWidgetItem(QString().sprintf("ZT2"));
|
||||||
|
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
mLogsTable->setItem(CurRow,3,NewItem);
|
||||||
|
|
||||||
|
CurRow++;
|
||||||
|
}
|
||||||
|
else if(ShowNoDetections == false && NbDetections == 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bool FilterItem = true;
|
||||||
|
|
||||||
|
for(int trig = 0; trig < NbDetections; trig++)
|
||||||
|
{
|
||||||
|
quint32 DetectionID = ZT2LogElement->mZTDetections.at(trig)->mDetectionID;
|
||||||
|
|
||||||
|
if((ShowCountDetections == true && DetectionID == DETECTION_ZT2_MAGNETIC_SENCOR_COUNT) ||
|
||||||
|
(ShowPPDetections == true && (DetectionID == DETECTION_ZT2_PPI_DETECTION || DetectionID == DETECTION_ZT2_PPE_DETECTION)))
|
||||||
|
{
|
||||||
|
FilterItem = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(FilterItem == false)
|
||||||
|
{
|
||||||
|
QTableWidgetItem * NewItem = new QTableWidgetItem(ZT2LogElement->mPassageDateTime.toString("yyyy/MM/dd - hh:mm:ss"));
|
||||||
|
NewItem->setData(Qt::UserRole,QVariant(i));
|
||||||
|
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
mLogsTable->setItem(CurRow,0,NewItem);
|
||||||
|
|
||||||
|
NewItem = new QTableWidgetItem(ZT2LogElement->mStationName);
|
||||||
|
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
mLogsTable->setItem(CurRow,1,NewItem);
|
||||||
|
|
||||||
|
NewItem = new QTableWidgetItem(QString().sprintf("%d",ZT2LogElement->mZTDetections.size()));
|
||||||
|
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
mLogsTable->setItem(CurRow,2,NewItem);
|
||||||
|
|
||||||
|
NewItem = new QTableWidgetItem(QString().sprintf("ZT2"));
|
||||||
|
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
mLogsTable->setItem(CurRow,3,NewItem);
|
||||||
|
|
||||||
|
CurRow++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mLogsTable->setRowCount(CurRow);
|
||||||
|
|
||||||
|
mLogsTable->setColumnWidth(0,150);
|
||||||
|
mLogsTable->setColumnWidth(1,100);
|
||||||
|
mLogsTable->setColumnWidth(2,50);
|
||||||
|
mLogsTable->setColumnWidth(3,50);
|
||||||
|
|
||||||
|
mLogsTable->sortItems(0,Qt::DescendingOrder);
|
||||||
|
|
||||||
|
mLogsTable->setCurrentCell(0,0);
|
||||||
|
LogsTableCellClicked(0,0);
|
||||||
|
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLogsListPage::ClearTable()
|
||||||
|
{
|
||||||
|
for(int Col = 0; Col < mLogsTable->columnCount(); Col++)
|
||||||
|
{
|
||||||
|
for(int Row = 0; Row < mLogsTable->rowCount(); Row++)
|
||||||
|
{
|
||||||
|
delete mLogsTable->item(Row,Col);
|
||||||
|
//mLogsTable->item(Row,Col) = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mLogsTable->setRowCount(0);
|
||||||
|
mLogsTable->clearContents();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLogsListPage::LogsTableCellSelected( int row, int col, int prevrow, int prevcol)
|
||||||
|
{
|
||||||
|
Q_UNUSED(prevrow)
|
||||||
|
Q_UNUSED(prevcol)
|
||||||
|
|
||||||
|
|
||||||
|
if(row < 0 || col < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
LogsTableCellClicked(row,col);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLogsListPage::LogsTableCellClicked(int row, int column)
|
||||||
|
{
|
||||||
|
Q_UNUSED(column);
|
||||||
|
|
||||||
|
int rowcount = mLogsTable->rowCount();
|
||||||
|
if(rowcount == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// qDebug("Selection : %d",row);
|
||||||
|
QList<CLogElement*> *LogsList = mLogMgrHandle->GetLogsList();
|
||||||
|
|
||||||
|
float MeanSpeed = 0.0;
|
||||||
|
QString Summary;
|
||||||
|
|
||||||
|
if(mLogsTable->item(row,0) == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int ItemIndex = mLogsTable->item(row,0)->data(Qt::UserRole).toInt();
|
||||||
|
//if(LogsList->at(row)->mZTLogType == ZT1_LOG_TYPE)
|
||||||
|
if(LogsList->at(ItemIndex)->mZTLogType == ZT1_LOG_TYPE)
|
||||||
|
{
|
||||||
|
// //CZT1LogElement *ZT1LogElement = (CZT1LogElement*) LogsList->at(row);
|
||||||
|
CZT1LogElement *ZT1LogElement = (CZT1LogElement*) LogsList->at(ItemIndex);
|
||||||
|
|
||||||
|
if(ZT1LogElement->mFileProtected == true)
|
||||||
|
{
|
||||||
|
mProtectLogChkBx->setCheckState(Qt::Checked);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mProtectLogChkBx->setCheckState(Qt::Unchecked);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Problem = "N/A";
|
||||||
|
if(ZT1LogElement->mFlags.mIsProblematicPassage == 1)
|
||||||
|
{
|
||||||
|
Problem = "OUI";
|
||||||
|
}
|
||||||
|
else if(ZT1LogElement->mFlags.mIsProblematicPassage == 0)
|
||||||
|
{
|
||||||
|
Problem = "NON";
|
||||||
|
}
|
||||||
|
MeanSpeed = ZT1LogElement->mMeanSpeed;
|
||||||
|
Summary.sprintf("Passage:\n\nDate: %s\nHeure: %s\nZone Test : ZT1\nTrain : %s\nNombre d'éléments: %d\nProblématique: %s\n\n\nDéclenchements: \n",
|
||||||
|
ZT1LogElement->mPassageDateTime.toString("yyyy/MM/dd").toAscii().data(),
|
||||||
|
ZT1LogElement->mPassageDateTime.toString("hh:mm:ss").toAscii().data(),
|
||||||
|
CZTData::GetTrainTypeString(ZT1LogElement->mTrainType),
|
||||||
|
ZT1LogElement->mNbElements,
|
||||||
|
Problem.toAscii().data());
|
||||||
|
|
||||||
|
if(ZT1LogElement->mZTDetections.size() > 0)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < ZT1LogElement->mZTDetections.size(); i++)
|
||||||
|
{
|
||||||
|
QString temp;
|
||||||
|
if(ZT1LogElement->mZTDetections.at(i)->mDetectionID == DETECTION_FN_DETECTION)
|
||||||
|
{
|
||||||
|
temp.sprintf("%s au bogie %d\n",CZTData::GetErrorString(ZT1LogElement->mZTDetections.at(i)->mDetectionID),ZT1LogElement->mZTDetections.at(i)->mRank);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
temp.sprintf("%s au rang %d\n",CZTData::GetErrorString(ZT1LogElement->mZTDetections.at(i)->mDetectionID),ZT1LogElement->mZTDetections.at(i)->mRank);
|
||||||
|
}
|
||||||
|
Summary += temp;
|
||||||
|
if(i >= MAX_DETECTION_LIST_NBR - 1)
|
||||||
|
{
|
||||||
|
temp = " - Autres déclenchements non affichés -";
|
||||||
|
Summary += temp;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Summary += "Aucun déclenchement";
|
||||||
|
}
|
||||||
|
//else if(LogsList->at(row)->mZTLogType == ZT2_LOG_TYPE)
|
||||||
|
else if(LogsList->at(ItemIndex)->mZTLogType == ZT2_LOG_TYPE)
|
||||||
|
{
|
||||||
|
//CZT2LogElement *ZT2LogElement = (CZT2LogElement*) LogsList->at(row);
|
||||||
|
CZT2LogElement *ZT2LogElement = (CZT2LogElement*) LogsList->at(ItemIndex);
|
||||||
|
|
||||||
|
if(ZT2LogElement->mFileProtected == true)
|
||||||
|
{
|
||||||
|
mProtectLogChkBx->setCheckState(Qt::Checked);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mProtectLogChkBx->setCheckState(Qt::Unchecked);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Problem = "N/A";
|
||||||
|
if(ZT2LogElement->mFlags.mIsProblematicPassage == 1)
|
||||||
|
{
|
||||||
|
Problem = "OUI";
|
||||||
|
}
|
||||||
|
else if(ZT2LogElement->mFlags.mIsProblematicPassage == 0)
|
||||||
|
{
|
||||||
|
Problem = "NON";
|
||||||
|
}
|
||||||
|
Summary.sprintf("Statistiques du passage:\n\nDate: %s\nHeure: %s\nZone Test: ZT2\nNombre d'éléments: %d\nProblématique: %s\n\n\n\nDéclenchements: \n",
|
||||||
|
ZT2LogElement->mPassageDateTime.toString("yyyy/MM/dd").toAscii().data(),
|
||||||
|
ZT2LogElement->mPassageDateTime.toString("hh:mm:ss").toAscii().data(),
|
||||||
|
ZT2LogElement->mNbElements,
|
||||||
|
Problem.toAscii().data());
|
||||||
|
|
||||||
|
if(ZT2LogElement->mZTDetections.size() > 0)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < ZT2LogElement->mZTDetections.size(); i++)
|
||||||
|
{
|
||||||
|
QString temp;
|
||||||
|
temp.sprintf("%s au rang %d\n",CZTData::GetErrorString(ZT2LogElement->mZTDetections.at(i)->mDetectionID),ZT2LogElement->mZTDetections.at(i)->mRank);
|
||||||
|
Summary += temp;
|
||||||
|
if(i >= MAX_DETECTION_LIST_NBR-1)
|
||||||
|
{
|
||||||
|
temp = "- Autres déclenchements non affichés -";
|
||||||
|
Summary += temp;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Summary += "Aucun déclenchement";
|
||||||
|
|
||||||
|
}
|
||||||
|
mSummaryText->setPlainText(Summary);
|
||||||
|
|
||||||
|
CLogElement* Element = mLogMgrHandle->LoadLogData(LogsList->at(ItemIndex));
|
||||||
|
mProgramHandle->LogViewRequest(Element,this);
|
||||||
|
mLogMgrHandle->FreeLogData(Element);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLogsListPage::StationFilterSelected(int Index)
|
||||||
|
{
|
||||||
|
Q_UNUSED(Index);
|
||||||
|
RefreshList();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLogsListPage::ViewZTLogBtnClicked(CPushButton *btn)
|
||||||
|
{
|
||||||
|
if(mLogsTable->rowCount() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int cursel = mLogsTable->selectedItems().at(0)->data(Qt::UserRole).toInt();
|
||||||
|
CLogElement* Element = mLogMgrHandle->GetLogsList()->at(cursel);
|
||||||
|
QString FilePath;
|
||||||
|
QDateTime PassageDateTime;
|
||||||
|
|
||||||
|
if(Element->mZTLogType == ZT1_LOG_TYPE)
|
||||||
|
{
|
||||||
|
CZT1LogElement* log = (CZT1LogElement*)Element;
|
||||||
|
FilePath = log->mLogFileName;
|
||||||
|
PassageDateTime = log->mPassageDateTime;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CZT2LogElement* log = (CZT2LogElement*)Element;
|
||||||
|
FilePath = log->mLogFileName;
|
||||||
|
PassageDateTime = log->mPassageDateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFileInfo FileDir(FilePath);
|
||||||
|
QString ZTLogFilePath = FileDir.absolutePath();
|
||||||
|
ZTLogFilePath += "/ZTLog.txt";
|
||||||
|
|
||||||
|
int line =0;
|
||||||
|
QFile *LogFile = new QFile(ZTLogFilePath);
|
||||||
|
if(LogFile)
|
||||||
|
{
|
||||||
|
if(LogFile->open(QIODevice::ReadOnly | QIODevice::Text | QIODevice::Unbuffered) == true)
|
||||||
|
{
|
||||||
|
QString LogText(LogFile->readAll());
|
||||||
|
|
||||||
|
//Try to find the line corresponding to the selected train passage in the log
|
||||||
|
QDateTime DateTimeLine1,DateTimeLine2;
|
||||||
|
|
||||||
|
QTextStream strm(&LogText);
|
||||||
|
strm.seek(0);
|
||||||
|
|
||||||
|
bool finished = false;
|
||||||
|
QString temp;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
temp = strm.readLine();
|
||||||
|
line++;
|
||||||
|
|
||||||
|
if(strm.atEnd())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
while(temp.length() < 10);
|
||||||
|
|
||||||
|
QStringList parts = temp.split(" : ");
|
||||||
|
QString LineText,DateString;
|
||||||
|
LineText.clear();
|
||||||
|
|
||||||
|
if(PassageDateTime > DateTimeLine1)
|
||||||
|
{
|
||||||
|
if(parts.size() != 0)
|
||||||
|
{
|
||||||
|
DateString = parts.at(0);
|
||||||
|
DateTimeLine1 = QDateTime::fromString(DateString,"yyyy/MM/dd - hh:mm:ss.zzz");
|
||||||
|
while(!finished)
|
||||||
|
{
|
||||||
|
temp = strm.readLine();
|
||||||
|
line++;
|
||||||
|
if(temp.length() > 10)
|
||||||
|
{
|
||||||
|
parts = temp.split(" : ");
|
||||||
|
if(parts.size() != 0)
|
||||||
|
{
|
||||||
|
DateString = parts.at(0);
|
||||||
|
DateTimeLine2 = QDateTime::fromString(DateString,"yyyy/MM/dd - hh:mm:ss.zzz");
|
||||||
|
|
||||||
|
if(PassageDateTime >= DateTimeLine1 && PassageDateTime <= DateTimeLine2)
|
||||||
|
{
|
||||||
|
LineText = parts.at(0);
|
||||||
|
finished = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(strm.atEnd())
|
||||||
|
finished = true;
|
||||||
|
}
|
||||||
|
DateTimeLine1 = DateTimeLine2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mProgramHandle->ShowZTLogRequest(LogText,LineText);
|
||||||
|
LogFile->close();
|
||||||
|
}
|
||||||
|
delete LogFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLogsListPage::SaveCSVLogBtnClicked(CPushButton *)
|
||||||
|
{
|
||||||
|
if(mLogsTable->rowCount() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QString Filename;
|
||||||
|
int cursel = mLogsTable->selectedItems().at(0)->data(Qt::UserRole).toInt();
|
||||||
|
CLogElement* Element = mLogMgrHandle->GetLogsList()->at(cursel);
|
||||||
|
mLogMgrHandle->LoadLogData(Element);
|
||||||
|
if(Element->mZTLogType == ZT1_LOG_TYPE)
|
||||||
|
{
|
||||||
|
CZT1LogElement *temp = (CZT1LogElement*)Element;
|
||||||
|
QString dummy;
|
||||||
|
dummy = temp->mLogFileName;//.replace("bin","csv");
|
||||||
|
Filename = dummy.replace("bin","csv");
|
||||||
|
|
||||||
|
QString CSVFileName = QFileDialog::getSaveFileName(0,"Exporter .csv",Filename,tr("CSV (*.csv)"));
|
||||||
|
|
||||||
|
CTrainLogFileMgr::instance()->SaveCSVFile(CSVFileName,&temp->mZTLogData,&temp->mFlags,&temp->mZTDetections,temp->mStationName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CZT2LogElement *temp = (CZT2LogElement*)Element;
|
||||||
|
QString dummy;
|
||||||
|
dummy = temp->mLogFileName;
|
||||||
|
Filename = dummy.replace("bin","csv");
|
||||||
|
|
||||||
|
QString CSVFileName = QFileDialog::getSaveFileName(0,"Exporter .csv",Filename,tr("CSV (*.csv)"));
|
||||||
|
|
||||||
|
CTrainLogFileMgr::instance()->SaveCSVFile(CSVFileName,&temp->mZTLogData,&temp->mZTDetections,temp->mStationName);
|
||||||
|
}
|
||||||
|
mLogMgrHandle->FreeLogData(Element);
|
||||||
|
}
|
||||||
|
void CLogsListPage::DeleteSelectedLog(CPushButton *)
|
||||||
|
{
|
||||||
|
if(mLogsTable->rowCount() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int SelRow = mLogsTable->selectedItems().at(0)->row();
|
||||||
|
int SelCol = mLogsTable->selectedItems().at(0)->column();
|
||||||
|
|
||||||
|
mLogMgrHandle->DeleteLog(mLogsTable->selectedItems().at(0)->data(Qt::UserRole).toInt());
|
||||||
|
RefreshList();
|
||||||
|
|
||||||
|
mLogsTable->setCurrentCell(SelRow,SelCol);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Grab the mouse if the user clicks outside buttons
|
||||||
|
void CLogsListPage::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
// qDebug("CLogsListPage");
|
||||||
|
Q_UNUSED(event)
|
||||||
|
}
|
||||||
|
void CLogsListPage::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
}
|
||||||
|
void CLogsListPage::CheckBoxClicked(int state)
|
||||||
|
{
|
||||||
|
Q_UNUSED(state)
|
||||||
|
RefreshList();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLogsListPage::ProtectLogCheckBoxClicked()
|
||||||
|
{
|
||||||
|
int state = mProtectLogChkBx->checkState();
|
||||||
|
int cursel = mLogsTable->selectedItems().at(0)->data(Qt::UserRole).toInt();
|
||||||
|
CLogElement* Element = mLogMgrHandle->GetLogsList()->at(cursel);
|
||||||
|
|
||||||
|
if(state == Qt::Checked)
|
||||||
|
{
|
||||||
|
if(mProgramHandle->SetLogProtection(true,Element,this) == RET_ERROR)
|
||||||
|
{
|
||||||
|
mProtectLogChkBx->setCheckState(Qt::Unchecked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(mProgramHandle->SetLogProtection(false,Element,this) == RET_ERROR)
|
||||||
|
{
|
||||||
|
mProtectLogChkBx->setCheckState(Qt::Checked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLogsListPage::TableDoubleClicked(int row, int col)
|
||||||
|
{
|
||||||
|
Q_UNUSED(col)
|
||||||
|
Q_UNUSED(row)
|
||||||
|
// ButtonClicked(mViewLogDataButton);
|
||||||
|
}
|
||||||
104
sources/GuiElements/LogsListPage.h
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Description du fichier si nécessaire.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131024 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef LOGSLISTPAGE_H
|
||||||
|
#define LOGSLISTPAGE_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
#include "Guipage.h"
|
||||||
|
#include <QString>
|
||||||
|
#include "PushButton.h"
|
||||||
|
#include "TextButtonWidget.h"
|
||||||
|
#include "LogMgr.h"
|
||||||
|
#include <QTableWidget>
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QComboBox>
|
||||||
|
|
||||||
|
#define MAX_DETECTION_LIST_NBR 6
|
||||||
|
|
||||||
|
class COutilZT;
|
||||||
|
|
||||||
|
class CLogsListPage : public CGuiPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
virtual ~CLogsListPage();
|
||||||
|
CLogsListPage(QGraphicsWidget *Parent = 0);
|
||||||
|
|
||||||
|
|
||||||
|
COutilZT *mProgramHandle;
|
||||||
|
CLogMgr *mLogMgrHandle;
|
||||||
|
|
||||||
|
unsigned int RefreshList();
|
||||||
|
void EnableEngineeringMode();
|
||||||
|
|
||||||
|
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||||
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
QTableWidget *mLogsTable;
|
||||||
|
QGraphicsTextItem *mSummaryText;
|
||||||
|
CTextButtonWidget *mViewLogDataButton;
|
||||||
|
CTextButtonWidget *mExportCSVLogButton;
|
||||||
|
|
||||||
|
QCheckBox *mShowZT1ItemsChkBx, *mShowZT2ItemsChkBx, *mShowNoDetectionsChkBx;
|
||||||
|
QCheckBox *mShowFNChkBx, *mShowCountChkBx, *mShowPGChkBx, *mShowPPChkBx,*mShowMPM10ChkBx, *mShowMRChkBx, *mShowProblematicTrainsChkbx;//, *mShowAllChkBx;
|
||||||
|
|
||||||
|
QTimer *mListParsingTimer;
|
||||||
|
QComboBox *mStationsFilterComboBox;
|
||||||
|
|
||||||
|
QString mStationFilter;
|
||||||
|
|
||||||
|
CPushButton *mViewZTLogBtn, *mSaveCSVLogBtn,*mDeleteFileButton;
|
||||||
|
QCheckBox *mProtectLogChkBx;
|
||||||
|
|
||||||
|
//bool mShowZT1Items,mShowZT2Items,mShowNoDetections,mUSBDetected;
|
||||||
|
|
||||||
|
void ClearTable();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void ButtonClicked(CTextButtonWidget *);
|
||||||
|
void LogsTableCellClicked(int, int);
|
||||||
|
void LogsTableCellSelected(int,int,int,int);
|
||||||
|
void CheckBoxClicked(int);
|
||||||
|
void TableDoubleClicked(int,int);
|
||||||
|
void StationFilterSelected(int);
|
||||||
|
void ViewZTLogBtnClicked(CPushButton *);
|
||||||
|
void SaveCSVLogBtnClicked(CPushButton *);
|
||||||
|
void DeleteSelectedLog(CPushButton*);
|
||||||
|
void ProtectLogCheckBoxClicked();
|
||||||
|
// void ParsingTimerExipred();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOGSLISTPAGE_H
|
||||||
133
sources/GuiElements/MainPage.cpp
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Page principale de la ZT. C'est sur cette dernière que tout est affiché.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20121221 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#include "MainPage.h"
|
||||||
|
#include <QPainter>
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include "OutilZT.h"
|
||||||
|
#include <QDateTime>
|
||||||
|
//#include "Version.h"
|
||||||
|
|
||||||
|
CMainPage::CMainPage(QGraphicsWidget *Parent)
|
||||||
|
{
|
||||||
|
setGeometry(0,0,SCREEN_RES_WIDTH,SCREEN_RES_HEIGHT);
|
||||||
|
|
||||||
|
mProgramHandle = 0;
|
||||||
|
|
||||||
|
// QGraphicsTextItem *SoftVersion = new QGraphicsTextItem(this);
|
||||||
|
// QFont TextFont;
|
||||||
|
// TextFont.setPointSize(15);
|
||||||
|
// TextFont.setBold(true);
|
||||||
|
// SoftVersion->setFont(TextFont);
|
||||||
|
// SoftVersion->setPlainText(QString().sprintf("Version: %s",SOFT_VERSION));
|
||||||
|
// SoftVersion->setZValue(1);
|
||||||
|
// SoftVersion->adjustSize();
|
||||||
|
// SoftVersion->setPos(800,2);
|
||||||
|
|
||||||
|
// mTimeDisplayText = new QGraphicsTextItem(this);
|
||||||
|
// mTimeDisplayText->setPos(400,2);
|
||||||
|
// mTimeDisplayText->setFont(TextFont);
|
||||||
|
// mTimeDisplayText->setZValue(1);
|
||||||
|
|
||||||
|
mDatabaseModePushButton = new CPushButton(this,"./Images/Save-icon.png");
|
||||||
|
mDatabaseModePushButton->setPos(10,10);
|
||||||
|
mDatabaseModePushButton->resize(50,50);
|
||||||
|
connect( mDatabaseModePushButton, SIGNAL( clicked(CPushButton*) ), this, SLOT(ButtonPressed(CPushButton*) ) );
|
||||||
|
|
||||||
|
mNetworkModePushButton = new CPushButton(this,"./Images/ethernet.png");
|
||||||
|
mNetworkModePushButton->setPos(10,150);
|
||||||
|
mNetworkModePushButton->resize(50,50);
|
||||||
|
connect( mNetworkModePushButton, SIGNAL( clicked(CPushButton*) ), this, SLOT(ButtonPressed(CPushButton*) ) );
|
||||||
|
mNetworkModePushButton->hide();
|
||||||
|
|
||||||
|
mZTLogsListPushButton = new CPushButton(this,"./Images/log.png");
|
||||||
|
mZTLogsListPushButton->setPos(10,80);
|
||||||
|
mZTLogsListPushButton->resize(50,50);
|
||||||
|
connect( mZTLogsListPushButton, SIGNAL( clicked(CPushButton*) ), this, SLOT(ButtonPressed(CPushButton*) ) );
|
||||||
|
|
||||||
|
mToolsPushButton = new CPushButton(this,"./Images/tools.png");
|
||||||
|
mToolsPushButton->setPos(10,375);
|
||||||
|
mToolsPushButton->resize(50,50);
|
||||||
|
connect( mToolsPushButton, SIGNAL( clicked(CPushButton*) ), this, SLOT(ButtonPressed(CPushButton*) ) );
|
||||||
|
|
||||||
|
mDatabaseOptionsPushButton = new CPushButton(this,"./Images/database.png");
|
||||||
|
mDatabaseOptionsPushButton->setPos(10,300);
|
||||||
|
mDatabaseOptionsPushButton->resize(50,50);
|
||||||
|
connect( mDatabaseOptionsPushButton, SIGNAL( clicked(CPushButton*) ), this, SLOT(ButtonPressed(CPushButton*) ) );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// CPushButton *LogsPushButton = new CPushButton(this,"./Images/Save-icon.png");
|
||||||
|
// LogsPushButton->setPos(70,700);
|
||||||
|
// LogsPushButton->resize(65,65);
|
||||||
|
// connect( LogsPushButton, SIGNAL( clicked(CPushButton*) ), this, SLOT(LogsButtonPressed()) );
|
||||||
|
|
||||||
|
|
||||||
|
// mTimeDisplayTimer = new QTimer();
|
||||||
|
// connect(mTimeDisplayTimer,SIGNAL(timeout()),this,SLOT(UpdateTime()));
|
||||||
|
// mTimeDisplayTimer->setSingleShot(false);
|
||||||
|
// mTimeDisplayTimer->start(1000);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMainPage::ButtonPressed(CPushButton *Btn)
|
||||||
|
{
|
||||||
|
if(Btn == mToolsPushButton)
|
||||||
|
{
|
||||||
|
mProgramHandle->ShowOptionsRequest();
|
||||||
|
}
|
||||||
|
else if(Btn == mNetworkModePushButton)
|
||||||
|
{
|
||||||
|
mProgramHandle->EnterNetworkModeRequest();
|
||||||
|
}
|
||||||
|
else if(Btn == mDatabaseModePushButton)
|
||||||
|
{
|
||||||
|
mProgramHandle->EnterDatabaseModeRequest();
|
||||||
|
}
|
||||||
|
else if(Btn == mDatabaseOptionsPushButton)
|
||||||
|
{
|
||||||
|
mProgramHandle->ShowDatabaseMgrRequest();
|
||||||
|
}
|
||||||
|
else if(Btn == mZTLogsListPushButton)
|
||||||
|
{
|
||||||
|
mProgramHandle->EnterZTLogModeRequest();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CMainPage::UpdateTime()
|
||||||
|
{
|
||||||
|
// QDateTime time = QDateTime::currentDateTime();
|
||||||
|
// mTimeDisplayText->setPlainText(time.toString("yyyy/MM/dd hh:mm:ss"));
|
||||||
|
|
||||||
|
}
|
||||||
77
sources/GuiElements/MainPage.h
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Description du fichier si nécessaire.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20121221 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef MAINPAGE_H
|
||||||
|
#define MAINPAGE_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
#include "Guipage.h"
|
||||||
|
#include <QString>
|
||||||
|
#include "PushButton.h"
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
|
||||||
|
class COutilZT;
|
||||||
|
class CEvent;
|
||||||
|
|
||||||
|
class CMainPage : public CGuiPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CMainPage(QGraphicsWidget *Parent = 0);
|
||||||
|
CPushButton *mToolsPushButton;
|
||||||
|
CPushButton *mNetworkModePushButton;
|
||||||
|
CPushButton *mDatabaseModePushButton;
|
||||||
|
CPushButton *mDatabaseOptionsPushButton;
|
||||||
|
CPushButton *mZTLogsListPushButton;
|
||||||
|
QGraphicsTextItem *mTimeDisplayText;
|
||||||
|
QTimer *mTimeDisplayTimer;
|
||||||
|
|
||||||
|
|
||||||
|
COutilZT *mProgramHandle;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void UpdateTime();
|
||||||
|
void ButtonPressed(CPushButton*);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MAINPAGE_H
|
||||||
216
sources/GuiElements/NetworkCtrlPage.cpp
Normal file
@ -0,0 +1,216 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Page affichant la liste des passages de train.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131021 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#include "NetworkCtrlPage.h"
|
||||||
|
#include <QGraphicsProxyWidget>
|
||||||
|
#include "OutilZT.h"
|
||||||
|
#include <QString>
|
||||||
|
#include <QTextCodec>
|
||||||
|
#include <QHeaderView>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CNetworkCtrlPage::~CNetworkCtrlPage()
|
||||||
|
{
|
||||||
|
delete mRadioButtonsGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
CNetworkCtrlPage::CNetworkCtrlPage(QGraphicsWidget *Parent)
|
||||||
|
{
|
||||||
|
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
|
||||||
|
setParentItem(Parent);
|
||||||
|
mProgramHandle = 0;
|
||||||
|
mIsConnecting = false;
|
||||||
|
|
||||||
|
mNetworkConnectButton = new CToggleTextButtonWidget("Déconnecter"," Connecter ",QPixmap("./Images/red_cross.png"),QPixmap("./Images/green_check.png"),25,125);
|
||||||
|
mNetworkConnectButton->setParentItem(this);
|
||||||
|
// mNetworkConnectButton->setPos(10,350);
|
||||||
|
mNetworkConnectButton->setPos(10,25);
|
||||||
|
connect(mNetworkConnectButton,SIGNAL(ToggleBtnActivate(CToggleTextButtonWidget*)),this,SLOT(ConnectButtonPressed()));
|
||||||
|
connect(mNetworkConnectButton,SIGNAL(ToggleBtnDeActivate(CToggleTextButtonWidget*)),this,SLOT(ConnectButtonReleased()));
|
||||||
|
|
||||||
|
mZTStatusRefreshButton = new CTextButtonWidget("Rafraîchir");
|
||||||
|
mZTStatusRefreshButton->setParentItem(this);
|
||||||
|
mZTStatusRefreshButton->setPos(180,75);
|
||||||
|
connect(mZTStatusRefreshButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||||
|
|
||||||
|
mZTLogDownloadButton = new CTextButtonWidget("Voir ZTLog");
|
||||||
|
mZTLogDownloadButton->setParentItem(this);
|
||||||
|
mZTLogDownloadButton->setPos(50,75);
|
||||||
|
connect(mZTLogDownloadButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||||
|
|
||||||
|
mTrainLogsDownloadButton = new CTextButtonWidget("Téléch. Passages");
|
||||||
|
mTrainLogsDownloadButton->setParentItem(this);
|
||||||
|
mTrainLogsDownloadButton->setPos(50,125);
|
||||||
|
connect(mTrainLogsDownloadButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||||
|
|
||||||
|
mRadioButtonsGroup = new QButtonGroup();
|
||||||
|
mViewRemoteControlRadioBtn = new QRadioButton("Voir contrôle");
|
||||||
|
QGraphicsProxyWidget *RadioButtonsProxyWidget = new QGraphicsProxyWidget(this);
|
||||||
|
RadioButtonsProxyWidget->setWidget(mViewRemoteControlRadioBtn);
|
||||||
|
RadioButtonsProxyWidget->setPos(180,0);
|
||||||
|
RadioButtonsProxyWidget->resize(150,15);
|
||||||
|
connect(mViewRemoteControlRadioBtn,SIGNAL(toggled(bool)),this,SLOT(RemoteViewRadioButtonToggled(bool)));
|
||||||
|
mViewRemoteTrainLogsRadioBtn = new QRadioButton("Voir passages");
|
||||||
|
RadioButtonsProxyWidget = new QGraphicsProxyWidget(this);
|
||||||
|
RadioButtonsProxyWidget->setWidget(mViewRemoteTrainLogsRadioBtn);
|
||||||
|
RadioButtonsProxyWidget->setPos(180,20);
|
||||||
|
RadioButtonsProxyWidget->resize(150,15);
|
||||||
|
connect(mViewRemoteTrainLogsRadioBtn,SIGNAL(toggled(bool)),this,SLOT(RemoteViewRadioButtonToggled(bool)));
|
||||||
|
mViewRemoteLiveZtRadioBtn = new QRadioButton("Voir temps réel");
|
||||||
|
RadioButtonsProxyWidget = new QGraphicsProxyWidget(this);
|
||||||
|
RadioButtonsProxyWidget->setWidget(mViewRemoteLiveZtRadioBtn);
|
||||||
|
RadioButtonsProxyWidget->setPos(180,40);
|
||||||
|
RadioButtonsProxyWidget->resize(150,15);
|
||||||
|
connect(mViewRemoteLiveZtRadioBtn,SIGNAL(toggled(bool)),this,SLOT(RemoteViewRadioButtonToggled(bool)));
|
||||||
|
mViewRemoteTrainLogsRadioBtn->setChecked(true);
|
||||||
|
mRadioButtonsGroup->addButton(mViewRemoteControlRadioBtn);
|
||||||
|
mRadioButtonsGroup->addButton(mViewRemoteTrainLogsRadioBtn);
|
||||||
|
mRadioButtonsGroup->addButton(mViewRemoteLiveZtRadioBtn);
|
||||||
|
|
||||||
|
|
||||||
|
mTxRxWidget = new CTxRxWidget();
|
||||||
|
mTxRxWidget->setParentItem(this);
|
||||||
|
mTxRxWidget->setPos(180,100);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkCtrlPage::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
// mBackgroundRect->setRect(boundingRect());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkCtrlPage::ButtonClicked(CTextButtonWidget *BtnPtr)
|
||||||
|
{
|
||||||
|
if(BtnPtr == mZTStatusRefreshButton)
|
||||||
|
{
|
||||||
|
mProgramHandle->RefreshRemoteZTStatusRequest();
|
||||||
|
}
|
||||||
|
else if(BtnPtr == mZTLogDownloadButton)
|
||||||
|
{
|
||||||
|
mProgramHandle->DownloadZTLogRequest();
|
||||||
|
}
|
||||||
|
else if(BtnPtr == mTrainLogsDownloadButton)
|
||||||
|
{
|
||||||
|
mProgramHandle->DownloadTrainLogsRequest();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkCtrlPage::ConnectButtonPressed()
|
||||||
|
{
|
||||||
|
mNetworkConnectButton->ForceDeactivation();
|
||||||
|
mNetworkConnectButton->OverrideText("Annuler...");
|
||||||
|
|
||||||
|
if(mIsConnecting == false)
|
||||||
|
{
|
||||||
|
if(mProgramHandle->ConnectToZTRequest() == RET_OK)
|
||||||
|
{
|
||||||
|
mIsConnecting = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mProgramHandle->DisconnectZTRequest();
|
||||||
|
mIsConnecting = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkCtrlPage::ConnectButtonReleased()
|
||||||
|
{
|
||||||
|
mProgramHandle->DisconnectZTRequest();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkCtrlPage::NetworkZTConnected(int ID)
|
||||||
|
{
|
||||||
|
mNetworkConnectButton->ForceActivation();
|
||||||
|
mIsConnecting = false;
|
||||||
|
}
|
||||||
|
void CNetworkCtrlPage::NetworkZTConnectionFailed(int ID)
|
||||||
|
{
|
||||||
|
mNetworkConnectButton->ForceDeactivation();
|
||||||
|
mIsConnecting = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkCtrlPage::NetworkRx()
|
||||||
|
{
|
||||||
|
mTxRxWidget->Receive();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkCtrlPage::NetworkTx()
|
||||||
|
{
|
||||||
|
mTxRxWidget->Transmit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkCtrlPage::DisableNetworkButtons()
|
||||||
|
{
|
||||||
|
mZTStatusRefreshButton->DisableButton();
|
||||||
|
mZTLogDownloadButton->DisableButton();
|
||||||
|
mTrainLogsDownloadButton->DisableButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkCtrlPage::EnableNetworkButtons()
|
||||||
|
{
|
||||||
|
mZTStatusRefreshButton->EnableButton();
|
||||||
|
mZTLogDownloadButton->EnableButton();
|
||||||
|
mTrainLogsDownloadButton->EnableButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkCtrlPage::RemoteViewRadioButtonToggled(bool state)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(mViewRemoteControlRadioBtn->isChecked())
|
||||||
|
{
|
||||||
|
if(mProgramHandle != 0)
|
||||||
|
mProgramHandle->ShowRemoteControlPage();
|
||||||
|
}
|
||||||
|
else if(mViewRemoteTrainLogsRadioBtn->isChecked())
|
||||||
|
{
|
||||||
|
if(mProgramHandle != 0)
|
||||||
|
mProgramHandle->ShowRemoteTrainLogsViewPages();
|
||||||
|
}
|
||||||
|
else if(mViewRemoteLiveZtRadioBtn->isChecked())
|
||||||
|
{
|
||||||
|
if(mProgramHandle != 0)
|
||||||
|
mProgramHandle->ShowRemoteLiveZTPage();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Grab the mouse if the user clicks outside buttons
|
||||||
|
void CNetworkCtrlPage::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
qDebug("CNetworkCtrlPage");
|
||||||
|
Q_UNUSED(event)
|
||||||
|
}
|
||||||
|
void CNetworkCtrlPage::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
}
|
||||||
87
sources/GuiElements/NetworkCtrlPage.h
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Description du fichier si nécessaire.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131024 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NETWORKCTRLPAGE_H
|
||||||
|
#define NETWORKCTRLPAGE_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
#include "Guipage.h"
|
||||||
|
#include <QString>
|
||||||
|
#include "ToggleTextButtonWidget.h"
|
||||||
|
#include "TextButtonWidget.h"
|
||||||
|
#include "TxRxWidget.h"
|
||||||
|
#include <QRadioButton>
|
||||||
|
#include <QButtonGroup>
|
||||||
|
|
||||||
|
class COutilZT;
|
||||||
|
|
||||||
|
class CNetworkCtrlPage : public CGuiPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
virtual ~CNetworkCtrlPage();
|
||||||
|
CNetworkCtrlPage(QGraphicsWidget *Parent = 0);
|
||||||
|
|
||||||
|
|
||||||
|
COutilZT *mProgramHandle;
|
||||||
|
|
||||||
|
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||||
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
|
void DisableNetworkButtons();
|
||||||
|
void EnableNetworkButtons();
|
||||||
|
|
||||||
|
private:
|
||||||
|
CToggleTextButtonWidget *mNetworkConnectButton;
|
||||||
|
CTextButtonWidget *mZTStatusRefreshButton;
|
||||||
|
CTxRxWidget *mTxRxWidget;
|
||||||
|
CTextButtonWidget *mZTLogDownloadButton;
|
||||||
|
CTextButtonWidget *mTrainLogsDownloadButton;
|
||||||
|
QRadioButton *mViewRemoteTrainLogsRadioBtn, *mViewRemoteControlRadioBtn, *mViewRemoteLiveZtRadioBtn;
|
||||||
|
QButtonGroup *mRadioButtonsGroup;
|
||||||
|
|
||||||
|
bool mIsConnecting;
|
||||||
|
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void ButtonClicked(CTextButtonWidget *);
|
||||||
|
void ConnectButtonPressed();
|
||||||
|
void ConnectButtonReleased();
|
||||||
|
void NetworkZTConnected(int);
|
||||||
|
void NetworkZTConnectionFailed(int);
|
||||||
|
void NetworkTx();
|
||||||
|
void NetworkRx();
|
||||||
|
void RemoteViewRadioButtonToggled(bool);
|
||||||
|
|
||||||
|
// void ParsingTimerExipred();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // NETWORKCTRLPAGE_H
|
||||||
490
sources/GuiElements/NetworkZTListPage.cpp
Normal file
@ -0,0 +1,490 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Page affichant la liste des passages de train.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131021 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#include "NetworkZTListPage.h"
|
||||||
|
#include <QGraphicsProxyWidget>
|
||||||
|
#include "OutilZT.h"
|
||||||
|
#include <QString>
|
||||||
|
#include <QTextCodec>
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include <NetworkManager.h>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
|
CNetworkZTListPage::~CNetworkZTListPage()
|
||||||
|
{
|
||||||
|
ClearTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
CNetworkZTListPage::CNetworkZTListPage(QGraphicsWidget *Parent)
|
||||||
|
{
|
||||||
|
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
|
||||||
|
setParentItem(Parent);
|
||||||
|
mProgramHandle = 0;
|
||||||
|
|
||||||
|
|
||||||
|
mZTListTable = new QTableWidget(0,3);
|
||||||
|
QGraphicsProxyWidget *TableProxy = new QGraphicsProxyWidget(this);
|
||||||
|
TableProxy->setWidget(mZTListTable);
|
||||||
|
TableProxy->setPos(3,20);
|
||||||
|
TableProxy->resize(320,300);
|
||||||
|
TableProxy->setZValue(3);
|
||||||
|
mZTListTable->resize(320,300);
|
||||||
|
mZTListTable->horizontalHeader()->setStretchLastSection(true);
|
||||||
|
mZTListTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
|
mZTListTable->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
|
mZTListTable->clearContents();
|
||||||
|
mZTListTable->setRowCount(NB_ZT_ID);
|
||||||
|
mZTListTable->setHorizontalHeaderLabels(QStringList() << "Zone Test" << "Addr. IP" << "Connection");
|
||||||
|
// connect(mLogsTable,SIGNAL(cellClicked(int,int)),this,SLOT(LogsTableCellClicked(int,int)));
|
||||||
|
connect(mZTListTable,SIGNAL(currentCellChanged(int,int,int,int)),this,SLOT(ZTListTableCellSelected(int,int,int,int)));
|
||||||
|
connect(mZTListTable,SIGNAL(cellDoubleClicked(int,int)),SLOT(TableDoubleClicked(int,int)));
|
||||||
|
|
||||||
|
|
||||||
|
for(int i = 0; i < NB_ZT_ID; i++)
|
||||||
|
{
|
||||||
|
QTableWidgetItem * NewItem = new QTableWidgetItem(COutilZT::GetStationName(i));
|
||||||
|
NewItem->setData(Qt::UserRole,QVariant(i));
|
||||||
|
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
mZTListTable->setItem(i,0,NewItem);
|
||||||
|
NewItem = new QTableWidgetItem("192.168.100.100");
|
||||||
|
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
mZTListTable->setItem(i,1,NewItem);
|
||||||
|
NewItem = new QTableWidgetItem("Inconnu");
|
||||||
|
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
mZTListTable->setItem(i,2,NewItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
mZTListTable->resizeColumnsToContents();
|
||||||
|
|
||||||
|
mZTListTable->setCurrentCell(0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void CNetworkZTListPage::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
// mBackgroundRect->setRect(boundingRect());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkZTListPage::ButtonClicked(CTextButtonWidget *BtnPtr)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CNetworkZTListPage::RefreshList()
|
||||||
|
{
|
||||||
|
|
||||||
|
// ClearTable();
|
||||||
|
|
||||||
|
// bool ShowZT1Items = (mShowZT1ItemsChkBx->checkState() == Qt::Checked);
|
||||||
|
// bool ShowZT2Items = (mShowZT2ItemsChkBx->checkState() == Qt::Checked);
|
||||||
|
// bool ShowNoDetections = (mShowNoDetectionsChkBx->checkState() == Qt::Checked);
|
||||||
|
|
||||||
|
// bool ShowPPDetections = (mShowPPChkBx->checkState() == Qt::Checked);
|
||||||
|
// bool ShowPGDetections = (mShowPGChkBx->checkState() == Qt::Checked);
|
||||||
|
// bool ShowCountDetections = (mShowCountChkBx->checkState() == Qt::Checked);
|
||||||
|
// bool ShowFNDetections = (mShowFNChkBx->checkState() == Qt::Checked);
|
||||||
|
|
||||||
|
|
||||||
|
// mLogsTable->setRowCount(mLogMgrHandle->GetLogsCount());
|
||||||
|
|
||||||
|
// if(mLogMgrHandle->GetLogsCount() == 0)
|
||||||
|
// return RET_OK;
|
||||||
|
|
||||||
|
// int CurRow = 0;
|
||||||
|
|
||||||
|
// QList<CLogElement*> *LogsList = mLogMgrHandle->GetLogsList();
|
||||||
|
// for(unsigned int i = 0; i < mLogMgrHandle->GetLogsCount(); i++)
|
||||||
|
// {
|
||||||
|
// if(LogsList->at(i)->mZTLogType == ZT1_LOG_TYPE && ShowZT1Items == true)
|
||||||
|
// {
|
||||||
|
// CZT1LogElement *ZT1LogElement = (CZT1LogElement*)LogsList->at(i);
|
||||||
|
// QString stationtext = mStationsFilterComboBox->currentText();
|
||||||
|
// if(ZT1LogElement->mStationName == mStationsFilterComboBox->currentText() || mStationsFilterComboBox->currentText() == "Toutes")
|
||||||
|
// {
|
||||||
|
// int NbDetections = ZT1LogElement->mZTDetections.size();
|
||||||
|
// if(ShowNoDetections == true && NbDetections == 0)
|
||||||
|
// {
|
||||||
|
// QTableWidgetItem * NewItem = new QTableWidgetItem(ZT1LogElement->mPassageDateTime.toString("yyyy/MM/dd - hh:mm:ss"));
|
||||||
|
// NewItem->setData(Qt::UserRole,QVariant(i));
|
||||||
|
// NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
// mLogsTable->setItem(CurRow,0,NewItem);
|
||||||
|
|
||||||
|
// NewItem = new QTableWidgetItem(ZT1LogElement->mStationName);
|
||||||
|
// NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
// mLogsTable->setItem(CurRow,1,NewItem);
|
||||||
|
|
||||||
|
// NewItem = new QTableWidgetItem(QString().sprintf("%d",NbDetections));
|
||||||
|
// NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
// mLogsTable->setItem(CurRow,2,NewItem);
|
||||||
|
|
||||||
|
// NewItem = new QTableWidgetItem(QString().sprintf("ZT1"));
|
||||||
|
// NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
// mLogsTable->setItem(CurRow,3,NewItem);
|
||||||
|
|
||||||
|
// CurRow++;
|
||||||
|
// }
|
||||||
|
// else if(ShowNoDetections == false && NbDetections == 0)
|
||||||
|
// {
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// bool FilterItem = true;
|
||||||
|
|
||||||
|
// for(int trig = 0; trig < NbDetections; trig++)
|
||||||
|
// {
|
||||||
|
// quint32 DetectionID = ZT1LogElement->mZTDetections.at(trig)->mDetectionID;
|
||||||
|
|
||||||
|
// if((ShowCountDetections == true && DetectionID == DETECTION_MAGNETIC_SENSOR_COUNT) ||
|
||||||
|
// (ShowFNDetections == true && DetectionID == DETECTION_FN_DETECTION) ||
|
||||||
|
// (ShowPGDetections == true && DetectionID == DETECTION_PG_DETECTION) ||
|
||||||
|
// (ShowPPDetections == true && (DetectionID == DETECTION_PPI_DETECTION || DetectionID == DETECTION_PPE_DETECTION)))
|
||||||
|
// {
|
||||||
|
// FilterItem = false;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if(FilterItem == false)
|
||||||
|
// {
|
||||||
|
// QTableWidgetItem * NewItem = new QTableWidgetItem(ZT1LogElement->mPassageDateTime.toString("yyyy/MM/dd - hh:mm:ss"));
|
||||||
|
// NewItem->setData(Qt::UserRole,QVariant(i));
|
||||||
|
// NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
// mLogsTable->setItem(CurRow,0,NewItem);
|
||||||
|
|
||||||
|
// NewItem = new QTableWidgetItem(ZT1LogElement->mStationName);
|
||||||
|
// NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
// mLogsTable->setItem(CurRow,1,NewItem);
|
||||||
|
|
||||||
|
// NewItem = new QTableWidgetItem(QString().sprintf("%d",NbDetections));
|
||||||
|
// NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
// mLogsTable->setItem(CurRow,2,NewItem);
|
||||||
|
|
||||||
|
// NewItem = new QTableWidgetItem(QString().sprintf("ZT1"));
|
||||||
|
// NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
// mLogsTable->setItem(CurRow,3,NewItem);
|
||||||
|
|
||||||
|
// CurRow++;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// }
|
||||||
|
// else if(LogsList->at(i)->mZTLogType == ZT2_LOG_TYPE && ShowZT2Items == true)
|
||||||
|
// {
|
||||||
|
// CZT2LogElement *ZT2LogElement = (CZT2LogElement*)LogsList->at(i);
|
||||||
|
|
||||||
|
// if(ZT2LogElement->mStationName == mStationsFilterComboBox->currentText() || mStationsFilterComboBox->currentText() == "Toutes")
|
||||||
|
// {
|
||||||
|
// int NbDetections = ZT2LogElement->mZTDetections.size();
|
||||||
|
// if(ShowNoDetections == true && NbDetections == 0)
|
||||||
|
// {
|
||||||
|
// QTableWidgetItem * NewItem = new QTableWidgetItem(ZT2LogElement->mPassageDateTime.toString("yyyy/MM/dd - hh:mm:ss"));
|
||||||
|
// NewItem->setData(Qt::UserRole,QVariant(i));
|
||||||
|
// NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
// mLogsTable->setItem(CurRow,0,NewItem);
|
||||||
|
|
||||||
|
// NewItem = new QTableWidgetItem(ZT2LogElement->mStationName);
|
||||||
|
// NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
// mLogsTable->setItem(CurRow,1,NewItem);
|
||||||
|
|
||||||
|
// NewItem = new QTableWidgetItem(QString().sprintf("%d",ZT2LogElement->mZTDetections.size()));
|
||||||
|
// NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
// mLogsTable->setItem(CurRow,2,NewItem);
|
||||||
|
|
||||||
|
// NewItem = new QTableWidgetItem(QString().sprintf("ZT2"));
|
||||||
|
// NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
// mLogsTable->setItem(CurRow,32,NewItem);
|
||||||
|
|
||||||
|
// CurRow++;
|
||||||
|
// }
|
||||||
|
// else if(ShowNoDetections == false && NbDetections == 0)
|
||||||
|
// {
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// bool FilterItem = true;
|
||||||
|
|
||||||
|
// for(int trig = 0; trig < NbDetections; trig++)
|
||||||
|
// {
|
||||||
|
// quint32 DetectionID = ZT2LogElement->mZTDetections.at(trig)->mDetectionID;
|
||||||
|
|
||||||
|
// if((ShowCountDetections == true && DetectionID == DETECTION_ZT2_MAGNETIC_SENCOR_COUNT) ||
|
||||||
|
// (ShowPPDetections == true && (DetectionID == DETECTION_ZT2_PPI_DETECTION || DetectionID == DETECTION_ZT2_PPE_DETECTION)))
|
||||||
|
// {
|
||||||
|
// FilterItem = false;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if(FilterItem == false)
|
||||||
|
// {
|
||||||
|
// QTableWidgetItem * NewItem = new QTableWidgetItem(ZT2LogElement->mPassageDateTime.toString("yyyy/MM/dd - hh:mm:ss"));
|
||||||
|
// NewItem->setData(Qt::UserRole,QVariant(i));
|
||||||
|
// NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
// mLogsTable->setItem(CurRow,0,NewItem);
|
||||||
|
|
||||||
|
// NewItem = new QTableWidgetItem(ZT2LogElement->mStationName);
|
||||||
|
// NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
// mLogsTable->setItem(CurRow,1,NewItem);
|
||||||
|
|
||||||
|
// NewItem = new QTableWidgetItem(QString().sprintf("%d",ZT2LogElement->mZTDetections.size()));
|
||||||
|
// NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
// mLogsTable->setItem(CurRow,2,NewItem);
|
||||||
|
|
||||||
|
// NewItem = new QTableWidgetItem(QString().sprintf("ZT2"));
|
||||||
|
// NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
// mLogsTable->setItem(CurRow,32,NewItem);
|
||||||
|
|
||||||
|
// CurRow++;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// mLogsTable->setRowCount(CurRow);
|
||||||
|
|
||||||
|
// mLogsTable->setColumnWidth(0,150);
|
||||||
|
// mLogsTable->setColumnWidth(1,75);
|
||||||
|
// mLogsTable->setColumnWidth(2,50);
|
||||||
|
// mLogsTable->setColumnWidth(3,50);
|
||||||
|
|
||||||
|
// mLogsTable->sortItems(0,Qt::DescendingOrder);
|
||||||
|
|
||||||
|
// mLogsTable->setCurrentCell(0,0);
|
||||||
|
// LogsTableCellClicked(0,0);
|
||||||
|
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkZTListPage::ClearTable()
|
||||||
|
{
|
||||||
|
for(int Col = 0; Col < mZTListTable->columnCount(); Col++)
|
||||||
|
{
|
||||||
|
for(int Row = 0; Row < mZTListTable->rowCount(); Row++)
|
||||||
|
{
|
||||||
|
delete mZTListTable->item(Row,Col);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mZTListTable->setRowCount(0);
|
||||||
|
mZTListTable->clearContents();
|
||||||
|
|
||||||
|
}
|
||||||
|
unsigned int CNetworkZTListPage::SetConfig(CSettingsData *SettingsData)
|
||||||
|
{
|
||||||
|
if(SettingsData->mNetworkCfgList.size() != NB_ZT_ID)
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
for(int i = 0; i < NB_ZT_ID; i++)
|
||||||
|
{
|
||||||
|
mZTListTable->item(i,1)->setText(SettingsData->mNetworkCfgList.at(i).mIPAdress);
|
||||||
|
}
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkZTListPage::ZTListTableCellSelected( int row, int col, int prevrow, int prevcol)
|
||||||
|
{
|
||||||
|
Q_UNUSED(prevrow)
|
||||||
|
Q_UNUSED(prevcol)
|
||||||
|
|
||||||
|
|
||||||
|
// if(row < 0 || col < 0)
|
||||||
|
// return;
|
||||||
|
|
||||||
|
// LogsTableCellClicked(row,col);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CNetworkZTListPage::GetSelectedZT()
|
||||||
|
{
|
||||||
|
return mZTListTable->selectedItems().at(0)->data(Qt::UserRole).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkZTListPage::ZTListTableCellClicked(int row, int column)
|
||||||
|
{
|
||||||
|
Q_UNUSED(column);
|
||||||
|
|
||||||
|
// int rowcount = mLogsTable->rowCount();
|
||||||
|
// if(rowcount == 0)
|
||||||
|
// return;
|
||||||
|
|
||||||
|
//// qDebug("Selection : %d",row);
|
||||||
|
// QList<CLogElement*> *LogsList = mLogMgrHandle->GetLogsList();
|
||||||
|
|
||||||
|
// float MeanSpeed = 0.0;
|
||||||
|
// QString Summary;
|
||||||
|
|
||||||
|
// if(mLogsTable->item(row,0) == 0)
|
||||||
|
// return;
|
||||||
|
|
||||||
|
// int ItemIndex = mLogsTable->item(row,0)->data(Qt::UserRole).toInt();
|
||||||
|
// //if(LogsList->at(row)->mZTLogType == ZT1_LOG_TYPE)
|
||||||
|
// if(LogsList->at(ItemIndex)->mZTLogType == ZT1_LOG_TYPE)
|
||||||
|
// {
|
||||||
|
//// //CZT1LogElement *ZT1LogElement = (CZT1LogElement*) LogsList->at(row);
|
||||||
|
// CZT1LogElement *ZT1LogElement = (CZT1LogElement*) LogsList->at(ItemIndex);
|
||||||
|
|
||||||
|
// MeanSpeed = ZT1LogElement->mMeanSpeed;
|
||||||
|
// Summary.sprintf("Passage:\n\nDate: %s\nHeure: %s\nZone Test : ZT1\nTrain : %s\nNombre d'éléments: %d\n\n\nDéclenchements: \n",
|
||||||
|
// ZT1LogElement->mPassageDateTime.toString("yyyy/MM/dd").toAscii().data(),
|
||||||
|
// ZT1LogElement->mPassageDateTime.toString("hh:mm:ss").toAscii().data(),
|
||||||
|
// CZTData::GetTrainTypeString(ZT1LogElement->mTrainType),
|
||||||
|
// ZT1LogElement->mNbElements);
|
||||||
|
|
||||||
|
// if(ZT1LogElement->mZTDetections.size() > 0)
|
||||||
|
// {
|
||||||
|
// for(int i = 0; i < ZT1LogElement->mZTDetections.size(); i++)
|
||||||
|
// {
|
||||||
|
// QString temp;
|
||||||
|
// if(ZT1LogElement->mZTDetections.at(i)->mDetectionID == DETECTION_FN_DETECTION)
|
||||||
|
// {
|
||||||
|
// temp.sprintf("%s au bogie %d\n",CZTData::GetErrorString(ZT1LogElement->mZTDetections.at(i)->mDetectionID),ZT1LogElement->mZTDetections.at(i)->mRank);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// temp.sprintf("%s au rang %d\n",CZTData::GetErrorString(ZT1LogElement->mZTDetections.at(i)->mDetectionID),ZT1LogElement->mZTDetections.at(i)->mRank);
|
||||||
|
// }
|
||||||
|
// Summary += temp;
|
||||||
|
// if(i >= MAX_DETECTION_LIST_NBR - 1)
|
||||||
|
// {
|
||||||
|
// temp = " - Autres déclenchements non affichés -";
|
||||||
|
// Summary += temp;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// Summary += "Aucun déclenchement";
|
||||||
|
// }
|
||||||
|
// //else if(LogsList->at(row)->mZTLogType == ZT2_LOG_TYPE)
|
||||||
|
// else if(LogsList->at(ItemIndex)->mZTLogType == ZT2_LOG_TYPE)
|
||||||
|
// {
|
||||||
|
// //CZT2LogElement *ZT2LogElement = (CZT2LogElement*) LogsList->at(row);
|
||||||
|
// CZT2LogElement *ZT2LogElement = (CZT2LogElement*) LogsList->at(ItemIndex);
|
||||||
|
|
||||||
|
// Summary.sprintf("Statistiques du passage:\n\nDate: %s\nHeure: %s\nZone Test: ZT2\nNombre d'éléments: %d\n\n\nDéclenchements: \n",
|
||||||
|
// ZT2LogElement->mPassageDateTime.toString("yyyy/MM/dd").toAscii().data(),
|
||||||
|
// ZT2LogElement->mPassageDateTime.toString("hh:mm:ss").toAscii().data(),
|
||||||
|
// ZT2LogElement->mNbElements);
|
||||||
|
|
||||||
|
// if(ZT2LogElement->mZTDetections.size() > 0)
|
||||||
|
// {
|
||||||
|
// for(int i = 0; i < ZT2LogElement->mZTDetections.size(); i++)
|
||||||
|
// {
|
||||||
|
// QString temp;
|
||||||
|
// temp.sprintf("%s au rang %d\n",CZTData::GetErrorString(ZT2LogElement->mZTDetections.at(i)->mDetectionID),ZT2LogElement->mZTDetections.at(i)->mRank);
|
||||||
|
// Summary += temp;
|
||||||
|
// if(i >= MAX_DETECTION_LIST_NBR-1)
|
||||||
|
// {
|
||||||
|
// temp = "- Autres déclenchements non affichés -";
|
||||||
|
// Summary += temp;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// Summary += "Aucun déclenchement";
|
||||||
|
|
||||||
|
// }
|
||||||
|
// mSummaryText->setPlainText(Summary);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Grab the mouse if the user clicks outside buttons
|
||||||
|
void CNetworkZTListPage::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
// qDebug("CNetworkZTListPage");
|
||||||
|
Q_UNUSED(event)
|
||||||
|
}
|
||||||
|
void CNetworkZTListPage::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkZTListPage::TableDoubleClicked(int row, int col)
|
||||||
|
{
|
||||||
|
Q_UNUSED(col)
|
||||||
|
Q_UNUSED(row)
|
||||||
|
// ButtonClicked(mViewLogDataButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkZTListPage::ZTNetworkStatusChanged(int ZTID,int Status)
|
||||||
|
{
|
||||||
|
if(ZTID >= NB_ZT_ID)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// qDebug() << "ZT Network status changed. ID: " << ZTID << "Status : " << Status;
|
||||||
|
|
||||||
|
QString ZTStatus;
|
||||||
|
QColor Color;
|
||||||
|
switch(Status)
|
||||||
|
{
|
||||||
|
case CNetworkManager::ZT_NETWORK_OFFLINE_STATUS:
|
||||||
|
{
|
||||||
|
ZTStatus = "Hors Ligne";
|
||||||
|
Color = Qt::red;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CNetworkManager::ZT_NETWORK_ONLINE_STATUS:
|
||||||
|
{
|
||||||
|
ZTStatus = "En Ligne";
|
||||||
|
Color = Qt::darkGreen;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CNetworkManager::ZT_NETWORK_SEARCHING_STATUS:
|
||||||
|
{
|
||||||
|
ZTStatus = "Recherche...";
|
||||||
|
Color = Qt::black;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CNetworkManager::ZT_NETWORK_UNKNOWN_STATUS:
|
||||||
|
{
|
||||||
|
ZTStatus = "Inconnu";
|
||||||
|
Color = Qt::black;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CNetworkManager::ZT_NETWORK_CONNECTED_STATUS:
|
||||||
|
{
|
||||||
|
ZTStatus = "Connecté";
|
||||||
|
Color = Qt::darkBlue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mZTListTable->item(ZTID,2)->setText(ZTStatus);
|
||||||
|
mZTListTable->item(ZTID,2)->setForeground(QBrush(Color));
|
||||||
|
|
||||||
|
}
|
||||||
85
sources/GuiElements/NetworkZTListPage.h
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Description du fichier si nécessaire.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131024 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NETWORKZTLISTPAGE_H
|
||||||
|
#define NETWORKZTLISTPAGE_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
#include "Guipage.h"
|
||||||
|
#include <QString>
|
||||||
|
#include "PushButton.h"
|
||||||
|
#include "TextButtonWidget.h"
|
||||||
|
#include <QTableWidget>
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include "ZTData.h"
|
||||||
|
|
||||||
|
|
||||||
|
class COutilZT;
|
||||||
|
|
||||||
|
class CNetworkZTListPage : public CGuiPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
virtual ~CNetworkZTListPage();
|
||||||
|
CNetworkZTListPage(QGraphicsWidget *Parent = 0);
|
||||||
|
|
||||||
|
|
||||||
|
COutilZT *mProgramHandle;
|
||||||
|
|
||||||
|
unsigned int RefreshList();
|
||||||
|
unsigned int SetConfig(CSettingsData *SettingsData);
|
||||||
|
int GetSelectedZT();
|
||||||
|
|
||||||
|
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||||
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
QTableWidget *mZTListTable;
|
||||||
|
|
||||||
|
void ClearTable();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void ButtonClicked(CTextButtonWidget *);
|
||||||
|
void ZTListTableCellClicked(int, int);
|
||||||
|
void ZTListTableCellSelected(int,int,int,int);
|
||||||
|
void TableDoubleClicked(int,int);
|
||||||
|
void ZTNetworkStatusChanged(int,int);
|
||||||
|
|
||||||
|
// void ParsingTimerExipred();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // NETWORKZTLISTPAGE_H
|
||||||
211
sources/GuiElements/OptionsPage.cpp
Normal file
@ -0,0 +1,211 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Page de sélection des options (sélection des fonctions de détection, ingénierie,
|
||||||
|
mode entretien, etc.).
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131021 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#include "OptionsPage.h"
|
||||||
|
#include <QPainter>
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include "OutilZT.h"
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QFont>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QTextEdit>
|
||||||
|
#include "OutilZT.h"
|
||||||
|
#include <QGraphicsProxyWidget>
|
||||||
|
#include "OutilZTVersion.h"
|
||||||
|
|
||||||
|
|
||||||
|
COptionsPage::~COptionsPage()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
COptionsPage::COptionsPage(QGraphicsWidget *Parent)
|
||||||
|
{
|
||||||
|
Q_UNUSED(Parent)
|
||||||
|
|
||||||
|
mProgramHandle = 0;
|
||||||
|
mSettings = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
mBackgroundRect = new QGraphicsRectItem(boundingRect(), this);
|
||||||
|
QBrush BackgroundBrush(QColor(245, 245, 255));
|
||||||
|
mBackgroundRect->setBrush(BackgroundBrush);
|
||||||
|
|
||||||
|
QGraphicsTextItem *Title = new QGraphicsTextItem("Options",this);
|
||||||
|
QFont font;
|
||||||
|
font.setPointSize(18);
|
||||||
|
Title->setFont(font);
|
||||||
|
Title->setPos(250,10);
|
||||||
|
|
||||||
|
QGraphicsTextItem *SoftVersion = new QGraphicsTextItem(this);
|
||||||
|
font.setPointSize(14);
|
||||||
|
SoftVersion->setFont(font);
|
||||||
|
QString VersionString = "OutilZT version: ";
|
||||||
|
VersionString += SOFTWARE_VERSION;
|
||||||
|
SoftVersion->setPlainText(VersionString);
|
||||||
|
SoftVersion->setPos(25,210);
|
||||||
|
|
||||||
|
QPixmap *FilePixmap = new QPixmap("./Images/open-file-icon.png");
|
||||||
|
mLogDataDirDialogButton = new CTextButtonWidget("Sélectionner",0,50,150,15,FilePixmap);
|
||||||
|
mLogDataDirDialogButton->setParentItem(this);
|
||||||
|
mLogDataDirDialogButton->setPos(25,100);
|
||||||
|
connect(mLogDataDirDialogButton, SIGNAL(TxtButtonClicked(CTextButtonWidget*)), this, SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||||
|
mLogDataDirDialogButton->hide();
|
||||||
|
|
||||||
|
mCancelButton = new CTextButtonWidget("Fermer");
|
||||||
|
mCancelButton->setParentItem(this);
|
||||||
|
mCancelButton->setPos(50,310);
|
||||||
|
connect(mCancelButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||||
|
|
||||||
|
font.setPointSize(12);
|
||||||
|
mLogsPathText = new QGraphicsTextItem(this);
|
||||||
|
mLogsPathText->setPlainText("Répertoire de données: ");
|
||||||
|
mLogsPathText->setFont(font);
|
||||||
|
mLogsPathText->setPos(25,65);
|
||||||
|
|
||||||
|
QGraphicsTextItem *StationName;
|
||||||
|
QLineEdit *StationIP;
|
||||||
|
QGraphicsProxyWidget *Proxy;
|
||||||
|
int xpos = 375;
|
||||||
|
int ypos = 150;
|
||||||
|
for(int i = 0; i < NB_ZT_ID; i++)
|
||||||
|
{
|
||||||
|
StationName = new QGraphicsTextItem(this);
|
||||||
|
StationName->setFont(font);
|
||||||
|
StationName->setPlainText(COutilZT::GetStationName(i));
|
||||||
|
StationName->adjustSize();
|
||||||
|
|
||||||
|
StationName->setPos(xpos-StationName->boundingRect().width(), ypos + (i*30));
|
||||||
|
|
||||||
|
StationIP = new QLineEdit("100.100.100.100");
|
||||||
|
Proxy = new QGraphicsProxyWidget(this);
|
||||||
|
Proxy->setWidget(StationIP);
|
||||||
|
// StationIP->setInputMask("000.000.000.000;");
|
||||||
|
Proxy->setPos(xpos+10,ypos +(i*30)+3);
|
||||||
|
StationIP->resize(100,20);
|
||||||
|
StationIP->setEnabled(false);
|
||||||
|
|
||||||
|
mIpAddressList.append(StationIP);
|
||||||
|
}
|
||||||
|
|
||||||
|
mApplyNetworkSettingsBtn = new CTextButtonWidget("Appliquer");
|
||||||
|
mApplyNetworkSettingsBtn->setParentItem(this);
|
||||||
|
mApplyNetworkSettingsBtn->setPos(50,260);
|
||||||
|
connect(mApplyNetworkSettingsBtn,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void COptionsPage::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
mBackgroundRect->setRect(boundingRect());
|
||||||
|
}
|
||||||
|
|
||||||
|
void COptionsPage::ButtonClicked(CTextButtonWidget *BtnPtr)
|
||||||
|
{
|
||||||
|
if(BtnPtr == mCancelButton)
|
||||||
|
{
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
else if(BtnPtr == mLogDataDirDialogButton)
|
||||||
|
{
|
||||||
|
QString DataFilePath;
|
||||||
|
DataFilePath.clear();
|
||||||
|
QFileDialog FileDlg;
|
||||||
|
FileDlg.setFileMode(QFileDialog::DirectoryOnly);
|
||||||
|
// DataFilePath = FileDlg.getOpenFileName(0,"Répertoire de données",QString(),QString(),0,QFileDialog::ShowDirsOnly);
|
||||||
|
DataFilePath = FileDlg.getExistingDirectory(0,"Répertoire de données");
|
||||||
|
|
||||||
|
if(DataFilePath.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
qDebug("open file %s",DataFilePath.toAscii().data());
|
||||||
|
mProgramHandle->DataSourceDirChanged(DataFilePath);
|
||||||
|
QString tmp = "Répertoire de données: ";
|
||||||
|
tmp += mProgramHandle->GetLogDataPath();
|
||||||
|
mLogsPathText->setPlainText(tmp);
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(BtnPtr == mApplyNetworkSettingsBtn)
|
||||||
|
{
|
||||||
|
if(mSettings == 0)
|
||||||
|
return;
|
||||||
|
for(int i = 0; i < mSettings->mNetworkCfgList.size(); i++)
|
||||||
|
{
|
||||||
|
mSettings->mNetworkCfgList[i].mIPAdress = mIpAddressList.at(i)->text();
|
||||||
|
}
|
||||||
|
mProgramHandle->NetworkDataChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void COptionsPage::SetLogsDataPath(QString Path)
|
||||||
|
{
|
||||||
|
mLogsPathText->setPlainText(Path);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COptionsPage::SetSettings(CSettingsData *SettingsData)
|
||||||
|
{
|
||||||
|
mSettings = SettingsData;
|
||||||
|
mLogsPathText->setPlainText(SettingsData->mDataSourceDirectoryPath);
|
||||||
|
|
||||||
|
if(SettingsData->mNetworkCfgList.size() != mIpAddressList.size())
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
for(int i = 0; i < mIpAddressList.size(); i++)
|
||||||
|
{
|
||||||
|
mIpAddressList.at(i)->setText(SettingsData->mNetworkCfgList.at(i).mIPAdress);
|
||||||
|
}
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void COptionsPage::EnableEngineeringMode()
|
||||||
|
{
|
||||||
|
mLogDataDirDialogButton->show();
|
||||||
|
|
||||||
|
for(int i = 0; i < mIpAddressList.size(); i++)
|
||||||
|
{
|
||||||
|
mIpAddressList.at(i)->setEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Grab the mouse if the user clicks outside buttons
|
||||||
|
void COptionsPage::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
// qDebug("COptionsPage");
|
||||||
|
Q_UNUSED(event)
|
||||||
|
}
|
||||||
|
void COptionsPage::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
}
|
||||||
83
sources/GuiElements/OptionsPage.h
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Description du fichier si nécessaire.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131021 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef OPTIONSPAGE_H
|
||||||
|
#define OPTIONSPAGE_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
#include "Guipage.h"
|
||||||
|
#include <QString>
|
||||||
|
#include "PushButton.h"
|
||||||
|
#include "TextButtonWidget.h"
|
||||||
|
#include "ZTData.h"
|
||||||
|
#include "QLineEdit"
|
||||||
|
|
||||||
|
class COutilZT;
|
||||||
|
|
||||||
|
class COptionsPage : public CGuiPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
COptionsPage(QGraphicsWidget *Parent = 0);
|
||||||
|
~COptionsPage();
|
||||||
|
CPushButton *mToolsPushButton;
|
||||||
|
|
||||||
|
|
||||||
|
COutilZT *mProgramHandle;
|
||||||
|
|
||||||
|
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||||
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
|
void SetLogsDataPath(QString Path);
|
||||||
|
|
||||||
|
unsigned int SetSettings(CSettingsData *SettingsData);
|
||||||
|
void EnableEngineeringMode();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
QGraphicsRectItem *mBackgroundRect;
|
||||||
|
CTextButtonWidget *mLogDataDirDialogButton;
|
||||||
|
CTextButtonWidget *mCancelButton;
|
||||||
|
CTextButtonWidget *mApplyNetworkSettingsBtn;
|
||||||
|
|
||||||
|
QGraphicsTextItem *mLogsPathText;
|
||||||
|
|
||||||
|
QList<QLineEdit*> mIpAddressList;
|
||||||
|
CSettingsData *mSettings;
|
||||||
|
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void ButtonClicked(CTextButtonWidget *);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // OPTIONSPAGE_H
|
||||||
118
sources/GuiElements/ProgressBarPage.cpp
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Page de sélection des options (sélection des fonctions de détection, ingénierie,
|
||||||
|
mode entretien, etc.).
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131021 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include "ProgressBarPage.h"
|
||||||
|
#include <QGraphicsProxyWidget>
|
||||||
|
|
||||||
|
|
||||||
|
CProgressBarPage::~CProgressBarPage()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
CProgressBarPage::CProgressBarPage(QGraphicsWidget *Parent)
|
||||||
|
{
|
||||||
|
Q_UNUSED(Parent)
|
||||||
|
resize(400,100);
|
||||||
|
|
||||||
|
mBackgroundRect = new QGraphicsRectItem(boundingRect(), this);
|
||||||
|
QBrush BackgroundBrush(QColor(245, 245, 255));
|
||||||
|
mBackgroundRect->setBrush(BackgroundBrush);
|
||||||
|
|
||||||
|
mTitle = new QGraphicsTextItem("Title",this);
|
||||||
|
QFont font;
|
||||||
|
font.setPointSize(15);
|
||||||
|
mTitle->setFont(font);
|
||||||
|
mTitle->setPos(10,2);
|
||||||
|
|
||||||
|
font.setPointSize(10);
|
||||||
|
mMiscLabel = new QGraphicsTextItem(this);
|
||||||
|
mMiscLabel->setPlainText("MiscLabel");
|
||||||
|
mMiscLabel->setFont(font);
|
||||||
|
mMiscLabel->setPos(10,50);
|
||||||
|
|
||||||
|
mProgressBar = new QProgressBar();
|
||||||
|
QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this);
|
||||||
|
proxy->setWidget(mProgressBar);
|
||||||
|
proxy->setPos(10,30);
|
||||||
|
mProgressBar->resize(390,20);
|
||||||
|
|
||||||
|
SetProgressBarRange(100);
|
||||||
|
mProgressBar->setValue(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CProgressBarPage::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
// mBackgroundRect->setRect(boundingRect());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CProgressBarPage::SetProgressBarRange(int range)
|
||||||
|
{
|
||||||
|
mProgressBar->setRange(0,range);
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CProgressBarPage::Tick()
|
||||||
|
{
|
||||||
|
mCurValue++;
|
||||||
|
mProgressBar->setValue(mCurValue);
|
||||||
|
mProgressBar->update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CProgressBarPage::Reset()
|
||||||
|
{
|
||||||
|
mCurValue = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CProgressBarPage::SetMiscLabel(QString Label)
|
||||||
|
{
|
||||||
|
mMiscLabel->setPlainText(Label);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CProgressBarPage::ClearMiscLabel()
|
||||||
|
{
|
||||||
|
mMiscLabel->setPlainText("");
|
||||||
|
}
|
||||||
|
|
||||||
|
void CProgressBarPage::SetTitle(QString Title)
|
||||||
|
{
|
||||||
|
mTitle->setPlainText(Title);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Grab the mouse if the user clicks outside buttons
|
||||||
|
void CProgressBarPage::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
}
|
||||||
|
void CProgressBarPage::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
}
|
||||||
78
sources/GuiElements/ProgressBarPage.h
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Description du fichier si nécessaire.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131021 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef PROGRESSBARPAGE_H
|
||||||
|
#define PROGRESSBARPAGE_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
#include "Guipage.h"
|
||||||
|
#include <QString>
|
||||||
|
#include <QProgressBar>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//class COutilZT;
|
||||||
|
|
||||||
|
class CProgressBarPage : public CGuiPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CProgressBarPage(QGraphicsWidget *Parent = 0);
|
||||||
|
~CProgressBarPage();
|
||||||
|
|
||||||
|
// COutilZT *mProgramHandle;
|
||||||
|
|
||||||
|
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||||
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
|
void SetProgressBarRange(int range);
|
||||||
|
void Tick();
|
||||||
|
void Reset();
|
||||||
|
void SetMiscLabel(QString Label);
|
||||||
|
void ClearMiscLabel();
|
||||||
|
void SetTitle(QString Title);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
QGraphicsRectItem *mBackgroundRect;
|
||||||
|
QGraphicsTextItem *mMiscLabel, *mTitle;
|
||||||
|
QProgressBar *mProgressBar;
|
||||||
|
int mCurValue;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
// void ButtonClicked(CTextButtonWidget *);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PROGRESSBARPAGE_H
|
||||||
258
sources/GuiElements/PushButton.cpp
Normal file
@ -0,0 +1,258 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2013 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Widget graphique Bouton qui consiste en une image sur laquelle l'on peut
|
||||||
|
cliquer.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20130204 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "PushButton.h"
|
||||||
|
#include <QPixmap>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QBitmap>
|
||||||
|
#include <QColor>
|
||||||
|
#include <QGraphicsPixmapItem>
|
||||||
|
|
||||||
|
CPushButton::CPushButton(QGraphicsItem *Parent,QString NormalFileName, bool UseTextOverlay,int ButtonData)
|
||||||
|
{
|
||||||
|
Q_UNUSED(ButtonData)
|
||||||
|
setParentItem(Parent);
|
||||||
|
|
||||||
|
setAcceptHoverEvents(true);
|
||||||
|
|
||||||
|
m_Normal = new QGraphicsPixmapItem(QPixmap(NormalFileName));
|
||||||
|
|
||||||
|
ClickTransparency = 1;
|
||||||
|
|
||||||
|
//Inform QGraphicsItem of the geometry
|
||||||
|
setGeometry(m_Normal->boundingRect());
|
||||||
|
|
||||||
|
ispressed = false;
|
||||||
|
isFlashingValid = false;
|
||||||
|
mDisplayFlashIcon = false;
|
||||||
|
isreleasing = false;
|
||||||
|
UseOverlay = UseTextOverlay;
|
||||||
|
ButtonTextOverlay = "";
|
||||||
|
|
||||||
|
|
||||||
|
timeLine = new QTimeLine(PRESS_EFFECT_FADE_TIMEOUT);
|
||||||
|
timeLine->setCurveShape(QTimeLine::EaseInCurve);
|
||||||
|
connect(timeLine, SIGNAL(valueChanged(qreal)), this, SLOT(TimeLine(qreal)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CPushButton::~CPushButton()
|
||||||
|
{
|
||||||
|
delete m_Normal;
|
||||||
|
delete timeLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPushButton::paint(QPainter *Painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Painter->setCompositionMode(QPainter::CompositionMode_DestinationOver);
|
||||||
|
/*if(isDown() || isChecked())
|
||||||
|
{
|
||||||
|
m_Normal->paint(Painter,option,widget);
|
||||||
|
qDebug("Paint Called, button down");
|
||||||
|
}
|
||||||
|
else if(underMouse())
|
||||||
|
{
|
||||||
|
m_Hovered->paint(Painter,option,widget);
|
||||||
|
qDebug("Paint Called, hovered");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_Pressed->paint(Painter,option,widget);
|
||||||
|
qDebug("Paint Called, normal");
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
if(ispressed)
|
||||||
|
{
|
||||||
|
|
||||||
|
//QRadialGradient gradient(50, 50, 50, 50, 50);
|
||||||
|
QRadialGradient gradient(m_Normal->boundingRect().center(),m_Normal->boundingRect().width()/2);
|
||||||
|
gradient.setColorAt(0, QColor::fromRgbF(1, 1, 1,1));
|
||||||
|
gradient.setColorAt(1, QColor::fromRgbF(1, 1, 1,0));
|
||||||
|
|
||||||
|
QBrush brush(gradient);
|
||||||
|
// m_Pressed->paint(Painter,option,widget);
|
||||||
|
m_Normal->paint(Painter,option,widget);
|
||||||
|
Painter->setBrush(brush);
|
||||||
|
Painter->setPen(Qt::NoPen);
|
||||||
|
//Painter->drawEllipse(m_Normal->boundingRect());
|
||||||
|
Painter->drawEllipse(m_Normal->boundingRect());
|
||||||
|
|
||||||
|
//qDebug("Paint Called, pressed");
|
||||||
|
}
|
||||||
|
/* else if(ishovered)
|
||||||
|
{
|
||||||
|
m_Hovered->paint(Painter,option,widget);
|
||||||
|
// qDebug("Paint Called, hovered");
|
||||||
|
}*/
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(mDisplayFlashIcon)
|
||||||
|
{
|
||||||
|
m_Flashing->paint(Painter,option,widget);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
//draw button icon
|
||||||
|
m_Normal->paint(Painter,option,widget);
|
||||||
|
|
||||||
|
//draw text overlay
|
||||||
|
QRectF textRect = m_Normal->boundingRect();//.adjusted(15, 10, -10, -15);
|
||||||
|
int flags = Qt::AlignHCenter | Qt::AlignVCenter;
|
||||||
|
|
||||||
|
QFont font;
|
||||||
|
font.setPixelSize(16);
|
||||||
|
font.setBold(true);
|
||||||
|
Painter->setPen(Qt::red);
|
||||||
|
Painter->setFont(font);
|
||||||
|
Painter->drawText(textRect, flags, ButtonTextOverlay);
|
||||||
|
|
||||||
|
//if necessary, draw halo animation
|
||||||
|
if(isreleasing)
|
||||||
|
{
|
||||||
|
//QRadialGradient gradient(50, 50, 50, 50, 50);
|
||||||
|
QRadialGradient gradient(m_Normal->boundingRect().center(),m_Normal->boundingRect().width()/2);
|
||||||
|
gradient.setColorAt(0, QColor::fromRgbF(1, 1, 1,ClickTransparency));
|
||||||
|
gradient.setColorAt(1, QColor::fromRgbF(1, 1, 1, 0));
|
||||||
|
|
||||||
|
QBrush brush(gradient);
|
||||||
|
// m_Pressed->paint(Painter,option,widget);
|
||||||
|
m_Normal->paint(Painter,option,widget);
|
||||||
|
Painter->setBrush(brush);
|
||||||
|
Painter->setPen(Qt::NoPen);
|
||||||
|
//Painter->drawEllipse(m_Normal->boundingRect());
|
||||||
|
Painter->drawEllipse(m_Normal->boundingRect());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// qDebug("Paint Called, normal");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPushButton::hoverEnterEvent ( QGraphicsSceneHoverEvent * event )
|
||||||
|
{
|
||||||
|
event->accept();
|
||||||
|
update();
|
||||||
|
// qDebug("Hover Enter Called");
|
||||||
|
}
|
||||||
|
void CPushButton::hoverLeaveEvent ( QGraphicsSceneHoverEvent * event )
|
||||||
|
{
|
||||||
|
event->accept();
|
||||||
|
update();
|
||||||
|
// qDebug("Hover Leave Called");
|
||||||
|
}
|
||||||
|
void CPushButton::mousePressEvent ( QGraphicsSceneMouseEvent * event )
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
//
|
||||||
|
ispressed = true;
|
||||||
|
update();
|
||||||
|
emit pressed(this);
|
||||||
|
|
||||||
|
|
||||||
|
// qDebug("Mouse Press Event");
|
||||||
|
//event->ignore();
|
||||||
|
|
||||||
|
}
|
||||||
|
void CPushButton::mouseReleaseEvent( QGraphicsSceneMouseEvent * event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
ispressed = false;
|
||||||
|
|
||||||
|
emit released(this);
|
||||||
|
isreleasing = true;
|
||||||
|
|
||||||
|
timeLine->start();
|
||||||
|
// qDebug("Button Mouse Release Event");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPushButton::StartFlashing()
|
||||||
|
{
|
||||||
|
mFlashTimer->start(mFlashTimeout);
|
||||||
|
}
|
||||||
|
void CPushButton::StopFlashing()
|
||||||
|
{
|
||||||
|
mFlashTimer->stop();
|
||||||
|
mDisplayFlashIcon = false;
|
||||||
|
}
|
||||||
|
void CPushButton::setFlashingData(QString FlashFileName,int FlashDelay)
|
||||||
|
{
|
||||||
|
QPixmap temp(FlashFileName);
|
||||||
|
QBitmap temp2 = temp.createMaskFromColor(QColor(255,255,255),Qt::MaskOutColor);
|
||||||
|
// temp.setMask(temp2);
|
||||||
|
m_Flashing = new QGraphicsPixmapItem(temp);
|
||||||
|
if(!m_Flashing)
|
||||||
|
{
|
||||||
|
isFlashingValid = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isFlashingValid = true;
|
||||||
|
mFlashTimeout = FlashDelay;
|
||||||
|
mFlashTimer = new QTimer(this);
|
||||||
|
connect(mFlashTimer,SIGNAL(timeout()),this,SLOT(FlashButton()));
|
||||||
|
|
||||||
|
}
|
||||||
|
void CPushButton::FlashButton()
|
||||||
|
{
|
||||||
|
mDisplayFlashIcon = !mDisplayFlashIcon;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPushButton::TimeLine(qreal value)
|
||||||
|
{
|
||||||
|
ClickTransparency = 1-value;
|
||||||
|
|
||||||
|
update();
|
||||||
|
|
||||||
|
if(value == 1)
|
||||||
|
{
|
||||||
|
isreleasing = false;
|
||||||
|
emit clicked(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPushButton::SetTextOverlay(QString Text)
|
||||||
|
{
|
||||||
|
ButtonTextOverlay = Text.left(MAX_OVERLAY_TEXT_LENGTH);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPushButton::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||||
|
{
|
||||||
|
m_Normal->setPixmap(m_Normal->pixmap().scaled(event->newSize().width(),event->newSize().height()));
|
||||||
|
this->resize(event->newSize().width(),event->newSize().height());
|
||||||
|
}
|
||||||
77
sources/GuiElements/PushButton.h
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
#ifndef PUSHBUTTON_H
|
||||||
|
#define PUSHBUTTON_H
|
||||||
|
|
||||||
|
//#include <QAbstractButton>
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
#include <QGraphicsSceneHoverEvent>
|
||||||
|
#include <QGraphicsItem>
|
||||||
|
class QGraphicsPixmapItem;
|
||||||
|
#include <QObject>
|
||||||
|
#include <QtCore/qtimeline.h>
|
||||||
|
|
||||||
|
class QTimer;
|
||||||
|
|
||||||
|
#define PRESS_EFFECT_FADE_TIMEOUT 200
|
||||||
|
#define MAX_OVERLAY_TEXT_LENGTH 3
|
||||||
|
|
||||||
|
class CPushButton : public QGraphicsWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CPushButton(QGraphicsItem *Parent, QString NormalFileName,bool UseTextOverlay = false, int ButtonData = 0);
|
||||||
|
virtual ~CPushButton();
|
||||||
|
|
||||||
|
void setFlashingData(QString FlashingFileName,int FlashingDelay);
|
||||||
|
void StartFlashing(void);
|
||||||
|
void StopFlashing(void);
|
||||||
|
void SetTextOverlay(QString Text);
|
||||||
|
void SetButtonData(unsigned long int ButtonData){mButtonData = ButtonData;}
|
||||||
|
unsigned long int GetBUttonData(){return mButtonData;}
|
||||||
|
|
||||||
|
|
||||||
|
void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
|
||||||
|
// QRectF boundingRect() const;
|
||||||
|
|
||||||
|
bool ispressed;
|
||||||
|
bool isreleasing;
|
||||||
|
bool isFlashingValid;
|
||||||
|
bool mDisplayFlashIcon;
|
||||||
|
bool UseOverlay;
|
||||||
|
QTimer *mFlashTimer;
|
||||||
|
int mFlashTimeout;
|
||||||
|
QString ButtonTextOverlay;
|
||||||
|
unsigned long int mButtonData;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//virtual void paintEvent(QPaintEvent *e);
|
||||||
|
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
|
||||||
|
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
|
||||||
|
virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
|
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event);
|
||||||
|
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QTimeLine *timeLine;
|
||||||
|
qreal ClickTransparency;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void clicked(CPushButton *ButtonPtr);
|
||||||
|
void pressed(CPushButton *ButtonPtr);
|
||||||
|
void released(CPushButton *ButtonPtr);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void FlashButton();
|
||||||
|
void TimeLine(qreal value);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QGraphicsPixmapItem *m_Normal;
|
||||||
|
QGraphicsPixmapItem *m_Pressed;
|
||||||
|
QGraphicsPixmapItem *m_Hovered;
|
||||||
|
QGraphicsPixmapItem *m_Flashing;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PUSHBUTTON_H
|
||||||
293
sources/GuiElements/RankRulerWidget.cpp
Normal file
@ -0,0 +1,293 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 - 2013 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Élément graphique qui affiche une règle qui indique le décompte des rangs
|
||||||
|
du train dans le temps. Ce qui permet de savoir à quel rang un événement
|
||||||
|
est survenu lors de la consultation d'un passage de train.
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### YYYMMDD JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "RankRulerWidget.h"
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QTextStream>
|
||||||
|
#include <QStyleOptionGraphicsItem>
|
||||||
|
|
||||||
|
CRankRulerWidget::~CRankRulerWidget()
|
||||||
|
{
|
||||||
|
delete mRulerPixmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
CRankRulerWidget::CRankRulerWidget(qreal RulerPixelWidth, QGraphicsItem *Parent)
|
||||||
|
{
|
||||||
|
setParentItem(Parent);
|
||||||
|
mPixelWidth = RulerPixelWidth;
|
||||||
|
mLabel = new QGraphicsTextItem(this);
|
||||||
|
|
||||||
|
mRulerPixmap = new QPixmap(boundingRect().width(),boundingRect().height());
|
||||||
|
// mRulerPixmap->fill(Qt::white);
|
||||||
|
mRankItems.clear();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRankRulerWidget::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
|
||||||
|
delete mRulerPixmap;
|
||||||
|
mRulerPixmap = new QPixmap(boundingRect().width(),boundingRect().height());
|
||||||
|
Render();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRankRulerWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
{
|
||||||
|
Q_UNUSED(widget)
|
||||||
|
|
||||||
|
if(mRankItems.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
painter->setClipRect(option->exposedRect);
|
||||||
|
painter->drawPixmap(0,0,*mRulerPixmap);
|
||||||
|
|
||||||
|
// if(mRankItems.isEmpty())
|
||||||
|
// return;
|
||||||
|
// QFont font;
|
||||||
|
// font.setPixelSize(12);
|
||||||
|
// painter->setFont(font);
|
||||||
|
// qreal pitch = mPixelWidth/(mEndTime - mStartTime); //pixel/ns
|
||||||
|
|
||||||
|
// int StartIndex = 0,EndIndex = 0;
|
||||||
|
// bool StartFound = false;
|
||||||
|
|
||||||
|
// for(int i = 0; i < mRankItems.size(); i++)
|
||||||
|
// {
|
||||||
|
// if(StartFound == false)
|
||||||
|
// {
|
||||||
|
// if(mStartTime <= mRankItems.at(i).mStartTime)
|
||||||
|
// {
|
||||||
|
// StartIndex = i;
|
||||||
|
// StartFound = true;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if(mRankItems.at(i).mEndTime <= mEndTime)
|
||||||
|
// {
|
||||||
|
// EndIndex = i;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if(StartIndex > 0)
|
||||||
|
// {
|
||||||
|
// if(mStartTime < mRankItems.at(StartIndex).mStartTime)
|
||||||
|
// {
|
||||||
|
// QRectF LabelRect;
|
||||||
|
// qreal StartPixel = 0;//mStartTime * pitch;
|
||||||
|
// qreal EndPixel = (mRankItems.at(StartIndex).mStartTime - mStartTime) * pitch;
|
||||||
|
// qreal Height = boundingRect().height();
|
||||||
|
|
||||||
|
// LabelRect.setRect(StartPixel,0,(EndPixel-StartPixel),Height);
|
||||||
|
// painter->drawLine(StartPixel,0,StartPixel,Height);
|
||||||
|
// painter->drawLine(EndPixel,0,EndPixel,Height);
|
||||||
|
// painter->drawText(LabelRect,mRankItems.at(StartIndex-1).mLabel,Qt::AlignHCenter | Qt::AlignVCenter);
|
||||||
|
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// for(int i = StartIndex; i <= EndIndex; i++)
|
||||||
|
// {
|
||||||
|
// QRectF LabelRect;
|
||||||
|
// qreal StartPixel = (mRankItems.at(i).mStartTime - mStartTime) * pitch;
|
||||||
|
|
||||||
|
// qreal EndPixel;
|
||||||
|
// if(mRankItems.at(i).mEndTime > mEndTime)
|
||||||
|
// EndPixel = (mEndTime - mStartTime) * pitch;
|
||||||
|
// else
|
||||||
|
// EndPixel = (mRankItems.at(i).mEndTime - mStartTime) * pitch;
|
||||||
|
|
||||||
|
// qreal Height = boundingRect().height();
|
||||||
|
|
||||||
|
// LabelRect.setRect(StartPixel,0,(EndPixel-StartPixel),Height);
|
||||||
|
// painter->drawLine(StartPixel,0,StartPixel,Height);
|
||||||
|
// painter->drawLine(EndPixel,0,EndPixel,Height);
|
||||||
|
// painter->drawText(LabelRect,mRankItems.at(i).mLabel,Qt::AlignHCenter | Qt::AlignVCenter);
|
||||||
|
// }
|
||||||
|
// if(EndIndex < mRankItems.size()-1)
|
||||||
|
// {
|
||||||
|
// if(mEndTime > mRankItems.at(EndIndex).mStartTime)
|
||||||
|
// {
|
||||||
|
// QRectF LabelRect;
|
||||||
|
// qreal StartPixel = (mRankItems.at(EndIndex).mEndTime - mStartTime) * pitch;
|
||||||
|
// qreal EndPixel = (mEndTime - mStartTime) * pitch;
|
||||||
|
// qreal Height = boundingRect().height();
|
||||||
|
|
||||||
|
// LabelRect.setRect(StartPixel,0,(EndPixel-StartPixel),Height);
|
||||||
|
// painter->drawLine(StartPixel,0,StartPixel,Height);
|
||||||
|
// painter->drawLine(EndPixel,0,EndPixel,Height);
|
||||||
|
//// if(EndIndex == StartIndex)
|
||||||
|
//// painter->drawText(LabelRect,mRankItems.at(EndIndex).mLabel,Qt::AlignHCenter | Qt::AlignVCenter);
|
||||||
|
//// else
|
||||||
|
// painter->drawText(LabelRect,mRankItems.at(EndIndex+1).mLabel,Qt::AlignHCenter | Qt::AlignVCenter);
|
||||||
|
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRankRulerWidget::Render()
|
||||||
|
{
|
||||||
|
|
||||||
|
if(mRankItems.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
mRulerPixmap->fill(Qt::white);
|
||||||
|
QPainter *painter = new QPainter(mRulerPixmap);
|
||||||
|
|
||||||
|
QFont font;
|
||||||
|
font.setPixelSize(12);
|
||||||
|
painter->setFont(font);
|
||||||
|
qreal pitch = mPixelWidth/(mEndTime - mStartTime); //pixel/ns
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int StartIndex = 0,EndIndex = 0;
|
||||||
|
bool StartFound = false;
|
||||||
|
|
||||||
|
for(int i = 0; i < mRankItems.size(); i++)
|
||||||
|
{
|
||||||
|
if(StartFound == false)
|
||||||
|
{
|
||||||
|
if(mStartTime <= mRankItems.at(i).mStartTime)
|
||||||
|
{
|
||||||
|
StartIndex = i;
|
||||||
|
StartFound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mRankItems.at(i).mEndTime <= mEndTime)
|
||||||
|
{
|
||||||
|
EndIndex = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(StartIndex > 0)
|
||||||
|
{
|
||||||
|
if(mStartTime < mRankItems.at(StartIndex).mStartTime)
|
||||||
|
{
|
||||||
|
QRectF LabelRect;
|
||||||
|
qreal StartPixel = 0;//mStartTime * pitch;
|
||||||
|
qreal EndPixel = (mRankItems.at(StartIndex).mStartTime - mStartTime) * pitch;
|
||||||
|
qreal Height = boundingRect().height();
|
||||||
|
|
||||||
|
LabelRect.setRect(StartPixel,0,(EndPixel-StartPixel),Height);
|
||||||
|
painter->drawLine(StartPixel,0,StartPixel,Height);
|
||||||
|
painter->drawLine(EndPixel,0,EndPixel,Height);
|
||||||
|
painter->drawText(LabelRect,mRankItems.at(StartIndex-1).mLabel,Qt::AlignHCenter | Qt::AlignVCenter);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = StartIndex; i <= EndIndex; i++)
|
||||||
|
{
|
||||||
|
QRectF LabelRect;
|
||||||
|
qreal StartPixel = (mRankItems.at(i).mStartTime - mStartTime) * pitch;
|
||||||
|
|
||||||
|
qreal EndPixel;
|
||||||
|
if(mRankItems.at(i).mEndTime > mEndTime)
|
||||||
|
EndPixel = (mEndTime - mStartTime) * pitch;
|
||||||
|
else
|
||||||
|
EndPixel = (mRankItems.at(i).mEndTime - mStartTime) * pitch;
|
||||||
|
|
||||||
|
qreal Height = boundingRect().height();
|
||||||
|
|
||||||
|
LabelRect.setRect(StartPixel,0,(EndPixel-StartPixel),Height);
|
||||||
|
painter->drawLine(StartPixel,0,StartPixel,Height);
|
||||||
|
painter->drawLine(EndPixel,0,EndPixel,Height);
|
||||||
|
painter->drawText(LabelRect,mRankItems.at(i).mLabel,Qt::AlignHCenter | Qt::AlignVCenter);
|
||||||
|
}
|
||||||
|
if(EndIndex < mRankItems.size()-1)
|
||||||
|
{
|
||||||
|
if(mEndTime > mRankItems.at(EndIndex).mStartTime)
|
||||||
|
{
|
||||||
|
QRectF LabelRect;
|
||||||
|
qreal StartPixel = (mRankItems.at(EndIndex).mEndTime - mStartTime) * pitch;
|
||||||
|
qreal EndPixel = (mEndTime - mStartTime) * pitch;
|
||||||
|
qreal Height = boundingRect().height();
|
||||||
|
|
||||||
|
LabelRect.setRect(StartPixel,0,(EndPixel-StartPixel),Height);
|
||||||
|
painter->drawLine(StartPixel,0,StartPixel,Height);
|
||||||
|
painter->drawLine(EndPixel,0,EndPixel,Height);
|
||||||
|
// if(EndIndex == StartIndex)
|
||||||
|
// painter->drawText(LabelRect,mRankItems.at(EndIndex).mLabel,Qt::AlignHCenter | Qt::AlignVCenter);
|
||||||
|
// else
|
||||||
|
painter->drawText(LabelRect,mRankItems.at(EndIndex+1).mLabel,Qt::AlignHCenter | Qt::AlignVCenter);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delete painter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int CRankRulerWidget::SetRange(quint64 StartTime, quint64 EndTime)
|
||||||
|
{
|
||||||
|
if(StartTime > EndTime)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(mRankItems.isEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
mStartTime = StartTime;
|
||||||
|
mEndTime = EndTime;
|
||||||
|
mTimeOffset = mRankItems.first().mStartTime;
|
||||||
|
|
||||||
|
Render();
|
||||||
|
|
||||||
|
update();
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CRankRulerWidget::AddRankItem(QString Rank, quint64 StartTime, quint64 EndTime)
|
||||||
|
{
|
||||||
|
CRankWidgetItem NewItem;
|
||||||
|
NewItem.mLabel = Rank;
|
||||||
|
NewItem.mStartTime = StartTime;
|
||||||
|
NewItem.mEndTime = EndTime;
|
||||||
|
|
||||||
|
mRankItems.append(NewItem);
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRankRulerWidget::SetLabel(QString Label, int Offset)
|
||||||
|
{
|
||||||
|
QFont font;
|
||||||
|
font.setBold(true);
|
||||||
|
mLabel->setFont(font);
|
||||||
|
mLabel->setPlainText(Label);
|
||||||
|
mLabel->setPos(-Offset,boundingRect().height()/2 - mLabel->boundingRect().height()/2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRankRulerWidget::ClearRuler()
|
||||||
|
{
|
||||||
|
mRankItems.clear();
|
||||||
|
}
|
||||||
74
sources/GuiElements/RankRulerWidget.h
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 - 2013 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Description du fichier si nécessaire.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131030 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### 20131107 Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef RANKRULERWIDGET_H
|
||||||
|
#define RANKRULERWIDGET_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
|
||||||
|
class CRankWidgetItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QString mLabel;
|
||||||
|
quint64 mStartTime;
|
||||||
|
quint64 mEndTime;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CRankRulerWidget : public QGraphicsWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CRankRulerWidget(qreal RulerPixelWidth,QGraphicsItem *Parent = 0);
|
||||||
|
~CRankRulerWidget();
|
||||||
|
|
||||||
|
|
||||||
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
|
||||||
|
unsigned int SetRange(quint64 StartTime, quint64 EndTime);
|
||||||
|
unsigned int AddRankItem(QString Rank,quint64 StartTime,quint64 EndTime);
|
||||||
|
void SetLabel(QString Label,int Offset);
|
||||||
|
void ClearRuler();
|
||||||
|
void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
qreal mPixelWidth;
|
||||||
|
quint64 mStartTime, mEndTime, mTimeOffset;
|
||||||
|
qreal mPixelPitch;
|
||||||
|
QGraphicsTextItem *mLabel;
|
||||||
|
|
||||||
|
QPixmap *mRulerPixmap;
|
||||||
|
|
||||||
|
QList<CRankWidgetItem> mRankItems;
|
||||||
|
|
||||||
|
|
||||||
|
void Render();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // RANKRULERWIDGET_H
|
||||||
395
sources/GuiElements/RemoteZTCtrlPage.cpp
Normal file
@ -0,0 +1,395 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Page affichant la liste des passages de train.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131021 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#include "RemoteZTCtrlPage.h"
|
||||||
|
#include <QGraphicsProxyWidget>
|
||||||
|
#include "OutilZT.h"
|
||||||
|
#include <QString>
|
||||||
|
#include <QTextCodec>
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include <QTextStream>
|
||||||
|
#include "TCPProtocol.h"
|
||||||
|
|
||||||
|
|
||||||
|
CRemoteZTCtrlPage::~CRemoteZTCtrlPage()
|
||||||
|
{
|
||||||
|
// delete mListParsingTimer;
|
||||||
|
}
|
||||||
|
|
||||||
|
CRemoteZTCtrlPage::CRemoteZTCtrlPage(QGraphicsWidget *Parent)
|
||||||
|
{
|
||||||
|
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
|
||||||
|
setParentItem(Parent);
|
||||||
|
mProgramHandle = 0;
|
||||||
|
|
||||||
|
|
||||||
|
mDeleteLogFile = new CTextButtonWidget("Effacer fichier LOG");
|
||||||
|
mDeleteLogFile->setParentItem(this);
|
||||||
|
mDeleteLogFile->setPos(10,10);
|
||||||
|
connect(mDeleteLogFile,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||||
|
|
||||||
|
mSetZTFunctionsBtn = new CTextButtonWidget("Envoyer Config");
|
||||||
|
mSetZTFunctionsBtn->setParentItem(this);
|
||||||
|
mSetZTFunctionsBtn->setPos(10,50);
|
||||||
|
connect(mSetZTFunctionsBtn,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||||
|
|
||||||
|
QFont font;
|
||||||
|
QPointF ArrayTopLeft;
|
||||||
|
ArrayTopLeft.setX(250);
|
||||||
|
ArrayTopLeft.setY(100);
|
||||||
|
qreal XButtonSpacing = 90;
|
||||||
|
qreal YLineSpacing = 40;
|
||||||
|
QString ONPixmapFilePath = "./Images/Slider_Green.png";
|
||||||
|
QString OFFPixmapFilePath = "./Images/Slider_Red.png";
|
||||||
|
QSizeF SlideButtonSize(50,30);
|
||||||
|
font.setPointSize(12);
|
||||||
|
|
||||||
|
|
||||||
|
QGraphicsTextItem *Label = new QGraphicsTextItem("Analyse",this);
|
||||||
|
Label->setFont(font);
|
||||||
|
Label->setPos(ArrayTopLeft.x() - 10,ArrayTopLeft.y() - YLineSpacing);
|
||||||
|
|
||||||
|
Label = new QGraphicsTextItem("TK",this);
|
||||||
|
Label->setFont(font);
|
||||||
|
Label->setPos(ArrayTopLeft.x() + XButtonSpacing +5 ,ArrayTopLeft.y() - YLineSpacing);
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
Label = new QGraphicsTextItem("Frotteur Négatif:",this);
|
||||||
|
Label->setFont(font);
|
||||||
|
Label->setPos(35,ArrayTopLeft.y() + (i*YLineSpacing));
|
||||||
|
mFNFuncToggleBtn = new CToggleButtonWidget(ONPixmapFilePath,OFFPixmapFilePath,this);
|
||||||
|
mFNFuncToggleBtn->resize(SlideButtonSize);
|
||||||
|
mFNFuncToggleBtn->setPos(ArrayTopLeft.x(),ArrayTopLeft.y() + (i*YLineSpacing));
|
||||||
|
mFNTKToggleBtn = new CToggleButtonWidget(ONPixmapFilePath,OFFPixmapFilePath,this);
|
||||||
|
mFNTKToggleBtn->resize(SlideButtonSize);
|
||||||
|
mFNTKToggleBtn->setPos(ArrayTopLeft.x() + XButtonSpacing,ArrayTopLeft.y() + (i*YLineSpacing));
|
||||||
|
|
||||||
|
i++;
|
||||||
|
Label = new QGraphicsTextItem("Pneu de guidage:",this);
|
||||||
|
Label->setFont(font);
|
||||||
|
Label->setPos(35,ArrayTopLeft.y() + (i*YLineSpacing));
|
||||||
|
mPGFuncToggleBtn = new CToggleButtonWidget(ONPixmapFilePath,OFFPixmapFilePath,this);
|
||||||
|
mPGFuncToggleBtn->resize(SlideButtonSize);
|
||||||
|
mPGFuncToggleBtn->setPos(ArrayTopLeft.x(),ArrayTopLeft.y() + (i*YLineSpacing));
|
||||||
|
mPGTKToggleBtn = new CToggleButtonWidget(ONPixmapFilePath,OFFPixmapFilePath,this);
|
||||||
|
mPGTKToggleBtn->resize(SlideButtonSize);
|
||||||
|
mPGTKToggleBtn->setPos(ArrayTopLeft.x() + XButtonSpacing,ArrayTopLeft.y() + (i*YLineSpacing));
|
||||||
|
|
||||||
|
i++;
|
||||||
|
Label = new QGraphicsTextItem("Pneu porteur:",this);
|
||||||
|
Label->setFont(font);
|
||||||
|
Label->setPos(35,ArrayTopLeft.y() + (i*YLineSpacing));
|
||||||
|
mPPFuncToggleBtn = new CToggleButtonWidget(ONPixmapFilePath,OFFPixmapFilePath,this);
|
||||||
|
mPPFuncToggleBtn->resize(SlideButtonSize);
|
||||||
|
mPPFuncToggleBtn->setPos(ArrayTopLeft.x(),ArrayTopLeft.y() + (i*YLineSpacing));
|
||||||
|
mPPTKToggleBtn = new CToggleButtonWidget(ONPixmapFilePath,OFFPixmapFilePath,this);
|
||||||
|
mPPTKToggleBtn->resize(SlideButtonSize);
|
||||||
|
mPPTKToggleBtn->setPos(ArrayTopLeft.x() + XButtonSpacing,ArrayTopLeft.y() + (i*YLineSpacing));
|
||||||
|
|
||||||
|
i++;
|
||||||
|
Label = new QGraphicsTextItem("Pneu porteur ZT2:",this);
|
||||||
|
Label->setFont(font);
|
||||||
|
Label->setPos(35,ArrayTopLeft.y() + (i*YLineSpacing));
|
||||||
|
mPP2FuncToggleBtn = new CToggleButtonWidget(ONPixmapFilePath,OFFPixmapFilePath,this);
|
||||||
|
mPP2FuncToggleBtn->resize(SlideButtonSize);
|
||||||
|
mPP2FuncToggleBtn->setPos(ArrayTopLeft.x(),ArrayTopLeft.y() + (i*YLineSpacing));
|
||||||
|
mPP2TKToggleBtn = new CToggleButtonWidget(ONPixmapFilePath,OFFPixmapFilePath,this);
|
||||||
|
mPP2TKToggleBtn->resize(SlideButtonSize);
|
||||||
|
mPP2TKToggleBtn->setPos(ArrayTopLeft.x() + XButtonSpacing,ArrayTopLeft.y() + (i*YLineSpacing));
|
||||||
|
|
||||||
|
i++;
|
||||||
|
Label = new QGraphicsTextItem("ZT1:",this);
|
||||||
|
Label->setFont(font);
|
||||||
|
Label->setPos(35,ArrayTopLeft.y() + (i*YLineSpacing));
|
||||||
|
mZT1FuncToggleBtn = new CToggleButtonWidget(ONPixmapFilePath,OFFPixmapFilePath,this);
|
||||||
|
mZT1FuncToggleBtn->resize(SlideButtonSize);
|
||||||
|
mZT1FuncToggleBtn->setPos(ArrayTopLeft.x(),ArrayTopLeft.y() + (i*YLineSpacing));
|
||||||
|
connect(mZT1FuncToggleBtn,SIGNAL(ButtonToggled(CToggleButtonWidget*)),this,SLOT(ToggleButtonToggled(CToggleButtonWidget*)));
|
||||||
|
mZT1TKToggleBtn = new CToggleButtonWidget(ONPixmapFilePath,OFFPixmapFilePath,this);
|
||||||
|
mZT1TKToggleBtn->resize(SlideButtonSize);
|
||||||
|
mZT1TKToggleBtn->setPos(ArrayTopLeft.x() + XButtonSpacing,ArrayTopLeft.y() + (i*YLineSpacing));
|
||||||
|
connect(mZT1TKToggleBtn,SIGNAL(ButtonToggled(CToggleButtonWidget*)),this,SLOT(ToggleButtonToggled(CToggleButtonWidget*)));
|
||||||
|
|
||||||
|
i++;
|
||||||
|
Label = new QGraphicsTextItem("ZT2:",this);
|
||||||
|
Label->setFont(font);
|
||||||
|
Label->setPos(35,ArrayTopLeft.y() + (i*YLineSpacing));
|
||||||
|
mZT2FuncToggleBtn = new CToggleButtonWidget(ONPixmapFilePath,OFFPixmapFilePath,this);
|
||||||
|
mZT2FuncToggleBtn->resize(SlideButtonSize);
|
||||||
|
mZT2FuncToggleBtn->setPos(ArrayTopLeft.x(),ArrayTopLeft.y() + (i*YLineSpacing));
|
||||||
|
connect(mZT2FuncToggleBtn,SIGNAL(ButtonToggled(CToggleButtonWidget*)),this,SLOT(ToggleButtonToggled(CToggleButtonWidget*)));
|
||||||
|
mZT2TKToggleBtn = new CToggleButtonWidget(ONPixmapFilePath,OFFPixmapFilePath,this);
|
||||||
|
mZT2TKToggleBtn->resize(SlideButtonSize);
|
||||||
|
mZT2TKToggleBtn->setPos(ArrayTopLeft.x() + XButtonSpacing,ArrayTopLeft.y() + (i*YLineSpacing));
|
||||||
|
connect(mZT2TKToggleBtn,SIGNAL(ButtonToggled(CToggleButtonWidget*)),this,SLOT(ToggleButtonToggled(CToggleButtonWidget*)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRemoteZTCtrlPage::ToggleButtonToggled(CToggleButtonWidget *ToggleButton)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(ToggleButton == mZT1FuncToggleBtn)
|
||||||
|
{
|
||||||
|
if(mZT1FuncToggleBtn->GetButtonState() == TOGGLE_BUTTON_OFF)
|
||||||
|
{
|
||||||
|
mFNFuncToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||||
|
mFNFuncToggleBtn->SetButtonEnabled(false);
|
||||||
|
mPGFuncToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||||
|
mPGFuncToggleBtn->SetButtonEnabled(false);
|
||||||
|
mPPFuncToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||||
|
mPPFuncToggleBtn->SetButtonEnabled(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mFNFuncToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||||
|
mFNFuncToggleBtn->SetButtonEnabled(true);
|
||||||
|
mPGFuncToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||||
|
mPGFuncToggleBtn->SetButtonEnabled(true);
|
||||||
|
mPPFuncToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||||
|
mPPFuncToggleBtn->SetButtonEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(ToggleButton == mZT1TKToggleBtn)
|
||||||
|
{
|
||||||
|
if(mZT1TKToggleBtn->GetButtonState() == TOGGLE_BUTTON_OFF)
|
||||||
|
{
|
||||||
|
mFNTKToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||||
|
mFNTKToggleBtn->SetButtonEnabled(false);
|
||||||
|
mPGTKToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||||
|
mPGTKToggleBtn->SetButtonEnabled(false);
|
||||||
|
mPPTKToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||||
|
mPPTKToggleBtn->SetButtonEnabled(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mFNTKToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||||
|
mFNTKToggleBtn->SetButtonEnabled(true);
|
||||||
|
mPGTKToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||||
|
mPGTKToggleBtn->SetButtonEnabled(true);
|
||||||
|
mPPTKToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||||
|
mPPTKToggleBtn->SetButtonEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ToggleButton == mZT2FuncToggleBtn)
|
||||||
|
{
|
||||||
|
if(mZT2FuncToggleBtn->GetButtonState() == TOGGLE_BUTTON_OFF)
|
||||||
|
{
|
||||||
|
mPP2FuncToggleBtn->SetButtonEnabled(false);
|
||||||
|
mPP2FuncToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mPP2FuncToggleBtn->SetButtonEnabled(true);
|
||||||
|
mPP2FuncToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(ToggleButton == mZT2TKToggleBtn)
|
||||||
|
{
|
||||||
|
if(mZT2TKToggleBtn->GetButtonState() == TOGGLE_BUTTON_OFF)
|
||||||
|
{
|
||||||
|
mPP2TKToggleBtn->SetButtonEnabled(false);
|
||||||
|
mPP2TKToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mPP2TKToggleBtn->SetButtonEnabled(true);
|
||||||
|
mPP2TKToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRemoteZTCtrlPage::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
// mBackgroundRect->setRect(boundingRect());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRemoteZTCtrlPage::ButtonClicked(CTextButtonWidget *BtnPtr)
|
||||||
|
{
|
||||||
|
if(BtnPtr == mDeleteLogFile)
|
||||||
|
{
|
||||||
|
mProgramHandle->DeleteRemoteZTLogRequest();
|
||||||
|
}
|
||||||
|
else if(BtnPtr == mSetZTFunctionsBtn)
|
||||||
|
{
|
||||||
|
CTCPZTFunctionsStatus FunctionsConfig;
|
||||||
|
|
||||||
|
//update FN flags
|
||||||
|
if(mFNFuncToggleBtn->GetButtonState() == TOGGLE_BUTTON_ON)
|
||||||
|
FunctionsConfig.mFNAnalysisActive = true;
|
||||||
|
else
|
||||||
|
FunctionsConfig.mFNAnalysisActive = false;
|
||||||
|
|
||||||
|
if(mFNTKToggleBtn->GetButtonState() == TOGGLE_BUTTON_ON)
|
||||||
|
FunctionsConfig.mFNTKActive = true;
|
||||||
|
else
|
||||||
|
FunctionsConfig.mFNTKActive = false;
|
||||||
|
|
||||||
|
//update PG flags
|
||||||
|
if(mPGFuncToggleBtn->GetButtonState() == TOGGLE_BUTTON_ON)
|
||||||
|
FunctionsConfig.mPGAnalysisActive = true;
|
||||||
|
else
|
||||||
|
FunctionsConfig.mPGAnalysisActive = false;
|
||||||
|
|
||||||
|
if(mPGTKToggleBtn->GetButtonState() == TOGGLE_BUTTON_ON)
|
||||||
|
FunctionsConfig.mPGTKActive = true;
|
||||||
|
else
|
||||||
|
FunctionsConfig.mPGTKActive = false;
|
||||||
|
|
||||||
|
//update PP flags
|
||||||
|
if(mPPFuncToggleBtn->GetButtonState() == TOGGLE_BUTTON_ON)
|
||||||
|
FunctionsConfig.mPP1AnalysisActive = true;
|
||||||
|
else
|
||||||
|
FunctionsConfig.mPP1AnalysisActive = false;
|
||||||
|
|
||||||
|
if(mPPTKToggleBtn->GetButtonState() == TOGGLE_BUTTON_ON)
|
||||||
|
FunctionsConfig.mPP1TKActive = true;
|
||||||
|
else
|
||||||
|
FunctionsConfig.mPP1TKActive = false;
|
||||||
|
|
||||||
|
//update PP2 flags
|
||||||
|
if(mPP2FuncToggleBtn->GetButtonState() == TOGGLE_BUTTON_ON)
|
||||||
|
FunctionsConfig.mPP2AnalysisActive = true;
|
||||||
|
else
|
||||||
|
FunctionsConfig.mPP2AnalysisActive = false;
|
||||||
|
|
||||||
|
if(mPP2TKToggleBtn->GetButtonState())
|
||||||
|
FunctionsConfig.mPP2TKActive = true;
|
||||||
|
else
|
||||||
|
FunctionsConfig.mPP2TKActive = false;
|
||||||
|
|
||||||
|
//update ZT1 flags
|
||||||
|
if(mZT1FuncToggleBtn->GetButtonState() == TOGGLE_BUTTON_ON)
|
||||||
|
FunctionsConfig.mZT1AnalysisActive = true;
|
||||||
|
else
|
||||||
|
FunctionsConfig.mZT1AnalysisActive = false;
|
||||||
|
|
||||||
|
if(mZT1TKToggleBtn->GetButtonState())
|
||||||
|
FunctionsConfig.mZT1TKActive = true;
|
||||||
|
else
|
||||||
|
FunctionsConfig.mZT1TKActive = false;
|
||||||
|
|
||||||
|
|
||||||
|
//update ZT2 flags
|
||||||
|
if(mZT2FuncToggleBtn->GetButtonState() == TOGGLE_BUTTON_ON)
|
||||||
|
FunctionsConfig.mZT2AnalysisActive = true;
|
||||||
|
else
|
||||||
|
FunctionsConfig.mZT2AnalysisActive = false;
|
||||||
|
|
||||||
|
if(mZT2TKToggleBtn->GetButtonState())
|
||||||
|
FunctionsConfig.mZT2TKActive = true;
|
||||||
|
else
|
||||||
|
FunctionsConfig.mZT2TKActive = false;
|
||||||
|
|
||||||
|
mProgramHandle->SetZTFunctionsStatus(FunctionsConfig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRemoteZTCtrlPage::UpdateDisplay(const CTCPZTStatus *RemoteZTStatus)
|
||||||
|
{
|
||||||
|
//update FN buttons
|
||||||
|
if(RemoteZTStatus->mFNAnalysisActive == true)
|
||||||
|
mFNFuncToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||||
|
else
|
||||||
|
mFNFuncToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||||
|
if(RemoteZTStatus->mFNTKActive == true)
|
||||||
|
mFNTKToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||||
|
else
|
||||||
|
mFNTKToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||||
|
|
||||||
|
//update PG buttons
|
||||||
|
if(RemoteZTStatus->mPGAnalysisActive == true)
|
||||||
|
mPGFuncToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||||
|
else
|
||||||
|
mPGFuncToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||||
|
if(RemoteZTStatus->mPGTKActive == true)
|
||||||
|
mPGTKToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||||
|
else
|
||||||
|
mPGTKToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||||
|
|
||||||
|
//update PP buttons
|
||||||
|
if(RemoteZTStatus->mPP1AnalysisActive == true)
|
||||||
|
mPPFuncToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||||
|
else
|
||||||
|
mPPFuncToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||||
|
if(RemoteZTStatus->mPP1TKActive == true)
|
||||||
|
mPPTKToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||||
|
else
|
||||||
|
mPPTKToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||||
|
|
||||||
|
//update PP2 buttons
|
||||||
|
if(RemoteZTStatus->mPP2AnalysisActive == true)
|
||||||
|
mPP2FuncToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||||
|
else
|
||||||
|
mPP2FuncToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||||
|
if(RemoteZTStatus->mPP2TKActive == true)
|
||||||
|
mPP2TKToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||||
|
else
|
||||||
|
mPP2TKToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||||
|
|
||||||
|
//update ZT1 buttons
|
||||||
|
if(RemoteZTStatus->mZT1AnalysisActive == true)
|
||||||
|
mZT1FuncToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||||
|
else
|
||||||
|
mZT1FuncToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||||
|
if(RemoteZTStatus->mZT1TKActive == true)
|
||||||
|
mZT1TKToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||||
|
else
|
||||||
|
mZT1TKToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||||
|
|
||||||
|
//update ZT2 buttons
|
||||||
|
if(RemoteZTStatus->mZT2AnalysisActive == true)
|
||||||
|
mZT2FuncToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||||
|
else
|
||||||
|
mZT2FuncToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||||
|
if(RemoteZTStatus->mZT2TKActive == true)
|
||||||
|
mZT2TKToggleBtn->SetButtonState(TOGGLE_BUTTON_ON);
|
||||||
|
else
|
||||||
|
mZT2TKToggleBtn->SetButtonState(TOGGLE_BUTTON_OFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRemoteZTCtrlPage::NetworkZTConnected(int ID)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void CRemoteZTCtrlPage::NetworkZTDisconnected(int ID)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Grab the mouse if the user clicks outside buttons
|
||||||
|
void CRemoteZTCtrlPage::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
// qDebug("CRemoteZTCtrlPage");
|
||||||
|
Q_UNUSED(event)
|
||||||
|
}
|
||||||
|
void CRemoteZTCtrlPage::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
}
|
||||||
82
sources/GuiElements/RemoteZTCtrlPage.h
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Description du fichier si nécessaire.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131024 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef REMOTEZTCTRLPAGE_H
|
||||||
|
#define REMOTEZTCTRLPAGE_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
#include "Guipage.h"
|
||||||
|
#include <QString>
|
||||||
|
#include "TextButtonWidget.h"
|
||||||
|
#include "ToggleButtonWidget.h"
|
||||||
|
|
||||||
|
|
||||||
|
class COutilZT;
|
||||||
|
class CTCPZTStatus;
|
||||||
|
|
||||||
|
class CRemoteZTCtrlPage : public CGuiPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
virtual ~CRemoteZTCtrlPage();
|
||||||
|
CRemoteZTCtrlPage(QGraphicsWidget *Parent = 0);
|
||||||
|
|
||||||
|
COutilZT *mProgramHandle;
|
||||||
|
|
||||||
|
CTextButtonWidget *mDeleteLogFile;
|
||||||
|
CTextButtonWidget *mSetZTFunctionsBtn;
|
||||||
|
|
||||||
|
CToggleButtonWidget *mFNFuncToggleBtn, *mFNTKToggleBtn;
|
||||||
|
CToggleButtonWidget *mPGFuncToggleBtn, *mPGTKToggleBtn;
|
||||||
|
CToggleButtonWidget *mPPFuncToggleBtn, *mPPTKToggleBtn;
|
||||||
|
CToggleButtonWidget *mPP2FuncToggleBtn, *mPP2TKToggleBtn;
|
||||||
|
CToggleButtonWidget *mZT1FuncToggleBtn, *mZT1TKToggleBtn;
|
||||||
|
CToggleButtonWidget *mZT2FuncToggleBtn, *mZT2TKToggleBtn;
|
||||||
|
|
||||||
|
void UpdateDisplay(const CTCPZTStatus *RemoteZTStatus);
|
||||||
|
|
||||||
|
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||||
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void ButtonClicked(CTextButtonWidget *);
|
||||||
|
void NetworkZTConnected(int);
|
||||||
|
void NetworkZTDisconnected(int);
|
||||||
|
void ToggleButtonToggled(CToggleButtonWidget *ToggleButton);
|
||||||
|
|
||||||
|
// void ParsingTimerExipred();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // REMOTEZTPAGE_H
|
||||||
182
sources/GuiElements/RemoteZTPage.cpp
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Page affichant la liste des passages de train.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131021 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#include "RemoteZTPage.h"
|
||||||
|
#include <QGraphicsProxyWidget>
|
||||||
|
#include "OutilZT.h"
|
||||||
|
#include <QString>
|
||||||
|
#include <QTextCodec>
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include <QTextStream>
|
||||||
|
|
||||||
|
|
||||||
|
CRemoteZTPage::~CRemoteZTPage()
|
||||||
|
{
|
||||||
|
// delete mListParsingTimer;
|
||||||
|
}
|
||||||
|
|
||||||
|
CRemoteZTPage::CRemoteZTPage(QGraphicsWidget *Parent)
|
||||||
|
{
|
||||||
|
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
|
||||||
|
setParentItem(Parent);
|
||||||
|
mProgramHandle = 0;
|
||||||
|
|
||||||
|
QFont font;
|
||||||
|
font.setPointSize(20);
|
||||||
|
font.setBold(true);
|
||||||
|
mStationName = new QGraphicsTextItem(this);
|
||||||
|
mStationName->setPlainText("Non connecté");
|
||||||
|
mStationName->setFont(font);
|
||||||
|
mStationName->setPos(20,10);
|
||||||
|
|
||||||
|
font.setPointSize(15);
|
||||||
|
font.setBold(false);
|
||||||
|
mRemoteZTStatus = new QGraphicsTextItem(this);
|
||||||
|
mRemoteZTStatus->setPlainText("Status de la ZT:");
|
||||||
|
mRemoteZTStatus->setFont(font);
|
||||||
|
mRemoteZTStatus->setPos(20,60);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRemoteZTPage::SetRemoteZTName(QString Name)
|
||||||
|
{
|
||||||
|
mStationName->setPlainText(Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRemoteZTPage::SetRemoteZTStatus(const CTCPZTStatus *status)
|
||||||
|
{
|
||||||
|
// QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
|
||||||
|
QString StatString;
|
||||||
|
QTextStream stream(&StatString,QIODevice::ReadWrite);
|
||||||
|
StatString.clear();
|
||||||
|
stream.seek(0);
|
||||||
|
stream.setAutoDetectUnicode(true);
|
||||||
|
|
||||||
|
StatString.append("Status de la ZT:\n");
|
||||||
|
StatString.append("ZT1: ");
|
||||||
|
switch(status->mZT1Status)
|
||||||
|
{
|
||||||
|
case SB_ZT_ACTIVE_STATUS:
|
||||||
|
{
|
||||||
|
StatString.append("ACTIVÉE");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SB_ZT_INACTIVE_STATUS:
|
||||||
|
{
|
||||||
|
StatString.append("DÉSACTIVÉE");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SB_ZT_NOT_PRESENT_STATUS:
|
||||||
|
{
|
||||||
|
StatString.append("ABSENTE (!?)");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SB_ZT_DISABLED_STATUS:
|
||||||
|
{
|
||||||
|
StatString.append("HORS-SERVICE");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StatString.append("\n");
|
||||||
|
StatString.append("ZT2: ");
|
||||||
|
switch(status->mZT2Status)
|
||||||
|
{
|
||||||
|
case SB_ZT_ACTIVE_STATUS:
|
||||||
|
{
|
||||||
|
StatString.append("ACTIVÉE");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SB_ZT_INACTIVE_STATUS:
|
||||||
|
{
|
||||||
|
StatString.append("DÉSACTIVÉE");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SB_ZT_NOT_PRESENT_STATUS:
|
||||||
|
{
|
||||||
|
StatString.append("ABSENTE");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SB_ZT_DISABLED_STATUS:
|
||||||
|
{
|
||||||
|
StatString.append("HORS-SERVICE");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StatString.append("\n");
|
||||||
|
|
||||||
|
StatString.append(QString("Nombre de passages: %1\n").arg(status->mNbPass));
|
||||||
|
StatString.append(QString("Nombre de déclenchements: %1\n").arg(status->mNbTrigs));
|
||||||
|
StatString.append(QString("Date de démarrage de la ZT: %1\n").arg(status->mZTStartDateTime.toString("yyyy/MM/dd - hh:mm")));
|
||||||
|
StatString.append(QString("Date actuelle de la ZT: %1\n").arg(status->mActualDateTime.toString("yyyy/MM/dd - hh:mm")));
|
||||||
|
StatString.append(QString("Seuil du pneu de guidage: %1\n").arg(status->mPGTreshold));
|
||||||
|
StatString.append(QString( "Mode Maintenance activé: %1\n").arg(status->mModeMaintenanceON));
|
||||||
|
StatString.append(QString("Mode calibration activé: %1\n").arg(status->mCalibModeON));
|
||||||
|
StatString.append(QString("Clef USB connectée: %1\n").arg(status->mUSBKeyConnected));
|
||||||
|
StatString.append(QString("Frotteur négatif: TK=[%1] - Analyse=[%2]\n").arg(status->mFNTKActive).arg(status->mFNAnalysisActive));
|
||||||
|
StatString.append(QString("Pneu de guidage: TK=[%1] - Analyse=[%2]\n").arg(status->mPGTKActive).arg(status->mPGAnalysisActive));
|
||||||
|
StatString.append(QString("Pneu porteur: TK=[%1] - Analyse=[%2]\n").arg(status->mPP1TKActive).arg(status->mPP1AnalysisActive));
|
||||||
|
StatString.append(QString("Pneu porteur ZT2: TK=[%1] - Analyse=[%2]\n").arg(status->mPP2TKActive).arg(status->mPP2AnalysisActive));
|
||||||
|
StatString.append(QString("ZT1: TK=[%1] - Analyse=[%2]\n").arg(status->mZT1TKActive).arg(status->mZT1AnalysisActive));
|
||||||
|
StatString.append(QString("ZT2: TK=[%1] - Analyse=[%2]\n").arg(status->mZT2TKActive).arg(status->mZT2AnalysisActive));
|
||||||
|
|
||||||
|
|
||||||
|
mRemoteZTStatus->setPlainText(StatString);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRemoteZTPage::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
// mBackgroundRect->setRect(boundingRect());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRemoteZTPage::ButtonClicked(CTextButtonWidget *BtnPtr)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRemoteZTPage::NetworkZTConnected(int ID)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void CRemoteZTPage::NetworkZTDisconnected(int ID)
|
||||||
|
{
|
||||||
|
mStationName->setPlainText("Non connecté");
|
||||||
|
mRemoteZTStatus->setPlainText("Status de la ZT:");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Grab the mouse if the user clicks outside buttons
|
||||||
|
void CRemoteZTPage::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
// qDebug("CRemoteZTPage");
|
||||||
|
Q_UNUSED(event)
|
||||||
|
}
|
||||||
|
void CRemoteZTPage::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
}
|
||||||
74
sources/GuiElements/RemoteZTPage.h
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Description du fichier si nécessaire.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131024 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef REMOTEZTPAGE_H
|
||||||
|
#define REMOTEZTPAGE_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
#include "Guipage.h"
|
||||||
|
#include <QString>
|
||||||
|
#include "ToggleTextButtonWidget.h"
|
||||||
|
|
||||||
|
|
||||||
|
class COutilZT;
|
||||||
|
class CTCPZTStatus;
|
||||||
|
|
||||||
|
class CRemoteZTPage : public CGuiPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
virtual ~CRemoteZTPage();
|
||||||
|
CRemoteZTPage(QGraphicsWidget *Parent = 0);
|
||||||
|
|
||||||
|
void SetRemoteZTName(QString Name);
|
||||||
|
void SetRemoteZTStatus(const CTCPZTStatus *status);
|
||||||
|
|
||||||
|
COutilZT *mProgramHandle;
|
||||||
|
|
||||||
|
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||||
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
QGraphicsTextItem *mStationName;
|
||||||
|
|
||||||
|
QGraphicsTextItem *mRemoteZTStatus;
|
||||||
|
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void ButtonClicked(CTextButtonWidget *);
|
||||||
|
void NetworkZTConnected(int);
|
||||||
|
void NetworkZTDisconnected(int);
|
||||||
|
|
||||||
|
// void ParsingTimerExipred();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // REMOTEZTPAGE_H
|
||||||
277
sources/GuiElements/TextButtonWidget.cpp
Normal file
@ -0,0 +1,277 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2013 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Widget Bouton dans lequel est affiché du texte. Une image peut aussi être
|
||||||
|
affichée à l'intérieur du bouton.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20130306 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "TextButtonWidget.h"
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QGraphicsSceneMouseEvent>
|
||||||
|
|
||||||
|
CTextButtonWidget::CTextButtonWidget(QString Text, int TextButtonData,int ButtonHeight,int ButtonWidth,int FontSize, QPixmap *ButtonImage)
|
||||||
|
{
|
||||||
|
|
||||||
|
mIsEnabled = true;
|
||||||
|
|
||||||
|
if(ButtonImage)
|
||||||
|
{
|
||||||
|
mButtonImagePtr = ButtonImage;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mButtonImagePtr = 0;
|
||||||
|
|
||||||
|
mIsPressed = false;
|
||||||
|
mWidgetText = Text;
|
||||||
|
mTextButtonData = TextButtonData;
|
||||||
|
mButtonHeight = ButtonHeight;
|
||||||
|
mBackgroundColor = QColor(245, 245, 255, 220);
|
||||||
|
|
||||||
|
if(FontSize == 0)
|
||||||
|
mFontSize = mButtonHeight -10;
|
||||||
|
else
|
||||||
|
mFontSize = FontSize;
|
||||||
|
|
||||||
|
//Fit widget size with text
|
||||||
|
|
||||||
|
mTextFont.setPixelSize(mFontSize);
|
||||||
|
mTextFont.setBold(true);
|
||||||
|
|
||||||
|
int IconOffset = 0;
|
||||||
|
QFontMetrics FontMetrics(mTextFont);
|
||||||
|
if(ButtonWidth == 0)
|
||||||
|
{
|
||||||
|
if(mButtonImagePtr != 0)
|
||||||
|
IconOffset = mButtonHeight + 5;
|
||||||
|
//mButtonWidth = FontMetrics.width(mWidgetText)+IconOffset + 10;
|
||||||
|
mButtonWidth = FontMetrics.boundingRect(mWidgetText).width()+IconOffset + 10;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mButtonWidth = ButtonWidth;
|
||||||
|
|
||||||
|
resize(mButtonWidth,mButtonHeight);
|
||||||
|
|
||||||
|
// setGeometry(0,0,TEXT_BUTTON_WIDGET_WIDTH,TEXT_BUTTON_WIDGET_HEIGHT);
|
||||||
|
setGeometry(0,0,rect().width(),rect().height());
|
||||||
|
mIsSelected = false;
|
||||||
|
mWidgetOrigin.setX(0);
|
||||||
|
mWidgetOrigin.setY(0);
|
||||||
|
|
||||||
|
mTimeLine = new QTimeLine(200,this);
|
||||||
|
mTimeLine->setCurveShape(QTimeLine::SineCurve);
|
||||||
|
connect(mTimeLine, SIGNAL(valueChanged(qreal)), this, SLOT(TimeLineEvent(qreal)));
|
||||||
|
|
||||||
|
mButtonImagePtr = ButtonImage;
|
||||||
|
|
||||||
|
//QRect WidgetRect(mWidgetOrigin.x(),mWidgetOrigin.y(),TEXT_BUTTON_WIDGET_WIDTH,TEXT_BUTTON_WIDGET_HEIGHT);
|
||||||
|
QRect WidgetRect(mWidgetOrigin.x(),mWidgetOrigin.y(),rect().width(),rect().height());
|
||||||
|
|
||||||
|
QRectF textRect = WidgetRect.adjusted(5, 2, -2, -2);
|
||||||
|
// int flags = Qt::AlignVCenter | Qt::AlignLeft;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CTextButtonWidget::CheckScrolling()
|
||||||
|
{
|
||||||
|
int IconOffset = 0;
|
||||||
|
if(mButtonImagePtr != 0)
|
||||||
|
IconOffset = rect().height();
|
||||||
|
|
||||||
|
QFontMetrics FontMetrics(mTextFont);
|
||||||
|
if(FontMetrics.boundingRect(mWidgetText).width()+IconOffset > rect().width())
|
||||||
|
{
|
||||||
|
mScrollingRequired = true;
|
||||||
|
mWidgetText.append(" ");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mScrollingRequired = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CTextButtonWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
{
|
||||||
|
PaintButtonWidget(painter,option,widget);
|
||||||
|
}
|
||||||
|
void CTextButtonWidget::PaintButtonWidget(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
|
||||||
|
{
|
||||||
|
Q_UNUSED(widget)
|
||||||
|
Q_UNUSED(option)
|
||||||
|
// painter->setOpacity(1);
|
||||||
|
if(mIsEnabled == false)
|
||||||
|
{
|
||||||
|
painter->setPen(QPen(Qt::black, 2));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(mIsPressed)
|
||||||
|
painter->setPen(QPen(Qt::red, 2));
|
||||||
|
else
|
||||||
|
painter->setPen(QPen(Qt::black, 2));
|
||||||
|
}
|
||||||
|
// if(mIsAnimating)
|
||||||
|
// painter->setBrush(QColor(0, 50, 255, 220));
|
||||||
|
// else
|
||||||
|
//painter->setBrush(QColor(245, 245, 255, 220));
|
||||||
|
painter->setBrush(mBackgroundColor);
|
||||||
|
//QRect WidgetRect(mWidgetOrigin.x(),mWidgetOrigin.y(),TEXT_BUTTON_WIDGET_WIDTH,TEXT_BUTTON_WIDGET_HEIGHT);
|
||||||
|
QRect WidgetRect(mWidgetOrigin.x(),mWidgetOrigin.y(),rect().width(),rect().height());
|
||||||
|
|
||||||
|
//painter->drawRoundedRect(WidgetRect,10,10);
|
||||||
|
painter->drawRect(WidgetRect);
|
||||||
|
|
||||||
|
QRectF textRect;
|
||||||
|
if(mButtonImagePtr)
|
||||||
|
textRect = WidgetRect.adjusted(rect().height() + 5, 2, -2, -2); //if there is an image, it will be square so text must begin at 5 + height of button (height determines size of image)
|
||||||
|
else
|
||||||
|
textRect = WidgetRect.adjusted(5, 2, -2, -2);
|
||||||
|
|
||||||
|
int flags = Qt::AlignVCenter | Qt::AlignLeft;
|
||||||
|
|
||||||
|
// QFont font;
|
||||||
|
// font.setPixelSize(mButtonHeight/2 - 10);
|
||||||
|
// font.setBold(true);
|
||||||
|
painter->setPen(QPen(Qt::black,1));
|
||||||
|
painter->setFont(mTextFont);
|
||||||
|
painter->drawText(textRect, flags, mWidgetText);
|
||||||
|
|
||||||
|
if(mButtonImagePtr)
|
||||||
|
{
|
||||||
|
painter->drawPixmap(WidgetRect.left(),WidgetRect.top(),mButtonImagePtr->scaled(rect().height(),rect().height()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CTextButtonWidget::SetButtonImage(QPixmap *ButtonImage)
|
||||||
|
{
|
||||||
|
if(ButtonImage != NULL)
|
||||||
|
{
|
||||||
|
mButtonImagePtr = ButtonImage;
|
||||||
|
update(rect());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CTextButtonWidget::SetButtonText(QString ButtonText)
|
||||||
|
{
|
||||||
|
mWidgetText = ButtonText;
|
||||||
|
update(rect());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CTextButtonWidget::SetButtonPos(int x, int y)
|
||||||
|
{
|
||||||
|
mWidgetOrigin.setX(x);
|
||||||
|
mWidgetOrigin.setY(y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CTextButtonWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
// qDebug("Mouse pressed Text Button Widget");
|
||||||
|
// mIsSelected = true;
|
||||||
|
// event->ignore();
|
||||||
|
// update();
|
||||||
|
|
||||||
|
// qDebug("Mouse pressed Text Button Widget");
|
||||||
|
if(mIsEnabled == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mIsPressed = true;
|
||||||
|
update(rect());
|
||||||
|
emit TxtButtonPressed(this);
|
||||||
|
// QGraphicsWidget::mousePressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CTextButtonWidget::SetBackgroundColor(QColor color)
|
||||||
|
{
|
||||||
|
mBackgroundColor = color;
|
||||||
|
update(rect());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CTextButtonWidget::mouseReleaseEvent( QGraphicsSceneMouseEvent * event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
///* qDebug("Mouse released Text Button Widget");
|
||||||
|
// mIsSelected = false;
|
||||||
|
// update();
|
||||||
|
// if(isVisible())
|
||||||
|
// emit clicked(this);
|
||||||
|
// event->ignore();*/
|
||||||
|
// //qDebug("Start Timeline");
|
||||||
|
// mIsAnimating = true;
|
||||||
|
// mTimeLine->start();
|
||||||
|
// qDebug("Mouse released Text Button Widget");
|
||||||
|
|
||||||
|
if(mIsEnabled == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mIsPressed = false;
|
||||||
|
update(rect());
|
||||||
|
emit TxtButtonReleased(this);
|
||||||
|
|
||||||
|
// qDebug("Text Button Widget clicked");
|
||||||
|
emit TxtButtonClicked(this);
|
||||||
|
|
||||||
|
// QGraphicsWidget::mouseReleaseEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
//void CTextButtonWidget::ButtonClicked()
|
||||||
|
//{
|
||||||
|
// mIsSelected = false;
|
||||||
|
// qDebug("A button is clicked");
|
||||||
|
//}
|
||||||
|
|
||||||
|
void CTextButtonWidget::TimeLineEvent(qreal value)
|
||||||
|
{
|
||||||
|
Q_UNUSED(value)
|
||||||
|
//// ClickTransparency = 255*value;
|
||||||
|
|
||||||
|
// update();
|
||||||
|
|
||||||
|
// if(value == 0)
|
||||||
|
// {
|
||||||
|
// mIsAnimating = false;
|
||||||
|
// emit clicked(this);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
void CTextButtonWidget::TickScrollingText()
|
||||||
|
{
|
||||||
|
if(mScrollingRequired && isVisible())
|
||||||
|
{
|
||||||
|
QChar Character = mWidgetText.at(mSongNameIndex);
|
||||||
|
mWidgetText.remove(mSongNameIndex,1);
|
||||||
|
mWidgetText.append(Character);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CTextButtonWidget::DisableButton()
|
||||||
|
{
|
||||||
|
mIsEnabled = false;
|
||||||
|
mBackgroundColor = QColor(100, 100, 110, 220);
|
||||||
|
update(rect());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CTextButtonWidget::EnableButton()
|
||||||
|
{
|
||||||
|
mIsEnabled = true;
|
||||||
|
mBackgroundColor = QColor(245, 245, 255, 220);
|
||||||
|
update(rect());
|
||||||
|
}
|
||||||
64
sources/GuiElements/TextButtonWidget.h
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
#ifndef TEXTBUTTONWIDGET_H
|
||||||
|
#define TEXTBUTTONWIDGET_H
|
||||||
|
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
#include <QRect>
|
||||||
|
#include <QTimeLine>
|
||||||
|
|
||||||
|
#define TEXT_BUTTON_WIDGET_WIDTH 280
|
||||||
|
#define TEXT_BUTTON_WIDGET_HEIGHT 25
|
||||||
|
|
||||||
|
class CTextButtonWidget : public QGraphicsWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CTextButtonWidget(QString Text, int TextButtonData = 0,int ButtonHeight = TEXT_BUTTON_WIDGET_HEIGHT,int ButtonWidth = 0,int FontSize = 0,QPixmap *ButtonImage = 0);
|
||||||
|
|
||||||
|
QString mWidgetText;
|
||||||
|
QString mDisplayText;
|
||||||
|
int mTextButtonData;
|
||||||
|
bool mIsSelected;
|
||||||
|
QRectF mButtonsAreaWindow;
|
||||||
|
QTimeLine *mTimeLine;
|
||||||
|
bool mIsPressed;
|
||||||
|
bool mScrollingRequired;
|
||||||
|
qreal ClickTransparency;
|
||||||
|
int mSongNameIndex;
|
||||||
|
QPixmap *mButtonImagePtr;
|
||||||
|
unsigned int mButtonHeight;
|
||||||
|
unsigned int mButtonWidth;
|
||||||
|
unsigned int mFontSize;
|
||||||
|
QColor mBackgroundColor;
|
||||||
|
QFont mTextFont;
|
||||||
|
bool mIsEnabled;
|
||||||
|
|
||||||
|
void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
|
||||||
|
void SetButtonPos(int x, int y);
|
||||||
|
void PaintButtonWidget(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
|
||||||
|
void SetButtonImage(QPixmap *ButtonImage);
|
||||||
|
void SetButtonText(QString ButtonText);
|
||||||
|
void SetBackgroundColor(QColor color);
|
||||||
|
void CheckScrolling(void);
|
||||||
|
void EnableButton(void);
|
||||||
|
void DisableButton(void);
|
||||||
|
|
||||||
|
|
||||||
|
QPoint mWidgetOrigin;
|
||||||
|
|
||||||
|
virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
|
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event);
|
||||||
|
void ButtonClicked(void);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void TimeLineEvent(qreal value);
|
||||||
|
void TickScrollingText();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void TxtButtonClicked(CTextButtonWidget *TextButtonPtr);
|
||||||
|
void TxtButtonPressed(CTextButtonWidget *TextButtonPtr);
|
||||||
|
void TxtButtonReleased(CTextButtonWidget *TextButtonPtr);
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TEXTBUTTONWIDGET_H
|
||||||
130
sources/GuiElements/ToggleButtonWidget.cpp
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2013 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Widget Bouton de style "toggle" qui affiche une image lorsqu'il est désactivé
|
||||||
|
et une autre image lorsqu'il est activé.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20130306 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "ToggleButtonWidget.h"
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QGraphicsSceneMouseEvent>
|
||||||
|
|
||||||
|
CToggleButtonWidget::CToggleButtonWidget(QString ONImageFilePath, QString OFFImageFilePath,QGraphicsItem *Parent, QString Label)
|
||||||
|
{
|
||||||
|
setParentItem(Parent);
|
||||||
|
mButtonState = TOGGLE_BUTTON_OFF;
|
||||||
|
|
||||||
|
mONPixmap = new QGraphicsPixmapItem(QPixmap(ONImageFilePath), this);
|
||||||
|
mONPixmap->hide();
|
||||||
|
mOFFPixmap = new QGraphicsPixmapItem(QPixmap(OFFImageFilePath), this);
|
||||||
|
mOFFPixmap->show();
|
||||||
|
|
||||||
|
mButtonEnabled = true;
|
||||||
|
mButtonData = 0;
|
||||||
|
|
||||||
|
if(Label.isEmpty() == false)
|
||||||
|
{
|
||||||
|
QGraphicsTextItem *BtnLabel = new QGraphicsTextItem(this);
|
||||||
|
BtnLabel->setPlainText(Label);
|
||||||
|
BtnLabel->adjustSize();
|
||||||
|
BtnLabel->setPos(-BtnLabel->boundingRect().width()-3,0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CToggleButtonWidget::SetData(unsigned int data)
|
||||||
|
{
|
||||||
|
mButtonData = data;
|
||||||
|
}
|
||||||
|
unsigned int CToggleButtonWidget::GetData()
|
||||||
|
{
|
||||||
|
return mButtonData;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CToggleButtonWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
}
|
||||||
|
|
||||||
|
void CToggleButtonWidget::mouseReleaseEvent( QGraphicsSceneMouseEvent * event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
|
||||||
|
if(mButtonEnabled == false)
|
||||||
|
return ;
|
||||||
|
|
||||||
|
if(mButtonState == TOGGLE_BUTTON_ON)
|
||||||
|
mButtonState = TOGGLE_BUTTON_OFF;
|
||||||
|
else
|
||||||
|
mButtonState = TOGGLE_BUTTON_ON;
|
||||||
|
|
||||||
|
UpdateButton();
|
||||||
|
emit ButtonToggled(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CToggleButtonWidget::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
|
||||||
|
|
||||||
|
mONPixmap->setPixmap(mONPixmap->pixmap().scaled(boundingRect().width(),boundingRect().height()));
|
||||||
|
mOFFPixmap->setPixmap(mOFFPixmap->pixmap().scaled(boundingRect().width(),boundingRect().height()));
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CToggleButtonWidget::GetButtonState()
|
||||||
|
{
|
||||||
|
return mButtonState;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CToggleButtonWidget::SetButtonEnabled(bool Enabled)
|
||||||
|
{
|
||||||
|
mButtonEnabled = Enabled;
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CToggleButtonWidget::SetButtonState(unsigned int State)
|
||||||
|
{
|
||||||
|
if(mButtonState != TOGGLE_BUTTON_OFF && mButtonState != TOGGLE_BUTTON_ON)
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
mButtonState = State;
|
||||||
|
UpdateButton();
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CToggleButtonWidget::UpdateButton()
|
||||||
|
{
|
||||||
|
if(mButtonState == TOGGLE_BUTTON_OFF)
|
||||||
|
{
|
||||||
|
mOFFPixmap->show();
|
||||||
|
mONPixmap->hide();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mOFFPixmap->hide();
|
||||||
|
mONPixmap->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
47
sources/GuiElements/ToggleButtonWidget.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#ifndef TOGGLEBUTTONWIDGET_H
|
||||||
|
#define TOGGLEBUTTONWIDGET_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
#include <QRect>
|
||||||
|
#include <QTimeLine>
|
||||||
|
|
||||||
|
#define TOGGLE_BUTTON_ON 1
|
||||||
|
#define TOGGLE_BUTTON_OFF 0
|
||||||
|
|
||||||
|
class CToggleButtonWidget : public QGraphicsWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CToggleButtonWidget(QString ONImageFilePath, QString OFFImageFilePath,QGraphicsItem *Parent,QString Label = QString());
|
||||||
|
|
||||||
|
|
||||||
|
virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
|
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event);
|
||||||
|
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||||
|
|
||||||
|
QGraphicsPixmapItem *mONPixmap, *mOFFPixmap;
|
||||||
|
|
||||||
|
unsigned int GetButtonState();
|
||||||
|
unsigned int SetButtonState(unsigned int State);
|
||||||
|
unsigned int SetButtonEnabled(bool Enabled);
|
||||||
|
void SetData(unsigned int data);
|
||||||
|
unsigned int GetData();
|
||||||
|
|
||||||
|
private:
|
||||||
|
unsigned int mButtonState;
|
||||||
|
bool mButtonEnabled;
|
||||||
|
unsigned int mButtonData;
|
||||||
|
|
||||||
|
void UpdateButton();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void ButtonToggled(CToggleButtonWidget*);
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TOGGLEBUTTONWIDGET_H
|
||||||
91
sources/GuiElements/ToggleTextButtonWidget.cpp
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2013 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20130306 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "TextButtonWidget.h"
|
||||||
|
#include <QPainter>
|
||||||
|
#include <ToggleTextButtonWidget.h>
|
||||||
|
|
||||||
|
CToggleTextButtonWidget::CToggleTextButtonWidget(QString ActivatedText, QString DeActivatedText, QPixmap ActivatedButtonImage, QPixmap DeActivatedButtonImage, int ButtonHeight,int ButtonWidth,int FontSize, int ToggleTextButtonData)
|
||||||
|
{
|
||||||
|
mButtonState = false;
|
||||||
|
mActivatedBtnText = ActivatedText;
|
||||||
|
mDeActivatedButtonText = DeActivatedText;
|
||||||
|
mActivatedBtnImage = ActivatedButtonImage;
|
||||||
|
mDeActivatedBtnImage = DeActivatedButtonImage;
|
||||||
|
mButtonHeight = ButtonHeight;
|
||||||
|
mButtonData = ToggleTextButtonData;
|
||||||
|
|
||||||
|
mTextButton = new CTextButtonWidget(DeActivatedText,mButtonData,mButtonHeight,ButtonWidth,FontSize,&mDeActivatedBtnImage);
|
||||||
|
connect(mTextButton, SIGNAL(TxtButtonClicked(CTextButtonWidget *)), this, SLOT(ChildTextButtonClicked(CTextButtonWidget *)));
|
||||||
|
|
||||||
|
setGeometry(mTextButton->rect());
|
||||||
|
mTextButton->setParentItem(this);
|
||||||
|
}
|
||||||
|
CToggleTextButtonWidget::~CToggleTextButtonWidget()
|
||||||
|
{
|
||||||
|
delete mTextButton;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CToggleTextButtonWidget::ChildTextButtonClicked(CTextButtonWidget *TextButtonPtr)
|
||||||
|
{
|
||||||
|
if(mButtonState)
|
||||||
|
{
|
||||||
|
mTextButton->SetButtonImage(&mDeActivatedBtnImage);
|
||||||
|
mTextButton->SetButtonText(mDeActivatedButtonText);
|
||||||
|
mTextButton->SetBackgroundColor(QColor(245, 245, 255, 220));
|
||||||
|
mButtonState = false;
|
||||||
|
emit ToggleBtnDeActivate(this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mTextButton->SetButtonImage(&mActivatedBtnImage);
|
||||||
|
mTextButton->SetButtonText(mActivatedBtnText);
|
||||||
|
mTextButton->SetBackgroundColor(Qt::green);
|
||||||
|
mButtonState = true;
|
||||||
|
emit ToggleBtnActivate(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CToggleTextButtonWidget::ForceActivation()
|
||||||
|
{
|
||||||
|
mTextButton->SetButtonImage(&mActivatedBtnImage);
|
||||||
|
mTextButton->SetButtonText(mActivatedBtnText);
|
||||||
|
mTextButton->SetBackgroundColor(Qt::green);
|
||||||
|
mButtonState = true;
|
||||||
|
}
|
||||||
|
void CToggleTextButtonWidget::ForceDeactivation()
|
||||||
|
{
|
||||||
|
mTextButton->SetButtonImage(&mDeActivatedBtnImage);
|
||||||
|
mTextButton->SetButtonText(mDeActivatedButtonText);
|
||||||
|
mTextButton->SetBackgroundColor(QColor(245, 245, 255, 220));
|
||||||
|
mButtonState = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CToggleTextButtonWidget::OverrideText(QString text)
|
||||||
|
{
|
||||||
|
mTextButton->SetButtonText(text);
|
||||||
|
}
|
||||||
44
sources/GuiElements/ToggleTextButtonWidget.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#ifndef TOGGLETEXTBUTTONWIDGET_H
|
||||||
|
#define TOGGLETEXTBUTTONWIDGET_H
|
||||||
|
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
#include <QRect>
|
||||||
|
#include <QTimeLine>
|
||||||
|
#include "TextButtonWidget.h"
|
||||||
|
|
||||||
|
#define TOGGLE_TEXT_BUTTON_WIDGET_WIDTH 280
|
||||||
|
#define TOGGLE_TEXT_BUTTON_WIDGET_HEIGHT 25
|
||||||
|
|
||||||
|
class CToggleTextButtonWidget : public QGraphicsWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CToggleTextButtonWidget(QString ActivatedText,QString DeActivatedText,
|
||||||
|
QPixmap ActivatedButtonImage,QPixmap DeActivatedButtonImage,
|
||||||
|
int ButtonHeight = TOGGLE_TEXT_BUTTON_WIDGET_HEIGHT,int ButtonWidth = 0,int FontSize = 0, int ToggleTextButtonData = 0);
|
||||||
|
virtual ~CToggleTextButtonWidget();
|
||||||
|
|
||||||
|
void ForceDeactivation();
|
||||||
|
void ForceActivation();
|
||||||
|
void OverrideText(QString text);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void ChildTextButtonClicked(CTextButtonWidget *TextButtonPtr);
|
||||||
|
// void TxtButtonPressed(CTextButtonWidget *TextButtonPtr);
|
||||||
|
// void TxtButtonReleased(CTextButtonWidget *TextButtonPtr);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void ToggleBtnActivate(CToggleTextButtonWidget* ButtonInstancePtr);
|
||||||
|
void ToggleBtnDeActivate(CToggleTextButtonWidget* ButtonInstancePtr);
|
||||||
|
|
||||||
|
private:
|
||||||
|
CTextButtonWidget *mTextButton;
|
||||||
|
QString mActivatedBtnText,mDeActivatedButtonText;
|
||||||
|
QPixmap mActivatedBtnImage,mDeActivatedBtnImage;
|
||||||
|
unsigned int mButtonHeight,mButtonWidth;
|
||||||
|
int mButtonData;
|
||||||
|
bool mButtonState; //false = deactivated(up), true = activated (down)
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TOGGLETEXTBUTTONWIDGET_H
|
||||||
92
sources/GuiElements/TxRxWidget.cpp
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2013 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20130306 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "TxRxWidget.h"
|
||||||
|
#include <QPainter>
|
||||||
|
#define TXRX_WIDGET_SIZE 30
|
||||||
|
|
||||||
|
CTxRxWidget::CTxRxWidget(QString Label)
|
||||||
|
{
|
||||||
|
mRxLedOffPixmap = new QGraphicsPixmapItem(QPixmap("./Images/green-led-off-md.png").scaled(TXRX_WIDGET_SIZE,TXRX_WIDGET_SIZE),this);
|
||||||
|
mRxLedOnPixmap = new QGraphicsPixmapItem(QPixmap("./Images/green-led-on-md.png").scaled(TXRX_WIDGET_SIZE,TXRX_WIDGET_SIZE),this);
|
||||||
|
mTxLedOffPixmap = new QGraphicsPixmapItem(QPixmap("./Images/red-led-off-md.png").scaled(TXRX_WIDGET_SIZE,TXRX_WIDGET_SIZE),this);
|
||||||
|
mTxLedOnPixmap = new QGraphicsPixmapItem(QPixmap("./Images/red-led-on-md.png").scaled(TXRX_WIDGET_SIZE,TXRX_WIDGET_SIZE),this);
|
||||||
|
|
||||||
|
mRxLedOffPixmap->setPos(0,20);
|
||||||
|
mRxLedOnPixmap->setPos(0,20);
|
||||||
|
mTxLedOffPixmap->setPos(30,20);
|
||||||
|
mTxLedOnPixmap->setPos(30,20);
|
||||||
|
|
||||||
|
mRxLedOnPixmap->hide();
|
||||||
|
mTxLedOnPixmap->hide();
|
||||||
|
|
||||||
|
mRxToggleTimer = new QTimer();
|
||||||
|
connect(mRxToggleTimer, SIGNAL(timeout()), this, SLOT(ToggleRxLed()));
|
||||||
|
mRxToggleTimer->setSingleShot(true);
|
||||||
|
|
||||||
|
mTxToggleTimer = new QTimer();
|
||||||
|
connect(mTxToggleTimer, SIGNAL(timeout()), this, SLOT(ToggleTxLed()));
|
||||||
|
mTxToggleTimer->setSingleShot(true);
|
||||||
|
|
||||||
|
mLabel = new QGraphicsTextItem(this);
|
||||||
|
mLabel->setPlainText(Label);
|
||||||
|
mLabel->setPos(5,0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CTxRxWidget::~CTxRxWidget()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CTxRxWidget::Receive()
|
||||||
|
{
|
||||||
|
mRxLedOnPixmap->show();
|
||||||
|
mRxLedOffPixmap->hide();
|
||||||
|
mRxToggleTimer->start(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CTxRxWidget::Transmit()
|
||||||
|
{
|
||||||
|
mTxLedOnPixmap->show();
|
||||||
|
mTxLedOffPixmap->hide();
|
||||||
|
mTxToggleTimer->start(50);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CTxRxWidget::ToggleRxLed()
|
||||||
|
{
|
||||||
|
mRxLedOnPixmap->hide();
|
||||||
|
mRxLedOffPixmap->show();
|
||||||
|
|
||||||
|
}
|
||||||
|
void CTxRxWidget::ToggleTxLed()
|
||||||
|
{
|
||||||
|
mTxLedOnPixmap->hide();
|
||||||
|
mTxLedOffPixmap->show();
|
||||||
|
|
||||||
|
}
|
||||||
33
sources/GuiElements/TxRxWidget.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#ifndef TXRXWIDGET_H
|
||||||
|
#define TXRXWIDGET_H
|
||||||
|
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
#include <QRect>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
class CTxRxWidget : public QGraphicsWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
|
||||||
|
CTxRxWidget(QString Lable = QString());
|
||||||
|
virtual ~CTxRxWidget();
|
||||||
|
|
||||||
|
QGraphicsTextItem *mLabel;
|
||||||
|
QGraphicsPixmapItem *mRxLedOnPixmap,*mRxLedOffPixmap;
|
||||||
|
QGraphicsPixmapItem *mTxLedOnPixmap,*mTxLedOffPixmap;
|
||||||
|
|
||||||
|
void Receive(void);
|
||||||
|
void Transmit(void);
|
||||||
|
|
||||||
|
QTimer *mRxToggleTimer;
|
||||||
|
QTimer *mTxToggleTimer;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
void ToggleRxLed();
|
||||||
|
void ToggleTxLed();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TXRXWIDGET_H
|
||||||
165
sources/GuiElements/ZTLogViewerPage.cpp
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Page permettant de visualiser le fichier ZTLog.txt
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131021 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#include "ZTLogViewerPage.h"
|
||||||
|
#include <QPainter>
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include <QFont>
|
||||||
|
#include <QGraphicsProxyWidget>
|
||||||
|
#include <QTextBlock>
|
||||||
|
#include <QScrollBar>
|
||||||
|
#include <QGraphicsSceneResizeEvent>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CZTLogViewerPage::CZTLogViewerPage(QGraphicsWidget *Parent, bool Embedded)
|
||||||
|
{
|
||||||
|
Q_UNUSED(Parent)
|
||||||
|
|
||||||
|
mZTLogText.clear();
|
||||||
|
mIsEmbedded = Embedded;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// QGraphicsTextItem *Title = new QGraphicsTextItem("Paramètres généraux",this);
|
||||||
|
// QFont font;
|
||||||
|
// font.setPointSize(18);
|
||||||
|
// Title->setFont(font);
|
||||||
|
// Title->setPos(40,10);
|
||||||
|
|
||||||
|
// Title = new QGraphicsTextItem("Ajuster date & heure",this);
|
||||||
|
// Title->setFont(font);
|
||||||
|
// Title->setPos(270,130);
|
||||||
|
|
||||||
|
if(!Embedded)
|
||||||
|
{
|
||||||
|
mBackgroundRect = new QGraphicsRectItem(boundingRect(), this);
|
||||||
|
QBrush BackgroundBrush(QColor(245, 245, 255));
|
||||||
|
mBackgroundRect->setBrush(BackgroundBrush);
|
||||||
|
|
||||||
|
mCancelButton = new CTextButtonWidget("Fermer");
|
||||||
|
mCancelButton->setParentItem(this);
|
||||||
|
mCancelButton->setPos(700,550);
|
||||||
|
connect(mCancelButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//mZTLogTextZone = new QTextEdit();
|
||||||
|
mZTLogTextZone = new QPlainTextEdit();
|
||||||
|
QGraphicsProxyWidget *Proxy = new QGraphicsProxyWidget(this);
|
||||||
|
Proxy->setWidget(mZTLogTextZone);
|
||||||
|
Proxy->setPos(10,10);
|
||||||
|
mZTLogTextZone->resize(780,500);
|
||||||
|
mZTLogTextZone->setReadOnly(true);
|
||||||
|
mZTLogTextZone->setWordWrapMode(QTextOption::NoWrap);
|
||||||
|
QPalette p = mZTLogTextZone->palette();
|
||||||
|
p.setColor(QPalette::Highlight,QColor(200,100,100));
|
||||||
|
mZTLogTextZone->setPalette(p);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CZTLogViewerPage::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
|
||||||
|
if(mIsEmbedded)
|
||||||
|
{
|
||||||
|
mZTLogTextZone->resize(event->newSize().toSize());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mBackgroundRect->setRect(boundingRect());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CZTLogViewerPage::SetZTLogText(QString Text, QString FocusText)
|
||||||
|
{
|
||||||
|
mZTLogText = Text;
|
||||||
|
LoadAndDisplayZTLog();
|
||||||
|
|
||||||
|
if(FocusText.length() != 0)
|
||||||
|
{
|
||||||
|
QTextCursor cursor = mZTLogTextZone->document()->find(FocusText);
|
||||||
|
cursor.select(QTextCursor::LineUnderCursor);
|
||||||
|
mZTLogTextZone->setFocus();
|
||||||
|
mZTLogTextZone->setTextCursor(cursor);
|
||||||
|
QScrollBar *VerticalSB = mZTLogTextZone->verticalScrollBar();
|
||||||
|
mZTLogTextZone->centerCursor();
|
||||||
|
//VerticalSB->setValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CZTLogViewerPage::ButtonClicked(CTextButtonWidget *BtnPtr)
|
||||||
|
{
|
||||||
|
if(BtnPtr == mCancelButton)
|
||||||
|
{
|
||||||
|
mZTLogTextZone->clear();
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CZTLogViewerPage::LoadAndDisplayZTLog()
|
||||||
|
{
|
||||||
|
mZTLogTextZone->clear();
|
||||||
|
|
||||||
|
mZTLogTextZone->setPlainText(mZTLogText);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CZTLogViewerPage::ScrollToLine(int Line)
|
||||||
|
{
|
||||||
|
QTextBlock TextBlock = mZTLogTextZone->document()->findBlockByLineNumber(Line-1);
|
||||||
|
QTextCursor cursor = mZTLogTextZone->textCursor();
|
||||||
|
cursor.setPosition(TextBlock.position());
|
||||||
|
mZTLogTextZone->setFocus();
|
||||||
|
mZTLogTextZone->setTextCursor(cursor);
|
||||||
|
mZTLogTextZone->centerCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CZTLogViewerPage::showEvent(QShowEvent *event)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
Q_UNUSED(event)
|
||||||
|
}
|
||||||
|
|
||||||
|
//Grab the mouse if the user clicks outside buttons
|
||||||
|
void CZTLogViewerPage::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
// qDebug("CZTLogViewerPage");
|
||||||
|
Q_UNUSED(event)
|
||||||
|
}
|
||||||
|
void CZTLogViewerPage::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
}
|
||||||
74
sources/GuiElements/ZTLogViewerPage.h
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Page permettant de visualiser le fichier ZTLog.txt
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131122 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef ZTLOGVIEWERPAGE_H
|
||||||
|
#define ZTLOGVIEWERPAGE_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
#include "Guipage.h"
|
||||||
|
#include <QString>
|
||||||
|
#include "TextButtonWidget.h"
|
||||||
|
#include <QTextEdit>
|
||||||
|
#include <QPlainTextEdit>
|
||||||
|
|
||||||
|
class CZoneTest;
|
||||||
|
|
||||||
|
class CZTLogViewerPage : public CGuiPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CZTLogViewerPage(QGraphicsWidget *Parent = 0, bool Embedded = false);
|
||||||
|
|
||||||
|
void SetZTLogText(QString Text, QString FocusText = QString());
|
||||||
|
void ScrollToLine(int Line);
|
||||||
|
|
||||||
|
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||||
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
virtual void showEvent ( QShowEvent * event );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
QGraphicsRectItem *mBackgroundRect;
|
||||||
|
CTextButtonWidget *mCancelButton;
|
||||||
|
// QTextEdit *mZTLogTextZone;
|
||||||
|
QPlainTextEdit *mZTLogTextZone;
|
||||||
|
QString mZTLogText;
|
||||||
|
bool mIsEmbedded;
|
||||||
|
|
||||||
|
void LoadAndDisplayZTLog();
|
||||||
|
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void ButtonClicked(CTextButtonWidget *);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ZTLOGVIEWERPAGE_H
|
||||||
272
sources/GuiElements/ZTLogsListPage.cpp
Normal file
@ -0,0 +1,272 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Page affichant la liste des fichiers ZTLOG.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131021 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#include "ZTLogsListPage.h"
|
||||||
|
#include <QGraphicsProxyWidget>
|
||||||
|
#include "OutilZT.h"
|
||||||
|
#include "TrainLogFileMgr.h"
|
||||||
|
#include <QString>
|
||||||
|
#include <QTextCodec>
|
||||||
|
#include <QTextStream>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CZTLogsListPage::~CZTLogsListPage()
|
||||||
|
{
|
||||||
|
|
||||||
|
// delete mListParsingTimer;
|
||||||
|
}
|
||||||
|
|
||||||
|
CZTLogsListPage::CZTLogsListPage(QGraphicsWidget *Parent)
|
||||||
|
{
|
||||||
|
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
|
||||||
|
setParentItem(Parent);
|
||||||
|
mProgramHandle = 0;
|
||||||
|
mZTLogFilesManager = 0;
|
||||||
|
mStationFilter.clear();
|
||||||
|
|
||||||
|
mZTLogsTable = new QTableWidget(0,3);
|
||||||
|
QGraphicsProxyWidget *TableProxy = new QGraphicsProxyWidget(this);
|
||||||
|
TableProxy->setWidget(mZTLogsTable);
|
||||||
|
TableProxy->setPos(3,20);
|
||||||
|
TableProxy->resize(380,350);
|
||||||
|
mZTLogsTable->resize(420,350);
|
||||||
|
mZTLogsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
|
mZTLogsTable->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
|
mZTLogsTable->clearContents();
|
||||||
|
mZTLogsTable->setRowCount(0);
|
||||||
|
mZTLogsTable->setHorizontalHeaderLabels(QStringList() << "Station" << "Début" << "Fin");
|
||||||
|
// connect(mZTLogsTable,SIGNAL(cellClicked(int,int)),this,SLOT(LogsTableCellClicked(int,int)));
|
||||||
|
connect(mZTLogsTable,SIGNAL(currentCellChanged(int,int,int,int)),this,SLOT(LogsTableCellSelected(int,int,int,int)));
|
||||||
|
connect(mZTLogsTable,SIGNAL(cellDoubleClicked(int,int)),SLOT(TableDoubleClicked(int,int)));
|
||||||
|
|
||||||
|
mSummaryText = new QGraphicsTextItem(this);
|
||||||
|
QFont textfont;
|
||||||
|
textfont.setPointSize(12);
|
||||||
|
mSummaryText->setFont(textfont);
|
||||||
|
mSummaryText->setPlainText("ZTLog:");
|
||||||
|
mSummaryText->setPos(3,370);
|
||||||
|
|
||||||
|
QGraphicsProxyWidget *WidgetProxy = new QGraphicsProxyWidget(this);
|
||||||
|
QGraphicsTextItem *Label = new QGraphicsTextItem(this);
|
||||||
|
Label->setPlainText("Station:");
|
||||||
|
Label->setPos(190,418);
|
||||||
|
|
||||||
|
WidgetProxy = new QGraphicsProxyWidget(this);
|
||||||
|
mStationsFilterComboBox = new QComboBox();
|
||||||
|
WidgetProxy->setWidget(mStationsFilterComboBox);
|
||||||
|
WidgetProxy->setPos(250,420);
|
||||||
|
mStationsFilterComboBox->insertItems(0,QStringList() << "Toutes" << "Angrignon" << "Snowdon" << "Henri Bourassa" << "Honoré Beaugrand" << "Longueuil" << "Berri UQAM" << "Montmorency 10/12" << "Montmorency 10/22" << "Côte Vertu" << "Saint-Michel");
|
||||||
|
mStationsFilterComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||||
|
mStationsFilterComboBox->adjustSize();
|
||||||
|
mStationsFilterComboBox->setMaxVisibleItems(15);
|
||||||
|
connect(mStationsFilterComboBox,SIGNAL(activated(int)),this,SLOT(StationFilterSelected(int)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CZTLogsListPage::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
// mBackgroundRect->setRect(boundingRect());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CZTLogsListPage::ButtonClicked(CTextButtonWidget *BtnPtr)
|
||||||
|
{
|
||||||
|
// if(BtnPtr == mViewLogDataButton)
|
||||||
|
// {
|
||||||
|
// if(mLogMgrHandle->GetLogsCount() == 0)
|
||||||
|
// return;
|
||||||
|
|
||||||
|
// int cursel = mZTLogsTable->selectedItems().at(0)->data(Qt::UserRole).toInt();
|
||||||
|
// CLogElement* Element = mLogMgrHandle->GetLogsList()->at(cursel);
|
||||||
|
// mProgramHandle->LogViewRequest(mLogMgrHandle->LoadLogData(Element),this);
|
||||||
|
// mLogMgrHandle->FreeLogData(Element);
|
||||||
|
|
||||||
|
// }
|
||||||
|
// else if(BtnPtr == mExportCSVLogButton)
|
||||||
|
// {
|
||||||
|
// if(mLogMgrHandle->GetLogsCount() == 0)
|
||||||
|
// return;
|
||||||
|
|
||||||
|
// QString Filename;
|
||||||
|
// int cursel = mZTLogsTable->selectedItems().at(0)->data(Qt::UserRole).toInt();
|
||||||
|
// CLogElement* Element = mLogMgrHandle->GetLogsList()->at(cursel);
|
||||||
|
// mLogMgrHandle->LoadLogData(Element);
|
||||||
|
// if(Element->mZTLogType == ZT1_LOG_TYPE)
|
||||||
|
// {
|
||||||
|
// CZT1LogElement *temp = (CZT1LogElement*)Element;
|
||||||
|
// Filename = temp->mLogFileName.replace("bin","csv");
|
||||||
|
// CTrainLogFileMgr::instance()->SaveCSVFile(Filename,&temp->mZTLogData,&temp->mFlags,&temp->mZTDetections,temp->mStationName);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// CZT2LogElement *temp = (CZT2LogElement*)Element;
|
||||||
|
// Filename = temp->mLogFileName.replace("bin","csv");
|
||||||
|
// CTrainLogFileMgr::instance()->SaveCSVFile(Filename,&temp->mZTLogData,&temp->mZTDetections,temp->mStationName);
|
||||||
|
// }
|
||||||
|
// mLogMgrHandle->FreeLogData(Element);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CZTLogsListPage::RefreshList()
|
||||||
|
{
|
||||||
|
ClearTable();
|
||||||
|
mProgramHandle->ShowZTLogFile("");
|
||||||
|
|
||||||
|
QList<CZTLogFileInfo> *ZTLogsList = mZTLogFilesManager->GetZTLogsList();
|
||||||
|
|
||||||
|
if(ZTLogsList->size() == 0)
|
||||||
|
return RET_OK;
|
||||||
|
|
||||||
|
mZTLogsTable->setRowCount(ZTLogsList->size());
|
||||||
|
|
||||||
|
int CurRow = 0;
|
||||||
|
for(int i = 0; i < ZTLogsList->size(); i++)
|
||||||
|
{
|
||||||
|
QString stationtext = mStationsFilterComboBox->currentText();
|
||||||
|
if(ZTLogsList->at(i).mStationName == stationtext || stationtext == "Toutes")
|
||||||
|
{
|
||||||
|
QTableWidgetItem * NewItem = new QTableWidgetItem(ZTLogsList->at(i).mStationName);
|
||||||
|
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
NewItem->setData(Qt::UserRole,QVariant(i));
|
||||||
|
mZTLogsTable->setItem(CurRow,0,NewItem);
|
||||||
|
|
||||||
|
NewItem = new QTableWidgetItem(ZTLogsList->at(i).mStartDateTime.toString("yyyy/MM/dd - hh:mm:ss"));
|
||||||
|
NewItem->setData(Qt::UserRole,QVariant(i));
|
||||||
|
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
mZTLogsTable->setItem(CurRow,1,NewItem);
|
||||||
|
|
||||||
|
NewItem = new QTableWidgetItem(ZTLogsList->at(i).mEndDateTime.toString("yyyy/MM/dd - hh:mm:ss"));
|
||||||
|
NewItem->setData(Qt::UserRole,QVariant(i));
|
||||||
|
NewItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
mZTLogsTable->setItem(CurRow,2,NewItem);
|
||||||
|
|
||||||
|
CurRow++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mZTLogsTable->setRowCount(CurRow);
|
||||||
|
|
||||||
|
mZTLogsTable->resizeColumnsToContents();
|
||||||
|
|
||||||
|
mZTLogsTable->sortItems(0,Qt::DescendingOrder);
|
||||||
|
|
||||||
|
mZTLogsTable->setCurrentCell(0,0);
|
||||||
|
LogsTableCellClicked(0,0);
|
||||||
|
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CZTLogsListPage::ClearTable()
|
||||||
|
{
|
||||||
|
for(int Col = 0; Col < mZTLogsTable->columnCount(); Col++)
|
||||||
|
{
|
||||||
|
for(int Row = 0; Row < mZTLogsTable->rowCount(); Row++)
|
||||||
|
{
|
||||||
|
delete mZTLogsTable->item(Row,Col);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mZTLogsTable->setRowCount(0);
|
||||||
|
mZTLogsTable->clearContents();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CZTLogsListPage::LogsTableCellSelected( int row, int col, int prevrow, int prevcol)
|
||||||
|
{
|
||||||
|
Q_UNUSED(prevrow)
|
||||||
|
Q_UNUSED(prevcol)
|
||||||
|
|
||||||
|
|
||||||
|
if(row < 0 || col < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
LogsTableCellClicked(row,col);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CZTLogsListPage::LogsTableCellClicked(int row, int column)
|
||||||
|
{
|
||||||
|
Q_UNUSED(column);
|
||||||
|
|
||||||
|
int rowcount = mZTLogsTable->rowCount();
|
||||||
|
if(rowcount == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
QList<CZTLogFileInfo> *ZTLogsList = mZTLogFilesManager->GetZTLogsList();
|
||||||
|
|
||||||
|
if(mZTLogsTable->item(row,0) == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int ItemIndex = mZTLogsTable->item(row,0)->data(Qt::UserRole).toInt();
|
||||||
|
|
||||||
|
|
||||||
|
QFile *ZTLogFile = new QFile(ZTLogsList->at(ItemIndex).mZTLogFilePath);
|
||||||
|
if(ZTLogFile)
|
||||||
|
{
|
||||||
|
ZTLogFile->open(QIODevice::ReadOnly | QIODevice::Text);
|
||||||
|
QString str = ZTLogFile->readAll();
|
||||||
|
|
||||||
|
ZTLogFile->close();
|
||||||
|
|
||||||
|
delete ZTLogFile;
|
||||||
|
|
||||||
|
mProgramHandle->ShowZTLogFile(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CZTLogsListPage::StationFilterSelected(int Index)
|
||||||
|
{
|
||||||
|
Q_UNUSED(Index);
|
||||||
|
RefreshList();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Grab the mouse if the user clicks outside buttons
|
||||||
|
void CZTLogsListPage::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
// qDebug("CLogsListPage");
|
||||||
|
Q_UNUSED(event)
|
||||||
|
}
|
||||||
|
void CZTLogsListPage::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
}
|
||||||
|
void CZTLogsListPage::CheckBoxClicked(int state)
|
||||||
|
{
|
||||||
|
Q_UNUSED(state)
|
||||||
|
RefreshList();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CZTLogsListPage::TableDoubleClicked(int row, int col)
|
||||||
|
{
|
||||||
|
Q_UNUSED(col)
|
||||||
|
Q_UNUSED(row)
|
||||||
|
//ButtonClicked(mViewLogDataButton);
|
||||||
|
}
|
||||||
91
sources/GuiElements/ZTLogsListPage.h
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Description du fichier si nécessaire.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131024 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef ZTLOGSLISTPAGE_H
|
||||||
|
#define ZTLOGSLISTPAGE_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
#include "Guipage.h"
|
||||||
|
#include <QString>
|
||||||
|
#include "PushButton.h"
|
||||||
|
#include "TextButtonWidget.h"
|
||||||
|
#include <QTableWidget>
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include "ZTData.h"
|
||||||
|
#include "ZTLogFilesMgr.h"
|
||||||
|
|
||||||
|
class COutilZT;
|
||||||
|
|
||||||
|
class CZTLogsListPage : public CGuiPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
virtual ~CZTLogsListPage();
|
||||||
|
CZTLogsListPage(QGraphicsWidget *Parent = 0);
|
||||||
|
|
||||||
|
|
||||||
|
COutilZT *mProgramHandle;
|
||||||
|
CZTLogFilesMgr *mZTLogFilesManager;
|
||||||
|
|
||||||
|
unsigned int RefreshList();
|
||||||
|
|
||||||
|
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||||
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
QTableWidget *mZTLogsTable;
|
||||||
|
QGraphicsTextItem *mSummaryText;
|
||||||
|
QTimer *mListParsingTimer;
|
||||||
|
QComboBox *mStationsFilterComboBox;
|
||||||
|
|
||||||
|
QString mStationFilter;
|
||||||
|
|
||||||
|
QList<CZTLogFileInfo> *mZTLogFilesList;
|
||||||
|
|
||||||
|
|
||||||
|
void ClearTable();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void ButtonClicked(CTextButtonWidget *);
|
||||||
|
void LogsTableCellClicked(int, int);
|
||||||
|
void LogsTableCellSelected(int,int,int,int);
|
||||||
|
void CheckBoxClicked(int);
|
||||||
|
void TableDoubleClicked(int,int);
|
||||||
|
void StationFilterSelected(int);
|
||||||
|
|
||||||
|
// void ParsingTimerExipred();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOGSLISTPAGE_H
|
||||||
643
sources/LogMgr.cpp
Normal file
@ -0,0 +1,643 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 - 2013 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Cette classe est responsable de la création d'une liste d'objets CLogElement
|
||||||
|
à partir des données de passage des trains contenues dans les fichiers log.
|
||||||
|
Cette classe est principalement utilisée par l'interface graphique pour la
|
||||||
|
visualisation des passages.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20121024 JFM
|
||||||
|
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "LogMgr.h"
|
||||||
|
|
||||||
|
#include "TrainLogFileMgr.h"
|
||||||
|
#include "OutilZT.h"
|
||||||
|
//#include "ZTLog.h"
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QBuffer>
|
||||||
|
|
||||||
|
CLogMgr::CLogMgr()
|
||||||
|
{
|
||||||
|
mProgramHandle = 0;
|
||||||
|
|
||||||
|
mDirParserThread = new QThread();
|
||||||
|
mDirParserWorkerThread = new CDirParserThread();
|
||||||
|
mDirParserWorkerThread->moveToThread(mDirParserThread);
|
||||||
|
connect(mDirParserThread,SIGNAL(started()),mDirParserWorkerThread,SLOT(ParseDirectories()));
|
||||||
|
connect(mDirParserThread,SIGNAL(finished()),this,SLOT(ThreadQuit()));
|
||||||
|
connect(mDirParserThread,SIGNAL(terminated()),this,SLOT(ThreadTerminated()));
|
||||||
|
// connect(mDirParserWorkerThread,SIGNAL(NewLogParsed(QString,bool)),this,SLOT(NewLogParsed(QString,bool)));
|
||||||
|
connect(mDirParserWorkerThread,SIGNAL(NewLogParsed(CLogElement*)),this,SLOT(NewLogParsed(CLogElement*)));
|
||||||
|
connect(mDirParserWorkerThread,SIGNAL(ParsingFinished(int)),this,SLOT(DirParsingFinished(int)));
|
||||||
|
connect(mDirParserWorkerThread,SIGNAL(EmptyDirParsed()),this,SLOT(EmptyDirParsed()));
|
||||||
|
|
||||||
|
mDatabaseParsingTimer = new QTimer();
|
||||||
|
mDatabaseParsingTimer->setInterval(60000);
|
||||||
|
connect(mDatabaseParsingTimer,SIGNAL(timeout()),this,SLOT(ParsingTimerExpired()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CLogMgr::~CLogMgr()
|
||||||
|
{
|
||||||
|
DestroyLogList();
|
||||||
|
delete mDirParserThread;
|
||||||
|
delete mDirParserWorkerThread;
|
||||||
|
delete mDatabaseParsingTimer;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CLogMgr::DestroyLogList()
|
||||||
|
{
|
||||||
|
for(int i = 0; i < mPassagesList.size(); i++)
|
||||||
|
{
|
||||||
|
delete mPassagesList.at(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
mPassagesList.clear();
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CLogMgr::ProtectLogElementFile(bool IsProtected, CLogElement *Element)
|
||||||
|
{
|
||||||
|
if(Element->mZTLogType == ZT1_LOG_TYPE)
|
||||||
|
{
|
||||||
|
CZT1LogElement *ZT1Element = (CZT1LogElement*)Element;
|
||||||
|
if(CTrainLogFileMgr::instance()->SetTrainLogProtected(IsProtected,ZT1Element->mLogFileName) == RET_OK)
|
||||||
|
{
|
||||||
|
ZT1Element->mFileProtected = IsProtected;
|
||||||
|
SaveDatabaseFile();
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(Element->mZTLogType == ZT2_LOG_TYPE)
|
||||||
|
{
|
||||||
|
CZT2LogElement *ZT2Element = (CZT2LogElement*)Element;
|
||||||
|
if(CTrainLogFileMgr::instance()->SetTrainLogProtected(IsProtected,ZT2Element->mLogFileName) == RET_OK)
|
||||||
|
{
|
||||||
|
ZT2Element->mFileProtected = IsProtected;
|
||||||
|
SaveDatabaseFile();
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
unsigned int CLogMgr::ParseLogs(bool RebuildDatabase, bool KeepData)
|
||||||
|
{
|
||||||
|
DestroyLogList();
|
||||||
|
qDebug("Parsing Logs now...");
|
||||||
|
|
||||||
|
mSaveDBFile = false;
|
||||||
|
mParsingFinished = false;
|
||||||
|
mProgramHandle->DatabaseFetchingBegin(this);
|
||||||
|
mDatabaseFileCounter = 0;
|
||||||
|
if(RebuildDatabase == true)
|
||||||
|
{
|
||||||
|
qDebug("Rebuilding database now...");
|
||||||
|
mDirParserWorkerThread->SetParsingInfo(QDir(mLogDataDir),"*.bin",KeepData);
|
||||||
|
qDebug("Starting parser thread now...");
|
||||||
|
mDirParserThread->start();
|
||||||
|
mSaveDBFile = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Load database file.
|
||||||
|
QDir BaseDir(mLogDataDir);
|
||||||
|
QString DatabaseFilePath = BaseDir.filePath("Trains.zdb");
|
||||||
|
// DatabaseFilePath += "Trains.zdb";
|
||||||
|
QFile* DatabaseFile = new QFile(BaseDir.filePath("Trains.zdb")/*DatabaseFilePath*/);
|
||||||
|
if(DatabaseFile)
|
||||||
|
{
|
||||||
|
if(DatabaseFile->open(QIODevice::ReadOnly | QIODevice::Unbuffered) == false)
|
||||||
|
{
|
||||||
|
//rebuild database...
|
||||||
|
qDebug("Failed to open Trains.zdb, rebuilding database now...");
|
||||||
|
mDirParserWorkerThread->SetParsingInfo(QDir(mLogDataDir),"*.bin",KeepData);
|
||||||
|
qDebug("Starting parser thread now...");
|
||||||
|
mDirParserThread->start();
|
||||||
|
mSaveDBFile = true;
|
||||||
|
delete DatabaseFile;
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DirParsingFinished(0);
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QByteArray DBData = DatabaseFile->readAll();
|
||||||
|
QDataStream *DBStrm = new QDataStream(DBData);
|
||||||
|
|
||||||
|
qint32 NBRecords;
|
||||||
|
*DBStrm >> NBRecords;
|
||||||
|
|
||||||
|
for(qint32 i = 0; i < NBRecords; i++)
|
||||||
|
{
|
||||||
|
unsigned int LogType;
|
||||||
|
*DBStrm >> LogType;
|
||||||
|
|
||||||
|
if(LogType == ZT1_LOG_TYPE)
|
||||||
|
{
|
||||||
|
CZT1LogElement *NewElement = new CZT1LogElement;
|
||||||
|
|
||||||
|
|
||||||
|
*DBStrm >> NewElement->mPassageDateTime
|
||||||
|
>> NewElement->mTrainType
|
||||||
|
>> NewElement->mNbElements
|
||||||
|
>> NewElement->mThreadDataStartTime
|
||||||
|
>> NewElement->mThreadDataEndTime
|
||||||
|
>> NewElement->mLogFileName
|
||||||
|
>> NewElement->mMeanSpeed
|
||||||
|
>> NewElement->mFlags
|
||||||
|
>> NewElement->mStationName
|
||||||
|
>> NewElement->mFileProtected;
|
||||||
|
|
||||||
|
int NBDetect;
|
||||||
|
*DBStrm >> NBDetect;
|
||||||
|
|
||||||
|
for(int i = 0; i < NBDetect; i++)
|
||||||
|
{
|
||||||
|
CZTDetectionData *NewDetection = new CZTDetectionData;
|
||||||
|
*DBStrm >> NewDetection->mDetectionID
|
||||||
|
>> NewDetection->mRank
|
||||||
|
>> NewDetection->mTimeStamp;
|
||||||
|
|
||||||
|
NewElement->mZTDetections.append(NewDetection);
|
||||||
|
}
|
||||||
|
NewLogParsed(NewElement);
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(LogType == ZT2_LOG_TYPE)
|
||||||
|
{
|
||||||
|
CZT2LogElement *NewElement = new CZT2LogElement;
|
||||||
|
|
||||||
|
|
||||||
|
*DBStrm >> NewElement->mPassageDateTime
|
||||||
|
>> NewElement->mLogFileName
|
||||||
|
>> NewElement->mNbElements
|
||||||
|
>> NewElement-> mStationName
|
||||||
|
>> NewElement->mFlags
|
||||||
|
>> NewElement->mFileProtected;
|
||||||
|
|
||||||
|
int NBDetect;
|
||||||
|
*DBStrm >> NBDetect;
|
||||||
|
|
||||||
|
for(int i = 0; i < NBDetect; i++)
|
||||||
|
{
|
||||||
|
CZTDetectionData *NewDetection = new CZTDetectionData;
|
||||||
|
*DBStrm >> NewDetection->mDetectionID
|
||||||
|
>> NewDetection->mRank
|
||||||
|
>> NewDetection->mTimeStamp;
|
||||||
|
|
||||||
|
NewElement->mZTDetections.append(NewDetection);
|
||||||
|
}
|
||||||
|
|
||||||
|
NewLogParsed(NewElement);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug("Invalid logtype in DB file...");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DatabaseFile->close();
|
||||||
|
delete DatabaseFile;
|
||||||
|
delete DBStrm;
|
||||||
|
|
||||||
|
DirParsingFinished(1);
|
||||||
|
|
||||||
|
}
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CLogMgr::SaveDatabaseFile()
|
||||||
|
{
|
||||||
|
|
||||||
|
QDir BaseDir(mLogDataDir);
|
||||||
|
QString DatabaseFilePath = BaseDir.filePath("Trains.zdb");
|
||||||
|
// DatabaseFilePath += "Trains.zdb";
|
||||||
|
QFile* DatabaseFile = new QFile(BaseDir.filePath("Trains.zdb")/*DatabaseFilePath*/);
|
||||||
|
|
||||||
|
|
||||||
|
if(DatabaseFile)
|
||||||
|
{
|
||||||
|
if(DatabaseFile->open(QIODevice::WriteOnly | QIODevice::Unbuffered) == false)
|
||||||
|
{
|
||||||
|
QMessageBox::information(0,"Erreur","Impossible de créer le fichier DB");
|
||||||
|
delete DatabaseFile;
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMessageBox::information(0,"Erreur","Impossible de créer le fichier DB");
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QByteArray byteArray;
|
||||||
|
QBuffer FileBuffer(&byteArray);
|
||||||
|
FileBuffer.open(QIODevice::WriteOnly);
|
||||||
|
QDataStream *DBStrm = new QDataStream(&FileBuffer);
|
||||||
|
|
||||||
|
qint32 NBRecords = mPassagesList.size();
|
||||||
|
*DBStrm << NBRecords;
|
||||||
|
|
||||||
|
for(qint32 i = 0; i < NBRecords; i++)
|
||||||
|
{
|
||||||
|
unsigned int LogType = mPassagesList.at(i)->mZTLogType;
|
||||||
|
*DBStrm << LogType;
|
||||||
|
|
||||||
|
if(LogType == ZT1_LOG_TYPE)
|
||||||
|
{
|
||||||
|
CZT1LogElement *NewElement = (CZT1LogElement*)mPassagesList.at(i);
|
||||||
|
|
||||||
|
|
||||||
|
*DBStrm << NewElement->mPassageDateTime
|
||||||
|
<< NewElement->mTrainType
|
||||||
|
<< NewElement->mNbElements
|
||||||
|
<< NewElement->mThreadDataStartTime
|
||||||
|
<< NewElement->mThreadDataEndTime
|
||||||
|
<< NewElement->mLogFileName
|
||||||
|
<< NewElement->mMeanSpeed
|
||||||
|
<< NewElement->mFlags
|
||||||
|
<< NewElement->mStationName
|
||||||
|
<< NewElement->mFileProtected;
|
||||||
|
|
||||||
|
int NBDetect = NewElement->mZTDetections.size();
|
||||||
|
*DBStrm << NBDetect;
|
||||||
|
|
||||||
|
for(int i = 0; i < NBDetect; i++)
|
||||||
|
{
|
||||||
|
*DBStrm << NewElement->mZTDetections.at(i)->mDetectionID
|
||||||
|
<< NewElement->mZTDetections.at(i)->mRank
|
||||||
|
<< NewElement->mZTDetections.at(i)->mTimeStamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(LogType == ZT2_LOG_TYPE)
|
||||||
|
{
|
||||||
|
CZT2LogElement *NewElement = (CZT2LogElement*)mPassagesList.at(i);
|
||||||
|
|
||||||
|
|
||||||
|
*DBStrm << NewElement->mPassageDateTime
|
||||||
|
<< NewElement->mLogFileName
|
||||||
|
<< NewElement->mNbElements
|
||||||
|
<< NewElement->mStationName
|
||||||
|
<< NewElement->mFlags
|
||||||
|
<< NewElement->mFileProtected;
|
||||||
|
|
||||||
|
int NBDetect = NewElement->mZTDetections.size();
|
||||||
|
*DBStrm << NBDetect;
|
||||||
|
|
||||||
|
for(int i = 0; i < NBDetect; i++)
|
||||||
|
{
|
||||||
|
*DBStrm << NewElement->mZTDetections.at(i)->mDetectionID
|
||||||
|
<< NewElement->mZTDetections.at(i)->mRank
|
||||||
|
<< NewElement->mZTDetections.at(i)->mTimeStamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug("Invalid log type in array!!!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FileBuffer.seek(0);
|
||||||
|
DatabaseFile->write(FileBuffer.buffer());
|
||||||
|
DatabaseFile->flush();
|
||||||
|
|
||||||
|
FileBuffer.close();
|
||||||
|
DatabaseFile->close();
|
||||||
|
delete DatabaseFile;
|
||||||
|
delete DBStrm;
|
||||||
|
mSaveDBFile = false;
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CLogMgr::RebuildDatabaseFile()
|
||||||
|
{
|
||||||
|
ParseLogs(true,false);
|
||||||
|
mSaveDBFile = true;
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int CLogMgr::ParseDir(QDir dir, bool KeepData)
|
||||||
|
{
|
||||||
|
|
||||||
|
QStringList LogFilters;
|
||||||
|
QFileInfoList list;
|
||||||
|
// QString LogDataDir = mProgramHandle->GetLogDataPath();
|
||||||
|
LogFilters << "*.bin";
|
||||||
|
|
||||||
|
//Load files in base directory
|
||||||
|
QDir LogDir(dir);
|
||||||
|
LogDir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
|
||||||
|
LogDir.setNameFilters(LogFilters);
|
||||||
|
LogDir.setSorting(QDir::Name);
|
||||||
|
list = LogDir.entryInfoList();
|
||||||
|
if(list.size() != 0)
|
||||||
|
{
|
||||||
|
//Extract data for each passage
|
||||||
|
for(int i = 0; i < list.size(); i++)
|
||||||
|
{
|
||||||
|
ParseNewLog(list.at(i).filePath(),KeepData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Check for subdirectories
|
||||||
|
QDir SubDirectories(dir);
|
||||||
|
|
||||||
|
SubDirectories.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
|
|
||||||
|
QFileInfoList SubDirList = SubDirectories.entryInfoList();
|
||||||
|
for(int i = 0; i < SubDirList.size(); i++)
|
||||||
|
{
|
||||||
|
ParseDir(QDir(SubDirList.at(i).absoluteFilePath()), KeepData);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
CLogElement* CLogMgr::LoadLogData(CLogElement *Element)
|
||||||
|
{
|
||||||
|
if(Element->mZTLogType == ZT1_LOG_TYPE)
|
||||||
|
{
|
||||||
|
CZT1LogElement *TargetElement = (CZT1LogElement*)Element;
|
||||||
|
QString FilePath = TargetElement->mLogFileName;
|
||||||
|
unsigned int ret;
|
||||||
|
|
||||||
|
//Make shure that the lists are empty in the target element
|
||||||
|
for(int i = 0; i < TargetElement->mZTLogData.size(); i++)
|
||||||
|
{
|
||||||
|
delete TargetElement->mZTLogData.at(i);
|
||||||
|
}
|
||||||
|
for(int i = 0; i < TargetElement->mZTDetections.size(); i++)
|
||||||
|
{
|
||||||
|
delete TargetElement->mZTDetections.at(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
TargetElement->mZTLogData.clear();
|
||||||
|
TargetElement->mZTDetections.clear();
|
||||||
|
|
||||||
|
//Passing the TargetElement to the OpenTrainLog function will fill it with data
|
||||||
|
CTrainLogFileMgr::instance()->OpenTrainLog(FilePath,ret,TargetElement,true);
|
||||||
|
|
||||||
|
return (CLogElement*)TargetElement;
|
||||||
|
}
|
||||||
|
else if(Element->mZTLogType == ZT2_LOG_TYPE)
|
||||||
|
{
|
||||||
|
CZT2LogElement *TargetElement = (CZT2LogElement*)Element;
|
||||||
|
QString FilePath = TargetElement->mLogFileName;
|
||||||
|
unsigned int ret;
|
||||||
|
|
||||||
|
//Make shure that the lists are empty in the target element
|
||||||
|
for(int i = 0; i < TargetElement->mZTLogData.size(); i++)
|
||||||
|
{
|
||||||
|
delete TargetElement->mZTLogData.at(i);
|
||||||
|
}
|
||||||
|
for(int i = 0; i < TargetElement->mZTDetections.size(); i++)
|
||||||
|
{
|
||||||
|
delete TargetElement->mZTDetections.at(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
TargetElement->mZTLogData.clear();
|
||||||
|
TargetElement->mZTDetections.clear();
|
||||||
|
|
||||||
|
//Passing the TargetElement to the OpenTrainLog function will fill it with data
|
||||||
|
CTrainLogFileMgr::instance()->OpenTrainLog(FilePath,ret,TargetElement,true);
|
||||||
|
|
||||||
|
return (CLogElement*)TargetElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CLogMgr::FreeLogData(CLogElement *Element)
|
||||||
|
{
|
||||||
|
if(Element->mZTLogType == ZT1_LOG_TYPE)
|
||||||
|
{
|
||||||
|
CZT1LogElement *temp = (CZT1LogElement*)Element;
|
||||||
|
for(int i = 0; i < temp->mZTLogData.size(); i++)
|
||||||
|
delete temp->mZTLogData.at(i);
|
||||||
|
temp->mZTLogData.clear();
|
||||||
|
}
|
||||||
|
if(Element->mZTLogType == ZT2_LOG_TYPE)
|
||||||
|
{
|
||||||
|
CZT2LogElement *temp = (CZT2LogElement*)Element;
|
||||||
|
for(int i = 0; i < temp->mZTLogData.size(); i++)
|
||||||
|
delete temp->mZTLogData.at(i);
|
||||||
|
temp->mZTLogData.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CLogMgr::DeleteLog(int LogIndex)
|
||||||
|
{
|
||||||
|
if(LogIndex >= mPassagesList.size())
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
QString Filename;
|
||||||
|
|
||||||
|
CLogElement *Element = mPassagesList.takeAt(LogIndex);
|
||||||
|
FreeLogData(Element); //make shure no data will be leaked
|
||||||
|
{
|
||||||
|
if(Element->mZTLogType == ZT1_LOG_TYPE)
|
||||||
|
{
|
||||||
|
CZT1LogElement *temp = (CZT1LogElement*)Element;
|
||||||
|
Filename = temp->mLogFileName;
|
||||||
|
|
||||||
|
}
|
||||||
|
if(Element->mZTLogType == ZT2_LOG_TYPE)
|
||||||
|
{
|
||||||
|
CZT2LogElement *temp = (CZT2LogElement*)Element;
|
||||||
|
Filename = temp->mLogFileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QDir DirObject;
|
||||||
|
DirObject.remove(Filename);
|
||||||
|
delete Element;
|
||||||
|
|
||||||
|
SaveDatabaseFile();
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CLogMgr::ParseNextLog()
|
||||||
|
{
|
||||||
|
if((int)mLogsFileIndex >= mLogsFilelist.size())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
//Extract data
|
||||||
|
|
||||||
|
if(ParseNewLog(mLogsFilelist.at(mLogsFileIndex).filePath()) == RET_ERROR)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
mLogsFileIndex++;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLogMgr::NewLogParsed(QString Filename,bool KeepData)
|
||||||
|
{
|
||||||
|
ParseNewLog(Filename,KeepData);
|
||||||
|
mDatabaseParsingTimer->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLogMgr::NewLogParsed(CLogElement * NewLog)
|
||||||
|
{
|
||||||
|
mPassagesList.append(NewLog);
|
||||||
|
mDatabaseParsingTimer->start();
|
||||||
|
mProgramHandle->DatabaseFetchingTick(this,mDatabaseFileCounter++);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLogMgr::DirParsingFinished(int Res)
|
||||||
|
{
|
||||||
|
|
||||||
|
mDatabaseParsingTimer->stop();
|
||||||
|
mParsingFinished = true;
|
||||||
|
mDirParserThread->quit();
|
||||||
|
mProgramHandle->LogsDatabaseLoaded(this,Res);
|
||||||
|
|
||||||
|
if(mSaveDBFile == true)
|
||||||
|
{
|
||||||
|
SaveDatabaseFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLogMgr::ParsingTimerExpired()
|
||||||
|
{
|
||||||
|
qDebug("Parsing timer timeout");
|
||||||
|
mDirParserWorkerThread->KillThread();
|
||||||
|
mDirParserThread->terminate();
|
||||||
|
DirParsingFinished(2);
|
||||||
|
|
||||||
|
}
|
||||||
|
void CLogMgr::EmptyDirParsed()
|
||||||
|
{
|
||||||
|
//The thread is not stuck. Kick the timer...
|
||||||
|
mDatabaseParsingTimer->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLogMgr::ThreadQuit()
|
||||||
|
{
|
||||||
|
qDebug("Thread quit slot");
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLogMgr::ThreadTerminated()
|
||||||
|
{
|
||||||
|
qDebug("Thread terminated slot");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int CLogMgr::ParseNewLog(QString FileName, bool KeepData)
|
||||||
|
{
|
||||||
|
Q_UNUSED(KeepData)
|
||||||
|
|
||||||
|
unsigned int ret;
|
||||||
|
CLogElement *NewLog = CTrainLogFileMgr::instance()->OpenTrainLog(FileName,ret);
|
||||||
|
|
||||||
|
if(ret == RET_ERROR)
|
||||||
|
{
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
//the date and time of the log entry is assigned the date and time of the first record...
|
||||||
|
if(NewLog->mZTLogType == ZT1_LOG_TYPE)
|
||||||
|
{
|
||||||
|
mPassagesList.append(NewLog);
|
||||||
|
}
|
||||||
|
else if(NewLog->mZTLogType == ZT2_LOG_TYPE)
|
||||||
|
{
|
||||||
|
mPassagesList.append(NewLog);
|
||||||
|
}
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CLogMgr::ParseImportedLogs(QStringList *NewLogFiles)
|
||||||
|
{
|
||||||
|
if(NewLogFiles == 0)
|
||||||
|
{
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < NewLogFiles->size(); i++)
|
||||||
|
{
|
||||||
|
ParseNewLog(NewLogFiles->at(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
SaveDatabaseFile();
|
||||||
|
mProgramHandle->LogsDatabaseLoaded(this,1);
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CLogMgr::GetLogsCount()
|
||||||
|
{
|
||||||
|
return mPassagesList.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<CLogElement*> * CLogMgr::GetLogsList()
|
||||||
|
{
|
||||||
|
return &mPassagesList;
|
||||||
|
}
|
||||||
|
|
||||||
|
CLogElement::~CLogElement()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
CZT1LogElement::~CZT1LogElement()
|
||||||
|
{
|
||||||
|
qDeleteAll(mZTLogData);
|
||||||
|
mZTLogData.clear();
|
||||||
|
|
||||||
|
qDeleteAll(mZTDetections);
|
||||||
|
mZTDetections.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
CZT2LogElement::~CZT2LogElement()
|
||||||
|
{
|
||||||
|
for(int i = 0; i < mZTLogData.size(); i++)
|
||||||
|
delete mZTLogData.at(i);
|
||||||
|
mZTLogData.clear();
|
||||||
|
|
||||||
|
for(int i = 0; i < mZTDetections.size(); i++)
|
||||||
|
delete mZTDetections.at(i);
|
||||||
|
mZTDetections.clear();
|
||||||
|
|
||||||
|
}
|
||||||
143
sources/LogMgr.h
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 - 2013 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Description du fichier si nécessaire.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### YYYMMDD JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef LOGMGR_H
|
||||||
|
#define LOGMGR_H
|
||||||
|
|
||||||
|
#include "ZTData.h"
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QList>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QReadWriteLock>
|
||||||
|
#include "DirParserThread.h"
|
||||||
|
|
||||||
|
class CLogElement
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
unsigned int mZTLogType;
|
||||||
|
virtual ~CLogElement();
|
||||||
|
};
|
||||||
|
//QDataStream &operator<<(QDataStream &out, const CLogElement &source);
|
||||||
|
//QDataStream &operator>>(QDataStream &in, CLogElement &dest);
|
||||||
|
|
||||||
|
class CZT1LogElement : public CLogElement
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CZT1LogElement(){mZTLogType=ZT1_LOG_TYPE;}
|
||||||
|
~CZT1LogElement();
|
||||||
|
QDateTime mPassageDateTime;
|
||||||
|
QVector<CZT1LogData*> mZTLogData;
|
||||||
|
QVector<CZTDetectionData*> mZTDetections;
|
||||||
|
quint32 mTrainType;
|
||||||
|
quint32 mNbElements;
|
||||||
|
quint64 mThreadDataStartTime, mThreadDataEndTime;
|
||||||
|
QString mLogFileName;
|
||||||
|
qreal mMeanSpeed;
|
||||||
|
CZT1FlagsData mFlags;
|
||||||
|
QString mStationName;
|
||||||
|
bool mFileProtected;
|
||||||
|
};
|
||||||
|
//QDataStream &operator<<(QDataStream &out, const CZT1LogElement &source);
|
||||||
|
//QDataStream &operator>>(QDataStream &in, CZT1LogElement &dest);
|
||||||
|
|
||||||
|
class CZT2LogElement : public CLogElement
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CZT2LogElement(){mZTLogType = ZT2_LOG_TYPE;}
|
||||||
|
~CZT2LogElement();
|
||||||
|
QDateTime mPassageDateTime;
|
||||||
|
QVector<CZT2LogData*> mZTLogData;
|
||||||
|
QVector<CZTDetectionData*> mZTDetections;
|
||||||
|
QString mLogFileName;
|
||||||
|
quint32 mNbElements;
|
||||||
|
QString mStationName;
|
||||||
|
CZT2FlagsData mFlags;
|
||||||
|
bool mFileProtected;
|
||||||
|
};
|
||||||
|
|
||||||
|
class COutilZT;
|
||||||
|
|
||||||
|
class CLogMgr : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CLogMgr();
|
||||||
|
~CLogMgr();
|
||||||
|
|
||||||
|
COutilZT *mProgramHandle;
|
||||||
|
|
||||||
|
unsigned int GetLogsCount();
|
||||||
|
QList<CLogElement*> *GetLogsList();
|
||||||
|
unsigned int ParseLogs(bool RebuildDatabase = false, bool KeepData = false);
|
||||||
|
unsigned int ParseNewLog(QString FileName, bool KeepData = false);
|
||||||
|
unsigned int ParseImportedLogs(QStringList *NewLogFiles);
|
||||||
|
CLogElement* LoadLogData(CLogElement * Element);
|
||||||
|
unsigned int FreeLogData(CLogElement * Element);
|
||||||
|
unsigned int DeleteLog(int LogIndex);
|
||||||
|
void SetLogDataDir(QString Dir){mLogDataDir = Dir;}
|
||||||
|
bool ParseNextLog();
|
||||||
|
unsigned int SaveDatabaseFile();
|
||||||
|
unsigned int RebuildDatabaseFile();
|
||||||
|
unsigned int ProtectLogElementFile(bool IsProtected, CLogElement *Element);
|
||||||
|
QTimer *mDatabaseParsingTimer;
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
CDirParserThread *mDirParserWorkerThread;
|
||||||
|
QThread *mDirParserThread;
|
||||||
|
QList<CLogElement*> mPassagesList;
|
||||||
|
unsigned int DestroyLogList();
|
||||||
|
int ParseDir(QDir dir, bool KeepData = false);
|
||||||
|
|
||||||
|
|
||||||
|
QFileInfoList mLogsFilelist;
|
||||||
|
unsigned int mLogsFileIndex;
|
||||||
|
QString mLogDataDir;
|
||||||
|
|
||||||
|
bool mParsingFinished;
|
||||||
|
unsigned int mDatabaseFileCounter;
|
||||||
|
bool mSaveDBFile;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void NewLogParsed(QString,bool);
|
||||||
|
void NewLogParsed(CLogElement*);
|
||||||
|
void DirParsingFinished(int);
|
||||||
|
void ParsingTimerExpired();
|
||||||
|
void EmptyDirParsed();
|
||||||
|
|
||||||
|
|
||||||
|
void ThreadQuit();
|
||||||
|
void ThreadTerminated();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // LOGMGR_H
|
||||||
|
|
||||||
226
sources/MainPanel.cpp
Normal file
@ -0,0 +1,226 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Classe qui crée la scène ainsi que les instances des différents objets
|
||||||
|
nécessaires à l'affichage.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20121210 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
#include "MainPanel.h"
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QGraphicsProxyWidget>
|
||||||
|
#include <QPixmap>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <QtGui>
|
||||||
|
#include <QColor>
|
||||||
|
|
||||||
|
//#include <QtPlugin>
|
||||||
|
//#ifndef Q_OS_WIN32
|
||||||
|
//Q_IMPORT_PLUGIN(qjpeg)
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
Panel::~Panel()
|
||||||
|
{
|
||||||
|
//if(scene)
|
||||||
|
//delete scene;
|
||||||
|
// delete mWelcomePage;
|
||||||
|
// delete mZTMainPage;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Panel::Panel()
|
||||||
|
{
|
||||||
|
|
||||||
|
scene = 0;
|
||||||
|
// setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);
|
||||||
|
// // setParent(0); // Create TopLevel-Widget
|
||||||
|
// setAttribute(Qt::WA_NoSystemBackground, true);
|
||||||
|
// setAttribute(Qt::WA_TranslucentBackground, true);
|
||||||
|
// setAttribute(Qt::WA_PaintOnScreen); // not needed in Qt 5.2 and up
|
||||||
|
|
||||||
|
//No Scrollbar
|
||||||
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
|
||||||
|
|
||||||
|
//Speed-up display
|
||||||
|
setCacheMode(CacheBackground);
|
||||||
|
setRenderHints(/*QPainter::Antialiasing | */QPainter::SmoothPixmapTransform/* | QPainter::TextAntialiasing*/);
|
||||||
|
setViewportUpdateMode(QGraphicsView::SmartViewportUpdate/*QGraphicsView::FullViewportUpdate*/);
|
||||||
|
|
||||||
|
// QPixmap background;
|
||||||
|
// background.load("./Images/GuiBackground.jpg");
|
||||||
|
// background = background.scaled(SCREEN_RES_WIDTH,SCREEN_RES_HEIGHT);
|
||||||
|
|
||||||
|
|
||||||
|
QLinearGradient BackgroundGradient(QPointF(rect().width()/2,0),QPointF(rect().width()/2,rect().height()));
|
||||||
|
BackgroundGradient.setColorAt(0.5,QColor(128,158,222));
|
||||||
|
BackgroundGradient.setColorAt(1,Qt::white);
|
||||||
|
QBrush BkBrush(BackgroundGradient);
|
||||||
|
setBackgroundBrush(BkBrush);
|
||||||
|
|
||||||
|
// QRectF bounds(0,0, QApplication::desktop()->geometry().width(),QApplication::desktop()->geometry().height());
|
||||||
|
QRectF bounds(0,0, SCREEN_RES_WIDTH,SCREEN_RES_HEIGHT);
|
||||||
|
scene = new QGraphicsScene(bounds, this);
|
||||||
|
setScene(scene);
|
||||||
|
|
||||||
|
//resize(QApplication::desktop()->geometry().width(),QApplication::desktop()->geometry().height());
|
||||||
|
|
||||||
|
resize(SCREEN_RES_WIDTH,SCREEN_RES_HEIGHT);
|
||||||
|
////////////////////////
|
||||||
|
|
||||||
|
setMouseTracking(true);
|
||||||
|
|
||||||
|
|
||||||
|
mMainPage = new CMainPage();
|
||||||
|
mDatabaseModeLogViewPage = new CLogViewPage();
|
||||||
|
mDatabaseModeLogListPage = new CLogsListPage();
|
||||||
|
mOptionsPage = new COptionsPage();
|
||||||
|
mNetworkZTListPage = new CNetworkZTListPage();
|
||||||
|
mNetworkCtrlPage = new CNetworkCtrlPage();
|
||||||
|
mRemoteZTPage = new CRemoteZTPage();
|
||||||
|
mZTLogViewerPage = new CZTLogViewerPage(0,false);
|
||||||
|
mNetworkModeLogListPage = new CLogsListPage();
|
||||||
|
mNetworkModeLogViewPage = new CLogViewPage();
|
||||||
|
mProgressBarPage = new CProgressBarPage();
|
||||||
|
mRemoteZTCtrlPage = new CRemoteZTCtrlPage();
|
||||||
|
mDatabaseMgrPage = new CDatabaseMgrPage();
|
||||||
|
mZTLogsListPage = new CZTLogsListPage();
|
||||||
|
mZTLogFileViewerPage = new CZTLogViewerPage(0,true);
|
||||||
|
|
||||||
|
|
||||||
|
scene->addItem(mMainPage);
|
||||||
|
scene->addItem(mDatabaseModeLogViewPage);
|
||||||
|
scene->addItem(mDatabaseModeLogListPage);
|
||||||
|
scene->addItem(mOptionsPage);
|
||||||
|
scene->addItem(mNetworkZTListPage);
|
||||||
|
scene->addItem(mNetworkCtrlPage);
|
||||||
|
scene->addItem(mRemoteZTPage);
|
||||||
|
scene->addItem(mZTLogViewerPage);
|
||||||
|
scene->addItem(mNetworkModeLogListPage);
|
||||||
|
scene->addItem(mNetworkModeLogViewPage);
|
||||||
|
scene->addItem(mProgressBarPage);
|
||||||
|
scene->addItem(mRemoteZTCtrlPage);
|
||||||
|
scene->addItem(mDatabaseMgrPage);
|
||||||
|
scene->addItem(mZTLogsListPage);
|
||||||
|
scene->addItem(mZTLogFileViewerPage);
|
||||||
|
|
||||||
|
|
||||||
|
mMainPage->setPos(0,0);
|
||||||
|
mMainPage->show();
|
||||||
|
mMainPage->setZValue(0);
|
||||||
|
mMainPage->resize(10,SCREEN_RES_HEIGHT);
|
||||||
|
|
||||||
|
mDatabaseModeLogViewPage->setPos(SCREEN_RES_WIDTH-980,0);
|
||||||
|
mDatabaseModeLogViewPage->resize(980,SCREEN_RES_HEIGHT);
|
||||||
|
mDatabaseModeLogViewPage->setZValue(0);
|
||||||
|
mDatabaseModeLogViewPage->DisableCloseButton();
|
||||||
|
mDatabaseModeLogViewPage->show();
|
||||||
|
|
||||||
|
mDatabaseModeLogListPage->setPos(100,0);
|
||||||
|
mDatabaseModeLogListPage->resize(400,SCREEN_RES_HEIGHT-100);
|
||||||
|
mDatabaseModeLogListPage->setZValue(1);
|
||||||
|
mDatabaseModeLogListPage->show();
|
||||||
|
|
||||||
|
mZTLogsListPage->setPos(100,0);
|
||||||
|
mZTLogsListPage->resize(SCREEN_RES_WIDTH,SCREEN_RES_HEIGHT);
|
||||||
|
mZTLogsListPage->setZValue(0);
|
||||||
|
mZTLogsListPage->hide();
|
||||||
|
|
||||||
|
mZTLogFileViewerPage->resize(980,700);
|
||||||
|
mZTLogFileViewerPage->setPos(600,10);
|
||||||
|
mZTLogFileViewerPage->hide();
|
||||||
|
mZTLogFileViewerPage->setZValue(0);
|
||||||
|
|
||||||
|
mOptionsPage->setPos(412,100);
|
||||||
|
mOptionsPage->hide();
|
||||||
|
mOptionsPage->resize(600,600);
|
||||||
|
mOptionsPage->setZValue(1);
|
||||||
|
|
||||||
|
mDatabaseMgrPage->setPos(412,100);
|
||||||
|
mDatabaseMgrPage->hide();
|
||||||
|
mDatabaseMgrPage->resize(644,400);
|
||||||
|
mDatabaseMgrPage->setZValue(1);
|
||||||
|
|
||||||
|
mNetworkZTListPage->setPos(100,0);
|
||||||
|
mNetworkZTListPage->setZValue(0);
|
||||||
|
mNetworkZTListPage->hide();
|
||||||
|
|
||||||
|
mNetworkCtrlPage->setPos(100,325);
|
||||||
|
mNetworkCtrlPage->resize(150,150);
|
||||||
|
mNetworkCtrlPage->setZValue(0);
|
||||||
|
mNetworkCtrlPage->hide();
|
||||||
|
|
||||||
|
mRemoteZTPage->setPos(450,0);
|
||||||
|
mRemoteZTPage->resize(SCREEN_RES_WIDTH-450,SCREEN_RES_HEIGHT);
|
||||||
|
mRemoteZTPage->setZValue(0);
|
||||||
|
mRemoteZTPage->hide();
|
||||||
|
|
||||||
|
mZTLogViewerPage->setPos(400,84);
|
||||||
|
mZTLogViewerPage->hide();
|
||||||
|
mZTLogViewerPage->resize(800,600);
|
||||||
|
mZTLogViewerPage->setZValue(1);
|
||||||
|
|
||||||
|
mNetworkModeLogListPage->setPos(1000,0);
|
||||||
|
mNetworkModeLogListPage->resize(400,SCREEN_RES_HEIGHT-100);
|
||||||
|
mNetworkModeLogListPage->setZValue(1);
|
||||||
|
mNetworkModeLogListPage->show();
|
||||||
|
|
||||||
|
mNetworkModeLogViewPage->setPos(SCREEN_RES_WIDTH-980,0);
|
||||||
|
mNetworkModeLogViewPage->resize(980,SCREEN_RES_HEIGHT);
|
||||||
|
mNetworkModeLogViewPage->setZValue(1);
|
||||||
|
mNetworkModeLogViewPage->EnableCloseButton();
|
||||||
|
mNetworkModeLogViewPage->hide();
|
||||||
|
|
||||||
|
mRemoteZTCtrlPage->setPos(1000,0);
|
||||||
|
mRemoteZTCtrlPage->resize(400,SCREEN_RES_HEIGHT-100);
|
||||||
|
mRemoteZTCtrlPage->hide();
|
||||||
|
mRemoteZTCtrlPage->setZValue(0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
mProgressBarPage->setPos(500,300);
|
||||||
|
// mProgressBarPage->resize(400,300);
|
||||||
|
mProgressBarPage->setZValue(2);
|
||||||
|
mProgressBarPage->hide();
|
||||||
|
|
||||||
|
installEventFilter(mDatabaseModeLogViewPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Panel::ShowMainPage()
|
||||||
|
{
|
||||||
|
mMainPage->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Panel::HideMainPAge()
|
||||||
|
{
|
||||||
|
mMainPage->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
//void Panel::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
//{
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
101
sources/MainPanel.h
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
#ifndef PANEL_H
|
||||||
|
#define PANEL_H
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Description du fichier si nécessaire.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20121210 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QtGui/qgraphicsview.h>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QGraphicsTextItem>
|
||||||
|
|
||||||
|
#include "Guipage.h"
|
||||||
|
#include "MainPage.h"
|
||||||
|
#include "LogViewPage.h"
|
||||||
|
#include "LogsListPage.h"
|
||||||
|
#include "OptionsPage.h"
|
||||||
|
#include "NetworkZTListPage.h"
|
||||||
|
#include "NetworkCtrlPage.h"
|
||||||
|
#include "RemoteZTPage.h"
|
||||||
|
#include "ZTLogViewerPage.h"
|
||||||
|
#include "ProgressBarPage.h"
|
||||||
|
#include "RemoteZTCtrlPage.h"
|
||||||
|
#include "DatabaseMgrPage.h"
|
||||||
|
#include "ZTLogsListPage.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Panel : public QGraphicsView
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
//QFile Ledfd;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Panel();
|
||||||
|
~Panel();
|
||||||
|
// virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
|
void HideWelcomePage(void);
|
||||||
|
|
||||||
|
void ShowMainPage(void);
|
||||||
|
void HideMainPAge(void);
|
||||||
|
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
// void AudioPageButtonClicked();
|
||||||
|
// void mMailMsgButtonPressed();
|
||||||
|
// void BusScheduleButtonPressed();
|
||||||
|
// void DayScheduleButtonPressed();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
QGraphicsScene *scene;
|
||||||
|
CMainPage *mMainPage;
|
||||||
|
|
||||||
|
//Database mode display
|
||||||
|
CLogViewPage *mDatabaseModeLogViewPage;
|
||||||
|
CLogsListPage *mDatabaseModeLogListPage;
|
||||||
|
COptionsPage *mOptionsPage;
|
||||||
|
CDatabaseMgrPage *mDatabaseMgrPage;
|
||||||
|
|
||||||
|
//Network mode display
|
||||||
|
CNetworkZTListPage *mNetworkZTListPage;
|
||||||
|
CNetworkCtrlPage *mNetworkCtrlPage;
|
||||||
|
CRemoteZTPage *mRemoteZTPage;
|
||||||
|
CZTLogViewerPage *mZTLogViewerPage;
|
||||||
|
CLogViewPage *mNetworkModeLogViewPage;
|
||||||
|
CLogsListPage *mNetworkModeLogListPage;
|
||||||
|
CRemoteZTCtrlPage *mRemoteZTCtrlPage;
|
||||||
|
CZTLogViewerPage *mZTLogFileViewerPage;
|
||||||
|
|
||||||
|
//ZTLogs mode display
|
||||||
|
CZTLogsListPage *mZTLogsListPage;
|
||||||
|
|
||||||
|
CProgressBarPage *mProgressBarPage;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PANEL_H
|
||||||
500
sources/NetworkManager.cpp
Normal file
@ -0,0 +1,500 @@
|
|||||||
|
#include "NetworkManager.h"
|
||||||
|
#include <QDebug>
|
||||||
|
#include "OutilZT.h"
|
||||||
|
|
||||||
|
CNetworkManager CNetworkManager::mSingleton;
|
||||||
|
|
||||||
|
CNetworkManager::CNetworkManager(QObject *parent) :
|
||||||
|
QObject(parent)
|
||||||
|
{
|
||||||
|
mConfig = 0;
|
||||||
|
mCurZTID = 0;
|
||||||
|
mProgramHandle = 0;
|
||||||
|
mZTUDPSocket = 0;
|
||||||
|
mUDPServerAdress = QHostAddress::Null;
|
||||||
|
|
||||||
|
mNetworkSMState = NETWORK_SM_STANDBY_STATE;
|
||||||
|
mOnlineCheckNetworkSMState = NETWORK_ONLINE_CHK_SM_STANDBY_STATE;
|
||||||
|
|
||||||
|
// mZTTcpSocket.setSocketOption(QAbstractSocket::LowDelayOption,1);
|
||||||
|
connect(&mZTTcpSocket,SIGNAL(connected()),this,SLOT(SocketConnected()));
|
||||||
|
connect(&mZTTcpSocket,SIGNAL(disconnected()),this,SLOT(SocketDisconnected()));
|
||||||
|
connect(&mZTTcpSocket,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(SocketError(QAbstractSocket::SocketError)));
|
||||||
|
connect(&mZTTcpSocket,SIGNAL(readyRead()),this,SLOT(SocketDataReady()));
|
||||||
|
|
||||||
|
mZTOnlineCheckingSocket.setSocketOption(QAbstractSocket::LowDelayOption,1);
|
||||||
|
connect(&mZTOnlineCheckingSocket,SIGNAL(connected()),this,SLOT(OnlineCheckSocketConnected()));
|
||||||
|
connect(&mZTOnlineCheckingSocket,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(OnlineCheckSocketError(QAbstractSocket::SocketError)));
|
||||||
|
|
||||||
|
}
|
||||||
|
CNetworkManager::~CNetworkManager()
|
||||||
|
{
|
||||||
|
mZTTcpSocket.disconnectFromHost();
|
||||||
|
mZTOnlineCheckingSocket.disconnectFromHost();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkManager::BindPointers(COutilZT *ProgramHandle)
|
||||||
|
{
|
||||||
|
mProgramHandle = ProgramHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkManager::OnlineCheckStateMachine(eNetworkSMEvent event)
|
||||||
|
{
|
||||||
|
switch(mOnlineCheckNetworkSMState)
|
||||||
|
{
|
||||||
|
case NETWORK_ONLINE_CHK_SM_INIT_STATE:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case NETWORK_ONLINE_CHK_SM_STANDBY_STATE:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case NETWORK_ONLINE_CHK_SM_CHECK_CONNECTIONS_STATE:
|
||||||
|
{
|
||||||
|
switch(event)
|
||||||
|
{
|
||||||
|
case NETWORK_SM_SOCKET_CONNECTED_EVENT:
|
||||||
|
{
|
||||||
|
// qDebug("%s Connected",mConfig->mNetworkCfgList.at(mCurZTID).mIPAdress.toAscii().data());
|
||||||
|
emit NetworkZTConnectionStatus(mOnlineCheckZTID,ZT_NETWORK_ONLINE_STATUS);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case NETWORK_SM_SOCKET_ERROR_EVENT:
|
||||||
|
{
|
||||||
|
// qDebug("%s Not connected",mConfig->mNetworkCfgList.at(mCurZTID).mIPAdress.toAscii().data());
|
||||||
|
emit NetworkZTConnectionStatus(mOnlineCheckZTID,ZT_NETWORK_OFFLINE_STATUS);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case NETWORK_SM_SOCKET_DISCONNECTED_EVENT:
|
||||||
|
{
|
||||||
|
//Nothing to do here but we need to manage it because it will be received each time we disconnect.
|
||||||
|
return;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
// qDebug("Unmanaged event in NETWORK_ONLINE_CHK_SM_CHECK_CONNECTIONS_STATE : %d",event);
|
||||||
|
return;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mOnlineCheckZTID++;
|
||||||
|
if(mNetworkSMState != NETWORK_SM_STANDBY_STATE)
|
||||||
|
{
|
||||||
|
//Skip the connected ZT if there is one.
|
||||||
|
if(mOnlineCheckZTID == mCurZTID)
|
||||||
|
{
|
||||||
|
mOnlineCheckZTID++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(mOnlineCheckZTID >= NB_ZT_ID)
|
||||||
|
{
|
||||||
|
mOnlineCheckNetworkSMState = NETWORK_ONLINE_CHK_SM_STANDBY_STATE;
|
||||||
|
mZTOnlineCheckingSocket.disconnectFromHost();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mZTOnlineCheckingSocket.disconnectFromHost();
|
||||||
|
// qDebug("Attempting to connect to %s",mConfig->mNetworkCfgList.at(mOnlineCheckZTID).mIPAdress.toAscii().data());
|
||||||
|
emit NetworkZTConnectionStatus(mOnlineCheckZTID,ZT_NETWORK_SEARCHING_STATUS);
|
||||||
|
mZTOnlineCheckingSocket.connectToHost(mConfig->mNetworkCfgList.at(mOnlineCheckZTID).mIPAdress,ZT_TCP_PORT);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkManager::NetworkStateMachine(eNetworkSMEvent event)
|
||||||
|
{
|
||||||
|
switch(mNetworkSMState)
|
||||||
|
{
|
||||||
|
case NETWORK_SM_INIT_STATE:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case NETWORK_SM_STANDBY_STATE:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case NETWORK_SM_INITIATE_CLIENT_CONNECTION_STATE:
|
||||||
|
{
|
||||||
|
switch(event)
|
||||||
|
{
|
||||||
|
case NETWORK_SM_SOCKET_CONNECTED_EVENT:
|
||||||
|
{
|
||||||
|
qDebug("%s Connected",mConfig->mNetworkCfgList.at(mCurZTID).mIPAdress.toAscii().data());
|
||||||
|
emit NetworkZTConnected(mCurZTID);
|
||||||
|
emit NetworkZTConnectionStatus(mCurZTID,ZT_NETWORK_CONNECTED_STATUS);
|
||||||
|
|
||||||
|
//RequestHeartbeat();
|
||||||
|
//mZTTcpSocket.write(GetStationNameReqPacket());
|
||||||
|
TCPTxRequest(GetStationNameReqPacket());
|
||||||
|
mNetworkSMState = NETWORK_SM_CLIENT_CONNECTED_STATE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case NETWORK_SM_SOCKET_ERROR_EVENT:
|
||||||
|
{
|
||||||
|
qDebug("%s Socket error",mConfig->mNetworkCfgList.at(mCurZTID).mIPAdress.toAscii().data());
|
||||||
|
emit NetworkZTConnectionError(mCurZTID);
|
||||||
|
mNetworkSMState = NETWORK_SM_STANDBY_STATE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case NETWORK_SM_SOCKET_DISCONNECTED_EVENT:
|
||||||
|
{
|
||||||
|
mNetworkSMState = NETWORK_SM_STANDBY_STATE;
|
||||||
|
emit NetworkZTConnectionStatus(mOnlineCheckZTID,ZT_NETWORK_UNKNOWN_STATUS);
|
||||||
|
emit NetworkZTConnectionError(mCurZTID);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
mNetworkSMState = NETWORK_SM_STANDBY_STATE;
|
||||||
|
qDebug("Invalid event in NETWORK_SM_INITIATE_CLIENT_CONNECTION_STATE : %d",event);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case NETWORK_SM_CLIENT_CONNECTED_STATE:
|
||||||
|
{
|
||||||
|
switch(event)
|
||||||
|
{
|
||||||
|
case NETWORK_SM_SOCKET_ERROR_EVENT:
|
||||||
|
{
|
||||||
|
qDebug("%s Socket error",mConfig->mNetworkCfgList.at(mCurZTID).mIPAdress.toAscii().data());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case NETWORK_SM_SOCKET_DISCONNECTED_EVENT:
|
||||||
|
{
|
||||||
|
emit NetworkZTDisconnected(mCurZTID);
|
||||||
|
emit NetworkZTConnectionStatus(mCurZTID,ZT_NETWORK_UNKNOWN_STATUS);
|
||||||
|
mNetworkSMState = NETWORK_SM_STANDBY_STATE;
|
||||||
|
//qDebug("%s Disconnected",mConfig->mNetworkCfgList.at(mCurZTID).mIPAdress.toAscii().data());
|
||||||
|
qDebug("TCP Socket disconnected");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
qDebug("Unmanaged event in NETWORK_SM_CLIENT_CONNECTED_STATE : %d",event);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CNetworkManager::InitUDPConnection(int ZTID)
|
||||||
|
{
|
||||||
|
mZTUDPSocket = new QUdpSocket(this);
|
||||||
|
if(mZTUDPSocket->bind(QHostAddress::Any,ZT_UDP_PORT) == false)
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
mUDPServerAdress = QHostAddress(mConfig->mNetworkCfgList.at(ZTID).mIPAdress);
|
||||||
|
|
||||||
|
connect(mZTUDPSocket,SIGNAL(readyRead()),this,SLOT(UDPSocketDataReady()));
|
||||||
|
|
||||||
|
QByteArray packet = GetInitUDPConnectionPacket();
|
||||||
|
mZTUDPSocket->writeDatagram(packet,mUDPServerAdress,ZT_UDP_PORT);
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CNetworkManager::StopUDPStream()
|
||||||
|
{
|
||||||
|
if(mZTUDPSocket == 0)
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
|
||||||
|
QByteArray packet = GetCloseUDPConnectionPacket();
|
||||||
|
mZTUDPSocket->writeDatagram(packet,mUDPServerAdress,ZT_UDP_PORT);
|
||||||
|
mZTUDPSocket->waitForBytesWritten();
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CNetworkManager::CloseUDPConnection()
|
||||||
|
{
|
||||||
|
if(mZTUDPSocket == 0)
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
|
||||||
|
// QByteArray packet = GetCloseUDPConnectionPacket();
|
||||||
|
// mZTUDPSocket->writeDatagram(packet,mUDPServerAdress,ZT_UDP_PORT);
|
||||||
|
// mZTUDPSocket->flush();
|
||||||
|
|
||||||
|
delete mZTUDPSocket;
|
||||||
|
mZTUDPSocket = 0;
|
||||||
|
mUDPServerAdress = QHostAddress::Null;
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CNetworkManager::CheckZTConnectionsStatus()
|
||||||
|
{
|
||||||
|
if(mOnlineCheckNetworkSMState != NETWORK_ONLINE_CHK_SM_STANDBY_STATE)
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
mOnlineCheckZTID = 0;
|
||||||
|
mOnlineCheckNetworkSMState = NETWORK_ONLINE_CHK_SM_CHECK_CONNECTIONS_STATE;
|
||||||
|
|
||||||
|
emit NetworkZTConnectionStatus(mOnlineCheckZTID,ZT_NETWORK_SEARCHING_STATUS);
|
||||||
|
// qDebug("Attempting to connect to %s",mConfig->mNetworkCfgList.at(mOnlineCheckZTID).mIPAdress.toAscii().data());
|
||||||
|
mZTOnlineCheckingSocket.connectToHost(mConfig->mNetworkCfgList.at(mOnlineCheckZTID).mIPAdress,ZT_TCP_PORT);
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int CNetworkManager::SetConfig(CSettingsData *Config)
|
||||||
|
{
|
||||||
|
mConfig = Config;
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CNetworkManager::ConnectToZT(int ZTID)
|
||||||
|
{
|
||||||
|
if(ZTID >= NB_ZT_ID)
|
||||||
|
{
|
||||||
|
qDebug("Cannot connect: Invalid ZT ID");
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mNetworkSMState != NETWORK_SM_STANDBY_STATE)
|
||||||
|
{
|
||||||
|
qDebug("Cannot connect: Invalid State machine state : %d",mNetworkSMState);
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mCurZTID = ZTID;
|
||||||
|
mNetworkSMState = NETWORK_SM_INITIATE_CLIENT_CONNECTION_STATE;
|
||||||
|
mZTTcpSocket.connectToHost(mConfig->mNetworkCfgList.at(mCurZTID).mIPAdress,ZT_TCP_PORT);
|
||||||
|
qDebug("Connecting to %s", mConfig->mNetworkCfgList.at(mCurZTID).mIPAdress.toAscii().data());
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CNetworkManager::DisconnectZT()
|
||||||
|
{
|
||||||
|
// if(mNetworkSMState == NETWORK_SM_STANDBY_STATE)
|
||||||
|
// return RET_ERROR;
|
||||||
|
|
||||||
|
if(mNetworkSMState != NETWORK_SM_CLIENT_CONNECTED_STATE)
|
||||||
|
{
|
||||||
|
qDebug("Aborting connection from ZT. Socket state : %d",mZTTcpSocket.state());
|
||||||
|
mZTTcpSocket.abort();
|
||||||
|
NetworkStateMachine(NETWORK_SM_SOCKET_DISCONNECTED_EVENT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug("Disconnecting from ZT. Socket state : %d",mZTTcpSocket.state());
|
||||||
|
mZTTcpSocket.disconnectFromHost();
|
||||||
|
}
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkManager::TCPTxRequest(const QByteArray &request)
|
||||||
|
{
|
||||||
|
qDebug() << "Tx request in Network Manager : " << request.size() << " bytes : " << request.toHex();
|
||||||
|
emit NetworkTCPTx();
|
||||||
|
mZTTcpSocket.write(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CNetworkManager::RefreshRemoteZTStatus()
|
||||||
|
{
|
||||||
|
if(mNetworkSMState != NETWORK_SM_CLIENT_CONNECTED_STATE)
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
TCPTxRequest(GetZTStatusReqPacket());
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CNetworkManager::DownloadZTLog()
|
||||||
|
{
|
||||||
|
if(mNetworkSMState != NETWORK_SM_CLIENT_CONNECTED_STATE)
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
TCPTxRequest(GetZTLogDownloadReqPacket());
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CNetworkManager::DownloadTrainLogs()
|
||||||
|
{
|
||||||
|
if(mNetworkSMState != NETWORK_SM_CLIENT_CONNECTED_STATE)
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
TCPTxRequest(GetTrainLogsDownloadReqPacket());
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CNetworkManager::DeleteRemoteZTLog()
|
||||||
|
{
|
||||||
|
if(mNetworkSMState != NETWORK_SM_CLIENT_CONNECTED_STATE)
|
||||||
|
return RET_ERROR;
|
||||||
|
TCPTxRequest(GetDeleteZTLogReqPacket());
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CNetworkManager::SetZTFunctions(const CTCPZTFunctionsStatus &ZTFunctions)
|
||||||
|
{
|
||||||
|
if(mNetworkSMState != NETWORK_SM_CLIENT_CONNECTED_STATE)
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
QByteArray data;
|
||||||
|
QDataStream strm(&data,QIODevice::WriteOnly);
|
||||||
|
strm.device()->seek(0);
|
||||||
|
|
||||||
|
strm << ZTFunctions;
|
||||||
|
|
||||||
|
TCPTxRequest(GetSetZTFunctionsPacket(data));
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//slots
|
||||||
|
void CNetworkManager::SocketConnected()
|
||||||
|
{
|
||||||
|
qDebug("Socket connected slot");
|
||||||
|
NetworkStateMachine(NETWORK_SM_SOCKET_CONNECTED_EVENT);
|
||||||
|
}
|
||||||
|
void CNetworkManager::SocketDisconnected()
|
||||||
|
{
|
||||||
|
qDebug("Socket disconnected slot");
|
||||||
|
NetworkStateMachine(NETWORK_SM_SOCKET_DISCONNECTED_EVENT);
|
||||||
|
}
|
||||||
|
void CNetworkManager::SocketError(QAbstractSocket::SocketError socketError)
|
||||||
|
{
|
||||||
|
qDebug("Socket error slot. Error:[%d]",socketError);
|
||||||
|
NetworkStateMachine(NETWORK_SM_SOCKET_ERROR_EVENT);
|
||||||
|
}
|
||||||
|
void CNetworkManager::SocketDataReady()
|
||||||
|
{
|
||||||
|
// qDebug() << "Socket data ready:" << mZTTcpSocket.bytesAvailable();
|
||||||
|
emit NetworkTCPRx();
|
||||||
|
AnalyzeNewData(mZTTcpSocket.readAll());
|
||||||
|
}
|
||||||
|
void CNetworkManager::OnlineCheckSocketConnected()
|
||||||
|
{
|
||||||
|
OnlineCheckStateMachine(NETWORK_SM_SOCKET_CONNECTED_EVENT);
|
||||||
|
}
|
||||||
|
void CNetworkManager::OnlineCheckSocketError(QAbstractSocket::SocketError socketError)
|
||||||
|
{
|
||||||
|
OnlineCheckStateMachine(NETWORK_SM_SOCKET_ERROR_EVENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkManager::TCPRxHeartbeat()
|
||||||
|
{
|
||||||
|
qDebug() << "TCP: Received Heartbeat";
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkManager::TCPRxStationName(QString Name)
|
||||||
|
{
|
||||||
|
qDebug() << "TCP: Received station name:" << Name;
|
||||||
|
mProgramHandle->RxStationName(Name);
|
||||||
|
|
||||||
|
mZTTcpSocket.write(GetZTStatusReqPacket());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkManager::TCPRxZTStatus(const QByteArray &data)
|
||||||
|
{
|
||||||
|
|
||||||
|
CTCPZTStatus status;
|
||||||
|
|
||||||
|
QDataStream stream(data);
|
||||||
|
stream.device()->seek(0);
|
||||||
|
|
||||||
|
stream >> status;
|
||||||
|
|
||||||
|
qDebug() << "TCP: Received ZT Status";
|
||||||
|
|
||||||
|
mProgramHandle->RxZTStatus(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkManager::TCPRxZTLog(QString ZTLog)
|
||||||
|
{
|
||||||
|
mProgramHandle->RxZTLog(ZTLog);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkManager::TCPRxTrainLogsDownladAck(qint32 NbFiles)
|
||||||
|
{
|
||||||
|
qDebug("TCP: Received downoad train files ack : %d",NbFiles);
|
||||||
|
mProgramHandle->DownloadTrainLogsBegin(NbFiles);
|
||||||
|
|
||||||
|
|
||||||
|
mZTTcpSocket.write(GetTrainLogsFileDataAckPacket((qint32)TCP_PROTOCOL_ACK));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkManager::TCPRxTrainLogFileData(const QByteArray &TrainFileData)
|
||||||
|
{
|
||||||
|
QDataStream strm(TrainFileData);
|
||||||
|
strm.device()->seek(0);
|
||||||
|
|
||||||
|
QString LogFilePathName;
|
||||||
|
strm >> LogFilePathName;
|
||||||
|
|
||||||
|
LogFilePathName.prepend(mProgramHandle->GetTrainLogsTempPath());
|
||||||
|
|
||||||
|
QFile* BinaryLogFile = new QFile(LogFilePathName);
|
||||||
|
if(BinaryLogFile)
|
||||||
|
{
|
||||||
|
if(BinaryLogFile->open(QIODevice::WriteOnly) == false)
|
||||||
|
{
|
||||||
|
qDebug("Could not create log file : %s",LogFilePathName.toLatin1().data());
|
||||||
|
delete BinaryLogFile;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BinaryLogFile->write(strm.device()->readAll());
|
||||||
|
|
||||||
|
BinaryLogFile->close();
|
||||||
|
delete BinaryLogFile;
|
||||||
|
|
||||||
|
mProgramHandle->RxTrainLogData(LogFilePathName);
|
||||||
|
|
||||||
|
mZTTcpSocket.write(GetTrainLogsFileDataAckPacket((qint32)TCP_PROTOCOL_ACK));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkManager::TCPRxTrainLogsDownloadFinished()
|
||||||
|
{
|
||||||
|
mProgramHandle->RxTrainLogsDownloadFinished();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkManager::TCPRxDeleteZTLogAck(bool success)
|
||||||
|
{
|
||||||
|
mProgramHandle->RemoteZTLogDeleted(success);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkManager::TCPRxSetZTFunctionsAck(bool ack)
|
||||||
|
{
|
||||||
|
mProgramHandle->SetZTFunctionsSatusDone(ack);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNetworkManager::UDPSocketDataReady()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
127
sources/NetworkManager.h
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
#ifndef NETWORKMANAGER_H
|
||||||
|
#define NETWORKMANAGER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include "ZTData.h"
|
||||||
|
#include <QTcpSocket>
|
||||||
|
#include <QUdpSocket>
|
||||||
|
#include "TCPProtocol.h"
|
||||||
|
#include "UDPProtocol.h"
|
||||||
|
|
||||||
|
class COutilZT;
|
||||||
|
|
||||||
|
class CNetworkManager : public QObject, public CTCPProtocol, public CUDPProtocol
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
|
||||||
|
enum eZTNetworkStatus
|
||||||
|
{
|
||||||
|
ZT_NETWORK_OFFLINE_STATUS,
|
||||||
|
ZT_NETWORK_ONLINE_STATUS,
|
||||||
|
ZT_NETWORK_SEARCHING_STATUS,
|
||||||
|
ZT_NETWORK_UNKNOWN_STATUS,
|
||||||
|
ZT_NETWORK_CONNECTED_STATUS
|
||||||
|
};
|
||||||
|
|
||||||
|
static CNetworkManager* instance(){return &mSingleton;}
|
||||||
|
static CNetworkManager mSingleton;
|
||||||
|
|
||||||
|
explicit CNetworkManager(QObject *parent = 0);
|
||||||
|
~CNetworkManager();
|
||||||
|
|
||||||
|
void BindPointers(COutilZT *ProgramHandle);
|
||||||
|
unsigned int SetConfig(CSettingsData *Config);
|
||||||
|
unsigned int ConnectToZT(int ZTID);
|
||||||
|
unsigned int DisconnectZT();
|
||||||
|
unsigned int RefreshRemoteZTStatus();
|
||||||
|
unsigned int DownloadZTLog();
|
||||||
|
unsigned int DownloadTrainLogs();
|
||||||
|
unsigned int DeleteRemoteZTLog();
|
||||||
|
unsigned int SetZTFunctions(const CTCPZTFunctionsStatus &ZTFunctions);
|
||||||
|
|
||||||
|
unsigned int InitUDPConnection(int ZTID);
|
||||||
|
unsigned int StopUDPStream();
|
||||||
|
unsigned int CloseUDPConnection();
|
||||||
|
|
||||||
|
int CheckZTConnectionsStatus();
|
||||||
|
|
||||||
|
virtual void TCPTxRequest(const QByteArray &request);
|
||||||
|
virtual void TCPRxHeartbeat();
|
||||||
|
virtual void TCPRxStationName(QString Name);
|
||||||
|
virtual void TCPRxZTStatus(const QByteArray &data);
|
||||||
|
virtual void TCPRxZTLog(QString ZTLog);
|
||||||
|
virtual void TCPRxTrainLogsDownladAck(qint32 NbFiles);
|
||||||
|
virtual void TCPRxTrainLogFileData(const QByteArray &TrainFileData);
|
||||||
|
virtual void TCPRxTrainLogsDownloadFinished();
|
||||||
|
virtual void TCPRxDeleteZTLogAck(bool success);
|
||||||
|
virtual void TCPRxSetZTFunctionsAck(bool ack);
|
||||||
|
|
||||||
|
private:
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
NETWORK_SM_INIT_STATE,
|
||||||
|
NETWORK_SM_STANDBY_STATE,
|
||||||
|
NETWORK_SM_INITIATE_CLIENT_CONNECTION_STATE,
|
||||||
|
NETWORK_SM_CLIENT_CONNECTED_STATE
|
||||||
|
|
||||||
|
}eNetworkSMState;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
NETWORK_ONLINE_CHK_SM_INIT_STATE,
|
||||||
|
NETWORK_ONLINE_CHK_SM_STANDBY_STATE,
|
||||||
|
NETWORK_ONLINE_CHK_SM_CHECK_CONNECTIONS_STATE
|
||||||
|
}eNetworkOnlineCheckSMState;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
NETWORK_SM_TIMER_EVENT,
|
||||||
|
NETWORK_SM_SOCKET_CONNECTED_EVENT,
|
||||||
|
NETWORK_SM_SOCKET_DISCONNECTED_EVENT,
|
||||||
|
NETWORK_SM_DATA_RX_EVENT,
|
||||||
|
NETWORK_SM_DATA_SEND_EVENT,
|
||||||
|
NETWORK_SM_SOCKET_ERROR_EVENT
|
||||||
|
}eNetworkSMEvent;
|
||||||
|
|
||||||
|
void NetworkStateMachine(eNetworkSMEvent event);
|
||||||
|
void OnlineCheckStateMachine(eNetworkSMEvent event);
|
||||||
|
|
||||||
|
QTcpSocket mZTTcpSocket;
|
||||||
|
QTcpSocket mZTOnlineCheckingSocket;
|
||||||
|
QUdpSocket *mZTUDPSocket;
|
||||||
|
QHostAddress mUDPServerAdress;
|
||||||
|
CSettingsData *mConfig;
|
||||||
|
eNetworkSMState mNetworkSMState;
|
||||||
|
eNetworkOnlineCheckSMState mOnlineCheckNetworkSMState;
|
||||||
|
|
||||||
|
|
||||||
|
int mCurZTID;
|
||||||
|
int mOnlineCheckZTID;
|
||||||
|
COutilZT *mProgramHandle;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void NetworkZTConnectionStatus(int,int);
|
||||||
|
void NetworkZTConnected(int);
|
||||||
|
void NetworkZTDisconnected(int);
|
||||||
|
void NetworkZTConnectionError(int);
|
||||||
|
void NetworkTCPTx();
|
||||||
|
void NetworkTCPRx();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
void SocketConnected();
|
||||||
|
void SocketDisconnected();
|
||||||
|
void SocketError(QAbstractSocket::SocketError socketError);
|
||||||
|
void SocketDataReady();
|
||||||
|
void OnlineCheckSocketError(QAbstractSocket::SocketError socketError);
|
||||||
|
void OnlineCheckSocketConnected();
|
||||||
|
|
||||||
|
void UDPSocketDataReady();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // NETWORKMANAGER_H
|
||||||
736
sources/OutilZT.cpp
Normal file
@ -0,0 +1,736 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Cette classe est considérée comme l'instance du programme qui
|
||||||
|
initialise et démarre tous les objets nécessaires.
|
||||||
|
Elle assure aussi la synchronisation de ces derniers à l'aide de sa
|
||||||
|
machine à états.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20121214 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "OutilZT.h"
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QTextCodec>
|
||||||
|
#include "NetworkManager.h"
|
||||||
|
|
||||||
|
#include <QByteArray>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
|
||||||
|
COutilZT::COutilZT()
|
||||||
|
{
|
||||||
|
panel.installEventFilter(this); //Install an event filter for CZoneTest to manage some events from GUI
|
||||||
|
|
||||||
|
}
|
||||||
|
COutilZT::~COutilZT()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int COutilZT::Start()
|
||||||
|
{
|
||||||
|
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
panel.mDatabaseModeLogListPage->mLogMgrHandle = &mDatabaseModeLogManager;
|
||||||
|
panel.mDatabaseModeLogListPage->mProgramHandle = this;
|
||||||
|
panel.mMainPage->mProgramHandle = this;
|
||||||
|
panel.mOptionsPage->mProgramHandle = this;
|
||||||
|
if(mIsEngMode == true)
|
||||||
|
{
|
||||||
|
panel.mOptionsPage->EnableEngineeringMode();
|
||||||
|
}
|
||||||
|
panel.mNetworkCtrlPage->mProgramHandle = this;
|
||||||
|
panel.mDatabaseMgrPage->mProgramHandle = this;
|
||||||
|
panel.mDatabaseMgrPage->mLogMgrHandle = &mDatabaseModeLogManager;
|
||||||
|
panel.mDatabaseMgrPage->mZTLogFilesManager = &mZTLogFilesManager;
|
||||||
|
if(mIsEngMode == true)
|
||||||
|
{
|
||||||
|
panel.mDatabaseMgrPage->EnableEngineeringMode();
|
||||||
|
}
|
||||||
|
if(mCanImport == true)
|
||||||
|
{
|
||||||
|
panel.mDatabaseMgrPage->EnableLogImport();
|
||||||
|
}
|
||||||
|
|
||||||
|
mDatabaseModeLogManager.mProgramHandle = this;
|
||||||
|
panel.mNetworkModeLogListPage->mProgramHandle = this;
|
||||||
|
panel.mNetworkModeLogListPage->mLogMgrHandle = &mNetworkModeLogManager;
|
||||||
|
panel.mNetworkModeLogViewPage->mProgramHandle = this;
|
||||||
|
mNetworkModeLogManager.mProgramHandle = this;
|
||||||
|
panel.mRemoteZTCtrlPage->mProgramHandle = this;
|
||||||
|
panel.mZTLogsListPage->mProgramHandle = this;
|
||||||
|
panel.mZTLogsListPage->mZTLogFilesManager = &mZTLogFilesManager;
|
||||||
|
if(mIsEngMode == true)
|
||||||
|
{
|
||||||
|
panel.mDatabaseModeLogListPage->EnableEngineeringMode();
|
||||||
|
panel.mNetworkModeLogListPage->EnableEngineeringMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
mSettingsFileMgr.LoadSettings(&mSettingsData);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CNetworkManager::instance()->BindPointers(this);
|
||||||
|
CNetworkManager::instance()->SetConfig(&mSettingsData);
|
||||||
|
panel.mNetworkZTListPage->SetConfig(&mSettingsData);
|
||||||
|
panel.mOptionsPage->SetSettings(&mSettingsData);
|
||||||
|
connect(CNetworkManager::instance(),SIGNAL(NetworkZTConnectionStatus(int,int)),panel.mNetworkZTListPage,SLOT(ZTNetworkStatusChanged(int,int)));
|
||||||
|
connect(CNetworkManager::instance(),SIGNAL(NetworkZTConnected(int)),panel.mNetworkCtrlPage,SLOT(NetworkZTConnected(int)));
|
||||||
|
connect(CNetworkManager::instance(),SIGNAL(NetworkZTConnectionError(int)),panel.mNetworkCtrlPage,SLOT(NetworkZTConnectionFailed(int)));
|
||||||
|
connect(CNetworkManager::instance(),SIGNAL(NetworkZTDisconnected(int)),panel.mNetworkCtrlPage,SLOT(NetworkZTConnectionFailed(int)));
|
||||||
|
connect(CNetworkManager::instance(),SIGNAL(NetworkTCPRx()),panel.mNetworkCtrlPage,SLOT(NetworkRx()));
|
||||||
|
connect(CNetworkManager::instance(),SIGNAL(NetworkTCPTx()),panel.mNetworkCtrlPage,SLOT(NetworkTx()));
|
||||||
|
|
||||||
|
connect(CNetworkManager::instance(),SIGNAL(NetworkZTConnected(int)),panel.mRemoteZTPage,SLOT(NetworkZTConnected(int)));
|
||||||
|
connect(CNetworkManager::instance(),SIGNAL(NetworkZTDisconnected(int)),panel.mRemoteZTPage,SLOT(NetworkZTDisconnected(int)));
|
||||||
|
|
||||||
|
// panel.mDatabaseModeLogListPage->RefreshList();
|
||||||
|
// panel.mZTLogsListPage->RefreshList();
|
||||||
|
|
||||||
|
//Show Graphic User Interface.
|
||||||
|
panel.setWindowTitle("Outil Zone Test");
|
||||||
|
panel.show();
|
||||||
|
|
||||||
|
|
||||||
|
mDatabaseModeLogManager.mProgramHandle = this;
|
||||||
|
mDatabaseModeLogManager.SetLogDataDir(GetLogDataPath());
|
||||||
|
mDatabaseModeLogManager.ParseLogs();
|
||||||
|
mNetworkModeLogManager.mProgramHandle = this;
|
||||||
|
mNetworkModeLogManager.SetLogDataDir(GetTrainLogsTempPath());
|
||||||
|
// mNetworkModeLogManager.ParseLogs();
|
||||||
|
mZTLogFilesManager.mProgramHandle = this;
|
||||||
|
mZTLogFilesManager.SetLogDataDir(GetLogDataPath());
|
||||||
|
mZTLogFilesManager.ParseZTLogFiles(false);
|
||||||
|
|
||||||
|
mOutilZTMode = MODE_INVALID;
|
||||||
|
// EnterNetworkModeRequest();
|
||||||
|
EnterDatabaseModeRequest();
|
||||||
|
|
||||||
|
mRebuildingDB = false;
|
||||||
|
|
||||||
|
// CNetworkManager::instance()->CheckZTConnectionsStatus();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int COutilZT::InitZT()
|
||||||
|
{
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void COutilZT::LogViewRequest(CLogElement *element, CLogsListPage *caller)
|
||||||
|
{
|
||||||
|
if(caller == panel.mDatabaseModeLogListPage)
|
||||||
|
{
|
||||||
|
panel.mDatabaseModeLogViewPage->SetLogData(element);
|
||||||
|
}
|
||||||
|
else if(caller == panel.mNetworkModeLogListPage)
|
||||||
|
{
|
||||||
|
panel.mNetworkModeLogViewPage->SetLogData(element);
|
||||||
|
ShowNetworkModeLogViewRequest();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::SetLogProtection(bool Protection, CLogElement* Element, CLogsListPage *Caller)
|
||||||
|
{
|
||||||
|
if(Caller == panel.mDatabaseModeLogListPage)
|
||||||
|
{
|
||||||
|
if(mDatabaseModeLogManager.ProtectLogElementFile(Protection,Element) == RET_OK)
|
||||||
|
{
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void COutilZT::LogViewCloseRequest(CLogViewPage *caller)
|
||||||
|
{
|
||||||
|
if(caller == panel.mNetworkModeLogViewPage)
|
||||||
|
{
|
||||||
|
HideNetworkModeLogViewRequest();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void COutilZT::ShowOptionsRequest()
|
||||||
|
{
|
||||||
|
panel.mOptionsPage->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void COutilZT::HideOptionsRequest()
|
||||||
|
{
|
||||||
|
panel.mOptionsPage->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void COutilZT::ShowDatabaseMgrRequest()
|
||||||
|
{
|
||||||
|
panel.mDatabaseMgrPage->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void COutilZT::HideDatabaseMgrRequest()
|
||||||
|
{
|
||||||
|
panel.mDatabaseMgrPage->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void COutilZT::EnterDatabaseModeRequest()
|
||||||
|
{
|
||||||
|
if(mOutilZTMode == MODE_DATABASE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
panel.mNetworkZTListPage->hide();
|
||||||
|
panel.mNetworkCtrlPage->hide();
|
||||||
|
panel.mRemoteZTPage->hide();
|
||||||
|
panel.mNetworkModeLogListPage->hide();
|
||||||
|
panel.mNetworkModeLogViewPage->hide();
|
||||||
|
panel.mRemoteZTCtrlPage->hide();
|
||||||
|
|
||||||
|
panel.mZTLogsListPage->hide();
|
||||||
|
panel.mZTLogFileViewerPage->hide();
|
||||||
|
|
||||||
|
panel.mDatabaseModeLogListPage->show();
|
||||||
|
panel.mDatabaseModeLogViewPage->show();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
mOutilZTMode = MODE_DATABASE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void COutilZT::EnterNetworkModeRequest()
|
||||||
|
{
|
||||||
|
if(mOutilZTMode == MODE_NETWORK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
panel.mDatabaseModeLogListPage->hide();
|
||||||
|
panel.mDatabaseModeLogViewPage->hide();
|
||||||
|
|
||||||
|
panel.mNetworkZTListPage->show();
|
||||||
|
panel.mNetworkCtrlPage->show();
|
||||||
|
panel.mRemoteZTPage->show();
|
||||||
|
panel.mNetworkModeLogListPage->show();
|
||||||
|
panel.mNetworkModeLogViewPage->hide();
|
||||||
|
panel.mRemoteZTCtrlPage->hide();
|
||||||
|
|
||||||
|
panel.mZTLogsListPage->hide();
|
||||||
|
panel.mZTLogFileViewerPage->hide();
|
||||||
|
|
||||||
|
mOutilZTMode = MODE_NETWORK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void COutilZT::EnterZTLogModeRequest()
|
||||||
|
{
|
||||||
|
if(mOutilZTMode == MODE_ZTLOG)
|
||||||
|
return;
|
||||||
|
|
||||||
|
panel.mDatabaseModeLogListPage->hide();
|
||||||
|
panel.mDatabaseModeLogViewPage->hide();
|
||||||
|
|
||||||
|
panel.mNetworkZTListPage->hide();
|
||||||
|
panel.mNetworkCtrlPage->hide();
|
||||||
|
panel.mRemoteZTPage->hide();
|
||||||
|
panel.mNetworkModeLogListPage->hide();
|
||||||
|
panel.mNetworkModeLogViewPage->hide();
|
||||||
|
panel.mRemoteZTCtrlPage->hide();
|
||||||
|
|
||||||
|
panel.mZTLogsListPage->show();
|
||||||
|
panel.mZTLogFileViewerPage->show();
|
||||||
|
|
||||||
|
|
||||||
|
mOutilZTMode = MODE_ZTLOG;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void COutilZT::ShowZTLogRequest(QString Log,QString FocusText,int line)
|
||||||
|
{
|
||||||
|
panel.mZTLogViewerPage->SetZTLogText(Log,FocusText);
|
||||||
|
if(line != -1)
|
||||||
|
panel.mZTLogViewerPage->ScrollToLine(line);
|
||||||
|
|
||||||
|
panel.mZTLogViewerPage->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void COutilZT::ShowNetworkModeLogViewRequest()
|
||||||
|
{
|
||||||
|
// panel.mRemoteZTPage->hide();
|
||||||
|
panel.mNetworkModeLogListPage->hide();
|
||||||
|
panel.mNetworkModeLogViewPage->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void COutilZT::HideNetworkModeLogViewRequest()
|
||||||
|
{
|
||||||
|
// panel.mRemoteZTPage->show();
|
||||||
|
panel.mNetworkModeLogListPage->show();
|
||||||
|
panel.mNetworkModeLogViewPage->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void COutilZT::ShowRemoteControlPage()
|
||||||
|
{
|
||||||
|
panel.mRemoteZTPage->show();
|
||||||
|
panel.mNetworkModeLogListPage->hide();
|
||||||
|
panel.mNetworkModeLogViewPage->hide();
|
||||||
|
panel.mRemoteZTCtrlPage->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void COutilZT::ShowRemoteTrainLogsViewPages()
|
||||||
|
{
|
||||||
|
panel.mRemoteZTPage->show();
|
||||||
|
panel.mNetworkModeLogListPage->show();
|
||||||
|
panel.mNetworkModeLogViewPage->hide();
|
||||||
|
panel.mRemoteZTCtrlPage->hide();
|
||||||
|
}
|
||||||
|
void COutilZT::ShowRemoteLiveZTPage()
|
||||||
|
{
|
||||||
|
panel.mRemoteZTPage->hide();
|
||||||
|
panel.mNetworkModeLogListPage->hide();
|
||||||
|
panel.mNetworkModeLogViewPage->hide();
|
||||||
|
panel.mRemoteZTCtrlPage->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString COutilZT::GetLogDataPath()
|
||||||
|
{
|
||||||
|
return mSettingsData.mDataSourceDirectoryPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString COutilZT::GetTrainLogsTempPath()
|
||||||
|
{
|
||||||
|
return QString("./Temp/");
|
||||||
|
}
|
||||||
|
|
||||||
|
void COutilZT::CleanTrainLogsTempPath()
|
||||||
|
{
|
||||||
|
QDir TrainLogsTempDir(GetTrainLogsTempPath());
|
||||||
|
|
||||||
|
TrainLogsTempDir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
|
||||||
|
QFileInfoList fileslist = TrainLogsTempDir.entryInfoList();
|
||||||
|
for(int i = 0; i < fileslist.size(); i++)
|
||||||
|
{
|
||||||
|
QDir().remove(fileslist.at(i).filePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::DataSourceDirChanged(QString NewPath)
|
||||||
|
{
|
||||||
|
mSettingsData.mDataSourceDirectoryPath = NewPath;
|
||||||
|
mSettingsFileMgr.SaveSettings(&mSettingsData);
|
||||||
|
mDatabaseModeLogManager.SetLogDataDir(NewPath);
|
||||||
|
mZTLogFilesManager.SetLogDataDir(NewPath);
|
||||||
|
LogsDatabaseChanged(0);
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::NetworkDataChanged()
|
||||||
|
{
|
||||||
|
mSettingsFileMgr.SaveSettings(&mSettingsData);
|
||||||
|
|
||||||
|
//todo: Notify network manager...
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::LogsDatabaseChanged(QStringList *NewLogs)
|
||||||
|
{
|
||||||
|
if(NewLogs == 0)
|
||||||
|
{
|
||||||
|
mDatabaseModeLogManager.ParseLogs(true,false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mDatabaseModeLogManager.ParseImportedLogs(NewLogs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ZTLogFilesChanged();
|
||||||
|
mZTLogFilesManager.ParseZTLogFiles(true);
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::RebuildDatabaseFile()
|
||||||
|
{
|
||||||
|
mDatabaseModeLogManager.ParseLogs(true,false);
|
||||||
|
// mRebuildingDB = true;
|
||||||
|
mZTLogFilesManager.ParseZTLogFiles(true);
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::LogsDatabaseLoaded(CLogMgr *Caller, int Status)
|
||||||
|
{
|
||||||
|
if(Caller == &mDatabaseModeLogManager)
|
||||||
|
{
|
||||||
|
// QMessageBox::information(0,"Parsing Finished","Parsing finished");
|
||||||
|
if(Status == 1)
|
||||||
|
{
|
||||||
|
panel.mDatabaseModeLogListPage->RefreshList();
|
||||||
|
panel.mDatabaseMgrPage->UpdateDBStats();
|
||||||
|
// if(mRebuildingDB)
|
||||||
|
// {
|
||||||
|
// mZTLogFilesManager.ParseZTLogFiles(true);
|
||||||
|
// mRebuildingDB = false;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMessageBox::information(0,"Erreur","Impossible de charger la base de données");
|
||||||
|
}
|
||||||
|
panel.mProgressBarPage->hide();
|
||||||
|
}
|
||||||
|
if(Caller == &mNetworkModeLogManager)
|
||||||
|
{
|
||||||
|
panel.mNetworkModeLogListPage->RefreshList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::UpdateLogsList(CLogMgr *Caller)
|
||||||
|
{
|
||||||
|
if(Caller == &mDatabaseModeLogManager)
|
||||||
|
{
|
||||||
|
panel.mDatabaseModeLogListPage->RefreshList();
|
||||||
|
}
|
||||||
|
if(Caller == &mNetworkModeLogManager)
|
||||||
|
{
|
||||||
|
panel.mNetworkModeLogListPage->RefreshList();
|
||||||
|
}
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::DatabaseFetchingBegin(CLogMgr *Caller)
|
||||||
|
{
|
||||||
|
if(Caller == &mDatabaseModeLogManager)
|
||||||
|
{
|
||||||
|
panel.mProgressBarPage->SetProgressBarRange(0);
|
||||||
|
panel.mProgressBarPage->SetTitle("Chargement de la base de données");
|
||||||
|
panel.mProgressBarPage->SetMiscLabel("");
|
||||||
|
panel.mProgressBarPage->show();
|
||||||
|
}
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::DatabaseFetchingTick(CLogMgr *Caller,int Index)
|
||||||
|
{
|
||||||
|
// qDebug() << "Rx new Train Log: " << FileName;
|
||||||
|
|
||||||
|
if(Caller == &mDatabaseModeLogManager)
|
||||||
|
{
|
||||||
|
panel.mProgressBarPage->Tick();
|
||||||
|
panel.mProgressBarPage->SetMiscLabel(QString("%1 passages chargés").arg(Index));
|
||||||
|
}
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int COutilZT::ZTLogFilesChanged()
|
||||||
|
{
|
||||||
|
mZTLogFilesManager.SaveDatabaseFile();
|
||||||
|
mZTLogFilesManager.ParseZTLogFiles(false);
|
||||||
|
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int COutilZT::ShowZTLogFile(QString FilePath)
|
||||||
|
{
|
||||||
|
panel.mZTLogFileViewerPage->SetZTLogText(FilePath);
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::ZTLogFilesDatabaseLoaded(CZTLogFilesMgr *Caller, int Status)
|
||||||
|
{
|
||||||
|
if(Caller == &mZTLogFilesManager)
|
||||||
|
{
|
||||||
|
if(Status == 1)
|
||||||
|
{
|
||||||
|
panel.mZTLogsListPage->RefreshList();
|
||||||
|
panel.mDatabaseMgrPage->UpdateDBStats();
|
||||||
|
// panel.mProgressBarPage->hide();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// QMessageBox::information(0,"Parsing failed","Parsing failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::ZTLogFilesFetchingBegin(CZTLogFilesMgr *Caller)
|
||||||
|
{
|
||||||
|
if(Caller == &mZTLogFilesManager)
|
||||||
|
{
|
||||||
|
// panel.mProgressBarPage->SetProgressBarRange(0);
|
||||||
|
// panel.mProgressBarPage->SetTitle("Chargement des fichiers LOG");
|
||||||
|
// panel.mProgressBarPage->SetMiscLabel("");
|
||||||
|
// panel.mProgressBarPage->show();
|
||||||
|
}
|
||||||
|
return RET_OK;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::ZTLogFilesFetchingTick(CZTLogFilesMgr *Caller, int Index, QString File)
|
||||||
|
{
|
||||||
|
if(Caller == &mZTLogFilesManager)
|
||||||
|
{
|
||||||
|
// panel.mProgressBarPage->Tick();
|
||||||
|
// panel.mProgressBarPage->SetMiscLabel(QString("%1 passages chargés : %2").arg(Index).arg(File));
|
||||||
|
}
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::ConnectToZTRequest()
|
||||||
|
{
|
||||||
|
int ID = panel.mNetworkZTListPage->GetSelectedZT();
|
||||||
|
CNetworkManager::instance()->ConnectToZT(ID);
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::RxStationName(QString StationName)
|
||||||
|
{
|
||||||
|
panel.mRemoteZTPage->SetRemoteZTName(StationName);
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::DisconnectZTRequest()
|
||||||
|
{
|
||||||
|
return CNetworkManager::instance()->DisconnectZT();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::RefreshRemoteZTStatusRequest()
|
||||||
|
{
|
||||||
|
|
||||||
|
if(CNetworkManager::instance()->RefreshRemoteZTStatus() == RET_OK)
|
||||||
|
{
|
||||||
|
panel.mNetworkCtrlPage->DisableNetworkButtons();
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::RxZTStatus(const CTCPZTStatus &status)
|
||||||
|
{
|
||||||
|
panel.mNetworkCtrlPage->EnableNetworkButtons();
|
||||||
|
panel.mRemoteZTPage->SetRemoteZTStatus(&status);
|
||||||
|
panel.mRemoteZTCtrlPage->UpdateDisplay(&status);
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::DownloadZTLogRequest()
|
||||||
|
{
|
||||||
|
if(CNetworkManager::instance()->DownloadZTLog() == RET_OK)
|
||||||
|
{
|
||||||
|
panel.mNetworkCtrlPage->DisableNetworkButtons();
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::RxZTLog(QString ZTLog)
|
||||||
|
{
|
||||||
|
panel.mNetworkCtrlPage->EnableNetworkButtons();
|
||||||
|
panel.mZTLogViewerPage->SetZTLogText(ZTLog);
|
||||||
|
panel.mZTLogViewerPage->show();
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::DownloadTrainLogsRequest()
|
||||||
|
{
|
||||||
|
if(CNetworkManager::instance()->DownloadTrainLogs() == RET_OK)
|
||||||
|
{
|
||||||
|
panel.mNetworkCtrlPage->DisableNetworkButtons();
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::DownloadTrainLogsBegin(int NbLogs)
|
||||||
|
{
|
||||||
|
CleanTrainLogsTempPath();
|
||||||
|
panel.mProgressBarPage->SetProgressBarRange(NbLogs);
|
||||||
|
panel.mProgressBarPage->SetTitle(QString("Réception de %1 fichiers").arg(NbLogs));
|
||||||
|
panel.mProgressBarPage->SetMiscLabel("");
|
||||||
|
panel.mProgressBarPage->show();
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::RxTrainLogData(QString FileName)
|
||||||
|
{
|
||||||
|
|
||||||
|
qDebug() << "Rx new Train Log: " << FileName;
|
||||||
|
panel.mProgressBarPage->Tick();
|
||||||
|
panel.mProgressBarPage->SetMiscLabel(QString("Réception: %1").arg(FileName));
|
||||||
|
return RET_OK;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::RxTrainLogsDownloadFinished()
|
||||||
|
{
|
||||||
|
panel.mNetworkCtrlPage->EnableNetworkButtons();
|
||||||
|
qDebug("TrainLogs download finished");
|
||||||
|
mNetworkModeLogManager.ParseLogs();
|
||||||
|
panel.mNetworkModeLogListPage->RefreshList();
|
||||||
|
panel.mProgressBarPage->hide();
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::DeleteRemoteZTLogRequest()
|
||||||
|
{
|
||||||
|
if(CNetworkManager::instance()->DeleteRemoteZTLog() == RET_OK)
|
||||||
|
{
|
||||||
|
panel.mNetworkCtrlPage->DisableNetworkButtons();
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::RemoteZTLogDeleted(bool Success)
|
||||||
|
{
|
||||||
|
panel.mNetworkCtrlPage->EnableNetworkButtons();
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::SetZTFunctionsStatus(CTCPZTFunctionsStatus status)
|
||||||
|
{
|
||||||
|
if(CNetworkManager::instance()->SetZTFunctions(status) == RET_OK)
|
||||||
|
{
|
||||||
|
panel.mNetworkCtrlPage->DisableNetworkButtons();
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int COutilZT::SetZTFunctionsSatusDone(bool succes)
|
||||||
|
{
|
||||||
|
panel.mNetworkCtrlPage->EnableNetworkButtons();
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Catch and manage some events from the graphics user interface
|
||||||
|
//like the keyboard Exit sequence (Ctrl-F10)
|
||||||
|
bool COutilZT::eventFilter(QObject *obj, QEvent *event)
|
||||||
|
{
|
||||||
|
if(obj == &panel) //Check if event is coming from the GUI
|
||||||
|
{
|
||||||
|
if(event->type() == QEvent::KeyPress)
|
||||||
|
{
|
||||||
|
QKeyEvent *KeyEvent = static_cast<QKeyEvent*>(event);
|
||||||
|
|
||||||
|
//Check if we received CTRL-F10
|
||||||
|
if(KeyEvent->key() == Qt::Key_F10 &&
|
||||||
|
KeyEvent->modifiers() == Qt::ControlModifier)
|
||||||
|
{
|
||||||
|
QApplication::exit(78); //Quit the application
|
||||||
|
return true; //keep the keystroke
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return QObject::eventFilter(obj,event);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QString COutilZT::GetStationName(int StationID)
|
||||||
|
{
|
||||||
|
switch(StationID)
|
||||||
|
{
|
||||||
|
case ANGRIGNON_ZT_ID:
|
||||||
|
{
|
||||||
|
return QString("Angrignon");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case HONORE_BEAUGRAND_ZT_ID:
|
||||||
|
{
|
||||||
|
return QString("Honoré-Beaugrand");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case LONGUEUIL_ZT_ID:
|
||||||
|
{
|
||||||
|
return QString("Longueuil");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case BERRI_UQAM_ZT_ID:
|
||||||
|
{
|
||||||
|
return QString("Berri-UQAM");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SNOWDON_ZT_ID:
|
||||||
|
{
|
||||||
|
return QString("Snowdon");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SAINT_MICHEL_ZT_ID:
|
||||||
|
{
|
||||||
|
return QString("Saint-Michel");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case COTE_VERTU_ZT_ID:
|
||||||
|
{
|
||||||
|
return QString("Côte-Vertu");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case HENRI_BOURASSA_ZT_ID:
|
||||||
|
{
|
||||||
|
return QString("Henri-Bourassa");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MONTMORENCY_ZT_ID:
|
||||||
|
{
|
||||||
|
return QString("Montmorency");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MONTMORENCY_10_12_ZT_ID:
|
||||||
|
{
|
||||||
|
return QString("Montmorency 10/12");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MONTMORENCY_10_22_ZT_ID:
|
||||||
|
{
|
||||||
|
return QString("Montmorency 10/22");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QString("Unknown !!!");
|
||||||
|
}
|
||||||
158
sources/OutilZT.h
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Description du fichier si nécessaire.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20121210 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef OUTILZT_H
|
||||||
|
#define OUTILZT_H
|
||||||
|
#include "MainPanel.h"
|
||||||
|
#include "LogMgr.h"
|
||||||
|
#include "ZTData.h"
|
||||||
|
#include "Settings.h"
|
||||||
|
#include "TCPProtocol.h"
|
||||||
|
#include "ZTLogFilesMgr.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class COutilZT : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
MODE_DATABASE,
|
||||||
|
MODE_NETWORK,
|
||||||
|
MODE_ZTLOG,
|
||||||
|
MODE_INVALID
|
||||||
|
}OutilZTMode;
|
||||||
|
|
||||||
|
|
||||||
|
COutilZT();
|
||||||
|
~COutilZT();
|
||||||
|
|
||||||
|
unsigned int Start();
|
||||||
|
|
||||||
|
QString GetLogDataPath();
|
||||||
|
QString GetTrainLogsTempPath();
|
||||||
|
void CleanTrainLogsTempPath();
|
||||||
|
|
||||||
|
static QString GetStationName(int StationID);
|
||||||
|
|
||||||
|
bool IsEngMode(){return mIsEngMode;}
|
||||||
|
|
||||||
|
//CLogList requests
|
||||||
|
void LogViewRequest(CLogElement* Element, CLogsListPage* caller);
|
||||||
|
unsigned int SetLogProtection(bool protection, CLogElement* Element, CLogsListPage *caller);
|
||||||
|
|
||||||
|
//CLogView requests
|
||||||
|
void LogViewCloseRequest(CLogViewPage *caller);
|
||||||
|
|
||||||
|
//CMainPage requests
|
||||||
|
void ShowOptionsRequest();
|
||||||
|
void HideOptionsRequest();
|
||||||
|
void ShowDatabaseMgrRequest();
|
||||||
|
void HideDatabaseMgrRequest();
|
||||||
|
|
||||||
|
void EnterDatabaseModeRequest();
|
||||||
|
void EnterNetworkModeRequest();
|
||||||
|
void EnterZTLogModeRequest();
|
||||||
|
void ShowZTLogRequest(QString Log, QString FocusText, int line = -1);
|
||||||
|
|
||||||
|
//Networkmode page requests
|
||||||
|
void ShowNetworkModeLogViewRequest();
|
||||||
|
void HideNetworkModeLogViewRequest();
|
||||||
|
void ShowRemoteTrainLogsViewPages();
|
||||||
|
void ShowRemoteControlPage();
|
||||||
|
void ShowRemoteLiveZTPage();
|
||||||
|
|
||||||
|
//Settings page requests
|
||||||
|
unsigned int DataSourceDirChanged(QString NewPath);
|
||||||
|
unsigned int NetworkDataChanged();
|
||||||
|
|
||||||
|
//DatabaseManager page requests
|
||||||
|
unsigned int LogsDatabaseChanged(QStringList *NewLogs);
|
||||||
|
unsigned int ZTLogFilesChanged();
|
||||||
|
unsigned int RebuildDatabaseFile();
|
||||||
|
|
||||||
|
//LogManager requests
|
||||||
|
unsigned int LogsDatabaseLoaded(CLogMgr *Caller, int Status);
|
||||||
|
unsigned int UpdateLogsList(CLogMgr *Caller);
|
||||||
|
unsigned int DatabaseFetchingBegin(CLogMgr *Caller);
|
||||||
|
unsigned int DatabaseFetchingTick(CLogMgr *Caller,int Index);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//ZTLogFilesPage requests
|
||||||
|
unsigned int ShowZTLogFile(QString FilePath);
|
||||||
|
|
||||||
|
//ZTLogFilesMgr requests
|
||||||
|
unsigned int ZTLogFilesDatabaseLoaded(CZTLogFilesMgr *Caller, int Status);
|
||||||
|
unsigned int ZTLogFilesFetchingBegin(CZTLogFilesMgr *Caller);
|
||||||
|
unsigned int ZTLogFilesFetchingTick(CZTLogFilesMgr *Caller, int Index, QString File = "");
|
||||||
|
|
||||||
|
|
||||||
|
//Network requests
|
||||||
|
unsigned int ConnectToZTRequest();
|
||||||
|
unsigned int DisconnectZTRequest();
|
||||||
|
unsigned int RxStationName(QString StationName);
|
||||||
|
unsigned int RefreshRemoteZTStatusRequest();
|
||||||
|
unsigned int RxZTStatus(const CTCPZTStatus &status);
|
||||||
|
unsigned int DownloadZTLogRequest();
|
||||||
|
unsigned int RxZTLog(QString ZTLog);
|
||||||
|
unsigned int DownloadTrainLogsRequest();
|
||||||
|
unsigned int DownloadTrainLogsBegin(int NbLogs);
|
||||||
|
unsigned int RxTrainLogData(QString FileName);
|
||||||
|
unsigned int RxTrainLogsDownloadFinished();
|
||||||
|
unsigned int DeleteRemoteZTLogRequest();
|
||||||
|
unsigned int RemoteZTLogDeleted(bool Success);
|
||||||
|
unsigned int SetZTFunctionsStatus(CTCPZTFunctionsStatus status);
|
||||||
|
unsigned int SetZTFunctionsSatusDone(bool succes);
|
||||||
|
|
||||||
|
|
||||||
|
bool mIsEngMode;
|
||||||
|
bool mCanImport;
|
||||||
|
bool mRebuildingDB;
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
unsigned int InitZT();
|
||||||
|
|
||||||
|
Panel panel;
|
||||||
|
CLogMgr mDatabaseModeLogManager;
|
||||||
|
CLogMgr mNetworkModeLogManager;
|
||||||
|
CSettingsFileMgr mSettingsFileMgr;
|
||||||
|
CSettingsData mSettingsData;
|
||||||
|
CZTLogFilesMgr mZTLogFilesManager;
|
||||||
|
|
||||||
|
OutilZTMode mOutilZTMode;
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool eventFilter(QObject *obj, QEvent *event);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // OUTILZT_H
|
||||||
6
sources/OutilZTVersion.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef OUTILZTVERSION_H
|
||||||
|
#define OUTILZTVERSION_H
|
||||||
|
|
||||||
|
#define SOFTWARE_VERSION "1.14"
|
||||||
|
|
||||||
|
#endif // OUTILZTVERSION_H
|
||||||
140
sources/Settings.cpp
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Utilisée pour la configuration non volatile de certains paramètres comme
|
||||||
|
les fonction de détection hors service (TK HS). Les paramètres sont sauvegardés
|
||||||
|
dans un fichier binaire qui est ouvert au démarrage du programme.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20121219 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "Settings.h"
|
||||||
|
#include <QTextStream>
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
|
CSettingsFileMgr::CSettingsFileMgr()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CSettingsFileMgr::LoadSettings(CSettingsData *SettingsData)
|
||||||
|
{
|
||||||
|
QFile* SettingsFile = new QFile("./Configuration/Settings.ozs");
|
||||||
|
if(SettingsFile)
|
||||||
|
{
|
||||||
|
if(SettingsFile->open(QIODevice::ReadOnly | QIODevice::Unbuffered) == false)
|
||||||
|
{
|
||||||
|
LoadDefaultSettings(SettingsData);
|
||||||
|
SaveSettings(SettingsData);
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LoadDefaultSettings(SettingsData);
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream * InputStream = new QDataStream(SettingsFile);
|
||||||
|
|
||||||
|
quint32 MagicNbr;// = 0xBAADCAFE;
|
||||||
|
|
||||||
|
*InputStream >> MagicNbr;
|
||||||
|
|
||||||
|
if(MagicNbr != 0xBAADCAFE)
|
||||||
|
{
|
||||||
|
LoadDefaultSettings(SettingsData);
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int NbNetworkEntries = 0;
|
||||||
|
|
||||||
|
*InputStream >> SettingsData->mDataSourceDirectoryPath;
|
||||||
|
|
||||||
|
*InputStream >> NbNetworkEntries;
|
||||||
|
|
||||||
|
for(int i = 0; i < NbNetworkEntries; i++)
|
||||||
|
{
|
||||||
|
CZTNetworkConfig NewCfg;
|
||||||
|
*InputStream >> NewCfg;
|
||||||
|
SettingsData->mNetworkCfgList.append(NewCfg);
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingsFile->close();
|
||||||
|
delete SettingsFile;
|
||||||
|
delete InputStream;
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CSettingsFileMgr::SaveSettings(CSettingsData *SettingsData)
|
||||||
|
{
|
||||||
|
QFile* SettingsFile = new QFile("./Configuration/Settings.ozs");
|
||||||
|
if(SettingsFile)
|
||||||
|
{
|
||||||
|
if(SettingsFile->open(QIODevice::WriteOnly | QIODevice::Unbuffered) == false)
|
||||||
|
{
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream * OutputStream = new QDataStream(SettingsFile);
|
||||||
|
|
||||||
|
quint32 MagicNbr = 0xBAADCAFE;
|
||||||
|
|
||||||
|
*OutputStream << MagicNbr;
|
||||||
|
|
||||||
|
|
||||||
|
*OutputStream << SettingsData->mDataSourceDirectoryPath;
|
||||||
|
*OutputStream << SettingsData->mNetworkCfgList.size();
|
||||||
|
|
||||||
|
for(int i = 0; i < SettingsData->mNetworkCfgList.size(); i++)
|
||||||
|
{
|
||||||
|
*OutputStream << SettingsData->mNetworkCfgList.at(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SettingsFile->flush();
|
||||||
|
SettingsFile->close();
|
||||||
|
|
||||||
|
delete SettingsFile;
|
||||||
|
delete OutputStream;
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSettingsFileMgr::LoadDefaultSettings(CSettingsData *SettingsData)
|
||||||
|
{
|
||||||
|
SettingsData->mDataSourceDirectoryPath = "./Trains/";
|
||||||
|
|
||||||
|
SettingsData->mNetworkCfgList.clear();
|
||||||
|
QString BaseIP = "192.168.0.11";
|
||||||
|
for(int i = 0; i < NB_ZT_ID; i++)
|
||||||
|
{
|
||||||
|
CZTNetworkConfig ZTNetCfg;
|
||||||
|
ZTNetCfg.mZTID = i;
|
||||||
|
ZTNetCfg.mIPAdress = BaseIP + QString::number(i);
|
||||||
|
SettingsData->mNetworkCfgList.append(ZTNetCfg);
|
||||||
|
}
|
||||||
|
}
|
||||||
22
sources/Settings.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#ifndef SETTINGS_H
|
||||||
|
#define SETTINGS_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include "ZTData.h"
|
||||||
|
|
||||||
|
class CSettingsFileMgr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CSettingsFileMgr();
|
||||||
|
|
||||||
|
unsigned int LoadSettings(CSettingsData *SettingsData);
|
||||||
|
unsigned int SaveSettings(CSettingsData *SettingsData);
|
||||||
|
void LoadDefaultSettings(CSettingsData *SettingsData);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SETTINGS_H
|
||||||
330
sources/TCPProtocol.cpp
Normal file
@ -0,0 +1,330 @@
|
|||||||
|
#include "TCPProtocol.h"
|
||||||
|
#include <QByteArray>
|
||||||
|
#include <QDataStream>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
CTCPProtocol::CTCPProtocol()
|
||||||
|
{
|
||||||
|
ResetRxStateMachine();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CTCPProtocol::AnalyzeNewData(QByteArray data)
|
||||||
|
{
|
||||||
|
QDataStream stream(data);
|
||||||
|
stream.device()->seek(0);
|
||||||
|
|
||||||
|
switch(mProtocolRxState)
|
||||||
|
{
|
||||||
|
case TCP_PROTOCOL_GET_HEADER_STATE:
|
||||||
|
{
|
||||||
|
quint32 header;
|
||||||
|
qint32 msg;
|
||||||
|
|
||||||
|
stream >> header;
|
||||||
|
|
||||||
|
if(header != TCP_PROTOCOL_HEADER)
|
||||||
|
{
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
stream >> msg;
|
||||||
|
stream >> mCurTransactionDataSize;
|
||||||
|
|
||||||
|
mCurTransactionMsg = (eTCPMessage)msg;
|
||||||
|
|
||||||
|
if(mCurTransactionDataSize != 0)
|
||||||
|
{
|
||||||
|
mCurTransactionData = stream.device()->readAll();
|
||||||
|
if(mCurTransactionData.size() < mCurTransactionDataSize)
|
||||||
|
{
|
||||||
|
mProtocolRxState = TCP_PROTOCOL_GET_DATA_STATE;
|
||||||
|
// qDebug() << "Datasize is: " << mCurTransactionDataSize << ". Going in GET_DATA_STATE";
|
||||||
|
}
|
||||||
|
else if(mCurTransactionData.size() > mCurTransactionDataSize)
|
||||||
|
{
|
||||||
|
//error
|
||||||
|
// qDebug("Rx data [%d] > Transaction data [%d]. Aborting transaction",mCurTransactionData.size(),(int)mCurTransactionDataSize);
|
||||||
|
ResetRxStateMachine();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DecodeTCPMessage();
|
||||||
|
ResetRxStateMachine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DecodeTCPMessage();
|
||||||
|
ResetRxStateMachine();
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TCP_PROTOCOL_GET_MSG_STATE:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TCP_PROTOCOL_GET_DATASIZE_STATE:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TCP_PROTOCOL_GET_DATA_STATE:
|
||||||
|
{
|
||||||
|
mCurTransactionData.append(data);
|
||||||
|
if(mCurTransactionData.size() == mCurTransactionDataSize)
|
||||||
|
{
|
||||||
|
//All data received
|
||||||
|
// qDebug() << "Data Rx complete... New data size = " << mCurTransactionData.size();
|
||||||
|
DecodeTCPMessage();
|
||||||
|
ResetRxStateMachine();
|
||||||
|
}
|
||||||
|
else if(mCurTransactionData.size() > mCurTransactionDataSize)
|
||||||
|
{
|
||||||
|
//error
|
||||||
|
qDebug("Rx data > Transaction data. Aborting transaction");
|
||||||
|
ResetRxStateMachine();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// qDebug() << "Chunk received. New data size = " << mCurTransactionData.size();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray CTCPProtocol::GetHeartbeatReqPacket()
|
||||||
|
{
|
||||||
|
return BuildSimpleRequestPacket((qint32)TCP_MSG_HEARTBEAT_REQUEST);
|
||||||
|
}
|
||||||
|
QByteArray CTCPProtocol::GetStationNameReqPacket()
|
||||||
|
{
|
||||||
|
return BuildSimpleRequestPacket((qint32)TCP_MSG_STATION_NAME_REQUEST);
|
||||||
|
}
|
||||||
|
QByteArray CTCPProtocol::GetZTStatusReqPacket()
|
||||||
|
{
|
||||||
|
return BuildSimpleRequestPacket((qint32)TCP_MSG_ZT_STATUS_REQUEST);
|
||||||
|
}
|
||||||
|
QByteArray CTCPProtocol::GetZTLogDownloadReqPacket()
|
||||||
|
{
|
||||||
|
return BuildSimpleRequestPacket((qint32)TCP_MSG_ZTLOG_DOWNLOAD_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray CTCPProtocol::BuildSimpleRequestPacket(qint32 RequestID)
|
||||||
|
{
|
||||||
|
QByteArray packet;
|
||||||
|
packet.clear();
|
||||||
|
QDataStream stream(&packet,QIODevice::WriteOnly);
|
||||||
|
stream.device()->seek(0);
|
||||||
|
|
||||||
|
stream << TCP_PROTOCOL_HEADER << RequestID << (qint64)0;
|
||||||
|
|
||||||
|
return packet;
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray CTCPProtocol::GetTrainLogsDownloadReqPacket()
|
||||||
|
{
|
||||||
|
return BuildSimpleRequestPacket((qint32)TCP_MSG_TRAINLOGS_DOWNLOAD_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray CTCPProtocol::GetTrainLogsFileDataAckPacket(qint32 Acknowledge)
|
||||||
|
{
|
||||||
|
QByteArray packet;
|
||||||
|
packet.clear();
|
||||||
|
QDataStream stream(&packet,QIODevice::WriteOnly);
|
||||||
|
stream.device()->seek(0);
|
||||||
|
qint64 size = 4;
|
||||||
|
|
||||||
|
stream << TCP_PROTOCOL_HEADER << (qint32)TCP_MSG_TRAINLOG_FILE_DATA_ACK << size << Acknowledge;
|
||||||
|
|
||||||
|
return packet;
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray CTCPProtocol::GetDeleteZTLogReqPacket()
|
||||||
|
{
|
||||||
|
return BuildSimpleRequestPacket((qint32)TCP_MSG_DELETE_ZTLOG_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray CTCPProtocol::GetSetZTFunctionsPacket(QByteArray &Data)
|
||||||
|
{
|
||||||
|
QByteArray packet;
|
||||||
|
packet.clear();
|
||||||
|
QDataStream stream(&packet,QIODevice::WriteOnly);
|
||||||
|
stream.device()->seek(0);
|
||||||
|
qint64 size = Data.size();
|
||||||
|
|
||||||
|
stream << TCP_PROTOCOL_HEADER << (qint32)TCP_MSG_SET_ZT_FUNCTIONS << size;
|
||||||
|
packet.append(Data);
|
||||||
|
|
||||||
|
return packet;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void CTCPProtocol::TCPTxRequest(const QByteArray &request)
|
||||||
|
{
|
||||||
|
qDebug("No reimplementation of TXRequest in TCPProtocol.c. Request not sent...");
|
||||||
|
}
|
||||||
|
|
||||||
|
void CTCPProtocol::ResetRxStateMachine()
|
||||||
|
{
|
||||||
|
mCurTransactionData.clear();
|
||||||
|
mCurTransactionDataSize = 0;
|
||||||
|
mCurTransactionMsg = TCP_MSG_UNKNOWN;
|
||||||
|
mProtocolRxState = TCP_PROTOCOL_GET_HEADER_STATE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int CTCPProtocol::DecodeTCPMessage()
|
||||||
|
{
|
||||||
|
switch(mCurTransactionMsg)
|
||||||
|
{
|
||||||
|
case TCP_MSG_HEARTBEAT_RESPONSE:
|
||||||
|
{
|
||||||
|
TCPRxHeartbeat();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TCP_MSG_STATION_NAME_RESPONSE:
|
||||||
|
{
|
||||||
|
TCPRxStationName(QString(mCurTransactionData));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TCP_MSG_ZT_STATUS_RESPONSE:
|
||||||
|
{
|
||||||
|
TCPRxZTStatus(mCurTransactionData);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TCP_MSG_ZTLOG_DOWNLOAD_RESPONSE:
|
||||||
|
{
|
||||||
|
TCPRxZTLog(QString(mCurTransactionData));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TCP_MSG_TRAINSLOGS_DOWNLOAD_ACK:
|
||||||
|
{
|
||||||
|
qint32 NbFiles = 0;
|
||||||
|
QDataStream strm(mCurTransactionData);
|
||||||
|
strm.device()->seek(0);
|
||||||
|
|
||||||
|
strm >> NbFiles;
|
||||||
|
TCPRxTrainLogsDownladAck(NbFiles);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TCP_MSG_TRAINLOG_FILE_DATA:
|
||||||
|
{
|
||||||
|
TCPRxTrainLogFileData(mCurTransactionData);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TCP_MSG_TRAINLOGS_DOWNLOAD_FINISHED:
|
||||||
|
{
|
||||||
|
TCPRxTrainLogsDownloadFinished();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TCP_MSG_DELETE_ZTLOG_ACK:
|
||||||
|
{
|
||||||
|
qint32 ack;
|
||||||
|
QDataStream strm(mCurTransactionData);
|
||||||
|
strm.device()->seek(0);
|
||||||
|
strm >> ack;
|
||||||
|
|
||||||
|
TCPRxDeleteZTLogAck((bool)ack);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TCP_MSG_SET_ZT_FUNCTIONS_ACK:
|
||||||
|
{
|
||||||
|
qint32 ack;
|
||||||
|
QDataStream strm(mCurTransactionData);
|
||||||
|
strm.device()->seek(0);
|
||||||
|
strm >> ack;
|
||||||
|
|
||||||
|
TCPRxSetZTFunctionsAck(ack);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case TCP_MSG_SET_ZT_FUNCTIONS:
|
||||||
|
case TCP_MSG_DELETE_ZTLOG_REQUEST:
|
||||||
|
case TCP_MSG_HEARTBEAT_REQUEST:
|
||||||
|
case TCP_MSG_STATION_NAME_REQUEST:
|
||||||
|
case TCP_MSG_ZT_STATUS_REQUEST:
|
||||||
|
case TCP_MSG_ZTLOG_DOWNLOAD_REQUEST:
|
||||||
|
case TCP_MSG_TRAINLOGS_DOWNLOAD_REQUEST:
|
||||||
|
case TCP_MSG_TRAINLOG_FILE_DATA_ACK:
|
||||||
|
case TCP_MSG_UNKNOWN:
|
||||||
|
{
|
||||||
|
qDebug() << "Received invalid msg:" << mCurTransactionMsg;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, CTCPZTStatus &dest)
|
||||||
|
{
|
||||||
|
|
||||||
|
in >> dest.mZT1Status
|
||||||
|
>> dest.mZT2Status
|
||||||
|
>> dest.mNbPass
|
||||||
|
>> dest.mNbTrigs
|
||||||
|
>> dest.mZTStartDateTime
|
||||||
|
>> dest.mActualDateTime
|
||||||
|
>> dest.mPGTreshold
|
||||||
|
>> dest.mModeMaintenanceON
|
||||||
|
>> dest.mCalibModeON
|
||||||
|
>> dest.mFNTKActive
|
||||||
|
>> dest.mFNAnalysisActive
|
||||||
|
>> dest.mPGTKActive
|
||||||
|
>> dest.mPGAnalysisActive
|
||||||
|
>> dest.mPP1TKActive
|
||||||
|
>> dest.mPP1AnalysisActive
|
||||||
|
>> dest.mPP2TKActive
|
||||||
|
>> dest.mPP2AnalysisActive
|
||||||
|
>> dest.mZT1TKActive
|
||||||
|
>> dest.mZT1AnalysisActive
|
||||||
|
>> dest.mZT2TKActive
|
||||||
|
>> dest.mZT2AnalysisActive
|
||||||
|
>> dest.mUSBKeyConnected;
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, CTCPZTFunctionsStatus &dest)
|
||||||
|
{
|
||||||
|
in >> dest.mFNTKActive
|
||||||
|
>> dest.mFNAnalysisActive
|
||||||
|
>> dest.mPGTKActive
|
||||||
|
>> dest.mPGAnalysisActive
|
||||||
|
>> dest.mPP1TKActive
|
||||||
|
>> dest.mPP1AnalysisActive
|
||||||
|
>> dest.mPP2TKActive
|
||||||
|
>> dest.mPP2AnalysisActive
|
||||||
|
>> dest.mZT1TKActive
|
||||||
|
>> dest.mZT1AnalysisActive
|
||||||
|
>> dest.mZT2TKActive
|
||||||
|
>> dest.mZT2AnalysisActive;
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const CTCPZTFunctionsStatus &source)
|
||||||
|
{
|
||||||
|
out << source.mFNTKActive
|
||||||
|
<< source.mFNAnalysisActive
|
||||||
|
<< source.mPGTKActive
|
||||||
|
<< source.mPGAnalysisActive
|
||||||
|
<< source.mPP1TKActive
|
||||||
|
<< source.mPP1AnalysisActive
|
||||||
|
<< source.mPP2TKActive
|
||||||
|
<< source.mPP2AnalysisActive
|
||||||
|
<< source.mZT1TKActive
|
||||||
|
<< source.mZT1AnalysisActive
|
||||||
|
<< source.mZT2TKActive
|
||||||
|
<< source.mZT2AnalysisActive;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
146
sources/TCPProtocol.h
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
#ifndef TCPPROTOCOL_H
|
||||||
|
#define TCPPROTOCOL_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QByteArray>
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
|
#define TCP_PROTOCOL_HEADER (quint32)0xDEADCAFE
|
||||||
|
|
||||||
|
class CTCPProtocol
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
TCP_MSG_HEARTBEAT_REQUEST,
|
||||||
|
TCP_MSG_HEARTBEAT_RESPONSE,
|
||||||
|
TCP_MSG_STATION_NAME_REQUEST,
|
||||||
|
TCP_MSG_STATION_NAME_RESPONSE,
|
||||||
|
TCP_MSG_ZT_STATUS_REQUEST,
|
||||||
|
TCP_MSG_ZT_STATUS_RESPONSE,
|
||||||
|
TCP_MSG_ZTLOG_DOWNLOAD_REQUEST,
|
||||||
|
TCP_MSG_ZTLOG_DOWNLOAD_RESPONSE,
|
||||||
|
|
||||||
|
TCP_MSG_TRAINLOGS_DOWNLOAD_REQUEST,
|
||||||
|
TCP_MSG_TRAINSLOGS_DOWNLOAD_ACK,
|
||||||
|
TCP_MSG_TRAINLOG_FILE_DATA,
|
||||||
|
TCP_MSG_TRAINLOG_FILE_DATA_ACK,
|
||||||
|
TCP_MSG_TRAINLOGS_DOWNLOAD_FINISHED,
|
||||||
|
TCP_MSG_DELETE_ZTLOG_REQUEST,
|
||||||
|
TCP_MSG_DELETE_ZTLOG_ACK,
|
||||||
|
TCP_MSG_SET_ZT_FUNCTIONS,
|
||||||
|
TCP_MSG_SET_ZT_FUNCTIONS_ACK,
|
||||||
|
|
||||||
|
TCP_MSG_UNKNOWN
|
||||||
|
}eTCPMessage;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
TCP_PROTOCOL_GET_HEADER_STATE,
|
||||||
|
TCP_PROTOCOL_GET_MSG_STATE,
|
||||||
|
TCP_PROTOCOL_GET_DATASIZE_STATE,
|
||||||
|
TCP_PROTOCOL_GET_DATA_STATE
|
||||||
|
}eTCPProtocolState;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
TCP_PROTOCOL_NACK,
|
||||||
|
TCP_PROTOCOL_ACK,
|
||||||
|
TCP_PROTOCOL_NACK_ABORT,
|
||||||
|
TCP_PROTOCOL_INVALID_ACK
|
||||||
|
}eTCPProtocolAcknowledge;
|
||||||
|
|
||||||
|
CTCPProtocol();
|
||||||
|
|
||||||
|
virtual void TCPTxRequest(const QByteArray &request) = 0;
|
||||||
|
virtual void TCPRxHeartbeat() = 0;
|
||||||
|
virtual void TCPRxStationName(QString Name) = 0;
|
||||||
|
virtual void TCPRxZTStatus(const QByteArray &data) = 0;
|
||||||
|
virtual void TCPRxZTLog(QString ZTLog) = 0;
|
||||||
|
virtual void TCPRxTrainLogsDownladAck(qint32 NbFiles) = 0;
|
||||||
|
virtual void TCPRxTrainLogFileData(const QByteArray &TrainFileData) = 0;
|
||||||
|
virtual void TCPRxTrainLogsDownloadFinished() = 0;
|
||||||
|
virtual void TCPRxDeleteZTLogAck(bool ack) = 0;
|
||||||
|
virtual void TCPRxSetZTFunctionsAck(bool ack) = 0;
|
||||||
|
|
||||||
|
unsigned int AnalyzeNewData(QByteArray data);
|
||||||
|
|
||||||
|
QByteArray GetHeartbeatReqPacket();
|
||||||
|
QByteArray GetStationNameReqPacket();
|
||||||
|
QByteArray GetZTStatusReqPacket();
|
||||||
|
QByteArray GetZTLogDownloadReqPacket();
|
||||||
|
QByteArray GetTrainLogsDownloadReqPacket();
|
||||||
|
QByteArray GetTrainLogsFileDataAckPacket(qint32 Acknowledge);
|
||||||
|
QByteArray GetDeleteZTLogReqPacket();
|
||||||
|
QByteArray GetSetZTFunctionsPacket(QByteArray &Data);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
eTCPProtocolState mProtocolRxState;
|
||||||
|
eTCPMessage mCurTransactionMsg;
|
||||||
|
qint64 mCurTransactionDataSize;
|
||||||
|
QByteArray mCurTransactionData;
|
||||||
|
|
||||||
|
void ResetRxStateMachine();
|
||||||
|
int DecodeTCPMessage();
|
||||||
|
QByteArray BuildSimpleRequestPacket(qint32 RequestID);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class CTCPZTStatus
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
quint32 mZT1Status; //
|
||||||
|
quint32 mZT2Status;
|
||||||
|
quint32 mNbPass;
|
||||||
|
quint32 mNbTrigs;
|
||||||
|
|
||||||
|
QDateTime mZTStartDateTime;
|
||||||
|
QDateTime mActualDateTime;
|
||||||
|
|
||||||
|
qint32 mPGTreshold;
|
||||||
|
|
||||||
|
bool mModeMaintenanceON;
|
||||||
|
bool mCalibModeON;
|
||||||
|
|
||||||
|
bool mFNTKActive;
|
||||||
|
bool mFNAnalysisActive;
|
||||||
|
bool mPGTKActive;
|
||||||
|
bool mPGAnalysisActive;
|
||||||
|
bool mPP1TKActive;
|
||||||
|
bool mPP1AnalysisActive;
|
||||||
|
bool mPP2TKActive;
|
||||||
|
bool mPP2AnalysisActive;
|
||||||
|
bool mZT1TKActive;
|
||||||
|
bool mZT1AnalysisActive;
|
||||||
|
bool mZT2TKActive;
|
||||||
|
bool mZT2AnalysisActive;
|
||||||
|
|
||||||
|
bool mUSBKeyConnected;
|
||||||
|
};
|
||||||
|
QDataStream &operator>>(QDataStream &in, CTCPZTStatus &dest);
|
||||||
|
|
||||||
|
class CTCPZTFunctionsStatus
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool mFNTKActive;
|
||||||
|
bool mFNAnalysisActive;
|
||||||
|
bool mPGTKActive;
|
||||||
|
bool mPGAnalysisActive;
|
||||||
|
bool mPP1TKActive;
|
||||||
|
bool mPP1AnalysisActive;
|
||||||
|
bool mPP2TKActive;
|
||||||
|
bool mPP2AnalysisActive;
|
||||||
|
bool mZT1TKActive;
|
||||||
|
bool mZT1AnalysisActive;
|
||||||
|
bool mZT2TKActive;
|
||||||
|
bool mZT2AnalysisActive;
|
||||||
|
};
|
||||||
|
QDataStream &operator>>(QDataStream &in, CTCPZTFunctionsStatus &dest);
|
||||||
|
QDataStream &operator<<(QDataStream &out, const CTCPZTFunctionsStatus &source);
|
||||||
|
|
||||||
|
|
||||||
|
#endif // TCPPROTOCOL_H
|
||||||
952
sources/TrainLogFileMgr.cpp
Normal file
@ -0,0 +1,952 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 - 2013 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Cette classe est responsable de la sauvegarde et de l'ouverture des fichiers
|
||||||
|
log de passage des trains.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### YYYMMDD JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "TrainLogFileMgr.h"
|
||||||
|
#include <QFile>
|
||||||
|
#include <QTextStream>
|
||||||
|
#include "LogMgr.h"
|
||||||
|
|
||||||
|
CTrainLogFileMgr CTrainLogFileMgr::mSingleton;
|
||||||
|
|
||||||
|
CTrainLogFileMgr::CTrainLogFileMgr()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//unsigned int CTrainLogFileMgr::SaveTrainLog(QString LogFilePathName, CZT1Log *ZT1Log, QList<CZTDetectionData *> *ZT1DetectionsLog,QString StationName)
|
||||||
|
unsigned int CTrainLogFileMgr::SaveTrainLog(QString LogFilePathName, CZT1Log *ZT1Log, QVector<CZTDetectionData *> *ZT1DetectionsLog,QString StationName)
|
||||||
|
{
|
||||||
|
QFile* BinaryLogFile = new QFile(LogFilePathName);
|
||||||
|
if(BinaryLogFile)
|
||||||
|
{
|
||||||
|
if(BinaryLogFile->open(QIODevice::WriteOnly | QIODevice::Unbuffered) == false)
|
||||||
|
{
|
||||||
|
qDebug("Could not create log file : %s",LogFilePathName.toLatin1().data());
|
||||||
|
delete BinaryLogFile;
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
QDataStream * OutputStream = new QDataStream(BinaryLogFile);
|
||||||
|
|
||||||
|
quint32 MagicNbr = 0xDEADBEEF;
|
||||||
|
|
||||||
|
quint32 NbLogEntry = 0,NbDetections = 0;
|
||||||
|
quint32 LogType = ZT1_LOG_TYPE;
|
||||||
|
NbLogEntry = ZT1Log->mZT1LogData.size();
|
||||||
|
NbDetections = ZT1DetectionsLog->size();
|
||||||
|
quint32 TrainType = 0;
|
||||||
|
quint32 NbElements = 0;
|
||||||
|
quint64 ThreadDataStartTime = 0, ThreadDataEndTime = 0;
|
||||||
|
qreal MeanSpeed = 0;
|
||||||
|
QDateTime DateTime;
|
||||||
|
|
||||||
|
|
||||||
|
//Compute some stats
|
||||||
|
int SpeedSampleCount = 0;
|
||||||
|
bool TrainTypeFound = false;
|
||||||
|
unsigned int NbBogie = 0;
|
||||||
|
bool ThreadStartTimeFound = false, ThreadEndTimeFound = false;
|
||||||
|
|
||||||
|
for(unsigned int i = 0; i < NbLogEntry; i++)
|
||||||
|
{
|
||||||
|
if(ZT1Log->mZT1LogData.at(i)->mZT1ThreadData != 0)
|
||||||
|
{
|
||||||
|
//get the train type
|
||||||
|
if(!TrainTypeFound)
|
||||||
|
{
|
||||||
|
if(ZT1Log->mZT1LogData.at(i)->mZT1ThreadData->mTrainType != TRAIN_TYPE_UNKNOWN)
|
||||||
|
{
|
||||||
|
TrainType = ZT1Log->mZT1LogData.at(i)->mZT1ThreadData->mTrainType;
|
||||||
|
TrainTypeFound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the rank count for the train
|
||||||
|
if(ZT1Log->mZT1LogData.at(i)->mZT1ThreadData->mRank > NbBogie)
|
||||||
|
NbBogie = ZT1Log->mZT1LogData.at(i)->mZT1ThreadData->mBogie;
|
||||||
|
|
||||||
|
//Find the time limits
|
||||||
|
if(ThreadStartTimeFound == false)
|
||||||
|
{
|
||||||
|
ThreadStartTimeFound = true;
|
||||||
|
ThreadDataStartTime = ZT1Log->mZT1LogData.at(i)->mTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Compute the mean speed
|
||||||
|
if(ZT1Log->mZT1LogData.at(i)->mZT1ThreadData->mTrainSpeed != 0)
|
||||||
|
{
|
||||||
|
MeanSpeed += ZT1Log->mZT1LogData.at(i)->mZT1ThreadData->mTrainSpeed;
|
||||||
|
SpeedSampleCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Find the time limits
|
||||||
|
if(ThreadStartTimeFound == true && ThreadEndTimeFound == false)
|
||||||
|
{
|
||||||
|
ThreadEndTimeFound = true;
|
||||||
|
ThreadDataEndTime = ZT1Log->mZT1LogData.at(i-1)->mTimestamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MeanSpeed /= SpeedSampleCount;
|
||||||
|
NbElements = NbBogie/6;
|
||||||
|
|
||||||
|
DateTime = ZT1Log->mZT1LogData.first()->mDateTime;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*OutputStream << MagicNbr << LogType << NbLogEntry << NbDetections;
|
||||||
|
*OutputStream << StationName;
|
||||||
|
|
||||||
|
*OutputStream << ZT1Log->mZT1Flags;
|
||||||
|
|
||||||
|
*OutputStream << TrainType << NbElements << ThreadDataStartTime << ThreadDataEndTime << MeanSpeed << DateTime;
|
||||||
|
|
||||||
|
|
||||||
|
//write detections
|
||||||
|
for(unsigned int i =0; i < NbDetections; i++)
|
||||||
|
{
|
||||||
|
*OutputStream << *ZT1DetectionsLog->at(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
//write train passage log
|
||||||
|
for(unsigned int i = 0; i < NbLogEntry; i++)
|
||||||
|
{
|
||||||
|
*OutputStream << *ZT1Log->mZT1LogData.at(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef USE_ANALOG_ACQUISITION
|
||||||
|
//write analog data if present.
|
||||||
|
if(ZT1Log->mZT1Flags.mAnalogTracePresent == 1)
|
||||||
|
{
|
||||||
|
for(unsigned int i = 0; i < NbLogEntry; i++)
|
||||||
|
{
|
||||||
|
*OutputStream << ZT1Log->mZT1LogData.at(i)->mAnalogData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
BinaryLogFile->close();
|
||||||
|
delete BinaryLogFile;
|
||||||
|
delete OutputStream;
|
||||||
|
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CTrainLogFileMgr::SaveTrainLog(QString LogFilePathName, QVector<CZT2LogData *> *ZT2Log, QVector<CZTDetectionData *> *ZT2DetectionsLog, QString StationName)
|
||||||
|
{
|
||||||
|
QFile* BinaryLogFile = new QFile(LogFilePathName);
|
||||||
|
if(BinaryLogFile)
|
||||||
|
{
|
||||||
|
if(BinaryLogFile->open(QIODevice::WriteOnly | QIODevice::Unbuffered) == false)
|
||||||
|
{
|
||||||
|
qDebug("Could not create log file : %s",LogFilePathName.toLatin1().data());
|
||||||
|
delete BinaryLogFile;
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
QDataStream * OutputStream = new QDataStream(BinaryLogFile);
|
||||||
|
|
||||||
|
quint32 MagicNbr = 0xDEADBEEF;
|
||||||
|
|
||||||
|
quint32 NbLogEntry,NbDetections;
|
||||||
|
quint32 LogType = ZT2_LOG_TYPE;
|
||||||
|
NbLogEntry = ZT2Log->size();
|
||||||
|
NbDetections = ZT2DetectionsLog->size();
|
||||||
|
quint32 NbElements = 0;
|
||||||
|
QDateTime DateTime = ZT2Log->at(0)->mDateTime;
|
||||||
|
|
||||||
|
|
||||||
|
//Get some stats
|
||||||
|
for(int j = 0; j < ZT2Log->size(); j++)
|
||||||
|
{
|
||||||
|
if(ZT2Log->at(j)->mZT2ThreadData != 0)
|
||||||
|
{
|
||||||
|
//Get the rank count for the train
|
||||||
|
if(ZT2Log->at(j)->mZT2ThreadData->mRank > NbElements)
|
||||||
|
NbElements = ZT2Log->at(j)->mZT2ThreadData->mBogie;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NbElements /= 6; //6 bogies per element
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*OutputStream << MagicNbr << LogType << NbLogEntry << NbDetections;
|
||||||
|
*OutputStream << StationName;
|
||||||
|
|
||||||
|
*OutputStream << NbElements << DateTime;
|
||||||
|
|
||||||
|
//write detections
|
||||||
|
for(unsigned int i =0; i < NbDetections; i++)
|
||||||
|
{
|
||||||
|
*OutputStream << *ZT2DetectionsLog->at(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//write train passage log
|
||||||
|
for(unsigned int i = 0; i < NbLogEntry; i++)
|
||||||
|
{
|
||||||
|
*OutputStream << *ZT2Log->at(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
BinaryLogFile->close();
|
||||||
|
delete BinaryLogFile;
|
||||||
|
delete OutputStream;
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
//It is the responsibility of the caller to make shure TargetElement is empty
|
||||||
|
CLogElement* CTrainLogFileMgr::OpenTrainLog(QString LogFilePathName,unsigned int &Retvalue,CLogElement* TargetElement,bool LoadData)
|
||||||
|
{
|
||||||
|
// if(!ZT1Log->isEmpty() || !ZT1DetectionsLog->isEmpty())
|
||||||
|
// return RET_ERROR;
|
||||||
|
|
||||||
|
int LogFileVersion;
|
||||||
|
bool FileProtected = false;
|
||||||
|
|
||||||
|
if(QFileInfo(LogFilePathName).suffix() != "bin")
|
||||||
|
{
|
||||||
|
Retvalue = RET_ERROR;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFile* BinaryLogFile = new QFile(LogFilePathName);
|
||||||
|
if(BinaryLogFile)
|
||||||
|
{
|
||||||
|
if(BinaryLogFile->open(QIODevice::ReadOnly | QIODevice::Unbuffered) == false)
|
||||||
|
{
|
||||||
|
Retvalue = RET_ERROR;
|
||||||
|
delete BinaryLogFile;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Retvalue = RET_ERROR;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream * InputStream = new QDataStream(BinaryLogFile);
|
||||||
|
|
||||||
|
quint32 MagicNbr,NbLogEntry,NbDetections,LogType;
|
||||||
|
|
||||||
|
*InputStream >> MagicNbr;
|
||||||
|
if(MagicNbr == 0xDEADBEEF)
|
||||||
|
{
|
||||||
|
LogFileVersion = 1;
|
||||||
|
FileProtected = false;
|
||||||
|
}
|
||||||
|
else if(MagicNbr == 0xDEADBEEF+1)
|
||||||
|
{
|
||||||
|
LogFileVersion = 2;
|
||||||
|
FileProtected = false;
|
||||||
|
}
|
||||||
|
else if(MagicNbr == 0xDEADBEEF+2)
|
||||||
|
{
|
||||||
|
LogFileVersion = 1;
|
||||||
|
FileProtected = true;
|
||||||
|
}
|
||||||
|
else if(MagicNbr == 0xDEADBEEF+3)
|
||||||
|
{
|
||||||
|
LogFileVersion = 2;
|
||||||
|
FileProtected = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
qDebug(QString().sprintf("Fichier de passage invalide (Magic number) %s",LogFilePathName.toAscii().data()).toAscii().data());
|
||||||
|
BinaryLogFile->close();
|
||||||
|
delete BinaryLogFile;
|
||||||
|
delete InputStream;
|
||||||
|
|
||||||
|
Retvalue = RET_ERROR;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
*InputStream >> LogType;
|
||||||
|
|
||||||
|
if(LogType == ZT1_LOG_TYPE)
|
||||||
|
{
|
||||||
|
CZT1LogElement *PassageLog;
|
||||||
|
if(TargetElement == 0)
|
||||||
|
{
|
||||||
|
PassageLog = new CZT1LogElement();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PassageLog = (CZT1LogElement*)TargetElement; //It is the responsibility of the caller to make shure TargetElement is empty
|
||||||
|
}
|
||||||
|
|
||||||
|
PassageLog->mLogFileName = LogFilePathName;
|
||||||
|
PassageLog->mFileProtected = FileProtected;
|
||||||
|
|
||||||
|
*InputStream >> NbLogEntry;
|
||||||
|
*InputStream >> NbDetections;
|
||||||
|
*InputStream >> PassageLog->mStationName;
|
||||||
|
if(LogFileVersion == 1)
|
||||||
|
{
|
||||||
|
*InputStream >> PassageLog->mFlags.mExtPGOffset
|
||||||
|
>> PassageLog->mFlags.mIntPGOffset
|
||||||
|
>> PassageLog->mFlags.mPGCalibrationON
|
||||||
|
>> PassageLog->mFlags.mPGTresholdValue
|
||||||
|
>> PassageLog->mFlags.mAnalogTracePresent;
|
||||||
|
}
|
||||||
|
else if(LogFileVersion == 2)
|
||||||
|
{
|
||||||
|
*InputStream >> PassageLog->mFlags;
|
||||||
|
}
|
||||||
|
|
||||||
|
*InputStream >> PassageLog->mTrainType;
|
||||||
|
*InputStream >> PassageLog->mNbElements;
|
||||||
|
*InputStream >> PassageLog->mThreadDataStartTime;
|
||||||
|
*InputStream >> PassageLog->mThreadDataEndTime;
|
||||||
|
*InputStream >> PassageLog->mMeanSpeed;
|
||||||
|
*InputStream >> PassageLog->mPassageDateTime;
|
||||||
|
|
||||||
|
for(unsigned int i = 0; i < NbDetections; i++)
|
||||||
|
{
|
||||||
|
CZTDetectionData *NewDetection = new CZTDetectionData();
|
||||||
|
*InputStream >> *NewDetection;
|
||||||
|
PassageLog->mZTDetections.append(NewDetection);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(LoadData == true)
|
||||||
|
{
|
||||||
|
for(unsigned int i = 0; i < NbLogEntry; i++)
|
||||||
|
{
|
||||||
|
CZT1LogData *NewLogChunk = new CZT1LogData();
|
||||||
|
*InputStream >> *NewLogChunk;
|
||||||
|
PassageLog->mZTLogData.append(NewLogChunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef USE_ANALOG_ACQUISITION
|
||||||
|
if(PassageLog->mFlags.mAnalogTracePresent == 1)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < PassageLog->mZTLogData.size(); i++)
|
||||||
|
{
|
||||||
|
*InputStream >> PassageLog->mZTLogData.at(i)->mAnalogData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BinaryLogFile->close();
|
||||||
|
delete BinaryLogFile;
|
||||||
|
delete InputStream;
|
||||||
|
|
||||||
|
Retvalue = RET_OK;
|
||||||
|
return (CZT1LogElement*) PassageLog;
|
||||||
|
}
|
||||||
|
else if(LogType == ZT2_LOG_TYPE)
|
||||||
|
{
|
||||||
|
quint32 NbElements;
|
||||||
|
QDateTime DateTime;
|
||||||
|
|
||||||
|
CZT2LogElement *PassageLog;
|
||||||
|
if(TargetElement == 0)
|
||||||
|
{
|
||||||
|
PassageLog = new CZT2LogElement();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PassageLog = (CZT2LogElement*) TargetElement; //It is the responsibility of the caller to make shure TargetElement is empty
|
||||||
|
}
|
||||||
|
|
||||||
|
*InputStream >> NbLogEntry;
|
||||||
|
*InputStream >> NbDetections;
|
||||||
|
*InputStream >> PassageLog->mStationName;
|
||||||
|
if(LogFileVersion == 2)
|
||||||
|
{
|
||||||
|
*InputStream >> PassageLog->mFlags;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PassageLog->mFlags.mIsProblematicPassage = 2;
|
||||||
|
}
|
||||||
|
*InputStream >> NbElements;
|
||||||
|
*InputStream >> DateTime;
|
||||||
|
|
||||||
|
PassageLog->mNbElements = NbElements;
|
||||||
|
PassageLog->mLogFileName = LogFilePathName;
|
||||||
|
PassageLog->mPassageDateTime = DateTime;
|
||||||
|
PassageLog->mFileProtected = FileProtected;
|
||||||
|
|
||||||
|
for(unsigned int i = 0; i < NbDetections; i++)
|
||||||
|
{
|
||||||
|
CZTDetectionData *NewDetection = new CZTDetectionData();
|
||||||
|
*InputStream >> *NewDetection;
|
||||||
|
PassageLog->mZTDetections.append(NewDetection);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(LoadData == true)
|
||||||
|
{
|
||||||
|
for(unsigned int i = 0; i < NbLogEntry; i++)
|
||||||
|
{
|
||||||
|
CZT2LogData *NewLogChunk = new CZT2LogData();
|
||||||
|
*InputStream >> *NewLogChunk;
|
||||||
|
PassageLog->mZTLogData.append(NewLogChunk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BinaryLogFile->close();
|
||||||
|
delete BinaryLogFile;
|
||||||
|
delete InputStream;
|
||||||
|
|
||||||
|
Retvalue = RET_OK;
|
||||||
|
return PassageLog;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug("Invalid log type in file %s",LogFilePathName.toLatin1().data());
|
||||||
|
Retvalue = RET_ERROR;
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CTrainLogFileMgr::SetTrainLogProtected(bool IsProtected, QString LogFilePathName)
|
||||||
|
{
|
||||||
|
QFile* BinaryLogFile = new QFile(LogFilePathName);
|
||||||
|
if(BinaryLogFile)
|
||||||
|
{
|
||||||
|
if(BinaryLogFile->open(QIODevice::ReadWrite | QIODevice::Unbuffered) == false)
|
||||||
|
{
|
||||||
|
qDebug("Could not Open log file to set protection : %s",LogFilePathName.toLatin1().data());
|
||||||
|
delete BinaryLogFile;
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
QDataStream * Stream = new QDataStream(BinaryLogFile);
|
||||||
|
|
||||||
|
quint32 MagicNbr;
|
||||||
|
|
||||||
|
*Stream >> MagicNbr;
|
||||||
|
|
||||||
|
BinaryLogFile->seek(0);
|
||||||
|
|
||||||
|
if(IsProtected == true)
|
||||||
|
{
|
||||||
|
if(MagicNbr == 0xDEADBEEF + 2 || MagicNbr == 0xDEADBEEF + 3)
|
||||||
|
{
|
||||||
|
//file is already protected
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(MagicNbr == 0xDEADBEEF || MagicNbr == 0xDEADBEEF + 1)
|
||||||
|
{
|
||||||
|
MagicNbr += 2;
|
||||||
|
*Stream << MagicNbr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Log File Error
|
||||||
|
BinaryLogFile->close();
|
||||||
|
qDebug("Invalid log file magic number to set protection : %s",LogFilePathName.toLatin1().data());
|
||||||
|
delete BinaryLogFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(MagicNbr == 0xDEADBEEF + 2 || MagicNbr == 0xDEADBEEF + 3)
|
||||||
|
{
|
||||||
|
//file is already protected
|
||||||
|
MagicNbr -= 2;
|
||||||
|
*Stream << MagicNbr;
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(MagicNbr == 0xDEADBEEF || MagicNbr == 0xDEADBEEF + 1)
|
||||||
|
{
|
||||||
|
//file is already unprotected
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Log File Error
|
||||||
|
BinaryLogFile->close();
|
||||||
|
qDebug("Invalid log file magic number to set protection : %s",LogFilePathName.toLatin1().data());
|
||||||
|
delete BinaryLogFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BinaryLogFile->close();
|
||||||
|
qDebug("Invalid log file magic number to set protection : %s",LogFilePathName.toLatin1().data());
|
||||||
|
delete BinaryLogFile;
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
//unsigned int CTrainLogFileMgr::SaveCSVFile(QString CSVFilePathName, CZT1Log *ZT1Log, QList<CZTDetectionData *> *ZT1DetectionsLog, QString StationName)
|
||||||
|
unsigned int CTrainLogFileMgr::SaveCSVFile(QString CSVFilePathName, CZT1Log *ZT1Log, QVector<CZTDetectionData *> *ZT1DetectionsLog, QString StationName)
|
||||||
|
{
|
||||||
|
return SaveCSVFile(CSVFilePathName, &ZT1Log->mZT1LogData, &ZT1Log->mZT1Flags, ZT1DetectionsLog,StationName);
|
||||||
|
}
|
||||||
|
|
||||||
|
//unsigned int CTrainLogFileMgr::SaveCSVFile(QString CSVFilePathName, QList<CZT1LogData*> *ZT1Log, CZT1FlagsData *ZT1Flags, QList<CZTDetectionData *> *ZT1DetectionsLog, QString StationName)
|
||||||
|
unsigned int CTrainLogFileMgr::SaveCSVFile(QString CSVFilePathName, QVector<CZT1LogData*> *ZT1Log, CZT1FlagsData *ZT1Flags, QVector<CZTDetectionData *> *ZT1DetectionsLog, QString StationName)
|
||||||
|
{
|
||||||
|
QFile CSVFile(CSVFilePathName);
|
||||||
|
if(!CSVFile.open(QIODevice::QIODevice::WriteOnly|QIODevice::Text|QIODevice::Truncate))
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
QTextStream CSVStream(&CSVFile);
|
||||||
|
|
||||||
|
CSVStream << "Log de passage du train dans la ZT1\n";
|
||||||
|
|
||||||
|
CSVStream << QString::fromUtf8("Station : ") << StationName << "\n";
|
||||||
|
CSVStream << QString::fromUtf8("Valeur seuil Pneu de guidage : ") << ZT1Flags->mPGTresholdValue << "\n";
|
||||||
|
CSVStream << QString::fromUtf8("Valeur zérotage PG Extérieur : ") << ZT1Flags->mExtPGOffset << "\n";
|
||||||
|
CSVStream << QString::fromUtf8("Valeur zérotage PG Intérieur : ") << ZT1Flags->mIntPGOffset << "\n";
|
||||||
|
if(ZT1Flags->mPGCalibrationON == 1)
|
||||||
|
{
|
||||||
|
CSVStream << "Calibration PG en cours lors du passage: OUI\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
CSVStream << "Calibration PG en cours lors du passage: NON\n";
|
||||||
|
|
||||||
|
CSVStream << QString::fromUtf8("Nombre de déclenchements : ") << ZT1DetectionsLog->size() << "\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(ZT1DetectionsLog->size() > 0)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < ZT1DetectionsLog->size(); i++)
|
||||||
|
{
|
||||||
|
CSVStream << QString::fromUtf8("Déclenchement ") << i+1 << ": " << ZT1DetectionsLog->at(i)->mTimeStamp << " - " << QString::fromUtf8(CZTData::GetErrorString(ZT1DetectionsLog->at(i)->mDetectionID)) << " au rang " << ZT1DetectionsLog->at(i)->mRank << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
CSVStream << "\n";
|
||||||
|
|
||||||
|
CSVStream << "Date,Heure,Timestamp,CI,CDV Approche,CDV ZT1,S1,S2,FN,PPI,PPE,PG,Vitesse,Bogie,Rang,Laser Ext,Laser Int,Train";
|
||||||
|
|
||||||
|
if(ZT1Flags->mAnalogTracePresent == 1)
|
||||||
|
{
|
||||||
|
CSVStream << ",4-20mA SDF";
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVStream << "\n";
|
||||||
|
|
||||||
|
for(int i = 0; i < ZT1Log->size(); i++)
|
||||||
|
{
|
||||||
|
CSVStream << ZT1Log->at(i)->mDateTime.toString("yyyy-MM-dd, hh:mm:ss:zzz") << ",";
|
||||||
|
CSVStream << ZT1Log->at(i)->mTimestamp << ",";
|
||||||
|
CSVStream << ZT1Log->at(i)->mCIZT1 << ",";
|
||||||
|
CSVStream << ZT1Log->at(i)->mCDVApproach_ZT1 << ",";
|
||||||
|
CSVStream << ZT1Log->at(i)->mCDVARM_ZT1 << ",";
|
||||||
|
|
||||||
|
if(ZT1Log->at(i)->mZT1ThreadData != 0)
|
||||||
|
{
|
||||||
|
CSVStream << ZT1Log->at(i)->mZT1ThreadData->mS1 << ",";
|
||||||
|
CSVStream << ZT1Log->at(i)->mZT1ThreadData->mS2 << ",";
|
||||||
|
CSVStream << ZT1Log->at(i)->mZT1ThreadData->mFN << ",";
|
||||||
|
CSVStream << ZT1Log->at(i)->mZT1ThreadData->mPInt << ",";
|
||||||
|
CSVStream << ZT1Log->at(i)->mZT1ThreadData->mPExt << ",";
|
||||||
|
CSVStream << ZT1Log->at(i)->mZT1ThreadData->mPG << ",";
|
||||||
|
CSVStream << ZT1Log->at(i)->mZT1ThreadData->mTrainSpeed << ",";
|
||||||
|
CSVStream << ZT1Log->at(i)->mZT1ThreadData->mBogie << ",";
|
||||||
|
CSVStream << ZT1Log->at(i)->mZT1ThreadData->mRank << ",";
|
||||||
|
CSVStream << ZT1Log->at(i)->mZT1ThreadData->mPGExtValue << ",";
|
||||||
|
CSVStream << ZT1Log->at(i)->mZT1ThreadData->mPGIntValue << ",";
|
||||||
|
CSVStream << CZTData::GetTrainTypeString(ZT1Log->at(i)->mZT1ThreadData->mTrainType);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CSVStream << "0,0,0,0,0,0,0,0,0,0,0,0";
|
||||||
|
//CSVStream <<"\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ZT1Flags->mAnalogTracePresent == 1)
|
||||||
|
{
|
||||||
|
CSVStream << "," << ZT1Log->at(i)->mAnalogData ;
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVStream << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVFile.flush();
|
||||||
|
CSVFile.close();
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int CTrainLogFileMgr::SaveCSVFile(QString CSVFilePathName, QVector<CZT2LogData *> *ZT2Log, QVector<CZTDetectionData *> *ZT2DetectionsLog, QString StationName)
|
||||||
|
//unsigned int CTrainLogFileMgr::SaveCSVFile(QString CSVFilePathName, QVector<CZT2LogData *> *ZT2Log, QVector<CZTDetectionData *> *ZT2DetectionsLog, QString StationName)
|
||||||
|
{
|
||||||
|
QFile CSVFile(CSVFilePathName);
|
||||||
|
if(!CSVFile.open(QIODevice::QIODevice::WriteOnly|QIODevice::Text|QIODevice::Truncate))
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
QTextStream CSVStream(&CSVFile);
|
||||||
|
|
||||||
|
CSVStream << "Log de passage du train dans la ZT2\n";
|
||||||
|
CSVStream << QString::fromUtf8("Station : ") << StationName << "\n";
|
||||||
|
|
||||||
|
CSVStream << QString::fromUtf8("Nombre de déclenchements : ") << ZT2DetectionsLog->size() << "\n";
|
||||||
|
|
||||||
|
|
||||||
|
if(ZT2DetectionsLog->size() > 0)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < ZT2DetectionsLog->size(); i++)
|
||||||
|
{
|
||||||
|
CSVStream << QString::fromUtf8("Déclenchement ") << i+1 << ": " << ZT2DetectionsLog->at(i)->mTimeStamp << " - " << QString::fromUtf8(CZTData::GetErrorString(ZT2DetectionsLog->at(i)->mDetectionID)) << " au rang " << ZT2DetectionsLog->at(i)->mRank << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVStream << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVStream << "Date,Heure,Timestamp,CI,CDV ZT2,S1,PPI,PPE,Bogie,Rang\n";
|
||||||
|
|
||||||
|
for(int i = 0; i < ZT2Log->size(); i++)
|
||||||
|
{
|
||||||
|
CSVStream << ZT2Log->at(i)->mDateTime.toString("yyyy-MM-dd, hh:mm:ss:zzz") << ",";
|
||||||
|
CSVStream << ZT2Log->at(i)->mTimestamp << ",";
|
||||||
|
CSVStream << ZT2Log->at(i)->mCIZT2 << ",";
|
||||||
|
CSVStream << ZT2Log->at(i)->mCDVARM_ZT2 << ",";
|
||||||
|
if(ZT2Log->at(i)->mZT2ThreadData != 0)
|
||||||
|
{
|
||||||
|
CSVStream << ZT2Log->at(i)->mZT2ThreadData->mS1 << ",";
|
||||||
|
CSVStream << ZT2Log->at(i)->mZT2ThreadData->mPPInt << ",";
|
||||||
|
CSVStream << ZT2Log->at(i)->mZT2ThreadData->mPPExt << ",";
|
||||||
|
CSVStream << ZT2Log->at(i)->mZT2ThreadData->mBogie << ",";
|
||||||
|
CSVStream << ZT2Log->at(i)->mZT2ThreadData->mRank << ",";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CSVStream << "0,0,0,0,0";
|
||||||
|
CSVStream <<"\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVFile.flush();
|
||||||
|
CSVFile.close();
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Cette fonction a été écrite pour des fins de tests et n'est PAS du tout robuste.
|
||||||
|
//utiliser avec précaution.
|
||||||
|
unsigned int CTrainLogFileMgr::SaveBINFromCSV(QString CSVFilePathName)
|
||||||
|
{
|
||||||
|
QFile CSVFile(CSVFilePathName);
|
||||||
|
if(!CSVFile.open(QIODevice::ReadOnly|QIODevice::Text))
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
QTextStream CSVStream(&CSVFile);
|
||||||
|
|
||||||
|
bool IsZT1 = true;
|
||||||
|
QString Line;
|
||||||
|
QStringList LineElements;
|
||||||
|
QString StationName;
|
||||||
|
Line.clear();
|
||||||
|
LineElements.clear();
|
||||||
|
|
||||||
|
Line = CSVStream.readLine(); //Log de passage du train dans la ZT1
|
||||||
|
if(Line.contains("ZT1") == true)
|
||||||
|
{
|
||||||
|
IsZT1 = true;
|
||||||
|
}
|
||||||
|
else if(Line.contains("ZT2") == true)
|
||||||
|
{
|
||||||
|
IsZT1 = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//invalid file
|
||||||
|
CSVFile.close();
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
Line = CSVStream.readLine(); //Station : Snowdon
|
||||||
|
LineElements = Line.split(":");
|
||||||
|
if(LineElements.isEmpty())
|
||||||
|
{
|
||||||
|
CSVFile.close();
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
StationName = LineElements.at(1);
|
||||||
|
Line.clear();
|
||||||
|
|
||||||
|
if(IsZT1 == true)
|
||||||
|
{
|
||||||
|
CZT1Log *ZT1LOG = new CZT1Log();
|
||||||
|
|
||||||
|
Line = CSVStream.readLine(); //Valeur seuil Pneu de guidage : 15625
|
||||||
|
LineElements = Line.split(":");
|
||||||
|
if(LineElements.isEmpty())
|
||||||
|
{
|
||||||
|
CSVFile.close();
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
ZT1LOG->mZT1Flags.mPGTresholdValue = LineElements.at(1).toInt();
|
||||||
|
Line.clear();
|
||||||
|
|
||||||
|
Line = CSVStream.readLine(); //Valeur zérotage PG Extérieur : 128457
|
||||||
|
LineElements = Line.split(":");
|
||||||
|
if(LineElements.isEmpty())
|
||||||
|
{
|
||||||
|
CSVFile.close();
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
ZT1LOG->mZT1Flags.mExtPGOffset = LineElements.at(1).toInt();
|
||||||
|
Line.clear();
|
||||||
|
|
||||||
|
Line = CSVStream.readLine(); //Valeur zérotage PG Intérieur : 1300637
|
||||||
|
LineElements = Line.split(":");
|
||||||
|
if(LineElements.isEmpty())
|
||||||
|
{
|
||||||
|
CSVFile.close();
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
ZT1LOG->mZT1Flags.mIntPGOffset = LineElements.at(1).toInt();
|
||||||
|
Line.clear();
|
||||||
|
|
||||||
|
Line = CSVStream.readLine(); //Calibration PG en cours lors du passage: NON
|
||||||
|
if(Line.contains("OUI") == true)
|
||||||
|
{
|
||||||
|
ZT1LOG->mZT1Flags.mPGCalibrationON = true;
|
||||||
|
}
|
||||||
|
else if(Line.contains("NON") == true)
|
||||||
|
{
|
||||||
|
ZT1LOG->mZT1Flags.mPGCalibrationON = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CSVFile.close();
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
Line.clear();
|
||||||
|
|
||||||
|
int NbDetections;
|
||||||
|
Line = CSVStream.readLine(); //Nombre de déclenchements : 12
|
||||||
|
LineElements = Line.split(":");
|
||||||
|
if(LineElements.isEmpty())
|
||||||
|
{
|
||||||
|
CSVFile.close();
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
NbDetections = LineElements.at(1).toInt();
|
||||||
|
Line.clear();
|
||||||
|
|
||||||
|
//Ignore detections...
|
||||||
|
for(int i = 0; i < NbDetections; i++)
|
||||||
|
{
|
||||||
|
Line = CSVStream.readLine();
|
||||||
|
Line.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Skip the empty line after the detections.
|
||||||
|
Line = CSVStream.readLine();
|
||||||
|
Line.clear();
|
||||||
|
|
||||||
|
//Skip the table header
|
||||||
|
Line = CSVStream.readLine();
|
||||||
|
Line.clear();
|
||||||
|
|
||||||
|
quint32 LastS1 = 0, LastS2 = 0, LastFN = 0;
|
||||||
|
quint32 S1Count = 0;
|
||||||
|
quint32 S2Count = 0;
|
||||||
|
quint32 FNCount = 0;
|
||||||
|
while(CSVStream.atEnd() == false)
|
||||||
|
{
|
||||||
|
|
||||||
|
Line.clear();
|
||||||
|
LineElements.clear();
|
||||||
|
|
||||||
|
Line = CSVStream.readLine(); //Date Heure Timestamp CI CDV Approche CDV ZT1 S1 S2 FN PPI PPE PG Vitesse Bogie Rang Sonde Ext Sonde Int Train
|
||||||
|
LineElements = Line.split(",");
|
||||||
|
if(LineElements.count() != 18)
|
||||||
|
{
|
||||||
|
CSVFile.close();
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDate date = QDate::fromString(LineElements.at(0),"yyyy-MM-dd");
|
||||||
|
if(date.isValid() == false)
|
||||||
|
{
|
||||||
|
CSVFile.close();
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTime time = QTime::fromString(LineElements.at(1).trimmed(),"hh:mm:ss:zzz");
|
||||||
|
if(time.isValid() == false)
|
||||||
|
{
|
||||||
|
CSVFile.close();
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
qint64 timestamp = LineElements.at(2).toLongLong();
|
||||||
|
|
||||||
|
quint32 CIZT1 = LineElements.at(3).toUInt();
|
||||||
|
|
||||||
|
quint32 CDVApproach_ZT1 = LineElements.at(4).toUInt();
|
||||||
|
|
||||||
|
quint32 CDVARM_ZT1 = LineElements.at(5).toUInt();
|
||||||
|
|
||||||
|
CZT1LogData *LogData;
|
||||||
|
CZT1ThreadData *ThreadData;
|
||||||
|
if(LineElements.at(17) == "0") //Check if ThreadData is valid
|
||||||
|
{
|
||||||
|
//Thread data not valid...
|
||||||
|
LogData = new CZT1LogData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ThreadData = new CZT1ThreadData();
|
||||||
|
LogData = new CZT1LogData(ThreadData);
|
||||||
|
|
||||||
|
|
||||||
|
quint32 S1 = LineElements.at(6).toUInt();
|
||||||
|
quint32 S2 = LineElements.at(7).toUInt();
|
||||||
|
quint32 FN = LineElements.at(8).toUInt();
|
||||||
|
quint32 PInt = LineElements.at(9).toUInt();
|
||||||
|
quint32 PExt = LineElements.at(10).toUInt();
|
||||||
|
quint32 PG = LineElements.at(11).toUInt();
|
||||||
|
qreal TrainSpeed = LineElements.at(12).toFloat();
|
||||||
|
quint32 Bogie = LineElements.at(13).toUInt();
|
||||||
|
quint32 Rank = LineElements.at(14).toUInt();
|
||||||
|
qint32 PGIntValue = LineElements.at(15).toInt();
|
||||||
|
qint32 PGExtValue = LineElements.at(16).toInt();
|
||||||
|
|
||||||
|
quint32 TrainType;
|
||||||
|
if(LineElements.at(17) == "Inconnu")
|
||||||
|
{
|
||||||
|
TrainType = TRAIN_TYPE_UNKNOWN;
|
||||||
|
}
|
||||||
|
else if(LineElements.at(17) == "MR63/73")
|
||||||
|
{
|
||||||
|
TrainType = TRAIN_TYPE_MR63_MR73;
|
||||||
|
}
|
||||||
|
else if(LineElements.at(17) == "MPM10")
|
||||||
|
{
|
||||||
|
TrainType = TRAIN_TYPE_MPM10;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CSVFile.close();
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(S1 == 1 && LastS1 == 0)
|
||||||
|
S1Count++;
|
||||||
|
|
||||||
|
if(S2 == 1 && LastS2 == 0)
|
||||||
|
S2Count++;
|
||||||
|
|
||||||
|
if(FN == 1 && LastFN == 0)
|
||||||
|
FNCount++;
|
||||||
|
|
||||||
|
LastS1 = S1;
|
||||||
|
LastS2 = S2;
|
||||||
|
LastFN = FN;
|
||||||
|
|
||||||
|
ThreadData->mTimeStamp = timestamp; //nanosecs
|
||||||
|
ThreadData->mDateTime.setDate(date);
|
||||||
|
ThreadData->mDateTime.setTime(time);
|
||||||
|
ThreadData->mS1 = S1;
|
||||||
|
ThreadData->mS2 = S2;
|
||||||
|
ThreadData->mFN = FN;
|
||||||
|
ThreadData->mPInt = PInt;
|
||||||
|
ThreadData->mPExt = PExt;
|
||||||
|
ThreadData->mPG = PG;
|
||||||
|
ThreadData->mTrainSpeed = TrainSpeed;
|
||||||
|
ThreadData->mBogie = Bogie;
|
||||||
|
ThreadData->mRank = Rank;
|
||||||
|
ThreadData->mPGIntValue = PGIntValue;
|
||||||
|
ThreadData->mPGExtValue = PGExtValue;
|
||||||
|
ThreadData->mS1Count = S1Count;
|
||||||
|
ThreadData->mS2Count = S2Count;
|
||||||
|
ThreadData->mFNCount = FNCount;
|
||||||
|
ThreadData->mTrainType = TrainType;
|
||||||
|
}
|
||||||
|
|
||||||
|
LogData->mTimestamp = timestamp;
|
||||||
|
LogData->mCIZT1 = CIZT1;
|
||||||
|
LogData->mCDVApproach_ZT1 = CDVApproach_ZT1;
|
||||||
|
LogData->mCDVARM_ZT1 = CDVARM_ZT1;
|
||||||
|
LogData->mDateTime.setDate(date);
|
||||||
|
LogData->mDateTime.setTime(time);
|
||||||
|
|
||||||
|
ZT1LOG->mZT1LogData.append(LogData);
|
||||||
|
}
|
||||||
|
|
||||||
|
// QList<CZTDetectionData*> Dummy; //JFM
|
||||||
|
QVector<CZTDetectionData*> Dummy;
|
||||||
|
Dummy.clear();
|
||||||
|
|
||||||
|
SaveTrainLog(CSVFilePathName.replace("csv","bin"),ZT1LOG,&Dummy,StationName);
|
||||||
|
|
||||||
|
for(int i = 0; i < ZT1LOG->mZT1LogData.size(); i++)
|
||||||
|
{
|
||||||
|
delete ZT1LOG->mZT1LogData.at(i);
|
||||||
|
}
|
||||||
|
ZT1LOG->mZT1LogData.clear();
|
||||||
|
delete ZT1LOG;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else //ZT1
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
61
sources/TrainLogFileMgr.h
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 - 2013 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Description du fichier si nécessaire.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### YYYMMDD JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef TRAINLOGFILEMGR_H
|
||||||
|
#define TRAINLOGFILEMGR_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include "ZTData.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class CLogElement;
|
||||||
|
|
||||||
|
class CTrainLogFileMgr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
//CTrainLogFileMgr is a singleton class
|
||||||
|
static CTrainLogFileMgr* instance(){return &mSingleton;}
|
||||||
|
static CTrainLogFileMgr mSingleton;
|
||||||
|
|
||||||
|
|
||||||
|
CTrainLogFileMgr();
|
||||||
|
unsigned int SaveTrainLog(QString LogFilePathName,CZT1Log *ZT1Log,QVector<CZTDetectionData*> *ZT1DetectionsLog,QString StationName);
|
||||||
|
unsigned int SaveTrainLog(QString LogFilePathName,QVector<CZT2LogData*> *ZT2Log,QVector<CZTDetectionData*> *ZT2DetectionsLog,QString StationName);
|
||||||
|
CLogElement *OpenTrainLog(QString LogFilePathName,unsigned int &RetValue,CLogElement *TargetElement = 0,bool LoadData = false);
|
||||||
|
unsigned int SaveCSVFile(QString CSVFilePathName,QVector<CZT1LogData*> *ZT1Log,CZT1FlagsData *ZT1Flags,QVector<CZTDetectionData*> *ZT1DetectionsLog, QString StationName);
|
||||||
|
unsigned int SaveCSVFile(QString CSVFilePathName,CZT1Log *ZT1Log,QVector<CZTDetectionData*> *ZT1DetectionsLog, QString StationName);
|
||||||
|
unsigned int SaveCSVFile(QString CSVFilePathName,QVector<CZT2LogData*> *ZT2Log,QVector<CZTDetectionData*> *ZT2DetectionsLog, QString StationName);
|
||||||
|
|
||||||
|
unsigned int SetTrainLogProtected(bool IsProtected,QString LogFilePathName);
|
||||||
|
|
||||||
|
unsigned int SaveBINFromCSV(QString CSVFilePathName);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TRAINLOGFILEMGR_H
|
||||||
|
|
||||||
41
sources/UDPProtocol.cpp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#include "UDPProtocol.h"
|
||||||
|
#include <QDataStream>
|
||||||
|
|
||||||
|
CUDPProtocol::CUDPProtocol()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int CUDPProtocol::AnalyseNewData(QByteArray Data)
|
||||||
|
{
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray CUDPProtocol::GetInitUDPConnectionPacket()
|
||||||
|
{
|
||||||
|
QByteArray packet;
|
||||||
|
packet.clear();
|
||||||
|
QDataStream stream(&packet,QIODevice::WriteOnly);
|
||||||
|
stream.device()->seek(0);
|
||||||
|
|
||||||
|
quint32 Request = (quint32)UDP_INIT_CONNECTION_REQUEST;
|
||||||
|
|
||||||
|
stream << UDP_PROTOCOL_HEADER << Request;
|
||||||
|
|
||||||
|
return packet;
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray CUDPProtocol::GetCloseUDPConnectionPacket()
|
||||||
|
{
|
||||||
|
QByteArray packet;
|
||||||
|
packet.clear();
|
||||||
|
QDataStream stream(&packet,QIODevice::WriteOnly);
|
||||||
|
stream.device()->seek(0);
|
||||||
|
|
||||||
|
quint32 Request = (quint32)UDP_CLOSE_CONNECTION_REQUEST;
|
||||||
|
|
||||||
|
stream << UDP_PROTOCOL_HEADER << Request;
|
||||||
|
|
||||||
|
return packet;
|
||||||
|
}
|
||||||
33
sources/UDPProtocol.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#ifndef UDPPROTOCOL_H
|
||||||
|
#define UDPPROTOCOL_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QByteArray>
|
||||||
|
|
||||||
|
#define UDP_PROTOCOL_HEADER (quint32)0xDEAD5AD5
|
||||||
|
|
||||||
|
|
||||||
|
class CUDPProtocol
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
UDP_INIT_CONNECTION_REQUEST,
|
||||||
|
UDP_CLOSE_CONNECTION_REQUEST,
|
||||||
|
TCP_MSG_UNKNOWN
|
||||||
|
}eUDPMessage;
|
||||||
|
|
||||||
|
|
||||||
|
CUDPProtocol();
|
||||||
|
|
||||||
|
public:
|
||||||
|
unsigned int AnalyseNewData(QByteArray Data);
|
||||||
|
|
||||||
|
QByteArray GetInitUDPConnectionPacket();
|
||||||
|
QByteArray GetStopUDPStreamPacket();
|
||||||
|
QByteArray GetCloseUDPConnectionPacket();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // UDPPROTOCOL_H
|
||||||
373
sources/ZTData.cpp
Normal file
@ -0,0 +1,373 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Classe fourre-tout qui contient les différentes structures données utilisées
|
||||||
|
un peu partout dans le programme.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### YYYMMDD JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "ZTData.h"
|
||||||
|
|
||||||
|
const char * CZTData::TrainTypeString[] = {"Inconnu","MR63/73", "MPM10"};
|
||||||
|
CZTData::CZTData()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * CZTData::ErrorString[] = {"Erreur de comptage S1-S2",
|
||||||
|
"Déclenchement frotteur négatif",
|
||||||
|
"Déclenchement pneu de guidage",
|
||||||
|
"Déclenchement pneu porteur intérieur",
|
||||||
|
"Déclenchement pneu porteur extérieur",
|
||||||
|
|
||||||
|
"Erreur de comptage ZT2",
|
||||||
|
"Déclenchement pneu porteur intérieur ZT2",
|
||||||
|
"Déclenchement pneu porteur extérieur ZT2",
|
||||||
|
|
||||||
|
"Panne équipement ZT1",
|
||||||
|
"Panne équipement ZT2",
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
const char * CZTData::ShortErrorString[] = {"V00",
|
||||||
|
"DFN",
|
||||||
|
"DPG",
|
||||||
|
"DPPI",
|
||||||
|
"DPPE",
|
||||||
|
|
||||||
|
"V002",
|
||||||
|
"DPPI2",
|
||||||
|
"DPPE2",
|
||||||
|
|
||||||
|
"PEQ1",
|
||||||
|
"PEQ2"};
|
||||||
|
|
||||||
|
const char* CZTData::GetErrorString(unsigned int ErrorID)
|
||||||
|
{
|
||||||
|
if(ErrorID >= DETECTION_MAX_DETECTION_ID)
|
||||||
|
ErrorID = 0;
|
||||||
|
return ErrorString[ErrorID];
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* CZTData::GetShortErrorString(unsigned int ErrorID)
|
||||||
|
{
|
||||||
|
if(ErrorID >= DETECTION_MAX_DETECTION_ID)
|
||||||
|
ErrorID = 0;
|
||||||
|
return ShortErrorString[ErrorID];
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* CZTData::GetTrainTypeString(unsigned int TrainType)
|
||||||
|
{
|
||||||
|
if(TrainType >= TRAIN_TYPE_MAX_ID)
|
||||||
|
TrainType = TRAIN_TYPE_UNKNOWN;
|
||||||
|
return TrainTypeString[TrainType];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CZT1LogData::CZT1LogData(CZT1ThreadData *ThreadData):
|
||||||
|
mZT1ThreadData(ThreadData)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
CZT1LogData::~CZT1LogData()
|
||||||
|
{
|
||||||
|
if(mZT1ThreadData != 0)
|
||||||
|
delete mZT1ThreadData;
|
||||||
|
}
|
||||||
|
|
||||||
|
CZT1ThreadData::~CZT1ThreadData()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CZT1ThreadData::operator =(CZT1ThreadData& TD)
|
||||||
|
{
|
||||||
|
mTimeStamp = TD.mTimeStamp;
|
||||||
|
mDateTime = TD.mDateTime;
|
||||||
|
mS1 = TD.mS1;
|
||||||
|
mS2 = TD.mS2;
|
||||||
|
mPInt = TD.mPInt;
|
||||||
|
mPExt = TD.mPExt;
|
||||||
|
mFN = TD.mFN;
|
||||||
|
mPG = TD.mPG;
|
||||||
|
|
||||||
|
mBogie = TD.mBogie;
|
||||||
|
mRank = TD.mRank;
|
||||||
|
mS1Count = TD.mS1Count;
|
||||||
|
mS2Count = TD.mS2Count;
|
||||||
|
mFNCount = TD.mFNCount;
|
||||||
|
mPGExtValue = TD.mPGExtValue;
|
||||||
|
mPGIntValue = TD.mPGIntValue;
|
||||||
|
mTrainSpeed = TD.mTrainSpeed;
|
||||||
|
mTrainType = TD.mTrainType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const CZT1FlagsData &source)
|
||||||
|
{
|
||||||
|
out << source.mExtPGOffset
|
||||||
|
<< source.mIntPGOffset
|
||||||
|
<< source.mPGCalibrationON
|
||||||
|
<< source.mPGTresholdValue
|
||||||
|
<< source.mAnalogTracePresent
|
||||||
|
<< source.mIsProblematicPassage
|
||||||
|
;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, CZT1FlagsData &dest)
|
||||||
|
{
|
||||||
|
in >> dest.mExtPGOffset
|
||||||
|
>> dest.mIntPGOffset
|
||||||
|
>> dest.mPGCalibrationON
|
||||||
|
>> dest.mPGTresholdValue
|
||||||
|
>> dest.mAnalogTracePresent
|
||||||
|
>> dest.mIsProblematicPassage
|
||||||
|
;
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream& operator<<(QDataStream &out, const CZT1LogData &source)
|
||||||
|
{
|
||||||
|
quint32 ThreadDataValid = 0;
|
||||||
|
if(source.mZT1ThreadData != 0)
|
||||||
|
ThreadDataValid = 1;
|
||||||
|
|
||||||
|
|
||||||
|
out << source.mDateTime
|
||||||
|
<< source.mTimestamp
|
||||||
|
<< source.mCIZT1
|
||||||
|
<< source.mCDVApproach_ZT1
|
||||||
|
<< source.mCDVARM_ZT1
|
||||||
|
<< ThreadDataValid;
|
||||||
|
|
||||||
|
if(ThreadDataValid == 1)
|
||||||
|
{
|
||||||
|
out << source.mZT1ThreadData->mS1
|
||||||
|
<< source.mZT1ThreadData->mS2
|
||||||
|
<< source.mZT1ThreadData->mFN
|
||||||
|
<< source.mZT1ThreadData->mPInt
|
||||||
|
<< source.mZT1ThreadData->mPExt
|
||||||
|
<< source.mZT1ThreadData->mPG
|
||||||
|
<< source.mZT1ThreadData->mTrainSpeed
|
||||||
|
<< source.mZT1ThreadData->mBogie
|
||||||
|
<< source.mZT1ThreadData->mRank
|
||||||
|
<< source.mZT1ThreadData->mPGExtValue
|
||||||
|
<< source.mZT1ThreadData->mPGIntValue
|
||||||
|
<< source.mZT1ThreadData->mTrainType
|
||||||
|
<< source.mZT1ThreadData->mS1Count
|
||||||
|
<< source.mZT1ThreadData->mS2Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, CZT1LogData &dest)
|
||||||
|
{
|
||||||
|
quint32 ThreadValid;
|
||||||
|
in >> dest.mDateTime
|
||||||
|
>> dest.mTimestamp
|
||||||
|
>> dest.mCIZT1
|
||||||
|
>> dest.mCDVApproach_ZT1
|
||||||
|
>> dest.mCDVARM_ZT1
|
||||||
|
>> ThreadValid;
|
||||||
|
if(ThreadValid == 1)
|
||||||
|
{
|
||||||
|
dest.mZT1ThreadData = new CZT1ThreadData();
|
||||||
|
in >> dest.mZT1ThreadData->mS1
|
||||||
|
>> dest.mZT1ThreadData->mS2
|
||||||
|
>> dest.mZT1ThreadData->mFN
|
||||||
|
>> dest.mZT1ThreadData->mPInt
|
||||||
|
>> dest.mZT1ThreadData->mPExt
|
||||||
|
>> dest.mZT1ThreadData->mPG
|
||||||
|
>> dest.mZT1ThreadData->mTrainSpeed
|
||||||
|
>> dest.mZT1ThreadData->mBogie
|
||||||
|
>> dest.mZT1ThreadData->mRank
|
||||||
|
>> dest.mZT1ThreadData->mPGExtValue
|
||||||
|
>> dest.mZT1ThreadData->mPGIntValue
|
||||||
|
>> dest.mZT1ThreadData->mTrainType
|
||||||
|
>>dest.mZT1ThreadData->mS1Count
|
||||||
|
>>dest.mZT1ThreadData->mS2Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const CZTDetectionData &source)
|
||||||
|
{
|
||||||
|
out << source.mTimeStamp
|
||||||
|
<< source.mRank
|
||||||
|
<< source.mDetectionID;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, CZTDetectionData &dest)
|
||||||
|
{
|
||||||
|
in >> dest.mTimeStamp
|
||||||
|
>> dest.mRank
|
||||||
|
>> dest.mDetectionID;
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
CZT2LogData::CZT2LogData(CZT2ThreadData *ThreadData):
|
||||||
|
mZT2ThreadData(ThreadData)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
CZT2LogData::~CZT2LogData()
|
||||||
|
{
|
||||||
|
if(mZT2ThreadData != 0)
|
||||||
|
delete mZT2ThreadData;
|
||||||
|
}
|
||||||
|
QDataStream &operator<<(QDataStream &out, const CZT2FlagsData &source)
|
||||||
|
{
|
||||||
|
out << source.mIsProblematicPassage
|
||||||
|
;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, CZT2FlagsData &dest)
|
||||||
|
{
|
||||||
|
in >> dest.mIsProblematicPassage
|
||||||
|
;
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QDataStream& operator<<(QDataStream &out, const CZT2LogData &source)
|
||||||
|
{
|
||||||
|
quint32 ThreadDataValid = 0;
|
||||||
|
if(source.mZT2ThreadData != 0)
|
||||||
|
ThreadDataValid = 1;
|
||||||
|
|
||||||
|
out << source.mDateTime
|
||||||
|
<< source.mTimestamp
|
||||||
|
<< source.mCIZT2
|
||||||
|
<< source.mCDVARM_ZT2
|
||||||
|
<< source.mCDVApproach_ZT2
|
||||||
|
<< ThreadDataValid;
|
||||||
|
|
||||||
|
if(ThreadDataValid == 1)
|
||||||
|
{
|
||||||
|
out << source.mZT2ThreadData->mS1
|
||||||
|
<< source.mZT2ThreadData->mPPInt
|
||||||
|
<< source.mZT2ThreadData->mPPExt
|
||||||
|
<< source.mZT2ThreadData->mBogie
|
||||||
|
<< source.mZT2ThreadData->mRank
|
||||||
|
<< source.mZT2ThreadData->mS1Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, CZT2LogData &dest)
|
||||||
|
{
|
||||||
|
quint32 ThreadValid;
|
||||||
|
in >> dest.mDateTime
|
||||||
|
>> dest.mTimestamp
|
||||||
|
>> dest.mCIZT2
|
||||||
|
>> dest.mCDVARM_ZT2
|
||||||
|
>> dest.mCDVApproach_ZT2
|
||||||
|
>> ThreadValid;
|
||||||
|
if(ThreadValid == 1)
|
||||||
|
{
|
||||||
|
dest.mZT2ThreadData = new CZT2ThreadData();
|
||||||
|
in >> dest.mZT2ThreadData->mS1
|
||||||
|
>> dest.mZT2ThreadData->mPPInt
|
||||||
|
>> dest.mZT2ThreadData->mPPExt
|
||||||
|
>> dest.mZT2ThreadData->mBogie
|
||||||
|
>> dest.mZT2ThreadData->mRank
|
||||||
|
>> dest.mZT2ThreadData->mS1Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
CZTDetectionFunctionConfig::CZTDetectionFunctionConfig()
|
||||||
|
{
|
||||||
|
for(int i = 0; i < DETECTION_FCT_MAX_FCT; i++)
|
||||||
|
{
|
||||||
|
mZTDetectionConfig[i].AnalysisActive = false;
|
||||||
|
mZTDetectionConfig[i].TKActive = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CZTDetectionFunctionConfig::operator =(CZTDetectionFunctionConfig& DF)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < DETECTION_FCT_MAX_FCT; i++)
|
||||||
|
{
|
||||||
|
mZTDetectionConfig[i].AnalysisActive = DF.mZTDetectionConfig[i].AnalysisActive;
|
||||||
|
mZTDetectionConfig[i].TKActive = DF.mZTDetectionConfig[i].TKActive;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const CZTDetectionFunctionConfig &source)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < DETECTION_FCT_MAX_FCT; i++)
|
||||||
|
{
|
||||||
|
out << source.mZTDetectionConfig[i].AnalysisActive
|
||||||
|
<< source.mZTDetectionConfig[i].TKActive;
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, CZTDetectionFunctionConfig &dest)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < DETECTION_FCT_MAX_FCT; i++)
|
||||||
|
{
|
||||||
|
in >> dest.mZTDetectionConfig[i].AnalysisActive
|
||||||
|
>> dest.mZTDetectionConfig[i].TKActive;
|
||||||
|
}
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
CSettingsData::CSettingsData()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
CZTSettingsData::CZTSettingsData()
|
||||||
|
{
|
||||||
|
mDetectionFunctionSettings = new CZTDetectionFunctionConfig();
|
||||||
|
mAutoExportZT1CSV = false;
|
||||||
|
mAutoExportZT2CSV = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const CZTNetworkConfig &source)
|
||||||
|
{
|
||||||
|
out << source.mZTID
|
||||||
|
<< source.mIPAdress;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, CZTNetworkConfig &dest)
|
||||||
|
{
|
||||||
|
in >> dest.mZTID
|
||||||
|
>> dest.mIPAdress;
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
348
sources/ZTData.h
Normal file
@ -0,0 +1,348 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Ces classes contiennent l'état de la Zone Tests et les informations nécessaires
|
||||||
|
au fonctionnement des machines à états.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20130501 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef ZTDATA_H
|
||||||
|
#define ZTDATA_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QObject>
|
||||||
|
#include <QTime>
|
||||||
|
#include <QDataStream>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
|
enum eZTLOGType
|
||||||
|
{
|
||||||
|
ZT1_LOG_TYPE,
|
||||||
|
ZT2_LOG_TYPE,
|
||||||
|
UNKNOWN_LOG_TYPE
|
||||||
|
};
|
||||||
|
|
||||||
|
enum eCDVState
|
||||||
|
{
|
||||||
|
CDV_STATE_OCCUPIED,
|
||||||
|
CDV_STATE_FREE,
|
||||||
|
CDV_STATE_ITI_CMD,
|
||||||
|
CDV_STATE_UNKNOWN
|
||||||
|
};
|
||||||
|
|
||||||
|
enum eSwitchCVDPosition
|
||||||
|
{
|
||||||
|
SWITCH_CDV_NORMAL_POSITION,
|
||||||
|
SWITCH_CDV_REVERSE_POSITION,
|
||||||
|
SWITCH_CDV_UNKNOWN_POSITION
|
||||||
|
};
|
||||||
|
|
||||||
|
enum eCDVType
|
||||||
|
{
|
||||||
|
CDV_NORMAL_TYPE,
|
||||||
|
CDV_SWITCH_TYPE
|
||||||
|
};
|
||||||
|
|
||||||
|
enum eDetectionID
|
||||||
|
{
|
||||||
|
DETECTION_MAGNETIC_SENSOR_COUNT,
|
||||||
|
DETECTION_FN_DETECTION,
|
||||||
|
DETECTION_PG_DETECTION,
|
||||||
|
DETECTION_PPI_DETECTION,
|
||||||
|
DETECTION_PPE_DETECTION,
|
||||||
|
|
||||||
|
DETECTION_ZT2_MAGNETIC_SENCOR_COUNT,
|
||||||
|
DETECTION_ZT2_PPI_DETECTION,
|
||||||
|
DETECTION_ZT2_PPE_DETECTION,
|
||||||
|
|
||||||
|
DETECTION_PEQ1_DETECTION,
|
||||||
|
DETECTION_PEQ2_DETECTION,
|
||||||
|
|
||||||
|
DETECTION_MAX_DETECTION_ID
|
||||||
|
};
|
||||||
|
|
||||||
|
enum eDetectionFunctionID
|
||||||
|
{
|
||||||
|
DETECTION_FCT_FN,
|
||||||
|
DETECTION_FCT_PG,
|
||||||
|
DETECTION_FCT_PP,
|
||||||
|
DETECTION_FCT_PP2,
|
||||||
|
DETECTION_FCT_ZT1,
|
||||||
|
DETECTION_FCT_ZT2,
|
||||||
|
|
||||||
|
DETECTION_FCT_MAX_FCT
|
||||||
|
};
|
||||||
|
|
||||||
|
enum eTrainTypeID
|
||||||
|
{
|
||||||
|
TRAIN_TYPE_UNKNOWN,
|
||||||
|
TRAIN_TYPE_MR63_MR73,
|
||||||
|
TRAIN_TYPE_MPM10,
|
||||||
|
|
||||||
|
|
||||||
|
TRAIN_TYPE_MAX_ID
|
||||||
|
};
|
||||||
|
|
||||||
|
enum eZT1FlagsID
|
||||||
|
{
|
||||||
|
ZT1_INT_PG_OFFSET_FLAG_ID,
|
||||||
|
ZT1_EXT_PG_OFFSET_FLAG_ID,
|
||||||
|
ZT1_PG_TRESHOLD_VALUE_FLAG_ID,
|
||||||
|
ZT1_PG_CALIB_ON_FLAG_ID,
|
||||||
|
|
||||||
|
|
||||||
|
ZT1_MAX_FLAG_ID
|
||||||
|
};
|
||||||
|
|
||||||
|
enum eZTStatus
|
||||||
|
{
|
||||||
|
SB_ZT_ACTIVE_STATUS,
|
||||||
|
SB_ZT_INACTIVE_STATUS,
|
||||||
|
SB_ZT_NOT_PRESENT_STATUS,
|
||||||
|
SB_ZT_DISABLED_STATUS,
|
||||||
|
SB_ZT_MAX_STATUS
|
||||||
|
};
|
||||||
|
|
||||||
|
class CZTData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CZTData();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int mCIZT2;
|
||||||
|
|
||||||
|
static const char *ErrorString[];
|
||||||
|
static const char *ShortErrorString[];
|
||||||
|
static const char* GetErrorString(unsigned int ErrorID);
|
||||||
|
static const char* GetShortErrorString(unsigned int ErrorID);
|
||||||
|
|
||||||
|
static const char *TrainTypeString[];
|
||||||
|
static const char *GetTrainTypeString(unsigned int TrainType);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
//This class contains data from the ZT1 analysis thread
|
||||||
|
//that is periodically communicated to the main thread
|
||||||
|
class CZT1ThreadData
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
~CZT1ThreadData();
|
||||||
|
qint64 mTimeStamp; //nanosecs
|
||||||
|
QDateTime mDateTime;
|
||||||
|
quint32 mS1;
|
||||||
|
quint32 mS2;
|
||||||
|
quint32 mPInt;
|
||||||
|
quint32 mPExt;
|
||||||
|
quint32 mFN;
|
||||||
|
quint32 mPG;
|
||||||
|
|
||||||
|
quint32 mBogie;
|
||||||
|
quint32 mRank;
|
||||||
|
quint32 mS1Count;
|
||||||
|
quint32 mS2Count;
|
||||||
|
quint32 mFNCount;
|
||||||
|
qint32 mPGExtValue;
|
||||||
|
qint32 mPGIntValue;
|
||||||
|
qreal mTrainSpeed;
|
||||||
|
quint32 mTrainType;
|
||||||
|
|
||||||
|
void operator=(CZT1ThreadData& a);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CZT1FlagsData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
qint32 mIntPGOffset;
|
||||||
|
qint32 mExtPGOffset;
|
||||||
|
qint32 mPGTresholdValue;
|
||||||
|
qint32 mPGCalibrationON;
|
||||||
|
qint32 mAnalogTracePresent;
|
||||||
|
qint32 mIsProblematicPassage; //This flag will be set if problems have been detected but not sent to PCC due to PURE comitee rules.
|
||||||
|
};
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const CZT1FlagsData &source);
|
||||||
|
QDataStream &operator>>(QDataStream &in, CZT1FlagsData &dest);
|
||||||
|
|
||||||
|
class CZT1LogData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CZT1LogData(CZT1ThreadData *ThreadData = 0);
|
||||||
|
~CZT1LogData();
|
||||||
|
|
||||||
|
QDateTime mDateTime;
|
||||||
|
qint64 mTimestamp;
|
||||||
|
quint32 mCIZT1;
|
||||||
|
quint32 mCDVApproach_ZT1;
|
||||||
|
quint32 mCDVARM_ZT1;
|
||||||
|
#ifdef USE_ANALOG_ACQUISITION
|
||||||
|
qint32 mAnalogData; //The analog data must be written or read to/from file manually (not part of the QStream << operator overloading)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
CZT1ThreadData *mZT1ThreadData;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CZT1Log
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// QList<CZT1LogData*> mZT1LogData;
|
||||||
|
QVector<CZT1LogData*> mZT1LogData;
|
||||||
|
CZT1FlagsData mZT1Flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const CZT1LogData &source);
|
||||||
|
QDataStream &operator>>(QDataStream &in, CZT1LogData &dest);
|
||||||
|
|
||||||
|
class CZT2ThreadData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
qint64 mTimeStamp;
|
||||||
|
quint32 mS1;
|
||||||
|
quint32 mPPInt;
|
||||||
|
quint32 mPPExt;
|
||||||
|
|
||||||
|
quint32 mBogie;
|
||||||
|
quint32 mRank;
|
||||||
|
quint32 mS1Count;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CZTDetectionData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
qint64 mTimeStamp;
|
||||||
|
// QDateTime mDateTime;
|
||||||
|
quint32 mDetectionID;
|
||||||
|
quint32 mRank;
|
||||||
|
// quint32 mBogie;
|
||||||
|
|
||||||
|
};
|
||||||
|
QDataStream &operator<<(QDataStream &out, const CZTDetectionData &source);
|
||||||
|
QDataStream &operator>>(QDataStream &in, CZTDetectionData &dest);
|
||||||
|
|
||||||
|
class CZT2FlagsData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
qint32 mIsProblematicPassage; //This flag will be set if problems have been detected but not sent to PCC due to PURE comitee rules.
|
||||||
|
};
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const CZT2FlagsData &source);
|
||||||
|
QDataStream &operator>>(QDataStream &in, CZT2FlagsData &dest);
|
||||||
|
|
||||||
|
class CZT2LogData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CZT2LogData(CZT2ThreadData *ThreadData = 0);
|
||||||
|
~CZT2LogData();
|
||||||
|
|
||||||
|
QDateTime mDateTime;
|
||||||
|
qint64 mTimestamp;
|
||||||
|
quint32 mCIZT2;
|
||||||
|
quint32 mCDVARM_ZT2;
|
||||||
|
quint32 mCDVApproach_ZT2;
|
||||||
|
|
||||||
|
CZT2ThreadData *mZT2ThreadData;
|
||||||
|
};
|
||||||
|
QDataStream &operator<<(QDataStream &out, const CZT2LogData &source);
|
||||||
|
QDataStream &operator>>(QDataStream &in, CZT2LogData &dest);
|
||||||
|
|
||||||
|
class CZT2Log
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QVector<CZT2LogData*> mZT2LogData;
|
||||||
|
CZT2FlagsData mZT2Flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CZTDetectionConfig
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool AnalysisActive;
|
||||||
|
bool TKActive;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CZTDetectionFunctionConfig
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CZTDetectionFunctionConfig();
|
||||||
|
CZTDetectionConfig mZTDetectionConfig[DETECTION_FCT_MAX_FCT];
|
||||||
|
|
||||||
|
void operator=(CZTDetectionFunctionConfig& a);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const CZTDetectionFunctionConfig &source);
|
||||||
|
QDataStream &operator>>(QDataStream &in, CZTDetectionFunctionConfig &dest);
|
||||||
|
|
||||||
|
class CZTSettingsData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CZTSettingsData();
|
||||||
|
|
||||||
|
CZTDetectionFunctionConfig *mDetectionFunctionSettings;
|
||||||
|
bool mAutoExportZT1CSV;
|
||||||
|
bool mAutoExportZT2CSV;
|
||||||
|
int mPGTreshold;
|
||||||
|
|
||||||
|
};
|
||||||
|
class CZTNetworkConfig
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int mZTID;
|
||||||
|
QString mIPAdress;
|
||||||
|
};
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const CZTNetworkConfig &source);
|
||||||
|
QDataStream &operator>>(QDataStream &in, CZTNetworkConfig &dest);
|
||||||
|
|
||||||
|
class CSettingsData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CSettingsData();
|
||||||
|
|
||||||
|
QString mDataSourceDirectoryPath;
|
||||||
|
QList<CZTNetworkConfig> mNetworkCfgList;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class CZTPGCalibrationData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
qint64 mTimestamp;
|
||||||
|
int mTrainNbr;
|
||||||
|
qint32 mPGExtValue;
|
||||||
|
qint32 mPGIntValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CZTLogFileInfo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QDateTime mStartDateTime;
|
||||||
|
QDateTime mEndDateTime;
|
||||||
|
QString mStationName;
|
||||||
|
int mZTStationID;
|
||||||
|
QString mZTLogFilePath;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ZTDATA_H
|
||||||
391
sources/ZTLogFilesMgr.cpp
Normal file
@ -0,0 +1,391 @@
|
|||||||
|
#include "ZTLogFilesMgr.h"
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QTextStream>
|
||||||
|
#include "OutilZT.h"
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QBuffer>
|
||||||
|
|
||||||
|
CZTLogFilesMgr::CZTLogFilesMgr()
|
||||||
|
{
|
||||||
|
|
||||||
|
mProgramHandle = 0;
|
||||||
|
|
||||||
|
mDirParserThread = new QThread();
|
||||||
|
mDirParserWorkerThread = new CDirParserThread();
|
||||||
|
mDirParserWorkerThread->moveToThread(mDirParserThread);
|
||||||
|
connect(mDirParserThread,SIGNAL(started()),mDirParserWorkerThread,SLOT(ParseDirectories()));
|
||||||
|
connect(mDirParserThread,SIGNAL(finished()),this,SLOT(ThreadQuit()));
|
||||||
|
connect(mDirParserThread,SIGNAL(terminated()),this,SLOT(ThreadTerminated()));
|
||||||
|
connect(mDirParserWorkerThread,SIGNAL(NewLogParsed(QString,bool)),this,SLOT(NewZTLogParsed(QString,bool)));
|
||||||
|
connect(mDirParserWorkerThread,SIGNAL(ParsingFinished(int)),this,SLOT(DirParsingFinished(int)));
|
||||||
|
connect(mDirParserWorkerThread,SIGNAL(EmptyDirParsed()),this,SLOT(EmptyDirParsed()));
|
||||||
|
|
||||||
|
mDatabaseParsingTimer = new QTimer();
|
||||||
|
mDatabaseParsingTimer->setInterval(60000);
|
||||||
|
connect(mDatabaseParsingTimer,SIGNAL(timeout()),this,SLOT(ParsingTimerExpired()));
|
||||||
|
|
||||||
|
mSaveDBFile = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CZTLogFilesMgr::~CZTLogFilesMgr()
|
||||||
|
{
|
||||||
|
delete mDirParserThread;
|
||||||
|
delete mDirParserWorkerThread;
|
||||||
|
delete mDatabaseParsingTimer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CZTLogFilesMgr::DestroyZTLogFilesList()
|
||||||
|
{
|
||||||
|
mZTLogFilesList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CZTLogFilesMgr::ParseZTLogFiles(bool RebuildDatabase)
|
||||||
|
{
|
||||||
|
mZTLogFilesList.clear();
|
||||||
|
|
||||||
|
if(RebuildDatabase == true)
|
||||||
|
{
|
||||||
|
mSaveDBFile = true;
|
||||||
|
mDirParserWorkerThread->SetParsingInfo(QDir(mLogDatabaseDir),"*.txt",false);
|
||||||
|
mDirParserThread->start();
|
||||||
|
mProgramHandle->ZTLogFilesFetchingBegin(this);
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QDir BaseDir(mLogDatabaseDir);
|
||||||
|
QString DatabaseFilePath = BaseDir.filePath("ZTLogs.zdb");
|
||||||
|
// DatabaseFilePath += "Trains.zdb";
|
||||||
|
QFile* DatabaseFile = new QFile(BaseDir.filePath("ZTLogs.zdb")/*DatabaseFilePath*/);
|
||||||
|
|
||||||
|
|
||||||
|
if(DatabaseFile)
|
||||||
|
{
|
||||||
|
if(DatabaseFile->open(QIODevice::ReadOnly | QIODevice::Unbuffered) == false)
|
||||||
|
{
|
||||||
|
mSaveDBFile = true;
|
||||||
|
mDirParserWorkerThread->SetParsingInfo(QDir(mLogDatabaseDir),"*.txt",false);
|
||||||
|
mDirParserThread->start();
|
||||||
|
mProgramHandle->ZTLogFilesFetchingBegin(this);
|
||||||
|
|
||||||
|
delete DatabaseFile;
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMessageBox::information(0,"Erreur","Impossible de créer le fichier DB ZTLog");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray DBData = DatabaseFile->readAll();
|
||||||
|
QDataStream *DBStrm = new QDataStream(DBData);
|
||||||
|
|
||||||
|
qint32 NBRecords;
|
||||||
|
*DBStrm >> NBRecords;
|
||||||
|
|
||||||
|
for(qint32 i = 0; i < NBRecords; i++)
|
||||||
|
{
|
||||||
|
CZTLogFileInfo NewElement;
|
||||||
|
|
||||||
|
*DBStrm >> NewElement.mStationName
|
||||||
|
>> NewElement.mZTStationID
|
||||||
|
>> NewElement.mStartDateTime
|
||||||
|
>> NewElement.mEndDateTime
|
||||||
|
>> NewElement.mZTLogFilePath;
|
||||||
|
|
||||||
|
mZTLogFilesList.append(NewElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
DatabaseFile->close();
|
||||||
|
delete DatabaseFile;
|
||||||
|
delete DBStrm;
|
||||||
|
|
||||||
|
DirParsingFinished(1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CZTLogFilesMgr::NewZTLogParsed(QString FilePath, bool KeepData)
|
||||||
|
{
|
||||||
|
Q_UNUSED(KeepData)
|
||||||
|
|
||||||
|
mProgramHandle->ZTLogFilesFetchingTick(this,mZTLogFilesList.size(),FilePath);
|
||||||
|
ExtractLogInfo(FilePath);
|
||||||
|
mDatabaseParsingTimer->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CZTLogFilesMgr::DirParsingFinished(int Res)
|
||||||
|
{
|
||||||
|
qDebug("ZTLog Files Parsing finished with result %d",Res);
|
||||||
|
mDirParserThread->quit();
|
||||||
|
mDatabaseParsingTimer->stop();
|
||||||
|
mProgramHandle->ZTLogFilesDatabaseLoaded(this,Res);
|
||||||
|
qDebug("Parsed %d ZTLog files",mZTLogFilesList.size());
|
||||||
|
|
||||||
|
if(mSaveDBFile == true)
|
||||||
|
{
|
||||||
|
SaveDatabaseFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int CZTLogFilesMgr::GetZTLogFilesCount()
|
||||||
|
{
|
||||||
|
return mZTLogFilesList.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CZTLogFilesMgr::ParsingTimerExpired()
|
||||||
|
{
|
||||||
|
qDebug("ZTLogs Parsing timer timeout");
|
||||||
|
mDirParserWorkerThread->KillThread();
|
||||||
|
mDirParserThread->terminate();
|
||||||
|
DirParsingFinished(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CZTLogFilesMgr::EmptyDirParsed()
|
||||||
|
{
|
||||||
|
//The thread is not stuck. Kick the timer...
|
||||||
|
mDatabaseParsingTimer->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CZTLogFilesMgr::ThreadQuit()
|
||||||
|
{
|
||||||
|
// qDebug("Thread quit slot");
|
||||||
|
}
|
||||||
|
|
||||||
|
void CZTLogFilesMgr::ThreadTerminated()
|
||||||
|
{
|
||||||
|
// qDebug("Thread terminated slot");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool CZTLogFilesMgr::ExtractLogInfo(QString LogFilePath)
|
||||||
|
{
|
||||||
|
QFileInfo LogFileInfo(LogFilePath);
|
||||||
|
|
||||||
|
if(LogFileInfo.fileName() != "ZTLog.txt")
|
||||||
|
return false;
|
||||||
|
|
||||||
|
CZTLogFileInfo NewLogFileInfo;
|
||||||
|
|
||||||
|
|
||||||
|
int line =0;
|
||||||
|
QFile *LogFile = new QFile(LogFilePath);
|
||||||
|
if(LogFile)
|
||||||
|
{
|
||||||
|
if(LogFile->open(QIODevice::ReadOnly | QIODevice::Text | QIODevice::Unbuffered) == true)
|
||||||
|
{
|
||||||
|
QString LogText(LogFile->readAll());
|
||||||
|
|
||||||
|
QTextStream strm(&LogText);
|
||||||
|
strm.seek(0);
|
||||||
|
|
||||||
|
QString temp;
|
||||||
|
|
||||||
|
//find a valid line
|
||||||
|
do
|
||||||
|
{
|
||||||
|
temp = strm.readLine();
|
||||||
|
line++;
|
||||||
|
|
||||||
|
if(strm.atEnd())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
while(temp.length() < 10);
|
||||||
|
|
||||||
|
// temp = strm.readLine();
|
||||||
|
QStringList parts = temp.split(" : ");
|
||||||
|
QString LineText,DateString;
|
||||||
|
|
||||||
|
|
||||||
|
if(parts.size() != 0)
|
||||||
|
{
|
||||||
|
LineText.clear();
|
||||||
|
|
||||||
|
DateString = parts.at(0);
|
||||||
|
NewLogFileInfo.mStartDateTime = QDateTime::fromString(DateString,"yyyy/MM/dd - hh:mm:ss.zzz");
|
||||||
|
}
|
||||||
|
|
||||||
|
//go to end of file
|
||||||
|
QString LastValidLine;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
temp = strm.readLine();
|
||||||
|
if(temp.size() >=10)
|
||||||
|
LastValidLine = temp;
|
||||||
|
}
|
||||||
|
while(!strm.atEnd());
|
||||||
|
|
||||||
|
parts = LastValidLine.split(" : ");
|
||||||
|
|
||||||
|
if(parts.size() != 0)
|
||||||
|
{
|
||||||
|
DateString = parts.at(0);
|
||||||
|
NewLogFileInfo.mEndDateTime = QDateTime::fromString(DateString,"yyyy/MM/dd - hh:mm:ss.zzz");
|
||||||
|
}
|
||||||
|
LogFile->close();
|
||||||
|
}
|
||||||
|
delete LogFile;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
NewLogFileInfo.mZTLogFilePath = LogFilePath;
|
||||||
|
|
||||||
|
if(LogFilePath.contains("ANG"))
|
||||||
|
{
|
||||||
|
NewLogFileInfo.mZTStationID = ANGRIGNON_ZT_ID;
|
||||||
|
NewLogFileInfo.mStationName = mProgramHandle->GetStationName(ANGRIGNON_ZT_ID);// "Angrignon";
|
||||||
|
}
|
||||||
|
else if(LogFilePath.contains("BUQ4"))
|
||||||
|
{
|
||||||
|
NewLogFileInfo.mZTStationID = BERRI_UQAM_ZT_ID;
|
||||||
|
NewLogFileInfo.mStationName = mProgramHandle->GetStationName(BERRI_UQAM_ZT_ID);//"Berri-UQAM";
|
||||||
|
}
|
||||||
|
else if(LogFilePath.contains("HBOU"))
|
||||||
|
{
|
||||||
|
NewLogFileInfo.mZTStationID = HENRI_BOURASSA_ZT_ID;
|
||||||
|
NewLogFileInfo.mStationName = mProgramHandle->GetStationName(HENRI_BOURASSA_ZT_ID);//"Henri-Bourassa";
|
||||||
|
}
|
||||||
|
else if(LogFilePath.contains("HBGR"))
|
||||||
|
{
|
||||||
|
NewLogFileInfo.mZTStationID = HONORE_BEAUGRAND_ZT_ID;
|
||||||
|
NewLogFileInfo.mStationName = mProgramHandle->GetStationName(HONORE_BEAUGRAND_ZT_ID);//"Honoré-Beaugrand";
|
||||||
|
}
|
||||||
|
else if(LogFilePath.contains("LONG"))
|
||||||
|
{
|
||||||
|
NewLogFileInfo.mZTStationID = LONGUEUIL_ZT_ID;
|
||||||
|
NewLogFileInfo.mStationName = mProgramHandle->GetStationName(LONGUEUIL_ZT_ID);//"Longueuil";
|
||||||
|
}
|
||||||
|
else if(LogFilePath.contains("MMOY"))
|
||||||
|
{
|
||||||
|
NewLogFileInfo.mZTStationID = MONTMORENCY_ZT_ID;
|
||||||
|
NewLogFileInfo.mStationName = mProgramHandle->GetStationName(MONTMORENCY_ZT_ID);//"Montmorency";
|
||||||
|
}
|
||||||
|
else if(LogFilePath.contains("MMO"))
|
||||||
|
{
|
||||||
|
NewLogFileInfo.mZTStationID = MONTMORENCY_10_12_ZT_ID;
|
||||||
|
NewLogFileInfo.mStationName = mProgramHandle->GetStationName(MONTMORENCY_10_12_ZT_ID);//"Montmorency 10/12";
|
||||||
|
}
|
||||||
|
else if(LogFilePath.contains("MMO2"))
|
||||||
|
{
|
||||||
|
NewLogFileInfo.mZTStationID = MONTMORENCY_10_22_ZT_ID;
|
||||||
|
NewLogFileInfo.mStationName = mProgramHandle->GetStationName(MONTMORENCY_10_22_ZT_ID);///"Montmorency 10/22";
|
||||||
|
}
|
||||||
|
else if(LogFilePath.contains("SMIC"))
|
||||||
|
{
|
||||||
|
NewLogFileInfo.mZTStationID = SAINT_MICHEL_ZT_ID;
|
||||||
|
NewLogFileInfo.mStationName = mProgramHandle->GetStationName(SAINT_MICHEL_ZT_ID);//"Saint-Michel";
|
||||||
|
}
|
||||||
|
else if(LogFilePath.contains("SNW5"))
|
||||||
|
{
|
||||||
|
NewLogFileInfo.mZTStationID = SNOWDON_ZT_ID;
|
||||||
|
NewLogFileInfo.mStationName = mProgramHandle->GetStationName(SNOWDON_ZT_ID);//"Snowdon";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mZTLogFilesList.append(NewLogFileInfo);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CZTLogFilesMgr::ParseDir(QDir dir)
|
||||||
|
{
|
||||||
|
|
||||||
|
QStringList LogFilters;
|
||||||
|
QFileInfoList list;
|
||||||
|
// QString LogDataDir = mProgramHandle->GetLogDataPath();
|
||||||
|
LogFilters << "*.txt";
|
||||||
|
|
||||||
|
//Load files in base directory
|
||||||
|
QDir LogDir(dir);
|
||||||
|
LogDir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
|
||||||
|
LogDir.setNameFilters(LogFilters);
|
||||||
|
LogDir.setSorting(QDir::Name);
|
||||||
|
list = LogDir.entryInfoList();
|
||||||
|
if(list.size() != 0)
|
||||||
|
{
|
||||||
|
//Extract data for each passage
|
||||||
|
for(int i = 0; i < list.size(); i++)
|
||||||
|
{
|
||||||
|
ExtractLogInfo(list.at(i).absoluteFilePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Check for subdirectories
|
||||||
|
QDir SubDirectories(dir);
|
||||||
|
|
||||||
|
SubDirectories.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
|
|
||||||
|
QFileInfoList SubDirList = SubDirectories.entryInfoList();
|
||||||
|
for(int i = 0; i < SubDirList.size(); i++)
|
||||||
|
{
|
||||||
|
ParseDir(QDir(SubDirList.at(i).absoluteFilePath()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CZTLogFilesMgr::SaveDatabaseFile()
|
||||||
|
{
|
||||||
|
qDebug("Saving ZTLogs.zdb database");
|
||||||
|
QDir BaseDir(mLogDatabaseDir);
|
||||||
|
QString DatabaseFilePath = BaseDir.filePath("ZTLogs.zdb");
|
||||||
|
// DatabaseFilePath += "Trains.zdb";
|
||||||
|
QFile* DatabaseFile = new QFile(BaseDir.filePath("ZTLogs.zdb")/*DatabaseFilePath*/);
|
||||||
|
|
||||||
|
|
||||||
|
if(DatabaseFile)
|
||||||
|
{
|
||||||
|
if(DatabaseFile->open(QIODevice::WriteOnly | QIODevice::Unbuffered) == false)
|
||||||
|
{
|
||||||
|
QMessageBox::information(0,"Erreur","Impossible de créer le fichier DB ZTLog");
|
||||||
|
delete DatabaseFile;
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMessageBox::information(0,"Erreur","Impossible de créer le fichier DB ZTLog");
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QByteArray byteArray;
|
||||||
|
QBuffer FileBuffer(&byteArray);
|
||||||
|
FileBuffer.open(QIODevice::WriteOnly);
|
||||||
|
QDataStream *DBStrm = new QDataStream(&FileBuffer);
|
||||||
|
|
||||||
|
qint32 NBRecords = mZTLogFilesList.size();
|
||||||
|
*DBStrm << NBRecords;
|
||||||
|
|
||||||
|
for(int i = 0; i < mZTLogFilesList.size(); i++)
|
||||||
|
{
|
||||||
|
*DBStrm << mZTLogFilesList.at(i).mStationName
|
||||||
|
<< mZTLogFilesList.at(i).mZTStationID
|
||||||
|
<< mZTLogFilesList.at(i).mStartDateTime
|
||||||
|
<< mZTLogFilesList.at(i).mEndDateTime
|
||||||
|
<< mZTLogFilesList.at(i).mZTLogFilePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
FileBuffer.seek(0);
|
||||||
|
DatabaseFile->write(FileBuffer.buffer());
|
||||||
|
DatabaseFile->flush();
|
||||||
|
|
||||||
|
FileBuffer.close();
|
||||||
|
DatabaseFile->close();
|
||||||
|
delete DatabaseFile;
|
||||||
|
delete DBStrm;
|
||||||
|
mSaveDBFile = false;
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
83
sources/ZTLogFilesMgr.h
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 - 2013 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Cette classe est responsable de la création d'une liste de tous lesfichiers
|
||||||
|
ZTLog présents dans la base de données. À ne pas confondre avec les fichiers
|
||||||
|
de passage.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20150227 JFM
|
||||||
|
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef ZTLOGFILESMGR_H
|
||||||
|
#define ZTLOGFILESMGR_H
|
||||||
|
|
||||||
|
#include "ZTData.h"
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QList>
|
||||||
|
#include <QDir>
|
||||||
|
#include "DirParserThread.h"
|
||||||
|
#include <QThread>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
class COutilZT;
|
||||||
|
|
||||||
|
class CZTLogFilesMgr: public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CZTLogFilesMgr();
|
||||||
|
~CZTLogFilesMgr();
|
||||||
|
|
||||||
|
COutilZT *mProgramHandle;
|
||||||
|
|
||||||
|
void DestroyZTLogFilesList();
|
||||||
|
void ParseZTLogFiles(bool RebuildDatabase);
|
||||||
|
bool ExtractLogInfo(QString LogFilePath);
|
||||||
|
void SetLogDataDir(QString Dir){mLogDatabaseDir = Dir;}
|
||||||
|
QList<CZTLogFileInfo> *GetZTLogsList(){return &mZTLogFilesList;}
|
||||||
|
int GetZTLogFilesCount();
|
||||||
|
int SaveDatabaseFile();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
QList<CZTLogFileInfo> mZTLogFilesList;
|
||||||
|
QString mLogDatabaseDir;
|
||||||
|
QThread *mDirParserThread;
|
||||||
|
CDirParserThread *mDirParserWorkerThread;
|
||||||
|
QTimer *mDatabaseParsingTimer;
|
||||||
|
bool mSaveDBFile;
|
||||||
|
|
||||||
|
|
||||||
|
int ParseDir(QDir dir);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void NewZTLogParsed(QString,bool);
|
||||||
|
void DirParsingFinished(int);
|
||||||
|
void ParsingTimerExpired();
|
||||||
|
void EmptyDirParsed();
|
||||||
|
|
||||||
|
|
||||||
|
void ThreadQuit();
|
||||||
|
void ThreadTerminated();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ZTLOGFILESMGR_H
|
||||||
73
sources/main.cpp
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Le main.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20121210 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
#include <QApplication>
|
||||||
|
#include "OutilZT.h"
|
||||||
|
#include "MainPanel.h"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
QApplication::setGraphicsSystem("raster");
|
||||||
|
//Qt Mainframe application instance.
|
||||||
|
QApplication a(argc, argv);
|
||||||
|
|
||||||
|
QFont serifFont("Times", 10, QFont::Bold);
|
||||||
|
QApplication::setFont(serifFont);
|
||||||
|
|
||||||
|
|
||||||
|
bool EngMode = false;
|
||||||
|
bool CanImport = false;
|
||||||
|
for ( int i = 1 ; i < argc ; i ++ )
|
||||||
|
{
|
||||||
|
// qDebug("%d %s",i,argv[i]);
|
||||||
|
if ( strcmp(argv[i],"-ing") == 0 )
|
||||||
|
{
|
||||||
|
EngMode = true;
|
||||||
|
CanImport = true;
|
||||||
|
}
|
||||||
|
if ( strcmp(argv[i],"-import") == 0 )
|
||||||
|
{
|
||||||
|
CanImport = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Create program instance
|
||||||
|
COutilZT OutilZT;
|
||||||
|
OutilZT.mIsEngMode = EngMode;
|
||||||
|
OutilZT.mCanImport = CanImport;
|
||||||
|
|
||||||
|
//setup stdout for screen printing.
|
||||||
|
setvbuf(stdout, NULL, _IONBF, 0 );
|
||||||
|
|
||||||
|
//Run Zone Tests
|
||||||
|
OutilZT.Start();
|
||||||
|
|
||||||
|
|
||||||
|
return a.exec();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||