├── .github └── workflows │ └── publish-docker-image.yml ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── CMakePresets.json ├── Dockerfile ├── LICENSE ├── ModbusTools.pro ├── README.md ├── bugfix.md ├── bugreport.md ├── build.bat ├── build.sh ├── changelog.md ├── doc ├── DoxyfileClient ├── DoxyfileServer ├── README.md ├── images │ ├── client_dataview_dialog.png │ ├── client_dataview_window.png │ ├── client_dataviewitem_dialog.png │ ├── client_dataviewitem_dialogx.png │ ├── client_device_dialog.png │ ├── client_device_dialogx.png │ ├── client_gui_schema.png │ ├── client_logview_window.png │ ├── client_port_dialog.png │ ├── client_port_dialogx.png │ ├── client_project_dialog.png │ ├── client_project_window.png │ ├── client_projectinfo_dialog.png │ ├── client_scanner_window.png │ ├── client_sendmessage_window.png │ ├── client_settings_dataview.png │ ├── client_settings_log.png │ ├── client_settings_view.png │ ├── client_statusbar.png │ ├── client_toolbar.png │ ├── client_view.png │ ├── server_dataview_dialog.png │ ├── server_dataview_window.png │ ├── server_dataviewitem_dialog.png │ ├── server_dataviewitem_dialogx.png │ ├── server_device_dialog.png │ ├── server_device_dialogx.png │ ├── server_device_window.png │ ├── server_gui_schema.png │ ├── server_logview_window.png │ ├── server_output_window.png │ ├── server_port_dialog.png │ ├── server_port_dialogx.png │ ├── server_project_dialog.png │ ├── server_project_window.png │ ├── server_projectinfo_dialog.png │ ├── server_script_window.png │ ├── server_scripting.png │ ├── server_scriptmodule_dialog.png │ ├── server_scriptmodule_window.png │ ├── server_scriptmodules_window.png │ ├── server_settings_dataview.png │ ├── server_settings_log.png │ ├── server_settings_scriptX.png │ ├── server_settings_view.png │ ├── server_simulation_dialogx.png │ ├── server_simulation_window.png │ ├── server_statusbar.png │ ├── server_toolbar.png │ └── server_view.png ├── input │ ├── client │ │ └── client.md │ ├── mainpage.md │ └── server │ │ └── server.md └── output │ ├── ModbusClient.chm │ ├── ModbusClient.qch │ ├── ModbusClient.qhc │ ├── ModbusClient.qhcp │ ├── ModbusServer.chm │ ├── ModbusServer.qch │ ├── ModbusServer.qhc │ └── ModbusServer.qhcp ├── examples ├── client │ ├── Eastron_SDM220Modbus.pjc │ ├── Hiking_DDS238-1_ZN.pjc │ └── Must_PV1800.pjc └── server │ ├── test_script.pjs │ └── test_script2.pjs └── src ├── README.md ├── client ├── CMakeLists.txt ├── client.pro ├── core │ ├── client.cpp │ ├── client.h │ ├── client_global.h │ └── core.pri ├── gui │ ├── client_rsc.qrc │ ├── client_ui.cpp │ ├── client_ui.h │ ├── client_ui.ui │ ├── client_windowmanager.cpp │ ├── client_windowmanager.h │ ├── dataview │ │ ├── client_dataviewdelegate.cpp │ │ ├── client_dataviewdelegate.h │ │ ├── client_dataviewmanager.cpp │ │ ├── client_dataviewmanager.h │ │ ├── client_dataviewmodel.cpp │ │ ├── client_dataviewmodel.h │ │ ├── client_dataviewui.cpp │ │ ├── client_dataviewui.h │ │ └── dataview.pri │ ├── dialogs │ │ ├── client_dialogdataviewitem.cpp │ │ ├── client_dialogdataviewitem.h │ │ ├── client_dialogdataviewitem.ui │ │ ├── client_dialogdevice.cpp │ │ ├── client_dialogdevice.h │ │ ├── client_dialogdevice.ui │ │ ├── client_dialogport.cpp │ │ ├── client_dialogport.h │ │ ├── client_dialogport.ui │ │ ├── client_dialogs.cpp │ │ ├── client_dialogs.h │ │ ├── dialogs.pri │ │ └── settings │ │ │ ├── client_dialogsettings.cpp │ │ │ ├── client_dialogsettings.h │ │ │ └── settings.pri │ ├── gui.pri │ ├── icons │ │ ├── client.ico │ │ ├── scanner.png │ │ └── sendmessage.png │ ├── project │ │ ├── client_projectdelegate.cpp │ │ ├── client_projectdelegate.h │ │ ├── client_projectmodel.cpp │ │ ├── client_projectmodel.h │ │ ├── client_projectui.cpp │ │ ├── client_projectui.h │ │ └── project.pri │ ├── scanner │ │ ├── client_dialogscannerrequest.cpp │ │ ├── client_dialogscannerrequest.h │ │ ├── client_dialogscannerrequest.ui │ │ ├── client_scanner.cpp │ │ ├── client_scanner.h │ │ ├── client_scannermodel.cpp │ │ ├── client_scannermodel.h │ │ ├── client_scannerthread.cpp │ │ ├── client_scannerthread.h │ │ ├── client_scannerui.cpp │ │ ├── client_scannerui.h │ │ ├── client_scannerui.ui │ │ └── scanner.pri │ └── sendmessage │ │ ├── client_sendmessageui.cpp │ │ ├── client_sendmessageui.h │ │ ├── client_sendmessageui.ui │ │ └── sendmessage.pri ├── main.cpp ├── project │ ├── client_builder.cpp │ ├── client_builder.h │ ├── client_dataview.cpp │ ├── client_dataview.h │ ├── client_device.cpp │ ├── client_device.h │ ├── client_dom.cpp │ ├── client_dom.h │ ├── client_port.cpp │ ├── client_port.h │ ├── client_project.cpp │ ├── client_project.h │ └── project.pri ├── runtime │ ├── client_devicerunnable.cpp │ ├── client_devicerunnable.h │ ├── client_portrunnable.cpp │ ├── client_portrunnable.h │ ├── client_rundevice.cpp │ ├── client_rundevice.h │ ├── client_runitem.cpp │ ├── client_runitem.h │ ├── client_runmessage.cpp │ ├── client_runmessage.h │ ├── client_runport.cpp │ ├── client_runport.h │ ├── client_runthread.cpp │ ├── client_runthread.h │ ├── client_runtime.cpp │ ├── client_runtime.h │ └── runtime.pri └── win_resource.rc ├── core ├── CMakeLists.txt ├── core.pro ├── core │ ├── core.cpp │ ├── core.h │ ├── core.pri │ ├── core_filemanager.cpp │ ├── core_filemanager.h │ ├── core_global.cpp │ └── core_global.h ├── gui │ ├── core_rsc.qrc │ ├── core_ui.cpp │ ├── core_ui.h │ ├── core_windowmanager.cpp │ ├── core_windowmanager.h │ ├── dataview │ │ ├── core_dataviewdelegate.cpp │ │ ├── core_dataviewdelegate.h │ │ ├── core_dataviewmanager.cpp │ │ ├── core_dataviewmanager.h │ │ ├── core_dataviewmodel.cpp │ │ ├── core_dataviewmodel.h │ │ ├── core_dataviewui.cpp │ │ ├── core_dataviewui.h │ │ └── dataview.pri │ ├── dialogs │ │ ├── core_dialogbase.cpp │ │ ├── core_dialogbase.h │ │ ├── core_dialogdataview.cpp │ │ ├── core_dialogdataview.h │ │ ├── core_dialogdataview.ui │ │ ├── core_dialogdataviewitem.cpp │ │ ├── core_dialogdataviewitem.h │ │ ├── core_dialogdevice.cpp │ │ ├── core_dialogdevice.h │ │ ├── core_dialogedit.h │ │ ├── core_dialogport.cpp │ │ ├── core_dialogport.h │ │ ├── core_dialogproject.cpp │ │ ├── core_dialogproject.h │ │ ├── core_dialogproject.ui │ │ ├── core_dialogprojectinfo.cpp │ │ ├── core_dialogprojectinfo.h │ │ ├── core_dialogprojectinfo.ui │ │ ├── core_dialogs.cpp │ │ ├── core_dialogs.h │ │ ├── core_dialogvaluelist.cpp │ │ ├── core_dialogvaluelist.h │ │ ├── core_dialogvaluelist.ui │ │ ├── dialogs.pri │ │ └── settings │ │ │ ├── core_dialogsettings.cpp │ │ │ ├── core_dialogsettings.h │ │ │ ├── core_widgetsettingsdataview.cpp │ │ │ ├── core_widgetsettingsdataview.h │ │ │ ├── core_widgetsettingsdataview.ui │ │ │ ├── core_widgetsettingslog.cpp │ │ │ ├── core_widgetsettingslog.h │ │ │ ├── core_widgetsettingslog.ui │ │ │ ├── core_widgetsettingsview.cpp │ │ │ ├── core_widgetsettingsview.h │ │ │ ├── core_widgetsettingsview.ui │ │ │ └── settings.pri │ ├── gui.pri │ ├── help │ │ ├── core_helpbrowser.cpp │ │ ├── core_helpbrowser.h │ │ ├── core_helpui.cpp │ │ ├── core_helpui.h │ │ └── help.pri │ ├── icons │ │ ├── Trash.png │ │ ├── arrow_down.png │ │ ├── arrow_up.png │ │ ├── clear.png │ │ ├── dataview.png │ │ ├── dataviewitem.png │ │ ├── device.png │ │ ├── edit.png │ │ ├── fileclose.png │ │ ├── filenew.png │ │ ├── fileopen.png │ │ ├── filesave.png │ │ ├── filesaveall.png │ │ ├── logexport.png │ │ ├── play.png │ │ ├── port.png │ │ ├── quit.png │ │ ├── redo.png │ │ ├── remove.png │ │ ├── resetproperty.png │ │ ├── stop.png │ │ └── undo.png │ ├── logview │ │ ├── core_logview.cpp │ │ ├── core_logview.h │ │ ├── core_logviewmodel.cpp │ │ ├── core_logviewmodel.h │ │ └── logview.pri │ ├── logviewlogview.pri │ ├── project │ │ ├── core_projectdelegate.cpp │ │ ├── core_projectdelegate.h │ │ ├── core_projectmodel.cpp │ │ ├── core_projectmodel.h │ │ ├── core_projectui.cpp │ │ ├── core_projectui.h │ │ └── project.pri │ └── widgets │ │ ├── core_addresswidget.cpp │ │ ├── core_addresswidget.h │ │ └── widgets.pri ├── mbcore_config.h.in ├── plugin │ ├── core_pluginmanager.cpp │ ├── core_pluginmanager.h │ └── plugin.pri ├── project │ ├── core_builder.cpp │ ├── core_builder.h │ ├── core_dataview.cpp │ ├── core_dataview.h │ ├── core_device.cpp │ ├── core_device.h │ ├── core_dom.cpp │ ├── core_dom.h │ ├── core_port.cpp │ ├── core_port.h │ ├── core_project.cpp │ ├── core_project.h │ ├── core_taskinfo.cpp │ ├── core_taskinfo.h │ └── project.pri ├── runtime │ ├── core_runtaskthread.cpp │ ├── core_runtaskthread.h │ ├── core_runtime.cpp │ ├── core_runtime.h │ └── runtime.pri ├── sdk │ ├── mbcore.cpp │ ├── mbcore.h │ ├── mbcore_base.cpp │ ├── mbcore_base.h │ ├── mbcore_binaryreader.cpp │ ├── mbcore_binaryreader.h │ ├── mbcore_binarywriter.cpp │ ├── mbcore_binarywriter.h │ ├── mbcore_config.h │ ├── mbcore_sharedpointer.h │ ├── mbcore_task.h │ ├── mbcore_taskfactory.h │ └── sdk.pri ├── task │ ├── core_taskfactoryinfo.cpp │ ├── core_taskfactoryinfo.h │ └── task.pri └── win_resource.rc ├── server ├── CMakeLists.txt ├── core │ ├── core.pri │ ├── server.cpp │ ├── server.h │ └── server_global.h ├── gui │ ├── dataview │ │ ├── dataview.pri │ │ ├── server_dataviewdelegate.cpp │ │ ├── server_dataviewdelegate.h │ │ ├── server_dataviewmanager.cpp │ │ ├── server_dataviewmanager.h │ │ ├── server_dataviewmodel.cpp │ │ ├── server_dataviewmodel.h │ │ ├── server_dataviewui.cpp │ │ └── server_dataviewui.h │ ├── device │ │ ├── device.pri │ │ ├── server_devicemanager.cpp │ │ ├── server_devicemanager.h │ │ ├── server_deviceui.cpp │ │ ├── server_deviceui.h │ │ ├── server_deviceui.ui │ │ ├── server_deviceuidelegate.cpp │ │ ├── server_deviceuidelegate.h │ │ ├── server_deviceuimodel.cpp │ │ └── server_deviceuimodel.h │ ├── dialogs │ │ ├── dialogs.pri │ │ ├── server_dialogdataviewitem.cpp │ │ ├── server_dialogdataviewitem.h │ │ ├── server_dialogdataviewitem.ui │ │ ├── server_dialogdevice.cpp │ │ ├── server_dialogdevice.h │ │ ├── server_dialogdevice.ui │ │ ├── server_dialogport.cpp │ │ ├── server_dialogport.h │ │ ├── server_dialogport.ui │ │ ├── server_dialogs.cpp │ │ ├── server_dialogs.h │ │ ├── server_dialogscriptmodule.cpp │ │ ├── server_dialogscriptmodule.h │ │ ├── server_dialogscriptmodule.ui │ │ ├── server_dialogsimaction.cpp │ │ ├── server_dialogsimaction.h │ │ ├── server_dialogsimaction.ui │ │ ├── server_dialogtask.cpp │ │ ├── server_dialogtask.h │ │ ├── server_dialogtask.ui │ │ └── settings │ │ │ ├── server_delegatesettingsscripteditorcolors.cpp │ │ │ ├── server_delegatesettingsscripteditorcolors.h │ │ │ ├── server_dialogsettings.cpp │ │ │ ├── server_dialogsettings.h │ │ │ ├── server_modelsettingsscripteditorcolors.cpp │ │ │ ├── server_modelsettingsscripteditorcolors.h │ │ │ ├── server_modelsettingsscriptinterpreters.cpp │ │ │ ├── server_modelsettingsscriptinterpreters.h │ │ │ ├── server_widgetsettingsscript.cpp │ │ │ ├── server_widgetsettingsscript.h │ │ │ ├── server_widgetsettingsscript.ui │ │ │ └── settings.pri │ ├── gui.pri │ ├── icons │ │ ├── greenmark.ico │ │ ├── minus.ico │ │ ├── plus.ico │ │ └── server.ico │ ├── project │ │ ├── project.pri │ │ ├── server_projectdelegate.cpp │ │ ├── server_projectdelegate.h │ │ ├── server_projectmodel.cpp │ │ ├── server_projectmodel.h │ │ ├── server_projectui.cpp │ │ └── server_projectui.h │ ├── script │ │ ├── editor │ │ │ ├── editor.pri │ │ │ ├── server_scripteditor.cpp │ │ │ ├── server_scripteditor.h │ │ │ ├── server_scripthighlighter.cpp │ │ │ └── server_scripthighlighter.h │ │ ├── script.pri │ │ ├── server_basescripteditor.cpp │ │ ├── server_basescripteditor.h │ │ ├── server_devicescripteditor.cpp │ │ ├── server_devicescripteditor.h │ │ ├── server_scriptmanager.cpp │ │ ├── server_scriptmanager.h │ │ ├── server_scriptmoduleeditor.cpp │ │ └── server_scriptmoduleeditor.h │ ├── scriptmodules │ │ ├── scriptmodules.pri │ │ ├── server_scriptmodulesdelegate.cpp │ │ ├── server_scriptmodulesdelegate.h │ │ ├── server_scriptmodulesmodel.cpp │ │ ├── server_scriptmodulesmodel.h │ │ ├── server_scriptmodulesui.cpp │ │ └── server_scriptmodulesui.h │ ├── server_outputview.cpp │ ├── server_outputview.h │ ├── server_rsc.qrc │ ├── server_ui.cpp │ ├── server_ui.h │ ├── server_ui.ui │ ├── server_windowmanager.cpp │ ├── server_windowmanager.h │ └── simactions │ │ ├── server_simactionsdelegate.cpp │ │ ├── server_simactionsdelegate.h │ │ ├── server_simactionsmodel.cpp │ │ ├── server_simactionsmodel.h │ │ ├── server_simactionsui.cpp │ │ ├── server_simactionsui.h │ │ └── simactions.pri ├── main.cpp ├── project │ ├── project.pri │ ├── server_builder.cpp │ ├── server_builder.h │ ├── server_dataview.cpp │ ├── server_dataview.h │ ├── server_device.cpp │ ├── server_device.h │ ├── server_deviceref.cpp │ ├── server_deviceref.h │ ├── server_dom.cpp │ ├── server_dom.h │ ├── server_port.cpp │ ├── server_port.h │ ├── server_project.cpp │ ├── server_project.h │ ├── server_scriptmodule.cpp │ ├── server_scriptmodule.h │ ├── server_simaction.cpp │ └── server_simaction.h ├── python │ ├── mbconfig.py │ ├── mbconfig.py.in │ ├── mbserver.py │ └── modbus.py ├── resource │ ├── python │ │ ├── programhead.py │ │ └── pytips.py │ └── server_resource.qrc ├── runtime │ ├── runtime.pri │ ├── server_portrunnable.cpp │ ├── server_portrunnable.h │ ├── server_rundevice.cpp │ ├── server_rundevice.h │ ├── server_runscriptthread.cpp │ ├── server_runscriptthread.h │ ├── server_runsimaction.cpp │ ├── server_runsimaction.h │ ├── server_runsimactiontask.cpp │ ├── server_runsimactiontask.h │ ├── server_runthread.cpp │ ├── server_runthread.h │ ├── server_runtime.cpp │ └── server_runtime.h ├── server.pro └── win_resource.rc ├── version.pri └── win_resource.rc.in /.github/workflows/publish-docker-image.yml: -------------------------------------------------------------------------------- 1 | name: Publish Docker image 2 | 3 | on: 4 | push: 5 | tags: 6 | - "v*" 7 | workflow_dispatch: 8 | 9 | jobs: 10 | push_to_registry: 11 | name: Push Docker image to Docker Hub 12 | runs-on: ubuntu-latest 13 | permissions: 14 | packages: write 15 | contents: read 16 | attestations: write 17 | id-token: write 18 | steps: 19 | - name: Check out the repo 20 | uses: actions/checkout@v4 21 | 22 | - name: Log in to Docker Hub 23 | uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a 24 | with: 25 | username: ${{ secrets.DOCKER_USERNAME }} 26 | password: ${{ secrets.DOCKER_PASSWORD }} 27 | 28 | - name: Extract metadata (tags, labels) for Docker 29 | id: meta 30 | uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 31 | with: 32 | images: ${{ vars.DOCKER_REPOSITORY }} 33 | tags: | 34 | # set latest tag for default branch 35 | type=raw,value=latest,enable={{is_default_branch}} 36 | # type=semver will be used on a push tag event, it removes the prepending v from the tag 37 | type=semver,pattern={{version}} 38 | 39 | - name: Build and push Docker image 40 | id: push 41 | uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 42 | with: 43 | context: . 44 | file: ./Dockerfile 45 | push: true 46 | tags: ${{ steps.meta.outputs.tags }} 47 | labels: ${{ steps.meta.outputs.labels }} 48 | 49 | - name: Generate artifact attestation 50 | uses: actions/attest-build-provenance@v2 51 | with: 52 | subject-name: index.docker.io/${{ vars.DOCKER_REPOSITORY }} 53 | subject-digest: ${{ steps.push.outputs.digest }} 54 | push-to-registry: true 55 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Qt-Project user files 2 | *.user 3 | .vscode/ 4 | tests/ 5 | doc/output/client 6 | doc/output/server 7 | TODO 8 | 9 | #ignore only cmake user presets in root folder 10 | /CMakeUserPresets.json 11 | 12 | # Python Byte-compiled / optimized / DLL files 13 | __pycache__/ 14 | *.py[cod] 15 | *$py.class 16 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "modbus"] 2 | path = modbus 3 | url = https://github.com/serhmarch/ModbusLib.git 4 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:22.04 2 | 3 | WORKDIR /app 4 | # tells apt not to prompt for user input, debconf for package configuration, and setting it to noninteractive ensures that any configuration questions are skipped or assigned default values. 5 | ENV DEBIAN_FRONTEND=noninteractive 6 | 7 | RUN apt update && apt install -y build-essential git cmake 8 | RUN apt install -y qtbase5-dev qttools5-dev 9 | 10 | RUN git clone --recursive https://github.com/serhmarch/ModbusTools.git 11 | 12 | WORKDIR /app/bin 13 | # build 14 | RUN cmake -S /app/ModbusTools -B . 15 | RUN cmake --build . 16 | RUN cmake --build . --config Debug 17 | RUN cmake --build . --config Release 18 | 19 | RUN yes | rm -r /app/ModbusTools 20 | 21 | # install vnc server and vnc proxy to make the vnc server accessible via web 22 | RUN apt install -y xvfb x11vnc fluxbox novnc supervisor 23 | 24 | COPY <<'EOF' supervisord.conf 25 | [supervisord] 26 | nodaemon=true 27 | logfile=/dev/null 28 | loglevel=debug 29 | 30 | [program:Xvfb] 31 | command=/usr/bin/Xvfb :1 -screen 0 1600x900x16 32 | priority=1 33 | 34 | [program:x11vnc] 35 | command=/usr/bin/x11vnc -display :1 -ncache 0 -forever -shared -nopw 36 | priority=2 37 | 38 | [program:fluxbox] 39 | command=/usr/bin/fluxbox 40 | environment=DISPLAY=:1 41 | priority=3 42 | 43 | [program:novnc] 44 | command=/usr/bin/websockify --web=/usr/share/novnc/ --cert=/home/ubuntu/novnc.pem 6080 localhost:5900 45 | priority=4 46 | 47 | [program:server] 48 | command=/app/bin/server 49 | environment=DISPLAY=:1 50 | priority=5 51 | 52 | [program:client] 53 | command=/app/bin/client 54 | environment=DISPLAY=:1 55 | priority=6 56 | EOF 57 | 58 | EXPOSE 6080 59 | 60 | CMD ["/usr/bin/supervisord", "-c", "supervisord.conf"] -------------------------------------------------------------------------------- /ModbusTools.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | # Specify the location where the help files should be installed 4 | HELPDIR = $$OUT_PWD/help 5 | 6 | # List of help files to install 7 | help.files = $$PWD/doc/output/*.qch \ 8 | $$PWD/doc/output/*.qhc 9 | 10 | help.path = $$HELPDIR 11 | help.depends = $(first) 12 | INSTALLS += help 13 | #QMAKE_POST_LINK=$(MAKE) install 14 | 15 | CONFIG += ordered 16 | 17 | SUBDIRS += modbus/src/modbus.pro 18 | SUBDIRS += src/core 19 | SUBDIRS += src/client 20 | SUBDIRS += src/server 21 | -------------------------------------------------------------------------------- /bugfix.md: -------------------------------------------------------------------------------- 1 | # 0.1.1 2 | 3 | ## virtual int parseArgs(int& argc, char **argv) 4 | 5 | Changed cause of program crash in Linux: 6 | virtual int parseArgs(int argc, char **argv); >> virtual int parseArgs(int& argc, char **argv); 7 | 8 | ## std::atomic m_refCount; 9 | 10 | Changed cause of program crash in Linux: 11 | g++ incorrectly initialize default constuctor for std::atomic for some reason. 12 | `std::atomic m_refCount;` was replaced by 13 | 14 | ```cpp 15 | typedef QAtomicInt RefCount_t; 16 | ... 17 | mb::RefCount_t m_refCount; 18 | ``` 19 | 20 | # 0.1.2 21 | 22 | * Fixed server-side bug when saving/exporting device 23 | 24 | # 0.1.3 25 | 26 | * Fixed 'ByteArray'-format DataView issue 27 | 28 | # 0.1.4 29 | 30 | * Fixed a crash bug for the 'readCoils' and 'readDiscreteInputs' functions 31 | when the bit offset was not a multiple of 8 32 | 33 | # 0.2.2 34 | 35 | * Fixed an Action value updates - Not Following Defined Register and Byte Order 36 | 37 | # 0.3.1 38 | 39 | * Fixed a bug of client/server crash when create/open project 40 | * Fixed a bug of client/server when change of port settings doesn't reflect in the port name in status bar 41 | 42 | # 0.3.2 43 | 44 | * Fixed a bug when changing the log settings does not affect the LogView of client/server 45 | 46 | # 0.3.3 47 | 48 | * Fixed incorrect data offset for 'WriteSingleRegister'-function in 'SendMessage'-window 49 | 50 | # 0.3.4 51 | 52 | * Fixed a bug for the DataView item if the specified byte order `MostSignifiedFirst` data was displayed/written incorrectly -------------------------------------------------------------------------------- /bugreport.md: -------------------------------------------------------------------------------- 1 | # Issue on com0com driver on Windows 2 | 3 | Program freezes on `WriteFile` standard WinAPI function when write to com0com virtual COM port -------------------------------------------------------------------------------- /build.bat: -------------------------------------------------------------------------------- 1 | cmake --preset "Win32-MSVC" 2 | cmake --build --preset "Win32-MSVC-Release" 3 | 4 | cmake --preset "Win64-MSVC" 5 | cmake --build --preset "Win64-MSVC-Release" 6 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | cmake --preset "Linux-Release" 3 | cmake --build --preset "Linux-Release" -------------------------------------------------------------------------------- /doc/images/client_dataview_dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/client_dataview_dialog.png -------------------------------------------------------------------------------- /doc/images/client_dataview_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/client_dataview_window.png -------------------------------------------------------------------------------- /doc/images/client_dataviewitem_dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/client_dataviewitem_dialog.png -------------------------------------------------------------------------------- /doc/images/client_dataviewitem_dialogx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/client_dataviewitem_dialogx.png -------------------------------------------------------------------------------- /doc/images/client_device_dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/client_device_dialog.png -------------------------------------------------------------------------------- /doc/images/client_device_dialogx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/client_device_dialogx.png -------------------------------------------------------------------------------- /doc/images/client_gui_schema.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/client_gui_schema.png -------------------------------------------------------------------------------- /doc/images/client_logview_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/client_logview_window.png -------------------------------------------------------------------------------- /doc/images/client_port_dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/client_port_dialog.png -------------------------------------------------------------------------------- /doc/images/client_port_dialogx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/client_port_dialogx.png -------------------------------------------------------------------------------- /doc/images/client_project_dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/client_project_dialog.png -------------------------------------------------------------------------------- /doc/images/client_project_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/client_project_window.png -------------------------------------------------------------------------------- /doc/images/client_projectinfo_dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/client_projectinfo_dialog.png -------------------------------------------------------------------------------- /doc/images/client_scanner_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/client_scanner_window.png -------------------------------------------------------------------------------- /doc/images/client_sendmessage_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/client_sendmessage_window.png -------------------------------------------------------------------------------- /doc/images/client_settings_dataview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/client_settings_dataview.png -------------------------------------------------------------------------------- /doc/images/client_settings_log.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/client_settings_log.png -------------------------------------------------------------------------------- /doc/images/client_settings_view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/client_settings_view.png -------------------------------------------------------------------------------- /doc/images/client_statusbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/client_statusbar.png -------------------------------------------------------------------------------- /doc/images/client_toolbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/client_toolbar.png -------------------------------------------------------------------------------- /doc/images/client_view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/client_view.png -------------------------------------------------------------------------------- /doc/images/server_dataview_dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_dataview_dialog.png -------------------------------------------------------------------------------- /doc/images/server_dataview_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_dataview_window.png -------------------------------------------------------------------------------- /doc/images/server_dataviewitem_dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_dataviewitem_dialog.png -------------------------------------------------------------------------------- /doc/images/server_dataviewitem_dialogx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_dataviewitem_dialogx.png -------------------------------------------------------------------------------- /doc/images/server_device_dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_device_dialog.png -------------------------------------------------------------------------------- /doc/images/server_device_dialogx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_device_dialogx.png -------------------------------------------------------------------------------- /doc/images/server_device_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_device_window.png -------------------------------------------------------------------------------- /doc/images/server_gui_schema.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_gui_schema.png -------------------------------------------------------------------------------- /doc/images/server_logview_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_logview_window.png -------------------------------------------------------------------------------- /doc/images/server_output_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_output_window.png -------------------------------------------------------------------------------- /doc/images/server_port_dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_port_dialog.png -------------------------------------------------------------------------------- /doc/images/server_port_dialogx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_port_dialogx.png -------------------------------------------------------------------------------- /doc/images/server_project_dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_project_dialog.png -------------------------------------------------------------------------------- /doc/images/server_project_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_project_window.png -------------------------------------------------------------------------------- /doc/images/server_projectinfo_dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_projectinfo_dialog.png -------------------------------------------------------------------------------- /doc/images/server_script_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_script_window.png -------------------------------------------------------------------------------- /doc/images/server_scripting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_scripting.png -------------------------------------------------------------------------------- /doc/images/server_scriptmodule_dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_scriptmodule_dialog.png -------------------------------------------------------------------------------- /doc/images/server_scriptmodule_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_scriptmodule_window.png -------------------------------------------------------------------------------- /doc/images/server_scriptmodules_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_scriptmodules_window.png -------------------------------------------------------------------------------- /doc/images/server_settings_dataview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_settings_dataview.png -------------------------------------------------------------------------------- /doc/images/server_settings_log.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_settings_log.png -------------------------------------------------------------------------------- /doc/images/server_settings_scriptX.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_settings_scriptX.png -------------------------------------------------------------------------------- /doc/images/server_settings_view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_settings_view.png -------------------------------------------------------------------------------- /doc/images/server_simulation_dialogx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_simulation_dialogx.png -------------------------------------------------------------------------------- /doc/images/server_simulation_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_simulation_window.png -------------------------------------------------------------------------------- /doc/images/server_statusbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_statusbar.png -------------------------------------------------------------------------------- /doc/images/server_toolbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_toolbar.png -------------------------------------------------------------------------------- /doc/images/server_view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/images/server_view.png -------------------------------------------------------------------------------- /doc/output/ModbusClient.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/output/ModbusClient.chm -------------------------------------------------------------------------------- /doc/output/ModbusClient.qch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/output/ModbusClient.qch -------------------------------------------------------------------------------- /doc/output/ModbusClient.qhc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/output/ModbusClient.qhc -------------------------------------------------------------------------------- /doc/output/ModbusClient.qhcp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | client/html/index.qhp 7 | ModbusClient.qch 8 | 9 | 10 | 11 | ModbusClient.qch 12 | 13 | 14 | -------------------------------------------------------------------------------- /doc/output/ModbusServer.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/output/ModbusServer.chm -------------------------------------------------------------------------------- /doc/output/ModbusServer.qch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/output/ModbusServer.qch -------------------------------------------------------------------------------- /doc/output/ModbusServer.qhc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/doc/output/ModbusServer.qhc -------------------------------------------------------------------------------- /doc/output/ModbusServer.qhcp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | server/html/index.qhp 7 | ModbusServer.qch 8 | 9 | 10 | 11 | ModbusServer.qch 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/client/client.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | 3 | include(../version.pri) 4 | 5 | CONFIG += no_keywords 6 | 7 | DESTDIR = ../../bin 8 | 9 | QT = core gui widgets 10 | 11 | unix:QMAKE_RPATHDIR += . 12 | 13 | #CONFIG += console 14 | #CONFIG -= app_bundle 15 | 16 | INCLUDEPATH += . .. \ 17 | $$PWD/../../modbus/src \ 18 | $$PWD/../core/sdk \ 19 | $$PWD/../core/core \ 20 | $$PWD/../core \ 21 | $$PWD/core 22 | 23 | include(core/core.pri) 24 | include(project/project.pri) 25 | include(gui/gui.pri) 26 | include(runtime/runtime.pri) 27 | 28 | HEADERS += 29 | 30 | SOURCES += \ 31 | main.cpp 32 | 33 | LIBS += -L../../bin -lcore 34 | LIBS += -L../../bin -lmodbus 35 | 36 | RC_ICONS = gui/icons/client.ico 37 | -------------------------------------------------------------------------------- /src/client/core/client_global.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef CLIENT_GLOBAL_H 24 | #define CLIENT_GLOBAL_H 25 | 26 | #include 27 | #include 28 | 29 | class mbClientPort; 30 | class mbClientDevice; 31 | class mbClientDataViewItem; 32 | class mbClientRunMessage; 33 | 34 | typedef mb::SharedPointer mbClientRunMessagePtr; 35 | 36 | namespace mb { 37 | 38 | namespace Client { 39 | 40 | typedef mbClientPort* PortHandle_t; 41 | typedef mbClientDevice* DeviceHandle_t; 42 | typedef mbClientDataViewItem* ItemHandle_t; 43 | 44 | } // namespace Client 45 | 46 | } // namespace mb 47 | 48 | #endif // CLIENT_GLOBAL_H 49 | -------------------------------------------------------------------------------- /src/client/core/core.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/client.h \ 3 | $$PWD/client_global.h 4 | 5 | SOURCES += \ 6 | $$PWD/client.cpp 7 | -------------------------------------------------------------------------------- /src/client/gui/client_rsc.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | icons/client.ico 4 | icons/scanner.png 5 | icons/sendmessage.png 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/client/gui/client_windowmanager.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #include "client_windowmanager.h" 24 | 25 | #include 26 | 27 | #include "client_ui.h" 28 | #include "dataview/client_dataviewmanager.h" 29 | 30 | mbClientWindowManager::mbClientWindowManager(mbClientUi *ui, mbClientDataViewManager *dataViewManager) : 31 | mbCoreWindowManager(ui, dataViewManager) 32 | { 33 | connect(this->dataViewManager(), &mbClientDataViewManager::maximizeDataViewUi, this, &mbClientWindowManager::maximizeDataViewUi); 34 | } 35 | 36 | void mbClientWindowManager::maximizeDataViewUi() 37 | { 38 | QList ls = m_area->subWindowList(); 39 | if (ls.count()) 40 | ls.first()->showMaximized(); 41 | } 42 | -------------------------------------------------------------------------------- /src/client/gui/client_windowmanager.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef CLIENT_WINDOWMANAGER_H 24 | #define CLIENT_WINDOWMANAGER_H 25 | 26 | #include 27 | 28 | class mbClientDevice; 29 | class mbClientDataView; 30 | 31 | class mbClientUi; 32 | class mbClientDataViewManager; 33 | class mbClientDataViewUi; 34 | 35 | class mbClientWindowManager : public mbCoreWindowManager 36 | { 37 | Q_OBJECT 38 | public: 39 | explicit mbClientWindowManager(mbClientUi *ui, mbClientDataViewManager *dataViewManager); 40 | 41 | public: 42 | inline mbClientUi *ui() const { return reinterpret_cast(uiCore()); } 43 | inline mbClientDataViewManager *dataViewManager() { return reinterpret_cast(dataViewManagerCore()); } 44 | inline mbClientDataView *activeDataView() const { return reinterpret_cast(activeDataViewCore()); } 45 | inline void setActiveDataView(mbClientDataView *dataView) { setActiveDataViewCore(reinterpret_cast(dataView)); } 46 | 47 | private Q_SLOTS: 48 | void maximizeDataViewUi(); 49 | }; 50 | 51 | #endif // CLIENT_WINDOWMANAGER_H 52 | -------------------------------------------------------------------------------- /src/client/gui/dataview/client_dataviewdelegate.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #include "client_dataviewdelegate.h" 24 | 25 | #include 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #include "client_dataviewmodel.h" 32 | 33 | mbClientDataViewDelegate::mbClientDataViewDelegate(QObject *parent) : 34 | mbCoreDataViewDelegate(parent) 35 | { 36 | } 37 | -------------------------------------------------------------------------------- /src/client/gui/dataview/client_dataviewdelegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef CLIENT_DATAVIEWDELEGATE_H 24 | #define CLIENT_DATAVIEWDELEGATE_H 25 | 26 | #include 27 | 28 | class mbClientDataViewDelegate : public mbCoreDataViewDelegate 29 | { 30 | Q_OBJECT 31 | public: 32 | mbClientDataViewDelegate(QObject *parent = nullptr); 33 | }; 34 | 35 | #endif // CLIENT_DATAVIEWDELEGATE_H 36 | -------------------------------------------------------------------------------- /src/client/gui/dataview/client_dataviewmanager.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #include "client_dataviewmanager.h" 24 | 25 | #include "client_dataviewui.h" 26 | #include 27 | #include 28 | 29 | mbClientDataViewManager::mbClientDataViewManager(QObject *parent) : 30 | mbCoreDataViewManager(parent) 31 | { 32 | } 33 | 34 | void mbClientDataViewManager::setProject(mbCoreProject *project) 35 | { 36 | mbCoreDataViewManager::setProject(project); 37 | if (this->project() && (this->project()->dataViewCount() == 1)) 38 | Q_EMIT maximizeDataViewUi(); 39 | } 40 | 41 | mbCoreDataViewUi *mbClientDataViewManager::createDataViewUi(mbCoreDataView *dataView) 42 | { 43 | return new mbClientDataViewUi(static_cast(dataView)); 44 | } 45 | -------------------------------------------------------------------------------- /src/client/gui/dataview/client_dataviewmodel.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef CLIENT_DATAVIEWMODEL_H 24 | #define CLIENT_DATAVIEWMODEL_H 25 | 26 | #include 27 | 28 | class mbClientDataView; 29 | class mbClientDataViewItem; 30 | 31 | class mbClientDataViewModel : public mbCoreDataViewModel 32 | { 33 | Q_OBJECT 34 | 35 | public: 36 | mbClientDataViewModel(mbClientDataView *dataView, QObject* parent = nullptr); 37 | ~mbClientDataViewModel(); 38 | 39 | public: 40 | inline mbClientDataView *dataView() const { return reinterpret_cast(dataViewCore()); } 41 | inline mbClientDataViewItem *item(const QModelIndex &index) const { return reinterpret_cast(itemCore(index)); } 42 | 43 | public: 44 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; 45 | Qt::ItemFlags flags(const QModelIndex &index) const override; 46 | bool setDataEdit(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; 47 | }; 48 | 49 | #endif // CLIENT_DATAVIEWMODEL_H 50 | -------------------------------------------------------------------------------- /src/client/gui/dataview/client_dataviewui.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #include "client_dataviewui.h" 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #include "client_dataviewmodel.h" 30 | #include "client_dataviewdelegate.h" 31 | 32 | mbClientDataViewUi::mbClientDataViewUi(mbClientDataView *dataView, QWidget *parent) : 33 | mbCoreDataViewUi(dataView, new mbClientDataViewModel(dataView), new mbClientDataViewDelegate(), parent) 34 | { 35 | } 36 | 37 | QList mbClientDataViewUi::selectedItems() const 38 | { 39 | QList ls = selectedItemsCore(); 40 | return QList(*(reinterpret_cast*>(&ls))); 41 | } 42 | -------------------------------------------------------------------------------- /src/client/gui/dataview/client_dataviewui.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef CLIENT_DATAVIEWUI_H 24 | #define CLIENT_DATAVIEWUI_H 25 | 26 | #include 27 | 28 | class mbClientDataView; 29 | class mbClientDataViewItem; 30 | class mbClientDataViewModel; 31 | class mbClientDataViewDelegate; 32 | 33 | class mbClientDataViewUi : public mbCoreDataViewUi 34 | { 35 | Q_OBJECT 36 | 37 | public: 38 | mbClientDataViewUi(mbClientDataView *dataView, QWidget *parent = nullptr); 39 | 40 | public: 41 | inline mbClientDataView *dataView() const { return reinterpret_cast(dataViewCore()); } 42 | inline mbClientDataViewModel *model() const { return reinterpret_cast(modelCore()); } 43 | QList selectedItems() const; 44 | }; 45 | 46 | #endif // CLIENT_DATAVIEWUI_H 47 | -------------------------------------------------------------------------------- /src/client/gui/dataview/dataview.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/client_dataviewdelegate.h \ 3 | $$PWD/client_dataviewmanager.h \ 4 | $$PWD/client_dataviewmodel.h \ 5 | $$PWD/client_dataviewui.h \ 6 | 7 | SOURCES += \ 8 | $$PWD/client_dataviewdelegate.cpp \ 9 | $$PWD/client_dataviewmanager.cpp \ 10 | $$PWD/client_dataviewmodel.cpp \ 11 | $$PWD/client_dataviewui.cpp \ 12 | -------------------------------------------------------------------------------- /src/client/gui/dialogs/client_dialogdataviewitem.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef CLIENT_DIALOGDATAVIEWITEM_H 24 | #define CLIENT_DIALOGDATAVIEWITEM_H 25 | 26 | #include 27 | 28 | class mbClientDevice; 29 | 30 | namespace Ui { 31 | class mbClientDialogDataViewItem; 32 | } 33 | 34 | class mbClientDialogDataViewItem : public mbCoreDialogDataViewItem 35 | { 36 | Q_OBJECT 37 | public: 38 | struct Strings : public mbCoreDialogDataViewItem::Strings 39 | { 40 | Strings(); 41 | static const Strings &instance(); 42 | }; 43 | 44 | public: 45 | explicit mbClientDialogDataViewItem(QWidget *parent = nullptr); 46 | ~mbClientDialogDataViewItem(); 47 | 48 | public: 49 | MBSETTINGS cachedSettings() const override; 50 | void setCachedSettings(const MBSETTINGS &settings) override; 51 | 52 | private: 53 | void fillFormEditInner(const MBSETTINGS &settings) override; 54 | void fillFormNewInner(const MBSETTINGS &settings) override; 55 | void fillDataInner(MBSETTINGS &settings) const override; 56 | 57 | private: 58 | Ui::mbClientDialogDataViewItem *ui; 59 | }; 60 | 61 | #endif // CLIENT_DIALOGDATAVIEWITEM_H 62 | -------------------------------------------------------------------------------- /src/client/gui/dialogs/client_dialogport.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef CLIENT_DIALOGPORT_H 24 | #define CLIENT_DIALOGPORT_H 25 | 26 | #include 27 | 28 | namespace Ui { 29 | class mbClientDialogPort; 30 | } 31 | 32 | class mbClientDialogPort : public mbCoreDialogPort 33 | { 34 | Q_OBJECT 35 | 36 | public: 37 | explicit mbClientDialogPort(QWidget *parent = nullptr); 38 | ~mbClientDialogPort(); 39 | 40 | public: 41 | MBSETTINGS cachedSettings() const override; 42 | void setCachedSettings(const MBSETTINGS &settings) override; 43 | 44 | private: 45 | void fillFormInner(const MBSETTINGS &settings) override; 46 | void fillDataInner(MBSETTINGS &settings) const override; 47 | 48 | private: 49 | Ui::mbClientDialogPort *ui; 50 | }; 51 | 52 | #endif // CLIENT_DIALOGPORT_H 53 | -------------------------------------------------------------------------------- /src/client/gui/dialogs/client_dialogs.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #include "client_dialogs.h" 24 | 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | #include "settings/client_dialogsettings.h" 31 | #include "client_dialogport.h" 32 | #include "client_dialogdevice.h" 33 | #include "client_dialogdataviewitem.h" 34 | 35 | mbClientDialogs::mbClientDialogs(QWidget *parent) : 36 | mbCoreDialogs (parent) 37 | { 38 | m_projectFilter = QStringLiteral("Client Project (*.pjc)"); 39 | m_settings = new mbClientDialogSettings(parent); 40 | m_port = new mbClientDialogPort(parent); 41 | m_device = new mbClientDialogDevice(parent); 42 | m_dataViewItem = new mbClientDialogDataViewItem(parent); 43 | 44 | m_projectInfo->setProjectType(QStringLiteral("Client Project")); 45 | } 46 | -------------------------------------------------------------------------------- /src/client/gui/dialogs/client_dialogs.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef CLIENT_DIALOGS_H 24 | #define CLIENT_DIALOGS_H 25 | 26 | #include 27 | 28 | class mbClientDialogs : public mbCoreDialogs 29 | { 30 | public: 31 | mbClientDialogs(QWidget* parent = nullptr); 32 | }; 33 | 34 | #endif // CLIENT_DIALOGS_H 35 | -------------------------------------------------------------------------------- /src/client/gui/dialogs/dialogs.pri: -------------------------------------------------------------------------------- 1 | include(settings/settings.pri) 2 | 3 | HEADERS += \ 4 | $$PWD/client_dialogdevice.h \ 5 | $$PWD/client_dialogport.h \ 6 | $$PWD/client_dialogs.h \ 7 | $$PWD/client_dialogdataviewitem.h 8 | 9 | SOURCES += \ 10 | $$PWD/client_dialogdevice.cpp \ 11 | $$PWD/client_dialogport.cpp \ 12 | $$PWD/client_dialogs.cpp \ 13 | $$PWD/client_dialogdataviewitem.cpp 14 | 15 | FORMS += \ 16 | $$PWD/client_dialogdevice.ui \ 17 | $$PWD/client_dialogport.ui \ 18 | $$PWD/client_dialogdataviewitem.ui 19 | -------------------------------------------------------------------------------- /src/client/gui/dialogs/settings/client_dialogsettings.cpp: -------------------------------------------------------------------------------- 1 | #include "client_dialogsettings.h" 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | mbClientDialogSettings::Strings::Strings() //: 10 | //title(QStringLiteral("Settings")), 11 | //cachePrefix(QStringLiteral("Ui.Dialogs.SystemSettings.")) 12 | { 13 | } 14 | 15 | const mbClientDialogSettings::Strings &mbClientDialogSettings::Strings::instance() 16 | { 17 | static const Strings s; 18 | return s; 19 | } 20 | 21 | mbClientDialogSettings::mbClientDialogSettings(QWidget *parent) : 22 | mbCoreDialogSettings(parent) 23 | { 24 | } 25 | 26 | void mbClientDialogSettings::fillForm(const MBSETTINGS &m) 27 | { 28 | mbCoreDialogSettings::fillForm(m); 29 | } 30 | 31 | void mbClientDialogSettings::fillData(MBSETTINGS &m) 32 | { 33 | mbCoreDialogSettings::fillData(m); 34 | } 35 | -------------------------------------------------------------------------------- /src/client/gui/dialogs/settings/client_dialogsettings.h: -------------------------------------------------------------------------------- 1 | #ifndef CLIENT_DIALOGSETTINGS_H 2 | #define CLIENT_DIALOGSETTINGS_H 3 | 4 | #include 5 | 6 | class mbClientWidgetSettingsScript; 7 | 8 | class mbClientDialogSettings : public mbCoreDialogSettings 9 | { 10 | Q_OBJECT 11 | 12 | public: 13 | struct Strings : public mbCoreDialogSettings::Strings 14 | { 15 | Strings(); 16 | static const Strings &instance(); 17 | }; 18 | 19 | public: 20 | mbClientDialogSettings(QWidget *parent = nullptr); 21 | 22 | protected: 23 | void fillForm(const MBSETTINGS &m) override; 24 | void fillData(MBSETTINGS &m) override; 25 | }; 26 | 27 | #endif // CLIENT_DIALOGSETTINGS_H 28 | -------------------------------------------------------------------------------- /src/client/gui/dialogs/settings/settings.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/client_dialogsettings.h \ 3 | 4 | SOURCES += \ 5 | $$PWD/client_dialogsettings.cpp \ 6 | -------------------------------------------------------------------------------- /src/client/gui/gui.pri: -------------------------------------------------------------------------------- 1 | include(dialogs/dialogs.pri) 2 | include(project/project.pri) 3 | include(dataview/dataview.pri) 4 | include(sendmessage/sendmessage.pri) 5 | include(scanner/scanner.pri) 6 | 7 | HEADERS += \ 8 | $$PWD/client_windowmanager.h \ 9 | $$PWD/client_ui.h \ 10 | 11 | SOURCES += \ 12 | $$PWD/client_windowmanager.cpp \ 13 | $$PWD/client_ui.cpp \ 14 | 15 | FORMS += \ 16 | $$PWD/client_ui.ui \ 17 | 18 | RESOURCES += \ 19 | $$PWD/client_rsc.qrc 20 | -------------------------------------------------------------------------------- /src/client/gui/icons/client.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/client/gui/icons/client.ico -------------------------------------------------------------------------------- /src/client/gui/icons/scanner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/client/gui/icons/scanner.png -------------------------------------------------------------------------------- /src/client/gui/icons/sendmessage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/client/gui/icons/sendmessage.png -------------------------------------------------------------------------------- /src/client/gui/project/client_projectdelegate.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #include "client_projectdelegate.h" 24 | 25 | mbClientProjectDelegate::mbClientProjectDelegate(QObject *parent) 26 | : mbCoreProjectDelegate{parent} 27 | { 28 | } 29 | -------------------------------------------------------------------------------- /src/client/gui/project/client_projectdelegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef CLIENT_PROJECTDELEGATE_H 24 | #define CLIENT_PROJECTDELEGATE_H 25 | 26 | #include 27 | 28 | class mbClientProjectDelegate : public mbCoreProjectDelegate 29 | { 30 | Q_OBJECT 31 | public: 32 | explicit mbClientProjectDelegate(QObject *parent = nullptr); 33 | }; 34 | 35 | #endif // CLIENT_PROJECTDELEGATE_H 36 | -------------------------------------------------------------------------------- /src/client/gui/project/client_projectui.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef CLIENT_PROJECTUI_H 24 | #define CLIENT_PROJECTUI_H 25 | 26 | #include 27 | 28 | class mbClientPort; 29 | class mbClientDevice; 30 | 31 | class mbClientProjectUi : public mbCoreProjectUi 32 | { 33 | Q_OBJECT 34 | public: 35 | explicit mbClientProjectUi(QWidget *parent = nullptr); 36 | 37 | public: 38 | inline mbClientPort *currentPort() const { return reinterpret_cast(currentPortCore ()); } 39 | inline mbClientPort *selectedPort() const { return reinterpret_cast(selectedPortCore()); } 40 | inline mbClientDevice *currentDevice() const { return reinterpret_cast(currentDeviceCore ()); } 41 | inline mbClientDevice *selectedDevice() const { return reinterpret_cast(selectedDeviceCore()); } 42 | 43 | Q_SIGNALS: 44 | void deviceDoubleClick(mbClientDevice *device); 45 | void deviceContextMenu(mbClientDevice *device); 46 | 47 | protected Q_SLOTS: 48 | void doubleClick(const QModelIndex &index) override; 49 | void contextMenu(const QModelIndex &index) override; 50 | }; 51 | 52 | #endif // CLIENT_PROJECTUI_H 53 | -------------------------------------------------------------------------------- /src/client/gui/project/project.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/client_projectdelegate.h \ 3 | $$PWD/client_projectmodel.h \ 4 | $$PWD/client_projectui.h \ 5 | 6 | SOURCES += \ 7 | $$PWD/client_projectdelegate.cpp\ 8 | $$PWD/client_projectmodel.cpp \ 9 | $$PWD/client_projectui.cpp \ 10 | -------------------------------------------------------------------------------- /src/client/gui/scanner/client_scannermodel.cpp: -------------------------------------------------------------------------------- 1 | #include "client_scannermodel.h" 2 | 3 | #include "client_scanner.h" 4 | 5 | mbClientScannerModel::mbClientScannerModel(mbClientScanner *scanner, QObject *parent) 6 | : QAbstractTableModel{parent} 7 | { 8 | m_scanner = scanner; 9 | connect(m_scanner, &mbClientScanner::deviceAdded, this, &mbClientScannerModel::deviceAdded); 10 | connect(m_scanner, &mbClientScanner::cleared, this, &mbClientScannerModel::cleared); 11 | } 12 | 13 | int mbClientScannerModel::rowCount(const QModelIndex &) const 14 | { 15 | return m_devices.count(); 16 | } 17 | 18 | int mbClientScannerModel::columnCount(const QModelIndex &) const 19 | { 20 | return 1; 21 | } 22 | 23 | QVariant mbClientScannerModel::data(const QModelIndex &index, int role) const 24 | { 25 | if (role == Qt::DisplayRole) 26 | return m_devices.value(index.row()); 27 | return QVariant(); 28 | } 29 | 30 | void mbClientScannerModel::deviceAdded(int index) 31 | { 32 | beginInsertRows(QModelIndex(), index, index); 33 | m_devices.append(m_scanner->deviceInfoStr(index)); 34 | endInsertRows(); 35 | } 36 | 37 | void mbClientScannerModel::cleared() 38 | { 39 | beginResetModel(); 40 | m_devices.clear(); 41 | endResetModel(); 42 | } 43 | -------------------------------------------------------------------------------- /src/client/gui/scanner/client_scannermodel.h: -------------------------------------------------------------------------------- 1 | #ifndef MBCLIENTSCANNERMODEL_H 2 | #define MBCLIENTSCANNERMODEL_H 3 | 4 | #include 5 | 6 | class mbClientScanner; 7 | 8 | class mbClientScannerModel : public QAbstractTableModel 9 | { 10 | public: 11 | explicit mbClientScannerModel(mbClientScanner *scanner, QObject *parent = nullptr); 12 | 13 | public: // table model interface 14 | int rowCount(const QModelIndex &parent = QModelIndex()) const; 15 | int columnCount(const QModelIndex &parent = QModelIndex()) const; 16 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; 17 | 18 | private Q_SLOTS: 19 | void deviceAdded(int index); 20 | void cleared(); 21 | 22 | private: 23 | mbClientScanner *m_scanner; 24 | QStringList m_devices; 25 | }; 26 | 27 | #endif // MBCLIENTSCANNERMODEL_H 28 | -------------------------------------------------------------------------------- /src/client/gui/scanner/scanner.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/client_dialogscannerrequest.h \ 3 | $$PWD/client_scanner.h \ 4 | $$PWD/client_scannermodel.h \ 5 | $$PWD/client_scannerthread.h \ 6 | $$PWD/client_scannerui.h 7 | 8 | SOURCES += \ 9 | $$PWD/client_dialogscannerrequest.cpp \ 10 | $$PWD/client_scanner.cpp \ 11 | $$PWD/client_scannermodel.cpp \ 12 | $$PWD/client_scannerthread.cpp \ 13 | $$PWD/client_scannerui.cpp 14 | 15 | FORMS += \ 16 | $$PWD/client_dialogscannerrequest.ui \ 17 | $$PWD/client_scannerui.ui 18 | -------------------------------------------------------------------------------- /src/client/gui/sendmessage/sendmessage.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/client_sendmessageui.h 3 | 4 | SOURCES += \ 5 | $$PWD/client_sendmessageui.cpp 6 | 7 | FORMS += \ 8 | $$PWD/client_sendmessageui.ui 9 | -------------------------------------------------------------------------------- /src/client/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #include 24 | 25 | #include "client.h" 26 | 27 | int main(int argc, char *argv[]) 28 | { 29 | mbClient sys; 30 | return sys.exec(argc, argv); 31 | } 32 | -------------------------------------------------------------------------------- /src/client/project/client_project.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #include "client_project.h" 24 | 25 | mbClientProject::mbClientProject(QObject *parent) : 26 | mbCoreProject(parent) 27 | { 28 | } 29 | 30 | mbClientProject::~mbClientProject() 31 | { 32 | } 33 | 34 | -------------------------------------------------------------------------------- /src/client/project/project.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/client_builder.h \ 3 | $$PWD/client_device.h \ 4 | $$PWD/client_dom.h \ 5 | $$PWD/client_port.h \ 6 | $$PWD/client_project.h \ 7 | $$PWD/client_dataview.h 8 | 9 | SOURCES += \ 10 | $$PWD/client_builder.cpp \ 11 | $$PWD/client_device.cpp \ 12 | $$PWD/client_dom.cpp \ 13 | $$PWD/client_port.cpp \ 14 | $$PWD/client_project.cpp \ 15 | $$PWD/client_dataview.cpp 16 | -------------------------------------------------------------------------------- /src/client/runtime/client_runport.cpp: -------------------------------------------------------------------------------- 1 | #include "client_runport.h" 2 | 3 | #include "client_runmessage.h" 4 | 5 | mbClientRunPort::mbClientRunPort(mbClientPort *port) : 6 | m_port(port) 7 | { 8 | } 9 | 10 | bool mbClientRunPort::hasExternalMessage() const 11 | { 12 | QReadLocker _(&m_lock); 13 | return m_externalMessages.count(); 14 | } 15 | 16 | void mbClientRunPort::pushExternalMessage(const mbClientRunMessagePtr &message) 17 | { 18 | QWriteLocker _(&m_lock); 19 | m_externalMessages.enqueue(message); 20 | } 21 | 22 | bool mbClientRunPort::popExternalMessage(mbClientRunMessagePtr *message) 23 | { 24 | QWriteLocker _(&m_lock); 25 | if (m_externalMessages.count()) 26 | { 27 | *message = m_externalMessages.dequeue(); 28 | return true; 29 | } 30 | return false; 31 | } 32 | 33 | -------------------------------------------------------------------------------- /src/client/runtime/client_runport.h: -------------------------------------------------------------------------------- 1 | #ifndef CLIENT_RUNPORT_H 2 | #define CLIENT_RUNPORT_H 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | class mbClientRunDevice; 11 | 12 | class mbClientRunPort 13 | { 14 | public: 15 | explicit mbClientRunPort(mbClientPort *port); 16 | 17 | public: 18 | inline mbClientPort *port() { return m_port; } 19 | 20 | public: // mbClientPort interface 21 | // Note: as port in runtime is unchangeable so access functions can be used safely 22 | inline QString name() const { return m_port->name(); } 23 | inline MBSETTINGS settings() const { return m_port->settings(); } 24 | inline bool isBroadcastEnabled() const { return m_port->isBroadcastEnabled(); } 25 | inline mbClientPort::Statistic statistic() const { return m_port->statistic(); } 26 | inline void setStatCountTx(quint32 count) { m_port->setStatCountTx(count); } 27 | inline void setStatCountRx(quint32 count) { m_port->setStatCountRx(count); } 28 | 29 | public: 30 | inline QList devices() const { return m_devices; } 31 | inline void pushDevices(const QList &devices) { m_devices.append(devices); } 32 | 33 | public: 34 | bool hasExternalMessage() const; 35 | void pushExternalMessage(const mbClientRunMessagePtr &message); 36 | bool popExternalMessage(mbClientRunMessagePtr *message); 37 | 38 | private: 39 | mutable QReadWriteLock m_lock; 40 | mbClientPort *m_port; 41 | QList m_devices; 42 | QQueue m_externalMessages; 43 | }; 44 | 45 | #endif // CLIENT_RUNPORT_H 46 | -------------------------------------------------------------------------------- /src/client/runtime/client_runthread.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #include "client_runthread.h" 24 | 25 | #include 26 | 27 | #include 28 | 29 | #include 30 | 31 | #include "client_runport.h" 32 | #include "client_rundevice.h" 33 | #include "client_portrunnable.h" 34 | 35 | mbClientRunThread::mbClientRunThread(mbClientRunPort *port, QObject *parent) 36 | : QThread(parent) 37 | { 38 | m_ctrlRun = true; 39 | m_port = port; 40 | m_settings = port->settings(); 41 | moveToThread(this); 42 | } 43 | 44 | mbClientRunThread::~mbClientRunThread() 45 | { 46 | } 47 | 48 | void mbClientRunThread::run() 49 | { 50 | QEventLoop loop; 51 | mbClientPortRunnable port(m_port, m_settings, this); 52 | m_ctrlRun = true; 53 | mbClient::LogInfo(port.name(), QStringLiteral("Start polling")); 54 | while (m_ctrlRun) 55 | { 56 | loop.processEvents(); 57 | port.run(); 58 | Modbus::msleep(1); 59 | } 60 | port.close(); 61 | mbClient::LogInfo(port.name(), QStringLiteral("Finish polling")); 62 | } 63 | -------------------------------------------------------------------------------- /src/client/runtime/client_runthread.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef CLIENT_RUNTHREAD_H 24 | #define CLIENT_RUNTHREAD_H 25 | 26 | #include 27 | 28 | #include 29 | 30 | class ModbusClient; 31 | 32 | class mbClientRunPort; 33 | class mbClientRunDevice; 34 | class mbClientDeviceRunnable; 35 | 36 | class mbClientRunThread : public QThread 37 | { 38 | public: 39 | explicit mbClientRunThread(mbClientRunPort *port, QObject *parent = nullptr); 40 | ~mbClientRunThread(); 41 | 42 | public: 43 | inline void stop() { m_ctrlRun = false; } 44 | 45 | protected: 46 | void run() override; 47 | 48 | private: 49 | bool m_ctrlRun; 50 | 51 | private: 52 | mbClientRunPort *m_port; 53 | Modbus::Settings m_settings; 54 | QList m_devices; 55 | }; 56 | 57 | #endif // CLIENT_RUNTHREAD_H 58 | -------------------------------------------------------------------------------- /src/client/runtime/runtime.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/client_devicerunnable.h \ 3 | $$PWD/client_portrunnable.h \ 4 | $$PWD/client_rundevice.h \ 5 | $$PWD/client_runitem.h \ 6 | $$PWD/client_runmessage.h \ 7 | $$PWD/client_runport.h \ 8 | $$PWD/client_runthread.h \ 9 | $$PWD/client_runtime.h 10 | 11 | SOURCES += \ 12 | $$PWD/client_devicerunnable.cpp \ 13 | $$PWD/client_portrunnable.cpp \ 14 | $$PWD/client_rundevice.cpp \ 15 | $$PWD/client_runitem.cpp \ 16 | $$PWD/client_runmessage.cpp \ 17 | $$PWD/client_runport.cpp \ 18 | $$PWD/client_runthread.cpp \ 19 | $$PWD/client_runtime.cpp 20 | -------------------------------------------------------------------------------- /src/client/win_resource.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | IDI_ICON1 ICON DISCARDABLE "gui\\icons\\client.ico" 4 | 5 | VS_VERSION_INFO VERSIONINFO 6 | FILEVERSION 0,4,4,0 7 | PRODUCTVERSION 0,4,4,0 8 | FILEFLAGSMASK 0x3fL 9 | #ifdef _DEBUG 10 | FILEFLAGS VS_FF_DEBUG 11 | #else 12 | FILEFLAGS 0x0L 13 | #endif 14 | FILEOS VOS__WINDOWS32 15 | FILETYPE VFT_DLL 16 | FILESUBTYPE 0x0L 17 | BEGIN 18 | BLOCK "StringFileInfo" 19 | BEGIN 20 | BLOCK "040904b0" 21 | BEGIN 22 | VALUE "CompanyName", "\0" 23 | VALUE "FileDescription", "\0" 24 | VALUE "FileVersion", "0.4.4.0\0" 25 | VALUE "LegalCopyright", "\0" 26 | VALUE "OriginalFilename", "client.exe\0" 27 | VALUE "ProductName", "client\0" 28 | VALUE "ProductVersion", "0.4.4.0\0" 29 | END 30 | END 31 | BLOCK "VarFileInfo" 32 | BEGIN 33 | VALUE "Translation", 0x0409, 1200 34 | END 35 | END 36 | /* End of Version info */ 37 | 38 | -------------------------------------------------------------------------------- /src/core/core.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = lib 2 | 3 | include(../version.pri) 4 | 5 | CONFIG += no_keywords 6 | 7 | DESTDIR = ../../bin 8 | 9 | QT = core gui widgets help 10 | 11 | DEFINES += MB_EXPORTS 12 | 13 | INCLUDEPATH += . \ 14 | ./../../modbus/src \ 15 | ./sdk\ 16 | ./core 17 | 18 | unix:QMAKE_RPATHDIR += . 19 | 20 | include(sdk/sdk.pri) 21 | include(core/core.pri) 22 | include(task/task.pri) 23 | include(plugin/plugin.pri) 24 | include(project/project.pri) 25 | include(gui/gui.pri) 26 | include(runtime/runtime.pri) 27 | 28 | HEADERS += 29 | 30 | SOURCES += 31 | 32 | LIBS += -L../../bin -lmodbus 33 | -------------------------------------------------------------------------------- /src/core/core/core.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/core.h \ 3 | $$PWD/core_filemanager.h \ 4 | $$PWD/core_global.h 5 | 6 | SOURCES += \ 7 | $$PWD/core.cpp \ 8 | $$PWD/core_filemanager.cpp \ 9 | $$PWD/core_global.cpp 10 | -------------------------------------------------------------------------------- /src/core/gui/core_rsc.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | icons/clear.png 4 | icons/edit.png 5 | icons/fileclose.png 6 | icons/filenew.png 7 | icons/fileopen.png 8 | icons/filesave.png 9 | icons/filesaveall.png 10 | icons/play.png 11 | icons/quit.png 12 | icons/remove.png 13 | icons/Trash.png 14 | icons/stop.png 15 | icons/redo.png 16 | icons/undo.png 17 | icons/resetproperty.png 18 | icons/port.png 19 | icons/device.png 20 | icons/dataview.png 21 | icons/dataviewitem.png 22 | icons/arrow_down.png 23 | icons/arrow_up.png 24 | icons/logexport.png 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/core/gui/dataview/core_dataviewdelegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef CORE_DATAVIEWDELEGATE_H 24 | #define CORE_DATAVIEWDELEGATE_H 25 | 26 | #include 27 | 28 | #include 29 | 30 | class MB_EXPORT mbCoreDataViewDelegate : public QStyledItemDelegate 31 | { 32 | Q_OBJECT 33 | public: 34 | mbCoreDataViewDelegate(QObject *parent = nullptr); 35 | 36 | public: 37 | bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override; 38 | QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const override; 39 | void setEditorData(QWidget *editor, const QModelIndex &index ) const override; 40 | void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const override; 41 | 42 | Q_SIGNALS: 43 | void doubleClick(const QModelIndex &index); 44 | void contextMenu(const QModelIndex &index); 45 | }; 46 | 47 | 48 | #endif // CORE_DATAVIEWDELEGATE_H 49 | -------------------------------------------------------------------------------- /src/core/gui/dataview/dataview.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/core_dataviewdelegate.h \ 3 | $$PWD/core_dataviewmanager.h \ 4 | $$PWD/core_dataviewmodel.h \ 5 | $$PWD/core_dataviewui.h \ 6 | 7 | SOURCES += \ 8 | $$PWD/core_dataviewdelegate.cpp \ 9 | $$PWD/core_dataviewmanager.cpp \ 10 | $$PWD/core_dataviewmodel.cpp \ 11 | $$PWD/core_dataviewui.cpp \ 12 | -------------------------------------------------------------------------------- /src/core/gui/dialogs/core_dialogbase.cpp: -------------------------------------------------------------------------------- 1 | #include "core_dialogbase.h" 2 | 3 | mbCoreDialogBase::Strings::Strings() : 4 | wGeometry(QStringLiteral("geometry")) 5 | { 6 | } 7 | 8 | const mbCoreDialogBase::Strings &mbCoreDialogBase::Strings::instance() 9 | { 10 | static const Strings s; 11 | return s; 12 | } 13 | 14 | 15 | mbCoreDialogBase::mbCoreDialogBase(const QString &cachePrefix, QWidget *parent) : QDialog(parent), 16 | m_cachePrefix(cachePrefix) 17 | { 18 | } 19 | 20 | MBSETTINGS mbCoreDialogBase::cachedSettings() const 21 | { 22 | const Strings &ds = Strings::instance(); 23 | const QString &prefix = m_cachePrefix; 24 | 25 | MBSETTINGS m; 26 | QRect r = this->geometry(); 27 | if (!r.topLeft().isNull()) 28 | m[prefix+ds.wGeometry] = this->saveGeometry(); 29 | return m; 30 | } 31 | 32 | void mbCoreDialogBase::setCachedSettings(const MBSETTINGS &m) 33 | { 34 | const Strings &ds = Strings::instance(); 35 | const QString &prefix = m_cachePrefix; 36 | 37 | MBSETTINGS::const_iterator it; 38 | MBSETTINGS::const_iterator end = m.end(); 39 | 40 | it = m.find(prefix+ds.wGeometry); if (it != end) this->restoreGeometry(it.value().toByteArray()); 41 | } 42 | -------------------------------------------------------------------------------- /src/core/gui/dialogs/core_dialogbase.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef CORE_DIALOGBASE_H 24 | #define CORE_DIALOGBASE_H 25 | 26 | #include 27 | 28 | #include 29 | 30 | class MB_EXPORT mbCoreDialogBase : public QDialog 31 | { 32 | public: 33 | struct MB_EXPORT Strings 34 | { 35 | const QString wGeometry; 36 | Strings(); 37 | static const Strings &instance(); 38 | }; 39 | 40 | public: 41 | mbCoreDialogBase(const QString &cachePrefix, QWidget *parent = nullptr); 42 | 43 | public: 44 | virtual MBSETTINGS cachedSettings() const; 45 | virtual void setCachedSettings(const MBSETTINGS &); 46 | 47 | protected: 48 | QString m_cachePrefix; 49 | }; 50 | 51 | #endif // CORE_DIALOGBASE_H 52 | -------------------------------------------------------------------------------- /src/core/gui/dialogs/core_dialogedit.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef CORE_DIALOGEDIT_H 24 | #define CORE_DIALOGEDIT_H 25 | 26 | #include "core_dialogbase.h" 27 | 28 | class MB_EXPORT mbCoreDialogEdit : public mbCoreDialogBase 29 | { 30 | public: 31 | using mbCoreDialogBase::mbCoreDialogBase; 32 | 33 | public: 34 | virtual MBSETTINGS getSettings(const MBSETTINGS &settings = MBSETTINGS(), const QString &title = QString()) = 0; 35 | }; 36 | 37 | #endif // CORE_DIALOGEDIT_H 38 | -------------------------------------------------------------------------------- /src/core/gui/dialogs/core_dialogproject.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef CORE_DIALOGPROJECT_H 24 | #define CORE_DIALOGPROJECT_H 25 | 26 | #include "core_dialogedit.h" 27 | 28 | namespace Ui { 29 | class mbCoreDialogProject; 30 | } 31 | 32 | class mbCoreProject; 33 | 34 | class MB_EXPORT mbCoreDialogProject : public mbCoreDialogEdit 35 | { 36 | Q_OBJECT 37 | 38 | public: 39 | struct MB_EXPORT Strings : public mbCoreDialogEdit::Strings 40 | { 41 | const QString title; 42 | const QString cachePrefix; 43 | Strings(); 44 | static const Strings &instance(); 45 | }; 46 | 47 | public: 48 | mbCoreDialogProject(QWidget *parent = nullptr); 49 | ~mbCoreDialogProject(); 50 | 51 | public: 52 | MBSETTINGS cachedSettings() const override; 53 | void setCachedSettings(const MBSETTINGS &settings) override; 54 | 55 | public: 56 | MBSETTINGS getSettings(const MBSETTINGS &settings, const QString &title = QString()) override; 57 | 58 | private: 59 | void fillForm(const MBSETTINGS &settings); 60 | void fillData(MBSETTINGS &settings); 61 | 62 | private: 63 | Ui::mbCoreDialogProject *ui; 64 | }; 65 | 66 | #endif // CORE_DIALOGPROJECT_H 67 | -------------------------------------------------------------------------------- /src/core/gui/dialogs/core_dialogproject.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | mbCoreDialogProject 4 | 5 | 6 | 7 | 0 8 | 0 9 | 375 10 | 268 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 20 | Name 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | Author 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | QFrame::NoFrame 41 | 42 | 43 | QFrame::Plain 44 | 45 | 46 | Comment 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | Qt::Horizontal 57 | 58 | 59 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /src/core/gui/dialogs/core_dialogprojectinfo.cpp: -------------------------------------------------------------------------------- 1 | #include "core_dialogprojectinfo.h" 2 | #include "ui_core_dialogprojectinfo.h" 3 | 4 | #include 5 | 6 | mbCoreDialogProjectInfo::Strings::Strings() : mbCoreDialogBase::Strings(), 7 | cachePrefix(QStringLiteral("Ui.Dialogs.ProjectInfo.")) 8 | { 9 | } 10 | 11 | const mbCoreDialogProjectInfo::Strings &mbCoreDialogProjectInfo::Strings::instance() 12 | { 13 | static const mbCoreDialogProjectInfo::Strings s; 14 | return s; 15 | } 16 | 17 | mbCoreDialogProjectInfo::mbCoreDialogProjectInfo(QWidget *parent) : 18 | mbCoreDialogBase(Strings::instance().cachePrefix, parent), 19 | ui(new Ui::mbCoreDialogProjectInfo) 20 | { 21 | ui->setupUi(this); 22 | 23 | // ---------------------------------------------------------------------------------- 24 | connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); 25 | connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject())); 26 | } 27 | 28 | mbCoreDialogProjectInfo::~mbCoreDialogProjectInfo() 29 | { 30 | delete ui; 31 | } 32 | 33 | void mbCoreDialogProjectInfo::setProjectType(const QString &type) 34 | { 35 | ui->lbType->setText(type); 36 | } 37 | 38 | void mbCoreDialogProjectInfo::showProjectInfo(mbCoreProject *project) 39 | { 40 | fillProjectInfo(project); 41 | QDialog::exec(); 42 | } 43 | 44 | void mbCoreDialogProjectInfo::fillProjectInfo(mbCoreProject *project) 45 | { 46 | ui->lbName ->setText(project->name()); 47 | ui->lbAuthor ->setText(project->author()); 48 | ui->lbPath ->setText(project->absoluteFilePath()); 49 | ui->lbSize ->setText(QString::number(project->fileSize())+QStringLiteral(" Bytes") ); 50 | ui->lbCreated ->setText(project->fileCreated().toString(Qt::ISODate)); 51 | ui->lbModified ->setText(project->fileModified().toString(Qt::ISODate)); 52 | ui->lbVersion ->setText(project->versionStr()); 53 | ui->lbEditNumber->setText(QString::number(project->editNumber())); 54 | 55 | ui->txtComment->setPlainText(project->comment()); 56 | } 57 | -------------------------------------------------------------------------------- /src/core/gui/dialogs/core_dialogprojectinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef CORE_DIALOGPROJECTINFO_H 2 | #define CORE_DIALOGPROJECTINFO_H 3 | 4 | #include "core_dialogbase.h" 5 | 6 | namespace Ui { 7 | class mbCoreDialogProjectInfo; 8 | } 9 | 10 | class mbCoreProject; 11 | 12 | class MB_EXPORT mbCoreDialogProjectInfo : public mbCoreDialogBase 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | struct MB_EXPORT Strings : public mbCoreDialogBase::Strings 18 | { 19 | const QString cachePrefix; 20 | Strings(); 21 | static const Strings &instance(); 22 | }; 23 | 24 | public: 25 | explicit mbCoreDialogProjectInfo(QWidget *parent = nullptr); 26 | ~mbCoreDialogProjectInfo(); 27 | 28 | public: 29 | void setProjectType(const QString &type); 30 | 31 | public: 32 | void showProjectInfo(mbCoreProject *project); 33 | 34 | protected: 35 | void fillProjectInfo(mbCoreProject *project); 36 | 37 | private: 38 | Ui::mbCoreDialogProjectInfo *ui; 39 | }; 40 | 41 | #endif // CORE_DIALOGPROJECTINFO_H 42 | -------------------------------------------------------------------------------- /src/core/gui/dialogs/core_dialogvaluelist.h: -------------------------------------------------------------------------------- 1 | #ifndef CORE_DIALOGVALUELIST_H 2 | #define CORE_DIALOGVALUELIST_H 3 | 4 | #include "core_dialogbase.h" 5 | 6 | namespace Ui { 7 | class mbCoreDialogValueList; 8 | } 9 | 10 | class mbCoreDialogValueList : public mbCoreDialogBase 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | struct MB_EXPORT Strings : public mbCoreDialogBase::Strings 16 | { 17 | const QString title; 18 | const QString cachePrefix; 19 | Strings(); 20 | static const Strings &instance(); 21 | }; 22 | 23 | public: 24 | explicit mbCoreDialogValueList(QWidget *parent = nullptr); 25 | ~mbCoreDialogValueList(); 26 | 27 | public: 28 | bool getValueList(const QVariantList &all, QVariantList ¤t, const QString &title = QString()); 29 | bool getValueList(const QStringList &all, QStringList ¤t, const QString &title = QString()); 30 | 31 | private: 32 | void fillForm(const QVariantList &all, const QVariantList ¤t); 33 | void fillData(QVariantList ¤t); 34 | void fillForm(const QStringList &all, const QStringList ¤t); 35 | void fillData(QStringList ¤t); 36 | 37 | private Q_SLOTS: 38 | void slotAdd(); 39 | void slotRemove(); 40 | void slotMoveUp(); 41 | void slotMoveDown(); 42 | 43 | private: 44 | Ui::mbCoreDialogValueList *ui; 45 | }; 46 | 47 | #endif // CORE_DIALOGVALUELIST_H 48 | -------------------------------------------------------------------------------- /src/core/gui/dialogs/dialogs.pri: -------------------------------------------------------------------------------- 1 | include(settings/settings.pri) 2 | 3 | HEADERS += \ 4 | $$PWD/core_dialogbase.h \ 5 | $$PWD/core_dialogedit.h \ 6 | $$PWD/core_dialogprojectinfo.h \ 7 | $$PWD/core_dialogproject.h \ 8 | $$PWD/core_dialogport.h \ 9 | $$PWD/core_dialogdevice.h \ 10 | $$PWD/core_dialogdataview.h \ 11 | $$PWD/core_dialogdataviewitem.h \ 12 | $$PWD/core_dialogvaluelist.h \ 13 | $$PWD/core_dialogs.h \ 14 | 15 | SOURCES += \ 16 | $$PWD/core_dialogbase.cpp \ 17 | $$PWD/core_dialogprojectinfo.cpp \ 18 | $$PWD/core_dialogproject.cpp \ 19 | $$PWD/core_dialogport.cpp \ 20 | $$PWD/core_dialogdevice.cpp \ 21 | $$PWD/core_dialogdataview.cpp \ 22 | $$PWD/core_dialogdataviewitem.cpp \ 23 | $$PWD/core_dialogvaluelist.cpp \ 24 | $$PWD/core_dialogs.cpp 25 | 26 | FORMS += \ 27 | $$PWD/core_dialogprojectinfo.ui \ 28 | $$PWD/core_dialogproject.ui \ 29 | $$PWD/core_dialogdataview.ui \ 30 | $$PWD/core_dialogvaluelist.ui 31 | -------------------------------------------------------------------------------- /src/core/gui/dialogs/settings/core_dialogsettings.h: -------------------------------------------------------------------------------- 1 | #ifndef CORE_DIALOGSETTINGS_H 2 | #define CORE_DIALOGSETTINGS_H 3 | 4 | #include "../core_dialogbase.h" 5 | 6 | class QSplitter; 7 | class QListWidget; 8 | class QStackedWidget; 9 | class mbCoreWidgetSettingsView; 10 | class mbCoreWidgetSettingsDataView; 11 | class mbCoreWidgetSettingsLog; 12 | 13 | class MB_EXPORT mbCoreDialogSettings : public mbCoreDialogBase 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | struct MB_EXPORT Strings : public mbCoreDialogBase::Strings 19 | { 20 | const QString title; 21 | const QString cachePrefix; 22 | const QString wSplitterState; 23 | Strings(); 24 | static const Strings &instance(); 25 | }; 26 | 27 | public: 28 | mbCoreDialogSettings(QWidget *parent = nullptr); 29 | 30 | public: 31 | MBSETTINGS cachedSettings() const override; 32 | void setCachedSettings(const MBSETTINGS &settings) override; 33 | 34 | public: 35 | bool editSettings(const QString& title = QString()); 36 | 37 | protected: 38 | virtual void fillForm(const MBSETTINGS &m); 39 | virtual void fillData(MBSETTINGS &m); 40 | 41 | protected: 42 | QSplitter *m_splitter ; 43 | QListWidget *m_listWidget ; 44 | QStackedWidget *m_stackedWidget; 45 | 46 | mbCoreWidgetSettingsView *m_view; 47 | mbCoreWidgetSettingsDataView *m_dataView; 48 | mbCoreWidgetSettingsLog *m_log ; 49 | }; 50 | 51 | #endif // CORE_DIALOGSETTINGS_H 52 | -------------------------------------------------------------------------------- /src/core/gui/dialogs/settings/core_widgetsettingsdataview.cpp: -------------------------------------------------------------------------------- 1 | #include "core_widgetsettingsdataview.h" 2 | #include "ui_core_widgetsettingsdataview.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | mbCoreWidgetSettingsDataView::mbCoreWidgetSettingsDataView(QWidget *parent) : 9 | QWidget(parent), 10 | ui(new Ui::mbCoreWidgetSettingsDataView) 11 | { 12 | ui->setupUi(this); 13 | 14 | QStringList columns = mbCore::globalCore()->availableDataViewColumns(); 15 | setColumns(columns); 16 | connect(ui->btnEditDataViewColumns, &QPushButton::clicked, this, &mbCoreWidgetSettingsDataView::slotEditColumns); 17 | } 18 | 19 | mbCoreWidgetSettingsDataView::~mbCoreWidgetSettingsDataView() 20 | { 21 | delete ui; 22 | } 23 | 24 | QStringList mbCoreWidgetSettingsDataView::getColumns() const 25 | { 26 | QStringList res; 27 | for (int i = 0; i < ui->lsDataViewColumns->count(); i++) 28 | { 29 | QListWidgetItem *item = ui->lsDataViewColumns->item(i); 30 | res.append(item->data(Qt::DisplayRole).toString()); 31 | } 32 | return res; 33 | } 34 | 35 | void mbCoreWidgetSettingsDataView::setColumns(const QStringList &columns) 36 | { 37 | ui->lsDataViewColumns->clear(); 38 | Q_FOREACH (const QString &column, columns) 39 | ui->lsDataViewColumns->addItem(column); 40 | } 41 | 42 | void mbCoreWidgetSettingsDataView::slotEditColumns() 43 | { 44 | QStringList ls = getColumns(); 45 | bool res = mbCore::globalCore()->coreUi()->dialogsCore()->getValueList(mbCore::globalCore()->availableDataViewColumns(), ls, QStringLiteral("Edit Columns")); 46 | if (res) 47 | setColumns(ls); 48 | } 49 | -------------------------------------------------------------------------------- /src/core/gui/dialogs/settings/core_widgetsettingsdataview.h: -------------------------------------------------------------------------------- 1 | #ifndef CORE_WIDGETSETTINGSDATAVIEW_H 2 | #define CORE_WIDGETSETTINGSDATAVIEW_H 3 | 4 | #include 5 | 6 | #include 7 | 8 | namespace Ui { 9 | class mbCoreWidgetSettingsDataView; 10 | } 11 | 12 | class mbCoreWidgetSettingsDataView : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit mbCoreWidgetSettingsDataView(QWidget *parent = nullptr); 18 | ~mbCoreWidgetSettingsDataView(); 19 | 20 | public: // properties 21 | QStringList getColumns() const; 22 | void setColumns(const QStringList &columns); 23 | 24 | private Q_SLOTS: 25 | void slotEditColumns(); 26 | 27 | private: 28 | Ui::mbCoreWidgetSettingsDataView *ui; 29 | }; 30 | 31 | #endif // CORE_WIDGETSETTINGSDATAVIEW_H 32 | -------------------------------------------------------------------------------- /src/core/gui/dialogs/settings/core_widgetsettingsdataview.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | mbCoreWidgetSettingsDataView 4 | 5 | 6 | 7 | 0 8 | 0 9 | 319 10 | 274 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | Columns 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | false 31 | 32 | 33 | 34 | 1 35 | 36 | 37 | 2 38 | 39 | 40 | 2 41 | 42 | 43 | 2 44 | 45 | 46 | 2 47 | 48 | 49 | 50 | 51 | ... 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /src/core/gui/dialogs/settings/core_widgetsettingslog.h: -------------------------------------------------------------------------------- 1 | #ifndef CORE_WIDGETSETTINGSLOG_H 2 | #define CORE_WIDGETSETTINGSLOG_H 3 | 4 | #include 5 | 6 | #include 7 | 8 | namespace Ui { 9 | class mbCoreWidgetSettingsLog; 10 | } 11 | 12 | class mbCoreWidgetSettingsLog : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit mbCoreWidgetSettingsLog(QWidget *parent = nullptr); 18 | ~mbCoreWidgetSettingsLog(); 19 | 20 | public: // properties 21 | mb::LogFlags logFlags() const; 22 | void setLogFlags(mb::LogFlags flags); 23 | 24 | bool useTimestamp() const; 25 | void setUseTimestamp(bool use); 26 | 27 | QString formatDateTime() const; 28 | void setFormatDateTime(const QString &format); 29 | 30 | QString logViewFont() const; 31 | void setLogViewFont(const QString &font); 32 | 33 | protected: 34 | QFont getLogViewFont() const; 35 | void setLogViewFont(const QFont &f); 36 | 37 | private Q_SLOTS: 38 | void slotFont(); 39 | 40 | private: 41 | Ui::mbCoreWidgetSettingsLog *ui; 42 | }; 43 | 44 | #endif // CORE_WIDGETSETTINGSLOG_H 45 | -------------------------------------------------------------------------------- /src/core/gui/dialogs/settings/core_widgetsettingsview.cpp: -------------------------------------------------------------------------------- 1 | #include "core_widgetsettingsview.h" 2 | #include "ui_core_widgetsettingsview.h" 3 | 4 | mbCoreWidgetSettingsView::mbCoreWidgetSettingsView(QWidget *parent) : 5 | QWidget(parent), 6 | ui(new Ui::mbCoreWidgetSettingsView) 7 | { 8 | ui->setupUi(this); 9 | 10 | QComboBox *cmb; 11 | cmb = ui->cmbAddressNotation; 12 | cmb->addItem(mb::toFineString(mb::Address::Notation_Modbus)); 13 | cmb->addItem(mb::toFineString(mb::Address::Notation_IEC61131)); 14 | cmb->addItem(mb::toFineString(mb::Address::Notation_IEC61131Hex)); 15 | cmb->setCurrentIndex(0); 16 | } 17 | 18 | mbCoreWidgetSettingsView::~mbCoreWidgetSettingsView() 19 | { 20 | delete ui; 21 | } 22 | 23 | bool mbCoreWidgetSettingsView::useNameWithSettings() const 24 | { 25 | return ui->chbUseNameWithSettings->isChecked(); 26 | } 27 | 28 | void mbCoreWidgetSettingsView::setUseNameWithSettings(bool use) 29 | { 30 | ui->chbUseNameWithSettings->setChecked(use); 31 | } 32 | 33 | mb::AddressNotation mbCoreWidgetSettingsView::addressNotation() const 34 | { 35 | return static_cast(ui->cmbAddressNotation->currentIndex()+1); 36 | } 37 | 38 | void mbCoreWidgetSettingsView::setAddressNotation(mb::AddressNotation notation) 39 | { 40 | ui->cmbAddressNotation->setCurrentIndex(notation-1); 41 | } 42 | 43 | -------------------------------------------------------------------------------- /src/core/gui/dialogs/settings/core_widgetsettingsview.h: -------------------------------------------------------------------------------- 1 | #ifndef CORE_WIDGETSETTINGSVIEW_H 2 | #define CORE_WIDGETSETTINGSVIEW_H 3 | 4 | #include 5 | 6 | #include 7 | 8 | namespace Ui { 9 | class mbCoreWidgetSettingsView; 10 | } 11 | 12 | class mbCoreWidgetSettingsView : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit mbCoreWidgetSettingsView(QWidget *parent = nullptr); 18 | ~mbCoreWidgetSettingsView(); 19 | 20 | public: // properties 21 | bool useNameWithSettings() const; 22 | void setUseNameWithSettings(bool use); 23 | mb::AddressNotation addressNotation() const; 24 | void setAddressNotation(mb::AddressNotation notation); 25 | 26 | private: 27 | Ui::mbCoreWidgetSettingsView *ui; 28 | }; 29 | 30 | #endif // CORE_WIDGETSETTINGSVIEW_H 31 | -------------------------------------------------------------------------------- /src/core/gui/dialogs/settings/core_widgetsettingsview.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | mbCoreWidgetSettingsView 4 | 5 | 6 | 7 | 0 8 | 0 9 | 307 10 | 232 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | Use Port/Device names with settings 21 | 22 | 23 | 24 | 25 | 26 | 27 | Modbus adr. notation: 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | Qt::Vertical 38 | 39 | 40 | 41 | 20 42 | 183 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /src/core/gui/dialogs/settings/settings.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/core_dialogsettings.h \ 3 | $$PWD/core_widgetsettingsdataview.h \ 4 | $$PWD/core_widgetsettingslog.h \ 5 | $$PWD/core_widgetsettingsview.h 6 | 7 | SOURCES += \ 8 | $$PWD/core_dialogsettings.cpp \ 9 | $$PWD/core_widgetsettingsdataview.cpp \ 10 | $$PWD/core_widgetsettingslog.cpp \ 11 | $$PWD/core_widgetsettingsview.cpp 12 | 13 | FORMS += \ 14 | $$PWD/core_widgetsettingsdataview.ui \ 15 | $$PWD/core_widgetsettingslog.ui \ 16 | $$PWD/core_widgetsettingsview.ui 17 | -------------------------------------------------------------------------------- /src/core/gui/gui.pri: -------------------------------------------------------------------------------- 1 | include(dialogs/dialogs.pri) 2 | include(project/project.pri) 3 | include(dataview/dataview.pri) 4 | include(logview/logview.pri) 5 | include(widgets/widgets.pri) 6 | include(help/help.pri) 7 | 8 | HEADERS += \ 9 | $$PWD/core_windowmanager.h \ 10 | $$PWD/core_ui.h 11 | 12 | SOURCES += \ 13 | $$PWD/core_windowmanager.cpp \ 14 | $$PWD/core_ui.cpp 15 | 16 | RESOURCES += \ 17 | $$PWD/core_rsc.qrc 18 | -------------------------------------------------------------------------------- /src/core/gui/help/core_helpbrowser.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef CORE_HELPBROWSER_H 24 | #define CORE_HELPBROWSER_H 25 | 26 | #include 27 | 28 | class QHelpEngine; 29 | 30 | class mbCoreHelpBrowser : public QTextBrowser 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | mbCoreHelpBrowser(QHelpEngine* helpEngine, QWidget *parent); 36 | 37 | public: 38 | QVariant loadResource(int type, const QUrl &name) override; 39 | void showHelpForKeyword(const QString &id); 40 | 41 | private: 42 | QHelpEngine *m_helpEngine; 43 | }; 44 | 45 | #endif // CORE_HELPBROWSER_H 46 | -------------------------------------------------------------------------------- /src/core/gui/help/core_helpui.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef CORE_HELPUI_H 24 | #define CORE_HELPUI_H 25 | 26 | #include 27 | #include 28 | 29 | class QHelpEngine; 30 | 31 | class mbCoreHelpUi : public QMainWindow 32 | { 33 | Q_OBJECT 34 | 35 | public: 36 | struct MB_EXPORT Strings 37 | { 38 | const QString prefix; 39 | const QString wGeometry; 40 | const QString wState; 41 | Strings(); 42 | static const Strings &instance(); 43 | }; 44 | 45 | public: 46 | mbCoreHelpUi(const QString &relativeCollectionFile, QWidget *parent = nullptr); 47 | ~mbCoreHelpUi(); 48 | 49 | public: 50 | MBSETTINGS cachedSettings() const; 51 | void setCachedSettings(const MBSETTINGS &settings); 52 | 53 | private: 54 | QHelpEngine *m_helpEngine; 55 | }; 56 | 57 | #endif // CORE_HELPUI_H 58 | -------------------------------------------------------------------------------- /src/core/gui/help/help.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/core_helpbrowser.h \ 3 | $$PWD/core_helpui.h \ 4 | 5 | SOURCES += \ 6 | $$PWD/core_helpbrowser.cpp \ 7 | $$PWD/core_helpui.cpp \ 8 | -------------------------------------------------------------------------------- /src/core/gui/icons/Trash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/core/gui/icons/Trash.png -------------------------------------------------------------------------------- /src/core/gui/icons/arrow_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/core/gui/icons/arrow_down.png -------------------------------------------------------------------------------- /src/core/gui/icons/arrow_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/core/gui/icons/arrow_up.png -------------------------------------------------------------------------------- /src/core/gui/icons/clear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/core/gui/icons/clear.png -------------------------------------------------------------------------------- /src/core/gui/icons/dataview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/core/gui/icons/dataview.png -------------------------------------------------------------------------------- /src/core/gui/icons/dataviewitem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/core/gui/icons/dataviewitem.png -------------------------------------------------------------------------------- /src/core/gui/icons/device.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/core/gui/icons/device.png -------------------------------------------------------------------------------- /src/core/gui/icons/edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/core/gui/icons/edit.png -------------------------------------------------------------------------------- /src/core/gui/icons/fileclose.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/core/gui/icons/fileclose.png -------------------------------------------------------------------------------- /src/core/gui/icons/filenew.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/core/gui/icons/filenew.png -------------------------------------------------------------------------------- /src/core/gui/icons/fileopen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/core/gui/icons/fileopen.png -------------------------------------------------------------------------------- /src/core/gui/icons/filesave.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/core/gui/icons/filesave.png -------------------------------------------------------------------------------- /src/core/gui/icons/filesaveall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/core/gui/icons/filesaveall.png -------------------------------------------------------------------------------- /src/core/gui/icons/logexport.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/core/gui/icons/logexport.png -------------------------------------------------------------------------------- /src/core/gui/icons/play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/core/gui/icons/play.png -------------------------------------------------------------------------------- /src/core/gui/icons/port.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/core/gui/icons/port.png -------------------------------------------------------------------------------- /src/core/gui/icons/quit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/core/gui/icons/quit.png -------------------------------------------------------------------------------- /src/core/gui/icons/redo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/core/gui/icons/redo.png -------------------------------------------------------------------------------- /src/core/gui/icons/remove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/core/gui/icons/remove.png -------------------------------------------------------------------------------- /src/core/gui/icons/resetproperty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/core/gui/icons/resetproperty.png -------------------------------------------------------------------------------- /src/core/gui/icons/stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/core/gui/icons/stop.png -------------------------------------------------------------------------------- /src/core/gui/icons/undo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/core/gui/icons/undo.png -------------------------------------------------------------------------------- /src/core/gui/logview/core_logviewmodel.h: -------------------------------------------------------------------------------- 1 | #ifndef XCHG_MESSAGEBUFFERMODEL_H 2 | #define XCHG_MESSAGEBUFFERMODEL_H 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | class mbCoreLogViewModel : public QAbstractTableModel 10 | { 11 | Q_OBJECT 12 | 13 | public: 14 | enum Column 15 | { 16 | Column_DateTime, 17 | Column_Source , 18 | Column_Category, 19 | Column_Text , 20 | ColumnCount 21 | }; 22 | 23 | struct Message 24 | { 25 | QDateTime datetime; 26 | mb::LogFlag category; 27 | QString source; 28 | QString text; 29 | }; 30 | 31 | public: 32 | explicit mbCoreLogViewModel(QObject *parent = 0); 33 | ~mbCoreLogViewModel(); 34 | 35 | public: 36 | QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; 37 | int rowCount(const QModelIndex &index = QModelIndex()) const override; 38 | int columnCount(const QModelIndex& = QModelIndex()) const override; 39 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 40 | 41 | public: 42 | void logMessage(mb::LogFlag flag, const QString &source, const QString &text); 43 | void clear(); 44 | 45 | private: 46 | inline int getActualIndex(int row) const { return (m_ptr + m_buff.size() - m_count + row) % m_buff.size(); } 47 | 48 | private: 49 | typedef QVector MessageBuffer; 50 | MessageBuffer m_buff; 51 | int m_ptr; 52 | int m_count; 53 | }; 54 | 55 | #endif // XCHG_MESSAGEBUFFERMODEL_H 56 | -------------------------------------------------------------------------------- /src/core/gui/logview/logview.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | #$$PWD/core_logviewmodel.h \ 3 | $$PWD/core_logview.h 4 | 5 | SOURCES += \ 6 | #$$PWD/core_logviewmodel.cpp \ 7 | $$PWD/core_logview.cpp 8 | -------------------------------------------------------------------------------- /src/core/gui/logviewlogview.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/xchg_messagebuffermodel.h \ 3 | $$PWD/xchg_messagebufferui.h \ 4 | 5 | SOURCES += \ 6 | $$PWD/xchg_messagebuffermodel.cpp \ 7 | $$PWD/xchg_messagebufferui.cpp \ 8 | -------------------------------------------------------------------------------- /src/core/gui/project/core_projectdelegate.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #include "core_projectdelegate.h" 24 | 25 | #include 26 | 27 | mbCoreProjectDelegate::mbCoreProjectDelegate(QObject *parent) 28 | : QStyledItemDelegate(parent) 29 | { 30 | } 31 | 32 | bool mbCoreProjectDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) 33 | { 34 | switch (event->type()) 35 | { 36 | case QEvent::MouseButtonDblClick: 37 | Q_EMIT doubleClick(index); 38 | return true; 39 | case QEvent::ContextMenu: 40 | Q_EMIT contextMenu(index); 41 | return true; 42 | default: 43 | return QStyledItemDelegate::editorEvent(event, model, option, index); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/core/gui/project/core_projectdelegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef CORE_PROJECTDELEGATE_H 24 | #define CORE_PROJECTDELEGATE_H 25 | 26 | #include 27 | 28 | #include 29 | 30 | class MB_EXPORT mbCoreProjectDelegate : public QStyledItemDelegate 31 | { 32 | Q_OBJECT 33 | public: 34 | explicit mbCoreProjectDelegate(QObject *parent = nullptr); 35 | 36 | public: 37 | bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override; 38 | 39 | Q_SIGNALS: 40 | void doubleClick(const QModelIndex &index); 41 | void contextMenu(const QModelIndex &index); 42 | }; 43 | 44 | #endif // CORE_PROJECTDELEGATE_H 45 | -------------------------------------------------------------------------------- /src/core/gui/project/project.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/core_projectdelegate.h \ 3 | $$PWD/core_projectmodel.h \ 4 | $$PWD/core_projectui.h \ 5 | 6 | SOURCES += \ 7 | $$PWD/core_projectdelegate.cpp\ 8 | $$PWD/core_projectmodel.cpp \ 9 | $$PWD/core_projectui.cpp \ 10 | -------------------------------------------------------------------------------- /src/core/gui/widgets/core_addresswidget.h: -------------------------------------------------------------------------------- 1 | #ifndef CORE_ADDRESSWIDGET_H 2 | #define CORE_ADDRESSWIDGET_H 3 | 4 | #include 5 | #include 6 | 7 | class QComboBox; 8 | 9 | class MB_EXPORT mbCoreAddressWidget : public QWidget 10 | { 11 | public: 12 | mbCoreAddressWidget(QWidget *parent = nullptr); 13 | 14 | public: 15 | bool isEnabledAddressType() const; 16 | void setEnabledAddressType(bool enable); 17 | bool isEnabledAddress() const; 18 | void setEnabledAddress(bool enable); 19 | mb::AddressNotation addressNotation() const { return m_notation; } 20 | Modbus::MemoryType addressType() const; 21 | mb::Address getAddress() const; 22 | void setAddress(const mb::Address &adr); 23 | 24 | public Q_SLOTS: 25 | void setAddressNotation(int notation); 26 | void setAddressType(int type); 27 | 28 | private: 29 | class SpinBox : public QSpinBox 30 | { 31 | public: 32 | explicit SpinBox(QWidget *parent = nullptr); 33 | QString textFromValue(int value) const override; 34 | int valueFromText(const QString &text) const override; 35 | QValidator::State validate(QString &input, int &pos) const override; 36 | 37 | public: 38 | inline bool isHex() const { return m_hex; } 39 | void setHex(bool hex); 40 | private: 41 | bool m_hex; 42 | }; 43 | 44 | private: 45 | QComboBox *m_cmbAdrType; 46 | SpinBox *m_spAddress ; 47 | 48 | private: 49 | mb::AddressNotation m_notation; 50 | }; 51 | 52 | #endif // MBCOREADDRESSWIDGET_H 53 | -------------------------------------------------------------------------------- /src/core/gui/widgets/widgets.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/core_addresswidget.h 3 | 4 | SOURCES += \ 5 | $$PWD/core_addresswidget.cpp 6 | -------------------------------------------------------------------------------- /src/core/mbcore_config.h.in: -------------------------------------------------------------------------------- 1 | #ifndef MBCORE_CONFIG_H 2 | #define MBCORE_CONFIG_H 3 | 4 | /* 5 | Major part of mbtools version 6 | */ 7 | #define MBTOOLS_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ 8 | 9 | /* 10 | Minor part of mbtools version 11 | */ 12 | #define MBTOOLS_VERSION_MINOR @PROJECT_VERSION_MINOR@ 13 | 14 | /* 15 | Patch part of mbtools version 16 | */ 17 | #define MBTOOLS_VERSION_PATCH @PROJECT_VERSION_PATCH@ 18 | 19 | #endif // MBCORE_CONFIG_H -------------------------------------------------------------------------------- /src/core/plugin/plugin.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/core_pluginmanager.h 3 | 4 | SOURCES += \ 5 | $$PWD/core_pluginmanager.cpp -------------------------------------------------------------------------------- /src/core/project/project.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/core_project.h \ 3 | $$PWD/core_port.h \ 4 | $$PWD/core_device.h \ 5 | $$PWD/core_dataview.h \ 6 | $$PWD/core_taskinfo.h \ 7 | $$PWD/core_dom.h \ 8 | $$PWD/core_builder.h \ 9 | 10 | SOURCES += \ 11 | $$PWD/core_project.cpp \ 12 | $$PWD/core_port.cpp \ 13 | $$PWD/core_device.cpp \ 14 | $$PWD/core_dataview.cpp\ 15 | $$PWD/core_taskinfo.cpp \ 16 | $$PWD/core_dom.cpp \ 17 | $$PWD/core_builder.cpp \ 18 | -------------------------------------------------------------------------------- /src/core/runtime/core_runtaskthread.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #include "core_runtaskthread.h" 24 | 25 | #include 26 | 27 | #include 28 | 29 | mbCoreRunTaskThread::mbCoreRunTaskThread(mbCoreTask *task, QObject *parent) 30 | : QThread{parent} 31 | { 32 | m_task = task; 33 | } 34 | 35 | mbCoreRunTaskThread::~mbCoreRunTaskThread() 36 | { 37 | delete m_task; 38 | } 39 | 40 | void mbCoreRunTaskThread::run() 41 | { 42 | QEventLoop ev; 43 | m_task->init(); 44 | m_run = true; 45 | while (m_run) 46 | { 47 | ev.processEvents(); 48 | m_task->loop(); 49 | Modbus::msleep(1); 50 | } 51 | m_task->final(); 52 | } 53 | -------------------------------------------------------------------------------- /src/core/runtime/core_runtaskthread.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef CORE_RUNTASKTHREAD_H 24 | #define CORE_RUNTASKTHREAD_H 25 | 26 | #include 27 | 28 | #include 29 | 30 | class mbCoreTask; 31 | 32 | class MB_EXPORT mbCoreRunTaskThread : public QThread 33 | { 34 | public: 35 | explicit mbCoreRunTaskThread(mbCoreTask *task, QObject *parent = nullptr); 36 | ~mbCoreRunTaskThread(); 37 | 38 | public: 39 | inline void stop() { m_run = false; } 40 | 41 | protected: 42 | void run(); 43 | 44 | protected: 45 | mbCoreTask* m_task; 46 | bool m_run; 47 | }; 48 | 49 | #endif // CORE_RUNTASKTHREAD_H 50 | -------------------------------------------------------------------------------- /src/core/runtime/core_runtime.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef CORE_RUNTIME_H 24 | #define CORE_RUNTIME_H 25 | 26 | #include 27 | 28 | #include 29 | 30 | class mbCoreProject; 31 | class mbCoreRunTaskThread; 32 | 33 | class MB_EXPORT mbCoreRuntime : public QObject 34 | { 35 | Q_OBJECT 36 | public: 37 | explicit mbCoreRuntime(QObject *parent = nullptr); 38 | 39 | public: 40 | inline mbCoreProject *projectCore() const { return m_project; } 41 | 42 | public: 43 | bool isRunning(); 44 | void start(); 45 | void stop(); 46 | 47 | Q_SIGNALS: 48 | 49 | public: 50 | virtual void createComponents(); 51 | virtual void startComponents(); 52 | virtual void beginStopComponents(); 53 | virtual bool tryStopComponents(); 54 | virtual void clearComponents(); 55 | 56 | protected: 57 | mbCoreProject *m_project; 58 | 59 | protected: // task threads 60 | typedef QList TaskThreads_t; 61 | TaskThreads_t m_taskThreads; 62 | }; 63 | 64 | #endif // CORE_RUNTIME_H 65 | -------------------------------------------------------------------------------- /src/core/runtime/runtime.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/core_runtaskthread.h \ 3 | $$PWD/core_runtime.h 4 | 5 | SOURCES += \ 6 | $$PWD/core_runtaskthread.cpp \ 7 | $$PWD/core_runtime.cpp 8 | -------------------------------------------------------------------------------- /src/core/sdk/mbcore_base.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #include "mbcore_base.h" 24 | 25 | 26 | mbCoreBase::mbCoreBase(QObject *parent) : QObject (parent) 27 | { 28 | } 29 | -------------------------------------------------------------------------------- /src/core/sdk/mbcore_base.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef MBCORE_BASE_H 24 | #define MBCORE_BASE_H 25 | 26 | #include 27 | 28 | class QWidget; 29 | 30 | #include "mbcore.h" 31 | 32 | class MB_EXPORT mbCoreBase : public QObject 33 | { 34 | Q_OBJECT 35 | 36 | public: 37 | explicit mbCoreBase(QObject *parent = nullptr); 38 | 39 | public: 40 | virtual QWidget* topLevel() const = 0; 41 | }; 42 | 43 | #endif // MBCORE_H 44 | -------------------------------------------------------------------------------- /src/core/sdk/mbcore_binaryreader.cpp: -------------------------------------------------------------------------------- 1 | #include "mbcore_binaryreader.h" 2 | 3 | mbCoreBinaryReader::mbCoreBinaryReader() 4 | { 5 | m_i = 0; 6 | } 7 | 8 | mbCoreBinaryReader::mbCoreBinaryReader(const QByteArray &v) 9 | { 10 | setData(v); 11 | } 12 | 13 | void mbCoreBinaryReader::setData(const QByteArray &v) 14 | { 15 | m_data = v; 16 | m_i = 0; 17 | } 18 | 19 | bool mbCoreBinaryReader::read(int &v) 20 | { 21 | if ((sizeof(v) + m_i) <= m_data.size()) 22 | { 23 | v = *reinterpret_cast(m_data.data()+m_i); 24 | m_i += sizeof(v); 25 | return true; 26 | } 27 | return false;; 28 | } 29 | 30 | bool mbCoreBinaryReader::read(QRect &v) 31 | { 32 | int x, y, w, h; 33 | if (read(x) && read(y) && read(w) && read(h)) 34 | { 35 | v.setRect(x, y, w, h); 36 | return true; 37 | } 38 | return false; 39 | } 40 | 41 | bool mbCoreBinaryReader::read(QByteArray &v) 42 | { 43 | int sz; 44 | if (read(sz) && ((sz + m_i) <= m_data.size())) 45 | { 46 | v = m_data.mid(m_i, sz); 47 | m_i += sz; 48 | return true; 49 | } 50 | return false; 51 | } 52 | 53 | bool mbCoreBinaryReader::read(QString &v) 54 | { 55 | QByteArray s; 56 | if (read(s)) 57 | { 58 | v = QString::fromUtf8(s); 59 | return true; 60 | } 61 | return false; 62 | } 63 | -------------------------------------------------------------------------------- /src/core/sdk/mbcore_binaryreader.h: -------------------------------------------------------------------------------- 1 | #ifndef MBCORE_BINARYREADER_H 2 | #define MBCORE_BINARYREADER_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class mbCoreBinaryReader 9 | { 10 | public: 11 | mbCoreBinaryReader(); 12 | mbCoreBinaryReader(const QByteArray &v); 13 | 14 | public: 15 | inline QByteArray data() const { return m_data; } 16 | void setData(const QByteArray &v); 17 | inline bool isProcessing() const { return m_i < m_data.size(); } 18 | inline bool isEnd() const { return m_i >= m_data.size(); } 19 | 20 | public: 21 | bool read(int &v); 22 | bool read(QRect &v); 23 | bool read(QByteArray &v); 24 | bool read(QString &v); 25 | 26 | private: 27 | QByteArray m_data; 28 | int m_i; 29 | }; 30 | 31 | #endif // MBCORE_BINARYREADER_H 32 | -------------------------------------------------------------------------------- /src/core/sdk/mbcore_binarywriter.cpp: -------------------------------------------------------------------------------- 1 | #include "mbcore_binarywriter.h" 2 | 3 | mbCoreBinaryWriter::mbCoreBinaryWriter() 4 | { 5 | 6 | } 7 | 8 | void mbCoreBinaryWriter::write(int v) 9 | { 10 | m_data.append(reinterpret_cast(&v), sizeof(v)); 11 | } 12 | 13 | void mbCoreBinaryWriter::write(const QRect &v) 14 | { 15 | write(v.x()); 16 | write(v.y()); 17 | write(v.width()); 18 | write(v.height()); 19 | } 20 | 21 | void mbCoreBinaryWriter::write(const QByteArray &v) 22 | { 23 | write(v.size()); 24 | m_data.append(v); 25 | } 26 | 27 | void mbCoreBinaryWriter::write(const QString &v) 28 | { 29 | write(v.toUtf8()); 30 | } 31 | -------------------------------------------------------------------------------- /src/core/sdk/mbcore_binarywriter.h: -------------------------------------------------------------------------------- 1 | #ifndef MBCOREBINARYWRITER_H 2 | #define MBCOREBINARYWRITER_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class mbCoreBinaryWriter 9 | { 10 | public: 11 | mbCoreBinaryWriter(); 12 | 13 | public: 14 | inline QByteArray data() const { return m_data; } 15 | 16 | public: 17 | void write(int v); 18 | void write(const QRect &v); 19 | void write(const QByteArray &v); 20 | void write(const QString &v); 21 | 22 | private: 23 | QByteArray m_data; 24 | }; 25 | 26 | #endif // MBCOREBINARYWRITER_H 27 | -------------------------------------------------------------------------------- /src/core/sdk/mbcore_config.h: -------------------------------------------------------------------------------- 1 | #ifndef MBCORE_CONFIG_H 2 | #define MBCORE_CONFIG_H 3 | 4 | /* 5 | Major part of mbtools version 6 | */ 7 | #define MBTOOLS_VERSION_MAJOR 0 8 | 9 | /* 10 | Minor part of mbtools version 11 | */ 12 | #define MBTOOLS_VERSION_MINOR 4 13 | 14 | /* 15 | Patch part of mbtools version 16 | */ 17 | #define MBTOOLS_VERSION_PATCH 4 18 | 19 | #endif // MBCORE_CONFIG_H 20 | -------------------------------------------------------------------------------- /src/core/sdk/mbcore_task.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef MBCORE_TASK_H 24 | #define MBCORE_TASK_H 25 | 26 | #include 27 | 28 | #include "mbcore.h" 29 | 30 | class MB_EXPORT mbCoreTask : public QObject 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | mbCoreTask(QObject* parent = nullptr) : QObject(parent) {} 36 | 37 | public: // task interface 38 | virtual int init() = 0; 39 | virtual int loop() = 0; 40 | virtual int final() = 0; 41 | }; 42 | 43 | 44 | #endif // MBCORE_TASK_H 45 | -------------------------------------------------------------------------------- /src/core/sdk/mbcore_taskfactory.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef MBCORE_TASKFACTORY_H 24 | #define MBCORE_TASKFACTORY_H 25 | 26 | #include 27 | 28 | #include "mbcore.h" 29 | 30 | class mbCoreBase; 31 | class mbCoreTask; 32 | 33 | class mbCoreTaskFactory 34 | { 35 | public: 36 | virtual ~mbCoreTaskFactory() {} 37 | 38 | public: 39 | virtual void initialize(mbCoreBase *core) = 0; 40 | virtual mbCoreTask *createTask(const MBSETTINGS& params, QObject *parent = nullptr) = 0; 41 | virtual bool getTaskParams(MBSETTINGS ¶ms, const QString &title = QString()) = 0; 42 | virtual QString paramsToString(const MBSETTINGS ¶ms) const = 0; 43 | virtual MBSETTINGS stringToParams(const QString ¶msString) const = 0; 44 | virtual bool canConvertStringToParams() const = 0; 45 | }; 46 | Q_DECLARE_INTERFACE(mbCoreTaskFactory, "mbtools.Core.TaskFactory.Interface") 47 | 48 | #endif // MBCORE_TASKFACTORY_H 49 | -------------------------------------------------------------------------------- /src/core/sdk/sdk.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/mbcore_binaryreader.h \ 3 | $$PWD/mbcore_binarywriter.h \ 4 | $$PWD/mbcore_config.h \ 5 | $$PWD/mbcore.h \ 6 | $$PWD/mbcore_base.h \ 7 | $$PWD/mbcore_sharedpointer.h \ 8 | $$PWD/mbcore_task.h \ 9 | $$PWD/mbcore_taskfactory.h 10 | 11 | SOURCES += \ 12 | $$PWD/mbcore.cpp \ 13 | $$PWD/mbcore_base.cpp \ 14 | $$PWD/mbcore_binaryreader.cpp \ 15 | $$PWD/mbcore_binarywriter.cpp 16 | 17 | -------------------------------------------------------------------------------- /src/core/task/core_taskfactoryinfo.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #include "core_taskfactoryinfo.h" 24 | 25 | const QString c_defaultTaskFactoryName = QStringLiteral("task"); 26 | 27 | mbCoreTaskFactoryInfo::mbCoreTaskFactoryInfo(mbCoreTaskFactory* taskFactory) 28 | { 29 | m_taskFactory = taskFactory; 30 | m_isPlugin = false; 31 | } 32 | 33 | mbCoreTaskFactoryInfo::~mbCoreTaskFactoryInfo() 34 | { 35 | } 36 | -------------------------------------------------------------------------------- /src/core/task/core_taskfactoryinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef CORE_TASKFACTORYINFO_H 24 | #define CORE_TASKFACTORYINFO_H 25 | 26 | #include 27 | 28 | class mbCore; 29 | class mbCoreTaskFactory; 30 | 31 | class mbCoreTaskFactoryInfo 32 | { 33 | public: 34 | mbCoreTaskFactoryInfo(mbCoreTaskFactory* taskFactory); 35 | ~mbCoreTaskFactoryInfo(); 36 | 37 | public: 38 | inline mbCoreTaskFactory* taskFactory() const { return m_taskFactory; } 39 | inline QString name() const { return m_name; } 40 | inline bool isPlugin() const { return m_isPlugin; } 41 | inline QString absoluteFilePath() const { return m_absoluteFilePath; } 42 | 43 | private: 44 | inline void setName(const QString& name) { m_name = name; } 45 | inline void setIsPlugin(bool isPlugin) { m_isPlugin = isPlugin; } 46 | inline void setAbsoluteFilePath(const QString& absoluteFilePath) { m_absoluteFilePath = absoluteFilePath; } 47 | 48 | private: 49 | friend class mbCore; 50 | 51 | mbCoreTaskFactory* m_taskFactory; 52 | QString m_name; 53 | QString m_absoluteFilePath; 54 | bool m_isPlugin; 55 | }; 56 | 57 | #endif // CORE_TASKFACTORYINFO_H 58 | -------------------------------------------------------------------------------- /src/core/task/task.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/core_taskfactoryinfo.h 3 | 4 | SOURCES += \ 5 | $$PWD/core_taskfactoryinfo.cpp 6 | -------------------------------------------------------------------------------- /src/core/win_resource.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | 5 | VS_VERSION_INFO VERSIONINFO 6 | FILEVERSION 0,4,4,0 7 | PRODUCTVERSION 0,4,4,0 8 | FILEFLAGSMASK 0x3fL 9 | #ifdef _DEBUG 10 | FILEFLAGS VS_FF_DEBUG 11 | #else 12 | FILEFLAGS 0x0L 13 | #endif 14 | FILEOS VOS__WINDOWS32 15 | FILETYPE VFT_DLL 16 | FILESUBTYPE 0x0L 17 | BEGIN 18 | BLOCK "StringFileInfo" 19 | BEGIN 20 | BLOCK "040904b0" 21 | BEGIN 22 | VALUE "CompanyName", "\0" 23 | VALUE "FileDescription", "\0" 24 | VALUE "FileVersion", "0.4.4.0\0" 25 | VALUE "LegalCopyright", "\0" 26 | VALUE "OriginalFilename", "core.dll\0" 27 | VALUE "ProductName", "core\0" 28 | VALUE "ProductVersion", "0.4.4.0\0" 29 | END 30 | END 31 | BLOCK "VarFileInfo" 32 | BEGIN 33 | VALUE "Translation", 0x0409, 1200 34 | END 35 | END 36 | /* End of Version info */ 37 | 38 | -------------------------------------------------------------------------------- /src/server/core/core.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/server.h \ 3 | $$PWD/server_global.h 4 | 5 | SOURCES += \ 6 | $$PWD/server.cpp 7 | -------------------------------------------------------------------------------- /src/server/core/server_global.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef SERVER_GLOBAL_H 24 | #define SERVER_GLOBAL_H 25 | 26 | #include 27 | #include 28 | 29 | namespace mb { 30 | 31 | } // namespace mb 32 | 33 | #endif // SERVER_GLOBAL_H 34 | -------------------------------------------------------------------------------- /src/server/gui/dataview/dataview.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/server_dataviewdelegate.h \ 3 | $$PWD/server_dataviewmanager.h \ 4 | $$PWD/server_dataviewmodel.h \ 5 | $$PWD/server_dataviewui.h 6 | 7 | SOURCES += \ 8 | $$PWD/server_dataviewdelegate.cpp \ 9 | $$PWD/server_dataviewmanager.cpp \ 10 | $$PWD/server_dataviewmodel.cpp \ 11 | $$PWD/server_dataviewui.cpp 12 | -------------------------------------------------------------------------------- /src/server/gui/dataview/server_dataviewdelegate.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #include "server_dataviewdelegate.h" 24 | 25 | mbServerDataViewDelegate::mbServerDataViewDelegate(QObject *parent) : 26 | mbCoreDataViewDelegate(parent) 27 | { 28 | } 29 | -------------------------------------------------------------------------------- /src/server/gui/dataview/server_dataviewdelegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef SERVER_DATAVIEWDELEGATE_H 24 | #define SERVER_DATAVIEWDELEGATE_H 25 | 26 | #include 27 | 28 | class mbServerDataViewDelegate : public mbCoreDataViewDelegate 29 | { 30 | Q_OBJECT 31 | public: 32 | mbServerDataViewDelegate(QObject *parent = nullptr); 33 | }; 34 | 35 | 36 | #endif // SERVER_DATAVIEWDELEGATE_H 37 | -------------------------------------------------------------------------------- /src/server/gui/dataview/server_dataviewmanager.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #include "server_dataviewmanager.h" 24 | 25 | #include "server_dataviewui.h" 26 | #include 27 | #include 28 | 29 | mbServerDataViewManager::mbServerDataViewManager(QObject *parent) : 30 | mbCoreDataViewManager(parent) 31 | { 32 | } 33 | 34 | mbCoreDataViewUi *mbServerDataViewManager::createDataViewUi(mbCoreDataView *dataView) 35 | { 36 | return new mbServerDataViewUi(static_cast(dataView)); 37 | } 38 | -------------------------------------------------------------------------------- /src/server/gui/dataview/server_dataviewmodel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #include "server_dataviewmodel.h" 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | mbServerDataViewModel::mbServerDataViewModel(mbServerDataView *dataView, QObject *parent) : 31 | mbCoreDataViewModel(dataView, parent) 32 | { 33 | } 34 | 35 | mbServerDataViewModel::~mbServerDataViewModel() 36 | { 37 | } 38 | 39 | void mbServerDataViewModel::refreshValues() 40 | { 41 | int Column_Value = dataView()->getColumnIndexByType(mbServerDataView::Value); 42 | if (Column_Value >= 0) 43 | Q_EMIT dataChanged(createIndex(0, Column_Value), createIndex(rowCount()-1, Column_Value)); 44 | } 45 | -------------------------------------------------------------------------------- /src/server/gui/dataview/server_dataviewmodel.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef SERVER_DATAVIEWMODEL_H 24 | #define SERVER_DATAVIEWMODEL_H 25 | 26 | #include 27 | 28 | class mbServerDataView; 29 | class mbServerDataViewItem; 30 | 31 | class mbServerDataViewModel : public mbCoreDataViewModel 32 | { 33 | Q_OBJECT 34 | public: 35 | mbServerDataViewModel(mbServerDataView *dataView, QObject* parent = nullptr); 36 | ~mbServerDataViewModel(); 37 | 38 | public: 39 | inline mbServerDataView *dataView() const { return reinterpret_cast(dataViewCore()); } 40 | inline mbServerDataViewItem *item(const QModelIndex &index) const { return reinterpret_cast(itemCore(index)); } 41 | 42 | public: 43 | void refreshValues(); 44 | }; 45 | 46 | #endif // SERVER_DATAVIEWMODEL_H 47 | -------------------------------------------------------------------------------- /src/server/gui/dataview/server_dataviewui.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef SERVER_DATAVIEWUI_H 24 | #define SERVER_DATAVIEWUI_H 25 | 26 | #include 27 | 28 | class QTableView; 29 | class mbServerDataView; 30 | class mbServerDataViewItem; 31 | class mbServerDataViewModel; 32 | class mbServerDataViewDelegate; 33 | 34 | class mbServerDataViewUi : public mbCoreDataViewUi 35 | { 36 | Q_OBJECT 37 | public: 38 | mbServerDataViewUi(mbServerDataView *dataView, QWidget *parent = nullptr); 39 | 40 | public: // QWidget 41 | 42 | public: 43 | inline bool isScanning() const { return m_timerId > 0; } 44 | inline mbServerDataView *dataView() const { return reinterpret_cast(dataViewCore()); } 45 | inline mbServerDataViewModel *model() const { return reinterpret_cast(modelCore()); } 46 | QList selectedItems() const; 47 | 48 | protected Q_SLOTS: 49 | void changePeriod(int period); 50 | 51 | private: 52 | bool event(QEvent *event) override; 53 | 54 | private: 55 | void startScanning(int period); 56 | void stopScanning(); 57 | 58 | private: 59 | int m_timerId; 60 | }; 61 | 62 | #endif // SERVER_DATAVIEWUI_H 63 | -------------------------------------------------------------------------------- /src/server/gui/device/device.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/server_devicemanager.h \ 3 | $$PWD/server_deviceui.h \ 4 | $$PWD/server_deviceuidelegate.h \ 5 | $$PWD/server_deviceuimodel.h 6 | 7 | SOURCES += \ 8 | $$PWD/server_devicemanager.cpp \ 9 | $$PWD/server_deviceui.cpp \ 10 | $$PWD/server_deviceuidelegate.cpp \ 11 | $$PWD/server_deviceuimodel.cpp 12 | 13 | FORMS += \ 14 | $$PWD/server_deviceui.ui 15 | -------------------------------------------------------------------------------- /src/server/gui/device/server_deviceuidelegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef SERVER_DEVICEUIDELEGATE_H 24 | #define SERVER_DEVICEUIDELEGATE_H 25 | 26 | #include 27 | 28 | class mbServerDeviceUiDelegate : public QStyledItemDelegate 29 | { 30 | public: 31 | mbServerDeviceUiDelegate(QObject *parent = nullptr); 32 | 33 | public: 34 | virtual QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override; 35 | virtual void setEditorData(QWidget *editor, const QModelIndex &index) const override; 36 | }; 37 | 38 | class mbServerDeviceUiDelegateBool : public mbServerDeviceUiDelegate 39 | { 40 | public: 41 | mbServerDeviceUiDelegateBool(QObject *parent = nullptr); 42 | 43 | public: 44 | bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override; 45 | }; 46 | 47 | #endif // SERVER_DEVICEUIDELEGATE_H 48 | -------------------------------------------------------------------------------- /src/server/gui/dialogs/dialogs.pri: -------------------------------------------------------------------------------- 1 | include(settings/settings.pri) 2 | 3 | HEADERS += \ 4 | $$PWD/server_dialogdevice.h \ 5 | $$PWD/server_dialogport.h \ 6 | $$PWD/server_dialogs.h \ 7 | $$PWD/server_dialogdataviewitem.h \ 8 | $$PWD/server_dialogsimaction.h \ 9 | $$PWD/server_dialogscriptmodule.h 10 | #$$PWD/server_dialogtask.h \ 11 | 12 | SOURCES += \ 13 | $$PWD/server_dialogdevice.cpp \ 14 | $$PWD/server_dialogport.cpp \ 15 | $$PWD/server_dialogs.cpp \ 16 | $$PWD/server_dialogdataviewitem.cpp \ 17 | $$PWD/server_dialogsimaction.cpp \ 18 | $$PWD/server_dialogscriptmodule.cpp 19 | #$$PWD/server_dialogtask.cpp \ 20 | 21 | FORMS += \ 22 | $$PWD/server_dialogdevice.ui \ 23 | $$PWD/server_dialogport.ui \ 24 | $$PWD/server_dialogdataviewitem.ui \ 25 | $$PWD/server_dialogsimaction.ui \ 26 | $$PWD/server_dialogscriptmodule.ui 27 | #$$PWD/server_dialogtask.ui \ 28 | -------------------------------------------------------------------------------- /src/server/gui/dialogs/server_dialogdataviewitem.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef SERVER_DIALOGDATAVIEWITEM_H 24 | #define SERVER_DIALOGDATAVIEWITEM_H 25 | 26 | #include 27 | 28 | class mbServerDevice; 29 | 30 | namespace Ui { 31 | class mbServerDialogDataViewItem; 32 | } 33 | 34 | class mbServerDialogDataViewItem : public mbCoreDialogDataViewItem 35 | { 36 | Q_OBJECT 37 | public: 38 | explicit mbServerDialogDataViewItem(QWidget *parent = nullptr); 39 | ~mbServerDialogDataViewItem(); 40 | 41 | private: 42 | Ui::mbServerDialogDataViewItem *ui; 43 | }; 44 | 45 | #endif // SERVER_DIALOGDATAVIEWITEM_H 46 | -------------------------------------------------------------------------------- /src/server/gui/dialogs/server_dialogport.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef SERVER_DIALOGPORT_H 24 | #define SERVER_DIALOGPORT_H 25 | 26 | #include 27 | 28 | class mbServerPort; 29 | 30 | namespace Ui { 31 | class mbServerDialogPort; 32 | } 33 | 34 | class mbServerDialogPort : public mbCoreDialogPort 35 | { 36 | Q_OBJECT 37 | 38 | public: 39 | explicit mbServerDialogPort(QWidget *parent = nullptr); 40 | ~mbServerDialogPort(); 41 | 42 | public: 43 | MBSETTINGS cachedSettings() const override; 44 | void setCachedSettings(const MBSETTINGS &settings) override; 45 | 46 | private: 47 | void fillFormInner(const MBSETTINGS &settings) override; 48 | void fillDataInner(MBSETTINGS &settings) const override; 49 | 50 | private: 51 | Ui::mbServerDialogPort *ui; 52 | }; 53 | 54 | #endif // SERVER_DIALOGPORT_H 55 | -------------------------------------------------------------------------------- /src/server/gui/dialogs/server_dialogs.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef SERVER_DIALOGS_H 24 | #define SERVER_DIALOGS_H 25 | 26 | #include 27 | #include 28 | 29 | class mbServer; 30 | class mbServerDialogProject; 31 | class mbServerDialogPort; 32 | class mbServerDialogDevice; 33 | class mbServerDialogDataView; 34 | class mbServerDialogDataViewItem; 35 | class mbServerDialogSimAction; 36 | class mbServerDialogScriptModule; 37 | 38 | class mbServerDialogs : public mbCoreDialogs 39 | { 40 | public: 41 | mbServerDialogs(QWidget *parent = nullptr); 42 | ~mbServerDialogs(); 43 | 44 | public: 45 | MBSETTINGS cachedSettings() const override; 46 | void setCachedSettings(const MBSETTINGS &settings) override; 47 | 48 | public: 49 | MBSETTINGS getSimAction(const MBSETTINGS &settings, const QString &title = QString()); 50 | MBSETTINGS getScriptModule(const MBSETTINGS &settings, const QString &title = QString()); 51 | 52 | private: 53 | mbServerDialogSimAction *m_simaction; 54 | mbServerDialogScriptModule *m_scriptModule; 55 | }; 56 | 57 | #endif // SERVER_DIALOGS_H 58 | -------------------------------------------------------------------------------- /src/server/gui/dialogs/server_dialogscriptmodule.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef SERVER_DIALOGSCRIPTMODULE_H 24 | #define SERVER_DIALOGSCRIPTMODULE_H 25 | 26 | #include 27 | 28 | namespace Ui { 29 | class mbServerDialogScriptModule; 30 | } 31 | 32 | class mbServerDialogScriptModule : public mbCoreDialogEdit 33 | { 34 | Q_OBJECT 35 | 36 | public: 37 | struct Strings : public mbCoreDialogEdit::Strings 38 | { 39 | const QString title; 40 | const QString cachePrefix; 41 | Strings(); 42 | static const Strings &instance(); 43 | }; 44 | 45 | public: 46 | mbServerDialogScriptModule(QWidget *parent = nullptr); 47 | ~mbServerDialogScriptModule(); 48 | 49 | public: 50 | MBSETTINGS cachedSettings() const override; 51 | void setCachedSettings(const MBSETTINGS &settings) override; 52 | 53 | public: 54 | MBSETTINGS getSettings(const MBSETTINGS &settings, const QString &title = QString()) override; 55 | 56 | private: 57 | void fillForm(const MBSETTINGS &settings); 58 | void fillData(MBSETTINGS &settings); 59 | 60 | private: 61 | Ui::mbServerDialogScriptModule *ui; 62 | }; 63 | 64 | #endif // SERVER_DIALOGSCRIPTMODULE_H 65 | -------------------------------------------------------------------------------- /src/server/gui/dialogs/server_dialogscriptmodule.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | mbServerDialogScriptModule 4 | 5 | 6 | 7 | 0 8 | 0 9 | 375 10 | 268 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 20 | Name 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | QFrame::NoFrame 31 | 32 | 33 | QFrame::Plain 34 | 35 | 36 | Comment 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | Qt::Horizontal 47 | 48 | 49 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/server/gui/dialogs/server_dialogtask.cpp: -------------------------------------------------------------------------------- 1 | #include "server_dialogtask.h" 2 | #include "ui_server_taskdialog.h" 3 | 4 | #include 5 | #include 6 | 7 | mbServerDialogTask::Strings::Strings() : 8 | title(QStringLiteral("Data")) 9 | { 10 | } 11 | 12 | const mbServerDialogTask::Strings &mbServerDialogTask::Strings::instance() 13 | { 14 | static const Strings s; 15 | return s; 16 | } 17 | 18 | mbServerDialogTask::mbServerDialogTask(mbServer* core, QWidget *parent) : QDialog(parent), 19 | ui(new Ui::mbServerDialogTask) 20 | { 21 | ui->setupUi(this); 22 | 23 | m_core = core; 24 | } 25 | 26 | mbServerDialogTask::~mbServerDialogTask() 27 | { 28 | delete ui; 29 | } 30 | 31 | bool mbServerDialogTask::getData(mbServerDialogTask::Data &data, const QString &title) 32 | { 33 | if (title.isEmpty()) 34 | setWindowTitle(Strings::instance().title); 35 | else 36 | setWindowTitle(title); 37 | // fill 'Type'-combobox 38 | QComboBox* cmb = ui->cmbType; 39 | cmb->clear(); 40 | Q_FOREACH (const mbCoreTaskFactoryInfo* f, m_core->taskFactories()) 41 | cmb->addItem(f->name()); 42 | if (data.type.length()) // type is not empty string 43 | { 44 | ui->lnName->setText(data.name); 45 | cmb->setCurrentText(data.type); 46 | } 47 | // ---------------------- 48 | switch (QDialog::exec()) 49 | { 50 | case QDialog::Accepted: 51 | data.name = ui->lnName->text(); 52 | data.type = cmb->currentText(); 53 | return true; 54 | default: 55 | return false; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/server/gui/dialogs/server_dialogtask.h: -------------------------------------------------------------------------------- 1 | #ifndef SERVER_DIALOGTASK_H 2 | #define SERVER_DIALOGTASK_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class mbServerDialogTask; 8 | } 9 | 10 | class mbServer; 11 | 12 | class mbServerDialogTask : public QDialog 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | struct Strings 18 | { 19 | const QString title; 20 | Strings(); 21 | static const Strings &instance(); 22 | }; 23 | 24 | struct Data 25 | { 26 | QString name; 27 | QString type; 28 | }; 29 | 30 | public: 31 | explicit mbServerDialogTask(mbServer *core, QWidget *parent = nullptr); 32 | ~mbServerDialogTask(); 33 | 34 | public: 35 | bool getData(Data &data, const QString &title = QString()); 36 | 37 | private: 38 | Ui::mbServerDialogTask *ui; 39 | mbServer* m_core; 40 | }; 41 | 42 | #endif // SERVER_DIALOGTASK_H 43 | -------------------------------------------------------------------------------- /src/server/gui/dialogs/settings/server_delegatesettingsscripteditorcolors.cpp: -------------------------------------------------------------------------------- 1 | #include "server_delegatesettingsscripteditorcolors.h" 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | mbServerDelegateSettingsScriptEditorColors::mbServerDelegateSettingsScriptEditorColors(QObject *parent) 10 | : QStyledItemDelegate{parent} 11 | { 12 | } 13 | 14 | bool mbServerDelegateSettingsScriptEditorColors::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) 15 | { 16 | switch (event->type()) 17 | { 18 | case QEvent::MouseButtonDblClick: 19 | { 20 | mbServerUi *ui = mbServer::global()->ui(); 21 | QColor color1 = model->data(index, Qt::BackgroundRole).value(); 22 | QColor color2 = ui->dialogs()->getColor(color1, ui, "Color"); 23 | if (color2.isValid()) 24 | model->setData(index, QVariant::fromValue(color2), Qt::BackgroundRole); 25 | } 26 | return true; 27 | default: 28 | return QStyledItemDelegate::editorEvent(event, model, option, index); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/server/gui/dialogs/settings/server_delegatesettingsscripteditorcolors.h: -------------------------------------------------------------------------------- 1 | #ifndef MBSERVERDELEGATESETTINGSSCRIPTEDITORCOLORS_H 2 | #define MBSERVERDELEGATESETTINGSSCRIPTEDITORCOLORS_H 3 | 4 | #include 5 | 6 | class mbServerDelegateSettingsScriptEditorColors : public QStyledItemDelegate 7 | { 8 | public: 9 | explicit mbServerDelegateSettingsScriptEditorColors(QObject *parent = nullptr); 10 | 11 | public: 12 | bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override; 13 | }; 14 | 15 | #endif // MBSERVERDELEGATESETTINGSSCRIPTEDITORCOLORS_H 16 | -------------------------------------------------------------------------------- /src/server/gui/dialogs/settings/server_dialogsettings.h: -------------------------------------------------------------------------------- 1 | #ifndef SERVER_DIALOGSETTINGS_H 2 | #define SERVER_DIALOGSETTINGS_H 3 | 4 | #include 5 | 6 | class mbServerWidgetSettingsScript; 7 | 8 | class mbServerDialogSettings : public mbCoreDialogSettings 9 | { 10 | Q_OBJECT 11 | 12 | public: 13 | struct Strings : public mbCoreDialogSettings::Strings 14 | { 15 | Strings(); 16 | static const Strings &instance(); 17 | }; 18 | 19 | public: 20 | mbServerDialogSettings(QWidget *parent = nullptr); 21 | 22 | protected: 23 | void fillForm(const MBSETTINGS &m) override; 24 | void fillData(MBSETTINGS &m) override; 25 | 26 | protected: 27 | mbServerWidgetSettingsScript *m_script; 28 | }; 29 | 30 | #endif // SERVER_DIALOGSETTINGS_H 31 | -------------------------------------------------------------------------------- /src/server/gui/dialogs/settings/server_modelsettingsscripteditorcolors.h: -------------------------------------------------------------------------------- 1 | #ifndef MBSERVERMODELSETTINGSSCRIPTEDITORCOLORS_H 2 | #define MBSERVERMODELSETTINGSSCRIPTEDITORCOLORS_H 3 | 4 | #include 5 | 6 | #include 7 | 8 | class mbServerModelSettingsScriptEditorColors : public QAbstractTableModel 9 | { 10 | Q_OBJECT 11 | 12 | public: 13 | struct ColorFormat 14 | { 15 | ColorFormat(mbServerScriptHighlighter::ColorFormatType ftype) : 16 | type(ftype), 17 | name(mbServerScriptHighlighter::toString(ftype)) 18 | {} 19 | mbServerScriptHighlighter::ColorFormatType type; 20 | QString name; 21 | QColor color; 22 | }; 23 | 24 | typedef QList ColorFormats; 25 | 26 | public: 27 | explicit mbServerModelSettingsScriptEditorColors(QObject *parent = nullptr); 28 | 29 | public: // QAbstractItemModel interface 30 | QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; 31 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; 32 | int columnCount(const QModelIndex &parent = QModelIndex()) const override; 33 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 34 | bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; 35 | 36 | public: 37 | mbServerScriptHighlighter::ColorFormats colorFormats() const; 38 | void setColorFormats(const mbServerScriptHighlighter::ColorFormats &f); 39 | 40 | public Q_SLOTS: 41 | void setDefaultEditorColors(); 42 | 43 | private: 44 | ColorFormats m_colorFormats; 45 | }; 46 | 47 | #endif // MBSERVERMODELSETTINGSSCRIPTEDITORCOLORS_H 48 | -------------------------------------------------------------------------------- /src/server/gui/dialogs/settings/settings.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/server_delegatesettingsscripteditorcolors.h \ 3 | $$PWD/server_dialogsettings.h \ 4 | $$PWD/server_modelsettingsscripteditorcolors.h \ 5 | $$PWD/server_modelsettingsscriptinterpreters.h \ 6 | $$PWD/server_widgetsettingsscript.h 7 | 8 | SOURCES += \ 9 | $$PWD/server_delegatesettingsscripteditorcolors.cpp \ 10 | $$PWD/server_dialogsettings.cpp \ 11 | $$PWD/server_modelsettingsscripteditorcolors.cpp \ 12 | $$PWD/server_modelsettingsscriptinterpreters.cpp \ 13 | $$PWD/server_widgetsettingsscript.cpp 14 | 15 | FORMS += \ 16 | $$PWD/server_widgetsettingsscript.ui 17 | -------------------------------------------------------------------------------- /src/server/gui/gui.pri: -------------------------------------------------------------------------------- 1 | include(dialogs/dialogs.pri) 2 | include(project/project.pri) 3 | include(device/device.pri) 4 | include(simactions/simactions.pri) 5 | include(scriptmodules//scriptmodules.pri) 6 | include(dataview/dataview.pri) 7 | include(script/script.pri) 8 | 9 | HEADERS += \ 10 | $$PWD/server_outputview.h \ 11 | $$PWD/server_windowmanager.h \ 12 | $$PWD/server_ui.h \ 13 | 14 | SOURCES += \ 15 | $$PWD/server_outputview.cpp \ 16 | $$PWD/server_windowmanager.cpp \ 17 | $$PWD/server_ui.cpp \ 18 | 19 | FORMS += \ 20 | $$PWD/server_ui.ui 21 | 22 | RESOURCES += \ 23 | $$PWD/server_rsc.qrc 24 | -------------------------------------------------------------------------------- /src/server/gui/icons/greenmark.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/server/gui/icons/greenmark.ico -------------------------------------------------------------------------------- /src/server/gui/icons/minus.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/server/gui/icons/minus.ico -------------------------------------------------------------------------------- /src/server/gui/icons/plus.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/server/gui/icons/plus.ico -------------------------------------------------------------------------------- /src/server/gui/icons/server.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serhmarch/ModbusTools/5fd2939f1698bae879584e277a895bdbd241721c/src/server/gui/icons/server.ico -------------------------------------------------------------------------------- /src/server/gui/project/project.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/server_projectdelegate.h \ 3 | $$PWD/server_projectmodel.h \ 4 | $$PWD/server_projectui.h \ 5 | 6 | SOURCES += \ 7 | $$PWD/server_projectdelegate.cpp\ 8 | $$PWD/server_projectmodel.cpp \ 9 | $$PWD/server_projectui.cpp \ 10 | -------------------------------------------------------------------------------- /src/server/gui/project/server_projectdelegate.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #include "server_projectdelegate.h" 24 | 25 | mbServerProjectDelegate::mbServerProjectDelegate(QObject *parent) 26 | : mbCoreProjectDelegate{parent} 27 | { 28 | } 29 | -------------------------------------------------------------------------------- /src/server/gui/project/server_projectdelegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef SERVER_PROJECTDELEGATE_H 24 | #define SERVER_PROJECTDELEGATE_H 25 | 26 | #include 27 | 28 | class mbServerProjectDelegate : public mbCoreProjectDelegate 29 | { 30 | Q_OBJECT 31 | public: 32 | explicit mbServerProjectDelegate(QObject *parent = nullptr); 33 | }; 34 | 35 | #endif // SERVER_PROJECTDELEGATE_H 36 | -------------------------------------------------------------------------------- /src/server/gui/script/editor/editor.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/server_scripthighlighter.h \ 3 | $$PWD/server_scripteditor.h 4 | 5 | SOURCES += \ 6 | $$PWD/server_scripthighlighter.cpp \ 7 | $$PWD/server_scripteditor.cpp 8 | -------------------------------------------------------------------------------- /src/server/gui/script/script.pri: -------------------------------------------------------------------------------- 1 | include(editor/editor.pri) 2 | 3 | HEADERS += \ 4 | $$PWD/server_basescripteditor.h \ 5 | $$PWD/server_devicescripteditor.h \ 6 | $$PWD/server_scriptmoduleeditor.h \ 7 | $$PWD/server_scriptmanager.h 8 | 9 | SOURCES += \ 10 | $$PWD/server_basescripteditor.cpp \ 11 | $$PWD/server_devicescripteditor.cpp \ 12 | $$PWD/server_scriptmoduleeditor.cpp \ 13 | $$PWD/server_scriptmanager.cpp 14 | -------------------------------------------------------------------------------- /src/server/gui/script/server_basescripteditor.cpp: -------------------------------------------------------------------------------- 1 | #include "server_basescripteditor.h" 2 | 3 | mbServerBaseScriptEditor::mbServerBaseScriptEditor(const Settings settings, QWidget *parent) : mbServerScriptEditor(settings, parent) 4 | { 5 | 6 | } 7 | 8 | void mbServerBaseScriptEditor::changeName(const QString &newName) 9 | { 10 | Q_EMIT nameChanged(getName(newName)); 11 | } 12 | 13 | -------------------------------------------------------------------------------- /src/server/gui/script/server_basescripteditor.h: -------------------------------------------------------------------------------- 1 | #ifndef SERVER_BASESCRIPTEDITOR_H 2 | #define SERVER_BASESCRIPTEDITOR_H 3 | 4 | #include "editor/server_scripteditor.h" 5 | 6 | class mbServerBaseScriptEditor : public mbServerScriptEditor 7 | { 8 | Q_OBJECT 9 | 10 | public: 11 | mbServerBaseScriptEditor(const mbServerScriptEditor::Settings settings, 12 | QWidget *parent = nullptr); 13 | public: 14 | virtual QString name() const = 0; 15 | 16 | Q_SIGNALS: 17 | void nameChanged(const QString& newName); 18 | 19 | protected Q_SLOTS: 20 | void changeName(const QString& newName); 21 | 22 | protected: 23 | virtual QString getName(const QString& deviceName) const = 0; 24 | }; 25 | 26 | #endif // SERVER_BASESCRIPTEDITOR_H 27 | -------------------------------------------------------------------------------- /src/server/gui/script/server_devicescripteditor.cpp: -------------------------------------------------------------------------------- 1 | #include "server_devicescripteditor.h" 2 | 3 | mbServerDeviceScriptEditor::mbServerDeviceScriptEditor(mbServerDevice *device, 4 | mbServerDevice::ScriptType scriptType, 5 | const mbServerScriptEditor::Settings settings, 6 | QWidget *parent) : 7 | mbServerBaseScriptEditor(settings, parent), m_device(device), 8 | m_scriptType(scriptType) 9 | { 10 | connect(m_device, &mbServerDevice::nameChanged, this, &mbServerDeviceScriptEditor::changeName); 11 | } 12 | 13 | QString mbServerDeviceScriptEditor::name() const 14 | { 15 | return getName(m_device->name()); 16 | } 17 | 18 | void mbServerDeviceScriptEditor::synchSourceCode() 19 | { 20 | switch (m_scriptType) 21 | { 22 | case mbServerDevice::Script_Init : m_device->setScriptInit (this->toPlainText()); break; 23 | case mbServerDevice::Script_Loop : m_device->setScriptLoop (this->toPlainText()); break; 24 | case mbServerDevice::Script_Final: m_device->setScriptFinal(this->toPlainText()); break; 25 | } 26 | } 27 | 28 | QString mbServerDeviceScriptEditor::getName(const QString &baseName) const 29 | { 30 | QString sScriptType; 31 | switch (m_scriptType) 32 | { 33 | case mbServerDevice::Script_Init: sScriptType = QStringLiteral(" : ScriptInit" ); break; 34 | case mbServerDevice::Script_Loop: sScriptType = QStringLiteral(" : ScriptLoop" ); break; 35 | case mbServerDevice::Script_Final: sScriptType = QStringLiteral(" : ScriptFinal"); break; 36 | } 37 | return baseName+sScriptType; 38 | } 39 | -------------------------------------------------------------------------------- /src/server/gui/script/server_devicescripteditor.h: -------------------------------------------------------------------------------- 1 | #ifndef SERVER_DEVICESCRIPTEDITOR_H 2 | #define SERVER_DEVICESCRIPTEDITOR_H 3 | 4 | #include "server_basescripteditor.h" 5 | #include 6 | 7 | class mbServerDevice; 8 | 9 | class mbServerDeviceScriptEditor : public mbServerBaseScriptEditor 10 | { 11 | Q_OBJECT 12 | 13 | public: 14 | mbServerDeviceScriptEditor(mbServerDevice *device, 15 | mbServerDevice::ScriptType scriptType, 16 | const mbServerScriptEditor::Settings settings, 17 | QWidget *parent = nullptr); 18 | 19 | public: 20 | inline mbServerDevice *device() const { return m_device; } 21 | inline mbServerDevice::ScriptType scriptType() const { return m_scriptType; } 22 | QString name() const override; 23 | 24 | public Q_SLOTS: 25 | void synchSourceCode(); 26 | 27 | private: 28 | QString getName(const QString& baseName) const override; 29 | 30 | private: 31 | mbServerDevice *m_device; 32 | mbServerDevice::ScriptType m_scriptType; 33 | }; 34 | 35 | #endif // SERVER_DEVICESCRIPTEDITOR_H 36 | -------------------------------------------------------------------------------- /src/server/gui/script/server_scriptmoduleeditor.cpp: -------------------------------------------------------------------------------- 1 | #include "server_scriptmoduleeditor.h" 2 | 3 | mbServerScriptModuleEditor::mbServerScriptModuleEditor(mbServerScriptModule *scriptModule, 4 | const mbServerScriptEditor::Settings settings, 5 | QWidget *parent) : 6 | mbServerBaseScriptEditor(settings, parent), 7 | m_scriptModule(scriptModule) 8 | { 9 | connect(m_scriptModule, &mbServerScriptModule::nameChanged, this, &mbServerScriptModuleEditor::changeName); 10 | connect(m_scriptModule, &mbServerScriptModule::beginToGetSourceCode, this, &mbServerScriptModuleEditor::synchSourceCode); 11 | } 12 | 13 | QString mbServerScriptModuleEditor::name() const 14 | { 15 | return getName(m_scriptModule->name()); 16 | } 17 | 18 | QString mbServerScriptModuleEditor::getName(const QString &baseName) const 19 | { 20 | return baseName+QStringLiteral(" : ScriptModule" ); 21 | } 22 | 23 | void mbServerScriptModuleEditor::synchSourceCode() 24 | { 25 | m_scriptModule->setSourceCode(this->toPlainText()); 26 | } 27 | -------------------------------------------------------------------------------- /src/server/gui/script/server_scriptmoduleeditor.h: -------------------------------------------------------------------------------- 1 | #ifndef SERVER_SCRIPTMODULEEDITOR_H 2 | #define SERVER_SCRIPTMODULEEDITOR_H 3 | 4 | #include "server_basescripteditor.h" 5 | #include 6 | 7 | class mbServerScriptModuleEditor : public mbServerBaseScriptEditor 8 | { 9 | Q_OBJECT 10 | 11 | public: 12 | mbServerScriptModuleEditor(mbServerScriptModule *scriptModule, 13 | const mbServerScriptEditor::Settings settings, 14 | QWidget *parent = nullptr); 15 | 16 | public: 17 | inline mbServerScriptModule *scriptModule() const { return m_scriptModule; } 18 | QString name() const override; 19 | 20 | public Q_SLOTS: 21 | void synchSourceCode(); 22 | 23 | private: 24 | QString getName(const QString& baseName) const override; 25 | 26 | private: 27 | mbServerScriptModule *m_scriptModule; 28 | }; 29 | 30 | #endif // SERVER_SCRIPTMODULEEDITOR_H 31 | -------------------------------------------------------------------------------- /src/server/gui/scriptmodules/scriptmodules.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/server_scriptmodulesdelegate.h \ 3 | $$PWD/server_scriptmodulesmodel.h \ 4 | $$PWD/server_scriptmodulesui.h 5 | 6 | SOURCES += \ 7 | $$PWD/server_scriptmodulesdelegate.cpp \ 8 | $$PWD/server_scriptmodulesmodel.cpp \ 9 | $$PWD/server_scriptmodulesui.cpp 10 | 11 | -------------------------------------------------------------------------------- /src/server/gui/scriptmodules/server_scriptmodulesdelegate.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #include "server_scriptmodulesdelegate.h" 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | #include "server_scriptmodulesmodel.h" 33 | 34 | mbServerScriptModulesDelegate::mbServerScriptModulesDelegate(QObject *parent) 35 | : QStyledItemDelegate{parent} 36 | { 37 | 38 | } 39 | 40 | bool mbServerScriptModulesDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) 41 | { 42 | switch (event->type()) 43 | { 44 | //case QEvent::MouseButtonDblClick: 45 | // Q_EMIT doubleClick(index); 46 | // return true; 47 | case QEvent::ContextMenu: 48 | Q_EMIT contextMenu(index); 49 | return true; 50 | default: 51 | return QStyledItemDelegate::editorEvent(event, model, option, index); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/server/gui/scriptmodules/server_scriptmodulesdelegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef SERVER_SCRIPTMODULESDELEGATE_H 24 | #define SERVER_SCRIPTMODULESDELEGATE_H 25 | 26 | #include 27 | 28 | class mbServerScriptModulesDelegate : public QStyledItemDelegate 29 | { 30 | Q_OBJECT 31 | public: 32 | explicit mbServerScriptModulesDelegate(QObject *parent = nullptr); 33 | 34 | public: 35 | bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override; 36 | 37 | Q_SIGNALS: 38 | void doubleClick(const QModelIndex &index); 39 | void contextMenu(const QModelIndex &index); 40 | }; 41 | 42 | #endif // SERVER_SCRIPTMODULESDELEGATE_H 43 | -------------------------------------------------------------------------------- /src/server/gui/server_outputview.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef SERVER_OUTPUTVIEW_H 24 | #define SERVER_OUTPUTVIEW_H 25 | 26 | #include 27 | #include 28 | 29 | class QPlainTextEdit; 30 | class QToolBar; 31 | 32 | class mbServerOutputView : public QWidget 33 | { 34 | Q_OBJECT 35 | 36 | public: 37 | struct Strings 38 | { 39 | const QString prefix; 40 | const QString font; 41 | Strings(); 42 | static const Strings &instance(); 43 | }; 44 | 45 | struct Defaults 46 | { 47 | const QString font; 48 | Defaults(); 49 | static const Defaults &instance(); 50 | }; 51 | 52 | public: 53 | explicit mbServerOutputView(QWidget *parent = nullptr); 54 | 55 | public: 56 | QString fontString() const; 57 | void setFontString(const QString &font); 58 | 59 | MBSETTINGS cachedSettings() const; 60 | void setCachedSettings(const MBSETTINGS &settings); 61 | 62 | public Q_SLOTS: 63 | void clear(); 64 | void showOutput(const QString& message); 65 | 66 | Q_SIGNALS: 67 | 68 | protected: 69 | QToolBar *m_toolBar; 70 | QPlainTextEdit *m_view; 71 | }; 72 | 73 | #endif // SERVER_OUTPUTVIEW_H 74 | -------------------------------------------------------------------------------- /src/server/gui/server_rsc.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | icons/minus.ico 4 | icons/plus.ico 5 | icons/server.ico 6 | icons/greenmark.ico 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/server/gui/simactions/server_simactionsdelegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef SERVER_SIMACTIONSDELEGATE_H 24 | #define SERVER_SIMACTIONSDELEGATE_H 25 | 26 | #include 27 | 28 | class mbServerSimActionsDelegate : public QStyledItemDelegate 29 | { 30 | Q_OBJECT 31 | public: 32 | explicit mbServerSimActionsDelegate(QObject *parent = nullptr); 33 | 34 | public: 35 | QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override; 36 | void setEditorData(QWidget *editor, const QModelIndex &index) const override; 37 | void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override; 38 | bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override; 39 | 40 | Q_SIGNALS: 41 | void doubleClick(const QModelIndex &index); 42 | void contextMenu(const QModelIndex &index); 43 | }; 44 | 45 | #endif // SERVER_SIMACTIONSDELEGATE_H 46 | -------------------------------------------------------------------------------- /src/server/gui/simactions/simactions.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/server_simactionsdelegate.h \ 3 | $$PWD/server_simactionsmodel.h \ 4 | $$PWD/server_simactionsui.h 5 | 6 | SOURCES += \ 7 | $$PWD/server_simactionsdelegate.cpp \ 8 | $$PWD/server_simactionsmodel.cpp \ 9 | $$PWD/server_simactionsui.cpp 10 | 11 | -------------------------------------------------------------------------------- /src/server/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #include "server.h" 24 | 25 | int main(int argc, char *argv[]) 26 | { 27 | mbServer sys; 28 | return sys.exec(argc, argv); 29 | } 30 | -------------------------------------------------------------------------------- /src/server/project/project.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/server_builder.h \ 3 | $$PWD/server_device.h \ 4 | $$PWD/server_deviceref.h \ 5 | $$PWD/server_dom.h \ 6 | $$PWD/server_port.h \ 7 | $$PWD/server_project.h \ 8 | $$PWD/server_dataview.h \ 9 | $$PWD/server_scriptmodule.h \ 10 | $$PWD/server_simaction.h 11 | 12 | SOURCES += \ 13 | $$PWD/server_builder.cpp \ 14 | $$PWD/server_device.cpp \ 15 | $$PWD/server_deviceref.cpp \ 16 | $$PWD/server_dom.cpp \ 17 | $$PWD/server_port.cpp \ 18 | $$PWD/server_project.cpp \ 19 | $$PWD/server_dataview.cpp \ 20 | $$PWD/server_scriptmodule.cpp \ 21 | $$PWD/server_simaction.cpp 22 | -------------------------------------------------------------------------------- /src/server/project/server_scriptmodule.cpp: -------------------------------------------------------------------------------- 1 | #include "server_scriptmodule.h" 2 | 3 | mbServerScriptModule::Strings::Strings() : 4 | name (QStringLiteral("name")), 5 | comment (QStringLiteral("comment")), 6 | sourceCode(QStringLiteral("sourceCode")) 7 | { 8 | } 9 | 10 | const mbServerScriptModule::Strings &mbServerScriptModule::Strings::instance() 11 | { 12 | static const Strings s; 13 | return s; 14 | } 15 | 16 | mbServerScriptModule::Defaults::Defaults() : 17 | name(QStringLiteral("module")) 18 | { 19 | } 20 | 21 | const mbServerScriptModule::Defaults &mbServerScriptModule::Defaults::instance() 22 | { 23 | static const Defaults d; 24 | return d; 25 | } 26 | 27 | 28 | mbServerScriptModule::mbServerScriptModule(QObject *parent) 29 | : QObject{parent} 30 | { 31 | 32 | } 33 | 34 | QString mbServerScriptModule::getSourceCode() 35 | { 36 | Q_EMIT beginToGetSourceCode(); 37 | return sourceCode(); 38 | } 39 | 40 | MBSETTINGS mbServerScriptModule::settings() const 41 | { 42 | const auto &s = Strings::instance(); 43 | MBSETTINGS res; 44 | res[s.name ] = name (); 45 | res[s.comment ] = comment (); 46 | res[s.sourceCode] = sourceCode(); 47 | return res; 48 | } 49 | 50 | void mbServerScriptModule::setSettings(const MBSETTINGS &settings) 51 | { 52 | const Strings &s = Strings::instance(); 53 | 54 | MBSETTINGS::const_iterator it; 55 | MBSETTINGS::const_iterator end = settings.end(); 56 | 57 | it = settings.find(s.name); 58 | if (it != end) 59 | { 60 | QString v = it.value().toString(); 61 | setName(v); 62 | } 63 | 64 | it = settings.find(s.comment); 65 | if (it != end) 66 | { 67 | QString v = it.value().toString(); 68 | setComment(v); 69 | } 70 | 71 | it = settings.find(s.sourceCode); 72 | if (it != end) 73 | { 74 | QString v = it.value().toString(); 75 | setSourceCode(v); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/server/project/server_scriptmodule.h: -------------------------------------------------------------------------------- 1 | #ifndef SERVER_SCRIPTMODULE_H 2 | #define SERVER_SCRIPTMODULE_H 3 | 4 | #include 5 | 6 | #include 7 | 8 | class mbServerScriptModule : public QObject 9 | { 10 | Q_OBJECT 11 | 12 | public: 13 | struct Strings 14 | { 15 | const QString name ; 16 | const QString comment ; 17 | const QString sourceCode; 18 | 19 | Strings(); 20 | static const Strings &instance(); 21 | }; 22 | 23 | public: 24 | struct Defaults 25 | { 26 | const QString name; 27 | 28 | Defaults(); 29 | static const Defaults &instance(); 30 | }; 31 | 32 | public: 33 | explicit mbServerScriptModule(QObject *parent = nullptr); 34 | 35 | public: // project 36 | inline QString name() const { return objectName(); } 37 | inline void setName(const QString& name) { setObjectName(name); Q_EMIT nameChanged(name); Q_EMIT changed(); } 38 | inline QString fileName() const { return name()+".py"; } 39 | inline QString comment() const { return m_comment; } 40 | inline void setComment(const QString& comment) { m_comment = comment; Q_EMIT changed(); } 41 | inline QString sourceCode() const { return m_code; } 42 | inline void setSourceCode(const QString& code) { m_code = code; } 43 | QString getSourceCode(); 44 | 45 | MBSETTINGS settings() const; 46 | void setSettings(const MBSETTINGS &settings); 47 | 48 | Q_SIGNALS: 49 | void nameChanged(const QString& newName); 50 | void changed(); 51 | void beginToGetSourceCode(); 52 | 53 | protected: 54 | QString m_comment; 55 | QString m_code; 56 | }; 57 | 58 | #endif // MBSERVERSCRIPTMODULE_H 59 | -------------------------------------------------------------------------------- /src/server/python/mbconfig.py: -------------------------------------------------------------------------------- 1 | # ----------------------------------------------------------------------------- 2 | # mbconfig.py 3 | # 4 | # DO NOT EDIT THIS FILE! It is autogenerated. 5 | # 6 | # This is Python module for ModbusTools server configuration. 7 | # It is intended to be converted into a usable Python module 8 | # containing configuration parameters and logic for the Modbus server. 9 | # ----------------------------------------------------------------------------- 10 | 11 | # Major part of mbtools version 12 | MBTOOLS_VERSION_MAJOR = 0 13 | 14 | # Minor part of mbtools version 15 | MBTOOLS_VERSION_MINOR = 4 16 | 17 | # Patch part of mbtools version 18 | MBTOOLS_VERSION_PATCH = 4 19 | 20 | # Integer representation of mbtools version 21 | MBTOOLS_VERSION_INT = (0 << 16) | (4 << 8) | 4 22 | 23 | # String representation of mbtools version 24 | MBTOOLS_VERSION_STR = "0.4.4" 25 | -------------------------------------------------------------------------------- /src/server/python/mbconfig.py.in: -------------------------------------------------------------------------------- 1 | # ----------------------------------------------------------------------------- 2 | # mbconfig.py 3 | # 4 | # DO NOT EDIT THIS FILE! It is autogenerated. 5 | # 6 | # This is Python module for ModbusTools server configuration. 7 | # It is intended to be converted into a usable Python module 8 | # containing configuration parameters and logic for the Modbus server. 9 | # ----------------------------------------------------------------------------- 10 | 11 | # Major part of mbtools version 12 | MBTOOLS_VERSION_MAJOR = @PROJECT_VERSION_MAJOR@ 13 | 14 | # Minor part of mbtools version 15 | MBTOOLS_VERSION_MINOR = @PROJECT_VERSION_MINOR@ 16 | 17 | # Patch part of mbtools version 18 | MBTOOLS_VERSION_PATCH = @PROJECT_VERSION_PATCH@ 19 | 20 | # Integer representation of mbtools version 21 | MBTOOLS_VERSION_INT = (@PROJECT_VERSION_MAJOR@ << 16) | (@PROJECT_VERSION_MINOR@ << 8) | @PROJECT_VERSION_PATCH@ 22 | 23 | # String representation of mbtools version 24 | MBTOOLS_VERSION_STR = "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@" 25 | -------------------------------------------------------------------------------- /src/server/resource/python/programhead.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | from os import sys, path 4 | from time import sleep, time 5 | import argparse 6 | 7 | _parser = argparse.ArgumentParser() 8 | _parser.add_argument('-prj', '--project', type=str, default="") 9 | _parser.add_argument('-imp', '--importpath', type=str, default="") 10 | _parser.add_argument('-i', '--memid' , type=str, default="") 11 | _parser.add_argument('-p', '--period' , type=int, default=100) 12 | _args = _parser.parse_args() 13 | 14 | _pathList = _args.importpath.split(";") 15 | 16 | sys.path.insert(0, path.normpath(path.dirname(path.abspath(__file__)))) 17 | sys.path.extend(_pathList) 18 | 19 | from mbserver import _MbDevice 20 | 21 | mbdevice = _MbDevice(_args.memid, _args.project) 22 | mem0x = mbdevice.getmem0x() 23 | mem1x = mbdevice.getmem1x() 24 | mem3x = mbdevice.getmem3x() 25 | mem4x = mbdevice.getmem4x() 26 | 27 | _mb_time_period = _args.period / 1000 28 | 29 | -------------------------------------------------------------------------------- /src/server/resource/python/pytips.py: -------------------------------------------------------------------------------- 1 | # Objects for access corresponding device memory: mem0x, mem1x, mem3x, mem4x. 2 | # 3 | # Every object has set of get/set function to work with different data types: 4 | # * mem0x, mem1x: `get(bitoffset:int)->(int, float)` and `set(bitoffset:int,value:(int, float))` 5 | # * mem3x, mem4x: `get(regoffset:int)->(int, float)` and `set(regoffset:int,value:(int, float))` 6 | # 7 | # : int8, uint8, int16, uint16, int32, uint32, int64, uint64, float, double. 8 | # 9 | # Examples: 10 | # v = mem0x.getint8(0) 11 | # mem1x.setint16(1, -1) 12 | # mem3x.setuint16(0, 65535) 13 | # mem3x.setfloat(0, 3.14) 14 | # mem4x.setdouble(10, 2.71828) 15 | 16 | -------------------------------------------------------------------------------- /src/server/resource/server_resource.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | python/programhead.py 4 | python/pytips.py 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/server/runtime/runtime.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/server_portrunnable.h \ 3 | $$PWD/server_rundevice.h \ 4 | $$PWD/server_runscriptthread.h \ 5 | $$PWD/server_runsimaction.h \ 6 | $$PWD/server_runsimactiontask.h \ 7 | $$PWD/server_runthread.h \ 8 | $$PWD/server_runtime.h 9 | 10 | SOURCES += \ 11 | $$PWD/server_portrunnable.cpp \ 12 | $$PWD/server_rundevice.cpp \ 13 | $$PWD/server_runscriptthread.cpp \ 14 | $$PWD/server_runsimaction.cpp \ 15 | $$PWD/server_runsimactiontask.cpp \ 16 | $$PWD/server_runthread.cpp \ 17 | $$PWD/server_runtime.cpp 18 | -------------------------------------------------------------------------------- /src/server/runtime/server_runscriptthread.h: -------------------------------------------------------------------------------- 1 | #ifndef SERVER_RUNSCRIPTTHREAD_H 2 | #define SERVER_RUNSCRIPTTHREAD_H 3 | 4 | #include 5 | #include 6 | 7 | class QProcess; 8 | class mbServerDevice; 9 | 10 | class mbServerRunScriptThread : public QThread 11 | { 12 | Q_OBJECT 13 | public: 14 | explicit mbServerRunScriptThread(mbServerDevice *device, const MBSETTINGS &scripts, QObject *parent = nullptr); 15 | 16 | public: 17 | inline void stop() { m_ctrlRun = false; } 18 | 19 | protected: 20 | void run() override; 21 | 22 | private Q_SLOTS: 23 | void readPyStdOut(); 24 | 25 | private: 26 | QString getImportPath(); 27 | QString getScriptInit(); 28 | QString getScriptLoop(); 29 | QString getScriptFinal(); 30 | 31 | private: 32 | bool m_ctrlRun; 33 | 34 | private: 35 | mbServerDevice *m_device; 36 | QByteArray m_deviceName; 37 | QString m_pyInterpreter; 38 | bool m_scriptUseOptimization; 39 | int m_scriptLoopPeriod; 40 | QString m_scriptInit ; 41 | QString m_scriptLoop ; 42 | QString m_scriptFinal; 43 | QProcess *m_py; 44 | }; 45 | 46 | #endif // SERVER_RUNSCRIPTTHREAD_H 47 | -------------------------------------------------------------------------------- /src/server/runtime/server_runsimactiontask.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef SERVER_RUNSIMACTIONTASK_H 24 | #define SERVER_RUNSIMACTIONTASK_H 25 | 26 | #include 27 | 28 | class mbServerSimAction; 29 | class mbServerRunSimAction; 30 | 31 | class mbServerRunSimActionTask : public mbCoreTask 32 | { 33 | public: 34 | explicit mbServerRunSimActionTask(QObject *parent = nullptr); 35 | ~mbServerRunSimActionTask(); 36 | 37 | public: 38 | void setActions(const QList &actions); 39 | 40 | public: // task interface 41 | virtual int init() override; 42 | virtual int loop() override; 43 | virtual int final() override; 44 | 45 | private: 46 | typedef QList Actions_t; 47 | 48 | Actions_t m_actions; 49 | }; 50 | 51 | #endif // SERVER_RUNSIMACTIONTASK_H 52 | -------------------------------------------------------------------------------- /src/server/runtime/server_runthread.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #include "server_runthread.h" 24 | 25 | #include 26 | 27 | #include 28 | 29 | #include 30 | 31 | #include 32 | 33 | #include "server_portrunnable.h" 34 | #include "server_rundevice.h" 35 | 36 | mbServerRunThread::mbServerRunThread(mbServerPort *serverPort, mbServerRunDevice *device, QObject *parent) 37 | : QThread(parent) 38 | { 39 | m_serverPort = serverPort; 40 | m_ctrlRun = true; 41 | m_device = device; 42 | m_settings = serverPort->settings(); 43 | } 44 | 45 | mbServerRunThread::~mbServerRunThread() 46 | { 47 | delete m_device; 48 | } 49 | 50 | void mbServerRunThread::run() 51 | { 52 | QEventLoop loop; 53 | mbServerPortRunnable port(m_serverPort, m_settings, m_device); 54 | m_ctrlRun = true; 55 | mbServer::LogInfo(port.name(), QStringLiteral("Start")); 56 | while (m_ctrlRun) 57 | { 58 | loop.processEvents(); 59 | port.run(); 60 | Modbus::msleep(1); 61 | } 62 | port.close(); 63 | mbServer::LogInfo(port.name(), QStringLiteral("Stop")); 64 | } 65 | -------------------------------------------------------------------------------- /src/server/runtime/server_runthread.h: -------------------------------------------------------------------------------- 1 | /* 2 | Modbus Tools 3 | 4 | Created: 2023 5 | Author: Serhii Marchuk, https://github.com/serhmarch 6 | 7 | Copyright (C) 2023 Serhii Marchuk 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | */ 23 | #ifndef SERVER_RUNTHREAD_H 24 | #define SERVER_RUNTHREAD_H 25 | 26 | #include 27 | 28 | #include 29 | 30 | class mbServerPort; 31 | class mbServerRunDevice; 32 | 33 | class mbServerRunThread : public QThread 34 | { 35 | public: 36 | explicit mbServerRunThread(mbServerPort *serverPort, mbServerRunDevice *device, QObject *parent = nullptr); 37 | ~mbServerRunThread(); 38 | 39 | public: 40 | inline void stop() { m_ctrlRun = false; } 41 | 42 | protected: 43 | void run() override; 44 | 45 | private: 46 | bool m_ctrlRun; 47 | 48 | private: 49 | mbServerPort *m_serverPort; 50 | mbServerRunDevice *m_device; 51 | Modbus::Settings m_settings; 52 | }; 53 | 54 | #endif // SERVER_RUNTHREAD_H 55 | -------------------------------------------------------------------------------- /src/server/server.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | 3 | include(../version.pri) 4 | 5 | CONFIG += no_keywords 6 | 7 | DESTDIR = ../../bin 8 | 9 | QT = core gui widgets 10 | 11 | unix:QMAKE_RPATHDIR += . 12 | 13 | INCLUDEPATH += . .. \ 14 | $$PWD/../../modbus/src \ 15 | $$PWD/../core/sdk \ 16 | $$PWD/../core/core \ 17 | $$PWD/../core \ 18 | $$PWD/core 19 | 20 | include(core/core.pri) 21 | include(project/project.pri) 22 | include(gui/gui.pri) 23 | include(runtime/runtime.pri) 24 | 25 | HEADERS += 26 | 27 | SOURCES += \ 28 | main.cpp 29 | 30 | RESOURCES += \ 31 | $$PWD/resource/server_resource.qrc 32 | 33 | LIBS += -L../../bin -lcore 34 | LIBS += -L../../bin -lmodbus 35 | 36 | RC_ICONS = gui/icons/server.ico 37 | 38 | DISTFILES += \ 39 | python/mbconfig.py \ 40 | python/mbserver.py \ 41 | python/modbus.py 42 | -------------------------------------------------------------------------------- /src/server/win_resource.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | IDI_ICON1 ICON DISCARDABLE "gui\\icons\\server.ico" 4 | 5 | VS_VERSION_INFO VERSIONINFO 6 | FILEVERSION 0,4,4,0 7 | PRODUCTVERSION 0,4,4,0 8 | FILEFLAGSMASK 0x3fL 9 | #ifdef _DEBUG 10 | FILEFLAGS VS_FF_DEBUG 11 | #else 12 | FILEFLAGS 0x0L 13 | #endif 14 | FILEOS VOS__WINDOWS32 15 | FILETYPE VFT_DLL 16 | FILESUBTYPE 0x0L 17 | BEGIN 18 | BLOCK "StringFileInfo" 19 | BEGIN 20 | BLOCK "040904b0" 21 | BEGIN 22 | VALUE "CompanyName", "\0" 23 | VALUE "FileDescription", "\0" 24 | VALUE "FileVersion", "0.4.4.0\0" 25 | VALUE "LegalCopyright", "\0" 26 | VALUE "OriginalFilename", "server.exe\0" 27 | VALUE "ProductName", "server\0" 28 | VALUE "ProductVersion", "0.4.4.0\0" 29 | END 30 | END 31 | BLOCK "VarFileInfo" 32 | BEGIN 33 | VALUE "Translation", 0x0409, 1200 34 | END 35 | END 36 | /* End of Version info */ 37 | 38 | -------------------------------------------------------------------------------- /src/version.pri: -------------------------------------------------------------------------------- 1 | CONFIG += skip_target_version_ext 2 | 3 | VERSION = "0.4.4.0" 4 | 5 | #__MBTOOLS_VERSION_LIST__ = $$split(VERSION, .) 6 | # 7 | #__MBTOOLS_VERSION_MAJOR__ = $$member(__MBTOOLS_VERSION_LIST__,0) 8 | #__MBTOOLS_VERSION_MINOR__ = $$member(__MBTOOLS_VERSION_LIST__,1) 9 | #__MBTOOLS_VERSION_PATCH__ = $$member(__MBTOOLS_VERSION_LIST__,2) 10 | #__MBTOOLS_VERSION_BUILD__ = $$member(__MBTOOLS_VERSION_LIST__,3) 11 | # 12 | #DEFINES += __MBTOOLS_VERSION_MAJOR__=$$__MBTOOLS_VERSION_MAJOR__ 13 | #DEFINES += __MBTOOLS_VERSION_MINOR__=$$__MBTOOLS_VERSION_MINOR__ 14 | #DEFINES += __MBTOOLS_VERSION_PATCH__=$$__MBTOOLS_VERSION_PATCH__ 15 | #DEFINES += __MBTOOLS_VERSION_BUILD__=$$__MBTOOLS_VERSION_BUILD__ 16 | -------------------------------------------------------------------------------- /src/win_resource.rc.in: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | @MBTOOLS_WIN_ICON@ 4 | 5 | VS_VERSION_INFO VERSIONINFO 6 | FILEVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,0 7 | PRODUCTVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,0 8 | FILEFLAGSMASK 0x3fL 9 | #ifdef _DEBUG 10 | FILEFLAGS VS_FF_DEBUG 11 | #else 12 | FILEFLAGS 0x0L 13 | #endif 14 | FILEOS VOS__WINDOWS32 15 | FILETYPE VFT_DLL 16 | FILESUBTYPE 0x0L 17 | BEGIN 18 | BLOCK "StringFileInfo" 19 | BEGIN 20 | BLOCK "040904b0" 21 | BEGIN 22 | VALUE "CompanyName", "\0" 23 | VALUE "FileDescription", "\0" 24 | VALUE "FileVersion", "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@.0\0" 25 | VALUE "LegalCopyright", "\0" 26 | VALUE "OriginalFilename", "@MBTOOLS_WIN_OUTFILE@\0" 27 | VALUE "ProductName", "@MBTOOLS_WIN_FILE@\0" 28 | VALUE "ProductVersion", "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@.0\0" 29 | END 30 | END 31 | BLOCK "VarFileInfo" 32 | BEGIN 33 | VALUE "Translation", 0x0409, 1200 34 | END 35 | END 36 | /* End of Version info */ 37 | 38 | --------------------------------------------------------------------------------